@alegendstale/holly-components 2.0.3 → 2.0.5
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/custom-elements.json +6366 -0
- 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.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 +43 -60
- 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,182 +1,117 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { html as l } from "lit";
|
|
2
|
+
import { query as d, property as p, customElement as f } from "lit/decorators.js";
|
|
3
|
+
import w from "quantize";
|
|
4
|
+
import { CanvasBase as c } from "./canvas-base.js";
|
|
5
|
+
import y from "./canvas-image.styles.js";
|
|
6
|
+
var v = Object.defineProperty, x = Object.getOwnPropertyDescriptor, h = (t, a, e, s) => {
|
|
7
|
+
for (var i = s > 1 ? void 0 : s ? x(a, e) : a, o = t.length - 1, n; o >= 0; o--)
|
|
8
|
+
(n = t[o]) && (i = (s ? n(a, e, i) : n(i)) || i);
|
|
9
|
+
return s && i && v(a, e, i), i;
|
|
6
10
|
};
|
|
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
|
-
static { this.styles = [...CanvasBase.styles, styles]; }
|
|
33
|
-
updated(_changedProperties) {
|
|
34
|
-
super.updated(_changedProperties);
|
|
35
|
-
if (_changedProperties.has('imageURL')) {
|
|
36
|
-
this.status = this.imageURL ? 'loading' : 'idle';
|
|
37
|
-
}
|
|
38
|
-
else if ((_changedProperties.has('width') || _changedProperties.has('height')) && this.status === 'success') {
|
|
39
|
-
this._performDraw();
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
get updateComplete() {
|
|
43
|
-
const _waitForImage = async () => {
|
|
44
|
-
await super.updateComplete;
|
|
45
|
-
if (this.status === 'loading') {
|
|
46
|
-
await new Promise((resolve) => {
|
|
47
|
-
this.addEventListener('canvas-ready', resolve, { once: true });
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
if (this.status === 'error') {
|
|
51
|
-
throw new Error(`canvas-image failed to load ${this.imageURL}`);
|
|
52
|
-
}
|
|
53
|
-
return true;
|
|
54
|
-
};
|
|
55
|
-
return _waitForImage();
|
|
56
|
-
}
|
|
57
|
-
render() {
|
|
58
|
-
// Allows CORS requests for images from different domains
|
|
59
|
-
return html `
|
|
60
|
-
${super.render()}
|
|
61
|
-
<img
|
|
62
|
-
src=${this.imageURL}
|
|
63
|
-
crossorigin='anonymous'
|
|
64
|
-
@load=${() => this._performDraw()}
|
|
65
|
-
@error=${() => this._handleLoadError()}
|
|
66
|
-
>
|
|
11
|
+
let r = class extends c {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(...arguments), this.imageURL = "", this.smoothing = !1, this.width = 0, this.height = 0, this.status = "idle";
|
|
14
|
+
}
|
|
15
|
+
updated(t) {
|
|
16
|
+
super.updated(t), t.has("imageURL") ? this.status = this.imageURL ? "loading" : "idle" : (t.has("width") || t.has("height")) && this.status === "success" && this._performDraw();
|
|
17
|
+
}
|
|
18
|
+
get updateComplete() {
|
|
19
|
+
return (async () => {
|
|
20
|
+
if (await super.updateComplete, this.status === "loading" && await new Promise((a) => {
|
|
21
|
+
this.addEventListener("canvas-ready", a, { once: !0 });
|
|
22
|
+
}), this.status === "error")
|
|
23
|
+
throw new Error(`canvas-image failed to load ${this.imageURL}`);
|
|
24
|
+
return !0;
|
|
25
|
+
})();
|
|
26
|
+
}
|
|
27
|
+
render() {
|
|
28
|
+
return l`
|
|
29
|
+
${super.render()}
|
|
30
|
+
<img
|
|
31
|
+
src=${this.imageURL}
|
|
32
|
+
crossorigin='anonymous'
|
|
33
|
+
@load=${() => this._performDraw()}
|
|
34
|
+
@error=${() => this._handleLoadError()}
|
|
35
|
+
>
|
|
67
36
|
`;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Updates & loads the canvas image.
|
|
40
|
+
* Attempts to preserve aspect ratio based on width.
|
|
41
|
+
*/
|
|
42
|
+
_performDraw() {
|
|
43
|
+
const t = this.image;
|
|
44
|
+
if (!t || !this.context) return;
|
|
45
|
+
const a = t.naturalHeight / t.naturalWidth;
|
|
46
|
+
let e = this.width, s = e * a;
|
|
47
|
+
s > this.height && (e = this.height / a, s = this.height), this.canvas.width = e, this.canvas.height = s, this.context.imageSmoothingEnabled = this.smoothing, this.context.drawImage(t, 0, 0, e, s), this.status = "success", this.dispatchEvent(new CustomEvent("canvas-ready"));
|
|
48
|
+
}
|
|
49
|
+
/** @internal Handle errors when the image fails to load. */
|
|
50
|
+
_handleLoadError() {
|
|
51
|
+
this.status = this.imageURL === "" ? "idle" : "error", this.dispatchEvent(new CustomEvent("canvas-ready"));
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Gets the most frequent colors in an image.
|
|
55
|
+
* @param numColors Number of colors to return
|
|
56
|
+
* @param quality Artificially reduce number of pixels (higher = less accurate but faster)
|
|
57
|
+
* @returns Most frequent colors
|
|
58
|
+
*/
|
|
59
|
+
async getPalette(t = 7, a = 10) {
|
|
60
|
+
const e = t <= 7 ? t : t + 1;
|
|
61
|
+
await this.updateComplete;
|
|
62
|
+
const s = await this.createPixelArray(a);
|
|
63
|
+
if (!s) return null;
|
|
64
|
+
const i = w(s, e);
|
|
65
|
+
return i ? i.palette() : [];
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Creates an array of pixels from the image.
|
|
69
|
+
* Inspired by colorthief
|
|
70
|
+
* @param quality Artificially reduce number of pixels (higher = less accurate but faster)
|
|
71
|
+
* @returns Array of pixels
|
|
72
|
+
*/
|
|
73
|
+
async createPixelArray(t) {
|
|
74
|
+
await this.updateComplete;
|
|
75
|
+
const a = [], e = (await this.getImageData())?.data;
|
|
76
|
+
if (!e) return null;
|
|
77
|
+
const s = this.height * this.width;
|
|
78
|
+
for (let i = 0; i < s; i += t) {
|
|
79
|
+
const o = i * 4, [n, m, u, g] = [e[o + 0], e[o + 1], e[o + 2], e[o + 3]];
|
|
80
|
+
(typeof g > "u" || g >= 125) && (n > 250 && m > 250 && u > 250 || a.push([n, m, u]));
|
|
68
81
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
// Calculate the new height based on the aspect ratio
|
|
78
|
-
const aspectRatio = img.naturalHeight / img.naturalWidth;
|
|
79
|
-
let drawWidth = this.width;
|
|
80
|
-
let drawHeight = drawWidth * aspectRatio;
|
|
81
|
-
// Ensure the new height fits within the canvas height
|
|
82
|
-
if (drawHeight > this.height) {
|
|
83
|
-
// Adjust width if height exceeds canvas height
|
|
84
|
-
drawWidth = this.height / aspectRatio;
|
|
85
|
-
drawHeight = this.height;
|
|
86
|
-
}
|
|
87
|
-
this.canvas.width = drawWidth;
|
|
88
|
-
this.canvas.height = drawHeight;
|
|
89
|
-
this.context.imageSmoothingEnabled = this.smoothing;
|
|
90
|
-
this.context.drawImage(img, 0, 0, drawWidth, drawHeight);
|
|
91
|
-
this.status = 'success';
|
|
92
|
-
this.dispatchEvent(new CustomEvent('canvas-ready'));
|
|
93
|
-
}
|
|
94
|
-
/** @internal Handle errors when the image fails to load. */
|
|
95
|
-
_handleLoadError() {
|
|
96
|
-
// Return to idle state if there is no URL.
|
|
97
|
-
this.status = this.imageURL === '' ? 'idle' : 'error';
|
|
98
|
-
this.dispatchEvent(new CustomEvent('canvas-ready'));
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Gets the most frequent colors in an image.
|
|
102
|
-
* @param numColors Number of colors to return
|
|
103
|
-
* @param quality Artificially reduce number of pixels (higher = less accurate but faster)
|
|
104
|
-
* @returns Most frequent colors
|
|
105
|
-
*/
|
|
106
|
-
async getPalette(numColors = 7, quality = 10) {
|
|
107
|
-
/*
|
|
108
|
-
Quantize has an issue with number of colors which has been addressed here https://github.com/olivierlesnicki/quantize/issues/9
|
|
109
|
-
`nColors` is a simple fix for this.
|
|
110
|
-
*/
|
|
111
|
-
const nColors = numColors <= 7 ? numColors : numColors + 1;
|
|
112
|
-
// Wait for image to load
|
|
113
|
-
await this.updateComplete;
|
|
114
|
-
// Get an array of pixels
|
|
115
|
-
const pixels = await this.createPixelArray(quality);
|
|
116
|
-
if (!pixels)
|
|
117
|
-
return null;
|
|
118
|
-
// Reduce pixels array to a small number of the most common colors
|
|
119
|
-
const colorMap = quantize(pixels, nColors);
|
|
120
|
-
// Return palette
|
|
121
|
-
return colorMap ? colorMap.palette() : [];
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Creates an array of pixels from the image.
|
|
125
|
-
* Inspired by colorthief
|
|
126
|
-
* @param quality Artificially reduce number of pixels (higher = less accurate but faster)
|
|
127
|
-
* @returns Array of pixels
|
|
128
|
-
*/
|
|
129
|
-
async createPixelArray(quality) {
|
|
130
|
-
await this.updateComplete;
|
|
131
|
-
const pixelArray = [];
|
|
132
|
-
const imageData = (await this.getImageData())?.data;
|
|
133
|
-
if (!imageData)
|
|
134
|
-
return null;
|
|
135
|
-
// Get number of pixels in image
|
|
136
|
-
const pixelCount = this.height * this.width;
|
|
137
|
-
for (let i = 0; i < pixelCount; i += quality) {
|
|
138
|
-
// Offset to correct starting position of each pixel
|
|
139
|
-
const offset = i * 4;
|
|
140
|
-
const [r, g, b, a] = [imageData[offset + 0], imageData[offset + 1], imageData[offset + 2], imageData[offset + 3]];
|
|
141
|
-
// If pixel is mostly opaque and not white
|
|
142
|
-
if (typeof a === 'undefined' || a >= 125) {
|
|
143
|
-
if (!(r > 250 && g > 250 && b > 250)) {
|
|
144
|
-
pixelArray.push([r, g, b]);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
return pixelArray;
|
|
149
|
-
}
|
|
150
|
-
/** Gets the image data from the canvas. */
|
|
151
|
-
async getImageData(x = 0, y = 0) {
|
|
152
|
-
try {
|
|
153
|
-
await this.updateComplete;
|
|
154
|
-
return this.context.getImageData(x, y, this.canvas.width, this.canvas.height);
|
|
155
|
-
}
|
|
156
|
-
catch (e) {
|
|
157
|
-
throw new Error('Failed to get image data.');
|
|
158
|
-
}
|
|
82
|
+
return a;
|
|
83
|
+
}
|
|
84
|
+
/** Gets the image data from the canvas. */
|
|
85
|
+
async getImageData(t = 0, a = 0) {
|
|
86
|
+
try {
|
|
87
|
+
return await this.updateComplete, this.context.getImageData(t, a, this.canvas.width, this.canvas.height);
|
|
88
|
+
} catch {
|
|
89
|
+
throw new Error("Failed to get image data.");
|
|
159
90
|
}
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
r.styles = [...c.styles, y];
|
|
94
|
+
h([
|
|
95
|
+
d("img")
|
|
96
|
+
], r.prototype, "image", 2);
|
|
97
|
+
h([
|
|
98
|
+
p({ type: String })
|
|
99
|
+
], r.prototype, "imageURL", 2);
|
|
100
|
+
h([
|
|
101
|
+
p({ type: Boolean })
|
|
102
|
+
], r.prototype, "smoothing", 2);
|
|
103
|
+
h([
|
|
104
|
+
p({ type: Number })
|
|
105
|
+
], r.prototype, "width", 2);
|
|
106
|
+
h([
|
|
107
|
+
p({ type: Number })
|
|
108
|
+
], r.prototype, "height", 2);
|
|
109
|
+
h([
|
|
110
|
+
p({ type: String, reflect: !0, attribute: "data-status" })
|
|
111
|
+
], r.prototype, "status", 2);
|
|
112
|
+
r = h([
|
|
113
|
+
f("canvas-image")
|
|
114
|
+
], r);
|
|
115
|
+
export {
|
|
116
|
+
r as CanvasImage
|
|
160
117
|
};
|
|
161
|
-
__decorate([
|
|
162
|
-
query('img')
|
|
163
|
-
], CanvasImage.prototype, "image", void 0);
|
|
164
|
-
__decorate([
|
|
165
|
-
property({ type: String })
|
|
166
|
-
], CanvasImage.prototype, "imageURL", void 0);
|
|
167
|
-
__decorate([
|
|
168
|
-
property({ type: Boolean })
|
|
169
|
-
], CanvasImage.prototype, "smoothing", void 0);
|
|
170
|
-
__decorate([
|
|
171
|
-
property({ type: Number })
|
|
172
|
-
], CanvasImage.prototype, "width", void 0);
|
|
173
|
-
__decorate([
|
|
174
|
-
property({ type: Number })
|
|
175
|
-
], CanvasImage.prototype, "height", void 0);
|
|
176
|
-
__decorate([
|
|
177
|
-
property({ type: String, reflect: true, attribute: 'data-status' })
|
|
178
|
-
], CanvasImage.prototype, "status", void 0);
|
|
179
|
-
CanvasImage = __decorate([
|
|
180
|
-
customElement('canvas-image')
|
|
181
|
-
], CanvasImage);
|
|
182
|
-
export { CanvasImage };
|
|
@@ -1,21 +1,24 @@
|
|
|
1
|
-
import { css } from
|
|
2
|
-
|
|
3
|
-
:host {
|
|
4
|
-
display: block;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
:host([data-status='error']) {
|
|
8
|
-
width: 100px;
|
|
9
|
-
height: 100px;
|
|
10
|
-
border: 2px solid red;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/* Hide when width hasn't been set */
|
|
14
|
-
canvas:not([width]) {
|
|
15
|
-
display: none;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
img {
|
|
19
|
-
display: none;
|
|
20
|
-
}
|
|
1
|
+
import { css as s } from "lit";
|
|
2
|
+
const e = s`
|
|
3
|
+
:host {
|
|
4
|
+
display: block;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
:host([data-status='error']) {
|
|
8
|
+
width: 100px;
|
|
9
|
+
height: 100px;
|
|
10
|
+
border: 2px solid red;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/* Hide when width hasn't been set */
|
|
14
|
+
canvas:not([width]) {
|
|
15
|
+
display: none;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
img {
|
|
19
|
+
display: none;
|
|
20
|
+
}
|
|
21
21
|
`;
|
|
22
|
+
export {
|
|
23
|
+
e as default
|
|
24
|
+
};
|
|
@@ -1,90 +1,66 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { LitElement as c, html as d } from "lit";
|
|
2
|
+
import { query as u, customElement as a } from "lit/decorators.js";
|
|
3
|
+
import { EventEmitter as m } from "../../utils/EventEmitter.js";
|
|
4
|
+
import S from "./carousel-scroller.styles.js";
|
|
5
|
+
var _ = Object.defineProperty, p = Object.getOwnPropertyDescriptor, h = (e, s, r, l) => {
|
|
6
|
+
for (var t = l > 1 ? void 0 : l ? p(s, r) : s, o = e.length - 1, n; o >= 0; o--)
|
|
7
|
+
(n = e[o]) && (t = (l ? n(s, r, t) : n(t)) || t);
|
|
8
|
+
return l && t && _(s, r, t), t;
|
|
6
9
|
};
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
/** @internal */
|
|
26
|
-
this._currentSlide = 0;
|
|
27
|
-
/** @internal */
|
|
28
|
-
this.debouncers = new WeakMap();
|
|
29
|
-
this.emitter.on('slotsLoaded', (slotChildren) => {
|
|
30
|
-
this.slotChildren = slotChildren;
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
disconnectedCallback() {
|
|
34
|
-
super.disconnectedCallback();
|
|
35
|
-
this.emitter.clear();
|
|
36
|
-
}
|
|
37
|
-
render() {
|
|
38
|
-
return html `
|
|
39
|
-
<div class="container">
|
|
40
|
-
<button @click=${this.scrollToPrevSlide}><</button>
|
|
41
|
-
<button @click=${this.scrollToNextSlide}>></button>
|
|
42
|
-
<div>
|
|
43
|
-
<slot @slotchange=${this.slotChange}></slot>
|
|
44
|
-
</div>
|
|
45
|
-
</div>
|
|
10
|
+
let i = class extends c {
|
|
11
|
+
constructor() {
|
|
12
|
+
super(), this.slotChildren = [], this.emitter = new m(), this._currentSlide = 0, this.debouncers = /* @__PURE__ */ new WeakMap(), this.emitter.on("slotsLoaded", (e) => {
|
|
13
|
+
this.slotChildren = e;
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
disconnectedCallback() {
|
|
17
|
+
super.disconnectedCallback(), this.emitter.clear();
|
|
18
|
+
}
|
|
19
|
+
render() {
|
|
20
|
+
return d`
|
|
21
|
+
<div class="container">
|
|
22
|
+
<button @click=${this.scrollToPrevSlide}><</button>
|
|
23
|
+
<button @click=${this.scrollToNextSlide}>></button>
|
|
24
|
+
<div>
|
|
25
|
+
<slot @slotchange=${this.slotChange}></slot>
|
|
26
|
+
</div>
|
|
27
|
+
</div>
|
|
46
28
|
`;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
29
|
+
}
|
|
30
|
+
/** Gets the current slide.
|
|
31
|
+
* @returns HTMLElement
|
|
32
|
+
*/
|
|
33
|
+
getCurrentSlide() {
|
|
34
|
+
return this.slotChildren[this._currentSlide - 1];
|
|
35
|
+
}
|
|
36
|
+
/** Scrolls to the slide before the current slide. */
|
|
37
|
+
scrollToPrevSlide() {
|
|
38
|
+
this._currentSlide = this._currentSlide === 0 ? this._currentSlide = this.slotChildren.length - 1 : this._currentSlide - 1, this.slotChildren.at(this._currentSlide)?.scrollIntoView({ behavior: "smooth", block: "nearest" });
|
|
39
|
+
}
|
|
40
|
+
/** Scrolls to the slide after the current slide. */
|
|
41
|
+
scrollToNextSlide() {
|
|
42
|
+
this._currentSlide = this._currentSlide === this.slotChildren.length - 1 ? 0 : this._currentSlide + 1, this.slotChildren.at(this._currentSlide)?.scrollIntoView({ behavior: "smooth", block: "nearest" });
|
|
43
|
+
}
|
|
44
|
+
/** @internal */
|
|
45
|
+
slotChange() {
|
|
46
|
+
const e = Array.from(
|
|
47
|
+
this.slotEl.assignedElements().map((r) => r)
|
|
48
|
+
);
|
|
49
|
+
clearTimeout(this.debouncers.get(this.slotEl));
|
|
50
|
+
const s = setTimeout(
|
|
51
|
+
() => this.emitter.emit("slotsLoaded", e),
|
|
52
|
+
100
|
|
53
|
+
);
|
|
54
|
+
this.debouncers.set(this.slotEl, s);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
i.styles = [S];
|
|
58
|
+
h([
|
|
59
|
+
u("slot")
|
|
60
|
+
], i.prototype, "slotEl", 2);
|
|
61
|
+
i = h([
|
|
62
|
+
a("carousel-scroller")
|
|
63
|
+
], i);
|
|
64
|
+
export {
|
|
65
|
+
i as CarouselScroller
|
|
83
66
|
};
|
|
84
|
-
__decorate([
|
|
85
|
-
query('slot')
|
|
86
|
-
], CarouselScroller.prototype, "slotEl", void 0);
|
|
87
|
-
CarouselScroller = __decorate([
|
|
88
|
-
customElement('carousel-scroller')
|
|
89
|
-
], CarouselScroller);
|
|
90
|
-
export { CarouselScroller };
|
|
@@ -1,66 +1,69 @@
|
|
|
1
|
-
import { css } from
|
|
2
|
-
|
|
3
|
-
:host {
|
|
4
|
-
--padding: 40px;
|
|
5
|
-
--margin: 80px;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
.container {
|
|
9
|
-
width: 600px;
|
|
10
|
-
height: 400px;
|
|
11
|
-
margin: 20px;
|
|
12
|
-
border-radius: 20px;
|
|
13
|
-
overflow: hidden;
|
|
14
|
-
position: relative;
|
|
15
|
-
|
|
16
|
-
& > button {
|
|
17
|
-
position: absolute;
|
|
18
|
-
width: var(--padding);
|
|
19
|
-
height: calc(var(--padding) * 2);
|
|
20
|
-
z-index: 1;
|
|
21
|
-
background-color: #00000080;
|
|
22
|
-
border: none;
|
|
23
|
-
bottom: calc(50% - var(--padding));
|
|
24
|
-
font-size: 32px;
|
|
25
|
-
|
|
26
|
-
&:hover {
|
|
27
|
-
background-color: #6352b880;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
&:nth-child(1) {
|
|
31
|
-
left: 0;
|
|
32
|
-
border-top-right-radius: 314px;
|
|
33
|
-
border-bottom-right-radius: 314px;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
&:nth-child(2) {
|
|
37
|
-
right: 0;
|
|
38
|
-
border-top-left-radius: 314px;
|
|
39
|
-
border-bottom-left-radius: 314px;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
& > div {
|
|
44
|
-
display: flex;
|
|
45
|
-
overflow-x: scroll;
|
|
46
|
-
position: relative;
|
|
47
|
-
scroll-behavior: smooth;
|
|
48
|
-
scroll-snap-type: x mandatory;
|
|
49
|
-
scrollbar-width: none;
|
|
50
|
-
padding: 0 var(--padding);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
::slotted(*) {
|
|
54
|
-
display: flex;
|
|
55
|
-
flex-direction: column;
|
|
56
|
-
justify-content: center;
|
|
57
|
-
min-height: calc(400px - var(--margin));
|
|
58
|
-
min-width: calc(600px - var(--margin));
|
|
59
|
-
max-height: calc(400px - var(--margin));
|
|
60
|
-
max-width: calc(600px - var(--margin));
|
|
61
|
-
background: white;
|
|
62
|
-
scroll-snap-align: center;
|
|
63
|
-
padding: calc(var(--margin) / 2);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
1
|
+
import { css as r } from "lit";
|
|
2
|
+
const o = r`
|
|
3
|
+
:host {
|
|
4
|
+
--padding: 40px;
|
|
5
|
+
--margin: 80px;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.container {
|
|
9
|
+
width: 600px;
|
|
10
|
+
height: 400px;
|
|
11
|
+
margin: 20px;
|
|
12
|
+
border-radius: 20px;
|
|
13
|
+
overflow: hidden;
|
|
14
|
+
position: relative;
|
|
15
|
+
|
|
16
|
+
& > button {
|
|
17
|
+
position: absolute;
|
|
18
|
+
width: var(--padding);
|
|
19
|
+
height: calc(var(--padding) * 2);
|
|
20
|
+
z-index: 1;
|
|
21
|
+
background-color: #00000080;
|
|
22
|
+
border: none;
|
|
23
|
+
bottom: calc(50% - var(--padding));
|
|
24
|
+
font-size: 32px;
|
|
25
|
+
|
|
26
|
+
&:hover {
|
|
27
|
+
background-color: #6352b880;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
&:nth-child(1) {
|
|
31
|
+
left: 0;
|
|
32
|
+
border-top-right-radius: 314px;
|
|
33
|
+
border-bottom-right-radius: 314px;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
&:nth-child(2) {
|
|
37
|
+
right: 0;
|
|
38
|
+
border-top-left-radius: 314px;
|
|
39
|
+
border-bottom-left-radius: 314px;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
& > div {
|
|
44
|
+
display: flex;
|
|
45
|
+
overflow-x: scroll;
|
|
46
|
+
position: relative;
|
|
47
|
+
scroll-behavior: smooth;
|
|
48
|
+
scroll-snap-type: x mandatory;
|
|
49
|
+
scrollbar-width: none;
|
|
50
|
+
padding: 0 var(--padding);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
::slotted(*) {
|
|
54
|
+
display: flex;
|
|
55
|
+
flex-direction: column;
|
|
56
|
+
justify-content: center;
|
|
57
|
+
min-height: calc(400px - var(--margin));
|
|
58
|
+
min-width: calc(600px - var(--margin));
|
|
59
|
+
max-height: calc(400px - var(--margin));
|
|
60
|
+
max-width: calc(600px - var(--margin));
|
|
61
|
+
background: white;
|
|
62
|
+
scroll-snap-align: center;
|
|
63
|
+
padding: calc(var(--margin) / 2);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
66
|
`;
|
|
67
|
+
export {
|
|
68
|
+
o as default
|
|
69
|
+
};
|