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,108 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { Popover } from './chunk-EYO4XMKU.js';
|
|
3
|
+
import { Calendar } from './chunk-2Z4YKJMT.js';
|
|
4
|
+
import { useControllableState } from './chunk-KPG24YFL.js';
|
|
5
|
+
import { useMotionPreset, cx } from './chunk-UFUN2OKY.js';
|
|
6
|
+
import * as React from 'react';
|
|
7
|
+
import { AnimatePresence, motion } from 'motion/react';
|
|
8
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
9
|
+
|
|
10
|
+
var DatePicker = React.forwardRef(function DatePicker2(props, ref) {
|
|
11
|
+
const {
|
|
12
|
+
mode = "single",
|
|
13
|
+
value: valueProp,
|
|
14
|
+
defaultValue,
|
|
15
|
+
onValueChange,
|
|
16
|
+
placeholder,
|
|
17
|
+
locale,
|
|
18
|
+
formatOptions = { month: "short", day: "numeric", year: "numeric" },
|
|
19
|
+
min,
|
|
20
|
+
max,
|
|
21
|
+
isDateDisabled,
|
|
22
|
+
weekStartsOn = 1,
|
|
23
|
+
placement = "bottom-start",
|
|
24
|
+
size = "md",
|
|
25
|
+
disabled,
|
|
26
|
+
className,
|
|
27
|
+
container,
|
|
28
|
+
today
|
|
29
|
+
} = props;
|
|
30
|
+
const isRange = mode === "range";
|
|
31
|
+
const [value, setValue] = useControllableState({
|
|
32
|
+
value: valueProp,
|
|
33
|
+
defaultValue: defaultValue ?? (isRange ? { start: null, end: null } : null),
|
|
34
|
+
onChange: onValueChange
|
|
35
|
+
});
|
|
36
|
+
const [open, setOpen] = React.useState(false);
|
|
37
|
+
const { t } = useMotionPreset();
|
|
38
|
+
const fmt = React.useMemo(() => new Intl.DateTimeFormat(locale, formatOptions), [locale, JSON.stringify(formatOptions)]);
|
|
39
|
+
const text = isRange ? value?.start ? `${fmt.format(value.start)} \u2013 ${value.end ? fmt.format(value.end) : "\u2026"}` : "" : value ? fmt.format(value) : "";
|
|
40
|
+
return /* @__PURE__ */ jsx(
|
|
41
|
+
Popover,
|
|
42
|
+
{
|
|
43
|
+
open,
|
|
44
|
+
onOpenChange: setOpen,
|
|
45
|
+
placement,
|
|
46
|
+
container,
|
|
47
|
+
className: "fl-date-picker__popover",
|
|
48
|
+
"aria-label": isRange ? "Choose dates" : "Choose a date",
|
|
49
|
+
content: isRange ? /* @__PURE__ */ jsx(
|
|
50
|
+
Calendar,
|
|
51
|
+
{
|
|
52
|
+
mode: "range",
|
|
53
|
+
value,
|
|
54
|
+
onValueChange: (next) => {
|
|
55
|
+
setValue(next);
|
|
56
|
+
if (next.start && next.end) setTimeout(() => setOpen(false), 260);
|
|
57
|
+
},
|
|
58
|
+
locale,
|
|
59
|
+
min,
|
|
60
|
+
max,
|
|
61
|
+
isDateDisabled,
|
|
62
|
+
weekStartsOn,
|
|
63
|
+
today
|
|
64
|
+
}
|
|
65
|
+
) : /* @__PURE__ */ jsx(
|
|
66
|
+
Calendar,
|
|
67
|
+
{
|
|
68
|
+
value,
|
|
69
|
+
onValueChange: (next) => {
|
|
70
|
+
setValue(next);
|
|
71
|
+
setTimeout(() => setOpen(false), 220);
|
|
72
|
+
},
|
|
73
|
+
locale,
|
|
74
|
+
min,
|
|
75
|
+
max,
|
|
76
|
+
isDateDisabled,
|
|
77
|
+
weekStartsOn,
|
|
78
|
+
today
|
|
79
|
+
}
|
|
80
|
+
),
|
|
81
|
+
children: /* @__PURE__ */ jsxs(
|
|
82
|
+
"button",
|
|
83
|
+
{
|
|
84
|
+
ref,
|
|
85
|
+
type: "button",
|
|
86
|
+
disabled,
|
|
87
|
+
className: cx("fl-reset-button fl-date-picker", className),
|
|
88
|
+
"data-size": size,
|
|
89
|
+
"data-empty": !text || void 0,
|
|
90
|
+
children: [
|
|
91
|
+
/* @__PURE__ */ jsxs("svg", { className: "fl-date-picker__icon", viewBox: "0 0 16 16", width: "15", height: "15", "aria-hidden": true, children: [
|
|
92
|
+
/* @__PURE__ */ jsx("rect", { x: "2", y: "3", width: "12", height: "11", rx: "2", fill: "none", stroke: "currentColor", strokeWidth: "1.3" }),
|
|
93
|
+
/* @__PURE__ */ jsx("path", { d: "M2 6.5h12M5.5 1.8v2.4M10.5 1.8v2.4", stroke: "currentColor", strokeWidth: "1.3", strokeLinecap: "round" })
|
|
94
|
+
] }),
|
|
95
|
+
props["aria-label"] && /* @__PURE__ */ jsxs("span", { className: "fl-sr-only", children: [
|
|
96
|
+
props["aria-label"],
|
|
97
|
+
": "
|
|
98
|
+
] }),
|
|
99
|
+
/* @__PURE__ */ jsx("span", { className: "fl-date-picker__text", children: /* @__PURE__ */ jsx(AnimatePresence, { mode: "popLayout", initial: false, children: /* @__PURE__ */ jsx(motion.span, { initial: { opacity: 0, y: 8 }, animate: { opacity: 1, y: 0 }, exit: { opacity: 0, y: -8 }, transition: t({ type: "spring", stiffness: 500, damping: 34 }), children: text || placeholder || (isRange ? "Select dates" : "Select a date") }, text || "empty") }) }),
|
|
100
|
+
/* @__PURE__ */ jsx(motion.svg, { className: "fl-date-picker__chevron", viewBox: "0 0 12 12", width: "12", height: "12", "aria-hidden": true, animate: { rotate: open ? 180 : 0 }, transition: t({ type: "spring", stiffness: 500, damping: 30 }), children: /* @__PURE__ */ jsx("path", { d: "M3 4.5 6 7.5 9 4.5", fill: "none", stroke: "currentColor", strokeWidth: "1.4", strokeLinecap: "round", strokeLinejoin: "round" }) })
|
|
101
|
+
]
|
|
102
|
+
}
|
|
103
|
+
)
|
|
104
|
+
}
|
|
105
|
+
);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
export { DatePicker };
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useIsoLayoutEffect, haptic } 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 { useMotionValue, useTransform, animate, motion, AnimatePresence } from 'motion/react';
|
|
7
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
8
|
+
|
|
9
|
+
var TabsContext = React.createContext(null);
|
|
10
|
+
var useTabs = () => {
|
|
11
|
+
const ctx = React.useContext(TabsContext);
|
|
12
|
+
if (!ctx) throw new Error("Tabs parts must be rendered inside <Tabs>.");
|
|
13
|
+
return ctx;
|
|
14
|
+
};
|
|
15
|
+
var PanelsContext = React.createContext(null);
|
|
16
|
+
var Tabs = React.forwardRef(function Tabs2({ value: valueProp, defaultValue = "", onValueChange, variant = "underline", haptics = true, className, children, ...rest }, ref) {
|
|
17
|
+
const [value, setValue] = useControllableState({ value: valueProp, defaultValue, onChange: onValueChange });
|
|
18
|
+
const values = React.useRef([]);
|
|
19
|
+
const [direction, setDirection] = React.useState(1);
|
|
20
|
+
const baseId = React.useId();
|
|
21
|
+
const select = (next) => {
|
|
22
|
+
if (next === value) return;
|
|
23
|
+
const a = values.current.indexOf(value);
|
|
24
|
+
const b = values.current.indexOf(next);
|
|
25
|
+
setDirection(b >= a ? 1 : -1);
|
|
26
|
+
if (haptics) haptic(4);
|
|
27
|
+
setValue(next);
|
|
28
|
+
};
|
|
29
|
+
const register = React.useCallback((v) => {
|
|
30
|
+
if (!values.current.includes(v)) values.current.push(v);
|
|
31
|
+
}, []);
|
|
32
|
+
return /* @__PURE__ */ jsx(TabsContext.Provider, { value: { value, select, direction, variant, baseId, register, values, reportHeight: () => {
|
|
33
|
+
} }, children: /* @__PURE__ */ jsx("div", { ...rest, ref, className: cx("fl-tabs", className), "data-variant": variant, children }) });
|
|
34
|
+
});
|
|
35
|
+
var TabsList = React.forwardRef(function TabsList2({ className, children, onKeyDown, ...rest }, ref) {
|
|
36
|
+
const { value, variant } = useTabs();
|
|
37
|
+
const { t } = useMotionPreset();
|
|
38
|
+
const listRef = React.useRef(null);
|
|
39
|
+
const left = useMotionValue(0);
|
|
40
|
+
const right = useMotionValue(0);
|
|
41
|
+
const width = useTransform([left, right], ([l, r]) => Math.max(0, r - l));
|
|
42
|
+
const placed = React.useRef(false);
|
|
43
|
+
const place = React.useCallback(
|
|
44
|
+
(instant) => {
|
|
45
|
+
const el = listRef.current?.querySelector('[role="tab"][aria-selected="true"]');
|
|
46
|
+
if (!el) return;
|
|
47
|
+
const L = el.offsetLeft;
|
|
48
|
+
const R = L + el.offsetWidth;
|
|
49
|
+
if (instant || !placed.current) {
|
|
50
|
+
left.set(L);
|
|
51
|
+
right.set(R);
|
|
52
|
+
placed.current = true;
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const forward = L > left.get();
|
|
56
|
+
const lead = { type: "spring", stiffness: 640, damping: 42 };
|
|
57
|
+
const trail = { type: "spring", stiffness: 240, damping: 26 };
|
|
58
|
+
animate(left, L, t(forward ? trail : lead));
|
|
59
|
+
animate(right, R, t(forward ? lead : trail));
|
|
60
|
+
},
|
|
61
|
+
[t]
|
|
62
|
+
);
|
|
63
|
+
useIsoLayoutEffect(() => place(false), [value, place]);
|
|
64
|
+
useIsoLayoutEffect(() => {
|
|
65
|
+
const el = listRef.current;
|
|
66
|
+
if (!el || typeof ResizeObserver === "undefined") return;
|
|
67
|
+
const ro = new ResizeObserver(() => place(true));
|
|
68
|
+
ro.observe(el);
|
|
69
|
+
return () => ro.disconnect();
|
|
70
|
+
}, [place]);
|
|
71
|
+
const handleKey = (event) => {
|
|
72
|
+
onKeyDown?.(event);
|
|
73
|
+
const tabs = Array.from(event.currentTarget.querySelectorAll('[role="tab"]:not(:disabled)'));
|
|
74
|
+
const i = tabs.indexOf(document.activeElement);
|
|
75
|
+
if (i === -1) return;
|
|
76
|
+
const next = { ArrowRight: i + 1, ArrowLeft: i - 1, Home: 0, End: tabs.length - 1 }[event.key];
|
|
77
|
+
if (next === void 0) return;
|
|
78
|
+
event.preventDefault();
|
|
79
|
+
const target = tabs[(next + tabs.length) % tabs.length];
|
|
80
|
+
target.focus();
|
|
81
|
+
target.click();
|
|
82
|
+
};
|
|
83
|
+
return /* @__PURE__ */ jsxs(
|
|
84
|
+
"div",
|
|
85
|
+
{
|
|
86
|
+
...rest,
|
|
87
|
+
ref: (el) => {
|
|
88
|
+
listRef.current = el;
|
|
89
|
+
if (typeof ref === "function") ref(el);
|
|
90
|
+
else if (ref) ref.current = el;
|
|
91
|
+
},
|
|
92
|
+
role: "tablist",
|
|
93
|
+
className: cx("fl-tabs__list", className),
|
|
94
|
+
"data-variant": variant,
|
|
95
|
+
onKeyDown: handleKey,
|
|
96
|
+
children: [
|
|
97
|
+
/* @__PURE__ */ jsx(motion.span, { className: "fl-tabs__indicator", "aria-hidden": true, style: { x: left, width } }),
|
|
98
|
+
children
|
|
99
|
+
]
|
|
100
|
+
}
|
|
101
|
+
);
|
|
102
|
+
});
|
|
103
|
+
var TabsTrigger = React.forwardRef(function TabsTrigger2({ value, className, children, onClick, ...rest }, ref) {
|
|
104
|
+
const ctx = useTabs();
|
|
105
|
+
ctx.register(value);
|
|
106
|
+
const selected = ctx.value === value;
|
|
107
|
+
return /* @__PURE__ */ jsx(
|
|
108
|
+
"button",
|
|
109
|
+
{
|
|
110
|
+
...rest,
|
|
111
|
+
ref,
|
|
112
|
+
type: "button",
|
|
113
|
+
role: "tab",
|
|
114
|
+
id: `${ctx.baseId}-tab-${value}`,
|
|
115
|
+
"aria-selected": selected,
|
|
116
|
+
"aria-controls": `${ctx.baseId}-panel-${value}`,
|
|
117
|
+
tabIndex: selected ? 0 : -1,
|
|
118
|
+
"data-state": selected ? "active" : "inactive",
|
|
119
|
+
className: cx("fl-reset-button fl-tabs__trigger", className),
|
|
120
|
+
onClick: (e) => {
|
|
121
|
+
onClick?.(e);
|
|
122
|
+
if (!e.defaultPrevented) ctx.select(value);
|
|
123
|
+
},
|
|
124
|
+
children
|
|
125
|
+
}
|
|
126
|
+
);
|
|
127
|
+
});
|
|
128
|
+
var TabsPanels = React.forwardRef(function TabsPanels2({ className, children, style, ...rest }, ref) {
|
|
129
|
+
const { t } = useMotionPreset();
|
|
130
|
+
const ctx = useTabs();
|
|
131
|
+
const [height, setHeight] = React.useState("auto");
|
|
132
|
+
const active = React.Children.toArray(children).filter(
|
|
133
|
+
(child) => React.isValidElement(child) && child.props.value === ctx.value
|
|
134
|
+
);
|
|
135
|
+
return /* @__PURE__ */ jsx(PanelsContext.Provider, { value: setHeight, children: /* @__PURE__ */ jsx(
|
|
136
|
+
motion.div,
|
|
137
|
+
{
|
|
138
|
+
...rest,
|
|
139
|
+
ref,
|
|
140
|
+
className: cx("fl-tabs__panels", className),
|
|
141
|
+
style,
|
|
142
|
+
initial: false,
|
|
143
|
+
animate: { height },
|
|
144
|
+
transition: t({ type: "spring", stiffness: 360, damping: 34 }),
|
|
145
|
+
children: /* @__PURE__ */ jsx(AnimatePresence, { initial: false, mode: "popLayout", children: active.map((child) => React.cloneElement(child, { key: child.props.value })) })
|
|
146
|
+
}
|
|
147
|
+
) });
|
|
148
|
+
});
|
|
149
|
+
var TabsContent = React.forwardRef(function TabsContent2({ value, className, children, ...rest }, ref) {
|
|
150
|
+
const ctx = useTabs();
|
|
151
|
+
const reportHeight = React.useContext(PanelsContext);
|
|
152
|
+
const { t, reduced } = useMotionPreset();
|
|
153
|
+
const inner = React.useRef(null);
|
|
154
|
+
const active = ctx.value === value;
|
|
155
|
+
useIsoLayoutEffect(() => {
|
|
156
|
+
if (!active || !reportHeight || !inner.current) return;
|
|
157
|
+
const el = inner.current;
|
|
158
|
+
reportHeight(el.offsetHeight);
|
|
159
|
+
if (typeof ResizeObserver === "undefined") return;
|
|
160
|
+
const ro = new ResizeObserver(() => reportHeight(el.offsetHeight));
|
|
161
|
+
ro.observe(el);
|
|
162
|
+
return () => ro.disconnect();
|
|
163
|
+
}, [active, reportHeight]);
|
|
164
|
+
const d = ctx.direction;
|
|
165
|
+
const body = /* @__PURE__ */ jsx(
|
|
166
|
+
motion.div,
|
|
167
|
+
{
|
|
168
|
+
...rest,
|
|
169
|
+
ref: (el) => {
|
|
170
|
+
inner.current = el;
|
|
171
|
+
if (typeof ref === "function") ref(el);
|
|
172
|
+
else if (ref) ref.current = el;
|
|
173
|
+
},
|
|
174
|
+
role: "tabpanel",
|
|
175
|
+
id: `${ctx.baseId}-panel-${value}`,
|
|
176
|
+
"aria-labelledby": `${ctx.baseId}-tab-${value}`,
|
|
177
|
+
tabIndex: 0,
|
|
178
|
+
className: cx("fl-tabs__content", className),
|
|
179
|
+
initial: { opacity: 0, x: reduced ? 0 : d * 28 },
|
|
180
|
+
animate: { opacity: 1, x: 0 },
|
|
181
|
+
exit: { opacity: 0, x: reduced ? 0 : d * -28 },
|
|
182
|
+
transition: t({ type: "spring", stiffness: 380, damping: 34, opacity: { duration: 0.18 } }),
|
|
183
|
+
children
|
|
184
|
+
},
|
|
185
|
+
value
|
|
186
|
+
);
|
|
187
|
+
return reportHeight ? body : /* @__PURE__ */ jsx(AnimatePresence, { initial: false, children: active && body });
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
export { Tabs, TabsContent, TabsList, TabsPanels, TabsTrigger };
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { clamp, rubberband } from './chunk-344MRWFO.js';
|
|
3
|
+
import { haptic } from './chunk-WGFJLFTP.js';
|
|
4
|
+
import { useControllableState } from './chunk-KPG24YFL.js';
|
|
5
|
+
import { useMotionPreset, cx } from './chunk-UFUN2OKY.js';
|
|
6
|
+
import * as React from 'react';
|
|
7
|
+
import { useMotionValue, animate, useMotionValueEvent, useTransform, motion } from 'motion/react';
|
|
8
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
9
|
+
|
|
10
|
+
var SETTLE = { type: "spring", stiffness: 320, damping: 34 };
|
|
11
|
+
var ANGLE = 20;
|
|
12
|
+
function normalize(options) {
|
|
13
|
+
return options.map((o) => typeof o === "string" ? { value: o, label: o } : o);
|
|
14
|
+
}
|
|
15
|
+
function WheelPickerImpl({ options: raw, value: valueProp, defaultValue, onValueChange, visibleCount = 5, itemHeight = 36, label, haptics = true, disabled, className, style, ...rest }, ref) {
|
|
16
|
+
const options = React.useMemo(() => normalize(raw), [raw]);
|
|
17
|
+
const [value, setValue] = useControllableState({ value: valueProp, defaultValue: defaultValue ?? options[0]?.value, onChange: onValueChange });
|
|
18
|
+
const { t, reduced } = useMotionPreset();
|
|
19
|
+
const index = Math.max(0, options.findIndex((o) => o.value === value));
|
|
20
|
+
const y = useMotionValue(-index * itemHeight);
|
|
21
|
+
const drag = React.useRef(null);
|
|
22
|
+
const [dragging, setDragging] = React.useState(false);
|
|
23
|
+
const local = React.useRef(null);
|
|
24
|
+
const id = React.useId();
|
|
25
|
+
const maxY = 0;
|
|
26
|
+
const minY = -(options.length - 1) * itemHeight;
|
|
27
|
+
const radius = itemHeight / (2 * Math.tan(ANGLE * Math.PI / 360));
|
|
28
|
+
const nearestEnabled = (i) => {
|
|
29
|
+
i = clamp(i, 0, options.length - 1);
|
|
30
|
+
if (!options[i]?.disabled) return i;
|
|
31
|
+
for (let d = 1; d < options.length; d++) {
|
|
32
|
+
if (options[i + d] && !options[i + d].disabled) return i + d;
|
|
33
|
+
if (options[i - d] && !options[i - d].disabled) return i - d;
|
|
34
|
+
}
|
|
35
|
+
return i;
|
|
36
|
+
};
|
|
37
|
+
const settleTo = (i, velocity = 0) => {
|
|
38
|
+
const target = nearestEnabled(i);
|
|
39
|
+
animate(y, -target * itemHeight, reduced ? { duration: 0 } : { ...SETTLE, velocity });
|
|
40
|
+
if (options[target] && options[target].value !== value) setValue(options[target].value);
|
|
41
|
+
};
|
|
42
|
+
React.useEffect(() => {
|
|
43
|
+
if (drag.current) return;
|
|
44
|
+
const target = -index * itemHeight;
|
|
45
|
+
if (Math.abs(y.get() - target) > 0.5) animate(y, target, t(SETTLE));
|
|
46
|
+
}, [index, itemHeight]);
|
|
47
|
+
const lastRow = React.useRef(index);
|
|
48
|
+
useMotionValueEvent(y, "change", (v) => {
|
|
49
|
+
const row = Math.round(-v / itemHeight);
|
|
50
|
+
if (row !== lastRow.current) {
|
|
51
|
+
lastRow.current = row;
|
|
52
|
+
if (haptics && (drag.current || dragging)) haptic(2);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
const onPointerDown = (event) => {
|
|
56
|
+
if (disabled || event.button !== 0) return;
|
|
57
|
+
y.stop();
|
|
58
|
+
drag.current = { y0: event.clientY, start: y.get(), samples: [{ t: performance.now(), y: event.clientY }] };
|
|
59
|
+
setDragging(true);
|
|
60
|
+
event.currentTarget.setPointerCapture?.(event.pointerId);
|
|
61
|
+
};
|
|
62
|
+
const onPointerMove = (event) => {
|
|
63
|
+
const d = drag.current;
|
|
64
|
+
if (!d) return;
|
|
65
|
+
const raw2 = d.start + (event.clientY - d.y0);
|
|
66
|
+
const v = raw2 > maxY ? maxY + rubberband(raw2 - maxY, itemHeight * 3) : raw2 < minY ? minY + rubberband(raw2 - minY, itemHeight * 3) : raw2;
|
|
67
|
+
y.set(v);
|
|
68
|
+
d.samples.push({ t: performance.now(), y: event.clientY });
|
|
69
|
+
if (d.samples.length > 6) d.samples.shift();
|
|
70
|
+
};
|
|
71
|
+
const onPointerUp = (event) => {
|
|
72
|
+
const d = drag.current;
|
|
73
|
+
if (!d) return;
|
|
74
|
+
drag.current = null;
|
|
75
|
+
setDragging(false);
|
|
76
|
+
const first = d.samples[0];
|
|
77
|
+
const last = d.samples[d.samples.length - 1];
|
|
78
|
+
const dt = Math.max(1, last.t - first.t);
|
|
79
|
+
const velocity = (last.y - first.y) / dt * 1e3;
|
|
80
|
+
const moved = Math.abs(event.clientY - d.y0) > 4;
|
|
81
|
+
if (!moved) {
|
|
82
|
+
const rect = local.current.getBoundingClientRect();
|
|
83
|
+
const offset = Math.round((event.clientY - (rect.top + rect.height / 2)) / itemHeight);
|
|
84
|
+
settleTo(Math.round(-y.get() / itemHeight) + offset);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
const projected = clamp(y.get() + velocity * 0.22, minY, maxY);
|
|
88
|
+
settleTo(Math.round(-projected / itemHeight), velocity);
|
|
89
|
+
};
|
|
90
|
+
React.useEffect(() => {
|
|
91
|
+
const el = local.current;
|
|
92
|
+
if (!el || disabled) return;
|
|
93
|
+
let acc = 0;
|
|
94
|
+
let timer;
|
|
95
|
+
const onWheel = (event) => {
|
|
96
|
+
event.preventDefault();
|
|
97
|
+
acc += event.deltaY;
|
|
98
|
+
const rows = Math.trunc(acc / 40);
|
|
99
|
+
if (rows !== 0) {
|
|
100
|
+
acc -= rows * 40;
|
|
101
|
+
const current = Math.round(-y.get() / itemHeight);
|
|
102
|
+
settleTo(current + rows);
|
|
103
|
+
}
|
|
104
|
+
clearTimeout(timer);
|
|
105
|
+
timer = setTimeout(() => acc = 0, 120);
|
|
106
|
+
};
|
|
107
|
+
el.addEventListener("wheel", onWheel, { passive: false });
|
|
108
|
+
return () => el.removeEventListener("wheel", onWheel);
|
|
109
|
+
});
|
|
110
|
+
const onKeyDown = (event) => {
|
|
111
|
+
rest.onKeyDown?.(event);
|
|
112
|
+
const page = Math.max(1, Math.floor(visibleCount / 2));
|
|
113
|
+
const map = { ArrowDown: 1, ArrowUp: -1, PageDown: page, PageUp: -page };
|
|
114
|
+
if (event.key in map) {
|
|
115
|
+
event.preventDefault();
|
|
116
|
+
settleTo(index + map[event.key]);
|
|
117
|
+
} else if (event.key === "Home") {
|
|
118
|
+
event.preventDefault();
|
|
119
|
+
settleTo(0);
|
|
120
|
+
} else if (event.key === "End") {
|
|
121
|
+
event.preventDefault();
|
|
122
|
+
settleTo(options.length - 1);
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
const height = visibleCount * itemHeight;
|
|
126
|
+
return /* @__PURE__ */ jsxs(
|
|
127
|
+
"div",
|
|
128
|
+
{
|
|
129
|
+
...rest,
|
|
130
|
+
ref: (el) => {
|
|
131
|
+
local.current = el;
|
|
132
|
+
if (typeof ref === "function") ref(el);
|
|
133
|
+
else if (ref) ref.current = el;
|
|
134
|
+
},
|
|
135
|
+
role: "listbox",
|
|
136
|
+
tabIndex: disabled ? -1 : 0,
|
|
137
|
+
"aria-label": label,
|
|
138
|
+
"aria-activedescendant": `${id}-${index}`,
|
|
139
|
+
"aria-disabled": disabled || void 0,
|
|
140
|
+
className: cx("fl-wheel", className),
|
|
141
|
+
"data-dragging": dragging || void 0,
|
|
142
|
+
style: { ...style, height, ["--fl-wheel-row"]: `${itemHeight}px` },
|
|
143
|
+
onPointerDown,
|
|
144
|
+
onPointerMove,
|
|
145
|
+
onPointerUp,
|
|
146
|
+
onPointerCancel: onPointerUp,
|
|
147
|
+
onKeyDown,
|
|
148
|
+
children: [
|
|
149
|
+
/* @__PURE__ */ jsx("div", { className: "fl-wheel__band", "aria-hidden": true }),
|
|
150
|
+
/* @__PURE__ */ jsx("div", { className: "fl-wheel__drum", children: options.map((option, i) => /* @__PURE__ */ jsx(WheelItem, { id: `${id}-${i}`, i, y, h: itemHeight, radius, visible: visibleCount, selected: i === index, option }, option.value)) })
|
|
151
|
+
]
|
|
152
|
+
}
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
function WheelItem({
|
|
156
|
+
id,
|
|
157
|
+
i,
|
|
158
|
+
y,
|
|
159
|
+
h,
|
|
160
|
+
radius,
|
|
161
|
+
visible,
|
|
162
|
+
selected,
|
|
163
|
+
option
|
|
164
|
+
}) {
|
|
165
|
+
const offset = useTransform(y, (v) => (i * h + v) / h);
|
|
166
|
+
const transform = useTransform(offset, (o) => `translateY(-50%) rotateX(${-o * ANGLE}deg) translateZ(${radius}px)`);
|
|
167
|
+
const half = visible / 2;
|
|
168
|
+
const opacity = useTransform(offset, (o) => {
|
|
169
|
+
const d = Math.abs(o);
|
|
170
|
+
if (d * ANGLE >= 90 || d > half + 0.5) return 0;
|
|
171
|
+
if (d > half - 0.5) return 0.6 * (half + 0.5 - d);
|
|
172
|
+
return d < 1 ? 1 - d * 0.25 : 0.75 - Math.min(1, d - 1) * 0.15;
|
|
173
|
+
});
|
|
174
|
+
return /* @__PURE__ */ jsx(
|
|
175
|
+
motion.div,
|
|
176
|
+
{
|
|
177
|
+
id,
|
|
178
|
+
role: "option",
|
|
179
|
+
"aria-selected": selected,
|
|
180
|
+
"aria-disabled": option.disabled || void 0,
|
|
181
|
+
className: "fl-wheel__item",
|
|
182
|
+
"data-selected": selected || void 0,
|
|
183
|
+
style: { transform, opacity, height: h },
|
|
184
|
+
children: option.label
|
|
185
|
+
}
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
var WheelPicker = React.forwardRef(WheelPickerImpl);
|
|
189
|
+
|
|
190
|
+
export { WheelPicker };
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var chunk5ARTY5RT_cjs = require('./chunk-5ARTY5RT.cjs');
|
|
5
|
+
var chunkPBMXL53R_cjs = require('./chunk-PBMXL53R.cjs');
|
|
6
|
+
var React = require('react');
|
|
7
|
+
var react = require('motion/react');
|
|
8
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
9
|
+
|
|
10
|
+
function _interopNamespace(e) {
|
|
11
|
+
if (e && e.__esModule) return e;
|
|
12
|
+
var n = Object.create(null);
|
|
13
|
+
if (e) {
|
|
14
|
+
Object.keys(e).forEach(function (k) {
|
|
15
|
+
if (k !== 'default') {
|
|
16
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
17
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function () { return e[k]; }
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
n.default = e;
|
|
25
|
+
return Object.freeze(n);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
29
|
+
|
|
30
|
+
var FOLLOW = { stiffness: 260, damping: 17, mass: 0.6 };
|
|
31
|
+
var MagneticButton = React__namespace.forwardRef(function MagneticButton2({ variant = "magnetic", tone = "ink", size = "md", strength = 0.4, radius = 64, icon, children, className, disabled, onPointerDown, ...rest }, ref) {
|
|
32
|
+
const { reduced } = chunkPBMXL53R_cjs.useMotionPreset();
|
|
33
|
+
const local = React__namespace.useRef(null);
|
|
34
|
+
const tx = react.useSpring(0, FOLLOW);
|
|
35
|
+
const ty = react.useSpring(0, FOLLOW);
|
|
36
|
+
const stretch = react.useSpring(0, { stiffness: 320, damping: 12, mass: 0.5 });
|
|
37
|
+
const angle = react.useMotionValue(0);
|
|
38
|
+
const press = react.useSpring(1, { stiffness: 700, damping: 22 });
|
|
39
|
+
React__namespace.useEffect(() => {
|
|
40
|
+
const el = local.current;
|
|
41
|
+
if (!el || reduced || disabled) return;
|
|
42
|
+
if (typeof window === "undefined" || window.matchMedia?.("(hover: none)").matches) return;
|
|
43
|
+
let rect = el.getBoundingClientRect();
|
|
44
|
+
let raf = 0;
|
|
45
|
+
const refresh = () => {
|
|
46
|
+
tx.set(0);
|
|
47
|
+
ty.set(0);
|
|
48
|
+
rect = el.getBoundingClientRect();
|
|
49
|
+
};
|
|
50
|
+
const onMove = (event) => {
|
|
51
|
+
cancelAnimationFrame(raf);
|
|
52
|
+
raf = requestAnimationFrame(() => {
|
|
53
|
+
const r = rect;
|
|
54
|
+
const cxp = r.left + r.width / 2;
|
|
55
|
+
const cyp = r.top + r.height / 2;
|
|
56
|
+
const dx = event.clientX - cxp;
|
|
57
|
+
const dy = event.clientY - cyp;
|
|
58
|
+
const inside = event.clientX > r.left - radius && event.clientX < r.right + radius && event.clientY > r.top - radius && event.clientY < r.bottom + radius;
|
|
59
|
+
if (!inside) {
|
|
60
|
+
tx.set(0);
|
|
61
|
+
ty.set(0);
|
|
62
|
+
stretch.set(0);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (variant === "magnetic") {
|
|
66
|
+
tx.set(dx * strength);
|
|
67
|
+
ty.set(dy * strength);
|
|
68
|
+
} else {
|
|
69
|
+
const reach = Math.hypot(r.width / 2 + radius, r.height / 2 + radius);
|
|
70
|
+
const d = Math.min(1, Math.hypot(dx, dy) / reach);
|
|
71
|
+
angle.set(Math.atan2(dy, dx) * 180 / Math.PI);
|
|
72
|
+
stretch.set(d * 0.22 * (strength / 0.4));
|
|
73
|
+
tx.set(dx * strength * 0.18);
|
|
74
|
+
ty.set(dy * strength * 0.18);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
const reset = () => {
|
|
79
|
+
tx.set(0);
|
|
80
|
+
ty.set(0);
|
|
81
|
+
stretch.set(0);
|
|
82
|
+
};
|
|
83
|
+
window.addEventListener("pointermove", onMove, { passive: true });
|
|
84
|
+
window.addEventListener("scroll", refresh, { passive: true, capture: true });
|
|
85
|
+
window.addEventListener("resize", refresh);
|
|
86
|
+
document.addEventListener("pointerleave", reset);
|
|
87
|
+
return () => {
|
|
88
|
+
cancelAnimationFrame(raf);
|
|
89
|
+
window.removeEventListener("pointermove", onMove);
|
|
90
|
+
window.removeEventListener("scroll", refresh, true);
|
|
91
|
+
window.removeEventListener("resize", refresh);
|
|
92
|
+
document.removeEventListener("pointerleave", reset);
|
|
93
|
+
};
|
|
94
|
+
}, [variant, strength, radius, reduced, disabled]);
|
|
95
|
+
const surface = react.useTransform(
|
|
96
|
+
[tx, ty, stretch, angle, press],
|
|
97
|
+
([x, y, s, a, p]) => variant === "elastic" ? `translate(${x}px, ${y}px) rotate(${a}deg) scale(${(1 + s) * p}, ${(1 - s * 0.45) * p}) rotate(${-a}deg)` : `translate(${x}px, ${y}px) scale(${p})`
|
|
98
|
+
);
|
|
99
|
+
const content = react.useTransform([tx, ty, press], ([x, y, p]) => {
|
|
100
|
+
const k = variant === "magnetic" ? 1.45 : 1;
|
|
101
|
+
return `translate(${x * k}px, ${y * k}px) scale(${p})`;
|
|
102
|
+
});
|
|
103
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
104
|
+
"button",
|
|
105
|
+
{
|
|
106
|
+
...rest,
|
|
107
|
+
ref: chunk5ARTY5RT_cjs.mergeRefs(local, ref),
|
|
108
|
+
type: rest.type ?? "button",
|
|
109
|
+
disabled,
|
|
110
|
+
className: chunkPBMXL53R_cjs.cx("fl-reset-button fl-mbutton", className),
|
|
111
|
+
"data-variant": variant,
|
|
112
|
+
"data-tone": tone,
|
|
113
|
+
"data-size": size,
|
|
114
|
+
onPointerDown: (e) => {
|
|
115
|
+
onPointerDown?.(e);
|
|
116
|
+
if (!disabled && !reduced) {
|
|
117
|
+
press.set(0.94);
|
|
118
|
+
const up = () => {
|
|
119
|
+
press.set(1);
|
|
120
|
+
window.removeEventListener("pointerup", up);
|
|
121
|
+
window.removeEventListener("pointercancel", up);
|
|
122
|
+
};
|
|
123
|
+
window.addEventListener("pointerup", up);
|
|
124
|
+
window.addEventListener("pointercancel", up);
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
children: [
|
|
128
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.motion.span, { className: "fl-mbutton__surface", "aria-hidden": true, style: { transform: surface } }),
|
|
129
|
+
/* @__PURE__ */ jsxRuntime.jsxs(react.motion.span, { className: "fl-mbutton__content", style: { transform: content }, children: [
|
|
130
|
+
icon && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "fl-mbutton__icon", children: icon }),
|
|
131
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children })
|
|
132
|
+
] })
|
|
133
|
+
]
|
|
134
|
+
}
|
|
135
|
+
);
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
exports.MagneticButton = MagneticButton;
|