@epilot/spark-ui 0.20.0 → 0.21.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 (258) hide show
  1. package/dist/components/accordion.cjs +7 -7
  2. package/dist/components/accordion.cjs.map +1 -1
  3. package/dist/components/accordion.d.ts +1 -1
  4. package/dist/components/accordion.js +1 -1
  5. package/dist/components/alert-dialog.cjs +10 -10
  6. package/dist/components/alert-dialog.cjs.map +1 -1
  7. package/dist/components/alert-dialog.js +1 -1
  8. package/dist/components/attachment.cjs +10 -10
  9. package/dist/components/attachment.cjs.map +1 -1
  10. package/dist/components/attachment.d.cts +2 -2
  11. package/dist/components/attachment.d.ts +2 -2
  12. package/dist/components/autocomplete.cjs +13 -13
  13. package/dist/components/autocomplete.cjs.map +1 -1
  14. package/dist/components/autocomplete.js +1 -1
  15. package/dist/components/avatar.cjs +2 -2
  16. package/dist/components/avatar.cjs.map +1 -1
  17. package/dist/components/avatar.js +1 -1
  18. package/dist/components/badge.cjs +2 -2
  19. package/dist/components/badge.cjs.map +1 -1
  20. package/dist/components/badge.js +1 -1
  21. package/dist/components/bar-chart-with-total.d.cts +1 -1
  22. package/dist/components/bar-chart-with-total.d.ts +1 -1
  23. package/dist/components/bar-chart.cjs +4 -4
  24. package/dist/components/bar-chart.cjs.map +1 -1
  25. package/dist/components/bar-chart.js +2 -2
  26. package/dist/components/box.cjs +2 -2
  27. package/dist/components/box.cjs.map +1 -1
  28. package/dist/components/box.js +1 -1
  29. package/dist/components/breadcrumbs.cjs +7 -7
  30. package/dist/components/breadcrumbs.cjs.map +1 -1
  31. package/dist/components/bubble.cjs +5 -5
  32. package/dist/components/bubble.cjs.map +1 -1
  33. package/dist/components/bubble.d.cts +1 -1
  34. package/dist/components/bubble.d.ts +1 -1
  35. package/dist/components/button-group.cjs +5 -5
  36. package/dist/components/button-group.cjs.map +1 -1
  37. package/dist/components/button-group.js +1 -1
  38. package/dist/components/button.cjs +2 -2
  39. package/dist/components/button.cjs.map +1 -1
  40. package/dist/components/button.d.cts +2 -2
  41. package/dist/components/button.d.ts +2 -2
  42. package/dist/components/button.js +1 -1
  43. package/dist/components/calendar.cjs +9 -9
  44. package/dist/components/calendar.cjs.map +1 -1
  45. package/dist/components/calendar.js +1 -1
  46. package/dist/components/callout.cjs +8 -8
  47. package/dist/components/callout.cjs.map +1 -1
  48. package/dist/components/callout.d.cts +1 -1
  49. package/dist/components/callout.d.ts +2 -2
  50. package/dist/components/callout.js +1 -1
  51. package/dist/components/card.cjs +16 -16
  52. package/dist/components/card.cjs.map +1 -1
  53. package/dist/components/card.js +2 -2
  54. package/dist/components/card.js.map +1 -1
  55. package/dist/components/chart.cjs +2 -2
  56. package/dist/components/chart.cjs.map +1 -1
  57. package/dist/components/checkbox.cjs +2 -2
  58. package/dist/components/checkbox.cjs.map +1 -1
  59. package/dist/components/checkbox.js +1 -1
  60. package/dist/components/circular-gauge.cjs +3 -3
  61. package/dist/components/circular-gauge.cjs.map +1 -1
  62. package/dist/components/day-of-week-picker.cjs +4 -4
  63. package/dist/components/day-of-week-picker.cjs.map +1 -1
  64. package/dist/components/dialog.cjs +9 -9
  65. package/dist/components/dialog.cjs.map +1 -1
  66. package/dist/components/dialog.js +1 -1
  67. package/dist/components/drawer.cjs +8 -8
  68. package/dist/components/drawer.cjs.map +1 -1
  69. package/dist/components/dropdown-menu.cjs +11 -11
  70. package/dist/components/dropdown-menu.cjs.map +1 -1
  71. package/dist/components/dropdown-menu.js +1 -1
  72. package/dist/components/empty-state.d.ts +1 -1
  73. package/dist/components/energy-breakdown.cjs +80 -0
  74. package/dist/components/energy-breakdown.cjs.map +1 -0
  75. package/dist/components/energy-breakdown.d.cts +24 -0
  76. package/dist/components/energy-breakdown.d.ts +24 -0
  77. package/dist/components/energy-breakdown.js +79 -0
  78. package/dist/components/energy-breakdown.js.map +1 -0
  79. package/dist/components/energy-history-chart.cjs +63 -0
  80. package/dist/components/energy-history-chart.cjs.map +1 -0
  81. package/dist/components/energy-history-chart.d.cts +64 -0
  82. package/dist/components/energy-history-chart.d.ts +64 -0
  83. package/dist/components/energy-history-chart.js +62 -0
  84. package/dist/components/energy-history-chart.js.map +1 -0
  85. package/dist/components/entity-card.cjs +11 -11
  86. package/dist/components/entity-card.cjs.map +1 -1
  87. package/dist/components/entity-card.d.ts +1 -1
  88. package/dist/components/field.cjs +15 -15
  89. package/dist/components/field.cjs.map +1 -1
  90. package/dist/components/hero-metric.cjs +4 -4
  91. package/dist/components/hero-metric.cjs.map +1 -1
  92. package/dist/components/icon.cjs +2 -2
  93. package/dist/components/icon.cjs.map +1 -1
  94. package/dist/components/icon.js +1 -1
  95. package/dist/components/info-block.cjs +9 -9
  96. package/dist/components/info-block.cjs.map +1 -1
  97. package/dist/components/info-block.d.cts +1 -1
  98. package/dist/components/info-block.d.ts +1 -1
  99. package/dist/components/input-date.cjs +3 -3
  100. package/dist/components/input-date.cjs.map +1 -1
  101. package/dist/components/input-date.js +1 -1
  102. package/dist/components/input-group.cjs +5 -5
  103. package/dist/components/input-group.cjs.map +1 -1
  104. package/dist/components/input-otp.cjs +3 -3
  105. package/dist/components/input-otp.cjs.map +1 -1
  106. package/dist/components/input-otp.js +1 -1
  107. package/dist/components/input.cjs +3 -3
  108. package/dist/components/input.cjs.map +1 -1
  109. package/dist/components/input.js +1 -1
  110. package/dist/components/label.cjs +2 -2
  111. package/dist/components/label.cjs.map +1 -1
  112. package/dist/components/layout.cjs +2 -2
  113. package/dist/components/layout.cjs.map +1 -1
  114. package/dist/components/line-chart.cjs +7 -7
  115. package/dist/components/line-chart.cjs.map +1 -1
  116. package/dist/components/line-chart.js +4 -4
  117. package/dist/components/list.cjs +10 -10
  118. package/dist/components/list.cjs.map +1 -1
  119. package/dist/components/list.js +1 -1
  120. package/dist/components/list.js.map +1 -1
  121. package/dist/components/marker.cjs +4 -4
  122. package/dist/components/marker.cjs.map +1 -1
  123. package/dist/components/marker.d.cts +1 -1
  124. package/dist/components/marker.d.ts +1 -1
  125. package/dist/components/message-scroller.cjs +8 -8
  126. package/dist/components/message-scroller.cjs.map +1 -1
  127. package/dist/components/message-scroller.js +4 -4
  128. package/dist/components/message-scroller.js.map +1 -1
  129. package/dist/components/message.cjs +7 -7
  130. package/dist/components/message.cjs.map +1 -1
  131. package/dist/components/number-flow.d.cts +2 -12
  132. package/dist/components/number-flow.d.ts +2 -12
  133. package/dist/components/page-header.cjs +6 -6
  134. package/dist/components/page-header.cjs.map +1 -1
  135. package/dist/components/page-header.d.cts +1 -1
  136. package/dist/components/page-header.d.ts +1 -1
  137. package/dist/components/page-header.js +1 -1
  138. package/dist/components/period-tabs.cjs +6 -6
  139. package/dist/components/period-tabs.cjs.map +1 -1
  140. package/dist/components/pill.cjs +3 -3
  141. package/dist/components/pill.cjs.map +1 -1
  142. package/dist/components/pill.js +2 -2
  143. package/dist/components/popover.cjs +2 -2
  144. package/dist/components/popover.cjs.map +1 -1
  145. package/dist/components/power-history-chart.cjs +498 -0
  146. package/dist/components/power-history-chart.cjs.map +1 -0
  147. package/dist/components/power-history-chart.d.cts +71 -0
  148. package/dist/components/power-history-chart.d.ts +71 -0
  149. package/dist/components/power-history-chart.js +496 -0
  150. package/dist/components/power-history-chart.js.map +1 -0
  151. package/dist/components/power-network.cjs +559 -0
  152. package/dist/components/power-network.cjs.map +1 -0
  153. package/dist/components/power-network.d.cts +80 -0
  154. package/dist/components/power-network.d.ts +80 -0
  155. package/dist/components/power-network.js +553 -0
  156. package/dist/components/power-network.js.map +1 -0
  157. package/dist/components/progress.cjs +2 -2
  158. package/dist/components/progress.cjs.map +1 -1
  159. package/dist/components/radio-card-group.cjs +3 -3
  160. package/dist/components/radio-card-group.cjs.map +1 -1
  161. package/dist/components/radio.cjs +3 -3
  162. package/dist/components/radio.cjs.map +1 -1
  163. package/dist/components/radio.js +1 -1
  164. package/dist/components/sankey-chart.cjs +13 -3
  165. package/dist/components/sankey-chart.cjs.map +1 -1
  166. package/dist/components/sankey-chart.d.cts +3 -2
  167. package/dist/components/sankey-chart.d.ts +3 -2
  168. package/dist/components/sankey-chart.js +11 -2
  169. package/dist/components/sankey-chart.js.map +1 -1
  170. package/dist/components/schedule-editor.cjs +9 -9
  171. package/dist/components/schedule-editor.cjs.map +1 -1
  172. package/dist/components/schedule-list.cjs +11 -11
  173. package/dist/components/schedule-list.cjs.map +1 -1
  174. package/dist/components/schedule-list.js +1 -1
  175. package/dist/components/scroll-area.cjs +3 -3
  176. package/dist/components/scroll-area.cjs.map +1 -1
  177. package/dist/components/segmented-control.cjs +4 -4
  178. package/dist/components/segmented-control.cjs.map +1 -1
  179. package/dist/components/select.cjs +13 -13
  180. package/dist/components/select.cjs.map +1 -1
  181. package/dist/components/select.js +2 -2
  182. package/dist/components/separator.cjs +3 -3
  183. package/dist/components/separator.cjs.map +1 -1
  184. package/dist/components/series-legend.cjs +4 -4
  185. package/dist/components/series-legend.cjs.map +1 -1
  186. package/dist/components/sheet.cjs +9 -9
  187. package/dist/components/sheet.cjs.map +1 -1
  188. package/dist/components/sheet.js +1 -1
  189. package/dist/components/skeleton.cjs +3 -3
  190. package/dist/components/skeleton.cjs.map +1 -1
  191. package/dist/components/slider.cjs +11 -11
  192. package/dist/components/slider.cjs.map +1 -1
  193. package/dist/components/solar-forecast-chart.cjs +108 -0
  194. package/dist/components/solar-forecast-chart.cjs.map +1 -0
  195. package/dist/components/solar-forecast-chart.d.cts +77 -0
  196. package/dist/components/solar-forecast-chart.d.ts +77 -0
  197. package/dist/components/solar-forecast-chart.js +103 -0
  198. package/dist/components/solar-forecast-chart.js.map +1 -0
  199. package/dist/components/sortable-list.cjs +3 -3
  200. package/dist/components/sortable-list.cjs.map +1 -1
  201. package/dist/components/spinner.cjs +2 -2
  202. package/dist/components/spinner.cjs.map +1 -1
  203. package/dist/components/stat-card.cjs +8 -8
  204. package/dist/components/stat-card.cjs.map +1 -1
  205. package/dist/components/stepper.cjs +3 -3
  206. package/dist/components/stepper.cjs.map +1 -1
  207. package/dist/components/stepper.js +1 -1
  208. package/dist/components/switch.cjs +3 -3
  209. package/dist/components/switch.cjs.map +1 -1
  210. package/dist/components/switch.js +1 -1
  211. package/dist/components/table.cjs +9 -9
  212. package/dist/components/table.cjs.map +1 -1
  213. package/dist/components/table.js +1 -1
  214. package/dist/components/tabs.cjs +8 -8
  215. package/dist/components/tabs.cjs.map +1 -1
  216. package/dist/components/tabs.js +1 -1
  217. package/dist/components/textarea.cjs +3 -3
  218. package/dist/components/textarea.cjs.map +1 -1
  219. package/dist/components/textarea.js +1 -1
  220. package/dist/components/theme.cjs +2 -2
  221. package/dist/components/theme.cjs.map +1 -1
  222. package/dist/components/theme.js +1 -1
  223. package/dist/components/thumbnail.cjs +3 -3
  224. package/dist/components/thumbnail.cjs.map +1 -1
  225. package/dist/components/time-picker.cjs +3 -3
  226. package/dist/components/time-picker.cjs.map +1 -1
  227. package/dist/components/toast.cjs +8 -8
  228. package/dist/components/toast.cjs.map +1 -1
  229. package/dist/components/toast.js +1 -1
  230. package/dist/components/tooltip.cjs +4 -4
  231. package/dist/components/tooltip.cjs.map +1 -1
  232. package/dist/components/tooltip.js +1 -1
  233. package/dist/components/typography.cjs +6 -6
  234. package/dist/components/typography.cjs.map +1 -1
  235. package/dist/components/wizard-layout.cjs +8 -8
  236. package/dist/components/wizard-layout.cjs.map +1 -1
  237. package/dist/lib/input-box-variants.cjs +9 -9
  238. package/dist/lib/input-box-variants.cjs.map +1 -1
  239. package/dist/number-flow-Bch81ixZ.d.cts +14 -0
  240. package/dist/number-flow-Bch81ixZ.d.ts +14 -0
  241. package/dist/styles/spark-default.css +11 -0
  242. package/dist/utils/build-sankey-nodes.cjs +72 -0
  243. package/dist/utils/build-sankey-nodes.cjs.map +1 -0
  244. package/dist/utils/build-sankey-nodes.d.cts +27 -0
  245. package/dist/utils/build-sankey-nodes.d.ts +27 -0
  246. package/dist/utils/build-sankey-nodes.js +71 -0
  247. package/dist/utils/build-sankey-nodes.js.map +1 -0
  248. package/dist/utils/cn.cjs +2 -2
  249. package/dist/utils/cn.d.cts +1 -1
  250. package/dist/utils/cn.d.ts +1 -1
  251. package/dist/utils/cn.js +1 -1
  252. package/dist/utils/format.cjs +13 -0
  253. package/dist/utils/format.cjs.map +1 -1
  254. package/dist/utils/format.d.cts +7 -1
  255. package/dist/utils/format.d.ts +7 -1
  256. package/dist/utils/format.js +12 -1
  257. package/dist/utils/format.js.map +1 -1
  258. package/package.json +2 -2
