@startinblox/core 0.19.0-beta.2 → 0.19.0-beta.20

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 (166) hide show
  1. package/dist/{_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.css → assets/MarkerCluster-614dea0a.css} +0 -0
  2. package/dist/{_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.Default.css → assets/MarkerCluster.Default-61258232.css} +0 -0
  3. package/dist/assets/en-e53105c5.js +14 -0
  4. package/dist/assets/en-e53105c5.js.map +1 -0
  5. package/dist/assets/fr-a7fcdb64.js +14 -0
  6. package/dist/assets/fr-a7fcdb64.js.map +1 -0
  7. package/dist/{_snowpack/pkg/fusejs.js → assets/helpers-bf15809c.js} +398 -454
  8. package/dist/assets/helpers-bf15809c.js.map +1 -0
  9. package/dist/{_snowpack/pkg/leaflet/dist/leaflet.css → assets/leaflet-3c081932.css} +3 -3
  10. package/dist/helpers.js +18 -0
  11. package/dist/helpers.js.map +1 -0
  12. package/dist/index.js +54606 -48
  13. package/dist/index.js.map +1 -0
  14. package/package.json +7 -22
  15. package/dist/_snowpack/pkg/autolinker.js +0 -4429
  16. package/dist/_snowpack/pkg/autolinker.js.map +0 -1
  17. package/dist/_snowpack/pkg/common/_baseUnary-d2677655.js +0 -353
  18. package/dist/_snowpack/pkg/common/_baseUnary-d2677655.js.map +0 -1
  19. package/dist/_snowpack/pkg/common/_commonjsHelpers-0597c316.js +0 -26
  20. package/dist/_snowpack/pkg/common/_commonjsHelpers-0597c316.js.map +0 -1
  21. package/dist/_snowpack/pkg/common/decode-26fbf385.js +0 -185
  22. package/dist/_snowpack/pkg/common/decode-26fbf385.js.map +0 -1
  23. package/dist/_snowpack/pkg/common/lit-html-3647afce.js +0 -1104
  24. package/dist/_snowpack/pkg/common/lit-html-3647afce.js.map +0 -1
  25. package/dist/_snowpack/pkg/delta-markdown-for-quill.js +0 -26198
  26. package/dist/_snowpack/pkg/delta-markdown-for-quill.js.map +0 -1
  27. package/dist/_snowpack/pkg/dialog-polyfill.js +0 -826
  28. package/dist/_snowpack/pkg/dialog-polyfill.js.map +0 -1
  29. package/dist/_snowpack/pkg/fusejs.js.map +0 -1
  30. package/dist/_snowpack/pkg/import-map.json +0 -25
  31. package/dist/_snowpack/pkg/jsonld-context-parser.js +0 -836
  32. package/dist/_snowpack/pkg/jsonld-context-parser.js.map +0 -1
  33. package/dist/_snowpack/pkg/jsonld.js +0 -11760
  34. package/dist/_snowpack/pkg/jsonld.js.map +0 -1
  35. package/dist/_snowpack/pkg/leaflet/dist/leaflet.css.proxy.js +0 -10
  36. package/dist/_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.Default.css.proxy.js +0 -10
  37. package/dist/_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.css.proxy.js +0 -10
  38. package/dist/_snowpack/pkg/lit-html/directives/if-defined.js +0 -39
  39. package/dist/_snowpack/pkg/lit-html/directives/if-defined.js.map +0 -1
  40. package/dist/_snowpack/pkg/lit-html/directives/unsafe-html.js +0 -48
  41. package/dist/_snowpack/pkg/lit-html/directives/unsafe-html.js.map +0 -1
  42. package/dist/_snowpack/pkg/lit-html/directives/until.js +0 -87
  43. package/dist/_snowpack/pkg/lit-html/directives/until.js.map +0 -1
  44. package/dist/_snowpack/pkg/lit-html.js +0 -94
  45. package/dist/_snowpack/pkg/lit-html.js.map +0 -1
  46. package/dist/_snowpack/pkg/markdown-it-link-attributes.js +0 -68
  47. package/dist/_snowpack/pkg/markdown-it-link-attributes.js.map +0 -1
  48. package/dist/_snowpack/pkg/markdown-it.js +0 -11307
  49. package/dist/_snowpack/pkg/markdown-it.js.map +0 -1
  50. package/dist/_snowpack/pkg/quill/dist/quill.snow.css.proxy.js +0 -10
  51. package/dist/_snowpack/pkg/quill-delta-to-markdown.js +0 -971
  52. package/dist/_snowpack/pkg/quill-delta-to-markdown.js.map +0 -1
  53. package/dist/_snowpack/pkg/quill.js +0 -14441
  54. package/dist/_snowpack/pkg/quill.js.map +0 -1
  55. package/dist/_snowpack/pkg/slim-select.js +0 -714
  56. package/dist/_snowpack/pkg/slim-select.js.map +0 -1
  57. package/dist/_snowpack/pkg/tui-calendar/dist/tui-calendar.css +0 -1149
  58. package/dist/_snowpack/pkg/tui-calendar/dist/tui-calendar.css.proxy.js +0 -10
  59. package/dist/_snowpack/pkg/tui-calendar.js +0 -46503
  60. package/dist/_snowpack/pkg/tui-calendar.js.map +0 -1
  61. package/dist/components/solid-ac-checker.js +0 -45
  62. package/dist/components/solid-calendar.js +0 -66
  63. package/dist/components/solid-delete.js +0 -96
  64. package/dist/components/solid-display.js +0 -150
  65. package/dist/components/solid-form-search.js +0 -173
  66. package/dist/components/solid-form.js +0 -257
  67. package/dist/components/solid-lang.js +0 -35
  68. package/dist/components/solid-map.js +0 -204
  69. package/dist/components/solid-table.js +0 -181
  70. package/dist/components/solid-widget.js +0 -72
  71. package/dist/import.css +0 -4
  72. package/dist/libs/Component.js +0 -13
  73. package/dist/libs/ComponentFactory.js +0 -165
  74. package/dist/libs/Compositor.js +0 -96
  75. package/dist/libs/Sib.js +0 -44
  76. package/dist/libs/filter.js +0 -184
  77. package/dist/libs/helpers.js +0 -185
  78. package/dist/libs/interfaces.js +0 -6
  79. package/dist/libs/lit-helpers.js +0 -139
  80. package/dist/libs/polyfills.js +0 -35
  81. package/dist/libs/store/custom-getter.js +0 -313
  82. package/dist/libs/store/server-pagination.js +0 -19
  83. package/dist/libs/store/server-search.js +0 -32
  84. package/dist/libs/store/store.js +0 -560
  85. package/dist/locales/en.json +0 -10
  86. package/dist/locales/en.json.proxy.js +0 -2
  87. package/dist/locales/fr.json +0 -10
  88. package/dist/locales/fr.json.proxy.js +0 -2
  89. package/dist/mixins/attributeBinderMixin.js +0 -113
  90. package/dist/mixins/contextMixin.js +0 -26
  91. package/dist/mixins/counterMixin.js +0 -54
  92. package/dist/mixins/federationMixin.js +0 -57
  93. package/dist/mixins/filterMixin.js +0 -152
  94. package/dist/mixins/grouperMixin.js +0 -73
  95. package/dist/mixins/highlighterMixin.js +0 -36
  96. package/dist/mixins/interfaces.js +0 -6
  97. package/dist/mixins/listMixin.js +0 -116
  98. package/dist/mixins/nextMixin.js +0 -23
  99. package/dist/mixins/paginateMixin.js +0 -97
  100. package/dist/mixins/requiredMixin.js +0 -38
  101. package/dist/mixins/serverPaginationMixin.js +0 -122
  102. package/dist/mixins/sorterMixin.js +0 -131
  103. package/dist/mixins/storeMixin.js +0 -139
  104. package/dist/mixins/translationMixin.js +0 -58
  105. package/dist/mixins/validationMixin.js +0 -95
  106. package/dist/mixins/widgetMixin.js +0 -364
  107. package/dist/new-widgets/attributeMixins/actionMixin.js +0 -13
  108. package/dist/new-widgets/attributeMixins/blankMixin.js +0 -7
  109. package/dist/new-widgets/attributeMixins/booleanMixin.js +0 -7
  110. package/dist/new-widgets/attributeMixins/index.js +0 -19
  111. package/dist/new-widgets/attributeMixins/mailtoMixin.js +0 -7
  112. package/dist/new-widgets/attributeMixins/multipleMixin.js +0 -27
  113. package/dist/new-widgets/attributeMixins/numberMixin.js +0 -7
  114. package/dist/new-widgets/attributeMixins/placeholderMixin.js +0 -16
  115. package/dist/new-widgets/attributeMixins/telMixin.js +0 -7
  116. package/dist/new-widgets/baseWidgetMixin.js +0 -109
  117. package/dist/new-widgets/callbackMixins/autocompletionMixin.js +0 -96
  118. package/dist/new-widgets/callbackMixins/index.js +0 -7
  119. package/dist/new-widgets/callbackMixins/richtextMixin.js +0 -37
  120. package/dist/new-widgets/callbackMixins/slimselect.css.proxy.js +0 -10
  121. package/dist/new-widgets/interfaces.js +0 -1
  122. package/dist/new-widgets/new-widget-factory.js +0 -91
  123. package/dist/new-widgets/templateAdditionMixins/addableMixin.js +0 -26
  124. package/dist/new-widgets/templateAdditionMixins/index.js +0 -13
  125. package/dist/new-widgets/templateAdditionMixins/labelLastMixin.js +0 -16
  126. package/dist/new-widgets/templateAdditionMixins/labelMixin.js +0 -18
  127. package/dist/new-widgets/templates/defaultTemplatesDirectory.js +0 -29
  128. package/dist/new-widgets/templates/displayTemplatesDirectory.js +0 -54
  129. package/dist/new-widgets/templates/formTemplatesDirectory.js +0 -423
  130. package/dist/new-widgets/templates/groupTemplatesDirectory.js +0 -11
  131. package/dist/new-widgets/templates/index.js +0 -6
  132. package/dist/new-widgets/templates/setTemplatesDirectory.js +0 -16
  133. package/dist/new-widgets/templatesDependencies/altMixin.js +0 -12
  134. package/dist/new-widgets/templatesDependencies/editableMixin.js +0 -60
  135. package/dist/new-widgets/templatesDependencies/filterRangeFormMixin.js +0 -34
  136. package/dist/new-widgets/templatesDependencies/formCheckboxMixin.js +0 -10
  137. package/dist/new-widgets/templatesDependencies/formCheckboxesMixin.js +0 -41
  138. package/dist/new-widgets/templatesDependencies/formDropdownMixin.js +0 -59
  139. package/dist/new-widgets/templatesDependencies/formFileMixin.js +0 -82
  140. package/dist/new-widgets/templatesDependencies/formLengthMixin.js +0 -18
  141. package/dist/new-widgets/templatesDependencies/formMinMaxMixin.js +0 -18
  142. package/dist/new-widgets/templatesDependencies/formMixin.js +0 -56
  143. package/dist/new-widgets/templatesDependencies/formNumberMixin.js +0 -10
  144. package/dist/new-widgets/templatesDependencies/formRadioMixin.js +0 -12
  145. package/dist/new-widgets/templatesDependencies/formStepMixin.js +0 -12
  146. package/dist/new-widgets/templatesDependencies/linkTextMixin.js +0 -13
  147. package/dist/new-widgets/templatesDependencies/multipleFormMixin.js +0 -125
  148. package/dist/new-widgets/templatesDependencies/multipleselectFormMixin.js +0 -74
  149. package/dist/new-widgets/templatesDependencies/patternMixin.js +0 -18
  150. package/dist/new-widgets/templatesDependencies/rangeMixin.js +0 -100
  151. package/dist/new-widgets/templatesDependencies/setMixin.js +0 -9
  152. package/dist/new-widgets/templatesDependencies/valueRichtextMixin.js +0 -9
  153. package/dist/new-widgets/valueTransformationMixins/autolinkMixin.js +0 -14
  154. package/dist/new-widgets/valueTransformationMixins/dateMixin.js +0 -29
  155. package/dist/new-widgets/valueTransformationMixins/dateTimeMixin.js +0 -12
  156. package/dist/new-widgets/valueTransformationMixins/index.js +0 -15
  157. package/dist/new-widgets/valueTransformationMixins/markdownMixin.js +0 -30
  158. package/dist/new-widgets/valueTransformationMixins/multilineMixin.js +0 -13
  159. package/dist/new-widgets/valueTransformationMixins/oembedMixin.js +0 -21
  160. package/dist/solid-template-element.js +0 -144
  161. package/dist/style/default-theme.css.proxy.js +0 -10
  162. package/dist/widgets/baseWidget.js +0 -267
  163. package/dist/widgets/widget-factory.js +0 -20
  164. /package/dist/{style/default-theme.css → assets/default-theme-d0f20a8a.css} +0 -0
  165. /package/dist/{_snowpack/pkg/quill/dist/quill.snow.css → assets/quill.snow-8f222e44.css} +0 -0
  166. /package/dist/{new-widgets/callbackMixins/slimselect.css → assets/slimselect-43e3ebc8.css} +0 -0
