@startinblox/core 0.19.0-beta.2 → 0.19.0-beta.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (166) hide show
  1. package/dist/{_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.css → assets/MarkerCluster-614dea0a.css} +0 -0
  2. package/dist/{_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.Default.css → assets/MarkerCluster.Default-61258232.css} +0 -0
  3. package/dist/assets/en-e53105c5.js +14 -0
  4. package/dist/assets/en-e53105c5.js.map +1 -0
  5. package/dist/assets/fr-a7fcdb64.js +14 -0
  6. package/dist/assets/fr-a7fcdb64.js.map +1 -0
  7. package/dist/{_snowpack/pkg/fusejs.js → assets/helpers-411e08e4.js} +499 -454
  8. package/dist/assets/helpers-411e08e4.js.map +1 -0
  9. package/dist/{_snowpack/pkg/leaflet/dist/leaflet.css → assets/leaflet-3c081932.css} +3 -3
  10. package/dist/helpers.js +22 -0
  11. package/dist/helpers.js.map +1 -0
  12. package/dist/index.js +54873 -48
  13. package/dist/index.js.map +1 -0
  14. package/package.json +7 -22
  15. package/dist/_snowpack/pkg/autolinker.js +0 -4429
  16. package/dist/_snowpack/pkg/autolinker.js.map +0 -1
  17. package/dist/_snowpack/pkg/common/_baseUnary-d2677655.js +0 -353
  18. package/dist/_snowpack/pkg/common/_baseUnary-d2677655.js.map +0 -1
  19. package/dist/_snowpack/pkg/common/_commonjsHelpers-0597c316.js +0 -26
  20. package/dist/_snowpack/pkg/common/_commonjsHelpers-0597c316.js.map +0 -1
  21. package/dist/_snowpack/pkg/common/decode-26fbf385.js +0 -185
  22. package/dist/_snowpack/pkg/common/decode-26fbf385.js.map +0 -1
  23. package/dist/_snowpack/pkg/common/lit-html-3647afce.js +0 -1104
  24. package/dist/_snowpack/pkg/common/lit-html-3647afce.js.map +0 -1
  25. package/dist/_snowpack/pkg/delta-markdown-for-quill.js +0 -26198
  26. package/dist/_snowpack/pkg/delta-markdown-for-quill.js.map +0 -1
  27. package/dist/_snowpack/pkg/dialog-polyfill.js +0 -826
  28. package/dist/_snowpack/pkg/dialog-polyfill.js.map +0 -1
  29. package/dist/_snowpack/pkg/fusejs.js.map +0 -1
  30. package/dist/_snowpack/pkg/import-map.json +0 -25
  31. package/dist/_snowpack/pkg/jsonld-context-parser.js +0 -836
  32. package/dist/_snowpack/pkg/jsonld-context-parser.js.map +0 -1
  33. package/dist/_snowpack/pkg/jsonld.js +0 -11760
  34. package/dist/_snowpack/pkg/jsonld.js.map +0 -1
  35. package/dist/_snowpack/pkg/leaflet/dist/leaflet.css.proxy.js +0 -10
  36. package/dist/_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.Default.css.proxy.js +0 -10
  37. package/dist/_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.css.proxy.js +0 -10
  38. package/dist/_snowpack/pkg/lit-html/directives/if-defined.js +0 -39
  39. package/dist/_snowpack/pkg/lit-html/directives/if-defined.js.map +0 -1
  40. package/dist/_snowpack/pkg/lit-html/directives/unsafe-html.js +0 -48
  41. package/dist/_snowpack/pkg/lit-html/directives/unsafe-html.js.map +0 -1
  42. package/dist/_snowpack/pkg/lit-html/directives/until.js +0 -87
  43. package/dist/_snowpack/pkg/lit-html/directives/until.js.map +0 -1
  44. package/dist/_snowpack/pkg/lit-html.js +0 -94
  45. package/dist/_snowpack/pkg/lit-html.js.map +0 -1
  46. package/dist/_snowpack/pkg/markdown-it-link-attributes.js +0 -68
  47. package/dist/_snowpack/pkg/markdown-it-link-attributes.js.map +0 -1
  48. package/dist/_snowpack/pkg/markdown-it.js +0 -11307
  49. package/dist/_snowpack/pkg/markdown-it.js.map +0 -1
  50. package/dist/_snowpack/pkg/quill/dist/quill.snow.css.proxy.js +0 -10
  51. package/dist/_snowpack/pkg/quill-delta-to-markdown.js +0 -971
  52. package/dist/_snowpack/pkg/quill-delta-to-markdown.js.map +0 -1
  53. package/dist/_snowpack/pkg/quill.js +0 -14441
  54. package/dist/_snowpack/pkg/quill.js.map +0 -1
  55. package/dist/_snowpack/pkg/slim-select.js +0 -714
  56. package/dist/_snowpack/pkg/slim-select.js.map +0 -1
  57. package/dist/_snowpack/pkg/tui-calendar/dist/tui-calendar.css +0 -1149
  58. package/dist/_snowpack/pkg/tui-calendar/dist/tui-calendar.css.proxy.js +0 -10
  59. package/dist/_snowpack/pkg/tui-calendar.js +0 -46503
  60. package/dist/_snowpack/pkg/tui-calendar.js.map +0 -1
  61. package/dist/components/solid-ac-checker.js +0 -45
  62. package/dist/components/solid-calendar.js +0 -66
  63. package/dist/components/solid-delete.js +0 -96
  64. package/dist/components/solid-display.js +0 -150
  65. package/dist/components/solid-form-search.js +0 -173
  66. package/dist/components/solid-form.js +0 -257
  67. package/dist/components/solid-lang.js +0 -35
  68. package/dist/components/solid-map.js +0 -204
  69. package/dist/components/solid-table.js +0 -181
  70. package/dist/components/solid-widget.js +0 -72
  71. package/dist/import.css +0 -4
  72. package/dist/libs/Component.js +0 -13
  73. package/dist/libs/ComponentFactory.js +0 -165
  74. package/dist/libs/Compositor.js +0 -96
  75. package/dist/libs/Sib.js +0 -44
  76. package/dist/libs/filter.js +0 -184
  77. package/dist/libs/helpers.js +0 -185
  78. package/dist/libs/interfaces.js +0 -6
  79. package/dist/libs/lit-helpers.js +0 -139
  80. package/dist/libs/polyfills.js +0 -35
  81. package/dist/libs/store/custom-getter.js +0 -313
  82. package/dist/libs/store/server-pagination.js +0 -19
  83. package/dist/libs/store/server-search.js +0 -32
  84. package/dist/libs/store/store.js +0 -560
  85. package/dist/locales/en.json +0 -10
  86. package/dist/locales/en.json.proxy.js +0 -2
  87. package/dist/locales/fr.json +0 -10
  88. package/dist/locales/fr.json.proxy.js +0 -2
  89. package/dist/mixins/attributeBinderMixin.js +0 -113
  90. package/dist/mixins/contextMixin.js +0 -26
  91. package/dist/mixins/counterMixin.js +0 -54
  92. package/dist/mixins/federationMixin.js +0 -57
  93. package/dist/mixins/filterMixin.js +0 -152
  94. package/dist/mixins/grouperMixin.js +0 -73
  95. package/dist/mixins/highlighterMixin.js +0 -36
  96. package/dist/mixins/interfaces.js +0 -6
  97. package/dist/mixins/listMixin.js +0 -116
  98. package/dist/mixins/nextMixin.js +0 -23
  99. package/dist/mixins/paginateMixin.js +0 -97
  100. package/dist/mixins/requiredMixin.js +0 -38
  101. package/dist/mixins/serverPaginationMixin.js +0 -122
  102. package/dist/mixins/sorterMixin.js +0 -131
  103. package/dist/mixins/storeMixin.js +0 -139
  104. package/dist/mixins/translationMixin.js +0 -58
  105. package/dist/mixins/validationMixin.js +0 -95
  106. package/dist/mixins/widgetMixin.js +0 -364
  107. package/dist/new-widgets/attributeMixins/actionMixin.js +0 -13
  108. package/dist/new-widgets/attributeMixins/blankMixin.js +0 -7
  109. package/dist/new-widgets/attributeMixins/booleanMixin.js +0 -7
  110. package/dist/new-widgets/attributeMixins/index.js +0 -19
  111. package/dist/new-widgets/attributeMixins/mailtoMixin.js +0 -7
  112. package/dist/new-widgets/attributeMixins/multipleMixin.js +0 -27
  113. package/dist/new-widgets/attributeMixins/numberMixin.js +0 -7
  114. package/dist/new-widgets/attributeMixins/placeholderMixin.js +0 -16
  115. package/dist/new-widgets/attributeMixins/telMixin.js +0 -7
  116. package/dist/new-widgets/baseWidgetMixin.js +0 -109
  117. package/dist/new-widgets/callbackMixins/autocompletionMixin.js +0 -96
  118. package/dist/new-widgets/callbackMixins/index.js +0 -7
  119. package/dist/new-widgets/callbackMixins/richtextMixin.js +0 -37
  120. package/dist/new-widgets/callbackMixins/slimselect.css.proxy.js +0 -10
  121. package/dist/new-widgets/interfaces.js +0 -1
  122. package/dist/new-widgets/new-widget-factory.js +0 -91
  123. package/dist/new-widgets/templateAdditionMixins/addableMixin.js +0 -26
  124. package/dist/new-widgets/templateAdditionMixins/index.js +0 -13
  125. package/dist/new-widgets/templateAdditionMixins/labelLastMixin.js +0 -16
  126. package/dist/new-widgets/templateAdditionMixins/labelMixin.js +0 -18
  127. package/dist/new-widgets/templates/defaultTemplatesDirectory.js +0 -29
  128. package/dist/new-widgets/templates/displayTemplatesDirectory.js +0 -54
  129. package/dist/new-widgets/templates/formTemplatesDirectory.js +0 -423
  130. package/dist/new-widgets/templates/groupTemplatesDirectory.js +0 -11
  131. package/dist/new-widgets/templates/index.js +0 -6
  132. package/dist/new-widgets/templates/setTemplatesDirectory.js +0 -16
  133. package/dist/new-widgets/templatesDependencies/altMixin.js +0 -12
  134. package/dist/new-widgets/templatesDependencies/editableMixin.js +0 -60
  135. package/dist/new-widgets/templatesDependencies/filterRangeFormMixin.js +0 -34
  136. package/dist/new-widgets/templatesDependencies/formCheckboxMixin.js +0 -10
  137. package/dist/new-widgets/templatesDependencies/formCheckboxesMixin.js +0 -41
  138. package/dist/new-widgets/templatesDependencies/formDropdownMixin.js +0 -59
  139. package/dist/new-widgets/templatesDependencies/formFileMixin.js +0 -82
  140. package/dist/new-widgets/templatesDependencies/formLengthMixin.js +0 -18
  141. package/dist/new-widgets/templatesDependencies/formMinMaxMixin.js +0 -18
  142. package/dist/new-widgets/templatesDependencies/formMixin.js +0 -56
  143. package/dist/new-widgets/templatesDependencies/formNumberMixin.js +0 -10
  144. package/dist/new-widgets/templatesDependencies/formRadioMixin.js +0 -12
  145. package/dist/new-widgets/templatesDependencies/formStepMixin.js +0 -12
  146. package/dist/new-widgets/templatesDependencies/linkTextMixin.js +0 -13
  147. package/dist/new-widgets/templatesDependencies/multipleFormMixin.js +0 -125
  148. package/dist/new-widgets/templatesDependencies/multipleselectFormMixin.js +0 -74
  149. package/dist/new-widgets/templatesDependencies/patternMixin.js +0 -18
  150. package/dist/new-widgets/templatesDependencies/rangeMixin.js +0 -100
  151. package/dist/new-widgets/templatesDependencies/setMixin.js +0 -9
  152. package/dist/new-widgets/templatesDependencies/valueRichtextMixin.js +0 -9
  153. package/dist/new-widgets/valueTransformationMixins/autolinkMixin.js +0 -14
  154. package/dist/new-widgets/valueTransformationMixins/dateMixin.js +0 -29
  155. package/dist/new-widgets/valueTransformationMixins/dateTimeMixin.js +0 -12
  156. package/dist/new-widgets/valueTransformationMixins/index.js +0 -15
  157. package/dist/new-widgets/valueTransformationMixins/markdownMixin.js +0 -30
  158. package/dist/new-widgets/valueTransformationMixins/multilineMixin.js +0 -13
  159. package/dist/new-widgets/valueTransformationMixins/oembedMixin.js +0 -21
  160. package/dist/solid-template-element.js +0 -144
  161. package/dist/style/default-theme.css.proxy.js +0 -10
  162. package/dist/widgets/baseWidget.js +0 -267
  163. package/dist/widgets/widget-factory.js +0 -20
  164. /package/dist/{style/default-theme.css → assets/default-theme-d0f20a8a.css} +0 -0
  165. /package/dist/{_snowpack/pkg/quill/dist/quill.snow.css → assets/quill.snow-8f222e44.css} +0 -0
  166. /package/dist/{new-widgets/callbackMixins/slimselect.css → assets/slimselect-43e3ebc8.css} +0 -0
