@geoffcox/sterling-svelte 1.0.12 → 2.0.1
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/Button.svelte +8 -46
- package/dist/Button.svelte.d.ts +9 -65
- package/dist/Callout.svelte +47 -72
- package/dist/Callout.svelte.d.ts +14 -55
- package/dist/Callout.types.d.ts +11 -0
- package/dist/Checkbox.svelte +12 -48
- package/dist/Checkbox.svelte.d.ts +9 -62
- package/dist/Dialog.svelte +30 -38
- package/dist/Dialog.svelte.d.ts +13 -36
- package/dist/Dropdown.svelte +39 -71
- package/dist/Dropdown.svelte.d.ts +17 -76
- package/dist/Input.svelte +16 -50
- package/dist/Input.svelte.d.ts +12 -74
- package/dist/Label.svelte +55 -161
- package/dist/Label.svelte.d.ts +16 -81
- package/dist/Link.svelte +9 -41
- package/dist/Link.svelte.d.ts +11 -64
- package/dist/List.svelte +35 -85
- package/dist/List.svelte.d.ts +19 -74
- package/dist/List.types.d.ts +3 -11
- package/dist/ListItem.svelte +27 -56
- package/dist/ListItem.svelte.d.ts +12 -66
- package/dist/Menu.svelte +18 -45
- package/dist/Menu.svelte.d.ts +13 -63
- package/dist/MenuBar.svelte +36 -78
- package/dist/MenuBar.svelte.d.ts +12 -57
- package/dist/MenuButton.svelte +56 -85
- package/dist/MenuButton.svelte.d.ts +19 -70
- package/dist/MenuItem.svelte +107 -151
- package/dist/MenuItem.svelte.d.ts +21 -82
- package/dist/MenuItem.types.d.ts +1 -9
- package/dist/MenuSeparator.svelte +9 -7
- package/dist/MenuSeparator.svelte.d.ts +6 -20
- package/dist/Popover.svelte +45 -64
- package/dist/Popover.svelte.d.ts +14 -58
- package/dist/Progress.constants.d.ts +1 -1
- package/dist/Progress.constants.js +1 -1
- package/dist/Progress.svelte +24 -71
- package/dist/Progress.svelte.d.ts +11 -60
- package/dist/Progress.types.d.ts +3 -3
- package/dist/Radio.svelte +19 -92
- package/dist/Radio.svelte.d.ts +11 -63
- package/dist/Select.svelte +55 -94
- package/dist/Select.svelte.d.ts +19 -82
- package/dist/Slider.svelte +41 -98
- package/dist/Slider.svelte.d.ts +18 -65
- package/dist/Switch.svelte +29 -78
- package/dist/Switch.svelte.d.ts +20 -73
- package/dist/Tab.svelte +23 -66
- package/dist/Tab.svelte.d.ts +11 -70
- package/dist/TabList.svelte +50 -76
- package/dist/TabList.svelte.d.ts +17 -69
- package/dist/TabList.types.d.ts +3 -11
- package/dist/TextArea.svelte +17 -59
- package/dist/TextArea.svelte.d.ts +18 -68
- package/dist/Tooltip.svelte +23 -66
- package/dist/Tooltip.svelte.d.ts +9 -69
- package/dist/Tree.svelte +32 -83
- package/dist/Tree.svelte.d.ts +14 -66
- package/dist/Tree.types.d.ts +3 -11
- package/dist/TreeChevron.svelte +10 -49
- package/dist/TreeChevron.svelte.d.ts +8 -52
- package/dist/TreeItem.svelte +105 -159
- package/dist/TreeItem.svelte.d.ts +21 -100
- package/dist/TreeItem.types.d.ts +2 -12
- package/dist/actions/clickOutside.d.ts +1 -0
- package/dist/actions/clickOutside.js +1 -0
- package/dist/actions/extraClass.d.ts +8 -0
- package/dist/actions/extraClass.js +14 -0
- package/dist/index.d.ts +4 -12
- package/dist/index.js +3 -9
- package/package.json +20 -22
- package/dist/Button.constants.d.ts +0 -2
- package/dist/Button.constants.js +0 -2
- package/dist/Button.types.d.ts +0 -6
- package/dist/ColorPicker.constants.d.ts +0 -1
- package/dist/ColorPicker.constants.js +0 -1
- package/dist/ColorPicker.svelte +0 -287
- package/dist/ColorPicker.svelte.d.ts +0 -52
- package/dist/ColorPicker.types.d.ts +0 -4
- package/dist/ColorPicker.types.js +0 -1
- package/dist/HexColorSliders.svelte +0 -103
- package/dist/HexColorSliders.svelte.d.ts +0 -51
- package/dist/HslColorSliders.svelte +0 -128
- package/dist/HslColorSliders.svelte.d.ts +0 -51
- package/dist/Label.types.d.ts +0 -6
- package/dist/Label.types.js +0 -1
- package/dist/MenuItemDisplay.svelte +0 -32
- package/dist/MenuItemDisplay.svelte.d.ts +0 -39
- package/dist/RgbColorSliders.svelte +0 -93
- package/dist/RgbColorSliders.svelte.d.ts +0 -24
- package/dist/TreeItemDisplay.svelte +0 -74
- package/dist/TreeItemDisplay.svelte.d.ts +0 -73
- package/dist/css/Button.base.css +0 -54
- package/dist/css/Button.colorful.css +0 -17
- package/dist/css/Button.css +0 -8
- package/dist/css/Button.disabled.css +0 -22
- package/dist/css/Button.secondary.colorful.css +0 -15
- package/dist/css/Button.secondary.css +0 -11
- package/dist/css/Button.shapes.css +0 -14
- package/dist/css/Button.tool.colorful.css +0 -13
- package/dist/css/Button.tool.css +0 -18
- package/dist/css/Callout.base.css +0 -55
- package/dist/css/Callout.colorful.css +0 -5
- package/dist/css/Callout.css +0 -2
- package/dist/css/Checkbox.base.css +0 -121
- package/dist/css/Checkbox.colorful.css +0 -17
- package/dist/css/Checkbox.css +0 -3
- package/dist/css/Checkbox.disabled.css +0 -28
- package/dist/css/ColorPicker.base.css +0 -23
- package/dist/css/ColorPicker.css +0 -1
- package/dist/css/Dialog.base.css +0 -114
- package/dist/css/Dialog.css +0 -1
- package/dist/css/Dropdown.base.css +0 -105
- package/dist/css/Dropdown.colorful.css +0 -23
- package/dist/css/Dropdown.composed.css +0 -11
- package/dist/css/Dropdown.css +0 -4
- package/dist/css/Dropdown.disabled.css +0 -32
- package/dist/css/HexColorSliders.base.css +0 -87
- package/dist/css/HexColorSliders.css +0 -1
- package/dist/css/HslColorSliders.base.css +0 -105
- package/dist/css/HslColorSliders.css +0 -1
- package/dist/css/Input.base.css +0 -72
- package/dist/css/Input.colorful.css +0 -22
- package/dist/css/Input.composed.css +0 -12
- package/dist/css/Input.css +0 -4
- package/dist/css/Input.disabled.css +0 -24
- package/dist/css/Label.base.css +0 -114
- package/dist/css/Label.boxed.colorful.css +0 -21
- package/dist/css/Label.boxed.css +0 -31
- package/dist/css/Label.colorful.css +0 -3
- package/dist/css/Label.css +0 -5
- package/dist/css/Label.disabled.css +0 -9
- package/dist/css/Link.base.css +0 -43
- package/dist/css/Link.colorful.css +0 -15
- package/dist/css/Link.css +0 -11
- package/dist/css/Link.disabled.css +0 -10
- package/dist/css/Link.ghost.colorful.css +0 -7
- package/dist/css/Link.ghost.css +0 -11
- package/dist/css/Link.text-underline.css +0 -8
- package/dist/css/Link.text-underline.ghost.css +0 -13
- package/dist/css/Link.undecorated.colorful.css +0 -8
- package/dist/css/Link.undecorated.css +0 -8
- package/dist/css/Link.undecorated.ghost.css +0 -8
- package/dist/css/Link.undecorated.underline.css +0 -8
- package/dist/css/List.base.css +0 -84
- package/dist/css/List.composed.css +0 -8
- package/dist/css/List.css +0 -3
- package/dist/css/List.disabled.css +0 -7
- package/dist/css/ListItem.base.css +0 -33
- package/dist/css/ListItem.css +0 -2
- package/dist/css/ListItem.disabled.css +0 -28
- package/dist/css/Menu.base.css +0 -21
- package/dist/css/Menu.css +0 -1
- package/dist/css/MenuBar.base.css +0 -9
- package/dist/css/MenuBar.css +0 -1
- package/dist/css/MenuButton.base.css +0 -13
- package/dist/css/MenuButton.css +0 -1
- package/dist/css/MenuItem.base.css +0 -48
- package/dist/css/MenuItem.css +0 -1
- package/dist/css/MenuItemDisplay.base.css +0 -79
- package/dist/css/MenuItemDisplay.css +0 -2
- package/dist/css/MenuItemDisplay.disabled.css +0 -28
- package/dist/css/MenuSeparator.base.css +0 -5
- package/dist/css/MenuSeparator.css +0 -1
- package/dist/css/Popover.css +0 -21
- package/dist/css/Progress.base.css +0 -85
- package/dist/css/Progress.css +0 -2
- package/dist/css/Progress.disabled.css +0 -17
- package/dist/css/Radio.base.css +0 -109
- package/dist/css/Radio.colorful.css +0 -18
- package/dist/css/Radio.css +0 -3
- package/dist/css/Radio.disabled.css +0 -28
- package/dist/css/RgbColorSliders.base.css +0 -94
- package/dist/css/RgbColorSliders.css +0 -1
- package/dist/css/Select.base.css +0 -101
- package/dist/css/Select.colorful.css +0 -24
- package/dist/css/Select.composed.css +0 -12
- package/dist/css/Select.css +0 -4
- package/dist/css/Select.disabled.css +0 -28
- package/dist/css/Slider.base.css +0 -152
- package/dist/css/Slider.colorful.css +0 -11
- package/dist/css/Slider.composed.css +0 -8
- package/dist/css/Slider.css +0 -4
- package/dist/css/Slider.disabled.css +0 -30
- package/dist/css/Switch.base.css +0 -175
- package/dist/css/Switch.colorful.css +0 -45
- package/dist/css/Switch.css +0 -3
- package/dist/css/Switch.disabled.css +0 -30
- package/dist/css/Tab.base.css +0 -96
- package/dist/css/Tab.colorful.css +0 -13
- package/dist/css/Tab.css +0 -3
- package/dist/css/Tab.disabled.css +0 -36
- package/dist/css/TabList.base.css +0 -34
- package/dist/css/TabList.css +0 -1
- package/dist/css/TextArea.base.css +0 -62
- package/dist/css/TextArea.colorful.css +0 -17
- package/dist/css/TextArea.composed.css +0 -8
- package/dist/css/TextArea.css +0 -4
- package/dist/css/TextArea.disabled.css +0 -28
- package/dist/css/Tooltip.base.css +0 -6
- package/dist/css/Tooltip.css +0 -1
- package/dist/css/Tree.base.css +0 -49
- package/dist/css/Tree.composed.css +0 -8
- package/dist/css/Tree.css +0 -3
- package/dist/css/Tree.disabled.css +0 -27
- package/dist/css/TreeChevron.base.css +0 -86
- package/dist/css/TreeChevron.css +0 -1
- package/dist/css/TreeItem.base.css +0 -3
- package/dist/css/TreeItem.css +0 -1
- package/dist/css/TreeItemDisplay.base.css +0 -48
- package/dist/css/TreeItemDisplay.colorful.css +0 -9
- package/dist/css/TreeItemDisplay.css +0 -3
- package/dist/css/TreeItemDisplay.disabled.css +0 -28
- package/dist/css/dark-mode.css +0 -134
- package/dist/css/light-mode.css +0 -134
- package/dist/css/sterling.css +0 -37
- package/dist/package.json +0 -108
- /package/dist/{Button.types.js → Callout.types.js} +0 -0
package/dist/ColorPicker.svelte
DELETED
|
@@ -1,287 +0,0 @@
|
|
|
1
|
-
<script>import { tick } from 'svelte';
|
|
2
|
-
import { TinyColor } from '@ctrl/tinycolor';
|
|
3
|
-
import Dropdown from './Dropdown.svelte';
|
|
4
|
-
import Input from './Input.svelte';
|
|
5
|
-
import Tab from './Tab.svelte';
|
|
6
|
-
import TabList from './TabList.svelte';
|
|
7
|
-
import RgbColorSliders from './RgbColorSliders.svelte';
|
|
8
|
-
import HslColorSliders from './HslColorSliders.svelte';
|
|
9
|
-
import HexColorSliders from './HexColorSliders.svelte';
|
|
10
|
-
import { round } from 'lodash-es';
|
|
11
|
-
import { trapKeyboardFocus } from './actions/trapKeyboardFocus';
|
|
12
|
-
// ----- Constants ----- //
|
|
13
|
-
const defaultColorText = '#000000';
|
|
14
|
-
// ----- Props ----- //
|
|
15
|
-
/** The color value in HEX, RGB, or HSL format */
|
|
16
|
-
export let colorText = defaultColorText;
|
|
17
|
-
/** The current color format */
|
|
18
|
-
export let colorFormat = 'hex';
|
|
19
|
-
/** When true, the picker is disabled. */
|
|
20
|
-
export let disabled = false;
|
|
21
|
-
/** When true, the dropdown is open. */
|
|
22
|
-
export let open = false;
|
|
23
|
-
/** Additional class names to apply. */
|
|
24
|
-
export let variant = '';
|
|
25
|
-
/** Additional class names to apply to the value input. */
|
|
26
|
-
export let valueVariant = '';
|
|
27
|
-
/** Additional class names to apply to sliders. */
|
|
28
|
-
export let sliderVariant = '';
|
|
29
|
-
// ----- State ----- //
|
|
30
|
-
let hue = 0;
|
|
31
|
-
let saturation = 0;
|
|
32
|
-
let lightness = 0;
|
|
33
|
-
let red = 0;
|
|
34
|
-
let green = 0;
|
|
35
|
-
let blue = 0;
|
|
36
|
-
let alpha = 1;
|
|
37
|
-
let hexAlpha = 255;
|
|
38
|
-
let updating = false;
|
|
39
|
-
let tabListRef;
|
|
40
|
-
let tabsRef;
|
|
41
|
-
// ----- Update HSL, RGB, Text ----- //
|
|
42
|
-
const updateFromRgb = async () => {
|
|
43
|
-
// tinycolor requires window
|
|
44
|
-
if (globalThis.window) {
|
|
45
|
-
if (!updating && (colorFormat === 'hex' || colorFormat === 'rgb')) {
|
|
46
|
-
updating = true;
|
|
47
|
-
const newAlpha = colorFormat === 'hex' ? hexAlpha / 255 : alpha;
|
|
48
|
-
const color = new TinyColor({ r: red, g: green, b: blue, a: newAlpha });
|
|
49
|
-
const hsl = color.toHsl();
|
|
50
|
-
hue = Math.round(hsl.h);
|
|
51
|
-
saturation = Math.round(hsl.s * 100);
|
|
52
|
-
lightness = Math.round(hsl.l * 100);
|
|
53
|
-
switch (colorFormat) {
|
|
54
|
-
case 'rgb':
|
|
55
|
-
colorText = color.toRgbString();
|
|
56
|
-
hexAlpha = Math.round(alpha * 255);
|
|
57
|
-
break;
|
|
58
|
-
case 'hex':
|
|
59
|
-
colorText = alpha === 100 ? color.toHexString() : color.toHex8String();
|
|
60
|
-
alpha = round(hexAlpha / 255, 2);
|
|
61
|
-
break;
|
|
62
|
-
}
|
|
63
|
-
await tick();
|
|
64
|
-
updating = false;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
const updateFromHsl = async () => {
|
|
69
|
-
// tinycolor requires window
|
|
70
|
-
if (globalThis.window) {
|
|
71
|
-
if (!updating && colorFormat === 'hsl') {
|
|
72
|
-
updating = true;
|
|
73
|
-
const color = new TinyColor({ h: hue, s: saturation / 100, l: lightness / 100, a: alpha });
|
|
74
|
-
const rgb = color.toRgb();
|
|
75
|
-
red = rgb.r;
|
|
76
|
-
green = rgb.g;
|
|
77
|
-
blue = rgb.b;
|
|
78
|
-
colorText = color.toHslString();
|
|
79
|
-
hexAlpha = Math.round(alpha * 255);
|
|
80
|
-
await tick();
|
|
81
|
-
updating = false;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
const updateColorsFromText = async () => {
|
|
86
|
-
// tinycolor requires window
|
|
87
|
-
if (globalThis.window) {
|
|
88
|
-
const color = new TinyColor(colorText);
|
|
89
|
-
if (color.isValid) {
|
|
90
|
-
if (!updating) {
|
|
91
|
-
updating = true;
|
|
92
|
-
switch (color.format) {
|
|
93
|
-
case 'hsl':
|
|
94
|
-
colorFormat = 'hsl';
|
|
95
|
-
break;
|
|
96
|
-
case 'rgb':
|
|
97
|
-
colorFormat = 'rgb';
|
|
98
|
-
break;
|
|
99
|
-
case 'hex':
|
|
100
|
-
case 'hex4':
|
|
101
|
-
case 'hex8':
|
|
102
|
-
colorFormat = 'hex';
|
|
103
|
-
break;
|
|
104
|
-
default:
|
|
105
|
-
break;
|
|
106
|
-
}
|
|
107
|
-
const hsl = color.toHsl();
|
|
108
|
-
hue = Math.round(hsl.h);
|
|
109
|
-
saturation = Math.round(hsl.s * 100);
|
|
110
|
-
lightness = Math.round(hsl.l * 100);
|
|
111
|
-
const rgb = color.toRgb();
|
|
112
|
-
red = rgb.r;
|
|
113
|
-
green = rgb.g;
|
|
114
|
-
blue = rgb.b;
|
|
115
|
-
if (rgb.a) {
|
|
116
|
-
alpha = hsl.a;
|
|
117
|
-
hexAlpha = Math.round(alpha * 255);
|
|
118
|
-
}
|
|
119
|
-
await tick();
|
|
120
|
-
updating = false;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
$: {
|
|
126
|
-
globalThis.window;
|
|
127
|
-
colorText;
|
|
128
|
-
updateColorsFromText();
|
|
129
|
-
}
|
|
130
|
-
$: {
|
|
131
|
-
globalThis.window;
|
|
132
|
-
colorFormat;
|
|
133
|
-
hue;
|
|
134
|
-
saturation;
|
|
135
|
-
lightness;
|
|
136
|
-
alpha;
|
|
137
|
-
updateFromHsl();
|
|
138
|
-
}
|
|
139
|
-
$: {
|
|
140
|
-
globalThis.window;
|
|
141
|
-
colorFormat;
|
|
142
|
-
red;
|
|
143
|
-
green;
|
|
144
|
-
blue;
|
|
145
|
-
alpha;
|
|
146
|
-
hexAlpha;
|
|
147
|
-
updateFromRgb();
|
|
148
|
-
}
|
|
149
|
-
// ----- Event handlers ----- //
|
|
150
|
-
const onInputBlur = async () => {
|
|
151
|
-
if (globalThis.window) {
|
|
152
|
-
if (!updating) {
|
|
153
|
-
if (colorText.trim().length === 0) {
|
|
154
|
-
colorText = defaultColorText;
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
const color = new TinyColor(colorText);
|
|
158
|
-
if (color.isValid) {
|
|
159
|
-
updating = true;
|
|
160
|
-
switch (colorFormat) {
|
|
161
|
-
case 'hsl':
|
|
162
|
-
colorText = color.toHslString();
|
|
163
|
-
break;
|
|
164
|
-
case 'rgb':
|
|
165
|
-
colorText = color.toRgbString();
|
|
166
|
-
break;
|
|
167
|
-
case 'hex':
|
|
168
|
-
colorText = alpha === 1 ? color.toHexString() : color.toHex8String();
|
|
169
|
-
break;
|
|
170
|
-
default:
|
|
171
|
-
break;
|
|
172
|
-
}
|
|
173
|
-
await tick();
|
|
174
|
-
updating = false;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
};
|
|
179
|
-
const onInputClick = (event) => {
|
|
180
|
-
event.stopPropagation();
|
|
181
|
-
return false;
|
|
182
|
-
};
|
|
183
|
-
const onInputKeydown = (event) => {
|
|
184
|
-
switch (event.key) {
|
|
185
|
-
case 'Tab':
|
|
186
|
-
if (open) {
|
|
187
|
-
setTimeout(() => {
|
|
188
|
-
tabListRef?.focus();
|
|
189
|
-
}, 0);
|
|
190
|
-
event.preventDefault();
|
|
191
|
-
event.stopPropagation();
|
|
192
|
-
return false;
|
|
193
|
-
}
|
|
194
|
-
break;
|
|
195
|
-
case 'Escape':
|
|
196
|
-
if (open) {
|
|
197
|
-
open = false;
|
|
198
|
-
event.preventDefault();
|
|
199
|
-
event.stopPropagation();
|
|
200
|
-
return false;
|
|
201
|
-
}
|
|
202
|
-
break;
|
|
203
|
-
}
|
|
204
|
-
// prevent typing from bubbling to the dropdown
|
|
205
|
-
event.stopImmediatePropagation();
|
|
206
|
-
};
|
|
207
|
-
// -----Initialization ----- //
|
|
208
|
-
updateColorsFromText();
|
|
209
|
-
</script>
|
|
210
|
-
|
|
211
|
-
<div class={`sterling-color-picker ${variant}`}>
|
|
212
|
-
<Dropdown
|
|
213
|
-
{disabled}
|
|
214
|
-
bind:open
|
|
215
|
-
on:blur
|
|
216
|
-
on:click
|
|
217
|
-
on:copy
|
|
218
|
-
on:cut
|
|
219
|
-
on:dblclick
|
|
220
|
-
on:dragend
|
|
221
|
-
on:dragenter
|
|
222
|
-
on:dragleave
|
|
223
|
-
on:dragover
|
|
224
|
-
on:dragstart
|
|
225
|
-
on:drop
|
|
226
|
-
on:focus
|
|
227
|
-
on:focusin
|
|
228
|
-
on:focusout
|
|
229
|
-
on:keydown
|
|
230
|
-
on:keypress
|
|
231
|
-
on:keyup
|
|
232
|
-
on:mousedown
|
|
233
|
-
on:mouseenter
|
|
234
|
-
on:mouseleave
|
|
235
|
-
on:mousemove
|
|
236
|
-
on:mouseover
|
|
237
|
-
on:mouseout
|
|
238
|
-
on:mouseup
|
|
239
|
-
on:wheel
|
|
240
|
-
on:paste
|
|
241
|
-
{variant}
|
|
242
|
-
{...$$restProps}
|
|
243
|
-
>
|
|
244
|
-
<div class="value" slot="value">
|
|
245
|
-
<div class="color-box" style="background-color: {colorText}" />
|
|
246
|
-
<Input
|
|
247
|
-
bind:value={colorText}
|
|
248
|
-
{disabled}
|
|
249
|
-
on:blur={onInputBlur}
|
|
250
|
-
on:click={onInputClick}
|
|
251
|
-
on:keydown={onInputKeydown}
|
|
252
|
-
spellcheck="false"
|
|
253
|
-
variant={`composed ${valueVariant}`}
|
|
254
|
-
/>
|
|
255
|
-
</div>
|
|
256
|
-
<div class="sterling-color-picker-popup" use:trapKeyboardFocus>
|
|
257
|
-
<div class="tabs" bind:this={tabsRef}>
|
|
258
|
-
<TabList bind:this={tabListRef} bind:selectedValue={colorFormat}>
|
|
259
|
-
<Tab value="hex">hex</Tab>
|
|
260
|
-
<Tab value="rgb">rgb</Tab>
|
|
261
|
-
<Tab value="hsl">hsl</Tab>
|
|
262
|
-
</TabList>
|
|
263
|
-
</div>
|
|
264
|
-
<div class="sliders">
|
|
265
|
-
{#if colorFormat === 'rgb'}
|
|
266
|
-
<RgbColorSliders bind:red bind:green bind:blue bind:alpha variant={sliderVariant} />
|
|
267
|
-
{:else if colorFormat === 'hex'}
|
|
268
|
-
<HexColorSliders
|
|
269
|
-
bind:red
|
|
270
|
-
bind:green
|
|
271
|
-
bind:blue
|
|
272
|
-
bind:alpha={hexAlpha}
|
|
273
|
-
variant={sliderVariant}
|
|
274
|
-
/>
|
|
275
|
-
{:else if colorFormat === 'hsl'}
|
|
276
|
-
<HslColorSliders
|
|
277
|
-
bind:hue
|
|
278
|
-
bind:saturation
|
|
279
|
-
bind:lightness
|
|
280
|
-
bind:alpha
|
|
281
|
-
variant={sliderVariant}
|
|
282
|
-
/>
|
|
283
|
-
{/if}
|
|
284
|
-
</div>
|
|
285
|
-
</div>
|
|
286
|
-
</Dropdown>
|
|
287
|
-
</div>
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
|
2
|
-
declare const __propDef: {
|
|
3
|
-
props: {
|
|
4
|
-
[x: string]: any;
|
|
5
|
-
colorText?: string | undefined;
|
|
6
|
-
colorFormat?: "hex" | "rgb" | "hsl" | undefined;
|
|
7
|
-
disabled?: boolean | undefined;
|
|
8
|
-
open?: boolean | undefined;
|
|
9
|
-
variant?: string | undefined;
|
|
10
|
-
valueVariant?: string | undefined;
|
|
11
|
-
sliderVariant?: string | undefined;
|
|
12
|
-
};
|
|
13
|
-
events: {
|
|
14
|
-
blur: FocusEvent;
|
|
15
|
-
click: MouseEvent;
|
|
16
|
-
copy: ClipboardEvent;
|
|
17
|
-
cut: ClipboardEvent;
|
|
18
|
-
dblclick: MouseEvent;
|
|
19
|
-
dragend: DragEvent;
|
|
20
|
-
dragenter: DragEvent;
|
|
21
|
-
dragleave: DragEvent;
|
|
22
|
-
dragover: DragEvent;
|
|
23
|
-
dragstart: DragEvent;
|
|
24
|
-
drop: DragEvent;
|
|
25
|
-
focus: FocusEvent;
|
|
26
|
-
focusin: FocusEvent;
|
|
27
|
-
focusout: FocusEvent;
|
|
28
|
-
keydown: KeyboardEvent;
|
|
29
|
-
keypress: KeyboardEvent;
|
|
30
|
-
keyup: KeyboardEvent;
|
|
31
|
-
mousedown: MouseEvent;
|
|
32
|
-
mouseenter: MouseEvent;
|
|
33
|
-
mouseleave: MouseEvent;
|
|
34
|
-
mousemove: MouseEvent;
|
|
35
|
-
mouseover: MouseEvent;
|
|
36
|
-
mouseout: MouseEvent;
|
|
37
|
-
mouseup: MouseEvent;
|
|
38
|
-
wheel: WheelEvent;
|
|
39
|
-
paste: ClipboardEvent;
|
|
40
|
-
} & {
|
|
41
|
-
[evt: string]: CustomEvent<any>;
|
|
42
|
-
};
|
|
43
|
-
slots: {};
|
|
44
|
-
exports?: undefined;
|
|
45
|
-
bindings?: undefined;
|
|
46
|
-
};
|
|
47
|
-
export type ColorPickerProps = typeof __propDef.props;
|
|
48
|
-
export type ColorPickerEvents = typeof __propDef.events;
|
|
49
|
-
export type ColorPickerSlots = typeof __propDef.slots;
|
|
50
|
-
export default class ColorPicker extends SvelteComponent<ColorPickerProps, ColorPickerEvents, ColorPickerSlots> {
|
|
51
|
-
}
|
|
52
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
<script>import { createEventDispatcher } from 'svelte';
|
|
2
|
-
import Input from './Input.svelte';
|
|
3
|
-
import Slider from './Slider.svelte';
|
|
4
|
-
// ----- Props ----- //
|
|
5
|
-
/** The red value. */
|
|
6
|
-
export let red = 0;
|
|
7
|
-
/** The green value. */
|
|
8
|
-
export let green = 0;
|
|
9
|
-
/** The blue value. */
|
|
10
|
-
export let blue = 0;
|
|
11
|
-
/** The alpha value. */
|
|
12
|
-
export let alpha = 255;
|
|
13
|
-
/** Additional class names to apply. */
|
|
14
|
-
export let variant = '';
|
|
15
|
-
// ----- State ----- //
|
|
16
|
-
let redText = red.toString(16).padStart(2, '0');
|
|
17
|
-
let greenText = green.toString(16).padStart(2, '0');
|
|
18
|
-
let blueText = blue.toString(16).padStart(2, '0');
|
|
19
|
-
let alphaText = alpha.toString(16).padStart(2, '0');
|
|
20
|
-
$: {
|
|
21
|
-
redText = red.toString(16).padStart(2, '0');
|
|
22
|
-
}
|
|
23
|
-
$: {
|
|
24
|
-
greenText = green.toString(16).padStart(2, '0');
|
|
25
|
-
}
|
|
26
|
-
$: {
|
|
27
|
-
blueText = blue.toString(16).padStart(2, '0');
|
|
28
|
-
}
|
|
29
|
-
$: {
|
|
30
|
-
alphaText = alpha.toString(16).padStart(2, '0');
|
|
31
|
-
}
|
|
32
|
-
// ----- Events ----- //
|
|
33
|
-
const dispatcher = createEventDispatcher();
|
|
34
|
-
const raiseChange = () => {
|
|
35
|
-
dispatcher('change', { red, green, blue, alpha });
|
|
36
|
-
};
|
|
37
|
-
$: red, green, blue, alpha, raiseChange();
|
|
38
|
-
// ----- Event Handlers ----- //
|
|
39
|
-
const onRedInputChange = (event) => {
|
|
40
|
-
const inputChangeEvent = event;
|
|
41
|
-
const text = inputChangeEvent?.currentTarget?.value;
|
|
42
|
-
red = text ? Number.parseInt(text, 16) : red;
|
|
43
|
-
};
|
|
44
|
-
const onGreenInputChange = (event) => {
|
|
45
|
-
const inputChangeEvent = event;
|
|
46
|
-
const text = inputChangeEvent?.currentTarget?.value;
|
|
47
|
-
green = text ? Number.parseInt(text, 16) : green;
|
|
48
|
-
};
|
|
49
|
-
const onBlueInputChange = (event) => {
|
|
50
|
-
const inputChangeEvent = event;
|
|
51
|
-
const text = inputChangeEvent?.currentTarget?.value;
|
|
52
|
-
blue = text ? Number.parseInt(text, 16) : blue;
|
|
53
|
-
};
|
|
54
|
-
const onAlphaInputchange = (event) => {
|
|
55
|
-
const inputChangeEvent = event;
|
|
56
|
-
const text = inputChangeEvent?.currentTarget?.value;
|
|
57
|
-
alpha = text ? Number.parseInt(text, 16) : alpha;
|
|
58
|
-
};
|
|
59
|
-
</script>
|
|
60
|
-
|
|
61
|
-
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
|
62
|
-
<div
|
|
63
|
-
class={`sterling-hex-color-sliders ${variant}`}
|
|
64
|
-
on:blur
|
|
65
|
-
on:click
|
|
66
|
-
on:copy
|
|
67
|
-
on:cut
|
|
68
|
-
on:dblclick
|
|
69
|
-
on:dragend
|
|
70
|
-
on:dragenter
|
|
71
|
-
on:dragleave
|
|
72
|
-
on:dragover
|
|
73
|
-
on:dragstart
|
|
74
|
-
on:drop
|
|
75
|
-
on:focus
|
|
76
|
-
on:focusin
|
|
77
|
-
on:focusout
|
|
78
|
-
on:keydown
|
|
79
|
-
on:keypress
|
|
80
|
-
on:keyup
|
|
81
|
-
on:mousedown
|
|
82
|
-
on:mouseenter
|
|
83
|
-
on:mouseleave
|
|
84
|
-
on:mousemove
|
|
85
|
-
on:mouseover
|
|
86
|
-
on:mouseout
|
|
87
|
-
on:mouseup
|
|
88
|
-
on:wheel
|
|
89
|
-
on:paste
|
|
90
|
-
{...$$restProps}
|
|
91
|
-
style={`--red:${red};--green:${green};--blue:${blue}`}
|
|
92
|
-
>
|
|
93
|
-
<Slider min={0} max={255} precision={0} bind:value={red} variant="red" />
|
|
94
|
-
<Input bind:value={redText} variant="red" on:change={(e) => onRedInputChange(e)} />
|
|
95
|
-
<Slider min={0} max={255} precision={0} bind:value={green} variant="green" />
|
|
96
|
-
<Input bind:value={greenText} variant="green" on:change={(e) => onGreenInputChange(e)} />
|
|
97
|
-
<Slider min={0} max={255} precision={0} bind:value={blue} variant="blue" />
|
|
98
|
-
<Input bind:value={blueText} variant="blue" on:change={(e) => onBlueInputChange(e)} />
|
|
99
|
-
<div class="alpha-hatch" />
|
|
100
|
-
<div class="alpha-gradient" />
|
|
101
|
-
<Slider min={0} max={255} precision={0} bind:value={alpha} variant="alpha" />
|
|
102
|
-
<Input bind:value={alphaText} variant="alpha" on:change={(e) => onAlphaInputchange(e)} />
|
|
103
|
-
</div>
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
|
2
|
-
declare const __propDef: {
|
|
3
|
-
props: {
|
|
4
|
-
[x: string]: any;
|
|
5
|
-
red?: number | undefined;
|
|
6
|
-
green?: number | undefined;
|
|
7
|
-
blue?: number | undefined;
|
|
8
|
-
alpha?: number | undefined;
|
|
9
|
-
variant?: string | undefined;
|
|
10
|
-
};
|
|
11
|
-
events: {
|
|
12
|
-
blur: FocusEvent;
|
|
13
|
-
click: MouseEvent;
|
|
14
|
-
copy: ClipboardEvent;
|
|
15
|
-
cut: ClipboardEvent;
|
|
16
|
-
dblclick: MouseEvent;
|
|
17
|
-
dragend: DragEvent;
|
|
18
|
-
dragenter: DragEvent;
|
|
19
|
-
dragleave: DragEvent;
|
|
20
|
-
dragover: DragEvent;
|
|
21
|
-
dragstart: DragEvent;
|
|
22
|
-
drop: DragEvent;
|
|
23
|
-
focus: FocusEvent;
|
|
24
|
-
focusin: FocusEvent;
|
|
25
|
-
focusout: FocusEvent;
|
|
26
|
-
keydown: KeyboardEvent;
|
|
27
|
-
keypress: KeyboardEvent;
|
|
28
|
-
keyup: KeyboardEvent;
|
|
29
|
-
mousedown: MouseEvent;
|
|
30
|
-
mouseenter: MouseEvent;
|
|
31
|
-
mouseleave: MouseEvent;
|
|
32
|
-
mousemove: MouseEvent;
|
|
33
|
-
mouseover: MouseEvent;
|
|
34
|
-
mouseout: MouseEvent;
|
|
35
|
-
mouseup: MouseEvent;
|
|
36
|
-
wheel: WheelEvent;
|
|
37
|
-
paste: ClipboardEvent;
|
|
38
|
-
change: CustomEvent<any>;
|
|
39
|
-
} & {
|
|
40
|
-
[evt: string]: CustomEvent<any>;
|
|
41
|
-
};
|
|
42
|
-
slots: {};
|
|
43
|
-
exports?: undefined;
|
|
44
|
-
bindings?: undefined;
|
|
45
|
-
};
|
|
46
|
-
export type HexColorSlidersProps = typeof __propDef.props;
|
|
47
|
-
export type HexColorSlidersEvents = typeof __propDef.events;
|
|
48
|
-
export type HexColorSlidersSlots = typeof __propDef.slots;
|
|
49
|
-
export default class HexColorSliders extends SvelteComponent<HexColorSlidersProps, HexColorSlidersEvents, HexColorSlidersSlots> {
|
|
50
|
-
}
|
|
51
|
-
export {};
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
<script>import { createEventDispatcher } from 'svelte';
|
|
2
|
-
import Input from './Input.svelte';
|
|
3
|
-
import Slider from './Slider.svelte';
|
|
4
|
-
import { round } from 'lodash-es';
|
|
5
|
-
// ----- Props ----- //
|
|
6
|
-
/** The hue value. */
|
|
7
|
-
export let hue = 0;
|
|
8
|
-
/** The saturation value. */
|
|
9
|
-
export let saturation = 0;
|
|
10
|
-
/** The lightness value. */
|
|
11
|
-
export let lightness = 0;
|
|
12
|
-
/** The alpha value. */
|
|
13
|
-
export let alpha = 1;
|
|
14
|
-
/** Additional class names to apply. */
|
|
15
|
-
export let variant = '';
|
|
16
|
-
// ----- State ----- //
|
|
17
|
-
let hueText = hue.toString();
|
|
18
|
-
let saturationText = saturation.toString();
|
|
19
|
-
let lightnessText = lightness.toString();
|
|
20
|
-
let alphaText = alpha.toString();
|
|
21
|
-
$: {
|
|
22
|
-
hueText = hue.toString();
|
|
23
|
-
}
|
|
24
|
-
$: {
|
|
25
|
-
saturationText = saturation.toString();
|
|
26
|
-
}
|
|
27
|
-
$: {
|
|
28
|
-
lightnessText = lightness.toString();
|
|
29
|
-
}
|
|
30
|
-
$: {
|
|
31
|
-
alphaText = alpha.toString();
|
|
32
|
-
}
|
|
33
|
-
// ----- Events ----- //
|
|
34
|
-
const dispatcher = createEventDispatcher();
|
|
35
|
-
const raiseChange = (hue, saturation, lightness) => {
|
|
36
|
-
dispatcher('change', { hue, saturation, lightness });
|
|
37
|
-
};
|
|
38
|
-
$: raiseChange(hue, saturation, lightness);
|
|
39
|
-
// ----- Event Handlers ----- //
|
|
40
|
-
const onHueInputChange = (event) => {
|
|
41
|
-
const inputChangeEvent = event;
|
|
42
|
-
const text = inputChangeEvent?.currentTarget?.value;
|
|
43
|
-
const newValue = text ? Number.parseFloat(text) : hue;
|
|
44
|
-
if (newValue && newValue !== Number.NaN) {
|
|
45
|
-
hue = Math.round(Math.max(0, Math.min(360, newValue)));
|
|
46
|
-
hueText = hue.toString();
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
const onSaturationInputChange = (event) => {
|
|
50
|
-
const inputChangeEvent = event;
|
|
51
|
-
const text = inputChangeEvent?.currentTarget?.value?.replace(/%/g, '');
|
|
52
|
-
const newValue = text ? Number.parseFloat(text) : saturation;
|
|
53
|
-
if (newValue && newValue !== Number.NaN) {
|
|
54
|
-
saturation = Math.round(Math.max(0, Math.min(100, newValue)));
|
|
55
|
-
saturationText = saturation.toString();
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
const onLightnessInputChange = (event) => {
|
|
59
|
-
const inputChangeEvent = event;
|
|
60
|
-
const text = inputChangeEvent?.currentTarget?.value?.replace(/%/g, '');
|
|
61
|
-
const newValue = text ? Number.parseFloat(text) : lightness;
|
|
62
|
-
if (newValue && newValue !== Number.NaN) {
|
|
63
|
-
lightness = Math.round(Math.max(0, Math.min(100, newValue)));
|
|
64
|
-
lightnessText = lightness.toString();
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
const onAlphaInputchange = (event) => {
|
|
68
|
-
const inputChangeEvent = event;
|
|
69
|
-
const text = inputChangeEvent?.currentTarget?.value;
|
|
70
|
-
const newValue = text ? Number.parseFloat(text) : alpha;
|
|
71
|
-
if (newValue && newValue !== Number.NaN) {
|
|
72
|
-
alpha = round(Math.max(0, Math.min(1, newValue)), 2);
|
|
73
|
-
alphaText = alpha.toString();
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
</script>
|
|
77
|
-
|
|
78
|
-
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
|
79
|
-
<div
|
|
80
|
-
class={`sterling-hsl-color-sliders ${variant}`}
|
|
81
|
-
on:blur
|
|
82
|
-
on:click
|
|
83
|
-
on:copy
|
|
84
|
-
on:cut
|
|
85
|
-
on:dblclick
|
|
86
|
-
on:dragend
|
|
87
|
-
on:dragenter
|
|
88
|
-
on:dragleave
|
|
89
|
-
on:dragover
|
|
90
|
-
on:dragstart
|
|
91
|
-
on:drop
|
|
92
|
-
on:focus
|
|
93
|
-
on:focusin
|
|
94
|
-
on:focusout
|
|
95
|
-
on:keydown
|
|
96
|
-
on:keypress
|
|
97
|
-
on:keyup
|
|
98
|
-
on:mousedown
|
|
99
|
-
on:mouseenter
|
|
100
|
-
on:mouseleave
|
|
101
|
-
on:mousemove
|
|
102
|
-
on:mouseover
|
|
103
|
-
on:mouseout
|
|
104
|
-
on:mouseup
|
|
105
|
-
on:wheel
|
|
106
|
-
on:paste
|
|
107
|
-
{...$$restProps}
|
|
108
|
-
style={`--hue:${hue};--saturation:${saturation}%;--lightness:${lightness}%`}
|
|
109
|
-
>
|
|
110
|
-
<Slider min={0} max={360} precision={0} bind:value={hue} variant="hue" />
|
|
111
|
-
<Input bind:value={hueText} variant="hue" on:change={(e) => onHueInputChange(e)} />
|
|
112
|
-
<Slider min={0} max={100} precision={0} bind:value={saturation} variant="saturation" />
|
|
113
|
-
<Input
|
|
114
|
-
bind:value={saturationText}
|
|
115
|
-
variant="saturation"
|
|
116
|
-
on:change={(e) => onSaturationInputChange(e)}
|
|
117
|
-
/>
|
|
118
|
-
<Slider min={0} max={100} precision={0} bind:value={lightness} variant="lightness" />
|
|
119
|
-
<Input
|
|
120
|
-
bind:value={lightnessText}
|
|
121
|
-
variant="lightness"
|
|
122
|
-
on:change={(e) => onLightnessInputChange(e)}
|
|
123
|
-
/>
|
|
124
|
-
<div class="alpha-hatch" />
|
|
125
|
-
<div class="alpha-gradient" />
|
|
126
|
-
<Slider min={0} max={1} precision={2} step={0.01} bind:value={alpha} variant="alpha" />
|
|
127
|
-
<Input bind:value={alphaText} variant="alpha" on:change={(e) => onAlphaInputchange(e)} />
|
|
128
|
-
</div>
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
|
2
|
-
declare const __propDef: {
|
|
3
|
-
props: {
|
|
4
|
-
[x: string]: any;
|
|
5
|
-
hue?: number | undefined;
|
|
6
|
-
saturation?: number | undefined;
|
|
7
|
-
lightness?: number | undefined;
|
|
8
|
-
alpha?: number | undefined;
|
|
9
|
-
variant?: string | undefined;
|
|
10
|
-
};
|
|
11
|
-
events: {
|
|
12
|
-
blur: FocusEvent;
|
|
13
|
-
click: MouseEvent;
|
|
14
|
-
copy: ClipboardEvent;
|
|
15
|
-
cut: ClipboardEvent;
|
|
16
|
-
dblclick: MouseEvent;
|
|
17
|
-
dragend: DragEvent;
|
|
18
|
-
dragenter: DragEvent;
|
|
19
|
-
dragleave: DragEvent;
|
|
20
|
-
dragover: DragEvent;
|
|
21
|
-
dragstart: DragEvent;
|
|
22
|
-
drop: DragEvent;
|
|
23
|
-
focus: FocusEvent;
|
|
24
|
-
focusin: FocusEvent;
|
|
25
|
-
focusout: FocusEvent;
|
|
26
|
-
keydown: KeyboardEvent;
|
|
27
|
-
keypress: KeyboardEvent;
|
|
28
|
-
keyup: KeyboardEvent;
|
|
29
|
-
mousedown: MouseEvent;
|
|
30
|
-
mouseenter: MouseEvent;
|
|
31
|
-
mouseleave: MouseEvent;
|
|
32
|
-
mousemove: MouseEvent;
|
|
33
|
-
mouseover: MouseEvent;
|
|
34
|
-
mouseout: MouseEvent;
|
|
35
|
-
mouseup: MouseEvent;
|
|
36
|
-
wheel: WheelEvent;
|
|
37
|
-
paste: ClipboardEvent;
|
|
38
|
-
change: CustomEvent<any>;
|
|
39
|
-
} & {
|
|
40
|
-
[evt: string]: CustomEvent<any>;
|
|
41
|
-
};
|
|
42
|
-
slots: {};
|
|
43
|
-
exports?: undefined;
|
|
44
|
-
bindings?: undefined;
|
|
45
|
-
};
|
|
46
|
-
export type HslColorSlidersProps = typeof __propDef.props;
|
|
47
|
-
export type HslColorSlidersEvents = typeof __propDef.events;
|
|
48
|
-
export type HslColorSlidersSlots = typeof __propDef.slots;
|
|
49
|
-
export default class HslColorSliders extends SvelteComponent<HslColorSlidersProps, HslColorSlidersEvents, HslColorSlidersSlots> {
|
|
50
|
-
}
|
|
51
|
-
export {};
|
package/dist/Label.types.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { LABEL_STATUSES, LABEL_VARIANTS } from './Label.constants';
|
|
2
|
-
type LabelStatusTuple = typeof LABEL_STATUSES;
|
|
3
|
-
export type LabelStatus = LabelStatusTuple[number];
|
|
4
|
-
type LabelVariantTuple = typeof LABEL_VARIANTS;
|
|
5
|
-
export type LabelVariant = LabelVariantTuple[number];
|
|
6
|
-
export {};
|
package/dist/Label.types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|