@alegendstale/holly-components 2.0.2 → 2.0.4

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 (137) hide show
  1. package/dist/components/absolute-container/absolute-container.js +79 -113
  2. package/dist/components/absolute-container/absolute-container.styles.js +20 -17
  3. package/dist/components/bottom-sheet/bottom-sheet.js +189 -319
  4. package/dist/components/bottom-sheet/bottom-sheet.styles.js +117 -114
  5. package/dist/components/canvas/canvas-base.d.ts +4 -1
  6. package/dist/components/canvas/canvas-base.d.ts.map +1 -1
  7. package/dist/components/canvas/canvas-base.js +51 -67
  8. package/dist/components/canvas/canvas-gradient.js +44 -69
  9. package/dist/components/canvas/canvas-image.js +112 -177
  10. package/dist/components/canvas/canvas-image.styles.js +23 -20
  11. package/dist/components/carousel-scroller/carousel-scroller.js +63 -87
  12. package/dist/components/carousel-scroller/carousel-scroller.styles.js +68 -65
  13. package/dist/components/color-palette/color-palette-utils.js +55 -104
  14. package/dist/components/color-palette/color-palette.js +250 -384
  15. package/dist/components/color-palette/color-palette.styles.js +92 -89
  16. package/dist/components/color-palette/component/color-palette-component.js +134 -188
  17. package/dist/components/color-palette/component/color-palette-component.styles.js +12 -9
  18. package/dist/components/color-palette/editor/color-palette-editor.js +413 -539
  19. package/dist/components/color-palette/editor/color-palette-editor.styles.js +149 -146
  20. package/dist/components/color-palette/editor/settings-item.js +32 -40
  21. package/dist/components/color-palette/editor/settings-item.styles.js +36 -33
  22. package/dist/components/color-palette/item/color-palette-item-edit.js +50 -84
  23. package/dist/components/color-palette/item/color-palette-item-edit.styles.js +53 -50
  24. package/dist/components/color-palette/item/color-palette-item.js +72 -107
  25. package/dist/components/color-palette/item/color-palette-item.styles.js +85 -82
  26. package/dist/components/color-palette/menu/color-palette-menu.js +162 -200
  27. package/dist/components/color-palette/menu/color-palette-menu.styles.js +51 -48
  28. package/dist/components/color-palette/menu/color-palette-reorder.js +76 -95
  29. package/dist/components/color-palette/menu/color-palette-reorder.styles.js +33 -30
  30. package/dist/components/draw-svg/draw-svg.js +35 -52
  31. package/dist/components/draw-svg/draw-svg.styles.js +41 -38
  32. package/dist/components/responsive-svg/responsive-svg.d.ts +2 -2
  33. package/dist/components/responsive-svg/responsive-svg.d.ts.map +1 -1
  34. package/dist/components/responsive-svg/responsive-svg.js +122 -174
  35. package/dist/components/responsive-svg/responsive-svg.styles.js +48 -45
  36. package/dist/components/tool-tip/tool-tip.d.ts +5 -1
  37. package/dist/components/tool-tip/tool-tip.d.ts.map +1 -1
  38. package/dist/components/tool-tip/tool-tip.js +64 -100
  39. package/dist/components/tool-tip/tool-tip.styles.js +60 -57
  40. package/dist/decorators/condCustomElement.js +8 -11
  41. package/dist/utils/EventEmitter.js +23 -23
  42. package/dist/utils/ResponsiveController.js +15 -18
  43. package/dist/utils/basicUtils.js +98 -146
  44. package/dist/utils/colorsea-wrapper.js +162 -166
  45. package/dist/utils/dragDropUtils.js +75 -119
  46. package/dist/utils/generateUtils.js +39 -73
  47. package/package.json +34 -64
  48. package/dist/components/absolute-container/absolute-container.stories.d.ts +0 -11
  49. package/dist/components/absolute-container/absolute-container.stories.d.ts.map +0 -1
  50. package/dist/components/absolute-container/absolute-container.stories.js +0 -64
  51. package/dist/components/absolute-container/index.d.ts +0 -2
  52. package/dist/components/absolute-container/index.d.ts.map +0 -1
  53. package/dist/components/absolute-container/index.js +0 -1
  54. package/dist/components/bottom-sheet/bottom-sheet.stories.d.ts +0 -17
  55. package/dist/components/bottom-sheet/bottom-sheet.stories.d.ts.map +0 -1
  56. package/dist/components/bottom-sheet/bottom-sheet.stories.js +0 -67
  57. package/dist/components/bottom-sheet/index.d.ts +0 -2
  58. package/dist/components/bottom-sheet/index.d.ts.map +0 -1
  59. package/dist/components/bottom-sheet/index.js +0 -1
  60. package/dist/components/canvas/canvas-base.stories.d.ts +0 -7
  61. package/dist/components/canvas/canvas-base.stories.d.ts.map +0 -1
  62. package/dist/components/canvas/canvas-base.stories.js +0 -24
  63. package/dist/components/canvas/canvas-gradient.stories.d.ts +0 -14
  64. package/dist/components/canvas/canvas-gradient.stories.d.ts.map +0 -1
  65. package/dist/components/canvas/canvas-gradient.stories.js +0 -46
  66. package/dist/components/canvas/canvas-image.stories.d.ts +0 -13
  67. package/dist/components/canvas/canvas-image.stories.d.ts.map +0 -1
  68. package/dist/components/canvas/canvas-image.stories.js +0 -49
  69. package/dist/components/canvas/index.d.ts +0 -3
  70. package/dist/components/canvas/index.d.ts.map +0 -1
  71. package/dist/components/canvas/index.js +0 -2
  72. package/dist/components/carousel-scroller/carousel-scroller.stories.d.ts +0 -13
  73. package/dist/components/carousel-scroller/carousel-scroller.stories.d.ts.map +0 -1
  74. package/dist/components/carousel-scroller/carousel-scroller.stories.js +0 -56
  75. package/dist/components/carousel-scroller/index.d.ts +0 -2
  76. package/dist/components/carousel-scroller/index.d.ts.map +0 -1
  77. package/dist/components/carousel-scroller/index.js +0 -1
  78. package/dist/components/color-palette/component/color-palette-component.stories.d.ts +0 -13
  79. package/dist/components/color-palette/component/color-palette-component.stories.d.ts.map +0 -1
  80. package/dist/components/color-palette/component/color-palette-component.stories.js +0 -75
  81. package/dist/components/color-palette/component/index.d.ts +0 -2
  82. package/dist/components/color-palette/component/index.d.ts.map +0 -1
  83. package/dist/components/color-palette/component/index.js +0 -1
  84. package/dist/components/color-palette/editor/color-palette-editor.stories.d.ts +0 -18
  85. package/dist/components/color-palette/editor/color-palette-editor.stories.d.ts.map +0 -1
  86. package/dist/components/color-palette/editor/color-palette-editor.stories.js +0 -67
  87. package/dist/components/color-palette/editor/index.d.ts +0 -2
  88. package/dist/components/color-palette/editor/index.d.ts.map +0 -1
  89. package/dist/components/color-palette/editor/index.js +0 -1
  90. package/dist/components/color-palette/index.d.ts +0 -6
  91. package/dist/components/color-palette/index.d.ts.map +0 -1
  92. package/dist/components/color-palette/index.js +0 -5
  93. package/dist/components/color-palette/item/index.d.ts +0 -3
  94. package/dist/components/color-palette/item/index.d.ts.map +0 -1
  95. package/dist/components/color-palette/item/index.js +0 -2
  96. package/dist/components/color-palette/menu/index.d.ts +0 -3
  97. package/dist/components/color-palette/menu/index.d.ts.map +0 -1
  98. package/dist/components/color-palette/menu/index.js +0 -2
  99. package/dist/components/color-palette/storybook/color-palette-invalid.stories.d.ts +0 -33
  100. package/dist/components/color-palette/storybook/color-palette-invalid.stories.d.ts.map +0 -1
  101. package/dist/components/color-palette/storybook/color-palette-invalid.stories.js +0 -62
  102. package/dist/components/color-palette/storybook/color-palette-valid.stories.d.ts +0 -52
  103. package/dist/components/color-palette/storybook/color-palette-valid.stories.d.ts.map +0 -1
  104. package/dist/components/color-palette/storybook/color-palette-valid.stories.js +0 -268
  105. package/dist/components/color-palette/storybook/color-palette.stories.d.ts +0 -27
  106. package/dist/components/color-palette/storybook/color-palette.stories.d.ts.map +0 -1
  107. package/dist/components/color-palette/storybook/color-palette.stories.js +0 -129
  108. package/dist/components/draw-svg/draw-svg.stories.d.ts +0 -7
  109. package/dist/components/draw-svg/draw-svg.stories.d.ts.map +0 -1
  110. package/dist/components/draw-svg/draw-svg.stories.js +0 -61
  111. package/dist/components/draw-svg/index.d.ts +0 -2
  112. package/dist/components/draw-svg/index.d.ts.map +0 -1
  113. package/dist/components/draw-svg/index.js +0 -1
  114. package/dist/components/responsive-svg/index.d.ts +0 -2
  115. package/dist/components/responsive-svg/index.d.ts.map +0 -1
  116. package/dist/components/responsive-svg/index.js +0 -1
  117. package/dist/components/responsive-svg/responsive-svg.stories.d.ts +0 -26
  118. package/dist/components/responsive-svg/responsive-svg.stories.d.ts.map +0 -1
  119. package/dist/components/responsive-svg/responsive-svg.stories.js +0 -194
  120. package/dist/components/tool-tip/index.d.ts +0 -2
  121. package/dist/components/tool-tip/index.d.ts.map +0 -1
  122. package/dist/components/tool-tip/index.js +0 -1
  123. package/dist/components/tool-tip/tool-tip.stories.d.ts +0 -16
  124. package/dist/components/tool-tip/tool-tip.stories.d.ts.map +0 -1
  125. package/dist/components/tool-tip/tool-tip.stories.js +0 -62
  126. package/dist/decorators/index.d.ts +0 -2
  127. package/dist/decorators/index.d.ts.map +0 -1
  128. package/dist/decorators/index.js +0 -1
  129. package/dist/index.d.ts +0 -11
  130. package/dist/index.d.ts.map +0 -1
  131. package/dist/index.js +0 -10
  132. package/dist/utils/index.d.ts +0 -5
  133. package/dist/utils/index.d.ts.map +0 -1
  134. package/dist/utils/index.js +0 -4
  135. package/dist/utils/types.d.ts +0 -5
  136. package/dist/utils/types.d.ts.map +0 -1
  137. package/dist/utils/types.js +0 -1
