@alegendstale/holly-components 2.0.3 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/absolute-container/absolute-container.js +79 -113
- package/dist/components/absolute-container/absolute-container.styles.js +20 -17
- package/dist/components/bottom-sheet/bottom-sheet.js +189 -319
- package/dist/components/bottom-sheet/bottom-sheet.styles.js +117 -114
- package/dist/components/canvas/canvas-base.d.ts +4 -1
- package/dist/components/canvas/canvas-base.d.ts.map +1 -1
- package/dist/components/canvas/canvas-base.js +51 -67
- package/dist/components/canvas/canvas-gradient.js +44 -69
- package/dist/components/canvas/canvas-image.js +112 -177
- package/dist/components/canvas/canvas-image.styles.js +23 -20
- package/dist/components/carousel-scroller/carousel-scroller.js +63 -87
- package/dist/components/carousel-scroller/carousel-scroller.styles.js +68 -65
- package/dist/components/color-palette/color-palette-utils.js +55 -104
- package/dist/components/color-palette/color-palette.js +250 -384
- package/dist/components/color-palette/color-palette.styles.js +92 -89
- package/dist/components/color-palette/component/color-palette-component.js +134 -188
- package/dist/components/color-palette/component/color-palette-component.styles.js +12 -9
- package/dist/components/color-palette/editor/color-palette-editor.js +413 -539
- package/dist/components/color-palette/editor/color-palette-editor.styles.js +149 -146
- package/dist/components/color-palette/editor/settings-item.js +32 -40
- package/dist/components/color-palette/editor/settings-item.styles.js +36 -33
- package/dist/components/color-palette/item/color-palette-item-edit.js +50 -84
- package/dist/components/color-palette/item/color-palette-item-edit.styles.js +53 -50
- package/dist/components/color-palette/item/color-palette-item.js +72 -107
- package/dist/components/color-palette/item/color-palette-item.styles.js +85 -82
- package/dist/components/color-palette/menu/color-palette-menu.js +162 -200
- package/dist/components/color-palette/menu/color-palette-menu.styles.js +51 -48
- package/dist/components/color-palette/menu/color-palette-reorder.js +76 -95
- package/dist/components/color-palette/menu/color-palette-reorder.styles.js +33 -30
- package/dist/components/draw-svg/draw-svg.js +35 -52
- package/dist/components/draw-svg/draw-svg.styles.js +41 -38
- package/dist/components/responsive-svg/responsive-svg.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 +29 -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,115 +1,118 @@
|
|
|
1
|
-
import { css } from
|
|
2
|
-
|
|
3
|
-
:host {
|
|
4
|
-
contain: content;
|
|
5
|
-
overscroll-behavior-block: none;
|
|
6
|
-
--height: fit-content;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
:host([dragging]) dialog {
|
|
10
|
-
#content {
|
|
11
|
-
cursor: grabbing;
|
|
12
|
-
/* Important! Prevents mobile browsers from reclaiming PointerMove event on touch devices */
|
|
13
|
-
touch-action: none;
|
|
14
|
-
/* Prevent weird scrollbar movement on mobile when dragging */
|
|
15
|
-
overflow-y: hidden;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
:host(:not([dragging])) dialog {
|
|
20
|
-
/* Only animate if not dragging */
|
|
21
|
-
transition-property: overlay opacity display;
|
|
22
|
-
transition-duration: 0.25s;
|
|
23
|
-
transition-behavior: allow-discrete;
|
|
24
|
-
|
|
25
|
-
&::backdrop {
|
|
26
|
-
transition-property: overlay opacity display;
|
|
27
|
-
transition-duration: 0.25s;
|
|
28
|
-
transition-behavior: allow-discrete;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
#content {
|
|
32
|
-
/* Allow scroll */
|
|
33
|
-
touch-action: pan-y;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
dialog {
|
|
38
|
-
display: none;
|
|
39
|
-
opacity: 0;
|
|
40
|
-
translate: 0 var(--height);
|
|
41
|
-
|
|
42
|
-
height: var(--height);
|
|
43
|
-
min-height: 0;
|
|
44
|
-
max-height: 100%;
|
|
45
|
-
min-width: 100%;
|
|
46
|
-
max-width: 100%;
|
|
47
|
-
flex-direction: column;
|
|
48
|
-
box-sizing: border-box;
|
|
49
|
-
padding: 0;
|
|
50
|
-
border: 0;
|
|
51
|
-
background-color: light-dark(#d9d9d9, #1c1c1c);
|
|
52
|
-
/* Important! Removes default browser styling, allowing bottom to work */
|
|
53
|
-
inset: unset;
|
|
54
|
-
bottom: 0;
|
|
55
|
-
left: 0;
|
|
56
|
-
overflow-y: hidden;
|
|
57
|
-
|
|
58
|
-
/* Important! Prevents mobile browsers from reclaiming PointerMove event on touch devices */
|
|
59
|
-
touch-action: none;
|
|
60
|
-
/* Prevent weird scrollbar movement on mobile when dragging */
|
|
61
|
-
overflow-y: hidden;
|
|
62
|
-
|
|
63
|
-
&[open] {
|
|
64
|
-
display: flex;
|
|
65
|
-
opacity: 1;
|
|
66
|
-
translate: 0 0;
|
|
67
|
-
|
|
68
|
-
&::backdrop {
|
|
69
|
-
opacity: 0.8;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
&::backdrop {
|
|
74
|
-
background: black;
|
|
75
|
-
opacity: 0;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
@starting-style {
|
|
80
|
-
dialog[open] {
|
|
81
|
-
opacity: 0;
|
|
82
|
-
translate: 0 var(--height);
|
|
83
|
-
|
|
84
|
-
&::backdrop {
|
|
85
|
-
opacity: 0;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
#handle {
|
|
91
|
-
display: block;
|
|
92
|
-
position: sticky;
|
|
93
|
-
top: 0;
|
|
94
|
-
background: transparent;
|
|
95
|
-
border: 0;
|
|
96
|
-
cursor: grabbing;
|
|
97
|
-
min-height: 35px;
|
|
98
|
-
user-select: none;
|
|
99
|
-
touch-action: none;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
div {
|
|
103
|
-
/* display: contents; */
|
|
104
|
-
overflow-y: auto;
|
|
105
|
-
scrollbar-width: none;
|
|
106
|
-
box-sizing: border-box;
|
|
107
|
-
min-height: 100%;
|
|
108
|
-
min-width: 100%;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
::slotted(*) {
|
|
112
|
-
/* Prevent slotted items from taking pointer events */
|
|
113
|
-
/* pointer-events: none; */
|
|
114
|
-
}
|
|
1
|
+
import { css as o } from "lit";
|
|
2
|
+
const e = o`
|
|
3
|
+
:host {
|
|
4
|
+
contain: content;
|
|
5
|
+
overscroll-behavior-block: none;
|
|
6
|
+
--height: fit-content;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
:host([dragging]) dialog {
|
|
10
|
+
#content {
|
|
11
|
+
cursor: grabbing;
|
|
12
|
+
/* Important! Prevents mobile browsers from reclaiming PointerMove event on touch devices */
|
|
13
|
+
touch-action: none;
|
|
14
|
+
/* Prevent weird scrollbar movement on mobile when dragging */
|
|
15
|
+
overflow-y: hidden;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
:host(:not([dragging])) dialog {
|
|
20
|
+
/* Only animate if not dragging */
|
|
21
|
+
transition-property: overlay opacity display;
|
|
22
|
+
transition-duration: 0.25s;
|
|
23
|
+
transition-behavior: allow-discrete;
|
|
24
|
+
|
|
25
|
+
&::backdrop {
|
|
26
|
+
transition-property: overlay opacity display;
|
|
27
|
+
transition-duration: 0.25s;
|
|
28
|
+
transition-behavior: allow-discrete;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
#content {
|
|
32
|
+
/* Allow scroll */
|
|
33
|
+
touch-action: pan-y;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
dialog {
|
|
38
|
+
display: none;
|
|
39
|
+
opacity: 0;
|
|
40
|
+
translate: 0 var(--height);
|
|
41
|
+
|
|
42
|
+
height: var(--height);
|
|
43
|
+
min-height: 0;
|
|
44
|
+
max-height: 100%;
|
|
45
|
+
min-width: 100%;
|
|
46
|
+
max-width: 100%;
|
|
47
|
+
flex-direction: column;
|
|
48
|
+
box-sizing: border-box;
|
|
49
|
+
padding: 0;
|
|
50
|
+
border: 0;
|
|
51
|
+
background-color: light-dark(#d9d9d9, #1c1c1c);
|
|
52
|
+
/* Important! Removes default browser styling, allowing bottom to work */
|
|
53
|
+
inset: unset;
|
|
54
|
+
bottom: 0;
|
|
55
|
+
left: 0;
|
|
56
|
+
overflow-y: hidden;
|
|
57
|
+
|
|
58
|
+
/* Important! Prevents mobile browsers from reclaiming PointerMove event on touch devices */
|
|
59
|
+
touch-action: none;
|
|
60
|
+
/* Prevent weird scrollbar movement on mobile when dragging */
|
|
61
|
+
overflow-y: hidden;
|
|
62
|
+
|
|
63
|
+
&[open] {
|
|
64
|
+
display: flex;
|
|
65
|
+
opacity: 1;
|
|
66
|
+
translate: 0 0;
|
|
67
|
+
|
|
68
|
+
&::backdrop {
|
|
69
|
+
opacity: 0.8;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
&::backdrop {
|
|
74
|
+
background: black;
|
|
75
|
+
opacity: 0;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
@starting-style {
|
|
80
|
+
dialog[open] {
|
|
81
|
+
opacity: 0;
|
|
82
|
+
translate: 0 var(--height);
|
|
83
|
+
|
|
84
|
+
&::backdrop {
|
|
85
|
+
opacity: 0;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
#handle {
|
|
91
|
+
display: block;
|
|
92
|
+
position: sticky;
|
|
93
|
+
top: 0;
|
|
94
|
+
background: transparent;
|
|
95
|
+
border: 0;
|
|
96
|
+
cursor: grabbing;
|
|
97
|
+
min-height: 35px;
|
|
98
|
+
user-select: none;
|
|
99
|
+
touch-action: none;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
div {
|
|
103
|
+
/* display: contents; */
|
|
104
|
+
overflow-y: auto;
|
|
105
|
+
scrollbar-width: none;
|
|
106
|
+
box-sizing: border-box;
|
|
107
|
+
min-height: 100%;
|
|
108
|
+
min-width: 100%;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
::slotted(*) {
|
|
112
|
+
/* Prevent slotted items from taking pointer events */
|
|
113
|
+
/* pointer-events: none; */
|
|
114
|
+
}
|
|
115
115
|
`;
|
|
116
|
+
export {
|
|
117
|
+
e as default
|
|
118
|
+
};
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { EventEmitter } from '../../utils/EventEmitter.js';
|
|
2
2
|
import { LitElement } from 'lit';
|
|
3
|
-
import { client } from '../../utils/types.js';
|
|
4
3
|
type EventMap = {
|
|
5
4
|
click: [hex: string];
|
|
6
5
|
move: [e: client];
|
|
7
6
|
};
|
|
7
|
+
type client = {
|
|
8
|
+
x: number;
|
|
9
|
+
y: number;
|
|
10
|
+
};
|
|
8
11
|
/**
|
|
9
12
|
* Utility component to help with creating canvases.
|
|
10
13
|
*/
|
|
@@ -1 +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,6BAA6B,CAAC;AAE3D,OAAO,EAAE,UAAU,EAAa,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"canvas-base.d.ts","sourceRoot":"","sources":["../../../src/components/canvas/canvas-base.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE3D,OAAO,EAAE,UAAU,EAAa,MAAM,KAAK,CAAC;AAG5C,KAAK,QAAQ,GAAG;IACf,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IACrB,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;CAClB,CAAC;AAEF,KAAK,MAAM,GAAG;IACb,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACV,CAAA;AAED;;GAEG;AACH,qBACa,UAAW,SAAQ,UAAU;IACzC,MAAM,CAAC,MAAM,4BAMX;IAEF,0BAA0B;IAE1B,SAAS,CAAC,MAAM,EAAG,iBAAiB,CAAC;IAErC,0BAA0B;IAC1B,SAAS,CAAC,OAAO,EAAG,wBAAwB,CAAC;IAE7C,yCAAyC;IAClC,OAAO,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAgC;IAEtE,oBAAoB,IAAI,IAAI;IAK5B,MAAM;IAqBN,iDAAiD;IAC1C,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAWpD"}
|
|
@@ -1,71 +1,55 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import m from "../../utils/colorsea-wrapper.js";
|
|
2
|
+
import { EventEmitter as h } from "../../utils/EventEmitter.js";
|
|
3
|
+
import { ref as u } from "lit/directives/ref.js";
|
|
4
|
+
import { css as f, LitElement as x, html as d } from "lit";
|
|
5
|
+
import { query as g, customElement as C } from "lit/decorators.js";
|
|
6
|
+
var y = 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 && y(e, r, t), t;
|
|
6
10
|
};
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
/** Public way to subscribe to events. */
|
|
19
|
-
this.emitter = new EventEmitter();
|
|
20
|
-
}
|
|
21
|
-
static { this.styles = [
|
|
22
|
-
css `
|
|
23
|
-
:host {
|
|
24
|
-
display: block;
|
|
25
|
-
}
|
|
26
|
-
`
|
|
27
|
-
]; }
|
|
28
|
-
disconnectedCallback() {
|
|
29
|
-
super.disconnectedCallback();
|
|
30
|
-
this.emitter.clear();
|
|
31
|
-
}
|
|
32
|
-
render() {
|
|
33
|
-
let canvasRef = (canvas) => {
|
|
34
|
-
if (!(canvas instanceof HTMLCanvasElement))
|
|
35
|
-
return;
|
|
36
|
-
this.context = canvas.getContext('2d', { willReadFrequently: true, alpha: true });
|
|
37
|
-
};
|
|
38
|
-
return html `
|
|
39
|
-
<canvas
|
|
40
|
-
@click=${(e) => this.emitter.emit('click', this.getCanvasHex(e.clientX, e.clientY))}
|
|
11
|
+
let c = class extends x {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(...arguments), this.emitter = new h();
|
|
14
|
+
}
|
|
15
|
+
disconnectedCallback() {
|
|
16
|
+
super.disconnectedCallback(), this.emitter.clear();
|
|
17
|
+
}
|
|
18
|
+
render() {
|
|
19
|
+
return d`
|
|
20
|
+
<canvas
|
|
21
|
+
@click=${(e) => this.emitter.emit("click", this.getCanvasHex(e.clientX, e.clientY))}
|
|
41
22
|
@pointermove=${(e) => {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
>
|
|
49
|
-
</canvas>
|
|
23
|
+
e.isPrimary && this.emitter.emit("move", { x: e.clientX, y: e.clientY });
|
|
24
|
+
}}
|
|
25
|
+
${u((e) => {
|
|
26
|
+
e instanceof HTMLCanvasElement && (this.context = e.getContext("2d", { willReadFrequently: !0, alpha: !0 }));
|
|
27
|
+
})}
|
|
28
|
+
>
|
|
29
|
+
</canvas>
|
|
50
30
|
`;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
+
c.styles = [
|
|
41
|
+
f`
|
|
42
|
+
:host {
|
|
43
|
+
display: block;
|
|
44
|
+
}
|
|
45
|
+
`
|
|
46
|
+
];
|
|
47
|
+
v([
|
|
48
|
+
g("canvas")
|
|
49
|
+
], c.prototype, "canvas", 2);
|
|
50
|
+
c = v([
|
|
51
|
+
C("canvas-base")
|
|
52
|
+
], c);
|
|
53
|
+
export {
|
|
54
|
+
c as CanvasBase
|
|
64
55
|
};
|
|
65
|
-
__decorate([
|
|
66
|
-
query('canvas')
|
|
67
|
-
], CanvasBase.prototype, "canvas", void 0);
|
|
68
|
-
CanvasBase = __decorate([
|
|
69
|
-
customElement('canvas-base')
|
|
70
|
-
], CanvasBase);
|
|
71
|
-
export { CanvasBase };
|
|
@@ -1,71 +1,46 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { Direction as h } from "../color-palette/color-palette-utils.js";
|
|
2
|
+
import { property as c, customElement as f } from "lit/decorators.js";
|
|
3
|
+
import { CanvasBase as d } from "./canvas-base.js";
|
|
4
|
+
import { isColorValid as u } from "../../utils/basicUtils.js";
|
|
5
|
+
var m = Object.defineProperty, y = Object.getOwnPropertyDescriptor, p = (r, e, o, s) => {
|
|
6
|
+
for (var t = s > 1 ? void 0 : s ? y(e, o) : e, n = r.length - 1, a; n >= 0; n--)
|
|
7
|
+
(a = r[n]) && (t = (s ? a(e, o, t) : a(t)) || t);
|
|
8
|
+
return s && t && m(e, o, t), t;
|
|
6
9
|
};
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
if (isColorValid(color)) {
|
|
44
|
-
gradient.addColorStop(i / (colors.length - 1), color);
|
|
45
|
-
colorStops.push(color);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
if (colorStops.length <= 1)
|
|
49
|
-
throw new Error('There are not enough valid color stops to create the gradient.');
|
|
50
|
-
this.context.fillStyle = gradient || '#000';
|
|
51
|
-
this.context.fillRect(0, 0, width, height);
|
|
52
|
-
this.canvas.classList.add('gradient');
|
|
53
|
-
this.canvas.style.setProperty('--palette-column-flex-basis', (height / colors.length / 2).toString() + 'px');
|
|
54
|
-
}
|
|
10
|
+
let i = class extends d {
|
|
11
|
+
constructor() {
|
|
12
|
+
super(...arguments), this.colors = [], this.height = 0, this.width = 0, this.direction = h.Column;
|
|
13
|
+
}
|
|
14
|
+
updated(r) {
|
|
15
|
+
super.updated(r), this.createGradient(this.colors, this.height, this.width, this.direction);
|
|
16
|
+
}
|
|
17
|
+
/** Creates a new gradient canvas */
|
|
18
|
+
createGradient(r, e, o, s) {
|
|
19
|
+
if (!this.context) return;
|
|
20
|
+
this.canvas.height = e, this.canvas.width = o;
|
|
21
|
+
let t = s === h.Column ? this.context.createLinearGradient(0, 0, o, 0) : this.context.createLinearGradient(0, 0, 0, e), n = [];
|
|
22
|
+
for (const [a, l] of r.entries())
|
|
23
|
+
u(l) && (t.addColorStop(a / (r.length - 1), l), n.push(l));
|
|
24
|
+
if (n.length <= 1) throw new Error("There are not enough valid color stops to create the gradient.");
|
|
25
|
+
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");
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
i.styles = [...d.styles];
|
|
29
|
+
p([
|
|
30
|
+
c({ type: Array })
|
|
31
|
+
], i.prototype, "colors", 2);
|
|
32
|
+
p([
|
|
33
|
+
c({ type: Number })
|
|
34
|
+
], i.prototype, "height", 2);
|
|
35
|
+
p([
|
|
36
|
+
c({ type: Number })
|
|
37
|
+
], i.prototype, "width", 2);
|
|
38
|
+
p([
|
|
39
|
+
c({ type: String })
|
|
40
|
+
], i.prototype, "direction", 2);
|
|
41
|
+
i = p([
|
|
42
|
+
f("canvas-gradient")
|
|
43
|
+
], i);
|
|
44
|
+
export {
|
|
45
|
+
i as CanvasGradient
|
|
55
46
|
};
|
|
56
|
-
__decorate([
|
|
57
|
-
property({ type: Array })
|
|
58
|
-
], CanvasGradient.prototype, "colors", void 0);
|
|
59
|
-
__decorate([
|
|
60
|
-
property({ type: Number })
|
|
61
|
-
], CanvasGradient.prototype, "height", void 0);
|
|
62
|
-
__decorate([
|
|
63
|
-
property({ type: Number })
|
|
64
|
-
], CanvasGradient.prototype, "width", void 0);
|
|
65
|
-
__decorate([
|
|
66
|
-
property({ type: String })
|
|
67
|
-
], CanvasGradient.prototype, "direction", void 0);
|
|
68
|
-
CanvasGradient = __decorate([
|
|
69
|
-
customElement('canvas-gradient')
|
|
70
|
-
], CanvasGradient);
|
|
71
|
-
export { CanvasGradient };
|