@alegendstale/holly-components 0.2.2

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 (106) hide show
  1. package/LICENSE +674 -0
  2. package/README.md +21 -0
  3. package/dist/components/absolute-container/absolute-container.d.ts +34 -0
  4. package/dist/components/absolute-container/absolute-container.d.ts.map +1 -0
  5. package/dist/components/absolute-container/absolute-container.js +96 -0
  6. package/dist/components/absolute-container/absolute-container.stories.d.ts +9 -0
  7. package/dist/components/absolute-container/absolute-container.stories.d.ts.map +1 -0
  8. package/dist/components/absolute-container/index.d.ts +2 -0
  9. package/dist/components/absolute-container/index.d.ts.map +1 -0
  10. package/dist/components/bottom-sheet/bottom-sheet.d.ts +68 -0
  11. package/dist/components/bottom-sheet/bottom-sheet.d.ts.map +1 -0
  12. package/dist/components/bottom-sheet/bottom-sheet.js +312 -0
  13. package/dist/components/bottom-sheet/bottom-sheet.stories.d.ts +14 -0
  14. package/dist/components/bottom-sheet/bottom-sheet.stories.d.ts.map +1 -0
  15. package/dist/components/bottom-sheet/bottom-sheet.test.d.ts +2 -0
  16. package/dist/components/bottom-sheet/bottom-sheet.test.d.ts.map +1 -0
  17. package/dist/components/bottom-sheet/index.d.ts +2 -0
  18. package/dist/components/bottom-sheet/index.d.ts.map +1 -0
  19. package/dist/components/canvas/canvas-base.d.ts +16 -0
  20. package/dist/components/canvas/canvas-base.d.ts.map +1 -0
  21. package/dist/components/canvas/canvas-base.js +48 -0
  22. package/dist/components/canvas/canvas-gradient.d.ts +20 -0
  23. package/dist/components/canvas/canvas-gradient.d.ts.map +1 -0
  24. package/dist/components/canvas/canvas-gradient.js +47 -0
  25. package/dist/components/canvas/canvas-image.d.ts +49 -0
  26. package/dist/components/canvas/canvas-image.d.ts.map +1 -0
  27. package/dist/components/canvas/canvas-image.js +117 -0
  28. package/dist/components/canvas/index.d.ts +3 -0
  29. package/dist/components/canvas/index.d.ts.map +1 -0
  30. package/dist/components/carousel-scroller/carousel-scroller.d.ts +29 -0
  31. package/dist/components/carousel-scroller/carousel-scroller.d.ts.map +1 -0
  32. package/dist/components/carousel-scroller/carousel-scroller.js +125 -0
  33. package/dist/components/carousel-scroller/carousel-scroller.stories.d.ts +11 -0
  34. package/dist/components/carousel-scroller/carousel-scroller.stories.d.ts.map +1 -0
  35. package/dist/components/carousel-scroller/index.d.ts +2 -0
  36. package/dist/components/carousel-scroller/index.d.ts.map +1 -0
  37. package/dist/components/color-palette/color-palette-utils.d.ts +69 -0
  38. package/dist/components/color-palette/color-palette-utils.d.ts.map +1 -0
  39. package/dist/components/color-palette/color-palette-utils.js +43 -0
  40. package/dist/components/color-palette/color-palette.d.ts +61 -0
  41. package/dist/components/color-palette/color-palette.d.ts.map +1 -0
  42. package/dist/components/color-palette/color-palette.js +346 -0
  43. package/dist/components/color-palette/component/color-palette-component.d.ts +22 -0
  44. package/dist/components/color-palette/component/color-palette-component.d.ts.map +1 -0
  45. package/dist/components/color-palette/component/color-palette-component.js +148 -0
  46. package/dist/components/color-palette/component/color-palette-component.stories.d.ts +11 -0
  47. package/dist/components/color-palette/component/color-palette-component.stories.d.ts.map +1 -0
  48. package/dist/components/color-palette/component/index.d.ts +2 -0
  49. package/dist/components/color-palette/component/index.d.ts.map +1 -0
  50. package/dist/components/color-palette/editor/color-palette-editor.d.ts +46 -0
  51. package/dist/components/color-palette/editor/color-palette-editor.d.ts.map +1 -0
  52. package/dist/components/color-palette/editor/color-palette-editor.js +611 -0
  53. package/dist/components/color-palette/editor/color-palette-editor.stories.d.ts +11 -0
  54. package/dist/components/color-palette/editor/color-palette-editor.stories.d.ts.map +1 -0
  55. package/dist/components/color-palette/editor/index.d.ts +2 -0
  56. package/dist/components/color-palette/editor/index.d.ts.map +1 -0
  57. package/dist/components/color-palette/index.d.ts +6 -0
  58. package/dist/components/color-palette/index.d.ts.map +1 -0
  59. package/dist/components/color-palette/item/color-palette-item-edit.d.ts +20 -0
  60. package/dist/components/color-palette/item/color-palette-item-edit.d.ts.map +1 -0
  61. package/dist/components/color-palette/item/color-palette-item-edit.js +91 -0
  62. package/dist/components/color-palette/item/color-palette-item.d.ts +29 -0
  63. package/dist/components/color-palette/item/color-palette-item.d.ts.map +1 -0
  64. package/dist/components/color-palette/item/color-palette-item.js +146 -0
  65. package/dist/components/color-palette/item/index.d.ts +3 -0
  66. package/dist/components/color-palette/item/index.d.ts.map +1 -0
  67. package/dist/components/color-palette/menu/color-palette-menu.d.ts +30 -0
  68. package/dist/components/color-palette/menu/color-palette-menu.d.ts.map +1 -0
  69. package/dist/components/color-palette/menu/color-palette-menu.js +231 -0
  70. package/dist/components/color-palette/menu/color-palette-reorder.d.ts +31 -0
  71. package/dist/components/color-palette/menu/color-palette-reorder.d.ts.map +1 -0
  72. package/dist/components/color-palette/menu/color-palette-reorder.js +108 -0
  73. package/dist/components/color-palette/menu/index.d.ts +3 -0
  74. package/dist/components/color-palette/menu/index.d.ts.map +1 -0
  75. package/dist/components/color-palette/storybook/color-palette-invalid.stories.d.ts +15 -0
  76. package/dist/components/color-palette/storybook/color-palette-invalid.stories.d.ts.map +1 -0
  77. package/dist/components/color-palette/storybook/color-palette-valid.stories.d.ts +34 -0
  78. package/dist/components/color-palette/storybook/color-palette-valid.stories.d.ts.map +1 -0
  79. package/dist/components/color-palette/storybook/color-palette.stories.d.ts +13 -0
  80. package/dist/components/color-palette/storybook/color-palette.stories.d.ts.map +1 -0
  81. package/dist/components/tool-tip/Tooltip2.d.ts +17 -0
  82. package/dist/components/tool-tip/Tooltip2.d.ts.map +1 -0
  83. package/dist/components/tool-tip/index.d.ts +2 -0
  84. package/dist/components/tool-tip/index.d.ts.map +1 -0
  85. package/dist/components/tool-tip/tool-tip.d.ts +29 -0
  86. package/dist/components/tool-tip/tool-tip.d.ts.map +1 -0
  87. package/dist/components/tool-tip/tool-tip.js +106 -0
  88. package/dist/components/tool-tip/tool-tip.stories.d.ts +12 -0
  89. package/dist/components/tool-tip/tool-tip.stories.d.ts.map +1 -0
  90. package/dist/index.d.ts +7 -0
  91. package/dist/index.d.ts.map +1 -0
  92. package/dist/index.js +13 -0
  93. package/dist/utils/EventEmitter.d.ts +9 -0
  94. package/dist/utils/EventEmitter.d.ts.map +1 -0
  95. package/dist/utils/EventEmitter.js +24 -0
  96. package/dist/utils/basicUtils.d.ts +47 -0
  97. package/dist/utils/basicUtils.d.ts.map +1 -0
  98. package/dist/utils/basicUtils.js +23 -0
  99. package/dist/utils/dragDropUtils.d.ts +36 -0
  100. package/dist/utils/dragDropUtils.d.ts.map +1 -0
  101. package/dist/utils/generateUtils.d.ts +27 -0
  102. package/dist/utils/generateUtils.d.ts.map +1 -0
  103. package/dist/utils/generateUtils.js +40 -0
  104. package/dist/utils/types.d.ts +5 -0
  105. package/dist/utils/types.d.ts.map +1 -0
  106. package/package.json +63 -0
