@startinblox/core 0.17.31 → 0.18.0-beta.2

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 (255) hide show
  1. package/dist/_snowpack/pkg/autolinker.js +3515 -3367
  2. package/dist/_snowpack/pkg/autolinker.js.map +1 -1
  3. package/dist/_snowpack/pkg/common/{_baseUnary-217dffb2.js → _baseUnary-c1edb653.js} +16 -40
  4. package/dist/_snowpack/pkg/common/{_baseUnary-217dffb2.js.map → _baseUnary-c1edb653.js.map} +1 -1
  5. package/dist/_snowpack/pkg/common/{_commonjsHelpers-8c19dec8.js → _commonjsHelpers-37fa8da4.js} +6 -2
  6. package/dist/_snowpack/pkg/common/_commonjsHelpers-37fa8da4.js.map +1 -0
  7. package/dist/_snowpack/pkg/common/{decode-a4c334cf.js → decode-26fbf385.js} +38 -69
  8. package/dist/_snowpack/pkg/common/decode-26fbf385.js.map +1 -0
  9. package/dist/_snowpack/pkg/common/lit-html-3647afce.js +1104 -0
  10. package/dist/_snowpack/pkg/common/lit-html-3647afce.js.map +1 -0
  11. package/dist/_snowpack/pkg/delta-markdown-for-quill.js +4767 -4246
  12. package/dist/_snowpack/pkg/delta-markdown-for-quill.js.map +1 -1
  13. package/dist/_snowpack/pkg/dialog-polyfill.js +107 -139
  14. package/dist/_snowpack/pkg/dialog-polyfill.js.map +1 -1
  15. package/dist/_snowpack/pkg/fusejs.js +411 -601
  16. package/dist/_snowpack/pkg/fusejs.js.map +1 -1
  17. package/dist/_snowpack/pkg/jsonld-context-parser.js +718 -686
  18. package/dist/_snowpack/pkg/jsonld-context-parser.js.map +1 -1
  19. package/dist/_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.Default.css +59 -59
  20. package/dist/_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.Default.css.proxy.js +1 -1
  21. package/dist/_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.css +14 -14
  22. package/dist/_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.css.proxy.js +1 -1
  23. package/dist/_snowpack/pkg/lit-html/directives/if-defined.js +13 -14
  24. package/dist/_snowpack/pkg/lit-html/directives/if-defined.js.map +1 -1
  25. package/dist/_snowpack/pkg/lit-html/directives/unsafe-html.js +17 -15
  26. package/dist/_snowpack/pkg/lit-html/directives/unsafe-html.js.map +1 -1
  27. package/dist/_snowpack/pkg/lit-html/directives/until.js +45 -46
  28. package/dist/_snowpack/pkg/lit-html/directives/until.js.map +1 -1
  29. package/dist/_snowpack/pkg/lit-html.js +37 -35
  30. package/dist/_snowpack/pkg/lit-html.js.map +1 -1
  31. package/dist/_snowpack/pkg/markdown-it-link-attributes.js +1 -20
  32. package/dist/_snowpack/pkg/markdown-it-link-attributes.js.map +1 -1
  33. package/dist/_snowpack/pkg/markdown-it.js +1731 -2284
  34. package/dist/_snowpack/pkg/markdown-it.js.map +1 -1
  35. package/dist/_snowpack/pkg/quill-delta-to-markdown.js +236 -294
  36. package/dist/_snowpack/pkg/quill-delta-to-markdown.js.map +1 -1
  37. package/dist/_snowpack/pkg/quill.js +12077 -11017
  38. package/dist/_snowpack/pkg/quill.js.map +1 -1
  39. package/dist/_snowpack/pkg/slim-select.js +711 -1
  40. package/dist/_snowpack/pkg/slim-select.js.map +1 -1
  41. package/dist/_snowpack/pkg/tui-calendar/dist/tui-calendar.css +1 -16
  42. package/dist/_snowpack/pkg/tui-calendar/dist/tui-calendar.css.proxy.js +1 -1
  43. package/dist/_snowpack/pkg/tui-calendar.js +44297 -40075
  44. package/dist/_snowpack/pkg/tui-calendar.js.map +1 -1
  45. package/dist/components/solid-ac-checker.js +4 -17
  46. package/dist/components/solid-calendar.js +5 -26
  47. package/dist/components/solid-delete.js +9 -24
  48. package/dist/components/solid-display.js +15 -59
  49. package/dist/components/solid-form-search.js +27 -79
  50. package/dist/components/solid-form.js +48 -143
  51. package/dist/components/solid-lang.js +8 -19
  52. package/dist/components/solid-map.js +26 -64
  53. package/dist/components/solid-table.js +51 -133
  54. package/dist/components/solid-widget.js +2 -24
  55. package/dist/index.js +17 -11
  56. package/dist/libs/Component.js +4 -10
  57. package/dist/libs/ComponentFactory.js +6 -34
  58. package/dist/libs/Compositor.js +8 -15
  59. package/dist/libs/Sib.js +7 -21
  60. package/dist/libs/filter.js +184 -0
  61. package/dist/libs/helpers.js +19 -47
  62. package/dist/libs/interfaces.js +1 -1
  63. package/dist/libs/lit-helpers.js +7 -34
  64. package/dist/libs/polyfills.js +7 -10
  65. package/dist/libs/store/server-pagination.js +22 -0
  66. package/dist/libs/store/server-search.js +35 -0
  67. package/dist/libs/store/store.js +243 -234
  68. package/dist/mixins/attributeBinderMixin.js +17 -25
  69. package/dist/mixins/contextMixin.js +5 -7
  70. package/dist/mixins/counterMixin.js +2 -23
  71. package/dist/mixins/federationMixin.js +2 -14
  72. package/dist/mixins/filterMixin.js +60 -100
  73. package/dist/mixins/grouperMixin.js +11 -18
  74. package/dist/mixins/highlighterMixin.js +2 -8
  75. package/dist/mixins/interfaces.js +3 -5
  76. package/dist/mixins/listMixin.js +12 -43
  77. package/dist/mixins/nextMixin.js +1 -4
  78. package/dist/mixins/paginateMixin.js +17 -30
  79. package/dist/mixins/requiredMixin.js +1 -9
  80. package/dist/mixins/serverPaginationMixin.js +122 -0
  81. package/dist/mixins/sorterMixin.js +26 -44
  82. package/dist/mixins/storeMixin.js +28 -21
  83. package/dist/mixins/translationMixin.js +2 -12
  84. package/dist/mixins/validationMixin.js +28 -46
  85. package/dist/mixins/widgetMixin.js +58 -154
  86. package/dist/new-widgets/attributeMixins/actionMixin.js +1 -2
  87. package/dist/new-widgets/attributeMixins/blankMixin.js +1 -4
  88. package/dist/new-widgets/attributeMixins/booleanMixin.js +1 -4
  89. package/dist/new-widgets/attributeMixins/index.js +1 -2
  90. package/dist/new-widgets/attributeMixins/mailtoMixin.js +1 -4
  91. package/dist/new-widgets/attributeMixins/multipleMixin.js +1 -2
  92. package/dist/new-widgets/attributeMixins/numberMixin.js +1 -4
  93. package/dist/new-widgets/attributeMixins/placeholderMixin.js +1 -4
  94. package/dist/new-widgets/attributeMixins/telMixin.js +1 -4
  95. package/dist/new-widgets/baseWidgetMixin.js +5 -18
  96. package/dist/new-widgets/callbackMixins/autocompletionMixin.js +3 -11
  97. package/dist/new-widgets/callbackMixins/index.js +1 -2
  98. package/dist/new-widgets/callbackMixins/richtextMixin.js +1 -6
  99. package/dist/new-widgets/interfaces.js +1 -0
  100. package/dist/new-widgets/new-widget-factory.js +14 -19
  101. package/dist/new-widgets/templateAdditionMixins/addableMixin.js +6 -21
  102. package/dist/new-widgets/templateAdditionMixins/index.js +2 -3
  103. package/dist/new-widgets/templateAdditionMixins/labelLastMixin.js +5 -18
  104. package/dist/new-widgets/templateAdditionMixins/labelMixin.js +5 -18
  105. package/dist/new-widgets/templates/defaultTemplatesDirectory.js +21 -27
  106. package/dist/new-widgets/templates/displayTemplatesDirectory.js +35 -70
  107. package/dist/new-widgets/templates/formTemplatesDirectory.js +350 -315
  108. package/dist/new-widgets/templates/groupTemplatesDirectory.js +5 -15
  109. package/dist/new-widgets/templates/index.js +1 -2
  110. package/dist/new-widgets/templates/setTemplatesDirectory.js +4 -37
  111. package/dist/new-widgets/templatesDependencies/altMixin.js +1 -2
  112. package/dist/new-widgets/templatesDependencies/editableMixin.js +9 -26
  113. package/dist/new-widgets/templatesDependencies/filterRangeFormMixin.js +3 -7
  114. package/dist/new-widgets/templatesDependencies/formCheckboxMixin.js +1 -5
  115. package/dist/new-widgets/templatesDependencies/formCheckboxesMixin.js +1 -11
  116. package/dist/new-widgets/templatesDependencies/formDropdownMixin.js +3 -13
  117. package/dist/new-widgets/templatesDependencies/formFileMixin.js +1 -13
  118. package/dist/new-widgets/templatesDependencies/formLengthMixin.js +1 -2
  119. package/dist/new-widgets/templatesDependencies/formMinMaxMixin.js +1 -2
  120. package/dist/new-widgets/templatesDependencies/formMixin.js +4 -14
  121. package/dist/new-widgets/templatesDependencies/formNumberMixin.js +1 -5
  122. package/dist/new-widgets/templatesDependencies/formRadioMixin.js +1 -5
  123. package/dist/new-widgets/templatesDependencies/formStepMixin.js +1 -2
  124. package/dist/new-widgets/templatesDependencies/linkTextMixin.js +13 -0
  125. package/dist/new-widgets/templatesDependencies/multipleFormMixin.js +23 -18
  126. package/dist/new-widgets/templatesDependencies/multipleselectFormMixin.js +1 -10
  127. package/dist/new-widgets/templatesDependencies/patternMixin.js +1 -2
  128. package/dist/new-widgets/templatesDependencies/rangeMixin.js +5 -15
  129. package/dist/new-widgets/templatesDependencies/setMixin.js +1 -4
  130. package/dist/new-widgets/templatesDependencies/valueRichtextMixin.js +1 -4
  131. package/dist/new-widgets/valueTransformationMixins/autolinkMixin.js +1 -5
  132. package/dist/new-widgets/valueTransformationMixins/dateMixin.js +5 -11
  133. package/dist/new-widgets/valueTransformationMixins/dateTimeMixin.js +1 -5
  134. package/dist/new-widgets/valueTransformationMixins/index.js +1 -2
  135. package/dist/new-widgets/valueTransformationMixins/markdownMixin.js +1 -7
  136. package/dist/new-widgets/valueTransformationMixins/multilineMixin.js +1 -5
  137. package/dist/new-widgets/valueTransformationMixins/oembedMixin.js +1 -7
  138. package/dist/solid-template-element.js +24 -44
  139. package/dist/widgets/baseWidget.js +21 -85
  140. package/dist/widgets/widget-factory.js +4 -6
  141. package/package.json +8 -6
  142. package/dist/_snowpack/env.js +0 -3
  143. package/dist/_snowpack/pkg/autolinker.js.map.proxy.js +0 -1
  144. package/dist/_snowpack/pkg/common/_baseUnary-217dffb2.js.map.proxy.js +0 -1
  145. package/dist/_snowpack/pkg/common/_commonjsHelpers-8c19dec8.js.map +0 -1
  146. package/dist/_snowpack/pkg/common/_commonjsHelpers-8c19dec8.js.map.proxy.js +0 -1
  147. package/dist/_snowpack/pkg/common/decode-a4c334cf.js.map +0 -1
  148. package/dist/_snowpack/pkg/common/decode-a4c334cf.js.map.proxy.js +0 -1
  149. package/dist/_snowpack/pkg/common/lit-html-babd44cd.js +0 -1119
  150. package/dist/_snowpack/pkg/common/lit-html-babd44cd.js.map +0 -1
  151. package/dist/_snowpack/pkg/common/lit-html-babd44cd.js.map.proxy.js +0 -1
  152. package/dist/_snowpack/pkg/delta-markdown-for-quill.js.map.proxy.js +0 -1
  153. package/dist/_snowpack/pkg/dialog-polyfill.js.map.proxy.js +0 -1
  154. package/dist/_snowpack/pkg/fusejs.js.map.proxy.js +0 -1
  155. package/dist/_snowpack/pkg/jsonld-context-parser.js.map.proxy.js +0 -1
  156. package/dist/_snowpack/pkg/lit-html/directives/if-defined.js.map.proxy.js +0 -1
  157. package/dist/_snowpack/pkg/lit-html/directives/unsafe-html.js.map.proxy.js +0 -1
  158. package/dist/_snowpack/pkg/lit-html/directives/until.js.map.proxy.js +0 -1
  159. package/dist/_snowpack/pkg/lit-html.js.map.proxy.js +0 -1
  160. package/dist/_snowpack/pkg/markdown-it-link-attributes.js.map.proxy.js +0 -1
  161. package/dist/_snowpack/pkg/markdown-it.js.map.proxy.js +0 -1
  162. package/dist/_snowpack/pkg/quill-delta-to-markdown.js.map.proxy.js +0 -1
  163. package/dist/_snowpack/pkg/quill.js.map.proxy.js +0 -1
  164. package/dist/_snowpack/pkg/slim-select.js.map.proxy.js +0 -1
  165. package/dist/_snowpack/pkg/tui-calendar.js.map.proxy.js +0 -1
  166. package/dist/components/solid-ac-checker.js.map +0 -1
  167. package/dist/components/solid-calendar.js.map +0 -1
  168. package/dist/components/solid-delete.js.map +0 -1
  169. package/dist/components/solid-display.js.map +0 -1
  170. package/dist/components/solid-form-search.js.map +0 -1
  171. package/dist/components/solid-form.js.map +0 -1
  172. package/dist/components/solid-lang.js.map +0 -1
  173. package/dist/components/solid-map.js.map +0 -1
  174. package/dist/components/solid-table.js.map +0 -1
  175. package/dist/components/solid-widget.js.map +0 -1
  176. package/dist/index.js.map +0 -1
  177. package/dist/libs/Component.js.map +0 -1
  178. package/dist/libs/ComponentFactory.js.map +0 -1
  179. package/dist/libs/Compositor.js.map +0 -1
  180. package/dist/libs/Sib.js.map +0 -1
  181. package/dist/libs/helpers.js.map +0 -1
  182. package/dist/libs/interfaces.js.map +0 -1
  183. package/dist/libs/lit-helpers.js.map +0 -1
  184. package/dist/libs/polyfills.js.map +0 -1
  185. package/dist/libs/store/store.js.map +0 -1
  186. package/dist/mixins/attributeBinderMixin.js.map +0 -1
  187. package/dist/mixins/contextMixin.js.map +0 -1
  188. package/dist/mixins/counterMixin.js.map +0 -1
  189. package/dist/mixins/federationMixin.js.map +0 -1
  190. package/dist/mixins/filterMixin.js.map +0 -1
  191. package/dist/mixins/grouperMixin.js.map +0 -1
  192. package/dist/mixins/highlighterMixin.js.map +0 -1
  193. package/dist/mixins/interfaces.js.map +0 -1
  194. package/dist/mixins/listMixin.js.map +0 -1
  195. package/dist/mixins/nextMixin.js.map +0 -1
  196. package/dist/mixins/paginateMixin.js.map +0 -1
  197. package/dist/mixins/requiredMixin.js.map +0 -1
  198. package/dist/mixins/sorterMixin.js.map +0 -1
  199. package/dist/mixins/storeMixin.js.map +0 -1
  200. package/dist/mixins/translationMixin.js.map +0 -1
  201. package/dist/mixins/validationMixin.js.map +0 -1
  202. package/dist/mixins/widgetMixin.js.map +0 -1
  203. package/dist/new-widgets/attributeMixins/actionMixin.js.map +0 -1
  204. package/dist/new-widgets/attributeMixins/blankMixin.js.map +0 -1
  205. package/dist/new-widgets/attributeMixins/booleanMixin.js.map +0 -1
  206. package/dist/new-widgets/attributeMixins/index.js.map +0 -1
  207. package/dist/new-widgets/attributeMixins/mailtoMixin.js.map +0 -1
  208. package/dist/new-widgets/attributeMixins/multipleMixin.js.map +0 -1
  209. package/dist/new-widgets/attributeMixins/numberMixin.js.map +0 -1
  210. package/dist/new-widgets/attributeMixins/placeholderMixin.js.map +0 -1
  211. package/dist/new-widgets/attributeMixins/telMixin.js.map +0 -1
  212. package/dist/new-widgets/baseWidgetMixin.js.map +0 -1
  213. package/dist/new-widgets/callbackMixins/autocompletionMixin.js.map +0 -1
  214. package/dist/new-widgets/callbackMixins/index.js.map +0 -1
  215. package/dist/new-widgets/callbackMixins/richtextMixin.js.map +0 -1
  216. package/dist/new-widgets/new-widget-factory.js.map +0 -1
  217. package/dist/new-widgets/templateAdditionMixins/addableMixin.js.map +0 -1
  218. package/dist/new-widgets/templateAdditionMixins/index.js.map +0 -1
  219. package/dist/new-widgets/templateAdditionMixins/labelLastMixin.js.map +0 -1
  220. package/dist/new-widgets/templateAdditionMixins/labelMixin.js.map +0 -1
  221. package/dist/new-widgets/templates/defaultTemplatesDirectory.js.map +0 -1
  222. package/dist/new-widgets/templates/displayTemplatesDirectory.js.map +0 -1
  223. package/dist/new-widgets/templates/formTemplatesDirectory.js.map +0 -1
  224. package/dist/new-widgets/templates/groupTemplatesDirectory.js.map +0 -1
  225. package/dist/new-widgets/templates/index.js.map +0 -1
  226. package/dist/new-widgets/templates/setTemplatesDirectory.js.map +0 -1
  227. package/dist/new-widgets/templatesDependencies/altMixin.js.map +0 -1
  228. package/dist/new-widgets/templatesDependencies/editableMixin.js.map +0 -1
  229. package/dist/new-widgets/templatesDependencies/filterRangeFormMixin.js.map +0 -1
  230. package/dist/new-widgets/templatesDependencies/formCheckboxMixin.js.map +0 -1
  231. package/dist/new-widgets/templatesDependencies/formCheckboxesMixin.js.map +0 -1
  232. package/dist/new-widgets/templatesDependencies/formDropdownMixin.js.map +0 -1
  233. package/dist/new-widgets/templatesDependencies/formFileMixin.js.map +0 -1
  234. package/dist/new-widgets/templatesDependencies/formLengthMixin.js.map +0 -1
  235. package/dist/new-widgets/templatesDependencies/formMinMaxMixin.js.map +0 -1
  236. package/dist/new-widgets/templatesDependencies/formMixin.js.map +0 -1
  237. package/dist/new-widgets/templatesDependencies/formNumberMixin.js.map +0 -1
  238. package/dist/new-widgets/templatesDependencies/formRadioMixin.js.map +0 -1
  239. package/dist/new-widgets/templatesDependencies/formStepMixin.js.map +0 -1
  240. package/dist/new-widgets/templatesDependencies/multipleFormMixin.js.map +0 -1
  241. package/dist/new-widgets/templatesDependencies/multipleselectFormMixin.js.map +0 -1
  242. package/dist/new-widgets/templatesDependencies/patternMixin.js.map +0 -1
  243. package/dist/new-widgets/templatesDependencies/rangeMixin.js.map +0 -1
  244. package/dist/new-widgets/templatesDependencies/setMixin.js.map +0 -1
  245. package/dist/new-widgets/templatesDependencies/valueRichtextMixin.js.map +0 -1
  246. package/dist/new-widgets/valueTransformationMixins/autolinkMixin.js.map +0 -1
  247. package/dist/new-widgets/valueTransformationMixins/dateMixin.js.map +0 -1
  248. package/dist/new-widgets/valueTransformationMixins/dateTimeMixin.js.map +0 -1
  249. package/dist/new-widgets/valueTransformationMixins/index.js.map +0 -1
  250. package/dist/new-widgets/valueTransformationMixins/markdownMixin.js.map +0 -1
  251. package/dist/new-widgets/valueTransformationMixins/multilineMixin.js.map +0 -1
  252. package/dist/new-widgets/valueTransformationMixins/oembedMixin.js.map +0 -1
  253. package/dist/solid-template-element.js.map +0 -1
  254. package/dist/widgets/baseWidget.js.map +0 -1
  255. package/dist/widgets/widget-factory.js.map +0 -1
