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.
Files changed (252) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +92 -3
  3. package/dist/chunk-2PABDSNH.cjs +208 -0
  4. package/dist/chunk-2Z4YKJMT.js +329 -0
  5. package/dist/chunk-344MRWFO.js +25 -0
  6. package/dist/chunk-3A2LHCPV.cjs +30 -0
  7. package/dist/chunk-3NQ776G6.cjs +204 -0
  8. package/dist/chunk-3XIEBFVO.cjs +130 -0
  9. package/dist/chunk-4IHNW52F.cjs +197 -0
  10. package/dist/chunk-4YGBUMQC.js +160 -0
  11. package/dist/chunk-5ARTY5RT.cjs +66 -0
  12. package/dist/chunk-5PAJS63K.cjs +156 -0
  13. package/dist/chunk-5Z32CAHE.cjs +261 -0
  14. package/dist/chunk-66ITQTT2.js +108 -0
  15. package/dist/chunk-6EABLOB7.js +190 -0
  16. package/dist/chunk-6FF73V3S.js +190 -0
  17. package/dist/chunk-6LRDNOZX.cjs +138 -0
  18. package/dist/chunk-76MEQHGW.js +192 -0
  19. package/dist/chunk-7B2YEOYF.js +26 -0
  20. package/dist/chunk-7Y22U2ZF.js +370 -0
  21. package/dist/chunk-AFGJQET4.js +186 -0
  22. package/dist/chunk-AG3OBSP5.cjs +216 -0
  23. package/dist/chunk-AHRXESD2.js +126 -0
  24. package/dist/chunk-AJPI65BL.cjs +153 -0
  25. package/dist/chunk-CCDDQHCS.js +182 -0
  26. package/dist/chunk-CGX6YCV6.js +130 -0
  27. package/dist/chunk-CPUW5LDN.cjs +28 -0
  28. package/dist/chunk-DAO7YH2R.cjs +165 -0
  29. package/dist/chunk-DO5WEBTN.cjs +139 -0
  30. package/dist/chunk-DUUDPN7C.cjs +203 -0
  31. package/dist/chunk-EOPY2VWT.cjs +185 -0
  32. package/dist/chunk-EUQ6BCML.cjs +175 -0
  33. package/dist/chunk-EYO4XMKU.js +145 -0
  34. package/dist/chunk-F7UECO7G.js +175 -0
  35. package/dist/chunk-FGJDDSUJ.js +303 -0
  36. package/dist/chunk-G5UZZ2XG.cjs +52 -0
  37. package/dist/chunk-GJ6WO63L.js +216 -0
  38. package/dist/chunk-GP32TY6P.cjs +409 -0
  39. package/dist/chunk-HQLB5Z37.cjs +275 -0
  40. package/dist/chunk-HSXGQNQ6.js +143 -0
  41. package/dist/chunk-I2XZ2WMY.js +385 -0
  42. package/dist/chunk-I525FOTN.cjs +214 -0
  43. package/dist/chunk-IAPRIVJO.js +157 -0
  44. package/dist/chunk-IUSSIILO.cjs +393 -0
  45. package/dist/chunk-JV6GJ3JJ.js +92 -0
  46. package/dist/chunk-KPG24YFL.js +30 -0
  47. package/dist/chunk-LGBMJIY6.js +174 -0
  48. package/dist/chunk-LYEOVFOQ.cjs +148 -0
  49. package/dist/chunk-LYYMITLC.js +238 -0
  50. package/dist/chunk-M42F5QS5.cjs +212 -0
  51. package/dist/chunk-NN3HMY7H.cjs +260 -0
  52. package/dist/chunk-NU5MGYFP.cjs +167 -0
  53. package/dist/chunk-OCIKUJ3U.js +117 -0
  54. package/dist/chunk-PBMXL53R.cjs +39 -0
  55. package/dist/chunk-PGEK6DFE.cjs +351 -0
  56. package/dist/chunk-QPWVBVDC.cjs +130 -0
  57. package/dist/chunk-QWYHH465.cjs +117 -0
  58. package/dist/chunk-RFCZJPGM.js +116 -0
  59. package/dist/chunk-RIBXHAKG.cjs +179 -0
  60. package/dist/chunk-SDWRKTFC.cjs +158 -0
  61. package/dist/chunk-SMY24MVU.js +92 -0
  62. package/dist/chunk-SSARMSS3.cjs +325 -0
  63. package/dist/chunk-T533JPW5.js +131 -0
  64. package/dist/chunk-T7AMVHIB.js +221 -0
  65. package/dist/chunk-TVGVZSIA.js +130 -0
  66. package/dist/chunk-UFU5S3LK.cjs +244 -0
  67. package/dist/chunk-UFUN2OKY.js +35 -0
  68. package/dist/chunk-VDSMO63G.cjs +153 -0
  69. package/dist/chunk-VHXWP5OX.cjs +115 -0
  70. package/dist/chunk-VW32EE3I.js +153 -0
  71. package/dist/chunk-WGFJLFTP.js +40 -0
  72. package/dist/chunk-WSL2OVTO.js +136 -0
  73. package/dist/chunk-WVWVJSU2.cjs +309 -0
  74. package/dist/chunk-XLZPYDNI.js +287 -0
  75. package/dist/chunk-XUBFOAT4.js +239 -0
  76. package/dist/chunk-Y3UCNSXF.js +253 -0
  77. package/dist/chunk-YDJMVDAJ.cjs +196 -0
  78. package/dist/chunk-ZF5HY2K4.cjs +238 -0
  79. package/dist/chunk-ZXKEYL6L.js +181 -0
  80. package/dist/chunk-ZZYMYQU2.js +108 -0
  81. package/dist/components/accordion.cjs +26 -0
  82. package/dist/components/accordion.d.cts +41 -0
  83. package/dist/components/accordion.d.ts +41 -0
  84. package/dist/components/accordion.js +5 -0
  85. package/dist/components/calendar.cjs +14 -0
  86. package/dist/components/calendar.d.cts +41 -0
  87. package/dist/components/calendar.d.ts +41 -0
  88. package/dist/components/calendar.js +5 -0
  89. package/dist/components/checkbox.cjs +14 -0
  90. package/dist/components/checkbox.d.cts +27 -0
  91. package/dist/components/checkbox.d.ts +27 -0
  92. package/dist/components/checkbox.js +5 -0
  93. package/dist/components/chip-select.cjs +14 -0
  94. package/dist/components/chip-select.d.cts +31 -0
  95. package/dist/components/chip-select.d.ts +31 -0
  96. package/dist/components/chip-select.js +5 -0
  97. package/dist/components/clock.cjs +12 -0
  98. package/dist/components/clock.d.cts +25 -0
  99. package/dist/components/clock.d.ts +25 -0
  100. package/dist/components/clock.js +3 -0
  101. package/dist/components/color-picker.cjs +14 -0
  102. package/dist/components/color-picker.d.cts +23 -0
  103. package/dist/components/color-picker.d.ts +23 -0
  104. package/dist/components/color-picker.js +5 -0
  105. package/dist/components/command-palette.cjs +20 -0
  106. package/dist/components/command-palette.d.cts +53 -0
  107. package/dist/components/command-palette.d.ts +53 -0
  108. package/dist/components/command-palette.js +7 -0
  109. package/dist/components/date-picker.cjs +18 -0
  110. package/dist/components/date-picker.d.cts +40 -0
  111. package/dist/components/date-picker.d.ts +40 -0
  112. package/dist/components/date-picker.js +9 -0
  113. package/dist/components/drawer.cjs +16 -0
  114. package/dist/components/drawer.d.cts +22 -0
  115. package/dist/components/drawer.d.ts +22 -0
  116. package/dist/components/drawer.js +7 -0
  117. package/dist/components/floating-panel.cjs +13 -0
  118. package/dist/components/floating-panel.d.cts +25 -0
  119. package/dist/components/floating-panel.d.ts +25 -0
  120. package/dist/components/floating-panel.js +4 -0
  121. package/dist/components/hold-button.cjs +13 -0
  122. package/dist/components/hold-button.d.cts +30 -0
  123. package/dist/components/hold-button.d.ts +30 -0
  124. package/dist/components/hold-button.js +4 -0
  125. package/dist/components/knob.cjs +15 -0
  126. package/dist/components/knob.d.cts +33 -0
  127. package/dist/components/knob.d.ts +33 -0
  128. package/dist/components/knob.js +6 -0
  129. package/dist/components/magnetic-button.cjs +13 -0
  130. package/dist/components/magnetic-button.d.cts +23 -0
  131. package/dist/components/magnetic-button.d.ts +23 -0
  132. package/dist/components/magnetic-button.js +4 -0
  133. package/dist/components/morph-button.cjs +13 -0
  134. package/dist/components/morph-button.d.cts +34 -0
  135. package/dist/components/morph-button.d.ts +34 -0
  136. package/dist/components/morph-button.js +4 -0
  137. package/dist/components/morph-dialog.cjs +32 -0
  138. package/dist/components/morph-dialog.d.cts +30 -0
  139. package/dist/components/morph-dialog.d.ts +30 -0
  140. package/dist/components/morph-dialog.js +7 -0
  141. package/dist/components/number-field.cjs +15 -0
  142. package/dist/components/number-field.d.cts +32 -0
  143. package/dist/components/number-field.d.ts +32 -0
  144. package/dist/components/number-field.js +6 -0
  145. package/dist/components/pin-input.cjs +14 -0
  146. package/dist/components/pin-input.d.cts +29 -0
  147. package/dist/components/pin-input.d.ts +29 -0
  148. package/dist/components/pin-input.js +5 -0
  149. package/dist/components/popover.cjs +16 -0
  150. package/dist/components/popover.d.cts +26 -0
  151. package/dist/components/popover.d.ts +26 -0
  152. package/dist/components/popover.js +7 -0
  153. package/dist/components/progress.cjs +17 -0
  154. package/dist/components/progress.d.cts +39 -0
  155. package/dist/components/progress.d.ts +39 -0
  156. package/dist/components/progress.js +4 -0
  157. package/dist/components/radial-menu.cjs +14 -0
  158. package/dist/components/radial-menu.d.cts +31 -0
  159. package/dist/components/radial-menu.d.ts +31 -0
  160. package/dist/components/radial-menu.js +5 -0
  161. package/dist/components/radio-group.cjs +14 -0
  162. package/dist/components/radio-group.d.cts +34 -0
  163. package/dist/components/radio-group.d.ts +34 -0
  164. package/dist/components/radio-group.js +5 -0
  165. package/dist/components/resizable-panels.cjs +18 -0
  166. package/dist/components/resizable-panels.d.cts +24 -0
  167. package/dist/components/resizable-panels.d.ts +24 -0
  168. package/dist/components/resizable-panels.js +5 -0
  169. package/dist/components/segmented-control.cjs +14 -0
  170. package/dist/components/segmented-control.d.cts +34 -0
  171. package/dist/components/segmented-control.d.ts +34 -0
  172. package/dist/components/segmented-control.js +5 -0
  173. package/dist/components/slider.cjs +15 -0
  174. package/dist/components/slider.d.cts +39 -0
  175. package/dist/components/slider.d.ts +39 -0
  176. package/dist/components/slider.js +6 -0
  177. package/dist/components/sortable-list.cjs +13 -0
  178. package/dist/components/sortable-list.d.cts +24 -0
  179. package/dist/components/sortable-list.d.ts +24 -0
  180. package/dist/components/sortable-list.js +4 -0
  181. package/dist/components/sparkline.cjs +14 -0
  182. package/dist/components/sparkline.d.cts +28 -0
  183. package/dist/components/sparkline.d.ts +28 -0
  184. package/dist/components/sparkline.js +5 -0
  185. package/dist/components/swipe-confirm.cjs +13 -0
  186. package/dist/components/swipe-confirm.d.cts +18 -0
  187. package/dist/components/swipe-confirm.d.ts +18 -0
  188. package/dist/components/swipe-confirm.js +4 -0
  189. package/dist/components/switch.cjs +15 -0
  190. package/dist/components/switch.d.cts +29 -0
  191. package/dist/components/switch.d.ts +29 -0
  192. package/dist/components/switch.js +6 -0
  193. package/dist/components/tabs.cjs +30 -0
  194. package/dist/components/tabs.d.cts +29 -0
  195. package/dist/components/tabs.d.ts +29 -0
  196. package/dist/components/tabs.js +5 -0
  197. package/dist/components/tether.cjs +16 -0
  198. package/dist/components/tether.d.cts +35 -0
  199. package/dist/components/tether.d.ts +35 -0
  200. package/dist/components/tether.js +3 -0
  201. package/dist/components/theme-switch.cjs +14 -0
  202. package/dist/components/theme-switch.d.cts +24 -0
  203. package/dist/components/theme-switch.d.ts +24 -0
  204. package/dist/components/theme-switch.js +5 -0
  205. package/dist/components/toaster.cjs +21 -0
  206. package/dist/components/toaster.d.cts +71 -0
  207. package/dist/components/toaster.d.ts +71 -0
  208. package/dist/components/toaster.js +4 -0
  209. package/dist/components/wheel-picker.cjs +15 -0
  210. package/dist/components/wheel-picker.d.cts +27 -0
  211. package/dist/components/wheel-picker.d.ts +27 -0
  212. package/dist/components/wheel-picker.js +6 -0
  213. package/dist/css/accordion.css +2 -0
  214. package/dist/css/base.css +2 -0
  215. package/dist/css/calendar.css +2 -0
  216. package/dist/css/checkbox.css +2 -0
  217. package/dist/css/chip-select.css +2 -0
  218. package/dist/css/clock.css +2 -0
  219. package/dist/css/color-picker.css +2 -0
  220. package/dist/css/command-palette.css +2 -0
  221. package/dist/css/date-picker.css +2 -0
  222. package/dist/css/drawer.css +2 -0
  223. package/dist/css/floating-panel.css +2 -0
  224. package/dist/css/hold-button.css +2 -0
  225. package/dist/css/knob.css +2 -0
  226. package/dist/css/magnetic-button.css +2 -0
  227. package/dist/css/morph-button.css +2 -0
  228. package/dist/css/morph-dialog.css +2 -0
  229. package/dist/css/number-field.css +2 -0
  230. package/dist/css/pin-input.css +2 -0
  231. package/dist/css/popover.css +2 -0
  232. package/dist/css/progress.css +2 -0
  233. package/dist/css/radial-menu.css +2 -0
  234. package/dist/css/radio-group.css +2 -0
  235. package/dist/css/resizable-panels.css +2 -0
  236. package/dist/css/segmented-control.css +2 -0
  237. package/dist/css/slider.css +2 -0
  238. package/dist/css/sortable-list.css +2 -0
  239. package/dist/css/sparkline.css +2 -0
  240. package/dist/css/swipe-confirm.css +2 -0
  241. package/dist/css/switch.css +2 -0
  242. package/dist/css/tabs.css +2 -0
  243. package/dist/css/tether.css +2 -0
  244. package/dist/css/theme-switch.css +2 -0
  245. package/dist/css/toaster.css +2 -0
  246. package/dist/css/wheel-picker.css +2 -0
  247. package/dist/index.cjs +249 -0
  248. package/dist/index.d.cts +77 -0
  249. package/dist/index.d.ts +77 -0
  250. package/dist/index.js +40 -0
  251. package/dist/styles.css +2 -0
  252. package/package.json +98 -6
