@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.
Files changed (157) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +182 -0
  3. package/dist/_snowpack/pkg/autolinker.js +4429 -0
  4. package/dist/_snowpack/pkg/autolinker.js.map +1 -0
  5. package/dist/_snowpack/pkg/common/_baseUnary-c1edb653.js +353 -0
  6. package/dist/_snowpack/pkg/common/_baseUnary-c1edb653.js.map +1 -0
  7. package/dist/_snowpack/pkg/common/_commonjsHelpers-37fa8da4.js +26 -0
  8. package/dist/_snowpack/pkg/common/_commonjsHelpers-37fa8da4.js.map +1 -0
  9. package/dist/_snowpack/pkg/common/decode-26fbf385.js +185 -0
  10. package/dist/_snowpack/pkg/common/decode-26fbf385.js.map +1 -0
  11. package/dist/_snowpack/pkg/common/lit-html-3647afce.js +1104 -0
  12. package/dist/_snowpack/pkg/common/lit-html-3647afce.js.map +1 -0
  13. package/dist/_snowpack/pkg/delta-markdown-for-quill.js +26198 -0
  14. package/dist/_snowpack/pkg/delta-markdown-for-quill.js.map +1 -0
  15. package/dist/_snowpack/pkg/dialog-polyfill.js +827 -0
  16. package/dist/_snowpack/pkg/dialog-polyfill.js.map +1 -0
  17. package/dist/_snowpack/pkg/fusejs.js +1593 -0
  18. package/dist/_snowpack/pkg/fusejs.js.map +1 -0
  19. package/dist/_snowpack/pkg/import-map.json +24 -0
  20. package/dist/_snowpack/pkg/jsonld-context-parser.js +836 -0
  21. package/dist/_snowpack/pkg/jsonld-context-parser.js.map +1 -0
  22. package/dist/_snowpack/pkg/leaflet/dist/leaflet.css +640 -0
  23. package/dist/_snowpack/pkg/leaflet/dist/leaflet.css.proxy.js +10 -0
  24. package/dist/_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.Default.css +60 -0
  25. package/dist/_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.Default.css.proxy.js +10 -0
  26. package/dist/_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.css +14 -0
  27. package/dist/_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.css.proxy.js +10 -0
  28. package/dist/_snowpack/pkg/lit-html/directives/if-defined.js +39 -0
  29. package/dist/_snowpack/pkg/lit-html/directives/if-defined.js.map +1 -0
  30. package/dist/_snowpack/pkg/lit-html/directives/unsafe-html.js +48 -0
  31. package/dist/_snowpack/pkg/lit-html/directives/unsafe-html.js.map +1 -0
  32. package/dist/_snowpack/pkg/lit-html/directives/until.js +87 -0
  33. package/dist/_snowpack/pkg/lit-html/directives/until.js.map +1 -0
  34. package/dist/_snowpack/pkg/lit-html.js +94 -0
  35. package/dist/_snowpack/pkg/lit-html.js.map +1 -0
  36. package/dist/_snowpack/pkg/markdown-it-link-attributes.js +68 -0
  37. package/dist/_snowpack/pkg/markdown-it-link-attributes.js.map +1 -0
  38. package/dist/_snowpack/pkg/markdown-it.js +11307 -0
  39. package/dist/_snowpack/pkg/markdown-it.js.map +1 -0
  40. package/dist/_snowpack/pkg/quill/dist/quill.snow.css +945 -0
  41. package/dist/_snowpack/pkg/quill/dist/quill.snow.css.proxy.js +10 -0
  42. package/dist/_snowpack/pkg/quill-delta-to-markdown.js +971 -0
  43. package/dist/_snowpack/pkg/quill-delta-to-markdown.js.map +1 -0
  44. package/dist/_snowpack/pkg/quill.js +14442 -0
  45. package/dist/_snowpack/pkg/quill.js.map +1 -0
  46. package/dist/_snowpack/pkg/slim-select.js +714 -0
  47. package/dist/_snowpack/pkg/slim-select.js.map +1 -0
  48. package/dist/_snowpack/pkg/tui-calendar/dist/tui-calendar.css +1149 -0
  49. package/dist/_snowpack/pkg/tui-calendar/dist/tui-calendar.css.proxy.js +10 -0
  50. package/dist/_snowpack/pkg/tui-calendar.js +46507 -0
  51. package/dist/_snowpack/pkg/tui-calendar.js.map +1 -0
  52. package/dist/components/solid-ac-checker.js +45 -0
  53. package/dist/components/solid-calendar.js +66 -0
  54. package/dist/components/solid-delete.js +96 -0
  55. package/dist/components/solid-display.js +150 -0
  56. package/dist/components/solid-form-search.js +177 -0
  57. package/dist/components/solid-form.js +259 -0
  58. package/dist/components/solid-lang.js +35 -0
  59. package/dist/components/solid-map.js +204 -0
  60. package/dist/components/solid-table.js +181 -0
  61. package/dist/components/solid-widget.js +72 -0
  62. package/dist/import.css +4 -0
  63. package/dist/index.js +49 -0
  64. package/dist/libs/Component.js +13 -0
  65. package/dist/libs/ComponentFactory.js +168 -0
  66. package/dist/libs/Compositor.js +96 -0
  67. package/dist/libs/Sib.js +44 -0
  68. package/dist/libs/filter.js +184 -0
  69. package/dist/libs/helpers.js +194 -0
  70. package/dist/libs/interfaces.js +6 -0
  71. package/dist/libs/lit-helpers.js +142 -0
  72. package/dist/libs/polyfills.js +37 -0
  73. package/dist/libs/store/server-pagination.js +22 -0
  74. package/dist/libs/store/server-search.js +35 -0
  75. package/dist/libs/store/store.js +814 -0
  76. package/dist/locales/en.json +10 -0
  77. package/dist/locales/en.json.proxy.js +2 -0
  78. package/dist/locales/fr.json +10 -0
  79. package/dist/locales/fr.json.proxy.js +2 -0
  80. package/dist/mixins/attributeBinderMixin.js +116 -0
  81. package/dist/mixins/contextMixin.js +26 -0
  82. package/dist/mixins/counterMixin.js +54 -0
  83. package/dist/mixins/federationMixin.js +51 -0
  84. package/dist/mixins/filterMixin.js +155 -0
  85. package/dist/mixins/grouperMixin.js +73 -0
  86. package/dist/mixins/highlighterMixin.js +36 -0
  87. package/dist/mixins/interfaces.js +6 -0
  88. package/dist/mixins/listMixin.js +105 -0
  89. package/dist/mixins/nextMixin.js +23 -0
  90. package/dist/mixins/paginateMixin.js +97 -0
  91. package/dist/mixins/requiredMixin.js +26 -0
  92. package/dist/mixins/serverPaginationMixin.js +122 -0
  93. package/dist/mixins/sorterMixin.js +131 -0
  94. package/dist/mixins/storeMixin.js +109 -0
  95. package/dist/mixins/translationMixin.js +58 -0
  96. package/dist/mixins/validationMixin.js +95 -0
  97. package/dist/mixins/widgetMixin.js +351 -0
  98. package/dist/new-widgets/attributeMixins/actionMixin.js +13 -0
  99. package/dist/new-widgets/attributeMixins/blankMixin.js +7 -0
  100. package/dist/new-widgets/attributeMixins/booleanMixin.js +7 -0
  101. package/dist/new-widgets/attributeMixins/index.js +19 -0
  102. package/dist/new-widgets/attributeMixins/mailtoMixin.js +7 -0
  103. package/dist/new-widgets/attributeMixins/multipleMixin.js +27 -0
  104. package/dist/new-widgets/attributeMixins/numberMixin.js +7 -0
  105. package/dist/new-widgets/attributeMixins/placeholderMixin.js +16 -0
  106. package/dist/new-widgets/attributeMixins/telMixin.js +7 -0
  107. package/dist/new-widgets/baseWidgetMixin.js +109 -0
  108. package/dist/new-widgets/callbackMixins/autocompletionMixin.js +96 -0
  109. package/dist/new-widgets/callbackMixins/index.js +7 -0
  110. package/dist/new-widgets/callbackMixins/richtextMixin.js +37 -0
  111. package/dist/new-widgets/callbackMixins/slimselect.css +2 -0
  112. package/dist/new-widgets/callbackMixins/slimselect.css.proxy.js +10 -0
  113. package/dist/new-widgets/interfaces.js +1 -0
  114. package/dist/new-widgets/new-widget-factory.js +91 -0
  115. package/dist/new-widgets/templateAdditionMixins/addableMixin.js +26 -0
  116. package/dist/new-widgets/templateAdditionMixins/index.js +13 -0
  117. package/dist/new-widgets/templateAdditionMixins/labelLastMixin.js +16 -0
  118. package/dist/new-widgets/templateAdditionMixins/labelMixin.js +18 -0
  119. package/dist/new-widgets/templates/defaultTemplatesDirectory.js +29 -0
  120. package/dist/new-widgets/templates/displayTemplatesDirectory.js +54 -0
  121. package/dist/new-widgets/templates/formTemplatesDirectory.js +432 -0
  122. package/dist/new-widgets/templates/groupTemplatesDirectory.js +11 -0
  123. package/dist/new-widgets/templates/index.js +6 -0
  124. package/dist/new-widgets/templates/setTemplatesDirectory.js +16 -0
  125. package/dist/new-widgets/templatesDependencies/altMixin.js +12 -0
  126. package/dist/new-widgets/templatesDependencies/editableMixin.js +60 -0
  127. package/dist/new-widgets/templatesDependencies/filterRangeFormMixin.js +34 -0
  128. package/dist/new-widgets/templatesDependencies/formCheckboxMixin.js +10 -0
  129. package/dist/new-widgets/templatesDependencies/formCheckboxesMixin.js +41 -0
  130. package/dist/new-widgets/templatesDependencies/formDropdownMixin.js +56 -0
  131. package/dist/new-widgets/templatesDependencies/formFileMixin.js +82 -0
  132. package/dist/new-widgets/templatesDependencies/formLengthMixin.js +18 -0
  133. package/dist/new-widgets/templatesDependencies/formMinMaxMixin.js +18 -0
  134. package/dist/new-widgets/templatesDependencies/formMixin.js +56 -0
  135. package/dist/new-widgets/templatesDependencies/formNumberMixin.js +10 -0
  136. package/dist/new-widgets/templatesDependencies/formRadioMixin.js +12 -0
  137. package/dist/new-widgets/templatesDependencies/formStepMixin.js +12 -0
  138. package/dist/new-widgets/templatesDependencies/linkTextMixin.js +13 -0
  139. package/dist/new-widgets/templatesDependencies/multipleFormMixin.js +112 -0
  140. package/dist/new-widgets/templatesDependencies/multipleselectFormMixin.js +65 -0
  141. package/dist/new-widgets/templatesDependencies/patternMixin.js +18 -0
  142. package/dist/new-widgets/templatesDependencies/rangeMixin.js +100 -0
  143. package/dist/new-widgets/templatesDependencies/setMixin.js +9 -0
  144. package/dist/new-widgets/templatesDependencies/valueRichtextMixin.js +9 -0
  145. package/dist/new-widgets/valueTransformationMixins/autolinkMixin.js +14 -0
  146. package/dist/new-widgets/valueTransformationMixins/dateMixin.js +29 -0
  147. package/dist/new-widgets/valueTransformationMixins/dateTimeMixin.js +12 -0
  148. package/dist/new-widgets/valueTransformationMixins/index.js +15 -0
  149. package/dist/new-widgets/valueTransformationMixins/markdownMixin.js +30 -0
  150. package/dist/new-widgets/valueTransformationMixins/multilineMixin.js +13 -0
  151. package/dist/new-widgets/valueTransformationMixins/oembedMixin.js +21 -0
  152. package/dist/solid-template-element.js +144 -0
  153. package/dist/style/default-theme.css +24 -0
  154. package/dist/style/default-theme.css.proxy.js +10 -0
  155. package/dist/widgets/baseWidget.js +268 -0
  156. package/dist/widgets/widget-factory.js +22 -0
  157. 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,10 @@