package/dist/libs/Sib.js CHANGED
@@ -1,5 +1,6 @@
1
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
-
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); }
3
4
  import { ComponentFactory } from "./ComponentFactory.js";
4
5
  import { defineComponent } from "./helpers.js";
5
6
  export class Sib {
@@ -8,51 +9,36 @@ export class Sib {
8
9
  const cls = this.toElement(component);
9
10
  defineComponent(component.name, cls);
10
11
  }
11
-
12
12
  static toElement(component) {
13
- var _temp;
14
-
15
- return _temp = class extends HTMLElement {
13
+ return class extends HTMLElement {
16
14
  constructor() {
17
15
  super();
18
-
19
16
  _defineProperty(this, "_component", null);
20
-
21
17
  this.component = new component(this);
22
18
  this.component.created();
23
19
  }
24
-
25
20
  get component() {
26
21
  if (this._component === null) {
27
22
  throw new Error('No component found');
28
23
  }
29
-
30
24
  return this._component;
31
25
  }
32
-
33
26
  set component(component) {
34
27
  this._component = component;
35
28
  }
36
-
37
29
  static get observedAttributes() {
38
30
  return component.observedAttributes;
39
31
  }
40
-
41
32
  attributeChangedCallback(name, oldValue, newValue) {
42
- const attr = name.replace(/([a-z0-9])-([a-z0-9])/g, (_c, p1, p2) => "".concat(p1).concat(p2.toUpperCase()));
33
+ const attr = name.replace(/([a-z0-9])-([a-z0-9])/g, (_c, p1, p2) => `${p1}${p2.toUpperCase()}`);
43
34
  this.component.attributesCallback(attr, newValue, oldValue);
44
35
  }
45
-
46
36
  connectedCallback() {
47
37
  this.component.attached();
48
38
  }
49
-
50
39
  disconnectedCallback() {
51
40
  this.component.detached();
52
41
  }
53
-
54
- }, _temp;
42
+ };
55
43
  }
56
-
57
- }
58
- //# sourceMappingURL=Sib.js.map
44
+ }
@@ -0,0 +1,184 @@
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 fields - 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 };
@@ -1,19 +1,16 @@
1
1
  import Fuse from "../_snowpack/pkg/fusejs.js";
