@alegendstale/holly-components 0.2.8 → 0.2.10

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