@ui5/webcomponents-base 0.34.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. package/.eslintignore +3 -1
  2. package/CHANGELOG.md +52 -0
  3. package/README.md +26 -2
  4. package/bundle.esm.js +6 -2
  5. package/dist/CSP.js +59 -0
  6. package/dist/Device.js +7 -0
  7. package/dist/EventProvider.js +19 -25
  8. package/dist/FontFace.js +7 -95
  9. package/dist/InitialConfiguration.js +31 -14
  10. package/dist/Keys.js +15 -0
  11. package/dist/ManagedStyles.js +83 -0
  12. package/dist/Render.js +3 -1
  13. package/dist/StaticAreaItem.js +11 -9
  14. package/dist/SystemCSSVars.js +4 -25
  15. package/dist/UI5Element.js +46 -60
  16. package/dist/UI5ElementMetadata.js +9 -1
  17. package/dist/asset-registries/Icons.js +29 -8
  18. package/dist/asset-registries/Illustrations.js +30 -0
  19. package/dist/asset-registries/LocaleData.js +11 -2
  20. package/dist/assets-meta/IconCollectionsAlias.js +18 -0
  21. package/dist/config/Theme.js +14 -0
  22. package/dist/css/FontFace.css +45 -0
  23. package/dist/css/OverrideFontFace.css +32 -0
  24. package/dist/css/SystemCSSVars.css +17 -0
  25. package/dist/delegate/ItemNavigation.js +66 -0
  26. package/dist/delegate/ScrollEnablement.js +7 -1
  27. package/dist/generated/AssetParameters.js +1 -1
  28. package/dist/generated/css/FontFace.css.js +5 -0
  29. package/dist/generated/css/OverrideFontFace.css.js +5 -0
  30. package/dist/generated/css/SystemCSSVars.css.js +5 -0
  31. package/dist/i18nBundle.js +33 -2
  32. package/dist/renderer/LitRenderer.js +24 -21
  33. package/dist/renderer/directives/style-map.js +72 -0
  34. package/dist/resources/bundle.esm.js +17 -101
  35. package/dist/resources/bundle.esm.js.map +1 -1
  36. package/dist/sap/base/Log.js +241 -0
  37. package/dist/sap/base/assert.js +8 -0
  38. package/dist/sap/base/security/URLListValidator.js +148 -0
  39. package/dist/sap/base/security/sanitizeHTML.js +16 -0
  40. package/dist/sap/base/util/now.js +7 -0
  41. package/dist/sap/ui/thirdparty/caja-html-sanitizer.js +3585 -0
  42. package/dist/test-resources/elements/WithStaticArea.js +2 -1
  43. package/dist/test-resources/pages/AllTestElements.html +3 -0
  44. package/dist/test-resources/pages/i18n.html +1 -3
  45. package/dist/test-resources/specs/ConfigurationChange.spec.js +9 -9
  46. package/dist/test-resources/specs/ConfigurationScript.spec.js +24 -24
  47. package/dist/test-resources/specs/ConfigurationURL.spec.js +64 -18
  48. package/dist/test-resources/specs/CustomTheme.spec.js +7 -7
  49. package/dist/test-resources/specs/EventProvider.spec.js +63 -0
  50. package/dist/test-resources/specs/StaticArea.spec.js +55 -13
  51. package/dist/test-resources/specs/Theming.spec.js +11 -11
  52. package/dist/test-resources/specs/UI5ElementInvalidation.js +29 -29
  53. package/dist/test-resources/specs/UI5ElementLifecycle.js +11 -11
  54. package/dist/test-resources/specs/UI5ElementListenForChildPropChanges.spec.js +11 -11
  55. package/dist/test-resources/specs/UI5ElementMetadataExt.js +8 -8
  56. package/dist/test-resources/specs/UI5ElementPropertyValidation.js +6 -6
  57. package/dist/test-resources/specs/UI5ElementPropsAndAttrs.spec.js +36 -36
  58. package/dist/test-resources/specs/UI5ElementShadowDOM.js +9 -9
  59. package/dist/test-resources/specs/UI5ElementSlots.js +9 -9
  60. package/dist/theming/CustomStyle.js +23 -3
  61. package/dist/theming/applyTheme.js +5 -8
  62. package/dist/theming/getEffectiveLinksHrefs.js +20 -0
  63. package/dist/theming/getStylesString.js +4 -2
  64. package/dist/theming/getThemeDesignerTheme.js +2 -1
  65. package/dist/theming/preloadLinks.js +23 -0
  66. package/dist/types/DataType.js +12 -0
  67. package/dist/types/Float.js +4 -0
  68. package/dist/types/Integer.js +4 -0
  69. package/dist/types/InvisibleMessageMode.js +30 -0
  70. package/dist/updateShadowRoot.js +8 -4
  71. package/dist/util/AriaLabelHelper.js +4 -4
  72. package/dist/util/FocusableElements.js +5 -1
  73. package/dist/util/HTMLSanitizer.js +7 -0
  74. package/dist/util/InvisibleMessage.js +58 -0
  75. package/dist/util/PopupUtils.js +1 -1
  76. package/dist/util/TabbableElements.js +1 -1
  77. package/dist/util/createLinkInHead.js +19 -0
  78. package/dist/util/encodeXML.js +35 -0
  79. package/dist/util/escapeRegex.js +10 -0
  80. package/dist/util/generateHighlightedMarkup.js +42 -0
  81. package/dist/util/getClassCopy.js +7 -2
  82. package/dist/util/isNodeTabbable.js +4 -4
  83. package/hash.txt +1 -1
  84. package/index.js +1 -1
  85. package/lib/generate-asset-parameters/index.js +0 -1
  86. package/lib/generate-styles/index.js +18 -0
  87. package/package-scripts.js +25 -3
  88. package/package.json +17 -9
  89. package/src/CSP.js +59 -0
  90. package/src/Device.js +7 -0
  91. package/src/EventProvider.js +19 -25
  92. package/src/FontFace.js +7 -95
  93. package/src/InitialConfiguration.js +31 -14
  94. package/src/Keys.js +15 -0
  95. package/src/ManagedStyles.js +83 -0
  96. package/src/Render.js +3 -1
  97. package/src/StaticAreaItem.js +11 -9
  98. package/src/SystemCSSVars.js +4 -25
  99. package/src/UI5Element.js +46 -60
  100. package/src/UI5ElementMetadata.js +9 -1
  101. package/src/asset-registries/Icons.js +29 -8
  102. package/src/asset-registries/Illustrations.js +30 -0
  103. package/src/asset-registries/LocaleData.js +11 -2
  104. package/src/assets-meta/IconCollectionsAlias.js +18 -0
  105. package/src/config/Theme.js +14 -0
  106. package/src/css/FontFace.css +45 -0
  107. package/src/css/OverrideFontFace.css +32 -0
  108. package/src/css/SystemCSSVars.css +17 -0
  109. package/src/delegate/ItemNavigation.js +66 -0
  110. package/src/delegate/ScrollEnablement.js +7 -1
  111. package/src/i18nBundle.js +33 -2
  112. package/src/renderer/LitRenderer.js +24 -21
  113. package/src/renderer/directives/style-map.js +72 -0
  114. package/src/theming/CustomStyle.js +23 -3
  115. package/src/theming/applyTheme.js +5 -8
  116. package/src/theming/getEffectiveLinksHrefs.js +20 -0
  117. package/src/theming/getStylesString.js +4 -2
  118. package/src/theming/getThemeDesignerTheme.js +2 -1
  119. package/src/theming/preloadLinks.js +23 -0
  120. package/src/types/DataType.js +12 -0
  121. package/src/types/Float.js +4 -0
  122. package/src/types/Integer.js +4 -0
  123. package/src/types/InvisibleMessageMode.js +30 -0
  124. package/src/updateShadowRoot.js +8 -4
  125. package/src/util/AriaLabelHelper.js +4 -4
  126. package/src/util/FocusableElements.js +5 -1
  127. package/src/util/HTMLSanitizer.js +7 -0
  128. package/src/util/InvisibleMessage.js +58 -0
  129. package/src/util/PopupUtils.js +1 -1
  130. package/src/util/TabbableElements.js +1 -1
  131. package/src/util/createLinkInHead.js +19 -0
  132. package/src/util/encodeXML.js +35 -0
  133. package/src/util/escapeRegex.js +10 -0
  134. package/src/util/generateHighlightedMarkup.js +42 -0
  135. package/src/util/getClassCopy.js +7 -2
  136. package/src/util/isNodeTabbable.js +4 -4
  137. package/used-modules.txt +7 -0
  138. package/dist/config/AssetsPath.js +0 -17
  139. package/dist/renderer/ifDefined.js +0 -21
  140. package/dist/renderer/scopeHTML.js +0 -32
  141. package/dist/theming/createThemePropertiesStyleTag.js +0 -20
  142. package/src/config/AssetsPath.js +0 -17
  143. package/src/renderer/ifDefined.js +0 -21
  144. package/src/renderer/scopeHTML.js +0 -32
  145. package/src/theming/createThemePropertiesStyleTag.js +0 -20