@@ -1,185 +0,0 @@
1
- import Fuse from "../_snowpack/pkg/fusejs.js";
2
- function uniqID() {
3
- return '_' + (Math.random() * Math.pow(36, 20)).toString(36).slice(0, 10);
4
- }
5
- function stringToDom(html) {
6
- const template = document.createElement('template');
7
- template.innerHTML = html;
8
- return template.content;
9
- }
10
- async function evalTemplateString(str, variables = {}) {
11
- const keys = Object.keys(variables);
12
- const values = keys.map(key => variables[key]);
13
- try {
14
- const AsyncFunction = Object.getPrototypeOf(async function () {}).constructor;
15
- const func = AsyncFunction.call(null, ...keys, 'return `' + str + '`');
16
- return await func(...values);
17
- } catch (e) {
18
- console.log(e);
19
- throw new SyntaxError('`' + str + '`');
20
- }
21
- }
22
- function importCSS(...stylesheets) {
23
- const linksElements = [];
24
- for (let url of stylesheets) {
25
- url = relativeSource(url);
26
- let link = Array.from(document.head.querySelectorAll('link')).find(link => link.href === url);
27
- if (link) return link;
28
- link = document.createElement('link');
29
- link.rel = 'stylesheet';
30
- link.href = url;
31
- document.head.appendChild(link);
32
- linksElements.push(link);
33
- }
34
- ;
35
- return linksElements;
36
- }
37
- function importJS(...plugins) {
38
- return plugins.map(url => {
39
- url = new URL(url, document.baseURI).href;
40
- let script = Array.from(document.querySelectorAll('script')).find(script => script.src === url);
41
- if (script) return script;
42
- script = document.createElement('script');
43
- script.src = url;
44
- document.head.appendChild(script);
45
- return script;
46
- });
47
- }
48
- function relativeSource(source) {
49
- if (!source.match(/^\..?\//)) return new URL(source, document.baseURI).href;
50
- const e = new Error();
51
- if (!e.stack) return source;
52
- const f2 = e.stack.split('\n').filter(l => l.includes(':'))[2];
53
- let line = f2.match(/[a-z]+:.*$/);
54
- if (!line) return source;
55
- const calledFile = line[0].replace(/(\:[0-9]+){2}\)?$/, '');
56
- source = new URL(source, calledFile).href;
57
- return source;
58
- }
59
- function loadScript(source) {
60
- source = relativeSource(source);
61
- return new Promise(resolve => {
62
- var script = document.createElement('script');
63
- var head = document.querySelector('head');
64
- script.async = true;
65
- script.onload = () => setTimeout(resolve, 0);
66
- script.src = source;
67
- if (head) head.appendChild(script);
68
- });
69
- }
70
- function domIsReady() {
71
- return new Promise(function (resolve) {
72
- if (document.readyState === 'complete') {
73
- resolve();
74
- } else {
75
- document.addEventListener('DOMContentLoaded', () => resolve());
76
- }
77
- });
78
- }
79
- function setDeepProperty(obj, path, value) {
80
- const name = path.shift();
81
- if (name) {
82
- if (!(name in obj)) obj[name] = {};
83
- if (path.length) setDeepProperty(obj[name], path, value);else obj[name] = value;
84
- }
85
- }
86
- function parseFieldsString(fields) {
87
- let fieldsArray;
88
-
89
- // remove all sets from fields
90
- while (fields.indexOf('(') > 0) {
91
- let firstBracket = fields.indexOf('(');
92
- let noset = fields.substring(firstBracket, findClosingBracketMatchIndex(fields, firstBracket) + 1);
93
- fields = fields.replace(noset, '');
94
- }
95
- const re = /((^\s*|,)\s*)(("(\\"|[^"])*")|('(\\'|[^'])*')|[^,]*)/gm; // match , not inside quotes
96
- fieldsArray = fields.match(re) || []; // separate fields
97
- if (!fieldsArray) return [];
98
- return fieldsArray.map(a => a.replace(/^[\s,]+/, '')); // remove commas and spaces
99
- }
100
-
101
- function findClosingBracketMatchIndex(str, pos) {
102
- if (str[pos] != '(') throw new Error("No '(' at index " + pos);
103
- let depth = 1;
104
- for (let i = pos + 1; i < str.length; i++) {
105
- switch (str[i]) {
106
- case '(':
107
- depth++;
108
- break;
109
- case ')':
110
- if (--depth == 0) return i;
111
- break;
112
- }
113
- }
114
- return -1;
115
- }
116
- function defineComponent(tagName, componentClass) {
117
- if (!customElements.get(tagName)) {
118
- customElements.define(tagName, componentClass);
119
- } else {
120
- console.warn(`Warning: the component "${tagName}" has already been loaded in another version of sib-core.`);
121
- }
122
- }
123
- function fuzzyCompare(subject, search) {
124
- const fuse = new Fuse([subject], {
125
- shouldSort: false,
126
- threshold: 0.37
127
- }).search(search);
128
- return fuse.length > 0;
129
- }
130
- const compare = {
131
- string(subject, query) {
132
- if (query === '') return true;
133
- if (subject.toString().toLowerCase().includes(String(query).toLowerCase())) return true;
134
- return fuzzyCompare(subject, query);
135
- },
136
- boolean(subject, query) {
137
- if (!query) return true;
138
- return subject;
139
- },
140
- number(subject, query) {
141
- return subject === query;
142
- },
143
- list(subject, list) {
144
- return list.includes(subject);
145
- },
146
- range(subject, range) {
147
- return (range[0] == null || range[0] === '' || subject >= range[0]) && (range[1] == null || range[1] === '' || subject <= range[1]);
148
- },
149
- resource(subject, query) {
150
- // dropdown default ' - ' option return an empty string
151
- if (query === '') return true;
152
- if (!query['@id']) return false;
153
- const ret = subject['@id'] === query['@id'];
154
- return ret;
155
- }
156
- };
157
- function transformArrayToContainer(resource) {
158
- const newValue = {
159
- ...resource
160
- };
161
- for (let predicate of Object.keys(newValue)) {
162
- // iterate over all properties
163
- const predicateValue = newValue[predicate];
164
- if (!predicateValue || typeof predicateValue !== 'object') continue; // undefined or literal, do nothing
165
- if (['permissions', '@context'].includes(predicate)) continue; // do not transform permissions and context
166
-
167
- // check all keys of nested resource
168
- if (!Array.isArray(predicateValue) && predicateValue['@id']) {
169
- newValue[predicate] = transformArrayToContainer(resource[predicate]);
170
- }
171
-
172
- // for arrays
173
- if (Array.isArray(predicateValue)) {
174
- newValue[predicate] = {
175
- 'ldp:contains': [...predicateValue]
176
- }; // transform to container
177
- newValue[predicate]['ldp:contains'].forEach((childPredicate, index) => {
178
- // and check all nested resources
179
- newValue[predicate]['ldp:contains'][index] = transformArrayToContainer(childPredicate);
180
- });
181
- }
182
- }
183
- return newValue;
184
- }
185
- export { uniqID, stringToDom, evalTemplateString, importCSS, importJS, loadScript, domIsReady, setDeepProperty, parseFieldsString, findClosingBracketMatchIndex, defineComponent, fuzzyCompare, compare, transformArrayToContainer };
@@ -1,6 +0,0 @@
1
- ;
2
- ;
3
- ;
4
- ;
5
- ;
6
- export {};
@@ -1,139 +0,0 @@
1
- /**
2
- * Spread function from open-wc/lit-helpers
3
- * More informations here: https://open-wc.org/developing/lit-helpers.html
4
- */
5
- import { html, directive, noChange } from '../_snowpack/pkg/lit-html.js';
6
- const prevCache = new WeakMap();
7
- export const spread = directive(spreadData => part => {
8
- const prevData = prevCache.get(part);
9
- if (prevData === spreadData) {
10
- return;
11
- }
12
- prevCache.set(part, spreadData);
13
- if (spreadData) {
14
- for (const key in spreadData) {
15
- const value = spreadData[key];
16
- if (value === noChange) continue;
17
- const prefix = key[0];
18
- const {
19
- element
20
- } = part.committer;
21
- if (prefix === '@') {
22
- const prevHandler = prevData && prevData[key];
23
- if (!prevHandler || prevHandler !== value) {
24
- const name = key.slice(1);
25
- if (prevHandler) element.removeEventListener(name, prevHandler);
26
- element.addEventListener(name, value);
27
- }
28
- continue;
29
- }
30
- if (prefix === '.') {
31
- if (!prevData || prevData[key] !== value) {
32
- element[key.slice(1)] = value;
33
- }
34
- continue;
35
- }
36
- if (prefix === '?') {
37
- if (!prevData || prevData[key] !== value) {
38
- const name = key.slice(1);
39
- if (value) {
40
- element.setAttribute(name, '');
41
- } else {
42
- element.removeAttribute(name);
43
- }
44
- }
45
- continue;
46
- }
47
- if (!prevData || prevData[key] !== value) {
48
- if (value != null) {
49
- element.setAttribute(key, String(value));
50
- } else {
51
- element.removeAttribute(key);
52
- }
53
- }
54
- }
55
- }
56
- if (prevData) {
57
- for (const key in prevData) {
58
- if (!spreadData || !(key in spreadData)) {
59
- const prefix = key[0];
60
- const {
61
- element
62
- } = part.committer;
63
- if (prefix === '@') {
64
- element.removeEventListener(key.slice(1), prevData[key]);
65
- continue;
66
- }
67
- if (prefix === '.') {
68
- element[key.slice(1)] = undefined;
69
- continue;
70
- }
71
- if (prefix === '?') {
72
- element.removeAttribute(key.slice(1));
73
- continue;
74
- }
75
- element.removeAttribute(key);
76
- }
77
- }
78
- }
79
- });
80
- function dropIndices(arr, needlessValues) {
81
- const newArr = [];
82
- let j = 0;
83
- for (let i = 0, n = arr.length; i < n; ++i) {
84
- if (needlessValues[j].index === i) {
85
- ++j;
86
- } else {
87
- newArr.push(arr[i]);
88
- }
89
- }
90
- return newArr;
91
- }
92
- const templateStringsCache = new WeakMap();
93
-
94
- // Convert dynamic tags to template strings
95
- // example: <${'div'}>${'this is example'}</${'div'}> => <div>${'this is example'}</div>
96
- export function preHTML(strings, ...values) {
97
- // check cache !important return equal link at first argument
98
- let cachedStrings = templateStringsCache.get(strings);
99
- if (cachedStrings) {
100
- for (let i = 0, n = cachedStrings.length; i < n; ++i) {
101
- const needlessValues = cachedStrings[i].needlessValues;
102
- let isSame = true;
103
- for (let ii = 0, nn = needlessValues.length; ii < nn; ++ii) {
104
- if (values[needlessValues[ii].index] !== needlessValues[ii].value) {
105
- isSame = false;
106
- break;
107
- }
108
- }
109
- if (isSame) {
110
- return html(cachedStrings[i].strings, ...dropIndices(values, needlessValues));
111
- }
112
- }
113
- }
114
- const needlessValues = [];
115
- const newStrings = [];
116
- let str;
117
- for (let i = 0, n = strings.length; i < n; ++i) {
118
- str = strings[i];
119
- while (str[str.length - 1] === '<' // open tag
120
- || str[str.length - 2] === '<' && str[str.length - 1] === '/' // close tag
121
- ) {
122
- needlessValues.push({
123
- value: values[i],
124
- index: i
125
- });
126
- str += values[i] + strings[++i];
127
- }
128
- newStrings.push(str);
129
- }
130
- if (!cachedStrings) {
131
- cachedStrings = [];
132
- templateStringsCache.set(strings, cachedStrings);
133
- }
134
- cachedStrings.push({
135
- strings: newStrings,
136
- needlessValues
137
- });
138
- return html(newStrings, ...dropIndices(values, needlessValues));
139
- }
@@ -1,35 +0,0 @@
1
- // Array.prototype.flat
2
- if (!('flat' in Array.prototype)) {
3
- Object.defineProperty(Array.prototype, 'flat', {
4
- configurable: true,
5
- value: function flat(depth = 1) {
6
- depth = isNaN(depth) ? 1 : Number(depth);
7
- if (depth === 0) return Array.prototype.slice.call(this);
8
- return Array.prototype.reduce.call(this, function (acc, cur) {
9
- if (Array.isArray(cur)) {
10
- acc.push.apply(acc, flat.call(cur, depth - 1));
11
- } else {
12
- acc.push(cur);
13
- }
14
- return acc;
15
- }, []);
16
- },
17
- writable: true
18
- });
19
- }
20
-
21
- // Element.prototype.toggleAttribute
22
- if (!Element.prototype.toggleAttribute) {
23
- Element.prototype.toggleAttribute = function (name, force = undefined) {
24
- if (force !== undefined) force = !!force;
25
- if (this.hasAttribute(name)) {
26
- if (force) return true;
27
- this.removeAttribute(name);
28
- return false;
29
- }
30
- if (force === false) return false;
31
- this.setAttribute(name, '');
32
- return true;
33
- };
34
- }
35
- export {};
@@ -1,313 +0,0 @@
1
- let _Symbol$toPrimitive;
2
- 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; }
3
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
4
- 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); }
5
- import JSONLDContextParser from '../../_snowpack/pkg/jsonld-context-parser.js';
6
- import { store } from './store.js';
7
- const ContextParser = JSONLDContextParser.ContextParser;
8
- _Symbol$toPrimitive = Symbol.toPrimitive;
9
- export class CustomGetter {
10
- // search attributes to give to server
11
-
12
- constructor(resourceId, resource, clientContext, serverContext, parentId = "", serverPagination = {}, serverSearch = {}) {
13
- _defineProperty(this, "resource", void 0);
14
- // content of the requested resource
15
- _defineProperty(this, "resourceId", void 0);
16
- _defineProperty(this, "clientContext", void 0);
17
- // context given by the app
18
- _defineProperty(this, "serverContext", void 0);
19
- // context given by the server
20
- _defineProperty(this, "parentId", void 0);
21
- // id of the parent resource, used to get the absolute url of the current resource
22
- _defineProperty(this, "containerTypes", void 0);
23
- // types of resources interpreted as containers
24
- _defineProperty(this, "serverPagination", void 0);
25
- // pagination attributes to give to server
26
- _defineProperty(this, "serverSearch", void 0);
27
- this.clientContext = clientContext;
28
- this.serverContext = serverContext;
29
- this.parentId = parentId;
30
- this.resource = resource;
31
- this.resourceId = resourceId;
32
- this.serverPagination = serverPagination;
33
- this.serverSearch = serverSearch;
34
- this.containerTypes = [this.getExpandedPredicate("ldp:Container"), this.getExpandedPredicate("ldp:BasicContainer"), this.getExpandedPredicate("ldp:DirectContainer"), this.getExpandedPredicate("ldp:IndirectContainer"), "sib:federatedContainer"];
35
- }
36
-
37
- /**
38
- * Get the property of a resource for a given path
39
- * Which means that if the resource is not complete, it will fetch it
40
- * And that we handle the `.` notation, traversing the path recursively
41
- * @param path: string
42
- */
43
- async get(path) {
44
- if (!path) return;
45
-
46
- // Specific case where the predicates is a full IRI, avoid splitting it on the dot notation
47
- try {
48
- let isUrl = new URL(path);
49
- // If the path is an absolute url, we need to fetch the resource
50
- if (isUrl) {
51
- let value = this.resource[this.getExpandedPredicate(path)];
52
- return value ? value : undefined;
53
- }
54
- } catch (e) {
55
- // Split the path on each dots
56
- const path1 = path.split('.');
57
-
58
- // Intermediate path var to request each resource individually until the path traversal is completed
59
- const path2 = [];
60
-
61
- // Actual value found from the store, if any
62
- let value;
63
- if (!this.isFullResource()) {
64
- // if resource is not complete, fetch it first
65
- await this.getResource(this.resourceId, {
66
- ...this.clientContext,
67
- ...this.serverContext
68
- }, this.parentId);
69
- }
70
-
71
- // If the path contains dot, we need to traverse the path recursively
72
- // We do that by poping one element from path1 at each step and affecting it to path2
73
- // Trying to get the value from it
74
- while (true) {
75
- try {
76
- value = this.resource[this.getExpandedPredicate(path1[0])];
77
- } catch (e) {
78
- break;
79
- }
80
- if (path1.length <= 1) break; // no dot path
81
- const lastPath1El = path1.pop();
82
- if (lastPath1El) path2.unshift(lastPath1El);
83
- }
84
- if (path2.length === 0) {
85
- // end of the path
86
- if (!value || !value['@id']) return this.getLiteralValue(value); // no value or not a resource
87
- return await this.getResource(value['@id'], {
88
- ...this.clientContext,
89
- ...this.serverContext
90
- }, this.parentId || this.resourceId); // return complete resource
91
- }
92
-
93
- if (!value) return undefined;
94
- let resource = await this.getResource(value['@id'], {
95
- ...this.clientContext,
96
- ...this.serverContext
97
- }, this.parentId || this.resourceId);
98
- store.subscribeResourceTo(this.resourceId, value['@id']);
99
- return resource ? await resource[path2.join('.')] : undefined; // return value
100
- }
101
- }
102
-
103
- /**
104
- * Return value depending of the current language
105
- * @param value
106
- * @returns
107
- */
108
- getLiteralValue(value) {
109
- if (typeof value === "object") {
110
- // value object: https://www.w3.org/TR/json-ld11/#value-objects
111
- if (value['@value']) {
112
- // 1 language
113
- return value['@value'];
114
- } else if (Array.isArray(value)) {
115
- // multiple languages
116
- if (value.length === 0) return null;
117
- const ln = store._getLanguage();
118
- let translatedValue = value.find(v => v['@language'] && v['@language'] === ln); // find current language
119
- if (!translatedValue) translatedValue = value.find(v => v['@language'] && v['@language'] === 'en'); // default to en
120
- return translatedValue ? translatedValue['@value'] || null : null;
121
- }
122
- }
123
- return value; // simple value
124
- }
125
-
126
- /**
127
- * Cache resource in the store, and return the created proxy
128
- * @param id
129
- * @param context
130
- * @param iriParent
131
- */
132
- async getResource(id, context, iriParent, forceFetch = false) {
133
- if (id.startsWith('_:b')) return store.get(id + iriParent); // anonymous node = get from cache
134
- return store.getData(id, context, iriParent, undefined, forceFetch);
135
- }
136
-
137
- /**
138
- * Return true if the resource is a container
139
- */
140
- isContainer() {
141
- if (this.resource["@type"]) {
142
- // @type is an array
143
- if (Array.isArray(this.resource["@type"])) return this.containerTypes.some(type => this.resource["@type"].includes(type));
144
- return this.containerTypes.includes(this.resource["@type"]);
145
- } else if (this.resource["type"]) {
146
- if (Array.isArray(this.resource["type"])) return this.containerTypes.some(type => this.resource["type"].includes(type));
147
- return this.containerTypes.includes(this.resource["type"]);
148
- }
149
- return false;
150
- }
151
-
152
- /**
153
- * Return true if the given key in the current resource in an array
154
- */
155
- isArray() {
156
- if (Array.isArray(this.resource)) return true;
157
- return false;
158
- }
159
-
160
- /**
161
- * Get all properties of a resource
162
- */
163
- getProperties() {
164
- return Object.keys(this.resource).map(prop => this.getCompactedPredicate(prop));
165
- }
166
-
167
- /**
168
- * Get children of container as objects
169
- */
170
- getChildren(predicateName) {
171
- return this.resource[this.getExpandedPredicate(predicateName)] || [];
172
- }
173
-
174
- /**
175
- * Get children of container as Proxys
176
- */
177
- getLdpContains() {
178
- let children = this.resource[this.getExpandedPredicate("ldp:contains")];
179
- if (!children) return null;
180
- if (!Array.isArray(children)) children = [children]; // convert to array if compacted to 1 resource
181
-
182
- let result = children ? children.map(res => {
183
- let resource = store.get(res['@id']);
184
- if (resource) return resource;
185
-
186
- // if not in cache, generate the basic resource
187
- resource = new CustomGetter(res['@id'], {
188
- '@id': res['@id']
189
- }, this.clientContext, this.serverContext, this.parentId).getProxy();
190
- store.cacheResource(res['@id'], resource); // put it in cache
191
- return resource; // and return it
192
- }) : [];
193
- return result;
194
- }
195
- merge(resource) {
196
- this.resource = {
197
- ...this.getResourceData(),
198
- ...resource.getResourceData()
199
- };
200
- }
201
- getResourceData() {
202
- return this.resource;
203
- }
204
-
205
- /**
206
- * return true resource seems complete
207
- * @param prop
208
- */
209
- isFullResource() {
210
- return Object.keys(this.resource).filter(p => !p.startsWith('@')).length > 0 // has some properties
211
- || this.resource['@id'].startsWith('_:b'); // anonymous node = always full resource
212
- }
213
-
214
- /**
215
- * Get permissions of a resource
216
- * @param resourceId
217
- * @returns
218
- */
219
- async getPermissions() {
220
- let permissionsIds = this.resource[this.getExpandedPredicate("permissions")];
221
- if (!permissionsIds) {
222
- // if no permission, re-fetch data from store
223
- await this.getResource(this.resourceId, {
224
- ...this.clientContext,
225
- ...this.serverContext
226
- }, this.parentId, true);
227
- permissionsIds = this.resource[this.getExpandedPredicate("permissions")];
228
- }
229
- if (!permissionsIds) return [];
230
- if (!Array.isArray(permissionsIds)) permissionsIds = [permissionsIds]; // convert to array if compacted to 1 resource
231
- const permissions = await Promise.all(permissionsIds.map(p => store.get(p['@id'] + this.parentId)) // get anonymous node from store
232
- .map(p => p ? p['mode.@type'] : ''));
233
- return permissions ? permissions.map(perm => ContextParser.expandTerm(perm, this.serverContext, true)) : [];
234
- }
235
-
236
- /**
237
- * returns compacted @type of resource
238
- */
239
- getType() {
240
- return this.resource['@type'] ? this.getCompactedIri(this.resource['@type']) : '';
241
- }
242
-
243
- /**
244
- * Remove the resource from the cache
245
- */
246
- clearCache() {
247
- store.clearCache(this.resourceId);
248
- }
249
- getExpandedPredicate(property) {
250
- return ContextParser.expandTerm(property, {
251
- ...this.clientContext,
252
- ...this.serverContext
253
- }, true);
254
- }
255
- getCompactedPredicate(property) {
256
- return ContextParser.compactIri(property, {
257
- ...this.clientContext,
258
- ...this.serverContext
259
- }, true);
260
- }
261
- getCompactedIri(id) {
262
- return ContextParser.compactIri(id, {
263
- ...this.clientContext,
264
- ...this.serverContext
265
- });
266
- }
267
- toString() {
268
- return this.getCompactedIri(this.resource['@id']);
269
- }
270
- [_Symbol$toPrimitive]() {
271
- return this.getCompactedIri(this.resource['@id']);
272
- }
273
-
274
- /**
275
- * Returns a Proxy which handles the different get requests
276
- */
277
- getProxy() {
278
- return new Proxy(this, {
279
- get: (resource, property) => {
280
- if (!this.resource) return undefined;
281
- if (typeof resource[property] === 'function') return resource[property].bind(resource);
282
- switch (property) {
283
- case '@id':
284
- if (this.resource['@id']) return this.getCompactedIri(this.resource['@id']); // Compact @id if possible
285
- else console.log(this.resource, this.resource['@id']);
286
- return;
287
- case '@type':
288
- return this.resource['@type'];
289
- // return synchronously
290
- case 'properties':
291
- return this.getProperties();
292
- case 'ldp:contains':
293
- return this.getLdpContains();
294
- // returns standard arrays synchronously
295
- case 'permissions':
296
- return this.getPermissions();
297
- // get expanded permissions
298
- case 'clientContext':
299
- return this.clientContext;
300
- // get saved client context to re-fetch easily a resource
301
- case 'serverContext':
302
- return this.serverContext;
303
- // get saved client context to re-fetch easily a resource
304
- case 'then':
305
- return;
306
- default:
307
- // FIXME: missing 'await'
308
- return resource.get(property);
309
- }
310
- }
311
- });
312
- }
313
- }
@@ -1,19 +0,0 @@
1
- export function formatAttributesToServerPaginationOptions(elementAttributes) {
2
- const attributes = new Map(Array.from(elementAttributes).map(({
3
- name,
4
- value
5
- }) => [name, value]));
6
- const limit = attributes.get('limit');
7
- const offset = attributes.get('offset');
8
- if (!offset || !limit) return;
9
- return {
10
- limit: limit,
11
- offset: offset
12
- };
13
- }
14
- export function appendServerPaginationToIri(iri, options) {
15
- const first = iri.includes('?') ? '&' : '?';
16
- const limit = options.limit;
17
- const offset = options.offset;
18
- return `${iri}${first}limit=${limit}&offset=${offset}`;
19
- }