@startinblox/core 0.18.0-beta.4 → 0.18.1

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 (43) hide show
  1. package/dist/_snowpack/pkg/common/{_baseUnary-d2677655.js → _baseUnary-c1edb653.js} +2 -2
  2. package/dist/_snowpack/pkg/common/{_baseUnary-d2677655.js.map → _baseUnary-c1edb653.js.map} +1 -1
  3. package/dist/_snowpack/pkg/common/{_commonjsHelpers-0597c316.js → _commonjsHelpers-37fa8da4.js} +2 -2
  4. package/dist/_snowpack/pkg/common/_commonjsHelpers-37fa8da4.js.map +1 -0
  5. package/dist/_snowpack/pkg/delta-markdown-for-quill.js +2 -2
  6. package/dist/_snowpack/pkg/dialog-polyfill.js +2 -1
  7. package/dist/_snowpack/pkg/dialog-polyfill.js.map +1 -1
  8. package/dist/_snowpack/pkg/import-map.json +0 -1
  9. package/dist/_snowpack/pkg/jsonld-context-parser.js +1 -1
  10. package/dist/_snowpack/pkg/markdown-it.js +1 -1
  11. package/dist/_snowpack/pkg/quill-delta-to-markdown.js +2 -2
  12. package/dist/_snowpack/pkg/quill.js +11644 -11643
  13. package/dist/_snowpack/pkg/quill.js.map +1 -1
  14. package/dist/_snowpack/pkg/tui-calendar.js +43199 -43195
  15. package/dist/_snowpack/pkg/tui-calendar.js.map +1 -1
  16. package/dist/components/solid-form-search.js +2 -1
  17. package/dist/components/solid-form.js +4 -2
  18. package/dist/libs/ComponentFactory.js +4 -1
  19. package/dist/libs/filter.js +1 -1
  20. package/dist/libs/helpers.js +10 -4
  21. package/dist/libs/lit-helpers.js +4 -1
  22. package/dist/libs/polyfills.js +4 -2
  23. package/dist/libs/store/server-pagination.js +7 -4
  24. package/dist/libs/store/server-search.js +7 -4
  25. package/dist/libs/store/store.js +346 -92
  26. package/dist/mixins/attributeBinderMixin.js +6 -3
  27. package/dist/mixins/federationMixin.js +0 -6
  28. package/dist/mixins/filterMixin.js +16 -13
  29. package/dist/mixins/listMixin.js +9 -20
  30. package/dist/mixins/requiredMixin.js +3 -15
  31. package/dist/mixins/storeMixin.js +0 -30
  32. package/dist/mixins/widgetMixin.js +5 -12
  33. package/dist/new-widgets/templates/formTemplatesDirectory.js +15 -6
  34. package/dist/new-widgets/templatesDependencies/formDropdownMixin.js +0 -3
  35. package/dist/new-widgets/templatesDependencies/multipleFormMixin.js +3 -7
  36. package/dist/new-widgets/templatesDependencies/multipleselectFormMixin.js +2 -11
  37. package/dist/widgets/baseWidget.js +5 -4
  38. package/dist/widgets/widget-factory.js +3 -1
  39. package/package.json +4 -5
  40. package/dist/_snowpack/pkg/common/_commonjsHelpers-0597c316.js.map +0 -1
  41. package/dist/_snowpack/pkg/jsonld.js +0 -11760
  42. package/dist/_snowpack/pkg/jsonld.js.map +0 -1
  43. package/dist/libs/store/custom-getter.js +0 -344
