@startinblox/core 0.17.21-beta.9 → 0.17.22

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