@startinblox/core 0.0.0
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/LICENSE +21 -0
- package/README.md +182 -0
- package/dist/_snowpack/pkg/autolinker.js +4429 -0
- package/dist/_snowpack/pkg/autolinker.js.map +1 -0
- package/dist/_snowpack/pkg/common/_baseUnary-c1edb653.js +353 -0
- package/dist/_snowpack/pkg/common/_baseUnary-c1edb653.js.map +1 -0
- package/dist/_snowpack/pkg/common/_commonjsHelpers-37fa8da4.js +26 -0
- package/dist/_snowpack/pkg/common/_commonjsHelpers-37fa8da4.js.map +1 -0
- package/dist/_snowpack/pkg/common/decode-26fbf385.js +185 -0
- 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 +26198 -0
- package/dist/_snowpack/pkg/delta-markdown-for-quill.js.map +1 -0
- package/dist/_snowpack/pkg/dialog-polyfill.js +827 -0
- package/dist/_snowpack/pkg/dialog-polyfill.js.map +1 -0
- package/dist/_snowpack/pkg/fusejs.js +1593 -0
- package/dist/_snowpack/pkg/fusejs.js.map +1 -0
- package/dist/_snowpack/pkg/import-map.json +24 -0
- package/dist/_snowpack/pkg/jsonld-context-parser.js +836 -0
- package/dist/_snowpack/pkg/jsonld-context-parser.js.map +1 -0
- package/dist/_snowpack/pkg/leaflet/dist/leaflet.css +640 -0
- package/dist/_snowpack/pkg/leaflet/dist/leaflet.css.proxy.js +10 -0
- package/dist/_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.Default.css +60 -0
- package/dist/_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.Default.css.proxy.js +10 -0
- package/dist/_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.css +14 -0
- package/dist/_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.css.proxy.js +10 -0
- package/dist/_snowpack/pkg/lit-html/directives/if-defined.js +39 -0
- package/dist/_snowpack/pkg/lit-html/directives/if-defined.js.map +1 -0
- package/dist/_snowpack/pkg/lit-html/directives/unsafe-html.js +48 -0
- package/dist/_snowpack/pkg/lit-html/directives/unsafe-html.js.map +1 -0
- package/dist/_snowpack/pkg/lit-html/directives/until.js +87 -0
- package/dist/_snowpack/pkg/lit-html/directives/until.js.map +1 -0
- package/dist/_snowpack/pkg/lit-html.js +94 -0
- package/dist/_snowpack/pkg/lit-html.js.map +1 -0
- package/dist/_snowpack/pkg/markdown-it-link-attributes.js +68 -0
- package/dist/_snowpack/pkg/markdown-it-link-attributes.js.map +1 -0
- package/dist/_snowpack/pkg/markdown-it.js +11307 -0
- package/dist/_snowpack/pkg/markdown-it.js.map +1 -0
- package/dist/_snowpack/pkg/quill/dist/quill.snow.css +945 -0
- package/dist/_snowpack/pkg/quill/dist/quill.snow.css.proxy.js +10 -0
- package/dist/_snowpack/pkg/quill-delta-to-markdown.js +971 -0
- package/dist/_snowpack/pkg/quill-delta-to-markdown.js.map +1 -0
- package/dist/_snowpack/pkg/quill.js +14442 -0
- package/dist/_snowpack/pkg/quill.js.map +1 -0
- package/dist/_snowpack/pkg/slim-select.js +714 -0
- package/dist/_snowpack/pkg/slim-select.js.map +1 -0
- package/dist/_snowpack/pkg/tui-calendar/dist/tui-calendar.css +1149 -0
- package/dist/_snowpack/pkg/tui-calendar/dist/tui-calendar.css.proxy.js +10 -0
- package/dist/_snowpack/pkg/tui-calendar.js +46507 -0
- package/dist/_snowpack/pkg/tui-calendar.js.map +1 -0
- package/dist/components/solid-ac-checker.js +45 -0
- package/dist/components/solid-calendar.js +66 -0
- package/dist/components/solid-delete.js +96 -0
- package/dist/components/solid-display.js +150 -0
- package/dist/components/solid-form-search.js +177 -0
- package/dist/components/solid-form.js +259 -0
- package/dist/components/solid-lang.js +35 -0
- package/dist/components/solid-map.js +204 -0
- package/dist/components/solid-table.js +181 -0
- package/dist/components/solid-widget.js +72 -0
- package/dist/import.css +4 -0
- package/dist/index.js +49 -0
- package/dist/libs/Component.js +13 -0
- package/dist/libs/ComponentFactory.js +168 -0
- package/dist/libs/Compositor.js +96 -0
- package/dist/libs/Sib.js +44 -0
- package/dist/libs/filter.js +184 -0
- package/dist/libs/helpers.js +194 -0
- package/dist/libs/interfaces.js +6 -0
- package/dist/libs/lit-helpers.js +142 -0
- package/dist/libs/polyfills.js +37 -0
- package/dist/libs/store/server-pagination.js +22 -0
- package/dist/libs/store/server-search.js +35 -0
- package/dist/libs/store/store.js +814 -0
- package/dist/locales/en.json +10 -0
- package/dist/locales/en.json.proxy.js +2 -0
- package/dist/locales/fr.json +10 -0
- package/dist/locales/fr.json.proxy.js +2 -0
- package/dist/mixins/attributeBinderMixin.js +116 -0
- package/dist/mixins/contextMixin.js +26 -0
- package/dist/mixins/counterMixin.js +54 -0
- package/dist/mixins/federationMixin.js +51 -0
- package/dist/mixins/filterMixin.js +155 -0
- package/dist/mixins/grouperMixin.js +73 -0
- package/dist/mixins/highlighterMixin.js +36 -0
- package/dist/mixins/interfaces.js +6 -0
- package/dist/mixins/listMixin.js +105 -0
- package/dist/mixins/nextMixin.js +23 -0
- package/dist/mixins/paginateMixin.js +97 -0
- package/dist/mixins/requiredMixin.js +26 -0
- package/dist/mixins/serverPaginationMixin.js +122 -0
- package/dist/mixins/sorterMixin.js +131 -0
- package/dist/mixins/storeMixin.js +109 -0
- package/dist/mixins/translationMixin.js +58 -0
- package/dist/mixins/validationMixin.js +95 -0
- package/dist/mixins/widgetMixin.js +351 -0
- package/dist/new-widgets/attributeMixins/actionMixin.js +13 -0
- package/dist/new-widgets/attributeMixins/blankMixin.js +7 -0
- package/dist/new-widgets/attributeMixins/booleanMixin.js +7 -0
- package/dist/new-widgets/attributeMixins/index.js +19 -0
- package/dist/new-widgets/attributeMixins/mailtoMixin.js +7 -0
- package/dist/new-widgets/attributeMixins/multipleMixin.js +27 -0
- package/dist/new-widgets/attributeMixins/numberMixin.js +7 -0
- package/dist/new-widgets/attributeMixins/placeholderMixin.js +16 -0
- package/dist/new-widgets/attributeMixins/telMixin.js +7 -0
- package/dist/new-widgets/baseWidgetMixin.js +109 -0
- package/dist/new-widgets/callbackMixins/autocompletionMixin.js +96 -0
- package/dist/new-widgets/callbackMixins/index.js +7 -0
- package/dist/new-widgets/callbackMixins/richtextMixin.js +37 -0
- package/dist/new-widgets/callbackMixins/slimselect.css +2 -0
- package/dist/new-widgets/callbackMixins/slimselect.css.proxy.js +10 -0
- package/dist/new-widgets/interfaces.js +1 -0
- package/dist/new-widgets/new-widget-factory.js +91 -0
- package/dist/new-widgets/templateAdditionMixins/addableMixin.js +26 -0
- package/dist/new-widgets/templateAdditionMixins/index.js +13 -0
- package/dist/new-widgets/templateAdditionMixins/labelLastMixin.js +16 -0
- package/dist/new-widgets/templateAdditionMixins/labelMixin.js +18 -0
- package/dist/new-widgets/templates/defaultTemplatesDirectory.js +29 -0
- package/dist/new-widgets/templates/displayTemplatesDirectory.js +54 -0
- package/dist/new-widgets/templates/formTemplatesDirectory.js +432 -0
- package/dist/new-widgets/templates/groupTemplatesDirectory.js +11 -0
- package/dist/new-widgets/templates/index.js +6 -0
- package/dist/new-widgets/templates/setTemplatesDirectory.js +16 -0
- package/dist/new-widgets/templatesDependencies/altMixin.js +12 -0
- package/dist/new-widgets/templatesDependencies/editableMixin.js +60 -0
- package/dist/new-widgets/templatesDependencies/filterRangeFormMixin.js +34 -0
- package/dist/new-widgets/templatesDependencies/formCheckboxMixin.js +10 -0
- package/dist/new-widgets/templatesDependencies/formCheckboxesMixin.js +41 -0
- package/dist/new-widgets/templatesDependencies/formDropdownMixin.js +56 -0
- package/dist/new-widgets/templatesDependencies/formFileMixin.js +82 -0
- package/dist/new-widgets/templatesDependencies/formLengthMixin.js +18 -0
- package/dist/new-widgets/templatesDependencies/formMinMaxMixin.js +18 -0
- package/dist/new-widgets/templatesDependencies/formMixin.js +56 -0
- package/dist/new-widgets/templatesDependencies/formNumberMixin.js +10 -0
- package/dist/new-widgets/templatesDependencies/formRadioMixin.js +12 -0
- package/dist/new-widgets/templatesDependencies/formStepMixin.js +12 -0
- package/dist/new-widgets/templatesDependencies/linkTextMixin.js +13 -0
- package/dist/new-widgets/templatesDependencies/multipleFormMixin.js +112 -0
- package/dist/new-widgets/templatesDependencies/multipleselectFormMixin.js +65 -0
- package/dist/new-widgets/templatesDependencies/patternMixin.js +18 -0
- package/dist/new-widgets/templatesDependencies/rangeMixin.js +100 -0
- package/dist/new-widgets/templatesDependencies/setMixin.js +9 -0
- package/dist/new-widgets/templatesDependencies/valueRichtextMixin.js +9 -0
- package/dist/new-widgets/valueTransformationMixins/autolinkMixin.js +14 -0
- package/dist/new-widgets/valueTransformationMixins/dateMixin.js +29 -0
- package/dist/new-widgets/valueTransformationMixins/dateTimeMixin.js +12 -0
- package/dist/new-widgets/valueTransformationMixins/index.js +15 -0
- package/dist/new-widgets/valueTransformationMixins/markdownMixin.js +30 -0
- package/dist/new-widgets/valueTransformationMixins/multilineMixin.js +13 -0
- package/dist/new-widgets/valueTransformationMixins/oembedMixin.js +21 -0
- package/dist/solid-template-element.js +144 -0
- package/dist/style/default-theme.css +24 -0
- package/dist/style/default-theme.css.proxy.js +10 -0
- package/dist/widgets/baseWidget.js +268 -0
- package/dist/widgets/widget-factory.js +22 -0
- package/package.json +117 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { store } from "../../libs/store/store.js";
|
|
2
|
+
const FormFileMixin = {
|
|
3
|
+
name: 'form-file-mixin',
|
|
4
|
+
attributes: {
|
|
5
|
+
uploadUrl: {
|
|
6
|
+
type: String,
|
|
7
|
+
default: ''
|
|
8
|
+
}
|
|
9
|
+
},
|
|
10
|
+
initialState: {
|
|
11
|
+
initialValue: ''
|
|
12
|
+
},
|
|
13
|
+
created() {
|
|
14
|
+
this.listAttributes['output'] = '';
|
|
15
|
+
this.listAttributes['resetButtonHidden'] = true;
|
|
16
|
+
this.listAttributes['selectFile'] = this.selectFile.bind(this);
|
|
17
|
+
this.listAttributes['resetFile'] = this.resetFile.bind(this);
|
|
18
|
+
},
|
|
19
|
+
attached() {
|
|
20
|
+
document.addEventListener('reset', e => {
|
|
21
|
+
if (e.target && e.target.contains(this.element)) {
|
|
22
|
+
this.value = this.initialValue;
|
|
23
|
+
this.listAttributes['resetButtonHidden'] = true;
|
|
24
|
+
this.planRender();
|
|
25
|
+
const dataHolder = this.element.querySelector('input[data-holder]');
|
|
26
|
+
dataHolder.value = this.value;
|
|
27
|
+
dataHolder.dispatchEvent(new Event('change'));
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
},
|
|
31
|
+
selectFile() {
|
|
32
|
+
if (this.uploadUrl === null) return;
|
|
33
|
+
if (this.initialValue === '') {
|
|
34
|
+
this.initialValue = this.value;
|
|
35
|
+
}
|
|
36
|
+
const filePicker = this.element.querySelector('input[type="file"]');
|
|
37
|
+
if (filePicker.files.length < 1) return;
|
|
38
|
+
const dataHolder = this.element.querySelector('input[data-holder]');
|
|
39
|
+
this.listAttributes['output'] = '⏳';
|
|
40
|
+
this.planRender();
|
|
41
|
+
const file = filePicker.files[0];
|
|
42
|
+
const formData = new FormData();
|
|
43
|
+
formData.append('file', file);
|
|
44
|
+
store.fetchAuthn(this.uploadUrl, {
|
|
45
|
+
method: 'POST',
|
|
46
|
+
body: formData
|
|
47
|
+
}).then(response => this.updateFile(dataHolder, response)).catch(error => {
|
|
48
|
+
this.listAttributes['fileValue'] = '';
|
|
49
|
+
this.listAttributes['output'] = 'upload error';
|
|
50
|
+
this.planRender();
|
|
51
|
+
console.error(error);
|
|
52
|
+
});
|
|
53
|
+
},
|
|
54
|
+
updateFile(dataHolder, response) {
|
|
55
|
+
const location = response.headers.get('location');
|
|
56
|
+
if (location == null) {
|
|
57
|
+
this.listAttributes['output'] = 'header location not found!';
|
|
58
|
+
} else {
|
|
59
|
+
this.value = location;
|
|
60
|
+
this.listAttributes['output'] = '';
|
|
61
|
+
this.listAttributes['resetButtonHidden'] = false;
|
|
62
|
+
dataHolder.value = location;
|
|
63
|
+
dataHolder.dispatchEvent(new Event('change'));
|
|
64
|
+
this.planRender();
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
resetFile(event) {
|
|
68
|
+
event.preventDefault();
|
|
69
|
+
this.value = '';
|
|
70
|
+
const filePicker = this.element.querySelector('input[type="file"]');
|
|
71
|
+
const dataHolder = this.element.querySelector('input[data-holder]');
|
|
72
|
+
if (filePicker && dataHolder) {
|
|
73
|
+
filePicker.value = dataHolder.value = '';
|
|
74
|
+
}
|
|
75
|
+
this.listAttributes['fileValue'] = '';
|
|
76
|
+
this.listAttributes['output'] = '';
|
|
77
|
+
this.listAttributes['resetButtonHidden'] = true;
|
|
78
|
+
dataHolder.dispatchEvent(new Event('change'));
|
|
79
|
+
this.planRender();
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
export { FormFileMixin };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const FormLengthMixin = {
|
|
2
|
+
name: 'form-length-mixin',
|
|
3
|
+
attributes: {
|
|
4
|
+
maxlength: {
|
|
5
|
+
type: Number,
|
|
6
|
+
callback: function (newValue) {
|
|
7
|
+
this.addToAttributes(newValue, 'maxlength');
|
|
8
|
+
}
|
|
9
|
+
},
|
|
10
|
+
minlength: {
|
|
11
|
+
type: Number,
|
|
12
|
+
callback: function (newValue) {
|
|
13
|
+
this.addToAttributes(newValue, 'minlength');
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
export { FormLengthMixin };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const FormMinMaxMixin = {
|
|
2
|
+
name: 'form-min-max-mixin',
|
|
3
|
+
attributes: {
|
|
4
|
+
min: {
|
|
5
|
+
type: Number,
|
|
6
|
+
callback: function (newValue) {
|
|
7
|
+
this.addToAttributes(newValue, 'min');
|
|
8
|
+
}
|
|
9
|
+
},
|
|
10
|
+
max: {
|
|
11
|
+
type: Number,
|
|
12
|
+
callback: function (newValue) {
|
|
13
|
+
this.addToAttributes(newValue, 'max');
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
export { FormMinMaxMixin };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
const FormMixin = {
|
|
2
|
+
name: 'form-mixin',
|
|
3
|
+
attributes: {
|
|
4
|
+
required: {
|
|
5
|
+
type: Boolean,
|
|
6
|
+
default: false,
|
|
7
|
+
callback: function () {
|
|
8
|
+
this.listAttributes['required'] = true;
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
autocomplete: {
|
|
12
|
+
type: String,
|
|
13
|
+
default: '',
|
|
14
|
+
callback: function (value) {
|
|
15
|
+
this.addToAttributes(value, "autocomplete");
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
attached() {
|
|
20
|
+
this.listAttributes['onChange'] = this.onChange.bind(this);
|
|
21
|
+
},
|
|
22
|
+
onChange(e) {
|
|
23
|
+
e.preventDefault();
|
|
24
|
+
e.stopPropagation();
|
|
25
|
+
this.element.dispatchEvent(new Event('change', {
|
|
26
|
+
bubbles: true
|
|
27
|
+
}));
|
|
28
|
+
},
|
|
29
|
+
getValue() {
|
|
30
|
+
if (!this.dataHolder || this.dataHolder.length === 0) return this.value;
|
|
31
|
+
if (this.dataHolder.length > 1) this.showDataHolderError(1, this.dataHolder.length);
|
|
32
|
+
return this.getValueFromElement(this.dataHolder[0]);
|
|
33
|
+
},
|
|
34
|
+
get type() {
|
|
35
|
+
return 'string';
|
|
36
|
+
},
|
|
37
|
+
get multiple() {
|
|
38
|
+
return false;
|
|
39
|
+
},
|
|
40
|
+
get dataHolder() {
|
|
41
|
+
const dataHolders = Array.from(this.element.querySelectorAll('[data-holder]'));
|
|
42
|
+
const widgetDataHolders = dataHolders.filter(element => {
|
|
43
|
+
const dataHolderAncestor = element.parentElement ? element.parentElement.closest('[data-holder]') : null;
|
|
44
|
+
// get the dataHolder of the widget only if no dataHolder ancestor in the current widget
|
|
45
|
+
return dataHolderAncestor === this.element || !dataHolderAncestor || !this.element.contains(dataHolderAncestor);
|
|
46
|
+
});
|
|
47
|
+
return widgetDataHolders.length ? widgetDataHolders : null;
|
|
48
|
+
},
|
|
49
|
+
getValueFromElement(element) {
|
|
50
|
+
return element.component ? element.component.getValue() : element.value;
|
|
51
|
+
},
|
|
52
|
+
showDataHolderError(expected, found) {
|
|
53
|
+
console.warn(`Expected ${expected} data-holder element in ${this.element.tagName}. Found ${found}`);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
export { FormMixin };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { uniqID } from '../../libs/helpers.js';
|
|
2
|
+
const FormRadioMixin = {
|
|
3
|
+
name: 'form-radio-mixin',
|
|
4
|
+
created() {
|
|
5
|
+
this.listAttributes['id'] = uniqID();
|
|
6
|
+
},
|
|
7
|
+
getValue() {
|
|
8
|
+
const checkedElement = this.element.querySelector('input[type=radio]:checked');
|
|
9
|
+
return checkedElement ? checkedElement.value : '';
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
export { FormRadioMixin };
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { StoreMixin } from '../../mixins/storeMixin.js';
|
|
2
|
+
const MultipleFormMixin = {
|
|
3
|
+
name: 'multiple-form-mixin',
|
|
4
|
+
use: [StoreMixin],
|
|
5
|
+
attributes: {
|
|
6
|
+
widget: {
|
|
7
|
+
type: String,
|
|
8
|
+
default: 'solid-form-text'
|
|
9
|
+
},
|
|
10
|
+
addLabel: {
|
|
11
|
+
type: String,
|
|
12
|
+
default: '+',
|
|
13
|
+
callback: function (value) {
|
|
14
|
+
if (value !== this.listAttributes['addLabel']) this.listAttributes['addLabel'] = value;
|
|
15
|
+
this.planRender();
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
removeLabel: {
|
|
19
|
+
type: String,
|
|
20
|
+
default: '×',
|
|
21
|
+
callback: function (value) {
|
|
22
|
+
if (value !== this.listAttributes['removeLabel']) this.listAttributes['removeLabel'] = value;
|
|
23
|
+
this.planRender();
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
range: {
|
|
27
|
+
type: String,
|
|
28
|
+
default: ''
|
|
29
|
+
},
|
|
30
|
+
addClass: {
|
|
31
|
+
type: String,
|
|
32
|
+
default: undefined,
|
|
33
|
+
callback: function (value) {
|
|
34
|
+
if (value !== this.listAttributes['addClass']) this.listAttributes['addClass'] = value;
|
|
35
|
+
this.planRender();
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
removeClass: {
|
|
39
|
+
type: String,
|
|
40
|
+
default: undefined,
|
|
41
|
+
callback: function (value) {
|
|
42
|
+
if (value !== this.listAttributes['removeClass']) this.listAttributes['removeClass'] = value;
|
|
43
|
+
this.planRender();
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
created() {
|
|
48
|
+
this.listValueTransformations.push(this.setDataSrc.bind(this));
|
|
49
|
+
this.listAttributes['children'] = [];
|
|
50
|
+
this.listAttributes['addLabel'] = this.addLabel;
|
|
51
|
+
this.listAttributes['removeLabel'] = this.removeLabel;
|
|
52
|
+
this.listAttributes['addClass'] = this.addClass;
|
|
53
|
+
this.listAttributes['removeClass'] = this.removeClass;
|
|
54
|
+
this.listAttributes['addItem'] = () => {
|
|
55
|
+
this.insertWidget();
|
|
56
|
+
this.planRender();
|
|
57
|
+
};
|
|
58
|
+
this.listAttributes['removeItem'] = index => {
|
|
59
|
+
this.element.querySelector(`[data-index="${this.name + index}"]`).remove();
|
|
60
|
+
this.element.dispatchEvent(new Event('change', {
|
|
61
|
+
bubbles: true
|
|
62
|
+
}));
|
|
63
|
+
};
|
|
64
|
+
},
|
|
65
|
+
setDataSrc(value, listValueTransformations) {
|
|
66
|
+
if (value && value !== this.dataSrc) this.dataSrc = value;
|
|
67
|
+
const nextProcessor = listValueTransformations.shift();
|
|
68
|
+
if (nextProcessor) nextProcessor(value, listValueTransformations);
|
|
69
|
+
},
|
|
70
|
+
populate() {
|
|
71
|
+
if (!this.resource || !this.resource['ldp:contains']) return;
|
|
72
|
+
this.listAttributes['children'] = []; // reset list
|
|
73
|
+
|
|
74
|
+
// set value in form
|
|
75
|
+
for (let resource of this.resource['ldp:contains']) {
|
|
76
|
+
// for each resource
|
|
77
|
+
this.insertWidget(resource['@id']); // create a widget
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
this.planRender();
|
|
81
|
+
},
|
|
82
|
+
insertWidget() {
|
|
83
|
+
let value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
84
|
+
if (!this.widget) return;
|
|
85
|
+
const widget = document.createElement(this.widget);
|
|
86
|
+
const attributes = {
|
|
87
|
+
'data-holder': true,
|
|
88
|
+
'name': this.name,
|
|
89
|
+
'value': value,
|
|
90
|
+
'range': this.range
|
|
91
|
+
};
|
|
92
|
+
for (let name of Object.keys(attributes)) {
|
|
93
|
+
if (typeof attributes[name] === "boolean") widget.toggleAttribute(name, attributes[name]);else widget.setAttribute(name, attributes[name]);
|
|
94
|
+
}
|
|
95
|
+
this.listAttributes['children'].push(widget);
|
|
96
|
+
},
|
|
97
|
+
empty() {
|
|
98
|
+
this.listAttributes['children'] = [];
|
|
99
|
+
this.planRender();
|
|
100
|
+
},
|
|
101
|
+
getValue() {
|
|
102
|
+
if (!this.dataHolder) return [];
|
|
103
|
+
return Array.from(this.dataHolder).map(element => this.getValueFromElement(element));
|
|
104
|
+
},
|
|
105
|
+
get type() {
|
|
106
|
+
return 'resource';
|
|
107
|
+
},
|
|
108
|
+
get multiple() {
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
export { MultipleFormMixin };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { StoreMixin } from '../../mixins/storeMixin.js';
|
|
2
|
+
const MultipleselectFormMixin = {
|
|
3
|
+
name: 'multipleselect-form-mixin',
|
|
4
|
+
use: [StoreMixin],
|
|
5
|
+
attributes: {
|
|
6
|
+
range: {
|
|
7
|
+
// range attribute is passed to the solid-dropdown
|
|
8
|
+
type: String,
|
|
9
|
+
default: '',
|
|
10
|
+
callback: function (value) {
|
|
11
|
+
if (value && value !== this.listAttributes['range']) this.listAttributes['range'] = value;
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
enum: {
|
|
15
|
+
// enum attribute is passed to the solid-dropdown
|
|
16
|
+
type: String,
|
|
17
|
+
default: '',
|
|
18
|
+
callback: function (value) {
|
|
19
|
+
if (value && value !== this.listAttributes['enum']) this.listAttributes['enum'] = value;
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
orderAsc: {
|
|
23
|
+
type: String,
|
|
24
|
+
default: 'name',
|
|
25
|
+
callback: function (newValue) {
|
|
26
|
+
this.addToAttributes(newValue, 'orderAsc');
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
orderDesc: {
|
|
30
|
+
type: String,
|
|
31
|
+
default: 'name',
|
|
32
|
+
callback: function (newValue) {
|
|
33
|
+
this.addToAttributes(newValue, 'orderDesc');
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
created() {
|
|
38
|
+
this.listValueTransformations.push(this.setDataSrc.bind(this));
|
|
39
|
+
},
|
|
40
|
+
setDataSrc(value, listValueTransformations) {
|
|
41
|
+
if (value && value !== this.dataSrc) this.dataSrc = value;
|
|
42
|
+
const nextProcessor = listValueTransformations.shift();
|
|
43
|
+
if (nextProcessor) nextProcessor(value, listValueTransformations);
|
|
44
|
+
},
|
|
45
|
+
populate() {
|
|
46
|
+
if (!this.resource || !this.resource['ldp:contains']) return;
|
|
47
|
+
this.setValue(this.resource['ldp:contains']);
|
|
48
|
+
this.planRender();
|
|
49
|
+
},
|
|
50
|
+
setValue(values) {
|
|
51
|
+
// set the values to the dropdown
|
|
52
|
+
this.listAttributes['values'] = JSON.stringify(values.map(r => r['@id']));
|
|
53
|
+
},
|
|
54
|
+
empty() {
|
|
55
|
+
this.listAttributes['values'] = [];
|
|
56
|
+
this.planRender();
|
|
57
|
+
},
|
|
58
|
+
get type() {
|
|
59
|
+
return this.enum === '' ? 'resource' : 'string';
|
|
60
|
+
},
|
|
61
|
+
get multiple() {
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
export { MultipleselectFormMixin };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const PatternMixin = {
|
|
2
|
+
name: 'pattern-mixin',
|
|
3
|
+
attributes: {
|
|
4
|
+
pattern: {
|
|
5
|
+
type: String,
|
|
6
|
+
callback: function (newValue) {
|
|
7
|
+
this.addToAttributes(newValue, 'pattern');
|
|
8
|
+
}
|
|
9
|
+
},
|
|
10
|
+
title: {
|
|
11
|
+
type: String,
|
|
12
|
+
callback: function (newValue) {
|
|
13
|
+
this.addToAttributes(newValue, 'title');
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
export { PatternMixin };
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { StoreMixin } from '../../mixins/storeMixin.js';
|
|
2
|
+
import { SorterMixin } from '../../mixins/sorterMixin.js';
|
|
3
|
+
import { FederationMixin } from '../../mixins/federationMixin.js';
|
|
4
|
+
const RangeMixin = {
|
|
5
|
+
name: 'range-mixin',
|
|
6
|
+
use: [StoreMixin, SorterMixin, FederationMixin],
|
|
7
|
+
attributes: {
|
|
8
|
+
range: {
|
|
9
|
+
type: String,
|
|
10
|
+
default: '',
|
|
11
|
+
callback: function (value) {
|
|
12
|
+
if (value !== this.dataSrc) this.dataSrc = value;
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
enum: {
|
|
16
|
+
type: String,
|
|
17
|
+
default: '',
|
|
18
|
+
callback: function (value) {
|
|
19
|
+
if (value !== null) {
|
|
20
|
+
const optional = value.trim().split(",");
|
|
21
|
+
let key;
|
|
22
|
+
let keyValue;
|
|
23
|
+
const list = {};
|
|
24
|
+
optional.forEach(element => {
|
|
25
|
+
if (element.includes("=")) {
|
|
26
|
+
const option = element.trim().split("=");
|
|
27
|
+
key = option[1].trim();
|
|
28
|
+
keyValue = option[0].trim();
|
|
29
|
+
list[key] = keyValue;
|
|
30
|
+
} else {
|
|
31
|
+
const elem = element.trim();
|
|
32
|
+
list[elem] = elem;
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
this.addToAttributes(list, 'enum');
|
|
36
|
+
}
|
|
37
|
+
;
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
optionLabel: {
|
|
41
|
+
type: String,
|
|
42
|
+
default: 'name',
|
|
43
|
+
callback: function (newValue) {
|
|
44
|
+
this.addToAttributes(newValue, 'optionLabel');
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
optionValue: {
|
|
48
|
+
type: String,
|
|
49
|
+
default: '@id',
|
|
50
|
+
callback: function (newValue) {
|
|
51
|
+
this.addToAttributes(newValue, 'optionValue');
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
initialState: {
|
|
56
|
+
listPostProcessors: []
|
|
57
|
+
},
|
|
58
|
+
created() {
|
|
59
|
+
this.listPostProcessors = [];
|
|
60
|
+
this.listAttributes['optionLabel'] = this.optionLabel;
|
|
61
|
+
this.listAttributes['optionValue'] = this.optionValue;
|
|
62
|
+
},
|
|
63
|
+
async populate() {
|
|
64
|
+
const resources = this.resource ? this.resource['ldp:contains'] : [];
|
|
65
|
+
const listPostProcessors = [...this.listPostProcessors];
|
|
66
|
+
listPostProcessors.push(this.setRangeAttribute.bind(this));
|
|
67
|
+
const nextProcessor = listPostProcessors.shift();
|
|
68
|
+
await nextProcessor(resources, listPostProcessors, null, this.dataSrc);
|
|
69
|
+
},
|
|
70
|
+
async setRangeAttribute(resources) {
|
|
71
|
+
if (resources) {
|
|
72
|
+
// process resources to create the template
|
|
73
|
+
const getRangeValue = async resource => {
|
|
74
|
+
const selectedValue = await resource[this.optionValue]; // value used for selected options
|
|
75
|
+
const value = this.optionValue.includes('@id') || selectedValue['@id'] ?
|
|
76
|
+
// value of the option
|
|
77
|
+
`{"@id": "${selectedValue}"}` :
|
|
78
|
+
// resource
|
|
79
|
+
selectedValue; // literal
|
|
80
|
+
const label = await resource[this.optionLabel]; // label of the option
|
|
81
|
+
|
|
82
|
+
return {
|
|
83
|
+
value,
|
|
84
|
+
label,
|
|
85
|
+
selectedValue
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
this.listAttributes['range'] = await Promise.all(resources.filter(el => el !== null).map(r => getRangeValue(r)));
|
|
89
|
+
}
|
|
90
|
+
this.planRender();
|
|
91
|
+
},
|
|
92
|
+
empty() {
|
|
93
|
+
this.listAttributes['range'] = [];
|
|
94
|
+
this.planRender();
|
|
95
|
+
},
|
|
96
|
+
get type() {
|
|
97
|
+
return this.enum === '' ? 'resource' : 'string';
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
export { RangeMixin };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import qdtm from '../../_snowpack/pkg/quill-delta-to-markdown.js';
|
|
2
|
+
const ValueRichtextMixin = {
|
|
3
|
+
name: 'valuerichtext-mixin',
|
|
4
|
+
getValue() {
|
|
5
|
+
const markdown = qdtm.deltaToMarkdown(this.quill.getContents().ops);
|
|
6
|
+
return markdown;
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
export { ValueRichtextMixin };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Autolinker } from '../../_snowpack/pkg/autolinker.js';
|
|
2
|
+
const AutolinkMixin = {
|
|
3
|
+
name: 'autolink-mixin',
|
|
4
|
+
created() {
|
|
5
|
+
this.listValueTransformations.push(this.transformValue.bind(this));
|
|
6
|
+
},
|
|
7
|
+
transformValue(value, listValueTransformations) {
|
|
8
|
+
const template = document.createElement('template');
|
|
9
|
+
template.innerHTML = Autolinker.link(value);
|
|
10
|
+
const nextProcessor = listValueTransformations.shift();
|
|
11
|
+
if (nextProcessor) nextProcessor(template.content, listValueTransformations);
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
export { AutolinkMixin };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const DateMixin = {
|
|
2
|
+
name: 'date-mixin',
|
|
3
|
+
created() {
|
|
4
|
+
this.listValueTransformations.push(this.transformValue.bind(this));
|
|
5
|
+
},
|
|
6
|
+
transformValue(value, listValueTransformations) {
|
|
7
|
+
try {
|
|
8
|
+
// workaround for giving a specific-formatted value to the form widget
|
|
9
|
+
this.listAttributes['originalValue'] = this.formatDateForInput(value);
|
|
10
|
+
} catch (e) {
|
|
11
|
+
console.warn('Invalid date format for widget', this.name);
|
|
12
|
+
this.listAttributes['originalValue'] = '';
|
|
13
|
+
}
|
|
14
|
+
const newValue = value ? new Date(value).toLocaleDateString() : value;
|
|
15
|
+
const nextProcessor = listValueTransformations.shift();
|
|
16
|
+
if (nextProcessor) nextProcessor(newValue, listValueTransformations);
|
|
17
|
+
},
|
|
18
|
+
formatDateForInput(date) {
|
|
19
|
+
let d = new Date(date);
|
|
20
|
+
if (isNaN(d.getTime())) throw new Error('Invalid date');
|
|
21
|
+
let month = `${d.getMonth() + 1}`;
|
|
22
|
+
let day = `${d.getDate()}`;
|
|
23
|
+
let year = d.getFullYear();
|
|
24
|
+
if (month.length < 2) month = `0${month}`;
|
|
25
|
+
if (day.length < 2) day = `0${day}`;
|
|
26
|
+
return [year, month, day].join('-');
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
export { DateMixin };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const DateTimeMixin = {
|
|
2
|
+
name: 'date-time-mixin',
|
|
3
|
+
created() {
|
|
4
|
+
this.listValueTransformations.push(this.transformValue.bind(this));
|
|
5
|
+
},
|
|
6
|
+
transformValue(value, listValueTransformations) {
|
|
7
|
+
const newValue = value ? new Date(value).toLocaleString() : value;
|
|
8
|
+
const nextProcessor = listValueTransformations.shift();
|
|
9
|
+
if (nextProcessor) nextProcessor(newValue, listValueTransformations);
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
export { DateTimeMixin };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { DateMixin } from './dateMixin.js';
|
|
2
|
+
import { DateTimeMixin } from './dateTimeMixin.js';
|
|
3
|
+
import { MultilineMixin } from './multilineMixin.js';
|
|
4
|
+
import { MarkdownMixin } from './markdownMixin.js';
|
|
5
|
+
import { OembedMixin } from './oembedMixin.js';
|
|
6
|
+
import { AutolinkMixin } from './autolinkMixin.js';
|
|
7
|
+
const valueTransformationDirectory = {
|
|
8
|
+
date: DateMixin,
|
|
9
|
+
datetime: DateTimeMixin,
|
|
10
|
+
multiline: MultilineMixin,
|
|
11
|
+
markdown: MarkdownMixin,
|
|
12
|
+
oembed: OembedMixin,
|
|
13
|
+
autolink: AutolinkMixin
|
|
14
|
+
};
|
|
15
|
+
export { valueTransformationDirectory, DateMixin, DateTimeMixin, MultilineMixin, MarkdownMixin, OembedMixin, AutolinkMixin };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { unsafeHTML } from '../../_snowpack/pkg/lit-html/directives/unsafe-html.js';
|
|
2
|
+
import markdownit from '../../_snowpack/pkg/markdown-it.js';
|
|
3
|
+
import mila from '../../_snowpack/pkg/markdown-it-link-attributes.js';
|
|
4
|
+
const MarkdownMixin = {
|
|
5
|
+
name: 'markdown-mixin',
|
|
6
|
+
created() {
|
|
7
|
+
this.listValueTransformations.push(this.transformValue.bind(this));
|
|
8
|
+
},
|
|
9
|
+
transformValue(value, listValueTransformations) {
|
|
10
|
+
let newValue = '';
|
|
11
|
+
if (value) {
|
|
12
|
+
const md = markdownit({
|
|
13
|
+
breaks: true,
|
|
14
|
+
html: false,
|
|
15
|
+
linkify: true
|
|
16
|
+
});
|
|
17
|
+
md.use(mila, {
|
|
18
|
+
attrs: {
|
|
19
|
+
target: '_blank',
|
|
20
|
+
rel: 'noopener'
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
const html = md.render(value);
|
|
24
|
+
newValue = unsafeHTML(html);
|
|
25
|
+
}
|
|
26
|
+
const nextProcessor = listValueTransformations.shift();
|
|
27
|
+
if (nextProcessor) nextProcessor(newValue, listValueTransformations);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
export { MarkdownMixin };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { unsafeHTML } from '../../_snowpack/pkg/lit-html/directives/unsafe-html.js';
|
|
2
|
+
const MultilineMixin = {
|
|
3
|
+
name: 'multiline-mixin',
|
|
4
|
+
created() {
|
|
5
|
+
this.listValueTransformations.push(this.transformValue.bind(this));
|
|
6
|
+
},
|
|
7
|
+
transformValue(value, listValueTransformations) {
|
|
8
|
+
const newValue = value ? unsafeHTML(value.replace(/\n/g, "<br/>")) : value;
|
|
9
|
+
const nextProcessor = listValueTransformations.shift();
|
|
10
|
+
if (nextProcessor) nextProcessor(newValue, listValueTransformations);
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
export { MultilineMixin };
|