@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/mixins/listMixin.js
CHANGED
|
@@ -1,25 +1,3 @@
|
|
|
1
|
-
function _templateObject2() {
|
|
2
|
-
const data = _taggedTemplateLiteral([""]);
|
|
3
|
-
|
|
4
|
-
_templateObject2 = function () {
|
|
5
|
-
return data;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
return data;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
function _templateObject() {
|
|
12
|
-
const data = _taggedTemplateLiteral(["\n <", " value=", "></", ">\n "]);
|
|
13
|
-
|
|
14
|
-
_templateObject = function () {
|
|
15
|
-
return data;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
return data;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
22
|
-
|
|
23
1
|
import { html, render } from '../_snowpack/pkg/lit-html.js';
|
|
24
2
|
import { preHTML } from '../libs/lit-helpers.js';
|
|
25
3
|
import { ifDefined } from '../_snowpack/pkg/lit-html/directives/if-defined.js';
|
|
@@ -42,20 +20,16 @@ const ListMixin = {
|
|
|
42
20
|
// Rendering to execute after all the processors have been executed
|
|
43
21
|
renderCallbacks: []
|
|
44
22
|
},
|
|
45
|
-
|
|
46
23
|
created() {
|
|
47
24
|
this.listPostProcessors = [];
|
|
48
25
|
this.renderCallbacks = [];
|
|
49
26
|
},
|
|
50
|
-
|
|
51
27
|
appendSingleElt(parent) {
|
|
52
28
|
this.appendChildElt(this.resource['@id'], parent);
|
|
53
29
|
},
|
|
54
|
-
|
|
55
30
|
setElementAttribute(attr) {
|
|
56
31
|
const containerAttribute = "solid-container";
|
|
57
32
|
const resourceAttribute = "solid-resource";
|
|
58
|
-
|
|
59
33
|
if (attr === "resource") {
|
|
60
34
|
this.element.removeAttribute(containerAttribute);
|
|
61
35
|
this.element.setAttribute(resourceAttribute, "");
|
|
@@ -64,32 +38,32 @@ const ListMixin = {
|
|
|
64
38
|
this.element.setAttribute(containerAttribute, "");
|
|
65
39
|
}
|
|
66
40
|
},
|
|
67
|
-
|
|
68
41
|
async populate() {
|
|
69
42
|
const div = this.div;
|
|
70
|
-
if (!this.resource) return;
|
|
43
|
+
if (!this.resource) return;
|
|
71
44
|
|
|
72
|
-
|
|
45
|
+
// Not a container but a single resource
|
|
46
|
+
if (!this.resource.isContainer?.()) {
|
|
73
47
|
this.setElementAttribute("resource");
|
|
74
48
|
this.appendSingleElt(div);
|
|
75
49
|
return;
|
|
76
50
|
}
|
|
77
|
-
|
|
78
51
|
this.setElementAttribute("container");
|
|
79
52
|
const listPostProcessors = [...this.listPostProcessors];
|
|
80
53
|
this.renderCallbacks = [];
|
|
81
54
|
listPostProcessors.push(this.renderDOM.bind(this));
|
|
82
|
-
listPostProcessors.push(this.handleEmptyWidget.bind(this));
|
|
55
|
+
listPostProcessors.push(this.handleEmptyWidget.bind(this));
|
|
83
56
|
|
|
57
|
+
// Execute the first post-processor of the list
|
|
84
58
|
const nextProcessor = listPostProcessors.shift();
|
|
85
|
-
await nextProcessor(this.resource['ldp:contains'], listPostProcessors, div, this.dataSrc);
|
|
59
|
+
await nextProcessor(this.resource['ldp:contains'], listPostProcessors, div, this.dataSrc);
|
|
86
60
|
|
|
61
|
+
// Execute the render callbacks
|
|
87
62
|
for (const renderCallback of this.renderCallbacks) {
|
|
88
63
|
// Render the template in the given parent element
|
|
89
64
|
render(renderCallback.template, renderCallback.parent);
|
|
90
65
|
}
|
|
91
66
|
},
|
|
92
|
-
|
|
93
67
|
/**
|
|
94
68
|
* Render resources in the DOM
|
|
95
69
|
* @param resources
|
|
@@ -103,11 +77,9 @@ const ListMixin = {
|
|
|
103
77
|
if (!resource) continue;
|
|
104
78
|
this.appendChildElt(resource['@id'], div);
|
|
105
79
|
}
|
|
106
|
-
|
|
107
80
|
const nextProcessor = listPostProcessors.shift();
|
|
108
81
|
if (nextProcessor) await nextProcessor(resources, listPostProcessors, div, context);
|
|
109
82
|
},
|
|
110
|
-
|
|
111
83
|
/**
|
|
112
84
|
* Show empty widget if no resources in the list
|
|
113
85
|
* @param resources
|
|
@@ -117,20 +89,17 @@ const ListMixin = {
|
|
|
117
89
|
*/
|
|
118
90
|
async handleEmptyWidget(resources, listPostProcessors, div, context) {
|
|
119
91
|
if (this.emptyWidget) {
|
|
120
|
-
const emptyWidgetTemplate = preHTML
|
|
121
|
-
|
|
92
|
+
const emptyWidgetTemplate = preHTML`
|
|
93
|
+
<${this.emptyWidget} value=${ifDefined(this.emptyValue)}></${this.emptyWidget}>
|
|
94
|
+
`;
|
|
122
95
|
if (!this.emptyWrapper) {
|
|
123
96
|
this.emptyWrapper = document.createElement('span');
|
|
124
97
|
this.element.appendChild(this.emptyWrapper);
|
|
125
98
|
}
|
|
126
|
-
|
|
127
|
-
render(resources.length > 0 ? html(_templateObject2()) : emptyWidgetTemplate, this.emptyWrapper);
|
|
99
|
+
render(resources.length > 0 ? html`` : emptyWidgetTemplate, this.emptyWrapper);
|
|
128
100
|
}
|
|
129
|
-
|
|
130
101
|
const nextProcessor = listPostProcessors.shift();
|
|
131
102
|
if (nextProcessor) await nextProcessor(resources, listPostProcessors, div, context);
|
|
132
103
|
}
|
|
133
|
-
|
|
134
104
|
};
|
|
135
|
-
export { ListMixin };
|
|
136
|
-
//# sourceMappingURL=listMixin.js.map
|
|
105
|
+
export { ListMixin };
|
package/dist/mixins/nextMixin.js
CHANGED
|
@@ -7,7 +7,6 @@ const NextMixin = {
|
|
|
7
7
|
default: ''
|
|
8
8
|
}
|
|
9
9
|
},
|
|
10
|
-
|
|
11
10
|
// Here "even.target" points to the content of the widgets of the children of solid-display
|
|
12
11
|
goToNext(resource) {
|
|
13
12
|
if (this.next) {
|
|
@@ -20,7 +19,5 @@ const NextMixin = {
|
|
|
20
19
|
}));
|
|
21
20
|
}
|
|
22
21
|
}
|
|
23
|
-
|
|
24
22
|
};
|
|
25
|
-
export { NextMixin };
|
|
26
|
-
//# sourceMappingURL=nextMixin.js.map
|
|
23
|
+
export { NextMixin };
|
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
function _templateObject() {
|
|
2
|
-
const data = _taggedTemplateLiteral(["\n <button\n data-id=\"prev\"\n ?disabled=", "\n @click=", "\n >\u2190</button>\n <button\n data-id=\"next\"\n ?disabled=", "\n @click=", "\n >\u2192</button>\n <span>\n <span data-id=\"current\">", "</span> / <span data-id=\"count\">", "</span>\n </span>\n "]);
|
|
3
|
-
|
|
4
|
-
_templateObject = function () {
|
|
5
|
-
return data;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
return data;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
12
|
-
|
|
13
1
|
import { html } from "../_snowpack/pkg/lit-html.js";
|
|
14
2
|
const PaginateMixin = {
|
|
15
3
|
name: 'paginate-mixin',
|
|
@@ -27,15 +15,12 @@ const PaginateMixin = {
|
|
|
27
15
|
initialState: {
|
|
28
16
|
currentPage: []
|
|
29
17
|
},
|
|
30
|
-
|
|
31
18
|
created() {
|
|
32
19
|
this.currentPage = [];
|
|
33
20
|
},
|
|
34
|
-
|
|
35
21
|
attached() {
|
|
36
22
|
this.listPostProcessors.push(this.paginateCallback.bind(this));
|
|
37
23
|
},
|
|
38
|
-
|
|
39
24
|
async paginateCallback(resources, listPostProcessors, div, context) {
|
|
40
25
|
if (this.paginateBy > 0) {
|
|
41
26
|
if (!this.currentPage[context]) this.currentPage[context] = 1;
|
|
@@ -47,37 +32,30 @@ const PaginateMixin = {
|
|
|
47
32
|
const firstElementIndex = (this.getCurrentPage(context) - 1) * this.paginateBy;
|
|
48
33
|
resources = resources.slice(firstElementIndex, firstElementIndex + this.paginateBy);
|
|
49
34
|
}
|
|
50
|
-
|
|
51
35
|
const nextProcessor = listPostProcessors.shift();
|
|
52
36
|
if (nextProcessor) await nextProcessor(resources, listPostProcessors, div, context);
|
|
53
37
|
},
|
|
54
|
-
|
|
55
38
|
getNavElement(div) {
|
|
56
39
|
const insertNode = div.parentNode || div;
|
|
57
|
-
return insertNode.querySelector(
|
|
40
|
+
return insertNode.querySelector(`nav[data-id="nav"]`);
|
|
58
41
|
},
|
|
59
|
-
|
|
60
42
|
/**
|
|
61
43
|
* Find nav element or create it if not existing
|
|
62
44
|
* @param div - insert nav next to this div
|
|
63
45
|
*/
|
|
64
46
|
initParentPaginationDiv(div) {
|
|
65
47
|
let nav = this.getNavElement(div);
|
|
66
|
-
|
|
67
48
|
if (!nav) {
|
|
68
49
|
nav = document.createElement('nav');
|
|
69
50
|
nav.setAttribute('data-id', 'nav');
|
|
70
51
|
const insertNode = div.parentNode || div;
|
|
71
52
|
insertNode.appendChild(nav);
|
|
72
53
|
}
|
|
73
|
-
|
|
74
54
|
return nav;
|
|
75
55
|
},
|
|
76
|
-
|
|
77
56
|
getCurrentPage(context) {
|
|
78
57
|
return this.currentPage[context];
|
|
79
58
|
},
|
|
80
|
-
|
|
81
59
|
setCurrentPage(page, context, pageCount) {
|
|
82
60
|
if (page < 1) page = !this.shouldLoop() ? 1 : pageCount;
|
|
83
61
|
if (page > pageCount) page = !this.shouldLoop() ? pageCount : 1;
|
|
@@ -85,15 +63,12 @@ const PaginateMixin = {
|
|
|
85
63
|
this.empty();
|
|
86
64
|
this.populate();
|
|
87
65
|
},
|
|
88
|
-
|
|
89
66
|
getPageCount(size) {
|
|
90
67
|
return Math.max(1, Math.ceil(size / this.paginateBy));
|
|
91
68
|
},
|
|
92
|
-
|
|
93
69
|
shouldLoop() {
|
|
94
70
|
return this.paginateLoop !== null;
|
|
95
71
|
},
|
|
96
|
-
|
|
97
72
|
/**
|
|
98
73
|
* Create pagination template
|
|
99
74
|
* @param pageCount
|
|
@@ -102,9 +77,21 @@ const PaginateMixin = {
|
|
|
102
77
|
renderPaginationNav(pageCount, context, div) {
|
|
103
78
|
this.getNavElement(div).toggleAttribute('hidden', pageCount <= 1);
|
|
104
79
|
const currentPage = this.getCurrentPage(context);
|
|
105
|
-
return html
|
|
80
|
+
return html`
|
|
81
|
+
<button
|
|
82
|
+
data-id="prev"
|
|
83
|
+
?disabled=${!this.shouldLoop() && currentPage <= 1}
|
|
84
|
+
@click=${() => this.setCurrentPage(currentPage - 1, context, pageCount)}
|
|
85
|
+
>←</button>
|
|
86
|
+
<button
|
|
87
|
+
data-id="next"
|
|
88
|
+
?disabled=${!this.shouldLoop() && currentPage >= pageCount}
|
|
89
|
+
@click=${() => this.setCurrentPage(currentPage + 1, context, pageCount)}
|
|
90
|
+
>→</button>
|
|
91
|
+
<span>
|
|
92
|
+
<span data-id="current">${currentPage}</span> / <span data-id="count">${String(pageCount)}</span>
|
|
93
|
+
</span>
|
|
94
|
+
`;
|
|
106
95
|
}
|
|
107
|
-
|
|
108
96
|
};
|
|
109
|
-
export { PaginateMixin };
|
|
110
|
-
//# sourceMappingURL=paginateMixin.js.map
|
|
97
|
+
export { PaginateMixin };
|
|
@@ -1,34 +1,26 @@
|
|
|
1
1
|
const RequiredMixin = {
|
|
2
2
|
name: 'required-mixin',
|
|
3
3
|
use: [],
|
|
4
|
-
|
|
5
4
|
attached() {
|
|
6
5
|
this.listPostProcessors.push(this.requiredResources.bind(this));
|
|
7
6
|
},
|
|
8
|
-
|
|
9
7
|
async requiredResources(resources, listPostProcessors, div, context) {
|
|
10
8
|
const displays = [];
|
|
11
9
|
const requiredFields = Array.from(this.element.attributes).filter(attr => attr.name.startsWith('required-')).map(attr => attr['name'].replace('required-', ''));
|
|
12
|
-
|
|
13
10
|
if (requiredFields.length) {
|
|
14
11
|
for (let resource of resources) {
|
|
15
12
|
let hasProps = true;
|
|
16
|
-
|
|
17
13
|
for (let field of requiredFields) {
|
|
18
14
|
if ((await resource[field]) == null || (await resource[field]) == "") {
|
|
19
15
|
hasProps = false;
|
|
20
16
|
continue;
|
|
21
17
|
}
|
|
22
18
|
}
|
|
23
|
-
|
|
24
19
|
if (hasProps) displays.push(resource);
|
|
25
20
|
}
|
|
26
21
|
}
|
|
27
|
-
|
|
28
22
|
const nextProcessor = listPostProcessors.shift();
|
|
29
23
|
if (nextProcessor) await nextProcessor(requiredFields.length ? displays : resources, listPostProcessors, div, context);
|
|
30
24
|
}
|
|
31
|
-
|
|
32
25
|
};
|
|
33
|
-
export { RequiredMixin };
|
|
34
|
-
//# sourceMappingURL=requiredMixin.js.map
|
|
26
|
+
export { RequiredMixin };
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { html, render } from "../_snowpack/pkg/lit-html.js";
|
|
2
|
+
const ServerPaginationMixin = {
|
|
3
|
+
name: 'server-pagination-mixin',
|
|
4
|
+
use: [],
|
|
5
|
+
attributes: {
|
|
6
|
+
limit: {
|
|
7
|
+
type: Number,
|
|
8
|
+
default: undefined
|
|
9
|
+
},
|
|
10
|
+
offset: {
|
|
11
|
+
type: Number,
|
|
12
|
+
default: undefined
|
|
13
|
+
},
|
|
14
|
+
pageCount: {
|
|
15
|
+
type: Number,
|
|
16
|
+
default: 1000
|
|
17
|
+
},
|
|
18
|
+
pageNumber: {
|
|
19
|
+
type: Number,
|
|
20
|
+
default: 0
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
initialState: {
|
|
24
|
+
currentOffset: []
|
|
25
|
+
},
|
|
26
|
+
attached() {
|
|
27
|
+
if (this.limit) {
|
|
28
|
+
this.setCurrentOffset(this.resourceId, 0);
|
|
29
|
+
const parentDiv = this.initServerPaginationDiv(this.div);
|
|
30
|
+
this.renderCallbacks.push({
|
|
31
|
+
template: this.renderServerPaginationNav(this.resourceId, parentDiv),
|
|
32
|
+
parent: parentDiv
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
getCurrentOffset(resourceId, limit) {
|
|
37
|
+
return this.currentOffset[resourceId + "#p" + limit];
|
|
38
|
+
},
|
|
39
|
+
async setCurrentOffset(resourceId, offset) {
|
|
40
|
+
let index = resourceId + "#p" + this.limit;
|
|
41
|
+
this.currentOffset[index] = this.offset = offset;
|
|
42
|
+
this.pageNumber = Number(this.offset / this.limit);
|
|
43
|
+
this.currentPage[resourceId] = this.pageNumber;
|
|
44
|
+
await this.fetchData(this.dataSrc);
|
|
45
|
+
},
|
|
46
|
+
async decreaseCurrentOffset(resourceId) {
|
|
47
|
+
let index = resourceId + "#p" + this.limit;
|
|
48
|
+
this.currentOffset[index] = this.offset = this.offset - this.limit;
|
|
49
|
+
this.currentPage[index] = this.offset / this.limit;
|
|
50
|
+
this.pageNumber = this.offset / this.limit;
|
|
51
|
+
this.updateNavButtons(resourceId, index, -1);
|
|
52
|
+
await this.fetchData(this.dataSrc);
|
|
53
|
+
},
|
|
54
|
+
async increaseCurrentOffset(resourceId) {
|
|
55
|
+
let index = resourceId + "#p" + this.limit;
|
|
56
|
+
this.currentOffset[index] = this.offset = this.offset + this.limit;
|
|
57
|
+
this.currentPage[index] = this.offset / this.limit;
|
|
58
|
+
this.updateNavButtons(resourceId, index, 1);
|
|
59
|
+
await this.fetchData(this.dataSrc);
|
|
60
|
+
},
|
|
61
|
+
updateNavButtons(resourceId, index, variance) {
|
|
62
|
+
this.element.querySelector("[data-id='prev']").disabled = this.currentOffset[index] <= 0;
|
|
63
|
+
this.element.querySelector("[data-id='next']").disabled = this.currentOffset[index] * this.limit >= this.pageCount;
|
|
64
|
+
this.element.querySelector("[data-id='current']").innerText = this.getCurrentServedPage(resourceId, variance);
|
|
65
|
+
},
|
|
66
|
+
getServerNavElement(div) {
|
|
67
|
+
if (div) {
|
|
68
|
+
const insertNode = div.parentNode || div;
|
|
69
|
+
return insertNode.querySelector(`nav[data-id="nav"]`);
|
|
70
|
+
}
|
|
71
|
+
return null;
|
|
72
|
+
},
|
|
73
|
+
getCurrentServedPage(context, variance) {
|
|
74
|
+
this.currentPage[context] = Number(this.currentPage[context]) + variance;
|
|
75
|
+
return this.currentPage[context];
|
|
76
|
+
},
|
|
77
|
+
/**
|
|
78
|
+
* Find nav element or create it if not existing
|
|
79
|
+
* @param div - insert nav next to this div
|
|
80
|
+
*/
|
|
81
|
+
initServerPaginationDiv(div) {
|
|
82
|
+
let nav = this.getServerNavElement(div);
|
|
83
|
+
if (!nav) {
|
|
84
|
+
nav = document.createElement('nav');
|
|
85
|
+
nav.setAttribute('data-id', 'nav');
|
|
86
|
+
const insertNode = div.parentNode || div;
|
|
87
|
+
insertNode.appendChild(nav);
|
|
88
|
+
}
|
|
89
|
+
return nav;
|
|
90
|
+
},
|
|
91
|
+
/**
|
|
92
|
+
* Create pagination template
|
|
93
|
+
*/
|
|
94
|
+
renderServerPaginationNav(resourceId, div) {
|
|
95
|
+
if (this.limit) {
|
|
96
|
+
const currentOffset = this.getCurrentOffset(resourceId, this.limit);
|
|
97
|
+
var currentPageNumber = this.getCurrentServedPage(resourceId, 1);
|
|
98
|
+
const pageCount = Math.ceil(this.pageCount / this.limit);
|
|
99
|
+
render(html`
|
|
100
|
+
<button
|
|
101
|
+
data-id="prev"
|
|
102
|
+
?disabled=${currentOffset <= 0}
|
|
103
|
+
@click=${() => this.decreaseCurrentOffset(resourceId)}
|
|
104
|
+
>←</button>
|
|
105
|
+
<button
|
|
106
|
+
data-id="next"
|
|
107
|
+
?disabled=${currentOffset >= (pageCount - 1) * this.limit}
|
|
108
|
+
@click=${() => this.increaseCurrentOffset(resourceId)}
|
|
109
|
+
>→</button>
|
|
110
|
+
<span>
|
|
111
|
+
<span data-id="current">
|
|
112
|
+
${currentPageNumber}
|
|
113
|
+
</span> /
|
|
114
|
+
<span data-id="count">
|
|
115
|
+
${this.pageCount}
|
|
116
|
+
</span>
|
|
117
|
+
</span>
|
|
118
|
+
`, div);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
export { ServerPaginationMixin };
|
|
@@ -21,7 +21,6 @@ const SorterMixin = {
|
|
|
21
21
|
sortedBy: {
|
|
22
22
|
type: String,
|
|
23
23
|
default: null,
|
|
24
|
-
|
|
25
24
|
callback(newValue) {
|
|
26
25
|
// if we change search form, re-populate
|
|
27
26
|
if (newValue && this.sortForm && newValue !== this.sortForm.getAttribute('id')) {
|
|
@@ -29,88 +28,76 @@ const SorterMixin = {
|
|
|
29
28
|
this.populate();
|
|
30
29
|
}
|
|
31
30
|
}
|
|
32
|
-
|
|
33
31
|
}
|
|
34
32
|
},
|
|
35
33
|
initialState: {
|
|
36
34
|
randomOrder: null
|
|
37
35
|
},
|
|
38
|
-
|
|
39
36
|
attached() {
|
|
40
37
|
this.listPostProcessors.push(this.orderCallback.bind(this));
|
|
41
38
|
},
|
|
42
|
-
|
|
43
39
|
created() {
|
|
44
40
|
this.randomOrder = [];
|
|
45
41
|
},
|
|
46
|
-
|
|
47
42
|
async sorterList() {
|
|
48
43
|
if (!this.resource) return;
|
|
49
44
|
this.empty();
|
|
50
45
|
await this.populate();
|
|
51
46
|
},
|
|
52
|
-
|
|
53
47
|
linkSorterForm() {
|
|
54
48
|
this.sortForm.addEventListener('formChange', () => {
|
|
55
49
|
this.sorterList();
|
|
56
50
|
});
|
|
57
51
|
},
|
|
58
|
-
|
|
59
52
|
async orderCallback(resources, listPostProcessors, div, context) {
|
|
60
53
|
if (this.orderBy) this.orderAsc = this.orderBy; // retrocompatibility. remove in 0.15
|
|
61
|
-
|
|
62
54
|
let sortingKey = '';
|
|
63
|
-
let orderValueToSort = '';
|
|
55
|
+
let orderValueToSort = '';
|
|
64
56
|
|
|
57
|
+
// if order-asc or order-desc attribute
|
|
65
58
|
if (this.orderAsc || this.orderDesc) {
|
|
66
59
|
sortingKey = this.orderAsc || this.orderDesc;
|
|
67
|
-
}
|
|
60
|
+
}
|
|
61
|
+
// if sorted-by attribute (solid-form-search data used)
|
|
68
62
|
else if (this.sortedBy) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
if (
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
this.linkSorterForm();
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
if (!this.sortForm.component.value.field) {
|
|
79
|
-
console.warn('The attribute field does not exist');
|
|
80
|
-
} else {
|
|
81
|
-
sortingKey = this.sortForm.component.value.field['value'];
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const orderField = this.sortForm.component.value.order;
|
|
85
|
-
orderValueToSort = orderField && orderField.value ? orderField.value : 'asc';
|
|
63
|
+
const sortedBy = this.sortedBy;
|
|
64
|
+
if (sortedBy != null) {
|
|
65
|
+
if (!this.sortForm) {
|
|
66
|
+
this.sortForm = document.getElementById(sortedBy);
|
|
67
|
+
if (!this.sortForm) throw `#${sortedBy} is not in DOM`;
|
|
68
|
+
this.linkSorterForm();
|
|
86
69
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
70
|
+
if (!this.sortForm.component.value.field) {
|
|
71
|
+
console.warn('The attribute field does not exist');
|
|
72
|
+
} else {
|
|
73
|
+
sortingKey = this.sortForm.component.value.field['value'];
|
|
74
|
+
}
|
|
75
|
+
const orderField = this.sortForm.component.value.order;
|
|
76
|
+
orderValueToSort = orderField && orderField.value ? orderField.value : 'asc';
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
// sorting data according to the defined value of sortingKey
|
|
90
80
|
if (sortingKey) {
|
|
91
81
|
let orderToSort = true; // set 'asc' by default
|
|
92
|
-
|
|
93
82
|
if (this.orderDesc || orderValueToSort == "desc") orderToSort = false;
|
|
94
83
|
resources = (await Promise.all(resources.map(async resource => ({
|
|
95
84
|
sortingKey: await resource[sortingKey],
|
|
96
85
|
// fetch sorting value
|
|
97
86
|
proxy: resource // and keep proxy
|
|
98
|
-
|
|
99
87
|
})))).sort(this.sortValuesByKey("sortingKey", orderToSort)) // sort this array
|
|
100
88
|
.map(r => r.proxy); // re-create array
|
|
101
|
-
}
|
|
89
|
+
}
|
|
90
|
+
// if order-by-random attribute
|
|
102
91
|
else if (this.isRandomSorted()) {
|
|
103
|
-
|
|
104
|
-
|
|
92
|
+
resources = this.shuffleResources(resources); // shuffle resources
|
|
93
|
+
}
|
|
105
94
|
|
|
106
95
|
const nextProcessor = listPostProcessors.shift();
|
|
107
96
|
if (nextProcessor) await nextProcessor(resources, listPostProcessors, div, context);
|
|
108
97
|
},
|
|
109
|
-
|
|
110
98
|
isRandomSorted() {
|
|
111
99
|
return this.orderByRandom !== null;
|
|
112
100
|
},
|
|
113
|
-
|
|
114
101
|
sortValuesByKey(key, asc) {
|
|
115
102
|
return function (a, b) {
|
|
116
103
|
if (!a[key]) return 1;
|
|
@@ -122,16 +109,13 @@ const SorterMixin = {
|
|
|
122
109
|
return comparison;
|
|
123
110
|
};
|
|
124
111
|
},
|
|
125
|
-
|
|
126
112
|
shuffleResources(array) {
|
|
127
113
|
let currentIndex = array.length;
|
|
128
114
|
let temporaryValue;
|
|
129
115
|
let randomIndex;
|
|
130
|
-
|
|
131
116
|
if (this.randomOrder.length !== array.length) {
|
|
132
117
|
// if no random order existing
|
|
133
118
|
this.randomOrder = [...Array(array.length).keys()]; // generate array of indexes
|
|
134
|
-
|
|
135
119
|
while (0 !== currentIndex) {
|
|
136
120
|
randomIndex = Math.floor(Math.random() * currentIndex);
|
|
137
121
|
currentIndex -= 1;
|
|
@@ -140,10 +124,8 @@ const SorterMixin = {
|
|
|
140
124
|
this.randomOrder[randomIndex] = temporaryValue;
|
|
141
125
|
}
|
|
142
126
|
}
|
|
143
|
-
|
|
144
127
|
return this.randomOrder.map(i => array[i]); // rebuild array with random order
|
|
145
128
|
}
|
|
146
|
-
|
|
147
129
|
};
|
|
148
|
-
|
|
149
|
-
|
|
130
|
+
|
|
131
|
+
export { SorterMixin };
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { store } from '../libs/store/store.js';
|
|
2
|
+
import { formatAttributesToServerSearchOptions, mergeServerSearchOptions } from '../libs/store/server-search.js';
|
|
2
3
|
import { AttributeBinderMixin } from './attributeBinderMixin.js';
|
|
3
4
|
import { ContextMixin } from './contextMixin.js';
|
|
5
|
+
import { ServerPaginationMixin } from './serverPaginationMixin.js';
|
|
6
|
+
import { formatAttributesToServerPaginationOptions } from '../libs/store/server-pagination.js';
|
|
4
7
|
const StoreMixin = {
|
|
5
8
|
name: 'store-mixin',
|
|
6
|
-
use: [AttributeBinderMixin, ContextMixin],
|
|
9
|
+
use: [AttributeBinderMixin, ContextMixin, ServerPaginationMixin],
|
|
7
10
|
attributes: {
|
|
8
11
|
noRender: {
|
|
9
12
|
type: String,
|
|
@@ -16,7 +19,13 @@ const StoreMixin = {
|
|
|
16
19
|
type: String,
|
|
17
20
|
default: null,
|
|
18
21
|
callback: async function (value) {
|
|
19
|
-
|
|
22
|
+
const filteredOnServer = this.element.attributes['filtered-on']?.value === 'server';
|
|
23
|
+
const limited = this.element.attributes['limit']?.value !== undefined;
|
|
24
|
+
if (this.noRender === null && !filteredOnServer && !limited) {
|
|
25
|
+
await this.fetchData(value);
|
|
26
|
+
} else if (this.noRender === null && !filteredOnServer) {
|
|
27
|
+
this.resourceId = value;
|
|
28
|
+
}
|
|
20
29
|
}
|
|
21
30
|
},
|
|
22
31
|
loaderId: {
|
|
@@ -32,7 +41,6 @@ const StoreMixin = {
|
|
|
32
41
|
resourceId: null,
|
|
33
42
|
subscription: null
|
|
34
43
|
},
|
|
35
|
-
|
|
36
44
|
created() {
|
|
37
45
|
if (this.element.closest('[no-render]')) this.noRender = ''; // if embedded in no-render, apply no-render to himself
|
|
38
46
|
},
|
|
@@ -40,47 +48,50 @@ const StoreMixin = {
|
|
|
40
48
|
detached() {
|
|
41
49
|
if (this.subscription) PubSub.unsubscribe(this.subscription);
|
|
42
50
|
},
|
|
43
|
-
|
|
44
51
|
get resource() {
|
|
45
|
-
|
|
46
|
-
|
|
52
|
+
let id = this.resourceId;
|
|
53
|
+
if (this.limit) {
|
|
54
|
+
id = this.resourceId + "#p" + this.limit + "?o" + this.offset;
|
|
55
|
+
}
|
|
56
|
+
const serverSearch = mergeServerSearchOptions(formatAttributesToServerSearchOptions(this.element.attributes), this.getDynamicServerSearch?.() // from `filterMixin`
|
|
57
|
+
);
|
|
47
58
|
|
|
59
|
+
return id ? store.get(id, serverSearch) : null;
|
|
60
|
+
},
|
|
48
61
|
get loader() {
|
|
49
62
|
return this.loaderId ? document.getElementById(this.loaderId) : null;
|
|
50
63
|
},
|
|
51
|
-
|
|
52
64
|
async fetchData(value) {
|
|
53
65
|
this.empty();
|
|
54
66
|
if (this.subscription) PubSub.unsubscribe(this.subscription);
|
|
55
67
|
if (!value || value == "undefined") return;
|
|
56
68
|
this.resourceId = value;
|
|
57
|
-
|
|
58
69
|
if (this.nestedField) {
|
|
59
70
|
const resource = await store.getData(value, this.context);
|
|
60
71
|
const nestedResource = resource ? await resource[this.nestedField] : null;
|
|
61
72
|
this.resourceId = nestedResource ? nestedResource['@id'] : null;
|
|
62
|
-
if (!this.resourceId) throw
|
|
73
|
+
if (!this.resourceId) throw `Error: the key "${this.nestedField}" does not exist on the resource`;
|
|
63
74
|
}
|
|
64
|
-
|
|
65
75
|
this.updateNavigateSubscription();
|
|
66
76
|
this.subscription = PubSub.subscribe(this.resourceId, this.updateDOM.bind(this));
|
|
67
|
-
|
|
77
|
+
const serverPagination = formatAttributesToServerPaginationOptions(this.element.attributes);
|
|
78
|
+
const dynamicServerSearch = this.getDynamicServerSearch?.(); // from `filterMixin`
|
|
79
|
+
const serverSearch = mergeServerSearchOptions(formatAttributesToServerSearchOptions(this.element.attributes), dynamicServerSearch);
|
|
80
|
+
const forceRefetch = !!dynamicServerSearch;
|
|
81
|
+
await store.getData(this.resourceId, this.context, undefined, undefined, forceRefetch, serverPagination, serverSearch);
|
|
68
82
|
this.updateDOM();
|
|
69
83
|
},
|
|
70
|
-
|
|
71
84
|
toggleLoaderHidden(toggle) {
|
|
72
85
|
if (this.loader) this.loader.toggleAttribute('hidden', toggle);
|
|
73
86
|
},
|
|
74
|
-
|
|
75
87
|
updateNavigateSubscription() {},
|
|
76
|
-
|
|
77
88
|
async updateDOM() {
|
|
78
89
|
this.toggleLoaderHidden(false); // brings a loader out if the attribute is set
|
|
79
|
-
|
|
80
90
|
this.empty();
|
|
81
91
|
await this.replaceAttributesData();
|
|
82
92
|
await this.populate();
|
|
83
|
-
setTimeout(() =>
|
|
93
|
+
setTimeout(() =>
|
|
94
|
+
// Brings the dispatchEvent at the end of the queue
|
|
84
95
|
this.element.dispatchEvent(new CustomEvent('populate', {
|
|
85
96
|
detail: {
|
|
86
97
|
resource: {
|
|
@@ -90,13 +101,9 @@ const StoreMixin = {
|
|
|
90
101
|
})));
|
|
91
102
|
this.toggleLoaderHidden(true);
|
|
92
103
|
},
|
|
93
|
-
|
|
94
104
|
empty() {},
|
|
95
|
-
|
|
96
105
|
update() {
|
|
97
106
|
if (this.noRender === null) this.updateDOM();
|
|
98
107
|
}
|
|
99
|
-
|
|
100
108
|
};
|
|
101
|
-
export { StoreMixin };
|
|
102
|
-
//# sourceMappingURL=storeMixin.js.map
|
|
109
|
+
export { StoreMixin };
|