@@ -0,0 +1,20 @@
1
+ import { Direction } from '../color-palette/color-palette-utils';
2
+ import { CanvasBase } from './canvas-base';
3
+ import { PropertyValues } from 'lit';
4
+ export declare class CanvasGradient extends CanvasBase {
5
+ colors: string[];
6
+ height: number;
7
+ width: number;
8
+ direction: Direction;
9
+ protected updated(_changedProperties: PropertyValues): void;
10
+ /**
11
+ * Creates a new gradient canvas
12
+ */
13
+ createGradient(colors: string[], height: number, width: number, direction: Direction): void;
14
+ }
15
+ declare global {
16
+ interface HTMLElementTagNameMap {
17
+ 'canvas-gradient': CanvasGradient;
18
+ }
19
+ }
20
+ //# sourceMappingURL=canvas-gradient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canvas-gradient.d.ts","sourceRoot":"","sources":["../../../src/components/canvas/canvas-gradient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAC;AAGjE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;AAErC,qBACa,cAAe,SAAQ,UAAU;IAE7C,MAAM,EAAE,MAAM,EAAE,CAAM;IAGtB,MAAM,EAAE,MAAM,CAAK;IAGnB,KAAK,EAAE,MAAM,CAAK;IAGlB,SAAS,EAAE,SAAS,CAAoB;IAExC,SAAS,CAAC,OAAO,CAAC,kBAAkB,EAAE,cAAc,GAAG,IAAI;IAM3D;;OAEG;IACI,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS;CAyB3F;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,iBAAiB,EAAE,cAAc,CAAC;KAClC;CACD"}
@@ -0,0 +1,47 @@
1
+ import { Direction as l } from "../color-palette/color-palette-utils.js";
2
+ import d from "validate-color";
3
+ import { property as c, customElement as f } from "lit/decorators.js";
4
+ import { CanvasBase as u } from "./canvas-base.js";
5
+ var m = Object.defineProperty, v = Object.getOwnPropertyDescriptor, p = (r, e, o, i) => {
6
+ for (var t = i > 1 ? void 0 : i ? v(e, o) : e, s = r.length - 1, a; s >= 0; s--)
7
+ (a = r[s]) && (t = (i ? a(e, o, t) : a(t)) || t);
8
+ return i && t && m(e, o, t), t;
9
+ };
10
+ let n = class extends u {
11
+ constructor() {
12
+ super(...arguments), this.colors = [], this.height = 0, this.width = 0, this.direction = l.Column;
13
+ }
14
+ updated(r) {
15
+ super.updated(r), this.createGradient(this.colors, this.height, this.width, this.direction);
16
+ }
17
+ /**
18
+ * Creates a new gradient canvas
19
+ */
20
+ createGradient(r, e, o, i) {
21
+ if (!this.context) return;
22
+ this.canvas.height = e, this.canvas.width = o;
23
+ let t = i === l.Column ? this.context.createLinearGradient(0, 0, o, 0) : this.context.createLinearGradient(0, 0, 0, e), s = [];
24
+ for (const [a, h] of r.entries())
25
+ d(h) && (t.addColorStop(a / (r.length - 1), h), s.push(h));
26
+ if (s.length <= 1) throw new Error("There are not enough valid color stops to create the gradient.");
27
+ this.context.fillStyle = t || "#000", this.context.fillRect(0, 0, o, e), this.canvas.classList.add("gradient"), this.canvas.style.setProperty("--palette-column-flex-basis", (e / r.length / 2).toString() + "px");
28
+ }
29
+ };
30
+ p([
31
+ c({ type: Array })
32
+ ], n.prototype, "colors", 2);
33
+ p([
34
+ c({ type: Number })
35
+ ], n.prototype, "height", 2);
36
+ p([
37
+ c({ type: Number })
38
+ ], n.prototype, "width", 2);
39
+ p([
40
+ c({ type: String })
41
+ ], n.prototype, "direction", 2);
42
+ n = p([
43
+ f("canvas-gradient")
44
+ ], n);
45
+ export {
46
+ n as CanvasGradient
47
+ };
@@ -0,0 +1,49 @@
1
+ import { PropertyValues } from 'lit';
2
+ import quantize from 'quantize';
3
+ import { CanvasBase } from './canvas-base';
4
+ export declare class CanvasImage extends CanvasBase {
5
+ static styles: import("lit").CSSResult[];
6
+ image: HTMLImageElement;
7
+ imageURL: string;
8
+ smoothing: boolean;
9
+ private loading;
10
+ width: number;
11
+ height: number;
12
+ protected firstUpdated(_changedProperties: PropertyValues): void;
13
+ render(): import("lit-html").TemplateResult<1>;
14
+ /**
15
+ * Updates & loads the canvas image.
16
+ * Attempts to preserve aspect ratio based on width.
17
+ * @param width The canvas width
18
+ * @param height The canvas height
19
+ */
20
+ updateImage(imageURL: string, width: number, height: number): void;
21
+ /**
22
+ * Gets the most frequent colors in an image
23
+ * @param numColors Number of colors to return
24
+ * @param quality Artificially reduce number of pixels (higher = less accurate but faster)
25
+ * @returns Most frequent colors
26
+ */
27
+ getPalette(numColors?: number, quality?: number): Promise<quantize.RgbPixel[] | null>;
28
+ /**
29
+ * Creates an array of pixels from the image
30
+ * Inspired by colorthief
31
+ * @param quality Artificially reduce number of pixels (higher = less accurate but faster)
32
+ * @returns
33
+ */
34
+ createPixelArray(quality: number): Promise<quantize.RgbPixel[] | null>;
35
+ /**
36
+ * Gets the image data from the canvas
37
+ */
38
+ getImageData(x?: number, y?: number): Promise<ImageData>;
39
+ /**
40
+ * Waits for loading variable to equal true
41
+ */
42
+ private waitForLoading;
43
+ }
44
+ declare global {
45
+ interface HTMLElementTagNameMap {
46
+ 'canvas-image': CanvasImage;
47
+ }
48
+ }
49
+ //# sourceMappingURL=canvas-image.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canvas-image.d.ts","sourceRoot":"","sources":["../../../src/components/canvas/canvas-image.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,cAAc,EAAE,MAAM,KAAK,CAAC;AAEhD,OAAO,QAAsB,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,qBACa,WAAY,SAAQ,UAAU;IAC1C,MAAM,CAAC,MAAM,4BAeX;IAGF,KAAK,EAAG,gBAAgB,CAAC;IAGzB,QAAQ,EAAE,MAAM,CAAM;IAGtB,SAAS,EAAE,OAAO,CAAS;IAE3B,OAAO,CAAC,OAAO,CAAiB;IAChC,KAAK,EAAE,MAAM,CAAK;IAClB,MAAM,EAAE,MAAM,CAAK;IAEnB,SAAS,CAAC,YAAY,CAAC,kBAAkB,EAAE,cAAc,GAAG,IAAI;IAOhE,MAAM;IAYN;;;;;OAKG;IACI,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAyBlE;;;;;OAKG;IACU,UAAU,CAAC,SAAS,SAAI,EAAE,OAAO,SAAK;IAqBnD;;;;;OAKG;IACU,gBAAgB,CAAC,OAAO,EAAE,MAAM;IAuB7C;;OAEG;IACU,YAAY,CAAC,CAAC,SAAI,EAAE,CAAC,SAAI;IAStC;;OAEG;IACH,OAAO,CAAC,cAAc,CAQnB;CACH;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,cAAc,EAAE,WAAW,CAAC;KAC5B;CACD"}
@@ -0,0 +1,117 @@
1
+ import { css as p, html as w } from "lit";
2
+ import { query as u, property as m, customElement as f } from "lit/decorators.js";
3
+ import y from "quantize";
4
+ import { CanvasBase as v } from "./canvas-base.js";
5
+ var x = Object.defineProperty, L = Object.getOwnPropertyDescriptor, h = (e, a, i, s) => {
6
+ for (var t = s > 1 ? void 0 : s ? L(a, i) : a, r = e.length - 1, n; r >= 0; r--)
7
+ (n = e[r]) && (t = (s ? n(a, i, t) : n(t)) || t);
8
+ return s && t && x(a, i, t), t;
9
+ };
10
+ let o = class extends v {
11
+ constructor() {
12
+ super(...arguments), this.imageURL = "", this.smoothing = !1, this.loading = !0, this.width = 0, this.height = 0, this.waitForLoading = () => new Promise((e) => {
13
+ const a = setInterval(() => {
14
+ this.loading || (clearInterval(a), e(!0));
15
+ }, 100);
16
+ });
17
+ }
18
+ firstUpdated(e) {
19
+ super.firstUpdated(e), this.canvas.classList.add("image"), this.context.imageSmoothingEnabled = this.smoothing;
20
+ }
21
+ render() {
22
+ return w`
23
+ ${super.render()}
24
+ <img
25
+ src=${this.imageURL}
26
+ crossorigin='anonymous'
27
+ @load=${() => this.loading = !1}
28
+ >
29
+ `;
30
+ }
31
+ /**
32
+ * Updates & loads the canvas image.
33
+ * Attempts to preserve aspect ratio based on width.
34
+ * @param width The canvas width
35
+ * @param height The canvas height
36
+ */
37
+ updateImage(e, a, i) {
38
+ this.image.src = e, this.waitForLoading().then(() => {
39
+ const s = this.image.naturalHeight / this.image.naturalWidth;
40
+ let t = a, r = t * s;
41
+ r > i && (t = i / s, r = i), this.width = this.canvas.width = t, this.height = this.canvas.height = r, this.context.drawImage(this.image, 0, 0, t, r);
42
+ });
43
+ }
44
+ /**
45
+ * Gets the most frequent colors in an image
46
+ * @param numColors Number of colors to return
47
+ * @param quality Artificially reduce number of pixels (higher = less accurate but faster)
48
+ * @returns Most frequent colors
49
+ */
50
+ async getPalette(e = 7, a = 10) {
51
+ const i = e <= 7 ? e : e + 1;
52
+ await this.waitForLoading();
53
+ const s = await this.createPixelArray(a);
54
+ if (!s) return null;
55
+ const t = y(s, i);
56
+ return t ? t.palette() : [];
57
+ }
58
+ /**
59
+ * Creates an array of pixels from the image
60
+ * Inspired by colorthief
61
+ * @param quality Artificially reduce number of pixels (higher = less accurate but faster)
62
+ * @returns
63
+ */
64
+ async createPixelArray(e) {
65
+ var t;
66
+ await this.waitForLoading();
67
+ const a = [], i = (t = await this.getImageData()) == null ? void 0 : t.data;
68
+ if (!i) return null;
69
+ const s = this.height * this.width;
70
+ for (let r = 0; r < s; r += e) {
71
+ const n = r * 4, [g, c, l, d] = [i[n + 0], i[n + 1], i[n + 2], i[n + 3]];
72
+ (typeof d > "u" || d >= 125) && (g > 250 && c > 250 && l > 250 || a.push([g, c, l]));
73
+ }
74
+ return a;
75
+ }
76
+ /**
77
+ * Gets the image data from the canvas
78
+ */
79
+ async getImageData(e = 0, a = 0) {
80
+ try {
81
+ return await this.waitForLoading(), this.context.getImageData(e, a, this.width, this.height);
82
+ } catch {
83
+ throw new Error("Failed to get image data.");
84
+ }
85
+ }
86
+ };
87
+ o.styles = [
88
+ p`
89
+ :host {
90
+ display: block;
91
+ }
92
+
93
+ /* Hide when width hasn't been set */
94
+ canvas:not([width]) {
95
+ display: none;
96
+ }
97
+
98
+ img {
99
+ display: none;
100
+ }
101
+ `
102
+ ];
103
+ h([
104
+ u("img")
105
+ ], o.prototype, "image", 2);
106
+ h([
107
+ m({ type: String })
108
+ ], o.prototype, "imageURL", 2);
109
+ h([
110
+ m({ type: Boolean })
111
+ ], o.prototype, "smoothing", 2);
112
+ o = h([
113
+ f("canvas-image")
114
+ ], o);
115
+ export {
116
+ o as CanvasImage
117
+ };
@@ -0,0 +1,3 @@
1
+ import './canvas-gradient';
2
+ import './canvas-image';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/canvas/index.ts"],"names":[],"mappings":"AAAA,OAAO,mBAAmB,CAAA;AAC1B,OAAO,gBAAgB,CAAA"}
@@ -0,0 +1,29 @@
1
+ import { LitElement } from 'lit';
2
+ import { EventEmitter } from '../../utils/EventEmitter';
3
+ type EventMap = {
4
+ slotsLoaded: [slotChildren: HTMLElement[]];
5
+ };
6
+ export interface CarouselContainerProps {
7
+ }
8
+ export declare class CarouselScroller extends LitElement {
9
+ static styles: import("lit").CSSResult;
10
+ slotEl: HTMLSlotElement;
11
+ slotChildren: HTMLElement[];
12
+ emitter: EventEmitter<EventMap>;
13
+ currentSlide: number;
14
+ debouncers: WeakMap<object, any>;
15
+ constructor();
16
+ disconnectedCallback(): void;
17
+ render(): import("lit-html").TemplateResult<1>;
18
+ getCurrentSlide(): HTMLElement;
19
+ scrollToPrevSlide(): void;
20
+ scrollToNextSlide(): void;
21
+ slotChange(): void;
22
+ }
23
+ declare global {
24
+ interface HTMLElementTagNameMap {
25
+ 'carousel-scroller': CarouselScroller;
26
+ }
27
+ }
28
+ export {};
29
+ //# sourceMappingURL=carousel-scroller.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"carousel-scroller.d.ts","sourceRoot":"","sources":["../../../src/components/carousel-scroller/carousel-scroller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,UAAU,EAAE,MAAM,KAAK,CAAC;AAE5C,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAExD,KAAK,QAAQ,GAAG;IACf,WAAW,EAAE,CAAC,YAAY,EAAE,WAAW,EAAE,CAAC,CAAC;CAC3C,CAAC;AAEF,MAAM,WAAW,sBAAsB;CAAG;AAE1C,qBACa,gBAAiB,SAAQ,UAAU;IAC/C,MAAM,CAAC,MAAM,0BAgEX;IAGF,MAAM,EAAG,eAAe,CAAC;IAEzB,YAAY,EAAE,WAAW,EAAE,CAAM;IAC1B,OAAO,yBAAgC;IAC9C,YAAY,SAAK;IACjB,UAAU,uBAAiB;;IAU3B,oBAAoB,IAAI,IAAI;IAK5B,MAAM;IAYN,eAAe;IAIf,iBAAiB;IAUjB,iBAAiB;IAUjB,UAAU;CAaV;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,mBAAmB,EAAE,gBAAgB,CAAA;KACrC;CACD"}
@@ -0,0 +1,125 @@
1
+ import { css as a, LitElement as c, html as h } from "lit";
2
+ import { query as p, customElement as u } from "lit/decorators.js";
3
+ import { EventEmitter as m } from "../../utils/EventEmitter.js";
4
+ var g = Object.defineProperty, b = Object.getOwnPropertyDescriptor, d = (t, r, i, o) => {
5
+ for (var e = o > 1 ? void 0 : o ? b(r, i) : r, s = t.length - 1, n; s >= 0; s--)
6
+ (n = t[s]) && (e = (o ? n(r, i, e) : n(e)) || e);
7
+ return o && e && g(r, i, e), e;
8
+ };
9
+ let l = class extends c {
10
+ constructor() {
11
+ super(), this.slotChildren = [], this.emitter = new m(), this.currentSlide = 0, this.debouncers = /* @__PURE__ */ new WeakMap(), this.emitter.on("slotsLoaded", (t) => {
12
+ this.slotChildren = t;
13
+ });
14
+ }
15
+ disconnectedCallback() {
16
+ super.disconnectedCallback(), this.emitter.clear();
17
+ }
18
+ render() {
19
+ return h`
20
+ <div class="container">
21
+ <button @click=${this.scrollToPrevSlide}><</button>
22
+ <button @click=${this.scrollToNextSlide}>></button>
23
+ <div>
24
+ <slot @slotchange=${this.slotChange}></slot>
25
+ </div>
26
+ </div>
27
+ `;
28
+ }
29
+ getCurrentSlide() {
30
+ return this.slotChildren[this.currentSlide - 1];
31
+ }
32
+ scrollToPrevSlide() {
33
+ var t;
34
+ this.currentSlide = this.currentSlide === 0 ? this.currentSlide = this.slotChildren.length - 1 : this.currentSlide - 1, (t = this.slotChildren.at(this.currentSlide)) == null || t.scrollIntoView({ behavior: "smooth", block: "nearest" });
35
+ }
36
+ scrollToNextSlide() {
37
+ var t;
38
+ this.currentSlide = this.currentSlide === this.slotChildren.length - 1 ? 0 : this.currentSlide + 1, (t = this.slotChildren.at(this.currentSlide)) == null || t.scrollIntoView({ behavior: "smooth", block: "nearest" });
39
+ }
40
+ slotChange() {
41
+ const t = Array.from(
42
+ this.slotEl.assignedElements().map((i) => i)
43
+ );
44
+ clearTimeout(this.debouncers.get(this.slotEl));
45
+ const r = setTimeout(
46
+ () => this.emitter.emit("slotsLoaded", t),
47
+ 100
48
+ );
49
+ this.debouncers.set(this.slotEl, r);
50
+ }
51
+ };
52
+ l.styles = a`
53
+ :host {
54
+ --padding: 40px;
55
+ --margin: 80px;
56
+ }
57
+
58
+ .container {
59
+ width: 600px;
60
+ height: 400px;
61
+ margin: 20px;
62
+ border-radius: 20px;
63
+ overflow: hidden;
64
+ position: relative;
65
+
66
+ & > button {
67
+ position: absolute;
68
+ width: var(--padding);
69
+ height: calc(var(--padding) * 2);
70
+ z-index: 1;
71
+ background-color: #00000080;
72
+ border: none;
73
+ bottom: calc(50% - var(--padding));
74
+ font-size: 32px;
75
+
76
+ &:hover {
77
+ background-color: #6352b880;
78
+ }
79
+
80
+ &:nth-child(1) {
81
+ left: 0;
82
+ border-top-right-radius: 314px;
83
+ border-bottom-right-radius: 314px;
84
+ }
85
+
86
+ &:nth-child(2) {
87
+ right: 0;
88
+ border-top-left-radius: 314px;
89
+ border-bottom-left-radius: 314px;
90
+ }
91
+ }
92
+
93
+ & > div {
94
+ display: flex;
95
+ overflow-x: scroll;
96
+ position: relative;
97
+ scroll-behavior: smooth;
98
+ scroll-snap-type: x mandatory;
99
+ scrollbar-width: none;
100
+ padding: 0 var(--padding);
101
+ }
102
+
103
+ ::slotted(*) {
104
+ display: flex;
105
+ flex-direction: column;
106
+ justify-content: center;
107
+ min-height: calc(400px - var(--margin));
108
+ min-width: calc(600px - var(--margin));
109
+ max-height: calc(400px - var(--margin));
110
+ max-width: calc(600px - var(--margin));
111
+ background: white;
112
+ scroll-snap-align: center;
113
+ padding: calc(var(--margin) / 2);
114
+ }
115
+ }
116
+ `;
117
+ d([
118
+ p("slot")
119
+ ], l.prototype, "slotEl", 2);
120
+ l = d([
121
+ u("carousel-scroller")
122
+ ], l);
123
+ export {
124
+ l as CarouselScroller
125
+ };
@@ -0,0 +1,11 @@
1
+ import type { Meta, StoryObj } from '@storybook/web-components';
2
+ declare const meta: Meta;
3
+ export default meta;
4
+ type Props = {
5
+ items: any[];
6
+ };
7
+ type Story = StoryObj<Props>;
8
+ export declare const Empty: Story;
9
+ export declare const OneItem: Story;
10
+ export declare const ManyItems: Story;
11
+ //# sourceMappingURL=carousel-scroller.stories.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"carousel-scroller.stories.d.ts","sourceRoot":"","sources":["../../../src/components/carousel-scroller/carousel-scroller.stories.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAIhE,QAAA,MAAM,IAAI,EAAE,IAIX,CAAC;AAEF,eAAe,IAAI,CAAC;AAEpB,KAAK,KAAK,GAAG;IAAE,KAAK,EAAE,GAAG,EAAE,CAAA;CAAE,CAAC;AAE9B,KAAK,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;AAkB7B,eAAO,MAAM,KAAK,EAAE,KAKnB,CAAC;AAEF,eAAO,MAAM,OAAO,EAAE,KAKrB,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,KAKvB,CAAC"}
@@ -0,0 +1,2 @@
1
+ import './carousel-scroller';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/carousel-scroller/index.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAA"}
@@ -0,0 +1,69 @@
1
+ export declare enum Direction {
2
+ Row = "row",
3
+ Column = "column"
4
+ }
5
+ export declare enum AliasMode {
6
+ Both = "Both",
7
+ Alias = "Prefer Alias"
8
+ }
9
+ export declare enum CopyFormat {
10
+ Raw = "Raw",
11
+ Value = "Value"
12
+ }
13
+ export interface ColorPaletteSettings {
14
+ noticeDuration: number;
15
+ errorPulse: boolean;
16
+ aliasMode: AliasMode;
17
+ corners: boolean;
18
+ hoverWhileEditing: boolean;
19
+ reloadDelay: number;
20
+ copyFormat: CopyFormat;
21
+ height: number;
22
+ width: number;
23
+ direction: Direction;
24
+ gradient: boolean;
25
+ preventHover: boolean;
26
+ override: boolean;
27
+ }
28
+ export declare const defaultSettings: ColorPaletteSettings;
29
+ export type PaletteSettings = {
30
+ height: number;
31
+ width: number;
32
+ direction: Direction;
33
+ gradient: boolean;
34
+ preventHover: boolean;
35
+ override: boolean;
36
+ aliases: string[];
37
+ };
38
+ export declare enum Status {
39
+ VALID = "Valid",
40
+ INVALID_COLORS = "Invalid Colors",
41
+ INVALID_SETTINGS = "Invalid Settings",
42
+ INVALID_COLORS_AND_SETTINGS = "Invalid Colors & Settings",
43
+ INVALID_GRADIENT = "Invalid Gradient"
44
+ }
45
+ export declare const urlRegex: RegExp;
46
+ export declare class PaletteError extends Error {
47
+ status: Status;
48
+ constructor(status: Status, message?: string);
49
+ }
50
+ /**
51
+ * Parses input & extracts settings
52
+ * @param input settings from codeblock
53
+ * @returns PaletteSettings or Status if settings are not valid
54
+ */
55
+ export declare function parseSettings(input: string): PaletteSettings | Status;
56
+ /**
57
+ * Parses input & extracts colors based on color space or URL
58
+ * @param input colors from codeblock
59
+ * @returns Array of colors or Status if colors are not valid
60
+ */
61
+ export declare function parseColors(input: string[], override: boolean): string[] | Status;
62
+ /**
63
+ * Calculates colors and settings based on codeblock contents
64
+ */
65
+ export declare function calcColorsAndSettings(input: string, pluginSettings: ColorPaletteSettings): {
66
+ colors: string[] | Status;
67
+ settings: PaletteSettings | Status | undefined;
68
+ };
69
+ //# sourceMappingURL=color-palette-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"color-palette-utils.d.ts","sourceRoot":"","sources":["../../../src/components/color-palette/color-palette-utils.ts"],"names":[],"mappings":"AAGA,oBAAY,SAAS;IACpB,GAAG,QAAQ;IACX,MAAM,WAAW;CACjB;AAED,oBAAY,SAAS;IACnB,IAAI,SAAS;IACb,KAAK,iBAAiB;CACvB;AAED,oBAAY,UAAU;IACpB,GAAG,QAAQ;IACX,KAAK,UAAU;CAChB;AAED,MAAM,WAAW,oBAAoB;IACnC,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,SAAS,CAAC;IACrB,OAAO,EAAE,OAAO,CAAC;IACjB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,UAAU,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,SAAS,CAAC;IACrB,QAAQ,EAAE,OAAO,CAAC;IAClB,YAAY,EAAE,OAAO,CAAC;IACtB,QAAQ,EAAE,OAAO,CAAA;CAClB;AAED,eAAO,MAAM,eAAe,EAAE,oBAc7B,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,SAAS,CAAC;IACrB,QAAQ,EAAE,OAAO,CAAC;IAClB,YAAY,EAAE,OAAO,CAAC;IACtB,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC;AAEF,oBAAY,MAAM;IACjB,KAAK,UAAU;IACf,cAAc,mBAAmB;IACjC,gBAAgB,qBAAqB;IACrC,2BAA2B,8BAA8B;IACzD,gBAAgB,qBAAqB;CACrC;AAED,eAAO,MAAM,QAAQ,QAAyJ,CAAA;AAE9K,qBAAa,YAAa,SAAQ,KAAK;IACtC,MAAM,EAAE,MAAM,CAAC;gBAEH,MAAM,EAAE,MAAM,EAAE,OAAO,SAAK;CAIxC;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,eAAe,GAAG,MAAM,CAQrE;AAED;;;;EAIE;AACF,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,OAAO,GAAG,MAAM,EAAE,GAAG,MAAM,CA8BjF;AAED;;EAEE;AACF,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,oBAAoB;;;EAaxF"}
@@ -0,0 +1,43 @@
1
+ import { parseUrl as i } from "../../utils/basicUtils.js";
2
+ import n from "validate-color";
3
+ var s = /* @__PURE__ */ ((r) => (r.Row = "row", r.Column = "column", r))(s || {}), u = /* @__PURE__ */ ((r) => (r.Both = "Both", r.Alias = "Prefer Alias", r))(u || {}), f = /* @__PURE__ */ ((r) => (r.Raw = "Raw", r.Value = "Value", r))(f || {});
4
+ const v = {
5
+ noticeDuration: 1e4,
6
+ errorPulse: !0,
7
+ aliasMode: "Both",
8
+ corners: !0,
9
+ hoverWhileEditing: !1,
10
+ reloadDelay: 5,
11
+ copyFormat: "Raw",
12
+ height: 150,
13
+ width: 700,
14
+ direction: "column",
15
+ gradient: !1,
16
+ preventHover: !1,
17
+ override: !1
18
+ };
19
+ var p = /* @__PURE__ */ ((r) => (r.VALID = "Valid", r.INVALID_COLORS = "Invalid Colors", r.INVALID_SETTINGS = "Invalid Settings", r.INVALID_COLORS_AND_SETTINGS = "Invalid Colors & Settings", r.INVALID_GRADIENT = "Invalid Gradient", r))(p || {});
20
+ const d = /(?:https:\/\/www\.|http:\/\/www\.|https:\/\/|http:\/\/)?[a-zA-Z0-9]{2,}(?:\.[a-zA-Z0-9]{2,})(?:\.[a-zA-Z0-9]{2,})?\/(?:palette\/)?([a-zA-Z0-9-]{2,})/;
21
+ class h extends Error {
22
+ constructor(l, t = "") {
23
+ super(t), this.status = l;
24
+ }
25
+ }
26
+ function w(r, l) {
27
+ let t = r.flatMap((e) => e.includes("(") ? e.split(";").flatMap((a) => a.trim()).filter((a) => a !== "") : e.split(",").flatMap((a) => a.trim())).flatMap((e) => e.trim().replace(";", ""));
28
+ const o = t.join("");
29
+ if (o.match(d)) return i(o);
30
+ for (let e of t)
31
+ if (!n(e)) return "Invalid Colors";
32
+ return t;
33
+ }
34
+ export {
35
+ u as AliasMode,
36
+ f as CopyFormat,
37
+ s as Direction,
38
+ h as PaletteError,
39
+ p as Status,
40
+ v as defaultSettings,
41
+ w as parseColors,
42
+ d as urlRegex
43
+ };
@@ -0,0 +1,61 @@
1
+ import { LitElement, TemplateResult, nothing, PropertyValues } from 'lit';
2
+ import { ColorPaletteSettings, Direction, PaletteSettings, Status } from './color-palette-utils';
3
+ import { EventEmitter } from '../../utils/EventEmitter';
4
+ type EventMap = {
5
+ resized: [palette: ResizeObserverEntry];
6
+ changed: [colors: string[], settings: PaletteSettings];
7
+ editMode: [editMode: boolean];
8
+ notice: [message: string];
9
+ };
10
+ export declare class ColorPalette extends LitElement {
11
+ static styles: import("lit").CSSResult[];
12
+ palette: HTMLDivElement;
13
+ _editMode: boolean;
14
+ set editMode(val: boolean);
15
+ get editMode(): boolean;
16
+ colors: string[];
17
+ height: number;
18
+ width: number;
19
+ direction: Direction;
20
+ gradient: boolean;
21
+ preventHover: boolean;
22
+ override: boolean;
23
+ aliases: string[];
24
+ maxWidth: number;
25
+ /**
26
+ * Helper accessor for settings
27
+ */
28
+ set settings({ height, width, direction, gradient, preventHover, override, aliases }: PaletteSettings);
29
+ get settings(): PaletteSettings;
30
+ status: Status;
31
+ private pulse;
32
+ emitter: EventEmitter<EventMap>;
33
+ pluginSettings: ColorPaletteSettings;
34
+ connectedCallback(): void;
35
+ disconnectedCallback(): void;
36
+ protected willUpdate(_changedProperties: PropertyValues): void;
37
+ /**
38
+ * Sets the current status and parses colors
39
+ */
40
+ setStatusAndColors(): void;
41
+ render(): TemplateResult<1>;
42
+ /**
43
+ * @returns `user` OR `auto` width based on which is more appropriate
44
+ */
45
+ getPaletteWidth(): number;
46
+ createPalette: () => TemplateResult | typeof nothing;
47
+ createColors(): TemplateResult;
48
+ createGradient(): TemplateResult;
49
+ /**
50
+ * Create invalid palette based on palette status
51
+ * @param type Palette status type
52
+ */
53
+ createInvalidPalette(type: Status, message?: string): TemplateResult<1>;
54
+ }
55
+ declare global {
56
+ interface HTMLElementTagNameMap {
57
+ 'color-palette': ColorPalette;
58
+ }
59
+ }
60
+ export {};
61
+ //# sourceMappingURL=color-palette.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"color-palette.d.ts","sourceRoot":"","sources":["../../../src/components/color-palette/color-palette.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAQ,cAAc,EAAE,OAAO,EAAO,cAAc,EAAE,MAAM,KAAK,CAAC;AAIrF,OAAO,EAAE,oBAAoB,EAAmB,SAAS,EAAgB,eAAe,EAAe,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAI7I,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAOxD,KAAK,QAAQ,GAAG;IACf,OAAO,EAAE,CAAC,OAAO,EAAE,mBAAmB,CAAC,CAAC;IACxC,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,eAAe,CAAC,CAAC;IACvD,QAAQ,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC9B,MAAM,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;CAC1B,CAAC;AAEF,qBACa,YAAa,SAAQ,UAAU;IAC3C,MAAM,CAAC,MAAM,4BA2FX;IAGF,OAAO,EAAG,cAAc,CAAC;IAEzB,SAAS,EAAE,OAAO,CAAS;IAC3B,IACI,QAAQ,CAAC,GAAG,EAAE,OAAO,EAGxB;IACD,IAAI,QAAQ,IAJM,OAAO,CAMxB;IAGD,MAAM,EAAE,MAAM,EAAE,CAAM;IAItB,MAAM,EAAE,MAAM,CAA0B;IAExC,KAAK,EAAE,MAAM,CAAyB;IAEtC,SAAS,EAAE,SAAS,CAA6B;IAEjD,QAAQ,EAAE,OAAO,CAAS;IAE1B,YAAY,EAAE,OAAO,CAAS;IAE9B,QAAQ,EAAE,OAAO,CAAS;IAE1B,OAAO,EAAE,MAAM,EAAE,CAAM;IAGvB,QAAQ,EAAE,MAAM,CAAK;IAErB;;OAEG;IACH,IAAW,QAAQ,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,eAAe,EAQ3G;IACD,IAAW,QAAQ,IAAI,eAAe,CAUrC;IAGM,MAAM,EAAE,MAAM,CAAgB;IAGrC,OAAO,CAAC,KAAK,CAAkB;IAExB,OAAO,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAgC;IAGtE,cAAc,EAAE,oBAAoB,CAAmB;IAEvD,iBAAiB,IAAI,IAAI;IAYzB,oBAAoB,IAAI,IAAI;IAK5B,SAAS,CAAC,UAAU,CAAC,kBAAkB,EAAE,cAAc,GAAG,IAAI;IAM9D;;OAEG;IACH,kBAAkB;IA6BlB,MAAM;IA2BN;;MAEE;IACK,eAAe;IAOtB,aAAa,QAAO,cAAc,GAAG,OAAO,OAAO,CAcjD;IAEF,YAAY,IAAI,cAAc;IAyE9B,cAAc,IAAI,cAAc;IAqChC;;;OAGG;IACH,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,SAAK;CAyB/C;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,eAAe,EAAE,YAAY,CAAC;KAC9B;CACD"}