@semantic-ui/component
Advanced tools
Comparing version 0.1.5 to 0.1.6
@@ -15,8 +15,8 @@ { | ||
"dependencies": { | ||
"@semantic-ui/query": "^0.1.5", | ||
"@semantic-ui/reactivity": "^0.1.5", | ||
"@semantic-ui/templating": "^0.1.5", | ||
"@semantic-ui/utils": "^0.1.5" | ||
"@semantic-ui/query": "^0.1.6", | ||
"@semantic-ui/reactivity": "^0.1.6", | ||
"@semantic-ui/templating": "^0.1.6", | ||
"@semantic-ui/utils": "^0.1.6" | ||
}, | ||
"version": "0.1.5" | ||
"version": "0.1.6" | ||
} |
@@ -0,5 +1,7 @@ | ||
import { noChange } from 'lit'; | ||
import { directive } from 'lit/directive.js'; | ||
import { AsyncDirective } from 'lit/async-directive.js'; | ||
import { Reaction } from '@semantic-ui/reactivity'; | ||
import { fatal, mapObject } from '@semantic-ui/utils'; | ||
import { fatal, isString, mapObject } from '@semantic-ui/utils'; | ||
import { Template } from '@semantic-ui/templating'; | ||
@@ -14,3 +16,3 @@ // Define directive | ||
} | ||
render({ getTemplateName, templateName, subTemplates, data, parentTemplate }) { | ||
render({ getTemplate, templateName, subTemplates, data, parentTemplate }) { | ||
const unpackData = (dataObj) => { | ||
@@ -21,6 +23,29 @@ return mapObject(dataObj, (val) => val()); | ||
const templateName = getTemplateName(); | ||
// expression can evaluate to a template or a string | ||
// in the case of a string we will pull from subtemplates | ||
let templateName; | ||
let template; | ||
// check if the template name is set and is the same as current | ||
if (this.template && this.templateName == templateName) { | ||
const templateOrName = getTemplate(); | ||
// find template to render | ||
if(isString(templateOrName)) { | ||
templateName = templateOrName; | ||
template = subTemplates[templateName]; | ||
if (!template) { | ||
fatal( | ||
`Could not find template named "${templateName}"`, | ||
subTemplates | ||
); | ||
return false; | ||
} | ||
} | ||
else if(templateOrName instanceof Template) { | ||
// support passing in full templates using expressions | ||
template = templateOrName; | ||
templateName = template.templateName; | ||
} | ||
// avoid recreating prototype if rendered already | ||
if(templateName == this.templateName) { | ||
return false; | ||
@@ -30,10 +55,2 @@ } | ||
// find template to render | ||
const template = subTemplates[templateName]; | ||
if (!template) { | ||
fatal( | ||
`Could not find template named "${getTemplateName()}"`, | ||
subTemplates | ||
); | ||
} | ||
// clone if it has changed | ||
@@ -40,0 +57,0 @@ this.template = template.clone({ templateName, subTemplates, data: unpackData(data) }); |
@@ -228,3 +228,3 @@ import { html, svg } from 'lit'; | ||
templateName: node.name, | ||
getTemplateName: () => this.evaluateExpression(node.name, data), // template name can be dynamic | ||
getTemplate: () => this.evaluateExpression(node.name, data), // template can be dynamic | ||
data: templateData, | ||
@@ -231,0 +231,0 @@ parentTemplate: this.template, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
48041
1412
- Removed@semantic-ui/component@0.1.6(transitive)
Updated@semantic-ui/query@^0.1.6
Updated@semantic-ui/utils@^0.1.6