Files
BeWoPlaner/BeWoPlanerMobil/node_modules/rijs.components/index.js
Lyndon Jetten fda2c306b5 MoK: Report Viewer hinzugefügt
FaC: Das alte Flag von Terminen, die in die Zeiterfassung übernommen worden sind, wird ebenfalls berücksichtigt.
2023-03-13 19:39:04 +01:00

36 lines
1.1 KiB
JavaScript

module.exports = function components(ripple){
if (!client) return ripple
log('creating')
// if no render is defined on a component, load up definition
Node.prototype.render = function(){
const name = this.nodeName.toLowerCase()
if (name.includes('-')) {
this.state = this.state || {}
return this.fn$ = this.fn$ || ripple
.subscribe(name)
.map(component => define(name, component))
// TODO: test this works well across all instances
// .until(new Promise(resolve => this.addEventListener('disconnected', () => {
// if (!this.isConnected) resolve()
// })))
}
}
// this is for backwards compatibility
Node.prototype.draw = function(){
this.render()
}
ready(() => Array.from(document.querySelectorAll('*'))
.filter(d => d.nodeName.includes('-'))
.map(node => node.render())
)
return ripple
}
const log = require('utilise/log')('[ri/components]')
, client = require('utilise/client')
, ready = require('utilise/ready')
, define = require('@compone/define')