seppia 0.0.0-stage → 0.1.0
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/LICENSE +21 -0
- package/README.md +92 -3
- package/dist/chunk-2PABDSNH.cjs +208 -0
- package/dist/chunk-2Z4YKJMT.js +329 -0
- package/dist/chunk-344MRWFO.js +25 -0
- package/dist/chunk-3A2LHCPV.cjs +30 -0
- package/dist/chunk-3NQ776G6.cjs +204 -0
- package/dist/chunk-3XIEBFVO.cjs +130 -0
- package/dist/chunk-4IHNW52F.cjs +197 -0
- package/dist/chunk-4YGBUMQC.js +160 -0
- package/dist/chunk-5ARTY5RT.cjs +66 -0
- package/dist/chunk-5PAJS63K.cjs +156 -0
- package/dist/chunk-5Z32CAHE.cjs +261 -0
- package/dist/chunk-66ITQTT2.js +108 -0
- package/dist/chunk-6EABLOB7.js +190 -0
- package/dist/chunk-6FF73V3S.js +190 -0
- package/dist/chunk-6LRDNOZX.cjs +138 -0
- package/dist/chunk-76MEQHGW.js +192 -0
- package/dist/chunk-7B2YEOYF.js +26 -0
- package/dist/chunk-7Y22U2ZF.js +370 -0
- package/dist/chunk-AFGJQET4.js +186 -0
- package/dist/chunk-AG3OBSP5.cjs +216 -0
- package/dist/chunk-AHRXESD2.js +126 -0
- package/dist/chunk-AJPI65BL.cjs +153 -0
- package/dist/chunk-CCDDQHCS.js +182 -0
- package/dist/chunk-CGX6YCV6.js +130 -0
- package/dist/chunk-CPUW5LDN.cjs +28 -0
- package/dist/chunk-DAO7YH2R.cjs +165 -0
- package/dist/chunk-DO5WEBTN.cjs +139 -0
- package/dist/chunk-DUUDPN7C.cjs +203 -0
- package/dist/chunk-EOPY2VWT.cjs +185 -0
- package/dist/chunk-EUQ6BCML.cjs +175 -0
- package/dist/chunk-EYO4XMKU.js +145 -0
- package/dist/chunk-F7UECO7G.js +175 -0
- package/dist/chunk-FGJDDSUJ.js +303 -0
- package/dist/chunk-G5UZZ2XG.cjs +52 -0
- package/dist/chunk-GJ6WO63L.js +216 -0
- package/dist/chunk-GP32TY6P.cjs +409 -0
- package/dist/chunk-HQLB5Z37.cjs +275 -0
- package/dist/chunk-HSXGQNQ6.js +143 -0
- package/dist/chunk-I2XZ2WMY.js +385 -0
- package/dist/chunk-I525FOTN.cjs +214 -0
- package/dist/chunk-IAPRIVJO.js +157 -0
- package/dist/chunk-IUSSIILO.cjs +393 -0
- package/dist/chunk-JV6GJ3JJ.js +92 -0
- package/dist/chunk-KPG24YFL.js +30 -0
- package/dist/chunk-LGBMJIY6.js +174 -0
- package/dist/chunk-LYEOVFOQ.cjs +148 -0
- package/dist/chunk-LYYMITLC.js +238 -0
- package/dist/chunk-M42F5QS5.cjs +212 -0
- package/dist/chunk-NN3HMY7H.cjs +260 -0
- package/dist/chunk-NU5MGYFP.cjs +167 -0
- package/dist/chunk-OCIKUJ3U.js +117 -0
- package/dist/chunk-PBMXL53R.cjs +39 -0
- package/dist/chunk-PGEK6DFE.cjs +351 -0
- package/dist/chunk-QPWVBVDC.cjs +130 -0
- package/dist/chunk-QWYHH465.cjs +117 -0
- package/dist/chunk-RFCZJPGM.js +116 -0
- package/dist/chunk-RIBXHAKG.cjs +179 -0
- package/dist/chunk-SDWRKTFC.cjs +158 -0
- package/dist/chunk-SMY24MVU.js +92 -0
- package/dist/chunk-SSARMSS3.cjs +325 -0
- package/dist/chunk-T533JPW5.js +131 -0
- package/dist/chunk-T7AMVHIB.js +221 -0
- package/dist/chunk-TVGVZSIA.js +130 -0
- package/dist/chunk-UFU5S3LK.cjs +244 -0
- package/dist/chunk-UFUN2OKY.js +35 -0
- package/dist/chunk-VDSMO63G.cjs +153 -0
- package/dist/chunk-VHXWP5OX.cjs +115 -0
- package/dist/chunk-VW32EE3I.js +153 -0
- package/dist/chunk-WGFJLFTP.js +40 -0
- package/dist/chunk-WSL2OVTO.js +136 -0
- package/dist/chunk-WVWVJSU2.cjs +309 -0
- package/dist/chunk-XLZPYDNI.js +287 -0
- package/dist/chunk-XUBFOAT4.js +239 -0
- package/dist/chunk-Y3UCNSXF.js +253 -0
- package/dist/chunk-YDJMVDAJ.cjs +196 -0
- package/dist/chunk-ZF5HY2K4.cjs +238 -0
- package/dist/chunk-ZXKEYL6L.js +181 -0
- package/dist/chunk-ZZYMYQU2.js +108 -0
- package/dist/components/accordion.cjs +26 -0
- package/dist/components/accordion.d.cts +41 -0
- package/dist/components/accordion.d.ts +41 -0
- package/dist/components/accordion.js +5 -0
- package/dist/components/calendar.cjs +14 -0
- package/dist/components/calendar.d.cts +41 -0
- package/dist/components/calendar.d.ts +41 -0
- package/dist/components/calendar.js +5 -0
- package/dist/components/checkbox.cjs +14 -0
- package/dist/components/checkbox.d.cts +27 -0
- package/dist/components/checkbox.d.ts +27 -0
- package/dist/components/checkbox.js +5 -0
- package/dist/components/chip-select.cjs +14 -0
- package/dist/components/chip-select.d.cts +31 -0
- package/dist/components/chip-select.d.ts +31 -0
- package/dist/components/chip-select.js +5 -0
- package/dist/components/clock.cjs +12 -0
- package/dist/components/clock.d.cts +25 -0
- package/dist/components/clock.d.ts +25 -0
- package/dist/components/clock.js +3 -0
- package/dist/components/color-picker.cjs +14 -0
- package/dist/components/color-picker.d.cts +23 -0
- package/dist/components/color-picker.d.ts +23 -0
- package/dist/components/color-picker.js +5 -0
- package/dist/components/command-palette.cjs +20 -0
- package/dist/components/command-palette.d.cts +53 -0
- package/dist/components/command-palette.d.ts +53 -0
- package/dist/components/command-palette.js +7 -0
- package/dist/components/date-picker.cjs +18 -0
- package/dist/components/date-picker.d.cts +40 -0
- package/dist/components/date-picker.d.ts +40 -0
- package/dist/components/date-picker.js +9 -0
- package/dist/components/drawer.cjs +16 -0
- package/dist/components/drawer.d.cts +22 -0
- package/dist/components/drawer.d.ts +22 -0
- package/dist/components/drawer.js +7 -0
- package/dist/components/floating-panel.cjs +13 -0
- package/dist/components/floating-panel.d.cts +25 -0
- package/dist/components/floating-panel.d.ts +25 -0
- package/dist/components/floating-panel.js +4 -0
- package/dist/components/hold-button.cjs +13 -0
- package/dist/components/hold-button.d.cts +30 -0
- package/dist/components/hold-button.d.ts +30 -0
- package/dist/components/hold-button.js +4 -0
- package/dist/components/knob.cjs +15 -0
- package/dist/components/knob.d.cts +33 -0
- package/dist/components/knob.d.ts +33 -0
- package/dist/components/knob.js +6 -0
- package/dist/components/magnetic-button.cjs +13 -0
- package/dist/components/magnetic-button.d.cts +23 -0
- package/dist/components/magnetic-button.d.ts +23 -0
- package/dist/components/magnetic-button.js +4 -0
- package/dist/components/morph-button.cjs +13 -0
- package/dist/components/morph-button.d.cts +34 -0
- package/dist/components/morph-button.d.ts +34 -0
- package/dist/components/morph-button.js +4 -0
- package/dist/components/morph-dialog.cjs +32 -0
- package/dist/components/morph-dialog.d.cts +30 -0
- package/dist/components/morph-dialog.d.ts +30 -0
- package/dist/components/morph-dialog.js +7 -0
- package/dist/components/number-field.cjs +15 -0
- package/dist/components/number-field.d.cts +32 -0
- package/dist/components/number-field.d.ts +32 -0
- package/dist/components/number-field.js +6 -0
- package/dist/components/pin-input.cjs +14 -0
- package/dist/components/pin-input.d.cts +29 -0
- package/dist/components/pin-input.d.ts +29 -0
- package/dist/components/pin-input.js +5 -0
- package/dist/components/popover.cjs +16 -0
- package/dist/components/popover.d.cts +26 -0
- package/dist/components/popover.d.ts +26 -0
- package/dist/components/popover.js +7 -0
- package/dist/components/progress.cjs +17 -0
- package/dist/components/progress.d.cts +39 -0
- package/dist/components/progress.d.ts +39 -0
- package/dist/components/progress.js +4 -0
- package/dist/components/radial-menu.cjs +14 -0
- package/dist/components/radial-menu.d.cts +31 -0
- package/dist/components/radial-menu.d.ts +31 -0
- package/dist/components/radial-menu.js +5 -0
- package/dist/components/radio-group.cjs +14 -0
- package/dist/components/radio-group.d.cts +34 -0
- package/dist/components/radio-group.d.ts +34 -0
- package/dist/components/radio-group.js +5 -0
- package/dist/components/resizable-panels.cjs +18 -0
- package/dist/components/resizable-panels.d.cts +24 -0
- package/dist/components/resizable-panels.d.ts +24 -0
- package/dist/components/resizable-panels.js +5 -0
- package/dist/components/segmented-control.cjs +14 -0
- package/dist/components/segmented-control.d.cts +34 -0
- package/dist/components/segmented-control.d.ts +34 -0
- package/dist/components/segmented-control.js +5 -0
- package/dist/components/slider.cjs +15 -0
- package/dist/components/slider.d.cts +39 -0
- package/dist/components/slider.d.ts +39 -0
- package/dist/components/slider.js +6 -0
- package/dist/components/sortable-list.cjs +13 -0
- package/dist/components/sortable-list.d.cts +24 -0
- package/dist/components/sortable-list.d.ts +24 -0
- package/dist/components/sortable-list.js +4 -0
- package/dist/components/sparkline.cjs +14 -0
- package/dist/components/sparkline.d.cts +28 -0
- package/dist/components/sparkline.d.ts +28 -0
- package/dist/components/sparkline.js +5 -0
- package/dist/components/swipe-confirm.cjs +13 -0
- package/dist/components/swipe-confirm.d.cts +18 -0
- package/dist/components/swipe-confirm.d.ts +18 -0
- package/dist/components/swipe-confirm.js +4 -0
- package/dist/components/switch.cjs +15 -0
- package/dist/components/switch.d.cts +29 -0
- package/dist/components/switch.d.ts +29 -0
- package/dist/components/switch.js +6 -0
- package/dist/components/tabs.cjs +30 -0
- package/dist/components/tabs.d.cts +29 -0
- package/dist/components/tabs.d.ts +29 -0
- package/dist/components/tabs.js +5 -0
- package/dist/components/tether.cjs +16 -0
- package/dist/components/tether.d.cts +35 -0
- package/dist/components/tether.d.ts +35 -0
- package/dist/components/tether.js +3 -0
- package/dist/components/theme-switch.cjs +14 -0
- package/dist/components/theme-switch.d.cts +24 -0
- package/dist/components/theme-switch.d.ts +24 -0
- package/dist/components/theme-switch.js +5 -0
- package/dist/components/toaster.cjs +21 -0
- package/dist/components/toaster.d.cts +71 -0
- package/dist/components/toaster.d.ts +71 -0
- package/dist/components/toaster.js +4 -0
- package/dist/components/wheel-picker.cjs +15 -0
- package/dist/components/wheel-picker.d.cts +27 -0
- package/dist/components/wheel-picker.d.ts +27 -0
- package/dist/components/wheel-picker.js +6 -0
- package/dist/css/accordion.css +2 -0
- package/dist/css/base.css +2 -0
- package/dist/css/calendar.css +2 -0
- package/dist/css/checkbox.css +2 -0
- package/dist/css/chip-select.css +2 -0
- package/dist/css/clock.css +2 -0
- package/dist/css/color-picker.css +2 -0
- package/dist/css/command-palette.css +2 -0
- package/dist/css/date-picker.css +2 -0
- package/dist/css/drawer.css +2 -0
- package/dist/css/floating-panel.css +2 -0
- package/dist/css/hold-button.css +2 -0
- package/dist/css/knob.css +2 -0
- package/dist/css/magnetic-button.css +2 -0
- package/dist/css/morph-button.css +2 -0
- package/dist/css/morph-dialog.css +2 -0
- package/dist/css/number-field.css +2 -0
- package/dist/css/pin-input.css +2 -0
- package/dist/css/popover.css +2 -0
- package/dist/css/progress.css +2 -0
- package/dist/css/radial-menu.css +2 -0
- package/dist/css/radio-group.css +2 -0
- package/dist/css/resizable-panels.css +2 -0
- package/dist/css/segmented-control.css +2 -0
- package/dist/css/slider.css +2 -0
- package/dist/css/sortable-list.css +2 -0
- package/dist/css/sparkline.css +2 -0
- package/dist/css/swipe-confirm.css +2 -0
- package/dist/css/switch.css +2 -0
- package/dist/css/tabs.css +2 -0
- package/dist/css/tether.css +2 -0
- package/dist/css/theme-switch.css +2 -0
- package/dist/css/toaster.css +2 -0
- package/dist/css/wheel-picker.css +2 -0
- package/dist/index.cjs +249 -0
- package/dist/index.d.cts +77 -0
- package/dist/index.d.ts +77 -0
- package/dist/index.js +40 -0
- package/dist/styles.css +2 -0
- package/package.json +98 -6
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { haptic, useIsoLayoutEffect } from './chunk-WGFJLFTP.js';
|
|
3
|
+
import { useControllableState } from './chunk-KPG24YFL.js';
|
|
4
|
+
import { cx, useMotionPreset } from './chunk-UFUN2OKY.js';
|
|
5
|
+
import * as React from 'react';
|
|
6
|
+
import { motion, useMotionValue, animate } from 'motion/react';
|
|
7
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
8
|
+
|
|
9
|
+
function useSystemDark() {
|
|
10
|
+
const [dark, setDark] = React.useState(false);
|
|
11
|
+
React.useEffect(() => {
|
|
12
|
+
if (typeof window === "undefined" || !window.matchMedia) return;
|
|
13
|
+
const mq = window.matchMedia("(prefers-color-scheme: dark)");
|
|
14
|
+
const update = () => setDark(mq.matches);
|
|
15
|
+
update();
|
|
16
|
+
mq.addEventListener?.("change", update);
|
|
17
|
+
return () => mq.removeEventListener?.("change", update);
|
|
18
|
+
}, []);
|
|
19
|
+
return dark;
|
|
20
|
+
}
|
|
21
|
+
var SPRING = { type: "spring", stiffness: 380, damping: 26, mass: 0.9 };
|
|
22
|
+
var ThemeSwitch = React.forwardRef(function ThemeSwitch2({ value, defaultValue = "light", onValueChange, variant = "eclipse", size = "md", label = "Dark mode", disabled, haptics = true, className, ...rest }, ref) {
|
|
23
|
+
const [theme, setTheme] = useControllableState({ value, defaultValue, onChange: onValueChange });
|
|
24
|
+
const systemDark = useSystemDark();
|
|
25
|
+
const dark = theme === "dark" || theme === "system" && systemDark;
|
|
26
|
+
const toggle = () => {
|
|
27
|
+
if (disabled) return;
|
|
28
|
+
if (haptics) haptic(6);
|
|
29
|
+
setTheme(dark ? "light" : "dark");
|
|
30
|
+
};
|
|
31
|
+
if (variant === "segmented") {
|
|
32
|
+
return /* @__PURE__ */ jsx(
|
|
33
|
+
Segmented,
|
|
34
|
+
{
|
|
35
|
+
...rest,
|
|
36
|
+
ref,
|
|
37
|
+
theme,
|
|
38
|
+
onSelect: (next) => {
|
|
39
|
+
if (haptics) haptic(5);
|
|
40
|
+
setTheme(next);
|
|
41
|
+
},
|
|
42
|
+
size,
|
|
43
|
+
disabled,
|
|
44
|
+
className
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
return /* @__PURE__ */ jsx(
|
|
49
|
+
"button",
|
|
50
|
+
{
|
|
51
|
+
...rest,
|
|
52
|
+
ref,
|
|
53
|
+
type: "button",
|
|
54
|
+
role: "switch",
|
|
55
|
+
"aria-checked": dark,
|
|
56
|
+
"aria-label": label,
|
|
57
|
+
disabled,
|
|
58
|
+
"data-variant": variant,
|
|
59
|
+
"data-size": size,
|
|
60
|
+
"data-state": dark ? "dark" : "light",
|
|
61
|
+
className: cx("fl-reset-button fl-theme-switch", className),
|
|
62
|
+
onClick: (e) => {
|
|
63
|
+
rest.onClick?.(e);
|
|
64
|
+
if (!e.defaultPrevented) toggle();
|
|
65
|
+
},
|
|
66
|
+
children: variant === "horizon" ? /* @__PURE__ */ jsx(Horizon, { dark }) : /* @__PURE__ */ jsx(Eclipse, { dark })
|
|
67
|
+
}
|
|
68
|
+
);
|
|
69
|
+
});
|
|
70
|
+
function useSafeId(prefix) {
|
|
71
|
+
return `${prefix}${React.useId().replace(/[^a-zA-Z0-9_-]/g, "")}`;
|
|
72
|
+
}
|
|
73
|
+
function Eclipse({ dark }) {
|
|
74
|
+
const { t } = useMotionPreset();
|
|
75
|
+
const maskId = useSafeId("fl-eclipse-");
|
|
76
|
+
const rays = Array.from({ length: 8 }, (_, i) => i * 45);
|
|
77
|
+
return /* @__PURE__ */ jsxs(
|
|
78
|
+
motion.svg,
|
|
79
|
+
{
|
|
80
|
+
className: "fl-theme-switch__icon",
|
|
81
|
+
viewBox: "0 0 24 24",
|
|
82
|
+
"aria-hidden": true,
|
|
83
|
+
initial: false,
|
|
84
|
+
animate: { rotate: dark ? -40 : 0 },
|
|
85
|
+
transition: t(SPRING),
|
|
86
|
+
children: [
|
|
87
|
+
/* @__PURE__ */ jsxs("mask", { id: maskId, children: [
|
|
88
|
+
/* @__PURE__ */ jsx("rect", { x: "0", y: "0", width: "24", height: "24", fill: "white" }),
|
|
89
|
+
/* @__PURE__ */ jsx(
|
|
90
|
+
motion.circle,
|
|
91
|
+
{
|
|
92
|
+
fill: "black",
|
|
93
|
+
initial: false,
|
|
94
|
+
animate: dark ? { cx: 17, cy: 7, r: 7.2 } : { cx: 27, cy: -3, r: 6 },
|
|
95
|
+
transition: t(SPRING)
|
|
96
|
+
}
|
|
97
|
+
)
|
|
98
|
+
] }),
|
|
99
|
+
/* @__PURE__ */ jsx(
|
|
100
|
+
motion.circle,
|
|
101
|
+
{
|
|
102
|
+
cx: "12",
|
|
103
|
+
cy: "12",
|
|
104
|
+
fill: "currentColor",
|
|
105
|
+
mask: `url(#${maskId})`,
|
|
106
|
+
initial: false,
|
|
107
|
+
animate: { r: dark ? 8.6 : 4.6 },
|
|
108
|
+
transition: t(dark ? SPRING : { ...SPRING, stiffness: 520 })
|
|
109
|
+
}
|
|
110
|
+
),
|
|
111
|
+
/* @__PURE__ */ jsx("g", { children: rays.map((angle, i) => /* @__PURE__ */ jsx("g", { transform: `rotate(${angle} 12 12)`, children: /* @__PURE__ */ jsx(
|
|
112
|
+
motion.line,
|
|
113
|
+
{
|
|
114
|
+
x1: "12",
|
|
115
|
+
x2: "12",
|
|
116
|
+
stroke: "currentColor",
|
|
117
|
+
strokeWidth: "1.8",
|
|
118
|
+
strokeLinecap: "round",
|
|
119
|
+
initial: false,
|
|
120
|
+
animate: dark ? { y1: 6.4, y2: 6.4, opacity: 0 } : { y1: 2.4, y2: 4.4, opacity: 1 },
|
|
121
|
+
transition: t({ ...SPRING, delay: dark ? i * 0.012 : 0.08 + i * 0.022 })
|
|
122
|
+
}
|
|
123
|
+
) }, angle)) }),
|
|
124
|
+
[
|
|
125
|
+
{ x: 19.2, y: 15.5, s: 1.2, d: 0.12 },
|
|
126
|
+
{ x: 16.4, y: 19.6, s: 0.85, d: 0.2 }
|
|
127
|
+
].map((star) => /* @__PURE__ */ jsx(
|
|
128
|
+
motion.path,
|
|
129
|
+
{
|
|
130
|
+
d: `M${star.x} ${star.y - 1.6 * star.s}L${star.x + 0.42 * star.s} ${star.y - 0.42 * star.s}L${star.x + 1.6 * star.s} ${star.y}L${star.x + 0.42 * star.s} ${star.y + 0.42 * star.s}L${star.x} ${star.y + 1.6 * star.s}L${star.x - 0.42 * star.s} ${star.y + 0.42 * star.s}L${star.x - 1.6 * star.s} ${star.y}L${star.x - 0.42 * star.s} ${star.y - 0.42 * star.s}Z`,
|
|
131
|
+
fill: "currentColor",
|
|
132
|
+
initial: false,
|
|
133
|
+
animate: dark ? { scale: 1, opacity: 1, rotate: 0 } : { scale: 0, opacity: 0, rotate: -90 },
|
|
134
|
+
transition: t({ type: "spring", stiffness: 500, damping: 20, delay: dark ? star.d : 0 })
|
|
135
|
+
},
|
|
136
|
+
star.x
|
|
137
|
+
))
|
|
138
|
+
]
|
|
139
|
+
}
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
function Horizon({ dark }) {
|
|
143
|
+
const { t } = useMotionPreset();
|
|
144
|
+
const rotate = useMotionValue(dark ? 180 : 0);
|
|
145
|
+
const first = React.useRef(true);
|
|
146
|
+
useIsoLayoutEffect(() => {
|
|
147
|
+
if (first.current) {
|
|
148
|
+
first.current = false;
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
const current = rotate.get();
|
|
152
|
+
const target = Math.ceil((current + 1) / 180) * 180;
|
|
153
|
+
animate(rotate, target, t({ type: "spring", stiffness: 120, damping: 17, mass: 1 }));
|
|
154
|
+
}, [dark]);
|
|
155
|
+
return /* @__PURE__ */ jsxs("span", { className: "fl-theme-switch__sky", "aria-hidden": true, children: [
|
|
156
|
+
[0, 1, 2].map((i) => /* @__PURE__ */ jsx(
|
|
157
|
+
motion.span,
|
|
158
|
+
{
|
|
159
|
+
className: "fl-theme-switch__star",
|
|
160
|
+
"data-i": i,
|
|
161
|
+
initial: false,
|
|
162
|
+
animate: dark ? { opacity: 1, scale: 1 } : { opacity: 0, scale: 0.2 },
|
|
163
|
+
transition: t({ type: "spring", stiffness: 400, damping: 22, delay: dark ? 0.25 + i * 0.07 : 0 })
|
|
164
|
+
},
|
|
165
|
+
i
|
|
166
|
+
)),
|
|
167
|
+
/* @__PURE__ */ jsxs(motion.span, { className: "fl-theme-switch__wheel", style: { rotate }, children: [
|
|
168
|
+
/* @__PURE__ */ jsx("span", { className: "fl-theme-switch__body", "data-body": "sun" }),
|
|
169
|
+
/* @__PURE__ */ jsx("span", { className: "fl-theme-switch__body", "data-body": "moon" })
|
|
170
|
+
] }),
|
|
171
|
+
/* @__PURE__ */ jsx("span", { className: "fl-theme-switch__ground" })
|
|
172
|
+
] });
|
|
173
|
+
}
|
|
174
|
+
var OPTIONS = [
|
|
175
|
+
{ value: "light", label: "Light" },
|
|
176
|
+
{ value: "system", label: "System" },
|
|
177
|
+
{ value: "dark", label: "Dark" }
|
|
178
|
+
];
|
|
179
|
+
var Segmented = React.forwardRef(function Segmented2({ theme, onSelect, size, disabled, className, ...rest }, ref) {
|
|
180
|
+
const { t } = useMotionPreset();
|
|
181
|
+
const index = OPTIONS.findIndex((o) => o.value === theme);
|
|
182
|
+
const buttons = React.useRef([]);
|
|
183
|
+
const onKeyDown = (event) => {
|
|
184
|
+
const delta = event.key === "ArrowRight" || event.key === "ArrowDown" ? 1 : event.key === "ArrowLeft" || event.key === "ArrowUp" ? -1 : 0;
|
|
185
|
+
if (!delta) return;
|
|
186
|
+
event.preventDefault();
|
|
187
|
+
const next = (index + delta + OPTIONS.length) % OPTIONS.length;
|
|
188
|
+
onSelect(OPTIONS[next].value);
|
|
189
|
+
buttons.current[next]?.focus();
|
|
190
|
+
};
|
|
191
|
+
return /* @__PURE__ */ jsxs(
|
|
192
|
+
"div",
|
|
193
|
+
{
|
|
194
|
+
...rest,
|
|
195
|
+
ref,
|
|
196
|
+
role: "radiogroup",
|
|
197
|
+
"aria-label": rest["aria-label"] ?? "Theme",
|
|
198
|
+
"data-variant": "segmented",
|
|
199
|
+
"data-size": size,
|
|
200
|
+
className: cx("fl-theme-switch", className),
|
|
201
|
+
onKeyDown,
|
|
202
|
+
children: [
|
|
203
|
+
/* @__PURE__ */ jsx(
|
|
204
|
+
motion.span,
|
|
205
|
+
{
|
|
206
|
+
className: "fl-theme-switch__thumb",
|
|
207
|
+
"aria-hidden": true,
|
|
208
|
+
initial: false,
|
|
209
|
+
animate: { x: `${index * 100}%` },
|
|
210
|
+
transition: t({ type: "spring", stiffness: 560, damping: 34 })
|
|
211
|
+
}
|
|
212
|
+
),
|
|
213
|
+
OPTIONS.map((option, i) => /* @__PURE__ */ jsx(
|
|
214
|
+
"button",
|
|
215
|
+
{
|
|
216
|
+
ref: (el) => {
|
|
217
|
+
buttons.current[i] = el;
|
|
218
|
+
},
|
|
219
|
+
type: "button",
|
|
220
|
+
role: "radio",
|
|
221
|
+
"aria-checked": theme === option.value,
|
|
222
|
+
"aria-label": option.label,
|
|
223
|
+
title: option.label,
|
|
224
|
+
tabIndex: theme === option.value ? 0 : -1,
|
|
225
|
+
disabled,
|
|
226
|
+
"data-state": theme === option.value ? "checked" : "unchecked",
|
|
227
|
+
className: "fl-reset-button fl-theme-switch__option",
|
|
228
|
+
onClick: () => onSelect(option.value),
|
|
229
|
+
children: /* @__PURE__ */ jsx(OptionIcon, { kind: option.value, active: theme === option.value })
|
|
230
|
+
},
|
|
231
|
+
option.value
|
|
232
|
+
))
|
|
233
|
+
]
|
|
234
|
+
}
|
|
235
|
+
);
|
|
236
|
+
});
|
|
237
|
+
function OptionIcon({ kind, active }) {
|
|
238
|
+
const { t } = useMotionPreset();
|
|
239
|
+
const pop = { scale: active ? 1 : 0.86, rotate: active && kind === "light" ? 45 : 0 };
|
|
240
|
+
return /* @__PURE__ */ jsxs(motion.svg, { viewBox: "0 0 16 16", width: "14", height: "14", "aria-hidden": true, initial: false, animate: pop, transition: t({ type: "spring", stiffness: 500, damping: 20 }), children: [
|
|
241
|
+
kind === "light" && /* @__PURE__ */ jsxs("g", { fill: "none", stroke: "currentColor", strokeWidth: "1.4", strokeLinecap: "round", children: [
|
|
242
|
+
/* @__PURE__ */ jsx("circle", { cx: "8", cy: "8", r: "2.6" }),
|
|
243
|
+
/* @__PURE__ */ jsx("path", { d: "M8 1.6v1.3M8 13.1v1.3M1.6 8h1.3M13.1 8h1.3M3.5 3.5l.9.9M11.6 11.6l.9.9M3.5 12.5l.9-.9M11.6 4.4l.9-.9" })
|
|
244
|
+
] }),
|
|
245
|
+
kind === "system" && /* @__PURE__ */ jsxs("g", { fill: "none", stroke: "currentColor", strokeWidth: "1.4", strokeLinejoin: "round", strokeLinecap: "round", children: [
|
|
246
|
+
/* @__PURE__ */ jsx("rect", { x: "1.8", y: "2.6", width: "12.4", height: "8.6", rx: "1.6" }),
|
|
247
|
+
/* @__PURE__ */ jsx("path", { d: "M5.6 13.6h4.8" })
|
|
248
|
+
] }),
|
|
249
|
+
kind === "dark" && /* @__PURE__ */ jsx("path", { d: "M13.4 9.6A5.6 5.6 0 0 1 6.4 2.6a5.6 5.6 0 1 0 7 7Z", fill: "none", stroke: "currentColor", strokeWidth: "1.4", strokeLinejoin: "round" })
|
|
250
|
+
] });
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
export { ThemeSwitch };
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var chunk3A2LHCPV_cjs = require('./chunk-3A2LHCPV.cjs');
|
|
5
|
+
var chunk5ARTY5RT_cjs = require('./chunk-5ARTY5RT.cjs');
|
|
6
|
+
var chunkG5UZZ2XG_cjs = require('./chunk-G5UZZ2XG.cjs');
|
|
7
|
+
var chunkPBMXL53R_cjs = require('./chunk-PBMXL53R.cjs');
|
|
8
|
+
var React = require('react');
|
|
9
|
+
var react = require('motion/react');
|
|
10
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
11
|
+
|
|
12
|
+
function _interopNamespace(e) {
|
|
13
|
+
if (e && e.__esModule) return e;
|
|
14
|
+
var n = Object.create(null);
|
|
15
|
+
if (e) {
|
|
16
|
+
Object.keys(e).forEach(function (k) {
|
|
17
|
+
if (k !== 'default') {
|
|
18
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
19
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () { return e[k]; }
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
n.default = e;
|
|
27
|
+
return Object.freeze(n);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
31
|
+
|
|
32
|
+
var SPRING = { type: "spring", stiffness: 520, damping: 32 };
|
|
33
|
+
function polar(cx2, cy, r, deg) {
|
|
34
|
+
const rad = (deg - 90) * Math.PI / 180;
|
|
35
|
+
return { x: cx2 + r * Math.cos(rad), y: cy + r * Math.sin(rad) };
|
|
36
|
+
}
|
|
37
|
+
function arcPath(cx2, cy, r, start, end) {
|
|
38
|
+
const a = polar(cx2, cy, r, start);
|
|
39
|
+
const b = polar(cx2, cy, r, end);
|
|
40
|
+
const large = end - start > 180 ? 1 : 0;
|
|
41
|
+
return `M ${a.x} ${a.y} A ${r} ${r} 0 ${large} 1 ${b.x} ${b.y}`;
|
|
42
|
+
}
|
|
43
|
+
var Knob = React__namespace.forwardRef(function Knob2({
|
|
44
|
+
value: valueProp,
|
|
45
|
+
defaultValue,
|
|
46
|
+
onValueChange,
|
|
47
|
+
onValueCommit,
|
|
48
|
+
min = 0,
|
|
49
|
+
max = 100,
|
|
50
|
+
step = 1,
|
|
51
|
+
variant = "arc",
|
|
52
|
+
size = 88,
|
|
53
|
+
arc = 270,
|
|
54
|
+
label,
|
|
55
|
+
formatValue = (v) => String(v),
|
|
56
|
+
ticks = 11,
|
|
57
|
+
sensitivity = 220,
|
|
58
|
+
disabled,
|
|
59
|
+
haptics = true,
|
|
60
|
+
className,
|
|
61
|
+
style,
|
|
62
|
+
...rest
|
|
63
|
+
}, ref) {
|
|
64
|
+
const initial = defaultValue ?? min;
|
|
65
|
+
const [value, setValue] = chunkG5UZZ2XG_cjs.useControllableState({ value: valueProp, defaultValue: initial, onChange: onValueChange });
|
|
66
|
+
const { t } = chunkPBMXL53R_cjs.useMotionPreset();
|
|
67
|
+
const local = React__namespace.useRef(null);
|
|
68
|
+
const frac = (v) => max === min ? 0 : (v - min) / (max - min);
|
|
69
|
+
const f = react.useMotionValue(frac(value));
|
|
70
|
+
const drag = React__namespace.useRef(null);
|
|
71
|
+
const [active, setActive] = React__namespace.useState(false);
|
|
72
|
+
const latest = React__namespace.useRef(value);
|
|
73
|
+
latest.current = value;
|
|
74
|
+
React__namespace.useEffect(() => {
|
|
75
|
+
react.animate(f, frac(value), t(SPRING));
|
|
76
|
+
}, [value, min, max]);
|
|
77
|
+
const commitValue = (v) => {
|
|
78
|
+
const next = chunk3A2LHCPV_cjs.clamp(chunk3A2LHCPV_cjs.snapToStep(v, step, min), min, max);
|
|
79
|
+
if (next !== latest.current) {
|
|
80
|
+
if (haptics && step >= (max - min) / 40) chunk5ARTY5RT_cjs.haptic(3);
|
|
81
|
+
setValue(next);
|
|
82
|
+
}
|
|
83
|
+
return next;
|
|
84
|
+
};
|
|
85
|
+
React__namespace.useEffect(() => {
|
|
86
|
+
const el = local.current;
|
|
87
|
+
if (!el || disabled) return;
|
|
88
|
+
const onWheel = (event) => {
|
|
89
|
+
event.preventDefault();
|
|
90
|
+
const delta = -event.deltaY / (event.shiftKey ? 600 : 160);
|
|
91
|
+
commitValue(latest.current + delta * (max - min) * 0.1 + Math.sign(delta) * 1e-4);
|
|
92
|
+
};
|
|
93
|
+
el.addEventListener("wheel", onWheel, { passive: false });
|
|
94
|
+
return () => el.removeEventListener("wheel", onWheel);
|
|
95
|
+
}, [disabled, min, max, step]);
|
|
96
|
+
const onPointerDown = (event) => {
|
|
97
|
+
if (disabled || event.button !== 0) return;
|
|
98
|
+
drag.current = { x: event.clientX, y: event.clientY, v: latest.current };
|
|
99
|
+
setActive(true);
|
|
100
|
+
event.currentTarget.setPointerCapture?.(event.pointerId);
|
|
101
|
+
event.currentTarget.focus({ preventScroll: true });
|
|
102
|
+
event.preventDefault();
|
|
103
|
+
};
|
|
104
|
+
const onPointerMove = (event) => {
|
|
105
|
+
const d = drag.current;
|
|
106
|
+
if (!d) return;
|
|
107
|
+
const delta = event.clientX - d.x - (event.clientY - d.y);
|
|
108
|
+
const scale = event.shiftKey ? 0.2 : 1;
|
|
109
|
+
commitValue(d.v + delta / sensitivity * (max - min) * scale);
|
|
110
|
+
};
|
|
111
|
+
const onPointerUp = () => {
|
|
112
|
+
if (!drag.current) return;
|
|
113
|
+
drag.current = null;
|
|
114
|
+
setActive(false);
|
|
115
|
+
onValueCommit?.(latest.current);
|
|
116
|
+
};
|
|
117
|
+
const onKeyDown = (event) => {
|
|
118
|
+
rest.onKeyDown?.(event);
|
|
119
|
+
if (disabled) return;
|
|
120
|
+
const big = Math.max(step, (max - min) / 10);
|
|
121
|
+
const map = {
|
|
122
|
+
ArrowUp: step,
|
|
123
|
+
ArrowRight: step,
|
|
124
|
+
ArrowDown: -step,
|
|
125
|
+
ArrowLeft: -step,
|
|
126
|
+
PageUp: big,
|
|
127
|
+
PageDown: -big
|
|
128
|
+
};
|
|
129
|
+
let next;
|
|
130
|
+
if (event.key in map) next = latest.current + map[event.key] * (event.shiftKey ? 10 : 1);
|
|
131
|
+
if (event.key === "Home") next = min;
|
|
132
|
+
if (event.key === "End") next = max;
|
|
133
|
+
if (next === void 0) return;
|
|
134
|
+
event.preventDefault();
|
|
135
|
+
const committed = commitValue(next);
|
|
136
|
+
onValueCommit?.(committed);
|
|
137
|
+
};
|
|
138
|
+
const start = -arc / 2;
|
|
139
|
+
const rotation = react.useTransform(f, (v) => start + v * arc);
|
|
140
|
+
const r = 44;
|
|
141
|
+
const track = arcPath(50, 50, r, start, start + arc);
|
|
142
|
+
const tickList = Array.from({ length: Math.max(2, ticks) }, (_, i) => i / (Math.max(2, ticks) - 1));
|
|
143
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
144
|
+
"div",
|
|
145
|
+
{
|
|
146
|
+
...rest,
|
|
147
|
+
ref: chunk5ARTY5RT_cjs.mergeRefs(local, ref),
|
|
148
|
+
role: "slider",
|
|
149
|
+
tabIndex: disabled ? -1 : 0,
|
|
150
|
+
"aria-label": label,
|
|
151
|
+
"aria-valuemin": min,
|
|
152
|
+
"aria-valuemax": max,
|
|
153
|
+
"aria-valuenow": value,
|
|
154
|
+
"aria-valuetext": formatValue(value),
|
|
155
|
+
"aria-disabled": disabled || void 0,
|
|
156
|
+
className: chunkPBMXL53R_cjs.cx("fl-knob", className),
|
|
157
|
+
"data-variant": variant,
|
|
158
|
+
"data-active": active || void 0,
|
|
159
|
+
"data-disabled": disabled || void 0,
|
|
160
|
+
style: { ...style, ["--fl-knob-size"]: `${size}px` },
|
|
161
|
+
onPointerDown,
|
|
162
|
+
onPointerMove,
|
|
163
|
+
onPointerUp,
|
|
164
|
+
onPointerCancel: onPointerUp,
|
|
165
|
+
onDoubleClick: () => {
|
|
166
|
+
if (disabled) return;
|
|
167
|
+
const committed = commitValue(initial);
|
|
168
|
+
onValueCommit?.(committed);
|
|
169
|
+
},
|
|
170
|
+
onKeyDown,
|
|
171
|
+
children: [
|
|
172
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "fl-knob__dial", children: [
|
|
173
|
+
/* @__PURE__ */ jsxRuntime.jsx("svg", { viewBox: "0 0 100 100", className: "fl-knob__svg", "aria-hidden": true, children: variant === "arc" ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
174
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: track, className: "fl-knob__track" }),
|
|
175
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.motion.path, { d: track, className: "fl-knob__fill", style: { pathLength: f } })
|
|
176
|
+
] }) : tickList.map((p, i) => /* @__PURE__ */ jsxRuntime.jsx(KnobTick, { p, f, start, arc }, i)) }),
|
|
177
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.motion.div, { className: "fl-knob__cap", style: { rotate: rotation }, "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "fl-knob__pointer" }) }),
|
|
178
|
+
variant === "arc" && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "fl-knob__value", children: formatValue(value) })
|
|
179
|
+
] }),
|
|
180
|
+
(label || variant === "machined") && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "fl-knob__caption", children: [
|
|
181
|
+
label && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "fl-knob__label", children: label }),
|
|
182
|
+
variant === "machined" && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "fl-knob__readout", children: formatValue(value) })
|
|
183
|
+
] })
|
|
184
|
+
]
|
|
185
|
+
}
|
|
186
|
+
);
|
|
187
|
+
});
|
|
188
|
+
function KnobTick({ p, f, start, arc }) {
|
|
189
|
+
const deg = start + p * arc;
|
|
190
|
+
const a = polar(50, 50, 47, deg);
|
|
191
|
+
const b = polar(50, 50, 42, deg);
|
|
192
|
+
const stroke = react.useTransform(f, (v) => v + 1e-6 >= p ? "var(--fl-knob-fill)" : "var(--fl-line-strong)");
|
|
193
|
+
return /* @__PURE__ */ jsxRuntime.jsx(react.motion.line, { x1: a.x, y1: a.y, x2: b.x, y2: b.y, className: "fl-knob__tick", style: { stroke } });
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
exports.Knob = Knob;
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var chunk3A2LHCPV_cjs = require('./chunk-3A2LHCPV.cjs');
|
|
5
|
+
var chunk5ARTY5RT_cjs = require('./chunk-5ARTY5RT.cjs');
|
|
6
|
+
var chunkG5UZZ2XG_cjs = require('./chunk-G5UZZ2XG.cjs');
|
|
7
|
+
var chunkPBMXL53R_cjs = require('./chunk-PBMXL53R.cjs');
|
|
8
|
+
var React = require('react');
|
|
9
|
+
var react = require('motion/react');
|
|
10
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
11
|
+
|
|
12
|
+
function _interopNamespace(e) {
|
|
13
|
+
if (e && e.__esModule) return e;
|
|
14
|
+
var n = Object.create(null);
|
|
15
|
+
if (e) {
|
|
16
|
+
Object.keys(e).forEach(function (k) {
|
|
17
|
+
if (k !== 'default') {
|
|
18
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
19
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () { return e[k]; }
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
n.default = e;
|
|
27
|
+
return Object.freeze(n);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
31
|
+
|
|
32
|
+
var ROLL = { type: "spring", stiffness: 360, damping: 30, mass: 0.8 };
|
|
33
|
+
var NumberField = React__namespace.forwardRef(function NumberField2({
|
|
34
|
+
value: valueProp,
|
|
35
|
+
defaultValue = 0,
|
|
36
|
+
onValueChange,
|
|
37
|
+
min = -Infinity,
|
|
38
|
+
max = Infinity,
|
|
39
|
+
step = 1,
|
|
40
|
+
variant = "split",
|
|
41
|
+
label,
|
|
42
|
+
format,
|
|
43
|
+
locale,
|
|
44
|
+
prefix,
|
|
45
|
+
suffix,
|
|
46
|
+
size = "md",
|
|
47
|
+
disabled,
|
|
48
|
+
haptics = true,
|
|
49
|
+
name,
|
|
50
|
+
className,
|
|
51
|
+
...rest
|
|
52
|
+
}, ref) {
|
|
53
|
+
const [value, setValue] = chunkG5UZZ2XG_cjs.useControllableState({ value: valueProp, defaultValue, onChange: onValueChange });
|
|
54
|
+
const [editing, setEditing] = React__namespace.useState(false);
|
|
55
|
+
const [draft, setDraft] = React__namespace.useState("");
|
|
56
|
+
const [direction, setDirection] = React__namespace.useState(1);
|
|
57
|
+
const inputRef = React__namespace.useRef(null);
|
|
58
|
+
const latest = React__namespace.useRef(value);
|
|
59
|
+
latest.current = value;
|
|
60
|
+
const inputId = React__namespace.useId();
|
|
61
|
+
const formatter = React__namespace.useMemo(() => {
|
|
62
|
+
try {
|
|
63
|
+
return new Intl.NumberFormat(locale, format);
|
|
64
|
+
} catch {
|
|
65
|
+
return new Intl.NumberFormat(locale);
|
|
66
|
+
}
|
|
67
|
+
}, [locale, JSON.stringify(format)]);
|
|
68
|
+
const set = (next) => {
|
|
69
|
+
const v = chunk3A2LHCPV_cjs.clamp(chunk3A2LHCPV_cjs.snapToStep(next, step, Number.isFinite(min) ? min : 0), min, max);
|
|
70
|
+
if (v === latest.current) return false;
|
|
71
|
+
setDirection(v > latest.current ? 1 : -1);
|
|
72
|
+
latest.current = v;
|
|
73
|
+
setValue(v);
|
|
74
|
+
return true;
|
|
75
|
+
};
|
|
76
|
+
const nudge = (k) => {
|
|
77
|
+
if (set(latest.current + k * step) && haptics) chunk5ARTY5RT_cjs.haptic(3);
|
|
78
|
+
};
|
|
79
|
+
const repeat = React__namespace.useRef({ count: 0 });
|
|
80
|
+
const stopRepeat = () => {
|
|
81
|
+
clearTimeout(repeat.current.timer);
|
|
82
|
+
repeat.current.count = 0;
|
|
83
|
+
};
|
|
84
|
+
const startRepeat = (k) => {
|
|
85
|
+
nudge(k);
|
|
86
|
+
const tick = () => {
|
|
87
|
+
repeat.current.count++;
|
|
88
|
+
nudge(k * (repeat.current.count > 24 ? 10 : 1));
|
|
89
|
+
repeat.current.timer = setTimeout(tick, Math.max(32, 130 - repeat.current.count * 9));
|
|
90
|
+
};
|
|
91
|
+
repeat.current.timer = setTimeout(tick, 380);
|
|
92
|
+
};
|
|
93
|
+
React__namespace.useEffect(() => stopRepeat, []);
|
|
94
|
+
const scrub = React__namespace.useRef(null);
|
|
95
|
+
const onScrubDown = (event) => {
|
|
96
|
+
if (disabled || event.button !== 0) return;
|
|
97
|
+
scrub.current = { x: event.clientX, v: latest.current };
|
|
98
|
+
event.currentTarget.setPointerCapture?.(event.pointerId);
|
|
99
|
+
event.preventDefault();
|
|
100
|
+
};
|
|
101
|
+
const onScrubMove = (event) => {
|
|
102
|
+
if (!scrub.current) return;
|
|
103
|
+
const dx = event.clientX - scrub.current.x;
|
|
104
|
+
const perStep = event.shiftKey ? 12 : 4;
|
|
105
|
+
if (set(scrub.current.v + Math.round(dx / perStep) * step) && haptics) chunk5ARTY5RT_cjs.haptic(2);
|
|
106
|
+
};
|
|
107
|
+
const onScrubUp = () => {
|
|
108
|
+
scrub.current = null;
|
|
109
|
+
};
|
|
110
|
+
const beginEdit = () => {
|
|
111
|
+
if (disabled) return;
|
|
112
|
+
setDraft(String(value));
|
|
113
|
+
setEditing(true);
|
|
114
|
+
requestAnimationFrame(() => inputRef.current?.select());
|
|
115
|
+
};
|
|
116
|
+
const finishEdit = () => {
|
|
117
|
+
const parsed = Number(draft.replace(/[^\d.,-]/g, "").replace(",", "."));
|
|
118
|
+
if (draft.trim() !== "" && Number.isFinite(parsed)) set(parsed);
|
|
119
|
+
setEditing(false);
|
|
120
|
+
};
|
|
121
|
+
const onKeyDown = (event) => {
|
|
122
|
+
const k = event.shiftKey ? 10 : 1;
|
|
123
|
+
if (event.key === "ArrowUp") {
|
|
124
|
+
event.preventDefault();
|
|
125
|
+
nudge(k);
|
|
126
|
+
setDraft(String(latest.current));
|
|
127
|
+
} else if (event.key === "ArrowDown") {
|
|
128
|
+
event.preventDefault();
|
|
129
|
+
nudge(-k);
|
|
130
|
+
setDraft(String(latest.current));
|
|
131
|
+
} else if (event.key === "Home" && Number.isFinite(min)) {
|
|
132
|
+
event.preventDefault();
|
|
133
|
+
set(min);
|
|
134
|
+
setDraft(String(min));
|
|
135
|
+
} else if (event.key === "End" && Number.isFinite(max)) {
|
|
136
|
+
event.preventDefault();
|
|
137
|
+
set(max);
|
|
138
|
+
setDraft(String(max));
|
|
139
|
+
} else if (event.key === "Enter") {
|
|
140
|
+
finishEdit();
|
|
141
|
+
} else if (event.key === "Escape") {
|
|
142
|
+
setEditing(false);
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
const formatted = `${prefix ?? ""}${formatter.format(value)}${suffix ?? ""}`;
|
|
146
|
+
const stepper = (k) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
147
|
+
"button",
|
|
148
|
+
{
|
|
149
|
+
type: "button",
|
|
150
|
+
tabIndex: -1,
|
|
151
|
+
"aria-label": k > 0 ? "Increase" : "Decrease",
|
|
152
|
+
className: "fl-reset-button fl-number__step",
|
|
153
|
+
disabled: disabled || (k > 0 ? value >= max : value <= min),
|
|
154
|
+
onPointerDown: (e) => {
|
|
155
|
+
if (e.button !== 0) return;
|
|
156
|
+
e.preventDefault();
|
|
157
|
+
startRepeat(k);
|
|
158
|
+
},
|
|
159
|
+
onPointerUp: stopRepeat,
|
|
160
|
+
onPointerLeave: stopRepeat,
|
|
161
|
+
onPointerCancel: stopRepeat,
|
|
162
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("svg", { viewBox: "0 0 16 16", width: "14", height: "14", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: k > 0 ? "M3.5 8h9M8 3.5v9" : "M3.5 8h9", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round" }) })
|
|
163
|
+
}
|
|
164
|
+
);
|
|
165
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { ...rest, ref, className: chunkPBMXL53R_cjs.cx("fl-number", className), "data-variant": variant, "data-size": size, "data-disabled": disabled || void 0, "data-editing": editing || void 0, children: [
|
|
166
|
+
label && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
167
|
+
"label",
|
|
168
|
+
{
|
|
169
|
+
htmlFor: inputId,
|
|
170
|
+
className: "fl-number__label",
|
|
171
|
+
onPointerDown: variant === "scrub" ? onScrubDown : void 0,
|
|
172
|
+
onPointerMove: variant === "scrub" ? onScrubMove : void 0,
|
|
173
|
+
onPointerUp: variant === "scrub" ? onScrubUp : void 0,
|
|
174
|
+
onPointerCancel: variant === "scrub" ? onScrubUp : void 0,
|
|
175
|
+
children: [
|
|
176
|
+
label,
|
|
177
|
+
variant === "scrub" && /* @__PURE__ */ jsxRuntime.jsx("svg", { className: "fl-number__grip", viewBox: "0 0 16 8", width: "16", height: "8", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M5 1 2 4l3 3M11 1l3 3-3 3", fill: "none", stroke: "currentColor", strokeWidth: "1.3", strokeLinecap: "round", strokeLinejoin: "round" }) })
|
|
178
|
+
]
|
|
179
|
+
}
|
|
180
|
+
),
|
|
181
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "fl-number__field", children: [
|
|
182
|
+
variant === "split" && stepper(-1),
|
|
183
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "fl-number__value", children: [
|
|
184
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
185
|
+
"input",
|
|
186
|
+
{
|
|
187
|
+
ref: inputRef,
|
|
188
|
+
id: inputId,
|
|
189
|
+
className: "fl-number__input",
|
|
190
|
+
role: "spinbutton",
|
|
191
|
+
inputMode: "decimal",
|
|
192
|
+
autoComplete: "off",
|
|
193
|
+
"aria-valuenow": value,
|
|
194
|
+
"aria-valuemin": Number.isFinite(min) ? min : void 0,
|
|
195
|
+
"aria-valuemax": Number.isFinite(max) ? max : void 0,
|
|
196
|
+
"aria-valuetext": formatted,
|
|
197
|
+
"aria-label": label ? void 0 : "Value",
|
|
198
|
+
disabled,
|
|
199
|
+
value: editing ? draft : formatted,
|
|
200
|
+
onChange: (e) => setDraft(e.target.value),
|
|
201
|
+
onFocus: beginEdit,
|
|
202
|
+
onBlur: finishEdit,
|
|
203
|
+
onKeyDown
|
|
204
|
+
}
|
|
205
|
+
),
|
|
206
|
+
/* @__PURE__ */ jsxRuntime.jsx(Odometer, { text: formatted, direction })
|
|
207
|
+
] }),
|
|
208
|
+
variant === "split" && stepper(1)
|
|
209
|
+
] }),
|
|
210
|
+
name && /* @__PURE__ */ jsxRuntime.jsx("input", { type: "hidden", name, value })
|
|
211
|
+
] });
|
|
212
|
+
});
|
|
213
|
+
function Odometer({ text, direction }) {
|
|
214
|
+
const { t } = chunkPBMXL53R_cjs.useMotionPreset();
|
|
215
|
+
const chars = Array.from(text);
|
|
216
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "fl-number__odometer", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx(react.AnimatePresence, { initial: false, mode: "popLayout", children: chars.map((ch, i) => {
|
|
217
|
+
const key = `${chars.length - i}`;
|
|
218
|
+
const isDigit = ch >= "0" && ch <= "9";
|
|
219
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
220
|
+
react.motion.span,
|
|
221
|
+
{
|
|
222
|
+
layout: "position",
|
|
223
|
+
className: isDigit ? "fl-number__digit" : "fl-number__sym",
|
|
224
|
+
initial: { opacity: 0, y: direction > 0 ? "60%" : "-60%" },
|
|
225
|
+
animate: { opacity: 1, y: "0%" },
|
|
226
|
+
exit: { opacity: 0, y: direction > 0 ? "-60%" : "60%" },
|
|
227
|
+
transition: t(ROLL),
|
|
228
|
+
children: isDigit ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
229
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "fl-number__ghost", children: "0" }),
|
|
230
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.motion.span, { className: "fl-number__column", initial: false, animate: { y: `${-Number(ch) * 10}%` }, transition: t(ROLL), children: "0123456789".split("").map((n) => /* @__PURE__ */ jsxRuntime.jsx("span", { children: n }, n)) })
|
|
231
|
+
] }) : ch
|
|
232
|
+
},
|
|
233
|
+
isDigit ? `d${key}` : `s${key}${ch}`
|
|
234
|
+
);
|
|
235
|
+
}) }) });
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
exports.NumberField = NumberField;
|