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

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-bf15809c.js} +398 -454
  8. package/dist/assets/helpers-bf15809c.js.map +1 -0
  9. package/dist/{_snowpack/pkg/leaflet/dist/leaflet.css → assets/leaflet-3c081932.css} +3 -3
  10. package/dist/helpers.js +18 -0
  11. package/dist/helpers.js.map +1 -0
  12. package/dist/index.js +54606 -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,1104 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
4
- * This code may only be used under the BSD style license found at
5
- * http://polymer.github.io/LICENSE.txt
6
- * The complete set of authors may be found at
7
- * http://polymer.github.io/AUTHORS.txt
8
- * The complete set of contributors may be found at
9
- * http://polymer.github.io/CONTRIBUTORS.txt
10
- * Code distributed by Google as part of the polymer project is also
11
- * subject to an additional IP rights grant found at
12
- * http://polymer.github.io/PATENTS.txt
13
- */
14
- const directives = new WeakMap();
15
- /**
16
- * Brands a function as a directive factory function so that lit-html will call
17
- * the function during template rendering, rather than passing as a value.
18
- *
19
- * A _directive_ is a function that takes a Part as an argument. It has the
20
- * signature: `(part: Part) => void`.
21
- *
22
- * A directive _factory_ is a function that takes arguments for data and
23
- * configuration and returns a directive. Users of directive usually refer to
24
- * the directive factory as the directive. For example, "The repeat directive".
25
- *
26
- * Usually a template author will invoke a directive factory in their template
27
- * with relevant arguments, which will then return a directive function.
28
- *
29
- * Here's an example of using the `repeat()` directive factory that takes an
30
- * array and a function to render an item:
31
- *
32
- * ```js
33
- * html`<ul><${repeat(items, (item) => html`<li>${item}</li>`)}</ul>`
34
- * ```
35
- *
36
- * When `repeat` is invoked, it returns a directive function that closes over
37
- * `items` and the template function. When the outer template is rendered, the
38
- * return directive function is called with the Part for the expression.
39
- * `repeat` then performs it's custom logic to render multiple items.
40
- *
41
- * @param f The directive factory function. Must be a function that returns a
42
- * function of the signature `(part: Part) => void`. The returned function will
43
- * be called with the part object.
44
- *
45
- * @example
46
- *
47
- * import {directive, html} from 'lit-html';
48
- *
49
- * const immutable = directive((v) => (part) => {
50
- * if (part.value !== v) {
51
- * part.setValue(v)
52
- * }
53
- * });
54
- */
55
- const directive = f => (...args) => {
56
- const d = f(...args);
57
- directives.set(d, true);
58
- return d;
59
- };
60
- const isDirective = o => {
61
- return typeof o === 'function' && directives.has(o);
62
- };
63
-
64
- /**
65
- * @license
66
- * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
67
- * This code may only be used under the BSD style license found at
68
- * http://polymer.github.io/LICENSE.txt
69
- * The complete set of authors may be found at
70
- * http://polymer.github.io/AUTHORS.txt
71
- * The complete set of contributors may be found at
72
- * http://polymer.github.io/CONTRIBUTORS.txt
73
- * Code distributed by Google as part of the polymer project is also
74
- * subject to an additional IP rights grant found at
75
- * http://polymer.github.io/PATENTS.txt
76
- */
77
- /**
78
- * True if the custom elements polyfill is in use.
79
- */
80
- const isCEPolyfill = typeof window !== 'undefined' && window.customElements != null && window.customElements.polyfillWrapFlushCallback !== undefined;
81
- /**
82
- * Removes nodes, starting from `start` (inclusive) to `end` (exclusive), from
83
- * `container`.
84
- */
85
- const removeNodes = (container, start, end = null) => {
86
- while (start !== end) {
87
- const n = start.nextSibling;
88
- container.removeChild(start);
89
- start = n;
90
- }
91
- };
92
-
93
- /**
94
- * @license
95
- * Copyright (c) 2018 The Polymer Project Authors. All rights reserved.
96
- * This code may only be used under the BSD style license found at
97
- * http://polymer.github.io/LICENSE.txt
98
- * The complete set of authors may be found at
99
- * http://polymer.github.io/AUTHORS.txt
100
- * The complete set of contributors may be found at
101
- * http://polymer.github.io/CONTRIBUTORS.txt
102
- * Code distributed by Google as part of the polymer project is also
103
- * subject to an additional IP rights grant found at
104
- * http://polymer.github.io/PATENTS.txt
105
- */
106
- /**
107
- * A sentinel value that signals that a value was handled by a directive and
108
- * should not be written to the DOM.
109
- */
110
- const noChange = {};
111
- /**
112
- * A sentinel value that signals a NodePart to fully clear its content.
113
- */
114
- const nothing = {};
115
-
116
- /**
117
- * @license
118
- * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
119
- * This code may only be used under the BSD style license found at
120
- * http://polymer.github.io/LICENSE.txt
121
- * The complete set of authors may be found at
122
- * http://polymer.github.io/AUTHORS.txt
123
- * The complete set of contributors may be found at
124
- * http://polymer.github.io/CONTRIBUTORS.txt
125
- * Code distributed by Google as part of the polymer project is also
126
- * subject to an additional IP rights grant found at
127
- * http://polymer.github.io/PATENTS.txt
128
- */
129
- /**
130
- * An expression marker with embedded unique key to avoid collision with
131
- * possible text in templates.
132
- */
133
- const marker = `{{lit-${String(Math.random()).slice(2)}}}`;
134
- /**
135
- * An expression marker used text-positions, multi-binding attributes, and
136
- * attributes with markup-like text values.
137
- */
138
- const nodeMarker = `<!--${marker}-->`;
139
- const markerRegex = new RegExp(`${marker}|${nodeMarker}`);
140
- /**
141
- * Suffix appended to all bound attribute names.
142
- */
143
- const boundAttributeSuffix = '$lit$';
144
- /**
145
- * An updatable Template that tracks the location of dynamic parts.
146
- */
147
- class Template {
148
- constructor(result, element) {
149
- this.parts = [];
150
- this.element = element;
151
- const nodesToRemove = [];
152
- const stack = [];
153
- // Edge needs all 4 parameters present; IE11 needs 3rd parameter to be null
154
- const walker = document.createTreeWalker(element.content, 133 /* NodeFilter.SHOW_{ELEMENT|COMMENT|TEXT} */, null, false);
155
- // Keeps track of the last index associated with a part. We try to delete
156
- // unnecessary nodes, but we never want to associate two different parts
157
- // to the same index. They must have a constant node between.
158
- let lastPartIndex = 0;
159
- let index = -1;
160
- let partIndex = 0;
161
- const {
162
- strings,
163
- values: {
164
- length
165
- }
166
- } = result;
167
- while (partIndex < length) {
168
- const node = walker.nextNode();
169
- if (node === null) {
170
- // We've exhausted the content inside a nested template element.
171
- // Because we still have parts (the outer for-loop), we know:
172
- // - There is a template in the stack
173
- // - The walker will find a nextNode outside the template
174
- walker.currentNode = stack.pop();
175
- continue;
176
- }
177
- index++;
178
- if (node.nodeType === 1 /* Node.ELEMENT_NODE */) {
179
- if (node.hasAttributes()) {
180
- const attributes = node.attributes;
181
- const {
182
- length
183
- } = attributes;
184
- // Per
185
- // https://developer.mozilla.org/en-US/docs/Web/API/NamedNodeMap,
186
- // attributes are not guaranteed to be returned in document order.
187
- // In particular, Edge/IE can return them out of order, so we cannot
188
- // assume a correspondence between part index and attribute index.
189
- let count = 0;
190
- for (let i = 0; i < length; i++) {
191
- if (endsWith(attributes[i].name, boundAttributeSuffix)) {
192
- count++;
193
- }
194
- }
195
- while (count-- > 0) {
196
- // Get the template literal section leading up to the first
197
- // expression in this attribute
198
- const stringForPart = strings[partIndex];
199
- // Find the attribute name
200
- const name = lastAttributeNameRegex.exec(stringForPart)[2];
201
- // Find the corresponding attribute
202
- // All bound attributes have had a suffix added in
203
- // TemplateResult#getHTML to opt out of special attribute
204
- // handling. To look up the attribute value we also need to add
205
- // the suffix.
206
- const attributeLookupName = name.toLowerCase() + boundAttributeSuffix;
207
- const attributeValue = node.getAttribute(attributeLookupName);
208
- node.removeAttribute(attributeLookupName);
209
- const statics = attributeValue.split(markerRegex);
210
- this.parts.push({
211
- type: 'attribute',
212
- index,
213
- name,
214
- strings: statics
215
- });
216
- partIndex += statics.length - 1;
217
- }
218
- }
219
- if (node.tagName === 'TEMPLATE') {
220
- stack.push(node);
221
- walker.currentNode = node.content;
222
- }
223
- } else if (node.nodeType === 3 /* Node.TEXT_NODE */) {
224
- const data = node.data;
225
- if (data.indexOf(marker) >= 0) {
226
- const parent = node.parentNode;
227
- const strings = data.split(markerRegex);
228
- const lastIndex = strings.length - 1;
229
- // Generate a new text node for each literal section
230
- // These nodes are also used as the markers for node parts
231
- for (let i = 0; i < lastIndex; i++) {
232
- let insert;
233
- let s = strings[i];
234
- if (s === '') {
235
- insert = createMarker();
236
- } else {
237
- const match = lastAttributeNameRegex.exec(s);
238
- if (match !== null && endsWith(match[2], boundAttributeSuffix)) {
239
- s = s.slice(0, match.index) + match[1] + match[2].slice(0, -boundAttributeSuffix.length) + match[3];
240
- }
241
- insert = document.createTextNode(s);
242
- }
243
- parent.insertBefore(insert, node);
244
- this.parts.push({
245
- type: 'node',
246
- index: ++index
247
- });
248
- }
249
- // If there's no text, we must insert a comment to mark our place.
250
- // Else, we can trust it will stick around after cloning.
251
- if (strings[lastIndex] === '') {
252
- parent.insertBefore(createMarker(), node);
253
- nodesToRemove.push(node);
254
- } else {
255
- node.data = strings[lastIndex];
256
- }
257
- // We have a part for each match found
258
- partIndex += lastIndex;
259
- }
260
- } else if (node.nodeType === 8 /* Node.COMMENT_NODE */) {
261
- if (node.data === marker) {
262
- const parent = node.parentNode;
263
- // Add a new marker node to be the startNode of the Part if any of
264
- // the following are true:
265
- // * We don't have a previousSibling
266
- // * The previousSibling is already the start of a previous part
267
- if (node.previousSibling === null || index === lastPartIndex) {
268
- index++;
269
- parent.insertBefore(createMarker(), node);
270
- }
271
- lastPartIndex = index;
272
- this.parts.push({
273
- type: 'node',
274
- index
275
- });
276
- // If we don't have a nextSibling, keep this node so we have an end.
277
- // Else, we can remove it to save future costs.
278
- if (node.nextSibling === null) {
279
- node.data = '';
280
- } else {
281
- nodesToRemove.push(node);
282
- index--;
283
- }
284
- partIndex++;
285
- } else {
286
- let i = -1;
287
- while ((i = node.data.indexOf(marker, i + 1)) !== -1) {
288
- // Comment node has a binding marker inside, make an inactive part
289
- // The binding won't work, but subsequent bindings will
290
- // TODO (justinfagnani): consider whether it's even worth it to
291
- // make bindings in comments work
292
- this.parts.push({
293
- type: 'node',
294
- index: -1
295
- });
296
- partIndex++;
297
- }
298
- }
299
- }
300
- }
301
- // Remove text binding nodes after the walk to not disturb the TreeWalker
302
- for (const n of nodesToRemove) {
303
- n.parentNode.removeChild(n);
304
- }
305
- }
306
- }
307
- const endsWith = (str, suffix) => {
308
- const index = str.length - suffix.length;
309
- return index >= 0 && str.slice(index) === suffix;
310
- };
311
- const isTemplatePartActive = part => part.index !== -1;
312
- // Allows `document.createComment('')` to be renamed for a
313
- // small manual size-savings.
314
- const createMarker = () => document.createComment('');
315
- /**
316
- * This regex extracts the attribute name preceding an attribute-position
317
- * expression. It does this by matching the syntax allowed for attributes
318
- * against the string literal directly preceding the expression, assuming that
319
- * the expression is in an attribute-value position.
320
- *
321
- * See attributes in the HTML spec:
322
- * https://www.w3.org/TR/html5/syntax.html#elements-attributes
323
- *
324
- * " \x09\x0a\x0c\x0d" are HTML space characters:
325
- * https://www.w3.org/TR/html5/infrastructure.html#space-characters
326
- *
327
- * "\0-\x1F\x7F-\x9F" are Unicode control characters, which includes every
328
- * space character except " ".
329
- *
330
- * So an attribute is:
331
- * * The name: any character except a control character, space character, ('),
332
- * ("), ">", "=", or "/"
333
- * * Followed by zero or more space characters
334
- * * Followed by "="
335
- * * Followed by zero or more space characters
336
- * * Followed by:
337
- * * Any character except space, ('), ("), "<", ">", "=", (`), or
338
- * * (") then any non-("), or
339
- * * (') then any non-(')
340
- */
341
- const lastAttributeNameRegex =
342
- // eslint-disable-next-line no-control-regex
343
- /([ \x09\x0a\x0c\x0d])([^\0-\x1F\x7F-\x9F "'>=/]+)([ \x09\x0a\x0c\x0d]*=[ \x09\x0a\x0c\x0d]*(?:[^ \x09\x0a\x0c\x0d"'`<>=]*|"[^"]*|'[^']*))$/;
344
-
345
- /**
346
- * @license
347
- * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
348
- * This code may only be used under the BSD style license found at
349
- * http://polymer.github.io/LICENSE.txt
350
- * The complete set of authors may be found at
351
- * http://polymer.github.io/AUTHORS.txt
352
- * The complete set of contributors may be found at
353
- * http://polymer.github.io/CONTRIBUTORS.txt
354
- * Code distributed by Google as part of the polymer project is also
355
- * subject to an additional IP rights grant found at
356
- * http://polymer.github.io/PATENTS.txt
357
- */
358
- /**
359
- * An instance of a `Template` that can be attached to the DOM and updated
360
- * with new values.
361
- */
362
- class TemplateInstance {
363
- constructor(template, processor, options) {
364
- this.__parts = [];
365
- this.template = template;
366
- this.processor = processor;
367
- this.options = options;
368
- }
369
- update(values) {
370
- let i = 0;
371
- for (const part of this.__parts) {
372
- if (part !== undefined) {
373
- part.setValue(values[i]);
374
- }
375
- i++;
376
- }
377
- for (const part of this.__parts) {
378
- if (part !== undefined) {
379
- part.commit();
380
- }
381
- }
382
- }
383
- _clone() {
384
- // There are a number of steps in the lifecycle of a template instance's
385
- // DOM fragment:
386
- // 1. Clone - create the instance fragment
387
- // 2. Adopt - adopt into the main document
388
- // 3. Process - find part markers and create parts
389
- // 4. Upgrade - upgrade custom elements
390
- // 5. Update - set node, attribute, property, etc., values
391
- // 6. Connect - connect to the document. Optional and outside of this
392
- // method.
393
- //
394
- // We have a few constraints on the ordering of these steps:
395
- // * We need to upgrade before updating, so that property values will pass
396
- // through any property setters.
397
- // * We would like to process before upgrading so that we're sure that the
398
- // cloned fragment is inert and not disturbed by self-modifying DOM.
399
- // * We want custom elements to upgrade even in disconnected fragments.
400
- //
401
- // Given these constraints, with full custom elements support we would
402
- // prefer the order: Clone, Process, Adopt, Upgrade, Update, Connect
403
- //
404
- // But Safari does not implement CustomElementRegistry#upgrade, so we
405
- // can not implement that order and still have upgrade-before-update and
406
- // upgrade disconnected fragments. So we instead sacrifice the
407
- // process-before-upgrade constraint, since in Custom Elements v1 elements
408
- // must not modify their light DOM in the constructor. We still have issues
409
- // when co-existing with CEv0 elements like Polymer 1, and with polyfills
410
- // that don't strictly adhere to the no-modification rule because shadow
411
- // DOM, which may be created in the constructor, is emulated by being placed
412
- // in the light DOM.
413
- //
414
- // The resulting order is on native is: Clone, Adopt, Upgrade, Process,
415
- // Update, Connect. document.importNode() performs Clone, Adopt, and Upgrade
416
- // in one step.
417
- //
418
- // The Custom Elements v1 polyfill supports upgrade(), so the order when
419
- // polyfilled is the more ideal: Clone, Process, Adopt, Upgrade, Update,
420
- // Connect.
421
- const fragment = isCEPolyfill ? this.template.element.content.cloneNode(true) : document.importNode(this.template.element.content, true);
422
- const stack = [];
423
- const parts = this.template.parts;
424
- // Edge needs all 4 parameters present; IE11 needs 3rd parameter to be null
425
- const walker = document.createTreeWalker(fragment, 133 /* NodeFilter.SHOW_{ELEMENT|COMMENT|TEXT} */, null, false);
426
- let partIndex = 0;
427
- let nodeIndex = 0;
428
- let part;
429
- let node = walker.nextNode();
430
- // Loop through all the nodes and parts of a template
431
- while (partIndex < parts.length) {
432
- part = parts[partIndex];
433
- if (!isTemplatePartActive(part)) {
434
- this.__parts.push(undefined);
435
- partIndex++;
436
- continue;
437
- }
438
- // Progress the tree walker until we find our next part's node.
439
- // Note that multiple parts may share the same node (attribute parts
440
- // on a single element), so this loop may not run at all.
441
- while (nodeIndex < part.index) {
442
- nodeIndex++;
443
- if (node.nodeName === 'TEMPLATE') {
444
- stack.push(node);
445
- walker.currentNode = node.content;
446
- }
447
- if ((node = walker.nextNode()) === null) {
448
- // We've exhausted the content inside a nested template element.
449
- // Because we still have parts (the outer for-loop), we know:
450
- // - There is a template in the stack
451
- // - The walker will find a nextNode outside the template
452
- walker.currentNode = stack.pop();
453
- node = walker.nextNode();
454
- }
455
- }
456
- // We've arrived at our part's node.
457
- if (part.type === 'node') {
458
- const part = this.processor.handleTextExpression(this.options);
459
- part.insertAfterNode(node.previousSibling);
460
- this.__parts.push(part);
461
- } else {
462
- this.__parts.push(...this.processor.handleAttributeExpressions(node, part.name, part.strings, this.options));
463
- }
464
- partIndex++;
465
- }
466
- if (isCEPolyfill) {
467
- document.adoptNode(fragment);
468
- customElements.upgrade(fragment);
469
- }
470
- return fragment;
471
- }
472
- }
473
-
474
- /**
475
- * @license
476
- * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
477
- * This code may only be used under the BSD style license found at
478
- * http://polymer.github.io/LICENSE.txt
479
- * The complete set of authors may be found at
480
- * http://polymer.github.io/AUTHORS.txt
481
- * The complete set of contributors may be found at
482
- * http://polymer.github.io/CONTRIBUTORS.txt
483
- * Code distributed by Google as part of the polymer project is also
484
- * subject to an additional IP rights grant found at
485
- * http://polymer.github.io/PATENTS.txt
486
- */
487
- /**
488
- * Our TrustedTypePolicy for HTML which is declared using the html template
489
- * tag function.
490
- *
491
- * That HTML is a developer-authored constant, and is parsed with innerHTML
492
- * before any untrusted expressions have been mixed in. Therefor it is
493
- * considered safe by construction.
494
- */
495
- const policy = window.trustedTypes && trustedTypes.createPolicy('lit-html', {
496
- createHTML: s => s
497
- });
498
- const commentMarker = ` ${marker} `;
499
- /**
500
- * The return type of `html`, which holds a Template and the values from
501
- * interpolated expressions.
502
- */
503
- class TemplateResult {
504
- constructor(strings, values, type, processor) {
505
- this.strings = strings;
506
- this.values = values;
507
- this.type = type;
508
- this.processor = processor;
509
- }
510
- /**
511
- * Returns a string of HTML used to create a `<template>` element.
512
- */
513
- getHTML() {
514
- const l = this.strings.length - 1;
515
- let html = '';
516
- let isCommentBinding = false;
517
- for (let i = 0; i < l; i++) {
518
- const s = this.strings[i];
519
- // For each binding we want to determine the kind of marker to insert
520
- // into the template source before it's parsed by the browser's HTML
521
- // parser. The marker type is based on whether the expression is in an
522
- // attribute, text, or comment position.
523
- // * For node-position bindings we insert a comment with the marker
524
- // sentinel as its text content, like <!--{{lit-guid}}-->.
525
- // * For attribute bindings we insert just the marker sentinel for the
526
- // first binding, so that we support unquoted attribute bindings.
527
- // Subsequent bindings can use a comment marker because multi-binding
528
- // attributes must be quoted.
529
- // * For comment bindings we insert just the marker sentinel so we don't
530
- // close the comment.
531
- //
532
- // The following code scans the template source, but is *not* an HTML
533
- // parser. We don't need to track the tree structure of the HTML, only
534
- // whether a binding is inside a comment, and if not, if it appears to be
535
- // the first binding in an attribute.
536
- const commentOpen = s.lastIndexOf('<!--');
537
- // We're in comment position if we have a comment open with no following
538
- // comment close. Because <-- can appear in an attribute value there can
539
- // be false positives.
540
- isCommentBinding = (commentOpen > -1 || isCommentBinding) && s.indexOf('-->', commentOpen + 1) === -1;
541
- // Check to see if we have an attribute-like sequence preceding the
542
- // expression. This can match "name=value" like structures in text,
543
- // comments, and attribute values, so there can be false-positives.
544
- const attributeMatch = lastAttributeNameRegex.exec(s);
545
- if (attributeMatch === null) {
546
- // We're only in this branch if we don't have a attribute-like
547
- // preceding sequence. For comments, this guards against unusual
548
- // attribute values like <div foo="<!--${'bar'}">. Cases like
549
- // <!-- foo=${'bar'}--> are handled correctly in the attribute branch
550
- // below.
551
- html += s + (isCommentBinding ? commentMarker : nodeMarker);
552
- } else {
553
- // For attributes we use just a marker sentinel, and also append a
554
- // $lit$ suffix to the name to opt-out of attribute-specific parsing
555
- // that IE and Edge do for style and certain SVG attributes.
556
- html += s.substr(0, attributeMatch.index) + attributeMatch[1] + attributeMatch[2] + boundAttributeSuffix + attributeMatch[3] + marker;
557
- }
558
- }
559
- html += this.strings[l];
560
- return html;
561
- }
562
- getTemplateElement() {
563
- const template = document.createElement('template');
564
- let value = this.getHTML();
565
- if (policy !== undefined) {
566
- // this is secure because `this.strings` is a TemplateStringsArray.
567
- // TODO: validate this when
568
- // https://github.com/tc39/proposal-array-is-template-object is
569
- // implemented.
570
- value = policy.createHTML(value);
571
- }
572
- template.innerHTML = value;
573
- return template;
574
- }
575
- }
576
-
577
- /**
578
- * @license
579
- * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
580
- * This code may only be used under the BSD style license found at
581
- * http://polymer.github.io/LICENSE.txt
582
- * The complete set of authors may be found at
583
- * http://polymer.github.io/AUTHORS.txt
584
- * The complete set of contributors may be found at
585
- * http://polymer.github.io/CONTRIBUTORS.txt
586
- * Code distributed by Google as part of the polymer project is also
587
- * subject to an additional IP rights grant found at
588
- * http://polymer.github.io/PATENTS.txt
589
- */
590
- const isPrimitive = value => {
591
- return value === null || !(typeof value === 'object' || typeof value === 'function');
592
- };
593
- const isIterable = value => {
594
- return Array.isArray(value) ||
595
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
596
- !!(value && value[Symbol.iterator]);
597
- };
598
- /**
599
- * Writes attribute values to the DOM for a group of AttributeParts bound to a
600
- * single attribute. The value is only set once even if there are multiple parts
601
- * for an attribute.
602
- */
603
- class AttributeCommitter {
604
- constructor(element, name, strings) {
605
- this.dirty = true;
606
- this.element = element;
607
- this.name = name;
608
- this.strings = strings;
609
- this.parts = [];
610
- for (let i = 0; i < strings.length - 1; i++) {
611
- this.parts[i] = this._createPart();
612
- }
613
- }
614
- /**
615
- * Creates a single part. Override this to create a differnt type of part.
616
- */
617
- _createPart() {
618
- return new AttributePart(this);
619
- }
620
- _getValue() {
621
- const strings = this.strings;
622
- const l = strings.length - 1;
623
- const parts = this.parts;
624
- // If we're assigning an attribute via syntax like:
625
- // attr="${foo}" or attr=${foo}
626
- // but not
627
- // attr="${foo} ${bar}" or attr="${foo} baz"
628
- // then we don't want to coerce the attribute value into one long
629
- // string. Instead we want to just return the value itself directly,
630
- // so that sanitizeDOMValue can get the actual value rather than
631
- // String(value)
632
- // The exception is if v is an array, in which case we do want to smash
633
- // it together into a string without calling String() on the array.
634
- //
635
- // This also allows trusted values (when using TrustedTypes) being
636
- // assigned to DOM sinks without being stringified in the process.
637
- if (l === 1 && strings[0] === '' && strings[1] === '') {
638
- const v = parts[0].value;
639
- if (typeof v === 'symbol') {
640
- return String(v);
641
- }
642
- if (typeof v === 'string' || !isIterable(v)) {
643
- return v;
644
- }
645
- }
646
- let text = '';
647
- for (let i = 0; i < l; i++) {
648
- text += strings[i];
649
- const part = parts[i];
650
- if (part !== undefined) {
651
- const v = part.value;
652
- if (isPrimitive(v) || !isIterable(v)) {
653
- text += typeof v === 'string' ? v : String(v);
654
- } else {
655
- for (const t of v) {
656
- text += typeof t === 'string' ? t : String(t);
657
- }
658
- }
659
- }
660
- }
661
- text += strings[l];
662
- return text;
663
- }
664
- commit() {
665
- if (this.dirty) {
666
- this.dirty = false;
667
- this.element.setAttribute(this.name, this._getValue());
668
- }
669
- }
670
- }
671
- /**
672
- * A Part that controls all or part of an attribute value.
673
- */
674
- class AttributePart {
675
- constructor(committer) {
676
- this.value = undefined;
677
- this.committer = committer;
678
- }
679
- setValue(value) {
680
- if (value !== noChange && (!isPrimitive(value) || value !== this.value)) {
681
- this.value = value;
682
- // If the value is a not a directive, dirty the committer so that it'll
683
- // call setAttribute. If the value is a directive, it'll dirty the
684
- // committer if it calls setValue().
685
- if (!isDirective(value)) {
686
- this.committer.dirty = true;
687
- }
688
- }
689
- }
690
- commit() {
691
- while (isDirective(this.value)) {
692
- const directive = this.value;
693
- this.value = noChange;
694
- directive(this);
695
- }
696
- if (this.value === noChange) {
697
- return;
698
- }
699
- this.committer.commit();
700
- }
701
- }
702
- /**
703
- * A Part that controls a location within a Node tree. Like a Range, NodePart
704
- * has start and end locations and can set and update the Nodes between those
705
- * locations.
706
- *
707
- * NodeParts support several value types: primitives, Nodes, TemplateResults,
708
- * as well as arrays and iterables of those types.
709
- */
710
- class NodePart {
711
- constructor(options) {
712
- this.value = undefined;
713
- this.__pendingValue = undefined;
714
- this.options = options;
715
- }
716
- /**
717
- * Appends this part into a container.
718
- *
719
- * This part must be empty, as its contents are not automatically moved.
720
- */
721
- appendInto(container) {
722
- this.startNode = container.appendChild(createMarker());
723
- this.endNode = container.appendChild(createMarker());
724
- }
725
- /**
726
- * Inserts this part after the `ref` node (between `ref` and `ref`'s next
727
- * sibling). Both `ref` and its next sibling must be static, unchanging nodes
728
- * such as those that appear in a literal section of a template.
729
- *
730
- * This part must be empty, as its contents are not automatically moved.
731
- */
732
- insertAfterNode(ref) {
733
- this.startNode = ref;
734
- this.endNode = ref.nextSibling;
735
- }
736
- /**
737
- * Appends this part into a parent part.
738
- *
739
- * This part must be empty, as its contents are not automatically moved.
740
- */
741
- appendIntoPart(part) {
742
- part.__insert(this.startNode = createMarker());
743
- part.__insert(this.endNode = createMarker());
744
- }
745
- /**
746
- * Inserts this part after the `ref` part.
747
- *
748
- * This part must be empty, as its contents are not automatically moved.
749
- */
750
- insertAfterPart(ref) {
751
- ref.__insert(this.startNode = createMarker());
752
- this.endNode = ref.endNode;
753
- ref.endNode = this.startNode;
754
- }
755
- setValue(value) {
756
- this.__pendingValue = value;
757
- }
758
- commit() {
759
- if (this.startNode.parentNode === null) {
760
- return;
761
- }
762
- while (isDirective(this.__pendingValue)) {
763
- const directive = this.__pendingValue;
764
- this.__pendingValue = noChange;
765
- directive(this);
766
- }
767
- const value = this.__pendingValue;
768
- if (value === noChange) {
769
- return;
770
- }
771
- if (isPrimitive(value)) {
772
- if (value !== this.value) {
773
- this.__commitText(value);
774
- }
775
- } else if (value instanceof TemplateResult) {
776
- this.__commitTemplateResult(value);
777
- } else if (value instanceof Node) {
778
- this.__commitNode(value);
779
- } else if (isIterable(value)) {
780
- this.__commitIterable(value);
781
- } else if (value === nothing) {
782
- this.value = nothing;
783
- this.clear();
784
- } else {
785
- // Fallback, will render the string representation
786
- this.__commitText(value);
787
- }
788
- }
789
- __insert(node) {
790
- this.endNode.parentNode.insertBefore(node, this.endNode);
791
- }
792
- __commitNode(value) {
793
- if (this.value === value) {
794
- return;
795
- }
796
- this.clear();
797
- this.__insert(value);
798
- this.value = value;
799
- }
800
- __commitText(value) {
801
- const node = this.startNode.nextSibling;
802
- value = value == null ? '' : value;
803
- // If `value` isn't already a string, we explicitly convert it here in case
804
- // it can't be implicitly converted - i.e. it's a symbol.
805
- const valueAsString = typeof value === 'string' ? value : String(value);
806
- if (node === this.endNode.previousSibling && node.nodeType === 3 /* Node.TEXT_NODE */) {
807
- // If we only have a single text node between the markers, we can just
808
- // set its value, rather than replacing it.
809
- // TODO(justinfagnani): Can we just check if this.value is primitive?
810
- node.data = valueAsString;
811
- } else {
812
- this.__commitNode(document.createTextNode(valueAsString));
813
- }
814
- this.value = value;
815
- }
816
- __commitTemplateResult(value) {
817
- const template = this.options.templateFactory(value);
818
- if (this.value instanceof TemplateInstance && this.value.template === template) {
819
- this.value.update(value.values);
820
- } else {
821
- // Make sure we propagate the template processor from the TemplateResult
822
- // so that we use its syntax extension, etc. The template factory comes
823
- // from the render function options so that it can control template
824
- // caching and preprocessing.
825
- const instance = new TemplateInstance(template, value.processor, this.options);
826
- const fragment = instance._clone();
827
- instance.update(value.values);
828
- this.__commitNode(fragment);
829
- this.value = instance;
830
- }
831
- }
832
- __commitIterable(value) {
833
- // For an Iterable, we create a new InstancePart per item, then set its
834
- // value to the item. This is a little bit of overhead for every item in
835
- // an Iterable, but it lets us recurse easily and efficiently update Arrays
836
- // of TemplateResults that will be commonly returned from expressions like:
837
- // array.map((i) => html`${i}`), by reusing existing TemplateInstances.
838
- // If _value is an array, then the previous render was of an
839
- // iterable and _value will contain the NodeParts from the previous
840
- // render. If _value is not an array, clear this part and make a new
841
- // array for NodeParts.
842
- if (!Array.isArray(this.value)) {
843
- this.value = [];
844
- this.clear();
845
- }
846
- // Lets us keep track of how many items we stamped so we can clear leftover
847
- // items from a previous render
848
- const itemParts = this.value;
849
- let partIndex = 0;
850
- let itemPart;
851
- for (const item of value) {
852
- // Try to reuse an existing part
853
- itemPart = itemParts[partIndex];
854
- // If no existing part, create a new one
855
- if (itemPart === undefined) {
856
- itemPart = new NodePart(this.options);
857
- itemParts.push(itemPart);
858
- if (partIndex === 0) {
859
- itemPart.appendIntoPart(this);
860
- } else {
861
- itemPart.insertAfterPart(itemParts[partIndex - 1]);
862
- }
863
- }
864
- itemPart.setValue(item);
865
- itemPart.commit();
866
- partIndex++;
867
- }
868
- if (partIndex < itemParts.length) {
869
- // Truncate the parts array so _value reflects the current state
870
- itemParts.length = partIndex;
871
- this.clear(itemPart && itemPart.endNode);
872
- }
873
- }
874
- clear(startNode = this.startNode) {
875
- removeNodes(this.startNode.parentNode, startNode.nextSibling, this.endNode);
876
- }
877
- }
878
- /**
879
- * Implements a boolean attribute, roughly as defined in the HTML
880
- * specification.
881
- *
882
- * If the value is truthy, then the attribute is present with a value of
883
- * ''. If the value is falsey, the attribute is removed.
884
- */
885
- class BooleanAttributePart {
886
- constructor(element, name, strings) {
887
- this.value = undefined;
888
- this.__pendingValue = undefined;
889
- if (strings.length !== 2 || strings[0] !== '' || strings[1] !== '') {
890
- throw new Error('Boolean attributes can only contain a single expression');
891
- }
892
- this.element = element;
893
- this.name = name;
894
- this.strings = strings;
895
- }
896
- setValue(value) {
897
- this.__pendingValue = value;
898
- }
899
- commit() {
900
- while (isDirective(this.__pendingValue)) {
901
- const directive = this.__pendingValue;
902
- this.__pendingValue = noChange;
903
- directive(this);
904
- }
905
- if (this.__pendingValue === noChange) {
906
- return;
907
- }
908
- const value = !!this.__pendingValue;
909
- if (this.value !== value) {
910
- if (value) {
911
- this.element.setAttribute(this.name, '');
912
- } else {
913
- this.element.removeAttribute(this.name);
914
- }
915
- this.value = value;
916
- }
917
- this.__pendingValue = noChange;
918
- }
919
- }
920
- /**
921
- * Sets attribute values for PropertyParts, so that the value is only set once
922
- * even if there are multiple parts for a property.
923
- *
924
- * If an expression controls the whole property value, then the value is simply
925
- * assigned to the property under control. If there are string literals or
926
- * multiple expressions, then the strings are expressions are interpolated into
927
- * a string first.
928
- */
929
- class PropertyCommitter extends AttributeCommitter {
930
- constructor(element, name, strings) {
931
- super(element, name, strings);
932
- this.single = strings.length === 2 && strings[0] === '' && strings[1] === '';
933
- }
934
- _createPart() {
935
- return new PropertyPart(this);
936
- }
937
- _getValue() {
938
- if (this.single) {
939
- return this.parts[0].value;
940
- }
941
- return super._getValue();
942
- }
943
- commit() {
944
- if (this.dirty) {
945
- this.dirty = false;
946
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
947
- this.element[this.name] = this._getValue();
948
- }
949
- }
950
- }
951
- class PropertyPart extends AttributePart {}
952
- // Detect event listener options support. If the `capture` property is read
953
- // from the options object, then options are supported. If not, then the third
954
- // argument to add/removeEventListener is interpreted as the boolean capture
955
- // value so we should only pass the `capture` property.
956
- let eventOptionsSupported = false;
957
- // Wrap into an IIFE because MS Edge <= v41 does not support having try/catch
958
- // blocks right into the body of a module
959
- (() => {
960
- try {
961
- const options = {
962
- get capture() {
963
- eventOptionsSupported = true;
964
- return false;
965
- }
966
- };
967
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
968
- window.addEventListener('test', options, options);
969
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
970
- window.removeEventListener('test', options, options);
971
- } catch (_e) {
972
- // event options not supported
973
- }
974
- })();
975
- class EventPart {
976
- constructor(element, eventName, eventContext) {
977
- this.value = undefined;
978
- this.__pendingValue = undefined;
979
- this.element = element;
980
- this.eventName = eventName;
981
- this.eventContext = eventContext;
982
- this.__boundHandleEvent = e => this.handleEvent(e);
983
- }
984
- setValue(value) {
985
- this.__pendingValue = value;
986
- }
987
- commit() {
988
- while (isDirective(this.__pendingValue)) {
989
- const directive = this.__pendingValue;
990
- this.__pendingValue = noChange;
991
- directive(this);
992
- }
993
- if (this.__pendingValue === noChange) {
994
- return;
995
- }
996
- const newListener = this.__pendingValue;
997
- const oldListener = this.value;
998
- const shouldRemoveListener = newListener == null || oldListener != null && (newListener.capture !== oldListener.capture || newListener.once !== oldListener.once || newListener.passive !== oldListener.passive);
999
- const shouldAddListener = newListener != null && (oldListener == null || shouldRemoveListener);
1000
- if (shouldRemoveListener) {
1001
- this.element.removeEventListener(this.eventName, this.__boundHandleEvent, this.__options);
1002
- }
1003
- if (shouldAddListener) {
1004
- this.__options = getOptions(newListener);
1005
- this.element.addEventListener(this.eventName, this.__boundHandleEvent, this.__options);
1006
- }
1007
- this.value = newListener;
1008
- this.__pendingValue = noChange;
1009
- }
1010
- handleEvent(event) {
1011
- if (typeof this.value === 'function') {
1012
- this.value.call(this.eventContext || this.element, event);
1013
- } else {
1014
- this.value.handleEvent(event);
1015
- }
1016
- }
1017
- }
1018
- // We copy options because of the inconsistent behavior of browsers when reading
1019
- // the third argument of add/removeEventListener. IE11 doesn't support options
1020
- // at all. Chrome 41 only reads `capture` if the argument is an object.
1021
- const getOptions = o => o && (eventOptionsSupported ? {
1022
- capture: o.capture,
1023
- passive: o.passive,
1024
- once: o.once
1025
- } : o.capture);
1026
-
1027
- /**
1028
- * @license
1029
- * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
1030
- * This code may only be used under the BSD style license found at
1031
- * http://polymer.github.io/LICENSE.txt
1032
- * The complete set of authors may be found at
1033
- * http://polymer.github.io/AUTHORS.txt
1034
- * The complete set of contributors may be found at
1035
- * http://polymer.github.io/CONTRIBUTORS.txt
1036
- * Code distributed by Google as part of the polymer project is also
1037
- * subject to an additional IP rights grant found at
1038
- * http://polymer.github.io/PATENTS.txt
1039
- */
1040
- /**
1041
- * Creates Parts when a template is instantiated.
1042
- */
1043
- class DefaultTemplateProcessor {
1044
- /**
1045
- * Create parts for an attribute-position binding, given the event, attribute
1046
- * name, and string literals.
1047
- *
1048
- * @param element The element containing the binding
1049
- * @param name The attribute name
1050
- * @param strings The string literals. There are always at least two strings,
1051
- * event for fully-controlled bindings with a single expression.
1052
- */
1053
- handleAttributeExpressions(element, name, strings, options) {
1054
- const prefix = name[0];
1055
- if (prefix === '.') {
1056
- const committer = new PropertyCommitter(element, name.slice(1), strings);
1057
- return committer.parts;
1058
- }
1059
- if (prefix === '@') {
1060
- return [new EventPart(element, name.slice(1), options.eventContext)];
1061
- }
1062
- if (prefix === '?') {
1063
- return [new BooleanAttributePart(element, name.slice(1), strings)];
1064
- }
1065
- const committer = new AttributeCommitter(element, name, strings);
1066
- return committer.parts;
1067
- }
1068
- /**
1069
- * Create parts for a text-position binding.
1070
- * @param templateFactory
1071
- */
1072
- handleTextExpression(options) {
1073
- return new NodePart(options);
1074
- }
1075
- }
1076
- const defaultTemplateProcessor = new DefaultTemplateProcessor();
1077
-
1078
- /**
1079
- * @license
1080
- * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
1081
- * This code may only be used under the BSD style license found at
1082
- * http://polymer.github.io/LICENSE.txt
1083
- * The complete set of authors may be found at
1084
- * http://polymer.github.io/AUTHORS.txt
1085
- * The complete set of contributors may be found at
1086
- * http://polymer.github.io/CONTRIBUTORS.txt
1087
- * Code distributed by Google as part of the polymer project is also
1088
- * subject to an additional IP rights grant found at
1089
- * http://polymer.github.io/PATENTS.txt
1090
- */
1091
- // IMPORTANT: do not change the property name or the assignment expression.
1092
- // This line will be used in regexes to search for lit-html usage.
1093
- // TODO(justinfagnani): inject version number at build time
1094
- if (typeof window !== 'undefined') {
1095
- (window['litHtmlVersions'] || (window['litHtmlVersions'] = [])).push('1.4.1');
1096
- }
1097
- /**
1098
- * Interprets a template literal as an HTML template that can efficiently
1099
- * render to and update a container.
1100
- */
1101
- const html = (strings, ...values) => new TemplateResult(strings, values, 'html', defaultTemplateProcessor);
1102
-
1103
- export { AttributePart as A, NodePart as N, Template as T, directive as d, html as h, isPrimitive as i, marker as m, noChange as n, removeNodes as r };
1104
- //# sourceMappingURL=lit-html-3647afce.js.map