@@ -0,0 +1,192 @@
1
+ 'use client';
2
+ import { useElementSize, haptic, mergeRefs } from './chunk-WGFJLFTP.js';
3
+ import { useMotionPreset, cx } from './chunk-UFUN2OKY.js';
4
+ import * as React from 'react';
5
+ import { useMotionValue, useMotionValueEvent, useAnimationFrame, useTransform, motion, animate } from 'motion/react';
6
+ import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
7
+
8
+ var REWIND = { type: "spring", stiffness: 260, damping: 18, mass: 0.8 };
9
+ function pillPath(w, h, inset) {
10
+ const r = Math.max(0, h / 2 - inset);
11
+ const x0 = inset;
12
+ const y0 = inset;
13
+ const x1 = w - inset;
14
+ const y1 = h - inset;
15
+ const mid = w / 2;
16
+ return `M${mid} ${y0} L${x1 - r} ${y0} A${r} ${r} 0 0 1 ${x1 - r} ${y1} L${x0 + r} ${y1} A${r} ${r} 0 0 1 ${x0 + r} ${y0} Z`;
17
+ }
18
+ var HoldButton = React.forwardRef(function HoldButton2({
19
+ onConfirm,
20
+ duration = 1200,
21
+ variant = "fill",
22
+ tone = "danger",
23
+ size = "md",
24
+ confirmedLabel = "Confirmed",
25
+ icon,
26
+ resetAfter = 2200,
27
+ haptics = true,
28
+ onHoldProgress,
29
+ children,
30
+ className,
31
+ disabled,
32
+ ...rest
33
+ }, ref) {
34
+ const { reduced } = useMotionPreset();
35
+ const p = useMotionValue(0);
36
+ const jitter = useMotionValue(0);
37
+ const holding = React.useRef(false);
38
+ const anim = React.useRef(null);
39
+ const [confirmed, setConfirmed] = React.useState(false);
40
+ const [active, setActive] = React.useState(false);
41
+ const timer = React.useRef(void 0);
42
+ const lastTick = React.useRef(0);
43
+ const [sizeRef, box] = useElementSize();
44
+ const pathRef = React.useRef(null);
45
+ const hintId = React.useId();
46
+ React.useEffect(() => () => clearTimeout(timer.current), []);
47
+ useMotionValueEvent(p, "change", (v) => {
48
+ onHoldProgress?.(Math.max(0, Math.min(1, v)));
49
+ const tick = Math.floor(v * 4);
50
+ if (holding.current && tick > lastTick.current && tick < 4 && haptics) haptic(3);
51
+ lastTick.current = tick;
52
+ });
53
+ useAnimationFrame((time) => {
54
+ if (reduced || !holding.current) {
55
+ if (jitter.get() !== 0) jitter.set(0);
56
+ return;
57
+ }
58
+ const v = p.get();
59
+ const amp = v > 0.6 ? (v - 0.6) / 0.4 * 1.4 : 0;
60
+ jitter.set(Math.sin(time * 0.11) * amp);
61
+ });
62
+ const confirm = () => {
63
+ holding.current = false;
64
+ setActive(false);
65
+ setConfirmed(true);
66
+ if (haptics) haptic([10, 50, 18]);
67
+ onConfirm?.();
68
+ if (resetAfter > 0) {
69
+ clearTimeout(timer.current);
70
+ timer.current = setTimeout(() => {
71
+ setConfirmed(false);
72
+ animate(p, 0, reduced ? { duration: 0 } : { duration: 0.35, ease: [0.4, 0, 0.2, 1] });
73
+ }, resetAfter);
74
+ }
75
+ };
76
+ const start = () => {
77
+ if (disabled || confirmed || holding.current) return;
78
+ holding.current = true;
79
+ setActive(true);
80
+ anim.current?.stop();
81
+ const remaining = (1 - p.get()) * duration;
82
+ anim.current = animate(p, 1, { duration: remaining / 1e3, ease: [0.35, 0, 0.75, 1] });
83
+ anim.current.then(() => {
84
+ if (holding.current && p.get() >= 0.999) confirm();
85
+ });
86
+ };
87
+ const cancel = () => {
88
+ if (!holding.current) return;
89
+ holding.current = false;
90
+ setActive(false);
91
+ anim.current?.stop();
92
+ animate(p, 0, reduced ? { duration: 0.15 } : REWIND);
93
+ };
94
+ const clamped = useTransform(p, (v) => Math.max(0, Math.min(1, v)));
95
+ const squeeze = useTransform(clamped, [0, 1], [1, 0.955]);
96
+ const clip = useTransform(clamped, (v) => `inset(0 ${(1 - v) * 100}% 0 0)`);
97
+ const inverseVisibility = useTransform(clamped, (v) => v > 1e-3 ? "visible" : "hidden");
98
+ const spark = useTransform(clamped, (v) => {
99
+ const path = pathRef.current;
100
+ if (!path) return "translate(-99px,-99px)";
101
+ const len = path.getTotalLength();
102
+ const pt = path.getPointAtLength(v * len);
103
+ return `translate(${pt.x}px, ${pt.y}px)`;
104
+ });
105
+ const sparkOpacity = useTransform(clamped, [0, 0.02, 0.98, 1], [0, 1, 1, 0]);
106
+ const strokeOpacity = useTransform(clamped, (v) => v > 2e-3 ? 1 : 0);
107
+ const content = (inverse = false) => /* @__PURE__ */ jsxs("span", { className: "fl-hold__content", "data-inverse": inverse || void 0, children: [
108
+ variant === "ring" && /* @__PURE__ */ jsx("span", { className: "fl-hold__icon", children: confirmed ? /* @__PURE__ */ jsx(Check, {}) : icon ?? /* @__PURE__ */ jsx(DefaultIcon, {}) }),
109
+ /* @__PURE__ */ jsx("span", { className: "fl-hold__label", children: confirmed ? confirmedLabel : children })
110
+ ] });
111
+ return /* @__PURE__ */ jsxs(
112
+ motion.button,
113
+ {
114
+ ...rest,
115
+ ref: mergeRefs(sizeRef, ref),
116
+ type: "button",
117
+ disabled,
118
+ "aria-describedby": hintId,
119
+ className: cx("fl-reset-button fl-hold", className),
120
+ "data-variant": variant,
121
+ "data-tone": tone,
122
+ "data-size": size,
123
+ "data-holding": active || void 0,
124
+ "data-state": confirmed ? "confirmed" : "idle",
125
+ style: { scale: squeeze, x: jitter },
126
+ onPointerDown: (e) => {
127
+ rest.onPointerDown?.(e);
128
+ if (e.button !== 0) return;
129
+ e.currentTarget.setPointerCapture?.(e.pointerId);
130
+ start();
131
+ },
132
+ onPointerUp: cancel,
133
+ onPointerCancel: cancel,
134
+ onKeyDown: (e) => {
135
+ if ((e.key === " " || e.key === "Enter") && !e.repeat) {
136
+ e.preventDefault();
137
+ start();
138
+ }
139
+ },
140
+ onKeyUp: (e) => {
141
+ if (e.key === " " || e.key === "Enter") cancel();
142
+ },
143
+ onBlur: cancel,
144
+ onContextMenu: (e) => e.preventDefault(),
145
+ children: [
146
+ variant === "fill" && /* @__PURE__ */ jsxs(Fragment, { children: [
147
+ /* @__PURE__ */ jsx(motion.span, { className: "fl-hold__fill", "aria-hidden": true, style: { scaleX: clamped } }),
148
+ content(),
149
+ /* @__PURE__ */ jsx(motion.span, { className: "fl-hold__inverse", "aria-hidden": true, style: { clipPath: clip, visibility: inverseVisibility }, children: content(true) })
150
+ ] }),
151
+ variant === "ring" && /* @__PURE__ */ jsxs(Fragment, { children: [
152
+ /* @__PURE__ */ jsx("span", { className: "fl-hold__dial", "aria-hidden": true, children: /* @__PURE__ */ jsxs("svg", { viewBox: "0 0 40 40", children: [
153
+ /* @__PURE__ */ jsx("circle", { className: "fl-hold__track", cx: "20", cy: "20", r: "18" }),
154
+ /* @__PURE__ */ jsx(motion.circle, { className: "fl-hold__progress", cx: "20", cy: "20", r: "18", style: { pathLength: clamped, opacity: strokeOpacity } })
155
+ ] }) }),
156
+ content()
157
+ ] }),
158
+ variant === "fuse" && /* @__PURE__ */ jsxs(Fragment, { children: [
159
+ box.width > 0 && /* @__PURE__ */ jsxs("svg", { className: "fl-hold__fuse", width: box.width, height: box.height, "aria-hidden": true, children: [
160
+ /* @__PURE__ */ jsx("path", { className: "fl-hold__fuse-track", d: pillPath(box.width, box.height, 1) }),
161
+ /* @__PURE__ */ jsx(motion.path, { ref: pathRef, className: "fl-hold__fuse-burn", d: pillPath(box.width, box.height, 1), style: { pathLength: clamped, opacity: strokeOpacity } }),
162
+ /* @__PURE__ */ jsx(motion.circle, { className: "fl-hold__spark", r: "2.6", cx: "0", cy: "0", style: { transform: spark, opacity: sparkOpacity } })
163
+ ] }),
164
+ content()
165
+ ] }),
166
+ /* @__PURE__ */ jsx("span", { id: hintId, className: "fl-sr-only", children: "Press and hold to confirm" }),
167
+ /* @__PURE__ */ jsx("span", { className: "fl-sr-only", "aria-live": "assertive", children: confirmed ? typeof confirmedLabel === "string" ? confirmedLabel : "Confirmed" : "" })
168
+ ]
169
+ }
170
+ );
171
+ });
172
+ function DefaultIcon() {
173
+ return /* @__PURE__ */ jsx("svg", { viewBox: "0 0 20 20", width: "18", height: "18", fill: "none", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true, children: /* @__PURE__ */ jsx("path", { d: "M4 6h12M8 6V4.5h4V6M6 6l.7 9.2a1.5 1.5 0 0 0 1.5 1.3h3.6a1.5 1.5 0 0 0 1.5-1.3L14 6" }) });
174
+ }
175
+ function Check() {
176
+ return /* @__PURE__ */ jsx("svg", { viewBox: "0 0 20 20", width: "18", height: "18", "aria-hidden": true, children: /* @__PURE__ */ jsx(
177
+ motion.path,
178
+ {
179
+ d: "M5 10.4 L8.4 13.6 L15 6.6",
180
+ fill: "none",
181
+ stroke: "currentColor",
182
+ strokeWidth: "2",
183
+ strokeLinecap: "round",
184
+ strokeLinejoin: "round",
185
+ initial: { pathLength: 0 },
186
+ animate: { pathLength: 1 },
187
+ transition: { type: "spring", stiffness: 220, damping: 22 }
188
+ }
189
+ ) });
190
+ }
191
+
192
+ export { HoldButton };
@@ -0,0 +1,26 @@
1
+ 'use client';
2
+ import { useMounted } from './chunk-WGFJLFTP.js';
3
+ import { createPortal } from 'react-dom';
4
+ import { jsx } from 'react/jsx-runtime';
5
+
6
+ function resolveTheme(anchor) {
7
+ const el = anchor?.closest("[data-theme],[data-fl-theme],.dark,.light");
8
+ if (!el) return void 0;
9
+ const attr = el.getAttribute("data-fl-theme") ?? el.getAttribute("data-theme");
10
+ if (attr === "dark" || attr === "light") return attr;
11
+ if (el.classList.contains("dark")) return "dark";
12
+ if (el.classList.contains("light")) return "light";
13
+ return void 0;
14
+ }
15
+ function Portal({ children, container, anchor, className }) {
16
+ const mounted = useMounted();
17
+ if (!mounted) return null;
18
+ const target = container ?? document.body;
19
+ const theme = resolveTheme(anchor);
20
+ return createPortal(
21
+ /* @__PURE__ */ jsx("div", { className: className ? `fl-portal ${className}` : "fl-portal", "data-fl-theme": theme, children }),
22
+ target
23
+ );
24
+ }
25
+
26
+ export { Portal };
@@ -0,0 +1,370 @@
1
+ 'use client';
2
+ import { useScrollLock, useFocusTrap, useEscape } from './chunk-SMY24MVU.js';
3
+ import { Portal } from './chunk-7B2YEOYF.js';
4
+ import { useIsoLayoutEffect } from './chunk-WGFJLFTP.js';
5
+ import { useControllableState } from './chunk-KPG24YFL.js';
6
+ import { useMotionPreset, cx } from './chunk-UFUN2OKY.js';
7
+ import * as React from 'react';
8
+ import { useMotionValue, animate, motion, AnimatePresence } from 'motion/react';
9
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
10
+
11
+ // src/components/command-palette/fuzzy.ts
12
+ function fuzzyMatch(query, text) {
13
+ const q = query.toLowerCase().replace(/\s+/g, "");
14
+ if (!q) return { score: 0, indices: [] };
15
+ const t = text.toLowerCase();
16
+ const sub = t.indexOf(query.toLowerCase().trim());
17
+ if (sub !== -1) {
18
+ const len = query.trim().length;
19
+ return { score: 1e3 - sub * 2 - (t.length - len) * 0.5 + (sub === 0 || /\W/.test(t[sub - 1] ?? " ") ? 120 : 0), indices: Array.from({ length: len }, (_, i) => sub + i) };
20
+ }
21
+ const indices = [];
22
+ let score = 0;
23
+ let ti = 0;
24
+ let run = 0;
25
+ for (let qi = 0; qi < q.length; qi++) {
26
+ const ch = q[qi];
27
+ let found = -1;
28
+ for (; ti < t.length; ti++) {
29
+ if (t[ti] === ch) {
30
+ found = ti;
31
+ break;
32
+ }
33
+ }
34
+ if (found === -1) return null;
35
+ const wordStart = found === 0 || /[\s\-_/.]/.test(t[found - 1]);
36
+ const consecutive = indices.length > 0 && indices[indices.length - 1] === found - 1;
37
+ run = consecutive ? run + 1 : 0;
38
+ score += 10 + (wordStart ? 30 : 0) + run * 15 - Math.min(found, 20) * 0.5;
39
+ indices.push(found);
40
+ ti = found + 1;
41
+ }
42
+ return { score: score - (t.length - q.length) * 0.3, indices };
43
+ }
44
+ var SPRING = { type: "spring", stiffness: 520, damping: 40 };
45
+ function isMac() {
46
+ return typeof navigator !== "undefined" && /mac|iphone|ipad/i.test(navigator.platform || navigator.userAgent);
47
+ }
48
+ function matchHotkey(event, hotkey) {
49
+ const parts = hotkey.toLowerCase().split("+");
50
+ const key = parts.pop();
51
+ const mod = parts.includes("mod");
52
+ const wantMeta = parts.includes("meta") || mod && isMac();
53
+ const wantCtrl = parts.includes("ctrl") || mod && !isMac();
54
+ return event.key.toLowerCase() === key && event.metaKey === wantMeta && event.ctrlKey === wantCtrl && event.shiftKey === parts.includes("shift") && event.altKey === parts.includes("alt");
55
+ }
56
+ function Highlight({ text, indices }) {
57
+ if (!indices.length) return /* @__PURE__ */ jsx(Fragment, { children: text });
58
+ const set = new Set(indices);
59
+ const out = [];
60
+ let buf = "";
61
+ let mark = false;
62
+ for (let i = 0; i <= text.length; i++) {
63
+ const m = set.has(i);
64
+ if (i === text.length || m !== mark) {
65
+ if (buf) out.push(mark ? /* @__PURE__ */ jsx("mark", { children: buf }, i) : buf);
66
+ buf = "";
67
+ mark = m;
68
+ }
69
+ if (i < text.length) buf += text[i];
70
+ }
71
+ return /* @__PURE__ */ jsx(Fragment, { children: out });
72
+ }
73
+ var CommandPalette = React.forwardRef(function CommandPalette2({
74
+ items,
75
+ open: openProp,
76
+ defaultOpen = false,
77
+ onOpenChange,
78
+ hotkey = "mod+k",
79
+ placeholder = "Type a command or search\u2026",
80
+ emptyMessage = "No results",
81
+ inline = false,
82
+ onItemSelect,
83
+ maxHeight = 360,
84
+ container,
85
+ footer = true,
86
+ className,
87
+ ...rest
88
+ }, ref) {
89
+ const [openState, setOpen] = useControllableState({ value: openProp, defaultValue: defaultOpen, onChange: onOpenChange });
90
+ const open = inline || openState;
91
+ const { t } = useMotionPreset();
92
+ const [query, setQuery] = React.useState("");
93
+ const [stack, setStack] = React.useState([]);
94
+ const [active, setActive] = React.useState(0);
95
+ const [direction, setDirection] = React.useState(1);
96
+ const panelRef = React.useRef(null);
97
+ const inputRef = React.useRef(null);
98
+ const listRef = React.useRef(null);
99
+ const innerRef = React.useRef(null);
100
+ const listId = React.useId();
101
+ const anchorRef = React.useRef(null);
102
+ const hy = useMotionValue(0);
103
+ const hh = useMotionValue(0);
104
+ const ho = useMotionValue(0);
105
+ const listHeight = useMotionValue(0);
106
+ const pointerMoved = React.useRef(false);
107
+ useScrollLock(open && !inline);
108
+ useFocusTrap(panelRef, open && !inline, inputRef);
109
+ useEscape(open && !inline, () => setOpen(false));
110
+ React.useEffect(() => {
111
+ if (!hotkey || inline) return;
112
+ const onKey = (event) => {
113
+ if (matchHotkey(event, hotkey)) {
114
+ event.preventDefault();
115
+ setOpen((o) => !o);
116
+ }
117
+ };
118
+ document.addEventListener("keydown", onKey);
119
+ return () => document.removeEventListener("keydown", onKey);
120
+ }, [hotkey, inline]);
121
+ React.useEffect(() => {
122
+ if (!open) {
123
+ setQuery("");
124
+ setStack([]);
125
+ setActive(0);
126
+ }
127
+ }, [open]);
128
+ const page = stack.length ? stack[stack.length - 1].items ?? [] : items;
129
+ const groups = React.useMemo(() => {
130
+ const map = /* @__PURE__ */ new Map();
131
+ for (const item of page) {
132
+ let row = null;
133
+ if (!query.trim()) row = { item, indices: [], score: 0 };
134
+ else {
135
+ const m = fuzzyMatch(query, item.label);
136
+ const kw = m ? null : (item.keywords ?? []).map((k) => fuzzyMatch(query, k)).find(Boolean);
137
+ if (m) row = { item, indices: m.indices, score: m.score };
138
+ else if (kw) row = { item, indices: [], score: kw.score * 0.6 };
139
+ }
140
+ if (!row) continue;
141
+ const g = item.group ?? "";
142
+ if (!map.has(g)) map.set(g, []);
143
+ map.get(g).push(row);
144
+ }
145
+ const list = Array.from(map, ([name, rows]) => ({ name, rows: query.trim() ? rows.sort((a, b) => b.score - a.score) : rows }));
146
+ if (query.trim()) list.sort((a, b) => (b.rows[0]?.score ?? 0) - (a.rows[0]?.score ?? 0));
147
+ return list;
148
+ }, [page, query]);
149
+ const flat = groups.flatMap((g) => g.rows);
150
+ const activeRow = flat[Math.min(active, flat.length - 1)];
151
+ React.useEffect(() => setActive(0), [query, stack.length]);
152
+ useIsoLayoutEffect(() => {
153
+ const list = listRef.current;
154
+ const el = activeRow ? list?.querySelector(`[data-cmd-id="${CSS.escape(activeRow.item.id)}"]`) : null;
155
+ if (!el || !list) {
156
+ ho.set(0);
157
+ return;
158
+ }
159
+ const top = el.offsetTop;
160
+ const height = el.offsetHeight;
161
+ if (ho.get() === 0) {
162
+ hy.set(top);
163
+ hh.set(height);
164
+ } else {
165
+ animate(hy, top, t(SPRING));
166
+ animate(hh, height, t(SPRING));
167
+ }
168
+ ho.set(1);
169
+ if (top < list.scrollTop) list.scrollTop = top - 8;
170
+ else if (top + height > list.scrollTop + list.clientHeight) list.scrollTop = top + height - list.clientHeight + 8;
171
+ }, [activeRow?.item.id, groups.length, open, stack.length, query]);
172
+ useIsoLayoutEffect(() => {
173
+ const inner = innerRef.current;
174
+ if (!inner || !open) return;
175
+ const apply = (instant) => {
176
+ const h = Math.min(maxHeight, inner.offsetHeight);
177
+ if (instant) listHeight.set(h);
178
+ else animate(listHeight, h, t({ type: "spring", stiffness: 420, damping: 38 }));
179
+ };
180
+ apply(listHeight.get() === 0);
181
+ if (typeof ResizeObserver === "undefined") return;
182
+ const ro = new ResizeObserver(() => apply(false));
183
+ ro.observe(inner);
184
+ return () => ro.disconnect();
185
+ }, [open, maxHeight]);
186
+ const choose = (row) => {
187
+ if (!row || row.item.disabled) return;
188
+ const { item } = row;
189
+ if (item.items) {
190
+ setDirection(1);
191
+ setStack((s) => [...s, item]);
192
+ setQuery("");
193
+ return;
194
+ }
195
+ const keep = item.onSelect?.() === false;
196
+ onItemSelect?.(item);
197
+ if (!keep && !inline) setOpen(false);
198
+ };
199
+ const onKeyDown = (event) => {
200
+ const n = flat.length;
201
+ if (event.key === "ArrowDown") {
202
+ event.preventDefault();
203
+ if (n) setActive((a) => (a + 1) % n);
204
+ } else if (event.key === "ArrowUp") {
205
+ event.preventDefault();
206
+ if (n) setActive((a) => (a - 1 + n) % n);
207
+ } else if (event.key === "Home" && event.ctrlKey) {
208
+ setActive(0);
209
+ } else if (event.key === "End" && event.ctrlKey) {
210
+ setActive(n - 1);
211
+ } else if (event.key === "Enter") {
212
+ event.preventDefault();
213
+ choose(activeRow);
214
+ } else if (event.key === "Backspace" && !query && stack.length) {
215
+ event.preventDefault();
216
+ setDirection(-1);
217
+ setStack((s) => s.slice(0, -1));
218
+ }
219
+ };
220
+ const currentPlaceholder = stack.length ? stack[stack.length - 1].placeholder ?? `Search ${stack[stack.length - 1].label.toLowerCase()}\u2026` : placeholder;
221
+ let rowIndex = -1;
222
+ const panel = /* @__PURE__ */ jsxs(
223
+ motion.div,
224
+ {
225
+ ...rest,
226
+ ref: (el) => {
227
+ panelRef.current = el;
228
+ if (typeof ref === "function") ref(el);
229
+ else if (ref) ref.current = el;
230
+ },
231
+ role: inline ? void 0 : "dialog",
232
+ "aria-modal": inline ? void 0 : true,
233
+ "aria-label": rest["aria-label"] ?? "Command palette",
234
+ className: cx("fl-command", className),
235
+ "data-inline": inline || void 0,
236
+ initial: inline ? false : { opacity: 0, scale: 0.96, y: -12 },
237
+ animate: { opacity: 1, scale: 1, y: 0 },
238
+ exit: { opacity: 0, scale: 0.97, y: -8, transition: { duration: 0.14 } },
239
+ transition: t({ type: "spring", stiffness: 460, damping: 34 }),
240
+ children: [
241
+ /* @__PURE__ */ jsxs("div", { className: "fl-command__search", children: [
242
+ /* @__PURE__ */ jsxs("svg", { viewBox: "0 0 16 16", width: "16", height: "16", "aria-hidden": true, className: "fl-command__glass", children: [
243
+ /* @__PURE__ */ jsx("circle", { cx: "7", cy: "7", r: "4.6", fill: "none", stroke: "currentColor", strokeWidth: "1.5" }),
244
+ /* @__PURE__ */ jsx("path", { d: "M10.6 10.6 14 14", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" })
245
+ ] }),
246
+ /* @__PURE__ */ jsx(AnimatePresence, { initial: false, children: stack.map((s) => /* @__PURE__ */ jsx(
247
+ motion.button,
248
+ {
249
+ type: "button",
250
+ className: "fl-reset-button fl-command__crumb",
251
+ initial: { opacity: 0, scale: 0.8, width: 0 },
252
+ animate: { opacity: 1, scale: 1, width: "auto" },
253
+ exit: { opacity: 0, scale: 0.8, width: 0 },
254
+ transition: t(SPRING),
255
+ onClick: () => {
256
+ setDirection(-1);
257
+ setStack((st) => st.slice(0, st.indexOf(s) + 1));
258
+ inputRef.current?.focus();
259
+ },
260
+ children: /* @__PURE__ */ jsx("span", { children: s.label })
261
+ },
262
+ s.id
263
+ )) }),
264
+ /* @__PURE__ */ jsx(
265
+ "input",
266
+ {
267
+ ref: inputRef,
268
+ className: "fl-command__input",
269
+ value: query,
270
+ placeholder: currentPlaceholder,
271
+ onChange: (e) => setQuery(e.target.value),
272
+ onKeyDown,
273
+ role: "combobox",
274
+ "aria-expanded": "true",
275
+ "aria-controls": listId,
276
+ "aria-activedescendant": activeRow ? `${listId}-${activeRow.item.id}` : void 0,
277
+ "aria-autocomplete": "list",
278
+ autoComplete: "off",
279
+ spellCheck: false
280
+ }
281
+ ),
282
+ !inline && /* @__PURE__ */ jsx("kbd", { className: "fl-kbd", children: "esc" })
283
+ ] }),
284
+ /* @__PURE__ */ jsxs(motion.div, { ref: listRef, className: "fl-command__list", id: listId, role: "listbox", style: { height: listHeight, maxHeight }, onPointerMove: () => pointerMoved.current = true, children: [
285
+ /* @__PURE__ */ jsx(motion.span, { className: "fl-command__highlight", "aria-hidden": true, style: { y: hy, height: hh, opacity: ho } }),
286
+ /* @__PURE__ */ jsx(AnimatePresence, { mode: "popLayout", initial: false, custom: direction, children: /* @__PURE__ */ jsxs(
287
+ motion.div,
288
+ {
289
+ ref: innerRef,
290
+ className: "fl-command__page",
291
+ custom: direction,
292
+ initial: { opacity: 0, x: direction * 24 },
293
+ animate: { opacity: 1, x: 0 },
294
+ exit: { opacity: 0, x: direction * -24 },
295
+ transition: t({ type: "spring", stiffness: 460, damping: 38, opacity: { duration: 0.12 } }),
296
+ children: [
297
+ flat.length === 0 && /* @__PURE__ */ jsx("div", { className: "fl-command__empty", children: emptyMessage }),
298
+ groups.map((group) => /* @__PURE__ */ jsxs("div", { role: "group", "aria-label": group.name || void 0, className: "fl-command__group", children: [
299
+ group.name && /* @__PURE__ */ jsx("div", { className: "fl-command__heading", "aria-hidden": true, children: group.name }),
300
+ group.rows.map((row) => {
301
+ rowIndex++;
302
+ const index = rowIndex;
303
+ const isActive = activeRow?.item.id === row.item.id;
304
+ return /* @__PURE__ */ jsxs(
305
+ "div",
306
+ {
307
+ id: `${listId}-${row.item.id}`,
308
+ "data-cmd-id": row.item.id,
309
+ role: "option",
310
+ "aria-selected": isActive,
311
+ "aria-disabled": row.item.disabled || void 0,
312
+ className: "fl-command__item",
313
+ "data-active": isActive || void 0,
314
+ onPointerMove: () => {
315
+ if (pointerMoved.current && !isActive) setActive(index);
316
+ },
317
+ onClick: () => choose(row),
318
+ children: [
319
+ row.item.icon && /* @__PURE__ */ jsx("span", { className: "fl-command__icon", children: row.item.icon }),
320
+ /* @__PURE__ */ jsxs("span", { className: "fl-command__text", children: [
321
+ /* @__PURE__ */ jsx("span", { className: "fl-command__label", children: /* @__PURE__ */ jsx(Highlight, { text: row.item.label, indices: row.indices }) }),
322
+ row.item.description && /* @__PURE__ */ jsx("span", { className: "fl-command__description", children: row.item.description })
323
+ ] }),
324
+ row.item.shortcut && /* @__PURE__ */ jsx("span", { className: "fl-command__shortcut", children: row.item.shortcut.map((k) => /* @__PURE__ */ jsx("kbd", { className: "fl-kbd", children: k }, k)) }),
325
+ row.item.items && /* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", width: "14", height: "14", "aria-hidden": true, className: "fl-command__chevron", children: /* @__PURE__ */ jsx("path", { d: "M6 3.5 10.5 8 6 12.5", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) })
326
+ ]
327
+ },
328
+ row.item.id
329
+ );
330
+ })
331
+ ] }, group.name || "_"))
332
+ ]
333
+ },
334
+ stack.length
335
+ ) })
336
+ ] }),
337
+ footer && /* @__PURE__ */ jsxs("div", { className: "fl-command__footer", "aria-hidden": true, children: [
338
+ /* @__PURE__ */ jsxs("span", { children: [
339
+ /* @__PURE__ */ jsx("kbd", { className: "fl-kbd", children: "\u2191" }),
340
+ /* @__PURE__ */ jsx("kbd", { className: "fl-kbd", children: "\u2193" }),
341
+ " navigate"
342
+ ] }),
343
+ /* @__PURE__ */ jsxs("span", { children: [
344
+ /* @__PURE__ */ jsx("kbd", { className: "fl-kbd", children: "\u21B5" }),
345
+ " select"
346
+ ] }),
347
+ stack.length > 0 && /* @__PURE__ */ jsxs("span", { children: [
348
+ /* @__PURE__ */ jsx("kbd", { className: "fl-kbd", children: "\u232B" }),
349
+ " back"
350
+ ] }),
351
+ /* @__PURE__ */ jsxs("span", { className: "fl-command__count", children: [
352
+ flat.length,
353
+ " results"
354
+ ] })
355
+ ] }),
356
+ /* @__PURE__ */ jsx("span", { className: "fl-sr-only", "aria-live": "polite", children: query ? `${flat.length} results` : "" })
357
+ ]
358
+ }
359
+ );
360
+ if (inline) return panel;
361
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
362
+ /* @__PURE__ */ jsx("span", { ref: anchorRef, hidden: true }),
363
+ /* @__PURE__ */ jsx(Portal, { container, anchor: anchorRef.current, children: /* @__PURE__ */ jsxs(AnimatePresence, { children: [
364
+ open && /* @__PURE__ */ jsx(motion.div, { className: "fl-overlay fl-command__overlay", initial: { opacity: 0 }, animate: { opacity: 1 }, exit: { opacity: 0 }, transition: { duration: 0.18 }, onPointerDown: () => setOpen(false) }, "overlay"),
365
+ open && /* @__PURE__ */ jsx("div", { className: "fl-command__frame", children: panel }, "frame")
366
+ ] }) })
367
+ ] });
368
+ });
369
+
370
+ export { CommandPalette, fuzzyMatch };