@statistikzh/leu 0.21.0 → 0.21.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 (74) hide show
  1. package/.release-please-manifest.json +1 -1
  2. package/CHANGELOG.md +7 -0
  3. package/dist/Accordion.js +1 -1
  4. package/dist/Button.js +1 -1
  5. package/dist/ButtonGroup.js +1 -1
  6. package/dist/ChartWrapper.js +1 -1
  7. package/dist/Checkbox.js +1 -1
  8. package/dist/CheckboxGroup.js +1 -1
  9. package/dist/Chip.js +1 -1
  10. package/dist/ChipGroup.js +1 -1
  11. package/dist/ChipLink.js +1 -1
  12. package/dist/ChipRemovable.js +1 -1
  13. package/dist/ChipSelectable.js +1 -1
  14. package/dist/Dialog.js +1 -1
  15. package/dist/Dropdown.js +1 -1
  16. package/dist/FileInput.js +2 -2
  17. package/dist/Icon.js +1 -1
  18. package/dist/Input.js +1 -1
  19. package/dist/{LeuElement-BFljD2fO.js → LeuElement-BLUQU9Eu.js} +1 -1
  20. package/dist/Menu.js +1 -1
  21. package/dist/MenuItem.js +1 -1
  22. package/dist/Message.js +1 -1
  23. package/dist/Pagination.js +1 -1
  24. package/dist/Placeholder.js +1 -1
  25. package/dist/Popup.js +1 -1
  26. package/dist/ProgressBar.js +1 -1
  27. package/dist/Radio.js +1 -1
  28. package/dist/RadioGroup.js +1 -1
  29. package/dist/Range.js +1 -1
  30. package/dist/ScrollTop.js +1 -1
  31. package/dist/Select.js +1 -1
  32. package/dist/Spinner.js +1 -1
  33. package/dist/Table.js +97 -3
  34. package/dist/Tag.js +1 -1
  35. package/dist/VisuallyHidden.js +1 -1
  36. package/dist/components/table/Table.d.ts.map +1 -1
  37. package/dist/index.js +2 -2
  38. package/dist/leu-accordion.js +1 -1
  39. package/dist/leu-button-group.js +1 -1
  40. package/dist/leu-button.js +1 -1
  41. package/dist/leu-chart-wrapper.js +1 -1
  42. package/dist/leu-checkbox-group.js +1 -1
  43. package/dist/leu-checkbox.js +1 -1
  44. package/dist/leu-chip-group.js +1 -1
  45. package/dist/leu-chip-link.js +1 -1
  46. package/dist/leu-chip-removable.js +1 -1
  47. package/dist/leu-chip-selectable.js +1 -1
  48. package/dist/leu-dialog.js +1 -1
  49. package/dist/leu-dropdown.js +1 -1
  50. package/dist/leu-file-input.js +2 -2
  51. package/dist/leu-icon.js +1 -1
  52. package/dist/leu-input.js +1 -1
  53. package/dist/leu-menu-item.js +1 -1
  54. package/dist/leu-menu.js +1 -1
  55. package/dist/leu-message.js +1 -1
  56. package/dist/leu-pagination.js +1 -1
  57. package/dist/leu-placeholder.js +1 -1
  58. package/dist/leu-popup.js +1 -1
  59. package/dist/leu-progress-bar.js +1 -1
  60. package/dist/leu-radio-group.js +1 -1
  61. package/dist/leu-radio.js +1 -1
  62. package/dist/leu-range.js +1 -1
  63. package/dist/leu-scroll-top.js +1 -1
  64. package/dist/leu-select.js +1 -1
  65. package/dist/leu-spinner.js +1 -1
  66. package/dist/leu-table.js +2 -2
  67. package/dist/leu-tag.js +1 -1
  68. package/dist/leu-visually-hidden.js +1 -1
  69. package/dist/lib/styleMap.d.ts +61 -0
  70. package/dist/lib/styleMap.d.ts.map +1 -0
  71. package/dist/web-types.json +1 -1
  72. package/package.json +1 -1
  73. package/src/components/table/Table.ts +1 -1
  74. package/src/lib/styleMap.ts +139 -0
