@pathscale/ui 1.1.0 → 1.1.2

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 (39) hide show
  1. package/dist/components/color-area/ColorArea.css +54 -0
  2. package/dist/components/color-area/ColorArea.d.ts +15 -0
  3. package/dist/components/color-area/ColorArea.js +211 -0
  4. package/dist/components/color-area/index.d.ts +3 -0
  5. package/dist/components/color-area/index.js +3 -0
  6. package/dist/components/color-field/ColorField.css +88 -0
  7. package/dist/components/color-field/ColorField.d.ts +15 -0
  8. package/dist/components/color-field/ColorField.js +165 -0
  9. package/dist/components/color-field/index.d.ts +3 -0
  10. package/dist/components/color-field/index.js +3 -0
  11. package/dist/components/color-picker/ColorPicker.css +28 -0
  12. package/dist/components/color-picker/ColorPicker.d.ts +33 -0
  13. package/dist/components/color-picker/ColorPicker.js +369 -0
  14. package/dist/components/color-picker/index.d.ts +2 -0
  15. package/dist/components/color-picker/index.js +8 -0
  16. package/dist/components/color-slider/ColorSlider.css +57 -0
  17. package/dist/components/color-slider/ColorSlider.d.ts +13 -0
  18. package/dist/components/color-slider/ColorSlider.js +178 -0
  19. package/dist/components/color-slider/index.d.ts +3 -0
  20. package/dist/components/color-slider/index.js +3 -0
  21. package/dist/components/color-swatch/ColorSwatch.css +84 -0
  22. package/dist/components/color-swatch/ColorSwatch.d.ts +17 -0
  23. package/dist/components/color-swatch/ColorSwatch.js +143 -0
  24. package/dist/components/color-swatch/index.d.ts +3 -0
  25. package/dist/components/color-swatch/index.js +3 -0
  26. package/dist/components/color-swatch-picker/ColorSwatchPicker.css +12 -0
  27. package/dist/components/color-swatch-picker/ColorSwatchPicker.d.ts +18 -0
  28. package/dist/components/color-swatch-picker/ColorSwatchPicker.js +109 -0
  29. package/dist/components/color-swatch-picker/index.d.ts +3 -0
  30. package/dist/components/color-swatch-picker/index.js +5 -0
  31. package/dist/components/colorpicker/ColorWheelFlower.css +147 -0
  32. package/dist/components/colorpicker/ColorWheelFlower.d.ts +1 -0
  33. package/dist/components/colorpicker/ColorWheelFlower.js +302 -243
  34. package/dist/components/table/EnhancedTable.js +97 -30
  35. package/dist/components/tabs/Tabs.css +1 -0
  36. package/dist/components/theme-color-picker/ThemeColorPicker.js +50 -29
  37. package/dist/index.d.ts +14 -2
  38. package/dist/index.js +14 -2
  39. package/package.json +1 -1
