@startinblox/core 0.18.1 → 0.19.0-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (163) 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 +54600 -48
  13. package/dist/index.js.map +1 -0
  14. package/package.json +8 -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-c1edb653.js +0 -353
  18. package/dist/_snowpack/pkg/common/_baseUnary-c1edb653.js.map +0 -1
  19. package/dist/_snowpack/pkg/common/_commonjsHelpers-37fa8da4.js +0 -26
  20. package/dist/_snowpack/pkg/common/_commonjsHelpers-37fa8da4.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 -827
  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 -24
  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/leaflet/dist/leaflet.css.proxy.js +0 -10
  34. package/dist/_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.Default.css.proxy.js +0 -10
  35. package/dist/_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.css.proxy.js +0 -10
  36. package/dist/_snowpack/pkg/lit-html/directives/if-defined.js +0 -39
  37. package/dist/_snowpack/pkg/lit-html/directives/if-defined.js.map +0 -1
  38. package/dist/_snowpack/pkg/lit-html/directives/unsafe-html.js +0 -48
  39. package/dist/_snowpack/pkg/lit-html/directives/unsafe-html.js.map +0 -1
  40. package/dist/_snowpack/pkg/lit-html/directives/until.js +0 -87
  41. package/dist/_snowpack/pkg/lit-html/directives/until.js.map +0 -1
  42. package/dist/_snowpack/pkg/lit-html.js +0 -94
  43. package/dist/_snowpack/pkg/lit-html.js.map +0 -1
  44. package/dist/_snowpack/pkg/markdown-it-link-attributes.js +0 -68
  45. package/dist/_snowpack/pkg/markdown-it-link-attributes.js.map +0 -1
  46. package/dist/_snowpack/pkg/markdown-it.js +0 -11307
  47. package/dist/_snowpack/pkg/markdown-it.js.map +0 -1
  48. package/dist/_snowpack/pkg/quill/dist/quill.snow.css.proxy.js +0 -10
  49. package/dist/_snowpack/pkg/quill-delta-to-markdown.js +0 -971
  50. package/dist/_snowpack/pkg/quill-delta-to-markdown.js.map +0 -1
  51. package/dist/_snowpack/pkg/quill.js +0 -14442
  52. package/dist/_snowpack/pkg/quill.js.map +0 -1
  53. package/dist/_snowpack/pkg/slim-select.js +0 -714
  54. package/dist/_snowpack/pkg/slim-select.js.map +0 -1
  55. package/dist/_snowpack/pkg/tui-calendar/dist/tui-calendar.css +0 -1149
  56. package/dist/_snowpack/pkg/tui-calendar/dist/tui-calendar.css.proxy.js +0 -10
  57. package/dist/_snowpack/pkg/tui-calendar.js +0 -46507
  58. package/dist/_snowpack/pkg/tui-calendar.js.map +0 -1
  59. package/dist/components/solid-ac-checker.js +0 -45
  60. package/dist/components/solid-calendar.js +0 -66
  61. package/dist/components/solid-delete.js +0 -96
  62. package/dist/components/solid-display.js +0 -150
  63. package/dist/components/solid-form-search.js +0 -174
  64. package/dist/components/solid-form.js +0 -259
  65. package/dist/components/solid-lang.js +0 -35
  66. package/dist/components/solid-map.js +0 -204
  67. package/dist/components/solid-table.js +0 -181
  68. package/dist/components/solid-widget.js +0 -72
  69. package/dist/import.css +0 -4
  70. package/dist/libs/Component.js +0 -13
  71. package/dist/libs/ComponentFactory.js +0 -168
  72. package/dist/libs/Compositor.js +0 -96
  73. package/dist/libs/Sib.js +0 -44
  74. package/dist/libs/filter.js +0 -184
  75. package/dist/libs/helpers.js +0 -191
  76. package/dist/libs/interfaces.js +0 -6
  77. package/dist/libs/lit-helpers.js +0 -142
  78. package/dist/libs/polyfills.js +0 -37
  79. package/dist/libs/store/server-pagination.js +0 -22
  80. package/dist/libs/store/server-search.js +0 -35
  81. package/dist/libs/store/store.js +0 -814
  82. package/dist/locales/en.json +0 -10
  83. package/dist/locales/en.json.proxy.js +0 -2
  84. package/dist/locales/fr.json +0 -10
  85. package/dist/locales/fr.json.proxy.js +0 -2
  86. package/dist/mixins/attributeBinderMixin.js +0 -116
  87. package/dist/mixins/contextMixin.js +0 -26
  88. package/dist/mixins/counterMixin.js +0 -54
  89. package/dist/mixins/federationMixin.js +0 -51
  90. package/dist/mixins/filterMixin.js +0 -155
  91. package/dist/mixins/grouperMixin.js +0 -73
  92. package/dist/mixins/highlighterMixin.js +0 -36
  93. package/dist/mixins/interfaces.js +0 -6
  94. package/dist/mixins/listMixin.js +0 -105
  95. package/dist/mixins/nextMixin.js +0 -23
  96. package/dist/mixins/paginateMixin.js +0 -97
  97. package/dist/mixins/requiredMixin.js +0 -26
  98. package/dist/mixins/serverPaginationMixin.js +0 -122
  99. package/dist/mixins/sorterMixin.js +0 -131
  100. package/dist/mixins/storeMixin.js +0 -109
  101. package/dist/mixins/translationMixin.js +0 -58
  102. package/dist/mixins/validationMixin.js +0 -95
  103. package/dist/mixins/widgetMixin.js +0 -351
  104. package/dist/new-widgets/attributeMixins/actionMixin.js +0 -13
  105. package/dist/new-widgets/attributeMixins/blankMixin.js +0 -7
  106. package/dist/new-widgets/attributeMixins/booleanMixin.js +0 -7
  107. package/dist/new-widgets/attributeMixins/index.js +0 -19
  108. package/dist/new-widgets/attributeMixins/mailtoMixin.js +0 -7
  109. package/dist/new-widgets/attributeMixins/multipleMixin.js +0 -27
  110. package/dist/new-widgets/attributeMixins/numberMixin.js +0 -7
  111. package/dist/new-widgets/attributeMixins/placeholderMixin.js +0 -16
  112. package/dist/new-widgets/attributeMixins/telMixin.js +0 -7
  113. package/dist/new-widgets/baseWidgetMixin.js +0 -109
  114. package/dist/new-widgets/callbackMixins/autocompletionMixin.js +0 -96
  115. package/dist/new-widgets/callbackMixins/index.js +0 -7
  116. package/dist/new-widgets/callbackMixins/richtextMixin.js +0 -37
  117. package/dist/new-widgets/callbackMixins/slimselect.css.proxy.js +0 -10
  118. package/dist/new-widgets/interfaces.js +0 -1
  119. package/dist/new-widgets/new-widget-factory.js +0 -91
  120. package/dist/new-widgets/templateAdditionMixins/addableMixin.js +0 -26
  121. package/dist/new-widgets/templateAdditionMixins/index.js +0 -13
  122. package/dist/new-widgets/templateAdditionMixins/labelLastMixin.js +0 -16
  123. package/dist/new-widgets/templateAdditionMixins/labelMixin.js +0 -18
  124. package/dist/new-widgets/templates/defaultTemplatesDirectory.js +0 -29
  125. package/dist/new-widgets/templates/displayTemplatesDirectory.js +0 -54
  126. package/dist/new-widgets/templates/formTemplatesDirectory.js +0 -432
  127. package/dist/new-widgets/templates/groupTemplatesDirectory.js +0 -11
  128. package/dist/new-widgets/templates/index.js +0 -6
  129. package/dist/new-widgets/templates/setTemplatesDirectory.js +0 -16
  130. package/dist/new-widgets/templatesDependencies/altMixin.js +0 -12
  131. package/dist/new-widgets/templatesDependencies/editableMixin.js +0 -60
  132. package/dist/new-widgets/templatesDependencies/filterRangeFormMixin.js +0 -34
  133. package/dist/new-widgets/templatesDependencies/formCheckboxMixin.js +0 -10
  134. package/dist/new-widgets/templatesDependencies/formCheckboxesMixin.js +0 -41
  135. package/dist/new-widgets/templatesDependencies/formDropdownMixin.js +0 -56
  136. package/dist/new-widgets/templatesDependencies/formFileMixin.js +0 -82
  137. package/dist/new-widgets/templatesDependencies/formLengthMixin.js +0 -18
  138. package/dist/new-widgets/templatesDependencies/formMinMaxMixin.js +0 -18
  139. package/dist/new-widgets/templatesDependencies/formMixin.js +0 -56
  140. package/dist/new-widgets/templatesDependencies/formNumberMixin.js +0 -10
  141. package/dist/new-widgets/templatesDependencies/formRadioMixin.js +0 -12
  142. package/dist/new-widgets/templatesDependencies/formStepMixin.js +0 -12
  143. package/dist/new-widgets/templatesDependencies/linkTextMixin.js +0 -13
  144. package/dist/new-widgets/templatesDependencies/multipleFormMixin.js +0 -112
  145. package/dist/new-widgets/templatesDependencies/multipleselectFormMixin.js +0 -65
  146. package/dist/new-widgets/templatesDependencies/patternMixin.js +0 -18
  147. package/dist/new-widgets/templatesDependencies/rangeMixin.js +0 -100
  148. package/dist/new-widgets/templatesDependencies/setMixin.js +0 -9
  149. package/dist/new-widgets/templatesDependencies/valueRichtextMixin.js +0 -9
  150. package/dist/new-widgets/valueTransformationMixins/autolinkMixin.js +0 -14
  151. package/dist/new-widgets/valueTransformationMixins/dateMixin.js +0 -29
  152. package/dist/new-widgets/valueTransformationMixins/dateTimeMixin.js +0 -12
  153. package/dist/new-widgets/valueTransformationMixins/index.js +0 -15
  154. package/dist/new-widgets/valueTransformationMixins/markdownMixin.js +0 -30
  155. package/dist/new-widgets/valueTransformationMixins/multilineMixin.js +0 -13
  156. package/dist/new-widgets/valueTransformationMixins/oembedMixin.js +0 -21
  157. package/dist/solid-template-element.js +0 -144
  158. package/dist/style/default-theme.css.proxy.js +0 -10
  159. package/dist/widgets/baseWidget.js +0 -268
  160. package/dist/widgets/widget-factory.js +0 -22
  161. /package/dist/{style/default-theme.css → assets/default-theme-d0f20a8a.css} +0 -0
  162. /package/dist/{_snowpack/pkg/quill/dist/quill.snow.css → assets/quill.snow-8f222e44.css} +0 -0
  163. /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,174 +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) {
74
- let isSet = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
75
- let tagName = '';
76
- // If auto-range-[field] exists, create range-[field] and sets its value
77
- if (this.element.hasAttribute('auto-range-' + field) && !this.element.hasAttribute('range-' + field)) {
78
- const idField = `${this.rangeId}_${field}`;
79
- this.element.setAttribute('range-' + field, 'store://local.' + idField);
80
- this.populate();
81
- }
82
- const widgetAttribute = this.element.getAttribute('widget-' + field);
83
- // Choose widget
84
- if (!widgetAttribute && (this.element.hasAttribute('range-' + field) || this.element.hasAttribute('enum-' + field))) {
85
- tagName = 'solid-form-dropdown';
86
- } else {
87
- tagName = widgetAttribute || (!isSet ? this.defaultWidget : this.defaultSetWidget);
88
- }
89
- // Create widget
90
- if (!customElements.get(tagName)) {
91
- // component does not exist
92
- if (tagName.startsWith('solid')) newWidgetFactory(tagName); // solid- -> create it
93
- }
94
-
95
- return this.widgetFromTagName(tagName);
96
- },
97
- async attach(elm) {
98
- if (this.attachedElements.has(elm)) return;
99
- this.attachedElements.add(elm);
100
- await this.updateAutoRanges();
101
- },
102
- async detach(elm) {
103
- if (!this.attachedElements.has(elm)) return;
104
- this.attachedElements.delete(elm);
105
- await this.updateAutoRanges();
106
- },
107
- async updateAutoRanges() {
108
- for (const attr of this.element.attributes) {
109
- if (!attr['name'].startsWith('auto-range-')) continue;
110
- const field = attr['name'].replace('auto-range-', '');
111
- const autoRangeValues = new Set();
112
- for (const elm of this.attachedElements) {
113
- for (const value of await elm.getValuesOfField(field)) {
114
- autoRangeValues.add(value);
115
- }
116
- }
117
- const idField = `${this.rangeId}_${field}`;
118
- const id = `store://local.${idField}`;
119
- const ldpContains = Array.from(autoRangeValues).map(id => ({
120
- '@id': id
121
- }));
122
- const data = {
123
- "@type": "ldp:Container",
124
- "@context": this.context,
125
- "ldp:contains": ldpContains
126
- };
127
- sibStore.setLocalData(data, id);
128
- }
129
- },
130
- change(resource) {
131
- this.element.dispatchEvent(new CustomEvent('formChange', {
132
- bubbles: true,
133
- detail: {
134
- resource
135
- }
136
- }));
137
- },
138
- async inputChange() {
139
- this.change(this.value);
140
- },
141
- getSubmitTemplate() {
142
- return html`
143
- <div class=${ifDefined(this.classSubmitButton)}>
144
- ${this.submitWidget === 'button' ? html`
145
- <button type="submit">${this.submitButton || ''}</button>
146
- ` : html`
147
- <input type="submit" value=${ifDefined(this.submitButton || undefined)}>
148
- `}
149
- </div>
150
- `;
151
- },
152
- empty() {},
153
- async populate() {
154
- await this.replaceAttributesData();
155
- if (this.submitButton == null) {
156
- this.element.addEventListener('input', () => this.inputChange());
157
- } else {
158
- this.element.addEventListener('submit', e => {
159
- e.preventDefault();
160
- this.inputChange();
161
- });
162
- }
163
- const fields = await this.getFields();
164
- const widgetTemplates = await Promise.all(fields.map(field => this.createWidgetTemplate(field)));
165
- const template = html`
166
- <form>
167
- ${widgetTemplates}
168
- ${this.submitButton == null ? '' : this.getSubmitTemplate()}
169
- </form>
170
- `;
171
- render(template, this.element);
172
- }
173
- };
174
- Sib.register(SolidFormSearch);