@startinblox/core 0.17.21-beta.9 → 0.17.22
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/package.json +2 -2
- package/dist/_snowpack/env.js +0 -3
- package/dist/_snowpack/pkg/autolinker.js +0 -4281
- package/dist/_snowpack/pkg/autolinker.js.map +0 -1
- package/dist/_snowpack/pkg/autolinker.js.map.proxy.js +0 -1
- package/dist/_snowpack/pkg/common/_baseUnary-217dffb2.js +0 -377
- package/dist/_snowpack/pkg/common/_baseUnary-217dffb2.js.map +0 -1
- package/dist/_snowpack/pkg/common/_baseUnary-217dffb2.js.map.proxy.js +0 -1
- package/dist/_snowpack/pkg/common/_commonjsHelpers-8c19dec8.js +0 -22
- 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 +0 -216
- 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 +0 -25677
- package/dist/_snowpack/pkg/delta-markdown-for-quill.js.map +0 -1
- package/dist/_snowpack/pkg/delta-markdown-for-quill.js.map.proxy.js +0 -1
- package/dist/_snowpack/pkg/dialog-polyfill.js +0 -859
- package/dist/_snowpack/pkg/dialog-polyfill.js.map +0 -1
- package/dist/_snowpack/pkg/dialog-polyfill.js.map.proxy.js +0 -1
- package/dist/_snowpack/pkg/fusejs.js +0 -1783
- package/dist/_snowpack/pkg/fusejs.js.map +0 -1
- package/dist/_snowpack/pkg/fusejs.js.map.proxy.js +0 -1
- package/dist/_snowpack/pkg/import-map.json +0 -23
- package/dist/_snowpack/pkg/jsonld-context-parser.js +0 -804
- package/dist/_snowpack/pkg/jsonld-context-parser.js.map +0 -1
- package/dist/_snowpack/pkg/jsonld-context-parser.js.map.proxy.js +0 -1
- package/dist/_snowpack/pkg/leaflet/dist/leaflet.css +0 -640
- package/dist/_snowpack/pkg/leaflet/dist/leaflet.css.proxy.js +0 -10
- package/dist/_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.Default.css +0 -60
- package/dist/_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.Default.css.proxy.js +0 -10
- package/dist/_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.css +0 -14
- package/dist/_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.css.proxy.js +0 -10
- package/dist/_snowpack/pkg/lit-html/directives/if-defined.js +0 -40
- package/dist/_snowpack/pkg/lit-html/directives/if-defined.js.map +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 +0 -46
- package/dist/_snowpack/pkg/lit-html/directives/unsafe-html.js.map +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 +0 -88
- package/dist/_snowpack/pkg/lit-html/directives/until.js.map +0 -1
- package/dist/_snowpack/pkg/lit-html/directives/until.js.map.proxy.js +0 -1
- package/dist/_snowpack/pkg/lit-html.js +0 -92
- package/dist/_snowpack/pkg/lit-html.js.map +0 -1
- package/dist/_snowpack/pkg/lit-html.js.map.proxy.js +0 -1
- package/dist/_snowpack/pkg/markdown-it.js +0 -11860
- package/dist/_snowpack/pkg/markdown-it.js.map +0 -1
- package/dist/_snowpack/pkg/markdown-it.js.map.proxy.js +0 -1
- package/dist/_snowpack/pkg/quill/dist/quill.snow.css +0 -945
- package/dist/_snowpack/pkg/quill/dist/quill.snow.css.proxy.js +0 -10
- package/dist/_snowpack/pkg/quill-delta-to-markdown.js +0 -1029
- package/dist/_snowpack/pkg/quill-delta-to-markdown.js.map +0 -1
- package/dist/_snowpack/pkg/quill-delta-to-markdown.js.map.proxy.js +0 -1
- package/dist/_snowpack/pkg/quill.js +0 -13382
- package/dist/_snowpack/pkg/quill.js.map +0 -1
- package/dist/_snowpack/pkg/quill.js.map.proxy.js +0 -1
- package/dist/_snowpack/pkg/slim-select.js +0 -4
- package/dist/_snowpack/pkg/slim-select.js.map +0 -1
- package/dist/_snowpack/pkg/slim-select.js.map.proxy.js +0 -1
- package/dist/_snowpack/pkg/tui-calendar/dist/tui-calendar.css +0 -1164
- package/dist/_snowpack/pkg/tui-calendar/dist/tui-calendar.css.proxy.js +0 -10
- package/dist/_snowpack/pkg/tui-calendar.js +0 -42285
- package/dist/_snowpack/pkg/tui-calendar.js.map +0 -1
- package/dist/_snowpack/pkg/tui-calendar.js.map.proxy.js +0 -1
- package/dist/components/solid-ac-checker.js +0 -51
- package/dist/components/solid-ac-checker.js.map +0 -1
- package/dist/components/solid-calendar.js +0 -87
- package/dist/components/solid-calendar.js.map +0 -1
- package/dist/components/solid-delete.js +0 -111
- package/dist/components/solid-delete.js.map +0 -1
- package/dist/components/solid-display.js +0 -194
- package/dist/components/solid-display.js.map +0 -1
- package/dist/components/solid-form-search.js +0 -226
- package/dist/components/solid-form-search.js.map +0 -1
- package/dist/components/solid-form.js +0 -354
- package/dist/components/solid-form.js.map +0 -1
- package/dist/components/solid-lang.js +0 -46
- package/dist/components/solid-lang.js.map +0 -1
- package/dist/components/solid-map.js +0 -242
- package/dist/components/solid-map.js.map +0 -1
- package/dist/components/solid-table.js +0 -263
- package/dist/components/solid-table.js.map +0 -1
- package/dist/components/solid-widget.js +0 -94
- package/dist/components/solid-widget.js.map +0 -1
- package/dist/import.css +0 -4
- package/dist/index.js +0 -43
- package/dist/index.js.map +0 -1
- package/dist/libs/Component.js +0 -19
- package/dist/libs/Component.js.map +0 -1
- package/dist/libs/ComponentFactory.js +0 -196
- package/dist/libs/ComponentFactory.js.map +0 -1
- package/dist/libs/Compositor.js +0 -103
- package/dist/libs/Compositor.js.map +0 -1
- package/dist/libs/Sib.js +0 -58
- package/dist/libs/Sib.js.map +0 -1
- package/dist/libs/filter.js +0 -214
- package/dist/libs/filter.js.map +0 -1
- package/dist/libs/helpers.js +0 -219
- package/dist/libs/helpers.js.map +0 -1
- package/dist/libs/interfaces.js +0 -6
- package/dist/libs/interfaces.js.map +0 -1
- package/dist/libs/lit-helpers.js +0 -169
- package/dist/libs/lit-helpers.js.map +0 -1
- package/dist/libs/polyfills.js +0 -40
- package/dist/libs/polyfills.js.map +0 -1
- package/dist/libs/store/store.js +0 -863
- package/dist/libs/store/store.js.map +0 -1
- package/dist/locales/en.json +0 -10
- package/dist/locales/en.json.proxy.js +0 -2
- package/dist/locales/fr.json +0 -10
- package/dist/locales/fr.json.proxy.js +0 -2
- package/dist/mixins/attributeBinderMixin.js +0 -124
- package/dist/mixins/attributeBinderMixin.js.map +0 -1
- package/dist/mixins/contextMixin.js +0 -28
- package/dist/mixins/contextMixin.js.map +0 -1
- package/dist/mixins/counterMixin.js +0 -75
- package/dist/mixins/counterMixin.js.map +0 -1
- package/dist/mixins/federationMixin.js +0 -63
- package/dist/mixins/federationMixin.js.map +0 -1
- package/dist/mixins/filterMixin.js +0 -136
- package/dist/mixins/filterMixin.js.map +0 -1
- package/dist/mixins/grouperMixin.js +0 -80
- package/dist/mixins/grouperMixin.js.map +0 -1
- package/dist/mixins/highlighterMixin.js +0 -42
- package/dist/mixins/highlighterMixin.js.map +0 -1
- package/dist/mixins/interfaces.js +0 -8
- package/dist/mixins/interfaces.js.map +0 -1
- package/dist/mixins/listMixin.js +0 -136
- package/dist/mixins/listMixin.js.map +0 -1
- package/dist/mixins/nextMixin.js +0 -26
- package/dist/mixins/nextMixin.js.map +0 -1
- package/dist/mixins/paginateMixin.js +0 -110
- package/dist/mixins/paginateMixin.js.map +0 -1
- package/dist/mixins/requiredMixin.js +0 -34
- package/dist/mixins/requiredMixin.js.map +0 -1
- package/dist/mixins/sorterMixin.js +0 -149
- package/dist/mixins/sorterMixin.js.map +0 -1
- package/dist/mixins/storeMixin.js +0 -102
- package/dist/mixins/storeMixin.js.map +0 -1
- package/dist/mixins/translationMixin.js +0 -68
- package/dist/mixins/translationMixin.js.map +0 -1
- package/dist/mixins/validationMixin.js +0 -113
- package/dist/mixins/validationMixin.js.map +0 -1
- package/dist/mixins/widgetMixin.js +0 -447
- package/dist/mixins/widgetMixin.js.map +0 -1
- package/dist/new-widgets/attributeMixins/actionMixin.js +0 -14
- package/dist/new-widgets/attributeMixins/actionMixin.js.map +0 -1
- package/dist/new-widgets/attributeMixins/blankMixin.js +0 -10
- package/dist/new-widgets/attributeMixins/blankMixin.js.map +0 -1
- package/dist/new-widgets/attributeMixins/booleanMixin.js +0 -10
- package/dist/new-widgets/attributeMixins/booleanMixin.js.map +0 -1
- package/dist/new-widgets/attributeMixins/index.js +0 -20
- package/dist/new-widgets/attributeMixins/index.js.map +0 -1
- package/dist/new-widgets/attributeMixins/mailtoMixin.js +0 -10
- package/dist/new-widgets/attributeMixins/mailtoMixin.js.map +0 -1
- package/dist/new-widgets/attributeMixins/multipleMixin.js +0 -28
- package/dist/new-widgets/attributeMixins/multipleMixin.js.map +0 -1
- package/dist/new-widgets/attributeMixins/numberMixin.js +0 -10
- package/dist/new-widgets/attributeMixins/numberMixin.js.map +0 -1
- package/dist/new-widgets/attributeMixins/placeholderMixin.js +0 -19
- package/dist/new-widgets/attributeMixins/placeholderMixin.js.map +0 -1
- package/dist/new-widgets/attributeMixins/telMixin.js +0 -10
- package/dist/new-widgets/attributeMixins/telMixin.js.map +0 -1
- package/dist/new-widgets/baseWidgetMixin.js +0 -122
- package/dist/new-widgets/baseWidgetMixin.js.map +0 -1
- package/dist/new-widgets/callbackMixins/autocompletionMixin.js +0 -104
- package/dist/new-widgets/callbackMixins/autocompletionMixin.js.map +0 -1
- package/dist/new-widgets/callbackMixins/index.js +0 -8
- package/dist/new-widgets/callbackMixins/index.js.map +0 -1
- package/dist/new-widgets/callbackMixins/richtextMixin.js +0 -42
- package/dist/new-widgets/callbackMixins/richtextMixin.js.map +0 -1
- package/dist/new-widgets/callbackMixins/slimselect.css +0 -2
- package/dist/new-widgets/callbackMixins/slimselect.css.proxy.js +0 -10
- package/dist/new-widgets/new-widget-factory.js +0 -96
- package/dist/new-widgets/new-widget-factory.js.map +0 -1
- package/dist/new-widgets/templateAdditionMixins/addableMixin.js +0 -41
- package/dist/new-widgets/templateAdditionMixins/addableMixin.js.map +0 -1
- package/dist/new-widgets/templateAdditionMixins/index.js +0 -14
- package/dist/new-widgets/templateAdditionMixins/index.js.map +0 -1
- package/dist/new-widgets/templateAdditionMixins/labelLastMixin.js +0 -29
- package/dist/new-widgets/templateAdditionMixins/labelLastMixin.js.map +0 -1
- package/dist/new-widgets/templateAdditionMixins/labelMixin.js +0 -31
- package/dist/new-widgets/templateAdditionMixins/labelMixin.js.map +0 -1
- package/dist/new-widgets/templates/defaultTemplatesDirectory.js +0 -36
- package/dist/new-widgets/templates/defaultTemplatesDirectory.js.map +0 -1
- package/dist/new-widgets/templates/displayTemplatesDirectory.js +0 -90
- package/dist/new-widgets/templates/displayTemplatesDirectory.js.map +0 -1
- package/dist/new-widgets/templates/formTemplatesDirectory.js +0 -397
- package/dist/new-widgets/templates/formTemplatesDirectory.js.map +0 -1
- package/dist/new-widgets/templates/groupTemplatesDirectory.js +0 -21
- package/dist/new-widgets/templates/groupTemplatesDirectory.js.map +0 -1
- package/dist/new-widgets/templates/index.js +0 -7
- package/dist/new-widgets/templates/index.js.map +0 -1
- package/dist/new-widgets/templates/setTemplatesDirectory.js +0 -49
- package/dist/new-widgets/templates/setTemplatesDirectory.js.map +0 -1
- package/dist/new-widgets/templatesDependencies/altMixin.js +0 -13
- package/dist/new-widgets/templatesDependencies/altMixin.js.map +0 -1
- package/dist/new-widgets/templatesDependencies/editableMixin.js +0 -77
- package/dist/new-widgets/templatesDependencies/editableMixin.js.map +0 -1
- package/dist/new-widgets/templatesDependencies/filterRangeFormMixin.js +0 -38
- package/dist/new-widgets/templatesDependencies/filterRangeFormMixin.js.map +0 -1
- package/dist/new-widgets/templatesDependencies/formCheckboxMixin.js +0 -14
- package/dist/new-widgets/templatesDependencies/formCheckboxMixin.js.map +0 -1
- package/dist/new-widgets/templatesDependencies/formCheckboxesMixin.js +0 -51
- package/dist/new-widgets/templatesDependencies/formCheckboxesMixin.js.map +0 -1
- package/dist/new-widgets/templatesDependencies/formDropdownMixin.js +0 -66
- package/dist/new-widgets/templatesDependencies/formDropdownMixin.js.map +0 -1
- package/dist/new-widgets/templatesDependencies/formFileMixin.js +0 -81
- package/dist/new-widgets/templatesDependencies/formFileMixin.js.map +0 -1
- package/dist/new-widgets/templatesDependencies/formLengthMixin.js +0 -19
- package/dist/new-widgets/templatesDependencies/formLengthMixin.js.map +0 -1
- package/dist/new-widgets/templatesDependencies/formMinMaxMixin.js +0 -19
- package/dist/new-widgets/templatesDependencies/formMinMaxMixin.js.map +0 -1
- package/dist/new-widgets/templatesDependencies/formMixin.js +0 -66
- package/dist/new-widgets/templatesDependencies/formMixin.js.map +0 -1
- package/dist/new-widgets/templatesDependencies/formNumberMixin.js +0 -14
- package/dist/new-widgets/templatesDependencies/formNumberMixin.js.map +0 -1
- package/dist/new-widgets/templatesDependencies/formRadioMixin.js +0 -16
- package/dist/new-widgets/templatesDependencies/formRadioMixin.js.map +0 -1
- package/dist/new-widgets/templatesDependencies/formStepMixin.js +0 -13
- package/dist/new-widgets/templatesDependencies/formStepMixin.js.map +0 -1
- package/dist/new-widgets/templatesDependencies/linkTextMixin.js +0 -14
- package/dist/new-widgets/templatesDependencies/linkTextMixin.js.map +0 -1
- package/dist/new-widgets/templatesDependencies/multipleFormMixin.js +0 -125
- package/dist/new-widgets/templatesDependencies/multipleFormMixin.js.map +0 -1
- package/dist/new-widgets/templatesDependencies/multipleselectFormMixin.js +0 -74
- package/dist/new-widgets/templatesDependencies/multipleselectFormMixin.js.map +0 -1
- package/dist/new-widgets/templatesDependencies/patternMixin.js +0 -19
- package/dist/new-widgets/templatesDependencies/patternMixin.js.map +0 -1
- package/dist/new-widgets/templatesDependencies/rangeMixin.js +0 -110
- package/dist/new-widgets/templatesDependencies/rangeMixin.js.map +0 -1
- package/dist/new-widgets/templatesDependencies/setMixin.js +0 -12
- package/dist/new-widgets/templatesDependencies/setMixin.js.map +0 -1
- package/dist/new-widgets/templatesDependencies/valueRichtextMixin.js +0 -12
- package/dist/new-widgets/templatesDependencies/valueRichtextMixin.js.map +0 -1
- package/dist/new-widgets/valueTransformationMixins/autolinkMixin.js +0 -18
- package/dist/new-widgets/valueTransformationMixins/autolinkMixin.js.map +0 -1
- package/dist/new-widgets/valueTransformationMixins/dateMixin.js +0 -35
- package/dist/new-widgets/valueTransformationMixins/dateMixin.js.map +0 -1
- package/dist/new-widgets/valueTransformationMixins/dateTimeMixin.js +0 -16
- package/dist/new-widgets/valueTransformationMixins/dateTimeMixin.js.map +0 -1
- package/dist/new-widgets/valueTransformationMixins/index.js +0 -16
- package/dist/new-widgets/valueTransformationMixins/index.js.map +0 -1
- package/dist/new-widgets/valueTransformationMixins/markdownMixin.js +0 -25
- package/dist/new-widgets/valueTransformationMixins/markdownMixin.js.map +0 -1
- package/dist/new-widgets/valueTransformationMixins/multilineMixin.js +0 -17
- package/dist/new-widgets/valueTransformationMixins/multilineMixin.js.map +0 -1
- package/dist/new-widgets/valueTransformationMixins/oembedMixin.js +0 -27
- package/dist/new-widgets/valueTransformationMixins/oembedMixin.js.map +0 -1
- package/dist/solid-template-element.js +0 -164
- package/dist/solid-template-element.js.map +0 -1
- package/dist/style/default-theme.css +0 -24
- package/dist/style/default-theme.css.proxy.js +0 -10
- package/dist/widgets/baseWidget.js +0 -332
- package/dist/widgets/baseWidget.js.map +0 -1
- package/dist/widgets/widget-factory.js +0 -24
- package/dist/widgets/widget-factory.js.map +0 -1
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
const SorterMixin = {
|
|
2
|
-
name: 'sorter-mixin',
|
|
3
|
-
use: [],
|
|
4
|
-
attributes: {
|
|
5
|
-
orderBy: {
|
|
6
|
-
type: String,
|
|
7
|
-
default: null
|
|
8
|
-
},
|
|
9
|
-
orderAsc: {
|
|
10
|
-
type: String,
|
|
11
|
-
default: null
|
|
12
|
-
},
|
|
13
|
-
orderDesc: {
|
|
14
|
-
type: String,
|
|
15
|
-
default: null
|
|
16
|
-
},
|
|
17
|
-
orderByRandom: {
|
|
18
|
-
type: String,
|
|
19
|
-
default: null
|
|
20
|
-
},
|
|
21
|
-
sortedBy: {
|
|
22
|
-
type: String,
|
|
23
|
-
default: null,
|
|
24
|
-
|
|
25
|
-
callback(newValue) {
|
|
26
|
-
// if we change search form, re-populate
|
|
27
|
-
if (newValue && this.sortForm && newValue !== this.sortForm.getAttribute('id')) {
|
|
28
|
-
this.sortForm = null;
|
|
29
|
-
this.populate();
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
initialState: {
|
|
36
|
-
randomOrder: null
|
|
37
|
-
},
|
|
38
|
-
|
|
39
|
-
attached() {
|
|
40
|
-
this.listPostProcessors.push(this.orderCallback.bind(this));
|
|
41
|
-
},
|
|
42
|
-
|
|
43
|
-
created() {
|
|
44
|
-
this.randomOrder = [];
|
|
45
|
-
},
|
|
46
|
-
|
|
47
|
-
async sorterList() {
|
|
48
|
-
if (!this.resource) return;
|
|
49
|
-
this.empty();
|
|
50
|
-
await this.populate();
|
|
51
|
-
},
|
|
52
|
-
|
|
53
|
-
linkSorterForm() {
|
|
54
|
-
this.sortForm.addEventListener('formChange', () => {
|
|
55
|
-
this.sorterList();
|
|
56
|
-
});
|
|
57
|
-
},
|
|
58
|
-
|
|
59
|
-
async orderCallback(resources, listPostProcessors, div, context) {
|
|
60
|
-
if (this.orderBy) this.orderAsc = this.orderBy; // retrocompatibility. remove in 0.15
|
|
61
|
-
|
|
62
|
-
let sortingKey = '';
|
|
63
|
-
let orderValueToSort = ''; // if order-asc or order-desc attribute
|
|
64
|
-
|
|
65
|
-
if (this.orderAsc || this.orderDesc) {
|
|
66
|
-
sortingKey = this.orderAsc || this.orderDesc;
|
|
67
|
-
} // if sorted-by attribute (solid-form-search data used)
|
|
68
|
-
else if (this.sortedBy) {
|
|
69
|
-
const sortedBy = this.sortedBy;
|
|
70
|
-
|
|
71
|
-
if (sortedBy != null) {
|
|
72
|
-
if (!this.sortForm) {
|
|
73
|
-
this.sortForm = document.getElementById(sortedBy);
|
|
74
|
-
if (!this.sortForm) throw "#".concat(sortedBy, " is not in DOM");
|
|
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';
|
|
86
|
-
}
|
|
87
|
-
} // sorting data according to the defined value of sortingKey
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
if (sortingKey) {
|
|
91
|
-
let orderToSort = true; // set 'asc' by default
|
|
92
|
-
|
|
93
|
-
if (this.orderDesc || orderValueToSort == "desc") orderToSort = false;
|
|
94
|
-
resources = (await Promise.all(resources.map(async resource => ({
|
|
95
|
-
sortingKey: await resource[sortingKey],
|
|
96
|
-
// fetch sorting value
|
|
97
|
-
proxy: resource // and keep proxy
|
|
98
|
-
|
|
99
|
-
})))).sort(this.sortValuesByKey("sortingKey", orderToSort)) // sort this array
|
|
100
|
-
.map(r => r.proxy); // re-create array
|
|
101
|
-
} // if order-by-random attribute
|
|
102
|
-
else if (this.isRandomSorted()) {
|
|
103
|
-
resources = this.shuffleResources(resources); // shuffle resources
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
const nextProcessor = listPostProcessors.shift();
|
|
107
|
-
if (nextProcessor) await nextProcessor(resources, listPostProcessors, div, context);
|
|
108
|
-
},
|
|
109
|
-
|
|
110
|
-
isRandomSorted() {
|
|
111
|
-
return this.orderByRandom !== null;
|
|
112
|
-
},
|
|
113
|
-
|
|
114
|
-
sortValuesByKey(key, asc) {
|
|
115
|
-
return function (a, b) {
|
|
116
|
-
if (!a[key]) return 1;
|
|
117
|
-
if (!b[key]) return -1;
|
|
118
|
-
const varA = typeof a[key] === 'string' ? a[key].toUpperCase() : a[key];
|
|
119
|
-
const varB = typeof b[key] === 'string' ? b[key].toUpperCase() : b[key];
|
|
120
|
-
let comparison = 0;
|
|
121
|
-
if (varA > varB) comparison = asc ? 1 : -1;else if (varA < varB) comparison = asc ? -1 : 1;
|
|
122
|
-
return comparison;
|
|
123
|
-
};
|
|
124
|
-
},
|
|
125
|
-
|
|
126
|
-
shuffleResources(array) {
|
|
127
|
-
let currentIndex = array.length;
|
|
128
|
-
let temporaryValue;
|
|
129
|
-
let randomIndex;
|
|
130
|
-
|
|
131
|
-
if (this.randomOrder.length !== array.length) {
|
|
132
|
-
// if no random order existing
|
|
133
|
-
this.randomOrder = [...Array(array.length).keys()]; // generate array of indexes
|
|
134
|
-
|
|
135
|
-
while (0 !== currentIndex) {
|
|
136
|
-
randomIndex = Math.floor(Math.random() * currentIndex);
|
|
137
|
-
currentIndex -= 1;
|
|
138
|
-
temporaryValue = this.randomOrder[currentIndex];
|
|
139
|
-
this.randomOrder[currentIndex] = this.randomOrder[randomIndex];
|
|
140
|
-
this.randomOrder[randomIndex] = temporaryValue;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
return this.randomOrder.map(i => array[i]); // rebuild array with random order
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
};
|
|
148
|
-
export { SorterMixin };
|
|
149
|
-
//# sourceMappingURL=sorterMixin.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["sorterMixin.ts"],"names":["SorterMixin","name","use","attributes","orderBy","type","String","default","orderAsc","orderDesc","orderByRandom","sortedBy","callback","newValue","sortForm","getAttribute","populate","initialState","randomOrder","attached","listPostProcessors","push","orderCallback","bind","created","sorterList","resource","empty","linkSorterForm","addEventListener","resources","div","context","sortingKey","orderValueToSort","document","getElementById","component","value","field","console","warn","orderField","order","orderToSort","Promise","all","map","proxy","sort","sortValuesByKey","r","isRandomSorted","shuffleResources","nextProcessor","shift","key","asc","a","b","varA","toUpperCase","varB","comparison","array","currentIndex","length","temporaryValue","randomIndex","Array","keys","Math","floor","random","i"],"mappings":"AAAA,MAAMA,WAAW,GAAG;AAClBC,EAAAA,IAAI,EAAE,cADY;AAElBC,EAAAA,GAAG,EAAE,EAFa;AAGlBC,EAAAA,UAAU,EAAE;AACVC,IAAAA,OAAO,EAAE;AACPC,MAAAA,IAAI,EAAEC,MADC;AAEPC,MAAAA,OAAO,EAAE;AAFF,KADC;AAKVC,IAAAA,QAAQ,EAAE;AACRH,MAAAA,IAAI,EAAEC,MADE;AAERC,MAAAA,OAAO,EAAE;AAFD,KALA;AASVE,IAAAA,SAAS,EAAE;AACTJ,MAAAA,IAAI,EAAEC,MADG;AAETC,MAAAA,OAAO,EAAE;AAFA,KATD;AAaVG,IAAAA,aAAa,EAAE;AACbL,MAAAA,IAAI,EAAEC,MADO;AAEbC,MAAAA,OAAO,EAAE;AAFI,KAbL;AAiBVI,IAAAA,QAAQ,EAAE;AACRN,MAAAA,IAAI,EAACC,MADG;AAERC,MAAAA,OAAO,EAAE,IAFD;;AAGRK,MAAAA,QAAQ,CAACC,QAAD,EAAmB;AACzB;AACA,YAAIA,QAAQ,IAAI,KAAKC,QAAjB,IAA6BD,QAAQ,KAAK,KAAKC,QAAL,CAAcC,YAAd,CAA2B,IAA3B,CAA9C,EAAgF;AAC9E,eAAKD,QAAL,GAAgB,IAAhB;AACA,eAAKE,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,WAAL,CAAiBgD,MAAjB,KAA4BF,KAAK,CAACE,MAAtC,EAA8C;AAAE;AAC9C,WAAKhD,WAAL,GAAmB,CAAE,GAAGmD,KAAK,CAACL,KAAK,CAACE,MAAP,CAAL,CAAoBI,IAApB,EAAL,CAAnB,CAD4C,CACU;;AACtD,aAAO,MAAML,YAAb,EAA2B;AACzBG,QAAAA,WAAW,GAAGG,IAAI,CAACC,KAAL,CAAWD,IAAI,CAACE,MAAL,KAAgBR,YAA3B,CAAd;AACAA,QAAAA,YAAY,IAAI,CAAhB;AACAE,QAAAA,cAAc,GAAG,KAAKjD,WAAL,CAAiB+C,YAAjB,CAAjB;AACA,aAAK/C,WAAL,CAAiB+C,YAAjB,IAAiC,KAAK/C,WAAL,CAAiBkD,WAAjB,CAAjC;AACA,aAAKlD,WAAL,CAAiBkD,WAAjB,IAAgCD,cAAhC;AACD;AACF;;AACD,WAAO,KAAKjD,WAAL,CAAiB6B,GAAjB,CAAsB2B,CAAD,IAAeV,KAAK,CAACU,CAAD,CAAzC,CAAP,CAd0C,CAcY;AACvD;;AAlIiB,CAApB;AAqIA,SACE1E,WADF","sourcesContent":["const SorterMixin = {\n name: 'sorter-mixin',\n use: [],\n attributes: {\n orderBy: {\n type: String,\n default: null\n },\n orderAsc: {\n type: String,\n default: null\n },\n orderDesc: {\n type: String,\n default: null\n },\n orderByRandom: {\n type: String,\n default: null\n },\n sortedBy: {\n type:String,\n default: null,\n callback(newValue: string) {\n // if we change search form, re-populate\n if (newValue && this.sortForm && newValue !== this.sortForm.getAttribute('id')) {\n this.sortForm = null;\n this.populate();\n }\n }\n }\n },\n initialState: {\n randomOrder: null\n },\n attached(): void {\n this.listPostProcessors.push(this.orderCallback.bind(this));\n },\n created(): void {\n this.randomOrder = [];\n },\n async sorterList(): Promise<void> {\n if (!this.resource) return;\n this.empty();\n await this.populate();\n },\n linkSorterForm() {\n this.sortForm.addEventListener('formChange', () => {\n this.sorterList();\n });\n },\n\n async orderCallback(resources: object[], listPostProcessors: Function[], div: HTMLElement, context: string) { \n if (this.orderBy) this.orderAsc = this.orderBy; // retrocompatibility. remove in 0.15\n let sortingKey = '';\n let orderValueToSort = '';\n\n // if order-asc or order-desc attribute\n if (this.orderAsc || this.orderDesc) {\n sortingKey = this.orderAsc || this.orderDesc;\n }\n // if sorted-by attribute (solid-form-search data used)\n else if (this.sortedBy) {\n const sortedBy = this.sortedBy;\n if (sortedBy != null) {\n if (!this.sortForm) {\n this.sortForm = document.getElementById(sortedBy);\n if (!this.sortForm) throw `#${sortedBy} is not in DOM`; \n this.linkSorterForm();\n }\n if (!this.sortForm.component.value.field) {\n console.warn('The attribute field does not exist')\n } else { \n sortingKey = this.sortForm.component.value.field['value'];\n }\n const orderField = this.sortForm.component.value.order;\n orderValueToSort = orderField && orderField.value ? orderField.value : 'asc';\n }\n }\n // sorting data according to the defined value of sortingKey\n if (sortingKey) {\n let orderToSort = true; // set 'asc' by default\n if (this.orderDesc || orderValueToSort == \"desc\") orderToSort = false;\n resources = (await Promise.all(resources.map(async (resource) => ({\n sortingKey: await resource[sortingKey], // fetch sorting value\n proxy: resource // and keep proxy\n }))))\n .sort(this.sortValuesByKey(\"sortingKey\", orderToSort)) // sort this array\n .map(r => r.proxy) // re-create array\n }\n // if order-by-random attribute\n else if (this.isRandomSorted()) {\n resources = this.shuffleResources(resources); // shuffle resources\n }\n\n const nextProcessor = listPostProcessors.shift();\n if(nextProcessor) await nextProcessor(resources, listPostProcessors, div, context);\n },\n isRandomSorted(): boolean {\n return this.orderByRandom !== null;\n },\n sortValuesByKey(key: string, asc: boolean): Function {\n return function (a: object, b: object): number {\n if (!a[key]) return 1;\n if (!b[key]) return -1;\n\n const varA = typeof a[key] === 'string' ? a[key].toUpperCase() : a[key];\n const varB = typeof b[key] === 'string' ? b[key].toUpperCase() : b[key];\n let comparison = 0;\n if (varA > varB) comparison = asc ? 1 : -1;\n else if (varA < varB) comparison = asc ? -1 : 1;\n\n return comparison;\n }\n },\n shuffleResources(array: object[]): object[] {\n let currentIndex = array.length;\n let temporaryValue: object;\n let randomIndex: number;\n if (this.randomOrder.length !== array.length) { // if no random order existing\n this.randomOrder = [ ...Array(array.length).keys() ]; // generate array of indexes\n while (0 !== currentIndex) {\n randomIndex = Math.floor(Math.random() * currentIndex);\n currentIndex -= 1;\n temporaryValue = this.randomOrder[currentIndex];\n this.randomOrder[currentIndex] = this.randomOrder[randomIndex];\n this.randomOrder[randomIndex] = temporaryValue;\n }\n }\n return this.randomOrder.map((i: number) => array[i]); // rebuild array with random order\n }\n}\n\nexport {\n SorterMixin\n}"]}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { store } from '../libs/store/store.js';
|
|
2
|
-
import { AttributeBinderMixin } from './attributeBinderMixin.js';
|
|
3
|
-
import { ContextMixin } from './contextMixin.js';
|
|
4
|
-
const StoreMixin = {
|
|
5
|
-
name: 'store-mixin',
|
|
6
|
-
use: [AttributeBinderMixin, ContextMixin],
|
|
7
|
-
attributes: {
|
|
8
|
-
noRender: {
|
|
9
|
-
type: String,
|
|
10
|
-
default: null,
|
|
11
|
-
callback: function (value) {
|
|
12
|
-
if (value === null) this.fetchData(this.dataSrc);
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
|
-
dataSrc: {
|
|
16
|
-
type: String,
|
|
17
|
-
default: null,
|
|
18
|
-
callback: async function (value) {
|
|
19
|
-
if (this.noRender === null) await this.fetchData(value);
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
loaderId: {
|
|
23
|
-
type: String,
|
|
24
|
-
default: ''
|
|
25
|
-
},
|
|
26
|
-
nestedField: {
|
|
27
|
-
type: String,
|
|
28
|
-
default: null
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
initialState: {
|
|
32
|
-
resourceId: null,
|
|
33
|
-
subscription: null
|
|
34
|
-
},
|
|
35
|
-
|
|
36
|
-
created() {
|
|
37
|
-
if (this.element.closest('[no-render]')) this.noRender = ''; // if embedded in no-render, apply no-render to himself
|
|
38
|
-
},
|
|
39
|
-
|
|
40
|
-
detached() {
|
|
41
|
-
if (this.subscription) PubSub.unsubscribe(this.subscription);
|
|
42
|
-
},
|
|
43
|
-
|
|
44
|
-
get resource() {
|
|
45
|
-
return this.resourceId ? store.get(this.resourceId) : null;
|
|
46
|
-
},
|
|
47
|
-
|
|
48
|
-
get loader() {
|
|
49
|
-
return this.loaderId ? document.getElementById(this.loaderId) : null;
|
|
50
|
-
},
|
|
51
|
-
|
|
52
|
-
async fetchData(value) {
|
|
53
|
-
this.empty();
|
|
54
|
-
if (this.subscription) PubSub.unsubscribe(this.subscription);
|
|
55
|
-
if (!value || value == "undefined") return;
|
|
56
|
-
this.resourceId = value;
|
|
57
|
-
|
|
58
|
-
if (this.nestedField) {
|
|
59
|
-
const resource = await store.getData(value, this.context);
|
|
60
|
-
const nestedResource = resource ? await resource[this.nestedField] : null;
|
|
61
|
-
this.resourceId = nestedResource ? nestedResource['@id'] : null;
|
|
62
|
-
if (!this.resourceId) throw "Error: the key \"".concat(this.nestedField, "\" does not exist on the resource");
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
this.updateNavigateSubscription();
|
|
66
|
-
this.subscription = PubSub.subscribe(this.resourceId, this.updateDOM.bind(this));
|
|
67
|
-
await store.getData(this.resourceId, this.context);
|
|
68
|
-
this.updateDOM();
|
|
69
|
-
},
|
|
70
|
-
|
|
71
|
-
toggleLoaderHidden(toggle) {
|
|
72
|
-
if (this.loader) this.loader.toggleAttribute('hidden', toggle);
|
|
73
|
-
},
|
|
74
|
-
|
|
75
|
-
updateNavigateSubscription() {},
|
|
76
|
-
|
|
77
|
-
async updateDOM() {
|
|
78
|
-
this.toggleLoaderHidden(false); // brings a loader out if the attribute is set
|
|
79
|
-
|
|
80
|
-
this.empty();
|
|
81
|
-
await this.replaceAttributesData();
|
|
82
|
-
await this.populate();
|
|
83
|
-
setTimeout(() => // Brings the dispatchEvent at the end of the queue
|
|
84
|
-
this.element.dispatchEvent(new CustomEvent('populate', {
|
|
85
|
-
detail: {
|
|
86
|
-
resource: {
|
|
87
|
-
"@id": this.dataSrc
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
})));
|
|
91
|
-
this.toggleLoaderHidden(true);
|
|
92
|
-
},
|
|
93
|
-
|
|
94
|
-
empty() {},
|
|
95
|
-
|
|
96
|
-
update() {
|
|
97
|
-
if (this.noRender === null) this.updateDOM();
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
};
|
|
101
|
-
export { StoreMixin };
|
|
102
|
-
//# sourceMappingURL=storeMixin.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["storeMixin.ts"],"names":["store","AttributeBinderMixin","ContextMixin","StoreMixin","name","use","attributes","noRender","type","String","default","callback","value","fetchData","dataSrc","loaderId","nestedField","initialState","resourceId","subscription","created","element","closest","detached","PubSub","unsubscribe","resource","get","loader","document","getElementById","empty","getData","context","nestedResource","updateNavigateSubscription","subscribe","updateDOM","bind","toggleLoaderHidden","toggle","toggleAttribute","replaceAttributesData","populate","setTimeout","dispatchEvent","CustomEvent","detail","update"],"mappings":"AAAA,SAASA,KAAT,QAAsB,qBAAtB;AACA,SAASC,oBAAT,QAAqC,wBAArC;AAEA,SAASC,YAAT,QAA6B,gBAA7B;AAEA,MAAMC,UAAU,GAAG;AACjBC,EAAAA,IAAI,EAAE,aADW;AAEjBC,EAAAA,GAAG,EAAE,CAACJ,oBAAD,EAAuBC,YAAvB,CAFY;AAGjBI,EAAAA,UAAU,EAAE;AACVC,IAAAA,QAAQ,EAAE;AACRC,MAAAA,IAAI,EAAEC,MADE;AAERC,MAAAA,OAAO,EAAE,IAFD;AAGRC,MAAAA,QAAQ,EAAE,UAAUC,KAAV,EAA0B;AAClC,YAAIA,KAAK,KAAK,IAAd,EAAoB,KAAKC,SAAL,CAAe,KAAKC,OAApB;AACrB;AALO,KADA;AAQVA,IAAAA,OAAO,EAAE;AACPN,MAAAA,IAAI,EAAEC,MADC;AAEPC,MAAA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B,CAA3B,CADQ,CAAV;AAGA,SAAKyB,kBAAL,CAAwB,IAAxB;AACD,GA3EgB;;AA4EjBR,EAAAA,KAAK,GAAQ,CACZ,CA7EgB;;AA8EjBiB,EAAAA,MAAM,GAAG;AACP,QAAI,KAAKzC,QAAL,KAAkB,IAAtB,EAA4B,KAAK8B,SAAL;AAC7B;;AAhFgB,CAAnB;AAmFA,SACElC,UADF","sourcesContent":["import { store } from '../libs/store/store';\nimport { AttributeBinderMixin } from './attributeBinderMixin';\nimport type { Resource } from './interfaces';\nimport { ContextMixin } from './contextMixin';\n\nconst StoreMixin = {\n name: 'store-mixin',\n use: [AttributeBinderMixin, ContextMixin],\n attributes: {\n noRender: {\n type: String,\n default: null,\n callback: function (value: boolean) {\n if (value === null) this.fetchData(this.dataSrc);\n }\n },\n dataSrc: {\n type: String,\n default: null,\n callback: async function (value: string) {\n if (this.noRender === null) await this.fetchData(value);\n },\n },\n loaderId: {\n type: String,\n default: ''\n },\n nestedField: {\n type: String,\n default: null\n },\n },\n initialState: {\n resourceId: null,\n subscription: null,\n },\n created() {\n if (this.element.closest('[no-render]')) this.noRender = ''; // if embedded in no-render, apply no-render to himself\n },\n detached() {\n if (this.subscription) PubSub.unsubscribe(this.subscription);\n },\n get resource(): Resource|null{\n return this.resourceId ? store.get(this.resourceId) : null;\n },\n get loader(): HTMLElement | null {\n return this.loaderId ? document.getElementById(this.loaderId) : null;\n },\n async fetchData(value: string) {\n this.empty();\n if (this.subscription) PubSub.unsubscribe(this.subscription);\n if (!value || value == \"undefined\") return;\n\n this.resourceId = value;\n\n if (this.nestedField) {\n const resource = await store.getData(value, this.context);\n const nestedResource = resource ? await resource[this.nestedField] : null;\n this.resourceId = nestedResource ? nestedResource['@id'] : null;\n if (!this.resourceId) throw `Error: the key \"${this.nestedField}\" does not exist on the resource`\n }\n this.updateNavigateSubscription();\n\n this.subscription = PubSub.subscribe(this.resourceId, this.updateDOM.bind(this));\n await store.getData(this.resourceId, this.context);\n this.updateDOM();\n },\n toggleLoaderHidden(toggle: boolean): void {\n if (this.loader) this.loader.toggleAttribute('hidden', toggle);\n },\n updateNavigateSubscription() { },\n async updateDOM(): Promise<void> {\n this.toggleLoaderHidden(false); // brings a loader out if the attribute is set\n this.empty();\n await this.replaceAttributesData();\n await this.populate();\n setTimeout(() => ( // Brings the dispatchEvent at the end of the queue\n this.element.dispatchEvent(new CustomEvent('populate', { detail: { resource: {\"@id\": this.dataSrc} } })))\n );\n this.toggleLoaderHidden(true);\n },\n empty():void {\n },\n update() {\n if (this.noRender === null) this.updateDOM();\n }\n};\n\nexport {\n StoreMixin\n}"]}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { store } from "../libs/store/store.js";
|
|
2
|
-
const TranslationMixin = {
|
|
3
|
-
name: 'translation-mixin',
|
|
4
|
-
use: [],
|
|
5
|
-
initialState: {
|
|
6
|
-
translationData: {}
|
|
7
|
-
},
|
|
8
|
-
|
|
9
|
-
created() {
|
|
10
|
-
this.getLang();
|
|
11
|
-
},
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Returns the translation module
|
|
15
|
-
* @param langCode - string: language needed in 2 char
|
|
16
|
-
* @returns - object: {key: translation}
|
|
17
|
-
*/
|
|
18
|
-
async getTranslationModule(langCode) {
|
|
19
|
-
const translationsModules = {
|
|
20
|
-
// define modules in a static way, snowpack does not support dynamic strings here
|
|
21
|
-
en: () => import("../locales/en.json.proxy.js"),
|
|
22
|
-
fr: () => import("../locales/fr.json.proxy.js")
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
if (!translationsModules[langCode]) {
|
|
26
|
-
// set default to EN if the file does not exist
|
|
27
|
-
console.warn("".concat(langCode, ".json translation file may not exist, English is setted by default"));
|
|
28
|
-
langCode = 'en';
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const module = await translationsModules[langCode]();
|
|
32
|
-
return module.default;
|
|
33
|
-
},
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Loads the right translation file and reload the component
|
|
37
|
-
*/
|
|
38
|
-
getLang() {
|
|
39
|
-
const languageStorage = store._getLanguage();
|
|
40
|
-
|
|
41
|
-
if (languageStorage) {
|
|
42
|
-
if (window.fetchTranslationPromise === undefined) {
|
|
43
|
-
// if translation data are not already fetched
|
|
44
|
-
window.fetchTranslationPromise = this.getTranslationModule(languageStorage);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
window.fetchTranslationPromise.then(res => {
|
|
48
|
-
if (res) {
|
|
49
|
-
this.translationData = res; // stock data in object passed to traduction method below
|
|
50
|
-
|
|
51
|
-
this.update(); // update the rendering in components and widgets
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Returns translation for a given key
|
|
59
|
-
* @param tradKey - string: key
|
|
60
|
-
* @returns - string: translation
|
|
61
|
-
*/
|
|
62
|
-
t(tradKey) {
|
|
63
|
-
return this.translationData[tradKey] || '';
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
};
|
|
67
|
-
export { TranslationMixin };
|
|
68
|
-
//# sourceMappingURL=translationMixin.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["translationMixin.ts"],"names":["store","TranslationMixin","name","use","initialState","translationData","created","getLang","getTranslationModule","langCode","translationsModules","en","fr","console","warn","module","default","languageStorage","_getLanguage","window","fetchTranslationPromise","undefined","then","res","update","t","tradKey"],"mappings":"AAAA,SAASA,KAAT,QAAsB,qBAAtB;AAEA,MAAMC,gBAAgB,GAAG;AACvBC,EAAAA,IAAI,EAAE,mBADiB;AAEvBC,EAAAA,GAAG,EAAE,EAFkB;AAGvBC,EAAAA,YAAY,EAAE;AACZC,IAAAA,eAAe,EAAC;AADJ,GAHS;;AAMvBC,EAAAA,OAAO,GAAG;AACR,SAAKC,OAAL;AACD,GARsB;;AASvB;AACF;AACA;AACA;AACA;AACE,QAAMC,oBAAN,CAA2BC,QAA3B,EAA6C;AAC3C,UAAMC,mBAAmB,GAAG;AAAE;AAC5BC,MAAAA,EAAE,EAAE,MAAM,OAAO,oBAAP,CADgB;AAE1BC,MAAAA,EAAE,EAAE,MAAM,OAAO,oBAAP;AAFgB,KAA5B;;AAIA,QAAI,CAACF,mBAAmB,CAACD,QAAD,CAAxB,EAAoC;AAAE;AACpCI,MAAAA,OAAO,CAACC,IAAR,WAAgBL,QAAhB;AACAA,MAAAA,QAAQ,GAAG,IAAX;AACD;;AACD,UAAMM,MAAM,GAAG,MAAML,mBAAmB,CAACD,QAAD,CAAnB,EAArB;AACA,WAAOM,MAAM,CAACC,OAAd;AACD,GAzBsB;;AA0BvB;AACF;AACA;AACET,EAAAA,OAAO,GAAG;AACR,UAAMU,eAAe,GAAGjB,KAAK,CAACkB,YAAN,EAAxB;;AACA,QAAGD,eAAH,EAAoB;AAClB,UAAIE,MAAM,CAACC,uBAAP,KAAmCC,SAAvC,EAAkD;AAAE;AAClDF,QAAAA,MAAM,CAACC,uBAAP,GAAiC,KAAKZ,oBAAL,CAA0BS,eAA1B,CAAjC;AACD;;AACDE,MAAAA,MAAM,CAACC,uBAAP,CAA+BE,IAA/B,CAAoCC,GAAG,IAAI;AACzC,YAAIA,GAAJ,EAAS;AACP,eAAKlB,eAAL,GAAuBkB,GAAvB,CADO,CACqB;;AAC5B,eAAKC,MAAL,GAFO,CAEQ;AAChB;AACF,OALD;AAMD;AACF,GA1CsB;;AA2CvB;AACF;AACA;AACA;AACA;AACEC,EAAAA,CAAC,CAACC,OAAD,EAAkB;AACjB,WAAO,KAAKrB,eAAL,CAAqBqB,OAArB,KAAiC,EAAxC;AACD;;AAlDsB,CAAzB;AAqDA,SACEzB,gBADF","sourcesContent":["import { store } from \"../libs/store/store\";\n\nconst TranslationMixin = {\n name: 'translation-mixin',\n use: [],\n initialState: {\n translationData:{}\n },\n created() {\n this.getLang();\n },\n /**\n * Returns the translation module\n * @param langCode - string: language needed in 2 char\n * @returns - object: {key: translation}\n */\n async getTranslationModule(langCode: string) {\n const translationsModules = { // define modules in a static way, snowpack does not support dynamic strings here\n en: () => import('../locales/en.json'),\n fr: () => import('../locales/fr.json'),\n };\n if (!translationsModules[langCode]) { // set default to EN if the file does not exist\n console.warn(`${langCode}.json translation file may not exist, English is setted by default`);\n langCode = 'en';\n }\n const module = await translationsModules[langCode]();\n return module.default;\n },\n /**\n * Loads the right translation file and reload the component\n */\n getLang() {\n const languageStorage = store._getLanguage();\n if(languageStorage) {\n if (window.fetchTranslationPromise === undefined) { // if translation data are not already fetched\n window.fetchTranslationPromise = this.getTranslationModule(languageStorage);\n }\n window.fetchTranslationPromise.then(res => {\n if (res) {\n this.translationData = res; // stock data in object passed to traduction method below\n this.update(); // update the rendering in components and widgets\n }\n })\n }\n },\n /**\n * Returns translation for a given key\n * @param tradKey - string: key\n * @returns - string: translation\n */\n t(tradKey: string) {\n return this.translationData[tradKey] || '';\n }\n}\n\nexport {\n TranslationMixin\n}"]}
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
function _templateObject3() {
|
|
2
|
-
const data = _taggedTemplateLiteral(["\n <p>", "</p>\n "]);
|
|
3
|
-
|
|
4
|
-
_templateObject3 = function () {
|
|
5
|
-
return data;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
return data;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
function _templateObject2() {
|
|
12
|
-
const data = _taggedTemplateLiteral(["\n <", " value=", "></", ">\n "]);
|
|
13
|
-
|
|
14
|
-
_templateObject2 = function () {
|
|
15
|
-
return data;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
return data;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function _templateObject() {
|
|
22
|
-
const data = _taggedTemplateLiteral(["\n <dialog id=\"", "\">\n ", "\n <div>\n <button\n @click=", " \n class=", "\n >\n ", "\n </button>\n <button\n @click=", "\n class=", "\n >\n ", "\n </button>\n </div>\n </dialog>\n "]);
|
|
23
|
-
|
|
24
|
-
_templateObject = function () {
|
|
25
|
-
return data;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
return data;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
32
|
-
|
|
33
|
-
import dialogPolyfill from '../_snowpack/pkg/dialog-polyfill.js';
|
|
34
|
-
import { html } from '../_snowpack/pkg/lit-html.js';
|
|
35
|
-
import { ifDefined } from '../_snowpack/pkg/lit-html/directives/if-defined.js';
|
|
36
|
-
import { uniqID } from '../libs/helpers.js';
|
|
37
|
-
import { TranslationMixin } from './translationMixin.js';
|
|
38
|
-
import { preHTML } from '../libs/lit-helpers.js';
|
|
39
|
-
const ValidationMixin = {
|
|
40
|
-
name: 'validation-mixin',
|
|
41
|
-
use: [TranslationMixin],
|
|
42
|
-
attributes: {
|
|
43
|
-
confirmationMessage: {
|
|
44
|
-
type: String,
|
|
45
|
-
default: null
|
|
46
|
-
},
|
|
47
|
-
confirmationType: {
|
|
48
|
-
type: String,
|
|
49
|
-
default: null
|
|
50
|
-
},
|
|
51
|
-
confirmationSubmitText: {
|
|
52
|
-
type: String,
|
|
53
|
-
default: null
|
|
54
|
-
},
|
|
55
|
-
confirmationCancelText: {
|
|
56
|
-
type: String,
|
|
57
|
-
default: null
|
|
58
|
-
},
|
|
59
|
-
confirmationSubmitClass: {
|
|
60
|
-
type: String,
|
|
61
|
-
default: undefined
|
|
62
|
-
},
|
|
63
|
-
confirmationCancelClass: {
|
|
64
|
-
type: String,
|
|
65
|
-
default: undefined
|
|
66
|
-
},
|
|
67
|
-
confirmationWidget: {
|
|
68
|
-
type: String,
|
|
69
|
-
default: undefined
|
|
70
|
-
}
|
|
71
|
-
},
|
|
72
|
-
|
|
73
|
-
created() {
|
|
74
|
-
this.dialogID = uniqID();
|
|
75
|
-
},
|
|
76
|
-
|
|
77
|
-
showModal() {
|
|
78
|
-
var dialog = document.getElementById(this.dialogID);
|
|
79
|
-
dialogPolyfill.registerDialog(dialog);
|
|
80
|
-
return dialog.showModal();
|
|
81
|
-
},
|
|
82
|
-
|
|
83
|
-
performAction() {
|
|
84
|
-
// Console warning if conf-type attr not filled AND conf-message filled
|
|
85
|
-
if (this.element.hasAttribute('confirmation-message') && !this.confirmationType) console.warn('confirmation-type attribute is missing.'); // Data directly submitted OR confirm dialog modal displayed
|
|
86
|
-
|
|
87
|
-
if (!this.confirmationType || this.confirmationType == "confirm" && confirm(this.confirmationMessage || this.t("validation.message"))) this.validateModal(); // Customisable dialog modal opened
|
|
88
|
-
|
|
89
|
-
if (this.confirmationType == "dialog") {
|
|
90
|
-
this.showModal();
|
|
91
|
-
}
|
|
92
|
-
},
|
|
93
|
-
|
|
94
|
-
getModalDialog() {
|
|
95
|
-
if (this.confirmationType == 'dialog') {
|
|
96
|
-
const quitDialog = () => {
|
|
97
|
-
var dialog = document.getElementById(this.dialogID);
|
|
98
|
-
if (dialog == null) return;
|
|
99
|
-
dialog.close();
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
const confirmChoice = () => {
|
|
103
|
-
this.validateModal();
|
|
104
|
-
quitDialog();
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
return html(_templateObject(), this.dialogID, this.confirmationWidget ? preHTML(_templateObject2(), this.confirmationWidget, this.resourceId, this.confirmationWidget) : html(_templateObject3(), this.confirmationMessage || this.t("validation.message")), confirmChoice, ifDefined(this.confirmationSubmitClass), this.confirmationSubmitText || this.t("validation.submit-text"), quitDialog, ifDefined(this.confirmationCancelClass), this.confirmationCancelText || this.t("validation.cancel-text"));
|
|
108
|
-
} else return '';
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
};
|
|
112
|
-
export { ValidationMixin };
|
|
113
|
-
//# sourceMappingURL=validationMixin.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["validationMixin.ts"],"names":["dialogPolyfill","html","ifDefined","uniqID","TranslationMixin","preHTML","ValidationMixin","name","use","attributes","confirmationMessage","type","String","default","confirmationType","confirmationSubmitText","confirmationCancelText","confirmationSubmitClass","undefined","confirmationCancelClass","confirmationWidget","created","dialogID","showModal","dialog","document","getElementById","registerDialog","performAction","element","hasAttribute","console","warn","confirm","t","validateModal","getModalDialog","quitDialog","close","confirmChoice","resourceId"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAOA,cAAP,MAA2B,iBAA3B;AACA,SAASC,IAAT,QAAqB,UAArB;AACA,SAASC,SAAT,QAA0B,gCAA1B;AACA,SAASC,MAAT,QAAuB,iBAAvB;AACA,SAASC,gBAAT,QAAiC,oBAAjC;AACA,SAASC,OAAT,QAAwB,qBAAxB;AAEA,MAAMC,eAAe,GAAG;AACtBC,EAAAA,IAAI,EAAE,kBADgB;AAEtBC,EAAAA,GAAG,EAAE,CAACJ,gBAAD,CAFiB;AAGtBK,EAAAA,UAAU,EAAE;AACVC,IAAAA,mBAAmB,EAAE;AACnBC,MAAAA,IAAI,EAAEC,MADa;AAEnBC,MAAAA,OAAO,EAAE;AAFU,KADX;AAKVC,IAAAA,gBAAgB,EAAE;AAChBH,MAAAA,IAAI,EAAEC,MADU;AAEhBC,MAAAA,OAAO,EAAE;AAFO,KALR;AASVE,IAAAA,sBAAsB,EAAE;AACtBJ,MAAAA,IAAI,EAAEC,MADgB;AAEtBC,MAAAA,OAAO,EAAE;AAFa,KATd;AAaVG,IAAAA,sBAAsB,EAAE;AACtBL,MAAAA,IAAI,EAAEC,MADgB;AAEtBC,MAAAA,OAAO,EAAE;AAFa,KAbd;AAiBVI,IAAAA,uBAAuB,EAAE;AACvBN,MAAAA,IAAI,EAAEC,MADiB;AAEvBC,MAAAA,OAAO,EAAEK;AAFc,KAjBf;AAqBVC,IAAAA,uBAAuB,EAAE;AACvBR,MAAAA,IAAI,EAAEC,MADiB;AAEvBC,MAAAA,OAAO,EAAEK;AAFc,KArBf;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AKqB,QADrB,EAEI,KAAKF,kBAAL,GAA0Bf,OAA1B,qBACG,KAAKe,kBADR,EACoC,KAAKoB,UADzC,EACyD,KAAKpB,kBAD9D,IAEEnB,IAFF,qBAGK,KAAKS,mBAAL,IAA4B,KAAKwB,CAAL,CAAO,oBAAP,CAHjC,CAFJ,EASiBK,aATjB,EAUgBrC,SAAS,CAAC,KAAKe,uBAAN,CAVzB,EAYQ,KAAKF,sBAAL,IAA+B,KAAKmB,CAAL,CAAO,wBAAP,CAZvC,EAeiBG,UAfjB,EAgBgBnC,SAAS,CAAC,KAAKiB,uBAAN,CAhBzB,EAkBQ,KAAKH,sBAAL,IAA+B,KAAKkB,CAAL,CAAO,wBAAP,CAlBvC;AAuBD,KAjCD,MAiCO,OAAO,EAAP;AACR;;AAtFqB,CAAxB;AAyFA,SACE5B,eADF","sourcesContent":["import dialogPolyfill from 'dialog-polyfill'\nimport { html } from 'lit-html';\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport { uniqID } from '../libs/helpers';\nimport { TranslationMixin } from './translationMixin';\nimport { preHTML } from '../libs/lit-helpers';\n\nconst ValidationMixin = {\n name: 'validation-mixin',\n use: [TranslationMixin],\n attributes: {\n confirmationMessage: {\n type: String,\n default: null\n },\n confirmationType: {\n type: String,\n default: null\n },\n confirmationSubmitText: {\n type: String,\n default: null\n },\n confirmationCancelText: {\n type: String,\n default: null\n },\n confirmationSubmitClass: {\n type: String,\n default: undefined\n },\n confirmationCancelClass: {\n type: String,\n default: undefined\n },\n confirmationWidget: {\n type: String,\n default: undefined\n }\n },\n created() {\n this.dialogID = uniqID();\n },\n showModal() {\n var dialog: any = document.getElementById(this.dialogID);\n dialogPolyfill.registerDialog(dialog);\n return dialog.showModal();\n },\n performAction() {\n // Console warning if conf-type attr not filled AND conf-message filled\n if (this.element.hasAttribute('confirmation-message') && !this.confirmationType) console.warn('confirmation-type attribute is missing.');\n // Data directly submitted OR confirm dialog modal displayed\n if ((!this.confirmationType) || (this.confirmationType == \"confirm\" && confirm(this.confirmationMessage || this.t(\"validation.message\")))) this.validateModal();\n // Customisable dialog modal opened\n if (this.confirmationType == \"dialog\") {\n this.showModal();\n }\n },\n getModalDialog() {\n if (this.confirmationType == 'dialog') {\n const quitDialog = () => {\n var dialog: any = document.getElementById(this.dialogID);\n if (dialog == null) return;\n dialog.close();\n }\n const confirmChoice = () => {\n this.validateModal();\n quitDialog();\n }\n return html`\n <dialog id=\"${this.dialogID}\">\n ${this.confirmationWidget ? preHTML`\n <${this.confirmationWidget} value=${this.resourceId}></${this.confirmationWidget}>\n ` : html`\n <p>${this.confirmationMessage || this.t(\"validation.message\")}</p>\n `}\n <div>\n <button\n @click=${confirmChoice} \n class=${ifDefined(this.confirmationSubmitClass)}\n >\n ${this.confirmationSubmitText || this.t(\"validation.submit-text\")}\n </button>\n <button\n @click=${quitDialog}\n class=${ifDefined(this.confirmationCancelClass)}\n >\n ${this.confirmationCancelText || this.t(\"validation.cancel-text\")}\n </button>\n </div>\n </dialog>\n `\n } else return '';\n },\n}\n\nexport {\n ValidationMixin\n}"]}
|