@tko/provider.component
Advanced tools
@@ -1,2 +0,3 @@ | ||
| // @tko/provider.component 🥊 4.0.0-beta1.4 ESM | ||
| "use strict"; | ||
| // @tko/provider.component 🥊 4.0.0-beta1.5 ESM | ||
| import { | ||
@@ -70,3 +71,6 @@ tagNameLower, | ||
| } | ||
| const $raw = objectMap(accessors, (value) => computed(value, null, { disposeWhenNodeIsRemoved: node })); | ||
| const $raw = objectMap( | ||
| accessors, | ||
| (value) => computed(value, null, { disposeWhenNodeIsRemoved: node }) | ||
| ); | ||
| const params = objectMap($raw, (v) => this.makeParamValue(node, v)); | ||
@@ -73,0 +77,0 @@ return Object.assign({ $raw }, params); |
@@ -5,4 +5,4 @@ { | ||
| "sourcesContent": ["\nimport {\n tagNameLower, objectMap\n} from '@tko/utils'\n\nimport registry from '@tko/utils.component'\n\nimport {\n unwrap, isWriteableObservable\n} from '@tko/observable'\n\nimport {\n computed\n} from '@tko/computed'\n\nimport {\n Provider\n} from '@tko/provider'\n\nimport {\n Parser\n} from '@tko/utils.parser'\n\nexport default class ComponentProvider extends Provider {\n get FOR_NODE_TYPES () { return [ 1 ] } // document.ELEMENT_NODE\n\n /**\n * Convert <slot name='X'> to <!-- ko slot: 'X' --><!-- /ko -->\n * @param {HTMLElement} node\n */\n preprocessNode (node) {\n if (node.tagName === 'SLOT') {\n const parent = node.parentNode\n const slotName = node.getAttribute('name') || ''\n const openNode = document.createComment(`ko slot: \"${slotName}\"`)\n const closeNode = document.createComment('/ko')\n parent.insertBefore(openNode, node)\n parent.insertBefore(closeNode, node)\n parent.removeChild(node)\n return [openNode, closeNode]\n }\n }\n\n nodeHasBindings (node) {\n return Boolean(this.getComponentNameForNode(node))\n }\n\n getBindingAccessors (node, context) {\n const componentName = this.getComponentNameForNode(node)\n if (!componentName) { return }\n const component = () => ({\n name: componentName,\n params: this.getComponentParams(node, context)\n })\n return { component }\n }\n\n getComponentNameForNode (node) {\n if (node.nodeType !== node.ELEMENT_NODE) { return }\n const tagName = tagNameLower(node)\n if (registry.isRegistered(tagName)) {\n const hasDash = tagName.includes('-')\n const isUnknownEntity = ('' + node) === '[object HTMLUnknownElement]'\n if (hasDash || isUnknownEntity) { return tagName }\n }\n }\n\n getComponentParams (node, context) {\n const parser = new Parser(node, context, this.globals)\n const paramsString = (node.getAttribute('params') || '').trim()\n const accessors = parser.parse(paramsString, context, node)\n if (!accessors || Object.keys(accessors).length === 0) {\n return { $raw: {} }\n }\n const $raw = objectMap(accessors,\n (value) => computed(value, null, { disposeWhenNodeIsRemoved: node })\n )\n const params = objectMap($raw, (v) => this.makeParamValue(node, v))\n return Object.assign({ $raw }, params)\n }\n\n makeParamValue (node, paramValueComputed) {\n const paramValue = paramValueComputed.peek()\n // Does the evaluation of the parameter value unwrap any observables?\n if (!paramValueComputed.isActive()) {\n // No it doesn't, so there's no need for any computed wrapper. Just pass through the supplied value directly.\n // Example: \"someVal: firstName, age: 123\" (whether or not firstName is an observable/computed)\n return paramValue\n }\n // Yes it does. Supply a computed property that unwraps both the outer (binding expression)\n // level of observability, and any inner (resulting model value) level of observability.\n // This means the component doesn't have to worry about multiple unwrapping. If the value is a\n // writable observable, the computed will also be writable and pass the value on to the observable.\n const isWriteable = isWriteableObservable(paramValue)\n\n return computed({\n read: () => unwrap(paramValueComputed()),\n write: isWriteable ? (v) => paramValueComputed()(v) : null,\n disposeWhenNodeIsRemoved: node\n })\n }\n}\n"], | ||
| "mappings": ";AACA;AAAA;AAAA;AAAA;AAIA;AAEA;AAAA;AAAA;AAAA;AAIA;AAAA;AAAA;AAIA;AAAA;AAAA;AAIA;AAAA;AAAA;AAIA,qBAAqB,0BAA0B,SAAS;AAAA,MAClD,iBAAkB;AAAE,WAAO,CAAE,CAAE;AAAA,EAAE;AAAA,EAMrC,eAAgB,MAAM;AACpB,QAAI,KAAK,YAAY,QAAQ;AAC3B,YAAM,SAAS,KAAK;AACpB,YAAM,WAAW,KAAK,aAAa,MAAM,KAAK;AAC9C,YAAM,WAAW,SAAS,cAAc,aAAa,W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mB,CAAC;AAAA,MACvC,OAAO,cAAc,CAAC,MAAM,mBAAmB,EAAE,CAAC,IAAI;AAAA,MACtD,0BAA0B;AAAA,IAC5B,CAAC;AAAA,EACH;AACF;", | ||
| "names": [] | ||
| } |
+2
-1
@@ -1,2 +0,3 @@ | ||
| // @tko/provider.component 🥊 4.0.0-beta1.4 ESM | ||
| "use strict"; | ||
| // @tko/provider.component 🥊 4.0.0-beta1.5 ESM | ||
| export { default as ComponentProvider } from "./ComponentProvider"; |
@@ -5,4 +5,4 @@ { | ||
| "sourcesContent": ["export {default as ComponentProvider} from './ComponentProvider'\n"], | ||
| "mappings": ";AAAA;", | ||
| "mappings": ";;AAAA,6CAA2C;", | ||
| "names": [] | ||
| } |
+2
-1
@@ -1,2 +0,3 @@ | ||
| // @tko/provider.component 🥊 4.0.0-beta1.4 MJS | ||
| "use strict"; | ||
| // @tko/provider.component 🥊 4.0.0-beta1.5 MJS | ||
| export { default as ComponentProvider } from "./ComponentProvider"; |
@@ -5,4 +5,4 @@ { | ||
| "sourcesContent": ["export {default as ComponentProvider} from './ComponentProvider'\n"], | ||
| "mappings": ";AAAA;", | ||
| "mappings": ";;AAAA,6CAA2C;", | ||
| "names": [] | ||
| } |
+3
-3
| { | ||
| "version": "4.0.0-beta1.4", | ||
| "version": "4.0.0-beta1.5", | ||
| "name": "@tko/provider.component", | ||
@@ -17,3 +17,3 @@ "description": "Bind custom web components e.g. <custom-binding>", | ||
| "@tko/utils.component": "^4.0.0-beta1.3", | ||
| "@tko/utils.parser": "^4.0.0-beta1.4", | ||
| "@tko/utils.parser": "^4.0.0-beta1.5", | ||
| "tslib": "^2.2.0" | ||
@@ -48,3 +48,3 @@ }, | ||
| }, | ||
| "gitHead": "7496e89dfd0f39a030f6ed9c371b82f1c359bb6d" | ||
| "gitHead": "ff3b66ef48b22af8668941935676ef67e7a4f929" | ||
| } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
352198
0.67%3605
0.53%