1
+ const FormNumberMixin = {
2
+ name: 'form-number-mixin',
3
+ getValueFromElement(element) {
4
+ return element.value ? Number(element.value) : '';
5
+ },
6
+ get type() {
7
+ return 'number';
8
+ }
9
+ };
10
+ export { FormNumberMixin };
@@ -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,12 @@
1
+ const FormStepMixin = {
2
+ name: 'form-time-mixin',
3
+ attributes: {
4
+ step: {
5
+ type: Number,
6
+ callback: function (newValue) {
7
+ this.addToAttributes(newValue, 'step');
8
+ }
9
+ }
10
+ }
11
+ };
12
+ export { FormStepMixin };
@@ -0,0 +1,13 @@
1
+ const LinkTextMixin = {
2
+ name: 'link-text-mixin',
3
+ attributes: {
4
+ linkText: {
5
+ type: String,
6
+ default: '',
7
+ callback: function (newValue) {
8
+ this.addToAttributes(newValue, 'linkText');
9
+ }
10
+ }
11
+ }
12
+ };
13
+ export { LinkTextMixin };
@@ -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
+ const SetMixin = {
2
+ name: 'set-mixin',
3
+ /**
4
+ * For sets and group widgets, remove auto rendering
5
+ * function to allow only manual renders
6
+ */
7
+ planRender() {}
8
+ };
9
+ export { SetMixin };
@@ -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 };