@@ -1,4 +1,3 @@
1
- import { store } from '../libs/store/store.js';
2
1
  const RequiredMixin = {
3
2
  name: 'required-mixin',
4
3
  use: [],
@@ -12,20 +11,9 @@ const RequiredMixin = {
12
11
  for (let resource of resources) {
13
12
  let hasProps = true;
14
13
  for (let field of requiredFields) {
15
- // Retrieve resource from store
16
- let res = store.get(resource['@id']);
17
- if (!res && !resource[field] && !(await resource[field])) {
18
- //TODO: refactor to better handle this edge case where res is either the direct resource or a proxy
19
- res = await store.getData(resource['@id'], this.context);
20
- if (!res || res[field] == null || res[field] == "") {
21
- hasProps = false;
22
- continue;
23
- }
24
- } else if (res) {
25
- if ((await res[field]) == null || (await res[field]) == "") {
26
- hasProps = false;
27
- continue;
28
- }
14
+ if ((await resource[field]) == null || (await resource[field]) == "") {
15
+ hasProps = false;
16
+ continue;
29
17
  }
30
18
  }
31
19
  if (hasProps) displays.push(resource);
@@ -35,17 +35,6 @@ const StoreMixin = {
35
35
  nestedField: {
36
36
  type: String,
37
37
  default: null
38
- },
39
- arrayField: {
40
- type: String,
41
- default: null,
42
- callback: function (value) {
43
- if (value) this.predicateName = store.getExpandedPredicate(this.arrayField, this.context);
44
- }
45
- },
46
- predicateName: {
47
- type: String,
48
- default: null
49
38
  }
50
39
  },
51
40
  initialState: {
@@ -78,26 +67,7 @@ const StoreMixin = {
78
67
  if (!value || value == "undefined") return;
79
68
  this.resourceId = value;
80
69
  if (this.nestedField) {
81
- // First step: store.getData
82
70
  const resource = await store.getData(value, this.context);
83
-
84
- // Which internally triggers store.fetchData -> Fine
85
-
86
- // Which triggers store.fetchAuthn -> Fine
87
-
88
- // Once done it calls store.cacheGraph
89
-
90
- // And the issue seems to reside in the caching ?
91
-
92
- // How is computed the key to cache the nested resource with proper id like
93
- // http:///localhost:3000/examples/data/list/group-3.jsonld#foaf:member ?
94
- // Should it be:
95
- // - http:///localhost:3000/examples/data/list/group-3.jsonld#foaf:member
96
- // - _:b1/examples/data/list/group-3.jsonld#foaf:member
97
- // - _:b9/examples/data/list/group-3.jsonld
98
- // - examples/data/list/group-3.jsonld#foaf:member
99
-
100
- // So the work is in cacheGraph ?
101
71
  const nestedResource = resource ? await resource[this.nestedField] : null;
102
72
  this.resourceId = nestedResource ? nestedResource['@id'] : null;
103
73
  if (!this.resourceId) throw `Error: the key "${this.nestedField}" does not exist on the resource`;
@@ -53,12 +53,6 @@ const WidgetMixin = {
53
53
  resource = res;
54
54
  break;
55
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
56
  }
63
57
  if (!this.dataSrc) console.error(new Error('You must provide a "fields" attribute'));
64
58
  if (!resource) return [];
@@ -120,10 +114,6 @@ const WidgetMixin = {
120
114
  * @param resource - Resource
121
115
  */
122
116
  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
117
  return resource && !resource.isContainer?.() ? await resource[field] : undefined;
128
118
  },
129
119
  /**
@@ -170,7 +160,8 @@ const WidgetMixin = {
170
160
  * @param field - string
171
161
  * @param isSet - boolean
172
162
  */
173
- getWidget(field, isSet = false) {
163
+ getWidget(field) {
164
+ let isSet = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
174
165
  const widget = this.element.getAttribute('widget-' + field);
175
166
  if (widget) return this.widgetFromTagName(widget);
176
167
  if (this.getAction(field)) return this.widgetFromTagName('solid-action');
@@ -232,7 +223,9 @@ const WidgetMixin = {
232
223
  * Creates and return a widget for field + add it to the widget list
233
224
  * @param field - string
234
225
  */
235
- async createWidgetTemplate(field, resource = null, transformAttributes = false) {
226
+ async createWidgetTemplate(field) {
227
+ let resource = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
228
+ let transformAttributes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
236
229
  if (this.isString(field)) return this.createString(field); // field is a static string
237
230
  if (this.isSet(field)) return await this.createSet(field);
238
231
  const currentResource = resource || this.resource;
@@ -176,14 +176,17 @@ export const formTemplates = {
176
176
  ${el.label}
177
177
  </option>
178
178
  `)}
179
- ${Object.entries(attributes.enum || []).map(([key, val]) => html`
179
+ ${Object.entries(attributes.enum || []).map(_ref => {
180
+ let [key, val] = _ref;
181
+ return html`
180
182
  <option
181
183
  value="${key}"
182
184
  ?selected=${!attributes.multiple ? value === key : attributes.values.includes(key)}
183
185
  >
184
186
  ${val}
185
187
  </option>
186
- `)}
188
+ `;
189
+ })}
187
190
  </select>
188
191
  `,
189
192
  dependencies: [FormDropdownMixin, FormMixin, RangeMixin]
@@ -204,7 +207,9 @@ export const formTemplates = {
204
207
  > <span>${el.label}</span>
205
208
  </label>
206
209
  `)}
207
- ${Object.entries(attributes.enum || []).map(([key, val]) => html`
210
+ ${Object.entries(attributes.enum || []).map(_ref2 => {
211
+ let [key, val] = _ref2;
212
+ return html`
208
213
  <label>
209
214
  <input
210
215
  type="radio"
@@ -214,7 +219,8 @@ export const formTemplates = {
214
219
  ?checked=${value === key}
215
220
  > <span>${val}</span>
216
221
  </label>
217
- `)}
222
+ `;
223
+ })}
218
224
  `,
219
225
  dependencies: [FormRadioMixin, FormMixin, RangeMixin]
220
226
  },
@@ -232,13 +238,16 @@ export const formTemplates = {
232
238
  /> <span>${el.label}</span>
233
239
  </label>
234
240
  `)}
235
- ${Object.entries(attributes.enum || []).map(([key, val]) => html`
241
+ ${Object.entries(attributes.enum || []).map(_ref3 => {
242
+ let [key, val] = _ref3;
243
+ return html`
236
244
  <label>
237
245
  <input type="checkbox"
238
246
  value="${key}"
239
247
  /> <span>${val}</span>
240
248
  </label>
241
- `)}
249
+ `;
250
+ })}
242
251
  </select>
243
252
  `,
244
253
  dependencies: [FormCheckboxesMixin, FormMixin, RangeMixin]
@@ -28,9 +28,6 @@ const FormDropdownMixin = {
28
28
  },
29
29
  created() {
30
30
  this.listAttributes['values'] = [];
31
- if (this.listAttributes['value'] && !JSON.parse(this.listAttributes['value']['@id']) && Array.isArray(JSON.parse(this.listAttributes['value']))) {
32
- this.listAttributes['values'] = this.listAttributes['value'];
33
- }
34
31
  if (this.multiple) this.listAttributes['multiple'] = true;
35
32
  },
36
33
  dispatchChange() {
@@ -79,7 +79,8 @@ const MultipleFormMixin = {
79
79
 
80
80
  this.planRender();
81
81
  },
82
- insertWidget(value = '') {
82
+ insertWidget() {
83
+ let value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
83
84
  if (!this.widget) return;
84
85
  const widget = document.createElement(this.widget);
85
86
  const attributes = {
@@ -99,12 +100,7 @@ const MultipleFormMixin = {
99
100
  },
100
101
  getValue() {
101
102
  if (!this.dataHolder) return [];
102
- // Was returning an array of functions, now returns an array of values.
103
- // Not sure about the tests results in that context
104
- return Array.from(this.dataHolder).map(element => {
105
- let elValue = this.getValueFromElement(element);
106
- return elValue;
107
- });
103
+ return Array.from(this.dataHolder).map(element => this.getValueFromElement(element));
108
104
  },
109
105
  get type() {
110
106
  return 'resource';
@@ -38,21 +38,12 @@ const MultipleselectFormMixin = {
38
38
  this.listValueTransformations.push(this.setDataSrc.bind(this));
39
39
  },
40
40
  setDataSrc(value, listValueTransformations) {
41
- if (value && value !== this.dataSrc) {
42
- try {
43
- if (Array.isArray(JSON.parse(value))) {
44
- this.setValue(JSON.parse(value));
45
- }
46
- } catch (ex) {
47
- this.dataSrc = value;
48
- console.log('Not an array', ex);
49
- }
50
- }
41
+ if (value && value !== this.dataSrc) this.dataSrc = value;
51
42
  const nextProcessor = listValueTransformations.shift();
52
43
  if (nextProcessor) nextProcessor(value, listValueTransformations);
53
44
  },
54
45
  populate() {
55
- if (!this.resource || !this.resource['ldp:contains'] && !Array.isArray(this.resource)) return;
46
+ if (!this.resource || !this.resource['ldp:contains']) return;
56
47
  this.setValue(this.resource['ldp:contains']);
57
48
  this.planRender();
58
49
  },
@@ -4,8 +4,8 @@ function _toPrimitive(input, hint) { if (typeof input !== "object" || input ===
4
4
  import { evalTemplateString } from '../libs/helpers.js';
5
5
  import { store } from '../libs/store/store.js';
6
6
  export class BaseWidget extends HTMLElement {
7
- constructor(...args) {
8
- super(...args);
7
+ constructor() {
8
+ super(...arguments);
9
9
  _defineProperty(this, "src", void 0);
10
10
  _defineProperty(this, "multiple", void 0);
11
11
  _defineProperty(this, "editable", void 0);
@@ -155,7 +155,7 @@ export class BaseWidget extends HTMLElement {
155
155
  if (!res) {
156
156
  // child not in cache yet
157
157
  try {
158
- const resourceId = resource.getChildren('ldp:contains')[index]['@id'];
158
+ const resourceId = resource.getChildren()[index]['@id'];
159
159
  res = await store.getData(resourceId, this.context);
160
160
  } catch (e) {
161
161
  continue;
@@ -210,7 +210,8 @@ export class BaseWidget extends HTMLElement {
210
210
  subscribe(event) {
211
211
  this._listen(event);
212
212
  }
213
- _listen(id, callback = () => {}) {
213
+ _listen(id) {
214
+ let callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : () => {};
214
215
  if (!this._subscriptions.get(id)) {
215
216
  this._subscriptions.set(id, PubSub.subscribe(id, async () => {
216
217
  await callback();
@@ -1,6 +1,8 @@
1
1
  import { BaseWidget } from './baseWidget.js';
2
2
  import { defineComponent } from '../libs/helpers.js';
3
- export const widgetFactory = (tagName, customTemplate, childTemplate = '', callback) => {
3
+ export const widgetFactory = function (tagName, customTemplate) {
4
+ let childTemplate = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
5
+ let callback = arguments.length > 3 ? arguments[3] : undefined;
4
6
  const registered = customElements.get(tagName);
5
7
  if (registered) return registered;
6
8
  const cls = class extends BaseWidget {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@startinblox/core",
3
- "version": "0.18.0-beta.4",
3
+ "version": "0.18.1",
4
4
  "description": "This is a series of web component respecting both the web components standards and the Linked Data Platform convention.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -13,7 +13,7 @@
13
13
  ],
14
14
  "scripts": {
15
15
  "build": "snowpack build --polyfill-node",
16
- "watch": "snowpack build --polyfill-node --watch",
16
+ "watch": "npm run build -- --watch",
17
17
  "serve": "node --watch server.js",
18
18
  "dev": "concurrently -n 'WATCH,SERVE' -c 'yellow.bold,magenta.bold' 'npm run watch' 'npm run serve'",
19
19
  "check-types": "tsc",
@@ -93,8 +93,6 @@
93
93
  "express": "^4.17.1",
94
94
  "find-free-port": "^2.0.0",
95
95
  "fuse.js": "^6.4.6",
96
- "semver": "7.5.4",
97
- "jsonld": "^8.3.1",
98
96
  "jsonld-context-parser": "^1.3.4",
99
97
  "leaflet": "1.7.1",
100
98
  "leaflet.markercluster": "1.5.3",
@@ -110,7 +108,8 @@
110
108
  "ts-node": "^9.1.1",
111
109
  "tui-calendar": "^1.13.0",
112
110
  "typescript": "^4.1.3",
113
- "wait-on": "^5.2.1"
111
+ "wait-on": "^5.2.1",
112
+ "semver": "^7.4.0"
114
113
  },
115
114
  "dependencies": {
116
115
  "cors": "^2.8.5"
@@ -1 +0,0 @@
1
- {"version":3,"file":"_commonjsHelpers-0597c316.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;"}