@startinblox/core 0.17.21-beta.2 → 0.17.21-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_snowpack/env.js +3 -0
- package/dist/_snowpack/pkg/autolinker.js +4281 -0
- package/dist/_snowpack/pkg/autolinker.js.map +1 -0
- package/dist/_snowpack/pkg/autolinker.js.map.proxy.js +1 -0
- package/dist/_snowpack/pkg/common/_baseUnary-217dffb2.js +377 -0
- package/dist/_snowpack/pkg/common/_baseUnary-217dffb2.js.map +1 -0
- package/dist/_snowpack/pkg/common/_baseUnary-217dffb2.js.map.proxy.js +1 -0
- package/dist/_snowpack/pkg/common/_commonjsHelpers-8c19dec8.js +22 -0
- package/dist/_snowpack/pkg/common/_commonjsHelpers-8c19dec8.js.map +1 -0
- package/dist/_snowpack/pkg/common/_commonjsHelpers-8c19dec8.js.map.proxy.js +1 -0
- package/dist/_snowpack/pkg/common/decode-a4c334cf.js +216 -0
- package/dist/_snowpack/pkg/common/decode-a4c334cf.js.map +1 -0
- package/dist/_snowpack/pkg/common/decode-a4c334cf.js.map.proxy.js +1 -0
- package/dist/_snowpack/pkg/common/lit-html-babd44cd.js +1119 -0
- package/dist/_snowpack/pkg/common/lit-html-babd44cd.js.map +1 -0
- package/dist/_snowpack/pkg/common/lit-html-babd44cd.js.map.proxy.js +1 -0
- package/dist/_snowpack/pkg/delta-markdown-for-quill.js +25677 -0
- package/dist/_snowpack/pkg/delta-markdown-for-quill.js.map +1 -0
- package/dist/_snowpack/pkg/delta-markdown-for-quill.js.map.proxy.js +1 -0
- package/dist/_snowpack/pkg/dialog-polyfill.js +859 -0
- package/dist/_snowpack/pkg/dialog-polyfill.js.map +1 -0
- package/dist/_snowpack/pkg/dialog-polyfill.js.map.proxy.js +1 -0
- package/dist/_snowpack/pkg/fusejs.js +1783 -0
- package/dist/_snowpack/pkg/fusejs.js.map +1 -0
- package/dist/_snowpack/pkg/fusejs.js.map.proxy.js +1 -0
- package/dist/_snowpack/pkg/import-map.json +23 -0
- package/dist/_snowpack/pkg/jsonld-context-parser.js +804 -0
- package/dist/_snowpack/pkg/jsonld-context-parser.js.map +1 -0
- package/dist/_snowpack/pkg/jsonld-context-parser.js.map.proxy.js +1 -0
- package/dist/_snowpack/pkg/leaflet/dist/leaflet.css +640 -0
- package/dist/_snowpack/pkg/leaflet/dist/leaflet.css.proxy.js +10 -0
- package/dist/_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.Default.css +60 -0
- package/dist/_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.Default.css.proxy.js +10 -0
- package/dist/_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.css +14 -0
- package/dist/_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.css.proxy.js +10 -0
- package/dist/_snowpack/pkg/lit-html/directives/if-defined.js +40 -0
- package/dist/_snowpack/pkg/lit-html/directives/if-defined.js.map +1 -0
- package/dist/_snowpack/pkg/lit-html/directives/if-defined.js.map.proxy.js +1 -0
- package/dist/_snowpack/pkg/lit-html/directives/unsafe-html.js +46 -0
- package/dist/_snowpack/pkg/lit-html/directives/unsafe-html.js.map +1 -0
- package/dist/_snowpack/pkg/lit-html/directives/unsafe-html.js.map.proxy.js +1 -0
- package/dist/_snowpack/pkg/lit-html/directives/until.js +88 -0
- package/dist/_snowpack/pkg/lit-html/directives/until.js.map +1 -0
- package/dist/_snowpack/pkg/lit-html/directives/until.js.map.proxy.js +1 -0
- package/dist/_snowpack/pkg/lit-html.js +92 -0
- package/dist/_snowpack/pkg/lit-html.js.map +1 -0
- package/dist/_snowpack/pkg/lit-html.js.map.proxy.js +1 -0
- package/dist/_snowpack/pkg/markdown-it.js +11860 -0
- package/dist/_snowpack/pkg/markdown-it.js.map +1 -0
- package/dist/_snowpack/pkg/markdown-it.js.map.proxy.js +1 -0
- package/dist/_snowpack/pkg/quill/dist/quill.snow.css +945 -0
- package/dist/_snowpack/pkg/quill/dist/quill.snow.css.proxy.js +10 -0
- package/dist/_snowpack/pkg/quill-delta-to-markdown.js +1029 -0
- package/dist/_snowpack/pkg/quill-delta-to-markdown.js.map +1 -0
- package/dist/_snowpack/pkg/quill-delta-to-markdown.js.map.proxy.js +1 -0
- package/dist/_snowpack/pkg/quill.js +13382 -0
- package/dist/_snowpack/pkg/quill.js.map +1 -0
- package/dist/_snowpack/pkg/quill.js.map.proxy.js +1 -0
- package/dist/_snowpack/pkg/slim-select.js +4 -0
- package/dist/_snowpack/pkg/slim-select.js.map +1 -0
- package/dist/_snowpack/pkg/slim-select.js.map.proxy.js +1 -0
- package/dist/_snowpack/pkg/tui-calendar/dist/tui-calendar.css +1164 -0
- package/dist/_snowpack/pkg/tui-calendar/dist/tui-calendar.css.proxy.js +10 -0
- package/dist/_snowpack/pkg/tui-calendar.js +42285 -0
- package/dist/_snowpack/pkg/tui-calendar.js.map +1 -0
- package/dist/_snowpack/pkg/tui-calendar.js.map.proxy.js +1 -0
- package/dist/components/solid-ac-checker.js +51 -0
- package/dist/components/solid-ac-checker.js.map +1 -0
- package/dist/components/solid-calendar.js +87 -0
- package/dist/components/solid-calendar.js.map +1 -0
- package/dist/components/solid-delete.js +111 -0
- package/dist/components/solid-delete.js.map +1 -0
- package/dist/components/solid-display.js +194 -0
- package/dist/components/solid-display.js.map +1 -0
- package/dist/components/solid-form-search.js +226 -0
- package/dist/components/solid-form-search.js.map +1 -0
- package/dist/components/solid-form.js +354 -0
- package/dist/components/solid-form.js.map +1 -0
- package/dist/components/solid-lang.js +46 -0
- package/dist/components/solid-lang.js.map +1 -0
- package/dist/components/solid-map.js +242 -0
- package/dist/components/solid-map.js.map +1 -0
- package/dist/components/solid-table.js +263 -0
- package/dist/components/solid-table.js.map +1 -0
- package/dist/components/solid-widget.js +94 -0
- package/dist/components/solid-widget.js.map +1 -0
- package/dist/import.css +4 -0
- package/dist/index.js +43 -0
- package/dist/index.js.map +1 -0
- package/dist/libs/Component.js +19 -0
- package/dist/libs/Component.js.map +1 -0
- package/dist/libs/ComponentFactory.js +196 -0
- package/dist/libs/ComponentFactory.js.map +1 -0
- package/dist/libs/Compositor.js +103 -0
- package/dist/libs/Compositor.js.map +1 -0
- package/dist/libs/Sib.js +58 -0
- package/dist/libs/Sib.js.map +1 -0
- package/dist/libs/helpers.js +219 -0
- package/dist/libs/helpers.js.map +1 -0
- package/dist/libs/interfaces.js +6 -0
- package/dist/libs/interfaces.js.map +1 -0
- package/dist/libs/lit-helpers.js +169 -0
- package/dist/libs/lit-helpers.js.map +1 -0
- package/dist/libs/polyfills.js +40 -0
- package/dist/libs/polyfills.js.map +1 -0
- package/dist/libs/store/store.js +862 -0
- package/dist/libs/store/store.js.map +1 -0
- package/dist/locales/en.json +10 -0
- package/dist/locales/en.json.proxy.js +2 -0
- package/dist/locales/fr.json +10 -0
- package/dist/locales/fr.json.proxy.js +2 -0
- package/dist/mixins/attributeBinderMixin.js +124 -0
- package/dist/mixins/attributeBinderMixin.js.map +1 -0
- package/dist/mixins/contextMixin.js +28 -0
- package/dist/mixins/contextMixin.js.map +1 -0
- package/dist/mixins/counterMixin.js +75 -0
- package/dist/mixins/counterMixin.js.map +1 -0
- package/dist/mixins/federationMixin.js +63 -0
- package/dist/mixins/federationMixin.js.map +1 -0
- package/dist/mixins/filterMixin.js +195 -0
- package/dist/mixins/filterMixin.js.map +1 -0
- package/dist/mixins/grouperMixin.js +80 -0
- package/dist/mixins/grouperMixin.js.map +1 -0
- package/dist/mixins/highlighterMixin.js +42 -0
- package/dist/mixins/highlighterMixin.js.map +1 -0
- package/dist/mixins/interfaces.js +8 -0
- package/dist/mixins/interfaces.js.map +1 -0
- package/dist/mixins/listMixin.js +136 -0
- package/dist/mixins/listMixin.js.map +1 -0
- package/dist/mixins/nextMixin.js +26 -0
- package/dist/mixins/nextMixin.js.map +1 -0
- package/dist/mixins/paginateMixin.js +110 -0
- package/dist/mixins/paginateMixin.js.map +1 -0
- package/dist/mixins/requiredMixin.js +34 -0
- package/dist/mixins/requiredMixin.js.map +1 -0
- package/dist/mixins/sorterMixin.js +149 -0
- package/dist/mixins/sorterMixin.js.map +1 -0
- package/dist/mixins/storeMixin.js +102 -0
- package/dist/mixins/storeMixin.js.map +1 -0
- package/dist/mixins/translationMixin.js +68 -0
- package/dist/mixins/translationMixin.js.map +1 -0
- package/dist/mixins/validationMixin.js +113 -0
- package/dist/mixins/validationMixin.js.map +1 -0
- package/dist/mixins/widgetMixin.js +447 -0
- package/dist/mixins/widgetMixin.js.map +1 -0
- package/dist/new-widgets/attributeMixins/actionMixin.js +14 -0
- package/dist/new-widgets/attributeMixins/actionMixin.js.map +1 -0
- package/dist/new-widgets/attributeMixins/blankMixin.js +10 -0
- package/dist/new-widgets/attributeMixins/blankMixin.js.map +1 -0
- package/dist/new-widgets/attributeMixins/booleanMixin.js +10 -0
- package/dist/new-widgets/attributeMixins/booleanMixin.js.map +1 -0
- package/dist/new-widgets/attributeMixins/index.js +20 -0
- package/dist/new-widgets/attributeMixins/index.js.map +1 -0
- package/dist/new-widgets/attributeMixins/mailtoMixin.js +10 -0
- package/dist/new-widgets/attributeMixins/mailtoMixin.js.map +1 -0
- package/dist/new-widgets/attributeMixins/multipleMixin.js +28 -0
- package/dist/new-widgets/attributeMixins/multipleMixin.js.map +1 -0
- package/dist/new-widgets/attributeMixins/numberMixin.js +10 -0
- package/dist/new-widgets/attributeMixins/numberMixin.js.map +1 -0
- package/dist/new-widgets/attributeMixins/placeholderMixin.js +19 -0
- package/dist/new-widgets/attributeMixins/placeholderMixin.js.map +1 -0
- package/dist/new-widgets/attributeMixins/telMixin.js +10 -0
- package/dist/new-widgets/attributeMixins/telMixin.js.map +1 -0
- package/dist/new-widgets/baseWidgetMixin.js +122 -0
- package/dist/new-widgets/baseWidgetMixin.js.map +1 -0
- package/dist/new-widgets/callbackMixins/autocompletionMixin.js +104 -0
- package/dist/new-widgets/callbackMixins/autocompletionMixin.js.map +1 -0
- package/dist/new-widgets/callbackMixins/index.js +8 -0
- package/dist/new-widgets/callbackMixins/index.js.map +1 -0
- package/dist/new-widgets/callbackMixins/richtextMixin.js +42 -0
- package/dist/new-widgets/callbackMixins/richtextMixin.js.map +1 -0
- package/dist/new-widgets/callbackMixins/slimselect.css +2 -0
- package/dist/new-widgets/callbackMixins/slimselect.css.proxy.js +10 -0
- package/dist/new-widgets/new-widget-factory.js +96 -0
- package/dist/new-widgets/new-widget-factory.js.map +1 -0
- package/dist/new-widgets/templateAdditionMixins/addableMixin.js +41 -0
- package/dist/new-widgets/templateAdditionMixins/addableMixin.js.map +1 -0
- package/dist/new-widgets/templateAdditionMixins/index.js +14 -0
- package/dist/new-widgets/templateAdditionMixins/index.js.map +1 -0
- package/dist/new-widgets/templateAdditionMixins/labelLastMixin.js +29 -0
- package/dist/new-widgets/templateAdditionMixins/labelLastMixin.js.map +1 -0
- package/dist/new-widgets/templateAdditionMixins/labelMixin.js +31 -0
- package/dist/new-widgets/templateAdditionMixins/labelMixin.js.map +1 -0
- package/dist/new-widgets/templates/defaultTemplatesDirectory.js +36 -0
- package/dist/new-widgets/templates/defaultTemplatesDirectory.js.map +1 -0
- package/dist/new-widgets/templates/displayTemplatesDirectory.js +90 -0
- package/dist/new-widgets/templates/displayTemplatesDirectory.js.map +1 -0
- package/dist/new-widgets/templates/formTemplatesDirectory.js +397 -0
- package/dist/new-widgets/templates/formTemplatesDirectory.js.map +1 -0
- package/dist/new-widgets/templates/groupTemplatesDirectory.js +21 -0
- package/dist/new-widgets/templates/groupTemplatesDirectory.js.map +1 -0
- package/dist/new-widgets/templates/index.js +7 -0
- package/dist/new-widgets/templates/index.js.map +1 -0
- package/dist/new-widgets/templates/setTemplatesDirectory.js +49 -0
- package/dist/new-widgets/templates/setTemplatesDirectory.js.map +1 -0
- package/dist/new-widgets/templatesDependencies/altMixin.js +13 -0
- package/dist/new-widgets/templatesDependencies/altMixin.js.map +1 -0
- package/dist/new-widgets/templatesDependencies/editableMixin.js +77 -0
- package/dist/new-widgets/templatesDependencies/editableMixin.js.map +1 -0
- package/dist/new-widgets/templatesDependencies/filterRangeFormMixin.js +38 -0
- package/dist/new-widgets/templatesDependencies/filterRangeFormMixin.js.map +1 -0
- package/dist/new-widgets/templatesDependencies/formCheckboxMixin.js +14 -0
- package/dist/new-widgets/templatesDependencies/formCheckboxMixin.js.map +1 -0
- package/dist/new-widgets/templatesDependencies/formCheckboxesMixin.js +51 -0
- package/dist/new-widgets/templatesDependencies/formCheckboxesMixin.js.map +1 -0
- package/dist/new-widgets/templatesDependencies/formDropdownMixin.js +66 -0
- package/dist/new-widgets/templatesDependencies/formDropdownMixin.js.map +1 -0
- package/dist/new-widgets/templatesDependencies/formFileMixin.js +81 -0
- package/dist/new-widgets/templatesDependencies/formFileMixin.js.map +1 -0
- package/dist/new-widgets/templatesDependencies/formLengthMixin.js +19 -0
- package/dist/new-widgets/templatesDependencies/formLengthMixin.js.map +1 -0
- package/dist/new-widgets/templatesDependencies/formMinMaxMixin.js +19 -0
- package/dist/new-widgets/templatesDependencies/formMinMaxMixin.js.map +1 -0
- package/dist/new-widgets/templatesDependencies/formMixin.js +66 -0
- package/dist/new-widgets/templatesDependencies/formMixin.js.map +1 -0
- package/dist/new-widgets/templatesDependencies/formNumberMixin.js +14 -0
- package/dist/new-widgets/templatesDependencies/formNumberMixin.js.map +1 -0
- package/dist/new-widgets/templatesDependencies/formRadioMixin.js +16 -0
- package/dist/new-widgets/templatesDependencies/formRadioMixin.js.map +1 -0
- package/dist/new-widgets/templatesDependencies/formStepMixin.js +13 -0
- package/dist/new-widgets/templatesDependencies/formStepMixin.js.map +1 -0
- package/dist/new-widgets/templatesDependencies/linkTextMixin.js +14 -0
- package/dist/new-widgets/templatesDependencies/linkTextMixin.js.map +1 -0
- package/dist/new-widgets/templatesDependencies/multipleFormMixin.js +125 -0
- package/dist/new-widgets/templatesDependencies/multipleFormMixin.js.map +1 -0
- package/dist/new-widgets/templatesDependencies/multipleselectFormMixin.js +74 -0
- package/dist/new-widgets/templatesDependencies/multipleselectFormMixin.js.map +1 -0
- package/dist/new-widgets/templatesDependencies/patternMixin.js +19 -0
- package/dist/new-widgets/templatesDependencies/patternMixin.js.map +1 -0
- package/dist/new-widgets/templatesDependencies/rangeMixin.js +110 -0
- package/dist/new-widgets/templatesDependencies/rangeMixin.js.map +1 -0
- package/dist/new-widgets/templatesDependencies/setMixin.js +12 -0
- package/dist/new-widgets/templatesDependencies/setMixin.js.map +1 -0
- package/dist/new-widgets/templatesDependencies/valueRichtextMixin.js +12 -0
- package/dist/new-widgets/templatesDependencies/valueRichtextMixin.js.map +1 -0
- package/dist/new-widgets/valueTransformationMixins/autolinkMixin.js +18 -0
- package/dist/new-widgets/valueTransformationMixins/autolinkMixin.js.map +1 -0
- package/dist/new-widgets/valueTransformationMixins/dateMixin.js +35 -0
- package/dist/new-widgets/valueTransformationMixins/dateMixin.js.map +1 -0
- package/dist/new-widgets/valueTransformationMixins/dateTimeMixin.js +16 -0
- package/dist/new-widgets/valueTransformationMixins/dateTimeMixin.js.map +1 -0
- package/dist/new-widgets/valueTransformationMixins/index.js +16 -0
- package/dist/new-widgets/valueTransformationMixins/index.js.map +1 -0
- package/dist/new-widgets/valueTransformationMixins/markdownMixin.js +25 -0
- package/dist/new-widgets/valueTransformationMixins/markdownMixin.js.map +1 -0
- package/dist/new-widgets/valueTransformationMixins/multilineMixin.js +17 -0
- package/dist/new-widgets/valueTransformationMixins/multilineMixin.js.map +1 -0
- package/dist/new-widgets/valueTransformationMixins/oembedMixin.js +27 -0
- package/dist/new-widgets/valueTransformationMixins/oembedMixin.js.map +1 -0
- package/dist/solid-template-element.js +164 -0
- package/dist/solid-template-element.js.map +1 -0
- package/dist/style/default-theme.css +24 -0
- package/dist/style/default-theme.css.proxy.js +10 -0
- package/dist/widgets/baseWidget.js +332 -0
- package/dist/widgets/baseWidget.js.map +1 -0
- package/dist/widgets/widget-factory.js +24 -0
- package/dist/widgets/widget-factory.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import Fuse from "../_snowpack/pkg/fusejs.js";
|
|
2
|
+
|
|
3
|
+
function uniqID() {
|
|
4
|
+
return '_' + (Math.random() * Math.pow(36, 20)).toString(36).slice(0, 10);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
function stringToDom(html) {
|
|
8
|
+
const template = document.createElement('template');
|
|
9
|
+
template.innerHTML = html;
|
|
10
|
+
return template.content;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async function evalTemplateString(str, variables = {}) {
|
|
14
|
+
const keys = Object.keys(variables);
|
|
15
|
+
const values = keys.map(key => variables[key]);
|
|
16
|
+
|
|
17
|
+
try {
|
|
18
|
+
const AsyncFunction = Object.getPrototypeOf(async function () {}).constructor;
|
|
19
|
+
const func = AsyncFunction.call(null, ...keys, 'return `' + str + '`');
|
|
20
|
+
return await func(...values);
|
|
21
|
+
} catch (e) {
|
|
22
|
+
console.log(e);
|
|
23
|
+
throw new SyntaxError('`' + str + '`');
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function importCSS(...stylesheets) {
|
|
28
|
+
const linksElements = [];
|
|
29
|
+
|
|
30
|
+
for (let url of stylesheets) {
|
|
31
|
+
url = relativeSource(url);
|
|
32
|
+
let link = Array.from(document.head.querySelectorAll('link')).find(link => link.href === url);
|
|
33
|
+
if (link) return link;
|
|
34
|
+
link = document.createElement('link');
|
|
35
|
+
link.rel = 'stylesheet';
|
|
36
|
+
link.href = url;
|
|
37
|
+
document.head.appendChild(link);
|
|
38
|
+
linksElements.push(link);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
;
|
|
42
|
+
return linksElements;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function importJS(...plugins) {
|
|
46
|
+
return plugins.map(url => {
|
|
47
|
+
url = new URL(url, document.baseURI).href;
|
|
48
|
+
let script = Array.from(document.querySelectorAll('script')).find(script => script.src === url);
|
|
49
|
+
if (script) return script;
|
|
50
|
+
script = document.createElement('script');
|
|
51
|
+
script.src = url;
|
|
52
|
+
document.head.appendChild(script);
|
|
53
|
+
return script;
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function relativeSource(source) {
|
|
58
|
+
if (!source.match(/^\..?\//)) return new URL(source, document.baseURI).href;
|
|
59
|
+
const e = new Error();
|
|
60
|
+
if (!e.stack) return source;
|
|
61
|
+
const f2 = e.stack.split('\n').filter(l => l.includes(':'))[2];
|
|
62
|
+
let line = f2.match(/[a-z]+:.*$/);
|
|
63
|
+
if (!line) return source;
|
|
64
|
+
const calledFile = line[0].replace(/(\:[0-9]+){2}\)?$/, '');
|
|
65
|
+
source = new URL(source, calledFile).href;
|
|
66
|
+
return source;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function loadScript(source) {
|
|
70
|
+
source = relativeSource(source);
|
|
71
|
+
return new Promise(resolve => {
|
|
72
|
+
var script = document.createElement('script');
|
|
73
|
+
var head = document.querySelector('head');
|
|
74
|
+
script.async = true;
|
|
75
|
+
|
|
76
|
+
script.onload = () => setTimeout(resolve, 0);
|
|
77
|
+
|
|
78
|
+
script.src = source;
|
|
79
|
+
if (head) head.appendChild(script);
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function domIsReady() {
|
|
84
|
+
return new Promise(function (resolve) {
|
|
85
|
+
if (document.readyState === 'complete') {
|
|
86
|
+
resolve();
|
|
87
|
+
} else {
|
|
88
|
+
document.addEventListener('DOMContentLoaded', () => resolve());
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function setDeepProperty(obj, path, value) {
|
|
94
|
+
const name = path.shift();
|
|
95
|
+
|
|
96
|
+
if (name) {
|
|
97
|
+
if (!(name in obj)) obj[name] = {};
|
|
98
|
+
if (path.length) setDeepProperty(obj[name], path, value);else obj[name] = value;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function parseFieldsString(fields) {
|
|
103
|
+
let fieldsArray; // remove all sets from fields
|
|
104
|
+
|
|
105
|
+
while (fields.indexOf('(') > 0) {
|
|
106
|
+
let firstBracket = fields.indexOf('(');
|
|
107
|
+
let noset = fields.substring(firstBracket, findClosingBracketMatchIndex(fields, firstBracket) + 1);
|
|
108
|
+
fields = fields.replace(noset, '');
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const re = /((^\s*|,)\s*)(("(\\"|[^"])*")|('(\\'|[^'])*')|[^,]*)/gm; // match , not inside quotes
|
|
112
|
+
|
|
113
|
+
fieldsArray = fields.match(re) || []; // separate fields
|
|
114
|
+
|
|
115
|
+
if (!fieldsArray) return [];
|
|
116
|
+
return fieldsArray.map(a => a.replace(/^[\s,]+/, '')); // remove commas and spaces
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function findClosingBracketMatchIndex(str, pos) {
|
|
120
|
+
if (str[pos] != '(') throw new Error("No '(' at index " + pos);
|
|
121
|
+
let depth = 1;
|
|
122
|
+
|
|
123
|
+
for (let i = pos + 1; i < str.length; i++) {
|
|
124
|
+
switch (str[i]) {
|
|
125
|
+
case '(':
|
|
126
|
+
depth++;
|
|
127
|
+
break;
|
|
128
|
+
|
|
129
|
+
case ')':
|
|
130
|
+
if (--depth == 0) return i;
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return -1;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function defineComponent(tagName, componentClass) {
|
|
139
|
+
if (!customElements.get(tagName)) {
|
|
140
|
+
customElements.define(tagName, componentClass);
|
|
141
|
+
} else {
|
|
142
|
+
console.warn("Warning: the component \"".concat(tagName, "\" has already been loaded in another version of sib-core."));
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function fuzzyCompare(subject, search) {
|
|
147
|
+
const fuse = new Fuse([subject], {
|
|
148
|
+
shouldSort: false,
|
|
149
|
+
threshold: 0.37
|
|
150
|
+
}).search(search);
|
|
151
|
+
return fuse.length > 0;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const compare = {
|
|
155
|
+
string(subject, query) {
|
|
156
|
+
if (query === '') return true;
|
|
157
|
+
if (subject.toString().toLowerCase().includes(String(query).toLowerCase())) return true;
|
|
158
|
+
return fuzzyCompare(subject, query);
|
|
159
|
+
},
|
|
160
|
+
|
|
161
|
+
boolean(subject, query) {
|
|
162
|
+
if (!query) return true;
|
|
163
|
+
return subject;
|
|
164
|
+
},
|
|
165
|
+
|
|
166
|
+
number(subject, query) {
|
|
167
|
+
return subject === query;
|
|
168
|
+
},
|
|
169
|
+
|
|
170
|
+
list(subject, list) {
|
|
171
|
+
return list.includes(subject);
|
|
172
|
+
},
|
|
173
|
+
|
|
174
|
+
range(subject, range) {
|
|
175
|
+
return (range[0] == null || range[0] === '' || subject >= range[0]) && (range[1] == null || range[1] === '' || subject <= range[1]);
|
|
176
|
+
},
|
|
177
|
+
|
|
178
|
+
resource(subject, query) {
|
|
179
|
+
// dropdown default ' - ' option return an empty string
|
|
180
|
+
if (query === '') return true;
|
|
181
|
+
if (!query['@id']) return false;
|
|
182
|
+
const ret = subject['@id'] === query['@id'];
|
|
183
|
+
return ret;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
function transformArrayToContainer(resource) {
|
|
189
|
+
const newValue = { ...resource
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
for (let predicate of Object.keys(newValue)) {
|
|
193
|
+
// iterate over all properties
|
|
194
|
+
const predicateValue = newValue[predicate];
|
|
195
|
+
if (!predicateValue || typeof predicateValue !== 'object') continue; // undefined or literal, do nothing
|
|
196
|
+
// check all keys of nested resource
|
|
197
|
+
|
|
198
|
+
if (!Array.isArray(predicateValue) && predicateValue['@id']) {
|
|
199
|
+
newValue[predicate] = transformArrayToContainer(resource[predicate]);
|
|
200
|
+
} // for arrays
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
if (Array.isArray(predicateValue)) {
|
|
204
|
+
newValue[predicate] = {
|
|
205
|
+
'ldp:contains': [...predicateValue]
|
|
206
|
+
}; // transform to container
|
|
207
|
+
|
|
208
|
+
newValue[predicate]['ldp:contains'].forEach((childPredicate, index) => {
|
|
209
|
+
// and check all nested resources
|
|
210
|
+
newValue[predicate]['ldp:contains'][index] = transformArrayToContainer(childPredicate);
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
return newValue;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
export { uniqID, stringToDom, evalTemplateString, importCSS, importJS, loadScript, domIsReady, setDeepProperty, parseFieldsString, findClosingBracketMatchIndex, defineComponent, fuzzyCompare, compare, transformArrayToContainer };
|
|
219
|
+
//# sourceMappingURL=helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["helpers.ts"],"names":["Fuse","uniqID","Math","random","pow","toString","slice","stringToDom","html","template","document","createElement","innerHTML","content","evalTemplateString","str","variables","keys","Object","values","map","key","AsyncFunction","getPrototypeOf","constructor","func","call","e","console","log","SyntaxError","importCSS","stylesheets","linksElements","url","relativeSource","link","Array","from","head","querySelectorAll","find","href","rel","appendChild","push","importJS","plugins","URL","baseURI","script","src","source","match","Error","stack","f2","split","filter","l","includes","line","calledFile","replace","loadScript","Promise","resolve","querySelector","async","onload","setTimeout","domIsReady","readyState","addEventListener","setDeepProperty","obj","path","value","name","shift","length","parseFieldsString","fields","fieldsArray","indexOf","firstBracket","noset","substring","findClosingBracketMatchIndex","re","a","pos","depth","i","defineComponent","tagName","componentClass","customElements","get","define","warn","fuzzyCompare","subject","search","fuse","shouldSort","threshold","compare","string","query","toLowerCase","String","boolean","number","list","range","resource","ret","transformArrayToContainer","newValue","predicate","predicateValue","isArray","forEach","childPredicate","index"],"mappings":"AAAA,OAAOA,IAAP,MAAiB,SAAjB;;AAEA,SAASC,MAAT,GAA0B;AACxB,SAAO,MAAM,CAACC,IAAI,CAAC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BAVF,EAWEM,eAXF,EAYEO,YAZF,EAaEM,OAbF,EAcEW,yBAdF","sourcesContent":["import Fuse from \"fuse.js\";\n\nfunction uniqID(): string {\n return '_' + (Math.random() * Math.pow(36, 20)).toString(36).slice(0, 10);\n}\n\nfunction stringToDom(html: string): DocumentFragment {\n const template = document.createElement('template');\n template.innerHTML = html;\n return template.content;\n}\n\nasync function evalTemplateString(str: string, variables: {[key:string]:any} = {}) {\n const keys = Object.keys(variables);\n const values = keys.map(key => variables[key]);\n try {\n const AsyncFunction = Object.getPrototypeOf(async function(){}).constructor\n const func = AsyncFunction.call(null, ...keys, 'return `' + str + '`');\n return await func(...values);\n } catch (e) {\n console.log(e);\n throw new SyntaxError('`' + str + '`');\n }\n}\n\nfunction importCSS(...stylesheets: string[]) {\n const linksElements: HTMLLinkElement[] = []; \n for(let url of stylesheets) {\n url = relativeSource(url);\n let link = Array.from(document.head.querySelectorAll('link')).find(\n link => link.href === url,\n );\n if (link) return link;\n link = document.createElement('link');\n link.rel = 'stylesheet';\n link.href = url;\n document.head.appendChild(link);\n linksElements.push(link);\n };\n return linksElements;\n}\n\nfunction importJS(...plugins: string[]): HTMLScriptElement[] {\n return plugins.map(url => {\n url = new URL(url, document.baseURI).href;\n let script = Array.from(document.querySelectorAll('script')).find(\n script => script.src === url,\n );\n if (script) return script;\n script = document.createElement('script');\n script.src = url;\n document.head.appendChild(script);\n return script;\n });\n}\n\nfunction relativeSource(source: string) {\n if (!source.match(/^\\..?\\//)) return new URL(source, document.baseURI).href;\n const e = new Error();\n if(!e.stack) return source;\n const f2 = e.stack.split('\\n').filter(l => l.includes(':'))[2];\n let line = f2.match(/[a-z]+:.*$/);\n if (!line) return source;\n const calledFile = line[0].replace(/(\\:[0-9]+){2}\\)?$/,'');\n source = new URL(source, calledFile).href;\n return source;\n}\n\nfunction loadScript(source: string) {\n source = relativeSource(source);\n return new Promise(resolve => {\n var script = document.createElement('script');\n var head = document.querySelector('head');\n script.async = true;\n script.onload = () => setTimeout(resolve, 0);\n script.src = source;\n if(head) head.appendChild(script);\n });\n}\n\nfunction domIsReady(): Promise<void> {\n return new Promise(function(resolve) {\n if (document.readyState === 'complete') {\n resolve();\n } else {\n document.addEventListener('DOMContentLoaded', () => resolve());\n }\n });\n}\n\nfunction setDeepProperty(obj: {[index:string]:any}, path: string[], value: any) {\n const name = path.shift();\n if (name) {\n if (!(name in obj)) obj[name] = {};\n if (path.length) setDeepProperty(obj[name], path, value);\n else obj[name] = value;\n }\n}\n\nfunction parseFieldsString(fields: string): string[] {\n let fieldsArray: string[];\n\n // remove all sets from fields\n while(fields.indexOf('(') > 0){\n let firstBracket = fields.indexOf('(');\n let noset = fields.substring(firstBracket, findClosingBracketMatchIndex(fields, firstBracket)+1)\n fields = fields.replace(noset, '')\n }\n\n const re = /((^\\s*|,)\\s*)((\"(\\\\\"|[^\"])*\")|('(\\\\'|[^'])*')|[^,]*)/gm; // match , not inside quotes\n fieldsArray = fields.match(re) || []; // separate fields\n if (!fieldsArray) return [];\n return fieldsArray.map(a => a.replace(/^[\\s,]+/, '')) // remove commas and spaces\n}\n\nfunction findClosingBracketMatchIndex(str: string, pos: number) {\n if (str[pos] != '(') throw new Error(\"No '(' at index \" + pos);\n let depth = 1;\n for (let i = pos + 1; i < str.length; i++) {\n switch (str[i]) {\n case '(':\n depth++;\n break;\n case ')':\n if (--depth == 0) return i;\n break;\n }\n }\n return -1;\n}\n\nfunction defineComponent(tagName: string, componentClass: typeof HTMLElement) {\n if (!customElements.get(tagName)) {\n customElements.define(tagName, componentClass);\n } else {\n console.warn(`Warning: the component \"${tagName}\" has already been loaded in another version of sib-core.`)\n }\n}\n\nfunction fuzzyCompare(subject: string, search: string) {\n const fuse = new Fuse([subject], {\n shouldSort: false,\n threshold: 0.37,\n }).search(search);\n return fuse.length > 0;\n}\n\nconst compare: { [k: string]: (subject: any, query: any) => boolean } = {\n string(subject: string, query: string) {\n if(query === '') return true;\n if(subject.toString().toLowerCase().includes(String(query).toLowerCase())) return true;\n return fuzzyCompare(subject, query);\n },\n boolean(subject: boolean, query: boolean) {\n if (!query) return true;\n return subject;\n },\n number(subject: number, query: number) {\n return subject === query;\n },\n list(subject: string, list: string[]) {\n return list.includes(subject);\n },\n range(subject: number | Date, range: [any, any]) {\n return (\n (range[0] == null || range[0] === '' || subject >= range[0]) &&\n (range[1] == null || range[1] === '' || subject <= range[1])\n );\n },\n resource(subject, query) {\n // dropdown default ' - ' option return an empty string\n if(query === '') return true;\n if (!query['@id']) return false;\n const ret = subject['@id'] === query['@id'];\n return ret;\n }\n};\n\nfunction transformArrayToContainer(resource: object) {\n const newValue = { ...resource };\n for (let predicate of Object.keys(newValue)) { // iterate over all properties\n const predicateValue = newValue[predicate];\n if (!predicateValue || typeof predicateValue !== 'object') continue; // undefined or literal, do nothing\n\n // check all keys of nested resource\n if (!Array.isArray(predicateValue) && predicateValue['@id']) {\n newValue[predicate] = transformArrayToContainer(resource[predicate]);\n }\n\n // for arrays\n if (Array.isArray(predicateValue)) {\n newValue[predicate] = { 'ldp:contains': [...predicateValue] }; // transform to container\n newValue[predicate]['ldp:contains'].forEach((childPredicate: any, index: number) => { // and check all nested resources\n newValue[predicate]['ldp:contains'][index] = transformArrayToContainer(childPredicate);\n });\n }\n }\n return newValue;\n}\n\nexport {\n uniqID,\n stringToDom,\n evalTemplateString,\n importCSS,\n importJS,\n loadScript,\n domIsReady,\n setDeepProperty,\n parseFieldsString,\n findClosingBracketMatchIndex,\n defineComponent,\n fuzzyCompare,\n compare,\n transformArrayToContainer\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["interfaces.ts"],"names":[],"mappings":"AAKC;AAUA;AA8BA;AAsBA;AAIA","sourcesContent":["export interface AccessorStaticInterface {\n [key: string]: {\n get: Function;\n set: Function;\n }\n};\n\nexport interface ArrayOfHooksInterface {\n created: HookInterface[];\n attached: HookInterface[];\n detached: HookInterface[];\n}\n\nexport interface AttributeChangedCallbackInterface {\n (newValue: any, oldValue: any): void;\n};\n\nexport interface AttributeDefinitionInterface {\n type?: any;\n default?: any;\n required?: boolean;\n callback?: AttributeChangedCallbackInterface;\n}\n\nexport interface AttributesDefinitionInterface {\n [key: string]: AttributeDefinitionInterface;\n}\n\nexport type ComponentConstructorInterface = new (element: HTMLElement) => ComponentInterface;\n\nexport interface ComponentInterface {\n element: HTMLElement;\n created():void;\n attached():void;\n detached():void;\n\n attributesCallback(key: string, value: any, oldValue: any):void;\n}\n\nexport interface ComponentStaticInterface extends HasAttributesDefinitionInterface, HasInitialStateInterface {\n name: String;\n\n hooks: ArrayOfHooksInterface;\n methods: Map<string, Function>;\n accessors: AccessorStaticInterface;\n};\n\nexport interface HasAttributesDefinitionInterface {\n attributes?: AttributesDefinitionInterface | undefined;\n}\n\nexport interface HasHooksInterface {\n created?: HookInterface;\n attached?: HookInterface;\n detached?: HookInterface;\n}\n\nexport interface HasInitialStateInterface {\n initialState?: object | undefined;\n}\n\nexport interface HasMixinsInterface {\n use?: MixinStaticInterface[] | undefined;\n}\n\nexport interface HookInterface {\n (): void;\n};\n\nexport interface MixinStaticInterface extends HasAttributesDefinitionInterface, HasMixinsInterface, HasInitialStateInterface, HasHooksInterface {\n name: String;\n};\n\nexport interface LocationResourceInterface {\n lat?: HookInterface;\n lng?: HookInterface;\n}\n"]}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Spread function from open-wc/lit-helpers
|
|
3
|
+
* More informations here: https://open-wc.org/developing/lit-helpers.html
|
|
4
|
+
*/
|
|
5
|
+
import { html, directive, noChange } from '../_snowpack/pkg/lit-html.js';
|
|
6
|
+
const prevCache = new WeakMap();
|
|
7
|
+
export const spread = directive(spreadData => part => {
|
|
8
|
+
const prevData = prevCache.get(part);
|
|
9
|
+
|
|
10
|
+
if (prevData === spreadData) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
prevCache.set(part, spreadData);
|
|
15
|
+
|
|
16
|
+
if (spreadData) {
|
|
17
|
+
for (const key in spreadData) {
|
|
18
|
+
const value = spreadData[key];
|
|
19
|
+
if (value === noChange) continue;
|
|
20
|
+
const prefix = key[0];
|
|
21
|
+
const {
|
|
22
|
+
element
|
|
23
|
+
} = part.committer;
|
|
24
|
+
|
|
25
|
+
if (prefix === '@') {
|
|
26
|
+
const prevHandler = prevData && prevData[key];
|
|
27
|
+
|
|
28
|
+
if (!prevHandler || prevHandler !== value) {
|
|
29
|
+
const name = key.slice(1);
|
|
30
|
+
if (prevHandler) element.removeEventListener(name, prevHandler);
|
|
31
|
+
element.addEventListener(name, value);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (prefix === '.') {
|
|
38
|
+
if (!prevData || prevData[key] !== value) {
|
|
39
|
+
element[key.slice(1)] = value;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (prefix === '?') {
|
|
46
|
+
if (!prevData || prevData[key] !== value) {
|
|
47
|
+
const name = key.slice(1);
|
|
48
|
+
|
|
49
|
+
if (value) {
|
|
50
|
+
element.setAttribute(name, '');
|
|
51
|
+
} else {
|
|
52
|
+
element.removeAttribute(name);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (!prevData || prevData[key] !== value) {
|
|
60
|
+
if (value != null) {
|
|
61
|
+
element.setAttribute(key, String(value));
|
|
62
|
+
} else {
|
|
63
|
+
element.removeAttribute(key);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (prevData) {
|
|
70
|
+
for (const key in prevData) {
|
|
71
|
+
if (!spreadData || !(key in spreadData)) {
|
|
72
|
+
const prefix = key[0];
|
|
73
|
+
const {
|
|
74
|
+
element
|
|
75
|
+
} = part.committer;
|
|
76
|
+
|
|
77
|
+
if (prefix === '@') {
|
|
78
|
+
element.removeEventListener(key.slice(1), prevData[key]);
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (prefix === '.') {
|
|
83
|
+
element[key.slice(1)] = undefined;
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (prefix === '?') {
|
|
88
|
+
element.removeAttribute(key.slice(1));
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
element.removeAttribute(key);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
function dropIndices(arr, needlessValues) {
|
|
99
|
+
const newArr = [];
|
|
100
|
+
let j = 0;
|
|
101
|
+
|
|
102
|
+
for (let i = 0, n = arr.length; i < n; ++i) {
|
|
103
|
+
if (needlessValues[j].index === i) {
|
|
104
|
+
++j;
|
|
105
|
+
} else {
|
|
106
|
+
newArr.push(arr[i]);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return newArr;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const templateStringsCache = new WeakMap(); // Convert dynamic tags to template strings
|
|
114
|
+
// example: <${'div'}>${'this is example'}</${'div'}> => <div>${'this is example'}</div>
|
|
115
|
+
|
|
116
|
+
export function preHTML(strings, ...values) {
|
|
117
|
+
// check cache !important return equal link at first argument
|
|
118
|
+
let cachedStrings = templateStringsCache.get(strings);
|
|
119
|
+
|
|
120
|
+
if (cachedStrings) {
|
|
121
|
+
for (let i = 0, n = cachedStrings.length; i < n; ++i) {
|
|
122
|
+
const needlessValues = cachedStrings[i].needlessValues;
|
|
123
|
+
let isSame = true;
|
|
124
|
+
|
|
125
|
+
for (let ii = 0, nn = needlessValues.length; ii < nn; ++ii) {
|
|
126
|
+
if (values[needlessValues[ii].index] !== needlessValues[ii].value) {
|
|
127
|
+
isSame = false;
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (isSame) {
|
|
133
|
+
return html(cachedStrings[i].strings, ...dropIndices(values, needlessValues));
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const needlessValues = [];
|
|
139
|
+
const newStrings = [];
|
|
140
|
+
let str;
|
|
141
|
+
|
|
142
|
+
for (let i = 0, n = strings.length; i < n; ++i) {
|
|
143
|
+
str = strings[i];
|
|
144
|
+
|
|
145
|
+
while (str[str.length - 1] === '<' // open tag
|
|
146
|
+
|| str[str.length - 2] === '<' && str[str.length - 1] === '/' // close tag
|
|
147
|
+
) {
|
|
148
|
+
needlessValues.push({
|
|
149
|
+
value: values[i],
|
|
150
|
+
index: i
|
|
151
|
+
});
|
|
152
|
+
str += values[i] + strings[++i];
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
newStrings.push(str);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if (!cachedStrings) {
|
|
159
|
+
cachedStrings = [];
|
|
160
|
+
templateStringsCache.set(strings, cachedStrings);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
cachedStrings.push({
|
|
164
|
+
strings: newStrings,
|
|
165
|
+
needlessValues
|
|
166
|
+
});
|
|
167
|
+
return html(newStrings, ...dropIndices(values, needlessValues));
|
|
168
|
+
}
|
|
169
|
+
//# sourceMappingURL=lit-helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["lit-helpers.ts"],"names":["html","directive","noChange","prevCache","WeakMap","spread","spreadData","part","prevData","get","set","key","value","prefix","element","committer","prevHandler","name","slice","removeEventListener","addEventListener","setAttribute","removeAttribute","String","undefined","dropIndices","arr","needlessValues","newArr","j","i","n","length","index","push","templateStringsCache","preHTML","strings","values","cachedStrings","isSame","ii","nn","newStrings","str"],"mappings":"AAAA;AACA;AACA;AACA;AACA,SAAQA,IAAR,EAA8BC,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IAAAA,oBAAoB,CAACzB,GAArB,CAAyB2B,OAAzB,EAAkCE,aAAlC;AACH;;AAEDA,EAAAA,aAAa,CAACL,IAAd,CAAmB;AACfG,IAAAA,OAAO,EAAEM,UADM;AAEfhB,IAAAA;AAFe,GAAnB;AAKA,SAAO3B,IAAI,CAAC2C,UAAD,EAAoB,GAAGlB,WAAW,CAACa,MAAD,EAASX,cAAT,CAAlC,CAAX;AACH","sourcesContent":["/**\n * Spread function from open-wc/lit-helpers\n * More informations here: https://open-wc.org/developing/lit-helpers.html\n */\nimport {html, TemplateResult, directive, noChange } from 'lit-html';\n\nconst prevCache = new WeakMap();\nexport const spread = directive((spreadData) => (part) => {\n const prevData = prevCache.get(part);\n if (prevData === spreadData) {\n return;\n }\n prevCache.set(part, spreadData);\n\n if (spreadData) {\n for (const key in spreadData) {\n const value = spreadData[key];\n if (value === noChange) continue;\n\n const prefix = key[0];\n const { element } = part.committer;\n\n if (prefix === '@') {\n const prevHandler = prevData && prevData[key];\n if (!prevHandler || prevHandler !== value) {\n const name = key.slice(1);\n if (prevHandler) element.removeEventListener(name, prevHandler);\n element.addEventListener(name, value);\n }\n continue;\n }\n if (prefix === '.') {\n if (!prevData || prevData[key] !== value) {\n element[key.slice(1)] = value;\n }\n continue;\n }\n if (prefix === '?') {\n if (!prevData || prevData[key] !== value) {\n const name = key.slice(1);\n if (value) {\n element.setAttribute(name, '');\n } else {\n element.removeAttribute(name);\n }\n }\n continue;\n }\n if (!prevData || prevData[key] !== value) {\n if (value != null) {\n element.setAttribute(key, String(value));\n } else {\n element.removeAttribute(key);\n }\n }\n }\n }\n\n if (prevData) {\n for (const key in prevData) {\n if (!spreadData || !(key in spreadData)) {\n const prefix = key[0];\n const { element } = part.committer;\n\n if (prefix === '@') {\n element.removeEventListener(key.slice(1), prevData[key]);\n continue;\n }\n if (prefix === '.') {\n element[key.slice(1)] = undefined;\n continue;\n }\n if (prefix === '?') {\n element.removeAttribute(key.slice(1));\n continue;\n }\n element.removeAttribute(key);\n }\n }\n }\n});\n\n\ninterface CachedNeedlessValue {\n value: any;\n index: number;\n}\n\ninterface CachedTemplateStrings {\n strings: string[];\n needlessValues: CachedNeedlessValue[];\n}\n\nfunction dropIndices(arr: any[], needlessValues: CachedNeedlessValue[]): any[] {\n const newArr: any[] = [];\n let j = 0;\n\n for (let i = 0, n = arr.length; i < n; ++i) {\n if (needlessValues[j].index === i) {\n ++j;\n } else {\n newArr.push(arr[i]);\n }\n }\n\n return newArr;\n}\n\nconst templateStringsCache = new WeakMap<TemplateStringsArray, CachedTemplateStrings[]>();\n\n// Convert dynamic tags to template strings\n// example: <${'div'}>${'this is example'}</${'div'}> => <div>${'this is example'}</div>\nexport function preHTML(strings: TemplateStringsArray, ...values: any[]): TemplateResult {\n // check cache !important return equal link at first argument\n let cachedStrings = templateStringsCache.get(strings) as CachedTemplateStrings[];\n if (cachedStrings) {\n for (let i = 0, n = cachedStrings.length; i < n; ++i) {\n const needlessValues = cachedStrings[i].needlessValues;\n let isSame = true;\n for (let ii = 0, nn = needlessValues.length; ii < nn; ++ii) {\n if (values[needlessValues[ii].index] !== needlessValues[ii].value) {\n isSame = false;\n break;\n }\n }\n\n if (isSame) {\n return html(\n cachedStrings[i].strings as any,\n ...dropIndices(values, needlessValues)\n );\n }\n }\n }\n\n const needlessValues: CachedNeedlessValue[] = [];\n const newStrings: string[] = [];\n\n let str: string;\n for (let i = 0, n = strings.length; i < n; ++i) {\n str = strings[i];\n\n while (\n str[str.length - 1] === '<' // open tag\n || (str[str.length - 2] === '<' && str[str.length - 1] === '/') // close tag\n ) {\n needlessValues.push({\n value: values[i],\n index: i,\n });\n str += values[i] + strings[++i];\n }\n\n newStrings.push(str);\n }\n\n if (!cachedStrings) {\n cachedStrings = [];\n templateStringsCache.set(strings, cachedStrings);\n }\n\n cachedStrings.push({\n strings: newStrings,\n needlessValues,\n });\n\n return html(newStrings as any, ...dropIndices(values, needlessValues));\n}"]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// Array.prototype.flat
|
|
2
|
+
if (!('flat' in Array.prototype)) {
|
|
3
|
+
Object.defineProperty(Array.prototype, 'flat', {
|
|
4
|
+
configurable: true,
|
|
5
|
+
value: function flat(depth = 1) {
|
|
6
|
+
depth = isNaN(depth) ? 1 : Number(depth);
|
|
7
|
+
if (depth === 0) return Array.prototype.slice.call(this);
|
|
8
|
+
return Array.prototype.reduce.call(this, function (acc, cur) {
|
|
9
|
+
if (Array.isArray(cur)) {
|
|
10
|
+
acc.push.apply(acc, flat.call(cur, depth - 1));
|
|
11
|
+
} else {
|
|
12
|
+
acc.push(cur);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return acc;
|
|
16
|
+
}, []);
|
|
17
|
+
},
|
|
18
|
+
writable: true
|
|
19
|
+
});
|
|
20
|
+
} // Element.prototype.toggleAttribute
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
if (!Element.prototype.toggleAttribute) {
|
|
24
|
+
Element.prototype.toggleAttribute = function (name, force = undefined) {
|
|
25
|
+
if (force !== undefined) force = !!force;
|
|
26
|
+
|
|
27
|
+
if (this.hasAttribute(name)) {
|
|
28
|
+
if (force) return true;
|
|
29
|
+
this.removeAttribute(name);
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (force === false) return false;
|
|
34
|
+
this.setAttribute(name, '');
|
|
35
|
+
return true;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export {};
|
|
40
|
+
//# sourceMappingURL=polyfills.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["polyfills.ts"],"names":["Array","prototype","Object","defineProperty","configurable","value","flat","depth","isNaN","Number","slice","call","reduce","acc","cur","isArray","push","apply","writable","Element","toggleAttribute","name","force","undefined","hasAttribute","removeAttribute","setAttribute"],"mappings":"AAAA;AACA,IAAI,EAAE,UAAUA,KAAK,CAACC,SAAlB,CAAJ,EAAkC;AAChCC,EAAAA,MAA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AAqBJ,IAArB;AACA,aAAO,KAAP;AACD;;AACD,QAAIC,KAAK,KAAK,KAAd,EAAqB,OAAO,KAAP;AAErB,SAAKI,YAAL,CAAkBL,IAAlB,EAAwB,EAAxB;AACA,WAAO,IAAP;AACD,GAbD;AAcD;;AAED","sourcesContent":["// Array.prototype.flat\nif (!('flat' in Array.prototype)) {\n Object.defineProperty(Array.prototype, 'flat', {\n configurable: true,\n value: function flat(this: any[], depth = 1) {\n depth = isNaN(depth) ? 1 : Number(depth);\n if (depth === 0) return Array.prototype.slice.call(this);\n return Array.prototype.reduce.call<any, any[], any[]>(\n this,\n function(acc:any[], cur: any) {\n if (Array.isArray(cur)) {\n acc.push.apply(acc, flat.call(cur, depth - 1));\n } else {\n acc.push(cur);\n }\n return acc;\n },\n [],\n );\n },\n writable: true,\n });\n}\n\n// Element.prototype.toggleAttribute\nif (!Element.prototype.toggleAttribute) {\n Element.prototype.toggleAttribute = function(name, force = undefined) {\n if (force !== undefined) force = !!force;\n\n if (this.hasAttribute(name)) {\n if (force) return true;\n\n this.removeAttribute(name);\n return false;\n }\n if (force === false) return false;\n\n this.setAttribute(name, '');\n return true;\n };\n}\n\nexport {}\n"]}
|