@@ -1,31 +1,34 @@
1
- import { css } from 'lit';
2
- export default css `
3
- :host {
4
- display: block;
5
- }
6
-
7
- menu {
8
- display: flex;
9
- flex-direction: column;
10
- gap: 0.5rem;
11
- background-color: rgb(27, 27, 27);
12
- padding: 0.5rem;
13
- border-radius: 5px;
14
-
15
- button {
16
- color: rgb(245, 245, 245);
17
- background-color: transparent;
18
- border: none;
19
- padding: 4px 12px;
20
- cursor: pointer;
21
-
22
- &:hover {
23
- background-color: rgb(75, 75, 75);
24
- }
25
-
26
- span {
27
- font-size: 14px;
28
- }
29
- }
30
- }
1
+ import { css as o } from "lit";
2
+ const n = o`
3
+ :host {
4
+ display: block;
5
+ }
6
+
7
+ menu {
8
+ display: flex;
9
+ flex-direction: column;
10
+ gap: 0.5rem;
11
+ background-color: rgb(27, 27, 27);
12
+ padding: 0.5rem;
13
+ border-radius: 5px;
14
+
15
+ button {
16
+ color: rgb(245, 245, 245);
17
+ background-color: transparent;
18
+ border: none;
19
+ padding: 4px 12px;
20
+ cursor: pointer;
21
+
22
+ &:hover {
23
+ background-color: rgb(75, 75, 75);
24
+ }
25
+
26
+ span {
27
+ font-size: 14px;
28
+ }
29
+ }
30
+ }
31
31
  `;
32
+ export {
33
+ n as default
34
+ };
@@ -1,54 +1,37 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
1
+ import { state as v, customElement as p } from "lit/decorators.js";
2
+ import { ResponsiveSvg as l } from "../responsive-svg/responsive-svg.js";
3
+ import { EventEmitter as m } from "../../utils/EventEmitter.js";
4
+ import g from "./draw-svg.styles.js";
5
+ var b = Object.defineProperty, f = Object.getOwnPropertyDescriptor, a = (s, t, n, r) => {
6
+ for (var e = r > 1 ? void 0 : r ? f(t, n) : t, c = s.length - 1, o; c >= 0; c--)
7
+ (o = s[c]) && (e = (r ? o(t, n, e) : o(e)) || e);
8
+ return r && e && b(t, n, e), e;
6
9
  };
7
- import { customElement, state } from 'lit/decorators.js';
8
- import { ResponsiveSvg } from '../responsive-svg/responsive-svg.js';
9
- import { EventEmitter } from '../../utils/EventEmitter.js';
10
- import styles from './draw-svg.styles.js';
11
- /**
12
- * Animates the provided SVG paths as if they were being drawn.
13
- *
14
- * @dependency responsive-svg
15
- *
16
- * @event {boolean} intersection - Emits when the component enters or leaves the viewport.
17
- * @prop emitter
18
- */
19
- let DrawSvg = class DrawSvg extends ResponsiveSvg {
20
- constructor() {
21
- super(...arguments);
22
- /** Whether the SVG is intersecting with the client viewport. Useful for determining when to animate. */
23
- this.isIntersecting = false;
24
- /** @internal */
25
- this.intersectionObserver = new IntersectionObserver(([entry]) => {
26
- this.isIntersecting = entry.isIntersecting;
27
- this.emitter.emit('intersection', entry.isIntersecting);
28
- });
29
- /** Public way to subscribe to events. */
30
- this.emitter = new EventEmitter();
31
- }
32
- static { this.styles = [...ResponsiveSvg.styles, styles]; }
33
- svgClasses() {
34
- super.svgClasses();
35
- return {
36
- animation: this.isIntersecting
37
- };
38
- }
39
- connectedCallback() {
40
- super.connectedCallback();
41
- this.intersectionObserver.observe(this);
42
- }
43
- disconnectedCallback() {
44
- super.disconnectedCallback();
45
- this.intersectionObserver.disconnect();
46
- }
10
+ let i = class extends l {
11
+ constructor() {
12
+ super(...arguments), this.isIntersecting = !1, this.intersectionObserver = new IntersectionObserver(([s]) => {
13
+ this.isIntersecting = s.isIntersecting, this.emitter.emit("intersection", s.isIntersecting);
14
+ }), this.emitter = new m();
15
+ }
16
+ svgClasses() {
17
+ return super.svgClasses(), {
18
+ animation: this.isIntersecting
19
+ };
20
+ }
21
+ connectedCallback() {
22
+ super.connectedCallback(), this.intersectionObserver.observe(this);
23
+ }
24
+ disconnectedCallback() {
25
+ super.disconnectedCallback(), this.intersectionObserver.disconnect();
26
+ }
27
+ };
28
+ i.styles = [...l.styles, g];
29
+ a([
30
+ v()
31
+ ], i.prototype, "isIntersecting", 2);
32
+ i = a([
33
+ p("draw-svg")
34
+ ], i);
35
+ export {
36
+ i as DrawSvg
47
37
  };
48
- __decorate([
49
- state()
50
- ], DrawSvg.prototype, "isIntersecting", void 0);
51
- DrawSvg = __decorate([
52
- customElement('draw-svg')
53
- ], DrawSvg);
54
- export { DrawSvg };
@@ -1,39 +1,42 @@
1
- import { css } from 'lit';
2
- export default css `
3
- :host {
4
- stroke: white;
5
- fill: white;
6
- }
7
-
8
- /* Override responsive-svg path fill */
9
- :host(:not([svgColors])) path {
10
- fill: transparent;
11
- }
12
-
13
- path {
14
- stroke-width: 2;
15
- stroke-dasharray: 1000;
16
- stroke-dashoffset: 1000;
17
- }
18
-
19
- .animation {
20
- path {
21
- animation: textAnimation 2s ease-in-out 1 forwards;
22
- will-change: fill, stroke-width, stroke-dashoffset;
23
- }
24
- }
25
-
26
- @keyframes textAnimation {
27
- 0% {
28
- stroke-dashoffset: 1000;
29
- }
30
- 60% {
31
- fill: transparent;
32
- }
33
- 100% {
34
- fill: inherit;
35
- stroke-dashoffset: 0;
36
- stroke-width: 1;
37
- }
38
- }
1
+ import { css as t } from "lit";
2
+ const e = t`
3
+ :host {
4
+ stroke: white;
5
+ fill: white;
6
+ }
7
+
8
+ /* Override responsive-svg path fill */
9
+ :host(:not([svgColors])) path {
10
+ fill: transparent;
11
+ }
12
+
13
+ path {
14
+ stroke-width: 2;
15
+ stroke-dasharray: 1000;
16
+ stroke-dashoffset: 1000;
17
+ }
18
+
19
+ .animation {
20
+ path {
21
+ animation: textAnimation 2s ease-in-out 1 forwards;
22
+ will-change: fill, stroke-width, stroke-dashoffset;
23
+ }
24
+ }
25
+
26
+ @keyframes textAnimation {
27
+ 0% {
28
+ stroke-dashoffset: 1000;
29
+ }
30
+ 60% {
31
+ fill: transparent;
32
+ }
33
+ 100% {
34
+ fill: inherit;
35
+ stroke-dashoffset: 0;
36
+ stroke-width: 1;
37
+ }
38
+ }
39
39
  `;
