@geoffcox/sterling-svelte 0.0.31 → 1.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/@types/clickOutside.d.ts +11 -7
- package/Button.svelte +11 -183
- package/Button.svelte.d.ts +2 -6
- package/Callout.svelte +107 -146
- package/Callout.svelte.d.ts +1 -1
- package/Checkbox.svelte +15 -177
- package/Checkbox.svelte.d.ts +2 -2
- package/ColorPicker.svelte +204 -223
- package/ColorPicker.svelte.d.ts +1 -2
- package/Dialog.svelte +90 -187
- package/Dialog.svelte.d.ts +2 -1
- package/Dropdown.svelte +52 -220
- package/Dropdown.svelte.d.ts +4 -8
- package/HexColorSliders.svelte +77 -145
- package/HexColorSliders.svelte.d.ts +28 -1
- package/HslColorSliders.svelte +99 -179
- package/HslColorSliders.svelte.d.ts +28 -1
- package/Input.svelte +27 -136
- package/Input.svelte.d.ts +2 -3
- package/Label.constants.d.ts +1 -0
- package/Label.constants.js +1 -0
- package/Label.svelte +96 -169
- package/Label.svelte.d.ts +6 -1
- package/Label.types.d.ts +3 -1
- package/Link.svelte +9 -106
- package/Link.svelte.d.ts +0 -1
- package/List.svelte +142 -230
- package/List.svelte.d.ts +2 -3
- package/List.types.d.ts +6 -1
- package/ListItem.svelte +25 -94
- package/ListItem.svelte.d.ts +2 -0
- package/Menu.svelte +48 -65
- package/Menu.svelte.d.ts +4 -1
- package/MenuBar.svelte +84 -86
- package/MenuBar.svelte.d.ts +4 -1
- package/MenuButton.svelte +66 -73
- package/MenuButton.svelte.d.ts +7 -3
- package/MenuItem.svelte +256 -288
- package/MenuItem.svelte.d.ts +2 -2
- package/MenuItemDisplay.svelte +12 -116
- package/MenuItemDisplay.svelte.d.ts +21 -7
- package/MenuSeparator.svelte +6 -45
- package/MenuSeparator.svelte.d.ts +8 -78
- package/Popover.constants.d.ts +1 -1
- package/Popover.constants.js +1 -1
- package/Popover.svelte +66 -80
- package/Popover.svelte.d.ts +5 -1
- package/Progress.svelte +28 -126
- package/Progress.svelte.d.ts +4 -3
- package/Radio.svelte +49 -192
- package/Radio.svelte.d.ts +2 -2
- package/RgbColorSliders.svelte +48 -137
- package/RgbColorSliders.svelte.d.ts +5 -5
- package/Select.svelte +122 -250
- package/Select.svelte.d.ts +6 -2
- package/Slider.svelte +90 -259
- package/Slider.svelte.d.ts +1 -2
- package/Switch.svelte +24 -259
- package/Switch.svelte.d.ts +3 -1
- package/Tab.svelte +27 -175
- package/Tab.svelte.d.ts +6 -4
- package/TabList.svelte +146 -171
- package/TabList.svelte.d.ts +3 -2
- package/TabList.types.d.ts +6 -1
- package/TextArea.svelte +32 -129
- package/TextArea.svelte.d.ts +1 -1
- package/Tooltip.svelte +46 -47
- package/Tooltip.svelte.d.ts +8 -3
- package/Tree.constants.d.ts +0 -1
- package/Tree.constants.js +0 -1
- package/Tree.svelte +35 -119
- package/Tree.svelte.d.ts +4 -4
- package/Tree.types.d.ts +1 -3
- package/TreeChevron.svelte +18 -98
- package/TreeChevron.svelte.d.ts +1 -0
- package/TreeItem.constants.d.ts +1 -0
- package/TreeItem.constants.js +1 -0
- package/TreeItem.svelte +251 -211
- package/TreeItem.svelte.d.ts +7 -3
- package/TreeItem.types.d.ts +1 -1
- package/TreeItemDisplay.svelte +20 -104
- package/TreeItemDisplay.svelte.d.ts +2 -2
- package/actions/applyLightDarkMode.d.ts +10 -0
- package/actions/applyLightDarkMode.js +36 -0
- package/actions/forwardEvents.js +3 -3
- package/css/Button.base.css +74 -0
- package/css/Button.colorful.css +17 -0
- package/css/Button.css +7 -0
- package/css/Button.secondary.colorful.css +15 -0
- package/css/Button.secondary.css +11 -0
- package/css/Button.shapes.css +14 -0
- package/css/Button.tool.colorful.css +13 -0
- package/css/Button.tool.css +18 -0
- package/css/Callout.base.css +43 -0
- package/css/Callout.colorful.css +5 -0
- package/css/Callout.css +2 -0
- package/css/Checkbox.base.css +145 -0
- package/css/Checkbox.colorful.css +17 -0
- package/css/Checkbox.css +2 -0
- package/css/ColorPicker.base.css +23 -0
- package/css/ColorPicker.css +1 -0
- package/css/Dialog.base.css +116 -0
- package/css/Dialog.css +1 -0
- package/css/Dropdown.base.css +147 -0
- package/css/Dropdown.colorful.css +23 -0
- package/css/Dropdown.css +2 -0
- package/css/HexColorSliders.base.css +106 -0
- package/css/HexColorSliders.css +1 -0
- package/css/HslColorSliders.base.css +124 -0
- package/css/HslColorSliders.css +1 -0
- package/css/Input.base.css +100 -0
- package/css/Input.colorful.css +22 -0
- package/css/Input.composed.css +8 -0
- package/css/Input.css +3 -0
- package/css/Label.base.css +119 -0
- package/css/Label.boxed.colorful.css +21 -0
- package/css/Label.boxed.css +31 -0
- package/css/Label.colorful.css +3 -0
- package/css/Label.css +4 -0
- package/css/Link.base.css +52 -0
- package/css/Link.colorful.css +15 -0
- package/css/Link.css +6 -0
- package/css/Link.ghost.colorful.css +7 -0
- package/css/Link.ghost.css +11 -0
- package/css/Link.undecorated.colorful.css +6 -0
- package/css/Link.undecorated.css +6 -0
- package/css/List.base.css +98 -0
- package/css/List.css +1 -0
- package/css/ListItem.base.css +59 -0
- package/css/ListItem.css +1 -0
- package/css/Menu.base.css +21 -0
- package/css/Menu.css +1 -0
- package/css/MenuBar.base.css +9 -0
- package/css/MenuBar.css +1 -0
- package/css/MenuButton.base.css +13 -0
- package/css/MenuButton.css +1 -0
- package/css/MenuItem.base.css +48 -0
- package/css/MenuItem.css +1 -0
- package/css/MenuItemDisplay.base.css +104 -0
- package/css/MenuItemDisplay.css +1 -0
- package/css/MenuSeparator.base.css +5 -0
- package/css/MenuSeparator.css +1 -0
- package/css/Popover copy.css +21 -0
- package/css/Popover.css +21 -0
- package/css/Progress.base.css +99 -0
- package/css/Progress.css +1 -0
- package/css/Radio.base.css +135 -0
- package/css/Radio.colorful.css +18 -0
- package/css/Radio.css +2 -0
- package/css/RgbColorSliders.base.css +94 -0
- package/css/RgbColorSliders.css +1 -0
- package/css/Select.base.css +127 -0
- package/css/Select.colorful.css +24 -0
- package/css/Select.composed.css +12 -0
- package/css/Select.css +3 -0
- package/css/Slider.base.css +182 -0
- package/css/Slider.colorful.css +11 -0
- package/css/Slider.composed.css +8 -0
- package/css/Slider.css +3 -0
- package/css/Switch.base.css +193 -0
- package/css/Switch.colorful.css +39 -0
- package/css/Switch.css +2 -0
- package/css/Tab.base.css +135 -0
- package/css/Tab.colorful.css +13 -0
- package/css/Tab.css +2 -0
- package/css/TabList.base.css +34 -0
- package/css/TabList.css +1 -0
- package/css/TextArea.base.css +85 -0
- package/css/TextArea.colorful.css +17 -0
- package/css/TextArea.composed.css +8 -0
- package/css/TextArea.css +3 -0
- package/css/Tooltip.base.css +6 -0
- package/css/Tooltip.css +1 -0
- package/css/Tree.base.css +74 -0
- package/css/Tree.composed.css +8 -0
- package/css/Tree.css +2 -0
- package/css/TreeChevron.base.css +86 -0
- package/css/TreeChevron.css +1 -0
- package/css/TreeItem.base.css +3 -0
- package/css/TreeItem.css +1 -0
- package/css/TreeItemDisplay.base.css +74 -0
- package/css/TreeItemDisplay.colorful.css +9 -0
- package/css/TreeItemDisplay.css +1 -0
- package/css/dark-mode.css +134 -0
- package/css/light-mode.css +134 -0
- package/css/sterling.css +37 -0
- package/index.d.ts +9 -13
- package/index.js +8 -12
- package/mediaQueries/prefersColorSchemeDark.d.ts +2 -0
- package/mediaQueries/prefersColorSchemeDark.js +10 -0
- package/{stores → mediaQueries}/prefersReducedMotion.d.ts +1 -0
- package/{stores → mediaQueries}/usingKeyboard.d.ts +1 -0
- package/package.json +121 -13
- package/Link.constants.d.ts +0 -1
- package/Link.constants.js +0 -1
- package/Link.types.d.ts +0 -4
- package/Link.types.js +0 -1
- package/theme/applyDarkTheme.d.ts +0 -7
- package/theme/applyDarkTheme.js +0 -11
- package/theme/applyLightTheme.d.ts +0 -7
- package/theme/applyLightTheme.js +0 -11
- package/theme/applyTheme.d.ts +0 -7
- package/theme/applyTheme.js +0 -20
- package/theme/colors.d.ts +0 -54
- package/theme/colors.js +0 -82
- package/theme/darkTheme.d.ts +0 -2
- package/theme/darkTheme.js +0 -142
- package/theme/lightTheme.d.ts +0 -2
- package/theme/lightTheme.js +0 -119
- package/theme/toggleDarkTheme.d.ts +0 -18
- package/theme/toggleDarkTheme.js +0 -53
- package/theme/types.d.ts +0 -21
- package/theme/types.js +0 -1
- /package/{stores → mediaQueries}/prefersReducedMotion.js +0 -0
- /package/{stores → mediaQueries}/usingKeyboard.js +0 -0
package/ColorPicker.svelte
CHANGED
|
@@ -1,21 +1,28 @@
|
|
|
1
|
-
<script>import { tick } from
|
|
2
|
-
import tinycolor from
|
|
3
|
-
import Dropdown from
|
|
4
|
-
import Input from
|
|
5
|
-
import Tab from
|
|
6
|
-
import TabList from
|
|
7
|
-
import RgbColorSliders from
|
|
8
|
-
import HslColorSliders from
|
|
9
|
-
import HexColorSliders from
|
|
10
|
-
import { round } from
|
|
11
|
-
import { trapKeyboardFocus } from
|
|
12
|
-
|
|
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 */
|
|
13
16
|
export let colorText = defaultColorText;
|
|
14
|
-
|
|
15
|
-
export let
|
|
16
|
-
|
|
17
|
+
/** The current color format */
|
|
18
|
+
export let colorFormat = 'hex';
|
|
19
|
+
/** When true, the picker is disabled. */
|
|
17
20
|
export let disabled = false;
|
|
21
|
+
/** When true, the dropdown is open. */
|
|
18
22
|
export let open = false;
|
|
23
|
+
/** Additional class names to apply. */
|
|
24
|
+
export let variant = '';
|
|
25
|
+
// ----- State ----- //
|
|
19
26
|
let hue = 0;
|
|
20
27
|
let saturation = 0;
|
|
21
28
|
let lightness = 0;
|
|
@@ -27,231 +34,205 @@ let hexAlpha = 255;
|
|
|
27
34
|
let updating = false;
|
|
28
35
|
let tabListRef;
|
|
29
36
|
let tabsRef;
|
|
37
|
+
// ----- Update HSL, RGB, Text ----- //
|
|
30
38
|
const updateFromRgb = async () => {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
39
|
+
if (!updating && (colorFormat === 'hex' || colorFormat === 'rgb')) {
|
|
40
|
+
updating = true;
|
|
41
|
+
const newAlpha = colorFormat === 'hex' ? hexAlpha / 255 : alpha;
|
|
42
|
+
const color = tinycolor({ r: red, g: green, b: blue, a: newAlpha });
|
|
43
|
+
const hsl = color.toHsl();
|
|
44
|
+
hue = Math.round(hsl.h);
|
|
45
|
+
saturation = Math.round(hsl.s * 100);
|
|
46
|
+
lightness = Math.round(hsl.l * 100);
|
|
47
|
+
switch (colorFormat) {
|
|
48
|
+
case 'rgb':
|
|
49
|
+
colorText = color.toRgbString();
|
|
50
|
+
hexAlpha = Math.round(alpha * 255);
|
|
51
|
+
break;
|
|
52
|
+
case 'hex':
|
|
53
|
+
colorText = alpha === 100 ? color.toHexString() : color.toHex8String();
|
|
54
|
+
alpha = round(hexAlpha / 255, 2);
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
await tick();
|
|
58
|
+
updating = false;
|
|
48
59
|
}
|
|
49
|
-
await tick();
|
|
50
|
-
updating = false;
|
|
51
|
-
}
|
|
52
60
|
};
|
|
53
61
|
const updateFromHsl = async () => {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
hexAlpha = Math.round(alpha * 255);
|
|
63
|
-
await tick();
|
|
64
|
-
updating = false;
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
const updateColorsFromText = async () => {
|
|
68
|
-
const color = tinycolor(colorText);
|
|
69
|
-
if (color.isValid) {
|
|
70
|
-
if (!updating) {
|
|
71
|
-
updating = true;
|
|
72
|
-
switch (color.format) {
|
|
73
|
-
case "hsl":
|
|
74
|
-
colorFormat = "hsl";
|
|
75
|
-
break;
|
|
76
|
-
case "rgb":
|
|
77
|
-
colorFormat = "rgb";
|
|
78
|
-
break;
|
|
79
|
-
case "hex":
|
|
80
|
-
case "hex4":
|
|
81
|
-
case "hex8":
|
|
82
|
-
colorFormat = "hex";
|
|
83
|
-
break;
|
|
84
|
-
default:
|
|
85
|
-
break;
|
|
86
|
-
}
|
|
87
|
-
const hsl = color.toHsl();
|
|
88
|
-
hue = Math.round(hsl.h);
|
|
89
|
-
saturation = Math.round(hsl.s * 100);
|
|
90
|
-
lightness = Math.round(hsl.l * 100);
|
|
91
|
-
const rgb = color.toRgb();
|
|
92
|
-
red = rgb.r;
|
|
93
|
-
green = rgb.g;
|
|
94
|
-
blue = rgb.b;
|
|
95
|
-
if (rgb.a) {
|
|
96
|
-
alpha = hsl.a;
|
|
62
|
+
if (!updating && colorFormat === 'hsl') {
|
|
63
|
+
updating = true;
|
|
64
|
+
const color = tinycolor({ h: hue, s: saturation / 100, l: lightness / 100, a: alpha });
|
|
65
|
+
const rgb = color.toRgb();
|
|
66
|
+
red = rgb.r;
|
|
67
|
+
green = rgb.g;
|
|
68
|
+
blue = rgb.b;
|
|
69
|
+
colorText = color.toHslString();
|
|
97
70
|
hexAlpha = Math.round(alpha * 255);
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
updating = false;
|
|
71
|
+
await tick();
|
|
72
|
+
updating = false;
|
|
101
73
|
}
|
|
102
|
-
}
|
|
103
74
|
};
|
|
104
|
-
|
|
105
|
-
colorText, updateColorsFromText();
|
|
106
|
-
$:
|
|
107
|
-
colorFormat, hue, saturation, lightness, alpha, updateFromHsl();
|
|
108
|
-
$:
|
|
109
|
-
colorFormat, red, green, blue, alpha, hexAlpha, updateFromRgb();
|
|
110
|
-
const onInputBlur = async () => {
|
|
111
|
-
if (!updating) {
|
|
112
|
-
if (colorText.trim().length === 0) {
|
|
113
|
-
colorText = defaultColorText;
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
75
|
+
const updateColorsFromText = async () => {
|
|
116
76
|
const color = tinycolor(colorText);
|
|
117
77
|
if (color.isValid) {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
78
|
+
if (!updating) {
|
|
79
|
+
updating = true;
|
|
80
|
+
switch (color.format) {
|
|
81
|
+
case 'hsl':
|
|
82
|
+
colorFormat = 'hsl';
|
|
83
|
+
break;
|
|
84
|
+
case 'rgb':
|
|
85
|
+
colorFormat = 'rgb';
|
|
86
|
+
break;
|
|
87
|
+
case 'hex':
|
|
88
|
+
case 'hex4':
|
|
89
|
+
case 'hex8':
|
|
90
|
+
colorFormat = 'hex';
|
|
91
|
+
break;
|
|
92
|
+
default:
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
const hsl = color.toHsl();
|
|
96
|
+
hue = Math.round(hsl.h);
|
|
97
|
+
saturation = Math.round(hsl.s * 100);
|
|
98
|
+
lightness = Math.round(hsl.l * 100);
|
|
99
|
+
const rgb = color.toRgb();
|
|
100
|
+
red = rgb.r;
|
|
101
|
+
green = rgb.g;
|
|
102
|
+
blue = rgb.b;
|
|
103
|
+
if (rgb.a) {
|
|
104
|
+
alpha = hsl.a;
|
|
105
|
+
hexAlpha = Math.round(alpha * 255);
|
|
106
|
+
}
|
|
107
|
+
await tick();
|
|
108
|
+
updating = false;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
$: colorText, updateColorsFromText();
|
|
113
|
+
$: colorFormat, hue, saturation, lightness, alpha, updateFromHsl();
|
|
114
|
+
$: colorFormat, red, green, blue, alpha, hexAlpha, updateFromRgb();
|
|
115
|
+
// ----- Event handlers ----- //
|
|
116
|
+
const onInputBlur = async () => {
|
|
117
|
+
if (!updating) {
|
|
118
|
+
if (colorText.trim().length === 0) {
|
|
119
|
+
colorText = defaultColorText;
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
const color = tinycolor(colorText);
|
|
123
|
+
if (color.isValid) {
|
|
124
|
+
updating = true;
|
|
125
|
+
switch (colorFormat) {
|
|
126
|
+
case 'hsl':
|
|
127
|
+
colorText = color.toHslString();
|
|
128
|
+
break;
|
|
129
|
+
case 'rgb':
|
|
130
|
+
colorText = color.toRgbString();
|
|
131
|
+
break;
|
|
132
|
+
case 'hex':
|
|
133
|
+
colorText = alpha === 1 ? color.toHexString() : color.toHex8String();
|
|
134
|
+
break;
|
|
135
|
+
default:
|
|
136
|
+
break;
|
|
137
|
+
}
|
|
138
|
+
await tick();
|
|
139
|
+
updating = false;
|
|
140
|
+
}
|
|
134
141
|
}
|
|
135
|
-
}
|
|
136
142
|
};
|
|
137
143
|
const onInputClick = (event) => {
|
|
138
|
-
|
|
139
|
-
|
|
144
|
+
event.stopPropagation();
|
|
145
|
+
return false;
|
|
140
146
|
};
|
|
141
147
|
const onInputKeydown = (event) => {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
148
|
+
switch (event.key) {
|
|
149
|
+
case 'Tab':
|
|
150
|
+
if (open) {
|
|
151
|
+
setTimeout(() => {
|
|
152
|
+
tabListRef?.focus();
|
|
153
|
+
}, 0);
|
|
154
|
+
event.preventDefault();
|
|
155
|
+
event.stopPropagation();
|
|
156
|
+
return false;
|
|
157
|
+
}
|
|
158
|
+
break;
|
|
159
|
+
case 'Escape':
|
|
160
|
+
if (open) {
|
|
161
|
+
open = false;
|
|
162
|
+
event.preventDefault();
|
|
163
|
+
event.stopPropagation();
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
166
|
+
break;
|
|
167
|
+
}
|
|
168
|
+
// prevent typing from bubbling to the dropdown
|
|
169
|
+
event.stopImmediatePropagation();
|
|
163
170
|
};
|
|
171
|
+
// -----Initialization ----- //
|
|
164
172
|
updateColorsFromText();
|
|
165
173
|
</script>
|
|
166
174
|
|
|
167
|
-
<
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
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
|
-
spellcheck="false"
|
|
211
|
-
/>
|
|
212
|
-
</div>
|
|
213
|
-
<div class="popup" use:trapKeyboardFocus>
|
|
214
|
-
<div class="tabs" bind:this={tabsRef}>
|
|
215
|
-
<TabList bind:this={tabListRef} bind:selectedValue={colorFormat} {colorful}>
|
|
216
|
-
<Tab value="hex">hex</Tab>
|
|
217
|
-
<Tab value="rgb">rgb</Tab>
|
|
218
|
-
<Tab value="hsl">hsl</Tab>
|
|
219
|
-
</TabList>
|
|
175
|
+
<div class={`sterling-color-picker ${variant}`}>
|
|
176
|
+
<Dropdown
|
|
177
|
+
{disabled}
|
|
178
|
+
bind:open
|
|
179
|
+
on:blur
|
|
180
|
+
on:click
|
|
181
|
+
on:copy
|
|
182
|
+
on:cut
|
|
183
|
+
on:dblclick
|
|
184
|
+
on:dragend
|
|
185
|
+
on:dragenter
|
|
186
|
+
on:dragleave
|
|
187
|
+
on:dragover
|
|
188
|
+
on:dragstart
|
|
189
|
+
on:drop
|
|
190
|
+
on:focus
|
|
191
|
+
on:focusin
|
|
192
|
+
on:focusout
|
|
193
|
+
on:keydown
|
|
194
|
+
on:keypress
|
|
195
|
+
on:keyup
|
|
196
|
+
on:mousedown
|
|
197
|
+
on:mouseenter
|
|
198
|
+
on:mouseleave
|
|
199
|
+
on:mousemove
|
|
200
|
+
on:mouseover
|
|
201
|
+
on:mouseout
|
|
202
|
+
on:mouseup
|
|
203
|
+
on:wheel
|
|
204
|
+
on:paste
|
|
205
|
+
{...$$restProps}
|
|
206
|
+
>
|
|
207
|
+
<div class="value" slot="value">
|
|
208
|
+
<div class="color-box" style="background-color: {colorText}" />
|
|
209
|
+
<Input
|
|
210
|
+
bind:value={colorText}
|
|
211
|
+
{disabled}
|
|
212
|
+
on:blur={onInputBlur}
|
|
213
|
+
on:click={onInputClick}
|
|
214
|
+
on:keydown={onInputKeydown}
|
|
215
|
+
spellcheck="false"
|
|
216
|
+
variant={`composed ${variant}`}
|
|
217
|
+
/>
|
|
220
218
|
</div>
|
|
221
|
-
<div class="
|
|
222
|
-
|
|
223
|
-
<
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
219
|
+
<div class="sterling-color-picker-popup" use:trapKeyboardFocus>
|
|
220
|
+
<div class="tabs" bind:this={tabsRef}>
|
|
221
|
+
<TabList bind:this={tabListRef} bind:selectedValue={colorFormat}>
|
|
222
|
+
<Tab value="hex">hex</Tab>
|
|
223
|
+
<Tab value="rgb">rgb</Tab>
|
|
224
|
+
<Tab value="hsl">hsl</Tab>
|
|
225
|
+
</TabList>
|
|
226
|
+
</div>
|
|
227
|
+
<div class="sliders">
|
|
228
|
+
{#if colorFormat === 'rgb'}
|
|
229
|
+
<RgbColorSliders bind:red bind:green bind:blue bind:alpha />
|
|
230
|
+
{:else if colorFormat === 'hex'}
|
|
231
|
+
<HexColorSliders bind:red bind:green bind:blue bind:alpha={hexAlpha} />
|
|
232
|
+
{:else if colorFormat === 'hsl'}
|
|
233
|
+
<HslColorSliders bind:hue bind:saturation bind:lightness bind:alpha />
|
|
234
|
+
{/if}
|
|
235
|
+
</div>
|
|
229
236
|
</div>
|
|
230
|
-
</
|
|
231
|
-
</
|
|
232
|
-
|
|
233
|
-
<style>
|
|
234
|
-
.value {
|
|
235
|
-
display: grid;
|
|
236
|
-
align-items: center;
|
|
237
|
-
justify-content: stretch;
|
|
238
|
-
justify-items: stretch;
|
|
239
|
-
grid-template-columns: auto 1fr;
|
|
240
|
-
padding-left: 0.5em;
|
|
241
|
-
width: 250px;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
.color-box {
|
|
245
|
-
width: 1em;
|
|
246
|
-
height: 1em;
|
|
247
|
-
border: 1px dashed var(--stsv-common__border-color);
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
.popup {
|
|
251
|
-
width: fit-content;
|
|
252
|
-
min-width: 500px;
|
|
253
|
-
display: grid;
|
|
254
|
-
align-items: center;
|
|
255
|
-
padding: 0.25em;
|
|
256
|
-
}
|
|
257
|
-
</style>
|
|
237
|
+
</Dropdown>
|
|
238
|
+
</div>
|
package/ColorPicker.svelte.d.ts
CHANGED
|
@@ -4,10 +4,9 @@ declare const __propDef: {
|
|
|
4
4
|
[x: string]: any;
|
|
5
5
|
colorText?: string | undefined;
|
|
6
6
|
colorFormat?: "hex" | "rgb" | "hsl" | undefined;
|
|
7
|
-
colorful?: boolean | undefined;
|
|
8
|
-
composed?: boolean | undefined;
|
|
9
7
|
disabled?: boolean | undefined;
|
|
10
8
|
open?: boolean | undefined;
|
|
9
|
+
variant?: string | undefined;
|
|
11
10
|
};
|
|
12
11
|
events: {
|
|
13
12
|
blur: FocusEvent;
|