@startinblox/core 0.19.0-beta.2 → 0.19.0-beta.21
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-411e08e4.js} +499 -454
- package/dist/assets/helpers-411e08e4.js.map +1 -0
- package/dist/{_snowpack/pkg/leaflet/dist/leaflet.css → assets/leaflet-3c081932.css} +3 -3
- package/dist/helpers.js +22 -0
- package/dist/helpers.js.map +1 -0
- package/dist/index.js +54873 -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 -313
- 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 -364
- 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 -125
- 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,72 +0,0 @@
|
|
|
1
|
-
import { Sib } from '../libs/Sib.js';
|
|
2
|
-
import { StoreMixin } from '../mixins/storeMixin.js';
|
|
3
|
-
import { BaseWidgetMixin } from '../new-widgets/baseWidgetMixin.js';
|
|
4
|
-
import { FormMixin } from '../new-widgets/templatesDependencies/formMixin.js';
|
|
5
|
-
import { ActionMixin } from '../new-widgets/attributeMixins/actionMixin.js';
|
|
6
|
-
import { evalTemplateString } from '../libs/helpers.js';
|
|
7
|
-
import { html, render } from '../_snowpack/pkg/lit-html.js';
|
|
8
|
-
import { unsafeHTML } from '../_snowpack/pkg/lit-html/directives/unsafe-html.js';
|
|
9
|
-
export const SolidWidget = {
|
|
10
|
-
name: 'solid-widget',
|
|
11
|
-
use: [],
|
|
12
|
-
attributes: {
|
|
13
|
-
name: {
|
|
14
|
-
type: String,
|
|
15
|
-
default: "",
|
|
16
|
-
required: true
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
attached() {
|
|
20
|
-
if (!this.name) return;
|
|
21
|
-
const template = this.template;
|
|
22
|
-
const newWidget = {
|
|
23
|
-
name: this.name,
|
|
24
|
-
use: [BaseWidgetMixin, StoreMixin, FormMixin, ActionMixin],
|
|
25
|
-
attributes: {
|
|
26
|
-
label: {
|
|
27
|
-
type: String,
|
|
28
|
-
default: '',
|
|
29
|
-
callback: function (newValue) {
|
|
30
|
-
this.addToAttributes(newValue, 'label');
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
get template() {
|
|
35
|
-
return () => this.evalTemplate(template).then(tpl => html`${unsafeHTML(tpl)}`);
|
|
36
|
-
},
|
|
37
|
-
evalTemplate(template) {
|
|
38
|
-
const tpl = evalTemplateString(template, {
|
|
39
|
-
name: this.name,
|
|
40
|
-
value: this.value || this.resource || '',
|
|
41
|
-
src: this.src,
|
|
42
|
-
label: this.label
|
|
43
|
-
});
|
|
44
|
-
return tpl;
|
|
45
|
-
},
|
|
46
|
-
async templateToDOM(template) {
|
|
47
|
-
render(await template, this.element);
|
|
48
|
-
},
|
|
49
|
-
// For form widgets, handle nested solid-form
|
|
50
|
-
getValueFromElement(element) {
|
|
51
|
-
if (element.tagName === "SOLID-FORM") return element.component.value; // nested solid-form
|
|
52
|
-
else if (element.component) return element.component.getValue(); // form widget
|
|
53
|
-
return element.value; // input
|
|
54
|
-
},
|
|
55
|
-
|
|
56
|
-
updateDOM() {
|
|
57
|
-
// override StoreMixin method to launch render when resource fetched
|
|
58
|
-
this.planRender();
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
Sib.register(newWidget); // and register component
|
|
62
|
-
},
|
|
63
|
-
|
|
64
|
-
get template() {
|
|
65
|
-
return this.element.querySelector('template:not([data-range])').innerHTML;
|
|
66
|
-
},
|
|
67
|
-
get childTemplate() {
|
|
68
|
-
const child = this.element.querySelector('template[data-range]');
|
|
69
|
-
return child ? child.innerHTML : null;
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
Sib.register(SolidWidget);
|
package/dist/import.css
DELETED
package/dist/libs/Component.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
3
|
-
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
4
|
-
export class Component {
|
|
5
|
-
constructor(element) {
|
|
6
|
-
_defineProperty(this, "element", void 0);
|
|
7
|
-
this.element = element;
|
|
8
|
-
}
|
|
9
|
-
created() {}
|
|
10
|
-
attached() {}
|
|
11
|
-
detached() {}
|
|
12
|
-
attributesCallback(_key, _value, _oldValue) {}
|
|
13
|
-
}
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
import { Compositor } from './Compositor.js';
|
|
2
|
-
import { Component } from './Component.js';
|
|
3
|
-
export class ComponentFactory {
|
|
4
|
-
static build(component) {
|
|
5
|
-
const {
|
|
6
|
-
initialState,
|
|
7
|
-
attributes,
|
|
8
|
-
methods,
|
|
9
|
-
hooks,
|
|
10
|
-
accessors,
|
|
11
|
-
name
|
|
12
|
-
} = Compositor.merge(component, Compositor.mergeMixin(component));
|
|
13
|
-
let componentConstructor = class extends Component {};
|
|
14
|
-
componentConstructor = ComponentFactory.bindInitialState(componentConstructor, initialState);
|
|
15
|
-
componentConstructor = ComponentFactory.bindAttributes(componentConstructor, attributes);
|
|
16
|
-
componentConstructor = ComponentFactory.bindMethods(componentConstructor, methods);
|
|
17
|
-
componentConstructor = ComponentFactory.bindAccessors(componentConstructor, accessors);
|
|
18
|
-
componentConstructor = ComponentFactory.bindHooks(componentConstructor, hooks);
|
|
19
|
-
Reflect.defineProperty(componentConstructor, 'name', {
|
|
20
|
-
value: name
|
|
21
|
-
});
|
|
22
|
-
return componentConstructor;
|
|
23
|
-
}
|
|
24
|
-
static bindInitialState(componentConstructor, initialState) {
|
|
25
|
-
if (initialState) {
|
|
26
|
-
Reflect.ownKeys(initialState).forEach(key => {
|
|
27
|
-
Reflect.defineProperty(componentConstructor.prototype, key, {
|
|
28
|
-
enumerable: true,
|
|
29
|
-
writable: true,
|
|
30
|
-
value: initialState[key]
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
return componentConstructor;
|
|
35
|
-
}
|
|
36
|
-
static bindAttributes(componentConstructor, attributes) {
|
|
37
|
-
if (attributes) {
|
|
38
|
-
const attributesList = Reflect.ownKeys(attributes).map(key => String(key));
|
|
39
|
-
const attributesCallback = {};
|
|
40
|
-
attributesList.forEach(key => {
|
|
41
|
-
const {
|
|
42
|
-
default: def,
|
|
43
|
-
type,
|
|
44
|
-
required,
|
|
45
|
-
callback
|
|
46
|
-
} = attributes[key];
|
|
47
|
-
let fromType;
|
|
48
|
-
let toType;
|
|
49
|
-
switch (type) {
|
|
50
|
-
case String:
|
|
51
|
-
fromType = value => String(value);
|
|
52
|
-
toType = value => value;
|
|
53
|
-
break;
|
|
54
|
-
case Object:
|
|
55
|
-
fromType = value => JSON.parse(value);
|
|
56
|
-
toType = value => JSON.stringify(value);
|
|
57
|
-
break;
|
|
58
|
-
case Number:
|
|
59
|
-
fromType = value => Number(value);
|
|
60
|
-
toType = value => Number(value).toString();
|
|
61
|
-
break;
|
|
62
|
-
case Boolean:
|
|
63
|
-
fromType = value => Boolean(value);
|
|
64
|
-
toType = value => value;
|
|
65
|
-
break;
|
|
66
|
-
default:
|
|
67
|
-
fromType = value => value;
|
|
68
|
-
toType = value => value;
|
|
69
|
-
break;
|
|
70
|
-
}
|
|
71
|
-
const attribute = key.replace(/([a-z0-9])([A-Z0-9])/g, '$1-$2').toLowerCase();
|
|
72
|
-
Reflect.defineProperty(componentConstructor.prototype, key, {
|
|
73
|
-
enumerable: true,
|
|
74
|
-
configurable: false,
|
|
75
|
-
get: function () {
|
|
76
|
-
const element = this.element;
|
|
77
|
-
if (!element.hasAttribute(attribute)) {
|
|
78
|
-
if (required && type !== Boolean) {
|
|
79
|
-
throw new Error(`Attribute ${key} is required`);
|
|
80
|
-
}
|
|
81
|
-
return def;
|
|
82
|
-
}
|
|
83
|
-
return fromType(element.getAttribute(attribute));
|
|
84
|
-
},
|
|
85
|
-
set: function (value) {
|
|
86
|
-
const element = this.element;
|
|
87
|
-
if (type === Boolean) {
|
|
88
|
-
if (!value) {
|
|
89
|
-
element.removeAttribute(attribute);
|
|
90
|
-
} else {
|
|
91
|
-
element.setAttribute(attribute, '');
|
|
92
|
-
}
|
|
93
|
-
} else {
|
|
94
|
-
element.setAttribute(attribute, toType(value));
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
if (callback && typeof callback === 'function') {
|
|
99
|
-
attributesCallback[key] = callback;
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
Reflect.defineProperty(componentConstructor, 'observedAttributes', {
|
|
103
|
-
get: () => attributesList.map(attr => attr.replace(/([a-z0-9])([A-Z0-9])/g, '$1-$2').toLowerCase())
|
|
104
|
-
});
|
|
105
|
-
Reflect.defineProperty(componentConstructor.prototype, 'attributesCallback', {
|
|
106
|
-
value: function (key, newValue, oldValue) {
|
|
107
|
-
if (key in attributesCallback) {
|
|
108
|
-
Reflect.apply(attributesCallback[key], this, [newValue, oldValue]);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
Reflect.defineProperty(componentConstructor.prototype, 'attributesCallback', attributesCallback);
|
|
113
|
-
}
|
|
114
|
-
return componentConstructor;
|
|
115
|
-
}
|
|
116
|
-
static bindAccessors(componentConstructor, accessors) {
|
|
117
|
-
if (accessors) {
|
|
118
|
-
Object.keys(accessors).forEach(property => {
|
|
119
|
-
Reflect.defineProperty(componentConstructor.prototype, property, {
|
|
120
|
-
get: function () {
|
|
121
|
-
return Reflect.apply(accessors[property].get, this, []);
|
|
122
|
-
},
|
|
123
|
-
set: function (value) {
|
|
124
|
-
return Reflect.apply(accessors[property].set, this, [value]);
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
return componentConstructor;
|
|
130
|
-
}
|
|
131
|
-
static bindMethods(componentConstructor, methods) {
|
|
132
|
-
methods.forEach((method, methodName) => {
|
|
133
|
-
Reflect.defineProperty(componentConstructor.prototype, methodName, {
|
|
134
|
-
value: function (...args) {
|
|
135
|
-
return Reflect.apply(method, this, args);
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
});
|
|
139
|
-
return componentConstructor;
|
|
140
|
-
}
|
|
141
|
-
static bindHooks(componentConstructor, hooks) {
|
|
142
|
-
Reflect.defineProperty(componentConstructor.prototype, 'created', {
|
|
143
|
-
value: function () {
|
|
144
|
-
hooks.created.forEach(hook => {
|
|
145
|
-
Reflect.apply(hook, this, []);
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
});
|
|
149
|
-
Reflect.defineProperty(componentConstructor.prototype, 'attached', {
|
|
150
|
-
value: function () {
|
|
151
|
-
hooks.attached.forEach(hook => {
|
|
152
|
-
Reflect.apply(hook, this, []);
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
});
|
|
156
|
-
Reflect.defineProperty(componentConstructor.prototype, 'detached', {
|
|
157
|
-
value: function () {
|
|
158
|
-
hooks.detached.forEach(hook => {
|
|
159
|
-
Reflect.apply(hook, this, []);
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
});
|
|
163
|
-
return componentConstructor;
|
|
164
|
-
}
|
|
165
|
-
}
|
package/dist/libs/Compositor.js
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
const HOOKS = ['created', 'attached', 'detached'];
|
|
2
|
-
const API = ['name', 'use', 'attributes', 'initialState', ...HOOKS];
|
|
3
|
-
export class Compositor {
|
|
4
|
-
static merge(component, mixins) {
|
|
5
|
-
return {
|
|
6
|
-
name: component.name,
|
|
7
|
-
attributes: Compositor.mergeAttributes([component, ...mixins]),
|
|
8
|
-
initialState: Compositor.mergeInitialState([component, ...mixins]),
|
|
9
|
-
methods: Compositor.mergeMethods([component, ...mixins]),
|
|
10
|
-
accessors: Compositor.mergeAccessors([component, ...mixins]),
|
|
11
|
-
hooks: Compositor.mergeHooks([component, ...mixins])
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
static mergeMixin(component) {
|
|
15
|
-
function deepMergeMixin(mixinAccumulator, currentMixin) {
|
|
16
|
-
const {
|
|
17
|
-
use: currentMixins
|
|
18
|
-
} = currentMixin;
|
|
19
|
-
if (currentMixins) {
|
|
20
|
-
currentMixins.forEach(mix => {
|
|
21
|
-
if (!mixinAccumulator.has(mix)) {
|
|
22
|
-
mixinAccumulator.set(mix, mix);
|
|
23
|
-
deepMergeMixin(mixinAccumulator, mix);
|
|
24
|
-
} else {
|
|
25
|
-
console.warn(`Duplicate mixin import (${mix.name})`);
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
const mixins = new Map();
|
|
31
|
-
deepMergeMixin(mixins, component);
|
|
32
|
-
return Array.from(mixins.values());
|
|
33
|
-
}
|
|
34
|
-
static mergeAttributes(mixins) {
|
|
35
|
-
let attributes = {};
|
|
36
|
-
mixins.forEach(mixin => {
|
|
37
|
-
if (!!mixin.attributes) {
|
|
38
|
-
attributes = {
|
|
39
|
-
...mixin.attributes,
|
|
40
|
-
...attributes
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
return attributes;
|
|
45
|
-
}
|
|
46
|
-
static mergeInitialState(mixins) {
|
|
47
|
-
let initialState = {};
|
|
48
|
-
mixins.forEach(mixin => {
|
|
49
|
-
if (!!mixin.initialState) {
|
|
50
|
-
initialState = {
|
|
51
|
-
...mixin.initialState,
|
|
52
|
-
...initialState
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
return initialState;
|
|
57
|
-
}
|
|
58
|
-
static mergeHooks(mixins) {
|
|
59
|
-
const hooks = {
|
|
60
|
-
created: [],
|
|
61
|
-
attached: [],
|
|
62
|
-
detached: []
|
|
63
|
-
};
|
|
64
|
-
mixins.reverse().forEach(mixin => {
|
|
65
|
-
HOOKS.forEach(hookName => {
|
|
66
|
-
if (!!mixin[hookName] && typeof mixin[hookName] === 'function') {
|
|
67
|
-
hooks[hookName].push(mixin[hookName]);
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
return hooks;
|
|
72
|
-
}
|
|
73
|
-
static mergeMethods(mixins) {
|
|
74
|
-
const methods = new Map();
|
|
75
|
-
mixins.reverse().forEach(mixin => {
|
|
76
|
-
const keys = Reflect.ownKeys(mixin).filter(key => typeof key === 'string' && API.indexOf(key) < 0 && !Object.getOwnPropertyDescriptor(mixin, key).get && !Object.getOwnPropertyDescriptor(mixin, key).set && typeof mixin[key] === 'function');
|
|
77
|
-
keys.forEach(key => {
|
|
78
|
-
methods.set(key, mixin[key]);
|
|
79
|
-
});
|
|
80
|
-
});
|
|
81
|
-
return methods;
|
|
82
|
-
}
|
|
83
|
-
static mergeAccessors(mixins) {
|
|
84
|
-
const accessors = {};
|
|
85
|
-
mixins.reverse().forEach(mixin => {
|
|
86
|
-
Reflect.ownKeys(mixin).filter(key => typeof key === 'string' && API.indexOf(key) < 0 && (Object.getOwnPropertyDescriptor(mixin, key).get || Object.getOwnPropertyDescriptor(mixin, key).set)).forEach(prop => {
|
|
87
|
-
accessors[prop] = {
|
|
88
|
-
...accessors[prop]
|
|
89
|
-
};
|
|
90
|
-
if (Reflect.getOwnPropertyDescriptor(mixin, prop).get) accessors[prop].get = Reflect.getOwnPropertyDescriptor(mixin, prop).get;
|
|
91
|
-
if (Reflect.getOwnPropertyDescriptor(mixin, prop).set) accessors[prop].set = Reflect.getOwnPropertyDescriptor(mixin, prop).set;
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
return accessors;
|
|
95
|
-
}
|
|
96
|
-
}
|
package/dist/libs/Sib.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
3
|
-
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
4
|
-
import { ComponentFactory } from "./ComponentFactory.js";
|
|
5
|
-
import { defineComponent } from "./helpers.js";
|
|
6
|
-
export class Sib {
|
|
7
|
-
static register(componentDefinition) {
|
|
8
|
-
const component = ComponentFactory.build(componentDefinition);
|
|
9
|
-
const cls = this.toElement(component);
|
|
10
|
-
defineComponent(component.name, cls);
|
|
11
|
-
}
|
|
12
|
-
static toElement(component) {
|
|
13
|
-
return class extends HTMLElement {
|
|
14
|
-
constructor() {
|
|
15
|
-
super();
|
|
16
|
-
_defineProperty(this, "_component", null);
|
|
17
|
-
this.component = new component(this);
|
|
18
|
-
this.component.created();
|
|
19
|
-
}
|
|
20
|
-
get component() {
|
|
21
|
-
if (this._component === null) {
|
|
22
|
-
throw new Error('No component found');
|
|
23
|
-
}
|
|
24
|
-
return this._component;
|
|
25
|
-
}
|
|
26
|
-
set component(component) {
|
|
27
|
-
this._component = component;
|
|
28
|
-
}
|
|
29
|
-
static get observedAttributes() {
|
|
30
|
-
return component.observedAttributes;
|
|
31
|
-
}
|
|
32
|
-
attributeChangedCallback(name, oldValue, newValue) {
|
|
33
|
-
const attr = name.replace(/([a-z0-9])-([a-z0-9])/g, (_c, p1, p2) => `${p1}${p2.toUpperCase()}`);
|
|
34
|
-
this.component.attributesCallback(attr, newValue, oldValue);
|
|
35
|
-
}
|
|
36
|
-
connectedCallback() {
|
|
37
|
-
this.component.attached();
|
|
38
|
-
}
|
|
39
|
-
disconnectedCallback() {
|
|
40
|
-
this.component.detached();
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
}
|
package/dist/libs/filter.js
DELETED
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
import { parseFieldsString, findClosingBracketMatchIndex, compare, uniqID } from "./helpers.js";
|
|
2
|
-
/**
|
|
3
|
-
* Check if the field is a set
|
|
4
|
-
* @param field - field to test
|
|
5
|
-
* @param fields - list of fields
|
|
6
|
-
* @returns true if the field is a set, false otherwise
|
|
7
|
-
*/
|
|
8
|
-
const isSet = (field, fields) => {
|
|
9
|
-
if (!fields) return false;
|
|
10
|
-
let foundSets = fields.match(getSetRegexp(field));
|
|
11
|
-
return foundSets ? foundSets.length > 0 : false;
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* Get the list of fields in the set
|
|
15
|
-
* @param field - set name to get
|
|
16
|
-
* @param fields - list of fields
|
|
17
|
-
* @returns a list of fields in the set
|
|
18
|
-
*/
|
|
19
|
-
const getSet = (field, fields) => {
|
|
20
|
-
const setString = fields.match(getSetRegexp(field));
|
|
21
|
-
if (!setString) return [];
|
|
22
|
-
const firstSetBracket = fields.indexOf(setString[0]) + setString[0].length - 1;
|
|
23
|
-
const lastSetBracket = findClosingBracketMatchIndex(fields, firstSetBracket);
|
|
24
|
-
const set = fields.substring(firstSetBracket + 1, lastSetBracket);
|
|
25
|
-
return parseFieldsString(set);
|
|
26
|
-
};
|
|
27
|
-
const getSetRegexp = field => {
|
|
28
|
-
return new RegExp(`(^|\\,|\\(|\\s)\\s*${field}\\s*\\(`, 'g');
|
|
29
|
-
};
|
|
30
|
-
/**
|
|
31
|
-
* Check if the field is a special search field
|
|
32
|
-
* @param field - field to test
|
|
33
|
-
* @param searchForm - current search form
|
|
34
|
-
* @returns true if the field is a special search field
|
|
35
|
-
*/
|
|
36
|
-
const isSearchField = (field, searchForm) => {
|
|
37
|
-
return searchForm.hasAttribute('search-' + field);
|
|
38
|
-
};
|
|
39
|
-
/**
|
|
40
|
-
* Get the fields targetted by a search field
|
|
41
|
-
* @param field - search field to get
|
|
42
|
-
* @param searchForm - current search form
|
|
43
|
-
* @returns a list of fields targetted by the current search field
|
|
44
|
-
*/
|
|
45
|
-
const getSearchField = (field, searchForm) => {
|
|
46
|
-
return parseFieldsString(searchForm.getAttribute('search-' + field));
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Throw or simply return value
|
|
51
|
-
* @param throwOn - should throw on True or False
|
|
52
|
-
* @param ret - value to return
|
|
53
|
-
* @returns
|
|
54
|
-
*/
|
|
55
|
-
const orThrow = (throwOn, ret) => {
|
|
56
|
-
if (throwOn === true && ret) throw true;
|
|
57
|
-
if (throwOn === false && !ret) throw false;
|
|
58
|
-
return ret;
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Compare a value to the query
|
|
63
|
-
* @param val - value to compare
|
|
64
|
-
* @param query - object to know how and what value to compare
|
|
65
|
-
* @param throwOn - should function throw error on True or False
|
|
66
|
-
* @returns true if value matches, throw error otherwise
|
|
67
|
-
*/
|
|
68
|
-
const matchValue = async (val, query, throwOn) => {
|
|
69
|
-
const subject = await val;
|
|
70
|
-
if (subject == null && query.value === '') return orThrow(throwOn, true); // filter not set and subject not existing -> ignore filter
|
|
71
|
-
if (subject == null) return orThrow(throwOn, false); // return false; // property does not exist on resource
|
|
72
|
-
if (query.list) {
|
|
73
|
-
// Filter on a container
|
|
74
|
-
if (query.value.length === 0) return orThrow(throwOn, true);
|
|
75
|
-
for (const v of query.value) {
|
|
76
|
-
if (await matchValue(subject, {
|
|
77
|
-
type: query.type,
|
|
78
|
-
value: v,
|
|
79
|
-
list: false
|
|
80
|
-
})) {
|
|
81
|
-
// do not throw here, we need the result
|
|
82
|
-
return orThrow(throwOn, true);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
return orThrow(throwOn, false);
|
|
86
|
-
}
|
|
87
|
-
if (subject.isContainer?.()) {
|
|
88
|
-
let ret = Promise.resolve(query.value === ''); // if no query, return a match
|
|
89
|
-
for (const value of subject['ldp:contains']) {
|
|
90
|
-
ret = (await ret) || (await matchValue(value, query)); // do not throw here, we need the result
|
|
91
|
-
if (ret) return orThrow(throwOn, true);
|
|
92
|
-
}
|
|
93
|
-
return orThrow(throwOn, await ret);
|
|
94
|
-
}
|
|
95
|
-
return orThrow(throwOn, compare[query.type](subject, query.value));
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Cache properties of a filter to avoid repeated parsing
|
|
100
|
-
* @param cacheKey - uniq key
|
|
101
|
-
* @param filter - filter to check
|
|
102
|
-
* @param fields - fields attribute of the element
|
|
103
|
-
* @param searchForm - current search form
|
|
104
|
-
*/
|
|
105
|
-
const cacheFieldsProps = (cacheKey, filter, fields, searchForm) => {
|
|
106
|
-
if (!window.cachePropsSearchFilter[cacheKey]) {
|
|
107
|
-
window.cachePropsSearchFilter[cacheKey] = {
|
|
108
|
-
setFields: isSet(filter, fields) ? getSet(filter, fields) : null,
|
|
109
|
-
setSearchFields: isSearchField(filter, searchForm) ? getSearchField(filter, searchForm) : null
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Check if one resource match one filter
|
|
116
|
-
* @param resource - resource to test
|
|
117
|
-
* @param filter - name of the property tested
|
|
118
|
-
* @param query - query object to know how to compare values
|
|
119
|
-
* @param fieldsAttr - fields attribute of the element
|
|
120
|
-
* @param searchForm - searchForm component
|
|
121
|
-
* @param filterId - uniqId used to fill the cache
|
|
122
|
-
* @param throwOn - should function throw error on True or False
|
|
123
|
-
* @returns return true if the resource matches the filter, throw error otherwise
|
|
124
|
-
*/
|
|
125
|
-
const matchFilter = async (resource, filter, query, fieldsAttr, searchForm, filterId, throwOn) => {
|
|
126
|
-
let fields = null;
|
|
127
|
-
const cacheKey = `${filter}_${filterId}`;
|
|
128
|
-
cacheFieldsProps(cacheKey, filter, fieldsAttr, searchForm);
|
|
129
|
-
if (window.cachePropsSearchFilter[cacheKey].setFields !== null) {
|
|
130
|
-
fields = window.cachePropsSearchFilter[cacheKey].setFields;
|
|
131
|
-
} else if (window.cachePropsSearchFilter[cacheKey].setSearchFields !== null) {
|
|
132
|
-
fields = window.cachePropsSearchFilter[cacheKey].setSearchFields;
|
|
133
|
-
} else {
|
|
134
|
-
// search on 1 field
|
|
135
|
-
return matchValue(resource[filter], query, throwOn);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
// search on multiple fields
|
|
139
|
-
try {
|
|
140
|
-
await Promise.all((fields || []).map(field => matchFilter(resource, field, query, fieldsAttr, searchForm, filterId, true // stop searching when 1 filter is true (= OR)
|
|
141
|
-
)));
|
|
142
|
-
} catch (e) {
|
|
143
|
-
return true;
|
|
144
|
-
}
|
|
145
|
-
throw false;
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* Check if one resource match all the filters
|
|
150
|
-
* @param resource - resource to test
|
|
151
|
-
* @param filters - current filters
|
|
152
|
-
* @param filterNames - names of the filters
|
|
153
|
-
* @param fields - fields attribute of the element
|
|
154
|
-
* @param searchForm - searchForm component
|
|
155
|
-
* @param filterId - uniqId used to fill the cache
|
|
156
|
-
* @returns true if resource match, false otherwise
|
|
157
|
-
*/
|
|
158
|
-
const matchFilters = async (resource, filters, filterNames, fields, searchForm, filterId) => {
|
|
159
|
-
// return true if all filters values are contained in the corresponding field of the resource
|
|
160
|
-
try {
|
|
161
|
-
await Promise.all(filterNames.map(filter => matchFilter(resource, filter, filters[filter], fields, searchForm, filterId, false // stop searching when 1 filter is false (= AND)
|
|
162
|
-
)));
|
|
163
|
-
} catch (e) {
|
|
164
|
-
return false;
|
|
165
|
-
}
|
|
166
|
-
return true;
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* Check which resources match the filters
|
|
171
|
-
* @param resources - list of resources to filter
|
|
172
|
-
* @param filters - current filters
|
|
173
|
-
* @param fields - fields attribute of the element
|
|
174
|
-
* @param searchForm - searchForm component
|
|
175
|
-
* @returns resources filtered
|
|
176
|
-
*/
|
|
177
|
-
const searchInResources = async (resources, filters, fields, searchForm) => {
|
|
178
|
-
// Optim: use cache to do these things only once
|
|
179
|
-
const filterNames = Object.keys(filters);
|
|
180
|
-
const filterId = uniqID();
|
|
181
|
-
window.cachePropsSearchFilter = {};
|
|
182
|
-
return Promise.all(resources.map(resource => matchFilters(resource, filters, filterNames, fields, searchForm, filterId)));
|
|
183
|
-
};
|
|
184
|
-
export { searchInResources };
|