@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.
- package/dist/components/absolute-container/absolute-container.js +79 -113
- package/dist/components/absolute-container/absolute-container.styles.js +20 -17
- package/dist/components/bottom-sheet/bottom-sheet.js +189 -319
- package/dist/components/bottom-sheet/bottom-sheet.styles.js +117 -114
- package/dist/components/canvas/canvas-base.d.ts +4 -1
- package/dist/components/canvas/canvas-base.d.ts.map +1 -1
- package/dist/components/canvas/canvas-base.js +51 -67
- package/dist/components/canvas/canvas-gradient.js +44 -69
- package/dist/components/canvas/canvas-image.js +112 -177
- package/dist/components/canvas/canvas-image.styles.js +23 -20
- package/dist/components/carousel-scroller/carousel-scroller.js +63 -87
- package/dist/components/carousel-scroller/carousel-scroller.styles.js +68 -65
- package/dist/components/color-palette/color-palette-utils.js +55 -104
- package/dist/components/color-palette/color-palette.js +250 -384
- package/dist/components/color-palette/color-palette.styles.js +92 -89
- package/dist/components/color-palette/component/color-palette-component.js +134 -188
- package/dist/components/color-palette/component/color-palette-component.styles.js +12 -9
- package/dist/components/color-palette/editor/color-palette-editor.js +413 -539
- package/dist/components/color-palette/editor/color-palette-editor.styles.js +149 -146
- package/dist/components/color-palette/editor/settings-item.js +32 -40
- package/dist/components/color-palette/editor/settings-item.styles.js +36 -33
- package/dist/components/color-palette/item/color-palette-item-edit.js +50 -84
- package/dist/components/color-palette/item/color-palette-item-edit.styles.js +53 -50
- package/dist/components/color-palette/item/color-palette-item.js +72 -107
- package/dist/components/color-palette/item/color-palette-item.styles.js +85 -82
- package/dist/components/color-palette/menu/color-palette-menu.js +162 -200
- package/dist/components/color-palette/menu/color-palette-menu.styles.js +51 -48
- package/dist/components/color-palette/menu/color-palette-reorder.js +76 -95
- package/dist/components/color-palette/menu/color-palette-reorder.styles.js +33 -30
- package/dist/components/draw-svg/draw-svg.js +35 -52
- package/dist/components/draw-svg/draw-svg.styles.js +41 -38
- package/dist/components/responsive-svg/responsive-svg.d.ts +2 -2
- package/dist/components/responsive-svg/responsive-svg.d.ts.map +1 -1
- package/dist/components/responsive-svg/responsive-svg.js +122 -174
- package/dist/components/responsive-svg/responsive-svg.styles.js +48 -45
- package/dist/components/tool-tip/tool-tip.d.ts +5 -1
- package/dist/components/tool-tip/tool-tip.d.ts.map +1 -1
- package/dist/components/tool-tip/tool-tip.js +64 -100
- package/dist/components/tool-tip/tool-tip.styles.js +60 -57
- package/dist/decorators/condCustomElement.js +8 -11
- package/dist/utils/EventEmitter.js +23 -23
- package/dist/utils/ResponsiveController.js +15 -18
- package/dist/utils/basicUtils.js +98 -146
- package/dist/utils/colorsea-wrapper.js +162 -166
- package/dist/utils/dragDropUtils.js +75 -119
- package/dist/utils/generateUtils.js +39 -73
- package/package.json +34 -64
- package/dist/components/absolute-container/absolute-container.stories.d.ts +0 -11
- package/dist/components/absolute-container/absolute-container.stories.d.ts.map +0 -1
- package/dist/components/absolute-container/absolute-container.stories.js +0 -64
- package/dist/components/absolute-container/index.d.ts +0 -2
- package/dist/components/absolute-container/index.d.ts.map +0 -1
- package/dist/components/absolute-container/index.js +0 -1
- package/dist/components/bottom-sheet/bottom-sheet.stories.d.ts +0 -17
- package/dist/components/bottom-sheet/bottom-sheet.stories.d.ts.map +0 -1
- package/dist/components/bottom-sheet/bottom-sheet.stories.js +0 -67
- package/dist/components/bottom-sheet/index.d.ts +0 -2
- package/dist/components/bottom-sheet/index.d.ts.map +0 -1
- package/dist/components/bottom-sheet/index.js +0 -1
- package/dist/components/canvas/canvas-base.stories.d.ts +0 -7
- package/dist/components/canvas/canvas-base.stories.d.ts.map +0 -1
- package/dist/components/canvas/canvas-base.stories.js +0 -24
- package/dist/components/canvas/canvas-gradient.stories.d.ts +0 -14
- package/dist/components/canvas/canvas-gradient.stories.d.ts.map +0 -1
- package/dist/components/canvas/canvas-gradient.stories.js +0 -46
- package/dist/components/canvas/canvas-image.stories.d.ts +0 -13
- package/dist/components/canvas/canvas-image.stories.d.ts.map +0 -1
- package/dist/components/canvas/canvas-image.stories.js +0 -49
- package/dist/components/canvas/index.d.ts +0 -3
- package/dist/components/canvas/index.d.ts.map +0 -1
- package/dist/components/canvas/index.js +0 -2
- package/dist/components/carousel-scroller/carousel-scroller.stories.d.ts +0 -13
- package/dist/components/carousel-scroller/carousel-scroller.stories.d.ts.map +0 -1
- package/dist/components/carousel-scroller/carousel-scroller.stories.js +0 -56
- package/dist/components/carousel-scroller/index.d.ts +0 -2
- package/dist/components/carousel-scroller/index.d.ts.map +0 -1
- package/dist/components/carousel-scroller/index.js +0 -1
- package/dist/components/color-palette/component/color-palette-component.stories.d.ts +0 -13
- package/dist/components/color-palette/component/color-palette-component.stories.d.ts.map +0 -1
- package/dist/components/color-palette/component/color-palette-component.stories.js +0 -75
- package/dist/components/color-palette/component/index.d.ts +0 -2
- package/dist/components/color-palette/component/index.d.ts.map +0 -1
- package/dist/components/color-palette/component/index.js +0 -1
- package/dist/components/color-palette/editor/color-palette-editor.stories.d.ts +0 -18
- package/dist/components/color-palette/editor/color-palette-editor.stories.d.ts.map +0 -1
- package/dist/components/color-palette/editor/color-palette-editor.stories.js +0 -67
- package/dist/components/color-palette/editor/index.d.ts +0 -2
- package/dist/components/color-palette/editor/index.d.ts.map +0 -1
- package/dist/components/color-palette/editor/index.js +0 -1
- package/dist/components/color-palette/index.d.ts +0 -6
- package/dist/components/color-palette/index.d.ts.map +0 -1
- package/dist/components/color-palette/index.js +0 -5
- package/dist/components/color-palette/item/index.d.ts +0 -3
- package/dist/components/color-palette/item/index.d.ts.map +0 -1
- package/dist/components/color-palette/item/index.js +0 -2
- package/dist/components/color-palette/menu/index.d.ts +0 -3
- package/dist/components/color-palette/menu/index.d.ts.map +0 -1
- package/dist/components/color-palette/menu/index.js +0 -2
- package/dist/components/color-palette/storybook/color-palette-invalid.stories.d.ts +0 -33
- package/dist/components/color-palette/storybook/color-palette-invalid.stories.d.ts.map +0 -1
- package/dist/components/color-palette/storybook/color-palette-invalid.stories.js +0 -62
- package/dist/components/color-palette/storybook/color-palette-valid.stories.d.ts +0 -52
- package/dist/components/color-palette/storybook/color-palette-valid.stories.d.ts.map +0 -1
- package/dist/components/color-palette/storybook/color-palette-valid.stories.js +0 -268
- package/dist/components/color-palette/storybook/color-palette.stories.d.ts +0 -27
- package/dist/components/color-palette/storybook/color-palette.stories.d.ts.map +0 -1
- package/dist/components/color-palette/storybook/color-palette.stories.js +0 -129
- package/dist/components/draw-svg/draw-svg.stories.d.ts +0 -7
- package/dist/components/draw-svg/draw-svg.stories.d.ts.map +0 -1
- package/dist/components/draw-svg/draw-svg.stories.js +0 -61
- package/dist/components/draw-svg/index.d.ts +0 -2
- package/dist/components/draw-svg/index.d.ts.map +0 -1
- package/dist/components/draw-svg/index.js +0 -1
- package/dist/components/responsive-svg/index.d.ts +0 -2
- package/dist/components/responsive-svg/index.d.ts.map +0 -1
- package/dist/components/responsive-svg/index.js +0 -1
- package/dist/components/responsive-svg/responsive-svg.stories.d.ts +0 -26
- package/dist/components/responsive-svg/responsive-svg.stories.d.ts.map +0 -1
- package/dist/components/responsive-svg/responsive-svg.stories.js +0 -194
- package/dist/components/tool-tip/index.d.ts +0 -2
- package/dist/components/tool-tip/index.d.ts.map +0 -1
- package/dist/components/tool-tip/index.js +0 -1
- package/dist/components/tool-tip/tool-tip.stories.d.ts +0 -16
- package/dist/components/tool-tip/tool-tip.stories.d.ts.map +0 -1
- package/dist/components/tool-tip/tool-tip.stories.js +0 -62
- package/dist/decorators/index.d.ts +0 -2
- package/dist/decorators/index.d.ts.map +0 -1
- package/dist/decorators/index.js +0 -1
- package/dist/index.d.ts +0 -11
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -10
- package/dist/utils/index.d.ts +0 -5
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js +0 -4
- package/dist/utils/types.d.ts +0 -5
- package/dist/utils/types.d.ts.map +0 -1
- package/dist/utils/types.js +0 -1
|
@@ -1,31 +1,34 @@
|
|
|
1
|
-
import { css } from
|
|
2
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
|
2
|
-
|
|
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
|
-
|
|
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,
|
|
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,EAAE,cAAc,EAAE,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,+HAKlC,CAAC;AAEX,eAAO,MAAM,iCAAiC,4BAA6B,CAAC;AAE5E,eAAO,MAAM,0BAA0B,+eAG7B,CAAC;AAEX,MAAM,MAAM,wBAAwB,GAAG,OAAO,+BAA+B,CAAC,MAAM,CAAC,CAAC;AACtF,MAAM,MAAM,0BAA0B,GAAG,OAAO,iCAAiC,CAAC,MAAM,CAAC,CAAC;AAC1F,MAAM,MAAM,mBAAmB,GAAG,OAAO,0BAA0B,CAAC,MAAM,CAAC,CAAC;AAC5E,MAAM,MAAM,oBAAoB,GAAG,GAAG,wBAAwB,IAAI,0BAA0B,EAAE,CAAC;AAQ/F;;;;;;;;;;;GAWG;AACH,qBACa,aAAc,SAAQ,UAAU;IAC5C,MAAM,CAAC,MAAM,4BAAY;IAEzB,kDAAkD;IAElD,OAAO,EAAE,OAAO,CAAS;IAEzB,yCAAyC;IAEzC,SAAS,EAAE,OAAO,CAAS;IAE3B,gBAAgB;IAChB,OAAO,CAAC,IAAI,CAAC,CAAiC;IAC9C;;;;OAIG;IACH,IACI,GAAG,CAAC,GAAG,EAAE,UAAU,GAAG,cAAc,CAAC,CAAC,CAAC,GAAG,MAAM,EASnD;IACD,IAAI,GAAG,IAVM,UAAU,GAAG,cAAc,CAAC,CAAC,CAAC,GAAG,MAAM,CAYnD;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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
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 };
|