@@ -1,8 +1,8 @@
1
1
  "use client";
2
2
  import { cn } from "../utils/cn.js";
3
3
  import { buttonVariants } from "./button.js";
4
- import { Close } from "@epilot/spark-icons";
5
4
  import "react";
5
+ import { Close } from "@epilot/spark-icons";
6
6
  import { jsx } from "react/jsx-runtime";
7
7
  import { Dialog } from "@base-ui/react/dialog";
8
8
  //#region src/components/sheet.tsx
@@ -1,17 +1,17 @@
1
1
  "use client";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  let react_jsx_runtime = require("react/jsx-runtime");
4
- let cnfast = require("cnfast");
4
+ let cn = require("cn");
5
5
  //#region src/components/skeleton.tsx
6
6
  function Skeleton({ className = "", ...props }) {
7
7
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
8
- className: (0, cnfast.cn)("animate-pulse rounded-md bg-base-gray-soft motion-reduce:animate-none", className),
8
+ className: (0, cn.cn)("animate-pulse rounded-md bg-base-gray-soft motion-reduce:animate-none", className),
9
9
  ...props
10
10
  });
11
11
  }
12
12
  function CardSkeleton({ children, className = "", padding = "p-4", ...props }) {
13
13
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
14
- className: (0, cnfast.cn)("flex flex-col rounded-lg border border-gray", padding, className),
14
+ className: (0, cn.cn)("flex flex-col rounded-lg border border-gray", padding, className),
15
15
  ...props,
16
16
  children
17
17
  });
@@ -1 +1 @@
1
- {"version":3,"file":"skeleton.cjs","names":[],"sources":["../../src/components/skeleton.tsx"],"sourcesContent":["import type { HTMLAttributes, ReactNode } from 'react'\nimport { cn } from '../utils/cn'\n\ntype SkeletonProps = HTMLAttributes<HTMLDivElement>\n\nexport function Skeleton({ className = '', ...props }: SkeletonProps) {\n return (\n <div\n className={cn(\n 'animate-pulse rounded-md bg-base-gray-soft motion-reduce:animate-none',\n className,\n )}\n {...props}\n />\n )\n}\n\ninterface CardSkeletonProps extends HTMLAttributes<HTMLDivElement> {\n children?: ReactNode\n padding?: 'p-3' | 'p-4'\n}\n\nexport function CardSkeleton({\n children,\n className = '',\n padding = 'p-4',\n ...props\n}: CardSkeletonProps) {\n return (\n <div\n className={cn(\n 'flex flex-col rounded-lg border border-gray',\n padding,\n className,\n )}\n {...props}\n >\n {children}\n </div>\n )\n}\n"],"mappings":";;;;;AAKA,SAAgB,SAAS,EAAE,YAAY,IAAI,GAAG,SAAwB;CACpE,OACE,iBAAA,GAAA,kBAAA,KAAC,OAAD;EACE,YAAA,GAAA,OAAA,IACE,yEACA,SACF;EACA,GAAI;CACL,CAAA;AAEL;AAOA,SAAgB,aAAa,EAC3B,UACA,YAAY,IACZ,UAAU,OACV,GAAG,SACiB;CACpB,OACE,iBAAA,GAAA,kBAAA,KAAC,OAAD;EACE,YAAA,GAAA,OAAA,IACE,+CACA,SACA,SACF;EACA,GAAI;EAEH;CACE,CAAA;AAET"}
1
+ {"version":3,"file":"skeleton.cjs","names":[],"sources":["../../src/components/skeleton.tsx"],"sourcesContent":["import type { HTMLAttributes, ReactNode } from 'react'\nimport { cn } from '../utils/cn'\n\ntype SkeletonProps = HTMLAttributes<HTMLDivElement>\n\nexport function Skeleton({ className = '', ...props }: SkeletonProps) {\n return (\n <div\n className={cn(\n 'animate-pulse rounded-md bg-base-gray-soft motion-reduce:animate-none',\n className,\n )}\n {...props}\n />\n )\n}\n\ninterface CardSkeletonProps extends HTMLAttributes<HTMLDivElement> {\n children?: ReactNode\n padding?: 'p-3' | 'p-4'\n}\n\nexport function CardSkeleton({\n children,\n className = '',\n padding = 'p-4',\n ...props\n}: CardSkeletonProps) {\n return (\n <div\n className={cn(\n 'flex flex-col rounded-lg border border-gray',\n padding,\n className,\n )}\n {...props}\n >\n {children}\n </div>\n )\n}\n"],"mappings":";;;;;AAKA,SAAgB,SAAS,EAAE,YAAY,IAAI,GAAG,SAAwB;CACpE,OACE,iBAAA,GAAA,kBAAA,KAAC,OAAD;EACE,YAAA,GAAA,GAAA,IACE,yEACA,SACF;EACA,GAAI;CACL,CAAA;AAEL;AAOA,SAAgB,aAAa,EAC3B,UACA,YAAY,IACZ,UAAU,OACV,GAAG,SACiB;CACpB,OACE,iBAAA,GAAA,kBAAA,KAAC,OAAD;EACE,YAAA,GAAA,GAAA,IACE,+CACA,SACA,SACF;EACA,GAAI;EAEH;CACE,CAAA;AAET"}
@@ -5,7 +5,7 @@ let react = require("react");
5
5
  react = require_chunk.__toESM(react);
6
6
  let react_jsx_runtime = require("react/jsx-runtime");
7
7
  let _base_ui_react_slider = require("@base-ui/react/slider");
8
- let cnfast = require("cnfast");
8
+ let cn = require("cn");
9
9
  //#region src/components/slider.tsx
10
10
  const MAX_TICKS = 24;