@@ -5,6 +5,8 @@ import {
5
5
  isRight,
6
6
  isHome,
7
7
  isEnd,
8
+ isPageDown,
9
+ isPageUp,
8
10
  } from "../Keys.js";
9
11
  import getActiveElement from "../util/getActiveElement.js";
10
12
 
@@ -52,6 +54,7 @@ class ItemNavigation {
52
54
  * - currentIndex: the index of the item that will be initially selected (from which navigation will begin)
53
55
  * - navigationMode (Auto|Horizontal|Vertical): whether the items are displayed horizontally (Horizontal), vertically (Vertical) or as a matrix (Auto) meaning the user can navigate in both directions (up/down and left/right)
54
56
  * - rowSize: tells how many items per row there are when the items are not rendered as a flat list but rather as a matrix. Relevant for navigationMode=Auto
57
+ * - skipItemsSize: tells how many items upon PAGE_UP and PAGE_DOWN should be skipped to applying the focus on the next item
55
58
  * - behavior (Static|Cycling): tells what to do when trying to navigate beyond the first and last items
56
59
  * Static means that nothing happens if the user tries to navigate beyond the first/last item.
57
60
  * Cycling means that when the user navigates beyond the last item they go to the first and vice versa.
@@ -85,6 +88,7 @@ class ItemNavigation {
85
88
  this._behavior = options.behavior || ItemNavigationBehavior.Static;
86
89
  this._navigationMode = options.navigationMode || NavigationMode.Auto;
87
90
  this._affectedPropertiesNames = options.affectedPropertiesNames || [];
91
+ this._skipItemsSize = options.skipItemsSize || null;
88
92
  }
89
93
 
90
94
  /**
@@ -142,6 +146,10 @@ class ItemNavigation {
142
146
  this._handleHome();
143
147
  } else if (isEnd(event)) {
144
148
  this._handleEnd();
149
+ } else if (isPageUp(event)) {
150
+ this._handlePageUp();
151
+ } else if (isPageDown(event)) {
152
+ this._handlePageDown();
145
153
  } else {
146
154
  return; // if none of the supported keys is pressed, we don't want to prevent the event or update the item navigation
147
155
  }
@@ -222,6 +230,64 @@ class ItemNavigation {
222
230
  this._currentIndex += (homeEndRange - 1 - this._currentIndex % homeEndRange); // eslint-disable-line
223
231
  }
224
232
 
233
+ _handlePageUp() {
234
+ if (this._rowSize > 1) {
235
+ // eslint-disable-next-line
236
+ // TODO: handle page up on matrix (grid) layout - ColorPalette, ProductSwitch.
237
+ return;
238
+ }
239
+ this._handlePageUpFlat();
240
+ }
241
+
242
+ _handlePageDown() {
243
+ if (this._rowSize > 1) {
244
+ // eslint-disable-next-line
245
+ // TODO: handle page up on matrix (grid) layout - ColorPalette, ProductSwitch.
246
+ return;
247
+ }
248
+ this._handlePageDownFlat();
249
+ }
250
+
251
+ /**
252
+ * Handles PAGE_UP in a flat list-like structure, both vertically and horizontally.
253
+ */
254
+ _handlePageUpFlat() {
255
+ if (this._skipItemsSize === null) {
256
+ // Move the focus to the very top (as Home).
257
+ this._currentIndex -= this._currentIndex;
258
+ }
259
+
260
+ if (this._currentIndex + 1 > this._skipItemsSize) {
261
+ // When there are more than "skipItemsSize" number of items to the top,
262
+ // move the focus up/left with the predefined number.
263
+ this._currentIndex -= this._skipItemsSize;
264
+ } else {
265
+ // Otherwise, move the focus to the very top (as Home).
266
+ this._currentIndex -= this._currentIndex;
267
+ }
268
+ }
269
+
270
+ /**
271
+ * Handles PAGE_DOWN in a flat list-like structure, both vertically and horizontally.
272
+ */
273
+ _handlePageDownFlat() {
274
+ if (this._skipItemsSize === null) {
275
+ // Move the focus to the very bottom (as End).
276
+ this._currentIndex = this._getItems().length - 1;
277
+ }
278
+
279
+ const currentToEndRange = this._getItems().length - this._currentIndex - 1;
280
+
281
+ if (currentToEndRange > this._skipItemsSize) {
282
+ // When there are more than "skipItemsSize" number of items until the bottom,
283
+ // move the focus down/right with the predefined number.
284
+ this._currentIndex += this._skipItemsSize;
285
+ } else {
286
+ // Otherwise, move the focus to the very bottom (as End).
287
+ this._currentIndex = this._getItems().length - 1;
288
+ }
289
+ }
290
+
225
291
  _applyTabIndex() {
226
292
  const items = this._getItems();
227
293
  for (let i = 0; i < items.length; i++) {
@@ -70,7 +70,13 @@ class ScrollEnablement extends EventProvider {
70
70
  this._container.scrollTop = top;
71
71
  }
72
72
 
73
- move(dx, dy) {
73
+ move(dx, dy, disableAnimation) {
74
+ if (disableAnimation) {
75
+ this._container.scrollLeft += dx;
76
+ this._container.scrollTop += dy;
77
+ return;
78
+ }
79
+
74
80
  return scroll({
75
81
  element: this._container,
76
82
  dx,
@@ -1,4 +1,4 @@
1
- const assetParameters = {"themes":{"default":"sap_fiori_3","all":["sap_fiori_3","sap_fiori_3_dark","sap_belize","sap_belize_hcb","sap_belize_hcw","sap_fiori_3_hcb","sap_fiori_3_hcw"]},"languages":{"default":"en","all":["ar","bg","ca","cs","cy","da","de","el","en","en_GB","en_US_sappsd","en_US_saprigi","en_US_saptrc","es","es_MX","et","fi","fr","fr_CA","hi","hr","hu","in","it","iw","ja","kk","ko","lt","lv","ms","nl","no","pl","pt_PT","pt","ro","ru","sh","sk","sl","sv","th","tr","uk","vi","zh_CN","zh_TW"]},"locales":{"default":"en","all":["ar","ar_EG","ar_SA","bg","ca","cs","da","de","de_AT","de_CH","el","el_CY","en","en_AU","en_GB","en_HK","en_IE","en_IN","en_NZ","en_PG","en_SG","en_ZA","es","es_AR","es_BO","es_CL","es_CO","es_MX","es_PE","es_UY","es_VE","et","fa","fi","fr","fr_BE","fr_CA","fr_CH","fr_LU","he","hi","hr","hu","id","it","it_CH","ja","kk","ko","lt","lv","ms","nb","nl","nl_BE","pl","pt","pt_PT","ro","ru","ru_UA","sk","sl","sr","sv","th","tr","uk","vi","zh_CN","zh_HK","zh_SG","zh_TW"]}};
1
+ const assetParameters = {"themes":{"default":"sap_fiori_3","all":["sap_fiori_3","sap_fiori_3_dark","sap_belize","sap_belize_hcb","sap_belize_hcw","sap_fiori_3_hcb","sap_fiori_3_hcw","sap_horizon","sap_horizon_exp"]},"languages":{"default":"en","all":["ar","bg","ca","cs","cy","da","de","el","en","en_GB","en_US_sappsd","en_US_saprigi","en_US_saptrc","es","es_MX","et","fi","fr","fr_CA","hi","hr","hu","in","it","iw","ja","kk","ko","lt","lv","ms","nl","no","pl","pt_PT","pt","ro","ru","sh","sk","sl","sv","th","tr","uk","vi","zh_CN","zh_TW"]},"locales":{"default":"en","all":["ar","ar_EG","ar_SA","bg","ca","cs","da","de","de_AT","de_CH","el","el_CY","en","en_AU","en_GB","en_HK","en_IE","en_IN","en_NZ","en_PG","en_SG","en_ZA","es","es_AR","es_BO","es_CL","es_CO","es_MX","es_PE","es_UY","es_VE","et","fa","fi","fr","fr_BE","fr_CA","fr_CH","fr_LU","he","hi","hr","hu","id","it","it_CH","ja","kk","ko","lt","lv","ms","nb","nl","nl_BE","pl","pt","pt_PT","ro","ru","ru_UA","sk","sl","sr","sv","th","tr","uk","vi","zh_CN","zh_HK","zh_SG","zh_TW"]}};
2
2
 
3
3
  const DEFAULT_THEME = assetParameters.themes.default;
4
4
  const DEFAULT_LANGUAGE = assetParameters.languages.default;
@@ -0,0 +1,5 @@
1
+ export default {
2
+ packageName: "@ui5/webcomponents-base",
3
+ fileName: "FontFace.css",
4
+ content: `@font-face{font-family:"72";font-style:normal;font-weight:400;src:local("72"),url(https://ui5.sap.com/sdk/resources/sap/ui/core/themes/sap_fiori_3/fonts/72-Regular.woff2?ui5-webcomponents) format("woff2"),url(https://ui5.sap.com/sdk/resources/sap/ui/core/themes/sap_fiori_3/fonts/72-Regular.woff?ui5-webcomponents) format("woff")}@font-face{font-family:"72full";font-style:normal;font-weight:400;src:local('72-full'),url(https://ui5.sap.com/sdk/resources/sap/ui/core/themes/sap_fiori_3/fonts/72-Regular-full.woff2?ui5-webcomponents) format("woff2"),url(https://ui5.sap.com/sdk/resources/sap/ui/core/themes/sap_fiori_3/fonts/72-Regular-full.woff?ui5-webcomponents) format("woff")}@font-face{font-family:"72";font-style:normal;font-weight:700;src:local('72-Bold'),url(https://ui5.sap.com/sdk/resources/sap/ui/core/themes/sap_fiori_3/fonts/72-Bold.woff2?ui5-webcomponents) format("woff2"),url(https://ui5.sap.com/sdk/resources/sap/ui/core/themes/sap_fiori_3/fonts/72-Bold.woff?ui5-webcomponents) format("woff")}@font-face{font-family:"72full";font-style:normal;font-weight:700;src:local('72-Bold-full'),url(https://ui5.sap.com/sdk/resources/sap/ui/core/themes/sap_fiori_3/fonts/72-Bold-full.woff2?ui5-webcomponents) format("woff2"),url(https://ui5.sap.com/sdk/resources/sap/ui/core/themes/sap_fiori_3/fonts/72-Bold-full.woff?ui5-webcomponents) format("woff")}@font-face{font-family:"72Black";font-style:bold;font-weight:900;src:local('72Black'),url(https://openui5nightly.hana.ondemand.com/resources/sap/ui/core/themes/sap_horizon/fonts/72-Black.woff2?ui5-webcomponents) format("woff2"),url(https://openui5nightly.hana.ondemand.com/resources/sap/ui/core/themes/sap_horizon/fonts/72-Black.woff?ui5-webcomponents) format("woff")}`
5
+ };
@@ -0,0 +1,5 @@
1
+ export default {
2
+ packageName: "@ui5/webcomponents-base",
3
+ fileName: "OverrideFontFace.css",
4
+ content: `@font-face{font-family:'72override';unicode-range:U+0102-0103,U+01A0-01A1,U+01AF-01B0,U+1EA0-1EB7,U+1EB8-1EC7,U+1EC8-1ECB,U+1ECC-1EE3,U+1EE4-1EF1,U+1EF4-1EF7;src:local('Arial'),local('Helvetica'),local('sans-serif')}`
5
+ };
@@ -0,0 +1,5 @@
1
+ export default {
2
+ packageName: "@ui5/webcomponents-base",
3
+ fileName: "SystemCSSVars.css",
4
+ content: `:root{--_ui5_content_density:cozy}.sapUiSizeCompact,.ui5-content-density-compact,[data-ui5-compact-size]{--_ui5_content_density:compact}[dir=rtl]{--_ui5_dir:rtl}[dir=ltr]{--_ui5_dir:ltr}`
5
+ };
@@ -3,6 +3,8 @@ import formatMessage from "./util/formatMessage.js";
3
3
 
4
4
  const I18nBundleInstances = new Map();
5
5
 
6
+ let customGetI18nBundle;
7
+
6
8
  /**
7
9
  * @class
8
10
  * @public
@@ -15,6 +17,7 @@ class I18nBundle {
15
17
  /**
16
18
  * Returns a text in the currently loaded language
17
19
  *
20
+ * @public
18
21
  * @param {Object|String} textObj key/defaultText pair or just the key
19
22
  * @param params Values for the placeholders
20
23
  * @returns {*}
@@ -38,7 +41,7 @@ class I18nBundle {
38
41
  }
39
42
  }
40
43
 
41
- const getI18nBundle = packageName => {
44
+ const getI18nBundleSync = packageName => {
42
45
  if (I18nBundleInstances.has(packageName)) {
43
46
  return I18nBundleInstances.get(packageName);
44
47
  }
@@ -48,8 +51,36 @@ const getI18nBundle = packageName => {
48
51
  return i18nBundle;
49
52
  };
50
53
 
54
+ /**
55
+ * Allows developers to provide a custom getI18nBundle implementation
56
+ * If this function is called, the custom implementation will be used for all components and will completely
57
+ * replace the default implementation.
58
+ *
59
+ * @public
60
+ * @param customGet the function to use instead of the standard getI18nBundle implementation
61
+ */
62
+ const registerCustomI18nBundleGetter = customGet => {
63
+ customGetI18nBundle = customGet;
64
+ };
65
+
66
+ /**
67
+ * Fetches and returns the I18nBundle instance for the given package
68
+ *
69
+ * @public
70
+ * @param packageName
71
+ * @returns {Promise<I18nBundle>}
72
+ */
73
+ const getI18nBundle = async packageName => {
74
+ if (customGetI18nBundle) {
75
+ return customGetI18nBundle(packageName);
76
+ }
77
+
78
+ await fetchI18nBundle(packageName);
79
+ return getI18nBundleSync(packageName);
80
+ };
81
+
51
82
  export {
52
83
  registerI18nLoader,
53
- fetchI18nBundle,
54
84
  getI18nBundle,
85
+ registerCustomI18nBundleGetter,
55
86
  };
@@ -1,31 +1,34 @@
1
- import { html, svg, render } from "lit-html/lit-html.js";
2
- import scopeHTML from "./scopeHTML.js";
1
+ import { render } from "lit-html";
2
+ import {
3
+ html,
4
+ svg,
5
+ unsafeStatic,
6
+ } from "lit-html/static.js";
3
7
 
4
- let tags;
5
- let suffix;
6
-
7
- const setTags = t => {
8
- tags = t;
9
- };
10
- const setSuffix = s => {
11
- suffix = s;
12
- };
13
-
14
- const litRender = (templateResult, domNode, styles, { eventContext } = {}) => {
15
- if (styles) {
16
- templateResult = html`<style>${styles}</style>${templateResult}`;
8
+ const litRender = (templateResult, domNode, styleStrOrHrefsArr, { host } = {}) => {
9
+ if (typeof styleStrOrHrefsArr === "string") {
10
+ templateResult = html`<style>${styleStrOrHrefsArr}</style>${templateResult}`;
11
+ } else if (Array.isArray(styleStrOrHrefsArr) && styleStrOrHrefsArr.length) {
12
+ templateResult = html`${styleStrOrHrefsArr.map(href => html`<link type="text/css" rel="stylesheet" href="${href}">`)}${templateResult}`;
17
13
  }
18
- render(templateResult, domNode, { eventContext });
14
+ render(templateResult, domNode, { host });
19
15
  };
20
16
 
21
- const scopedHtml = (strings, ...values) => html(scopeHTML(strings, tags, suffix), ...values);
22
- const scopedSvg = (strings, ...values) => svg(scopeHTML(strings, tags, suffix), ...values);
17
+ const scopeTag = (tag, tags, suffix) => {
18
+ const resultTag = suffix && (tags || []).includes(tag) ? `${tag}-${suffix}` : tag;
19
+ return unsafeStatic(resultTag);
20
+ };
23
21
 
24
- export { setTags, setSuffix };
25
- export { scopedHtml as html, scopedSvg as svg };
22
+ export {
23
+ html,
24
+ svg,
25
+ unsafeStatic,
26
+ };
27
+ export { scopeTag };
26
28
  export { repeat } from "lit-html/directives/repeat.js";
27
29
  export { classMap } from "lit-html/directives/class-map.js";
28
- export { styleMap } from "lit-html/directives/style-map.js";
30
+ export { styleMap } from "./directives/style-map.js";
31
+ export { ifDefined } from "lit-html/directives/if-defined.js";
29
32
  export { unsafeHTML } from "lit-html/directives/unsafe-html.js";
30
33
 
31
34
  export default litRender;
@@ -0,0 +1,72 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2018 Google LLC
4
+ * SPDX-License-Identifier: BSD-3-Clause
5
+ */
6
+
7
+ /**
8
+ * This is the original style-map.js directive from lit-html 2 with the only difference that "render" is not called even for the first rendering (update is used instead)
9
+ */
10
+
11
+ import { noChange } from 'lit-html';
12
+ import { directive, Directive, PartType, } from 'lit-html/directive.js';
13
+ class StyleMapDirective extends Directive {
14
+ constructor(partInfo) {
15
+ var _a;
16
+ super(partInfo);
17
+ if (partInfo.type !== PartType.ATTRIBUTE ||
18
+ partInfo.name !== 'style' ||
19
+ ((_a = partInfo.strings) === null || _a === void 0 ? void 0 : _a.length) > 2) {
20
+ throw new Error('The `styleMap` directive must be used in the `style` attribute ' +
21
+ 'and must be the only part in the attribute.');
22
+ }
23
+ }
24
+ render(styleInfo) {
25
+ return "";
26
+ }
27
+ update(part, [styleInfo]) {
28
+ const { style } = part.element;
29
+ if (this._previousStyleProperties === undefined) {
30
+ this._previousStyleProperties = new Set();
31
+ for (const name in styleInfo) {
32
+ this._previousStyleProperties.add(name);
33
+ }
34
+ // return this.render(styleInfo);
35
+ }
36
+ // Remove old properties that no longer exist in styleInfo
37
+ // We use forEach() instead of for-of so that re don't require down-level
38
+ // iteration.
39
+ this._previousStyleProperties.forEach((name) => {
40
+ // If the name isn't in styleInfo or it's null/undefined
41
+ if (styleInfo[name] == null) {
42
+ this._previousStyleProperties.delete(name);
43
+ if (name.includes('-')) {
44
+ style.removeProperty(name);
45
+ }
46
+ else {
47
+ // Note reset using empty string (vs null) as IE11 does not always
48
+ // reset via null (https://developer.mozilla.org/en-US/docs/Web/API/ElementCSSInlineStyle/style#setting_styles)
49
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
50
+ style[name] = '';
51
+ }
52
+ }
53
+ });
54
+ // Add or update properties
55
+ for (const name in styleInfo) {
56
+ const value = styleInfo[name];
57
+ if (value != null) {
58
+ this._previousStyleProperties.add(name);
59
+ if (name.includes('-')) {
60
+ style.setProperty(name, value);
61
+ }
62
+ else {
63
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
64
+ style[name] = value;
65
+ }
66
+ }
67
+ }
68
+ return noChange;
69
+ }
70
+ }
71
+
72
+ export const styleMap = directive(StyleMapDirective);