40
+ export {
41
+ e as default
42
+ };
@@ -1,4 +1,4 @@
1
- import { LitElement, TemplateResult } from 'lit';
1
+ import { LitElement, TemplateResult, PropertyValues } from 'lit';
2
2
  type ViewBox = {
3
3
  x: number;
4
4
  y: number;
@@ -51,7 +51,7 @@ export declare class ResponsiveSvg extends LitElement {
51
51
  /** The viewBox dimensions the SVG will use. */
52
52
  protected viewBox: ViewBox;
53
53
  protected svgClasses(): {};
54
- connectedCallback(): void;
54
+ protected willUpdate(_changedProperties: PropertyValues): void;
55
55
  render(): TemplateResult<1> | undefined;
56
56
  /** Applies a part name to all paths in the given element. */
57
57
  private applyPartToPaths;
@@ -1 +1 @@
1
- {"version":3,"file":"responsive-svg.d.ts","sourceRoot":"","sources":["../../../src/components/responsive-svg/responsive-svg.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAQ,cAAc,EAAkB,MAAM,KAAK,CAAC;AAQvE,KAAK,OAAO,GAAG;IACd,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAA;CACd,CAAA;AAED,eAAO,MAAM,+BAA+B,+HAK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AYnD;IAED,gBAAgB;IAChB,OAAO,CAAC,oBAAoB,CAAkC;IAC9D;;;;OAIG;IACH,IACI,mBAAmB,CAAC,GAAG,EAAE,mBAAmB,GAAG,SAAS,EAE3D;IACD,IAAI,mBAAmB,IAHM,mBAAmB,GAAG,SAAS,CAW3D;IAED,+CAA+C;IAC/C,SAAS,CAAC,OAAO,EAAE,OAAO,CAAuC;IAGjE,SAAS,CAAC,UAAU;IAIpB,SAAS,CAAC,UAAU,CAAC,kBAAkB,EAAE,cAAc,GAAG,IAAI;IAkB9D,MAAM;IAwCN,6DAA6D;IAC7D,OAAO,CAAC,gBAAgB;IAaxB;;;;OAIG;IACI,cAAc,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,GAAG,IAAI;CAMtD;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,gBAAgB,EAAE,aAAa,CAAC;KAChC;CACD"}
@@ -1,182 +1,130 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
1
+ import { LitElement as g, html as c } from "lit";
2
+ import { property as a, customElement as v } from "lit/decorators.js";
3
+ import { styleMap as f } from "lit/directives/style-map.js";
4
+ import { parseSVG as u } from "../../utils/basicUtils.js";
5
+ import { classMap as m } from "lit/directives/class-map.js";
6
+ import { isTemplateResult as x } from "lit/directive-helpers.js";
7
+ import y from "./responsive-svg.styles.js";
8
+ var d = Object.defineProperty, w = Object.getOwnPropertyDescriptor, n = (t, e, i, o) => {
9
+ for (var s = o > 1 ? void 0 : o ? w(e, i) : e, r = t.length - 1, h; r >= 0; r--)
10
+ (h = t[r]) && (s = (o ? h(e, i, s) : h(s)) || s);
11
+ return o && s && d(e, i, s), s;
6
12
  };
7
- import { LitElement, html } from 'lit';
8
- import { customElement, property } from 'lit/decorators.js';
9
- import { styleMap } from 'lit/directives/style-map.js';
10
- import { parseSVG } from '../../utils/basicUtils.js';
11
- import { classMap } from 'lit/directives/class-map.js';
12
- import { isTemplateResult } from 'lit/directive-helpers.js';
13
- import styles from './responsive-svg.styles.js';
14
- export const preserveAspectRatioAlignOptions = [
15
- "none",
16
- "xMinYMin", "xMidYMin", "xMaxYMin",
17
- "xMinYMid", "xMidYMid", "xMaxYMid",
18
- "xMinYMax", "xMidYMax", "xMaxYMax",
19
- ];
20
- export const preserveAspectRatioSpacingOptions = ["meet", "slice"];
21
- export const preserveAspectRatioOptions = [
22
- ...preserveAspectRatioAlignOptions,
23
- ...preserveAspectRatioAlignOptions.flatMap(align => preserveAspectRatioSpacingOptions.map(spacing => `${align} ${spacing}`))
24
- ];
25
- const preserveAspectRatioSet = new Set(preserveAspectRatioOptions);
26
- function isPreserveAspectRatio(value) {
27
- return preserveAspectRatioSet.has(value);
13
+ const l = [
14
+ "none",
15
+ "xMinYMin",
16
+ "xMidYMin",
17
+ "xMaxYMin",
18
+ "xMinYMid",
19
+ "xMidYMid",
20
+ "xMaxYMid",
21
+ "xMinYMax",
22
+ "xMidYMax",
23
+ "xMaxYMax"
24
+ ], A = ["meet", "slice"], M = [
25
+ ...l,
26
+ ...l.flatMap((t) => A.map((e) => `${t} ${e}`))
27
+ ], _ = new Set(M);
28
+ function R(t) {
29
+ return _.has(t);
28
30
  }
29
- /**
30
- * Responsively sizes SVGs to font-size or automatically fits them to the container.
31
- *
32
- * @cssprop {<length> (em)} --svg-width - Controls the width of the SVG. (Expects em value)
33
- * @cssprop {<length> (em)} --svg-height - Controls the height of the SVG. (Expects em value)
34
- * @cssprop {<length> (em)} --svg-width-fallback - Set by the component as a fallback in case --svg-width is not defined.
35
- * @cssprop {<length> (em)} --svg-height-fallback - Set by the component as a fallback in case --svg-height is not defined.
36
- * @cssprop {number} --scale - Controls the scale of the SVG when sized relative to font-size.
37
- *
38
- * @csspart __svg - Styles the SVG element.
39
- * @csspart __path - Styles all child path elements of the SVG.
40
- */
41
- let ResponsiveSvg = class ResponsiveSvg extends LitElement {
42
- constructor() {
43
- super(...arguments);
44
- /** The SVG will attempt to fill its container. */
45
- this.autofit = false;
46
- /** Use the colors from the SVG input. */
47
- this.svgColors = false;
48
- /** The viewBox dimensions the SVG will use. */
49
- this.viewBox = { x: 0, y: 0, width: 0, height: 0 };
31
+ let p = class extends g {
32
+ constructor() {
33
+ super(...arguments), this.autofit = !1, this.svgColors = !1, this.viewBox = { x: 0, y: 0, width: 0, height: 0 };
34
+ }
35
+ set svg(t) {
36
+ const e = t instanceof SVGElement || x(t) ? t : u(t);
37
+ e instanceof Element && !(e instanceof SVGElement) || (this._svg = e);
38
+ }
39
+ get svg() {
40
+ return this._svg ?? "";
41
+ }
42
+ set preserveAspectRatio(t) {
43
+ this._preserveAspectRatio = t;
44
+ }
45
+ get preserveAspectRatio() {
46
+ if (this._preserveAspectRatio == null && this.svg instanceof SVGElement) {
47
+ const t = this.svg.getAttribute("preserveAspectRatio") || "";
48
+ if (R(t)) return t;
50
49
  }
51
- static { this.styles = [styles]; }
52
- /**
53
- * The SVG to responsively size.
54
- * Must use a property expression (.) to set
55
- * @type {SVGElement | TemplateResult<2> | string}
56
- */
57
- set svg(val) {
58
- const _svg = val instanceof SVGElement
59
- ? val : isTemplateResult(val)
60
- ? val : parseSVG(val);
61
- // Parse error
62
- if (_svg instanceof Element && !(_svg instanceof SVGElement))
63
- return;
64
- this._svg = _svg;
50
+ return this._preserveAspectRatio || "xMidYMid meet";
51
+ }
52
+ // For classes inheriting from responsive-svg (e.g. draw-svg)
53
+ svgClasses() {
54
+ return {};
55
+ }
56
+ willUpdate(t) {
57
+ if (super.willUpdate(t), this.svg instanceof SVGElement) {
58
+ const e = this.getViewBoxSize(this.svg), i = this.svg.getAttribute("width"), o = this.svg.getAttribute("height");
59
+ this.viewBox = e ?? { x: 0, y: 0, width: Number(i) || 0, height: Number(o) || 0 };
60
+ } else {
61
+ const e = this.style.getPropertyValue("--svg-width"), i = this.style.getPropertyValue("--svg-height");
62
+ this.viewBox = { x: 0, y: 0, width: parseFloat(e) || 0, height: parseFloat(i) || 0 };
65
63
  }
66
- get svg() {
67
- return this._svg ?? '';
68
- }
69
- /**
70
- * Set whether SVG preserves its aspect ratio alignment or spacing.
71
- * @type {PreserveAspectRatio}
72
- * @default xMidYMid meet
73
- */
74
- set preserveAspectRatio(val) {
75
- this._preserveAspectRatio = val;
76
- }
77
- get preserveAspectRatio() {
78
- // Attempt to automatically get value from SVG
79
- if (this._preserveAspectRatio == undefined && this.svg instanceof SVGElement) {
80
- const attribute = this.svg.getAttribute('preserveAspectRatio') || '';
81
- if (isPreserveAspectRatio(attribute))
82
- return attribute;
83
- }
84
- // Otherwise return the preserveAspectRatio the user set OR default value
85
- return this._preserveAspectRatio || 'xMidYMid meet';
86
- }
87
- // For classes inheriting from responsive-svg (e.g. draw-svg)
88
- svgClasses() {
89
- return {};
90
- }
91
- connectedCallback() {
92
- super.connectedCallback();
93
- if (this.svg instanceof SVGElement) {
94
- const _viewBox = this.getViewBoxSize(this.svg);
95
- const _width = this.svg.getAttribute('width');
96
- const _height = this.svg.getAttribute('height');
97
- this.viewBox = _viewBox ?? { x: 0, y: 0, width: Number(_width) || 0, height: Number(_height) || 0 };
98
- }
99
- else {
100
- const _width = this.style.getPropertyValue('--svg-width');
101
- const _height = this.style.getPropertyValue('--svg-height');
102
- this.viewBox = { x: 0, y: 0, width: parseFloat(_width) || 0, height: parseFloat(_height) || 0 };
103
- }
104
- }
105
- render() {
106
- const viewBox = this.viewBox;
107
- const preserveAspectRatio = this.preserveAspectRatio;
108
- const svgClasses = this.svgClasses();
109
- // Check if svg exists, otherwise early return
110
- if (typeof this.svg === 'string')
111
- return html `<p style="font-size: initial;">⚠️ SVG Error</p>`;
112
- else {
113
- // SVGElement provided as input
114
- if (this.svg instanceof SVGElement) {
115
- const clonedSVG = this.svg.cloneNode(true);
116
- this.applyPartToPaths(clonedSVG, '__path');
117
- return buildSVG(Array.from(clonedSVG.children), viewBox);
118
- }
119
- // TemplateResult<2> provided as input
120
- else
121
- return buildSVG(this.svg, viewBox);
122
- }
123
- function buildSVG(svg, viewBox) {
124
- if (svg) {
125
- return html `
126
- <svg
127
- part="__svg"
128
- class=${classMap(svgClasses)}
129
- style=${styleMap({
130
- '--svg-width-fallback': `${viewBox.width}em`,
131
- '--svg-height-fallback': `${viewBox.height}em`,
132
- })}
133
- viewBox="${viewBox.x} ${viewBox.y} ${viewBox.width} ${viewBox.height}"
134
- preserveAspectRatio=${preserveAspectRatio}
135
- xmlns="http://www.w3.org/2000/svg"
136
- >
137
- ${svg}
138
- </svg>
64
+ }
65
+ render() {
66
+ const t = this.viewBox, e = this.preserveAspectRatio, i = this.svgClasses();
67
+ if (typeof this.svg == "string") return c`<p style="font-size: initial;">⚠️ SVG Error</p>`;
68
+ if (this.svg instanceof SVGElement) {
69
+ const s = this.svg.cloneNode(!0);
70
+ return this.applyPartToPaths(s, "__path"), o(Array.from(s.children), t);
71
+ } else return o(this.svg, t);
72
+ function o(s, r) {
73
+ if (s)
74
+ return c`
75
+ <svg
76
+ part="__svg"
77
+ class=${m(i)}
78
+ style=${f({
79
+ "--svg-width-fallback": `${r.width}em`,
80
+ "--svg-height-fallback": `${r.height}em`
81
+ })}
82
+ viewBox="${r.x} ${r.y} ${r.width} ${r.height}"
83
+ preserveAspectRatio=${e}
84
+ xmlns="http://www.w3.org/2000/svg"
85
+ >
86
+ ${s}
87
+ </svg>
139
88
  `;
140
- }
141
- }
142
- }
143
- /** Applies a part name to all paths in the given element. */
144
- applyPartToPaths(element, partValue) {
145
- if (element instanceof Element) {
146
- if (element.tagName.toLowerCase() === 'path') {
147
- element.setAttribute('part', partValue);
148
- }
149
- // Recursively check each child
150
- for (const child of Array.from(element.children)) {
151
- this.applyPartToPaths(child, partValue);
152
- }
153
- }
154
89
  }
155
- /**
156
- * Gets the viewBox dimensions from an SVG element.
157
- * @param svg The SVG to get the attribute from.
158
- * @returns The SVG viewBox x, y, width, and height
159
- */
160
- getViewBoxSize(svg) {
161
- const viewBox = svg.getAttribute('viewBox')?.split(' ');
162
- if (!viewBox)
163
- return null;
164
- return { x: +viewBox[0], y: +viewBox[1], width: +viewBox[2], height: +viewBox[3] };
90
+ }
91
+ /** Applies a part name to all paths in the given element. */
92
+ applyPartToPaths(t, e) {
93
+ if (t instanceof Element) {
94
+ t.tagName.toLowerCase() === "path" && t.setAttribute("part", e);
95
+ for (const i of Array.from(t.children))
96
+ this.applyPartToPaths(i, e);
165
97
  }
98
+ }
99
+ /**
100
+ * Gets the viewBox dimensions from an SVG element.
101
+ * @param svg The SVG to get the attribute from.
102
+ * @returns The SVG viewBox x, y, width, and height
103
+ */
104
+ getViewBoxSize(t) {
105
+ const e = t.getAttribute("viewBox")?.split(" ");
106
+ return e ? { x: +e[0], y: +e[1], width: +e[2], height: +e[3] } : null;
107
+ }
108
+ };
109
+ p.styles = [y];
110
+ n([
111
+ a({ type: Boolean, reflect: !0 })
112
+ ], p.prototype, "autofit", 2);
113
+ n([
114
+ a({ type: Boolean, reflect: !0 })
115
+ ], p.prototype, "svgColors", 2);
116
+ n([
117
+ a({ type: Object })
118
+ ], p.prototype, "svg", 1);
119
+ n([
120
+ a({ type: String, reflect: !0 })
121
+ ], p.prototype, "preserveAspectRatio", 1);
122
+ p = n([
123
+ v("responsive-svg")
124
+ ], p);
125
+ export {
126
+ p as ResponsiveSvg,
127
+ l as preserveAspectRatioAlignOptions,
128
+ M as preserveAspectRatioOptions,
129
+ A as preserveAspectRatioSpacingOptions
166
130
  };
167
- __decorate([
168
- property({ type: Boolean, reflect: true })
169
- ], ResponsiveSvg.prototype, "autofit", void 0);
170
- __decorate([
171
- property({ type: Boolean, reflect: true })
172
- ], ResponsiveSvg.prototype, "svgColors", void 0);
173
- __decorate([
174
- property({ type: Object })
175
- ], ResponsiveSvg.prototype, "svg", null);
176
- __decorate([
177
- property({ type: String, reflect: true })
178
- ], ResponsiveSvg.prototype, "preserveAspectRatio", null);
179
- ResponsiveSvg = __decorate([
180
- customElement('responsive-svg')
181
- ], ResponsiveSvg);
182
- export { ResponsiveSvg };