@@ -1,3 +1,3 @@
1
1
  {
2
- ".": "0.21.0"
2
+ ".": "0.21.1"
3
3
  }
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.21.1](https://github.com/statistikZH/leu/compare/leu-v0.21.0...leu-v0.21.1) (2025-11-17)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * use custom implementation of the styleMap directive to be compatible with strict CSPs ([3a9a4d4](https://github.com/statistikZH/leu/commit/3a9a4d4a0685791ba35f4799b89c95e0f53eb037))
9
+
3
10
  ## [0.21.0](https://github.com/statistikZH/leu/compare/leu-v0.20.0...leu-v0.21.0) (2025-11-13)
4
11
 
5
12
 
package/dist/Accordion.js CHANGED
@@ -2,7 +2,7 @@ import { _ as __decorate } from './_tslib-CNEFicEt.js';
2
2
  import { css, nothing } from 'lit';
3
3
  import { unsafeStatic, html } from 'lit/static-html.js';
4
4
  import { property } from 'lit/decorators.js';
5
- import { L as LeuElement } from './LeuElement-BFljD2fO.js';
5
+ import { L as LeuElement } from './LeuElement-BLUQU9Eu.js';
6
6
 
7
7
  var css_248z = css`:host {
8
8
  --accordion-font-regular: var(--leu-font-family-regular);
package/dist/Button.js CHANGED
@@ -4,7 +4,7 @@ import { classMap } from 'lit/directives/class-map.js';
4
4
  import { ifDefined } from 'lit/directives/if-defined.js';
5
5
  import { property } from 'lit/decorators.js';
6
6
  import { LeuIcon } from './Icon.js';
7
- import { L as LeuElement } from './LeuElement-BFljD2fO.js';
7
+ import { L as LeuElement } from './LeuElement-BLUQU9Eu.js';
8
8
  import { H as HasSlotController } from './hasSlotController-Bm2tipvG.js';
9
9
 
10
10
  /**
@@ -1,5 +1,5 @@
1
1
  import { css, html } from 'lit';
2
- import { L as LeuElement } from './LeuElement-BFljD2fO.js';
2
+ import { L as LeuElement } from './LeuElement-BLUQU9Eu.js';
3
3
  import { LeuButton } from './Button.js';
4
4
  import './_tslib-CNEFicEt.js';
5
5
  import 'lit/directives/class-map.js';
@@ -1,7 +1,7 @@
1
1
  import { _ as __decorate } from './_tslib-CNEFicEt.js';
2
2
  import { css, nothing, html } from 'lit';
3
3
  import { property } from 'lit/decorators.js';
4
- import { L as LeuElement } from './LeuElement-BFljD2fO.js';
4
+ import { L as LeuElement } from './LeuElement-BLUQU9Eu.js';
5
5
  import { H as HasSlotController } from './hasSlotController-Bm2tipvG.js';
6
6
  import { LeuSpinner } from './Spinner.js';
7
7
 
package/dist/Checkbox.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { _ as __decorate } from './_tslib-CNEFicEt.js';
2
2
  import { css, html } from 'lit';
3
3
  import { property } from 'lit/decorators.js';
4
- import { L as LeuElement } from './LeuElement-BFljD2fO.js';
4
+ import { L as LeuElement } from './LeuElement-BLUQU9Eu.js';
5
5
  import { LeuIcon } from './Icon.js';
6
6
 
7
7
  var css_248z = css`:host {
@@ -2,7 +2,7 @@ import { _ as __decorate } from './_tslib-CNEFicEt.js';
2
2
  import { css, html } from 'lit';
3
3
  import { classMap } from 'lit/directives/class-map.js';
4
4
  import { property } from 'lit/decorators.js';
5
- import { L as LeuElement } from './LeuElement-BFljD2fO.js';
5
+ import { L as LeuElement } from './LeuElement-BLUQU9Eu.js';
6
6
  import { LeuCheckbox } from './Checkbox.js';
7
7
  import './Icon.js';
8
8
 
package/dist/Chip.js CHANGED
@@ -1,4 +1,4 @@
1
- import { L as LeuElement } from './LeuElement-BFljD2fO.js';
1
+ import { L as LeuElement } from './LeuElement-BLUQU9Eu.js';
2
2
  import { css } from 'lit';
3
3
 
4
4
  var css_248z = css`:host *::before,
package/dist/ChipGroup.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { unsafeStatic, html } from 'lit/static-html.js';
2
- import { L as LeuElement } from './LeuElement-BFljD2fO.js';
2
+ import { L as LeuElement } from './LeuElement-BLUQU9Eu.js';
3
3
  import { css } from 'lit';
4
4
 
5
5
  var css_248z = css`.label {
package/dist/ChipLink.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { html } from 'lit';
2
2
  import { LeuChipBase } from './Chip.js';
3
- import './LeuElement-BFljD2fO.js';
3
+ import './LeuElement-BLUQU9Eu.js';
4
4
 
5
5
  const SIZES = {
6
6
  regular: "regular",
@@ -1,7 +1,7 @@
1
1
  import { html } from 'lit';
2
2
  import { LeuChipBase } from './Chip.js';
3
3
  import { LeuIcon } from './Icon.js';
4
- import './LeuElement-BFljD2fO.js';
4
+ import './LeuElement-BLUQU9Eu.js';
5
5
  import './_tslib-CNEFicEt.js';
6
6
  import 'lit/decorators.js';
7
7
 
@@ -1,6 +1,6 @@
1
1
  import { html } from 'lit';
2
2
  import { LeuChipBase } from './Chip.js';
3
- import './LeuElement-BFljD2fO.js';
3
+ import './LeuElement-BLUQU9Eu.js';
4
4
 
5
5
  const SIZES = {
6
6
  small: "small",
package/dist/Dialog.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { css, nothing, html } from 'lit';
2
2
  import { createRef, ref } from 'lit/directives/ref.js';
3
3
  import { classMap } from 'lit/directives/class-map.js';
4
- import { L as LeuElement } from './LeuElement-BFljD2fO.js';
4
+ import { L as LeuElement } from './LeuElement-BLUQU9Eu.js';
5
5
  import { H as HasSlotController } from './hasSlotController-Bm2tipvG.js';
6
6
  import { LeuIcon } from './Icon.js';
7
7
  import './_tslib-CNEFicEt.js';
package/dist/Dropdown.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { css, nothing, html } from 'lit';
2
2
  import { createRef, ref } from 'lit/directives/ref.js';
3
- import { L as LeuElement } from './LeuElement-BFljD2fO.js';
3
+ import { L as LeuElement } from './LeuElement-BLUQU9Eu.js';
4
4
  import { H as HasSlotController } from './hasSlotController-Bm2tipvG.js';
5
5
  import { LeuButton } from './Button.js';
6
6
  import { LeuMenu } from './Menu.js';
package/dist/FileInput.js CHANGED
@@ -3,7 +3,7 @@ import { css, html, nothing } from 'lit';
3
3
  import { property, state, query } from 'lit/decorators.js';
4
4
  import { ifDefined } from 'lit/directives/if-defined.js';
5
5
  import { classMap } from 'lit/directives/class-map.js';
6
- import { L as LeuElement } from './LeuElement-BFljD2fO.js';
6
+ import { L as LeuElement } from './LeuElement-BLUQU9Eu.js';
7
7
  import './Accordion.js';
8
8
  import { LeuButton } from './Button.js';
9
9
  import './ButtonGroup.js';
@@ -34,7 +34,7 @@ import './Chip.js';
34
34
  import 'lit/directives/ref.js';
35
35
  import '@floating-ui/dom';
36
36
  import 'lit/directives/live.js';
37
- import 'lit/directives/style-map.js';
37
+ import 'lit/directive.js';
38
38
 
39
39
  var css_248z = css`:host {
40
40
  --file-input-font-regular: var(--leu-font-family-regular);
package/dist/Icon.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { _ as __decorate } from './_tslib-CNEFicEt.js';
2
2
  import { css, html, svg } from 'lit';
3
3
  import { property } from 'lit/decorators.js';
4
- import { L as LeuElement } from './LeuElement-BFljD2fO.js';
4
+ import { L as LeuElement } from './LeuElement-BLUQU9Eu.js';
5
5
 
6
6
  var css_248z = css`:host {
7
7
  display: contents;
package/dist/Input.js CHANGED
@@ -3,7 +3,7 @@ import { classMap } from 'lit/directives/class-map.js';
3
3
  import { ifDefined } from 'lit/directives/if-defined.js';
4
4
  import { live } from 'lit/directives/live.js';
5
5
  import { createRef, ref } from 'lit/directives/ref.js';
6
- import { L as LeuElement } from './LeuElement-BFljD2fO.js';
6
+ import { L as LeuElement } from './LeuElement-BLUQU9Eu.js';
7
7
  import { LeuIcon } from './Icon.js';
8
8
  import './_tslib-CNEFicEt.js';
9
9
  import 'lit/decorators.js';
@@ -35,7 +35,7 @@ class LeuElement extends LitElement {
35
35
  }
36
36
  }
37
37
  }
38
- LeuElement.version = "0.21.0";
38
+ LeuElement.version = "0.21.1";
39
39
  LeuElement.dependencies = {};
40
40
  LeuElement.styles = css_248z;
41
41
 
package/dist/Menu.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { css, html } from 'lit';
2
- import { L as LeuElement } from './LeuElement-BFljD2fO.js';
2
+ import { L as LeuElement } from './LeuElement-BLUQU9Eu.js';
3
3
  import { LeuMenuItem } from './MenuItem.js';
4
4
  import 'lit/directives/if-defined.js';
5
5
  import './Icon.js';
package/dist/MenuItem.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { css, html, nothing } from 'lit';
2
2
  import { ifDefined } from 'lit/directives/if-defined.js';
3
- import { L as LeuElement } from './LeuElement-BFljD2fO.js';
3
+ import { L as LeuElement } from './LeuElement-BLUQU9Eu.js';
4
4
  import { LeuIcon } from './Icon.js';
5
5
  import './_tslib-CNEFicEt.js';
6
6
  import 'lit/decorators.js';
package/dist/Message.js CHANGED
@@ -2,7 +2,7 @@ import { _ as __decorate } from './_tslib-CNEFicEt.js';
2
2
  import { css, html, nothing } from 'lit';
3
3
  import { property } from 'lit/decorators.js';
4
4
  import { classMap } from 'lit/directives/class-map.js';
5
- import { L as LeuElement } from './LeuElement-BFljD2fO.js';
5
+ import { L as LeuElement } from './LeuElement-BLUQU9Eu.js';
6
6
  import { LeuIcon } from './Icon.js';
7
7
  import { H as HasSlotController } from './hasSlotController-Bm2tipvG.js';
8
8
 
@@ -2,7 +2,7 @@ import { _ as __decorate } from './_tslib-CNEFicEt.js';
2
2
  import { css, html } from 'lit';
3
3
  import { live } from 'lit/directives/live.js';
4
4
  import { property, state } from 'lit/decorators.js';
5
- import { L as LeuElement } from './LeuElement-BFljD2fO.js';
5
+ import { L as LeuElement } from './LeuElement-BLUQU9Eu.js';
6
6
  import { LeuButton } from './Button.js';
7
7
  import { LeuVisuallyHidden } from './VisuallyHidden.js';
8
8
  import { LeuIcon } from './Icon.js';
@@ -1,5 +1,5 @@
1
1
  import { css, html } from 'lit';
2
- import { L as LeuElement } from './LeuElement-BFljD2fO.js';
2
+ import { L as LeuElement } from './LeuElement-BLUQU9Eu.js';
3
3
 
4
4
  var css_248z = css`:host {
5
5
  --placeholder-font-regular: var(--leu-font-family-regular);
package/dist/Popup.js CHANGED
@@ -2,7 +2,7 @@ import { _ as __decorate } from './_tslib-CNEFicEt.js';
2
2
  import { css, html } from 'lit';
3
3
  import { property } from 'lit/decorators.js';
4
4
  import { autoUpdate, size, flip, shift, computePosition } from '@floating-ui/dom';
5
- import { L as LeuElement } from './LeuElement-BFljD2fO.js';
5
+ import { L as LeuElement } from './LeuElement-BLUQU9Eu.js';
6
6
 
7
7
  var css_248z = css`:host {
8
8
  --popup-font-regular: var(--leu-font-family-regular);
@@ -2,7 +2,7 @@ import { _ as __decorate } from './_tslib-CNEFicEt.js';
2
2
  import { css, nothing, html } from 'lit';
3
3
  import { ifDefined } from 'lit/directives/if-defined.js';
4
4
  import { property } from 'lit/decorators.js';
5
- import { L as LeuElement } from './LeuElement-BFljD2fO.js';
5
+ import { L as LeuElement } from './LeuElement-BLUQU9Eu.js';
6
6
 
7
7
  var css_248z = css`/* :host {
8
8
  --progress-bar-font-regular: var(--leu-font-family-regular);
package/dist/Radio.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { _ as __decorate } from './_tslib-CNEFicEt.js';
2
2
  import { css, html } from 'lit';
3
3
  import { property } from 'lit/decorators.js';
4
- import { L as LeuElement } from './LeuElement-BFljD2fO.js';
4
+ import { L as LeuElement } from './LeuElement-BLUQU9Eu.js';
5
5
 
6
6
  var css_248z = css`:host {
7
7
  --radio-color: var(--leu-color-black-40);
@@ -2,7 +2,7 @@ import { _ as __decorate } from './_tslib-CNEFicEt.js';
2
2
  import { css, html } from 'lit';
3
3
  import { classMap } from 'lit/directives/class-map.js';
4
4
  import { property } from 'lit/decorators.js';
5
- import { L as LeuElement } from './LeuElement-BFljD2fO.js';
5
+ import { L as LeuElement } from './LeuElement-BLUQU9Eu.js';
6
6
  import { LeuRadio } from './Radio.js';
7
7
 
8
8
  var css_248z = css`:host {
package/dist/Range.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { css, html } from 'lit';
2
- import { L as LeuElement } from './LeuElement-BFljD2fO.js';
2
+ import { L as LeuElement } from './LeuElement-BLUQU9Eu.js';
3
3
 
4
4
  var css_248z = css`:host {
5
5
  --range-color: var(--leu-color-black-40);
package/dist/ScrollTop.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { css, html } from 'lit';
2
2
  import { classMap } from 'lit/directives/class-map.js';
3
- import { L as LeuElement } from './LeuElement-BFljD2fO.js';
3
+ import { L as LeuElement } from './LeuElement-BLUQU9Eu.js';
4
4
  import { LeuButton } from './Button.js';
5
5
  import { LeuIcon } from './Icon.js';
6
6
  import './_tslib-CNEFicEt.js';
package/dist/Select.js CHANGED
@@ -2,7 +2,7 @@ import { css, nothing, html } from 'lit';
2
2
  import { classMap } from 'lit/directives/class-map.js';
3
3
  import { createRef, ref } from 'lit/directives/ref.js';
4
4
  import { ifDefined } from 'lit/directives/if-defined.js';
5
- import { L as LeuElement } from './LeuElement-BFljD2fO.js';
5
+ import { L as LeuElement } from './LeuElement-BLUQU9Eu.js';
6
6
  import { H as HasSlotController } from './hasSlotController-Bm2tipvG.js';
7
7
  import { LeuButton } from './Button.js';
8
8
  import { LeuMenu } from './Menu.js';
package/dist/Spinner.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { css, html } from 'lit';
2
- import { L as LeuElement } from './LeuElement-BFljD2fO.js';
2
+ import { L as LeuElement } from './LeuElement-BLUQU9Eu.js';
3
3
 
4
4
  var css_248z = css`@keyframes leu-spinner-rotate {
5
5
  from {
package/dist/Table.js CHANGED
@@ -1,8 +1,8 @@
1
- import { css, html, nothing } from 'lit';
1
+ import { nothing, noChange, css, html } from 'lit';
2
2
  import { classMap } from 'lit/directives/class-map.js';
3
- import { styleMap } from 'lit/directives/style-map.js';
4
3
  import { createRef, ref } from 'lit/directives/ref.js';
5
- import { L as LeuElement } from './LeuElement-BFljD2fO.js';
4
+ import { L as LeuElement } from './LeuElement-BLUQU9Eu.js';
5
+ import { directive, Directive, PartType } from 'lit/directive.js';
6
6
  import { LeuIcon } from './Icon.js';
7
7
  import { LeuPagination } from './Pagination.js';
8
8
  import './_tslib-CNEFicEt.js';
@@ -13,6 +13,100 @@ import 'lit/directives/if-defined.js';
13
13
  import './hasSlotController-Bm2tipvG.js';
14
14
  import './VisuallyHidden.js';
15
15
 
16
+ /* eslint-disable prefer-template,no-param-reassign,no-restricted-syntax,guard-for-in */
17
+ /**
18
+ * The original lit styleMap directive is not compatible with a strict style-src content security policy.
19
+ * There is an an open issue about this in the lit repository:
20
+ * https://github.com/lit/lit/issues/4719
21
+ *
22
+ * This file contains a custom implementation of the styleMap directive that bypasses
23
+ * the render method and directly updates the styles using the .style.setProperty and
24
+ * .style.removeProperty methods.
25
+ *
26
+ * In the original implementation, the render method returns a string that is set as the
27
+ * value of the style attribute. This approach is blocked by strict CSPs that disallow
28
+ * inline styles.
29
+ *
30
+ * As we don't support SSR in this library, we can safely skip the render method.
31
+ */
32
+ const important = "important";
33
+ // The leading space is important
34
+ const importantFlag = " !" + important;
35
+ // How many characters to remove from a value, as a negative number
36
+ const flagTrim = 0 - importantFlag.length;
37
+ class StyleMapDirective extends Directive {
38
+ constructor(partInfo) {
39
+ super(partInfo);
40
+ if (partInfo.type !== PartType.ATTRIBUTE ||
41
+ partInfo.name !== "style" ||
42
+ partInfo.strings?.length > 2) {
43
+ throw new Error("The `styleMap` directive must be used in the `style` attribute " +
44
+ "and must be the only part in the attribute.");
45
+ }
46
+ }
47
+ render(_styleInfo) {
48
+ return nothing;
49
+ }
50
+ update(part, [styleInfo]) {
51
+ const { style } = part.element;
52
+ if (this._previousStyleProperties === undefined) {
53
+ this._previousStyleProperties = new Set(Object.keys(styleInfo));
54
+ }
55
+ // Remove old properties that no longer exist in styleInfo
56
+ for (const name of this._previousStyleProperties) {
57
+ // If the name isn't in styleInfo or it's null/undefined
58
+ if (styleInfo[name] == null) {
59
+ this._previousStyleProperties.delete(name);
60
+ if (name.includes("-")) {
61
+ style.removeProperty(name);
62
+ }
63
+ else {
64
+ style[name] = null;
65
+ }
66
+ }
67
+ }
68
+ // Add or update properties
69
+ for (const name in styleInfo) {
70
+ const value = styleInfo[name];
71
+ if (value != null) {
72
+ this._previousStyleProperties.add(name);
73
+ const isImportant = typeof value === "string" && value.endsWith(importantFlag);
74
+ if (name.includes("-") || isImportant) {
75
+ style.setProperty(name, isImportant
76
+ ? value.slice(0, flagTrim)
77
+ : value, isImportant ? important : "");
78
+ }
79
+ else {
80
+ style[name] = value;
81
+ }
82
+ }
83
+ }
84
+ return noChange;
85
+ }
86
+ }
87
+ /**
88
+ * !A custom implementation of lit's `styleMap` directive!
89
+ * A directive that applies CSS properties to an element.
90
+ *
91
+ * `styleMap` can only be used in the `style` attribute and must be the only
92
+ * expression in the attribute. It takes the property names in the
93
+ * {@link StyleInfo styleInfo} object and adds the properties to the inline
94
+ * style of the element.
95
+ *
96
+ * Property names with dashes (`-`) are assumed to be valid CSS
97
+ * property names and set on the element's style object using `setProperty()`.
98
+ * Names without dashes are assumed to be camelCased JavaScript property names
99
+ * and set on the element's style object using property assignment, allowing the
100
+ * style object to translate JavaScript-style names to CSS property names.
101
+ *
102
+ * For example `styleMap({backgroundColor: 'red', 'border-top': '5px', '--size':
103
+ * '0'})` sets the `background-color`, `border-top` and `--size` properties.
104
+ *
105
+ * @param styleInfo
106
+ * @see {@link https://lit.dev/docs/templates/directives/#stylemap styleMap code samples on Lit.dev}
107
+ */
108
+ const styleMap = directive(StyleMapDirective);
109
+
16
110
  var css_248z = css`:host {
17
111
  position: relative;
18
112
  display: block;
package/dist/Tag.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { _ as __decorate } from './_tslib-CNEFicEt.js';
2
2
  import { css, html } from 'lit';
3
3
  import { property } from 'lit/decorators.js';
4
- import { L as LeuElement } from './LeuElement-BFljD2fO.js';
4
+ import { L as LeuElement } from './LeuElement-BLUQU9Eu.js';
5
5
 
6
6
  var css_248z = css`:host {
7
7
  /* --tag-font-regular: var(--leu-font-family-regular);
@@ -1,5 +1,5 @@
1
1
  import { css, html } from 'lit';
2
- import { L as LeuElement } from './LeuElement-BFljD2fO.js';
2
+ import { L as LeuElement } from './LeuElement-BLUQU9Eu.js';
3
3
 
4
4
  var css_248z = css`:host {
5
5
  clip: rect(0 0 0 0);
@@ -1 +1 @@
1
- {"version":3,"file":"Table.d.ts","sourceRoot":"","sources":["../../../src/components/table/Table.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAI3D;;GAEG;AACH,qBAAa,QAAS,SAAQ,UAAU;IACtC,MAAM,CAAC,YAAY;;;MAGlB;IAED,MAAM,CAAC,MAAM,iCAA8B;IAE3C,MAAM,CAAC,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAYhB;;IAkCD,oBAAoB;IAIpB,wBAAwB,CAAC,IAAI,KAAA,EAAE,MAAM,KAAA,EAAE,MAAM,KAAA;IAQ7C,YAAY;IAMZ,YAAY,CAAC,MAAM,KAAA;IAMnB,WAAW,CAAC,KAAK,KAAA;IAIjB,iBAAiB;IAUjB,QAAQ,CAAC,GAAG,KAAA;IAIZ,SAAS,CAAC,GAAG,KAAA;IAUb,aAAa;IAMb,IAAI,QAAQ,QAEX;IAED,IAAI,WAAW,QAMd;IAED,IAAI,KAAK,QAOR;IAED,MAAM;CAyGP"}
1
+ {"version":3,"file":"Table.d.ts","sourceRoot":"","sources":["../../../src/components/table/Table.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAEpD,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAI3D;;GAEG;AACH,qBAAa,QAAS,SAAQ,UAAU;IACtC,MAAM,CAAC,YAAY;;;MAGlB;IAED,MAAM,CAAC,MAAM,iCAA8B;IAE3C,MAAM,CAAC,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAYhB;;IAkCD,oBAAoB;IAIpB,wBAAwB,CAAC,IAAI,KAAA,EAAE,MAAM,KAAA,EAAE,MAAM,KAAA;IAQ7C,YAAY;IAMZ,YAAY,CAAC,MAAM,KAAA;IAMnB,WAAW,CAAC,KAAK,KAAA;IAIjB,iBAAiB;IAUjB,QAAQ,CAAC,GAAG,KAAA;IAIZ,SAAS,CAAC,GAAG,KAAA;IAUb,aAAa;IAMb,IAAI,QAAQ,QAEX;IAED,IAAI,WAAW,QAMd;IAED,IAAI,KAAK,QAOR;IAED,MAAM;CAyGP"}
package/dist/index.js CHANGED
@@ -18,7 +18,7 @@ export { LeuRadio } from './Radio.js';
18
18
  export { LeuRadioGroup } from './RadioGroup.js';
19
19
  export { LeuSelect } from './Select.js';
20
20
  export { LeuTable } from './Table.js';
21
- export { L as LeuElement } from './LeuElement-BFljD2fO.js';
21
+ export { L as LeuElement } from './LeuElement-BLUQU9Eu.js';
22
22
  import './_tslib-CNEFicEt.js';
23
23
  import 'lit';
24
24
  import 'lit/static-html.js';
@@ -33,4 +33,4 @@ import 'lit/directives/ref.js';
33
33
  import 'lit/directives/live.js';
34
34
  import './VisuallyHidden.js';
35
35
  import '@floating-ui/dom';
36
- import 'lit/directives/style-map.js';
36
+ import 'lit/directive.js';
@@ -3,7 +3,7 @@ import './_tslib-CNEFicEt.js';
3
3
  import 'lit';
4
4
  import 'lit/static-html.js';
5
5
  import 'lit/decorators.js';
6
- import './LeuElement-BFljD2fO.js';
6
+ import './LeuElement-BLUQU9Eu.js';
7
7
 
8
8
  LeuAccordion.define("leu-accordion");
9
9
 
@@ -1,6 +1,6 @@
1
1
  import { LeuButtonGroup } from './ButtonGroup.js';
2
2
  import 'lit';
3
- import './LeuElement-BFljD2fO.js';
3
+ import './LeuElement-BLUQU9Eu.js';
4
4
  import './Button.js';
5
5
  import './_tslib-CNEFicEt.js';
6
6
  import 'lit/directives/class-map.js';
@@ -5,7 +5,7 @@ import 'lit/directives/class-map.js';
5
5
  import 'lit/directives/if-defined.js';
6
6
  import 'lit/decorators.js';
7
7
  import './Icon.js';
8
- import './LeuElement-BFljD2fO.js';
8
+ import './LeuElement-BLUQU9Eu.js';
9
9
  import './hasSlotController-Bm2tipvG.js';
10
10
 
11
11
  LeuButton.define("leu-button");
@@ -2,7 +2,7 @@ import { LeuChartWrapper } from './ChartWrapper.js';
2
2
  import './_tslib-CNEFicEt.js';
3
3
  import 'lit';
4
4
  import 'lit/decorators.js';
5
- import './LeuElement-BFljD2fO.js';
5
+ import './LeuElement-BLUQU9Eu.js';
6
6
  import './hasSlotController-Bm2tipvG.js';
7
7
  import './Spinner.js';
8
8
 
@@ -3,7 +3,7 @@ import './_tslib-CNEFicEt.js';
3
3
  import 'lit';
4
4
  import 'lit/directives/class-map.js';
5
5
  import 'lit/decorators.js';
6
- import './LeuElement-BFljD2fO.js';
6
+ import './LeuElement-BLUQU9Eu.js';
7
7
  import './Checkbox.js';
8
8
  import './Icon.js';
9
9
 
@@ -2,7 +2,7 @@ import { LeuCheckbox } from './Checkbox.js';
2
2
  import './_tslib-CNEFicEt.js';
3
3
  import 'lit';
4
4
  import 'lit/decorators.js';
5
- import './LeuElement-BFljD2fO.js';
5
+ import './LeuElement-BLUQU9Eu.js';
6
6
  import './Icon.js';
7
7
 
8
8
  LeuCheckbox.define("leu-checkbox");
@@ -1,6 +1,6 @@
1
1
  import { LeuChipGroup } from './ChipGroup.js';
2
2
  import 'lit/static-html.js';
3
- import './LeuElement-BFljD2fO.js';
3
+ import './LeuElement-BLUQU9Eu.js';
4
4
  import 'lit';
5
5
 
6
6
  LeuChipGroup.define("leu-chip-group");
@@ -1,7 +1,7 @@
1
1
  import { LeuChipLink } from './ChipLink.js';
2
2
  import 'lit';
3
3
  import './Chip.js';
4
- import './LeuElement-BFljD2fO.js';
4
+ import './LeuElement-BLUQU9Eu.js';
5
5
 
6
6
  LeuChipLink.define("leu-chip-link");
7
7
 
@@ -1,7 +1,7 @@
1
1
  import { LeuChipRemovable } from './ChipRemovable.js';
2
2
  import 'lit';
3
3
  import './Chip.js';
4
- import './LeuElement-BFljD2fO.js';
4
+ import './LeuElement-BLUQU9Eu.js';
5
5
  import './Icon.js';
6
6
  import './_tslib-CNEFicEt.js';
7
7
  import 'lit/decorators.js';
@@ -1,7 +1,7 @@
1
1
  import { LeuChipSelectable } from './ChipSelectable.js';
2
2
  import 'lit';
3
3
  import './Chip.js';
4
- import './LeuElement-BFljD2fO.js';
4
+ import './LeuElement-BLUQU9Eu.js';
5
5
 
6
6
  LeuChipSelectable.define("leu-chip-selectable");
7
7
 
@@ -2,7 +2,7 @@ import { LeuDialog } from './Dialog.js';
2
2
  import 'lit';
3
3
  import 'lit/directives/ref.js';
4
4
  import 'lit/directives/class-map.js';
5
- import './LeuElement-BFljD2fO.js';
5
+ import './LeuElement-BLUQU9Eu.js';
6
6
  import './hasSlotController-Bm2tipvG.js';
7
7
  import './Icon.js';
8
8
  import './_tslib-CNEFicEt.js';
@@ -1,7 +1,7 @@
1
1
  import { LeuDropdown } from './Dropdown.js';
2
2
  import 'lit';
3
3
  import 'lit/directives/ref.js';
4
- import './LeuElement-BFljD2fO.js';
4
+ import './LeuElement-BLUQU9Eu.js';
5
5
  import './hasSlotController-Bm2tipvG.js';
6
6
  import './Button.js';
7
7
  import './_tslib-CNEFicEt.js';
@@ -4,7 +4,7 @@ import 'lit';
4
4
  import 'lit/decorators.js';
5
5
  import 'lit/directives/if-defined.js';
6
6
  import 'lit/directives/class-map.js';
7
- import './LeuElement-BFljD2fO.js';
7
+ import './LeuElement-BLUQU9Eu.js';
8
8
  import './Accordion.js';
9
9
  import 'lit/static-html.js';
10
10
  import './Button.js';
@@ -34,7 +34,7 @@ import './Radio.js';
34
34
  import './RadioGroup.js';
35
35
  import './Select.js';
36
36
  import './Table.js';
37
- import 'lit/directives/style-map.js';
37
+ import 'lit/directive.js';
38
38
  import './leu-icon.js';
39
39
 
40
40
  LeuFileInput.define("leu-file-input");
package/dist/leu-icon.js CHANGED
@@ -2,7 +2,7 @@ import { LeuIcon } from './Icon.js';
2
2
  import './_tslib-CNEFicEt.js';
3
3
  import 'lit';
4
4
  import 'lit/decorators.js';
5
- import './LeuElement-BFljD2fO.js';
5
+ import './LeuElement-BLUQU9Eu.js';
6
6
 
7
7
  LeuIcon.define("leu-icon");
8
8
 
package/dist/leu-input.js CHANGED
@@ -4,7 +4,7 @@ import 'lit/directives/class-map.js';
4
4
  import 'lit/directives/if-defined.js';
5
5
  import 'lit/directives/live.js';
6
6
  import 'lit/directives/ref.js';
7
- import './LeuElement-BFljD2fO.js';
7
+ import './LeuElement-BLUQU9Eu.js';
8
8
  import './Icon.js';
9
9
  import './_tslib-CNEFicEt.js';
10
10
  import 'lit/decorators.js';
@@ -1,7 +1,7 @@
1
1
  import { LeuMenuItem } from './MenuItem.js';
2
2
  import 'lit';
3
3
  import 'lit/directives/if-defined.js';
4
- import './LeuElement-BFljD2fO.js';
4
+ import './LeuElement-BLUQU9Eu.js';
5
5
  import './Icon.js';
6
6
  import './_tslib-CNEFicEt.js';
7
7
  import 'lit/decorators.js';
package/dist/leu-menu.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { LeuMenu } from './Menu.js';
2
2
  import 'lit';
3
- import './LeuElement-BFljD2fO.js';
3
+ import './LeuElement-BLUQU9Eu.js';
4
4
  import './MenuItem.js';
5
5
  import 'lit/directives/if-defined.js';
6
6
  import './Icon.js';
@@ -3,7 +3,7 @@ import './_tslib-CNEFicEt.js';
3
3
  import 'lit';
4
4
  import 'lit/decorators.js';
5
5
  import 'lit/directives/class-map.js';
6
- import './LeuElement-BFljD2fO.js';
6
+ import './LeuElement-BLUQU9Eu.js';
7
7
  import './Icon.js';
8
8
  import './hasSlotController-Bm2tipvG.js';
9
9
 
@@ -3,7 +3,7 @@ import './_tslib-CNEFicEt.js';
3
3
  import 'lit';
4
4
  import 'lit/directives/live.js';
5
5
  import 'lit/decorators.js';
6
- import './LeuElement-BFljD2fO.js';
6
+ import './LeuElement-BLUQU9Eu.js';
7
7
  import './Button.js';
8
8
  import 'lit/directives/class-map.js';
9
9
  import 'lit/directives/if-defined.js';
@@ -1,6 +1,6 @@
1
1
  import { LeuPlaceholder } from './Placeholder.js';
2
2
  import 'lit';
3
- import './LeuElement-BFljD2fO.js';
3
+ import './LeuElement-BLUQU9Eu.js';
4
4
 
5
5
  LeuPlaceholder.define("leu-placeholder");
6
6
 
package/dist/leu-popup.js CHANGED
@@ -3,7 +3,7 @@ import './_tslib-CNEFicEt.js';
3
3
  import 'lit';
4
4
  import 'lit/decorators.js';
5
5
  import '@floating-ui/dom';
6
- import './LeuElement-BFljD2fO.js';
6
+ import './LeuElement-BLUQU9Eu.js';
7
7
 
8
8
  LeuPopup.define("leu-popup");
9
9
 
@@ -3,7 +3,7 @@ import './_tslib-CNEFicEt.js';
3
3
  import 'lit';
4
4
  import 'lit/directives/if-defined.js';
5
5
  import 'lit/decorators.js';
6
- import './LeuElement-BFljD2fO.js';
6
+ import './LeuElement-BLUQU9Eu.js';
7
7
 
8
8
  LeuProgressBar.define("leu-progress-bar");
9
9
 
@@ -3,7 +3,7 @@ import './_tslib-CNEFicEt.js';
3
3
  import 'lit';
4
4
  import 'lit/directives/class-map.js';
5
5
  import 'lit/decorators.js';
6
- import './LeuElement-BFljD2fO.js';
6
+ import './LeuElement-BLUQU9Eu.js';
7
7
  import './Radio.js';
8
8
 
9
9
  LeuRadioGroup.define("leu-radio-group");
package/dist/leu-radio.js CHANGED
@@ -2,7 +2,7 @@ import { LeuRadio } from './Radio.js';
2
2
  import './_tslib-CNEFicEt.js';
3
3
  import 'lit';
4
4
  import 'lit/decorators.js';
5
- import './LeuElement-BFljD2fO.js';
5
+ import './LeuElement-BLUQU9Eu.js';
6
6
 
7
7
  LeuRadio.define("leu-radio");
8
8
 
package/dist/leu-range.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { LeuRange } from './Range.js';
2
2
  import 'lit';
3
- import './LeuElement-BFljD2fO.js';
3
+ import './LeuElement-BLUQU9Eu.js';
4
4
 
5
5
  LeuRange.define("leu-range");
6
6
 
@@ -1,7 +1,7 @@
1
1
  import { LeuScrollTop } from './ScrollTop.js';
2
2
  import 'lit';
3
3
  import 'lit/directives/class-map.js';
4
- import './LeuElement-BFljD2fO.js';
4
+ import './LeuElement-BLUQU9Eu.js';
5
5
  import './Button.js';
6
6
  import './_tslib-CNEFicEt.js';
7
7
  import 'lit/directives/if-defined.js';
@@ -3,7 +3,7 @@ import 'lit';
3
3
  import 'lit/directives/class-map.js';
4
4
  import 'lit/directives/ref.js';
5
5
  import 'lit/directives/if-defined.js';
6
- import './LeuElement-BFljD2fO.js';
6
+ import './LeuElement-BLUQU9Eu.js';
7
7
  import './hasSlotController-Bm2tipvG.js';
8
8
  import './Button.js';
9
9
  import './_tslib-CNEFicEt.js';
@@ -1,6 +1,6 @@
1
1
  import { LeuSpinner } from './Spinner.js';
2
2
  import 'lit';
3
- import './LeuElement-BFljD2fO.js';
3
+ import './LeuElement-BLUQU9Eu.js';
4
4
 
5
5
  LeuSpinner.define("leu-spinner");
6
6
 
package/dist/leu-table.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import { LeuTable } from './Table.js';
2
2
  import 'lit';
3
3
  import 'lit/directives/class-map.js';
4
- import 'lit/directives/style-map.js';
5
4
  import 'lit/directives/ref.js';
6
- import './LeuElement-BFljD2fO.js';
5
+ import './LeuElement-BLUQU9Eu.js';
6
+ import 'lit/directive.js';
7
7
  import './Icon.js';
8
8
  import './_tslib-CNEFicEt.js';
9
9
  import 'lit/decorators.js';
package/dist/leu-tag.js CHANGED
@@ -2,7 +2,7 @@ import { LeuTag } from './Tag.js';
2
2
  import './_tslib-CNEFicEt.js';
3
3
  import 'lit';
4
4
  import 'lit/decorators.js';
5
- import './LeuElement-BFljD2fO.js';
5
+ import './LeuElement-BLUQU9Eu.js';
6
6
 
7
7
  LeuTag.define("leu-tag");
8
8
 
@@ -1,6 +1,6 @@
1
1
  import { LeuVisuallyHidden } from './VisuallyHidden.js';
2
2
  import 'lit';
3
- import './LeuElement-BFljD2fO.js';
3
+ import './LeuElement-BLUQU9Eu.js';
4
4
 
5
5
  LeuVisuallyHidden.define("leu-visually-hidden");
6
6
 
@@ -0,0 +1,61 @@
1
+ /**
2
+ * The original lit styleMap directive is not compatible with a strict style-src content security policy.
3
+ * There is an an open issue about this in the lit repository:
4
+ * https://github.com/lit/lit/issues/4719
5
+ *
6
+ * This file contains a custom implementation of the styleMap directive that bypasses
7
+ * the render method and directly updates the styles using the .style.setProperty and
8
+ * .style.removeProperty methods.
9
+ *
10
+ * In the original implementation, the render method returns a string that is set as the
11
+ * value of the style attribute. This approach is blocked by strict CSPs that disallow
12
+ * inline styles.
13
+ *
14
+ * As we don't support SSR in this library, we can safely skip the render method.
15
+ */
16
+ import { AttributePart } from "lit";
17
+ import { Directive, DirectiveParameters, PartInfo } from "lit/directive.js";
18
+ /**
19
+ * A key-value set of CSS properties and values.
20
+ *
21
+ * The key should be either a valid CSS property name string, like
22
+ * `'background-color'`, or a valid JavaScript camel case property name
23
+ * for CSSStyleDeclaration like `backgroundColor`.
24
+ */
25
+ export interface StyleInfo {
26
+ [name: string]: string | number | undefined | null;
27
+ }
28
+ declare class StyleMapDirective extends Directive {
29
+ private _previousStyleProperties?;
30
+ constructor(partInfo: PartInfo);
31
+ render(_styleInfo: Readonly<StyleInfo>): symbol;
32
+ update(part: AttributePart, [styleInfo]: DirectiveParameters<this>): symbol;
33
+ }
34
+ /**
35
+ * !A custom implementation of lit's `styleMap` directive!
36
+ * A directive that applies CSS properties to an element.
37
+ *
38
+ * `styleMap` can only be used in the `style` attribute and must be the only
39
+ * expression in the attribute. It takes the property names in the
40
+ * {@link StyleInfo styleInfo} object and adds the properties to the inline
41
+ * style of the element.
42
+ *
43
+ * Property names with dashes (`-`) are assumed to be valid CSS
44
+ * property names and set on the element's style object using `setProperty()`.
45
+ * Names without dashes are assumed to be camelCased JavaScript property names
46
+ * and set on the element's style object using property assignment, allowing the
47
+ * style object to translate JavaScript-style names to CSS property names.
48
+ *
49
+ * For example `styleMap({backgroundColor: 'red', 'border-top': '5px', '--size':
50
+ * '0'})` sets the `background-color`, `border-top` and `--size` properties.
51
+ *
52
+ * @param styleInfo
53
+ * @see {@link https://lit.dev/docs/templates/directives/#stylemap styleMap code samples on Lit.dev}
54
+ */
55
+ export declare const styleMap: (_styleInfo: Readonly<StyleInfo>) => import("lit-html/directive.js").DirectiveResult<typeof StyleMapDirective>;
56
+ /**
57
+ * The type of the class that powers this directive. Necessary for naming the
58
+ * directive's return type.
59
+ */
60
+ export type { StyleMapDirective };
61
+ //# sourceMappingURL=styleMap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styleMap.d.ts","sourceRoot":"","sources":["../../src/lib/styleMap.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,aAAa,EAAqB,MAAM,KAAK,CAAA;AACtD,OAAO,EAEL,SAAS,EACT,mBAAmB,EACnB,QAAQ,EAET,MAAM,kBAAkB,CAAA;AAEzB;;;;;;GAMG;AACH,MAAM,WAAW,SAAS;IACxB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,IAAI,CAAA;CACnD;AAQD,cAAM,iBAAkB,SAAQ,SAAS;IACvC,OAAO,CAAC,wBAAwB,CAAC,CAAa;gBAElC,QAAQ,EAAE,QAAQ;IAc9B,MAAM,CAAC,UAAU,EAAE,QAAQ,CAAC,SAAS,CAAC;IAI7B,MAAM,CAAC,IAAI,EAAE,aAAa,EAAE,CAAC,SAAS,CAAC,EAAE,mBAAmB,CAAC,IAAI,CAAC;CA4C5E;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,QAAQ,gHAA+B,CAAA;AAEpD;;;GAGG;AACH,YAAY,EAAE,iBAAiB,EAAE,CAAA"}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://raw.githubusercontent.com/JetBrains/web-types/master/schema/web-types.json",
3
3
  "name": "@statistikzh/leu",
4
- "version": "0.21.0",
4
+ "version": "0.21.1",
5
5
  "description-markup": "markdown",
6
6
  "contributions": {
7
7
  "html": {
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "UI component library of the canton of zurich",
4
4
  "license": "MIT",
5
5
  "author": "statistikzh",
6
- "version": "0.21.0",
6
+ "version": "0.21.1",
7
7
  "type": "module",
8
8
  "main": "dist/index.js",
9
9
  "module": "dist/index.js",
@@ -1,9 +1,9 @@
1
1
  import { html, nothing } from "lit"
2
2
  import { classMap } from "lit/directives/class-map.js"
3
- import { styleMap } from "lit/directives/style-map.js"
4
3
  import { createRef, ref } from "lit/directives/ref.js"
5
4
 
6
5
  import { LeuElement } from "../../lib/LeuElement.js"
6
+ import { styleMap } from "../../lib/styleMap.js"
7
7
  import { LeuIcon } from "../icon/Icon.js"
8
8
  import { LeuPagination } from "../pagination/Pagination.js"
9
9
 
@@ -0,0 +1,139 @@
1
+ /* eslint-disable prefer-template,no-param-reassign,no-restricted-syntax,guard-for-in */
2
+
3
+ /**
4
+ * The original lit styleMap directive is not compatible with a strict style-src content security policy.
5
+ * There is an an open issue about this in the lit repository:
6
+ * https://github.com/lit/lit/issues/4719
7
+ *
8
+ * This file contains a custom implementation of the styleMap directive that bypasses
9
+ * the render method and directly updates the styles using the .style.setProperty and
10
+ * .style.removeProperty methods.
11
+ *
12
+ * In the original implementation, the render method returns a string that is set as the
13
+ * value of the style attribute. This approach is blocked by strict CSPs that disallow
14
+ * inline styles.
15
+ *
16
+ * As we don't support SSR in this library, we can safely skip the render method.
17
+ */
18
+
19
+ import { AttributePart, noChange, nothing } from "lit"
20
+ import {
21
+ directive,
22
+ Directive,
23
+ DirectiveParameters,
24
+ PartInfo,
25
+ PartType,
26
+ } from "lit/directive.js"
27
+
28
+ /**
29
+ * A key-value set of CSS properties and values.
30
+ *
31
+ * The key should be either a valid CSS property name string, like
32
+ * `'background-color'`, or a valid JavaScript camel case property name
33
+ * for CSSStyleDeclaration like `backgroundColor`.
34
+ */
35
+ export interface StyleInfo {
36
+ [name: string]: string | number | undefined | null
37
+ }
38
+
39
+ const important = "important"
40
+ // The leading space is important
41
+ const importantFlag = " !" + important
42
+ // How many characters to remove from a value, as a negative number
43
+ const flagTrim = 0 - importantFlag.length
44
+
45
+ class StyleMapDirective extends Directive {
46
+ private _previousStyleProperties?: Set<string>
47
+
48
+ constructor(partInfo: PartInfo) {
49
+ super(partInfo)
50
+ if (
51
+ partInfo.type !== PartType.ATTRIBUTE ||
52
+ partInfo.name !== "style" ||
53
+ (partInfo.strings?.length as number) > 2
54
+ ) {
55
+ throw new Error(
56
+ "The `styleMap` directive must be used in the `style` attribute " +
57
+ "and must be the only part in the attribute.",
58
+ )
59
+ }
60
+ }
61
+
62
+ render(_styleInfo: Readonly<StyleInfo>) {
63
+ return nothing
64
+ }
65
+
66
+ override update(part: AttributePart, [styleInfo]: DirectiveParameters<this>) {
67
+ const { style } = part.element as HTMLElement
68
+
69
+ if (this._previousStyleProperties === undefined) {
70
+ this._previousStyleProperties = new Set(Object.keys(styleInfo))
71
+ }
72
+
73
+ // Remove old properties that no longer exist in styleInfo
74
+ for (const name of this._previousStyleProperties) {
75
+ // If the name isn't in styleInfo or it's null/undefined
76
+ if (styleInfo[name] == null) {
77
+ this._previousStyleProperties!.delete(name)
78
+ if (name.includes("-")) {
79
+ style.removeProperty(name)
80
+ } else {
81
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
82
+ ;(style as any)[name] = null
83
+ }
84
+ }
85
+ }
86
+
87
+ // Add or update properties
88
+ for (const name in styleInfo) {
89
+ const value = styleInfo[name]
90
+ if (value != null) {
91
+ this._previousStyleProperties.add(name)
92
+ const isImportant =
93
+ typeof value === "string" && value.endsWith(importantFlag)
94
+ if (name.includes("-") || isImportant) {
95
+ style.setProperty(
96
+ name,
97
+ isImportant
98
+ ? (value as string).slice(0, flagTrim)
99
+ : (value as string),
100
+ isImportant ? important : "",
101
+ )
102
+ } else {
103
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
104
+ ;(style as any)[name] = value
105
+ }
106
+ }
107
+ }
108
+ return noChange
109
+ }
110
+ }
111
+
112
+ /**
113
+ * !A custom implementation of lit's `styleMap` directive!
114
+ * A directive that applies CSS properties to an element.
115
+ *
116
+ * `styleMap` can only be used in the `style` attribute and must be the only
117
+ * expression in the attribute. It takes the property names in the
118
+ * {@link StyleInfo styleInfo} object and adds the properties to the inline
119
+ * style of the element.
120
+ *
121
+ * Property names with dashes (`-`) are assumed to be valid CSS
122
+ * property names and set on the element's style object using `setProperty()`.
123
+ * Names without dashes are assumed to be camelCased JavaScript property names
124
+ * and set on the element's style object using property assignment, allowing the
125
+ * style object to translate JavaScript-style names to CSS property names.
126
+ *
127
+ * For example `styleMap({backgroundColor: 'red', 'border-top': '5px', '--size':
128
+ * '0'})` sets the `background-color`, `border-top` and `--size` properties.
129
+ *
130
+ * @param styleInfo
131
+ * @see {@link https://lit.dev/docs/templates/directives/#stylemap styleMap code samples on Lit.dev}
132
+ */
133
+ export const styleMap = directive(StyleMapDirective)
134
+
135
+ /**
136
+ * The type of the class that powers this directive. Necessary for naming the
137
+ * directive's return type.
138
+ */
139
+ export type { StyleMapDirective }