@startinblox/core 0.19.0-beta.1 → 0.19.0-beta.10
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/leaflet.markercluster/dist/MarkerCluster.css → assets/MarkerCluster-614dea0a.css} +0 -0
- package/dist/{_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.Default.css → assets/MarkerCluster.Default-61258232.css} +0 -0
- package/dist/assets/en-e53105c5.js +14 -0
- package/dist/assets/en-e53105c5.js.map +1 -0
- package/dist/assets/fr-a7fcdb64.js +14 -0
- package/dist/assets/fr-a7fcdb64.js.map +1 -0
- package/dist/{_snowpack/pkg/fusejs.js → assets/helpers-bf15809c.js} +398 -454
- package/dist/assets/helpers-bf15809c.js.map +1 -0
- package/dist/{_snowpack/pkg/leaflet/dist/leaflet.css → assets/leaflet-3c081932.css} +3 -3
- package/dist/helpers.js +18 -0
- package/dist/helpers.js.map +1 -0
- package/dist/index.js +54600 -48
- package/dist/index.js.map +1 -0
- package/package.json +7 -22
- package/dist/_snowpack/pkg/autolinker.js +0 -4429
- package/dist/_snowpack/pkg/autolinker.js.map +0 -1
- package/dist/_snowpack/pkg/common/_baseUnary-d2677655.js +0 -353
- package/dist/_snowpack/pkg/common/_baseUnary-d2677655.js.map +0 -1
- package/dist/_snowpack/pkg/common/_commonjsHelpers-0597c316.js +0 -26
- package/dist/_snowpack/pkg/common/_commonjsHelpers-0597c316.js.map +0 -1
- package/dist/_snowpack/pkg/common/decode-26fbf385.js +0 -185
- package/dist/_snowpack/pkg/common/decode-26fbf385.js.map +0 -1
- package/dist/_snowpack/pkg/common/lit-html-3647afce.js +0 -1104
- package/dist/_snowpack/pkg/common/lit-html-3647afce.js.map +0 -1
- package/dist/_snowpack/pkg/delta-markdown-for-quill.js +0 -26198
- package/dist/_snowpack/pkg/delta-markdown-for-quill.js.map +0 -1
- package/dist/_snowpack/pkg/dialog-polyfill.js +0 -826
- package/dist/_snowpack/pkg/dialog-polyfill.js.map +0 -1
- package/dist/_snowpack/pkg/fusejs.js.map +0 -1
- package/dist/_snowpack/pkg/import-map.json +0 -25
- package/dist/_snowpack/pkg/jsonld-context-parser.js +0 -836
- package/dist/_snowpack/pkg/jsonld-context-parser.js.map +0 -1
- package/dist/_snowpack/pkg/jsonld.js +0 -11760
- package/dist/_snowpack/pkg/jsonld.js.map +0 -1
- package/dist/_snowpack/pkg/leaflet/dist/leaflet.css.proxy.js +0 -10
- package/dist/_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.Default.css.proxy.js +0 -10
- package/dist/_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.css.proxy.js +0 -10
- package/dist/_snowpack/pkg/lit-html/directives/if-defined.js +0 -39
- package/dist/_snowpack/pkg/lit-html/directives/if-defined.js.map +0 -1
- package/dist/_snowpack/pkg/lit-html/directives/unsafe-html.js +0 -48
- package/dist/_snowpack/pkg/lit-html/directives/unsafe-html.js.map +0 -1
- package/dist/_snowpack/pkg/lit-html/directives/until.js +0 -87
- package/dist/_snowpack/pkg/lit-html/directives/until.js.map +0 -1
- package/dist/_snowpack/pkg/lit-html.js +0 -94
- package/dist/_snowpack/pkg/lit-html.js.map +0 -1
- package/dist/_snowpack/pkg/markdown-it-link-attributes.js +0 -68
- package/dist/_snowpack/pkg/markdown-it-link-attributes.js.map +0 -1
- package/dist/_snowpack/pkg/markdown-it.js +0 -11307
- package/dist/_snowpack/pkg/markdown-it.js.map +0 -1
- package/dist/_snowpack/pkg/quill/dist/quill.snow.css.proxy.js +0 -10
- package/dist/_snowpack/pkg/quill-delta-to-markdown.js +0 -971
- package/dist/_snowpack/pkg/quill-delta-to-markdown.js.map +0 -1
- package/dist/_snowpack/pkg/quill.js +0 -14441
- package/dist/_snowpack/pkg/quill.js.map +0 -1
- package/dist/_snowpack/pkg/slim-select.js +0 -714
- package/dist/_snowpack/pkg/slim-select.js.map +0 -1
- package/dist/_snowpack/pkg/tui-calendar/dist/tui-calendar.css +0 -1149
- package/dist/_snowpack/pkg/tui-calendar/dist/tui-calendar.css.proxy.js +0 -10
- package/dist/_snowpack/pkg/tui-calendar.js +0 -46503
- package/dist/_snowpack/pkg/tui-calendar.js.map +0 -1
- package/dist/components/solid-ac-checker.js +0 -45
- package/dist/components/solid-calendar.js +0 -66
- package/dist/components/solid-delete.js +0 -96
- package/dist/components/solid-display.js +0 -150
- package/dist/components/solid-form-search.js +0 -173
- package/dist/components/solid-form.js +0 -257
- package/dist/components/solid-lang.js +0 -35
- package/dist/components/solid-map.js +0 -204
- package/dist/components/solid-table.js +0 -181
- package/dist/components/solid-widget.js +0 -72
- package/dist/import.css +0 -4
- package/dist/libs/Component.js +0 -13
- package/dist/libs/ComponentFactory.js +0 -165
- package/dist/libs/Compositor.js +0 -96
- package/dist/libs/Sib.js +0 -44
- package/dist/libs/filter.js +0 -184
- package/dist/libs/helpers.js +0 -185
- package/dist/libs/interfaces.js +0 -6
- package/dist/libs/lit-helpers.js +0 -139
- package/dist/libs/polyfills.js +0 -35
- package/dist/libs/store/custom-getter.js +0 -344
- package/dist/libs/store/server-pagination.js +0 -19
- package/dist/libs/store/server-search.js +0 -32
- package/dist/libs/store/store.js +0 -560
- 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 -113
- package/dist/mixins/contextMixin.js +0 -26
- package/dist/mixins/counterMixin.js +0 -54
- package/dist/mixins/federationMixin.js +0 -57
- package/dist/mixins/filterMixin.js +0 -152
- package/dist/mixins/grouperMixin.js +0 -73
- package/dist/mixins/highlighterMixin.js +0 -36
- package/dist/mixins/interfaces.js +0 -6
- package/dist/mixins/listMixin.js +0 -116
- package/dist/mixins/nextMixin.js +0 -23
- package/dist/mixins/paginateMixin.js +0 -97
- package/dist/mixins/requiredMixin.js +0 -38
- package/dist/mixins/serverPaginationMixin.js +0 -122
- package/dist/mixins/sorterMixin.js +0 -131
- package/dist/mixins/storeMixin.js +0 -139
- package/dist/mixins/translationMixin.js +0 -58
- package/dist/mixins/validationMixin.js +0 -95
- package/dist/mixins/widgetMixin.js +0 -358
- package/dist/new-widgets/attributeMixins/actionMixin.js +0 -13
- package/dist/new-widgets/attributeMixins/blankMixin.js +0 -7
- package/dist/new-widgets/attributeMixins/booleanMixin.js +0 -7
- package/dist/new-widgets/attributeMixins/index.js +0 -19
- package/dist/new-widgets/attributeMixins/mailtoMixin.js +0 -7
- package/dist/new-widgets/attributeMixins/multipleMixin.js +0 -27
- package/dist/new-widgets/attributeMixins/numberMixin.js +0 -7
- package/dist/new-widgets/attributeMixins/placeholderMixin.js +0 -16
- package/dist/new-widgets/attributeMixins/telMixin.js +0 -7
- package/dist/new-widgets/baseWidgetMixin.js +0 -109
- package/dist/new-widgets/callbackMixins/autocompletionMixin.js +0 -96
- package/dist/new-widgets/callbackMixins/index.js +0 -7
- package/dist/new-widgets/callbackMixins/richtextMixin.js +0 -37
- package/dist/new-widgets/callbackMixins/slimselect.css.proxy.js +0 -10
- package/dist/new-widgets/interfaces.js +0 -1
- package/dist/new-widgets/new-widget-factory.js +0 -91
- package/dist/new-widgets/templateAdditionMixins/addableMixin.js +0 -26
- package/dist/new-widgets/templateAdditionMixins/index.js +0 -13
- package/dist/new-widgets/templateAdditionMixins/labelLastMixin.js +0 -16
- package/dist/new-widgets/templateAdditionMixins/labelMixin.js +0 -18
- package/dist/new-widgets/templates/defaultTemplatesDirectory.js +0 -29
- package/dist/new-widgets/templates/displayTemplatesDirectory.js +0 -54
- package/dist/new-widgets/templates/formTemplatesDirectory.js +0 -423
- package/dist/new-widgets/templates/groupTemplatesDirectory.js +0 -11
- package/dist/new-widgets/templates/index.js +0 -6
- package/dist/new-widgets/templates/setTemplatesDirectory.js +0 -16
- package/dist/new-widgets/templatesDependencies/altMixin.js +0 -12
- package/dist/new-widgets/templatesDependencies/editableMixin.js +0 -60
- package/dist/new-widgets/templatesDependencies/filterRangeFormMixin.js +0 -34
- package/dist/new-widgets/templatesDependencies/formCheckboxMixin.js +0 -10
- package/dist/new-widgets/templatesDependencies/formCheckboxesMixin.js +0 -41
- package/dist/new-widgets/templatesDependencies/formDropdownMixin.js +0 -59
- package/dist/new-widgets/templatesDependencies/formFileMixin.js +0 -82
- package/dist/new-widgets/templatesDependencies/formLengthMixin.js +0 -18
- package/dist/new-widgets/templatesDependencies/formMinMaxMixin.js +0 -18
- package/dist/new-widgets/templatesDependencies/formMixin.js +0 -56
- package/dist/new-widgets/templatesDependencies/formNumberMixin.js +0 -10
- package/dist/new-widgets/templatesDependencies/formRadioMixin.js +0 -12
- package/dist/new-widgets/templatesDependencies/formStepMixin.js +0 -12
- package/dist/new-widgets/templatesDependencies/linkTextMixin.js +0 -13
- package/dist/new-widgets/templatesDependencies/multipleFormMixin.js +0 -116
- package/dist/new-widgets/templatesDependencies/multipleselectFormMixin.js +0 -74
- package/dist/new-widgets/templatesDependencies/patternMixin.js +0 -18
- package/dist/new-widgets/templatesDependencies/rangeMixin.js +0 -100
- package/dist/new-widgets/templatesDependencies/setMixin.js +0 -9
- package/dist/new-widgets/templatesDependencies/valueRichtextMixin.js +0 -9
- package/dist/new-widgets/valueTransformationMixins/autolinkMixin.js +0 -14
- package/dist/new-widgets/valueTransformationMixins/dateMixin.js +0 -29
- package/dist/new-widgets/valueTransformationMixins/dateTimeMixin.js +0 -12
- package/dist/new-widgets/valueTransformationMixins/index.js +0 -15
- package/dist/new-widgets/valueTransformationMixins/markdownMixin.js +0 -30
- package/dist/new-widgets/valueTransformationMixins/multilineMixin.js +0 -13
- package/dist/new-widgets/valueTransformationMixins/oembedMixin.js +0 -21
- package/dist/solid-template-element.js +0 -144
- package/dist/style/default-theme.css.proxy.js +0 -10
- package/dist/widgets/baseWidget.js +0 -267
- package/dist/widgets/widget-factory.js +0 -20
- /package/dist/{style/default-theme.css → assets/default-theme-d0f20a8a.css} +0 -0
- /package/dist/{_snowpack/pkg/quill/dist/quill.snow.css → assets/quill.snow-8f222e44.css} +0 -0
- /package/dist/{new-widgets/callbackMixins/slimselect.css → assets/slimselect-43e3ebc8.css} +0 -0
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import { base_context, store } from '../libs/store/store.js';
|
|
2
|
-
const AttributeBinderMixin = {
|
|
3
|
-
name: 'attribute-binder-mixin',
|
|
4
|
-
use: [],
|
|
5
|
-
initialState: {
|
|
6
|
-
bindedAttributes: null
|
|
7
|
-
},
|
|
8
|
-
created() {
|
|
9
|
-
this.bindedAttributes = {};
|
|
10
|
-
},
|
|
11
|
-
/**
|
|
12
|
-
* Reset attributes values
|
|
13
|
-
*/
|
|
14
|
-
resetAttributesData() {
|
|
15
|
-
for (let attr of Object.keys(this.bindedAttributes)) {
|
|
16
|
-
this.element.setAttribute(attr, this.bindedAttributes[attr]);
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
/**
|
|
20
|
-
* Replace store://XXX attributes by corresponding data
|
|
21
|
-
* @param reset - set to false if no need to reset data
|
|
22
|
-
*/
|
|
23
|
-
async replaceAttributesData(reset = true) {
|
|
24
|
-
if (reset) this.resetAttributesData();
|
|
25
|
-
const oldAttributes = Array.from(this.element.attributes) // transform NamedNodeMap in object
|
|
26
|
-
.reduce((obj, attr) => {
|
|
27
|
-
// Keep only attributes starting with `store://...`
|
|
28
|
-
if (!attr.value.match(/^store:\/\/(resource|container|user)/)) return {
|
|
29
|
-
...obj
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
// Save attr for reset later
|
|
33
|
-
if (!this.bindedAttributes[attr.name]) this.bindedAttributes[attr.name] = attr.value;
|
|
34
|
-
return {
|
|
35
|
-
...obj,
|
|
36
|
-
[attr.name]: attr.value // add "key: value"
|
|
37
|
-
};
|
|
38
|
-
}, {});
|
|
39
|
-
const newAttributes = await this.transformAttributes({
|
|
40
|
-
...oldAttributes
|
|
41
|
-
}, this.resource); // generate new attributes
|
|
42
|
-
|
|
43
|
-
for (let attr of Object.keys(newAttributes)) {
|
|
44
|
-
// set attributes on element
|
|
45
|
-
if (oldAttributes[attr] == newAttributes[attr]) continue; // only if it changed
|
|
46
|
-
this.element.setAttribute(attr, newAttributes[attr]);
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
/**
|
|
50
|
-
* Transform attributes from `store://...` to their actual value
|
|
51
|
-
* @param attributes - object representing attributes of an element
|
|
52
|
-
* @param resource - resource to use to resolve attributes
|
|
53
|
-
* @returns - object representing attributes of an element with resolved values
|
|
54
|
-
*/
|
|
55
|
-
async transformAttributes(attributes, resource) {
|
|
56
|
-
const isContainer = resource && resource.isContainer?.();
|
|
57
|
-
for (let attr of Object.keys(attributes)) {
|
|
58
|
-
const value = attributes[attr];
|
|
59
|
-
// Avoid error if value is a number
|
|
60
|
-
if (typeof value === 'string') {
|
|
61
|
-
// Replace attribute value
|
|
62
|
-
if (!isContainer && resource && value.startsWith('store://resource')) {
|
|
63
|
-
// RESOURCE
|
|
64
|
-
let path = value.replace('store://resource.', '');
|
|
65
|
-
attributes[attr] = resource ? await resource[path] : '';
|
|
66
|
-
} else if (isContainer && resource && value.startsWith('store://container')) {
|
|
67
|
-
// CONTAINER
|
|
68
|
-
let path = value.replace('store://container.', '');
|
|
69
|
-
attributes[attr] = resource ? await resource[path] : '';
|
|
70
|
-
} else if (value.startsWith('store://user')) {
|
|
71
|
-
// USER
|
|
72
|
-
const userId = await this.retry(this.getUser.bind(this)); // retry until sibAuth is defined
|
|
73
|
-
const user = userId && userId['@id'] ? await store.getData(userId['@id'], this.context || base_context) : null;
|
|
74
|
-
if (!user) {
|
|
75
|
-
attributes[attr] = '';
|
|
76
|
-
continue;
|
|
77
|
-
}
|
|
78
|
-
let path = value.replace('store://user.', '');
|
|
79
|
-
attributes[attr] = user ? await user[path] : '';
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
return attributes;
|
|
84
|
-
},
|
|
85
|
-
/**
|
|
86
|
-
* Returns logged in user from sib-auth
|
|
87
|
-
* @returns userId
|
|
88
|
-
*/
|
|
89
|
-
async getUser() {
|
|
90
|
-
const sibAuth = document.querySelector('sib-auth');
|
|
91
|
-
return sibAuth.getUser();
|
|
92
|
-
},
|
|
93
|
-
/**
|
|
94
|
-
* Retry [fn] for [maxRetries] times every [ms]
|
|
95
|
-
* @param fn
|
|
96
|
-
* @param ms
|
|
97
|
-
* @param maxRetries
|
|
98
|
-
* @returns
|
|
99
|
-
*/
|
|
100
|
-
async retry(fn, ms = 200, maxRetries = 5) {
|
|
101
|
-
return new Promise((resolve, reject) => {
|
|
102
|
-
let retries = 0;
|
|
103
|
-
fn().then(resolve).catch(() => {
|
|
104
|
-
setTimeout(() => {
|
|
105
|
-
++retries;
|
|
106
|
-
if (retries == maxRetries) return reject();
|
|
107
|
-
this.retry(fn, ms).then(resolve);
|
|
108
|
-
}, ms);
|
|
109
|
-
});
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
export { AttributeBinderMixin };
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { base_context } from '../libs/store/store.js';
|
|
2
|
-
const ContextMixin = {
|
|
3
|
-
name: 'store-mixin',
|
|
4
|
-
use: [],
|
|
5
|
-
attributes: {
|
|
6
|
-
extraContext: {
|
|
7
|
-
type: String,
|
|
8
|
-
default: null
|
|
9
|
-
}
|
|
10
|
-
},
|
|
11
|
-
get context() {
|
|
12
|
-
return {
|
|
13
|
-
...base_context,
|
|
14
|
-
...this.extra_context
|
|
15
|
-
};
|
|
16
|
-
},
|
|
17
|
-
get extra_context() {
|
|
18
|
-
let extraContextElement = this.extraContext ? document.getElementById(this.extraContext) :
|
|
19
|
-
// take element extra context first
|
|
20
|
-
document.querySelector('[data-default-context]'); // ... or look for a default extra context
|
|
21
|
-
|
|
22
|
-
if (extraContextElement) return JSON.parse(extraContextElement.textContent || "{}");
|
|
23
|
-
return {};
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
export { ContextMixin };
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { html } from '../_snowpack/pkg/lit-html.js';
|
|
2
|
-
import { unsafeHTML } from '../_snowpack/pkg/lit-html/directives/unsafe-html.js';
|
|
3
|
-
import { evalTemplateString } from '../libs/helpers.js';
|
|
4
|
-
const CounterMixin = {
|
|
5
|
-
name: 'counter-mixin',
|
|
6
|
-
use: [],
|
|
7
|
-
attributes: {
|
|
8
|
-
counterTemplate: {
|
|
9
|
-
type: String,
|
|
10
|
-
default: null
|
|
11
|
-
}
|
|
12
|
-
},
|
|
13
|
-
initialState: {
|
|
14
|
-
counter: null,
|
|
15
|
-
parentCounterDiv: null
|
|
16
|
-
},
|
|
17
|
-
attached() {
|
|
18
|
-
this.listPostProcessors.push(this.countResources.bind(this));
|
|
19
|
-
},
|
|
20
|
-
async countResources(resources, listPostProcessors, div, context) {
|
|
21
|
-
if (this.counterTemplate) {
|
|
22
|
-
this.initParentCounterDiv(div);
|
|
23
|
-
this.renderCallbacks.push({
|
|
24
|
-
// add counter template to render callback
|
|
25
|
-
template: await this.renderCounter(resources.length),
|
|
26
|
-
parent: this.parentCounterDiv
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
const nextProcessor = listPostProcessors.shift();
|
|
30
|
-
if (nextProcessor) await nextProcessor(resources, listPostProcessors, div, context);
|
|
31
|
-
},
|
|
32
|
-
/**
|
|
33
|
-
* Create the parent div of the counter in the component.
|
|
34
|
-
* @param div: parent div where to insert the counter div
|
|
35
|
-
*/
|
|
36
|
-
initParentCounterDiv(div) {
|
|
37
|
-
if (this.parentCounterDiv) return;
|
|
38
|
-
this.parentCounterDiv = document.createElement('div');
|
|
39
|
-
this.element.insertBefore(this.parentCounterDiv, div);
|
|
40
|
-
},
|
|
41
|
-
async renderCounter(resourceNumber) {
|
|
42
|
-
let htmlCounter;
|
|
43
|
-
try {
|
|
44
|
-
htmlCounter = await evalTemplateString(this.counterTemplate, {
|
|
45
|
-
counter: resourceNumber
|
|
46
|
-
});
|
|
47
|
-
} catch (e) {
|
|
48
|
-
console.error(new Error('error in counter-template'), e);
|
|
49
|
-
throw e;
|
|
50
|
-
}
|
|
51
|
-
return html`${unsafeHTML(htmlCounter)}`;
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
export { CounterMixin };
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { store } from '../libs/store/store.js';
|
|
2
|
-
const FederationMixin = {
|
|
3
|
-
name: 'federation-mixin',
|
|
4
|
-
use: [],
|
|
5
|
-
initialState: {
|
|
6
|
-
containerFetched: null
|
|
7
|
-
},
|
|
8
|
-
attached() {
|
|
9
|
-
this.listPostProcessors.push(this.fetchSources.bind(this));
|
|
10
|
-
},
|
|
11
|
-
async fetchSources(resources, listPostProcessors, div, context) {
|
|
12
|
-
this.containerFetched = [];
|
|
13
|
-
let newResources = await this.getResources(resources);
|
|
14
|
-
newResources = [...new Set(newResources)]; // remove possible duplicates
|
|
15
|
-
|
|
16
|
-
const nextProcessor = listPostProcessors.shift();
|
|
17
|
-
if (nextProcessor) await nextProcessor(newResources, listPostProcessors, div, context);
|
|
18
|
-
},
|
|
19
|
-
async getResources(resources) {
|
|
20
|
-
if (!resources) return [];
|
|
21
|
-
const newResources = [];
|
|
22
|
-
const getChildResources = async res => {
|
|
23
|
-
if (!res) return;
|
|
24
|
-
if (res.isContainer?.()) {
|
|
25
|
-
// if this is a container
|
|
26
|
-
const containerId = res['@id'];
|
|
27
|
-
if (!this.containerFetched.includes(containerId)) {
|
|
28
|
-
// prevent from including twice the same source
|
|
29
|
-
this.containerFetched.push(containerId);
|
|
30
|
-
const resourcesFetched = await this.fetchSource(containerId); // fetch the resources of this container
|
|
31
|
-
if (resourcesFetched) newResources.push(...(await this.getResources(resourcesFetched))); // Add content of source to array...
|
|
32
|
-
}
|
|
33
|
-
} else if (!res.isArray?.()) {
|
|
34
|
-
const resource = await store.getData(res['@id'], this.context);
|
|
35
|
-
if (resource) newResources.push(resource);
|
|
36
|
-
} else {
|
|
37
|
-
newResources.push(res); // Or resource directly if not a container
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
// Special case for list support, if there is only one item it is serialized as an object, not an array
|
|
42
|
-
if (!Array.isArray(resources)) resources = [resources];
|
|
43
|
-
await Promise.all(resources.map(res => getChildResources(res)));
|
|
44
|
-
return newResources;
|
|
45
|
-
},
|
|
46
|
-
async fetchSource(containerId) {
|
|
47
|
-
const cachedContainer = store.get(containerId); // find container in cache
|
|
48
|
-
if (!cachedContainer || cachedContainer['ldp:contains'] === null) {
|
|
49
|
-
// if container not fetched
|
|
50
|
-
store.clearCache(containerId); // empty cache
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const container = await store.getData(containerId, this.context); // and fetch it
|
|
54
|
-
return container ? container['ldp:contains'] : null;
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
export { FederationMixin };
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import { searchInResources } from '../libs/filter.js';
|
|
2
|
-
const FilterMixin = {
|
|
3
|
-
name: 'filter-mixin',
|
|
4
|
-
use: [],
|
|
5
|
-
initialState: {
|
|
6
|
-
searchCount: null
|
|
7
|
-
},
|
|
8
|
-
attributes: {
|
|
9
|
-
searchFields: {
|
|
10
|
-
type: String,
|
|
11
|
-
default: null
|
|
12
|
-
},
|
|
13
|
-
filteredBy: {
|
|
14
|
-
type: String,
|
|
15
|
-
default: null,
|
|
16
|
-
callback(newValue) {
|
|
17
|
-
// if we change search form, re-populate
|
|
18
|
-
if (newValue && this.searchForm && newValue !== this.searchForm.getAttribute('id')) {
|
|
19
|
-
this.searchForm.component.detach(this);
|
|
20
|
-
this.searchForm = null;
|
|
21
|
-
this.populate();
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
filteredOn: {
|
|
26
|
-
type: String,
|
|
27
|
-
// 'server' | 'client'
|
|
28
|
-
default: 'client'
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
created() {
|
|
32
|
-
this.searchCount = new Map();
|
|
33
|
-
this.element.addEventListener('populate', () => {
|
|
34
|
-
if (!window.document.contains(this.element)) return;
|
|
35
|
-
this.searchForm?.component.updateAutoRanges();
|
|
36
|
-
});
|
|
37
|
-
},
|
|
38
|
-
attached() {
|
|
39
|
-
const filteredBy = this.filteredBy;
|
|
40
|
-
if (this.isFilteredOnServer() && filteredBy) {
|
|
41
|
-
this.searchForm = document.getElementById(filteredBy);
|
|
42
|
-
if (!this.searchForm) throw `#${filteredBy} is not in DOM`;
|
|
43
|
-
// this.searchForm.component.attach(this); // is it necessary?
|
|
44
|
-
this.searchForm.addEventListener('formChange', () => this.onServerSearchChange());
|
|
45
|
-
} else {
|
|
46
|
-
this.listPostProcessors.push(this.filterCallback.bind(this));
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
get filters() {
|
|
50
|
-
return this.searchForm?.component?.value ?? {};
|
|
51
|
-
},
|
|
52
|
-
set filters(filters) {
|
|
53
|
-
if (this.searchForm?.component?.value) {
|
|
54
|
-
this.searchForm.component.value = filters;
|
|
55
|
-
this.filterList();
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
isFilteredOnServer() {
|
|
59
|
-
return this.filteredOn === 'server' && !!this.fetchData;
|
|
60
|
-
},
|
|
61
|
-
async onServerSearchChange() {
|
|
62
|
-
await this.fetchData(this.dataSrc);
|
|
63
|
-
this.empty();
|
|
64
|
-
await this.populate();
|
|
65
|
-
},
|
|
66
|
-
getDynamicServerSearch() {
|
|
67
|
-
const filters = this.filters;
|
|
68
|
-
if (this.isFilteredOnServer() && filters) {
|
|
69
|
-
const fields = Object.keys(filters);
|
|
70
|
-
const value = Object.values(filters).map(({
|
|
71
|
-
value
|
|
72
|
-
}) => value).filter(value => !!value).join(' ').trim();
|
|
73
|
-
if (fields.length > 0 && value) {
|
|
74
|
-
return {
|
|
75
|
-
fields,
|
|
76
|
-
value
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
return;
|
|
81
|
-
},
|
|
82
|
-
async filterCallback(resources, listPostProcessors, div, context) {
|
|
83
|
-
if (this.filteredBy || this.searchFields) {
|
|
84
|
-
if (!this.searchCount.has(context)) this.searchCount.set(context, 1);
|
|
85
|
-
if (!this.searchForm) await this.createFilter(context);
|
|
86
|
-
const filteredResources = await searchInResources(resources, this.filters, this.fields, this.searchForm);
|
|
87
|
-
resources = resources.filter((_v, index) => filteredResources[index]);
|
|
88
|
-
}
|
|
89
|
-
const nextProcessor = listPostProcessors.shift();
|
|
90
|
-
if (nextProcessor) await nextProcessor(resources, listPostProcessors, div, context + (this.searchCount.get(context) || ''));
|
|
91
|
-
},
|
|
92
|
-
async filterList(context) {
|
|
93
|
-
this.searchCount.set(context, this.searchCount.get(context) + 1);
|
|
94
|
-
if (!this.resource) return;
|
|
95
|
-
this.empty();
|
|
96
|
-
await this.populate();
|
|
97
|
-
},
|
|
98
|
-
async getValuesOfField(field) {
|
|
99
|
-
const arrayOfDataObjects = this.resource['ldp:contains'];
|
|
100
|
-
const arrayOfDataIds = [];
|
|
101
|
-
for (const obj of arrayOfDataObjects) {
|
|
102
|
-
// for each element, if it's an object, catch all elements in 'ldp:contains' key
|
|
103
|
-
const nextArrayOfObjects = await obj[field];
|
|
104
|
-
if (!nextArrayOfObjects) continue;
|
|
105
|
-
if (typeof nextArrayOfObjects !== "object") {
|
|
106
|
-
console.warn(`The format value of ${field} is not suitable with auto-range-[field] attribute`);
|
|
107
|
-
continue;
|
|
108
|
-
}
|
|
109
|
-
if (nextArrayOfObjects['@type'] !== 'ldp:Container') {
|
|
110
|
-
// if no element in 'ldp:contains', catch object id
|
|
111
|
-
arrayOfDataIds.push(nextArrayOfObjects['@id']);
|
|
112
|
-
} else {
|
|
113
|
-
if (!nextArrayOfObjects['ldp:contains']) continue;
|
|
114
|
-
for (const obj of nextArrayOfObjects['ldp:contains']) {
|
|
115
|
-
// catch each element id
|
|
116
|
-
arrayOfDataIds.push(obj['@id']);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
return arrayOfDataIds;
|
|
121
|
-
},
|
|
122
|
-
async createFilter(context) {
|
|
123
|
-
const filteredBy = this.filteredBy;
|
|
124
|
-
if (filteredBy != null) {
|
|
125
|
-
this.searchForm = document.getElementById(filteredBy);
|
|
126
|
-
if (!this.searchForm) throw `#${filteredBy} is not in DOM`;
|
|
127
|
-
} else {
|
|
128
|
-
this.searchForm = document.createElement(`solid-form-search`);
|
|
129
|
-
}
|
|
130
|
-
this.searchForm.component.attach(this);
|
|
131
|
-
this.searchForm.addEventListener('formChange', () => {
|
|
132
|
-
this.filterList(context);
|
|
133
|
-
});
|
|
134
|
-
this.searchForm.toggleAttribute('naked', true);
|
|
135
|
-
if (filteredBy) return;
|
|
136
|
-
|
|
137
|
-
//pass attributes to search form
|
|
138
|
-
const searchAttributes = Array.from(this.element.attributes).filter(attr => attr['name'].startsWith('search-')).map(attr => ({
|
|
139
|
-
name: attr['name'].replace('search-', ''),
|
|
140
|
-
value: attr['value']
|
|
141
|
-
}));
|
|
142
|
-
searchAttributes.forEach(({
|
|
143
|
-
name,
|
|
144
|
-
value
|
|
145
|
-
}) => {
|
|
146
|
-
this.searchForm.setAttribute(name, value);
|
|
147
|
-
});
|
|
148
|
-
this.element.insertBefore(this.searchForm, this.element.firstChild);
|
|
149
|
-
await this.searchForm.component.populate();
|
|
150
|
-
}
|
|
151
|
-
};
|
|
152
|
-
export { FilterMixin };
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
const GrouperMixin = {
|
|
2
|
-
name: 'grouper-mixin',
|
|
3
|
-
use: [],
|
|
4
|
-
attributes: {
|
|
5
|
-
groupBy: {
|
|
6
|
-
type: String,
|
|
7
|
-
default: null
|
|
8
|
-
},
|
|
9
|
-
groupWidget: {
|
|
10
|
-
type: String,
|
|
11
|
-
default: 'solid-group-default'
|
|
12
|
-
},
|
|
13
|
-
groupClass: {
|
|
14
|
-
type: String,
|
|
15
|
-
default: ''
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
attached() {
|
|
19
|
-
this.listPostProcessors.push(this.groupResources.bind(this));
|
|
20
|
-
},
|
|
21
|
-
async groupResources(resources, listPostProcessors, div, context) {
|
|
22
|
-
const nextProcessor = listPostProcessors.shift();
|
|
23
|
-
if (this.groupBy) {
|
|
24
|
-
let groups = {};
|
|
25
|
-
for (let resource of resources) {
|
|
26
|
-
const valueGroup = await resource[this.groupBy];
|
|
27
|
-
if (valueGroup == null) continue;
|
|
28
|
-
if (!groups[valueGroup]) groups[valueGroup] = {
|
|
29
|
-
resources: []
|
|
30
|
-
}; // if no group yet, we create one...
|
|
31
|
-
groups[valueGroup].resources.push(resource); // ...and push corresponding resource into it
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// For each group, get group widget and call next processors
|
|
35
|
-
const parents = Object.keys(groups).map(g => ({
|
|
36
|
-
group: g,
|
|
37
|
-
parent: this.renderGroup(g, div)
|
|
38
|
-
}));
|
|
39
|
-
for (let {
|
|
40
|
-
group,
|
|
41
|
-
parent
|
|
42
|
-
} of parents) {
|
|
43
|
-
if (nextProcessor) await nextProcessor(groups[group].resources,
|
|
44
|
-
// give only resources from group
|
|
45
|
-
[...listPostProcessors],
|
|
46
|
-
// copy post processors
|
|
47
|
-
parent,
|
|
48
|
-
// parent is group widget
|
|
49
|
-
context + "_" + group);
|
|
50
|
-
}
|
|
51
|
-
} else {
|
|
52
|
-
if (nextProcessor) await nextProcessor(resources, listPostProcessors, div, context);
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
/**
|
|
56
|
-
* Create a group widget or find if it already exists
|
|
57
|
-
* @param groupName
|
|
58
|
-
*/
|
|
59
|
-
renderGroup(groupName, div) {
|
|
60
|
-
let groupElt = this.element.querySelector(`${this.groupWidget}[value="${groupName}"]`);
|
|
61
|
-
if (!groupElt) {
|
|
62
|
-
groupElt = document.createElement(this.groupWidget);
|
|
63
|
-
groupElt.setAttribute('value', groupName);
|
|
64
|
-
if (this.groupClass) groupElt.setAttribute('class', this.groupClass);
|
|
65
|
-
if (groupElt.component) groupElt.component.render(); // Force the rendering of the widget
|
|
66
|
-
div.appendChild(groupElt); // and append it to the parent div
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return groupElt.querySelector('[data-content]') || groupElt; // return the node where to insert content
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
export { GrouperMixin };
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
const HighlighterMixin = {
|
|
2
|
-
name: 'highlighter-mixin',
|
|
3
|
-
use: [],
|
|
4
|
-
attached() {
|
|
5
|
-
this.listPostProcessors.push(this.hightlightCallback.bind(this));
|
|
6
|
-
},
|
|
7
|
-
async hightlightCallback(resources, listPostProcessors, div, context) {
|
|
8
|
-
for (let attr of this.element.attributes) {
|
|
9
|
-
if (attr.name.startsWith('highlight-')) {
|
|
10
|
-
const field = attr.name.split('highlight-')[1];
|
|
11
|
-
resources = await Promise.all(resources.map(async resource => ({
|
|
12
|
-
sortingKey: await resource[field],
|
|
13
|
-
// fetch sorting value
|
|
14
|
-
proxy: resource // and keep proxy
|
|
15
|
-
})));
|
|
16
|
-
|
|
17
|
-
resources = this.sortHighlighted(resources, "sortingKey", attr.value); // highlight element
|
|
18
|
-
resources = resources.map(resource => resource.proxy); // and re-transform in arra of resources
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const nextProcessor = listPostProcessors.shift();
|
|
23
|
-
if (nextProcessor) await nextProcessor(resources, listPostProcessors, div, context);
|
|
24
|
-
},
|
|
25
|
-
sortHighlighted(resources, field, value) {
|
|
26
|
-
for (let [index, res] of resources.entries()) {
|
|
27
|
-
if (res[field] && res[field] == value) {
|
|
28
|
-
// put the current element at the beginning of the array
|
|
29
|
-
resources.splice(0, 0, resources.splice(index, 1)[0]); // TODO : test with sort
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return resources;
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
export { HighlighterMixin };
|
package/dist/mixins/listMixin.js
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import { html, render } from '../_snowpack/pkg/lit-html.js';
|
|
2
|
-
import { preHTML } from '../libs/lit-helpers.js';
|
|
3
|
-
import { ifDefined } from '../_snowpack/pkg/lit-html/directives/if-defined.js';
|
|
4
|
-
const ListMixin = {
|
|
5
|
-
name: 'list-mixin',
|
|
6
|
-
use: [],
|
|
7
|
-
attributes: {
|
|
8
|
-
emptyWidget: {
|
|
9
|
-
type: String,
|
|
10
|
-
default: null
|
|
11
|
-
},
|
|
12
|
-
emptyValue: {
|
|
13
|
-
type: String,
|
|
14
|
-
default: ''
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
|
-
initialState: {
|
|
18
|
-
// Processors functions to execute on the list before rendering
|
|
19
|
-
listPostProcessors: [],
|
|
20
|
-
// Rendering to execute after all the processors have been executed
|
|
21
|
-
renderCallbacks: []
|
|
22
|
-
},
|
|
23
|
-
created() {
|
|
24
|
-
this.listPostProcessors = [];
|
|
25
|
-
this.renderCallbacks = [];
|
|
26
|
-
},
|
|
27
|
-
appendSingleElt(parent) {
|
|
28
|
-
this.appendChildElt(this.resource['@id'], parent);
|
|
29
|
-
},
|
|
30
|
-
setElementAttribute(attr) {
|
|
31
|
-
const containerAttribute = "solid-container";
|
|
32
|
-
const resourceAttribute = "solid-resource";
|
|
33
|
-
if (attr === "resource") {
|
|
34
|
-
this.element.removeAttribute(containerAttribute);
|
|
35
|
-
this.element.setAttribute(resourceAttribute, "");
|
|
36
|
-
} else {
|
|
37
|
-
this.element.removeAttribute(resourceAttribute);
|
|
38
|
-
this.element.setAttribute(containerAttribute, "");
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
async populate() {
|
|
42
|
-
const div = this.div;
|
|
43
|
-
if (!this.resource) return;
|
|
44
|
-
|
|
45
|
-
// Not a container but a single resource
|
|
46
|
-
if (!this.resource.isContainer?.() && !this.arrayField && !this.predicateName) {
|
|
47
|
-
this.setElementAttribute("resource");
|
|
48
|
-
this.appendSingleElt(div);
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
if (this.resource.isContainer?.()) {
|
|
52
|
-
this.setElementAttribute("container");
|
|
53
|
-
const listPostProcessors = [...this.listPostProcessors];
|
|
54
|
-
this.renderCallbacks = [];
|
|
55
|
-
listPostProcessors.push(this.renderDOM.bind(this));
|
|
56
|
-
listPostProcessors.push(this.handleEmptyWidget.bind(this));
|
|
57
|
-
|
|
58
|
-
// Execute the first post-processor of the list
|
|
59
|
-
const nextProcessor = listPostProcessors.shift();
|
|
60
|
-
await nextProcessor(this.resource['ldp:contains'], listPostProcessors, div, this.dataSrc);
|
|
61
|
-
} else if (this.arrayField && this.predicateName && this.resource[this.predicateName]) {
|
|
62
|
-
this.setElementAttribute("container");
|
|
63
|
-
const listPostProcessors = [...this.listPostProcessors];
|
|
64
|
-
this.renderCallbacks = [];
|
|
65
|
-
listPostProcessors.push(this.renderDOM.bind(this));
|
|
66
|
-
listPostProcessors.push(this.handleEmptyWidget.bind(this));
|
|
67
|
-
|
|
68
|
-
// Execute the first post-processor of the list
|
|
69
|
-
const nextProcessor = listPostProcessors.shift();
|
|
70
|
-
await nextProcessor(await this.resource[this.predicateName], listPostProcessors, div, this.dataSrc);
|
|
71
|
-
}
|
|
72
|
-
// Execute the render callbacks
|
|
73
|
-
for (const renderCallback of this.renderCallbacks) {
|
|
74
|
-
// Render the template in the given parent element
|
|
75
|
-
render(renderCallback.template, renderCallback.parent);
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
/**
|
|
79
|
-
* Render resources in the DOM
|
|
80
|
-
* @param resources
|
|
81
|
-
* @param listPostProcessors
|
|
82
|
-
* @param div
|
|
83
|
-
* @param context
|
|
84
|
-
*/
|
|
85
|
-
async renderDOM(resources, listPostProcessors, div, context) {
|
|
86
|
-
// Create child components
|
|
87
|
-
for (let resource of resources) {
|
|
88
|
-
if (!resource) continue;
|
|
89
|
-
this.appendChildElt(resource['@id'], div);
|
|
90
|
-
}
|
|
91
|
-
const nextProcessor = listPostProcessors.shift();
|
|
92
|
-
if (nextProcessor) await nextProcessor(resources, listPostProcessors, div, context);
|
|
93
|
-
},
|
|
94
|
-
/**
|
|
95
|
-
* Show empty widget if no resources in the list
|
|
96
|
-
* @param resources
|
|
97
|
-
* @param listPostProcessors
|
|
98
|
-
* @param div
|
|
99
|
-
* @param context
|
|
100
|
-
*/
|
|
101
|
-
async handleEmptyWidget(resources, listPostProcessors, div, context) {
|
|
102
|
-
if (this.emptyWidget) {
|
|
103
|
-
const emptyWidgetTemplate = preHTML`
|
|
104
|
-
<${this.emptyWidget} value=${ifDefined(this.emptyValue)}></${this.emptyWidget}>
|
|
105
|
-
`;
|
|
106
|
-
if (!this.emptyWrapper) {
|
|
107
|
-
this.emptyWrapper = document.createElement('span');
|
|
108
|
-
this.element.appendChild(this.emptyWrapper);
|
|
109
|
-
}
|
|
110
|
-
render(resources.length > 0 ? html`` : emptyWidgetTemplate, this.emptyWrapper);
|
|
111
|
-
}
|
|
112
|
-
const nextProcessor = listPostProcessors.shift();
|
|
113
|
-
if (nextProcessor) await nextProcessor(resources, listPostProcessors, div, context);
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
export { ListMixin };
|
package/dist/mixins/nextMixin.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
const NextMixin = {
|
|
2
|
-
name: 'next-mixin',
|
|
3
|
-
use: [],
|
|
4
|
-
attributes: {
|
|
5
|
-
next: {
|
|
6
|
-
type: String,
|
|
7
|
-
default: ''
|
|
8
|
-
}
|
|
9
|
-
},
|
|
10
|
-
// Here "even.target" points to the content of the widgets of the children of solid-display
|
|
11
|
-
goToNext(resource) {
|
|
12
|
-
if (this.next) {
|
|
13
|
-
this.element.dispatchEvent(new CustomEvent('requestNavigation', {
|
|
14
|
-
bubbles: true,
|
|
15
|
-
detail: {
|
|
16
|
-
route: this.next,
|
|
17
|
-
resource: resource
|
|
18
|
-
}
|
|
19
|
-
}));
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
export { NextMixin };
|