11
11
  function snapToStep(value, min, max, step) {
@@ -85,7 +85,7 @@ function Slider({ className, children, value, defaultValue, min = 0, max = 100,
85
85
  thumbAlignment,
86
86
  onValueChange: emitChange,
87
87
  onValueCommitted: (next, eventDetails) => onValueCommitted?.(matchValueShape(next, current), eventDetails),
88
- className: (0, cnfast.cn)("relative flex w-full flex-col gap-2 data-[orientation=vertical]:h-full data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-row", className),
88
+ className: (0, cn.cn)("relative flex w-full flex-col gap-2 data-[orientation=vertical]:h-full data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-row", className),
89
89
  ...props,
90
90
  children: children ?? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SliderControl, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(SliderTrack, { children: [
91
91
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SliderIndicator, {}),
@@ -108,7 +108,7 @@ Slider.displayName = "Slider";
108
108
  function SliderControl({ className, ...props }) {
109
109
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_slider.Slider.Control, {
110
110
  "data-slot": "slider-control",
111
- className: (0, cnfast.cn)("group/slider touch-target relative flex min-h-6 w-full touch-none items-center select-none", "data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-40 data-[orientation=vertical]:w-6 data-[orientation=vertical]:justify-center", "data-disabled:pointer-events-none data-disabled:opacity-50", className),
111
+ className: (0, cn.cn)("group/slider touch-target relative flex min-h-6 w-full touch-none items-center select-none", "data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-40 data-[orientation=vertical]:w-6 data-[orientation=vertical]:justify-center", "data-disabled:pointer-events-none data-disabled:opacity-50", className),
112
112
  ...props
113
113
  });
114
114
  }
@@ -117,7 +117,7 @@ SliderControl.displayName = "SliderControl";
117
117
  function SliderTrack({ className, ...props }) {
118
118
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_slider.Slider.Track, {
119
119
  "data-slot": "slider-track",
120
- className: (0, cnfast.cn)("relative h-3 w-full rounded-(--spark-rounded-sm) bg-gray-a4", "data-[orientation=vertical]:h-full data-[orientation=vertical]:w-3", className),
120
+ className: (0, cn.cn)("relative h-3 w-full rounded-(--spark-rounded-sm) bg-gray-a4", "data-[orientation=vertical]:h-full data-[orientation=vertical]:w-3", className),
121
121
  ...props
122
122
  });
123
123
  }
@@ -126,7 +126,7 @@ SliderTrack.displayName = "SliderTrack";
126
126
  function SliderIndicator({ className, ...props }) {
127
127
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_slider.Slider.Indicator, {
128
128
  "data-slot": "slider-indicator",
129
- className: (0, cnfast.cn)("rounded-(--spark-rounded-sm) bg-(--spark-slider-range,var(--spark-9))", "transition-none duration-150 group-focus-within/slider:transition-[width,height,inset-inline-start] data-dragging:transition-none motion-reduce:transition-none", className),
129
+ className: (0, cn.cn)("rounded-(--spark-rounded-sm) bg-(--spark-slider-range,var(--spark-9))", "transition-none duration-150 group-focus-within/slider:transition-[width,height,inset-inline-start] data-dragging:transition-none motion-reduce:transition-none", className),
130
130
  ...props
131
131
  });
132
132
  }
@@ -150,7 +150,7 @@ function SliderTicks({ className, ...props }) {
150
150
  const bandHigh = values.length > 1 ? Math.max(...values) : values[0] ?? min;
151
151
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
152
152
  "aria-hidden": "true",
153
- className: (0, cnfast.cn)("pointer-events-none absolute inset-0", className),
153
+ className: (0, cn.cn)("pointer-events-none absolute inset-0", className),
154
154
  "data-slot": "slider-ticks",
155
155
  ...props,
156
156
  children: Array.from({ length: dotCount }, (_, k) => {
@@ -158,7 +158,7 @@ function SliderTicks({ className, ...props }) {
158
158
  const position = min + index * step;
159
159
  const pct = (position - min) / (max - min) * 100;
160
160
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
161
- className: (0, cnfast.cn)("absolute top-1/2 size-1 -translate-x-1/2 -translate-y-1/2 rounded-full", position >= bandLow && position <= bandHigh ? "bg-(--spark-slider-tick-on,var(--spark-on-solid,#fff))" : "bg-gray-a8"),
161
+ className: (0, cn.cn)("absolute top-1/2 size-1 -translate-x-1/2 -translate-y-1/2 rounded-full", position >= bandLow && position <= bandHigh ? "bg-(--spark-slider-tick-on,var(--spark-on-solid,#fff))" : "bg-gray-a8"),
162
162
  style: { left: `${pct}%` }
163
163
  }, index);
164
164
  })
@@ -168,7 +168,7 @@ SliderTicks.displayName = "SliderTicks";
168
168
  function SliderThumb({ className, ...props }) {
169
169
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_slider.Slider.Thumb, {
170
170
  "data-slot": "slider-thumb",
171
- className: (0, cnfast.cn)("block size-4 shrink-0 rounded-(--spark-rounded-lg) bg-(--spark-slider-range,var(--spark-9))", "shadow-[0_0_0_2px_var(--spark-background,#fff),0_1px_2px_0_rgb(0_0_0/0.2)]", "before:absolute before:top-1/2 before:left-1/2 before:size-6 before:-translate-x-1/2 before:-translate-y-1/2 before:content-['']", "outline-hidden has-[input:focus-visible]:ring-2 has-[input:focus-visible]:ring-offset-2", "data-dragging:ring-2 data-dragging:ring-offset-2", "transition-shadow duration-150 group-focus-within/slider:transition-[inset-inline-start,top,box-shadow] data-dragging:transition-none motion-reduce:transition-none", "disabled:pointer-events-none", className),
171
+ className: (0, cn.cn)("block size-4 shrink-0 rounded-(--spark-rounded-lg) bg-(--spark-slider-range,var(--spark-9))", "shadow-[0_0_0_2px_var(--spark-background,#fff),0_1px_2px_0_rgb(0_0_0/0.2)]", "before:absolute before:top-1/2 before:left-1/2 before:size-6 before:-translate-x-1/2 before:-translate-y-1/2 before:content-['']", "outline-hidden has-[input:focus-visible]:ring-2 has-[input:focus-visible]:ring-offset-2", "data-dragging:ring-2 data-dragging:ring-offset-2", "transition-shadow duration-150 group-focus-within/slider:transition-[inset-inline-start,top,box-shadow] data-dragging:transition-none motion-reduce:transition-none", "disabled:pointer-events-none", className),
172
172
  ...props
173
173
  });
174
174
  }
@@ -176,7 +176,7 @@ SliderThumb.displayName = "SliderThumb";
176
176
  function SliderValue({ className, ...props }) {
177
177
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_slider.Slider.Value, {
178
178
  "data-slot": "slider-value",
179
- className: (0, cnfast.cn)("text-sm text-gray tabular-nums", className),
179
+ className: (0, cn.cn)("text-sm text-gray tabular-nums", className),
180
180
  ...props
181
181
  });
182
182
  }
@@ -217,7 +217,7 @@ function SliderInput({ className, index = 0, unit, disabled, onFocus, onBlur, on
217
217
  };
218
218
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
219
219
  "data-slot": "slider-input",
220
- className: (0, cnfast.cn)("inline-flex items-baseline gap-1", className),
220
+ className: (0, cn.cn)("inline-flex items-baseline gap-1", className),
221
221
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
222
222
  type: "number",
223
223
  inputMode: "decimal",
@@ -246,7 +246,7 @@ function SliderInput({ className, index = 0, unit, disabled, onFocus, onBlur, on
246
246
  if (event.key === "Enter") event.currentTarget.blur();
247
247
  onKeyDown?.(event);
248
248
  },
249
- className: (0, cnfast.cn)("w-16 bg-transparent tabular-nums outline-hidden", "rounded-(--spark-rounded-sm) focus-visible:ring-2 focus-visible:ring-offset-2", "disabled:cursor-not-allowed disabled:opacity-50", "[appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none"),
249
+ className: (0, cn.cn)("w-16 bg-transparent tabular-nums outline-hidden", "rounded-(--spark-rounded-sm) focus-visible:ring-2 focus-visible:ring-offset-2", "disabled:cursor-not-allowed disabled:opacity-50", "[appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none"),
250
250
  ...props
251
251
  }), unit ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
252
252
  className: "text-sm text-gray",
