@alegendstale/holly-components 0.2.9 → 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.
- package/dist/components/absolute-container/absolute-container.js +113 -91
- package/dist/components/absolute-container/absolute-container.stories.js +36 -0
- package/dist/components/absolute-container/index.js +1 -1
- package/dist/components/bottom-sheet/bottom-sheet.js +415 -308
- package/dist/components/bottom-sheet/bottom-sheet.stories.js +43 -0
- package/dist/components/bottom-sheet/bottom-sheet.test.js +15 -0
- package/dist/components/bottom-sheet/index.js +1 -1
- package/dist/components/canvas/canvas-base.d.ts +2 -1
- package/dist/components/canvas/canvas-base.d.ts.map +1 -1
- package/dist/components/canvas/canvas-base.js +56 -44
- package/dist/components/canvas/canvas-gradient.js +61 -45
- package/dist/components/canvas/canvas-image.js +158 -111
- package/dist/components/canvas/index.js +2 -2
- package/dist/components/carousel-scroller/carousel-scroller.js +133 -121
- package/dist/components/carousel-scroller/carousel-scroller.stories.js +40 -0
- package/dist/components/carousel-scroller/index.js +1 -1
- package/dist/components/color-palette/color-palette-utils.js +105 -41
- package/dist/components/color-palette/color-palette.js +429 -337
- package/dist/components/color-palette/component/color-palette-component.js +184 -142
- package/dist/components/color-palette/component/color-palette-component.stories.js +74 -0
- package/dist/components/color-palette/component/index.js +1 -0
- package/dist/components/color-palette/editor/color-palette-editor.js +702 -591
- package/dist/components/color-palette/editor/color-palette-editor.stories.js +39 -0
- package/dist/components/color-palette/editor/index.js +1 -0
- package/dist/components/color-palette/index.js +5 -7
- package/dist/components/color-palette/item/color-palette-item-edit.js +114 -87
- package/dist/components/color-palette/item/color-palette-item.js +155 -140
- package/dist/components/color-palette/item/index.js +2 -0
- package/dist/components/color-palette/menu/color-palette-menu.js +241 -217
- package/dist/components/color-palette/menu/color-palette-reorder.js +117 -103
- package/dist/components/color-palette/menu/index.js +2 -0
- package/dist/components/color-palette/storybook/color-palette-invalid.stories.js +90 -0
- package/dist/components/color-palette/storybook/color-palette-valid.stories.js +295 -0
- package/dist/components/color-palette/storybook/color-palette.stories.js +76 -0
- package/dist/components/tool-tip/Tooltip2.js +103 -0
- package/dist/components/tool-tip/index.js +1 -1
- package/dist/components/tool-tip/tool-tip.d.ts +1 -0
- package/dist/components/tool-tip/tool-tip.d.ts.map +1 -1
- package/dist/components/tool-tip/tool-tip.js +125 -102
- package/dist/components/tool-tip/tool-tip.stories.js +30 -0
- package/dist/index.js +6 -14
- package/dist/utils/EventEmitter.js +23 -23
- package/dist/utils/basicUtils.js +149 -32
- package/dist/utils/dragDropUtils.js +121 -0
- package/dist/utils/generateUtils.js +73 -39
- package/dist/utils/types.d.ts +1 -1
- package/dist/utils/types.d.ts.map +1 -1
- package/dist/utils/types.js +1 -0
- package/package.json +1 -1
- package/dist/_virtual/_commonjsHelpers.js +0 -8
- package/dist/_virtual/x11.js +0 -4
- package/dist/node_modules/colorsea/colors/x11.js +0 -14
|
@@ -1,346 +1,438 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
|
|
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
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
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
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
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
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
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
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
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
|
-
|
|
208
|
-
|
|
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
|
-
|
|
300
|
-
|
|
301
|
-
],
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
],
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
],
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
],
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
],
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
],
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
],
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
],
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
],
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
],
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
],
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
],
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
],
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
],
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
],
|
|
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 };
|