@@ -0,0 +1,54 @@
1
+ @layer components {
2
+ .color-area {
3
+ position: relative;
4
+ width: 100%;
5
+ max-width: 14rem;
6
+ flex-shrink: 0;
7
+ border-radius: 1rem;
8
+ aspect-ratio: 1 / 1;
9
+ background: var(--color-area-background);
10
+ box-shadow: inset 0 0 0 1px oklch(0% 0 0 / 0.1);
11
+ cursor: crosshair;
12
+ outline: none;
13
+ user-select: none;
14
+ -webkit-tap-highlight-color: transparent;
15
+ }
16
+
17
+ .color-area[data-disabled="true"] {
18
+ cursor: not-allowed;
19
+ opacity: 0.5;
20
+ }
21
+
22
+ .color-area:focus-visible,
23
+ .color-area[data-focus-visible="true"] {
24
+ box-shadow:
25
+ 0 0 0 3px color-mix(in oklab, var(--color-accent) 22%, transparent),
26
+ inset 0 0 0 1px oklch(0% 0 0 / 0.1);
27
+ }
28
+
29
+ .color-area__thumb {
30
+ position: absolute;
31
+ width: 1rem;
32
+ height: 1rem;
33
+ border-radius: 9999px;
34
+ border: 3px solid #fff;
35
+ box-shadow:
36
+ 0 0 0 1px oklch(0% 0 0 / 0.1),
37
+ inset 0 0 0 1px oklch(0% 0 0 / 0.1);
38
+ transform: translate(-50%, -50%);
39
+ transition:
40
+ width 150ms ease,
41
+ height 150ms ease,
42
+ box-shadow 150ms ease;
43
+ pointer-events: none;
44
+ }
45
+
46
+ .color-area__thumb[data-dragging="true"] {
47
+ width: 1.25rem;
48
+ height: 1.25rem;
49
+ }
50
+
51
+ .color-area__thumb[data-disabled="true"] {
52
+ opacity: 0.65;
53
+ }
54
+ }
@@ -0,0 +1,15 @@
1
+ import "./ColorArea.css";
2
+ import { type Component, type JSX } from "solid-js";
3
+ import type { IComponentBaseProps } from "../types";
4
+ export type ColorAreaValue = {
5
+ h: number;
6
+ s: number;
7
+ v: number;
8
+ };
9
+ export type ColorAreaProps = Omit<JSX.HTMLAttributes<HTMLDivElement>, "children" | "onChange"> & IComponentBaseProps & {
10
+ value?: ColorAreaValue;
11
+ onChange?: (value: ColorAreaValue) => void;
12
+ isDisabled?: boolean;
13
+ };
14
+ declare const ColorArea: Component<ColorAreaProps>;
15
+ export default ColorArea;
@@ -0,0 +1,211 @@
1
+ import * as __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__ from "solid-js/web";
2
+ import "./ColorArea.css";
3
+ import * as __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__ from "solid-js";
4
+ import * as __WEBPACK_EXTERNAL_MODULE_tailwind_merge_e05e3e95__ from "tailwind-merge";
5
+ var _tmpl$ = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.template)("<div><div class=color-area__thumb data-slot=color-area-thumb>");
6
+ const DEFAULT_VALUE = {
7
+ h: 0,
8
+ s: 100,
9
+ v: 100
10
+ };
11
+ const clamp = (value, min, max)=>Math.min(max, Math.max(min, value));
12
+ const normalizeValue = (value)=>({
13
+ h: (value.h % 360 + 360) % 360,
14
+ s: clamp(value.s, 0, 100),
15
+ v: clamp(value.v, 0, 100)
16
+ });
17
+ const hsvToRgb = (h, s, v)=>{
18
+ const saturation = clamp(s, 0, 100) / 100;
19
+ const brightness = clamp(v, 0, 100) / 100;
20
+ const hue = (h % 360 + 360) % 360;
21
+ const chroma = brightness * saturation;
22
+ const huePrime = hue / 60;
23
+ const x = chroma * (1 - Math.abs(huePrime % 2 - 1));
24
+ const match = brightness - chroma;
25
+ let rPrime = 0;
26
+ let gPrime = 0;
27
+ let bPrime = 0;
28
+ if (huePrime >= 0 && huePrime < 1) {
29
+ rPrime = chroma;
30
+ gPrime = x;
31
+ } else if (huePrime < 2) {
32
+ rPrime = x;
33
+ gPrime = chroma;
34
+ } else if (huePrime < 3) {
35
+ gPrime = chroma;
36
+ bPrime = x;
37
+ } else if (huePrime < 4) {
38
+ gPrime = x;
39
+ bPrime = chroma;
40
+ } else if (huePrime < 5) {
41
+ rPrime = x;
42
+ bPrime = chroma;
43
+ } else {
44
+ rPrime = chroma;
45
+ bPrime = x;
46
+ }
47
+ return {
48
+ r: Math.round((rPrime + match) * 255),
49
+ g: Math.round((gPrime + match) * 255),
50
+ b: Math.round((bPrime + match) * 255)
51
+ };
52
+ };
53
+ const ColorArea_ColorArea = (props)=>{
54
+ const [local, others] = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.splitProps)(props, [
55
+ "class",
56
+ "className",
57
+ "value",
58
+ "onChange",
59
+ "isDisabled",
60
+ "dataTheme",
61
+ "style",
62
+ "aria-label"
63
+ ]);
64
+ const [internalValue, setInternalValue] = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createSignal)(DEFAULT_VALUE);
65
+ const [isDragging, setIsDragging] = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createSignal)(false);
66
+ let areaRef;
67
+ const isControlled = ()=>void 0 !== local.value;
68
+ const currentValue = ()=>normalizeValue(local.value ?? internalValue());
69
+ const isDisabled = ()=>Boolean(local.isDisabled);
70
+ const emitChange = (next)=>{
71
+ const normalized = normalizeValue(next);
72
+ if (!isControlled()) setInternalValue(normalized);
73
+ local.onChange?.(normalized);
74
+ };
75
+ const updateFromPointer = (clientX, clientY)=>{
76
+ if (!areaRef || isDisabled()) return;
77
+ const rect = areaRef.getBoundingClientRect();
78
+ const saturation = (clientX - rect.left) / rect.width * 100;
79
+ const vertical = (clientY - rect.top) / rect.height * 100;
80
+ const brightness = 100 - vertical;
81
+ emitChange({
82
+ h: currentValue().h,
83
+ s: saturation,
84
+ v: brightness
85
+ });
86
+ };
87
+ const handlePointerDown = (event)=>{
88
+ if (isDisabled()) return;
89
+ event.preventDefault();
90
+ event.currentTarget.setPointerCapture(event.pointerId);
91
+ setIsDragging(true);
92
+ updateFromPointer(event.clientX, event.clientY);
93
+ };
94
+ const handlePointerMove = (event)=>{
95
+ if (!isDragging()) return;
96
+ updateFromPointer(event.clientX, event.clientY);
97
+ };
98
+ const handlePointerUp = (event)=>{
99
+ if (event.currentTarget.hasPointerCapture(event.pointerId)) event.currentTarget.releasePointerCapture(event.pointerId);
100
+ setIsDragging(false);
101
+ };
102
+ const handleLostPointerCapture = ()=>{
103
+ setIsDragging(false);
104
+ };
105
+ const handleKeyDown = (event)=>{
106
+ if (isDisabled()) return;
107
+ const step = event.shiftKey ? 10 : 1;
108
+ const value = currentValue();
109
+ if ("ArrowLeft" === event.key) {
110
+ event.preventDefault();
111
+ emitChange({
112
+ ...value,
113
+ s: value.s - step
114
+ });
115
+ return;
116
+ }
117
+ if ("ArrowRight" === event.key) {
118
+ event.preventDefault();
119
+ emitChange({
120
+ ...value,
121
+ s: value.s + step
122
+ });
123
+ return;
124
+ }
125
+ if ("ArrowUp" === event.key) {
126
+ event.preventDefault();
127
+ emitChange({
128
+ ...value,
129
+ v: value.v + step
130
+ });
131
+ return;
132
+ }
133
+ if ("ArrowDown" === event.key) {
134
+ event.preventDefault();
135
+ emitChange({
136
+ ...value,
137
+ v: value.v - step
138
+ });
139
+ }
140
+ };
141
+ const style = ()=>{
142
+ const color = currentValue();
143
+ const thumb = hsvToRgb(color.h, color.s, color.v);
144
+ const userStyle = local.style;
145
+ return {
146
+ "--color-area-background": `linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, hsl(${color.h} 100% 50%))`,
147
+ "--color-area-thumb-color": `rgb(${thumb.r} ${thumb.g} ${thumb.b})`,
148
+ ...userStyle
149
+ };
150
+ };
151
+ return (()=>{
152
+ var _el$ = _tmpl$(), _el$2 = _el$.firstChild;
153
+ var _ref$ = areaRef;
154
+ "function" == typeof _ref$ ? (0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.use)(_ref$, _el$) : areaRef = _el$;
155
+ (0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.spread)(_el$, (0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.mergeProps)(others, {
156
+ get ["class"] () {
157
+ return (0, __WEBPACK_EXTERNAL_MODULE_tailwind_merge_e05e3e95__.twMerge)("color-area", local.class, local.className);
158
+ },
159
+ get ["data-theme"] () {
160
+ return local.dataTheme;
161
+ },
162
+ "data-slot": "color-area",
163
+ get ["data-disabled"] () {
164
+ return isDisabled() ? "true" : "false";
165
+ },
166
+ get tabIndex () {
167
+ return isDisabled() ? -1 : 0;
168
+ },
169
+ role: "slider",
170
+ get ["aria-label"] () {
171
+ return local["aria-label"] ?? "Color area";
172
+ },
173
+ "aria-valuemin": 0,
174
+ "aria-valuemax": 100,
175
+ get ["aria-valuenow"] () {
176
+ return Math.round(currentValue().s);
177
+ },
178
+ get ["aria-valuetext"] () {
179
+ return `Saturation ${Math.round(currentValue().s)}%, Brightness ${Math.round(currentValue().v)}%`;
180
+ },
181
+ get ["aria-disabled"] () {
182
+ return isDisabled() ? "true" : "false";
183
+ },
184
+ get style () {
185
+ return style();
186
+ },
187
+ onPointerDown: handlePointerDown,
188
+ onPointerMove: handlePointerMove,
189
+ onPointerUp: handlePointerUp,
190
+ onLostPointerCapture: handleLostPointerCapture,
191
+ onKeyDown: handleKeyDown
192
+ }), false, true);
193
+ _el$2.style.setProperty("background-color", "var(--color-area-thumb-color)");
194
+ (0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.effect)((_p$)=>{
195
+ var _v$ = isDragging() ? "true" : "false", _v$2 = isDisabled() ? "true" : "false", _v$3 = `${currentValue().s}%`, _v$4 = `${100 - currentValue().v}%`;
196
+ _v$ !== _p$.e && (0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.setAttribute)(_el$2, "data-dragging", _p$.e = _v$);
197
+ _v$2 !== _p$.t && (0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.setAttribute)(_el$2, "data-disabled", _p$.t = _v$2);
198
+ _v$3 !== _p$.a && (null != (_p$.a = _v$3) ? _el$2.style.setProperty("left", _v$3) : _el$2.style.removeProperty("left"));
199
+ _v$4 !== _p$.o && (null != (_p$.o = _v$4) ? _el$2.style.setProperty("top", _v$4) : _el$2.style.removeProperty("top"));
200
+ return _p$;
201
+ }, {
202
+ e: void 0,
203
+ t: void 0,
204
+ a: void 0,
205
+ o: void 0
206
+ });
207
+ return _el$;
208
+ })();
209
+ };
210
+ const ColorArea = ColorArea_ColorArea;
211
+ export { ColorArea as default };
@@ -0,0 +1,3 @@
1
+ import ColorArea from "./ColorArea";
2
+ export type { ColorAreaProps, ColorAreaValue } from "./ColorArea";
3
+ export default ColorArea;
@@ -0,0 +1,3 @@
1
+ import * as __WEBPACK_EXTERNAL_MODULE__ColorArea_js_309d2077__ from "./ColorArea.js";
2
+ const color_area = __WEBPACK_EXTERNAL_MODULE__ColorArea_js_309d2077__["default"];
3
+ export { color_area as default };
@@ -0,0 +1,88 @@
1
+ @layer components {
2
+ .color-field {
3
+ display: flex;
4
+ flex-direction: column;
5
+ gap: 0.25rem;
6
+ width: fit-content;
7
+ }
8
+
9
+ .color-field--full-width {
10
+ width: 100%;
11
+ }
12
+
13
+ .color-field__group {
14
+ position: relative;
15
+ display: inline-flex;
16
+ height: 2.25rem;
17
+ width: fit-content;
18
+ min-width: 7rem;
19
+ align-items: center;
20
+ overflow: hidden;
21
+ border-radius: 0.75rem;
22
+ border: 1px solid var(--color-base-300);
23
+ background-color: var(--color-base-100);
24
+ color: var(--color-base-content);
25
+ box-shadow: 0 1px 0 oklch(100% 0 0 / calc(var(--depth) * 0.1)) inset;
26
+ transition:
27
+ background-color 150ms ease,
28
+ border-color 150ms ease,
29
+ box-shadow 150ms ease;
30
+ }
31
+
32
+ .color-field__group--full-width {
33
+ width: 100%;
34
+ }
35
+
36
+ @media (hover: hover) {
37
+ .color-field__group:hover:not(:focus-within):not([data-disabled="true"]) {
38
+ background-color: var(--color-base-200);
39
+ border-color: color-mix(in oklab, var(--color-base-content) 22%, transparent);
40
+ }
41
+ }
42
+
43
+ .color-field__group:focus-within {
44
+ border-color: var(--color-accent);
45
+ box-shadow: 0 0 0 3px color-mix(in oklab, var(--color-accent) 24%, transparent);
46
+ }
47
+
48
+ .color-field__group--invalid,
49
+ .color-field__group[data-invalid="true"] {
50
+ border-color: var(--color-error);
51
+ background-color: var(--color-base-100);
52
+ }
53
+
54
+ .color-field__group--invalid:focus-within,
55
+ .color-field__group[data-invalid="true"]:focus-within {
56
+ box-shadow: 0 0 0 3px color-mix(in oklab, var(--color-error) 24%, transparent);
57
+ }
58
+
59
+ .color-field__group[data-disabled="true"] {
60
+ cursor: not-allowed;
61
+ border-color: var(--color-base-300);
62
+ background-color: var(--color-base-200);
63
+ color: color-mix(in oklab, var(--color-base-content) 55%, transparent);
64
+ box-shadow: none;
65
+ opacity: 0.85;
66
+ }
67
+
68
+ .color-field__input {
69
+ width: 100%;
70
+ height: 100%;
71
+ border: 0;
72
+ background: transparent;
73
+ color: inherit;
74
+ font-size: 0.875rem;
75
+ line-height: 1.25rem;
76
+ font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
77
+ padding-inline: 0.75rem;
78
+ outline: none;
79
+ }
80
+
81
+ .color-field__input::placeholder {
82
+ color: color-mix(in oklab, var(--color-base-content) 45%, transparent);
83
+ }
84
+
85
+ .color-field__input:disabled {
86
+ cursor: not-allowed;
87
+ }
88
+ }
@@ -0,0 +1,15 @@
1
+ import "./ColorField.css";
2
+ import { type Component, type JSX } from "solid-js";
3
+ import { type ColorFormat } from "../colorpicker/ColorUtils";
4
+ import type { IComponentBaseProps } from "../types";
5
+ export type ColorFieldFormat = ColorFormat;
6
+ export type ColorFieldProps = Omit<JSX.InputHTMLAttributes<HTMLInputElement>, "type" | "value" | "defaultValue" | "onChange"> & IComponentBaseProps & {
7
+ value?: string;
8
+ defaultValue?: string;
9
+ onChange?: (value: string) => void;
10
+ isDisabled?: boolean;
11
+ format?: ColorFieldFormat;
12
+ fullWidth?: boolean;
13
+ };
14
+ declare const ColorField: Component<ColorFieldProps>;
15
+ export default ColorField;
@@ -0,0 +1,165 @@
1
+ import * as __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__ from "solid-js/web";
2
+ import "./ColorField.css";
3
+ import * as __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__ from "solid-js";
4
+ import * as __WEBPACK_EXTERNAL_MODULE_tailwind_merge_e05e3e95__ from "tailwind-merge";
5
+ import * as __WEBPACK_EXTERNAL_MODULE__colorpicker_ColorUtils_js_79ac07b0__ from "../colorpicker/ColorUtils.js";
6
+ var _tmpl$ = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.template)("<div data-slot=color-field><div data-slot=color-field-group><input>");
7
+ const FALLBACK_COLOR = "#FFFFFF";
8
+ const invokeEventHandler = (handler, event)=>{
9
+ if ("function" == typeof handler) return void handler(event);
10
+ if (Array.isArray(handler) && "function" == typeof handler[0]) handler[0](handler[1], event);
11
+ };
12
+ const normalizeColor = (value, format)=>{
13
+ const parsed = (0, __WEBPACK_EXTERNAL_MODULE__colorpicker_ColorUtils_js_79ac07b0__.parseColor)(value);
14
+ if (!parsed) return null;
15
+ const formatted = (0, __WEBPACK_EXTERNAL_MODULE__colorpicker_ColorUtils_js_79ac07b0__.formatColor)(parsed, format);
16
+ return "hex" === format ? formatted.toUpperCase() : formatted;
17
+ };
18
+ const ColorField = (props)=>{
19
+ const [local, others] = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.splitProps)(props, [
20
+ "class",
21
+ "className",
22
+ "value",
23
+ "defaultValue",
24
+ "onChange",
25
+ "isDisabled",
26
+ "disabled",
27
+ "format",
28
+ "fullWidth",
29
+ "dataTheme",
30
+ "onInput",
31
+ "onBlur",
32
+ "onFocus",
33
+ "onKeyDown"
34
+ ]);
35
+ const format = ()=>local.format ?? "hex";
36
+ const isDisabled = ()=>Boolean(local.isDisabled) || Boolean(local.disabled);
37
+ const initialValue = ()=>{
38
+ const seed = local.value ?? local.defaultValue ?? FALLBACK_COLOR;
39
+ return normalizeColor(seed, format()) ?? FALLBACK_COLOR;
40
+ };
41
+ const [inputValue, setInputValue] = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createSignal)(initialValue());
42
+ const [lastValidValue, setLastValidValue] = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createSignal)(initialValue());
43
+ const [isInvalid, setIsInvalid] = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createSignal)(false);
44
+ const [isFocused, setIsFocused] = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createSignal)(false);
45
+ (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createEffect)(()=>{
46
+ const nextValue = local.value;
47
+ const nextFormat = format();
48
+ if (isFocused()) return;
49
+ if (void 0 !== nextValue) {
50
+ const normalized = normalizeColor(nextValue, nextFormat) ?? lastValidValue();
51
+ setInputValue(normalized);
52
+ setLastValidValue(normalized);
53
+ setIsInvalid(false);
54
+ return;
55
+ }
56
+ const normalized = normalizeColor(lastValidValue(), nextFormat) ?? FALLBACK_COLOR;
57
+ setInputValue(normalized);
58
+ setLastValidValue(normalized);
59
+ setIsInvalid(false);
60
+ });
61
+ const emitIfValid = (value)=>{
62
+ const normalized = normalizeColor(value, format());
63
+ if (!normalized) return null;
64
+ local.onChange?.(normalized);
65
+ return normalized;
66
+ };
67
+ const commit = ()=>{
68
+ const normalized = emitIfValid(inputValue());
69
+ if (normalized) {
70
+ setInputValue(normalized);
71
+ setLastValidValue(normalized);
72
+ setIsInvalid(false);
73
+ return;
74
+ }
75
+ setInputValue(lastValidValue());
76
+ setIsInvalid(false);
77
+ };
78
+ const handleInput = (event)=>{
79
+ invokeEventHandler(local.onInput, event);
80
+ if (event.defaultPrevented) return;
81
+ const raw = event.currentTarget.value;
82
+ setInputValue(raw);
83
+ const normalized = emitIfValid(raw);
84
+ if (normalized) {
85
+ setLastValidValue(normalized);
86
+ setIsInvalid(false);
87
+ return;
88
+ }
89
+ setIsInvalid(raw.trim().length > 0);
90
+ };
91
+ const handleBlur = (event)=>{
92
+ invokeEventHandler(local.onBlur, event);
93
+ setIsFocused(false);
94
+ if (event.defaultPrevented) return;
95
+ commit();
96
+ };
97
+ const handleFocus = (event)=>{
98
+ invokeEventHandler(local.onFocus, event);
99
+ if (event.defaultPrevented) return;
100
+ setIsFocused(true);
101
+ };
102
+ const handleKeyDown = (event)=>{
103
+ invokeEventHandler(local.onKeyDown, event);
104
+ if (event.defaultPrevented) return;
105
+ if ("Enter" === event.key) {
106
+ event.preventDefault();
107
+ commit();
108
+ }
109
+ if ("Escape" === event.key) {
110
+ event.preventDefault();
111
+ setInputValue(lastValidValue());
112
+ setIsInvalid(false);
113
+ event.currentTarget.blur();
114
+ }
115
+ };
116
+ return (()=>{
117
+ var _el$ = _tmpl$(), _el$2 = _el$.firstChild, _el$3 = _el$2.firstChild;
118
+ (0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.spread)(_el$3, (0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.mergeProps)(others, {
119
+ type: "text",
120
+ get value () {
121
+ return inputValue();
122
+ },
123
+ get disabled () {
124
+ return isDisabled();
125
+ },
126
+ class: "color-field__input",
127
+ "data-slot": "color-field-input",
128
+ spellcheck: false,
129
+ autocapitalize: "off",
130
+ autocomplete: "off",
131
+ autocorrect: "off",
132
+ get ["aria-invalid"] () {
133
+ return isInvalid() ? "true" : "false";
134
+ },
135
+ onInput: handleInput,
136
+ onBlur: handleBlur,
137
+ onFocus: handleFocus,
138
+ onKeyDown: handleKeyDown
139
+ }), false, false);
140
+ (0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.effect)((_p$)=>{
141
+ var _v$ = (0, __WEBPACK_EXTERNAL_MODULE_tailwind_merge_e05e3e95__.twMerge)("color-field", local.fullWidth && "color-field--full-width", isDisabled() && "color-field--disabled", local.class, local.className), _v$2 = local.dataTheme, _v$3 = isDisabled() ? "true" : "false", _v$4 = isInvalid() ? "true" : "false", _v$5 = isDisabled() ? "true" : "false", _v$6 = (0, __WEBPACK_EXTERNAL_MODULE_tailwind_merge_e05e3e95__.twMerge)("color-field__group", isInvalid() && "color-field__group--invalid", local.fullWidth && "color-field__group--full-width"), _v$7 = isDisabled() ? "true" : "false", _v$8 = isInvalid() ? "true" : "false";
142
+ _v$ !== _p$.e && (0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.className)(_el$, _p$.e = _v$);
143
+ _v$2 !== _p$.t && (0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.setAttribute)(_el$, "data-theme", _p$.t = _v$2);
144
+ _v$3 !== _p$.a && (0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.setAttribute)(_el$, "data-disabled", _p$.a = _v$3);
145
+ _v$4 !== _p$.o && (0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.setAttribute)(_el$, "data-invalid", _p$.o = _v$4);
146
+ _v$5 !== _p$.i && (0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.setAttribute)(_el$, "aria-disabled", _p$.i = _v$5);
147
+ _v$6 !== _p$.n && (0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.className)(_el$2, _p$.n = _v$6);
148
+ _v$7 !== _p$.s && (0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.setAttribute)(_el$2, "data-disabled", _p$.s = _v$7);
149
+ _v$8 !== _p$.h && (0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.setAttribute)(_el$2, "data-invalid", _p$.h = _v$8);
150
+ return _p$;
151
+ }, {
152
+ e: void 0,
153
+ t: void 0,
154
+ a: void 0,
155
+ o: void 0,
156
+ i: void 0,
157
+ n: void 0,
158
+ s: void 0,
159
+ h: void 0
160
+ });
161
+ return _el$;
162
+ })();
163
+ };
164
+ const color_field_ColorField = ColorField;
165
+ export { color_field_ColorField as default };
@@ -0,0 +1,3 @@
1
+ import ColorField from "./ColorField";
2
+ export type { ColorFieldProps, ColorFieldFormat } from "./ColorField";
3
+ export default ColorField;
@@ -0,0 +1,3 @@
1
+ import * as __WEBPACK_EXTERNAL_MODULE__ColorField_js_8c5d2ce6__ from "./ColorField.js";
2
+ const color_field = __WEBPACK_EXTERNAL_MODULE__ColorField_js_8c5d2ce6__["default"];
3
+ export { color_field as default };
@@ -0,0 +1,28 @@
1
+ @layer components {
2
+ .color-picker {
3
+ display: flex;
4
+ flex-direction: column;
5
+ gap: 0.75rem;
6
+ width: fit-content;
7
+ min-width: 14rem;
8
+ max-width: 100%;
9
+ }
10
+
11
+ .color-picker[data-disabled="true"] {
12
+ opacity: 0.9;
13
+ }
14
+
15
+ .color-picker__area {
16
+ width: 100%;
17
+ max-width: 14rem;
18
+ }
19
+
20
+ .color-picker__slider {
21
+ width: 100%;
22
+ max-width: 14rem;
23
+ }
24
+
25
+ .color-picker__field {
26
+ width: 100%;
27
+ }
28
+ }
@@ -0,0 +1,33 @@
1
+ import "./ColorPicker.css";
2
+ import { type Component, type JSX } from "solid-js";
3
+ import { type ColorAreaProps, type ColorAreaValue } from "../color-area";
4
+ import { type ColorFieldProps } from "../color-field";
5
+ import { type ColorSliderProps } from "../color-slider";
6
+ import type { IComponentBaseProps } from "../types";
7
+ export type ColorPickerAreaProps = Omit<ColorAreaProps, "value" | "onChange" | "isDisabled"> & {
8
+ onChange?: (value: ColorAreaValue) => void;
9
+ };
10
+ declare const ColorPickerArea: Component<ColorPickerAreaProps>;
11
+ export type ColorPickerSliderProps = Omit<ColorSliderProps, "value" | "onChange" | "isDisabled"> & {
12
+ onChange?: (value: number) => void;
13
+ };
14
+ declare const ColorPickerSlider: Component<ColorPickerSliderProps>;
15
+ export type ColorPickerFieldProps = Omit<ColorFieldProps, "value" | "onChange" | "isDisabled"> & {
16
+ onChange?: (value: string) => void;
17
+ };
18
+ declare const ColorPickerField: Component<ColorPickerFieldProps>;
19
+ export type ColorPickerProps = Omit<JSX.HTMLAttributes<HTMLDivElement>, "children" | "onChange"> & IComponentBaseProps & {
20
+ children?: JSX.Element;
21
+ value?: string;
22
+ defaultValue?: string;
23
+ onChange?: (value: string) => void;
24
+ isDisabled?: boolean;
25
+ };
26
+ declare const ColorPickerRoot: Component<ColorPickerProps>;
27
+ declare const ColorPicker: Component<ColorPickerProps> & {
28
+ Root: Component<ColorPickerProps>;
29
+ Area: Component<ColorPickerAreaProps>;
30
+ Slider: Component<ColorPickerSliderProps>;
31
+ Field: Component<ColorPickerFieldProps>;
32
+ };
33
+ export { ColorPicker as default, ColorPicker, ColorPickerRoot, ColorPickerArea, ColorPickerSlider, ColorPickerField, };