@startinblox/core 0.19.0-beta.1 → 0.19.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.css → assets/MarkerCluster-614dea0a.css} +0 -0
- package/dist/{_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.Default.css → assets/MarkerCluster.Default-61258232.css} +0 -0
- package/dist/assets/en-e53105c5.js +14 -0
- package/dist/assets/en-e53105c5.js.map +1 -0
- package/dist/assets/fr-a7fcdb64.js +14 -0
- package/dist/assets/fr-a7fcdb64.js.map +1 -0
- package/dist/{_snowpack/pkg/fusejs.js → assets/helpers-bf15809c.js} +398 -454
- package/dist/assets/helpers-bf15809c.js.map +1 -0
- package/dist/{_snowpack/pkg/leaflet/dist/leaflet.css → assets/leaflet-3c081932.css} +3 -3
- package/dist/helpers.js +18 -0
- package/dist/helpers.js.map +1 -0
- package/dist/index.js +54600 -48
- package/dist/index.js.map +1 -0
- package/package.json +7 -22
- package/dist/_snowpack/pkg/autolinker.js +0 -4429
- package/dist/_snowpack/pkg/autolinker.js.map +0 -1
- package/dist/_snowpack/pkg/common/_baseUnary-d2677655.js +0 -353
- package/dist/_snowpack/pkg/common/_baseUnary-d2677655.js.map +0 -1
- package/dist/_snowpack/pkg/common/_commonjsHelpers-0597c316.js +0 -26
- package/dist/_snowpack/pkg/common/_commonjsHelpers-0597c316.js.map +0 -1
- package/dist/_snowpack/pkg/common/decode-26fbf385.js +0 -185
- package/dist/_snowpack/pkg/common/decode-26fbf385.js.map +0 -1
- package/dist/_snowpack/pkg/common/lit-html-3647afce.js +0 -1104
- package/dist/_snowpack/pkg/common/lit-html-3647afce.js.map +0 -1
- package/dist/_snowpack/pkg/delta-markdown-for-quill.js +0 -26198
- package/dist/_snowpack/pkg/delta-markdown-for-quill.js.map +0 -1
- package/dist/_snowpack/pkg/dialog-polyfill.js +0 -826
- package/dist/_snowpack/pkg/dialog-polyfill.js.map +0 -1
- package/dist/_snowpack/pkg/fusejs.js.map +0 -1
- package/dist/_snowpack/pkg/import-map.json +0 -25
- package/dist/_snowpack/pkg/jsonld-context-parser.js +0 -836
- package/dist/_snowpack/pkg/jsonld-context-parser.js.map +0 -1
- package/dist/_snowpack/pkg/jsonld.js +0 -11760
- package/dist/_snowpack/pkg/jsonld.js.map +0 -1
- package/dist/_snowpack/pkg/leaflet/dist/leaflet.css.proxy.js +0 -10
- package/dist/_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.Default.css.proxy.js +0 -10
- package/dist/_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.css.proxy.js +0 -10
- package/dist/_snowpack/pkg/lit-html/directives/if-defined.js +0 -39
- package/dist/_snowpack/pkg/lit-html/directives/if-defined.js.map +0 -1
- package/dist/_snowpack/pkg/lit-html/directives/unsafe-html.js +0 -48
- package/dist/_snowpack/pkg/lit-html/directives/unsafe-html.js.map +0 -1
- package/dist/_snowpack/pkg/lit-html/directives/until.js +0 -87
- package/dist/_snowpack/pkg/lit-html/directives/until.js.map +0 -1
- package/dist/_snowpack/pkg/lit-html.js +0 -94
- package/dist/_snowpack/pkg/lit-html.js.map +0 -1
- package/dist/_snowpack/pkg/markdown-it-link-attributes.js +0 -68
- package/dist/_snowpack/pkg/markdown-it-link-attributes.js.map +0 -1
- package/dist/_snowpack/pkg/markdown-it.js +0 -11307
- package/dist/_snowpack/pkg/markdown-it.js.map +0 -1
- package/dist/_snowpack/pkg/quill/dist/quill.snow.css.proxy.js +0 -10
- package/dist/_snowpack/pkg/quill-delta-to-markdown.js +0 -971
- package/dist/_snowpack/pkg/quill-delta-to-markdown.js.map +0 -1
- package/dist/_snowpack/pkg/quill.js +0 -14441
- package/dist/_snowpack/pkg/quill.js.map +0 -1
- package/dist/_snowpack/pkg/slim-select.js +0 -714
- package/dist/_snowpack/pkg/slim-select.js.map +0 -1
- package/dist/_snowpack/pkg/tui-calendar/dist/tui-calendar.css +0 -1149
- package/dist/_snowpack/pkg/tui-calendar/dist/tui-calendar.css.proxy.js +0 -10
- package/dist/_snowpack/pkg/tui-calendar.js +0 -46503
- package/dist/_snowpack/pkg/tui-calendar.js.map +0 -1
- package/dist/components/solid-ac-checker.js +0 -45
- package/dist/components/solid-calendar.js +0 -66
- package/dist/components/solid-delete.js +0 -96
- package/dist/components/solid-display.js +0 -150
- package/dist/components/solid-form-search.js +0 -173
- package/dist/components/solid-form.js +0 -257
- package/dist/components/solid-lang.js +0 -35
- package/dist/components/solid-map.js +0 -204
- package/dist/components/solid-table.js +0 -181
- package/dist/components/solid-widget.js +0 -72
- package/dist/import.css +0 -4
- package/dist/libs/Component.js +0 -13
- package/dist/libs/ComponentFactory.js +0 -165
- package/dist/libs/Compositor.js +0 -96
- package/dist/libs/Sib.js +0 -44
- package/dist/libs/filter.js +0 -184
- package/dist/libs/helpers.js +0 -185
- package/dist/libs/interfaces.js +0 -6
- package/dist/libs/lit-helpers.js +0 -139
- package/dist/libs/polyfills.js +0 -35
- package/dist/libs/store/custom-getter.js +0 -344
- package/dist/libs/store/server-pagination.js +0 -19
- package/dist/libs/store/server-search.js +0 -32
- package/dist/libs/store/store.js +0 -560
- package/dist/locales/en.json +0 -10
- package/dist/locales/en.json.proxy.js +0 -2
- package/dist/locales/fr.json +0 -10
- package/dist/locales/fr.json.proxy.js +0 -2
- package/dist/mixins/attributeBinderMixin.js +0 -113
- package/dist/mixins/contextMixin.js +0 -26
- package/dist/mixins/counterMixin.js +0 -54
- package/dist/mixins/federationMixin.js +0 -57
- package/dist/mixins/filterMixin.js +0 -152
- package/dist/mixins/grouperMixin.js +0 -73
- package/dist/mixins/highlighterMixin.js +0 -36
- package/dist/mixins/interfaces.js +0 -6
- package/dist/mixins/listMixin.js +0 -116
- package/dist/mixins/nextMixin.js +0 -23
- package/dist/mixins/paginateMixin.js +0 -97
- package/dist/mixins/requiredMixin.js +0 -38
- package/dist/mixins/serverPaginationMixin.js +0 -122
- package/dist/mixins/sorterMixin.js +0 -131
- package/dist/mixins/storeMixin.js +0 -139
- package/dist/mixins/translationMixin.js +0 -58
- package/dist/mixins/validationMixin.js +0 -95
- package/dist/mixins/widgetMixin.js +0 -358
- package/dist/new-widgets/attributeMixins/actionMixin.js +0 -13
- package/dist/new-widgets/attributeMixins/blankMixin.js +0 -7
- package/dist/new-widgets/attributeMixins/booleanMixin.js +0 -7
- package/dist/new-widgets/attributeMixins/index.js +0 -19
- package/dist/new-widgets/attributeMixins/mailtoMixin.js +0 -7
- package/dist/new-widgets/attributeMixins/multipleMixin.js +0 -27
- package/dist/new-widgets/attributeMixins/numberMixin.js +0 -7
- package/dist/new-widgets/attributeMixins/placeholderMixin.js +0 -16
- package/dist/new-widgets/attributeMixins/telMixin.js +0 -7
- package/dist/new-widgets/baseWidgetMixin.js +0 -109
- package/dist/new-widgets/callbackMixins/autocompletionMixin.js +0 -96
- package/dist/new-widgets/callbackMixins/index.js +0 -7
- package/dist/new-widgets/callbackMixins/richtextMixin.js +0 -37
- package/dist/new-widgets/callbackMixins/slimselect.css.proxy.js +0 -10
- package/dist/new-widgets/interfaces.js +0 -1
- package/dist/new-widgets/new-widget-factory.js +0 -91
- package/dist/new-widgets/templateAdditionMixins/addableMixin.js +0 -26
- package/dist/new-widgets/templateAdditionMixins/index.js +0 -13
- package/dist/new-widgets/templateAdditionMixins/labelLastMixin.js +0 -16
- package/dist/new-widgets/templateAdditionMixins/labelMixin.js +0 -18
- package/dist/new-widgets/templates/defaultTemplatesDirectory.js +0 -29
- package/dist/new-widgets/templates/displayTemplatesDirectory.js +0 -54
- package/dist/new-widgets/templates/formTemplatesDirectory.js +0 -423
- package/dist/new-widgets/templates/groupTemplatesDirectory.js +0 -11
- package/dist/new-widgets/templates/index.js +0 -6
- package/dist/new-widgets/templates/setTemplatesDirectory.js +0 -16
- package/dist/new-widgets/templatesDependencies/altMixin.js +0 -12
- package/dist/new-widgets/templatesDependencies/editableMixin.js +0 -60
- package/dist/new-widgets/templatesDependencies/filterRangeFormMixin.js +0 -34
- package/dist/new-widgets/templatesDependencies/formCheckboxMixin.js +0 -10
- package/dist/new-widgets/templatesDependencies/formCheckboxesMixin.js +0 -41
- package/dist/new-widgets/templatesDependencies/formDropdownMixin.js +0 -59
- package/dist/new-widgets/templatesDependencies/formFileMixin.js +0 -82
- package/dist/new-widgets/templatesDependencies/formLengthMixin.js +0 -18
- package/dist/new-widgets/templatesDependencies/formMinMaxMixin.js +0 -18
- package/dist/new-widgets/templatesDependencies/formMixin.js +0 -56
- package/dist/new-widgets/templatesDependencies/formNumberMixin.js +0 -10
- package/dist/new-widgets/templatesDependencies/formRadioMixin.js +0 -12
- package/dist/new-widgets/templatesDependencies/formStepMixin.js +0 -12
- package/dist/new-widgets/templatesDependencies/linkTextMixin.js +0 -13
- package/dist/new-widgets/templatesDependencies/multipleFormMixin.js +0 -116
- package/dist/new-widgets/templatesDependencies/multipleselectFormMixin.js +0 -74
- package/dist/new-widgets/templatesDependencies/patternMixin.js +0 -18
- package/dist/new-widgets/templatesDependencies/rangeMixin.js +0 -100
- package/dist/new-widgets/templatesDependencies/setMixin.js +0 -9
- package/dist/new-widgets/templatesDependencies/valueRichtextMixin.js +0 -9
- package/dist/new-widgets/valueTransformationMixins/autolinkMixin.js +0 -14
- package/dist/new-widgets/valueTransformationMixins/dateMixin.js +0 -29
- package/dist/new-widgets/valueTransformationMixins/dateTimeMixin.js +0 -12
- package/dist/new-widgets/valueTransformationMixins/index.js +0 -15
- package/dist/new-widgets/valueTransformationMixins/markdownMixin.js +0 -30
- package/dist/new-widgets/valueTransformationMixins/multilineMixin.js +0 -13
- package/dist/new-widgets/valueTransformationMixins/oembedMixin.js +0 -21
- package/dist/solid-template-element.js +0 -144
- package/dist/style/default-theme.css.proxy.js +0 -10
- package/dist/widgets/baseWidget.js +0 -267
- package/dist/widgets/widget-factory.js +0 -20
- /package/dist/{style/default-theme.css → assets/default-theme-d0f20a8a.css} +0 -0
- /package/dist/{_snowpack/pkg/quill/dist/quill.snow.css → assets/quill.snow-8f222e44.css} +0 -0
- /package/dist/{new-widgets/callbackMixins/slimselect.css → assets/slimselect-43e3ebc8.css} +0 -0
|
@@ -1,358 +0,0 @@
|
|
|
1
|
-
import { spread, preHTML } from '../libs/lit-helpers.js';
|
|
2
|
-
import { parseFieldsString, findClosingBracketMatchIndex } from '../libs/helpers.js';
|
|
3
|
-
import { newWidgetFactory } from '../new-widgets/new-widget-factory.js';
|
|
4
|
-
import { WidgetType } from './interfaces.js';
|
|
5
|
-
import { html, render } from '../_snowpack/pkg/lit-html.js';
|
|
6
|
-
import { ifDefined } from '../_snowpack/pkg/lit-html/directives/if-defined.js';
|
|
7
|
-
const WidgetMixin = {
|
|
8
|
-
name: 'widget-mixin',
|
|
9
|
-
use: [],
|
|
10
|
-
attributes: {
|
|
11
|
-
fields: {
|
|
12
|
-
type: String,
|
|
13
|
-
default: undefined
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
initialState: {
|
|
17
|
-
nameWidgets: null,
|
|
18
|
-
_div: null
|
|
19
|
-
},
|
|
20
|
-
created() {
|
|
21
|
-
this.nameWidgets = [];
|
|
22
|
-
},
|
|
23
|
-
attached() {
|
|
24
|
-
if (!this.dataSrc && !this.resource && this.noRender === null) this.populate();
|
|
25
|
-
},
|
|
26
|
-
get parentElement() {
|
|
27
|
-
return 'div';
|
|
28
|
-
},
|
|
29
|
-
get div() {
|
|
30
|
-
if (this._div) return this._div;
|
|
31
|
-
this._div = document.createElement(this.parentElement);
|
|
32
|
-
this.element.appendChild(this._div);
|
|
33
|
-
return this._div;
|
|
34
|
-
},
|
|
35
|
-
set div(value) {
|
|
36
|
-
this._div = value;
|
|
37
|
-
},
|
|
38
|
-
get widgets() {
|
|
39
|
-
return this.nameWidgets.map(name => this.element.querySelector(`[name="${name}"]`));
|
|
40
|
-
},
|
|
41
|
-
/**
|
|
42
|
-
* Return field list of the component
|
|
43
|
-
*/
|
|
44
|
-
async getFields() {
|
|
45
|
-
// TODO : improve code
|
|
46
|
-
const attr = this.fields;
|
|
47
|
-
if (attr === '') return [];
|
|
48
|
-
if (attr) return parseFieldsString(attr);
|
|
49
|
-
let resource = this.resource;
|
|
50
|
-
if (resource && resource.isContainer?.()) {
|
|
51
|
-
// If container, keep the 1rst resource
|
|
52
|
-
for (let res of resource['ldp:contains']) {
|
|
53
|
-
resource = res;
|
|
54
|
-
break;
|
|
55
|
-
}
|
|
56
|
-
} else if (resource && this.arrayField && this.predicateName) {
|
|
57
|
-
// if array, keep the 1rst resource
|
|
58
|
-
for (let res of resource[this.predicateName]) {
|
|
59
|
-
resource = res;
|
|
60
|
-
break;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
if (!this.dataSrc) console.error(new Error('You must provide a "fields" attribute'));
|
|
64
|
-
if (!resource) return [];
|
|
65
|
-
let fields = [];
|
|
66
|
-
for (const prop of resource.properties) {
|
|
67
|
-
if (!prop.startsWith('@') && !(prop === "permissions") && (await resource[prop])) fields.push(prop);
|
|
68
|
-
}
|
|
69
|
-
return fields;
|
|
70
|
-
},
|
|
71
|
-
/**
|
|
72
|
-
* return attribute if "field" is an action
|
|
73
|
-
* @param field - string
|
|
74
|
-
*/
|
|
75
|
-
getAction(field) {
|
|
76
|
-
const action = this.element.getAttribute('action-' + field);
|
|
77
|
-
return action;
|
|
78
|
-
},
|
|
79
|
-
/**
|
|
80
|
-
* return true if "field" is editable
|
|
81
|
-
* @param field - string
|
|
82
|
-
*/
|
|
83
|
-
editable(field) {
|
|
84
|
-
return this.element.hasAttribute('editable-' + field);
|
|
85
|
-
},
|
|
86
|
-
/**
|
|
87
|
-
* Return regexp to check if "field" is a set
|
|
88
|
-
* @param field - string
|
|
89
|
-
*/
|
|
90
|
-
getSetRegexp(field) {
|
|
91
|
-
return new RegExp(`(^|\\,|\\(|\\s)\\s*${field}\\s*\\(`, 'g');
|
|
92
|
-
},
|
|
93
|
-
/**
|
|
94
|
-
* Return fields contained in set "field"
|
|
95
|
-
* @param field - string
|
|
96
|
-
*/
|
|
97
|
-
getSet(field) {
|
|
98
|
-
const setString = this.fields.match(this.getSetRegexp(field));
|
|
99
|
-
if (!setString) return [];
|
|
100
|
-
const firstSetBracket = this.fields.indexOf(setString[0]) + setString[0].length - 1;
|
|
101
|
-
const lastSetBracket = findClosingBracketMatchIndex(this.fields, firstSetBracket);
|
|
102
|
-
const set = this.fields.substring(firstSetBracket + 1, lastSetBracket);
|
|
103
|
-
return parseFieldsString(set);
|
|
104
|
-
},
|
|
105
|
-
/**
|
|
106
|
-
* Return true if "field" is a set
|
|
107
|
-
* @param field - string
|
|
108
|
-
*/
|
|
109
|
-
isSet(field) {
|
|
110
|
-
if (!this.fields) return false;
|
|
111
|
-
let foundSets = this.fields.match(this.getSetRegexp(field));
|
|
112
|
-
return foundSets ? foundSets.length > 0 : false;
|
|
113
|
-
},
|
|
114
|
-
isString(field) {
|
|
115
|
-
return field.startsWith('\'') || field.startsWith('\"');
|
|
116
|
-
},
|
|
117
|
-
/**
|
|
118
|
-
* Return the value of "resource" for predicate "field"
|
|
119
|
-
* @param field - string
|
|
120
|
-
* @param resource - Resource
|
|
121
|
-
*/
|
|
122
|
-
async fetchValue(field, resource) {
|
|
123
|
-
if (resource && !resource.isContainer?.()) {
|
|
124
|
-
let fieldValue = await resource[field];
|
|
125
|
-
if (Array.isArray(fieldValue) && !fieldValue['ldp:contains']) return JSON.stringify(fieldValue);
|
|
126
|
-
}
|
|
127
|
-
return resource && !resource.isContainer?.() ? await resource[field] : undefined;
|
|
128
|
-
},
|
|
129
|
-
/**
|
|
130
|
-
* Return the value of the field
|
|
131
|
-
* @param field - field
|
|
132
|
-
*/
|
|
133
|
-
async getValue(field, resource) {
|
|
134
|
-
const escapedField = this.getEscapedField(field);
|
|
135
|
-
if (this.getAction(escapedField)) {
|
|
136
|
-
return this.getAction(escapedField);
|
|
137
|
-
}
|
|
138
|
-
if (this.element.hasAttribute('value-' + field)) {
|
|
139
|
-
return this.element.getAttribute('value-' + field);
|
|
140
|
-
}
|
|
141
|
-
let resourceValue = await this.fetchValue(field, resource);
|
|
142
|
-
|
|
143
|
-
// Empty value
|
|
144
|
-
if (resourceValue === undefined || resourceValue === '' || resourceValue === null)
|
|
145
|
-
// If null or empty, return field default value
|
|
146
|
-
return this.element.hasAttribute('default-' + field) ? this.element.getAttribute('default-' + field) : '';
|
|
147
|
-
return resourceValue;
|
|
148
|
-
},
|
|
149
|
-
empty() {},
|
|
150
|
-
/**
|
|
151
|
-
* Return a widget from a tagName, and create it if necessary
|
|
152
|
-
* @param tagName - string
|
|
153
|
-
*/
|
|
154
|
-
widgetFromTagName(tagName) {
|
|
155
|
-
let type = tagName.startsWith('solid') ? WidgetType.CUSTOM : WidgetType.USER;
|
|
156
|
-
if (!customElements.get(tagName)) {
|
|
157
|
-
// component does not exist
|
|
158
|
-
if (tagName.startsWith('solid')) newWidgetFactory(tagName); // solid- -> create it
|
|
159
|
-
else type = WidgetType.NATIVE; // or use a native tag
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
return {
|
|
163
|
-
tagName,
|
|
164
|
-
type
|
|
165
|
-
}; // return tagName
|
|
166
|
-
},
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* Return widget for field "field"
|
|
170
|
-
* @param field - string
|
|
171
|
-
* @param isSet - boolean
|
|
172
|
-
*/
|
|
173
|
-
getWidget(field, isSet = false) {
|
|
174
|
-
const widget = this.element.getAttribute('widget-' + field);
|
|
175
|
-
if (widget) return this.widgetFromTagName(widget);
|
|
176
|
-
if (this.getAction(field)) return this.widgetFromTagName('solid-action');
|
|
177
|
-
return !isSet ? this.widgetFromTagName(this.defaultWidget) : this.widgetFromTagName(this.defaultSetWidget);
|
|
178
|
-
},
|
|
179
|
-
/**
|
|
180
|
-
* Return multiple widget if "field" is a multiple, false if it's not
|
|
181
|
-
* @param field - string
|
|
182
|
-
*/
|
|
183
|
-
multiple(field) {
|
|
184
|
-
const attribute = 'multiple-' + field;
|
|
185
|
-
if (!this.element.hasAttribute(attribute)) return null;
|
|
186
|
-
const widget = this.element.getAttribute(attribute) || this.defaultMultipleWidget;
|
|
187
|
-
return this.widgetFromTagName(widget);
|
|
188
|
-
},
|
|
189
|
-
/**
|
|
190
|
-
* If attribute "lookForAttr" is set on element, add "attrKey" to the "attributes" list
|
|
191
|
-
* @param lookForAttr - string
|
|
192
|
-
* @param setAttrKey - string
|
|
193
|
-
* @param attributes - object
|
|
194
|
-
*/
|
|
195
|
-
addToAttributes(lookForAttr, setAttrKey, attributes) {
|
|
196
|
-
const attribute = this.element.getAttribute(lookForAttr);
|
|
197
|
-
if (attribute == null) return;
|
|
198
|
-
attributes[setAttrKey] = attribute;
|
|
199
|
-
},
|
|
200
|
-
/**
|
|
201
|
-
* Return all the attributes of widget "field"
|
|
202
|
-
* @param field - string
|
|
203
|
-
* @param resource - Resource
|
|
204
|
-
*/
|
|
205
|
-
widgetAttributes(field, resource) {
|
|
206
|
-
const attrs = {
|
|
207
|
-
name: field
|
|
208
|
-
};
|
|
209
|
-
const escapedField = this.getEscapedField(field);
|
|
210
|
-
|
|
211
|
-
// transfer all multiple-[field]-[attr] attributes as [attr] for multiple widget [field]
|
|
212
|
-
const multipleAttributes = ['fields', 'label', 'widget', 'add-label', 'remove-label', 'next', 'empty-widget', 'add-class', 'remove-class'];
|
|
213
|
-
for (let attr of multipleAttributes) this.addToAttributes(`multiple-${escapedField}-${attr}`, attr, attrs);
|
|
214
|
-
|
|
215
|
-
// transfer all [attr]-[field] attributes as [attr] attribute for widget [field]
|
|
216
|
-
const defaultAttributes = ['range', 'enum', 'label', 'placeholder', 'class',
|
|
217
|
-
|
|
218
|
-
/* 'widget', */
|
|
219
|
-
, 'required', 'editable', 'autocomplete', 'upload-url', 'option-label', 'option-value', 'order-by',
|
|
220
|
-
// deprecated. Remove in 0.15
|
|
221
|
-
'each-label', 'order-asc', 'order-desc', 'min', 'max', 'pattern', 'title', 'start-value', 'end-value', 'alt', 'step', 'maxlength', 'minlength', 'search-text', 'search-placeholder', 'link-text'];
|
|
222
|
-
for (let attr of defaultAttributes) this.addToAttributes(`${attr}-${escapedField}`, attr, attrs);
|
|
223
|
-
const addableAttributes = Array.from(this.element.attributes).filter(a => a.name.startsWith(`addable-${escapedField}`));
|
|
224
|
-
for (let attr of addableAttributes) this.addToAttributes(attr.name, attr.name.replace(`addable-${escapedField}`, 'addable'), attrs);
|
|
225
|
-
const resourceId = resource ? resource['@id'] : null;
|
|
226
|
-
if (this.multiple(escapedField)) attrs['widget'] = this.getWidget(escapedField).tagName;
|
|
227
|
-
if (this.getAction(escapedField) && resourceId) attrs['src'] = this.element.getAttribute('src-' + escapedField) || resourceId;
|
|
228
|
-
if (this.editable(escapedField) && resourceId) attrs['value-id'] = resourceId;
|
|
229
|
-
return attrs;
|
|
230
|
-
},
|
|
231
|
-
/**
|
|
232
|
-
* Creates and return a widget for field + add it to the widget list
|
|
233
|
-
* @param field - string
|
|
234
|
-
*/
|
|
235
|
-
async createWidgetTemplate(field, resource = null, transformAttributes = false) {
|
|
236
|
-
if (this.isString(field)) return this.createString(field); // field is a static string
|
|
237
|
-
if (this.isSet(field)) return await this.createSet(field);
|
|
238
|
-
const currentResource = resource || this.resource;
|
|
239
|
-
let attributes = this.widgetAttributes(field, currentResource);
|
|
240
|
-
const escapedField = this.getEscapedField(field);
|
|
241
|
-
const widgetMeta = this.multiple(escapedField) || this.getWidget(escapedField);
|
|
242
|
-
let tagName = widgetMeta.tagName;
|
|
243
|
-
let widgetTemplate = html``;
|
|
244
|
-
|
|
245
|
-
// Set attributes
|
|
246
|
-
let value = await this.getValue(field, currentResource);
|
|
247
|
-
if (widgetMeta.type === WidgetType.NATIVE) {
|
|
248
|
-
// native widget (ie: h1)
|
|
249
|
-
widgetTemplate = preHTML`
|
|
250
|
-
<${tagName}
|
|
251
|
-
name="${ifDefined(attributes.name)}"
|
|
252
|
-
class="${ifDefined(attributes.class)}"
|
|
253
|
-
>${value}</${tagName}>
|
|
254
|
-
`;
|
|
255
|
-
} else {
|
|
256
|
-
// custom widget (ie: solid-display-value)
|
|
257
|
-
// Check if value is defined, and if the default widget is needed
|
|
258
|
-
if ((value === null || value === '') && this.element.hasAttribute('default-widget-' + field)) {
|
|
259
|
-
tagName = this.element.getAttribute('default-widget-' + field);
|
|
260
|
-
}
|
|
261
|
-
// Set attributes to the widget
|
|
262
|
-
// setAttribute set a string. Make sure null values are empty
|
|
263
|
-
if (value === null || value === undefined) attributes.value = '';
|
|
264
|
-
if (widgetMeta.type === WidgetType.USER && value['@id']) {
|
|
265
|
-
// if value is a resource and solid-widget used, set data-src
|
|
266
|
-
attributes['data-src'] = value['@id'];
|
|
267
|
-
} else {
|
|
268
|
-
// otherwise, set value attribute
|
|
269
|
-
attributes['value'] = value;
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
// Subscribe widgets if they show a resource
|
|
273
|
-
if (value && value['@id']) attributes['auto-subscribe'] = value['@id'];
|
|
274
|
-
|
|
275
|
-
// Transform store://XXX attributes
|
|
276
|
-
if (transformAttributes) attributes = await this.transformAttributes(attributes, currentResource);
|
|
277
|
-
widgetTemplate = preHTML`<${tagName} ...=${spread(attributes)}></${tagName}>`;
|
|
278
|
-
}
|
|
279
|
-
this.nameWidgets.push(field);
|
|
280
|
-
return widgetTemplate;
|
|
281
|
-
},
|
|
282
|
-
defineAttribute(widget, attribute, value) {
|
|
283
|
-
if (widget.getAttribute(attribute) !== value) {
|
|
284
|
-
// if attribute is different than previous one
|
|
285
|
-
widget.setAttribute(attribute, value); // set it
|
|
286
|
-
}
|
|
287
|
-
},
|
|
288
|
-
|
|
289
|
-
/**
|
|
290
|
-
* Create a set and add fields to it
|
|
291
|
-
* @param field - string
|
|
292
|
-
*/
|
|
293
|
-
async createSet(field) {
|
|
294
|
-
const setWidget = this.getWidget(field, true);
|
|
295
|
-
|
|
296
|
-
// Get set attributes
|
|
297
|
-
const attrs = {
|
|
298
|
-
name: field
|
|
299
|
-
};
|
|
300
|
-
const setAttributes = ['class', 'label'];
|
|
301
|
-
for (let attr of setAttributes) this.addToAttributes(`${attr}-${field}`, attr, attrs);
|
|
302
|
-
|
|
303
|
-
// Create widget if not already existing
|
|
304
|
-
let widget = this.element.querySelector(`${setWidget.tagName}[name="${field}"]`);
|
|
305
|
-
let initializing = false; // used to render widget only first time
|
|
306
|
-
if (!widget) {
|
|
307
|
-
widget = document.createElement(setWidget.tagName);
|
|
308
|
-
initializing = true;
|
|
309
|
-
}
|
|
310
|
-
for (let name of Object.keys(attrs)) {
|
|
311
|
-
this.defineAttribute(widget, name, attrs[name], setWidget.type);
|
|
312
|
-
}
|
|
313
|
-
if (widget.component && initializing) widget.component.render();
|
|
314
|
-
let setFields = this.getSet(field);
|
|
315
|
-
// Catch widget for the set if all these fields are empty
|
|
316
|
-
if (this.element.hasAttribute('empty-' + field)) {
|
|
317
|
-
let hasOnlyEmpty = true;
|
|
318
|
-
for (let field of setFields) {
|
|
319
|
-
let value = await this.getValue(field, this.resource);
|
|
320
|
-
if (value !== '') {
|
|
321
|
-
// if one not empty
|
|
322
|
-
hasOnlyEmpty = false;
|
|
323
|
-
continue; // break loop
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
;
|
|
328
|
-
if (hasOnlyEmpty) {
|
|
329
|
-
// if only empty values, return empty-widget
|
|
330
|
-
const attributes = this.widgetAttributes(field, this.resource);
|
|
331
|
-
const tagName = this.element.getAttribute(`empty-${field}`);
|
|
332
|
-
const valueSet = this.element.getAttribute(`empty-${field}-value`);
|
|
333
|
-
if (valueSet) attributes.value = valueSet;
|
|
334
|
-
return preHTML`<${tagName} ...=${spread(attributes)}></${tagName}>`;
|
|
335
|
-
}
|
|
336
|
-
;
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
// Render template
|
|
340
|
-
const widgetsTemplate = await Promise.all(setFields.map(field => this.createWidgetTemplate(field)));
|
|
341
|
-
const template = html`${widgetsTemplate}`;
|
|
342
|
-
render(template, widget.querySelector('[data-content]') || widget);
|
|
343
|
-
return widget;
|
|
344
|
-
},
|
|
345
|
-
createString(value) {
|
|
346
|
-
return html`
|
|
347
|
-
<span>${value.slice(1, -1).replace(/\\(['"])/g, '$1')}</span>
|
|
348
|
-
`;
|
|
349
|
-
},
|
|
350
|
-
/**
|
|
351
|
-
* Returns field name without starting "@"
|
|
352
|
-
* @param field
|
|
353
|
-
*/
|
|
354
|
-
getEscapedField(field) {
|
|
355
|
-
return field.startsWith('@') ? field.slice(1, field.length) : field;
|
|
356
|
-
}
|
|
357
|
-
};
|
|
358
|
-
export { WidgetMixin };
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { MultipleMixin } from './multipleMixin.js';
|
|
2
|
-
import { ActionMixin } from './actionMixin.js';
|
|
3
|
-
import { BlankMixin } from './blankMixin.js';
|
|
4
|
-
import { MailtoMixin } from './mailtoMixin.js';
|
|
5
|
-
import { TelMixin } from './telMixin.js';
|
|
6
|
-
import { PlaceholderMixin } from './placeholderMixin.js';
|
|
7
|
-
import { BooleanMixin } from './booleanMixin.js';
|
|
8
|
-
import { NumberMixin } from './numberMixin.js';
|
|
9
|
-
const attributeDirectory = {
|
|
10
|
-
multiple: MultipleMixin,
|
|
11
|
-
action: ActionMixin,
|
|
12
|
-
blank: BlankMixin,
|
|
13
|
-
mailto: MailtoMixin,
|
|
14
|
-
tel: TelMixin,
|
|
15
|
-
placeholder: PlaceholderMixin,
|
|
16
|
-
bool: BooleanMixin,
|
|
17
|
-
num: NumberMixin
|
|
18
|
-
};
|
|
19
|
-
export { attributeDirectory, MultipleMixin, ActionMixin, BlankMixin, MailtoMixin, TelMixin, PlaceholderMixin };
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
const MultipleMixin = {
|
|
2
|
-
name: 'multiple-mixin',
|
|
3
|
-
attributes: {
|
|
4
|
-
fields: {
|
|
5
|
-
type: String,
|
|
6
|
-
default: '',
|
|
7
|
-
callback: function (newValue) {
|
|
8
|
-
this.addToAttributes(newValue, 'fields');
|
|
9
|
-
}
|
|
10
|
-
},
|
|
11
|
-
next: {
|
|
12
|
-
type: String,
|
|
13
|
-
default: '',
|
|
14
|
-
callback: function (newValue) {
|
|
15
|
-
this.addToAttributes(newValue, 'next');
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
emptyWidget: {
|
|
19
|
-
type: String,
|
|
20
|
-
default: '',
|
|
21
|
-
callback: function (newValue) {
|
|
22
|
-
this.addToAttributes(newValue, 'emptyWidget');
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
export { MultipleMixin };
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
const PlaceholderMixin = {
|
|
2
|
-
name: 'placeholder-mixin',
|
|
3
|
-
attributes: {
|
|
4
|
-
placeholder: {
|
|
5
|
-
type: String,
|
|
6
|
-
default: '',
|
|
7
|
-
callback: function (newValue) {
|
|
8
|
-
this.addToAttributes(newValue, 'placeholder');
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
},
|
|
12
|
-
attached() {
|
|
13
|
-
this.listAttributes['placeholder'] = this.placeholder || this.label || this.name || '';
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
export { PlaceholderMixin };
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import { render } from '../_snowpack/pkg/lit-html.js';
|
|
2
|
-
const BaseWidgetMixin = {
|
|
3
|
-
name: 'widget-mixin',
|
|
4
|
-
use: [],
|
|
5
|
-
attributes: {
|
|
6
|
-
value: {
|
|
7
|
-
type: String,
|
|
8
|
-
default: '',
|
|
9
|
-
callback: function () {
|
|
10
|
-
this.planRender();
|
|
11
|
-
}
|
|
12
|
-
},
|
|
13
|
-
name: {
|
|
14
|
-
type: String,
|
|
15
|
-
default: '',
|
|
16
|
-
callback: function (newValue) {
|
|
17
|
-
this.addToAttributes(newValue, 'name');
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
label: {
|
|
21
|
-
type: String,
|
|
22
|
-
default: null,
|
|
23
|
-
callback: function (newValue) {
|
|
24
|
-
this.addToAttributes(newValue, 'label');
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
|
-
autoSubscribe: {
|
|
28
|
-
type: String,
|
|
29
|
-
default: null,
|
|
30
|
-
callback: function (newValue) {
|
|
31
|
-
if (this.subscription) PubSub.unsubscribe(this.subscription);
|
|
32
|
-
this.subscribe(newValue);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
initialState: {
|
|
37
|
-
listValueTransformations: [],
|
|
38
|
-
listTemplateAdditions: [],
|
|
39
|
-
listAttributes: {},
|
|
40
|
-
listCallbacks: [],
|
|
41
|
-
renderPlanned: false
|
|
42
|
-
},
|
|
43
|
-
get template() {
|
|
44
|
-
return null;
|
|
45
|
-
},
|
|
46
|
-
created() {
|
|
47
|
-
this.listValueTransformations = [];
|
|
48
|
-
this.listAttributes = {};
|
|
49
|
-
this.listTemplateAdditions = [];
|
|
50
|
-
this.listCallbacks = [];
|
|
51
|
-
this.subscription = null;
|
|
52
|
-
},
|
|
53
|
-
attached() {
|
|
54
|
-
this.planRender();
|
|
55
|
-
},
|
|
56
|
-
detached() {
|
|
57
|
-
if (this.subscription) PubSub.unsubscribe(this.subscription);
|
|
58
|
-
},
|
|
59
|
-
planRender() {
|
|
60
|
-
if (!this.renderPlanned && document.body.contains(this.element)) {
|
|
61
|
-
this.renderPlanned = true;
|
|
62
|
-
setTimeout(() => {
|
|
63
|
-
this.render();
|
|
64
|
-
this.renderPlanned = false;
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
},
|
|
68
|
-
render() {
|
|
69
|
-
const listValueTransformations = [...this.listValueTransformations];
|
|
70
|
-
listValueTransformations.push(this.renderTemplate.bind(this));
|
|
71
|
-
const nextProcessor = listValueTransformations.shift();
|
|
72
|
-
nextProcessor(this.value, listValueTransformations);
|
|
73
|
-
|
|
74
|
-
// Callbacks
|
|
75
|
-
const listCallbacks = [...this.listCallbacks];
|
|
76
|
-
if (listCallbacks.length) {
|
|
77
|
-
const nextCallback = listCallbacks.shift();
|
|
78
|
-
nextCallback(this.value, listCallbacks);
|
|
79
|
-
}
|
|
80
|
-
this.element.dispatchEvent(new CustomEvent('widgetRendered', {
|
|
81
|
-
bubbles: true
|
|
82
|
-
}));
|
|
83
|
-
},
|
|
84
|
-
renderTemplate(value) {
|
|
85
|
-
const template = this.template(value, {
|
|
86
|
-
...this.listAttributes
|
|
87
|
-
});
|
|
88
|
-
const listTemplateAdditions = [...this.listTemplateAdditions];
|
|
89
|
-
listTemplateAdditions.push(this.templateToDOM.bind(this));
|
|
90
|
-
const nextProcessor = listTemplateAdditions.shift();
|
|
91
|
-
nextProcessor(template, listTemplateAdditions);
|
|
92
|
-
},
|
|
93
|
-
templateToDOM(template) {
|
|
94
|
-
render(template, this.element);
|
|
95
|
-
},
|
|
96
|
-
addToAttributes(value, attrKey) {
|
|
97
|
-
if (value !== null && value !== this.listAttributes[attrKey]) {
|
|
98
|
-
this.listAttributes[attrKey] = value;
|
|
99
|
-
this.planRender();
|
|
100
|
-
}
|
|
101
|
-
},
|
|
102
|
-
subscribe(event) {
|
|
103
|
-
this.subscription = PubSub.subscribe(event, () => this.planRender());
|
|
104
|
-
},
|
|
105
|
-
update() {
|
|
106
|
-
this.planRender();
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
|
-
export { BaseWidgetMixin };
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { fuzzyCompare } from '../../libs/helpers.js';
|
|
2
|
-
import SlimSelect from '../../_snowpack/pkg/slim-select.js';
|
|
3
|
-
import { TranslationMixin } from '../../mixins/translationMixin.js';
|
|
4
|
-
const AutocompletionMixin = {
|
|
5
|
-
name: 'autocompletion-mixin',
|
|
6
|
-
use: [TranslationMixin],
|
|
7
|
-
attributes: {
|
|
8
|
-
searchText: {
|
|
9
|
-
type: String,
|
|
10
|
-
default: null,
|
|
11
|
-
callback: function (newValue) {
|
|
12
|
-
this.addToAttributes(newValue, 'searchText');
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
|
-
searchPlaceholder: {
|
|
16
|
-
type: String,
|
|
17
|
-
default: null,
|
|
18
|
-
callback: function (newValue) {
|
|
19
|
-
this.addToAttributes(newValue, 'searchPlaceholder');
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
initialState: {
|
|
24
|
-
slimSelect: null,
|
|
25
|
-
mutationObserver: null
|
|
26
|
-
},
|
|
27
|
-
created() {
|
|
28
|
-
//@ts-ignore
|
|
29
|
-
import("./slimselect.css.proxy.js");
|
|
30
|
-
this.slimSelect = null;
|
|
31
|
-
this.addToAttributes(true, 'autocomplete');
|
|
32
|
-
this.listCallbacks.push(this.addCallback.bind(this));
|
|
33
|
-
},
|
|
34
|
-
detached() {
|
|
35
|
-
if (this.slimSelect) this.slimSelect.destroy();
|
|
36
|
-
if (this.mutationObserver) this.mutationObserver.disconnect();
|
|
37
|
-
},
|
|
38
|
-
addCallback(value, listCallbacks) {
|
|
39
|
-
if (this.slimSelect) return;
|
|
40
|
-
let select = this.element.querySelector('select');
|
|
41
|
-
if (select) {
|
|
42
|
-
this.initSlimSelect(select);
|
|
43
|
-
} else {
|
|
44
|
-
// if no select available, wait for one and init slimSelect
|
|
45
|
-
new MutationObserver((_m, observer) => {
|
|
46
|
-
const select = this.element.querySelector('select');
|
|
47
|
-
if (select) {
|
|
48
|
-
this.initSlimSelect(select);
|
|
49
|
-
observer.disconnect(); // then disconnect mutationObserver
|
|
50
|
-
}
|
|
51
|
-
}).observe(this.element, {
|
|
52
|
-
childList: true,
|
|
53
|
-
characterData: true,
|
|
54
|
-
subtree: true
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
const nextProcessor = listCallbacks.shift();
|
|
58
|
-
if (nextProcessor) nextProcessor(value, listCallbacks);
|
|
59
|
-
},
|
|
60
|
-
initSlimSelect(select) {
|
|
61
|
-
const slimSelect = new SlimSelect({
|
|
62
|
-
select
|
|
63
|
-
});
|
|
64
|
-
this.slimSelect = slimSelect;
|
|
65
|
-
select.addEventListener('change', () => {
|
|
66
|
-
this.slimSelect.render();
|
|
67
|
-
this.element.dispatchEvent(new Event('input', {
|
|
68
|
-
bubbles: true
|
|
69
|
-
}));
|
|
70
|
-
});
|
|
71
|
-
this.element.addEventListener('input', e => {
|
|
72
|
-
if (e.target !== this.element) {
|
|
73
|
-
// avoid update search result when search in slimSelect suggestions
|
|
74
|
-
e.stopPropagation();
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
// when data changes, re-build slimSelect
|
|
79
|
-
if (this.mutationObserver) this.mutationObserver.disconnect();
|
|
80
|
-
this.mutationObserver = new MutationObserver(() => {
|
|
81
|
-
this.slimSelect.destroy();
|
|
82
|
-
this.slimSelect = new SlimSelect({
|
|
83
|
-
select,
|
|
84
|
-
placeholder: this.placeholder || this.t("autocompletion.placeholder"),
|
|
85
|
-
searchText: this.searchText || this.t("autocompletion.searchText"),
|
|
86
|
-
searchPlaceholder: this.searchPlaceholder || this.t("autocompletion.searchPlaceholder"),
|
|
87
|
-
searchFilter: (option, filterValue) => fuzzyCompare(option.text, filterValue)
|
|
88
|
-
});
|
|
89
|
-
}).observe(select, {
|
|
90
|
-
childList: true,
|
|
91
|
-
characterData: true,
|
|
92
|
-
subtree: true
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
export { AutocompletionMixin };
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { AutocompletionMixin } from './autocompletionMixin.js';
|
|
2
|
-
import { RichtextMixin } from './richtextMixin.js';
|
|
3
|
-
const callbackDirectory = {
|
|
4
|
-
autocompletion: AutocompletionMixin,
|
|
5
|
-
richtext: RichtextMixin
|
|
6
|
-
};
|
|
7
|
-
export { callbackDirectory, AutocompletionMixin, RichtextMixin };
|