@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.
- package/LICENSE +674 -0
- package/README.md +21 -0
- package/dist/components/absolute-container/absolute-container.d.ts +34 -0
- package/dist/components/absolute-container/absolute-container.d.ts.map +1 -0
- package/dist/components/absolute-container/absolute-container.js +96 -0
- package/dist/components/absolute-container/absolute-container.stories.d.ts +9 -0
- package/dist/components/absolute-container/absolute-container.stories.d.ts.map +1 -0
- package/dist/components/absolute-container/index.d.ts +2 -0
- package/dist/components/absolute-container/index.d.ts.map +1 -0
- package/dist/components/bottom-sheet/bottom-sheet.d.ts +68 -0
- package/dist/components/bottom-sheet/bottom-sheet.d.ts.map +1 -0
- package/dist/components/bottom-sheet/bottom-sheet.js +312 -0
- package/dist/components/bottom-sheet/bottom-sheet.stories.d.ts +14 -0
- package/dist/components/bottom-sheet/bottom-sheet.stories.d.ts.map +1 -0
- package/dist/components/bottom-sheet/bottom-sheet.test.d.ts +2 -0
- package/dist/components/bottom-sheet/bottom-sheet.test.d.ts.map +1 -0
- package/dist/components/bottom-sheet/index.d.ts +2 -0
- package/dist/components/bottom-sheet/index.d.ts.map +1 -0
- package/dist/components/canvas/canvas-base.d.ts +16 -0
- package/dist/components/canvas/canvas-base.d.ts.map +1 -0
- package/dist/components/canvas/canvas-base.js +48 -0
- package/dist/components/canvas/canvas-gradient.d.ts +20 -0
- package/dist/components/canvas/canvas-gradient.d.ts.map +1 -0
- package/dist/components/canvas/canvas-gradient.js +47 -0
- package/dist/components/canvas/canvas-image.d.ts +49 -0
- package/dist/components/canvas/canvas-image.d.ts.map +1 -0
- package/dist/components/canvas/canvas-image.js +117 -0
- package/dist/components/canvas/index.d.ts +3 -0
- package/dist/components/canvas/index.d.ts.map +1 -0
- package/dist/components/carousel-scroller/carousel-scroller.d.ts +29 -0
- package/dist/components/carousel-scroller/carousel-scroller.d.ts.map +1 -0
- package/dist/components/carousel-scroller/carousel-scroller.js +125 -0
- package/dist/components/carousel-scroller/carousel-scroller.stories.d.ts +11 -0
- package/dist/components/carousel-scroller/carousel-scroller.stories.d.ts.map +1 -0
- package/dist/components/carousel-scroller/index.d.ts +2 -0
- package/dist/components/carousel-scroller/index.d.ts.map +1 -0
- package/dist/components/color-palette/color-palette-utils.d.ts +69 -0
- package/dist/components/color-palette/color-palette-utils.d.ts.map +1 -0
- package/dist/components/color-palette/color-palette-utils.js +43 -0
- package/dist/components/color-palette/color-palette.d.ts +61 -0
- package/dist/components/color-palette/color-palette.d.ts.map +1 -0
- package/dist/components/color-palette/color-palette.js +346 -0
- package/dist/components/color-palette/component/color-palette-component.d.ts +22 -0
- package/dist/components/color-palette/component/color-palette-component.d.ts.map +1 -0
- package/dist/components/color-palette/component/color-palette-component.js +148 -0
- package/dist/components/color-palette/component/color-palette-component.stories.d.ts +11 -0
- package/dist/components/color-palette/component/color-palette-component.stories.d.ts.map +1 -0
- package/dist/components/color-palette/component/index.d.ts +2 -0
- package/dist/components/color-palette/component/index.d.ts.map +1 -0
- package/dist/components/color-palette/editor/color-palette-editor.d.ts +46 -0
- package/dist/components/color-palette/editor/color-palette-editor.d.ts.map +1 -0
- package/dist/components/color-palette/editor/color-palette-editor.js +611 -0
- package/dist/components/color-palette/editor/color-palette-editor.stories.d.ts +11 -0
- package/dist/components/color-palette/editor/color-palette-editor.stories.d.ts.map +1 -0
- package/dist/components/color-palette/editor/index.d.ts +2 -0
- package/dist/components/color-palette/editor/index.d.ts.map +1 -0
- package/dist/components/color-palette/index.d.ts +6 -0
- package/dist/components/color-palette/index.d.ts.map +1 -0
- package/dist/components/color-palette/item/color-palette-item-edit.d.ts +20 -0
- package/dist/components/color-palette/item/color-palette-item-edit.d.ts.map +1 -0
- package/dist/components/color-palette/item/color-palette-item-edit.js +91 -0
- package/dist/components/color-palette/item/color-palette-item.d.ts +29 -0
- package/dist/components/color-palette/item/color-palette-item.d.ts.map +1 -0
- package/dist/components/color-palette/item/color-palette-item.js +146 -0
- package/dist/components/color-palette/item/index.d.ts +3 -0
- package/dist/components/color-palette/item/index.d.ts.map +1 -0
- package/dist/components/color-palette/menu/color-palette-menu.d.ts +30 -0
- package/dist/components/color-palette/menu/color-palette-menu.d.ts.map +1 -0
- package/dist/components/color-palette/menu/color-palette-menu.js +231 -0
- package/dist/components/color-palette/menu/color-palette-reorder.d.ts +31 -0
- package/dist/components/color-palette/menu/color-palette-reorder.d.ts.map +1 -0
- package/dist/components/color-palette/menu/color-palette-reorder.js +108 -0
- package/dist/components/color-palette/menu/index.d.ts +3 -0
- package/dist/components/color-palette/menu/index.d.ts.map +1 -0
- package/dist/components/color-palette/storybook/color-palette-invalid.stories.d.ts +15 -0
- package/dist/components/color-palette/storybook/color-palette-invalid.stories.d.ts.map +1 -0
- package/dist/components/color-palette/storybook/color-palette-valid.stories.d.ts +34 -0
- package/dist/components/color-palette/storybook/color-palette-valid.stories.d.ts.map +1 -0
- package/dist/components/color-palette/storybook/color-palette.stories.d.ts +13 -0
- package/dist/components/color-palette/storybook/color-palette.stories.d.ts.map +1 -0
- package/dist/components/tool-tip/Tooltip2.d.ts +17 -0
- package/dist/components/tool-tip/Tooltip2.d.ts.map +1 -0
- package/dist/components/tool-tip/index.d.ts +2 -0
- package/dist/components/tool-tip/index.d.ts.map +1 -0
- package/dist/components/tool-tip/tool-tip.d.ts +29 -0
- package/dist/components/tool-tip/tool-tip.d.ts.map +1 -0
- package/dist/components/tool-tip/tool-tip.js +106 -0
- package/dist/components/tool-tip/tool-tip.stories.d.ts +12 -0
- package/dist/components/tool-tip/tool-tip.stories.d.ts.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/utils/EventEmitter.d.ts +9 -0
- package/dist/utils/EventEmitter.d.ts.map +1 -0
- package/dist/utils/EventEmitter.js +24 -0
- package/dist/utils/basicUtils.d.ts +47 -0
- package/dist/utils/basicUtils.d.ts.map +1 -0
- package/dist/utils/basicUtils.js +23 -0
- package/dist/utils/dragDropUtils.d.ts +36 -0
- package/dist/utils/dragDropUtils.d.ts.map +1 -0
- package/dist/utils/generateUtils.d.ts +27 -0
- package/dist/utils/generateUtils.d.ts.map +1 -0
- package/dist/utils/generateUtils.js +40 -0
- package/dist/utils/types.d.ts +5 -0
- package/dist/utils/types.d.ts.map +1 -0
- package/package.json +63 -0
package/README.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Web Components
|
|
2
|
+
|
|
3
|
+
## Absolute Container
|
|
4
|
+
|
|
5
|
+
A container component which can serve as a modal or popup wrapper.
|
|
6
|
+
|
|
7
|
+
## Bottom Sheet
|
|
8
|
+
|
|
9
|
+
A container component primarily for mobile devices which slides up and down from the bottom of the screen.
|
|
10
|
+
|
|
11
|
+
## Carousel Scroller
|
|
12
|
+
|
|
13
|
+
A component which can have any number of sliders, and rotates circularly.
|
|
14
|
+
|
|
15
|
+
## Color Palette
|
|
16
|
+
|
|
17
|
+
A color palette component, with editing, menus and more included.
|
|
18
|
+
|
|
19
|
+
## Tooltip
|
|
20
|
+
|
|
21
|
+
A simple tooltip component.
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
import { Ref } from 'lit/directives/ref.js';
|
|
3
|
+
import { EventEmitter } from '../../utils/EventEmitter';
|
|
4
|
+
type EventMap = {
|
|
5
|
+
visibility: [open: boolean];
|
|
6
|
+
};
|
|
7
|
+
export declare class AbsoluteContainer extends LitElement {
|
|
8
|
+
static styles: import("lit").CSSResult[];
|
|
9
|
+
dialogRef: Ref<HTMLDialogElement>;
|
|
10
|
+
private _open;
|
|
11
|
+
set open(val: boolean);
|
|
12
|
+
get open(): boolean;
|
|
13
|
+
protected left: number;
|
|
14
|
+
protected top: number;
|
|
15
|
+
emitter: EventEmitter<EventMap>;
|
|
16
|
+
/**
|
|
17
|
+
* Disables the ContextEvent (right click, or long touch)
|
|
18
|
+
*
|
|
19
|
+
* Useful for context menus
|
|
20
|
+
*/
|
|
21
|
+
disableContextEvent: boolean;
|
|
22
|
+
disconnectedCallback(): void;
|
|
23
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
24
|
+
toggle(): void;
|
|
25
|
+
setOpen(val: boolean): void;
|
|
26
|
+
setPosition(left: number, top: number): void;
|
|
27
|
+
}
|
|
28
|
+
declare global {
|
|
29
|
+
interface HTMLElementTagNameMap {
|
|
30
|
+
'absolute-container': AbsoluteContainer;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=absolute-container.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"absolute-container.d.ts","sourceRoot":"","sources":["../../../src/components/absolute-container/absolute-container.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,MAAM,KAAK,CAAC;AAE5C,OAAO,EAAa,GAAG,EAAO,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAExD,KAAK,QAAQ,GAAG;IACf,UAAU,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;CAC3B,CAAA;AAED,qBACa,iBAAkB,SAAQ,UAAU;IAChD,MAAM,CAAC,MAAM,4BAkBX;IAEF,SAAS,EAAE,GAAG,CAAC,iBAAiB,CAAC,CAAe;IAEhD,OAAO,CAAC,KAAK,CAAkB;IAC/B,IACI,IAAI,CAAC,GAAG,EAAE,OAAO,EAYpB;IACD,IAAI,IAAI,IAbM,OAAO,CAepB;IAGD,SAAS,CAAC,IAAI,EAAE,MAAM,CAAK;IAG3B,SAAS,CAAC,GAAG,EAAE,MAAM,CAAK;IAE1B,OAAO,EAAE,YAAY,CAAC,QAAQ,CAAC,CAA+B;IAE9D;;;;OAIG;IAEH,mBAAmB,EAAE,OAAO,CAAS;IAErC,oBAAoB,IAAI,IAAI;IAM5B,MAAM;IA2BC,MAAM;IAIN,OAAO,CAAC,GAAG,EAAE,OAAO;IAIpB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM;CAI5C;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,oBAAoB,EAAE,iBAAiB,CAAC;KACxC;CACD"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { css as h, LitElement as d, html as c } from "lit";
|
|
2
|
+
import { property as a, state as f, customElement as u } from "lit/decorators.js";
|
|
3
|
+
import { createRef as m, ref as g } from "lit/directives/ref.js";
|
|
4
|
+
import { styleMap as b } from "lit/directives/style-map.js";
|
|
5
|
+
import { EventEmitter as v } from "../../utils/EventEmitter.js";
|
|
6
|
+
var y = Object.defineProperty, _ = Object.getOwnPropertyDescriptor, n = (e, t, r, i) => {
|
|
7
|
+
for (var o = i > 1 ? void 0 : i ? _(t, r) : t, l = e.length - 1, p; l >= 0; l--)
|
|
8
|
+
(p = e[l]) && (o = (i ? p(t, r, o) : p(o)) || o);
|
|
9
|
+
return i && o && y(t, r, o), o;
|
|
10
|
+
};
|
|
11
|
+
let s = class extends d {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(...arguments), this.dialogRef = m(), this._open = !1, this.left = 0, this.top = 0, this.emitter = new v(), this.disableContextEvent = !1;
|
|
14
|
+
}
|
|
15
|
+
set open(e) {
|
|
16
|
+
this._open = e, requestAnimationFrame(() => {
|
|
17
|
+
if (!this.dialogRef.value) return;
|
|
18
|
+
let t = this.dialogRef.value;
|
|
19
|
+
t.open ? t.close() : t.showModal();
|
|
20
|
+
}), this.emitter.emit("visibility", e);
|
|
21
|
+
}
|
|
22
|
+
get open() {
|
|
23
|
+
return this._open;
|
|
24
|
+
}
|
|
25
|
+
disconnectedCallback() {
|
|
26
|
+
super.disconnectedCallback(), this.emitter.clear();
|
|
27
|
+
}
|
|
28
|
+
render() {
|
|
29
|
+
const e = {
|
|
30
|
+
inset: this.left === 0 && this.top === 0 ? 0 : "unset",
|
|
31
|
+
left: `${this.left}px`,
|
|
32
|
+
top: `${this.top}px`
|
|
33
|
+
};
|
|
34
|
+
return c`
|
|
35
|
+
<dialog
|
|
36
|
+
part='dialog'
|
|
37
|
+
style=${b(e)}
|
|
38
|
+
@mousedown=${(t) => {
|
|
39
|
+
if (!(t.target instanceof HTMLElement)) return;
|
|
40
|
+
const r = t.offsetX < 0 || t.offsetX > t.target.offsetWidth, i = t.offsetY < 0 || t.offsetY > t.target.offsetHeight;
|
|
41
|
+
(r || i) && (this.open = !1);
|
|
42
|
+
}}
|
|
43
|
+
@contextmenu=${(t) => this.disableContextEvent && t.preventDefault()}
|
|
44
|
+
${g(this.dialogRef)}
|
|
45
|
+
>
|
|
46
|
+
<slot></slot>
|
|
47
|
+
</dialog>
|
|
48
|
+
`;
|
|
49
|
+
}
|
|
50
|
+
toggle() {
|
|
51
|
+
this.open = !this.open;
|
|
52
|
+
}
|
|
53
|
+
setOpen(e) {
|
|
54
|
+
this.open = e;
|
|
55
|
+
}
|
|
56
|
+
setPosition(e, t) {
|
|
57
|
+
this.left = e, this.top = t;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
s.styles = [
|
|
61
|
+
h`
|
|
62
|
+
:host {
|
|
63
|
+
display: block;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
dialog {
|
|
67
|
+
width: min-content;
|
|
68
|
+
border: 0;
|
|
69
|
+
padding: 0;
|
|
70
|
+
background-color: transparent;
|
|
71
|
+
scrollbar-width: thin;
|
|
72
|
+
|
|
73
|
+
&::backdrop {
|
|
74
|
+
background-color: transparent;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
`
|
|
78
|
+
];
|
|
79
|
+
n([
|
|
80
|
+
a({ type: Boolean, reflect: !0 })
|
|
81
|
+
], s.prototype, "open", 1);
|
|
82
|
+
n([
|
|
83
|
+
f()
|
|
84
|
+
], s.prototype, "left", 2);
|
|
85
|
+
n([
|
|
86
|
+
f()
|
|
87
|
+
], s.prototype, "top", 2);
|
|
88
|
+
n([
|
|
89
|
+
a({ type: Boolean, reflect: !0 })
|
|
90
|
+
], s.prototype, "disableContextEvent", 2);
|
|
91
|
+
s = n([
|
|
92
|
+
u("absolute-container")
|
|
93
|
+
], s);
|
|
94
|
+
export {
|
|
95
|
+
s as AbsoluteContainer
|
|
96
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/web-components';
|
|
2
|
+
declare const meta: Meta;
|
|
3
|
+
export default meta;
|
|
4
|
+
type Props = {
|
|
5
|
+
disableContextEvent: boolean;
|
|
6
|
+
};
|
|
7
|
+
type Story = StoryObj<Props>;
|
|
8
|
+
export declare const Example: Story;
|
|
9
|
+
//# sourceMappingURL=absolute-container.stories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"absolute-container.stories.d.ts","sourceRoot":"","sources":["../../../src/components/absolute-container/absolute-container.stories.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAKhE,QAAA,MAAM,IAAI,EAAE,IAIX,CAAC;AAEF,eAAe,IAAI,CAAC;AAEpB,KAAK,KAAK,GAAG;IAAE,mBAAmB,EAAE,OAAO,CAAA;CAAE,CAAC;AAE9C,KAAK,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;AA6B7B,eAAO,MAAM,OAAO,EAAE,KAIrB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/absolute-container/index.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAA"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
import { EventEmitter } from '../../utils/EventEmitter';
|
|
3
|
+
type EventMap = {
|
|
4
|
+
snapped: [snapped: boolean, activeElement: Element | null | undefined];
|
|
5
|
+
};
|
|
6
|
+
export declare class BottomSheet extends LitElement {
|
|
7
|
+
static styles: import("lit").CSSResult[];
|
|
8
|
+
private dialog;
|
|
9
|
+
private nonModalDialog?;
|
|
10
|
+
private modalDialog?;
|
|
11
|
+
open: boolean;
|
|
12
|
+
nonmodal: boolean;
|
|
13
|
+
dragging: boolean;
|
|
14
|
+
scrolling: boolean;
|
|
15
|
+
snapPoints: number[];
|
|
16
|
+
defaultSnap: number;
|
|
17
|
+
set height(val: number);
|
|
18
|
+
get height(): number;
|
|
19
|
+
emitter: EventEmitter<EventMap>;
|
|
20
|
+
private startY;
|
|
21
|
+
private startHeight;
|
|
22
|
+
private previousTouch;
|
|
23
|
+
private lastScrollTop;
|
|
24
|
+
connectedCallback(): void;
|
|
25
|
+
disconnectedCallback(): void;
|
|
26
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
27
|
+
/**
|
|
28
|
+
* Find closest point index to target in array
|
|
29
|
+
*/
|
|
30
|
+
private closestSnapPointIndex;
|
|
31
|
+
/**
|
|
32
|
+
* Sets sheet height to the closest snap
|
|
33
|
+
* @param height percentage
|
|
34
|
+
*/
|
|
35
|
+
private setSnap;
|
|
36
|
+
/**
|
|
37
|
+
* @returns Whether sheet is snapped to a snap point
|
|
38
|
+
*/
|
|
39
|
+
private isSnapped;
|
|
40
|
+
/**
|
|
41
|
+
* Sets the display state of the sheet
|
|
42
|
+
*/
|
|
43
|
+
showSheet(open: boolean): void;
|
|
44
|
+
/**
|
|
45
|
+
* Toggles the display state of the sheet
|
|
46
|
+
*/
|
|
47
|
+
toggleSheet(): void;
|
|
48
|
+
/**
|
|
49
|
+
* Remove overscroll to prevent mobile browsers from refreshing during drag
|
|
50
|
+
*/
|
|
51
|
+
private setOverscroll;
|
|
52
|
+
private setDialog;
|
|
53
|
+
private touchDown;
|
|
54
|
+
private touchMove;
|
|
55
|
+
private touchUp;
|
|
56
|
+
private pointerDown;
|
|
57
|
+
private pointerMove;
|
|
58
|
+
private pointerUp;
|
|
59
|
+
private onSnapped;
|
|
60
|
+
private contentScroll;
|
|
61
|
+
}
|
|
62
|
+
declare global {
|
|
63
|
+
interface HTMLElementTagNameMap {
|
|
64
|
+
'bottom-sheet': BottomSheet;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
export {};
|
|
68
|
+
//# sourceMappingURL=bottom-sheet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bottom-sheet.d.ts","sourceRoot":"","sources":["../../../src/components/bottom-sheet/bottom-sheet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,MAAM,KAAK,CAAC;AAE5C,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAExD,KAAK,QAAQ,GAAG;IACf,OAAO,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;CACvE,CAAC;AAEF,qBACa,WAAY,SAAQ,UAAU;IAC1C,MAAM,CAAC,MAAM,4BAmHX;IAGF,OAAO,CAAC,MAAM,CAAqB;IAGnC,OAAO,CAAC,cAAc,CAAC,CAAoB;IAG3C,OAAO,CAAC,WAAW,CAAC,CAAoB;IAGjC,IAAI,EAAE,OAAO,CAAS;IAGtB,QAAQ,EAAE,OAAO,CAAS;IAG1B,QAAQ,EAAE,OAAO,CAAS;IAG1B,SAAS,EAAE,OAAO,CAAS;IAG3B,UAAU,EAAE,MAAM,EAAE,CAAM;IAG1B,WAAW,EAAE,MAAM,CAAO;IAEjC,IAMI,MAAM,CAAC,GAAG,EAAE,MAAM,EAQrB;IACD,IAAI,MAAM,IATM,MAAM,CAWrB;IAEM,OAAO,yBAA+B;IAE7C,OAAO,CAAC,MAAM,CAAa;IAC3B,OAAO,CAAC,WAAW,CAAa;IAChC,OAAO,CAAC,aAAa,CAAsB;IAC3C,OAAO,CAAC,aAAa,CAAa;IAElC,iBAAiB,IAAI,IAAI;IAczB,oBAAoB,IAAI,IAAI;IAK5B,MAAM;IAqDN;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAI7B;;;OAGG;IACH,OAAO,CAAC,OAAO;IAUf;;OAEG;IACH,OAAO,CAAC,SAAS;IAIjB;;OAEG;IACI,SAAS,CAAC,IAAI,EAAE,OAAO;IAO9B;;OAEG;IACI,WAAW;IAIlB;;OAEG;IACH,OAAO,CAAC,aAAa;IAQrB,OAAO,CAAC,SAAS;IAsBjB,OAAO,CAAC,SAAS;IAOjB,OAAO,CAAC,SAAS;IAwCjB,OAAO,CAAC,OAAO;IAQf,OAAO,CAAC,WAAW;IASnB,OAAO,CAAC,WAAW;IAgBnB,OAAO,CAAC,SAAS;IAQjB,OAAO,CAAC,SAAS;IAIjB,OAAO,CAAC,aAAa;CAUrB;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,cAAc,EAAE,WAAW,CAAC;KAC5B;CACD"}
|
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
import { css as p, LitElement as g, html as d } from "lit";
|
|
2
|
+
import { query as c, property as a, customElement as u } from "lit/decorators.js";
|
|
3
|
+
import { EventEmitter as m } from "../../utils/EventEmitter.js";
|
|
4
|
+
var f = Object.defineProperty, v = Object.getOwnPropertyDescriptor, r = (t, e, o, s) => {
|
|
5
|
+
for (var n = s > 1 ? void 0 : s ? v(e, o) : e, h = t.length - 1, l; h >= 0; h--)
|
|
6
|
+
(l = t[h]) && (n = (s ? l(e, o, n) : l(n)) || n);
|
|
7
|
+
return s && n && f(e, o, n), n;
|
|
8
|
+
};
|
|
9
|
+
let i = class extends g {
|
|
10
|
+
constructor() {
|
|
11
|
+
super(...arguments), this.open = !1, this.nonmodal = !1, this.dragging = !1, this.scrolling = !1, this.snapPoints = [], this.defaultSnap = NaN, this.emitter = new m(), this.startY = 0, this.startHeight = 0, this.previousTouch = null, this.lastScrollTop = 0;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Sets the height of the sheet
|
|
15
|
+
* Infinity can be used to fit content automatically
|
|
16
|
+
* @param height percentage or infinity
|
|
17
|
+
*/
|
|
18
|
+
set height(t) {
|
|
19
|
+
var o;
|
|
20
|
+
const e = Math.min(Math.max(t, 0), 100);
|
|
21
|
+
this.emitter.emit("snapped", this.isSnapped(e), (o = this.shadowRoot) == null ? void 0 : o.activeElement), isFinite(t) ? this.style.setProperty("--height", `${Math.round(e)}dvh`) : this.style.setProperty("--height", "fit-content");
|
|
22
|
+
}
|
|
23
|
+
get height() {
|
|
24
|
+
return parseInt(this.style.getPropertyValue("--height"));
|
|
25
|
+
}
|
|
26
|
+
connectedCallback() {
|
|
27
|
+
super.connectedCallback();
|
|
28
|
+
const t = this.snapPoints.length === 2 ? 0 : 1;
|
|
29
|
+
this.defaultSnap = this.snapPoints.length > 0 ? isNaN(this.defaultSnap) ? this.snapPoints[Math.round(this.snapPoints.length / 2) - t] : this.defaultSnap : NaN, this.emitter.on("snapped", this.onSnapped.bind(this)), requestAnimationFrame(() => {
|
|
30
|
+
this.showSheet(this.open);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
disconnectedCallback() {
|
|
34
|
+
super.disconnectedCallback(), this.emitter.clear();
|
|
35
|
+
}
|
|
36
|
+
render() {
|
|
37
|
+
return requestAnimationFrame(() => {
|
|
38
|
+
this.setDialog(this.open);
|
|
39
|
+
}), d`
|
|
40
|
+
<dialog
|
|
41
|
+
@click=${(t) => {
|
|
42
|
+
t.stopPropagation(), this.toggleSheet();
|
|
43
|
+
}}
|
|
44
|
+
>
|
|
45
|
+
<button
|
|
46
|
+
id="handle"
|
|
47
|
+
part="handle"
|
|
48
|
+
@pointerdown=${this.pointerDown}
|
|
49
|
+
@pointermove=${this.pointerMove}
|
|
50
|
+
@pointerup=${this.pointerUp}
|
|
51
|
+
@click=${(t) => {
|
|
52
|
+
t.stopPropagation();
|
|
53
|
+
}}
|
|
54
|
+
>
|
|
55
|
+
⸻
|
|
56
|
+
</button>
|
|
57
|
+
|
|
58
|
+
<div
|
|
59
|
+
id='content'
|
|
60
|
+
part="content"
|
|
61
|
+
tabindex='0'
|
|
62
|
+
@touchstart=${this.touchDown}
|
|
63
|
+
@touchend=${this.touchUp}
|
|
64
|
+
@touchmove=${this.touchMove}
|
|
65
|
+
@scroll=${this.contentScroll}
|
|
66
|
+
@touchcancel=${(t) => {
|
|
67
|
+
console.warn("User Agent touchcancelled the event.", t.target);
|
|
68
|
+
}}
|
|
69
|
+
@dragstart=${(t) => {
|
|
70
|
+
t.preventDefault();
|
|
71
|
+
}}
|
|
72
|
+
@click=${(t) => {
|
|
73
|
+
t.stopPropagation();
|
|
74
|
+
}}
|
|
75
|
+
>
|
|
76
|
+
<slot></slot>
|
|
77
|
+
</div>
|
|
78
|
+
</dialog>
|
|
79
|
+
`;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Find closest point index to target in array
|
|
83
|
+
*/
|
|
84
|
+
closestSnapPointIndex(t, e) {
|
|
85
|
+
return t.reduce((o, s, n) => Math.abs(s - e) < Math.abs(t[o] - e) ? n : o, 0);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Sets sheet height to the closest snap
|
|
89
|
+
* @param height percentage
|
|
90
|
+
*/
|
|
91
|
+
setSnap(t) {
|
|
92
|
+
if (this.snapPoints.length === 0) return;
|
|
93
|
+
const e = this.snapPoints[this.closestSnapPointIndex(this.snapPoints, t)];
|
|
94
|
+
e === this.snapPoints[0] && this.showSheet(!1), this.height = e;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* @returns Whether sheet is snapped to a snap point
|
|
98
|
+
*/
|
|
99
|
+
isSnapped(t) {
|
|
100
|
+
return this.snapPoints.some((e) => e === Math.round(t));
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Sets the display state of the sheet
|
|
104
|
+
*/
|
|
105
|
+
showSheet(t) {
|
|
106
|
+
this.open = t, this.height = isNaN(this.defaultSnap) ? 1 / 0 : this.defaultSnap, this.setOverscroll(t), this.setDialog(t);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Toggles the display state of the sheet
|
|
110
|
+
*/
|
|
111
|
+
toggleSheet() {
|
|
112
|
+
this.showSheet(!this.open);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Remove overscroll to prevent mobile browsers from refreshing during drag
|
|
116
|
+
*/
|
|
117
|
+
setOverscroll(t) {
|
|
118
|
+
const e = document.querySelector("html"), o = document.querySelector("body"), s = t ? "none" : "unset";
|
|
119
|
+
e && e.style.setProperty("overscroll-behavior-block", s), o && o.style.setProperty("overscroll-behavior-block", s);
|
|
120
|
+
}
|
|
121
|
+
setDialog(t) {
|
|
122
|
+
t && !this.dialog.open ? this.nonmodal ? this.dialog.show() : this.dialog.showModal() : t && this.dialog.open ? this.nonmodal && this.modalDialog ? (this.dialog.close(), this.dialog.show()) : !this.nonmodal && this.nonModalDialog && (this.dialog.close(), this.dialog.showModal()) : this.dialog.close();
|
|
123
|
+
}
|
|
124
|
+
touchDown(t) {
|
|
125
|
+
t.target instanceof HTMLElement && (this.startY = t.touches[0].pageY, this.startHeight = this.height);
|
|
126
|
+
}
|
|
127
|
+
touchMove(t) {
|
|
128
|
+
if (!(t.target instanceof HTMLElement)) return;
|
|
129
|
+
const e = t.touches[0];
|
|
130
|
+
let o = NaN;
|
|
131
|
+
this.previousTouch && (o = e.pageY - this.previousTouch.pageY), this.previousTouch = e;
|
|
132
|
+
let s = this.startY - t.touches[0].pageY;
|
|
133
|
+
const n = this.startHeight + s / window.innerHeight * 100;
|
|
134
|
+
!this.scrolling && this.dragging ? this.height = n : this.scrolling && this.dragging || this.scrolling && !this.dragging ? t.target.focus({ preventScroll: !0 }) : !this.scrolling && !this.dragging && (o >= 0 ? this.height = Math.min(n, this.defaultSnap || this.snapPoints[this.snapPoints.length - 1]) : t.target.focus({ preventScroll: !0 }));
|
|
135
|
+
}
|
|
136
|
+
touchUp(t) {
|
|
137
|
+
t.target instanceof HTMLElement && (this.previousTouch = null, this.setSnap(this.height));
|
|
138
|
+
}
|
|
139
|
+
pointerDown(t) {
|
|
140
|
+
t.target instanceof HTMLElement && (t.target.setPointerCapture(t.pointerId), this.startY = t.pageY, this.startHeight = this.height);
|
|
141
|
+
}
|
|
142
|
+
pointerMove(t) {
|
|
143
|
+
if (!(t.target instanceof HTMLElement && t.target.hasPointerCapture(t.pointerId)) || !t.isPrimary) return;
|
|
144
|
+
t.preventDefault();
|
|
145
|
+
let e = this.startY - t.pageY;
|
|
146
|
+
const o = this.startHeight + e / window.innerHeight * 100;
|
|
147
|
+
t.target.id === "handle" && (this.height = o);
|
|
148
|
+
}
|
|
149
|
+
pointerUp(t) {
|
|
150
|
+
t.target instanceof HTMLElement && (t.target.releasePointerCapture(t.pointerId), this.setSnap(this.height));
|
|
151
|
+
}
|
|
152
|
+
onSnapped(t, e) {
|
|
153
|
+
this.dragging = !t;
|
|
154
|
+
}
|
|
155
|
+
contentScroll(t) {
|
|
156
|
+
if (!(t.target instanceof HTMLElement && t.target.id === "content")) return;
|
|
157
|
+
const e = t.target.scrollTop;
|
|
158
|
+
this.scrolling = e !== this.lastScrollTop, this.lastScrollTop = e, e === 0 && (this.scrolling = !1);
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
i.styles = [
|
|
162
|
+
p`
|
|
163
|
+
:host {
|
|
164
|
+
contain: content;
|
|
165
|
+
overscroll-behavior-block: none;
|
|
166
|
+
--height: fit-content;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
:host([dragging]) dialog {
|
|
170
|
+
#content {
|
|
171
|
+
cursor: grabbing;
|
|
172
|
+
/* Important! Prevents mobile browsers from reclaiming PointerMove event on touch devices */
|
|
173
|
+
touch-action: none;
|
|
174
|
+
/* Prevent weird scrollbar movement on mobile when dragging */
|
|
175
|
+
overflow-y: hidden;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
:host(:not([dragging])) dialog {
|
|
180
|
+
/* Only animate if not dragging */
|
|
181
|
+
transition-property: overlay opacity display;
|
|
182
|
+
transition-duration: 0.25s;
|
|
183
|
+
transition-behavior: allow-discrete;
|
|
184
|
+
|
|
185
|
+
&::backdrop {
|
|
186
|
+
transition-property: overlay opacity display;
|
|
187
|
+
transition-duration: 0.25s;
|
|
188
|
+
transition-behavior: allow-discrete;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
#content {
|
|
192
|
+
/* Allow scroll */
|
|
193
|
+
touch-action: pan-y;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
dialog {
|
|
198
|
+
display: none;
|
|
199
|
+
opacity: 0;
|
|
200
|
+
translate: 0 var(--height);
|
|
201
|
+
|
|
202
|
+
height: var(--height);
|
|
203
|
+
min-height: 0;
|
|
204
|
+
max-height: 100%;
|
|
205
|
+
min-width: 100%;
|
|
206
|
+
max-width: 100%;
|
|
207
|
+
flex-direction: column;
|
|
208
|
+
box-sizing: border-box;
|
|
209
|
+
padding: 0;
|
|
210
|
+
border: 0;
|
|
211
|
+
background-color: light-dark(#d9d9d9, #1c1c1c);
|
|
212
|
+
/* Important! Removes default browser styling, allowing bottom to work */
|
|
213
|
+
inset: unset;
|
|
214
|
+
bottom: 0;
|
|
215
|
+
left: 0;
|
|
216
|
+
overflow-y: hidden;
|
|
217
|
+
|
|
218
|
+
/* Important! Prevents mobile browsers from reclaiming PointerMove event on touch devices */
|
|
219
|
+
touch-action: none;
|
|
220
|
+
/* Prevent weird scrollbar movement on mobile when dragging */
|
|
221
|
+
overflow-y: hidden;
|
|
222
|
+
|
|
223
|
+
&[open] {
|
|
224
|
+
display: flex;
|
|
225
|
+
opacity: 1;
|
|
226
|
+
translate: 0 0;
|
|
227
|
+
|
|
228
|
+
&::backdrop {
|
|
229
|
+
opacity: 0.8;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
&::backdrop {
|
|
234
|
+
background: black;
|
|
235
|
+
opacity: 0;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
@starting-style {
|
|
240
|
+
dialog[open] {
|
|
241
|
+
opacity: 0;
|
|
242
|
+
translate: 0 var(--height);
|
|
243
|
+
|
|
244
|
+
&::backdrop {
|
|
245
|
+
opacity: 0;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
#handle {
|
|
251
|
+
display: block;
|
|
252
|
+
position: sticky;
|
|
253
|
+
top: 0;
|
|
254
|
+
background: transparent;
|
|
255
|
+
border: 0;
|
|
256
|
+
cursor: grabbing;
|
|
257
|
+
min-height: 35px;
|
|
258
|
+
user-select: none;
|
|
259
|
+
touch-action: none;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
div {
|
|
263
|
+
/* display: contents; */
|
|
264
|
+
overflow-y: auto;
|
|
265
|
+
scrollbar-width: none;
|
|
266
|
+
box-sizing: border-box;
|
|
267
|
+
min-height: 100%;
|
|
268
|
+
min-width: 100%;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
::slotted(*) {
|
|
272
|
+
/* Prevent slotted items from taking pointer events */
|
|
273
|
+
/* pointer-events: none; */
|
|
274
|
+
}
|
|
275
|
+
`
|
|
276
|
+
];
|
|
277
|
+
r([
|
|
278
|
+
c("dialog")
|
|
279
|
+
], i.prototype, "dialog", 2);
|
|
280
|
+
r([
|
|
281
|
+
c("dialog:not(:modal)")
|
|
282
|
+
], i.prototype, "nonModalDialog", 2);
|
|
283
|
+
r([
|
|
284
|
+
c("dialog:modal")
|
|
285
|
+
], i.prototype, "modalDialog", 2);
|
|
286
|
+
r([
|
|
287
|
+
a({ type: Boolean, reflect: !0 })
|
|
288
|
+
], i.prototype, "open", 2);
|
|
289
|
+
r([
|
|
290
|
+
a({ type: Boolean, reflect: !0 })
|
|
291
|
+
], i.prototype, "nonmodal", 2);
|
|
292
|
+
r([
|
|
293
|
+
a({ type: Boolean, reflect: !0 })
|
|
294
|
+
], i.prototype, "dragging", 2);
|
|
295
|
+
r([
|
|
296
|
+
a({ type: Boolean, reflect: !0 })
|
|
297
|
+
], i.prototype, "scrolling", 2);
|
|
298
|
+
r([
|
|
299
|
+
a({ type: Array })
|
|
300
|
+
], i.prototype, "snapPoints", 2);
|
|
301
|
+
r([
|
|
302
|
+
a({ type: Number })
|
|
303
|
+
], i.prototype, "defaultSnap", 2);
|
|
304
|
+
r([
|
|
305
|
+
a({ type: Number, reflect: !0 })
|
|
306
|
+
], i.prototype, "height", 1);
|
|
307
|
+
i = r([
|
|
308
|
+
u("bottom-sheet")
|
|
309
|
+
], i);
|
|
310
|
+
export {
|
|
311
|
+
i as BottomSheet
|
|
312
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/web-components';
|
|
2
|
+
declare const meta: Meta;
|
|
3
|
+
export default meta;
|
|
4
|
+
type Props = {
|
|
5
|
+
open: boolean;
|
|
6
|
+
nonmodal: boolean;
|
|
7
|
+
snapPoints: number[];
|
|
8
|
+
defaultSnap: number;
|
|
9
|
+
};
|
|
10
|
+
type Story = StoryObj<Props>;
|
|
11
|
+
export declare const Modal: Story;
|
|
12
|
+
export declare const NonModal: Story;
|
|
13
|
+
export declare const Thirds: Story;
|
|
14
|
+
//# sourceMappingURL=bottom-sheet.stories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bottom-sheet.stories.d.ts","sourceRoot":"","sources":["../../../src/components/bottom-sheet/bottom-sheet.stories.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAGhE,QAAA,MAAM,IAAI,EAAE,IAIX,CAAC;AAEF,eAAe,IAAI,CAAC;AAEpB,KAAK,KAAK,GAAG;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAC;IAAC,UAAU,EAAE,MAAM,EAAE,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAAC;AAE7F,KAAK,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;AAiB7B,eAAO,MAAM,KAAK,EAAE,KAMnB,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,KAOtB,CAAC;AAEF,eAAO,MAAM,MAAM,EAAE,KAMpB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bottom-sheet.test.d.ts","sourceRoot":"","sources":["../../../src/components/bottom-sheet/bottom-sheet.test.ts"],"names":[],"mappings":"AAEA,OAAO,gBAAgB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/bottom-sheet/index.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { EventEmitter } from '../../utils/EventEmitter';
|
|
2
|
+
type EventMap = {
|
|
3
|
+
click: [hex: string];
|
|
4
|
+
move: [e: client];
|
|
5
|
+
};
|
|
6
|
+
import { LitElement } from 'lit';
|
|
7
|
+
export declare class CanvasBase extends LitElement {
|
|
8
|
+
canvas: HTMLCanvasElement;
|
|
9
|
+
protected context: CanvasRenderingContext2D;
|
|
10
|
+
emitter: EventEmitter<EventMap>;
|
|
11
|
+
disconnectedCallback(): void;
|
|
12
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
13
|
+
getCanvasHex(clientX: number, clientY: number): string;
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=canvas-base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canvas-base.d.ts","sourceRoot":"","sources":["../../../src/components/canvas/canvas-base.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAGxD,KAAK,QAAQ,GAAG;IACf,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IACrB,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;CAClB,CAAC;AAEF,OAAO,EAAE,UAAU,EAAa,MAAM,KAAK,CAAC;AAG5C,qBACa,UAAW,SAAQ,UAAU;IAEzC,MAAM,EAAG,iBAAiB,CAAC;IAE3B,SAAS,CAAC,OAAO,EAAG,wBAAwB,CAAC;IAEtC,OAAO,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAgC;IAEtE,oBAAoB,IAAI,IAAI;IAK5B,MAAM;IAsBC,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAWpD"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import m from "colorsea";
|
|
2
|
+
import { EventEmitter as u } from "../../utils/EventEmitter.js";
|
|
3
|
+
import { ref as f } from "lit/directives/ref.js";
|
|
4
|
+
import { LitElement as h, html as x } from "lit";
|
|
5
|
+
import { query as d, customElement as g } from "lit/decorators.js";
|
|
6
|
+
var C = Object.defineProperty, b = Object.getOwnPropertyDescriptor, v = (i, e, r, a) => {
|
|
7
|
+
for (var t = a > 1 ? void 0 : a ? b(e, r) : e, n = i.length - 1, s; n >= 0; n--)
|
|
8
|
+
(s = i[n]) && (t = (a ? s(e, r, t) : s(t)) || t);
|
|
9
|
+
return a && t && C(e, r, t), t;
|
|
10
|
+
};
|
|
11
|
+
let c = class extends h {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(...arguments), this.emitter = new u();
|
|
14
|
+
}
|
|
15
|
+
disconnectedCallback() {
|
|
16
|
+
super.disconnectedCallback(), this.emitter.clear();
|
|
17
|
+
}
|
|
18
|
+
render() {
|
|
19
|
+
return x`
|
|
20
|
+
<canvas
|
|
21
|
+
@click=${(e) => this.emitter.emit("click", this.getCanvasHex(e.clientX, e.clientY))}
|
|
22
|
+
@pointermove=${(e) => {
|
|
23
|
+
e.isPrimary && this.emitter.emit("move", { x: e.clientX, y: e.clientY });
|
|
24
|
+
}}
|
|
25
|
+
${f((e) => {
|
|
26
|
+
e instanceof HTMLCanvasElement && (this.context = e.getContext("2d", { willReadFrequently: !0, alpha: !0 }));
|
|
27
|
+
})}
|
|
28
|
+
>
|
|
29
|
+
</canvas>
|
|
30
|
+
`;
|
|
31
|
+
}
|
|
32
|
+
// Retrieves the hex from the mouse position
|
|
33
|
+
getCanvasHex(i, e) {
|
|
34
|
+
const r = this.canvas.getBoundingClientRect();
|
|
35
|
+
let a = i - r.left, t = e - r.top, [n, s, o, p] = this.context.getImageData(a, t, 1, 1).data;
|
|
36
|
+
const l = Math.round(p / 255 * 100);
|
|
37
|
+
return l !== 255 ? m([n, s, o, l]).hex() : m([n, s, o]).hex();
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
v([
|
|
41
|
+
d("canvas")
|
|
42
|
+
], c.prototype, "canvas", 2);
|
|
43
|
+
c = v([
|
|
44
|
+
g("canvas-base")
|
|
45
|
+
], c);
|
|
46
|
+
export {
|
|
47
|
+
c as CanvasBase
|
|
48
|
+
};
|