2
-
3
2
  function uniqID() {
4
3
  return '_' + (Math.random() * Math.pow(36, 20)).toString(36).slice(0, 10);
5
4
  }
6
-
7
5
  function stringToDom(html) {
8
6
  const template = document.createElement('template');
9
7
  template.innerHTML = html;
10
8
  return template.content;
11
9
  }
12
-
13
- async function evalTemplateString(str, variables = {}) {
10
+ async function evalTemplateString(str) {
11
+ let variables = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
14
12
  const keys = Object.keys(variables);
15
13
  const values = keys.map(key => variables[key]);
16
-
17
14
  try {
18
15
  const AsyncFunction = Object.getPrototypeOf(async function () {}).constructor;
19
16
  const func = AsyncFunction.call(null, ...keys, 'return `' + str + '`');
@@ -23,10 +20,11 @@ async function evalTemplateString(str, variables = {}) {
23
20
  throw new SyntaxError('`' + str + '`');
24
21
  }
25
22
  }
26
-
27
- function importCSS(...stylesheets) {
23
+ function importCSS() {
28
24
  const linksElements = [];
29
-
25
+ for (var _len = arguments.length, stylesheets = new Array(_len), _key = 0; _key < _len; _key++) {
26
+ stylesheets[_key] = arguments[_key];
27
+ }
30
28
  for (let url of stylesheets) {
31
29
  url = relativeSource(url);
32
30
  let link = Array.from(document.head.querySelectorAll('link')).find(link => link.href === url);
@@ -37,12 +35,13 @@ function importCSS(...stylesheets) {
37
35
  document.head.appendChild(link);
38
36
  linksElements.push(link);
39
37
  }
40
-
41
38
  ;
42
39
  return linksElements;
43
40
  }
44
-
45
- function importJS(...plugins) {
41
+ function importJS() {
42
+ for (var _len2 = arguments.length, plugins = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
43
+ plugins[_key2] = arguments[_key2];
44
+ }
46
45
  return plugins.map(url => {
47
46
  url = new URL(url, document.baseURI).href;
48
47
  let script = Array.from(document.querySelectorAll('script')).find(script => script.src === url);
@@ -53,7 +52,6 @@ function importJS(...plugins) {
53
52
  return script;
54
53
  });
55
54
  }
56
-
57
55
  function relativeSource(source) {
58
56
  if (!source.match(/^\..?\//)) return new URL(source, document.baseURI).href;
59
57
  const e = new Error();
@@ -65,21 +63,17 @@ function relativeSource(source) {
65
63
  source = new URL(source, calledFile).href;
66
64
  return source;
67
65
  }
68
-
69
66
  function loadScript(source) {
70
67
  source = relativeSource(source);
71
68
  return new Promise(resolve => {
72
69
  var script = document.createElement('script');
73
70
  var head = document.querySelector('head');
74
71
  script.async = true;
75
-
76
72
  script.onload = () => setTimeout(resolve, 0);
77
-
78
73
  script.src = source;
79
74
  if (head) head.appendChild(script);
80
75
  });
81
76
  }
82
-
83
77
  function domIsReady() {
84
78
  return new Promise(function (resolve) {
85
79
  if (document.readyState === 'complete') {
@@ -89,29 +83,24 @@ function domIsReady() {
89
83
  }
90
84
  });
91
85
  }
92
-
93
86
  function setDeepProperty(obj, path, value) {
94
87
  const name = path.shift();
95
-
96
88
  if (name) {
97
89
  if (!(name in obj)) obj[name] = {};
98
90
  if (path.length) setDeepProperty(obj[name], path, value);else obj[name] = value;
99
91
  }
100
92
  }
101
-
102
93
  function parseFieldsString(fields) {
103
- let fieldsArray; // remove all sets from fields
94
+ let fieldsArray;
104
95
 
96
+ // remove all sets from fields
105
97
  while (fields.indexOf('(') > 0) {
106
98
  let firstBracket = fields.indexOf('(');
107
99
  let noset = fields.substring(firstBracket, findClosingBracketMatchIndex(fields, firstBracket) + 1);
108
100
  fields = fields.replace(noset, '');
109
101
  }
110
-
111
102
  const re = /((^\s*|,)\s*)(("(\\"|[^"])*")|('(\\'|[^'])*')|[^,]*)/gm; // match , not inside quotes
112
-
113
103
  fieldsArray = fields.match(re) || []; // separate fields
114
-
115
104
  if (!fieldsArray) return [];
116
105
  return fieldsArray.map(a => a.replace(/^[\s,]+/, '')); // remove commas and spaces
117
106
  }
@@ -119,30 +108,25 @@ function parseFieldsString(fields) {
119
108
  function findClosingBracketMatchIndex(str, pos) {
120
109
  if (str[pos] != '(') throw new Error("No '(' at index " + pos);
121
110
  let depth = 1;
122
-
123
111
  for (let i = pos + 1; i < str.length; i++) {
124
112
  switch (str[i]) {
125
113
  case '(':
126
114
  depth++;
127
115
  break;
128
-
129
116
  case ')':
130
117
  if (--depth == 0) return i;
131
118
  break;
132
119
  }
133
120
  }
134
-
135
121
  return -1;
136
122
  }
137
-
138
123
  function defineComponent(tagName, componentClass) {
139
124
  if (!customElements.get(tagName)) {
140
125
  customElements.define(tagName, componentClass);
141
126
  } else {
142
- console.warn("Warning: the component \"".concat(tagName, "\" has already been loaded in another version of sib-core."));
127
+ console.warn(`Warning: the component "${tagName}" has already been loaded in another version of sib-core.`);
143
128
  }
144
129
  }
145
-
146
130
  function fuzzyCompare(subject, search) {
147
131
  const fuse = new Fuse([subject], {
148
132
  shouldSort: false,
@@ -150,31 +134,25 @@ function fuzzyCompare(subject, search) {
150
134
  }).search(search);
151
135
  return fuse.length > 0;
152
136
  }
153
-
154
137
  const compare = {
155
138
  string(subject, query) {
156
139
  if (query === '') return true;
157
140
  if (subject.toString().toLowerCase().includes(String(query).toLowerCase())) return true;
158
141
  return fuzzyCompare(subject, query);
159
142
  },
160
-
161
143
  boolean(subject, query) {
162
144
  if (!query) return true;
163
145
  return subject;
164
146
  },
165
-
166
147
  number(subject, query) {
167
148
  return subject === query;
168
149
  },
169
-
170
150
  list(subject, list) {
171
151
  return list.includes(subject);
172
152
  },
173
-
174
153
  range(subject, range) {
175
154
  return (range[0] == null || range[0] === '' || subject >= range[0]) && (range[1] == null || range[1] === '' || subject <= range[1]);
176
155
  },
177
-
178
156
  resource(subject, query) {
179
157
  // dropdown default ' - ' option return an empty string
180
158
  if (query === '') return true;
@@ -182,38 +160,32 @@ const compare = {
182
160
  const ret = subject['@id'] === query['@id'];
183
161
  return ret;
184
162
  }
185
-
186
163
  };
187
-
188
164
  function transformArrayToContainer(resource) {
189
- const newValue = { ...resource
165
+ const newValue = {
166
+ ...resource
190
167
  };
191
-
192
168
  for (let predicate of Object.keys(newValue)) {
193
169
  // iterate over all properties
194
170
  const predicateValue = newValue[predicate];
195
171
  if (!predicateValue || typeof predicateValue !== 'object') continue; // undefined or literal, do nothing
196
- // check all keys of nested resource
197
172
 
173
+ // check all keys of nested resource
198
174
  if (!Array.isArray(predicateValue) && predicateValue['@id']) {
199
175
  newValue[predicate] = transformArrayToContainer(resource[predicate]);
200
- } // for arrays
201
-
176
+ }
202
177
 
178
+ // for arrays
203
179
  if (Array.isArray(predicateValue)) {
204
180
  newValue[predicate] = {
205
181
  'ldp:contains': [...predicateValue]
206
182
  }; // transform to container
207
-
208
183
  newValue[predicate]['ldp:contains'].forEach((childPredicate, index) => {
209
184
  // and check all nested resources
210
185
  newValue[predicate]['ldp:contains'][index] = transformArrayToContainer(childPredicate);
211
186
  });
212
187
  }
213
188
  }
214
-
215
189
  return newValue;
216
190
  }
217
-
218
- export { uniqID, stringToDom, evalTemplateString, importCSS, importJS, loadScript, domIsReady, setDeepProperty, parseFieldsString, findClosingBracketMatchIndex, defineComponent, fuzzyCompare, compare, transformArrayToContainer };
219
- //# sourceMappingURL=helpers.js.map
191
+ export { uniqID, stringToDom, evalTemplateString, importCSS, importJS, loadScript, domIsReady, setDeepProperty, parseFieldsString, findClosingBracketMatchIndex, defineComponent, fuzzyCompare, compare, transformArrayToContainer };
@@ -3,4 +3,4 @@
3
3
  ;
4
4
  ;
5
5
  ;
6
- //# sourceMappingURL=interfaces.js.map
6
+ export {};
@@ -6,13 +6,10 @@ import { html, directive, noChange } from '../_snowpack/pkg/lit-html.js';
6
6
  const prevCache = new WeakMap();
7
7
  export const spread = directive(spreadData => part => {
8
8
  const prevData = prevCache.get(part);
9
-
10
9
  if (prevData === spreadData) {
11
10
  return;
12
11
  }
13
-
14
12
  prevCache.set(part, spreadData);
15
-
16
13
  if (spreadData) {
17
14
  for (const key in spreadData) {
18
15
  const value = spreadData[key];
@@ -21,41 +18,32 @@ export const spread = directive(spreadData => part => {
21
18
  const {
22
19
  element
23
20
  } = part.committer;
24
-
25
21
  if (prefix === '@') {
26
22
  const prevHandler = prevData && prevData[key];
27
-
28
23
  if (!prevHandler || prevHandler !== value) {
29
24
  const name = key.slice(1);
30
25
  if (prevHandler) element.removeEventListener(name, prevHandler);
31
26
  element.addEventListener(name, value);
32
27
  }
33
-
34
28
  continue;
35
29
  }
36
-
37
30
  if (prefix === '.') {
38
31
  if (!prevData || prevData[key] !== value) {
39
32
  element[key.slice(1)] = value;
40
33
  }
41
-
42
34
  continue;
43
35
  }
44
-
45
36
  if (prefix === '?') {
46
37
  if (!prevData || prevData[key] !== value) {
47
38
  const name = key.slice(1);
48
-
49
39
  if (value) {
50
40
  element.setAttribute(name, '');
51
41
  } else {
52
42
  element.removeAttribute(name);
53
43
  }
54
44
  }
55
-
56
45
  continue;
57
46
  }
58
-
59
47
  if (!prevData || prevData[key] !== value) {
60
48
  if (value != null) {
61
49
  element.setAttribute(key, String(value));
@@ -65,7 +53,6 @@ export const spread = directive(spreadData => part => {
65
53
  }
66
54
  }
67
55
  }
68
-
69
56
  if (prevData) {
70
57
  for (const key in prevData) {
71
58
  if (!spreadData || !(key in spreadData)) {
@@ -73,32 +60,26 @@ export const spread = directive(spreadData => part => {
73
60
  const {
74
61
  element
75
62
  } = part.committer;
76
-
77
63
  if (prefix === '@') {
78
64
  element.removeEventListener(key.slice(1), prevData[key]);
79
65
  continue;
80
66
  }
81
-
82
67
  if (prefix === '.') {
83
68
  element[key.slice(1)] = undefined;
84
69
  continue;
85
70
  }
86
-
87
71
  if (prefix === '?') {
88
72
  element.removeAttribute(key.slice(1));
89
73
  continue;
90
74
  }
91
-
92
75
  element.removeAttribute(key);
93
76
  }
94
77
  }
95
78
  }
96
79
  });
97
-
98
80
  function dropIndices(arr, needlessValues) {
99
81
  const newArr = [];
100
82
  let j = 0;
101
-
102
83
  for (let i = 0, n = arr.length; i < n; ++i) {
103
84
  if (needlessValues[j].index === i) {
104
85
  ++j;
@@ -106,42 +87,38 @@ function dropIndices(arr, needlessValues) {
106
87
  newArr.push(arr[i]);
107
88
  }
108
89
  }
109
-
110
90
  return newArr;
111
91
  }
92
+ const templateStringsCache = new WeakMap();
112
93
 
113
- const templateStringsCache = new WeakMap(); // Convert dynamic tags to template strings
94
+ // Convert dynamic tags to template strings
114
95
  // example: <${'div'}>${'this is example'}</${'div'}> => <div>${'this is example'}</div>
115
-
116
- export function preHTML(strings, ...values) {
96
+ export function preHTML(strings) {
117
97
  // check cache !important return equal link at first argument
118
98
  let cachedStrings = templateStringsCache.get(strings);
119
-
99
+ for (var _len = arguments.length, values = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
100
+ values[_key - 1] = arguments[_key];
101
+ }
120
102
  if (cachedStrings) {
121
103
  for (let i = 0, n = cachedStrings.length; i < n; ++i) {
122
104
  const needlessValues = cachedStrings[i].needlessValues;
123
105
  let isSame = true;
124
-
125
106
  for (let ii = 0, nn = needlessValues.length; ii < nn; ++ii) {
126
107
  if (values[needlessValues[ii].index] !== needlessValues[ii].value) {
127
108
  isSame = false;
128
109
  break;
129
110
  }
130
111
  }
131
-
132
112
  if (isSame) {
133
113
  return html(cachedStrings[i].strings, ...dropIndices(values, needlessValues));
134
114
  }
135
115
  }
136
116
  }
137
-
138
117
  const needlessValues = [];
139
118
  const newStrings = [];
140
119
  let str;
141
-
142
120
  for (let i = 0, n = strings.length; i < n; ++i) {
143
121
  str = strings[i];
144
-
145
122
  while (str[str.length - 1] === '<' // open tag
146
123
  || str[str.length - 2] === '<' && str[str.length - 1] === '/' // close tag
147
124
  ) {
@@ -151,19 +128,15 @@ export function preHTML(strings, ...values) {
151
128
  });
152
129
  str += values[i] + strings[++i];
153
130
  }
154
-
155
131
  newStrings.push(str);
156
132
  }
157
-
158
133
  if (!cachedStrings) {
159
134
  cachedStrings = [];
160
135
  templateStringsCache.set(strings, cachedStrings);
161
136
  }
162
-
163
137
  cachedStrings.push({
164
138
  strings: newStrings,
165
139
  needlessValues
166
140
  });
167
141
  return html(newStrings, ...dropIndices(values, needlessValues));
168
- }
169
- //# sourceMappingURL=lit-helpers.js.map
142
+ }
@@ -2,7 +2,8 @@
2
2
  if (!('flat' in Array.prototype)) {
3
3
  Object.defineProperty(Array.prototype, 'flat', {
4
4
  configurable: true,
5
- value: function flat(depth = 1) {
5
+ value: function flat() {
6
+ let depth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
6
7
  depth = isNaN(depth) ? 1 : Number(depth);
7
8
  if (depth === 0) return Array.prototype.slice.call(this);
8
9
  return Array.prototype.reduce.call(this, function (acc, cur) {
@@ -11,30 +12,26 @@ if (!('flat' in Array.prototype)) {
11
12
  } else {
12
13
  acc.push(cur);
13
14
  }
14
-
15
15
  return acc;
16
16
  }, []);
17
17
  },
18
18
  writable: true
19
19
  });
20
- } // Element.prototype.toggleAttribute
21
-
20
+ }
22
21
 
22
+ // Element.prototype.toggleAttribute
23
23
  if (!Element.prototype.toggleAttribute) {
24
- Element.prototype.toggleAttribute = function (name, force = undefined) {
24
+ Element.prototype.toggleAttribute = function (name) {
25
+ let force = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
25
26
  if (force !== undefined) force = !!force;
26
-
27
27
  if (this.hasAttribute(name)) {
28
28
  if (force) return true;
29
29
  this.removeAttribute(name);
30
30
  return false;
31
31
  }
32
-
33
32
  if (force === false) return false;
34
33
  this.setAttribute(name, '');
35
34
  return true;
36
35
  };
37
36
  }
38
-
39
- export {};
40
- //# sourceMappingURL=polyfills.js.map
37
+ export {};