@startinblox/core 0.17.31 → 0.18.0-beta.1
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/pkg/autolinker.js +3515 -3367
- package/dist/_snowpack/pkg/autolinker.js.map +1 -1
- package/dist/_snowpack/pkg/common/{_baseUnary-217dffb2.js → _baseUnary-c1edb653.js} +16 -40
- package/dist/_snowpack/pkg/common/{_baseUnary-217dffb2.js.map → _baseUnary-c1edb653.js.map} +1 -1
- package/dist/_snowpack/pkg/common/{_commonjsHelpers-8c19dec8.js → _commonjsHelpers-37fa8da4.js} +6 -2
- package/dist/_snowpack/pkg/common/_commonjsHelpers-37fa8da4.js.map +1 -0
- package/dist/_snowpack/pkg/common/{decode-a4c334cf.js → decode-26fbf385.js} +38 -69
- package/dist/_snowpack/pkg/common/decode-26fbf385.js.map +1 -0
- package/dist/_snowpack/pkg/common/lit-html-3647afce.js +1104 -0
- package/dist/_snowpack/pkg/common/lit-html-3647afce.js.map +1 -0
- package/dist/_snowpack/pkg/delta-markdown-for-quill.js +4767 -4246
- package/dist/_snowpack/pkg/delta-markdown-for-quill.js.map +1 -1
- package/dist/_snowpack/pkg/dialog-polyfill.js +107 -139
- package/dist/_snowpack/pkg/dialog-polyfill.js.map +1 -1
- package/dist/_snowpack/pkg/fusejs.js +411 -601
- package/dist/_snowpack/pkg/fusejs.js.map +1 -1
- package/dist/_snowpack/pkg/jsonld-context-parser.js +718 -686
- package/dist/_snowpack/pkg/jsonld-context-parser.js.map +1 -1
- package/dist/_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.Default.css +59 -59
- package/dist/_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.Default.css.proxy.js +1 -1
- package/dist/_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.css +14 -14
- package/dist/_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.css.proxy.js +1 -1
- package/dist/_snowpack/pkg/lit-html/directives/if-defined.js +13 -14
- package/dist/_snowpack/pkg/lit-html/directives/if-defined.js.map +1 -1
- package/dist/_snowpack/pkg/lit-html/directives/unsafe-html.js +17 -15
- package/dist/_snowpack/pkg/lit-html/directives/unsafe-html.js.map +1 -1
- package/dist/_snowpack/pkg/lit-html/directives/until.js +45 -46
- package/dist/_snowpack/pkg/lit-html/directives/until.js.map +1 -1
- package/dist/_snowpack/pkg/lit-html.js +37 -35
- package/dist/_snowpack/pkg/lit-html.js.map +1 -1
- package/dist/_snowpack/pkg/markdown-it-link-attributes.js +1 -20
- package/dist/_snowpack/pkg/markdown-it-link-attributes.js.map +1 -1
- package/dist/_snowpack/pkg/markdown-it.js +1731 -2284
- package/dist/_snowpack/pkg/markdown-it.js.map +1 -1
- package/dist/_snowpack/pkg/quill-delta-to-markdown.js +236 -294
- package/dist/_snowpack/pkg/quill-delta-to-markdown.js.map +1 -1
- package/dist/_snowpack/pkg/quill.js +12077 -11017
- package/dist/_snowpack/pkg/quill.js.map +1 -1
- package/dist/_snowpack/pkg/slim-select.js +711 -1
- package/dist/_snowpack/pkg/slim-select.js.map +1 -1
- package/dist/_snowpack/pkg/tui-calendar/dist/tui-calendar.css +1 -16
- package/dist/_snowpack/pkg/tui-calendar/dist/tui-calendar.css.proxy.js +1 -1
- package/dist/_snowpack/pkg/tui-calendar.js +44297 -40075
- package/dist/_snowpack/pkg/tui-calendar.js.map +1 -1
- package/dist/components/solid-ac-checker.js +4 -17
- package/dist/components/solid-calendar.js +5 -26
- package/dist/components/solid-delete.js +9 -24
- package/dist/components/solid-display.js +15 -59
- package/dist/components/solid-form-search.js +27 -79
- package/dist/components/solid-form.js +48 -143
- package/dist/components/solid-lang.js +8 -19
- package/dist/components/solid-map.js +26 -64
- package/dist/components/solid-table.js +51 -133
- package/dist/components/solid-widget.js +2 -24
- package/dist/index.js +17 -11
- package/dist/libs/Component.js +4 -10
- package/dist/libs/ComponentFactory.js +6 -34
- package/dist/libs/Compositor.js +8 -15
- package/dist/libs/Sib.js +7 -21
- package/dist/libs/filter.js +184 -0
- package/dist/libs/helpers.js +19 -47
- package/dist/libs/interfaces.js +1 -1
- package/dist/libs/lit-helpers.js +7 -34
- package/dist/libs/polyfills.js +7 -10
- package/dist/libs/store/server-pagination.js +22 -0
- package/dist/libs/store/server-search.js +35 -0
- package/dist/libs/store/store.js +212 -227
- package/dist/mixins/attributeBinderMixin.js +17 -25
- package/dist/mixins/contextMixin.js +5 -7
- package/dist/mixins/counterMixin.js +2 -23
- package/dist/mixins/federationMixin.js +2 -14
- package/dist/mixins/filterMixin.js +60 -100
- package/dist/mixins/grouperMixin.js +11 -18
- package/dist/mixins/highlighterMixin.js +2 -8
- package/dist/mixins/interfaces.js +3 -5
- package/dist/mixins/listMixin.js +12 -43
- package/dist/mixins/nextMixin.js +1 -4
- package/dist/mixins/paginateMixin.js +17 -30
- package/dist/mixins/requiredMixin.js +1 -9
- package/dist/mixins/serverPaginationMixin.js +122 -0
- package/dist/mixins/sorterMixin.js +26 -44
- package/dist/mixins/storeMixin.js +28 -21
- package/dist/mixins/translationMixin.js +2 -12
- package/dist/mixins/validationMixin.js +28 -46
- package/dist/mixins/widgetMixin.js +58 -154
- package/dist/new-widgets/attributeMixins/actionMixin.js +1 -2
- package/dist/new-widgets/attributeMixins/blankMixin.js +1 -4
- package/dist/new-widgets/attributeMixins/booleanMixin.js +1 -4
- package/dist/new-widgets/attributeMixins/index.js +1 -2
- package/dist/new-widgets/attributeMixins/mailtoMixin.js +1 -4
- package/dist/new-widgets/attributeMixins/multipleMixin.js +1 -2
- package/dist/new-widgets/attributeMixins/numberMixin.js +1 -4
- package/dist/new-widgets/attributeMixins/placeholderMixin.js +1 -4
- package/dist/new-widgets/attributeMixins/telMixin.js +1 -4
- package/dist/new-widgets/baseWidgetMixin.js +5 -18
- package/dist/new-widgets/callbackMixins/autocompletionMixin.js +3 -11
- package/dist/new-widgets/callbackMixins/index.js +1 -2
- package/dist/new-widgets/callbackMixins/richtextMixin.js +1 -6
- package/dist/new-widgets/interfaces.js +1 -0
- package/dist/new-widgets/new-widget-factory.js +14 -19
- package/dist/new-widgets/templateAdditionMixins/addableMixin.js +6 -21
- package/dist/new-widgets/templateAdditionMixins/index.js +2 -3
- package/dist/new-widgets/templateAdditionMixins/labelLastMixin.js +5 -18
- package/dist/new-widgets/templateAdditionMixins/labelMixin.js +5 -18
- package/dist/new-widgets/templates/defaultTemplatesDirectory.js +21 -27
- package/dist/new-widgets/templates/displayTemplatesDirectory.js +35 -70
- package/dist/new-widgets/templates/formTemplatesDirectory.js +350 -315
- package/dist/new-widgets/templates/groupTemplatesDirectory.js +5 -15
- package/dist/new-widgets/templates/index.js +1 -2
- package/dist/new-widgets/templates/setTemplatesDirectory.js +4 -37
- package/dist/new-widgets/templatesDependencies/altMixin.js +1 -2
- package/dist/new-widgets/templatesDependencies/editableMixin.js +9 -26
- package/dist/new-widgets/templatesDependencies/filterRangeFormMixin.js +3 -7
- package/dist/new-widgets/templatesDependencies/formCheckboxMixin.js +1 -5
- package/dist/new-widgets/templatesDependencies/formCheckboxesMixin.js +1 -11
- package/dist/new-widgets/templatesDependencies/formDropdownMixin.js +3 -13
- package/dist/new-widgets/templatesDependencies/formFileMixin.js +1 -13
- package/dist/new-widgets/templatesDependencies/formLengthMixin.js +1 -2
- package/dist/new-widgets/templatesDependencies/formMinMaxMixin.js +1 -2
- package/dist/new-widgets/templatesDependencies/formMixin.js +4 -14
- package/dist/new-widgets/templatesDependencies/formNumberMixin.js +1 -5
- package/dist/new-widgets/templatesDependencies/formRadioMixin.js +1 -5
- package/dist/new-widgets/templatesDependencies/formStepMixin.js +1 -2
- package/dist/new-widgets/templatesDependencies/linkTextMixin.js +13 -0
- package/dist/new-widgets/templatesDependencies/multipleFormMixin.js +23 -18
- package/dist/new-widgets/templatesDependencies/multipleselectFormMixin.js +1 -10
- package/dist/new-widgets/templatesDependencies/patternMixin.js +1 -2
- package/dist/new-widgets/templatesDependencies/rangeMixin.js +5 -15
- package/dist/new-widgets/templatesDependencies/setMixin.js +1 -4
- package/dist/new-widgets/templatesDependencies/valueRichtextMixin.js +1 -4
- package/dist/new-widgets/valueTransformationMixins/autolinkMixin.js +1 -5
- package/dist/new-widgets/valueTransformationMixins/dateMixin.js +5 -11
- package/dist/new-widgets/valueTransformationMixins/dateTimeMixin.js +1 -5
- package/dist/new-widgets/valueTransformationMixins/index.js +1 -2
- package/dist/new-widgets/valueTransformationMixins/markdownMixin.js +1 -7
- package/dist/new-widgets/valueTransformationMixins/multilineMixin.js +1 -5
- package/dist/new-widgets/valueTransformationMixins/oembedMixin.js +1 -7
- package/dist/solid-template-element.js +24 -44
- package/dist/widgets/baseWidget.js +21 -85
- package/dist/widgets/widget-factory.js +4 -6
- package/package.json +8 -6
- package/dist/_snowpack/env.js +0 -3
- package/dist/_snowpack/pkg/autolinker.js.map.proxy.js +0 -1
- package/dist/_snowpack/pkg/common/_baseUnary-217dffb2.js.map.proxy.js +0 -1
- package/dist/_snowpack/pkg/common/_commonjsHelpers-8c19dec8.js.map +0 -1
- package/dist/_snowpack/pkg/common/_commonjsHelpers-8c19dec8.js.map.proxy.js +0 -1
- package/dist/_snowpack/pkg/common/decode-a4c334cf.js.map +0 -1
- package/dist/_snowpack/pkg/common/decode-a4c334cf.js.map.proxy.js +0 -1
- package/dist/_snowpack/pkg/common/lit-html-babd44cd.js +0 -1119
- package/dist/_snowpack/pkg/common/lit-html-babd44cd.js.map +0 -1
- package/dist/_snowpack/pkg/common/lit-html-babd44cd.js.map.proxy.js +0 -1
- package/dist/_snowpack/pkg/delta-markdown-for-quill.js.map.proxy.js +0 -1
- package/dist/_snowpack/pkg/dialog-polyfill.js.map.proxy.js +0 -1
- package/dist/_snowpack/pkg/fusejs.js.map.proxy.js +0 -1
- package/dist/_snowpack/pkg/jsonld-context-parser.js.map.proxy.js +0 -1
- package/dist/_snowpack/pkg/lit-html/directives/if-defined.js.map.proxy.js +0 -1
- package/dist/_snowpack/pkg/lit-html/directives/unsafe-html.js.map.proxy.js +0 -1
- package/dist/_snowpack/pkg/lit-html/directives/until.js.map.proxy.js +0 -1
- package/dist/_snowpack/pkg/lit-html.js.map.proxy.js +0 -1
- package/dist/_snowpack/pkg/markdown-it-link-attributes.js.map.proxy.js +0 -1
- package/dist/_snowpack/pkg/markdown-it.js.map.proxy.js +0 -1
- package/dist/_snowpack/pkg/quill-delta-to-markdown.js.map.proxy.js +0 -1
- package/dist/_snowpack/pkg/quill.js.map.proxy.js +0 -1
- package/dist/_snowpack/pkg/slim-select.js.map.proxy.js +0 -1
- package/dist/_snowpack/pkg/tui-calendar.js.map.proxy.js +0 -1
- package/dist/components/solid-ac-checker.js.map +0 -1
- package/dist/components/solid-calendar.js.map +0 -1
- package/dist/components/solid-delete.js.map +0 -1
- package/dist/components/solid-display.js.map +0 -1
- package/dist/components/solid-form-search.js.map +0 -1
- package/dist/components/solid-form.js.map +0 -1
- package/dist/components/solid-lang.js.map +0 -1
- package/dist/components/solid-map.js.map +0 -1
- package/dist/components/solid-table.js.map +0 -1
- package/dist/components/solid-widget.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/libs/Component.js.map +0 -1
- package/dist/libs/ComponentFactory.js.map +0 -1
- package/dist/libs/Compositor.js.map +0 -1
- package/dist/libs/Sib.js.map +0 -1
- package/dist/libs/helpers.js.map +0 -1
- package/dist/libs/interfaces.js.map +0 -1
- package/dist/libs/lit-helpers.js.map +0 -1
- package/dist/libs/polyfills.js.map +0 -1
- package/dist/libs/store/store.js.map +0 -1
- package/dist/mixins/attributeBinderMixin.js.map +0 -1
- package/dist/mixins/contextMixin.js.map +0 -1
- package/dist/mixins/counterMixin.js.map +0 -1
- package/dist/mixins/federationMixin.js.map +0 -1
- package/dist/mixins/filterMixin.js.map +0 -1
- package/dist/mixins/grouperMixin.js.map +0 -1
- package/dist/mixins/highlighterMixin.js.map +0 -1
- package/dist/mixins/interfaces.js.map +0 -1
- package/dist/mixins/listMixin.js.map +0 -1
- package/dist/mixins/nextMixin.js.map +0 -1
- package/dist/mixins/paginateMixin.js.map +0 -1
- package/dist/mixins/requiredMixin.js.map +0 -1
- package/dist/mixins/sorterMixin.js.map +0 -1
- package/dist/mixins/storeMixin.js.map +0 -1
- package/dist/mixins/translationMixin.js.map +0 -1
- package/dist/mixins/validationMixin.js.map +0 -1
- package/dist/mixins/widgetMixin.js.map +0 -1
- package/dist/new-widgets/attributeMixins/actionMixin.js.map +0 -1
- package/dist/new-widgets/attributeMixins/blankMixin.js.map +0 -1
- package/dist/new-widgets/attributeMixins/booleanMixin.js.map +0 -1
- package/dist/new-widgets/attributeMixins/index.js.map +0 -1
- package/dist/new-widgets/attributeMixins/mailtoMixin.js.map +0 -1
- package/dist/new-widgets/attributeMixins/multipleMixin.js.map +0 -1
- package/dist/new-widgets/attributeMixins/numberMixin.js.map +0 -1
- package/dist/new-widgets/attributeMixins/placeholderMixin.js.map +0 -1
- package/dist/new-widgets/attributeMixins/telMixin.js.map +0 -1
- package/dist/new-widgets/baseWidgetMixin.js.map +0 -1
- package/dist/new-widgets/callbackMixins/autocompletionMixin.js.map +0 -1
- package/dist/new-widgets/callbackMixins/index.js.map +0 -1
- package/dist/new-widgets/callbackMixins/richtextMixin.js.map +0 -1
- package/dist/new-widgets/new-widget-factory.js.map +0 -1
- package/dist/new-widgets/templateAdditionMixins/addableMixin.js.map +0 -1
- package/dist/new-widgets/templateAdditionMixins/index.js.map +0 -1
- package/dist/new-widgets/templateAdditionMixins/labelLastMixin.js.map +0 -1
- package/dist/new-widgets/templateAdditionMixins/labelMixin.js.map +0 -1
- package/dist/new-widgets/templates/defaultTemplatesDirectory.js.map +0 -1
- package/dist/new-widgets/templates/displayTemplatesDirectory.js.map +0 -1
- package/dist/new-widgets/templates/formTemplatesDirectory.js.map +0 -1
- package/dist/new-widgets/templates/groupTemplatesDirectory.js.map +0 -1
- package/dist/new-widgets/templates/index.js.map +0 -1
- package/dist/new-widgets/templates/setTemplatesDirectory.js.map +0 -1
- package/dist/new-widgets/templatesDependencies/altMixin.js.map +0 -1
- package/dist/new-widgets/templatesDependencies/editableMixin.js.map +0 -1
- package/dist/new-widgets/templatesDependencies/filterRangeFormMixin.js.map +0 -1
- package/dist/new-widgets/templatesDependencies/formCheckboxMixin.js.map +0 -1
- package/dist/new-widgets/templatesDependencies/formCheckboxesMixin.js.map +0 -1
- package/dist/new-widgets/templatesDependencies/formDropdownMixin.js.map +0 -1
- package/dist/new-widgets/templatesDependencies/formFileMixin.js.map +0 -1
- package/dist/new-widgets/templatesDependencies/formLengthMixin.js.map +0 -1
- package/dist/new-widgets/templatesDependencies/formMinMaxMixin.js.map +0 -1
- package/dist/new-widgets/templatesDependencies/formMixin.js.map +0 -1
- package/dist/new-widgets/templatesDependencies/formNumberMixin.js.map +0 -1
- package/dist/new-widgets/templatesDependencies/formRadioMixin.js.map +0 -1
- package/dist/new-widgets/templatesDependencies/formStepMixin.js.map +0 -1
- package/dist/new-widgets/templatesDependencies/multipleFormMixin.js.map +0 -1
- package/dist/new-widgets/templatesDependencies/multipleselectFormMixin.js.map +0 -1
- package/dist/new-widgets/templatesDependencies/patternMixin.js.map +0 -1
- package/dist/new-widgets/templatesDependencies/rangeMixin.js.map +0 -1
- package/dist/new-widgets/templatesDependencies/setMixin.js.map +0 -1
- package/dist/new-widgets/templatesDependencies/valueRichtextMixin.js.map +0 -1
- package/dist/new-widgets/valueTransformationMixins/autolinkMixin.js.map +0 -1
- package/dist/new-widgets/valueTransformationMixins/dateMixin.js.map +0 -1
- package/dist/new-widgets/valueTransformationMixins/dateTimeMixin.js.map +0 -1
- package/dist/new-widgets/valueTransformationMixins/index.js.map +0 -1
- package/dist/new-widgets/valueTransformationMixins/markdownMixin.js.map +0 -1
- package/dist/new-widgets/valueTransformationMixins/multilineMixin.js.map +0 -1
- package/dist/new-widgets/valueTransformationMixins/oembedMixin.js.map +0 -1
- package/dist/solid-template-element.js.map +0 -1
- package/dist/widgets/baseWidget.js.map +0 -1
- package/dist/widgets/widget-factory.js.map +0 -1
package/dist/libs/Sib.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
|
-
|
|
1
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
3
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
3
4
|
import { ComponentFactory } from "./ComponentFactory.js";
|
|
4
5
|
import { defineComponent } from "./helpers.js";
|
|
5
6
|
export class Sib {
|
|
@@ -8,51 +9,36 @@ export class Sib {
|
|
|
8
9
|
const cls = this.toElement(component);
|
|
9
10
|
defineComponent(component.name, cls);
|
|
10
11
|
}
|
|
11
|
-
|
|
12
12
|
static toElement(component) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return _temp = class extends HTMLElement {
|
|
13
|
+
return class extends HTMLElement {
|
|
16
14
|
constructor() {
|
|
17
15
|
super();
|
|
18
|
-
|
|
19
16
|
_defineProperty(this, "_component", null);
|
|
20
|
-
|
|
21
17
|
this.component = new component(this);
|
|
22
18
|
this.component.created();
|
|
23
19
|
}
|
|
24
|
-
|
|
25
20
|
get component() {
|
|
26
21
|
if (this._component === null) {
|
|
27
22
|
throw new Error('No component found');
|
|
28
23
|
}
|
|
29
|
-
|
|
30
24
|
return this._component;
|
|
31
25
|
}
|
|
32
|
-
|
|
33
26
|
set component(component) {
|
|
34
27
|
this._component = component;
|
|
35
28
|
}
|
|
36
|
-
|
|
37
29
|
static get observedAttributes() {
|
|
38
30
|
return component.observedAttributes;
|
|
39
31
|
}
|
|
40
|
-
|
|
41
32
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
42
|
-
const attr = name.replace(/([a-z0-9])-([a-z0-9])/g, (_c, p1, p2) =>
|
|
33
|
+
const attr = name.replace(/([a-z0-9])-([a-z0-9])/g, (_c, p1, p2) => `${p1}${p2.toUpperCase()}`);
|
|
43
34
|
this.component.attributesCallback(attr, newValue, oldValue);
|
|
44
35
|
}
|
|
45
|
-
|
|
46
36
|
connectedCallback() {
|
|
47
37
|
this.component.attached();
|
|
48
38
|
}
|
|
49
|
-
|
|
50
39
|
disconnectedCallback() {
|
|
51
40
|
this.component.detached();
|
|
52
41
|
}
|
|
53
|
-
|
|
54
|
-
}, _temp;
|
|
42
|
+
};
|
|
55
43
|
}
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
//# sourceMappingURL=Sib.js.map
|
|
44
|
+
}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { parseFieldsString, findClosingBracketMatchIndex, compare, uniqID } from "./helpers.js";
|
|
2
|
+
/**
|
|
3
|
+
* Check if the field is a set
|
|
4
|
+
* @param field - field to test
|
|
5
|
+
* @param fields - list of fields
|
|
6
|
+
* @returns true if the field is a set, false otherwise
|
|
7
|
+
*/
|
|
8
|
+
const isSet = (field, fields) => {
|
|
9
|
+
if (!fields) return false;
|
|
10
|
+
let foundSets = fields.match(getSetRegexp(field));
|
|
11
|
+
return foundSets ? foundSets.length > 0 : false;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Get the list of fields in the set
|
|
15
|
+
* @param field - set name to get
|
|
16
|
+
* @param fields - list of fields
|
|
17
|
+
* @returns a list of fields in the set
|
|
18
|
+
*/
|
|
19
|
+
const getSet = (field, fields) => {
|
|
20
|
+
const setString = fields.match(getSetRegexp(field));
|
|
21
|
+
if (!setString) return [];
|
|
22
|
+
const firstSetBracket = fields.indexOf(setString[0]) + setString[0].length - 1;
|
|
23
|
+
const lastSetBracket = findClosingBracketMatchIndex(fields, firstSetBracket);
|
|
24
|
+
const set = fields.substring(firstSetBracket + 1, lastSetBracket);
|
|
25
|
+
return parseFieldsString(set);
|
|
26
|
+
};
|
|
27
|
+
const getSetRegexp = field => {
|
|
28
|
+
return new RegExp(`(^|\\,|\\(|\\s)\\s*${field}\\s*\\(`, 'g');
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Check if the field is a special search field
|
|
32
|
+
* @param field - field to test
|
|
33
|
+
* @param searchForm - current search form
|
|
34
|
+
* @returns true if the field is a special search field
|
|
35
|
+
*/
|
|
36
|
+
const isSearchField = (field, searchForm) => {
|
|
37
|
+
return searchForm.hasAttribute('search-' + field);
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Get the fields targetted by a search field
|
|
41
|
+
* @param field - search field to get
|
|
42
|
+
* @param searchForm - current search form
|
|
43
|
+
* @returns a list of fields targetted by the current search field
|
|
44
|
+
*/
|
|
45
|
+
const getSearchField = (field, searchForm) => {
|
|
46
|
+
return parseFieldsString(searchForm.getAttribute('search-' + field));
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Throw or simply return value
|
|
51
|
+
* @param throwOn - should throw on True or False
|
|
52
|
+
* @param ret - value to return
|
|
53
|
+
* @returns
|
|
54
|
+
*/
|
|
55
|
+
const orThrow = (throwOn, ret) => {
|
|
56
|
+
if (throwOn === true && ret) throw true;
|
|
57
|
+
if (throwOn === false && !ret) throw false;
|
|
58
|
+
return ret;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Compare a value to the query
|
|
63
|
+
* @param val - value to compare
|
|
64
|
+
* @param query - object to know how and what value to compare
|
|
65
|
+
* @param throwOn - should function throw error on True or False
|
|
66
|
+
* @returns true if value matches, throw error otherwise
|
|
67
|
+
*/
|
|
68
|
+
const matchValue = async (val, query, throwOn) => {
|
|
69
|
+
const subject = await val;
|
|
70
|
+
if (subject == null && query.value === '') return orThrow(throwOn, true); // filter not set and subject not existing -> ignore filter
|
|
71
|
+
if (subject == null) return orThrow(throwOn, false); // return false; // property does not exist on resource
|
|
72
|
+
if (query.list) {
|
|
73
|
+
// Filter on a container
|
|
74
|
+
if (query.value.length === 0) return orThrow(throwOn, true);
|
|
75
|
+
for (const v of query.value) {
|
|
76
|
+
if (await matchValue(subject, {
|
|
77
|
+
type: query.type,
|
|
78
|
+
value: v,
|
|
79
|
+
list: false
|
|
80
|
+
})) {
|
|
81
|
+
// do not throw here, we need the result
|
|
82
|
+
return orThrow(throwOn, true);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return orThrow(throwOn, false);
|
|
86
|
+
}
|
|
87
|
+
if (subject.isContainer?.()) {
|
|
88
|
+
let ret = Promise.resolve(query.value === ''); // if no query, return a match
|
|
89
|
+
for (const value of subject['ldp:contains']) {
|
|
90
|
+
ret = (await ret) || (await matchValue(value, query)); // do not throw here, we need the result
|
|
91
|
+
if (ret) return orThrow(throwOn, true);
|
|
92
|
+
}
|
|
93
|
+
return orThrow(throwOn, await ret);
|
|
94
|
+
}
|
|
95
|
+
return orThrow(throwOn, compare[query.type](subject, query.value));
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Cache properties of a filter to avoid repeated parsing
|
|
100
|
+
* @param cacheKey - uniq key
|
|
101
|
+
* @param filter - filter to check
|
|
102
|
+
* @param fields - fields attribute of the element
|
|
103
|
+
* @param searchForm - current search form
|
|
104
|
+
*/
|
|
105
|
+
const cacheFieldsProps = (cacheKey, filter, fields, searchForm) => {
|
|
106
|
+
if (!window.cachePropsSearchFilter[cacheKey]) {
|
|
107
|
+
window.cachePropsSearchFilter[cacheKey] = {
|
|
108
|
+
setFields: isSet(filter, fields) ? getSet(filter, fields) : null,
|
|
109
|
+
setSearchFields: isSearchField(filter, searchForm) ? getSearchField(filter, searchForm) : null
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Check if one resource match one filter
|
|
116
|
+
* @param resource - resource to test
|
|
117
|
+
* @param filter - name of the property tested
|
|
118
|
+
* @param query - query object to know how to compare values
|
|
119
|
+
* @param fields - fields attribute of the element
|
|
120
|
+
* @param searchForm - searchForm component
|
|
121
|
+
* @param filterId - uniqId used to fill the cache
|
|
122
|
+
* @param throwOn - should function throw error on True or False
|
|
123
|
+
* @returns return true if the resource matches the filter, throw error otherwise
|
|
124
|
+
*/
|
|
125
|
+
const matchFilter = async (resource, filter, query, fieldsAttr, searchForm, filterId, throwOn) => {
|
|
126
|
+
let fields = null;
|
|
127
|
+
const cacheKey = `${filter}_${filterId}`;
|
|
128
|
+
cacheFieldsProps(cacheKey, filter, fieldsAttr, searchForm);
|
|
129
|
+
if (window.cachePropsSearchFilter[cacheKey].setFields !== null) {
|
|
130
|
+
fields = window.cachePropsSearchFilter[cacheKey].setFields;
|
|
131
|
+
} else if (window.cachePropsSearchFilter[cacheKey].setSearchFields !== null) {
|
|
132
|
+
fields = window.cachePropsSearchFilter[cacheKey].setSearchFields;
|
|
133
|
+
} else {
|
|
134
|
+
// search on 1 field
|
|
135
|
+
return matchValue(resource[filter], query, throwOn);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// search on multiple fields
|
|
139
|
+
try {
|
|
140
|
+
await Promise.all((fields || []).map(field => matchFilter(resource, field, query, fieldsAttr, searchForm, filterId, true // stop searching when 1 filter is true (= OR)
|
|
141
|
+
)));
|
|
142
|
+
} catch (e) {
|
|
143
|
+
return true;
|
|
144
|
+
}
|
|
145
|
+
throw false;
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Check if one resource match all the filters
|
|
150
|
+
* @param resource - resource to test
|
|
151
|
+
* @param filters - current filters
|
|
152
|
+
* @param filterNames - names of the filters
|
|
153
|
+
* @param fields - fields attribute of the element
|
|
154
|
+
* @param searchForm - searchForm component
|
|
155
|
+
* @param filterId - uniqId used to fill the cache
|
|
156
|
+
* @returns true if resource match, false otherwise
|
|
157
|
+
*/
|
|
158
|
+
const matchFilters = async (resource, filters, filterNames, fields, searchForm, filterId) => {
|
|
159
|
+
// return true if all filters values are contained in the corresponding field of the resource
|
|
160
|
+
try {
|
|
161
|
+
await Promise.all(filterNames.map(filter => matchFilter(resource, filter, filters[filter], fields, searchForm, filterId, false // stop searching when 1 filter is false (= AND)
|
|
162
|
+
)));
|
|
163
|
+
} catch (e) {
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
166
|
+
return true;
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Check which resources match the filters
|
|
171
|
+
* @param resources - list of resources to filter
|
|
172
|
+
* @param filters - current filters
|
|
173
|
+
* @param fields - fields attribute of the element
|
|
174
|
+
* @param searchForm - searchForm component
|
|
175
|
+
* @returns resources filtered
|
|
176
|
+
*/
|
|
177
|
+
const searchInResources = async (resources, filters, fields, searchForm) => {
|
|
178
|
+
// Optim: use cache to do these things only once
|
|
179
|
+
const filterNames = Object.keys(filters);
|
|
180
|
+
const filterId = uniqID();
|
|
181
|
+
window.cachePropsSearchFilter = {};
|
|
182
|
+
return Promise.all(resources.map(resource => matchFilters(resource, filters, filterNames, fields, searchForm, filterId)));
|
|
183
|
+
};
|
|
184
|
+
export { searchInResources };
|
package/dist/libs/helpers.js
CHANGED
|
@@ -1,19 +1,16 @@
|
|
|
1
1
|
import Fuse from "../_snowpack/pkg/fusejs.js";
|
|
2
|
-
|
|
3
2
|
function uniqID() {
|
|
4
3
|
return '_' + (Math.random() * Math.pow(36, 20)).toString(36).slice(0, 10);
|
|
5
4
|
}
|
|
6
|
-
|
|
7
5
|
function stringToDom(html) {
|
|
8
6
|
const template = document.createElement('template');
|
|
9
7
|
template.innerHTML = html;
|
|
10
8
|
return template.content;
|
|
11
9
|
}
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
async function evalTemplateString(str) {
|
|
11
|
+
let variables = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
14
12
|
const keys = Object.keys(variables);
|
|
15
13
|
const values = keys.map(key => variables[key]);
|
|
16
|
-
|
|
17
14
|
try {
|
|
18
15
|
const AsyncFunction = Object.getPrototypeOf(async function () {}).constructor;
|
|
19
16
|
const func = AsyncFunction.call(null, ...keys, 'return `' + str + '`');
|
|
@@ -23,10 +20,11 @@ async function evalTemplateString(str, variables = {}) {
|
|
|
23
20
|
throw new SyntaxError('`' + str + '`');
|
|
24
21
|
}
|
|
25
22
|
}
|
|
26
|
-
|
|
27
|
-
function importCSS(...stylesheets) {
|
|
23
|
+
function importCSS() {
|
|
28
24
|
const linksElements = [];
|
|
29
|
-
|
|
25
|
+
for (var _len = arguments.length, stylesheets = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
26
|
+
stylesheets[_key] = arguments[_key];
|
|
27
|
+
}
|
|
30
28
|
for (let url of stylesheets) {
|
|
31
29
|
url = relativeSource(url);
|
|
32
30
|
let link = Array.from(document.head.querySelectorAll('link')).find(link => link.href === url);
|
|
@@ -37,12 +35,13 @@ function importCSS(...stylesheets) {
|
|
|
37
35
|
document.head.appendChild(link);
|
|
38
36
|
linksElements.push(link);
|
|
39
37
|
}
|
|
40
|
-
|
|
41
38
|
;
|
|
42
39
|
return linksElements;
|
|
43
40
|
}
|
|
44
|
-
|
|
45
|
-
|
|
41
|
+
function importJS() {
|
|
42
|
+
for (var _len2 = arguments.length, plugins = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
43
|
+
plugins[_key2] = arguments[_key2];
|
|
44
|
+
}
|
|
46
45
|
return plugins.map(url => {
|
|
47
46
|
url = new URL(url, document.baseURI).href;
|
|
48
47
|
let script = Array.from(document.querySelectorAll('script')).find(script => script.src === url);
|
|
@@ -53,7 +52,6 @@ function importJS(...plugins) {
|
|
|
53
52
|
return script;
|
|
54
53
|
});
|
|
55
54
|
}
|
|
56
|
-
|
|
57
55
|
function relativeSource(source) {
|
|
58
56
|
if (!source.match(/^\..?\//)) return new URL(source, document.baseURI).href;
|
|
59
57
|
const e = new Error();
|
|
@@ -65,21 +63,17 @@ function relativeSource(source) {
|
|
|
65
63
|
source = new URL(source, calledFile).href;
|
|
66
64
|
return source;
|
|
67
65
|
}
|
|
68
|
-
|
|
69
66
|
function loadScript(source) {
|
|
70
67
|
source = relativeSource(source);
|
|
71
68
|
return new Promise(resolve => {
|
|
72
69
|
var script = document.createElement('script');
|
|
73
70
|
var head = document.querySelector('head');
|
|
74
71
|
script.async = true;
|
|
75
|
-
|
|
76
72
|
script.onload = () => setTimeout(resolve, 0);
|
|
77
|
-
|
|
78
73
|
script.src = source;
|
|
79
74
|
if (head) head.appendChild(script);
|
|
80
75
|
});
|
|
81
76
|
}
|
|
82
|
-
|
|
83
77
|
function domIsReady() {
|
|
84
78
|
return new Promise(function (resolve) {
|
|
85
79
|
if (document.readyState === 'complete') {
|
|
@@ -89,29 +83,24 @@ function domIsReady() {
|
|
|
89
83
|
}
|
|
90
84
|
});
|
|
91
85
|
}
|
|
92
|
-
|
|
93
86
|
function setDeepProperty(obj, path, value) {
|
|
94
87
|
const name = path.shift();
|
|
95
|
-
|
|
96
88
|
if (name) {
|
|
97
89
|
if (!(name in obj)) obj[name] = {};
|
|
98
90
|
if (path.length) setDeepProperty(obj[name], path, value);else obj[name] = value;
|
|
99
91
|
}
|
|
100
92
|
}
|
|
101
|
-
|
|
102
93
|
function parseFieldsString(fields) {
|
|
103
|
-
let fieldsArray;
|
|
94
|
+
let fieldsArray;
|
|
104
95
|
|
|
96
|
+
// remove all sets from fields
|
|
105
97
|
while (fields.indexOf('(') > 0) {
|
|
106
98
|
let firstBracket = fields.indexOf('(');
|
|
107
99
|
let noset = fields.substring(firstBracket, findClosingBracketMatchIndex(fields, firstBracket) + 1);
|
|
108
100
|
fields = fields.replace(noset, '');
|
|
109
101
|
}
|
|
110
|
-
|
|
111
102
|
const re = /((^\s*|,)\s*)(("(\\"|[^"])*")|('(\\'|[^'])*')|[^,]*)/gm; // match , not inside quotes
|
|
112
|
-
|
|
113
103
|
fieldsArray = fields.match(re) || []; // separate fields
|
|
114
|
-
|
|
115
104
|
if (!fieldsArray) return [];
|
|
116
105
|
return fieldsArray.map(a => a.replace(/^[\s,]+/, '')); // remove commas and spaces
|
|
117
106
|
}
|
|
@@ -119,30 +108,25 @@ function parseFieldsString(fields) {
|
|
|
119
108
|
function findClosingBracketMatchIndex(str, pos) {
|
|
120
109
|
if (str[pos] != '(') throw new Error("No '(' at index " + pos);
|
|
121
110
|
let depth = 1;
|
|
122
|
-
|
|
123
111
|
for (let i = pos + 1; i < str.length; i++) {
|
|
124
112
|
switch (str[i]) {
|
|
125
113
|
case '(':
|
|
126
114
|
depth++;
|
|
127
115
|
break;
|
|
128
|
-
|
|
129
116
|
case ')':
|
|
130
117
|
if (--depth == 0) return i;
|
|
131
118
|
break;
|
|
132
119
|
}
|
|
133
120
|
}
|
|
134
|
-
|
|
135
121
|
return -1;
|
|
136
122
|
}
|
|
137
|
-
|
|
138
123
|
function defineComponent(tagName, componentClass) {
|
|
139
124
|
if (!customElements.get(tagName)) {
|
|
140
125
|
customElements.define(tagName, componentClass);
|
|
141
126
|
} else {
|
|
142
|
-
console.warn(
|
|
127
|
+
console.warn(`Warning: the component "${tagName}" has already been loaded in another version of sib-core.`);
|
|
143
128
|
}
|
|
144
129
|
}
|
|
145
|
-
|
|
146
130
|
function fuzzyCompare(subject, search) {
|
|
147
131
|
const fuse = new Fuse([subject], {
|
|
148
132
|
shouldSort: false,
|
|
@@ -150,31 +134,25 @@ function fuzzyCompare(subject, search) {
|
|
|
150
134
|
}).search(search);
|
|
151
135
|
return fuse.length > 0;
|
|
152
136
|
}
|
|
153
|
-
|
|
154
137
|
const compare = {
|
|
155
138
|
string(subject, query) {
|
|
156
139
|
if (query === '') return true;
|
|
157
140
|
if (subject.toString().toLowerCase().includes(String(query).toLowerCase())) return true;
|
|
158
141
|
return fuzzyCompare(subject, query);
|
|
159
142
|
},
|
|
160
|
-
|
|
161
143
|
boolean(subject, query) {
|
|
162
144
|
if (!query) return true;
|
|
163
145
|
return subject;
|
|
164
146
|
},
|
|
165
|
-
|
|
166
147
|
number(subject, query) {
|
|
167
148
|
return subject === query;
|
|
168
149
|
},
|
|
169
|
-
|
|
170
150
|
list(subject, list) {
|
|
171
151
|
return list.includes(subject);
|
|
172
152
|
},
|
|
173
|
-
|
|
174
153
|
range(subject, range) {
|
|
175
154
|
return (range[0] == null || range[0] === '' || subject >= range[0]) && (range[1] == null || range[1] === '' || subject <= range[1]);
|
|
176
155
|
},
|
|
177
|
-
|
|
178
156
|
resource(subject, query) {
|
|
179
157
|
// dropdown default ' - ' option return an empty string
|
|
180
158
|
if (query === '') return true;
|
|
@@ -182,38 +160,32 @@ const compare = {
|
|
|
182
160
|
const ret = subject['@id'] === query['@id'];
|
|
183
161
|
return ret;
|
|
184
162
|
}
|
|
185
|
-
|
|
186
163
|
};
|
|
187
|
-
|
|
188
164
|
function transformArrayToContainer(resource) {
|
|
189
|
-
const newValue = {
|
|
165
|
+
const newValue = {
|
|
166
|
+
...resource
|
|
190
167
|
};
|
|
191
|
-
|
|
192
168
|
for (let predicate of Object.keys(newValue)) {
|
|
193
169
|
// iterate over all properties
|
|
194
170
|
const predicateValue = newValue[predicate];
|
|
195
171
|
if (!predicateValue || typeof predicateValue !== 'object') continue; // undefined or literal, do nothing
|
|
196
|
-
// check all keys of nested resource
|
|
197
172
|
|
|
173
|
+
// check all keys of nested resource
|
|
198
174
|
if (!Array.isArray(predicateValue) && predicateValue['@id']) {
|
|
199
175
|
newValue[predicate] = transformArrayToContainer(resource[predicate]);
|
|
200
|
-
}
|
|
201
|
-
|
|
176
|
+
}
|
|
202
177
|
|
|
178
|
+
// for arrays
|
|
203
179
|
if (Array.isArray(predicateValue)) {
|
|
204
180
|
newValue[predicate] = {
|
|
205
181
|
'ldp:contains': [...predicateValue]
|
|
206
182
|
}; // transform to container
|
|
207
|
-
|
|
208
183
|
newValue[predicate]['ldp:contains'].forEach((childPredicate, index) => {
|
|
209
184
|
// and check all nested resources
|
|
210
185
|
newValue[predicate]['ldp:contains'][index] = transformArrayToContainer(childPredicate);
|
|
211
186
|
});
|
|
212
187
|
}
|
|
213
188
|
}
|
|
214
|
-
|
|
215
189
|
return newValue;
|
|
216
190
|
}
|
|
217
|
-
|
|
218
|
-
export { uniqID, stringToDom, evalTemplateString, importCSS, importJS, loadScript, domIsReady, setDeepProperty, parseFieldsString, findClosingBracketMatchIndex, defineComponent, fuzzyCompare, compare, transformArrayToContainer };
|
|
219
|
-
//# sourceMappingURL=helpers.js.map
|
|
191
|
+
export { uniqID, stringToDom, evalTemplateString, importCSS, importJS, loadScript, domIsReady, setDeepProperty, parseFieldsString, findClosingBracketMatchIndex, defineComponent, fuzzyCompare, compare, transformArrayToContainer };
|
package/dist/libs/interfaces.js
CHANGED
package/dist/libs/lit-helpers.js
CHANGED
|
@@ -6,13 +6,10 @@ import { html, directive, noChange } from '../_snowpack/pkg/lit-html.js';
|
|
|
6
6
|
const prevCache = new WeakMap();
|
|
7
7
|
export const spread = directive(spreadData => part => {
|
|
8
8
|
const prevData = prevCache.get(part);
|
|
9
|
-
|
|
10
9
|
if (prevData === spreadData) {
|
|
11
10
|
return;
|
|
12
11
|
}
|
|
13
|
-
|
|
14
12
|
prevCache.set(part, spreadData);
|
|
15
|
-
|
|
16
13
|
if (spreadData) {
|
|
17
14
|
for (const key in spreadData) {
|
|
18
15
|
const value = spreadData[key];
|
|
@@ -21,41 +18,32 @@ export const spread = directive(spreadData => part => {
|
|
|
21
18
|
const {
|
|
22
19
|
element
|
|
23
20
|
} = part.committer;
|
|
24
|
-
|
|
25
21
|
if (prefix === '@') {
|
|
26
22
|
const prevHandler = prevData && prevData[key];
|
|
27
|
-
|
|
28
23
|
if (!prevHandler || prevHandler !== value) {
|
|
29
24
|
const name = key.slice(1);
|
|
30
25
|
if (prevHandler) element.removeEventListener(name, prevHandler);
|
|
31
26
|
element.addEventListener(name, value);
|
|
32
27
|
}
|
|
33
|
-
|
|
34
28
|
continue;
|
|
35
29
|
}
|
|
36
|
-
|
|
37
30
|
if (prefix === '.') {
|
|
38
31
|
if (!prevData || prevData[key] !== value) {
|
|
39
32
|
element[key.slice(1)] = value;
|
|
40
33
|
}
|
|
41
|
-
|
|
42
34
|
continue;
|
|
43
35
|
}
|
|
44
|
-
|
|
45
36
|
if (prefix === '?') {
|
|
46
37
|
if (!prevData || prevData[key] !== value) {
|
|
47
38
|
const name = key.slice(1);
|
|
48
|
-
|
|
49
39
|
if (value) {
|
|
50
40
|
element.setAttribute(name, '');
|
|
51
41
|
} else {
|
|
52
42
|
element.removeAttribute(name);
|
|
53
43
|
}
|
|
54
44
|
}
|
|
55
|
-
|
|
56
45
|
continue;
|
|
57
46
|
}
|
|
58
|
-
|
|
59
47
|
if (!prevData || prevData[key] !== value) {
|
|
60
48
|
if (value != null) {
|
|
61
49
|
element.setAttribute(key, String(value));
|
|
@@ -65,7 +53,6 @@ export const spread = directive(spreadData => part => {
|
|
|
65
53
|
}
|
|
66
54
|
}
|
|
67
55
|
}
|
|
68
|
-
|
|
69
56
|
if (prevData) {
|
|
70
57
|
for (const key in prevData) {
|
|
71
58
|
if (!spreadData || !(key in spreadData)) {
|
|
@@ -73,32 +60,26 @@ export const spread = directive(spreadData => part => {
|
|
|
73
60
|
const {
|
|
74
61
|
element
|
|
75
62
|
} = part.committer;
|
|
76
|
-
|
|
77
63
|
if (prefix === '@') {
|
|
78
64
|
element.removeEventListener(key.slice(1), prevData[key]);
|
|
79
65
|
continue;
|
|
80
66
|
}
|
|
81
|
-
|
|
82
67
|
if (prefix === '.') {
|
|
83
68
|
element[key.slice(1)] = undefined;
|
|
84
69
|
continue;
|
|
85
70
|
}
|
|
86
|
-
|
|
87
71
|
if (prefix === '?') {
|
|
88
72
|
element.removeAttribute(key.slice(1));
|
|
89
73
|
continue;
|
|
90
74
|
}
|
|
91
|
-
|
|
92
75
|
element.removeAttribute(key);
|
|
93
76
|
}
|
|
94
77
|
}
|
|
95
78
|
}
|
|
96
79
|
});
|
|
97
|
-
|
|
98
80
|
function dropIndices(arr, needlessValues) {
|
|
99
81
|
const newArr = [];
|
|
100
82
|
let j = 0;
|
|
101
|
-
|
|
102
83
|
for (let i = 0, n = arr.length; i < n; ++i) {
|
|
103
84
|
if (needlessValues[j].index === i) {
|
|
104
85
|
++j;
|
|
@@ -106,42 +87,38 @@ function dropIndices(arr, needlessValues) {
|
|
|
106
87
|
newArr.push(arr[i]);
|
|
107
88
|
}
|
|
108
89
|
}
|
|
109
|
-
|
|
110
90
|
return newArr;
|
|
111
91
|
}
|
|
92
|
+
const templateStringsCache = new WeakMap();
|
|
112
93
|
|
|
113
|
-
|
|
94
|
+
// Convert dynamic tags to template strings
|
|
114
95
|
// example: <${'div'}>${'this is example'}</${'div'}> => <div>${'this is example'}</div>
|
|
115
|
-
|
|
116
|
-
export function preHTML(strings, ...values) {
|
|
96
|
+
export function preHTML(strings) {
|
|
117
97
|
// check cache !important return equal link at first argument
|
|
118
98
|
let cachedStrings = templateStringsCache.get(strings);
|
|
119
|
-
|
|
99
|
+
for (var _len = arguments.length, values = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
100
|
+
values[_key - 1] = arguments[_key];
|
|
101
|
+
}
|
|
120
102
|
if (cachedStrings) {
|
|
121
103
|
for (let i = 0, n = cachedStrings.length; i < n; ++i) {
|
|
122
104
|
const needlessValues = cachedStrings[i].needlessValues;
|
|
123
105
|
let isSame = true;
|
|
124
|
-
|
|
125
106
|
for (let ii = 0, nn = needlessValues.length; ii < nn; ++ii) {
|
|
126
107
|
if (values[needlessValues[ii].index] !== needlessValues[ii].value) {
|
|
127
108
|
isSame = false;
|
|
128
109
|
break;
|
|
129
110
|
}
|
|
130
111
|
}
|
|
131
|
-
|
|
132
112
|
if (isSame) {
|
|
133
113
|
return html(cachedStrings[i].strings, ...dropIndices(values, needlessValues));
|
|
134
114
|
}
|
|
135
115
|
}
|
|
136
116
|
}
|
|
137
|
-
|
|
138
117
|
const needlessValues = [];
|
|
139
118
|
const newStrings = [];
|
|
140
119
|
let str;
|
|
141
|
-
|
|
142
120
|
for (let i = 0, n = strings.length; i < n; ++i) {
|
|
143
121
|
str = strings[i];
|
|
144
|
-
|
|
145
122
|
while (str[str.length - 1] === '<' // open tag
|
|
146
123
|
|| str[str.length - 2] === '<' && str[str.length - 1] === '/' // close tag
|
|
147
124
|
) {
|
|
@@ -151,19 +128,15 @@ export function preHTML(strings, ...values) {
|
|
|
151
128
|
});
|
|
152
129
|
str += values[i] + strings[++i];
|
|
153
130
|
}
|
|
154
|
-
|
|
155
131
|
newStrings.push(str);
|
|
156
132
|
}
|
|
157
|
-
|
|
158
133
|
if (!cachedStrings) {
|
|
159
134
|
cachedStrings = [];
|
|
160
135
|
templateStringsCache.set(strings, cachedStrings);
|
|
161
136
|
}
|
|
162
|
-
|
|
163
137
|
cachedStrings.push({
|
|
164
138
|
strings: newStrings,
|
|
165
139
|
needlessValues
|
|
166
140
|
});
|
|
167
141
|
return html(newStrings, ...dropIndices(values, needlessValues));
|
|
168
|
-
}
|
|
169
|
-
//# sourceMappingURL=lit-helpers.js.map
|
|
142
|
+
}
|
package/dist/libs/polyfills.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
if (!('flat' in Array.prototype)) {
|
|
3
3
|
Object.defineProperty(Array.prototype, 'flat', {
|
|
4
4
|
configurable: true,
|
|
5
|
-
value: function flat(
|
|
5
|
+
value: function flat() {
|
|
6
|
+
let depth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
6
7
|
depth = isNaN(depth) ? 1 : Number(depth);
|
|
7
8
|
if (depth === 0) return Array.prototype.slice.call(this);
|
|
8
9
|
return Array.prototype.reduce.call(this, function (acc, cur) {
|
|
@@ -11,30 +12,26 @@ if (!('flat' in Array.prototype)) {
|
|
|
11
12
|
} else {
|
|
12
13
|
acc.push(cur);
|
|
13
14
|
}
|
|
14
|
-
|
|
15
15
|
return acc;
|
|
16
16
|
}, []);
|
|
17
17
|
},
|
|
18
18
|
writable: true
|
|
19
19
|
});
|
|
20
|
-
}
|
|
21
|
-
|
|
20
|
+
}
|
|
22
21
|
|
|
22
|
+
// Element.prototype.toggleAttribute
|
|
23
23
|
if (!Element.prototype.toggleAttribute) {
|
|
24
|
-
Element.prototype.toggleAttribute = function (name
|
|
24
|
+
Element.prototype.toggleAttribute = function (name) {
|
|
25
|
+
let force = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
|
|
25
26
|
if (force !== undefined) force = !!force;
|
|
26
|
-
|
|
27
27
|
if (this.hasAttribute(name)) {
|
|
28
28
|
if (force) return true;
|
|
29
29
|
this.removeAttribute(name);
|
|
30
30
|
return false;
|
|
31
31
|
}
|
|
32
|
-
|
|
33
32
|
if (force === false) return false;
|
|
34
33
|
this.setAttribute(name, '');
|
|
35
34
|
return true;
|
|
36
35
|
};
|
|
37
36
|
}
|
|
38
|
-
|
|
39
|
-
export {};
|
|
40
|
-
//# sourceMappingURL=polyfills.js.map
|
|
37
|
+
export {};
|