@startinblox/core 0.17.20 → 0.17.21-beta.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 (256) hide show
  1. package/package.json +2 -2
  2. package/dist/_snowpack/env.js +0 -3
  3. package/dist/_snowpack/pkg/autolinker.js +0 -4281
  4. package/dist/_snowpack/pkg/autolinker.js.map +0 -1
  5. package/dist/_snowpack/pkg/autolinker.js.map.proxy.js +0 -1
  6. package/dist/_snowpack/pkg/common/_baseUnary-217dffb2.js +0 -377
  7. package/dist/_snowpack/pkg/common/_baseUnary-217dffb2.js.map +0 -1
  8. package/dist/_snowpack/pkg/common/_baseUnary-217dffb2.js.map.proxy.js +0 -1
  9. package/dist/_snowpack/pkg/common/_commonjsHelpers-8c19dec8.js +0 -22
  10. package/dist/_snowpack/pkg/common/_commonjsHelpers-8c19dec8.js.map +0 -1
  11. package/dist/_snowpack/pkg/common/_commonjsHelpers-8c19dec8.js.map.proxy.js +0 -1
  12. package/dist/_snowpack/pkg/common/decode-a4c334cf.js +0 -216
  13. package/dist/_snowpack/pkg/common/decode-a4c334cf.js.map +0 -1
  14. package/dist/_snowpack/pkg/common/decode-a4c334cf.js.map.proxy.js +0 -1
  15. package/dist/_snowpack/pkg/common/lit-html-babd44cd.js +0 -1119
  16. package/dist/_snowpack/pkg/common/lit-html-babd44cd.js.map +0 -1
  17. package/dist/_snowpack/pkg/common/lit-html-babd44cd.js.map.proxy.js +0 -1
  18. package/dist/_snowpack/pkg/delta-markdown-for-quill.js +0 -25677
  19. package/dist/_snowpack/pkg/delta-markdown-for-quill.js.map +0 -1
  20. package/dist/_snowpack/pkg/delta-markdown-for-quill.js.map.proxy.js +0 -1
  21. package/dist/_snowpack/pkg/dialog-polyfill.js +0 -859
  22. package/dist/_snowpack/pkg/dialog-polyfill.js.map +0 -1
  23. package/dist/_snowpack/pkg/dialog-polyfill.js.map.proxy.js +0 -1
  24. package/dist/_snowpack/pkg/fusejs.js +0 -1783
  25. package/dist/_snowpack/pkg/fusejs.js.map +0 -1
  26. package/dist/_snowpack/pkg/fusejs.js.map.proxy.js +0 -1
  27. package/dist/_snowpack/pkg/import-map.json +0 -23
  28. package/dist/_snowpack/pkg/jsonld-context-parser.js +0 -804
  29. package/dist/_snowpack/pkg/jsonld-context-parser.js.map +0 -1
  30. package/dist/_snowpack/pkg/jsonld-context-parser.js.map.proxy.js +0 -1
  31. package/dist/_snowpack/pkg/leaflet/dist/leaflet.css +0 -640
  32. package/dist/_snowpack/pkg/leaflet/dist/leaflet.css.proxy.js +0 -10
  33. package/dist/_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.Default.css +0 -60
  34. package/dist/_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.Default.css.proxy.js +0 -10
  35. package/dist/_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.css +0 -14
  36. package/dist/_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.css.proxy.js +0 -10
  37. package/dist/_snowpack/pkg/lit-html/directives/if-defined.js +0 -40
  38. package/dist/_snowpack/pkg/lit-html/directives/if-defined.js.map +0 -1
  39. package/dist/_snowpack/pkg/lit-html/directives/if-defined.js.map.proxy.js +0 -1
  40. package/dist/_snowpack/pkg/lit-html/directives/unsafe-html.js +0 -46
  41. package/dist/_snowpack/pkg/lit-html/directives/unsafe-html.js.map +0 -1
  42. package/dist/_snowpack/pkg/lit-html/directives/unsafe-html.js.map.proxy.js +0 -1
  43. package/dist/_snowpack/pkg/lit-html/directives/until.js +0 -88
  44. package/dist/_snowpack/pkg/lit-html/directives/until.js.map +0 -1
  45. package/dist/_snowpack/pkg/lit-html/directives/until.js.map.proxy.js +0 -1
  46. package/dist/_snowpack/pkg/lit-html.js +0 -92
  47. package/dist/_snowpack/pkg/lit-html.js.map +0 -1
  48. package/dist/_snowpack/pkg/lit-html.js.map.proxy.js +0 -1
  49. package/dist/_snowpack/pkg/markdown-it.js +0 -11860
  50. package/dist/_snowpack/pkg/markdown-it.js.map +0 -1
  51. package/dist/_snowpack/pkg/markdown-it.js.map.proxy.js +0 -1
  52. package/dist/_snowpack/pkg/quill/dist/quill.snow.css +0 -945
  53. package/dist/_snowpack/pkg/quill/dist/quill.snow.css.proxy.js +0 -10
  54. package/dist/_snowpack/pkg/quill-delta-to-markdown.js +0 -1029
  55. package/dist/_snowpack/pkg/quill-delta-to-markdown.js.map +0 -1
  56. package/dist/_snowpack/pkg/quill-delta-to-markdown.js.map.proxy.js +0 -1
  57. package/dist/_snowpack/pkg/quill.js +0 -13382
  58. package/dist/_snowpack/pkg/quill.js.map +0 -1
  59. package/dist/_snowpack/pkg/quill.js.map.proxy.js +0 -1
  60. package/dist/_snowpack/pkg/slim-select.js +0 -4
  61. package/dist/_snowpack/pkg/slim-select.js.map +0 -1
  62. package/dist/_snowpack/pkg/slim-select.js.map.proxy.js +0 -1
  63. package/dist/_snowpack/pkg/tui-calendar/dist/tui-calendar.css +0 -1164
  64. package/dist/_snowpack/pkg/tui-calendar/dist/tui-calendar.css.proxy.js +0 -10
  65. package/dist/_snowpack/pkg/tui-calendar.js +0 -42285
  66. package/dist/_snowpack/pkg/tui-calendar.js.map +0 -1
  67. package/dist/_snowpack/pkg/tui-calendar.js.map.proxy.js +0 -1
  68. package/dist/components/solid-ac-checker.js +0 -58
  69. package/dist/components/solid-ac-checker.js.map +0 -1
  70. package/dist/components/solid-calendar.js +0 -87
  71. package/dist/components/solid-calendar.js.map +0 -1
  72. package/dist/components/solid-delete.js +0 -111
  73. package/dist/components/solid-delete.js.map +0 -1
  74. package/dist/components/solid-display.js +0 -194
  75. package/dist/components/solid-display.js.map +0 -1
  76. package/dist/components/solid-form-search.js +0 -226
  77. package/dist/components/solid-form-search.js.map +0 -1
  78. package/dist/components/solid-form.js +0 -354
  79. package/dist/components/solid-form.js.map +0 -1
  80. package/dist/components/solid-lang.js +0 -46
  81. package/dist/components/solid-lang.js.map +0 -1
  82. package/dist/components/solid-map.js +0 -242
  83. package/dist/components/solid-map.js.map +0 -1
  84. package/dist/components/solid-table.js +0 -263
  85. package/dist/components/solid-table.js.map +0 -1
  86. package/dist/components/solid-widget.js +0 -94
  87. package/dist/components/solid-widget.js.map +0 -1
  88. package/dist/import.css +0 -4
  89. package/dist/index.js +0 -43
  90. package/dist/index.js.map +0 -1
  91. package/dist/libs/Component.js +0 -19
  92. package/dist/libs/Component.js.map +0 -1
  93. package/dist/libs/ComponentFactory.js +0 -196
  94. package/dist/libs/ComponentFactory.js.map +0 -1
  95. package/dist/libs/Compositor.js +0 -103
  96. package/dist/libs/Compositor.js.map +0 -1
  97. package/dist/libs/Sib.js +0 -58
  98. package/dist/libs/Sib.js.map +0 -1
  99. package/dist/libs/helpers.js +0 -219
  100. package/dist/libs/helpers.js.map +0 -1
  101. package/dist/libs/interfaces.js +0 -6
  102. package/dist/libs/interfaces.js.map +0 -1
  103. package/dist/libs/lit-helpers.js +0 -169
  104. package/dist/libs/lit-helpers.js.map +0 -1
  105. package/dist/libs/polyfills.js +0 -40
  106. package/dist/libs/polyfills.js.map +0 -1
  107. package/dist/libs/store/store.js +0 -802
  108. package/dist/libs/store/store.js.map +0 -1
  109. package/dist/locales/en.json +0 -10
  110. package/dist/locales/en.json.proxy.js +0 -2
  111. package/dist/locales/fr.json +0 -10
  112. package/dist/locales/fr.json.proxy.js +0 -2
  113. package/dist/mixins/attributeBinderMixin.js +0 -124
  114. package/dist/mixins/attributeBinderMixin.js.map +0 -1
  115. package/dist/mixins/contextMixin.js +0 -28
  116. package/dist/mixins/contextMixin.js.map +0 -1
  117. package/dist/mixins/counterMixin.js +0 -75
  118. package/dist/mixins/counterMixin.js.map +0 -1
  119. package/dist/mixins/federationMixin.js +0 -63
  120. package/dist/mixins/federationMixin.js.map +0 -1
  121. package/dist/mixins/filterMixin.js +0 -195
  122. package/dist/mixins/filterMixin.js.map +0 -1
  123. package/dist/mixins/grouperMixin.js +0 -80
  124. package/dist/mixins/grouperMixin.js.map +0 -1
  125. package/dist/mixins/highlighterMixin.js +0 -42
  126. package/dist/mixins/highlighterMixin.js.map +0 -1
  127. package/dist/mixins/interfaces.js +0 -8
  128. package/dist/mixins/interfaces.js.map +0 -1
  129. package/dist/mixins/listMixin.js +0 -136
  130. package/dist/mixins/listMixin.js.map +0 -1
  131. package/dist/mixins/nextMixin.js +0 -26
  132. package/dist/mixins/nextMixin.js.map +0 -1
  133. package/dist/mixins/paginateMixin.js +0 -110
  134. package/dist/mixins/paginateMixin.js.map +0 -1
  135. package/dist/mixins/requiredMixin.js +0 -34
  136. package/dist/mixins/requiredMixin.js.map +0 -1
  137. package/dist/mixins/sorterMixin.js +0 -149
  138. package/dist/mixins/sorterMixin.js.map +0 -1
  139. package/dist/mixins/storeMixin.js +0 -102
  140. package/dist/mixins/storeMixin.js.map +0 -1
  141. package/dist/mixins/translationMixin.js +0 -68
  142. package/dist/mixins/translationMixin.js.map +0 -1
  143. package/dist/mixins/validationMixin.js +0 -113
  144. package/dist/mixins/validationMixin.js.map +0 -1
  145. package/dist/mixins/widgetMixin.js +0 -447
  146. package/dist/mixins/widgetMixin.js.map +0 -1
  147. package/dist/new-widgets/attributeMixins/actionMixin.js +0 -14
  148. package/dist/new-widgets/attributeMixins/actionMixin.js.map +0 -1
  149. package/dist/new-widgets/attributeMixins/blankMixin.js +0 -10
  150. package/dist/new-widgets/attributeMixins/blankMixin.js.map +0 -1
  151. package/dist/new-widgets/attributeMixins/booleanMixin.js +0 -10
  152. package/dist/new-widgets/attributeMixins/booleanMixin.js.map +0 -1
  153. package/dist/new-widgets/attributeMixins/index.js +0 -20
  154. package/dist/new-widgets/attributeMixins/index.js.map +0 -1
  155. package/dist/new-widgets/attributeMixins/mailtoMixin.js +0 -10
  156. package/dist/new-widgets/attributeMixins/mailtoMixin.js.map +0 -1
  157. package/dist/new-widgets/attributeMixins/multipleMixin.js +0 -28
  158. package/dist/new-widgets/attributeMixins/multipleMixin.js.map +0 -1
  159. package/dist/new-widgets/attributeMixins/numberMixin.js +0 -10
  160. package/dist/new-widgets/attributeMixins/numberMixin.js.map +0 -1
  161. package/dist/new-widgets/attributeMixins/placeholderMixin.js +0 -19
  162. package/dist/new-widgets/attributeMixins/placeholderMixin.js.map +0 -1
  163. package/dist/new-widgets/attributeMixins/telMixin.js +0 -10
  164. package/dist/new-widgets/attributeMixins/telMixin.js.map +0 -1
  165. package/dist/new-widgets/baseWidgetMixin.js +0 -122
  166. package/dist/new-widgets/baseWidgetMixin.js.map +0 -1
  167. package/dist/new-widgets/callbackMixins/autocompletionMixin.js +0 -104
  168. package/dist/new-widgets/callbackMixins/autocompletionMixin.js.map +0 -1
  169. package/dist/new-widgets/callbackMixins/index.js +0 -8
  170. package/dist/new-widgets/callbackMixins/index.js.map +0 -1
  171. package/dist/new-widgets/callbackMixins/richtextMixin.js +0 -42
  172. package/dist/new-widgets/callbackMixins/richtextMixin.js.map +0 -1
  173. package/dist/new-widgets/callbackMixins/slimselect.css +0 -2
  174. package/dist/new-widgets/callbackMixins/slimselect.css.proxy.js +0 -10
  175. package/dist/new-widgets/new-widget-factory.js +0 -96
  176. package/dist/new-widgets/new-widget-factory.js.map +0 -1
  177. package/dist/new-widgets/templateAdditionMixins/addableMixin.js +0 -41
  178. package/dist/new-widgets/templateAdditionMixins/addableMixin.js.map +0 -1
  179. package/dist/new-widgets/templateAdditionMixins/index.js +0 -14
  180. package/dist/new-widgets/templateAdditionMixins/index.js.map +0 -1
  181. package/dist/new-widgets/templateAdditionMixins/labelLastMixin.js +0 -29
  182. package/dist/new-widgets/templateAdditionMixins/labelLastMixin.js.map +0 -1
  183. package/dist/new-widgets/templateAdditionMixins/labelMixin.js +0 -31
  184. package/dist/new-widgets/templateAdditionMixins/labelMixin.js.map +0 -1
  185. package/dist/new-widgets/templates/defaultTemplatesDirectory.js +0 -35
  186. package/dist/new-widgets/templates/defaultTemplatesDirectory.js.map +0 -1
  187. package/dist/new-widgets/templates/displayTemplatesDirectory.js +0 -89
  188. package/dist/new-widgets/templates/displayTemplatesDirectory.js.map +0 -1
  189. package/dist/new-widgets/templates/formTemplatesDirectory.js +0 -397
  190. package/dist/new-widgets/templates/formTemplatesDirectory.js.map +0 -1
  191. package/dist/new-widgets/templates/groupTemplatesDirectory.js +0 -21
  192. package/dist/new-widgets/templates/groupTemplatesDirectory.js.map +0 -1
  193. package/dist/new-widgets/templates/index.js +0 -7
  194. package/dist/new-widgets/templates/index.js.map +0 -1
  195. package/dist/new-widgets/templates/setTemplatesDirectory.js +0 -49
  196. package/dist/new-widgets/templates/setTemplatesDirectory.js.map +0 -1
  197. package/dist/new-widgets/templatesDependencies/altMixin.js +0 -13
  198. package/dist/new-widgets/templatesDependencies/altMixin.js.map +0 -1
  199. package/dist/new-widgets/templatesDependencies/editableMixin.js +0 -77
  200. package/dist/new-widgets/templatesDependencies/editableMixin.js.map +0 -1
  201. package/dist/new-widgets/templatesDependencies/filterRangeFormMixin.js +0 -38
  202. package/dist/new-widgets/templatesDependencies/filterRangeFormMixin.js.map +0 -1
  203. package/dist/new-widgets/templatesDependencies/formCheckboxMixin.js +0 -14
  204. package/dist/new-widgets/templatesDependencies/formCheckboxMixin.js.map +0 -1
  205. package/dist/new-widgets/templatesDependencies/formCheckboxesMixin.js +0 -51
  206. package/dist/new-widgets/templatesDependencies/formCheckboxesMixin.js.map +0 -1
  207. package/dist/new-widgets/templatesDependencies/formDropdownMixin.js +0 -66
  208. package/dist/new-widgets/templatesDependencies/formDropdownMixin.js.map +0 -1
  209. package/dist/new-widgets/templatesDependencies/formFileMixin.js +0 -81
  210. package/dist/new-widgets/templatesDependencies/formFileMixin.js.map +0 -1
  211. package/dist/new-widgets/templatesDependencies/formLengthMixin.js +0 -19
  212. package/dist/new-widgets/templatesDependencies/formLengthMixin.js.map +0 -1
  213. package/dist/new-widgets/templatesDependencies/formMinMaxMixin.js +0 -19
  214. package/dist/new-widgets/templatesDependencies/formMinMaxMixin.js.map +0 -1
  215. package/dist/new-widgets/templatesDependencies/formMixin.js +0 -66
  216. package/dist/new-widgets/templatesDependencies/formMixin.js.map +0 -1
  217. package/dist/new-widgets/templatesDependencies/formNumberMixin.js +0 -14
  218. package/dist/new-widgets/templatesDependencies/formNumberMixin.js.map +0 -1
  219. package/dist/new-widgets/templatesDependencies/formRadioMixin.js +0 -16
  220. package/dist/new-widgets/templatesDependencies/formRadioMixin.js.map +0 -1
  221. package/dist/new-widgets/templatesDependencies/formStepMixin.js +0 -13
  222. package/dist/new-widgets/templatesDependencies/formStepMixin.js.map +0 -1
  223. package/dist/new-widgets/templatesDependencies/multipleFormMixin.js +0 -107
  224. package/dist/new-widgets/templatesDependencies/multipleFormMixin.js.map +0 -1
  225. package/dist/new-widgets/templatesDependencies/multipleselectFormMixin.js +0 -74
  226. package/dist/new-widgets/templatesDependencies/multipleselectFormMixin.js.map +0 -1
  227. package/dist/new-widgets/templatesDependencies/patternMixin.js +0 -19
  228. package/dist/new-widgets/templatesDependencies/patternMixin.js.map +0 -1
  229. package/dist/new-widgets/templatesDependencies/rangeMixin.js +0 -110
  230. package/dist/new-widgets/templatesDependencies/rangeMixin.js.map +0 -1
  231. package/dist/new-widgets/templatesDependencies/setMixin.js +0 -12
  232. package/dist/new-widgets/templatesDependencies/setMixin.js.map +0 -1
  233. package/dist/new-widgets/templatesDependencies/valueRichtextMixin.js +0 -12
  234. package/dist/new-widgets/templatesDependencies/valueRichtextMixin.js.map +0 -1
  235. package/dist/new-widgets/valueTransformationMixins/autolinkMixin.js +0 -18
  236. package/dist/new-widgets/valueTransformationMixins/autolinkMixin.js.map +0 -1
  237. package/dist/new-widgets/valueTransformationMixins/dateMixin.js +0 -35
  238. package/dist/new-widgets/valueTransformationMixins/dateMixin.js.map +0 -1
  239. package/dist/new-widgets/valueTransformationMixins/dateTimeMixin.js +0 -16
  240. package/dist/new-widgets/valueTransformationMixins/dateTimeMixin.js.map +0 -1
  241. package/dist/new-widgets/valueTransformationMixins/index.js +0 -16
  242. package/dist/new-widgets/valueTransformationMixins/index.js.map +0 -1
  243. package/dist/new-widgets/valueTransformationMixins/markdownMixin.js +0 -25
  244. package/dist/new-widgets/valueTransformationMixins/markdownMixin.js.map +0 -1
  245. package/dist/new-widgets/valueTransformationMixins/multilineMixin.js +0 -17
  246. package/dist/new-widgets/valueTransformationMixins/multilineMixin.js.map +0 -1
  247. package/dist/new-widgets/valueTransformationMixins/oembedMixin.js +0 -27
  248. package/dist/new-widgets/valueTransformationMixins/oembedMixin.js.map +0 -1
  249. package/dist/solid-template-element.js +0 -164
  250. package/dist/solid-template-element.js.map +0 -1
  251. package/dist/style/default-theme.css +0 -24
  252. package/dist/style/default-theme.css.proxy.js +0 -10
  253. package/dist/widgets/baseWidget.js +0 -332
  254. package/dist/widgets/baseWidget.js.map +0 -1
  255. package/dist/widgets/widget-factory.js +0 -24
  256. package/dist/widgets/widget-factory.js.map +0 -1
