@classytic/fluid 0.4.0 → 0.4.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.
- package/dist/client/color-picker.d.mts +78 -0
- package/dist/client/color-picker.mjs +344 -0
- package/dist/client/gallery.d.mts +175 -0
- package/dist/client/gallery.mjs +545 -0
- package/dist/client/spreadsheet.d.mts +210 -0
- package/dist/client/spreadsheet.mjs +611 -0
- package/dist/forms.mjs +3 -3
- package/package.json +40 -15
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
2
|
+
import * as react from "react";
|
|
3
|
+
import { ReactNode } from "react";
|
|
4
|
+
|
|
5
|
+
//#region src/components/color-picker.d.ts
|
|
6
|
+
type RGBA = [number, number, number, number];
|
|
7
|
+
interface ColorPickerContextValue {
|
|
8
|
+
hue: number;
|
|
9
|
+
saturation: number;
|
|
10
|
+
lightness: number;
|
|
11
|
+
alpha: number;
|
|
12
|
+
setHue: (hue: number) => void;
|
|
13
|
+
setSaturation: (saturation: number) => void;
|
|
14
|
+
setLightness: (lightness: number) => void;
|
|
15
|
+
setAlpha: (alpha: number) => void;
|
|
16
|
+
getCurrentColor: () => RGBA;
|
|
17
|
+
onChange?: (color: RGBA) => void;
|
|
18
|
+
}
|
|
19
|
+
declare function useColorPicker(): ColorPickerContextValue;
|
|
20
|
+
declare function useColorPickerHex(): string;
|
|
21
|
+
interface ColorPickerProps {
|
|
22
|
+
/** Current color value (hex string, e.g. "#ff0000") */
|
|
23
|
+
value?: string;
|
|
24
|
+
/** Default color if value is not provided */
|
|
25
|
+
defaultValue?: string;
|
|
26
|
+
/** Callback with [R, G, B, Alpha(0-1)] when color changes */
|
|
27
|
+
onChange?: (color: RGBA) => void;
|
|
28
|
+
className?: string;
|
|
29
|
+
children?: ReactNode;
|
|
30
|
+
}
|
|
31
|
+
declare function ColorPicker({
|
|
32
|
+
value,
|
|
33
|
+
defaultValue,
|
|
34
|
+
onChange,
|
|
35
|
+
className,
|
|
36
|
+
children
|
|
37
|
+
}: ColorPickerProps): react_jsx_runtime0.JSX.Element;
|
|
38
|
+
interface ColorPickerSelectionProps {
|
|
39
|
+
className?: string;
|
|
40
|
+
}
|
|
41
|
+
declare const ColorPickerSelection: react.NamedExoticComponent<ColorPickerSelectionProps>;
|
|
42
|
+
interface ColorPickerHueProps {
|
|
43
|
+
className?: string;
|
|
44
|
+
}
|
|
45
|
+
declare function ColorPickerHue({
|
|
46
|
+
className
|
|
47
|
+
}: ColorPickerHueProps): react_jsx_runtime0.JSX.Element;
|
|
48
|
+
interface ColorPickerAlphaProps {
|
|
49
|
+
className?: string;
|
|
50
|
+
}
|
|
51
|
+
declare function ColorPickerAlpha({
|
|
52
|
+
className
|
|
53
|
+
}: ColorPickerAlphaProps): react_jsx_runtime0.JSX.Element;
|
|
54
|
+
interface ColorPickerEyeDropperProps {
|
|
55
|
+
className?: string;
|
|
56
|
+
children?: ReactNode;
|
|
57
|
+
}
|
|
58
|
+
declare function ColorPickerEyeDropper({
|
|
59
|
+
className,
|
|
60
|
+
children
|
|
61
|
+
}: ColorPickerEyeDropperProps): react_jsx_runtime0.JSX.Element;
|
|
62
|
+
interface ColorPickerInputProps {
|
|
63
|
+
className?: string;
|
|
64
|
+
/** Show alpha percentage alongside hex */
|
|
65
|
+
showAlpha?: boolean;
|
|
66
|
+
}
|
|
67
|
+
declare function ColorPickerInput({
|
|
68
|
+
className,
|
|
69
|
+
showAlpha
|
|
70
|
+
}: ColorPickerInputProps): react_jsx_runtime0.JSX.Element;
|
|
71
|
+
interface ColorPickerPreviewProps {
|
|
72
|
+
className?: string;
|
|
73
|
+
}
|
|
74
|
+
declare function ColorPickerPreview({
|
|
75
|
+
className
|
|
76
|
+
}: ColorPickerPreviewProps): react_jsx_runtime0.JSX.Element;
|
|
77
|
+
//#endregion
|
|
78
|
+
export { ColorPicker, ColorPickerAlpha, type ColorPickerAlphaProps, ColorPickerEyeDropper, type ColorPickerEyeDropperProps, ColorPickerHue, type ColorPickerHueProps, ColorPickerInput, type ColorPickerInputProps, ColorPickerPreview, type ColorPickerPreviewProps, type ColorPickerProps, ColorPickerSelection, type ColorPickerSelectionProps, type RGBA, useColorPicker, useColorPickerHex };
|
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { t as cn } from "../utils-DQ5SCVoW.mjs";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { createContext, memo, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
|
|
6
|
+
import { Pipette } from "lucide-react";
|
|
7
|
+
import { Button } from "@/components/ui/button";
|
|
8
|
+
import { Input } from "@/components/ui/input";
|
|
9
|
+
|
|
10
|
+
//#region src/components/color-picker.tsx
|
|
11
|
+
function hexToRgb(hex) {
|
|
12
|
+
const h = hex.replace("#", "");
|
|
13
|
+
const expanded = h.length === 3 ? h.split("").map((c) => c + c).join("") : h;
|
|
14
|
+
const n = parseInt(expanded.slice(0, 6), 16);
|
|
15
|
+
return [
|
|
16
|
+
n >> 16 & 255,
|
|
17
|
+
n >> 8 & 255,
|
|
18
|
+
n & 255
|
|
19
|
+
];
|
|
20
|
+
}
|
|
21
|
+
function rgbToHsl(r, g, b) {
|
|
22
|
+
r /= 255;
|
|
23
|
+
g /= 255;
|
|
24
|
+
b /= 255;
|
|
25
|
+
const max = Math.max(r, g, b), min = Math.min(r, g, b);
|
|
26
|
+
const l = (max + min) / 2;
|
|
27
|
+
if (max === min) return [
|
|
28
|
+
0,
|
|
29
|
+
0,
|
|
30
|
+
l * 100
|
|
31
|
+
];
|
|
32
|
+
const d = max - min;
|
|
33
|
+
const s = l > .5 ? d / (2 - max - min) : d / (max + min);
|
|
34
|
+
let h;
|
|
35
|
+
if (max === r) h = ((g - b) / d + (g < b ? 6 : 0)) / 6;
|
|
36
|
+
else if (max === g) h = ((b - r) / d + 2) / 6;
|
|
37
|
+
else h = ((r - g) / d + 4) / 6;
|
|
38
|
+
return [
|
|
39
|
+
h * 360,
|
|
40
|
+
s * 100,
|
|
41
|
+
l * 100
|
|
42
|
+
];
|
|
43
|
+
}
|
|
44
|
+
function hslToRgb(h, s, l) {
|
|
45
|
+
h /= 360;
|
|
46
|
+
s /= 100;
|
|
47
|
+
l /= 100;
|
|
48
|
+
if (s === 0) {
|
|
49
|
+
const v = Math.round(l * 255);
|
|
50
|
+
return [
|
|
51
|
+
v,
|
|
52
|
+
v,
|
|
53
|
+
v
|
|
54
|
+
];
|
|
55
|
+
}
|
|
56
|
+
const hue2rgb = (p, q, t) => {
|
|
57
|
+
if (t < 0) t += 1;
|
|
58
|
+
if (t > 1) t -= 1;
|
|
59
|
+
if (t < 1 / 6) return p + (q - p) * 6 * t;
|
|
60
|
+
if (t < 1 / 2) return q;
|
|
61
|
+
if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;
|
|
62
|
+
return p;
|
|
63
|
+
};
|
|
64
|
+
const q = l < .5 ? l * (1 + s) : l + s - l * s;
|
|
65
|
+
const p = 2 * l - q;
|
|
66
|
+
return [
|
|
67
|
+
Math.round(hue2rgb(p, q, h + 1 / 3) * 255),
|
|
68
|
+
Math.round(hue2rgb(p, q, h) * 255),
|
|
69
|
+
Math.round(hue2rgb(p, q, h - 1 / 3) * 255)
|
|
70
|
+
];
|
|
71
|
+
}
|
|
72
|
+
function hslToHex(h, s, l) {
|
|
73
|
+
const [r, g, b] = hslToRgb(h, s, l);
|
|
74
|
+
return "#" + [
|
|
75
|
+
r,
|
|
76
|
+
g,
|
|
77
|
+
b
|
|
78
|
+
].map((x) => x.toString(16).padStart(2, "0")).join("");
|
|
79
|
+
}
|
|
80
|
+
function hslToHexa(h, s, l, a) {
|
|
81
|
+
const [r, g, b] = hslToRgb(h, s, l);
|
|
82
|
+
return "#" + [
|
|
83
|
+
r,
|
|
84
|
+
g,
|
|
85
|
+
b,
|
|
86
|
+
Math.round(a * 255)
|
|
87
|
+
].map((x) => x.toString(16).padStart(2, "0")).join("");
|
|
88
|
+
}
|
|
89
|
+
function hexToHsl(hex) {
|
|
90
|
+
return rgbToHsl(...hexToRgb(hex));
|
|
91
|
+
}
|
|
92
|
+
const ColorPickerContext = createContext(void 0);
|
|
93
|
+
function useColorPicker() {
|
|
94
|
+
const context = useContext(ColorPickerContext);
|
|
95
|
+
if (!context) throw new Error("useColorPicker must be used within a ColorPicker");
|
|
96
|
+
return context;
|
|
97
|
+
}
|
|
98
|
+
function useColorPickerHex() {
|
|
99
|
+
const { hue, saturation, lightness } = useColorPicker();
|
|
100
|
+
return hslToHex(hue, saturation, lightness);
|
|
101
|
+
}
|
|
102
|
+
function ColorPicker({ value, defaultValue = "#000000", onChange, className, children }) {
|
|
103
|
+
const [ih, is, il] = hexToHsl(value || defaultValue);
|
|
104
|
+
const [hue, setHue] = useState(ih || 0);
|
|
105
|
+
const [saturation, setSaturation] = useState(is || 100);
|
|
106
|
+
const [lightness, setLightness] = useState(il || 50);
|
|
107
|
+
const [alpha, setAlpha] = useState(100);
|
|
108
|
+
const notify = useCallback((h, s, l, a) => {
|
|
109
|
+
if (!onChange) return;
|
|
110
|
+
const [r, g, b] = hslToRgb(h, s, l);
|
|
111
|
+
onChange([
|
|
112
|
+
r,
|
|
113
|
+
g,
|
|
114
|
+
b,
|
|
115
|
+
a / 100
|
|
116
|
+
]);
|
|
117
|
+
}, [onChange]);
|
|
118
|
+
const setHueNotify = useCallback((v) => {
|
|
119
|
+
setHue(v);
|
|
120
|
+
notify(v, saturation, lightness, alpha);
|
|
121
|
+
}, [
|
|
122
|
+
saturation,
|
|
123
|
+
lightness,
|
|
124
|
+
alpha,
|
|
125
|
+
notify
|
|
126
|
+
]);
|
|
127
|
+
const setSaturationNotify = useCallback((v) => {
|
|
128
|
+
setSaturation(v);
|
|
129
|
+
notify(hue, v, lightness, alpha);
|
|
130
|
+
}, [
|
|
131
|
+
hue,
|
|
132
|
+
lightness,
|
|
133
|
+
alpha,
|
|
134
|
+
notify
|
|
135
|
+
]);
|
|
136
|
+
const setLightnessNotify = useCallback((v) => {
|
|
137
|
+
setLightness(v);
|
|
138
|
+
notify(hue, saturation, v, alpha);
|
|
139
|
+
}, [
|
|
140
|
+
hue,
|
|
141
|
+
saturation,
|
|
142
|
+
alpha,
|
|
143
|
+
notify
|
|
144
|
+
]);
|
|
145
|
+
const setAlphaNotify = useCallback((v) => {
|
|
146
|
+
setAlpha(v);
|
|
147
|
+
notify(hue, saturation, lightness, v);
|
|
148
|
+
}, [
|
|
149
|
+
hue,
|
|
150
|
+
saturation,
|
|
151
|
+
lightness,
|
|
152
|
+
notify
|
|
153
|
+
]);
|
|
154
|
+
const getCurrentColor = useCallback(() => {
|
|
155
|
+
const [r, g, b] = hslToRgb(hue, saturation, lightness);
|
|
156
|
+
return [
|
|
157
|
+
r,
|
|
158
|
+
g,
|
|
159
|
+
b,
|
|
160
|
+
alpha / 100
|
|
161
|
+
];
|
|
162
|
+
}, [
|
|
163
|
+
hue,
|
|
164
|
+
saturation,
|
|
165
|
+
lightness,
|
|
166
|
+
alpha
|
|
167
|
+
]);
|
|
168
|
+
return /* @__PURE__ */ jsx(ColorPickerContext.Provider, {
|
|
169
|
+
value: {
|
|
170
|
+
hue,
|
|
171
|
+
saturation,
|
|
172
|
+
lightness,
|
|
173
|
+
alpha,
|
|
174
|
+
setHue: setHueNotify,
|
|
175
|
+
setSaturation: setSaturationNotify,
|
|
176
|
+
setLightness: setLightnessNotify,
|
|
177
|
+
setAlpha: setAlphaNotify,
|
|
178
|
+
getCurrentColor,
|
|
179
|
+
onChange
|
|
180
|
+
},
|
|
181
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
182
|
+
className: cn("flex size-full flex-col gap-4", className),
|
|
183
|
+
children
|
|
184
|
+
})
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
const ColorPickerSelection = memo(function ColorPickerSelection({ className }) {
|
|
188
|
+
const containerRef = useRef(null);
|
|
189
|
+
const [isDragging, setIsDragging] = useState(false);
|
|
190
|
+
const { hue, saturation, lightness, setSaturation, setLightness } = useColorPicker();
|
|
191
|
+
const backgroundGradient = useMemo(() => `linear-gradient(0deg, rgba(0,0,0,1), rgba(0,0,0,0)), linear-gradient(90deg, rgba(255,255,255,1), rgba(255,255,255,0)), hsl(${hue}, 100%, 50%)`, [hue]);
|
|
192
|
+
const positionX = saturation / 100;
|
|
193
|
+
const topLightness = positionX < .01 ? 100 : 50 + 50 * (1 - positionX);
|
|
194
|
+
const positionY = topLightness > 0 ? Math.max(0, Math.min(1, 1 - lightness / topLightness)) : 0;
|
|
195
|
+
const updateColor = useCallback((clientX, clientY) => {
|
|
196
|
+
if (!containerRef.current) return;
|
|
197
|
+
const rect = containerRef.current.getBoundingClientRect();
|
|
198
|
+
const x = Math.max(0, Math.min(1, (clientX - rect.left) / rect.width));
|
|
199
|
+
const y = Math.max(0, Math.min(1, (clientY - rect.top) / rect.height));
|
|
200
|
+
setSaturation(x * 100);
|
|
201
|
+
setLightness((x < .01 ? 100 : 50 + 50 * (1 - x)) * (1 - y));
|
|
202
|
+
}, [setSaturation, setLightness]);
|
|
203
|
+
const handlePointerDown = useCallback((e) => {
|
|
204
|
+
e.preventDefault();
|
|
205
|
+
setIsDragging(true);
|
|
206
|
+
updateColor(e.clientX, e.clientY);
|
|
207
|
+
}, [updateColor]);
|
|
208
|
+
useEffect(() => {
|
|
209
|
+
if (!isDragging) return;
|
|
210
|
+
const onMove = (e) => updateColor(e.clientX, e.clientY);
|
|
211
|
+
const onUp = () => setIsDragging(false);
|
|
212
|
+
window.addEventListener("pointermove", onMove);
|
|
213
|
+
window.addEventListener("pointerup", onUp);
|
|
214
|
+
return () => {
|
|
215
|
+
window.removeEventListener("pointermove", onMove);
|
|
216
|
+
window.removeEventListener("pointerup", onUp);
|
|
217
|
+
};
|
|
218
|
+
}, [isDragging, updateColor]);
|
|
219
|
+
return /* @__PURE__ */ jsx("div", {
|
|
220
|
+
className: cn("relative size-full cursor-crosshair rounded", className),
|
|
221
|
+
onPointerDown: handlePointerDown,
|
|
222
|
+
ref: containerRef,
|
|
223
|
+
style: { background: backgroundGradient },
|
|
224
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
225
|
+
className: "-translate-x-1/2 -translate-y-1/2 pointer-events-none absolute h-4 w-4 rounded-full border-2 border-white",
|
|
226
|
+
style: {
|
|
227
|
+
left: `${positionX * 100}%`,
|
|
228
|
+
top: `${positionY * 100}%`,
|
|
229
|
+
boxShadow: "0 0 0 1px rgba(0,0,0,0.5)"
|
|
230
|
+
}
|
|
231
|
+
})
|
|
232
|
+
});
|
|
233
|
+
});
|
|
234
|
+
function ColorSlider({ value, max, onChange, trackClassName, trackStyle, children, className }) {
|
|
235
|
+
const ref = useRef(null);
|
|
236
|
+
const [dragging, setDragging] = useState(false);
|
|
237
|
+
const update = useCallback((clientX) => {
|
|
238
|
+
if (!ref.current) return;
|
|
239
|
+
const rect = ref.current.getBoundingClientRect();
|
|
240
|
+
const x = Math.max(0, Math.min(1, (clientX - rect.left) / rect.width));
|
|
241
|
+
onChange(Math.round(x * max));
|
|
242
|
+
}, [max, onChange]);
|
|
243
|
+
const handlePointerDown = useCallback((e) => {
|
|
244
|
+
e.preventDefault();
|
|
245
|
+
setDragging(true);
|
|
246
|
+
update(e.clientX);
|
|
247
|
+
}, [update]);
|
|
248
|
+
useEffect(() => {
|
|
249
|
+
if (!dragging) return;
|
|
250
|
+
const onMove = (e) => update(e.clientX);
|
|
251
|
+
const onUp = () => setDragging(false);
|
|
252
|
+
window.addEventListener("pointermove", onMove);
|
|
253
|
+
window.addEventListener("pointerup", onUp);
|
|
254
|
+
return () => {
|
|
255
|
+
window.removeEventListener("pointermove", onMove);
|
|
256
|
+
window.removeEventListener("pointerup", onUp);
|
|
257
|
+
};
|
|
258
|
+
}, [dragging, update]);
|
|
259
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
260
|
+
ref,
|
|
261
|
+
className: cn("relative flex h-4 w-full touch-none items-center", className),
|
|
262
|
+
onPointerDown: handlePointerDown,
|
|
263
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
264
|
+
className: cn("relative h-3 w-full rounded-full", trackClassName),
|
|
265
|
+
style: trackStyle,
|
|
266
|
+
children
|
|
267
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
268
|
+
className: "pointer-events-none absolute top-0 h-4 w-4 -translate-x-1/2 rounded-full border border-primary/50 bg-background shadow",
|
|
269
|
+
style: { left: `${value / max * 100}%` }
|
|
270
|
+
})]
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
const HUE_GRADIENT = "linear-gradient(90deg, #FF0000, #FFFF00, #00FF00, #00FFFF, #0000FF, #FF00FF, #FF0000)";
|
|
274
|
+
function ColorPickerHue({ className }) {
|
|
275
|
+
const { hue, setHue } = useColorPicker();
|
|
276
|
+
return /* @__PURE__ */ jsx(ColorSlider, {
|
|
277
|
+
value: hue,
|
|
278
|
+
max: 360,
|
|
279
|
+
onChange: setHue,
|
|
280
|
+
trackStyle: { background: HUE_GRADIENT },
|
|
281
|
+
className
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
const CHECKER_BG = "url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAMUlEQVQ4T2NkYGAQYcAP3uCTZhw1gGGYhAGBZIA/nYDCgBDAm9BGDWAAJyRCgLaBCAAgXwixzAS0pgAAAABJRU5ErkJggg==')";
|
|
285
|
+
function ColorPickerAlpha({ className }) {
|
|
286
|
+
const { alpha, setAlpha } = useColorPicker();
|
|
287
|
+
return /* @__PURE__ */ jsx(ColorSlider, {
|
|
288
|
+
value: alpha,
|
|
289
|
+
max: 100,
|
|
290
|
+
onChange: setAlpha,
|
|
291
|
+
trackStyle: {
|
|
292
|
+
backgroundImage: CHECKER_BG,
|
|
293
|
+
backgroundSize: "contain"
|
|
294
|
+
},
|
|
295
|
+
className,
|
|
296
|
+
children: /* @__PURE__ */ jsx("div", { className: "absolute inset-0 rounded-full bg-gradient-to-r from-transparent to-black/50 dark:to-white/50" })
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
function ColorPickerEyeDropper({ className, children }) {
|
|
300
|
+
const { setHue, setSaturation, setLightness, setAlpha } = useColorPicker();
|
|
301
|
+
const handleEyeDropper = async () => {
|
|
302
|
+
try {
|
|
303
|
+
const [h, s, l] = hexToHsl((await new EyeDropper().open()).sRGBHex);
|
|
304
|
+
setHue(h);
|
|
305
|
+
setSaturation(s);
|
|
306
|
+
setLightness(l);
|
|
307
|
+
setAlpha(100);
|
|
308
|
+
} catch {}
|
|
309
|
+
};
|
|
310
|
+
return /* @__PURE__ */ jsx(Button, {
|
|
311
|
+
type: "button",
|
|
312
|
+
variant: "outline",
|
|
313
|
+
size: "icon",
|
|
314
|
+
className: cn("shrink-0", className),
|
|
315
|
+
onClick: handleEyeDropper,
|
|
316
|
+
children: children || /* @__PURE__ */ jsx(Pipette, { className: "h-4 w-4" })
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
function ColorPickerInput({ className, showAlpha = false }) {
|
|
320
|
+
const { hue, saturation, lightness, alpha } = useColorPicker();
|
|
321
|
+
const hex = hslToHex(hue, saturation, lightness);
|
|
322
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
323
|
+
className: cn("flex items-center gap-2", className),
|
|
324
|
+
children: [/* @__PURE__ */ jsx(Input, {
|
|
325
|
+
readOnly: true,
|
|
326
|
+
value: hex,
|
|
327
|
+
className: "flex-1"
|
|
328
|
+
}), showAlpha && /* @__PURE__ */ jsxs("span", {
|
|
329
|
+
className: "text-sm text-muted-foreground",
|
|
330
|
+
children: [Math.round(alpha), "%"]
|
|
331
|
+
})]
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
function ColorPickerPreview({ className }) {
|
|
335
|
+
const { hue, saturation, lightness, alpha } = useColorPicker();
|
|
336
|
+
const color = hslToHexa(hue, saturation, lightness, alpha / 100);
|
|
337
|
+
return /* @__PURE__ */ jsx("div", {
|
|
338
|
+
className: cn("h-10 w-10 rounded-md border border-input", className),
|
|
339
|
+
style: { backgroundColor: color }
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
//#endregion
|
|
344
|
+
export { ColorPicker, ColorPickerAlpha, ColorPickerEyeDropper, ColorPickerHue, ColorPickerInput, ColorPickerPreview, ColorPickerSelection, useColorPicker, useColorPickerHex };
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/components/gallery/types.d.ts
|
|
5
|
+
interface GalleryImage {
|
|
6
|
+
src: string;
|
|
7
|
+
thumbnail?: string;
|
|
8
|
+
alt?: string;
|
|
9
|
+
}
|
|
10
|
+
interface GalleryBadge {
|
|
11
|
+
label: string;
|
|
12
|
+
className?: string;
|
|
13
|
+
}
|
|
14
|
+
interface GalleryClassNames {
|
|
15
|
+
root?: string;
|
|
16
|
+
main?: string;
|
|
17
|
+
mainImage?: string;
|
|
18
|
+
slider?: string;
|
|
19
|
+
thumbnails?: string;
|
|
20
|
+
thumbnail?: string;
|
|
21
|
+
thumbnailActive?: string;
|
|
22
|
+
dots?: string;
|
|
23
|
+
dot?: string;
|
|
24
|
+
dotActive?: string;
|
|
25
|
+
nav?: string;
|
|
26
|
+
navPrev?: string;
|
|
27
|
+
navNext?: string;
|
|
28
|
+
badges?: string;
|
|
29
|
+
badge?: string;
|
|
30
|
+
lightbox?: string;
|
|
31
|
+
lightboxImage?: string;
|
|
32
|
+
lightboxHeader?: string;
|
|
33
|
+
lightboxFooter?: string;
|
|
34
|
+
}
|
|
35
|
+
interface GalleryContextValue {
|
|
36
|
+
images: GalleryImage[];
|
|
37
|
+
selectedIndex: number;
|
|
38
|
+
setSelectedIndex: (index: number) => void;
|
|
39
|
+
lightboxOpen: boolean;
|
|
40
|
+
setLightboxOpen: (open: boolean) => void;
|
|
41
|
+
goToNext: () => void;
|
|
42
|
+
goToPrevious: () => void;
|
|
43
|
+
classNames?: GalleryClassNames;
|
|
44
|
+
title?: string;
|
|
45
|
+
}
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region src/components/gallery/gallery-main.d.ts
|
|
48
|
+
interface GalleryMainProps {
|
|
49
|
+
children?: ReactNode;
|
|
50
|
+
badges?: GalleryBadge[];
|
|
51
|
+
showNav?: boolean;
|
|
52
|
+
aspectRatio?: string;
|
|
53
|
+
className?: string;
|
|
54
|
+
}
|
|
55
|
+
declare function GalleryMain({
|
|
56
|
+
children,
|
|
57
|
+
badges,
|
|
58
|
+
showNav,
|
|
59
|
+
aspectRatio,
|
|
60
|
+
className
|
|
61
|
+
}: GalleryMainProps): react_jsx_runtime0.JSX.Element;
|
|
62
|
+
//#endregion
|
|
63
|
+
//#region src/components/gallery/gallery-thumbnails.d.ts
|
|
64
|
+
interface GalleryThumbnailsProps {
|
|
65
|
+
/** Show on mobile (default: true) */
|
|
66
|
+
showOnMobile?: boolean;
|
|
67
|
+
/** Layout orientation (default: "horizontal") */
|
|
68
|
+
orientation?: "horizontal" | "vertical";
|
|
69
|
+
/** Thumbnail size class (default: "w-16 h-20 sm:w-20 sm:h-24") */
|
|
70
|
+
sizeClassName?: string;
|
|
71
|
+
className?: string;
|
|
72
|
+
}
|
|
73
|
+
declare function GalleryThumbnails({
|
|
74
|
+
showOnMobile,
|
|
75
|
+
orientation,
|
|
76
|
+
sizeClassName,
|
|
77
|
+
className
|
|
78
|
+
}: GalleryThumbnailsProps): react_jsx_runtime0.JSX.Element | null;
|
|
79
|
+
//#endregion
|
|
80
|
+
//#region src/components/gallery/gallery-dots.d.ts
|
|
81
|
+
interface GalleryDotsProps {
|
|
82
|
+
/** Show on desktop (default: false — dots are usually mobile-only) */
|
|
83
|
+
showOnDesktop?: boolean;
|
|
84
|
+
className?: string;
|
|
85
|
+
}
|
|
86
|
+
declare function GalleryDots({
|
|
87
|
+
showOnDesktop,
|
|
88
|
+
className
|
|
89
|
+
}: GalleryDotsProps): react_jsx_runtime0.JSX.Element | null;
|
|
90
|
+
//#endregion
|
|
91
|
+
//#region src/components/gallery/gallery-lightbox.d.ts
|
|
92
|
+
interface GalleryLightboxProps {
|
|
93
|
+
className?: string;
|
|
94
|
+
}
|
|
95
|
+
declare function GalleryLightbox({
|
|
96
|
+
className
|
|
97
|
+
}: GalleryLightboxProps): react_jsx_runtime0.JSX.Element | null;
|
|
98
|
+
//#endregion
|
|
99
|
+
//#region src/components/gallery/gallery-nav.d.ts
|
|
100
|
+
interface GalleryNavProps {
|
|
101
|
+
/** Which direction this button navigates */
|
|
102
|
+
direction: "prev" | "next";
|
|
103
|
+
className?: string;
|
|
104
|
+
children?: React.ReactNode;
|
|
105
|
+
}
|
|
106
|
+
declare function GalleryNav({
|
|
107
|
+
direction,
|
|
108
|
+
className,
|
|
109
|
+
children
|
|
110
|
+
}: GalleryNavProps): react_jsx_runtime0.JSX.Element | null;
|
|
111
|
+
//#endregion
|
|
112
|
+
//#region src/components/gallery/index.d.ts
|
|
113
|
+
interface ImageGalleryRootProps {
|
|
114
|
+
children: ReactNode;
|
|
115
|
+
images: GalleryImage[];
|
|
116
|
+
defaultIndex?: number;
|
|
117
|
+
classNames?: GalleryClassNames;
|
|
118
|
+
title?: string;
|
|
119
|
+
onIndexChange?: (index: number) => void;
|
|
120
|
+
className?: string;
|
|
121
|
+
}
|
|
122
|
+
declare function ImageGalleryRoot({
|
|
123
|
+
children,
|
|
124
|
+
images,
|
|
125
|
+
defaultIndex,
|
|
126
|
+
classNames,
|
|
127
|
+
title,
|
|
128
|
+
onIndexChange,
|
|
129
|
+
className
|
|
130
|
+
}: ImageGalleryRootProps): react_jsx_runtime0.JSX.Element;
|
|
131
|
+
interface ImageGalleryProps {
|
|
132
|
+
images: GalleryImage[];
|
|
133
|
+
title?: string;
|
|
134
|
+
badges?: GalleryBadge[];
|
|
135
|
+
/** Default selected index */
|
|
136
|
+
defaultIndex?: number;
|
|
137
|
+
/** Show thumbnails on mobile (default: true). If false, shows dots */
|
|
138
|
+
showMobileThumbnails?: boolean;
|
|
139
|
+
/** Main image aspect ratio */
|
|
140
|
+
aspectRatio?: string;
|
|
141
|
+
/** Show navigation arrows */
|
|
142
|
+
showNav?: boolean;
|
|
143
|
+
/** Custom class names for styling */
|
|
144
|
+
classNames?: GalleryClassNames;
|
|
145
|
+
/** Callback when index changes */
|
|
146
|
+
onIndexChange?: (index: number) => void;
|
|
147
|
+
/** Root className */
|
|
148
|
+
className?: string;
|
|
149
|
+
}
|
|
150
|
+
declare function ImageGallerySimple({
|
|
151
|
+
images,
|
|
152
|
+
title,
|
|
153
|
+
badges,
|
|
154
|
+
defaultIndex,
|
|
155
|
+
showMobileThumbnails,
|
|
156
|
+
aspectRatio,
|
|
157
|
+
showNav,
|
|
158
|
+
classNames,
|
|
159
|
+
onIndexChange,
|
|
160
|
+
className
|
|
161
|
+
}: ImageGalleryProps): react_jsx_runtime0.JSX.Element;
|
|
162
|
+
declare const ImageGallery: typeof ImageGallerySimple & {
|
|
163
|
+
Root: typeof ImageGalleryRoot;
|
|
164
|
+
Main: typeof GalleryMain;
|
|
165
|
+
Thumbnails: typeof GalleryThumbnails;
|
|
166
|
+
Dots: typeof GalleryDots;
|
|
167
|
+
Nav: typeof GalleryNav;
|
|
168
|
+
Lightbox: typeof GalleryLightbox;
|
|
169
|
+
};
|
|
170
|
+
//#endregion
|
|
171
|
+
//#region src/components/gallery/gallery-context.d.ts
|
|
172
|
+
declare function useGallery(): GalleryContextValue;
|
|
173
|
+
declare function useGalleryOptional(): GalleryContextValue | null;
|
|
174
|
+
//#endregion
|
|
175
|
+
export { type GalleryBadge, type GalleryClassNames, type GalleryImage, ImageGallery, type ImageGalleryProps, useGallery, useGalleryOptional };
|