@alegendstale/holly-components 2.0.2 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/absolute-container/absolute-container.js +79 -113
- package/dist/components/absolute-container/absolute-container.styles.js +20 -17
- package/dist/components/bottom-sheet/bottom-sheet.js +189 -319
- package/dist/components/bottom-sheet/bottom-sheet.styles.js +117 -114
- package/dist/components/canvas/canvas-base.d.ts +4 -1
- package/dist/components/canvas/canvas-base.d.ts.map +1 -1
- package/dist/components/canvas/canvas-base.js +51 -67
- package/dist/components/canvas/canvas-gradient.js +44 -69
- package/dist/components/canvas/canvas-image.js +112 -177
- package/dist/components/canvas/canvas-image.styles.js +23 -20
- package/dist/components/carousel-scroller/carousel-scroller.js +63 -87
- package/dist/components/carousel-scroller/carousel-scroller.styles.js +68 -65
- package/dist/components/color-palette/color-palette-utils.js +55 -104
- package/dist/components/color-palette/color-palette.js +250 -384
- package/dist/components/color-palette/color-palette.styles.js +92 -89
- package/dist/components/color-palette/component/color-palette-component.js +134 -188
- package/dist/components/color-palette/component/color-palette-component.styles.js +12 -9
- package/dist/components/color-palette/editor/color-palette-editor.js +413 -539
- package/dist/components/color-palette/editor/color-palette-editor.styles.js +149 -146
- package/dist/components/color-palette/editor/settings-item.js +32 -40
- package/dist/components/color-palette/editor/settings-item.styles.js +36 -33
- package/dist/components/color-palette/item/color-palette-item-edit.js +50 -84
- package/dist/components/color-palette/item/color-palette-item-edit.styles.js +53 -50
- package/dist/components/color-palette/item/color-palette-item.js +72 -107
- package/dist/components/color-palette/item/color-palette-item.styles.js +85 -82
- package/dist/components/color-palette/menu/color-palette-menu.js +162 -200
- package/dist/components/color-palette/menu/color-palette-menu.styles.js +51 -48
- package/dist/components/color-palette/menu/color-palette-reorder.js +76 -95
- package/dist/components/color-palette/menu/color-palette-reorder.styles.js +33 -30
- package/dist/components/draw-svg/draw-svg.js +35 -52
- package/dist/components/draw-svg/draw-svg.styles.js +41 -38
- package/dist/components/responsive-svg/responsive-svg.d.ts +2 -2
- package/dist/components/responsive-svg/responsive-svg.d.ts.map +1 -1
- package/dist/components/responsive-svg/responsive-svg.js +122 -174
- package/dist/components/responsive-svg/responsive-svg.styles.js +48 -45
- package/dist/components/tool-tip/tool-tip.d.ts +5 -1
- package/dist/components/tool-tip/tool-tip.d.ts.map +1 -1
- package/dist/components/tool-tip/tool-tip.js +64 -100
- package/dist/components/tool-tip/tool-tip.styles.js +60 -57
- package/dist/decorators/condCustomElement.js +8 -11
- package/dist/utils/EventEmitter.js +23 -23
- package/dist/utils/ResponsiveController.js +15 -18
- package/dist/utils/basicUtils.js +98 -146
- package/dist/utils/colorsea-wrapper.js +162 -166
- package/dist/utils/dragDropUtils.js +75 -119
- package/dist/utils/generateUtils.js +39 -73
- package/package.json +34 -64
- package/dist/components/absolute-container/absolute-container.stories.d.ts +0 -11
- package/dist/components/absolute-container/absolute-container.stories.d.ts.map +0 -1
- package/dist/components/absolute-container/absolute-container.stories.js +0 -64
- package/dist/components/absolute-container/index.d.ts +0 -2
- package/dist/components/absolute-container/index.d.ts.map +0 -1
- package/dist/components/absolute-container/index.js +0 -1
- package/dist/components/bottom-sheet/bottom-sheet.stories.d.ts +0 -17
- package/dist/components/bottom-sheet/bottom-sheet.stories.d.ts.map +0 -1
- package/dist/components/bottom-sheet/bottom-sheet.stories.js +0 -67
- package/dist/components/bottom-sheet/index.d.ts +0 -2
- package/dist/components/bottom-sheet/index.d.ts.map +0 -1
- package/dist/components/bottom-sheet/index.js +0 -1
- package/dist/components/canvas/canvas-base.stories.d.ts +0 -7
- package/dist/components/canvas/canvas-base.stories.d.ts.map +0 -1
- package/dist/components/canvas/canvas-base.stories.js +0 -24
- package/dist/components/canvas/canvas-gradient.stories.d.ts +0 -14
- package/dist/components/canvas/canvas-gradient.stories.d.ts.map +0 -1
- package/dist/components/canvas/canvas-gradient.stories.js +0 -46
- package/dist/components/canvas/canvas-image.stories.d.ts +0 -13
- package/dist/components/canvas/canvas-image.stories.d.ts.map +0 -1
- package/dist/components/canvas/canvas-image.stories.js +0 -49
- package/dist/components/canvas/index.d.ts +0 -3
- package/dist/components/canvas/index.d.ts.map +0 -1
- package/dist/components/canvas/index.js +0 -2
- package/dist/components/carousel-scroller/carousel-scroller.stories.d.ts +0 -13
- package/dist/components/carousel-scroller/carousel-scroller.stories.d.ts.map +0 -1
- package/dist/components/carousel-scroller/carousel-scroller.stories.js +0 -56
- package/dist/components/carousel-scroller/index.d.ts +0 -2
- package/dist/components/carousel-scroller/index.d.ts.map +0 -1
- package/dist/components/carousel-scroller/index.js +0 -1
- package/dist/components/color-palette/component/color-palette-component.stories.d.ts +0 -13
- package/dist/components/color-palette/component/color-palette-component.stories.d.ts.map +0 -1
- package/dist/components/color-palette/component/color-palette-component.stories.js +0 -75
- package/dist/components/color-palette/component/index.d.ts +0 -2
- package/dist/components/color-palette/component/index.d.ts.map +0 -1
- package/dist/components/color-palette/component/index.js +0 -1
- package/dist/components/color-palette/editor/color-palette-editor.stories.d.ts +0 -18
- package/dist/components/color-palette/editor/color-palette-editor.stories.d.ts.map +0 -1
- package/dist/components/color-palette/editor/color-palette-editor.stories.js +0 -67
- package/dist/components/color-palette/editor/index.d.ts +0 -2
- package/dist/components/color-palette/editor/index.d.ts.map +0 -1
- package/dist/components/color-palette/editor/index.js +0 -1
- package/dist/components/color-palette/index.d.ts +0 -6
- package/dist/components/color-palette/index.d.ts.map +0 -1
- package/dist/components/color-palette/index.js +0 -5
- package/dist/components/color-palette/item/index.d.ts +0 -3
- package/dist/components/color-palette/item/index.d.ts.map +0 -1
- package/dist/components/color-palette/item/index.js +0 -2
- package/dist/components/color-palette/menu/index.d.ts +0 -3
- package/dist/components/color-palette/menu/index.d.ts.map +0 -1
- package/dist/components/color-palette/menu/index.js +0 -2
- package/dist/components/color-palette/storybook/color-palette-invalid.stories.d.ts +0 -33
- package/dist/components/color-palette/storybook/color-palette-invalid.stories.d.ts.map +0 -1
- package/dist/components/color-palette/storybook/color-palette-invalid.stories.js +0 -62
- package/dist/components/color-palette/storybook/color-palette-valid.stories.d.ts +0 -52
- package/dist/components/color-palette/storybook/color-palette-valid.stories.d.ts.map +0 -1
- package/dist/components/color-palette/storybook/color-palette-valid.stories.js +0 -268
- package/dist/components/color-palette/storybook/color-palette.stories.d.ts +0 -27
- package/dist/components/color-palette/storybook/color-palette.stories.d.ts.map +0 -1
- package/dist/components/color-palette/storybook/color-palette.stories.js +0 -129
- package/dist/components/draw-svg/draw-svg.stories.d.ts +0 -7
- package/dist/components/draw-svg/draw-svg.stories.d.ts.map +0 -1
- package/dist/components/draw-svg/draw-svg.stories.js +0 -61
- package/dist/components/draw-svg/index.d.ts +0 -2
- package/dist/components/draw-svg/index.d.ts.map +0 -1
- package/dist/components/draw-svg/index.js +0 -1
- package/dist/components/responsive-svg/index.d.ts +0 -2
- package/dist/components/responsive-svg/index.d.ts.map +0 -1
- package/dist/components/responsive-svg/index.js +0 -1
- package/dist/components/responsive-svg/responsive-svg.stories.d.ts +0 -26
- package/dist/components/responsive-svg/responsive-svg.stories.d.ts.map +0 -1
- package/dist/components/responsive-svg/responsive-svg.stories.js +0 -194
- package/dist/components/tool-tip/index.d.ts +0 -2
- package/dist/components/tool-tip/index.d.ts.map +0 -1
- package/dist/components/tool-tip/index.js +0 -1
- package/dist/components/tool-tip/tool-tip.stories.d.ts +0 -16
- package/dist/components/tool-tip/tool-tip.stories.d.ts.map +0 -1
- package/dist/components/tool-tip/tool-tip.stories.js +0 -62
- package/dist/decorators/index.d.ts +0 -2
- package/dist/decorators/index.d.ts.map +0 -1
- package/dist/decorators/index.js +0 -1
- package/dist/index.d.ts +0 -11
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -10
- package/dist/utils/index.d.ts +0 -5
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js +0 -4
- package/dist/utils/types.d.ts +0 -5
- package/dist/utils/types.d.ts.map +0 -1
- package/dist/utils/types.js +0 -1
|
@@ -1,393 +1,259 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { LitElement as I, html as c, nothing as S } from "lit";
|
|
2
|
+
import { query as C, property as n, state as $, customElement as x } from "lit/decorators.js";
|
|
3
|
+
import { styleMap as y } from "lit/directives/style-map.js";
|
|
4
|
+
import { repeat as N } from "lit/directives/repeat.js";
|
|
5
|
+
import { defaultSettings as u, Status as l, parseColors as w, PaletteError as v, Direction as _ } from "./color-palette-utils.js";
|
|
6
|
+
import { ColorPaletteItem as T } from "./item/color-palette-item.js";
|
|
7
|
+
import { copyToClipboard as m } from "../../utils/basicUtils.js";
|
|
8
|
+
import { EventEmitter as b } from "../../utils/EventEmitter.js";
|
|
9
|
+
import { CanvasGradient as A } from "../canvas/canvas-gradient.js";
|
|
10
|
+
import { classMap as D } from "lit/directives/class-map.js";
|
|
11
|
+
import { ColorPaletteItemEdit as M } from "./item/color-palette-item-edit.js";
|
|
12
|
+
import { ref as g, createRef as P } from "lit/directives/ref.js";
|
|
13
|
+
import L from "./color-palette.styles.js";
|
|
14
|
+
var E = Object.defineProperty, O = Object.getOwnPropertyDescriptor, o = (t, e, s, a) => {
|
|
15
|
+
for (var i = a > 1 ? void 0 : a ? O(e, s) : e, h = t.length - 1, p; h >= 0; h--)
|
|
16
|
+
(p = t[h]) && (i = (a ? p(e, s, i) : p(i)) || i);
|
|
17
|
+
return a && i && E(e, s, i), i;
|
|
6
18
|
};
|
|
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
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
/** Public way to subscribe to events. */
|
|
70
|
-
this.emitter = new EventEmitter();
|
|
71
|
-
/** Extended settings */
|
|
72
|
-
this.pluginSettings = defaultSettings;
|
|
73
|
-
}
|
|
74
|
-
static { this.styles = [styles]; }
|
|
75
|
-
/**
|
|
76
|
-
* Whether the palette can be edited.
|
|
77
|
-
* @type {boolean}
|
|
78
|
-
* @default false
|
|
79
|
-
*/
|
|
80
|
-
set editMode(val) {
|
|
81
|
-
this._editMode = val;
|
|
82
|
-
this.emitter.emit('editMode', val);
|
|
83
|
-
}
|
|
84
|
-
get editMode() {
|
|
85
|
-
return this._editMode;
|
|
86
|
-
}
|
|
87
|
-
/** Helper accessor for settings */
|
|
88
|
-
set settings({ height, width, direction, gradient, preventHover, override, aliases }) {
|
|
89
|
-
this.height = height;
|
|
90
|
-
this.width = width;
|
|
91
|
-
this.direction = direction;
|
|
92
|
-
this.gradient = gradient;
|
|
93
|
-
this.preventHover = preventHover;
|
|
94
|
-
this.override = override;
|
|
95
|
-
this.aliases = aliases;
|
|
96
|
-
}
|
|
97
|
-
get settings() {
|
|
98
|
-
return {
|
|
99
|
-
height: this.height,
|
|
100
|
-
width: this.width,
|
|
101
|
-
direction: this.direction,
|
|
102
|
-
gradient: this.gradient,
|
|
103
|
-
preventHover: this.preventHover,
|
|
104
|
-
hideText: this.hideText,
|
|
105
|
-
override: this.override,
|
|
106
|
-
aliases: this.aliases,
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
connectedCallback() {
|
|
110
|
-
super.connectedCallback();
|
|
111
|
-
// Pulse the Invalid Palette to show its location
|
|
112
|
-
if (this.pluginSettings.errorPulse) {
|
|
113
|
-
this.pulse = true;
|
|
114
|
-
setTimeout(() => {
|
|
115
|
-
this.pulse = false;
|
|
116
|
-
}, this.pluginSettings.noticeDuration);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
disconnectedCallback() {
|
|
120
|
-
super.disconnectedCallback();
|
|
121
|
-
this.emitter.clear();
|
|
122
|
-
}
|
|
123
|
-
willUpdate(_changedProperties) {
|
|
124
|
-
super.willUpdate(_changedProperties);
|
|
125
|
-
this.setStatusAndColors();
|
|
126
|
-
}
|
|
127
|
-
/** Sets the current status and parses colors. */
|
|
128
|
-
setStatusAndColors() {
|
|
129
|
-
const isSettingsValid = () => {
|
|
130
|
-
return (!isNaN(this.height)
|
|
131
|
-
&& !isNaN(this.width)
|
|
132
|
-
&& Object.values(Direction).includes(this.direction)
|
|
133
|
-
&& this.gradient != null
|
|
134
|
-
&& this.preventHover != null
|
|
135
|
-
&& this.hideText != null
|
|
136
|
-
&& this.override != null
|
|
137
|
-
&& (this.aliases instanceof Array
|
|
138
|
-
|| typeof this.aliases === 'undefined'));
|
|
139
|
-
};
|
|
140
|
-
const colorsResult = parseColors(this.colors, this.override);
|
|
141
|
-
if (!isSettingsValid()) {
|
|
142
|
-
this.status = Status.INVALID_SETTINGS;
|
|
143
|
-
}
|
|
144
|
-
// Set status to invalid if parsedColors returns a status, or if parsedColors returns an empty array
|
|
145
|
-
if (typeof colorsResult === 'string' || (typeof colorsResult === 'object' && colorsResult.length === 0)) {
|
|
146
|
-
this.status = this.status === Status.INVALID_SETTINGS ? Status.INVALID_COLORS_AND_SETTINGS : Status.INVALID_COLORS;
|
|
147
|
-
}
|
|
148
|
-
if (typeof colorsResult === 'object') {
|
|
149
|
-
this.colors = colorsResult;
|
|
150
|
-
}
|
|
151
|
-
if (this.colors.length <= 1 && this.gradient)
|
|
152
|
-
this.status = Status.INVALID_GRADIENT;
|
|
153
|
-
}
|
|
154
|
-
render() {
|
|
155
|
-
const paletteStyles = {
|
|
156
|
-
// Set default corner style
|
|
157
|
-
'--palette-corners': this.pluginSettings.corners ? '5px' : '0px',
|
|
158
|
-
'--palette-height': `${this.height}px`,
|
|
159
|
-
'--palette-width': `${this.getPaletteWidth()}px`,
|
|
160
|
-
'--palette-column-flex-basis': `${(this.height / this.colors.length / 2)}px`
|
|
161
|
-
};
|
|
162
|
-
const invalidStyles = {
|
|
163
|
-
animation: this.pulse ? `pulse ${this.pluginSettings.noticeDuration / 1000 / 2}s infinite` : ''
|
|
164
|
-
};
|
|
165
|
-
const paletteClasses = {
|
|
166
|
-
"palette-scroll": this.width > defaultSettings.width,
|
|
167
|
-
};
|
|
168
|
-
return html `
|
|
169
|
-
<div
|
|
170
|
-
id="palette"
|
|
171
|
-
class=${classMap(paletteClasses)}
|
|
172
|
-
style=${this.status === Status.VALID ? styleMap(paletteStyles) : styleMap(invalidStyles)}
|
|
173
|
-
>
|
|
174
|
-
${this.createPalette()}
|
|
175
|
-
</div>
|
|
19
|
+
let r = class extends I {
|
|
20
|
+
constructor() {
|
|
21
|
+
super(...arguments), this._editMode = !1, this.colors = [], this.height = u.height, this.width = u.width, this.direction = u.direction, this.gradient = !1, this.preventHover = !1, this.hideText = !1, this.override = !1, this.aliases = [], this.maxWidth = 0, this.status = l.VALID, this.pulse = !1, this.emitter = new b(), this.pluginSettings = u;
|
|
22
|
+
}
|
|
23
|
+
set editMode(t) {
|
|
24
|
+
this._editMode = t, this.emitter.emit("editMode", t);
|
|
25
|
+
}
|
|
26
|
+
get editMode() {
|
|
27
|
+
return this._editMode;
|
|
28
|
+
}
|
|
29
|
+
/** Helper accessor for settings */
|
|
30
|
+
set settings({ height: t, width: e, direction: s, gradient: a, preventHover: i, override: h, aliases: p }) {
|
|
31
|
+
this.height = t, this.width = e, this.direction = s, this.gradient = a, this.preventHover = i, this.override = h, this.aliases = p;
|
|
32
|
+
}
|
|
33
|
+
get settings() {
|
|
34
|
+
return {
|
|
35
|
+
height: this.height,
|
|
36
|
+
width: this.width,
|
|
37
|
+
direction: this.direction,
|
|
38
|
+
gradient: this.gradient,
|
|
39
|
+
preventHover: this.preventHover,
|
|
40
|
+
hideText: this.hideText,
|
|
41
|
+
override: this.override,
|
|
42
|
+
aliases: this.aliases
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
connectedCallback() {
|
|
46
|
+
super.connectedCallback(), this.pluginSettings.errorPulse && (this.pulse = !0, setTimeout(() => {
|
|
47
|
+
this.pulse = !1;
|
|
48
|
+
}, this.pluginSettings.noticeDuration));
|
|
49
|
+
}
|
|
50
|
+
disconnectedCallback() {
|
|
51
|
+
super.disconnectedCallback(), this.emitter.clear();
|
|
52
|
+
}
|
|
53
|
+
willUpdate(t) {
|
|
54
|
+
super.willUpdate(t), this.setStatusAndColors();
|
|
55
|
+
}
|
|
56
|
+
/** Sets the current status and parses colors. */
|
|
57
|
+
setStatusAndColors() {
|
|
58
|
+
const t = () => !isNaN(this.height) && !isNaN(this.width) && Object.values(_).includes(this.direction) && this.gradient != null && this.preventHover != null && this.hideText != null && this.override != null && (this.aliases instanceof Array || typeof this.aliases > "u"), e = w(this.colors, this.override);
|
|
59
|
+
t() || (this.status = l.INVALID_SETTINGS), (typeof e == "string" || typeof e == "object" && e.length === 0) && (this.status = this.status === l.INVALID_SETTINGS ? l.INVALID_COLORS_AND_SETTINGS : l.INVALID_COLORS), typeof e == "object" && (this.colors = e), this.colors.length <= 1 && this.gradient && (this.status = l.INVALID_GRADIENT);
|
|
60
|
+
}
|
|
61
|
+
render() {
|
|
62
|
+
const t = {
|
|
63
|
+
// Set default corner style
|
|
64
|
+
"--palette-corners": this.pluginSettings.corners ? "5px" : "0px",
|
|
65
|
+
"--palette-height": `${this.height}px`,
|
|
66
|
+
"--palette-width": `${this.getPaletteWidth()}px`,
|
|
67
|
+
"--palette-column-flex-basis": `${this.height / this.colors.length / 2}px`
|
|
68
|
+
}, e = {
|
|
69
|
+
animation: this.pulse ? `pulse ${this.pluginSettings.noticeDuration / 1e3 / 2}s infinite` : ""
|
|
70
|
+
}, s = {
|
|
71
|
+
"palette-scroll": this.width > u.width
|
|
72
|
+
};
|
|
73
|
+
return c`
|
|
74
|
+
<div
|
|
75
|
+
id="palette"
|
|
76
|
+
class=${D(s)}
|
|
77
|
+
style=${this.status === l.VALID ? y(t) : y(e)}
|
|
78
|
+
>
|
|
79
|
+
${this.createPalette()}
|
|
80
|
+
</div>
|
|
176
81
|
`;
|
|
82
|
+
}
|
|
83
|
+
/** @returns `user` OR `auto` width based on which is more appropriate. */
|
|
84
|
+
getPaletteWidth() {
|
|
85
|
+
return this.maxWidth < this.settings.width && this.maxWidth > 0 ? this.maxWidth : this.settings.width;
|
|
86
|
+
}
|
|
87
|
+
/** Creates a color palette or gradient palette depending on settings. */
|
|
88
|
+
createPalette() {
|
|
89
|
+
try {
|
|
90
|
+
if (this.status === l.VALID)
|
|
91
|
+
return this.gradient ? this.createGradient() : this.createColors();
|
|
92
|
+
throw new v(this.status);
|
|
93
|
+
} catch (t) {
|
|
94
|
+
return t instanceof v ? (this.emitter.emit("notice", t.message), this.createInvalidPalette(t.status, t.message)) : S;
|
|
177
95
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
this.emitter.emit('changed', this.colors, this.settings);
|
|
230
|
-
});
|
|
231
|
-
item.emitter.on('alias', (alias) => {
|
|
232
|
-
// Get the index of the alias relative to the PaletteItem color
|
|
233
|
-
const aliasIndex = this.colors.findIndex((val) => val === color);
|
|
234
|
-
for (let i = 0; i < aliasIndex; i++) {
|
|
235
|
-
// Set empty strings to empty indexes
|
|
236
|
-
if (!this.aliases[i])
|
|
237
|
-
this.aliases[i] = '';
|
|
238
|
-
}
|
|
239
|
-
// Set modified alias index
|
|
240
|
-
this.aliases[aliasIndex] = alias;
|
|
241
|
-
this.emitter.emit('changed', this.colors, this.settings);
|
|
242
|
-
});
|
|
243
|
-
};
|
|
244
|
-
return !this.editMode
|
|
245
|
-
? html `
|
|
246
|
-
<color-palette-item
|
|
247
|
-
color=${color}
|
|
248
|
-
alias=${this.aliases?.[index] || ''}
|
|
249
|
-
aliasMode=${this.pluginSettings.aliasMode}
|
|
250
|
-
direction=${this.direction}
|
|
251
|
-
?editMode=${this.editMode}
|
|
252
|
-
height=${this.height}
|
|
253
|
-
?preventHover=${this.preventHover}
|
|
254
|
-
?hideText=${this.hideText}
|
|
255
|
-
colorCount=${this.colors.length}
|
|
256
|
-
${ref(itemRef)}
|
|
257
|
-
>
|
|
258
|
-
</color-palette-item>
|
|
259
|
-
`
|
|
260
|
-
: html `
|
|
261
|
-
<color-palette-item-edit
|
|
262
|
-
draggable=${true}
|
|
263
|
-
color=${color}
|
|
264
|
-
alias=${this.aliases?.[index] || ''}
|
|
265
|
-
aliasMode=${this.pluginSettings.aliasMode}
|
|
266
|
-
direction=${this.direction}
|
|
267
|
-
?editMode=${this.editMode}
|
|
268
|
-
height=${this.height}
|
|
269
|
-
?preventHover=${this.preventHover}
|
|
270
|
-
?hideText=${this.hideText}
|
|
271
|
-
colorCount=${this.colors.length}
|
|
272
|
-
?stabilizeWhileEditing=${this.pluginSettings.stabilizeWhileEditing}
|
|
273
|
-
${ref(itemEditRef)}
|
|
274
|
-
>
|
|
275
|
-
</color-palette-item-edit>
|
|
96
|
+
}
|
|
97
|
+
/** Create a color palette. */
|
|
98
|
+
createColors() {
|
|
99
|
+
return c`
|
|
100
|
+
${N(
|
|
101
|
+
this.colors,
|
|
102
|
+
(t, e) => {
|
|
103
|
+
let s = (i) => {
|
|
104
|
+
i instanceof T && (i.emitter.clear(), i.emitter.on("click", async (h) => await m(t.toUpperCase(), this.pluginSettings.copyFormat)));
|
|
105
|
+
}, a = (i) => {
|
|
106
|
+
i instanceof M && (i.emitter.clear(), i.emitter.on("click", async (h) => await m(t.toUpperCase(), this.pluginSettings.copyFormat)), i.emitter.on("trash", (h) => {
|
|
107
|
+
h.stopPropagation();
|
|
108
|
+
const p = this.colors.indexOf(t);
|
|
109
|
+
this.colors = this.colors.filter((d, f) => f !== p), this.aliases = this.aliases.filter((d, f) => f !== p), this.emitter.emit("changed", this.colors, this.settings);
|
|
110
|
+
}), i.emitter.on("alias", (h) => {
|
|
111
|
+
const p = this.colors.findIndex((d) => d === t);
|
|
112
|
+
for (let d = 0; d < p; d++)
|
|
113
|
+
this.aliases[d] || (this.aliases[d] = "");
|
|
114
|
+
this.aliases[p] = h, this.emitter.emit("changed", this.colors, this.settings);
|
|
115
|
+
}));
|
|
116
|
+
};
|
|
117
|
+
return this.editMode ? c`
|
|
118
|
+
<color-palette-item-edit
|
|
119
|
+
draggable=${!0}
|
|
120
|
+
color=${t}
|
|
121
|
+
alias=${this.aliases?.[e] || ""}
|
|
122
|
+
aliasMode=${this.pluginSettings.aliasMode}
|
|
123
|
+
direction=${this.direction}
|
|
124
|
+
?editMode=${this.editMode}
|
|
125
|
+
height=${this.height}
|
|
126
|
+
?preventHover=${this.preventHover}
|
|
127
|
+
?hideText=${this.hideText}
|
|
128
|
+
colorCount=${this.colors.length}
|
|
129
|
+
?stabilizeWhileEditing=${this.pluginSettings.stabilizeWhileEditing}
|
|
130
|
+
${g(a)}
|
|
131
|
+
>
|
|
132
|
+
</color-palette-item-edit>
|
|
133
|
+
` : c`
|
|
134
|
+
<color-palette-item
|
|
135
|
+
color=${t}
|
|
136
|
+
alias=${this.aliases?.[e] || ""}
|
|
137
|
+
aliasMode=${this.pluginSettings.aliasMode}
|
|
138
|
+
direction=${this.direction}
|
|
139
|
+
?editMode=${this.editMode}
|
|
140
|
+
height=${this.height}
|
|
141
|
+
?preventHover=${this.preventHover}
|
|
142
|
+
?hideText=${this.hideText}
|
|
143
|
+
colorCount=${this.colors.length}
|
|
144
|
+
${g(s)}
|
|
145
|
+
>
|
|
146
|
+
</color-palette-item>
|
|
276
147
|
`;
|
|
277
|
-
|
|
148
|
+
}
|
|
149
|
+
)}
|
|
278
150
|
`;
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
.colors=${this.colors}
|
|
307
|
-
height=${this.height}
|
|
308
|
-
width=${this.getPaletteWidth()}
|
|
309
|
-
direction=${this.direction}
|
|
310
|
-
id="canvas"
|
|
311
|
-
${ref(canvasRef)}
|
|
312
|
-
>
|
|
313
|
-
</canvas-gradient>
|
|
314
|
-
</tool-tip>
|
|
151
|
+
}
|
|
152
|
+
/** Create a gradient palette. */
|
|
153
|
+
createGradient() {
|
|
154
|
+
let t = P(), e = (s) => {
|
|
155
|
+
s instanceof A && (s.emitter.clear(), s.emitter.on("click", async (a) => await m(a.toUpperCase(), this.pluginSettings.copyFormat)), s.emitter.on("move", (a) => {
|
|
156
|
+
if (!t.value) return;
|
|
157
|
+
let i = t.value;
|
|
158
|
+
i.text = s.getCanvasHex(a.x, a.y).toUpperCase(), i.setClampedPosition(a, this.getBoundingClientRect());
|
|
159
|
+
}));
|
|
160
|
+
};
|
|
161
|
+
return c`
|
|
162
|
+
<tool-tip
|
|
163
|
+
id="tooltip"
|
|
164
|
+
trigger="hover"
|
|
165
|
+
?display=${!this.preventHover}
|
|
166
|
+
${g(t)}
|
|
167
|
+
>
|
|
168
|
+
<canvas-gradient
|
|
169
|
+
.colors=${this.colors}
|
|
170
|
+
height=${this.height}
|
|
171
|
+
width=${this.getPaletteWidth()}
|
|
172
|
+
direction=${this.direction}
|
|
173
|
+
id="canvas"
|
|
174
|
+
${g(e)}
|
|
175
|
+
>
|
|
176
|
+
</canvas-gradient>
|
|
177
|
+
</tool-tip>
|
|
315
178
|
`;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Create invalid palette based on palette status.
|
|
182
|
+
* @param type Palette status type
|
|
183
|
+
*/
|
|
184
|
+
createInvalidPalette(t, e = "") {
|
|
185
|
+
let s = "Invalid palette";
|
|
186
|
+
switch (t) {
|
|
187
|
+
case l.INVALID_COLORS:
|
|
188
|
+
s = "Colors are defined incorrectly";
|
|
189
|
+
break;
|
|
190
|
+
case l.INVALID_SETTINGS:
|
|
191
|
+
s = "Issues parsing settings";
|
|
192
|
+
break;
|
|
193
|
+
case l.INVALID_COLORS_AND_SETTINGS:
|
|
194
|
+
s = "Colors and settings are defined incorrectly";
|
|
195
|
+
break;
|
|
196
|
+
case l.INVALID_GRADIENT:
|
|
197
|
+
s = "Gradients require more than 1 color to display";
|
|
198
|
+
break;
|
|
316
199
|
}
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
let defaultMessage = 'Invalid palette';
|
|
323
|
-
switch (type) {
|
|
324
|
-
case Status.INVALID_COLORS:
|
|
325
|
-
defaultMessage = 'Colors are defined incorrectly';
|
|
326
|
-
break;
|
|
327
|
-
case Status.INVALID_SETTINGS:
|
|
328
|
-
defaultMessage = 'Issues parsing settings';
|
|
329
|
-
break;
|
|
330
|
-
case Status.INVALID_COLORS_AND_SETTINGS:
|
|
331
|
-
defaultMessage = 'Colors and settings are defined incorrectly';
|
|
332
|
-
break;
|
|
333
|
-
case Status.INVALID_GRADIENT:
|
|
334
|
-
defaultMessage = 'Gradients require more than 1 color to display';
|
|
335
|
-
break;
|
|
336
|
-
}
|
|
337
|
-
this.emitter.emit('notice', `Palette:\n${message ? message : defaultMessage}`);
|
|
338
|
-
return html `
|
|
339
|
-
<section id="invalid">
|
|
340
|
-
<span>${type}</span>
|
|
341
|
-
</section>
|
|
200
|
+
return this.emitter.emit("notice", `Palette:
|
|
201
|
+
${e || s}`), c`
|
|
202
|
+
<section id="invalid">
|
|
203
|
+
<span>${t}</span>
|
|
204
|
+
</section>
|
|
342
205
|
`;
|
|
343
|
-
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
r.styles = [L];
|
|
209
|
+
o([
|
|
210
|
+
C("#palette")
|
|
211
|
+
], r.prototype, "palette", 2);
|
|
212
|
+
o([
|
|
213
|
+
n({ type: Boolean })
|
|
214
|
+
], r.prototype, "editMode", 1);
|
|
215
|
+
o([
|
|
216
|
+
n({ type: Array, reflect: !0 })
|
|
217
|
+
], r.prototype, "colors", 2);
|
|
218
|
+
o([
|
|
219
|
+
n({ type: Number, reflect: !0 })
|
|
220
|
+
], r.prototype, "height", 2);
|
|
221
|
+
o([
|
|
222
|
+
n({ type: Number, reflect: !0 })
|
|
223
|
+
], r.prototype, "width", 2);
|
|
224
|
+
o([
|
|
225
|
+
n({ type: String, reflect: !0 })
|
|
226
|
+
], r.prototype, "direction", 2);
|
|
227
|
+
o([
|
|
228
|
+
n({ type: Boolean, reflect: !0 })
|
|
229
|
+
], r.prototype, "gradient", 2);
|
|
230
|
+
o([
|
|
231
|
+
n({ type: Boolean, reflect: !0 })
|
|
232
|
+
], r.prototype, "preventHover", 2);
|
|
233
|
+
o([
|
|
234
|
+
n({ type: Boolean, reflect: !0 })
|
|
235
|
+
], r.prototype, "hideText", 2);
|
|
236
|
+
o([
|
|
237
|
+
n({ type: Boolean, reflect: !0 })
|
|
238
|
+
], r.prototype, "override", 2);
|
|
239
|
+
o([
|
|
240
|
+
n({ type: Array, reflect: !0 })
|
|
241
|
+
], r.prototype, "aliases", 2);
|
|
242
|
+
o([
|
|
243
|
+
n({ type: Number })
|
|
244
|
+
], r.prototype, "maxWidth", 2);
|
|
245
|
+
o([
|
|
246
|
+
$()
|
|
247
|
+
], r.prototype, "status", 2);
|
|
248
|
+
o([
|
|
249
|
+
$()
|
|
250
|
+
], r.prototype, "pulse", 2);
|
|
251
|
+
o([
|
|
252
|
+
n({ type: Object })
|
|
253
|
+
], r.prototype, "pluginSettings", 2);
|
|
254
|
+
r = o([
|
|
255
|
+
x("color-palette")
|
|
256
|
+
], r);
|
|
257
|
+
export {
|
|
258
|
+
r as ColorPalette
|
|
344
259
|
};
|
|
345
|
-
__decorate([
|
|
346
|
-
query('#palette')
|
|
347
|
-
], ColorPalette.prototype, "palette", void 0);
|
|
348
|
-
__decorate([
|
|
349
|
-
property({ type: Boolean })
|
|
350
|
-
], ColorPalette.prototype, "editMode", null);
|
|
351
|
-
__decorate([
|
|
352
|
-
property({ type: Array, reflect: true })
|
|
353
|
-
], ColorPalette.prototype, "colors", void 0);
|
|
354
|
-
__decorate([
|
|
355
|
-
property({ type: Number, reflect: true })
|
|
356
|
-
], ColorPalette.prototype, "height", void 0);
|
|
357
|
-
__decorate([
|
|
358
|
-
property({ type: Number, reflect: true })
|
|
359
|
-
], ColorPalette.prototype, "width", void 0);
|
|
360
|
-
__decorate([
|
|
361
|
-
property({ type: String, reflect: true })
|
|
362
|
-
], ColorPalette.prototype, "direction", void 0);
|
|
363
|
-
__decorate([
|
|
364
|
-
property({ type: Boolean, reflect: true })
|
|
365
|
-
], ColorPalette.prototype, "gradient", void 0);
|
|
366
|
-
__decorate([
|
|
367
|
-
property({ type: Boolean, reflect: true })
|
|
368
|
-
], ColorPalette.prototype, "preventHover", void 0);
|
|
369
|
-
__decorate([
|
|
370
|
-
property({ type: Boolean, reflect: true })
|
|
371
|
-
], ColorPalette.prototype, "hideText", void 0);
|
|
372
|
-
__decorate([
|
|
373
|
-
property({ type: Boolean, reflect: true })
|
|
374
|
-
], ColorPalette.prototype, "override", void 0);
|
|
375
|
-
__decorate([
|
|
376
|
-
property({ type: Array, reflect: true })
|
|
377
|
-
], ColorPalette.prototype, "aliases", void 0);
|
|
378
|
-
__decorate([
|
|
379
|
-
property({ type: Number })
|
|
380
|
-
], ColorPalette.prototype, "maxWidth", void 0);
|
|
381
|
-
__decorate([
|
|
382
|
-
state()
|
|
383
|
-
], ColorPalette.prototype, "status", void 0);
|
|
384
|
-
__decorate([
|
|
385
|
-
state()
|
|
386
|
-
], ColorPalette.prototype, "pulse", void 0);
|
|
387
|
-
__decorate([
|
|
388
|
-
property({ type: Object })
|
|
389
|
-
], ColorPalette.prototype, "pluginSettings", void 0);
|
|
390
|
-
ColorPalette = __decorate([
|
|
391
|
-
customElement('color-palette')
|
|
392
|
-
], ColorPalette);
|
|
393
|
-
export { ColorPalette };
|