@@ -1 +1 @@
1
- {"version":3,"file":"slider.cjs","names":["React","BaseSlider"],"sources":["../../src/components/slider.tsx"],"sourcesContent":["import { Slider as BaseSlider } from '@base-ui/react/slider'\nimport * as React from 'react'\nimport { cn } from '../utils/cn'\n\ntype SliderValue = number | number[]\n\ntype SliderVariant = 'default' | 'ticks'\n\n// Above this many steps the tick dots become a picket fence, so `variant=\"ticks\"`\n// silently stops drawing them (the continuous rail stays).\nconst MAX_TICKS = 24\n\n// Clamp to [min, max] then snap to the step grid (origin = min), trimming float\n// noise to the step's own decimal precision. `max` is always valid even if it\n// isn't a step multiple (matches Base UI).\nfunction snapToStep(\n value: number,\n min: number,\n max: number,\n step: number,\n): number {\n const clamped = Math.min(max, Math.max(min, value))\n\n if (!(step > 0)) {\n return clamped\n }\n\n const snapped = min + Math.round((clamped - min) / step) * step\n const bounded = Math.min(max, Math.max(min, snapped))\n const decimals = (String(step).split('.')[1] ?? '').length\n\n return decimals > 0 ? Number(bounded.toFixed(decimals)) : bounded\n}\n\nfunction matchValueShape(\n next: number | readonly number[],\n current: SliderValue,\n): SliderValue {\n const nextValues = typeof next === 'number' ? [next] : [...next]\n if (Array.isArray(current)) {\n return nextValues\n }\n return nextValues[0] ?? current\n}\n\n/**\n * Base UI's slider context is internal-only (not re-exported from\n * `@base-ui/react/slider`), so the editable `<SliderInput>` can't read the\n * current value from it. Instead `<Slider>` owns the value (controllable) and\n * shares it through this Spark context — keeping direct-input robust against\n * Base UI internal changes and letting inputs live anywhere in the subtree.\n */\ntype SliderContextValue = {\n values: readonly number[]\n min: number\n max: number\n step: number\n disabled: boolean\n /**\n * Write one thumb's value (from a `SliderInput`). Snaps to the step grid and\n * clamps; range values are kept sorted. Fires `onValueChange` only when the\n * value actually changes. When `commit` is set it also fires `onValueCommitted`\n * — but only if the committed value differs from `commitBaseline` (the value\n * when editing began), so a plain focus→blur never emits a spurious commit.\n */\n setThumbValue: (\n index: number,\n next: number,\n options?: { commit?: boolean; commitBaseline?: number },\n ) => void\n}\n\nconst SliderContext = React.createContext<SliderContextValue | null>(null)\n\nfunction useSliderContext(part: string): SliderContextValue {\n const ctx = React.useContext(SliderContext)\n\n if (!ctx) {\n throw new Error(`<${part}> must be rendered inside <Slider>`)\n }\n\n return ctx\n}\n\ntype SliderProps<Value extends SliderValue = SliderValue> = Omit<\n React.ComponentProps<typeof BaseSlider.Root>,\n 'value' | 'defaultValue' | 'onValueChange' | 'onValueCommitted' | 'render'\n> & {\n value?: Value\n defaultValue?: Value\n // Generic over the value shape: a single `number` keeps single-thumb handlers\n // number-typed, an array keeps range handlers array-typed — so callers don't\n // widen/narrow at every call site.\n onValueChange?: (\n value: Value,\n eventDetails: BaseSlider.Root.ChangeEventDetails,\n ) => void\n onValueCommitted?: (\n value: Value,\n eventDetails: BaseSlider.Root.CommitEventDetails,\n ) => void\n /**\n * `ticks` marks each step with a small dot on the rail — light on the accent\n * fill, neutral on the unfilled rail. Needs a sensible `step`; the dots are\n * hidden when the step count is < 2 or exceeds {@link MAX_TICKS}, and (in the\n * default render) for vertical sliders. Default `default`.\n */\n variant?: SliderVariant\n}\n\n/**\n * Root. Owns the value (controlled via `value` or uncontrolled via\n * `defaultValue`) and provides the Spark context. With no children it renders\n * the default single/range track (a childless-default, matching the library's\n * `*Close` idiom); pass children to compose `SliderInput` / `SliderValue` /\n * `SliderControl` yourself.\n */\nfunction Slider<Value extends SliderValue = SliderValue>({\n className,\n children,\n value,\n defaultValue,\n min = 0,\n max = 100,\n step = 1,\n disabled = false,\n orientation = 'horizontal',\n variant = 'default',\n onValueChange,\n onValueCommitted,\n // Radix positioned thumbs edge-aligned (inset within the track at min/max);\n // Base UI defaults to center-aligned (half the thumb overflows). `edge` keeps\n // the classic look and the thumb inside the rail.\n thumbAlignment = 'edge',\n // The accessible name belongs on the thumb's nested range input, not just the\n // Root — so keep it on the Root (names the group) AND forward it to the\n // childless-default thumb(s). When you compose your own thumbs, label them.\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledby,\n ...props\n}: SliderProps<Value>) {\n const isControlled = value !== undefined\n const [uncontrolled, setUncontrolled] = React.useState<SliderValue>(\n defaultValue ?? min,\n )\n const current = (isControlled ? value : uncontrolled) as SliderValue\n const values = React.useMemo(\n () => (Array.isArray(current) ? current : [current]),\n [current],\n )\n\n // Base UI hands back `number | readonly number[]`; we forward it as the\n // caller's `Value` (the runtime shape matches what they passed in).\n const emitChange = (\n next: number | readonly number[],\n eventDetails: BaseSlider.Root.ChangeEventDetails,\n ) => {\n const shaped = matchValueShape(next, current) as Value\n\n if (!isControlled) {\n setUncontrolled(shaped as SliderValue)\n }\n\n onValueChange?.(shaped, eventDetails)\n }\n\n // The direct-input write path. Snaps + clamps; for a range it swaps one thumb\n // and re-sorts (Base UI renders from a sorted copy, so an unsorted write would\n // desync the inputs from the thumbs). Fires onValueChange only on a real\n // change; fires onValueCommitted only when the committed value moved off the\n // pre-edit baseline.\n const setThumbValue = (\n index: number,\n next: number,\n options?: { commit?: boolean; commitBaseline?: number },\n ) => {\n const snapped = snapToStep(next, min, max, step)\n const wasArray = Array.isArray(current)\n let nextValue: SliderValue\n\n if (wasArray) {\n const copy = [...(current as number[])]\n copy[index] = snapped\n copy.sort((a, b) => a - b)\n nextValue = copy\n } else {\n nextValue = snapped\n }\n\n const changed = wasArray\n ? (nextValue as number[]).some((v, i) => v !== (current as number[])[i])\n : nextValue !== current\n\n // input-driven changes have no pointer/keyboard event; Base UI's own detail\n // object isn't constructible here, so we hand the consumer a minimal one.\n const details = {\n reason: 'input-change',\n } as unknown as BaseSlider.Root.ChangeEventDetails\n\n if (changed) {\n emitChange(nextValue, details)\n }\n\n if (options?.commit) {\n const committedChanged =\n options.commitBaseline === undefined\n ? changed\n : snapped !== options.commitBaseline\n\n if (committedChanged) {\n onValueCommitted?.(\n nextValue as Value,\n details as unknown as BaseSlider.Root.CommitEventDetails,\n )\n }\n }\n }\n\n // Rebuilt each render (cheap — <Slider> only re-renders on a value change) so\n // setThumbValue always closes over the current value + latest callbacks.\n const context: SliderContextValue = {\n values,\n min,\n max,\n step,\n disabled,\n setThumbValue,\n }\n\n // ticks are horizontal-only in the default render; SliderTicks self-hides when\n // the step count isn't countable, so no density check is needed here.\n const showTicks = variant === 'ticks' && orientation === 'horizontal'\n\n return (\n <SliderContext.Provider value={context}>\n <BaseSlider.Root\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledby}\n data-slot=\"slider\"\n value={current}\n min={min}\n max={max}\n step={step}\n disabled={disabled}\n orientation={orientation}\n thumbAlignment={thumbAlignment}\n onValueChange={emitChange}\n onValueCommitted={(next, eventDetails) =>\n onValueCommitted?.(\n matchValueShape(next, current) as Value,\n eventDetails,\n )\n }\n className={cn(\n 'relative flex w-full flex-col gap-2 data-[orientation=vertical]:h-full data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-row',\n className,\n )}\n {...props}\n >\n {children ?? (\n <SliderControl>\n <SliderTrack>\n <SliderIndicator />\n {showTicks ? <SliderTicks /> : null}\n {values.map((_, index) => (\n <SliderThumb\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledby}\n index={values.length > 1 ? index : undefined}\n key={index}\n />\n ))}\n </SliderTrack>\n </SliderControl>\n )}\n </BaseSlider.Root>\n </SliderContext.Provider>\n )\n}\n\nSlider.displayName = 'Slider'\n\n/**\n * The interactive, draggable surface. A pointer-press anywhere on it moves the\n * nearest thumb (Base UI's track-press), so its full band is the target — kept\n * at ≥24px tall (WCAG 2.5.8) with the thin rail centered.\n */\nfunction SliderControl({\n className,\n ...props\n}: React.ComponentProps<typeof BaseSlider.Control>) {\n return (\n <BaseSlider.Control\n data-slot=\"slider-control\"\n className={cn(\n 'group/slider touch-target relative flex min-h-6 w-full touch-none items-center select-none',\n 'data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-40 data-[orientation=vertical]:w-6 data-[orientation=vertical]:justify-center',\n 'data-disabled:pointer-events-none data-disabled:opacity-50',\n className,\n )}\n {...props}\n />\n )\n}\n\nSliderControl.displayName = 'SliderControl'\n\n/** The rail — the full extent, neutral at rest. Holds the Indicator + Thumb(s). */\nfunction SliderTrack({\n className,\n ...props\n}: React.ComponentProps<typeof BaseSlider.Track>) {\n return (\n <BaseSlider.Track\n data-slot=\"slider-track\"\n className={cn(\n // 12px rail so the corner radius is legible; follows the [data-radius] knob\n // (square at none → pill at large/full). no overflow-hidden: the thumb is a\n // child and would be clipped.\n 'relative h-3 w-full rounded-(--spark-rounded-sm) bg-gray-a4',\n 'data-[orientation=vertical]:h-full data-[orientation=vertical]:w-3',\n className,\n )}\n {...props}\n />\n )\n}\n\nSliderTrack.displayName = 'SliderTrack'\n\n/** The filled portion (min → thumb). Accent, deepens in high-contrast. */\nfunction SliderIndicator({\n className,\n ...props\n}: React.ComponentProps<typeof BaseSlider.Indicator>) {\n return (\n <BaseSlider.Indicator\n data-slot=\"slider-indicator\"\n className={cn(\n // matches the rail's radius so the fill's corners track the knob too\n 'rounded-(--spark-rounded-sm) bg-(--spark-slider-range,var(--spark-9))',\n // ease only while focused (keyboard/rail-click); programmatic and\n // initial value sets snap instantly instead of sweeping from 0.\n // transition-none base matters: bare duration-150 leaves property=all\n 'transition-none duration-150 group-focus-within/slider:transition-[width,height,inset-inline-start] data-dragging:transition-none motion-reduce:transition-none',\n className,\n )}\n {...props}\n />\n )\n}\n\nSliderIndicator.displayName = 'SliderIndicator'\n\n/**\n * Step tick dots overlaid on the rail (shown when `variant=\"ticks\"`). A dot at\n * each interior step — light (`--spark-slider-tick-on`, on the accent fill) for\n * steps up to the value, neutral gray beyond it. The endpoints are omitted (they\n * sit under the rounded rail ends / the thumb). Self-guards: draws nothing unless\n * the step count is in `[2, MAX_TICKS]`, so it's safe to compose directly.\n * Decorative + pointer-transparent so it never blocks a track-press. (Horizontal\n * orientation.)\n */\nfunction SliderTicks({ className, ...props }: React.ComponentProps<'div'>) {\n const { min, max, step, values } = useSliderContext('SliderTicks')\n\n if (!(step > 0) || max <= min) {\n return null\n }\n\n // count the reachable step intervals (floor, so a non-dividing step still gets\n // a dot on its last reachable step); drop the final one when it lands on max.\n const intervals = Math.floor((max - min) / step)\n\n if (intervals < 2 || intervals > MAX_TICKS) {\n return null\n }\n\n const lastIsEndpoint = min + intervals * step === max\n const dotCount = lastIsEndpoint ? intervals - 1 : intervals\n\n // Active band: [min, value] for a single thumb, [low, high] for a range.\n const bandLow = values.length > 1 ? Math.min(...values) : min\n const bandHigh = values.length > 1 ? Math.max(...values) : (values[0] ?? min)\n\n return (\n <div\n aria-hidden=\"true\"\n className={cn('pointer-events-none absolute inset-0', className)}\n data-slot=\"slider-ticks\"\n {...props}\n >\n {Array.from({ length: dotCount }, (_, k) => {\n const index = k + 1 // interior steps only (skip the two endpoints)\n const position = min + index * step\n const pct = ((position - min) / (max - min)) * 100\n const filled = position >= bandLow && position <= bandHigh\n\n return (\n <span\n className={cn(\n 'absolute top-1/2 size-1 -translate-x-1/2 -translate-y-1/2 rounded-full',\n // light dot on the accent fill (flips to step-1 in HC via the token);\n // neutral gray dot on the unfilled rail.\n filled\n ? 'bg-(--spark-slider-tick-on,var(--spark-on-solid,#fff))'\n : 'bg-gray-a8',\n )}\n key={index}\n style={{ left: `${pct}%` }}\n />\n )\n })}\n </div>\n )\n}\n\nSliderTicks.displayName = 'SliderTicks'\n\nfunction SliderThumb({\n className,\n ...props\n}: React.ComponentProps<typeof BaseSlider.Thumb>) {\n return (\n <BaseSlider.Thumb\n data-slot=\"slider-thumb\"\n className={cn(\n 'block size-4 shrink-0 rounded-(--spark-rounded-lg) bg-(--spark-slider-range,var(--spark-9))',\n 'shadow-[0_0_0_2px_var(--spark-background,#fff),0_1px_2px_0_rgb(0_0_0/0.2)]',\n \"before:absolute before:top-1/2 before:left-1/2 before:size-6 before:-translate-x-1/2 before:-translate-y-1/2 before:content-['']\",\n 'outline-hidden has-[input:focus-visible]:ring-2 has-[input:focus-visible]:ring-offset-2',\n 'data-dragging:ring-2 data-dragging:ring-offset-2',\n 'transition-shadow duration-150 group-focus-within/slider:transition-[inset-inline-start,top,box-shadow] data-dragging:transition-none motion-reduce:transition-none',\n 'disabled:pointer-events-none',\n className,\n )}\n {...props}\n />\n )\n}\n\nSliderThumb.displayName = 'SliderThumb'\n\nfunction SliderValue({\n className,\n ...props\n}: React.ComponentProps<typeof BaseSlider.Value>) {\n return (\n <BaseSlider.Value\n data-slot=\"slider-value\"\n className={cn('text-sm text-gray tabular-nums', className)}\n {...props}\n />\n )\n}\n\nSliderValue.displayName = 'SliderValue'\n\ntype SliderInputProps = Omit<\n React.ComponentProps<'input'>,\n 'value' | 'defaultValue' | 'type' | 'onChange' | 'min' | 'max' | 'step'\n> & {\n /** Which thumb this input drives on a range slider. Defaults to 0. */\n index?: number\n /** Unit rendered after the field (e.g. \"€/month\"). Consumer-supplied — no default. */\n unit?: React.ReactNode\n}\n\n/**\n * Accessible direct-input — a native number field synced to a thumb's value, so\n * a user can type an exact value instead of dragging (or in addition to it).\n * Needs an accessible name: pass `aria-label` (no built-in default — portals are\n * multi-language). While typing it live-updates the thumb only for values already\n * in range (no mid-keystroke jump to the min/max); it snaps + clamps on\n * blur/Enter. `onFocus`/`onBlur`/`onKeyDown` you pass are composed with the\n * internal handlers, not replaced.\n */\nfunction SliderInput({\n className,\n index = 0,\n unit,\n disabled,\n onFocus,\n onBlur,\n onKeyDown,\n ...props\n}: SliderInputProps) {\n const ctx = useSliderContext('SliderInput')\n const currentValue = ctx.values[index] ?? ctx.min\n const [draft, setDraft] = React.useState<string>(String(currentValue))\n const [editing, setEditing] = React.useState(false)\n // the thumb value when editing began — commit fires only if it moved off this\n const baselineRef = React.useRef(currentValue)\n\n // Keep the field in sync when the value changes elsewhere (drag/keyboard),\n // but never fight the user's in-progress typing.\n React.useEffect(() => {\n if (!editing) {\n setDraft(String(currentValue))\n }\n }, [currentValue, editing])\n\n const parseInput = (raw: string): number | null => {\n if (raw.trim() === '') {\n return null\n }\n\n const parsed = Number(raw)\n\n return Number.isNaN(parsed) ? null : parsed\n }\n\n const commit = () => {\n const parsed = parseInput(draft)\n\n if (parsed === null) {\n setDraft(String(currentValue)) // reset an empty/invalid entry\n return\n }\n\n ctx.setThumbValue(index, parsed, {\n commit: true,\n commitBaseline: baselineRef.current,\n })\n }\n\n return (\n <span\n data-slot=\"slider-input\"\n className={cn('inline-flex items-baseline gap-1', className)}\n >\n <input\n type=\"number\"\n inputMode=\"decimal\"\n min={ctx.min}\n max={ctx.max}\n step={ctx.step}\n disabled={disabled ?? ctx.disabled}\n value={editing ? draft : String(currentValue)}\n onChange={(event) => {\n const raw = event.target.value\n setDraft(raw)\n const parsed = parseInput(raw)\n\n // live-update the thumb only when the typed value is already in range,\n // so a partial entry (e.g. \"7\" en route to \"75\") doesn't snap the thumb\n // to the min mid-keystroke. Out-of-range values clamp on blur/Enter.\n if (parsed !== null && parsed >= ctx.min && parsed <= ctx.max) {\n ctx.setThumbValue(index, parsed)\n }\n }}\n onFocus={(event) => {\n baselineRef.current = ctx.values[index] ?? ctx.min\n setEditing(true)\n onFocus?.(event)\n }}\n onBlur={(event) => {\n setEditing(false)\n commit()\n onBlur?.(event)\n }}\n onKeyDown={(event) => {\n // Enter blurs, and the single onBlur commit runs — no double-commit.\n if (event.key === 'Enter') {\n event.currentTarget.blur()\n }\n\n onKeyDown?.(event)\n }}\n className={cn(\n 'w-16 bg-transparent tabular-nums outline-hidden',\n 'rounded-(--spark-rounded-sm) focus-visible:ring-2 focus-visible:ring-offset-2',\n 'disabled:cursor-not-allowed disabled:opacity-50',\n // hide the native spinners — the slider is the primary affordance\n '[appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none',\n )}\n {...props}\n />\n {unit ? (\n <span className=\"text-sm text-gray\" data-slot=\"slider-unit\">\n {unit}\n </span>\n ) : null}\n </span>\n )\n}\n\nSliderInput.displayName = 'SliderInput'\n\nexport {\n Slider,\n SliderControl,\n SliderIndicator,\n SliderInput,\n SliderThumb,\n SliderTicks,\n SliderTrack,\n SliderValue,\n}\nexport type { SliderInputProps, SliderProps, SliderVariant }\n"],"mappings":";;;;;;;;;AAUA,MAAM,YAAY;AAKlB,SAAS,WACP,OACA,KACA,KACA,MACQ;CACR,MAAM,UAAU,KAAK,IAAI,KAAK,KAAK,IAAI,KAAK,KAAK,CAAC;CAElD,IAAI,EAAE,OAAO,IACX,OAAO;CAGT,MAAM,UAAU,MAAM,KAAK,OAAO,UAAU,OAAO,IAAI,IAAI;CAC3D,MAAM,UAAU,KAAK,IAAI,KAAK,KAAK,IAAI,KAAK,OAAO,CAAC;CACpD,MAAM,YAAY,OAAO,IAAI,EAAE,MAAM,GAAG,EAAE,MAAM,IAAI;CAEpD,OAAO,WAAW,IAAI,OAAO,QAAQ,QAAQ,QAAQ,CAAC,IAAI;AAC5D;AAEA,SAAS,gBACP,MACA,SACa;CACb,MAAM,aAAa,OAAO,SAAS,WAAW,CAAC,IAAI,IAAI,CAAC,GAAG,IAAI;CAC/D,IAAI,MAAM,QAAQ,OAAO,GACvB,OAAO;CAET,OAAO,WAAW,MAAM;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AEA,OACE,iBAAA,GAAA,kBAAA,MAAC,QAAD;EACE,aAAU;EACV,YAAA,GAAA,OAAA,IAAc,oCAAoC,SAAS;YAF7D,CAIE,iBAAA,GAAA,kBAAA,KAAC,SAAD;GACE,MAAK;GACL,WAAU;GACV,KAAK,IAAI;GACT,KAAK,IAAI;GACT,MAAM,IAAI;GACV,UAAU,YAAY,IAAI;GAC1B,OAAO,UAAU,QAAQ,OAAO,YAAY;GAC5C,WAAW,UAAU;IACnB,MAAM,MAAM,MAAM,OAAO;IACzB,SAAS,GAAG;IACZ,MAAM,SAAS,WAAW,GAAG;IAK7B,IAAI,WAAW,QAAQ,UAAU,IAAI,OAAO,UAAU,IAAI,KACxD,IAAI,cAAc,OAAO,MAAM;GAEnC;GACA,UAAU,UAAU;IAClB,YAAY,UAAU,IAAI,OAAO,UAAU,IAAI;IAC/C,WAAW,IAAI;IACf,UAAU,KAAK;GACjB;GACA,SAAS,UAAU;IACjB,WAAW,KAAK;IAChB,OAAO;IACP,SAAS,KAAK;GAChB;GACA,YAAY,UAAU;IAEpB,IAAI,MAAM,QAAQ,SAChB,MAAM,cAAc,KAAK;IAG3B,YAAY,KAAK;GACnB;GACA,YAAA,GAAA,OAAA,IACE,mDACA,iFACA,mDAEA,sHACF;GACA,GAAI;EACL,CAAA,GACA,OACC,iBAAA,GAAA,kBAAA,KAAC,QAAD;GAAM,WAAU;GAAoB,aAAU;aAC3C;EACG,CAAA,IACJ,IACA;;AAEV;AAEA,YAAY,cAAc"}
1
+ {"version":3,"file":"slider.cjs","names":["React","BaseSlider"],"sources":["../../src/components/slider.tsx"],"sourcesContent":["import { Slider as BaseSlider } from '@base-ui/react/slider'\nimport * as React from 'react'\nimport { cn } from '../utils/cn'\n\ntype SliderValue = number | number[]\n\ntype SliderVariant = 'default' | 'ticks'\n\n// Above this many steps the tick dots become a picket fence, so `variant=\"ticks\"`\n// silently stops drawing them (the continuous rail stays).\nconst MAX_TICKS = 24\n\n// Clamp to [min, max] then snap to the step grid (origin = min), trimming float\n// noise to the step's own decimal precision. `max` is always valid even if it\n// isn't a step multiple (matches Base UI).\nfunction snapToStep(\n value: number,\n min: number,\n max: number,\n step: number,\n): number {\n const clamped = Math.min(max, Math.max(min, value))\n\n if (!(step > 0)) {\n return clamped\n }\n\n const snapped = min + Math.round((clamped - min) / step) * step\n const bounded = Math.min(max, Math.max(min, snapped))\n const decimals = (String(step).split('.')[1] ?? '').length\n\n return decimals > 0 ? Number(bounded.toFixed(decimals)) : bounded\n}\n\nfunction matchValueShape(\n next: number | readonly number[],\n current: SliderValue,\n): SliderValue {\n const nextValues = typeof next === 'number' ? [next] : [...next]\n if (Array.isArray(current)) {\n return nextValues\n }\n return nextValues[0] ?? current\n}\n\n/**\n * Base UI's slider context is internal-only (not re-exported from\n * `@base-ui/react/slider`), so the editable `<SliderInput>` can't read the\n * current value from it. Instead `<Slider>` owns the value (controllable) and\n * shares it through this Spark context — keeping direct-input robust against\n * Base UI internal changes and letting inputs live anywhere in the subtree.\n */\ntype SliderContextValue = {\n values: readonly number[]\n min: number\n max: number\n step: number\n disabled: boolean\n /**\n * Write one thumb's value (from a `SliderInput`). Snaps to the step grid and\n * clamps; range values are kept sorted. Fires `onValueChange` only when the\n * value actually changes. When `commit` is set it also fires `onValueCommitted`\n * — but only if the committed value differs from `commitBaseline` (the value\n * when editing began), so a plain focus→blur never emits a spurious commit.\n */\n setThumbValue: (\n index: number,\n next: number,\n options?: { commit?: boolean; commitBaseline?: number },\n ) => void\n}\n\nconst SliderContext = React.createContext<SliderContextValue | null>(null)\n\nfunction useSliderContext(part: string): SliderContextValue {\n const ctx = React.useContext(SliderContext)\n\n if (!ctx) {\n throw new Error(`<${part}> must be rendered inside <Slider>`)\n }\n\n return ctx\n}\n\ntype SliderProps<Value extends SliderValue = SliderValue> = Omit<\n React.ComponentProps<typeof BaseSlider.Root>,\n 'value' | 'defaultValue' | 'onValueChange' | 'onValueCommitted' | 'render'\n> & {\n value?: Value\n defaultValue?: Value\n // Generic over the value shape: a single `number` keeps single-thumb handlers\n // number-typed, an array keeps range handlers array-typed — so callers don't\n // widen/narrow at every call site.\n onValueChange?: (\n value: Value,\n eventDetails: BaseSlider.Root.ChangeEventDetails,\n ) => void\n onValueCommitted?: (\n value: Value,\n eventDetails: BaseSlider.Root.CommitEventDetails,\n ) => void\n /**\n * `ticks` marks each step with a small dot on the rail — light on the accent\n * fill, neutral on the unfilled rail. Needs a sensible `step`; the dots are\n * hidden when the step count is < 2 or exceeds {@link MAX_TICKS}, and (in the\n * default render) for vertical sliders. Default `default`.\n */\n variant?: SliderVariant\n}\n\n/**\n * Root. Owns the value (controlled via `value` or uncontrolled via\n * `defaultValue`) and provides the Spark context. With no children it renders\n * the default single/range track (a childless-default, matching the library's\n * `*Close` idiom); pass children to compose `SliderInput` / `SliderValue` /\n * `SliderControl` yourself.\n */\nfunction Slider<Value extends SliderValue = SliderValue>({\n className,\n children,\n value,\n defaultValue,\n min = 0,\n max = 100,\n step = 1,\n disabled = false,\n orientation = 'horizontal',\n variant = 'default',\n onValueChange,\n onValueCommitted,\n // Radix positioned thumbs edge-aligned (inset within the track at min/max);\n // Base UI defaults to center-aligned (half the thumb overflows). `edge` keeps\n // the classic look and the thumb inside the rail.\n thumbAlignment = 'edge',\n // The accessible name belongs on the thumb's nested range input, not just the\n // Root — so keep it on the Root (names the group) AND forward it to the\n // childless-default thumb(s). When you compose your own thumbs, label them.\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledby,\n ...props\n}: SliderProps<Value>) {\n const isControlled = value !== undefined\n const [uncontrolled, setUncontrolled] = React.useState<SliderValue>(\n defaultValue ?? min,\n )\n const current = (isControlled ? value : uncontrolled) as SliderValue\n const values = React.useMemo(\n () => (Array.isArray(current) ? current : [current]),\n [current],\n )\n\n // Base UI hands back `number | readonly number[]`; we forward it as the\n // caller's `Value` (the runtime shape matches what they passed in).\n const emitChange = (\n next: number | readonly number[],\n eventDetails: BaseSlider.Root.ChangeEventDetails,\n ) => {\n const shaped = matchValueShape(next, current) as Value\n\n if (!isControlled) {\n setUncontrolled(shaped as SliderValue)\n }\n\n onValueChange?.(shaped, eventDetails)\n }\n\n // The direct-input write path. Snaps + clamps; for a range it swaps one thumb\n // and re-sorts (Base UI renders from a sorted copy, so an unsorted write would\n // desync the inputs from the thumbs). Fires onValueChange only on a real\n // change; fires onValueCommitted only when the committed value moved off the\n // pre-edit baseline.\n const setThumbValue = (\n index: number,\n next: number,\n options?: { commit?: boolean; commitBaseline?: number },\n ) => {\n const snapped = snapToStep(next, min, max, step)\n const wasArray = Array.isArray(current)\n let nextValue: SliderValue\n\n if (wasArray) {\n const copy = [...(current as number[])]\n copy[index] = snapped\n copy.sort((a, b) => a - b)\n nextValue = copy\n } else {\n nextValue = snapped\n }\n\n const changed = wasArray\n ? (nextValue as number[]).some((v, i) => v !== (current as number[])[i])\n : nextValue !== current\n\n // input-driven changes have no pointer/keyboard event; Base UI's own detail\n // object isn't constructible here, so we hand the consumer a minimal one.\n const details = {\n reason: 'input-change',\n } as unknown as BaseSlider.Root.ChangeEventDetails\n\n if (changed) {\n emitChange(nextValue, details)\n }\n\n if (options?.commit) {\n const committedChanged =\n options.commitBaseline === undefined\n ? changed\n : snapped !== options.commitBaseline\n\n if (committedChanged) {\n onValueCommitted?.(\n nextValue as Value,\n details as unknown as BaseSlider.Root.CommitEventDetails,\n )\n }\n }\n }\n\n // Rebuilt each render (cheap — <Slider> only re-renders on a value change) so\n // setThumbValue always closes over the current value + latest callbacks.\n const context: SliderContextValue = {\n values,\n min,\n max,\n step,\n disabled,\n setThumbValue,\n }\n\n // ticks are horizontal-only in the default render; SliderTicks self-hides when\n // the step count isn't countable, so no density check is needed here.\n const showTicks = variant === 'ticks' && orientation === 'horizontal'\n\n return (\n <SliderContext.Provider value={context}>\n <BaseSlider.Root\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledby}\n data-slot=\"slider\"\n value={current}\n min={min}\n max={max}\n step={step}\n disabled={disabled}\n orientation={orientation}\n thumbAlignment={thumbAlignment}\n onValueChange={emitChange}\n onValueCommitted={(next, eventDetails) =>\n onValueCommitted?.(\n matchValueShape(next, current) as Value,\n eventDetails,\n )\n }\n className={cn(\n 'relative flex w-full flex-col gap-2 data-[orientation=vertical]:h-full data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-row',\n className,\n )}\n {...props}\n >\n {children ?? (\n <SliderControl>\n <SliderTrack>\n <SliderIndicator />\n {showTicks ? <SliderTicks /> : null}\n {values.map((_, index) => (\n <SliderThumb\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledby}\n index={values.length > 1 ? index : undefined}\n key={index}\n />\n ))}\n </SliderTrack>\n </SliderControl>\n )}\n </BaseSlider.Root>\n </SliderContext.Provider>\n )\n}\n\nSlider.displayName = 'Slider'\n\n/**\n * The interactive, draggable surface. A pointer-press anywhere on it moves the\n * nearest thumb (Base UI's track-press), so its full band is the target — kept\n * at ≥24px tall (WCAG 2.5.8) with the thin rail centered.\n */\nfunction SliderControl({\n className,\n ...props\n}: React.ComponentProps<typeof BaseSlider.Control>) {\n return (\n <BaseSlider.Control\n data-slot=\"slider-control\"\n className={cn(\n 'group/slider touch-target relative flex min-h-6 w-full touch-none items-center select-none',\n 'data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-40 data-[orientation=vertical]:w-6 data-[orientation=vertical]:justify-center',\n 'data-disabled:pointer-events-none data-disabled:opacity-50',\n className,\n )}\n {...props}\n />\n )\n}\n\nSliderControl.displayName = 'SliderControl'\n\n/** The rail — the full extent, neutral at rest. Holds the Indicator + Thumb(s). */\nfunction SliderTrack({\n className,\n ...props\n}: React.ComponentProps<typeof BaseSlider.Track>) {\n return (\n <BaseSlider.Track\n data-slot=\"slider-track\"\n className={cn(\n // 12px rail so the corner radius is legible; follows the [data-radius] knob\n // (square at none → pill at large/full). no overflow-hidden: the thumb is a\n // child and would be clipped.\n 'relative h-3 w-full rounded-(--spark-rounded-sm) bg-gray-a4',\n 'data-[orientation=vertical]:h-full data-[orientation=vertical]:w-3',\n className,\n )}\n {...props}\n />\n )\n}\n\nSliderTrack.displayName = 'SliderTrack'\n\n/** The filled portion (min → thumb). Accent, deepens in high-contrast. */\nfunction SliderIndicator({\n className,\n ...props\n}: React.ComponentProps<typeof BaseSlider.Indicator>) {\n return (\n <BaseSlider.Indicator\n data-slot=\"slider-indicator\"\n className={cn(\n // matches the rail's radius so the fill's corners track the knob too\n 'rounded-(--spark-rounded-sm) bg-(--spark-slider-range,var(--spark-9))',\n // ease only while focused (keyboard/rail-click); programmatic and\n // initial value sets snap instantly instead of sweeping from 0.\n // transition-none base matters: bare duration-150 leaves property=all\n 'transition-none duration-150 group-focus-within/slider:transition-[width,height,inset-inline-start] data-dragging:transition-none motion-reduce:transition-none',\n className,\n )}\n {...props}\n />\n )\n}\n\nSliderIndicator.displayName = 'SliderIndicator'\n\n/**\n * Step tick dots overlaid on the rail (shown when `variant=\"ticks\"`). A dot at\n * each interior step — light (`--spark-slider-tick-on`, on the accent fill) for\n * steps up to the value, neutral gray beyond it. The endpoints are omitted (they\n * sit under the rounded rail ends / the thumb). Self-guards: draws nothing unless\n * the step count is in `[2, MAX_TICKS]`, so it's safe to compose directly.\n * Decorative + pointer-transparent so it never blocks a track-press. (Horizontal\n * orientation.)\n */\nfunction SliderTicks({ className, ...props }: React.ComponentProps<'div'>) {\n const { min, max, step, values } = useSliderContext('SliderTicks')\n\n if (!(step > 0) || max <= min) {\n return null\n }\n\n // count the reachable step intervals (floor, so a non-dividing step still gets\n // a dot on its last reachable step); drop the final one when it lands on max.\n const intervals = Math.floor((max - min) / step)\n\n if (intervals < 2 || intervals > MAX_TICKS) {\n return null\n }\n\n const lastIsEndpoint = min + intervals * step === max\n const dotCount = lastIsEndpoint ? intervals - 1 : intervals\n\n // Active band: [min, value] for a single thumb, [low, high] for a range.\n const bandLow = values.length > 1 ? Math.min(...values) : min\n const bandHigh = values.length > 1 ? Math.max(...values) : (values[0] ?? min)\n\n return (\n <div\n aria-hidden=\"true\"\n className={cn('pointer-events-none absolute inset-0', className)}\n data-slot=\"slider-ticks\"\n {...props}\n >\n {Array.from({ length: dotCount }, (_, k) => {\n const index = k + 1 // interior steps only (skip the two endpoints)\n const position = min + index * step\n const pct = ((position - min) / (max - min)) * 100\n const filled = position >= bandLow && position <= bandHigh\n\n return (\n <span\n className={cn(\n 'absolute top-1/2 size-1 -translate-x-1/2 -translate-y-1/2 rounded-full',\n // light dot on the accent fill (flips to step-1 in HC via the token);\n // neutral gray dot on the unfilled rail.\n filled\n ? 'bg-(--spark-slider-tick-on,var(--spark-on-solid,#fff))'\n : 'bg-gray-a8',\n )}\n key={index}\n style={{ left: `${pct}%` }}\n />\n )\n })}\n </div>\n )\n}\n\nSliderTicks.displayName = 'SliderTicks'\n\nfunction SliderThumb({\n className,\n ...props\n}: React.ComponentProps<typeof BaseSlider.Thumb>) {\n return (\n <BaseSlider.Thumb\n data-slot=\"slider-thumb\"\n className={cn(\n 'block size-4 shrink-0 rounded-(--spark-rounded-lg) bg-(--spark-slider-range,var(--spark-9))',\n 'shadow-[0_0_0_2px_var(--spark-background,#fff),0_1px_2px_0_rgb(0_0_0/0.2)]',\n \"before:absolute before:top-1/2 before:left-1/2 before:size-6 before:-translate-x-1/2 before:-translate-y-1/2 before:content-['']\",\n 'outline-hidden has-[input:focus-visible]:ring-2 has-[input:focus-visible]:ring-offset-2',\n 'data-dragging:ring-2 data-dragging:ring-offset-2',\n 'transition-shadow duration-150 group-focus-within/slider:transition-[inset-inline-start,top,box-shadow] data-dragging:transition-none motion-reduce:transition-none',\n 'disabled:pointer-events-none',\n className,\n )}\n {...props}\n />\n )\n}\n\nSliderThumb.displayName = 'SliderThumb'\n\nfunction SliderValue({\n className,\n ...props\n}: React.ComponentProps<typeof BaseSlider.Value>) {\n return (\n <BaseSlider.Value\n data-slot=\"slider-value\"\n className={cn('text-sm text-gray tabular-nums', className)}\n {...props}\n />\n )\n}\n\nSliderValue.displayName = 'SliderValue'\n\ntype SliderInputProps = Omit<\n React.ComponentProps<'input'>,\n 'value' | 'defaultValue' | 'type' | 'onChange' | 'min' | 'max' | 'step'\n> & {\n /** Which thumb this input drives on a range slider. Defaults to 0. */\n index?: number\n /** Unit rendered after the field (e.g. \"€/month\"). Consumer-supplied — no default. */\n unit?: React.ReactNode\n}\n\n/**\n * Accessible direct-input — a native number field synced to a thumb's value, so\n * a user can type an exact value instead of dragging (or in addition to it).\n * Needs an accessible name: pass `aria-label` (no built-in default — portals are\n * multi-language). While typing it live-updates the thumb only for values already\n * in range (no mid-keystroke jump to the min/max); it snaps + clamps on\n * blur/Enter. `onFocus`/`onBlur`/`onKeyDown` you pass are composed with the\n * internal handlers, not replaced.\n */\nfunction SliderInput({\n className,\n index = 0,\n unit,\n disabled,\n onFocus,\n onBlur,\n onKeyDown,\n ...props\n}: SliderInputProps) {\n const ctx = useSliderContext('SliderInput')\n const currentValue = ctx.values[index] ?? ctx.min\n const [draft, setDraft] = React.useState<string>(String(currentValue))\n const [editing, setEditing] = React.useState(false)\n // the thumb value when editing began — commit fires only if it moved off this\n const baselineRef = React.useRef(currentValue)\n\n // Keep the field in sync when the value changes elsewhere (drag/keyboard),\n // but never fight the user's in-progress typing.\n React.useEffect(() => {\n if (!editing) {\n setDraft(String(currentValue))\n }\n }, [currentValue, editing])\n\n const parseInput = (raw: string): number | null => {\n if (raw.trim() === '') {\n return null\n }\n\n const parsed = Number(raw)\n\n return Number.isNaN(parsed) ? null : parsed\n }\n\n const commit = () => {\n const parsed = parseInput(draft)\n\n if (parsed === null) {\n setDraft(String(currentValue)) // reset an empty/invalid entry\n return\n }\n\n ctx.setThumbValue(index, parsed, {\n commit: true,\n commitBaseline: baselineRef.current,\n })\n }\n\n return (\n <span\n data-slot=\"slider-input\"\n className={cn('inline-flex items-baseline gap-1', className)}\n >\n <input\n type=\"number\"\n inputMode=\"decimal\"\n min={ctx.min}\n max={ctx.max}\n step={ctx.step}\n disabled={disabled ?? ctx.disabled}\n value={editing ? draft : String(currentValue)}\n onChange={(event) => {\n const raw = event.target.value\n setDraft(raw)\n const parsed = parseInput(raw)\n\n // live-update the thumb only when the typed value is already in range,\n // so a partial entry (e.g. \"7\" en route to \"75\") doesn't snap the thumb\n // to the min mid-keystroke. Out-of-range values clamp on blur/Enter.\n if (parsed !== null && parsed >= ctx.min && parsed <= ctx.max) {\n ctx.setThumbValue(index, parsed)\n }\n }}\n onFocus={(event) => {\n baselineRef.current = ctx.values[index] ?? ctx.min\n setEditing(true)\n onFocus?.(event)\n }}\n onBlur={(event) => {\n setEditing(false)\n commit()\n onBlur?.(event)\n }}\n onKeyDown={(event) => {\n // Enter blurs, and the single onBlur commit runs — no double-commit.\n if (event.key === 'Enter') {\n event.currentTarget.blur()\n }\n\n onKeyDown?.(event)\n }}\n className={cn(\n 'w-16 bg-transparent tabular-nums outline-hidden',\n 'rounded-(--spark-rounded-sm) focus-visible:ring-2 focus-visible:ring-offset-2',\n 'disabled:cursor-not-allowed disabled:opacity-50',\n // hide the native spinners — the slider is the primary affordance\n '[appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none',\n )}\n {...props}\n />\n {unit ? (\n <span className=\"text-sm text-gray\" data-slot=\"slider-unit\">\n {unit}\n </span>\n ) : null}\n </span>\n )\n}\n\nSliderInput.displayName = 'SliderInput'\n\nexport {\n Slider,\n SliderControl,\n SliderIndicator,\n SliderInput,\n SliderThumb,\n SliderTicks,\n SliderTrack,\n SliderValue,\n}\nexport type { SliderInputProps, SliderProps, SliderVariant }\n"],"mappings":";;;;;;;;;AAUA,MAAM,YAAY;AAKlB,SAAS,WACP,OACA,KACA,KACA,MACQ;CACR,MAAM,UAAU,KAAK,IAAI,KAAK,KAAK,IAAI,KAAK,KAAK,CAAC;CAElD,IAAI,EAAE,OAAO,IACX,OAAO;CAGT,MAAM,UAAU,MAAM,KAAK,OAAO,UAAU,OAAO,IAAI,IAAI;CAC3D,MAAM,UAAU,KAAK,IAAI,KAAK,KAAK,IAAI,KAAK,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AAY,cAAc"}
@@ -0,0 +1,108 @@
1
+ "use client";
2
+ Object.defineProperties(exports, {
3
+ __esModule: { value: true },
4
+ [Symbol.toStringTag]: { value: "Module" }
5
+ });
6
+ require("../utils/chars.cjs");
7
+ const require_utils_format = require("../utils/format.cjs");
8
+ const require_components_line_chart = require("./line-chart.cjs");
9
+ let react = require("react");
10
+ let react_jsx_runtime = require("react/jsx-runtime");
11
+ let cn = require("cn");
12
+ //#region src/components/solar-forecast-chart.tsx
13
+ const DEFAULT_HEIGHT = 220;
14
+ const BASE_MARGIN = {
15
+ top: 8,
16
+ right: 8,
17
+ bottom: 28,
18
+ left: 34
19
+ };
20
+ /** Extra headroom for the weather icon row pinned above the plot. */
21
+ const WEATHER_ROW_HEIGHT = 24;
22
+ function defaultFormatValue(value) {
23
+ return `${require_utils_format.oneDecimalFormat.format(value)} kW`;
24
+ }
25
+ function defaultFormatTime(date) {
26
+ return date.getHours().toString().padStart(2, "0");
27
+ }
28
+ /**
29
+ * Responsive line plot of measured production (solid) against a forecast
30
+ * (dashed) over a day. Optionally overlays hourly weather icons and
31
+ * sunrise/sunset markers, all pinned to the same time axis. Sizes itself to its
32
+ * container; compose a title and any summary around it.
33
+ */
34
+ function SolarForecastChart({ produced, forecast, producedLabel = "Produced", forecastLabel = "Forecast", formatValue = defaultFormatValue, yAxisUnit = "kW", formatTime = defaultFormatTime, formatTooltipTime, weather, sunrise, sunset, formatMarkerTime, curve = "monotone", height = DEFAULT_HEIGHT, className, zoomable, zoomResetLabel, zoomDomain, onZoomDomainChange }) {
35
+ const containerRef = (0, react.useRef)(null);
36
+ const [width, setWidth] = (0, react.useState)(0);
37
+ (0, react.useEffect)(() => {
38
+ const el = containerRef.current;
39
+ if (!el) return;
40
+ const ro = new ResizeObserver((entries) => {
41
+ const entry = entries[0];
42
+ if (entry) setWidth(entry.contentRect.width);
43
+ });
44
+ ro.observe(el);
45
+ return () => ro.disconnect();
46
+ }, []);
47
+ const hasWeather = weather != null && weather.length > 0;
48
+ const margin = {
49
+ ...BASE_MARGIN,
50
+ top: hasWeather ? BASE_MARGIN.top + WEATHER_ROW_HEIGHT : BASE_MARGIN.top
51
+ };
52
+ const formatMarker = formatMarkerTime ?? formatTooltipTime ?? formatTime;
53
+ const topContent = hasWeather ? weather.map((point, i) => {
54
+ const WeatherGlyph = point.icon;
55
+ return {
56
+ key: `weather-${point.date.valueOf()}-${i}`,
57
+ date: point.date,
58
+ content: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(WeatherGlyph, { className: "text-gray-light [--spark-icon-size:18px]" })
59
+ };
60
+ }) : void 0;
61
+ const referenceLines = [sunrise && {
62
+ key: "sunrise",
63
+ date: sunrise,
64
+ label: formatMarker(sunrise)
65
+ }, sunset && {
66
+ key: "sunset",
67
+ date: sunset,
68
+ label: formatMarker(sunset)
69
+ }].filter((x) => Boolean(x));
70
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
71
+ ref: containerRef,
72
+ className: (0, cn.cn)("w-full", className),
73
+ children: width > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_line_chart.LineChart, {
74
+ width,
75
+ height,
76
+ margin,
77
+ curve,
78
+ series: [{
79
+ id: "produced",
80
+ data: produced,
81
+ label: producedLabel
82
+ }, {
83
+ id: "forecast",
84
+ data: forecast,
85
+ label: forecastLabel,
86
+ dashed: true
87
+ }],
88
+ showGrid: true,
89
+ xTickCount: 6,
90
+ yTickCount: 4,
91
+ yAxisUnit,
92
+ formatDate: formatTime,
93
+ formatTooltipDate: formatTooltipTime ?? formatTime,
94
+ formatValue,
95
+ referenceLines: referenceLines.length > 0 ? referenceLines : void 0,
96
+ topContent,
97
+ zoomable,
98
+ zoomResetLabel,
99
+ zoomDomain,
100
+ onZoomDomainChange
101
+ })
102
+ });
103
+ }
104
+ //#endregion
105
+ exports.SolarForecastChart = SolarForecastChart;
106
+ exports.default = SolarForecastChart;
107
+
108
+ //# sourceMappingURL=solar-forecast-chart.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"solar-forecast-chart.cjs","names":["oneDecimalFormat","LineChart"],"sources":["../../src/components/solar-forecast-chart.tsx"],"sourcesContent":["import type { SparkIcon } from '@epilot/spark-icons'\nimport { type JSX, type ReactNode, useEffect, useRef, useState } from 'react'\nimport { NARROW_NBSP } from '../utils/chars'\nimport { cn } from '../utils/cn'\nimport { oneDecimalFormat } from '../utils/format'\nimport {\n LineChart,\n type LineChartCurve,\n type LineChartDatum,\n} from './line-chart'\n\nconst DEFAULT_HEIGHT = 220\n// `left` leaves room for the y-axis tick labels + unit (matches the 34px gutter\n// used by BarChart / PowerHistoryChart).\nconst BASE_MARGIN = { top: 8, right: 8, bottom: 28, left: 34 }\n/** Extra headroom for the weather icon row pinned above the plot. */\nconst WEATHER_ROW_HEIGHT = 24\n\nfunction defaultFormatValue(value: number): string {\n return `${oneDecimalFormat.format(value)}${NARROW_NBSP}kW`\n}\n\nfunction defaultFormatTime(date: Date): string {\n return date.getHours().toString().padStart(2, '0')\n}\n\nexport interface SolarForecastWeatherPoint {\n date: Date\n icon: SparkIcon\n}\n\nexport interface SolarForecastChartProps {\n /** Measured production, drawn as the solid line. */\n produced: LineChartDatum[]\n /** Predicted production, drawn as the dashed line. */\n forecast: LineChartDatum[]\n /** Tooltip label for the produced series. */\n producedLabel?: ReactNode\n /** Tooltip label for the forecast series. */\n forecastLabel?: ReactNode\n /** Tooltip value formatter. Defaults to one-decimal kW (power). */\n formatValue?: (value: number) => string\n /** Unit shown once atop the y-axis; ticks render as plain numbers. Defaults to \"kW\". */\n yAxisUnit?: string\n /** X-axis tick formatter. Defaults to the zero-padded hour. */\n formatTime?: (date: Date) => string\n /** Tooltip time formatter. Defaults to `formatTime`. */\n formatTooltipTime?: (date: Date) => string\n /**\n * Hourly weather icons drawn along the top of the plot, aligned to the time\n * axis. Their dates must fall within the plotted day.\n */\n weather?: SolarForecastWeatherPoint[]\n /** Sunrise time, drawn as a labelled vertical marker on the plot. */\n sunrise?: Date\n /** Sunset time, drawn as a labelled vertical marker on the plot. */\n sunset?: Date\n /** Label formatter for the sunrise/sunset markers. Defaults to `formatTime`. */\n formatMarkerTime?: (date: Date) => string\n curve?: LineChartCurve\n height?: number\n className?: string\n zoomable?: boolean\n zoomResetLabel?: string\n zoomDomain?: [Date, Date] | null\n onZoomDomainChange?: (domain: [Date, Date] | null) => void\n}\n\n/**\n * Responsive line plot of measured production (solid) against a forecast\n * (dashed) over a day. Optionally overlays hourly weather icons and\n * sunrise/sunset markers, all pinned to the same time axis. Sizes itself to its\n * container; compose a title and any summary around it.\n */\nexport function SolarForecastChart({\n produced,\n forecast,\n producedLabel = 'Produced',\n forecastLabel = 'Forecast',\n formatValue = defaultFormatValue,\n yAxisUnit = 'kW',\n formatTime = defaultFormatTime,\n formatTooltipTime,\n weather,\n sunrise,\n sunset,\n formatMarkerTime,\n curve = 'monotone',\n height = DEFAULT_HEIGHT,\n className,\n zoomable,\n zoomResetLabel,\n zoomDomain,\n onZoomDomainChange,\n}: SolarForecastChartProps): JSX.Element {\n const containerRef = useRef<HTMLDivElement>(null)\n const [width, setWidth] = useState(0)\n\n useEffect(() => {\n const el = containerRef.current\n if (!el) return\n const ro = new ResizeObserver((entries) => {\n const entry = entries[0]\n if (entry) setWidth(entry.contentRect.width)\n })\n ro.observe(el)\n return () => ro.disconnect()\n }, [])\n\n const hasWeather = weather != null && weather.length > 0\n const margin = {\n ...BASE_MARGIN,\n top: hasWeather ? BASE_MARGIN.top + WEATHER_ROW_HEIGHT : BASE_MARGIN.top,\n }\n const formatMarker = formatMarkerTime ?? formatTooltipTime ?? formatTime\n\n const topContent = hasWeather\n ? weather.map((point, i) => {\n const WeatherGlyph = point.icon\n return {\n key: `weather-${point.date.valueOf()}-${i}`,\n date: point.date,\n content: (\n <WeatherGlyph className=\"text-gray-light [--spark-icon-size:18px]\" />\n ),\n }\n })\n : undefined\n\n const referenceLines = [\n sunrise && { key: 'sunrise', date: sunrise, label: formatMarker(sunrise) },\n sunset && { key: 'sunset', date: sunset, label: formatMarker(sunset) },\n ].filter((x): x is { key: string; date: Date; label: string } => Boolean(x))\n\n return (\n <div ref={containerRef} className={cn('w-full', className)}>\n {width > 0 && (\n <LineChart\n width={width}\n height={height}\n margin={margin}\n curve={curve}\n series={[\n { id: 'produced', data: produced, label: producedLabel },\n {\n id: 'forecast',\n data: forecast,\n label: forecastLabel,\n dashed: true,\n },\n ]}\n showGrid\n xTickCount={6}\n yTickCount={4}\n yAxisUnit={yAxisUnit}\n formatDate={formatTime}\n formatTooltipDate={formatTooltipTime ?? formatTime}\n formatValue={formatValue}\n referenceLines={\n referenceLines.length > 0 ? referenceLines : undefined\n }\n topContent={topContent}\n zoomable={zoomable}\n zoomResetLabel={zoomResetLabel}\n zoomDomain={zoomDomain}\n onZoomDomainChange={onZoomDomainChange}\n />\n )}\n </div>\n )\n}\n\nexport default SolarForecastChart\n"],"mappings":";;;;;;;;;;;;AAWA,MAAM,iBAAiB;AAGvB,MAAM,cAAc;CAAE,KAAK;CAAG,OAAO;CAAG,QAAQ;CAAI,MAAM;AAAG;;AAE7D,MAAM,qBAAqB;AAE3B,SAAS,mBAAmB,OAAuB;CACjD,OAAO,GAAGA,qBAAAA,iBAAiB,OAAO,KAAK;AACzC;AAEA,SAAS,kBAAkB,MAAoB;CAC7C,OAAO,KAAK,SAAS,EAAE,SAAS,EAAE,SAAS,GAAG,GAAG;AACnD;;;;;;;AAkDA,SAAgB,mBAAmB,EACjC,UACA,UACA,gBAAgB,YAChB,gBAAgB,YAChB,cAAc,oBACd,YAAY,MACZ,aAAa,mBACb,mBACA,SACA,SACA,QACA,kBACA,QAAQ,YACR,SAAS,gBACT,WACA,UACA,gBACA,YACA,sBACuC;CACvC,MAAM,gBAAA,GAAA,MAAA,QAAsC,IAAI;CAChD,MAAM,CAAC,OAAO,aAAA,GAAA,MAAA,UAAqB,CAAC;CAEpC,CAAA,GAAA,MAAA,iBAAgB;EACd,MAAM,KAAK,aAAa;EACxB,IAAI,CAAC,IA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F;GACM;GACJ;GACQ;EACrB,CAAA;CAEA,CAAA;AAET"}
@@ -0,0 +1,77 @@
1
+ "use client";
2
+
3
+ import { LineChartCurve, LineChartDatum } from "./line-chart.cjs";
4
+ import { JSX, ReactNode } from "react";
5
+ import { SparkIcon } from "@epilot/spark-icons";
6
+
7
+ //#region src/components/solar-forecast-chart.d.ts
8
+ interface SolarForecastWeatherPoint {
9
+ date: Date;
10
+ icon: SparkIcon;
11
+ }
12
+ interface SolarForecastChartProps {
13
+ /** Measured production, drawn as the solid line. */
14
+ produced: LineChartDatum[];
15
+ /** Predicted production, drawn as the dashed line. */
16
+ forecast: LineChartDatum[];
17
+ /** Tooltip label for the produced series. */
18
+ producedLabel?: ReactNode;
19
+ /** Tooltip label for the forecast series. */
20
+ forecastLabel?: ReactNode;
21
+ /** Tooltip value formatter. Defaults to one-decimal kW (power). */
22
+ formatValue?: (value: number) => string;
23
+ /** Unit shown once atop the y-axis; ticks render as plain numbers. Defaults to "kW". */
24
+ yAxisUnit?: string;
25
+ /** X-axis tick formatter. Defaults to the zero-padded hour. */
26
+ formatTime?: (date: Date) => string;
27
+ /** Tooltip time formatter. Defaults to `formatTime`. */
28
+ formatTooltipTime?: (date: Date) => string;
29
+ /**
30
+ * Hourly weather icons drawn along the top of the plot, aligned to the time
31
+ * axis. Their dates must fall within the plotted day.
32
+ */
33
+ weather?: SolarForecastWeatherPoint[];
34
+ /** Sunrise time, drawn as a labelled vertical marker on the plot. */
35
+ sunrise?: Date;
36
+ /** Sunset time, drawn as a labelled vertical marker on the plot. */
37
+ sunset?: Date;
38
+ /** Label formatter for the sunrise/sunset markers. Defaults to `formatTime`. */
39
+ formatMarkerTime?: (date: Date) => string;
40
+ curve?: LineChartCurve;
41
+ height?: number;
42
+ className?: string;
43
+ zoomable?: boolean;
44
+ zoomResetLabel?: string;
45
+ zoomDomain?: [Date, Date] | null;
46
+ onZoomDomainChange?: (domain: [Date, Date] | null) => void;
47
+ }
48
+ /**
49
+ * Responsive line plot of measured production (solid) against a forecast
50
+ * (dashed) over a day. Optionally overlays hourly weather icons and
51
+ * sunrise/sunset markers, all pinned to the same time axis. Sizes itself to its
52
+ * container; compose a title and any summary around it.
53
+ */
54
+ declare function SolarForecastChart({
55
+ produced,
56
+ forecast,
57
+ producedLabel,
58
+ forecastLabel,
59
+ formatValue,
60
+ yAxisUnit,
61
+ formatTime,
62
+ formatTooltipTime,
63
+ weather,
64
+ sunrise,
65
+ sunset,
66
+ formatMarkerTime,
67
+ curve,
68
+ height,
69
+ className,
70
+ zoomable,
71
+ zoomResetLabel,
72
+ zoomDomain,
73
+ onZoomDomainChange
74
+ }: SolarForecastChartProps): JSX.Element;
75
+ //#endregion
76
+ export { SolarForecastChart, SolarForecastChart as default, SolarForecastChartProps, SolarForecastWeatherPoint };
77
+ //# sourceMappingURL=solar-forecast-chart.d.cts.map
@@ -0,0 +1,77 @@
1
+ "use client";
2
+
3
+ import { LineChartCurve, LineChartDatum } from "./line-chart.js";
4
+ import { JSX, ReactNode } from "react";
5
+ import { SparkIcon } from "@epilot/spark-icons";
6
+
7
+ //#region src/components/solar-forecast-chart.d.ts
8
+ interface SolarForecastWeatherPoint {
9
+ date: Date;
10
+ icon: SparkIcon;
11
+ }
12
+ interface SolarForecastChartProps {
13
+ /** Measured production, drawn as the solid line. */
14
+ produced: LineChartDatum[];
15
+ /** Predicted production, drawn as the dashed line. */
16
+ forecast: LineChartDatum[];
17
+ /** Tooltip label for the produced series. */
18
+ producedLabel?: ReactNode;
19
+ /** Tooltip label for the forecast series. */
20
+ forecastLabel?: ReactNode;
21
+ /** Tooltip value formatter. Defaults to one-decimal kW (power). */
22
+ formatValue?: (value: number) => string;
23
+ /** Unit shown once atop the y-axis; ticks render as plain numbers. Defaults to "kW". */
24
+ yAxisUnit?: string;
25
+ /** X-axis tick formatter. Defaults to the zero-padded hour. */
26
+ formatTime?: (date: Date) => string;
27
+ /** Tooltip time formatter. Defaults to `formatTime`. */
28
+ formatTooltipTime?: (date: Date) => string;
29
+ /**
30
+ * Hourly weather icons drawn along the top of the plot, aligned to the time
31
+ * axis. Their dates must fall within the plotted day.
32
+ */
33
+ weather?: SolarForecastWeatherPoint[];
34
+ /** Sunrise time, drawn as a labelled vertical marker on the plot. */
35
+ sunrise?: Date;
36
+ /** Sunset time, drawn as a labelled vertical marker on the plot. */
37
+ sunset?: Date;
38
+ /** Label formatter for the sunrise/sunset markers. Defaults to `formatTime`. */
39
+ formatMarkerTime?: (date: Date) => string;
40
+ curve?: LineChartCurve;
41
+ height?: number;
42
+ className?: string;
43
+ zoomable?: boolean;
44
+ zoomResetLabel?: string;
45
+ zoomDomain?: [Date, Date] | null;
46
+ onZoomDomainChange?: (domain: [Date, Date] | null) => void;
47
+ }
48
+ /**
49
+ * Responsive line plot of measured production (solid) against a forecast
50
+ * (dashed) over a day. Optionally overlays hourly weather icons and
51
+ * sunrise/sunset markers, all pinned to the same time axis. Sizes itself to its
52
+ * container; compose a title and any summary around it.
53
+ */
54
+ declare function SolarForecastChart({
55
+ produced,
56
+ forecast,
57
+ producedLabel,
58
+ forecastLabel,
59
+ formatValue,
60
+ yAxisUnit,
61
+ formatTime,
62
+ formatTooltipTime,
63
+ weather,
64
+ sunrise,
65
+ sunset,
66
+ formatMarkerTime,
67
+ curve,
68
+ height,
69
+ className,
70
+ zoomable,
71
+ zoomResetLabel,
72
+ zoomDomain,
73
+ onZoomDomainChange
74
+ }: SolarForecastChartProps): JSX.Element;
75
+ //#endregion
76
+ export { SolarForecastChart, SolarForecastChart as default, SolarForecastChartProps, SolarForecastWeatherPoint };
77
+ //# sourceMappingURL=solar-forecast-chart.d.ts.map