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,186 @@
1
+ 'use client';
2
+ import { rubberClamp } from './chunk-344MRWFO.js';
3
+ import { useIsoLayoutEffect, mergeRefs, 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, useTransform, animate, motion } from 'motion/react';
8
+ import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
9
+
10
+ var KNOB_SPRING = { type: "spring", stiffness: 760, damping: 34, mass: 0.75 };
11
+ var STRETCH = 6;
12
+ var INSET = 2;
13
+ var Switch = React.forwardRef(function Switch2({
14
+ checked: checkedProp,
15
+ defaultChecked = false,
16
+ onCheckedChange,
17
+ variant = "toggle",
18
+ size = "md",
19
+ labels = ["Off", "On"],
20
+ name,
21
+ value = "on",
22
+ haptics = true,
23
+ disabled,
24
+ className,
25
+ onClick,
26
+ onPointerDown,
27
+ onKeyDown,
28
+ onKeyUp,
29
+ ...rest
30
+ }, forwardedRef) {
31
+ const [checked, setChecked] = useControllableState({ value: checkedProp, defaultValue: defaultChecked, onChange: onCheckedChange });
32
+ const { reduced, t } = useMotionPreset();
33
+ const rootRef = React.useRef(null);
34
+ const [pressed, setPressed] = React.useState(false);
35
+ const [dragging, setDragging] = React.useState(false);
36
+ const [metrics, setMetrics] = React.useState({ travel: 18, knob: 22 });
37
+ const drag = React.useRef(null);
38
+ const suppressClick = React.useRef(false);
39
+ const x = useMotionValue(0);
40
+ const width = useMotionValue(metrics.knob);
41
+ const metricsRef = React.useRef(metrics);
42
+ metricsRef.current = metrics;
43
+ const progress = useTransform(x, (v) => Math.min(1, Math.max(0, v / Math.max(1, metricsRef.current.travel - STRETCH))));
44
+ const rotate = useMotionValue(0);
45
+ const draggable = variant !== "rocker";
46
+ useIsoLayoutEffect(() => {
47
+ const el = rootRef.current;
48
+ if (!el || variant === "rocker") return;
49
+ const h = el.clientHeight;
50
+ const w = el.clientWidth;
51
+ const knob = h - INSET * 2;
52
+ setMetrics({ knob, travel: w - knob - INSET * 2 });
53
+ }, [size, variant]);
54
+ const first = React.useRef(true);
55
+ useIsoLayoutEffect(() => {
56
+ if (variant === "rocker") {
57
+ const base = checked ? -1 : 1;
58
+ const target = pressed ? base * 4 : base * 11;
59
+ if (first.current) rotate.set(target);
60
+ else animate(rotate, target, t(pressed ? { type: "spring", stiffness: 900, damping: 40 } : { type: "spring", stiffness: 560, damping: 18 }));
61
+ first.current = false;
62
+ return;
63
+ }
64
+ if (dragging) return;
65
+ const stretch = pressed ? STRETCH : 0;
66
+ const targetX = checked ? metrics.travel - stretch : 0;
67
+ const targetW = metrics.knob + stretch;
68
+ if (first.current) {
69
+ x.set(targetX);
70
+ width.set(targetW);
71
+ } else {
72
+ animate(x, targetX, t(KNOB_SPRING));
73
+ animate(width, targetW, t(KNOB_SPRING));
74
+ }
75
+ first.current = false;
76
+ }, [checked, pressed, dragging, metrics, variant, reduced]);
77
+ const commit = (next) => {
78
+ if (next !== checked && haptics) haptic(8);
79
+ setChecked(next);
80
+ };
81
+ const handlePointerDown = (event) => {
82
+ onPointerDown?.(event);
83
+ if (disabled || event.defaultPrevented || event.button !== 0) return;
84
+ setPressed(true);
85
+ if (draggable) {
86
+ drag.current = { x0: event.clientX, start: x.get(), moved: false };
87
+ event.currentTarget.setPointerCapture?.(event.pointerId);
88
+ }
89
+ };
90
+ const handlePointerMove = (event) => {
91
+ const d = drag.current;
92
+ if (!d) return;
93
+ const dx = event.clientX - d.x0;
94
+ if (!d.moved && Math.abs(dx) > 3) {
95
+ d.moved = true;
96
+ setDragging(true);
97
+ }
98
+ if (d.moved) {
99
+ const max = metrics.travel - STRETCH;
100
+ x.set(rubberClamp(d.start + dx, 0, max, metrics.travel, 0.4));
101
+ }
102
+ };
103
+ const endPointer = (event, cancelled = false) => {
104
+ const d = drag.current;
105
+ drag.current = null;
106
+ setPressed(false);
107
+ if (d?.moved) {
108
+ suppressClick.current = !cancelled;
109
+ setDragging(false);
110
+ if (!cancelled) commit(x.get() > (metrics.travel - STRETCH) / 2);
111
+ }
112
+ if (event.currentTarget.hasPointerCapture?.(event.pointerId)) event.currentTarget.releasePointerCapture(event.pointerId);
113
+ };
114
+ const handleClick = (event) => {
115
+ onClick?.(event);
116
+ if (suppressClick.current) {
117
+ suppressClick.current = false;
118
+ return;
119
+ }
120
+ if (disabled || event.defaultPrevented) return;
121
+ commit(!checked);
122
+ };
123
+ const handleKeyDown = (event) => {
124
+ onKeyDown?.(event);
125
+ if ((event.key === " " || event.key === "Enter") && !event.repeat && !disabled) setPressed(true);
126
+ };
127
+ const handleKeyUp = (event) => {
128
+ onKeyUp?.(event);
129
+ if (event.key === " " || event.key === "Enter") setPressed(false);
130
+ };
131
+ const offLabelOpacity = useTransform(progress, [0, 0.6], [1, 0]);
132
+ const offLabelX = useTransform(progress, [0, 1], [0, 10]);
133
+ const onLabelOpacity = useTransform(progress, [0.4, 1], [0, 1]);
134
+ const onLabelX = useTransform(progress, [0, 1], [-10, 0]);
135
+ const shadeLeft = useTransform(rotate, [-11, 11], [1, 0]);
136
+ const shadeRight = useTransform(rotate, [-11, 11], [0, 1]);
137
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
138
+ /* @__PURE__ */ jsx(
139
+ "button",
140
+ {
141
+ ...rest,
142
+ ref: mergeRefs(rootRef, forwardedRef),
143
+ type: "button",
144
+ role: "switch",
145
+ "aria-checked": checked,
146
+ disabled,
147
+ "data-state": checked ? "checked" : "unchecked",
148
+ "data-variant": variant,
149
+ "data-size": size,
150
+ "data-pressed": pressed || void 0,
151
+ "data-dragging": dragging || void 0,
152
+ className: cx("fl-reset-button fl-switch", className),
153
+ onClick: handleClick,
154
+ onPointerDown: handlePointerDown,
155
+ onPointerMove: handlePointerMove,
156
+ onPointerUp: (e) => endPointer(e),
157
+ onPointerCancel: (e) => endPointer(e, true),
158
+ onKeyDown: handleKeyDown,
159
+ onKeyUp: handleKeyUp,
160
+ onBlur: () => setPressed(false),
161
+ children: variant === "rocker" ? /* @__PURE__ */ jsx("span", { className: "fl-switch__bezel", "aria-hidden": true, children: /* @__PURE__ */ jsxs(motion.span, { className: "fl-switch__paddle", style: { rotateY: rotate }, children: [
162
+ /* @__PURE__ */ jsxs("span", { className: "fl-switch__half", "data-side": "on", children: [
163
+ /* @__PURE__ */ jsx("span", { className: "fl-switch__glyph", children: labels[1] }),
164
+ /* @__PURE__ */ jsx(motion.span, { className: "fl-switch__shade", style: { opacity: shadeLeft } })
165
+ ] }),
166
+ /* @__PURE__ */ jsxs("span", { className: "fl-switch__half", "data-side": "off", children: [
167
+ /* @__PURE__ */ jsx("span", { className: "fl-switch__glyph", children: labels[0] }),
168
+ /* @__PURE__ */ jsx(motion.span, { className: "fl-switch__shade", style: { opacity: shadeRight } })
169
+ ] })
170
+ ] }) }) : /* @__PURE__ */ jsxs(Fragment, { children: [
171
+ /* @__PURE__ */ jsxs("span", { className: "fl-switch__track", "aria-hidden": true, children: [
172
+ /* @__PURE__ */ jsx(motion.span, { className: "fl-switch__fill", style: { opacity: progress } }),
173
+ variant === "label" && /* @__PURE__ */ jsxs(Fragment, { children: [
174
+ /* @__PURE__ */ jsx(motion.span, { className: "fl-switch__text", "data-side": "on", style: { opacity: onLabelOpacity, x: onLabelX }, children: labels[1] }),
175
+ /* @__PURE__ */ jsx(motion.span, { className: "fl-switch__text", "data-side": "off", style: { opacity: offLabelOpacity, x: offLabelX }, children: labels[0] })
176
+ ] })
177
+ ] }),
178
+ /* @__PURE__ */ jsx(motion.span, { className: "fl-switch__knob", "aria-hidden": true, style: { x, width } })
179
+ ] })
180
+ }
181
+ ),
182
+ name && checked ? /* @__PURE__ */ jsx("input", { type: "hidden", name, value }) : null
183
+ ] });
184
+ });
185
+
186
+ export { Switch };
@@ -0,0 +1,216 @@
1
+ 'use client';
2
+ 'use strict';
3
+
4
+ var chunk5ARTY5RT_cjs = require('./chunk-5ARTY5RT.cjs');
5
+ var chunkG5UZZ2XG_cjs = require('./chunk-G5UZZ2XG.cjs');
6
+ var chunkPBMXL53R_cjs = require('./chunk-PBMXL53R.cjs');
7
+ var React = require('react');
8
+ var react = require('motion/react');
9
+ var jsxRuntime = require('react/jsx-runtime');
10
+
11
+ function _interopNamespace(e) {
12
+ if (e && e.__esModule) return e;
13
+ var n = Object.create(null);
14
+ if (e) {
15
+ Object.keys(e).forEach(function (k) {
16
+ if (k !== 'default') {
17
+ var d = Object.getOwnPropertyDescriptor(e, k);
18
+ Object.defineProperty(n, k, d.get ? d : {
19
+ enumerable: true,
20
+ get: function () { return e[k]; }
21
+ });
22
+ }
23
+ });
24
+ }
25
+ n.default = e;
26
+ return Object.freeze(n);
27
+ }
28
+
29
+ var React__namespace = /*#__PURE__*/_interopNamespace(React);
30
+
31
+ var TabsContext = React__namespace.createContext(null);
32
+ var useTabs = () => {
33
+ const ctx = React__namespace.useContext(TabsContext);
34
+ if (!ctx) throw new Error("Tabs parts must be rendered inside <Tabs>.");
35
+ return ctx;
36
+ };
37
+ var PanelsContext = React__namespace.createContext(null);
38
+ var Tabs = React__namespace.forwardRef(function Tabs2({ value: valueProp, defaultValue = "", onValueChange, variant = "underline", haptics = true, className, children, ...rest }, ref) {
39
+ const [value, setValue] = chunkG5UZZ2XG_cjs.useControllableState({ value: valueProp, defaultValue, onChange: onValueChange });
40
+ const values = React__namespace.useRef([]);
41
+ const [direction, setDirection] = React__namespace.useState(1);
42
+ const baseId = React__namespace.useId();
43
+ const select = (next) => {
44
+ if (next === value) return;
45
+ const a = values.current.indexOf(value);
46
+ const b = values.current.indexOf(next);
47
+ setDirection(b >= a ? 1 : -1);
48
+ if (haptics) chunk5ARTY5RT_cjs.haptic(4);
49
+ setValue(next);
50
+ };
51
+ const register = React__namespace.useCallback((v) => {
52
+ if (!values.current.includes(v)) values.current.push(v);
53
+ }, []);
54
+ return /* @__PURE__ */ jsxRuntime.jsx(TabsContext.Provider, { value: { value, select, direction, variant, baseId, register, values, reportHeight: () => {
55
+ } }, children: /* @__PURE__ */ jsxRuntime.jsx("div", { ...rest, ref, className: chunkPBMXL53R_cjs.cx("fl-tabs", className), "data-variant": variant, children }) });
56
+ });
57
+ var TabsList = React__namespace.forwardRef(function TabsList2({ className, children, onKeyDown, ...rest }, ref) {
58
+ const { value, variant } = useTabs();
59
+ const { t } = chunkPBMXL53R_cjs.useMotionPreset();
60
+ const listRef = React__namespace.useRef(null);
61
+ const left = react.useMotionValue(0);
62
+ const right = react.useMotionValue(0);
63
+ const width = react.useTransform([left, right], ([l, r]) => Math.max(0, r - l));
64
+ const placed = React__namespace.useRef(false);
65
+ const place = React__namespace.useCallback(
66
+ (instant) => {
67
+ const el = listRef.current?.querySelector('[role="tab"][aria-selected="true"]');
68
+ if (!el) return;
69
+ const L = el.offsetLeft;
70
+ const R = L + el.offsetWidth;
71
+ if (instant || !placed.current) {
72
+ left.set(L);
73
+ right.set(R);
74
+ placed.current = true;
75
+ return;
76
+ }
77
+ const forward = L > left.get();
78
+ const lead = { type: "spring", stiffness: 640, damping: 42 };
79
+ const trail = { type: "spring", stiffness: 240, damping: 26 };
80
+ react.animate(left, L, t(forward ? trail : lead));
81
+ react.animate(right, R, t(forward ? lead : trail));
82
+ },
83
+ [t]
84
+ );
85
+ chunk5ARTY5RT_cjs.useIsoLayoutEffect(() => place(false), [value, place]);
86
+ chunk5ARTY5RT_cjs.useIsoLayoutEffect(() => {
87
+ const el = listRef.current;
88
+ if (!el || typeof ResizeObserver === "undefined") return;
89
+ const ro = new ResizeObserver(() => place(true));
90
+ ro.observe(el);
91
+ return () => ro.disconnect();
92
+ }, [place]);
93
+ const handleKey = (event) => {
94
+ onKeyDown?.(event);
95
+ const tabs = Array.from(event.currentTarget.querySelectorAll('[role="tab"]:not(:disabled)'));
96
+ const i = tabs.indexOf(document.activeElement);
97
+ if (i === -1) return;
98
+ const next = { ArrowRight: i + 1, ArrowLeft: i - 1, Home: 0, End: tabs.length - 1 }[event.key];
99
+ if (next === void 0) return;
100
+ event.preventDefault();
101
+ const target = tabs[(next + tabs.length) % tabs.length];
102
+ target.focus();
103
+ target.click();
104
+ };
105
+ return /* @__PURE__ */ jsxRuntime.jsxs(
106
+ "div",
107
+ {
108
+ ...rest,
109
+ ref: (el) => {
110
+ listRef.current = el;
111
+ if (typeof ref === "function") ref(el);
112
+ else if (ref) ref.current = el;
113
+ },
114
+ role: "tablist",
115
+ className: chunkPBMXL53R_cjs.cx("fl-tabs__list", className),
116
+ "data-variant": variant,
117
+ onKeyDown: handleKey,
118
+ children: [
119
+ /* @__PURE__ */ jsxRuntime.jsx(react.motion.span, { className: "fl-tabs__indicator", "aria-hidden": true, style: { x: left, width } }),
120
+ children
121
+ ]
122
+ }
123
+ );
124
+ });
125
+ var TabsTrigger = React__namespace.forwardRef(function TabsTrigger2({ value, className, children, onClick, ...rest }, ref) {
126
+ const ctx = useTabs();
127
+ ctx.register(value);
128
+ const selected = ctx.value === value;
129
+ return /* @__PURE__ */ jsxRuntime.jsx(
130
+ "button",
131
+ {
132
+ ...rest,
133
+ ref,
134
+ type: "button",
135
+ role: "tab",
136
+ id: `${ctx.baseId}-tab-${value}`,
137
+ "aria-selected": selected,
138
+ "aria-controls": `${ctx.baseId}-panel-${value}`,
139
+ tabIndex: selected ? 0 : -1,
140
+ "data-state": selected ? "active" : "inactive",
141
+ className: chunkPBMXL53R_cjs.cx("fl-reset-button fl-tabs__trigger", className),
142
+ onClick: (e) => {
143
+ onClick?.(e);
144
+ if (!e.defaultPrevented) ctx.select(value);
145
+ },
146
+ children
147
+ }
148
+ );
149
+ });
150
+ var TabsPanels = React__namespace.forwardRef(function TabsPanels2({ className, children, style, ...rest }, ref) {
151
+ const { t } = chunkPBMXL53R_cjs.useMotionPreset();
152
+ const ctx = useTabs();
153
+ const [height, setHeight] = React__namespace.useState("auto");
154
+ const active = React__namespace.Children.toArray(children).filter(
155
+ (child) => React__namespace.isValidElement(child) && child.props.value === ctx.value
156
+ );
157
+ return /* @__PURE__ */ jsxRuntime.jsx(PanelsContext.Provider, { value: setHeight, children: /* @__PURE__ */ jsxRuntime.jsx(
158
+ react.motion.div,
159
+ {
160
+ ...rest,
161
+ ref,
162
+ className: chunkPBMXL53R_cjs.cx("fl-tabs__panels", className),
163
+ style,
164
+ initial: false,
165
+ animate: { height },
166
+ transition: t({ type: "spring", stiffness: 360, damping: 34 }),
167
+ children: /* @__PURE__ */ jsxRuntime.jsx(react.AnimatePresence, { initial: false, mode: "popLayout", children: active.map((child) => React__namespace.cloneElement(child, { key: child.props.value })) })
168
+ }
169
+ ) });
170
+ });
171
+ var TabsContent = React__namespace.forwardRef(function TabsContent2({ value, className, children, ...rest }, ref) {
172
+ const ctx = useTabs();
173
+ const reportHeight = React__namespace.useContext(PanelsContext);
174
+ const { t, reduced } = chunkPBMXL53R_cjs.useMotionPreset();
175
+ const inner = React__namespace.useRef(null);
176
+ const active = ctx.value === value;
177
+ chunk5ARTY5RT_cjs.useIsoLayoutEffect(() => {
178
+ if (!active || !reportHeight || !inner.current) return;
179
+ const el = inner.current;
180
+ reportHeight(el.offsetHeight);
181
+ if (typeof ResizeObserver === "undefined") return;
182
+ const ro = new ResizeObserver(() => reportHeight(el.offsetHeight));
183
+ ro.observe(el);
184
+ return () => ro.disconnect();
185
+ }, [active, reportHeight]);
186
+ const d = ctx.direction;
187
+ const body = /* @__PURE__ */ jsxRuntime.jsx(
188
+ react.motion.div,
189
+ {
190
+ ...rest,
191
+ ref: (el) => {
192
+ inner.current = el;
193
+ if (typeof ref === "function") ref(el);
194
+ else if (ref) ref.current = el;
195
+ },
196
+ role: "tabpanel",
197
+ id: `${ctx.baseId}-panel-${value}`,
198
+ "aria-labelledby": `${ctx.baseId}-tab-${value}`,
199
+ tabIndex: 0,
200
+ className: chunkPBMXL53R_cjs.cx("fl-tabs__content", className),
201
+ initial: { opacity: 0, x: reduced ? 0 : d * 28 },
202
+ animate: { opacity: 1, x: 0 },
203
+ exit: { opacity: 0, x: reduced ? 0 : d * -28 },
204
+ transition: t({ type: "spring", stiffness: 380, damping: 34, opacity: { duration: 0.18 } }),
205
+ children
206
+ },
207
+ value
208
+ );
209
+ return reportHeight ? body : /* @__PURE__ */ jsxRuntime.jsx(react.AnimatePresence, { initial: false, children: active && body });
210
+ });
211
+
212
+ exports.Tabs = Tabs;
213
+ exports.TabsContent = TabsContent;
214
+ exports.TabsList = TabsList;
215
+ exports.TabsPanels = TabsPanels;
216
+ exports.TabsTrigger = TabsTrigger;
@@ -0,0 +1,126 @@
1
+ 'use client';
2
+ import { useScrollLock, useFocusTrap, useEscape } from './chunk-SMY24MVU.js';
3
+ import { Portal } from './chunk-7B2YEOYF.js';
4
+ import { useIsoLayoutEffect, mergeRefs } 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, useDragControls, animate, useTransform, AnimatePresence, motion } from 'motion/react';
9
+ import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
10
+
11
+ var SNAP = { type: "spring", stiffness: 380, damping: 38, mass: 0.9 };
12
+ var Drawer = React.forwardRef(function Drawer2({ open: openProp, defaultOpen = false, onOpenChange, trigger, snapPoints = [0.5, 0.92], defaultSnap = 0, title, description, container, onSnapChange, className, children, ...rest }, ref) {
13
+ const [open, setOpen] = useControllableState({ value: openProp, defaultValue: defaultOpen, onChange: onOpenChange });
14
+ const { t, reduced } = useMotionPreset();
15
+ const sheetRef = React.useRef(null);
16
+ const triggerRef = React.useRef(null);
17
+ const [frameH, setFrameH] = React.useState(0);
18
+ const [snap, setSnap] = React.useState(defaultSnap);
19
+ const y = useMotionValue(1e4);
20
+ const controls = useDragControls();
21
+ const titleId = React.useId();
22
+ const points = [...snapPoints].sort((a, b) => a - b);
23
+ const maxH = points[points.length - 1];
24
+ const sheetH = frameH * maxH;
25
+ const yFor = (i) => sheetH - frameH * points[i];
26
+ const closedY = sheetH + 24;
27
+ useScrollLock(open);
28
+ useFocusTrap(sheetRef, open);
29
+ useEscape(open, () => setOpen(false));
30
+ useIsoLayoutEffect(() => {
31
+ if (!open) return;
32
+ const frame = sheetRef.current?.closest(".fl-portal");
33
+ const measure = () => setFrameH(frame?.clientHeight || window.innerHeight);
34
+ measure();
35
+ window.addEventListener("resize", measure);
36
+ return () => window.removeEventListener("resize", measure);
37
+ }, [open]);
38
+ useIsoLayoutEffect(() => {
39
+ if (!open || !frameH) return;
40
+ const start = Math.min(defaultSnap, points.length - 1);
41
+ setSnap(start);
42
+ y.set(closedY);
43
+ animate(y, yFor(start), t(SNAP));
44
+ }, [open, frameH]);
45
+ const close = () => setOpen(false);
46
+ const onDragEnd = (_, info) => {
47
+ const projected = y.get() + info.velocity.y * 0.2;
48
+ if (projected > yFor(0) + frameH * points[0] * 0.45 || info.velocity.y > 1200) {
49
+ animate(y, closedY, t({ ...SNAP, velocity: info.velocity.y })).then(close);
50
+ return;
51
+ }
52
+ let best = 0;
53
+ points.forEach((_2, i) => {
54
+ if (Math.abs(yFor(i) - projected) < Math.abs(yFor(best) - projected)) best = i;
55
+ });
56
+ setSnap(best);
57
+ onSnapChange?.(best);
58
+ animate(y, yFor(best), t({ ...SNAP, velocity: info.velocity.y }));
59
+ };
60
+ const backdrop = useTransform(y, [closedY, yFor(0)], [0, 1]);
61
+ const clonedTrigger = trigger ? React.cloneElement(trigger, {
62
+ ref: mergeRefs(triggerRef, trigger.props.ref),
63
+ "aria-haspopup": "dialog",
64
+ "aria-expanded": open,
65
+ onClick: (e) => {
66
+ trigger.props.onClick?.(e);
67
+ if (!e.defaultPrevented) setOpen(true);
68
+ }
69
+ }) : null;
70
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
71
+ clonedTrigger,
72
+ /* @__PURE__ */ jsx(Portal, { container, anchor: triggerRef.current, children: /* @__PURE__ */ jsxs(AnimatePresence, { onExitComplete: () => y.set(1e4), children: [
73
+ open && /* @__PURE__ */ jsx(motion.div, { className: "fl-overlay fl-drawer__backdrop", style: { opacity: backdrop }, exit: { opacity: 0 }, transition: { duration: 0.2 }, onClick: close }, "backdrop"),
74
+ open && /* @__PURE__ */ jsxs(
75
+ motion.div,
76
+ {
77
+ ...rest,
78
+ ref: mergeRefs(sheetRef, ref),
79
+ role: "dialog",
80
+ "aria-modal": "true",
81
+ "aria-labelledby": title ? titleId : void 0,
82
+ "aria-label": title ? void 0 : rest["aria-label"] ?? "Drawer",
83
+ tabIndex: -1,
84
+ className: cx("fl-drawer", className),
85
+ "data-snap": snap,
86
+ style: { y, height: sheetH || "50%" },
87
+ drag: "y",
88
+ dragListener: false,
89
+ dragControls: controls,
90
+ dragConstraints: { top: yFor(points.length - 1), bottom: closedY },
91
+ dragElastic: { top: reduced ? 0 : 0.08, bottom: 0.6 },
92
+ dragMomentum: false,
93
+ onDragEnd,
94
+ exit: { y: closedY, transition: t({ ...SNAP, stiffness: 420 }) },
95
+ children: [
96
+ /* @__PURE__ */ jsxs("div", { className: "fl-drawer__grab", onPointerDown: (e) => controls.start(e), children: [
97
+ /* @__PURE__ */ jsx("span", { className: "fl-drawer__handle" }),
98
+ (title || description) && /* @__PURE__ */ jsxs("div", { className: "fl-drawer__header", children: [
99
+ title && /* @__PURE__ */ jsx("h2", { id: titleId, className: "fl-drawer__title", children: title }),
100
+ description && /* @__PURE__ */ jsx("p", { className: "fl-drawer__description", children: description })
101
+ ] })
102
+ ] }),
103
+ /* @__PURE__ */ jsx("div", { className: "fl-drawer__content", style: { maxHeight: frameH * points[snap] - 72 || void 0 }, children }),
104
+ /* @__PURE__ */ jsx(
105
+ "button",
106
+ {
107
+ type: "button",
108
+ className: "fl-sr-only",
109
+ onClick: () => {
110
+ const next = (snap + 1) % points.length;
111
+ setSnap(next);
112
+ onSnapChange?.(next);
113
+ animate(y, yFor(next), t(SNAP));
114
+ },
115
+ children: snap < points.length - 1 ? "Expand drawer" : "Collapse drawer"
116
+ }
117
+ )
118
+ ]
119
+ },
120
+ "sheet"
121
+ )
122
+ ] }) })
123
+ ] });
124
+ });
125
+
126
+ export { Drawer };
@@ -0,0 +1,153 @@
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 chunkPBMXL53R_cjs = require('./chunk-PBMXL53R.cjs');
7
+ var React = require('react');
8
+ var react = require('motion/react');
9
+ var jsxRuntime = require('react/jsx-runtime');
10
+
11
+ function _interopNamespace(e) {
12
+ if (e && e.__esModule) return e;
13
+ var n = Object.create(null);
14
+ if (e) {
15
+ Object.keys(e).forEach(function (k) {
16
+ if (k !== 'default') {
17
+ var d = Object.getOwnPropertyDescriptor(e, k);
18
+ Object.defineProperty(n, k, d.get ? d : {
19
+ enumerable: true,
20
+ get: function () { return e[k]; }
21
+ });
22
+ }
23
+ });
24
+ }
25
+ n.default = e;
26
+ return Object.freeze(n);
27
+ }
28
+
29
+ var React__namespace = /*#__PURE__*/_interopNamespace(React);
30
+
31
+ var PAD_Y = 6;
32
+ var BAR_MAX = 24;
33
+ var GAP = 2;
34
+ function resample(values, n) {
35
+ if (values.length === n) return values.slice();
36
+ if (values.length === 0) return Array.from({ length: n }, () => 0);
37
+ if (values.length === 1) return Array.from({ length: n }, () => values[0]);
38
+ return Array.from({ length: n }, (_, i) => {
39
+ const t = i / Math.max(1, n - 1) * (values.length - 1);
40
+ const a = Math.floor(t);
41
+ const b = Math.min(values.length - 1, a + 1);
42
+ return values[a] + (values[b] - values[a]) * (t - a);
43
+ });
44
+ }
45
+ var Sparkline = React__namespace.forwardRef(function Sparkline2({ data, labels, variant = "line", label = "Series", formatValue = (v) => v.toLocaleString(), height = 72, showValue = true, showDelta = true, zeroBased, className, ...rest }, ref) {
46
+ const { t } = chunkPBMXL53R_cjs.useMotionPreset();
47
+ const [sizeRef, size] = chunk5ARTY5RT_cjs.useElementSize();
48
+ const [shown, setShown] = React__namespace.useState(data);
49
+ const from = React__namespace.useRef(data);
50
+ const target = React__namespace.useRef(data);
51
+ const progress = react.useMotionValue(1);
52
+ const [scrub, setScrub] = React__namespace.useState(null);
53
+ const tableId = React__namespace.useId();
54
+ React__namespace.useEffect(() => {
55
+ from.current = resample(shown, data.length);
56
+ target.current = data;
57
+ progress.set(0);
58
+ const c = react.animate(progress, 1, t({ type: "spring", stiffness: 160, damping: 22 }));
59
+ return () => c.stop();
60
+ }, [data.join(",")]);
61
+ react.useMotionValueEvent(progress, "change", (p) => {
62
+ setShown(target.current.map((v, i) => from.current[i] + (v - from.current[i]) * p));
63
+ });
64
+ const W = Math.max(0, size.width);
65
+ const H = height;
66
+ const n = shown.length;
67
+ const bars = variant === "bars";
68
+ const lo = Math.min(...data, bars || zeroBased ? 0 : Infinity);
69
+ const hi = Math.max(...data, bars || zeroBased ? 0 : -Infinity);
70
+ const span = hi - lo || 1;
71
+ const yOf = (v) => PAD_Y + (1 - (v - lo) / span) * (H - PAD_Y * 2);
72
+ const step = n > 1 ? (W - (bars ? 0 : 8)) / (bars ? n : n - 1) : 0;
73
+ const xOf = (i) => bars ? step * i + step / 2 : 4 + step * i;
74
+ const line = shown.map((v, i) => `${i ? "L" : "M"}${xOf(i).toFixed(1)} ${yOf(v).toFixed(1)}`).join("");
75
+ const area = n ? `${line}L${xOf(n - 1).toFixed(1)} ${H}L${xOf(0).toFixed(1)} ${H}Z` : "";
76
+ const barW = Math.max(1, Math.min(BAR_MAX, step - GAP));
77
+ const base = yOf(Math.max(lo, Math.min(0, hi)));
78
+ const index = scrub ?? n - 1;
79
+ const value = data[index] ?? 0;
80
+ const delta = data.length > 1 ? (data[data.length - 1] - data[0]) / Math.abs(data[0] || 1) * 100 : 0;
81
+ const pick = (clientX, el) => {
82
+ const rect = el.getBoundingClientRect();
83
+ const x = clientX - rect.left;
84
+ const i = bars ? Math.floor(x / step) : Math.round((x - 4) / step);
85
+ setScrub(chunk3A2LHCPV_cjs.clamp(i, 0, data.length - 1));
86
+ };
87
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { ...rest, ref, className: chunkPBMXL53R_cjs.cx("fl-spark", className), "data-variant": variant, "data-scrubbing": scrub !== null || void 0, children: [
88
+ (showValue || label) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "fl-spark__head", children: [
89
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "fl-spark__label", children: label }),
90
+ showValue && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "fl-spark__value", children: [
91
+ /* @__PURE__ */ jsxRuntime.jsx("strong", { children: formatValue(value) }),
92
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "fl-spark__meta", children: scrub !== null ? labels?.[scrub] ?? `#${scrub + 1}` : showDelta && data.length > 1 ? `${delta >= 0 ? "\u25B2" : "\u25BC"} ${Math.abs(delta).toFixed(1)}%` : "" })
93
+ ] })
94
+ ] }),
95
+ /* @__PURE__ */ jsxRuntime.jsx(
96
+ "div",
97
+ {
98
+ ref: sizeRef,
99
+ className: "fl-spark__plot",
100
+ style: { height: H },
101
+ role: "group",
102
+ tabIndex: 0,
103
+ "aria-label": `${label}: ${data.length} values from ${formatValue(data[0] ?? 0)} to ${formatValue(data[data.length - 1] ?? 0)}. Use left and right arrow keys to read values.`,
104
+ "aria-describedby": tableId,
105
+ onPointerMove: (e) => pick(e.clientX, e.currentTarget),
106
+ onPointerDown: (e) => pick(e.clientX, e.currentTarget),
107
+ onPointerLeave: () => setScrub(null),
108
+ onBlur: () => setScrub(null),
109
+ onKeyDown: (e) => {
110
+ const map = { ArrowRight: 1, ArrowLeft: -1 };
111
+ if (e.key in map) {
112
+ e.preventDefault();
113
+ setScrub((s) => chunk3A2LHCPV_cjs.clamp((s ?? data.length - 1) + map[e.key], 0, data.length - 1));
114
+ } else if (e.key === "Home") {
115
+ e.preventDefault();
116
+ setScrub(0);
117
+ } else if (e.key === "End") {
118
+ e.preventDefault();
119
+ setScrub(data.length - 1);
120
+ } else if (e.key === "Escape") setScrub(null);
121
+ },
122
+ children: W > 0 && /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: W, height: H, "aria-hidden": true, className: "fl-spark__svg", children: [
123
+ /* @__PURE__ */ jsxRuntime.jsx("line", { className: "fl-spark__baseline", x1: 0, x2: W, y1: bars ? base : H - 0.5, y2: bars ? base : H - 0.5 }),
124
+ bars ? shown.map((v, i) => {
125
+ const y = yOf(v);
126
+ const top = Math.min(y, base);
127
+ const h = Math.max(0.5, Math.abs(base - y));
128
+ const r = Math.min(4, h, barW / 2);
129
+ const x = xOf(i) - barW / 2;
130
+ const up = v >= 0;
131
+ const d = up ? `M${x} ${top + h}V${top + r}Q${x} ${top} ${x + r} ${top}H${x + barW - r}Q${x + barW} ${top} ${x + barW} ${top + r}V${top + h}Z` : `M${x} ${top}V${top + h - r}Q${x} ${top + h} ${x + r} ${top + h}H${x + barW - r}Q${x + barW} ${top + h} ${x + barW} ${top + h - r}V${top}Z`;
132
+ return /* @__PURE__ */ jsxRuntime.jsx("path", { d, className: "fl-spark__bar", "data-active": scrub === i || void 0, "data-dim": scrub !== null && scrub !== i || void 0 }, i);
133
+ }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
134
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: area, className: "fl-spark__area" }),
135
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: line, className: "fl-spark__line" })
136
+ ] }),
137
+ scrub !== null && !bars && /* @__PURE__ */ jsxRuntime.jsx("line", { className: "fl-spark__crosshair", x1: xOf(scrub), x2: xOf(scrub), y1: 0, y2: H }),
138
+ !bars && n > 0 && /* @__PURE__ */ jsxRuntime.jsx("circle", { className: "fl-spark__dot", cx: xOf(index), cy: yOf(shown[index] ?? 0), r: 4 })
139
+ ] })
140
+ }
141
+ ),
142
+ /* @__PURE__ */ jsxRuntime.jsxs("table", { id: tableId, className: "fl-sr-only", children: [
143
+ /* @__PURE__ */ jsxRuntime.jsx("caption", { children: label }),
144
+ /* @__PURE__ */ jsxRuntime.jsx("tbody", { children: data.map((v, i) => /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
145
+ /* @__PURE__ */ jsxRuntime.jsx("th", { scope: "row", children: labels?.[i] ?? `Point ${i + 1}` }),
146
+ /* @__PURE__ */ jsxRuntime.jsx("td", { children: formatValue(v) })
147
+ ] }, i)) })
148
+ ] }),
149
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "fl-sr-only", "aria-live": "polite", children: scrub !== null ? `${labels?.[scrub] ?? `Point ${scrub + 1}`}: ${formatValue(value)}` : "" })
150
+ ] });
151
+ });
152
+
153
+ exports.Sparkline = Sparkline;