@@ -1,110 +0,0 @@
1
- function _templateObject() {
2
- const data = _taggedTemplateLiteral(["\n <button\n data-id=\"prev\"\n ?disabled=", "\n @click=", "\n >\u2190</button>\n <button\n data-id=\"next\"\n ?disabled=", "\n @click=", "\n >\u2192</button>\n <span>\n <span data-id=\"current\">", "</span> / <span data-id=\"count\">", "</span>\n </span>\n "]);
3
-
4
- _templateObject = function () {
5
- return data;
6
- };
7
-
8
- return data;
9
- }
10
-
11
- function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
12
-
13
- import { html } from "../_snowpack/pkg/lit-html.js";
14
- const PaginateMixin = {
15
- name: 'paginate-mixin',
16
- use: [],
17
- attributes: {
18
- paginateBy: {
19
- type: Number,
20
- default: 0
21
- },
22
- paginateLoop: {
23
- type: String,
24
- default: null
25
- }
26
- },
27
- initialState: {
28
- currentPage: []
29
- },
30
-
31
- created() {
32
- this.currentPage = [];
33
- },
34
-
35
- attached() {
36
- this.listPostProcessors.push(this.paginateCallback.bind(this));
37
- },
38
-
39
- async paginateCallback(resources, listPostProcessors, div, context) {
40
- if (this.paginateBy > 0) {
41
- if (!this.currentPage[context]) this.currentPage[context] = 1;
42
- const parentDiv = this.initParentPaginationDiv(div, context);
43
- this.renderCallbacks.push({
44
- template: this.renderPaginationNav(this.getPageCount(resources.length), context, div),
45
- parent: parentDiv
46
- });
47
- const firstElementIndex = (this.getCurrentPage(context) - 1) * this.paginateBy;
48
- resources = resources.slice(firstElementIndex, firstElementIndex + this.paginateBy);
49
- }
50
-
51
- const nextProcessor = listPostProcessors.shift();
52
- if (nextProcessor) await nextProcessor(resources, listPostProcessors, div, context);
53
- },
54
-
55
- getNavElement(div) {
56
- const insertNode = div.parentNode || div;
57
- return insertNode.querySelector("nav[data-id=\"nav\"]");
58
- },
59
-
60
- /**
61
- * Find nav element or create it if not existing
62
- * @param div - insert nav next to this div
63
- */
64
- initParentPaginationDiv(div) {
65
- let nav = this.getNavElement(div);
66
-
67
- if (!nav) {
68
- nav = document.createElement('nav');
69
- nav.setAttribute('data-id', 'nav');
70
- const insertNode = div.parentNode || div;
71
- insertNode.appendChild(nav);
72
- }
73
-
74
- return nav;
75
- },
76
-
77
- getCurrentPage(context) {
78
- return this.currentPage[context];
79
- },
80
-
81
- setCurrentPage(page, context, pageCount) {
82
- if (page < 1) page = !this.shouldLoop() ? 1 : pageCount;
83
- if (page > pageCount) page = !this.shouldLoop() ? pageCount : 1;
84
- this.currentPage[context] = page;
85
- this.empty();
86
- this.populate();
87
- },
88
-
89
- getPageCount(size) {
90
- return Math.max(1, Math.ceil(size / this.paginateBy));
91
- },
92
-
93
- shouldLoop() {
94
- return this.paginateLoop !== null;
95
- },
96
-
97
- /**
98
- * Create pagination template
99
- * @param pageCount
100
- * @param context
101
- */
102
- renderPaginationNav(pageCount, context, div) {
103
- this.getNavElement(div).toggleAttribute('hidden', pageCount <= 1);
104
- const currentPage = this.getCurrentPage(context);
105
- return html(_templateObject(), !this.shouldLoop() && currentPage <= 1, () => this.setCurrentPage(currentPage - 1, context, pageCount), !this.shouldLoop() && currentPage >= pageCount, () => this.setCurrentPage(currentPage + 1, context, pageCount), currentPage, String(pageCount));
106
- }
107
-
108
- };
109
- export { PaginateMixin };
110
- //# sourceMappingURL=paginateMixin.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["paginateMixin.ts"],"names":["html","PaginateMixin","name","use","attributes","paginateBy","type","Number","default","paginateLoop","String","initialState","currentPage","created","attached","listPostProcessors","push","paginateCallback","bind","resources","div","context","parentDiv","initParentPaginationDiv","renderCallbacks","template","renderPaginationNav","getPageCount","length","parent","firstElementIndex","getCurrentPage","slice","nextProcessor","shift","getNavElement","insertNode","parentNode","querySelector","nav","document","createElement","setAttribute","appendChild","setCurrentPage","page","pageCount","shouldLoop","empty","populate","size","Math","max","ceil","toggleAttribute"],"mappings":";;;;;;;;;;;;AAAA,SAASA,IAAT,QAAqC,UAArC;AAEA,MAAMC,aAAa,GAAG;AACpBC,EAAAA,IAAI,EAAE,gBADc;AAEpBC,EAAAA,GAAG,EAAE,EAFe;AAGpBC,EAAAA,UAAU,EAAE;AACVC,IAAAA,UAAU,EAAE;AACVC,MAAAA,IAAI,EAAEC,MADI;AAEVC,MAAAA,OAAO,EAAE;AAFC,KADF;AAKVC,IAAAA,YAAY,EAAE;AACZH,MAAAA,IAAI,EAAEI,MADM;AAEZF,MAAAA,OAAO,EAAE;AAFG;AALJ,GAHQ;AAapBG,EAAAA,YAAY,EAAE;AACZC,IAAAA,WAAW,EAAE;AADD,GAbM;;AAgBpBC,EAAAA,OAAO,GAAG;AACR,SAAKD,WAAL,GAAmB,EAAnB;AACD,GAlBmB;;AAmBpBE,EAAAA,QAAQ,GAAS;AACf,SAAKC,kBAAL,CAAwBC,IAAxB,CAA6B,KAAKC,gBAAL,CAAsBC,IAAtB,CAA2B,IAA3B,CAA7B;AACD,GArBmB;;AAsBpB,QAAMD,gBAAN,CAAuBE,SAAvB,EAA4CJ,kBAA5C,EAA4EK,GAA5E,EAA8FC,OAA9F,EAA+G;AAC7G,QAAI,KAAKhB,UAAL,GAAkB,CAAtB,EAA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CAHrD,EAIa,MAAM,KAAKgC,cAAL,CAAoBhC,WAAW,GAAG,CAAlC,EAAqCS,OAArC,EAA8CyB,SAA9C,CAJnB,EAQgB,CAAC,KAAKC,UAAL,EAAD,IAAsBnC,WAAW,IAAIkC,SARrD,EASc,MAAM,KAAKF,cAAL,CAAoBhC,WAAW,GAAG,CAAlC,EAAqCS,OAArC,EAA8CyB,SAA9C,CATpB,EAY8BlC,WAZ9B,EAY4EF,MAAM,CAACoC,SAAD,CAZlF;AAeD;;AAhGmB,CAAtB;AAmGA,SACE7C,aADF","sourcesContent":["import { html, TemplateResult } from \"lit-html\";\n\nconst PaginateMixin = {\n name: 'paginate-mixin',\n use: [],\n attributes: {\n paginateBy: {\n type: Number,\n default: 0\n },\n paginateLoop: {\n type: String,\n default: null\n }\n },\n initialState: {\n currentPage: [],\n },\n created() {\n this.currentPage = [];\n },\n attached(): void {\n this.listPostProcessors.push(this.paginateCallback.bind(this));\n },\n async paginateCallback(resources: object[], listPostProcessors: Function[], div: HTMLElement, context: string) {\n if (this.paginateBy > 0) {\n if (!this.currentPage[context]) this.currentPage[context] = 1;\n const parentDiv = this.initParentPaginationDiv(div, context);\n this.renderCallbacks.push({\n template: this.renderPaginationNav(this.getPageCount(resources.length),context,div),\n parent: parentDiv\n });\n\n const firstElementIndex = (this.getCurrentPage(context) - 1) * this.paginateBy;\n resources = resources.slice(firstElementIndex, firstElementIndex + this.paginateBy);\n }\n\n const nextProcessor = listPostProcessors.shift();\n if (nextProcessor) await nextProcessor(resources, listPostProcessors, div,context);\n },\n getNavElement(div: HTMLElement) {\n const insertNode = div.parentNode || div;\n return insertNode.querySelector(`nav[data-id=\"nav\"]`);\n },\n /**\n * Find nav element or create it if not existing\n * @param div - insert nav next to this div\n */\n initParentPaginationDiv(div: HTMLElement) {\n let nav = this.getNavElement(div);\n if (!nav) {\n nav = document.createElement('nav');\n nav.setAttribute('data-id', 'nav');\n const insertNode = div.parentNode || div;\n insertNode.appendChild(nav);\n }\n return nav;\n },\n getCurrentPage(context: string) {\n return this.currentPage[context];\n },\n setCurrentPage(page: number, context: string, pageCount: number): void {\n if (page < 1) page = !this.shouldLoop() ? 1 : pageCount;\n if (page > pageCount) page = !this.shouldLoop() ? pageCount : 1;\n this.currentPage[context] = page;\n this.empty();\n this.populate();\n },\n getPageCount(size: number): number {\n return Math.max(1, Math.ceil(size / this.paginateBy));\n },\n shouldLoop(): boolean {\n return this.paginateLoop !== null;\n },\n /**\n * Create pagination template\n * @param pageCount\n * @param context\n */\n renderPaginationNav(pageCount: number, context: string, div: HTMLElement): TemplateResult {\n this.getNavElement(div).toggleAttribute('hidden', pageCount <= 1);\n const currentPage = this.getCurrentPage(context);\n\n return html`\n <button\n data-id=\"prev\"\n ?disabled=${!this.shouldLoop() && currentPage <= 1}\n @click=${() => this.setCurrentPage(currentPage - 1, context, pageCount)}\n >←</button>\n <button\n data-id=\"next\"\n ?disabled=${!this.shouldLoop() && currentPage >= pageCount}\n @click=${ () => this.setCurrentPage(currentPage + 1, context, pageCount)}\n >→</button>\n <span>\n <span data-id=\"current\">${currentPage}</span> / <span data-id=\"count\">${String(pageCount)}</span>\n </span>\n `;\n },\n}\n\nexport {\n PaginateMixin\n}"]}
@@ -1,34 +0,0 @@
1
- const RequiredMixin = {
2
- name: 'required-mixin',
3
- use: [],
4
-
5
- attached() {
6
- this.listPostProcessors.push(this.requiredResources.bind(this));
7
- },
8
-
9
- async requiredResources(resources, listPostProcessors, div, context) {
10
- const displays = [];
11
- const requiredFields = Array.from(this.element.attributes).filter(attr => attr.name.startsWith('required-')).map(attr => attr['name'].replace('required-', ''));
12
-
13
- if (requiredFields.length) {
14
- for (let resource of resources) {
15
- let hasProps = true;
16
-
17
- for (let field of requiredFields) {
18
- if ((await resource[field]) == null || (await resource[field]) == "") {
19
- hasProps = false;
20
- continue;
21
- }
22
- }
23
-
24
- if (hasProps) displays.push(resource);
25
- }
26
- }
27
-
28
- const nextProcessor = listPostProcessors.shift();
29
- if (nextProcessor) await nextProcessor(requiredFields.length ? displays : resources, listPostProcessors, div, context);
30
- }
31
-
32
- };
33
- export { RequiredMixin };
34
- //# sourceMappingURL=requiredMixin.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["requiredMixin.ts"],"names":["RequiredMixin","name","use","attached","listPostProcessors","push","requiredResources","bind","resources","div","context","displays","requiredFields","Array","from","element","attributes","filter","attr","startsWith","map","replace","length","resource","hasProps","field","nextProcessor","shift"],"mappings":"AAAA,MAAMA,aAAa,GAAG;AACpBC,EAAAA,IAAI,EAAE,gBADc;AAEpBC,EAAAA,GAAG,EAAE,EAFe;;AAGpBC,EAAAA,QAAQ,GAAS;AACf,SAAKC,kBAAL,CAAwBC,IAAxB,CAA6B,KAAKC,iBAAL,CAAuBC,IAAvB,CAA4B,IAA5B,CAA7B;AACD,GALmB;;AAMpB,QAAMD,iBAAN,CAAwBE,SAAxB,EAA6CJ,kBAA7C,EAA6EK,GAA7E,EAA+FC,OAA/F,EAA+H;AAC7H,UAAMC,QAAe,GAAG,EAAxB;AACA,UAAMC,cAAc,GAAGC,KAAK,CAACC,IAAN,CAAY,KAAKC,OAAN,CAA0BC,UAArC,EAAiDC,MAAjD,CAAwDC,IAAI,IAAIA,IAAI,CAACjB,IAAL,CAAUkB,UAAV,CAAqB,WAArB,CAAhE,EACpBC,GADoB,CAChBF,IAAI,IAAIA,IAAI,CAAC,MAAD,CAAJ,CAAaG,OAAb,CAAqB,WAArB,EAAkC,EAAlC,CADQ,CAAvB;;AAGA,QAAIT,cAAc,CAACU,MAAnB,EAA2B;AACzB,WAAK,IAAIC,QAAT,IAAqBf,SAArB,EAAgC;AAC9B,YAAIgB,QAAQ,GAAG,IAAf;;AACA,aAAI,IAAIC,KAAR,IAAiBb,cAAjB,EAAiC;AAC/B,cAAI,OAAMW,QAAQ,CAACE,KAAD,CAAd,KAAyB,IAAzB,IAAiC,OAAMF,QAAQ,CAACE,KAAD,CAAd,KAAyB,EAA9D,EAAkE;AAChED,YAAAA,QAAQ,GAAG,KAAX;AACA;AACD;AACF;;AACD,YAAIA,QAAJ,EAAcb,QAAQ,CAACN,IAAT,CAAckB,QAAd;AACf;AACF;;AACD,UAAMG,aAAa,GAAGtB,kBAAkB,CAACuB,KAAnB,EAAtB;AACA,QAAID,aAAJ,EAAmB,MAAMA,aAAa,CAACd,cAAc,CAACU,MAAf,GAAwBX,QAAxB,GAAmCH,SAApC,EAA+CJ,kBAA/C,EAAmEK,GAAnE,EAAwEC,OAAxE,CAAnB;AACpB;;AAzBmB,CAAtB;AA4BA,SACEV,aADF","sourcesContent":["const RequiredMixin = {\n name: 'required-mixin',\n use: [],\n attached(): void {\n this.listPostProcessors.push(this.requiredResources.bind(this));\n },\n async requiredResources(resources: object[], listPostProcessors: Function[], div: HTMLElement, context: string): Promise<void> {\n const displays: any[] = [];\n const requiredFields = Array.from((this.element as Element).attributes).filter(attr => attr.name.startsWith('required-'))\n .map(attr => attr['name'].replace('required-', ''));\n\n if (requiredFields.length) {\n for (let resource of resources) {\n let hasProps = true;\n for(let field of requiredFields) {\n if (await resource[field] == null || await resource[field] == \"\") {\n hasProps = false;\n continue\n }\n }\n if (hasProps) displays.push(resource);\n }\n }\n const nextProcessor = listPostProcessors.shift();\n if (nextProcessor) await nextProcessor(requiredFields.length ? displays : resources, listPostProcessors, div, context);\n }\n}\n\nexport {\n RequiredMixin\n}\n"]}
@@ -1,149 +0,0 @@
1
- const SorterMixin = {
2
- name: 'sorter-mixin',
3
- use: [],
4
- attributes: {
5
- orderBy: {
6
- type: String,
7
- default: null
8
- },
9
- orderAsc: {
10
- type: String,
11
- default: null
12
- },
13
- orderDesc: {
14
- type: String,
15
- default: null
16
- },
17
- orderByRandom: {
18
- type: String,
19
- default: null
20
- },
21
- sortedBy: {
22
- type: String,
23
- default: null,
24
-
25
- callback(newValue) {
26
- // if we change search form, re-populate
27
- if (newValue && this.sortForm && newValue !== this.sortForm.getAttribute('id')) {
28
- this.sortForm = null;
29
- this.populate();
30
- }
31
- }
32
-
33
- }
34
- },
35
- initialState: {
36
- randomOrder: null
37
- },
38
-
39
- attached() {
40
- this.listPostProcessors.push(this.orderCallback.bind(this));
41
- },
42
-
43
- created() {
44
- this.randomOrder = [];
45
- },
46
-
47
- async sorterList() {
48
- if (!this.resource) return;
49
- this.empty();
50
- await this.populate();
51
- },
52
-
53
- linkSorterForm() {
54
- this.sortForm.addEventListener('formChange', () => {
55
- this.sorterList();
56
- });
57
- },
58
-
59
- async orderCallback(resources, listPostProcessors, div, context) {
60
- if (this.orderBy) this.orderAsc = this.orderBy; // retrocompatibility. remove in 0.15
61
-
62
- let sortingKey = '';
63
- let orderValueToSort = ''; // if order-asc or order-desc attribute
64
-
65
- if (this.orderAsc || this.orderDesc) {
66
- sortingKey = this.orderAsc || this.orderDesc;
67
- } // if sorted-by attribute (solid-form-search data used)
68
- else if (this.sortedBy) {
69
- const sortedBy = this.sortedBy;
70
-
71
- if (sortedBy != null) {
72
- if (!this.sortForm) {
73
- this.sortForm = document.getElementById(sortedBy);
74
- if (!this.sortForm) throw "#".concat(sortedBy, " is not in DOM");
75
- this.linkSorterForm();
76
- }
77
-
78
- if (!this.sortForm.component.value.field) {
79
- console.warn('The attribute field does not exist');
80
- } else {
81
- sortingKey = this.sortForm.component.value.field['value'];
82
- }
83
-
84
- const orderField = this.sortForm.component.value.order;
85
- orderValueToSort = orderField && orderField.value ? orderField.value : 'asc';
86
- }
87
- } // sorting data according to the defined value of sortingKey
88
-
89
-
90
- if (sortingKey) {
91
- let orderToSort = true; // set 'asc' by default
92
-
93
- if (this.orderDesc || orderValueToSort == "desc") orderToSort = false;
94
- resources = (await Promise.all(resources.map(async resource => ({
95
- sortingKey: await resource[sortingKey],
96
- // fetch sorting value
97
- proxy: resource // and keep proxy
98
-
99
- })))).sort(this.sortValuesByKey("sortingKey", orderToSort)) // sort this array
100
- .map(r => r.proxy); // re-create array
101
- } // if order-by-random attribute
102
- else if (this.isRandomSorted()) {
103
- resources = this.shuffleResources(resources); // shuffle resources
104
- }
105
-
106
- const nextProcessor = listPostProcessors.shift();
107
- if (nextProcessor) await nextProcessor(resources, listPostProcessors, div, context);
108
- },
109
-
110
- isRandomSorted() {
111
- return this.orderByRandom !== null;
112
- },
113
-
114
- sortValuesByKey(key, asc) {
115
- return function (a, b) {
116
- if (!a[key]) return 1;
117
- if (!b[key]) return -1;
118
- const varA = typeof a[key] === 'string' ? a[key].toUpperCase() : a[key];
119
- const varB = typeof b[key] === 'string' ? b[key].toUpperCase() : b[key];
120
- let comparison = 0;
121
- if (varA > varB) comparison = asc ? 1 : -1;else if (varA < varB) comparison = asc ? -1 : 1;
122
- return comparison;
123
- };
124
- },
125
-
126
- shuffleResources(array) {
127
- let currentIndex = array.length;
128
- let temporaryValue;
129
- let randomIndex;
130
-
131
- if (this.randomOrder.length !== array.length) {
132
- // if no random order existing
133
- this.randomOrder = [...Array(array.length).keys()]; // generate array of indexes
134
-
135
- while (0 !== currentIndex) {
136
- randomIndex = Math.floor(Math.random() * currentIndex);
137
- currentIndex -= 1;
138
- temporaryValue = this.randomOrder[currentIndex];
139
- this.randomOrder[currentIndex] = this.randomOrder[randomIndex];
140
- this.randomOrder[randomIndex] = temporaryValue;
141
- }
142
- }
143
-
144
- return this.randomOrder.map(i => array[i]); // rebuild array with random order
145
- }
146
-
147
- };
148
- export { SorterMixin };
149
- //# sourceMappingURL=sorterMixin.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["sorterMixin.ts"],"names":["SorterMixin","name","use","attributes","orderBy","type","String","default","orderAsc","orderDesc","orderByRandom","sortedBy","callback","newValue","sortForm","getAttribute","populate","initialState","randomOrder","attached","listPostProcessors","push","orderCallback","bind","created","sorterList","resource","empty","linkSorterForm","addEventListener","resources","div","context","sortingKey","orderValueToSort","document","getElementById","component","value","field","console","warn","orderField","order","orderToSort","Promise","all","map","proxy","sort","sortValuesByKey","r","isRandomSorted","shuffleResources","nextProcessor","shift","key","asc","a","b","varA","toUpperCase","varB","comparison","array","currentIndex","length","temporaryValue","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AAjB;AACA,aAAK/C,WAAL,CAAiB+C,YAAjB,IAAiC,KAAK/C,WAAL,CAAiBkD,WAAjB,CAAjC;AACA,aAAKlD,WAAL,CAAiBkD,WAAjB,IAAgCD,cAAhC;AACD;AACF;;AACD,WAAO,KAAKjD,WAAL,CAAiB6B,GAAjB,CAAsB2B,CAAD,IAAeV,KAAK,CAACU,CAAD,CAAzC,CAAP,CAd0C,CAcY;AACvD;;AAlIiB,CAApB;AAqIA,SACE1E,WADF","sourcesContent":["const SorterMixin = {\n name: 'sorter-mixin',\n use: [],\n attributes: {\n orderBy: {\n type: String,\n default: null\n },\n orderAsc: {\n type: String,\n default: null\n },\n orderDesc: {\n type: String,\n default: null\n },\n orderByRandom: {\n type: String,\n default: null\n },\n sortedBy: {\n type:String,\n default: null,\n callback(newValue: string) {\n // if we change search form, re-populate\n if (newValue && this.sortForm && newValue !== this.sortForm.getAttribute('id')) {\n this.sortForm = null;\n this.populate();\n }\n }\n }\n },\n initialState: {\n randomOrder: null\n },\n attached(): void {\n this.listPostProcessors.push(this.orderCallback.bind(this));\n },\n created(): void {\n this.randomOrder = [];\n },\n async sorterList(): Promise<void> {\n if (!this.resource) return;\n this.empty();\n await this.populate();\n },\n linkSorterForm() {\n this.sortForm.addEventListener('formChange', () => {\n this.sorterList();\n });\n },\n\n async orderCallback(resources: object[], listPostProcessors: Function[], div: HTMLElement, context: string) { \n if (this.orderBy) this.orderAsc = this.orderBy; // retrocompatibility. remove in 0.15\n let sortingKey = '';\n let orderValueToSort = '';\n\n // if order-asc or order-desc attribute\n if (this.orderAsc || this.orderDesc) {\n sortingKey = this.orderAsc || this.orderDesc;\n }\n // if sorted-by attribute (solid-form-search data used)\n else if (this.sortedBy) {\n const sortedBy = this.sortedBy;\n if (sortedBy != null) {\n if (!this.sortForm) {\n this.sortForm = document.getElementById(sortedBy);\n if (!this.sortForm) throw `#${sortedBy} is not in DOM`; \n this.linkSorterForm();\n }\n if (!this.sortForm.component.value.field) {\n console.warn('The attribute field does not exist')\n } else { \n sortingKey = this.sortForm.component.value.field['value'];\n }\n const orderField = this.sortForm.component.value.order;\n orderValueToSort = orderField && orderField.value ? orderField.value : 'asc';\n }\n }\n // sorting data according to the defined value of sortingKey\n if (sortingKey) {\n let orderToSort = true; // set 'asc' by default\n if (this.orderDesc || orderValueToSort == \"desc\") orderToSort = false;\n resources = (await Promise.all(resources.map(async (resource) => ({\n sortingKey: await resource[sortingKey], // fetch sorting value\n proxy: resource // and keep proxy\n }))))\n .sort(this.sortValuesByKey(\"sortingKey\", orderToSort)) // sort this array\n .map(r => r.proxy) // re-create array\n }\n // if order-by-random attribute\n else if (this.isRandomSorted()) {\n resources = this.shuffleResources(resources); // shuffle resources\n }\n\n const nextProcessor = listPostProcessors.shift();\n if(nextProcessor) await nextProcessor(resources, listPostProcessors, div, context);\n },\n isRandomSorted(): boolean {\n return this.orderByRandom !== null;\n },\n sortValuesByKey(key: string, asc: boolean): Function {\n return function (a: object, b: object): number {\n if (!a[key]) return 1;\n if (!b[key]) return -1;\n\n const varA = typeof a[key] === 'string' ? a[key].toUpperCase() : a[key];\n const varB = typeof b[key] === 'string' ? b[key].toUpperCase() : b[key];\n let comparison = 0;\n if (varA > varB) comparison = asc ? 1 : -1;\n else if (varA < varB) comparison = asc ? -1 : 1;\n\n return comparison;\n }\n },\n shuffleResources(array: object[]): object[] {\n let currentIndex = array.length;\n let temporaryValue: object;\n let randomIndex: number;\n if (this.randomOrder.length !== array.length) { // if no random order existing\n this.randomOrder = [ ...Array(array.length).keys() ]; // generate array of indexes\n while (0 !== currentIndex) {\n randomIndex = Math.floor(Math.random() * currentIndex);\n currentIndex -= 1;\n temporaryValue = this.randomOrder[currentIndex];\n this.randomOrder[currentIndex] = this.randomOrder[randomIndex];\n this.randomOrder[randomIndex] = temporaryValue;\n }\n }\n return this.randomOrder.map((i: number) => array[i]); // rebuild array with random order\n }\n}\n\nexport {\n SorterMixin\n}"]}
@@ -1,102 +0,0 @@
1
- import { store } from '../libs/store/store.js';
2
- import { AttributeBinderMixin } from './attributeBinderMixin.js';
3
- import { ContextMixin } from './contextMixin.js';
4
- const StoreMixin = {
5
- name: 'store-mixin',
6
- use: [AttributeBinderMixin, ContextMixin],
7
- attributes: {
8
- noRender: {
9
- type: String,
10
- default: null,
11
- callback: function (value) {
12
- if (value === null) this.fetchData(this.dataSrc);
13
- }
14
- },
15
- dataSrc: {
16
- type: String,
17
- default: null,
18
- callback: async function (value) {
19
- if (this.noRender === null) await this.fetchData(value);
20
- }
21
- },
22
- loaderId: {
23
- type: String,
24
- default: ''
25
- },
26
- nestedField: {
27
- type: String,
28
- default: null
29
- }
30
- },
31
- initialState: {
32
- resourceId: null,
33
- subscription: null
34
- },
35
-
36
- created() {
37
- if (this.element.closest('[no-render]')) this.noRender = ''; // if embedded in no-render, apply no-render to himself
38
- },
39
-
40
- detached() {
41
- if (this.subscription) PubSub.unsubscribe(this.subscription);
42
- },
43
-
44
- get resource() {
45
- return this.resourceId ? store.get(this.resourceId) : null;
46
- },
47
-
48
- get loader() {
49
- return this.loaderId ? document.getElementById(this.loaderId) : null;
50
- },
51
-
52
- async fetchData(value) {
53
- this.empty();
54
- if (this.subscription) PubSub.unsubscribe(this.subscription);
55
- if (!value || value == "undefined") return;
56
- this.resourceId = value;
57
-
58
- if (this.nestedField) {
59
- const resource = await store.getData(value, this.context);
60
- const nestedResource = resource ? await resource[this.nestedField] : null;
61
- this.resourceId = nestedResource ? nestedResource['@id'] : null;
62
- if (!this.resourceId) throw "Error: the key \"".concat(this.nestedField, "\" does not exist on the resource");
63
- }
64
-
65
- this.updateNavigateSubscription();
66
- this.subscription = PubSub.subscribe(this.resourceId, this.updateDOM.bind(this));
67
- await store.getData(this.resourceId, this.context);
68
- this.updateDOM();
69
- },
70
-
71
- toggleLoaderHidden(toggle) {
72
- if (this.loader) this.loader.toggleAttribute('hidden', toggle);
73
- },
74
-
75
- updateNavigateSubscription() {},
76
-
77
- async updateDOM() {
78
- this.toggleLoaderHidden(false); // brings a loader out if the attribute is set
79
-
80
- this.empty();
81
- await this.replaceAttributesData();
82
- await this.populate();
83
- setTimeout(() => // Brings the dispatchEvent at the end of the queue
84
- this.element.dispatchEvent(new CustomEvent('populate', {
85
- detail: {
86
- resource: {
87
- "@id": this.dataSrc
88
- }
89
- }
90
- })));
91
- this.toggleLoaderHidden(true);
92
- },
93
-
94
- empty() {},
95
-
96
- update() {
97
- if (this.noRender === null) this.updateDOM();
98
- }
99
-
100
- };
101
- export { StoreMixin };
102
- //# sourceMappingURL=storeMixin.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["storeMixin.ts"],"names":["store","AttributeBinderMixin","ContextMixin","StoreMixin","name","use","attributes","noRender","type","String","default","callback","value","fetchData","dataSrc","loaderId","nestedField","initialState","resourceId","subscription","created","element","closest","detached","PubSub","unsubscribe","resource","get","loader","document","getElementById","empty","getData","context","nestedResource","updateNavigateSubscription","subscribe","updateDOM","bind","toggleLoaderHidden","toggle","toggleAttribute","replaceAttributesData","populate","setTimeout","dispatchEvent","CustomEvent","detail","update"],"mappings":"AAAA,SAASA,KAAT,QAAsB,qBAAtB;AACA,SAASC,oBAAT,QAAqC,wBAArC;AAEA,SAASC,YAAT,QAA6B,gBAA7B;AAEA,MAAMC,UAAU,GAAG;AACjBC,EAAAA,IAAI,EAAE,aADW;AAEjBC,EAAAA,GAAG,EAAE,CAACJ,oBAAD,EAAuBC,YAAvB,CAFY;AAGjBI,EAAAA,UAAU,EAAE;AACVC,IAAAA,QAAQ,EAAE;AACRC,MAAAA,IAAI,EAAEC,MADE;AAERC,MAAAA,OAAO,EAAE,IAFD;AAGRC,MAAAA,QAAQ,EAAE,UAAUC,KAAV,EAA0B;AAClC,YAAIA,KAAK,KAAK,IAAd,EAAoB,KAAKC,SAAL,CAAe,KAAKC,OAApB;AACrB;AALO,KADA;AAQVA,IAAAA,OAAO,EAAE;AACPN,MAAAA,IAAI,EAAEC,MADC;AAEPC,MAAAA,OAAO,EAAE,IAFF;AAGPC,MAAA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yB,kBAAL,CAAwB,IAAxB;AACD,GA3EgB;;AA4EjBR,EAAAA,KAAK,GAAQ,CACZ,CA7EgB;;AA8EjBiB,EAAAA,MAAM,GAAG;AACP,QAAI,KAAKzC,QAAL,KAAkB,IAAtB,EAA4B,KAAK8B,SAAL;AAC7B;;AAhFgB,CAAnB;AAmFA,SACElC,UADF","sourcesContent":["import { store } from '../libs/store/store';\nimport { AttributeBinderMixin } from './attributeBinderMixin';\nimport type { Resource } from './interfaces';\nimport { ContextMixin } from './contextMixin';\n\nconst StoreMixin = {\n name: 'store-mixin',\n use: [AttributeBinderMixin, ContextMixin],\n attributes: {\n noRender: {\n type: String,\n default: null,\n callback: function (value: boolean) {\n if (value === null) this.fetchData(this.dataSrc);\n }\n },\n dataSrc: {\n type: String,\n default: null,\n callback: async function (value: string) {\n if (this.noRender === null) await this.fetchData(value);\n },\n },\n loaderId: {\n type: String,\n default: ''\n },\n nestedField: {\n type: String,\n default: null\n },\n },\n initialState: {\n resourceId: null,\n subscription: null,\n },\n created() {\n if (this.element.closest('[no-render]')) this.noRender = ''; // if embedded in no-render, apply no-render to himself\n },\n detached() {\n if (this.subscription) PubSub.unsubscribe(this.subscription);\n },\n get resource(): Resource|null{\n return this.resourceId ? store.get(this.resourceId) : null;\n },\n get loader(): HTMLElement | null {\n return this.loaderId ? document.getElementById(this.loaderId) : null;\n },\n async fetchData(value: string) {\n this.empty();\n if (this.subscription) PubSub.unsubscribe(this.subscription);\n if (!value || value == \"undefined\") return;\n\n this.resourceId = value;\n\n if (this.nestedField) {\n const resource = await store.getData(value, this.context);\n const nestedResource = resource ? await resource[this.nestedField] : null;\n this.resourceId = nestedResource ? nestedResource['@id'] : null;\n if (!this.resourceId) throw `Error: the key \"${this.nestedField}\" does not exist on the resource`\n }\n this.updateNavigateSubscription();\n\n this.subscription = PubSub.subscribe(this.resourceId, this.updateDOM.bind(this));\n await store.getData(this.resourceId, this.context);\n this.updateDOM();\n },\n toggleLoaderHidden(toggle: boolean): void {\n if (this.loader) this.loader.toggleAttribute('hidden', toggle);\n },\n updateNavigateSubscription() { },\n async updateDOM(): Promise<void> {\n this.toggleLoaderHidden(false); // brings a loader out if the attribute is set\n this.empty();\n await this.replaceAttributesData();\n await this.populate();\n setTimeout(() => ( // Brings the dispatchEvent at the end of the queue\n this.element.dispatchEvent(new CustomEvent('populate', { detail: { resource: {\"@id\": this.dataSrc} } })))\n );\n this.toggleLoaderHidden(true);\n },\n empty():void {\n },\n update() {\n if (this.noRender === null) this.updateDOM();\n }\n};\n\nexport {\n StoreMixin\n}"]}
@@ -1,68 +0,0 @@
1
- import { store } from "../libs/store/store.js";
2
- const TranslationMixin = {
3
- name: 'translation-mixin',
4
- use: [],
5
- initialState: {
6
- translationData: {}
7
- },
8
-
9
- created() {
10
- this.getLang();
11
- },
12
-
13
- /**
14
- * Returns the translation module
15
- * @param langCode - string: language needed in 2 char
16
- * @returns - object: {key: translation}
17
- */
18
- async getTranslationModule(langCode) {
19
- const translationsModules = {
20
- // define modules in a static way, snowpack does not support dynamic strings here
21
- en: () => import("../locales/en.json.proxy.js"),
22
- fr: () => import("../locales/fr.json.proxy.js")
23
- };
24
-
25
- if (!translationsModules[langCode]) {
26
- // set default to EN if the file does not exist
27
- console.warn("".concat(langCode, ".json translation file may not exist, English is setted by default"));
28
- langCode = 'en';
29
- }
30
-
31
- const module = await translationsModules[langCode]();
32
- return module.default;
33
- },
34
-
35
- /**
36
- * Loads the right translation file and reload the component
37
- */
38
- getLang() {
39
- const languageStorage = store._getLanguage();
40
-
41
- if (languageStorage) {
42
- if (window.fetchTranslationPromise === undefined) {
43
- // if translation data are not already fetched
44
- window.fetchTranslationPromise = this.getTranslationModule(languageStorage);
45
- }
46
-
47
- window.fetchTranslationPromise.then(res => {
48
- if (res) {
49
- this.translationData = res; // stock data in object passed to traduction method below
50
-
51
- this.update(); // update the rendering in components and widgets
52
- }
53
- });
54
- }
55
- },
56
-
57
- /**
58
- * Returns translation for a given key
59
- * @param tradKey - string: key
60
- * @returns - string: translation
61
- */
62
- t(tradKey) {
63
- return this.translationData[tradKey] || '';
64
- }
65
-
66
- };
67
- export { TranslationMixin };
68
- //# sourceMappingURL=translationMixin.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["translationMixin.ts"],"names":["store","TranslationMixin","name","use","initialState","translationData","created","getLang","getTranslationModule","langCode","translationsModules","en","fr","console","warn","module","default","languageStorage","_getLanguage","window","fetchTranslationPromise","undefined","then","res","update","t","tradKey"],"mappings":"AAAA,SAASA,KAAT,QAAsB,qBAAtB;AAEA,MAAMC,gBAAgB,GAAG;AACvBC,EAAAA,IAAI,EAAE,mBADiB;AAEvBC,EAAAA,GAAG,EAAE,EAFkB;AAGvBC,EAAAA,YAAY,EAAE;AACZC,IAAAA,eAAe,EAAC;AADJ,GAHS;;AAMvBC,EAAAA,OAAO,GAAG;AACR,SAAKC,OAAL;AACD,GARsB;;AASvB;AACF;AACA;AACA;AACA;AACE,QAAMC,oBAAN,CAA2BC,QAA3B,EAA6C;AAC3C,UAAMC,mBAAmB,GAAG;AAAE;AAC5BC,MAAAA,EAAE,EAAE,MAAM,OAAO,oBAAP,CADgB;AAE1BC,MAAAA,EAAE,EAAE,MAAM,OAAO,oBAAP;AAFgB,KAA5B;;AAIA,QAAI,CAACF,mBAAmB,CAACD,QAAD,CAAxB,EAAoC;AAAE;AACpCI,MAAAA,OAAO,CAACC,IAAR,WAAgBL,QAAhB;AACAA,MAAAA,QAAQ,GAAG,IAAX;AACD;;AACD,UAAMM,MAAM,GAAG,MAAML,mBAAmB,CAACD,QAAD,CAAnB,EAArB;AACA,WAAOM,MAAM,CAACC,OAAd;AACD,GAzBsB;;AA0BvB;AACF;AACA;AACET,EAAAA,OAAO,GAAG;AACR,UAAMU,eAAe,GAAGjB,KAAK,CAACkB,YAAN,EAAxB;;AACA,QAAGD,eAAH,EAAoB;AAClB,UAAIE,MAAM,CAACC,uBAAP,KAAmCC,SAAvC,EAAkD;AAAE;AAClDF,QAAAA,MAAM,CAACC,uBAAP,GAAiC,KAAKZ,oBAAL,CAA0BS,eAA1B,CAAjC;AACD;;AACDE,MAAAA,MAAM,CAACC,uBAAP,CAA+BE,IAA/B,CAAoCC,GAAG,IAAI;AACzC,YAAIA,GAAJ,EAAS;AACP,eAAKlB,eAAL,GAAuBkB,GAAvB,CADO,CACqB;;AAC5B,eAAKC,MAAL,GAFO,CAEQ;AAChB;AACF,OALD;AAMD;AACF,GA1CsB;;AA2CvB;AACF;AACA;AACA;AACA;AACEC,EAAAA,CAAC,CAACC,OAAD,EAAkB;AACjB,WAAO,KAAKrB,eAAL,CAAqBqB,OAArB,KAAiC,EAAxC;AACD;;AAlDsB,CAAzB;AAqDA,SACEzB,gBADF","sourcesContent":["import { store } from \"../libs/store/store\";\n\nconst TranslationMixin = {\n name: 'translation-mixin',\n use: [],\n initialState: {\n translationData:{}\n },\n created() {\n this.getLang();\n },\n /**\n * Returns the translation module\n * @param langCode - string: language needed in 2 char\n * @returns - object: {key: translation}\n */\n async getTranslationModule(langCode: string) {\n const translationsModules = { // define modules in a static way, snowpack does not support dynamic strings here\n en: () => import('../locales/en.json'),\n fr: () => import('../locales/fr.json'),\n };\n if (!translationsModules[langCode]) { // set default to EN if the file does not exist\n console.warn(`${langCode}.json translation file may not exist, English is setted by default`);\n langCode = 'en';\n }\n const module = await translationsModules[langCode]();\n return module.default;\n },\n /**\n * Loads the right translation file and reload the component\n */\n getLang() {\n const languageStorage = store._getLanguage();\n if(languageStorage) {\n if (window.fetchTranslationPromise === undefined) { // if translation data are not already fetched\n window.fetchTranslationPromise = this.getTranslationModule(languageStorage);\n }\n window.fetchTranslationPromise.then(res => {\n if (res) {\n this.translationData = res; // stock data in object passed to traduction method below\n this.update(); // update the rendering in components and widgets\n }\n })\n }\n },\n /**\n * Returns translation for a given key\n * @param tradKey - string: key\n * @returns - string: translation\n */\n t(tradKey: string) {\n return this.translationData[tradKey] || '';\n }\n}\n\nexport {\n TranslationMixin\n}"]}
@@ -1,113 +0,0 @@
1
- function _templateObject3() {
2
- const data = _taggedTemplateLiteral(["\n <p>", "</p>\n "]);
3
-
4
- _templateObject3 = function () {
5
- return data;
6
- };
7
-
8
- return data;
9
- }
10
-
11
- function _templateObject2() {
12
- const data = _taggedTemplateLiteral(["\n <", " value=", "></", ">\n "]);
13
-
14
- _templateObject2 = function () {
15
- return data;
16
- };
17
-
18
- return data;
19
- }
20
-
21
- function _templateObject() {
22
- const data = _taggedTemplateLiteral(["\n <dialog id=\"", "\">\n ", "\n <div>\n <button\n @click=", " \n class=", "\n >\n ", "\n </button>\n <button\n @click=", "\n class=", "\n >\n ", "\n </button>\n </div>\n </dialog>\n "]);
23
-
24
- _templateObject = function () {
25
- return data;
26
- };
27
-
28
- return data;
29
- }
30
-
31
- function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
32
-
33
- import dialogPolyfill from '../_snowpack/pkg/dialog-polyfill.js';
34
- import { html } from '../_snowpack/pkg/lit-html.js';
35
- import { ifDefined } from '../_snowpack/pkg/lit-html/directives/if-defined.js';
36
- import { uniqID } from '../libs/helpers.js';
37
- import { TranslationMixin } from './translationMixin.js';
38
- import { preHTML } from '../libs/lit-helpers.js';
39
- const ValidationMixin = {
40
- name: 'validation-mixin',
41
- use: [TranslationMixin],
42
- attributes: {
43
- confirmationMessage: {
44
- type: String,
45
- default: null
46
- },
47
- confirmationType: {
48
- type: String,
49
- default: null
50
- },
51
- confirmationSubmitText: {
52
- type: String,
53
- default: null
54
- },
55
- confirmationCancelText: {
56
- type: String,
57
- default: null
58
- },
59
- confirmationSubmitClass: {
60
- type: String,
61
- default: undefined
62
- },
63
- confirmationCancelClass: {
64
- type: String,
65
- default: undefined
66
- },
67
- confirmationWidget: {
68
- type: String,
69
- default: undefined
70
- }
71
- },
72
-
73
- created() {
74
- this.dialogID = uniqID();
75
- },
76
-
77
- showModal() {
78
- var dialog = document.getElementById(this.dialogID);
79
- dialogPolyfill.registerDialog(dialog);
80
- return dialog.showModal();
81
- },
82
-
83
- performAction() {
84
- // Console warning if conf-type attr not filled AND conf-message filled
85
- if (this.element.hasAttribute('confirmation-message') && !this.confirmationType) console.warn('confirmation-type attribute is missing.'); // Data directly submitted OR confirm dialog modal displayed
86
-
87
- if (!this.confirmationType || this.confirmationType == "confirm" && confirm(this.confirmationMessage || this.t("validation.message"))) this.validateModal(); // Customisable dialog modal opened
88
-
89
- if (this.confirmationType == "dialog") {
90
- this.showModal();
91
- }
92
- },
93
-
94
- getModalDialog() {
95
- if (this.confirmationType == 'dialog') {
96
- const quitDialog = () => {
97
- var dialog = document.getElementById(this.dialogID);
98
- if (dialog == null) return;
99
- dialog.close();
100
- };
101
-
102
- const confirmChoice = () => {
103
- this.validateModal();
104
- quitDialog();
105
- };
106
-
107
- return html(_templateObject(), this.dialogID, this.confirmationWidget ? preHTML(_templateObject2(), this.confirmationWidget, this.resourceId, this.confirmationWidget) : html(_templateObject3(), this.confirmationMessage || this.t("validation.message")), confirmChoice, ifDefined(this.confirmationSubmitClass), this.confirmationSubmitText || this.t("validation.submit-text"), quitDialog, ifDefined(this.confirmationCancelClass), this.confirmationCancelText || this.t("validation.cancel-text"));
108
- } else return '';
109
- }
110
-
111
- };
112
- export { ValidationMixin };
113
- //# sourceMappingURL=validationMixin.js.map