@@ -1,45 +0,0 @@
1
- import JSONLDContextParser from '../_snowpack/pkg/jsonld-context-parser.js';
2
- import { Sib } from '../libs/Sib.js';
3
- import { StoreMixin } from '../mixins/storeMixin.js';
4
- export const SolidAcChecker = {
5
- name: 'solid-ac-checker',
6
- use: [StoreMixin],
7
- attributes: {
8
- permission: {
9
- type: String,
10
- default: ''
11
- },
12
- noPermission: {
13
- type: String,
14
- default: ''
15
- }
16
- },
17
- async populate() {
18
- if (!this.resource) return;
19
- let displayElement;
20
- const ContextParser = JSONLDContextParser.ContextParser;
21
- const myParser = new ContextParser();
22
- const context = await myParser.parse(this.context);
23
- const permissions = await this.resource.permissions;
24
- if (this.permission) {
25
- // User has permission of ...
26
- displayElement = permissions.some(p => {
27
- return ContextParser.compactIri(p, context) === this.permission;
28
- });
29
- } else if (this.noPermission) {
30
- // User has no permission of ...
31
- displayElement = permissions.every(p => {
32
- return ContextParser.compactIri(p, context) !== this.noPermission;
33
- });
34
- } else {
35
- // No parameter provided
36
- console.warn('solid-ac-checker: you should define at least one of "permission" or "no-permission" attribute.');
37
- return;
38
- }
39
- if (displayElement) this.element.removeAttribute('hidden');
40
- },
41
- empty() {
42
- this.element.setAttribute('hidden', '');
43
- }
44
- };
45
- Sib.register(SolidAcChecker);
@@ -1,66 +0,0 @@
1
- import { Sib } from '../libs/Sib.js';
2
- import { ListMixin } from '../mixins/listMixin.js';
3
- import { StoreMixin } from '../mixins/storeMixin.js';
4
- import { NextMixin } from '../mixins/nextMixin.js';
5
- import { store } from '../libs/store/store.js';
6
- import { uniqID } from '../libs/helpers.js';
7
- import Calendar from '../_snowpack/pkg/tui-calendar.js';
8
- import { html, render } from '../_snowpack/pkg/lit-html.js';
9
- export const SolidCalendar = {
10
- name: 'solid-calendar',
11
- use: [ListMixin, StoreMixin, NextMixin],
12
- initialState: {
13
- subscriptions: null
14
- },
15
- created() {
16
- //@ts-ignore
17
- import("../_snowpack/pkg/tui-calendar/dist/tui-calendar.css.proxy.js");
18
- const id = uniqID();
19
- const template = html`
20
- <div id=${id} style="width:100%;height:100%;"></div>
21
- `;
22
- render(template, this.element);
23
- this.calendar = new Calendar(this.element.querySelector(`#${id}`), {
24
- defaultView: 'month'
25
- });
26
- this.calendar.on('clickSchedule', this.dispatchSelect.bind(this));
27
- this.subscriptions = new Map();
28
- },
29
- get extra_context() {
30
- return {
31
- date: "http://www.w3.org/2001/XMLSchema#dateTime"
32
- };
33
- },
34
- dispatchSelect(event) {
35
- const resource = {
36
- '@id': event['schedule'].id
37
- };
38
- this.element.dispatchEvent(new CustomEvent('resourceSelect', {
39
- detail: {
40
- resource: resource
41
- }
42
- }));
43
- this.goToNext(resource);
44
- },
45
- async appendChildElt(resourceId) {
46
- const resource = await store.getData(resourceId, this.context);
47
- if (!resource) return;
48
- if (!this.subscriptions.get(resourceId)) {
49
- this.subscriptions.set(resourceId, PubSub.subscribe(resourceId, () => this.updateDOM()));
50
- } // TODO : mixin gestion des enfants
51
- const date = await resource['date'];
52
- const name = await resource['name'];
53
- if (name && date) {
54
- this.calendar.createSchedules([{
55
- id: resource['@id'],
56
- title: name.toString(),
57
- category: 'time',
58
- start: date.toString()
59
- }]);
60
- }
61
- },
62
- empty() {
63
- this.calendar.clear();
64
- }
65
- };
66
- Sib.register(SolidCalendar);
@@ -1,96 +0,0 @@
1
- import { Sib } from '../libs/Sib.js';
2
- import { base_context, store } from '../libs/store/store.js';
3
- import { NextMixin } from '../mixins/nextMixin.js';
4
- import { ValidationMixin } from '../mixins/validationMixin.js';
5
- import { AttributeBinderMixin } from '../mixins/attributeBinderMixin.js';
6
- import { html, render } from '../_snowpack/pkg/lit-html.js';
7
- export const SolidDelete = {
8
- name: 'solid-delete',
9
- use: [NextMixin, ValidationMixin, AttributeBinderMixin],
10
- attributes: {
11
- dataSrc: {
12
- type: String,
13
- default: null,
14
- callback: function () {
15
- this.resourceId = this.dataSrc;
16
- }
17
- },
18
- dataLabel: {
19
- type: String,
20
- default: null,
21
- callback: function (newValue, oldValue) {
22
- if (newValue !== oldValue) this.planRender();
23
- }
24
- },
25
- extraContext: {
26
- type: String,
27
- default: null
28
- }
29
- },
30
- initialState: {
31
- renderPlanned: false
32
- },
33
- created() {
34
- this.planRender();
35
- },
36
- planRender() {
37
- if (!this.renderPlanned) {
38
- this.renderPlanned = true;
39
- setTimeout(() => {
40
- this.render();
41
- this.renderPlanned = false;
42
- });
43
- }
44
- },
45
- get context() {
46
- let extraContextElement = this.extraContext ? document.getElementById(this.extraContext) :
47
- // take element extra context first
48
- document.querySelector('[data-default-context]'); // ... or look for a default extra context
49
-
50
- let extraContext = {};
51
- if (extraContextElement) extraContext = JSON.parse(extraContextElement.textContent || "{}");
52
- return {
53
- ...base_context,
54
- ...extraContext
55
- };
56
- },
57
- async delete(e) {
58
- e.stopPropagation();
59
- if (!this.dataSrc) return;
60
- this.performAction(); // In validationMixin, method defining what to do according to the present attributes
61
- },
62
-
63
- deletion() {
64
- return store.delete(this.dataSrc, this.context).then(response => {
65
- if (!response.ok) return;
66
- this.goToNext(null);
67
- const eventData = {
68
- detail: {
69
- resource: {
70
- "@id": this.dataSrc
71
- }
72
- },
73
- bubbles: true
74
- };
75
- this.element.dispatchEvent(new CustomEvent('save', eventData));
76
- this.element.dispatchEvent(new CustomEvent('resourceDeleted', eventData)); // Deprecated. To remove in 0.15
77
- });
78
- },
79
-
80
- validateModal() {
81
- // Send method to validationMixin, used by the dialog modal and performAction method
82
- return this.deletion();
83
- },
84
- update() {
85
- this.render();
86
- },
87
- async render() {
88
- await this.replaceAttributesData(false);
89
- const button = html`
90
- <button @click=${this.delete.bind(this)}>${this.dataLabel || this.t("solid-delete.button")}</button>
91
- ${this.getModalDialog()}
92
- `;
93
- render(button, this.element);
94
- }
95
- };
96
- Sib.register(SolidDelete);
@@ -1,150 +0,0 @@
1
- import { Sib } from '../libs/Sib.js';
2
- import { WidgetMixin } from '../mixins/widgetMixin.js';
3
- import { ListMixin } from '../mixins/listMixin.js';
4
- import { StoreMixin } from '../mixins/storeMixin.js';
5
- import { PaginateMixin } from '../mixins/paginateMixin.js';
6
- import { FilterMixin } from '../mixins/filterMixin.js';
7
- import { CounterMixin } from '../mixins/counterMixin.js';
8
- import { SorterMixin } from '../mixins/sorterMixin.js';
9
- import { GrouperMixin } from '../mixins/grouperMixin.js';
10
- import { FederationMixin } from '../mixins/federationMixin.js';
11
- import { HighlighterMixin } from '../mixins/highlighterMixin.js';
12
- import { NextMixin } from '../mixins/nextMixin.js';
13
- import { RequiredMixin } from '../mixins/requiredMixin.js';
14
- import { spread } from '../libs/lit-helpers.js';
15
- import { html, render } from '../_snowpack/pkg/lit-html.js';
16
- import { ifDefined } from '../_snowpack/pkg/lit-html/directives/if-defined.js';
17
- export const SolidDisplay = {
18
- name: 'solid-display',
19
- use: [WidgetMixin, ListMixin, StoreMixin, PaginateMixin, GrouperMixin, CounterMixin, HighlighterMixin, FilterMixin, SorterMixin, RequiredMixin, FederationMixin, NextMixin],
20
- attributes: {
21
- defaultWidget: {
22
- type: String,
23
- default: 'solid-display-value'
24
- }
25
- },
26
- initialState: {
27
- activeSubscription: null,
28
- removeActiveSubscription: null
29
- },
30
- created() {
31
- // Set route active at initialization
32
- const route = document.querySelector('solid-route[active]');
33
- if (!route) return;
34
- setTimeout(() => {
35
- if (route['resourceId'] === this.resourceId) this.addActiveCallback();
36
- });
37
- },
38
- detached() {
39
- if (this.activeSubscription) PubSub.unsubscribe(this.activeSubscription);
40
- if (this.removeActiveSubscription) PubSub.unsubscribe(this.removeActiveSubscription);
41
- },
42
- // Update subscription when id changes
43
- updateNavigateSubscription() {
44
- if (this.activeSubscription) PubSub.unsubscribe(this.activeSubscription);
45
- if (this.resourceId) {
46
- this.activeSubscription = PubSub.subscribe('enterRoute.' + this.resourceId, this.addActiveCallback.bind(this));
47
- }
48
- },
49
- addActiveCallback() {
50
- this.element.setAttribute('active', '');
51
- this.removeActiveSubscription = PubSub.subscribe('leaveRoute', this.removeActiveCallback.bind(this));
52
- },
53
- removeActiveCallback() {
54
- this.element.removeAttribute('active');
55
- PubSub.unsubscribe(this.removeActiveSubscription);
56
- },
57
- get childTag() {
58
- return this.element.dataset.child || this.element.tagName;
59
- },
60
- get defaultMultipleWidget() {
61
- return 'solid-multiple';
62
- },
63
- get defaultSetWidget() {
64
- return 'solid-set-default';
65
- },
66
- // Here "even.target" points to the content of the widgets of the children of solid-display
67
- dispatchSelect(event, resourceId) {
68
- const linkTarget = event.target.closest('a');
69
- if (linkTarget && linkTarget.hasAttribute('href')) return;
70
- const resource = {
71
- "@id": resourceId
72
- };
73
- this.element.dispatchEvent(new CustomEvent('resourceSelect', {
74
- detail: {
75
- resource: resource
76
- }
77
- }));
78
- this.goToNext(resource);
79
- },
80
- enterKeydownAction(event, resourceId) {
81
- if (event.keyCode === 13) {
82
- const resource = {
83
- "@id": resourceId
84
- };
85
- this.goToNext(resource);
86
- }
87
- },
88
- /**
89
- * Returns template of a child element (resource)
90
- * @param resourceId
91
- * @param attributes
92
- */
93
- getChildTemplate(resourceId, attributes) {
94
- let template = html`
95
- <solid-display
96
- data-src=${resourceId}
97
- @click=${event => this.dispatchSelect(event, resourceId)}
98
- @keydown=${event => this.enterKeydownAction(event, resourceId)}
99
- fields=${ifDefined(this.fields)}
100
- ...=${spread(attributes)}
101
- ></solid-display>
102
- `;
103
- return template;
104
- },
105
- /**
106
- * Creates and render the content of a single element (resource)
107
- * @param parent
108
- */
109
- async appendSingleElt(parent) {
110
- const fields = await this.getFields();
111
- const widgetTemplates = await Promise.all(
112
- // generate all widget templates
113
- fields.map(field => this.createWidgetTemplate(field)));
114
- render(html`${widgetTemplates}`, parent);
115
- },
116
- /**
117
- * @override listMixin method to use litHtml
118
- *
119
- * Render resources from a container
120
- * @param resources
121
- * @param listPostProcessors
122
- * @param div
123
- * @param context
124
- */
125
- async renderDOM(resources, listPostProcessors, div, context) {
126
- const attributes = this.getChildAttributes(); // get attributes of children only once
127
- // and create a child template for each resource
128
- const template = html`${resources.map(r => r ? this.getChildTemplate(r['@id'], attributes) : null)}`;
129
- render(template, div);
130
- const nextProcessor = listPostProcessors.shift();
131
- if (nextProcessor) await nextProcessor(resources, listPostProcessors, div, context);
132
- },
133
- /**
134
- * Get attributes to dispatch to children from current element
135
- */
136
- getChildAttributes() {
137
- const attributes = {};
138
- for (let attr of this.element.attributes) {
139
- //copy widget and value attributes
140
- if (attr.name.startsWith('value-') || attr.name.startsWith('label-') || attr.name.startsWith('placeholder-') || attr.name.startsWith('widget-') || attr.name.startsWith('class-') || attr.name.startsWith('multiple-') || attr.name.startsWith('editable-') || attr.name.startsWith('action-') || attr.name.startsWith('default-') || attr.name.startsWith('link-text-') || attr.name == 'extra-context') attributes[attr.name] = attr.value;
141
- if (attr.name.startsWith('child-')) attributes[attr.name.replace(/^child-/, '')] = attr.value;
142
- if (attr.name == 'next') {
143
- attributes['role'] = 'button';
144
- attributes['tabindex'] = '0';
145
- }
146
- }
147
- return attributes;
148
- }
149
- };
150
- Sib.register(SolidDisplay);
@@ -1,173 +0,0 @@
1
- import { Sib } from '../libs/Sib.js';
2
- import { WidgetMixin } from '../mixins/widgetMixin.js';
3
- import { AttributeBinderMixin } from '../mixins/attributeBinderMixin.js';
4
- import { ContextMixin } from '../mixins/contextMixin.js';
5
- import { newWidgetFactory } from '../new-widgets/new-widget-factory.js';
6
- import { html, render } from '../_snowpack/pkg/lit-html.js';
7
- import { ifDefined } from '../_snowpack/pkg/lit-html/directives/if-defined.js';
8
- import { uniqID } from '../libs/helpers.js';
9
- export const SolidFormSearch = {
10
- name: 'solid-form-search',
11
- use: [WidgetMixin, AttributeBinderMixin, ContextMixin],
12
- attributes: {
13
- defaultWidget: {
14
- type: String,
15
- default: 'solid-form-label-text'
16
- },
17
- submitButton: {
18
- type: String,
19
- default: null,
20
- callback: function (newValue, oldValue) {
21
- if (this.noRender == null && newValue !== oldValue) this.populate();
22
- }
23
- },
24
- submitWidget: {
25
- type: String,
26
- default: undefined
27
- },
28
- classSubmitButton: {
29
- type: String,
30
- default: undefined
31
- },
32
- noRender: {
33
- type: String,
34
- default: null,
35
- callback: function (value) {
36
- if (value === null) this.populate();
37
- }
38
- }
39
- },
40
- initialState: {
41
- error: ''
42
- },
43
- created() {
44
- if (this.element.closest('[no-render]')) this.noRender = ''; // if embedded in no-render, apply no-render to himself
45
- this.autoRangeValues = {};
46
- this.rangeId = uniqID();
47
- this.attachedElements = new Set();
48
- },
49
- get defaultMultipleWidget() {
50
- return 'solid-multiple-form';
51
- },
52
- get defaultSetWidget() {
53
- return 'solid-set-default';
54
- },
55
- get value() {
56
- const values = {};
57
- this.widgets.forEach(widget => {
58
- const name = (widget.component || widget).name;
59
- if (name == null) return;
60
- let value = widget.component ? widget.component.getValue() : widget.value;
61
- try {
62
- value = JSON.parse(value);
63
- } catch {}
64
- value = {
65
- type: widget.component.type,
66
- list: !!widget.component.multiple,
67
- value: value
68
- };
69
- values[name] = value;
70
- });
71
- return values;
72
- },
73
- getWidget(field, isSet = false) {
74
- let tagName = '';
75
- // If auto-range-[field] exists, create range-[field] and sets its value
76
- if (this.element.hasAttribute('auto-range-' + field) && !this.element.hasAttribute('range-' + field)) {
77
- const idField = `${this.rangeId}_${field}`;
78
- this.element.setAttribute('range-' + field, 'store://local.' + idField);
79
- this.populate();
80
- }
81
- const widgetAttribute = this.element.getAttribute('widget-' + field);
82
- // Choose widget
83
- if (!widgetAttribute && (this.element.hasAttribute('range-' + field) || this.element.hasAttribute('enum-' + field))) {
84
- tagName = 'solid-form-dropdown';
85
- } else {
86
- tagName = widgetAttribute || (!isSet ? this.defaultWidget : this.defaultSetWidget);
87
- }
88
- // Create widget
89
- if (!customElements.get(tagName)) {
90
- // component does not exist
91
- if (tagName.startsWith('solid')) newWidgetFactory(tagName); // solid- -> create it
92
- }
93
-
94
- return this.widgetFromTagName(tagName);
95
- },
96
- async attach(elm) {
97
- if (this.attachedElements.has(elm)) return;
98
- this.attachedElements.add(elm);
99
- await this.updateAutoRanges();
100
- },
101
- async detach(elm) {
102
- if (!this.attachedElements.has(elm)) return;
103
- this.attachedElements.delete(elm);
104
- await this.updateAutoRanges();
105
- },
106
- async updateAutoRanges() {
107
- for (const attr of this.element.attributes) {
108
- if (!attr['name'].startsWith('auto-range-')) continue;
109
- const field = attr['name'].replace('auto-range-', '');
110
- const autoRangeValues = new Set();
111
- for (const elm of this.attachedElements) {
112
- for (const value of await elm.getValuesOfField(field)) {
113
- autoRangeValues.add(value);
114
- }
115
- }
116
- const idField = `${this.rangeId}_${field}`;
117
- const id = `store://local.${idField}`;
118
- const ldpContains = Array.from(autoRangeValues).map(id => ({
119
- '@id': id
120
- }));
121
- const data = {
122
- "@type": "ldp:Container",
123
- "@context": this.context,
124
- "ldp:contains": ldpContains
125
- };
126
- sibStore.setLocalData(data, id);
127
- }
128
- },
129
- change(resource) {
130
- this.element.dispatchEvent(new CustomEvent('formChange', {
131
- bubbles: true,
132
- detail: {
133
- resource
134
- }
135
- }));
136
- },
137
- async inputChange() {
138
- this.change(this.value);
139
- },
140
- getSubmitTemplate() {
141
- return html`
142
- <div class=${ifDefined(this.classSubmitButton)}>
143
- ${this.submitWidget === 'button' ? html`
144
- <button type="submit">${this.submitButton || ''}</button>
145
- ` : html`
146
- <input type="submit" value=${ifDefined(this.submitButton || undefined)}>
147
- `}
148
- </div>
149
- `;
150
- },
151
- empty() {},
152
- async populate() {
153
- await this.replaceAttributesData();
154
- if (this.submitButton == null) {
155
- this.element.addEventListener('input', () => this.inputChange());
156
- } else {
157
- this.element.addEventListener('submit', e => {
158
- e.preventDefault();
159
- this.inputChange();
160
- });
161
- }
162
- const fields = await this.getFields();
163
- const widgetTemplates = await Promise.all(fields.map(field => this.createWidgetTemplate(field)));
164
- const template = html`
165
- <form>
166
- ${widgetTemplates}
167
- ${this.submitButton == null ? '' : this.getSubmitTemplate()}
168
- </form>
169
- `;
170
- render(template, this.element);
171
- }
172
- };
173
- Sib.register(SolidFormSearch);