@surflane/ui 0.4.0 → 0.6.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 (296) hide show
  1. package/README.md +2 -2
  2. package/dist/{disclosure.d.ts → accordion.d.ts} +1 -17
  3. package/dist/{disclosure.js → accordion.js} +3 -17
  4. package/dist/alert-dialog.d.ts +31 -0
  5. package/dist/alert-dialog.js +22 -0
  6. package/dist/app-shell.d.ts +44 -3
  7. package/dist/app-shell.js +86 -13
  8. package/dist/{input-extensions.d.ts → autocomplete.d.ts} +4 -42
  9. package/dist/{input-extensions.js → autocomplete.js} +7 -26
  10. package/dist/avatar.js +3 -5
  11. package/dist/badge.d.ts +20 -0
  12. package/dist/badge.js +16 -0
  13. package/dist/bottom-navigation.d.ts +66 -0
  14. package/dist/bottom-navigation.js +36 -0
  15. package/dist/{navigation.d.ts → breadcrumbs.d.ts} +2 -6
  16. package/dist/breadcrumbs.js +31 -0
  17. package/dist/button.d.ts +11 -0
  18. package/dist/button.js +27 -4
  19. package/dist/{content.d.ts → card.d.ts} +6 -24
  20. package/dist/card.js +26 -0
  21. package/dist/chart.d.ts +35 -0
  22. package/dist/chart.js +123 -50
  23. package/dist/checkbox-group.d.ts +2 -0
  24. package/dist/checkbox-group.js +16 -0
  25. package/dist/checkbox.d.ts +9 -0
  26. package/dist/checkbox.js +29 -0
  27. package/dist/choice-label.d.ts +25 -0
  28. package/dist/choice-label.js +14 -0
  29. package/dist/choice.d.ts +7 -0
  30. package/dist/choice.js +3 -0
  31. package/dist/code.d.ts +21 -0
  32. package/dist/{content.js → code.js} +5 -30
  33. package/dist/collapsible.d.ts +18 -0
  34. package/dist/collapsible.js +21 -0
  35. package/dist/{advanced-forms.d.ts → combobox.d.ts} +5 -25
  36. package/dist/{advanced-forms.js → combobox.js} +13 -49
  37. package/dist/{context-overlays.d.ts → context-menu.d.ts} +6 -28
  38. package/dist/{context-overlays.js → context-menu.js} +5 -25
  39. package/dist/css/accordion.css +11 -0
  40. package/dist/css/alert-dialog.css +11 -0
  41. package/{src → dist/css}/all.css +1 -1
  42. package/dist/css/app-shell.css +12 -0
  43. package/dist/css/autocomplete.css +15 -0
  44. package/dist/css/avatar.css +10 -0
  45. package/dist/css/badge.css +10 -0
  46. package/dist/css/bottom-navigation.css +8 -0
  47. package/dist/css/breadcrumbs.css +12 -0
  48. package/dist/css/button.css +8 -0
  49. package/dist/css/card.css +11 -0
  50. package/dist/css/chart.css +13 -0
  51. package/dist/css/checkbox-group.css +9 -0
  52. package/dist/css/checkbox.css +9 -0
  53. package/dist/css/choice-label.css +9 -0
  54. package/dist/css/code.css +13 -0
  55. package/dist/css/collapsible.css +11 -0
  56. package/dist/css/combobox.css +14 -0
  57. package/dist/css/context-menu.css +15 -0
  58. package/dist/css/date-picker.css +12 -0
  59. package/dist/css/dialog.css +10 -0
  60. package/dist/css/drawer.css +11 -0
  61. package/dist/css/empty-state.css +9 -0
  62. package/dist/css/field.css +10 -0
  63. package/dist/css/fieldset.css +8 -0
  64. package/dist/css/file-upload.css +17 -0
  65. package/dist/css/filter-bar.css +8 -0
  66. package/dist/css/form.css +8 -0
  67. package/dist/css/icon.css +8 -0
  68. package/dist/css/inline-message.css +10 -0
  69. package/dist/css/input.css +9 -0
  70. package/dist/css/layout.css +9 -0
  71. package/dist/css/link.css +9 -0
  72. package/dist/css/list.css +9 -0
  73. package/dist/css/markdown.css +18 -0
  74. package/dist/css/menu.css +14 -0
  75. package/dist/css/menubar.css +9 -0
  76. package/dist/css/meter.css +9 -0
  77. package/dist/css/native-select.css +13 -0
  78. package/dist/css/navigation-menu.css +11 -0
  79. package/dist/css/number-field.css +11 -0
  80. package/dist/css/otp-field.css +10 -0
  81. package/dist/css/page-header.css +11 -0
  82. package/dist/css/pagination.css +11 -0
  83. package/dist/css/popover.css +9 -0
  84. package/dist/css/preview-card.css +11 -0
  85. package/dist/css/progress.css +9 -0
  86. package/dist/css/radio-group.css +9 -0
  87. package/dist/css/rules/accordion.css +21 -0
  88. package/dist/css/rules/alert-dialog.css +23 -0
  89. package/dist/css/rules/app-shell.css +220 -0
  90. package/dist/css/rules/autocomplete.css +3 -0
  91. package/dist/css/rules/avatar.css +17 -0
  92. package/dist/css/rules/badge.css +17 -0
  93. package/dist/css/rules/bar.css +38 -0
  94. package/dist/css/rules/base.css +46 -0
  95. package/dist/css/rules/bottom-navigation.css +142 -0
  96. package/dist/css/rules/breadcrumbs.css +9 -0
  97. package/dist/css/rules/button.css +131 -0
  98. package/dist/css/rules/card.css +10 -0
  99. package/dist/css/rules/chart.css +256 -0
  100. package/dist/css/rules/checkbox-group.css +3 -0
  101. package/dist/css/rules/checkbox.css +25 -0
  102. package/dist/css/rules/choice-label.css +52 -0
  103. package/dist/css/rules/choice.css +104 -0
  104. package/dist/css/rules/code.css +9 -0
  105. package/dist/css/rules/collapsible.css +12 -0
  106. package/dist/css/rules/combobox.css +177 -0
  107. package/dist/css/rules/context-menu.css +9 -0
  108. package/dist/css/rules/date-picker.css +301 -0
  109. package/dist/css/rules/dialog.css +160 -0
  110. package/dist/css/rules/disclosure.css +107 -0
  111. package/dist/css/rules/drawer.css +18 -0
  112. package/dist/css/rules/empty-state.css +9 -0
  113. package/dist/css/rules/field-control.css +70 -0
  114. package/dist/css/rules/field.css +56 -0
  115. package/dist/css/rules/fieldset.css +23 -0
  116. package/dist/css/rules/file-upload.css +156 -0
  117. package/dist/css/rules/filter-bar.css +56 -0
  118. package/dist/css/rules/form.css +15 -0
  119. package/dist/css/rules/gauge.css +61 -0
  120. package/dist/css/rules/icon.css +27 -0
  121. package/dist/css/rules/inline-message.css +10 -0
  122. package/dist/css/rules/input-group.css +69 -0
  123. package/dist/css/rules/input.css +33 -0
  124. package/dist/css/rules/item.css +14 -0
  125. package/dist/css/rules/layout.css +3 -0
  126. package/dist/css/rules/link.css +9 -0
  127. package/dist/css/rules/list.css +10 -0
  128. package/dist/css/rules/markdown.css +63 -0
  129. package/dist/css/rules/menu.css +97 -0
  130. package/dist/css/rules/menubar.css +18 -0
  131. package/dist/css/rules/meter.css +3 -0
  132. package/dist/css/rules/native-select.css +3 -0
  133. package/dist/css/rules/navigation-menu.css +159 -0
  134. package/dist/css/rules/number-field.css +55 -0
  135. package/dist/css/rules/otp-field.css +68 -0
  136. package/dist/css/rules/page-header.css +3 -0
  137. package/dist/css/rules/pagination.css +3 -0
  138. package/dist/css/rules/panel.css +221 -0
  139. package/dist/css/rules/popover.css +41 -0
  140. package/dist/css/rules/popup.css +27 -0
  141. package/dist/css/rules/preview-card.css +60 -0
  142. package/dist/css/rules/progress.css +14 -0
  143. package/dist/css/rules/radio-group.css +26 -0
  144. package/dist/css/rules/scroll-area.css +101 -0
  145. package/dist/css/rules/select.css +88 -0
  146. package/dist/css/rules/separator.css +3 -0
  147. package/dist/css/rules/sheet.css +3 -0
  148. package/dist/css/rules/sizing.css +140 -0
  149. package/dist/css/rules/skeleton.css +41 -0
  150. package/dist/css/rules/slider.css +123 -0
  151. package/dist/css/rules/sparkline.css +52 -0
  152. package/dist/css/rules/spinner.css +38 -0
  153. package/dist/css/rules/stat.css +59 -0
  154. package/dist/css/rules/switch.css +50 -0
  155. package/dist/css/rules/syntax-highlighter.css +82 -0
  156. package/dist/css/rules/table.css +28 -0
  157. package/dist/css/rules/tabs.css +126 -0
  158. package/dist/css/rules/textarea.css +21 -0
  159. package/dist/css/rules/toast.css +247 -0
  160. package/dist/css/rules/toggle-group.css +3 -0
  161. package/dist/css/rules/toggle.css +27 -0
  162. package/dist/css/rules/toolbar.css +62 -0
  163. package/dist/css/rules/tooltip.css +38 -0
  164. package/dist/css/rules/tree.css +98 -0
  165. package/dist/css/rules/typography.css +3 -0
  166. package/dist/css/scroll-area.css +8 -0
  167. package/dist/css/select.css +12 -0
  168. package/dist/css/separator.css +9 -0
  169. package/dist/css/sheet.css +11 -0
  170. package/dist/css/sizing.css +7 -0
  171. package/dist/css/skeleton.css +8 -0
  172. package/dist/css/slider.css +8 -0
  173. package/dist/css/sparkline.css +8 -0
  174. package/dist/css/spinner.css +8 -0
  175. package/dist/css/stat.css +9 -0
  176. package/dist/css/styles.css +100 -0
  177. package/dist/css/switch.css +9 -0
  178. package/dist/css/syntax-highlighter.css +9 -0
  179. package/dist/css/table.css +12 -0
  180. package/dist/css/tabs.css +8 -0
  181. package/dist/css/textarea.css +10 -0
  182. package/dist/css/toast.css +11 -0
  183. package/dist/css/toggle-group.css +9 -0
  184. package/dist/css/toggle.css +10 -0
  185. package/dist/css/toolbar.css +12 -0
  186. package/dist/css/tooltip.css +9 -0
  187. package/dist/css/tree.css +10 -0
  188. package/dist/css/typography.css +9 -0
  189. package/dist/date-picker.js +3 -2
  190. package/dist/dialog.d.ts +6 -24
  191. package/dist/dialog.js +7 -20
  192. package/dist/{panels.d.ts → drawer.d.ts} +3 -34
  193. package/dist/drawer.js +47 -0
  194. package/dist/empty-state.d.ts +29 -0
  195. package/dist/empty-state.js +19 -0
  196. package/dist/field.d.ts +42 -0
  197. package/dist/field.js +21 -0
  198. package/dist/fieldset.d.ts +14 -0
  199. package/dist/fieldset.js +10 -0
  200. package/dist/file-upload.d.ts +3 -1
  201. package/dist/file-upload.js +7 -5
  202. package/dist/filter-bar.js +1 -1
  203. package/dist/form.d.ts +2 -0
  204. package/dist/form.js +7 -0
  205. package/dist/format.d.ts +25 -0
  206. package/dist/format.js +42 -0
  207. package/dist/icon.d.ts +11 -0
  208. package/dist/icon.js +19 -3
  209. package/dist/index.d.ts +61 -30
  210. package/dist/index.js +75 -33
  211. package/dist/{messages.d.ts → inline-message.d.ts} +0 -28
  212. package/dist/{messages.js → inline-message.js} +3 -18
  213. package/dist/input.js +2 -2
  214. package/dist/{foundations.d.ts → layout.d.ts} +5 -23
  215. package/dist/{foundations.js → layout.js} +4 -19
  216. package/dist/link.d.ts +6 -0
  217. package/dist/link.js +17 -0
  218. package/dist/list.d.ts +33 -0
  219. package/dist/list.js +21 -0
  220. package/dist/markdown.js +4 -5
  221. package/dist/menu.d.ts +7 -5
  222. package/dist/menu.js +12 -8
  223. package/dist/menubar.d.ts +4 -0
  224. package/dist/menubar.js +4 -0
  225. package/dist/meter.d.ts +29 -0
  226. package/dist/meter.js +13 -0
  227. package/dist/native-select.d.ts +8 -0
  228. package/dist/native-select.js +54 -0
  229. package/dist/navigation-menu.js +8 -5
  230. package/dist/number-field.d.ts +23 -0
  231. package/dist/number-field.js +33 -0
  232. package/dist/page-header.d.ts +12 -0
  233. package/dist/page-header.js +9 -0
  234. package/dist/pagination.js +3 -4
  235. package/dist/panel.d.ts +13 -0
  236. package/dist/panel.js +13 -0
  237. package/dist/parts.d.ts +19 -1
  238. package/dist/parts.js +32 -6
  239. package/dist/popover.d.ts +23 -6
  240. package/dist/popover.js +17 -7
  241. package/dist/preview-card.d.ts +29 -0
  242. package/dist/preview-card.js +27 -0
  243. package/dist/progress.d.ts +29 -0
  244. package/dist/progress.js +13 -0
  245. package/dist/radio-group.d.ts +16 -0
  246. package/dist/radio-group.js +31 -0
  247. package/dist/scroll-area.js +3 -4
  248. package/dist/select.d.ts +8 -8
  249. package/dist/select.js +19 -54
  250. package/dist/separator.d.ts +4 -0
  251. package/dist/separator.js +8 -0
  252. package/dist/sheet.d.ts +29 -0
  253. package/dist/sheet.js +39 -0
  254. package/dist/skeleton.d.ts +8 -0
  255. package/dist/skeleton.js +8 -0
  256. package/dist/slider.d.ts +40 -0
  257. package/dist/slider.js +27 -0
  258. package/dist/sparkline.d.ts +41 -0
  259. package/dist/sparkline.js +50 -0
  260. package/dist/spinner.d.ts +13 -0
  261. package/dist/spinner.js +10 -0
  262. package/dist/stat.d.ts +59 -0
  263. package/dist/stat.js +26 -0
  264. package/dist/status.d.ts +2 -20
  265. package/dist/status.js +11 -14
  266. package/dist/switch.d.ts +13 -0
  267. package/dist/switch.js +25 -0
  268. package/dist/syntax-highlighter.js +2 -1
  269. package/dist/{data.d.ts → table.d.ts} +8 -32
  270. package/dist/{data.js → table.js} +15 -30
  271. package/dist/textarea.d.ts +7 -0
  272. package/dist/textarea.js +12 -0
  273. package/dist/toast.d.ts +57 -1
  274. package/dist/toast.js +80 -8
  275. package/dist/toggle-group.d.ts +5 -0
  276. package/dist/toggle-group.js +7 -0
  277. package/dist/toggle.d.ts +7 -0
  278. package/dist/toggle.js +9 -0
  279. package/dist/{commands.d.ts → toolbar.d.ts} +0 -13
  280. package/dist/toolbar.js +14 -0
  281. package/dist/tooltip.d.ts +10 -3
  282. package/dist/tooltip.js +4 -4
  283. package/dist/tree.js +4 -2
  284. package/dist/typography.d.ts +12 -0
  285. package/dist/typography.js +14 -0
  286. package/package.json +324 -25
  287. package/dist/chevron.d.ts +0 -3
  288. package/dist/chevron.js +0 -6
  289. package/dist/commands.js +0 -27
  290. package/dist/feedback.d.ts +0 -76
  291. package/dist/feedback.js +0 -35
  292. package/dist/forms.d.ts +0 -91
  293. package/dist/forms.js +0 -109
  294. package/dist/navigation.js +0 -41
  295. package/dist/panels.js +0 -100
  296. package/src/styles.css +0 -3780
@@ -0,0 +1,29 @@
1
+ import * as React from 'react';
2
+ export declare const Progress: {
3
+ Root: React.ForwardRefExoticComponent<Omit<Omit<Omit<import("@base-ui/react/progress").ProgressRootProps, "ref"> & React.RefAttributes<HTMLDivElement>, "ref">, "size"> & {
4
+ size?: import("./sizing.js").ComponentSize;
5
+ } & React.RefAttributes<HTMLDivElement>>;
6
+ Label: React.ForwardRefExoticComponent<Omit<Omit<Omit<import("@base-ui/react/progress").ProgressLabelProps, "ref"> & React.RefAttributes<HTMLSpanElement>, "ref">, "size"> & {
7
+ size?: import("./sizing.js").ComponentSize;
8
+ } & React.RefAttributes<HTMLSpanElement>>;
9
+ Value: React.ForwardRefExoticComponent<Omit<Omit<Omit<import("@base-ui/react/progress").ProgressValueProps, "ref"> & React.RefAttributes<HTMLSpanElement>, "ref">, "size"> & {
10
+ size?: import("./sizing.js").ComponentSize;
11
+ } & React.RefAttributes<HTMLSpanElement>>;
12
+ Track: React.ForwardRefExoticComponent<Omit<Omit<Omit<import("@base-ui/react/progress").ProgressTrackProps, "ref"> & React.RefAttributes<HTMLDivElement>, "ref">, "size"> & {
13
+ size?: import("./sizing.js").ComponentSize;
14
+ } & React.RefAttributes<HTMLDivElement>>;
15
+ Indicator: React.ForwardRefExoticComponent<Omit<Omit<Omit<import("@base-ui/react/progress").ProgressIndicatorProps, "ref"> & React.RefAttributes<HTMLDivElement>, "ref">, "size"> & {
16
+ size?: import("./sizing.js").ComponentSize;
17
+ } & React.RefAttributes<HTMLDivElement>>;
18
+ };
19
+ export declare const ProgressIndicator: React.ForwardRefExoticComponent<Omit<Omit<Omit<import("@base-ui/react/progress").ProgressIndicatorProps, "ref"> & React.RefAttributes<HTMLDivElement>, "ref">, "size"> & {
20
+ size?: import("./sizing.js").ComponentSize;
21
+ } & React.RefAttributes<HTMLDivElement>>, ProgressLabel: React.ForwardRefExoticComponent<Omit<Omit<Omit<import("@base-ui/react/progress").ProgressLabelProps, "ref"> & React.RefAttributes<HTMLSpanElement>, "ref">, "size"> & {
22
+ size?: import("./sizing.js").ComponentSize;
23
+ } & React.RefAttributes<HTMLSpanElement>>, ProgressRoot: React.ForwardRefExoticComponent<Omit<Omit<Omit<import("@base-ui/react/progress").ProgressRootProps, "ref"> & React.RefAttributes<HTMLDivElement>, "ref">, "size"> & {
24
+ size?: import("./sizing.js").ComponentSize;
25
+ } & React.RefAttributes<HTMLDivElement>>, ProgressTrack: React.ForwardRefExoticComponent<Omit<Omit<Omit<import("@base-ui/react/progress").ProgressTrackProps, "ref"> & React.RefAttributes<HTMLDivElement>, "ref">, "size"> & {
26
+ size?: import("./sizing.js").ComponentSize;
27
+ } & React.RefAttributes<HTMLDivElement>>, ProgressValue: React.ForwardRefExoticComponent<Omit<Omit<Omit<import("@base-ui/react/progress").ProgressValueProps, "ref"> & React.RefAttributes<HTMLSpanElement>, "ref">, "size"> & {
28
+ size?: import("./sizing.js").ComponentSize;
29
+ } & React.RefAttributes<HTMLSpanElement>>;
@@ -0,0 +1,13 @@
1
+ 'use client';
2
+ import { Progress as BaseProgress } from '@base-ui/react/progress';
3
+ import { part } from './parts.js';
4
+ export const Progress = {
5
+ ...BaseProgress,
6
+ Root: /* @__PURE__ */ part(BaseProgress.Root, 'pui-gauge pui-progress'),
7
+ Label: /* @__PURE__ */ part(BaseProgress.Label, 'pui-gauge-label'),
8
+ Value: /* @__PURE__ */ part(BaseProgress.Value, 'pui-gauge-value'),
9
+ Track: /* @__PURE__ */ part(BaseProgress.Track, 'pui-gauge-track'),
10
+ Indicator: /* @__PURE__ */ part(BaseProgress.Indicator, 'pui-gauge-indicator'),
11
+ };
12
+ // Flat names for React Server Components, which cannot dot into client exports.
13
+ export const { Indicator: ProgressIndicator, Label: ProgressLabel, Root: ProgressRoot, Track: ProgressTrack, Value: ProgressValue, } = Progress;
@@ -0,0 +1,16 @@
1
+ import * as React from 'react';
2
+ import { Radio as BaseRadio } from '@base-ui/react/radio';
3
+ import { RadioGroup as BaseRadioGroup } from '@base-ui/react/radio-group';
4
+ import { type ChoiceSize } from './choice.js';
5
+ export declare function RadioGroup<Value = string>({ value, defaultValue, onValueChange, className, form, ref, ...props }: BaseRadioGroup.Props<Value>): React.JSX.Element;
6
+ declare const RadioRoot: React.ForwardRefExoticComponent<Omit<BaseRadio.Root.Props<unknown>, "ref"> & ChoiceSize & React.RefAttributes<HTMLSpanElement>>;
7
+ export declare const Radio: {
8
+ Root: React.ForwardRefExoticComponent<Omit<BaseRadio.Root.Props<unknown>, "ref"> & ChoiceSize & React.RefAttributes<HTMLSpanElement>>;
9
+ Indicator: React.ForwardRefExoticComponent<Omit<Omit<Omit<import("@base-ui/react/radio").RadioIndicatorProps, "ref"> & React.RefAttributes<HTMLSpanElement>, "ref">, "size"> & {
10
+ size?: import("./sizing.js").ComponentSize;
11
+ } & React.RefAttributes<HTMLSpanElement>>;
12
+ };
13
+ export { RadioRoot };
14
+ export declare const RadioIndicator: React.ForwardRefExoticComponent<Omit<Omit<Omit<import("@base-ui/react/radio").RadioIndicatorProps, "ref"> & React.RefAttributes<HTMLSpanElement>, "ref">, "size"> & {
15
+ size?: import("./sizing.js").ComponentSize;
16
+ } & React.RefAttributes<HTMLSpanElement>>;
@@ -0,0 +1,31 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import * as React from 'react';
4
+ import { useComponentSize } from './sizing.js';
5
+ import { Radio as BaseRadio } from '@base-ui/react/radio';
6
+ import { RadioGroup as BaseRadioGroup } from '@base-ui/react/radio-group';
7
+ import { skin, part } from './parts.js';
8
+ import { useRootRef, useResetValue } from './form-state.js';
9
+ import { ChoiceResetPaint } from './choice.js';
10
+ export function RadioGroup({ value, defaultValue, onValueChange, className, form, ref, ...props }) {
11
+ const [element, attach] = useRootRef(ref);
12
+ const [selected, setSelected, revision] = useResetValue(value, defaultValue ?? null, element, form);
13
+ return (_jsx(ChoiceResetPaint.Provider, { value: revision, children: _jsx(BaseRadioGroup, { ...props, form: form, ref: attach, value: selected, className: skin('pui-choice-group', className), onValueChange: (next, event) => {
14
+ onValueChange?.(next, event);
15
+ if (value === undefined && !event.isCanceled)
16
+ setSelected(next);
17
+ } }) }));
18
+ }
19
+ const RadioRoot = /* @__PURE__ */ React.forwardRef(function RadioRoot({ size, className, ...props }, ref) {
20
+ React.useContext(ChoiceResetPaint);
21
+ const scheme = useComponentSize(size);
22
+ return (_jsx(BaseRadio.Root, { ...props, "data-ui-size": size ? scheme : undefined, ref: ref, className: skin('pui-radio', className) }));
23
+ });
24
+ export const Radio = {
25
+ ...BaseRadio,
26
+ Root: RadioRoot,
27
+ Indicator: /* @__PURE__ */ part(BaseRadio.Indicator, 'pui-radio-indicator'),
28
+ };
29
+ // Flat names for React Server Components, which cannot dot into client exports.
30
+ export { RadioRoot };
31
+ export const { Indicator: RadioIndicator } = Radio;
@@ -2,6 +2,7 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import * as React from 'react';
4
4
  import { ScrollArea as BaseScrollArea } from '@base-ui/react/scroll-area';
5
+ import { cx } from './parts.js';
5
6
  export const ScrollArea = /* @__PURE__ */ React.forwardRef(function ScrollArea({ label, orientation = 'horizontal', scrollChain = 'auto', style, rootClassName, rootStyle, tabIndex = label ? 0 : undefined, role = label ? 'region' : undefined, className, children, ...props }, ref) {
6
7
  const dragPointer = React.useRef(null);
7
8
  const clearDrag = (event) => {
@@ -10,7 +11,7 @@ export const ScrollArea = /* @__PURE__ */ React.forwardRef(function ScrollArea({
10
11
  dragPointer.current = null;
11
12
  event.currentTarget.removeAttribute('data-scroll-dragging');
12
13
  };
13
- return (_jsxs(BaseScrollArea.Root, { className: ['pui-scroll-root', rootClassName].filter(Boolean).join(' '), style: rootStyle, onPointerMoveCapture: (event) => {
14
+ return (_jsxs(BaseScrollArea.Root, { className: cx('pui-scroll-root', rootClassName), style: rootStyle, onPointerMoveCapture: (event) => {
14
15
  if (event.pointerType === 'touch')
15
16
  return;
16
17
  const root = event.currentTarget;
@@ -27,9 +28,7 @@ export const ScrollArea = /* @__PURE__ */ React.forwardRef(function ScrollArea({
27
28
  dragPointer.current = event.pointerId;
28
29
  event.currentTarget.setAttribute('data-scroll-dragging', bar.getAttribute('data-orientation') ?? '');
29
30
  }
30
- }, onPointerUpCapture: clearDrag, onPointerCancelCapture: clearDrag, onLostPointerCapture: clearDrag, children: [_jsx(BaseScrollArea.Viewport, { ...props, ref: ref, className: ['pui-scroll-viewport scroll-area', className]
31
- .filter(Boolean)
32
- .join(' '), role: role, "aria-label": label, tabIndex: tabIndex, "data-scroll-orientation": orientation, style: {
31
+ }, onPointerUpCapture: clearDrag, onPointerCancelCapture: clearDrag, onLostPointerCapture: clearDrag, children: [_jsx(BaseScrollArea.Viewport, { ...props, ref: ref, className: cx('pui-scroll-viewport', className), role: role, "aria-label": label, tabIndex: tabIndex, "data-scroll-orientation": orientation, style: {
33
32
  overflowX: orientation === 'vertical' ? 'hidden' : 'auto',
34
33
  overflowY: orientation === 'horizontal' ? 'hidden' : 'auto',
35
34
  overscrollBehaviorX: orientation === 'vertical' ? 'auto' : scrollChain,
package/dist/select.d.ts CHANGED
@@ -5,8 +5,13 @@ export type SelectOption = {
5
5
  label: React.ReactNode;
6
6
  disabled?: boolean;
7
7
  };
8
- export type SelectProps = {
8
+ /** Options under a visible heading, like an HTML optgroup. */
9
+ export type SelectGroup = {
10
+ label: React.ReactNode;
9
11
  options: SelectOption[];
12
+ };
13
+ export type SelectProps = {
14
+ options: (SelectOption | SelectGroup)[];
10
15
  value?: string;
11
16
  defaultValue?: string;
12
17
  onValueChange?: (value: string) => void;
@@ -24,10 +29,5 @@ export type SelectProps = {
24
29
  'aria-describedby'?: string;
25
30
  'aria-invalid'?: React.AriaAttributes['aria-invalid'];
26
31
  };
27
- export declare function Select({ options, value, defaultValue, onValueChange, className, inputRef, triggerRef, size, ...props }: SelectProps): React.JSX.Element;
28
- /** Transitional HTML-option adapter. Submitted values use Base UI's native hidden input. */
29
- export declare const NativeSelect: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.SelectHTMLAttributes<HTMLSelectElement>, HTMLSelectElement>, "ref">, "size" | "multiple"> & {
30
- size?: ComponentSizeAlias;
31
- } & React.RefAttributes<HTMLButtonElement>>;
32
- export declare function NativeSelectOption(props: React.ComponentProps<'option'>): React.JSX.Element;
33
- export declare function NativeSelectOptGroup(props: React.ComponentProps<'optgroup'>): React.JSX.Element;
32
+ /** A single-choice list. The ref reaches the trigger button, as triggerRef does. */
33
+ export declare const Select: React.ForwardRefExoticComponent<SelectProps & React.RefAttributes<HTMLButtonElement>>;
package/dist/select.js CHANGED
@@ -1,18 +1,24 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import * as React from 'react';
4
+ import { Icon } from './icon.js';
4
5
  import { useComponentSize } from './sizing.js';
5
6
  import { Select as BaseSelect } from '@base-ui/react/select';
6
- import { sizeName } from './parts.js';
7
- const cx = (...v) => v.filter(Boolean).join(' ');
8
- function Chevron() {
9
- return (_jsx("svg", { width: '16', height: '16', viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor', strokeWidth: '1.7', "aria-hidden": 'true', children: _jsx("path", { d: 'm7 10 5 5 5-5' }) }));
10
- }
11
- function Check() {
12
- return (_jsx("svg", { width: '14', height: '14', viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor', strokeWidth: '1.7', "aria-hidden": 'true', children: _jsx("path", { d: 'm5 12 4 4L19 6' }) }));
13
- }
14
- export function Select({ options, value, defaultValue, onValueChange, className, inputRef, triggerRef, size, ...props }) {
7
+ import { sizeName, cx } from './parts.js';
8
+ const isGroup = (item) => 'options' in item;
9
+ const flatten = (items) => items.flatMap((item) => (isGroup(item) ? item.options : [item]));
10
+ /** A single-choice list. The ref reaches the trigger button, as triggerRef does. */
11
+ export const Select = /* @__PURE__ */ React.forwardRef(function Select({ options: items, value, defaultValue, onValueChange, className, inputRef, triggerRef, size, ...props }, ref) {
15
12
  const scheme = useComponentSize(size);
13
+ const options = flatten(items);
14
+ // One stable callback, so the trigger ref is not detached on every render.
15
+ const setTrigger = React.useCallback((node) => {
16
+ for (const target of [ref, triggerRef])
17
+ if (typeof target === 'function')
18
+ target(node);
19
+ else if (target)
20
+ target.current = node;
21
+ }, [ref, triggerRef]);
16
22
  const [localValue, setLocalValue] = React.useState(defaultValue ?? options[0]?.value ?? '');
17
23
  const nativeInput = React.useRef(null);
18
24
  const initialValue = defaultValue ?? options[0]?.value ?? '';
@@ -41,7 +47,7 @@ export function Select({ options, value, defaultValue, onValueChange, className,
41
47
  }, [initialValue, props.form]);
42
48
  const selected = value ?? localValue;
43
49
  const { name, form, required, disabled, id, ...aria } = props;
44
- return (_jsx("span", { className: cx('pui-select control-shell select-control', className), "data-size": sizeName(size), "data-ui-size": scheme, "data-disabled": disabled || undefined, children: _jsxs(BaseSelect.Root, { items: options, value: selected, onValueChange: (v) => {
50
+ return (_jsx("span", { className: cx('pui-select', className), "data-size": sizeName(size), "data-ui-size": scheme, "data-disabled": disabled || undefined, children: _jsxs(BaseSelect.Root, { items: options, value: selected, onValueChange: (v) => {
45
51
  setLocalValue(v ?? '');
46
52
  onValueChange?.(v ?? '');
47
53
  }, inputRef: (node) => {
@@ -50,49 +56,8 @@ export function Select({ options, value, defaultValue, onValueChange, className,
50
56
  inputRef(node);
51
57
  else if (inputRef)
52
58
  inputRef.current = node;
53
- }, name: name, form: form, required: required, disabled: disabled, id: id, children: [_jsxs(BaseSelect.Trigger, { ...aria, ref: triggerRef, className: 'pui-select-trigger form-control', "data-value": selected, children: [_jsx(BaseSelect.Value, {}), _jsx(BaseSelect.Icon, { className: 'pui-select-icon select-chevron', children: _jsx(Chevron, {}) })] }), _jsx(BaseSelect.Portal, { children: _jsx(BaseSelect.Positioner, { className: 'pui-positioner', sideOffset: 6, alignItemWithTrigger: false, children: _jsx(BaseSelect.Popup, { className: 'pui-select-popup', "data-ui-size": scheme, children: _jsx(BaseSelect.List, { children: options.map((o) => (_jsxs(BaseSelect.Item, { className: 'pui-select-item', value: o.value, "data-option-value": o.value, disabled: o.disabled, children: [_jsx(BaseSelect.ItemIndicator, { className: 'pui-select-check', children: _jsx(Check, {}) }), _jsx(BaseSelect.ItemText, { children: o.label })] }, o.value))) }) }) }) })] }) }));
54
- }
55
- function optionList(children) {
56
- return React.Children.toArray(children).flatMap((child) => {
57
- if (!React.isValidElement(child))
58
- return [];
59
- const p = child.props;
60
- if (child.type === React.Fragment ||
61
- child.type === 'optgroup' ||
62
- child.type === NativeSelectOptGroup)
63
- return optionList(p.children);
64
- return [
65
- {
66
- value: String(p.value ?? p.children ?? ''),
67
- label: p.label ?? p.children,
68
- disabled: p.disabled,
69
- },
70
- ];
71
- });
72
- }
73
- /** Transitional HTML-option adapter. Submitted values use Base UI's native hidden input. */
74
- export const NativeSelect = /* @__PURE__ */ React.forwardRef(function NativeSelect({ children, onChange, value, defaultValue, className, size, ...props }, ref) {
75
- const input = React.useRef(null);
76
- const options = optionList(children);
77
- return (_jsx(Select, { options: options, value: value === undefined ? undefined : String(value), defaultValue: defaultValue === undefined ? undefined : String(defaultValue), className: className, size: size, inputRef: input, triggerRef: ref, name: props.name, form: props.form, disabled: props.disabled, required: props.required, id: props.id, "aria-label": props['aria-label'], "aria-labelledby": props['aria-labelledby'], "aria-describedby": props['aria-describedby'], "aria-invalid": props['aria-invalid'], onValueChange: (next) => {
78
- if (!onChange)
79
- return;
80
- const target = input.current;
81
- if (!target)
82
- return;
83
- const setter = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value')?.set;
84
- setter?.call(target, next);
85
- const event = new Event('change', { bubbles: true });
86
- Object.defineProperties(event, {
87
- target: { value: target },
88
- currentTarget: { value: target },
89
- });
90
- onChange(event);
91
- } }));
59
+ }, name: name, form: form, required: required, disabled: disabled, id: id, children: [_jsxs(BaseSelect.Trigger, { ...aria, ref: setTrigger, className: 'pui-select-trigger', "data-value": selected, children: [_jsx(BaseSelect.Value, {}), _jsx(BaseSelect.Icon, { className: 'pui-select-icon', children: _jsx(Icon, { name: 'chevron-down' }) })] }), _jsx(BaseSelect.Portal, { children: _jsx(BaseSelect.Positioner, { className: 'pui-positioner', sideOffset: 6, alignItemWithTrigger: false, children: _jsx(BaseSelect.Popup, { className: 'pui-select-popup', "data-ui-size": scheme, children: _jsx(BaseSelect.List, { children: items.map((item, index) => isGroup(item) ? (_jsxs(BaseSelect.Group, { className: 'pui-select-group', children: [_jsx(BaseSelect.GroupLabel, { className: 'pui-select-group-label', children: item.label }), item.options.map(renderOption)] }, index)) : (renderOption(item))) }) }) }) })] }) }));
92
60
  });
93
- export function NativeSelectOption(props) {
94
- return _jsx("option", { ...props });
95
- }
96
- export function NativeSelectOptGroup(props) {
97
- return _jsx("optgroup", { ...props });
61
+ function renderOption(option) {
62
+ return (_jsxs(BaseSelect.Item, { className: 'pui-select-item', value: option.value, "data-option-value": option.value, disabled: option.disabled, children: [_jsx(BaseSelect.ItemIndicator, { className: 'pui-select-check', children: _jsx(Icon, { name: 'check' }) }), _jsx(BaseSelect.ItemText, { children: option.label })] }, option.value));
98
63
  }
@@ -0,0 +1,4 @@
1
+ import * as React from 'react';
2
+ export declare const Separator: React.ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react/separator").SeparatorProps, "ref"> & React.RefAttributes<HTMLDivElement>, "ref"> & {
3
+ inset?: boolean;
4
+ } & React.RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,8 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import * as React from 'react';
4
+ import { Separator as BaseSeparator } from '@base-ui/react/separator';
5
+ import { skin } from './parts.js';
6
+ export const Separator = /* @__PURE__ */ React.forwardRef(function Separator({ inset = false, className, ...props }, ref) {
7
+ return (_jsx(BaseSeparator, { ...props, ref: ref, "data-inset": inset || undefined, className: skin('pui-separator', className) }));
8
+ });
@@ -0,0 +1,29 @@
1
+ import * as React from 'react';
2
+ import { Dialog as BaseDialog } from '@base-ui/react/dialog';
3
+ import { Footer, Header, type PanelOptions, type PanelSide } from './panel.js';
4
+ declare function SheetRoot({ side, modal, ...props }: React.ComponentProps<typeof BaseDialog.Root> & {
5
+ side?: PanelSide;
6
+ }): React.JSX.Element;
7
+ declare const SheetContent: React.ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react/dialog").DialogPopupProps, "ref"> & React.RefAttributes<HTMLDivElement>, "ref"> & PanelOptions & React.RefAttributes<HTMLDivElement>>;
8
+ declare function SheetTitle({ className, ...props }: React.ComponentProps<typeof BaseDialog.Title>): React.JSX.Element;
9
+ declare function SheetDescription({ className, ...props }: React.ComponentProps<typeof BaseDialog.Description>): React.JSX.Element;
10
+ export declare const Sheet: {
11
+ Root: typeof SheetRoot;
12
+ Content: React.ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react/dialog").DialogPopupProps, "ref"> & React.RefAttributes<HTMLDivElement>, "ref"> & PanelOptions & React.RefAttributes<HTMLDivElement>>;
13
+ Header: typeof Header;
14
+ Body: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
15
+ Footer: typeof Footer;
16
+ Title: typeof SheetTitle;
17
+ Description: typeof SheetDescription;
18
+ Backdrop: React.ForwardRefExoticComponent<Omit<import("@base-ui/react/dialog").DialogBackdropProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
19
+ Close: React.ForwardRefExoticComponent<Omit<import("@base-ui/react/dialog").DialogCloseProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
20
+ Popup: React.ForwardRefExoticComponent<Omit<import("@base-ui/react/dialog").DialogPopupProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
21
+ Portal: React.ForwardRefExoticComponent<Omit<import("@base-ui/react/dialog").DialogPortalProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
22
+ Viewport: React.ForwardRefExoticComponent<Omit<import("@base-ui/react/dialog").DialogViewportProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
23
+ Trigger: BaseDialog.Trigger;
24
+ createHandle: typeof BaseDialog.createHandle;
25
+ Handle: typeof BaseDialog.Handle;
26
+ };
27
+ export { SheetDescription, SheetRoot, SheetTitle, SheetContent };
28
+ export declare const SheetBackdrop: React.ForwardRefExoticComponent<Omit<import("@base-ui/react/dialog").DialogBackdropProps, "ref"> & React.RefAttributes<HTMLDivElement>>, SheetClose: React.ForwardRefExoticComponent<Omit<import("@base-ui/react/dialog").DialogCloseProps, "ref"> & React.RefAttributes<HTMLButtonElement>>, SheetHandle: typeof BaseDialog.Handle, SheetPopup: React.ForwardRefExoticComponent<Omit<import("@base-ui/react/dialog").DialogPopupProps, "ref"> & React.RefAttributes<HTMLDivElement>>, SheetPortal: React.ForwardRefExoticComponent<Omit<import("@base-ui/react/dialog").DialogPortalProps, "ref"> & React.RefAttributes<HTMLDivElement>>, SheetTrigger: BaseDialog.Trigger, SheetViewport: React.ForwardRefExoticComponent<Omit<import("@base-ui/react/dialog").DialogViewportProps, "ref"> & React.RefAttributes<HTMLDivElement>>, SheetHeader: typeof Header, SheetBody: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>, SheetFooter: typeof Footer;
29
+ export type { PanelSide } from './panel.js';
package/dist/sheet.js ADDED
@@ -0,0 +1,39 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import * as React from 'react';
4
+ import { Icon } from './icon.js';
5
+ import { skin } from './parts.js';
6
+ import { useComponentSize, normalizeSize } from './sizing.js';
7
+ import { Dialog as BaseDialog } from '@base-ui/react/dialog';
8
+ import { Body, Footer, Header, } from './panel.js';
9
+ const SheetSide = /* @__PURE__ */ React.createContext({
10
+ side: 'right',
11
+ modal: true,
12
+ });
13
+ function SheetRoot({ side = 'right', modal = true, ...props }) {
14
+ return (_jsx(SheetSide.Provider, { value: { side, modal }, children: _jsx(BaseDialog.Root, { ...props, modal: modal }) }));
15
+ }
16
+ const SheetContent = /* @__PURE__ */ React.forwardRef(function SheetContent({ size, flush, closeLabel = 'Close panel', className, children, ...props }, ref) {
17
+ const scheme = useComponentSize(size);
18
+ const { side, modal } = React.useContext(SheetSide);
19
+ return (_jsx(BaseDialog.Portal, { children: _jsxs("div", { className: 'pui-panel-layer', "data-ui-size": scheme, children: [modal === true && (_jsx(BaseDialog.Backdrop, { className: 'pui-panel-backdrop' })), _jsx("div", { className: 'pui-panel-viewport', "data-side": side, "data-flush": flush || undefined, children: _jsxs(BaseDialog.Popup, { ...props, ref: ref, className: skin('pui-panel', className), "data-side": side, "data-size": normalizeSize(size) ?? 'default', "data-flush": flush || undefined, children: [_jsx(BaseDialog.Close, { className: 'pui-panel-close pui-icon-button', "aria-label": closeLabel, children: _jsx(Icon, { name: 'close' }) }), children] }) })] }) }));
20
+ });
21
+ function SheetTitle({ className, ...props }) {
22
+ return (_jsx(BaseDialog.Title, { ...props, className: skin('pui-panel-title', className) }));
23
+ }
24
+ function SheetDescription({ className, ...props }) {
25
+ return (_jsx(BaseDialog.Description, { ...props, className: skin('pui-panel-description', className) }));
26
+ }
27
+ export const Sheet = {
28
+ ...BaseDialog,
29
+ Root: SheetRoot,
30
+ Content: SheetContent,
31
+ Header,
32
+ Body,
33
+ Footer,
34
+ Title: SheetTitle,
35
+ Description: SheetDescription,
36
+ };
37
+ // Flat names for React Server Components, which cannot dot into client exports.
38
+ export { SheetDescription, SheetRoot, SheetTitle, SheetContent };
39
+ export const { Backdrop: SheetBackdrop, Close: SheetClose, Handle: SheetHandle, Popup: SheetPopup, Portal: SheetPortal, Trigger: SheetTrigger, Viewport: SheetViewport, Header: SheetHeader, Body: SheetBody, Footer: SheetFooter, } = Sheet;
@@ -0,0 +1,8 @@
1
+ import * as React from 'react';
2
+ export type SkeletonProps = Omit<React.ComponentPropsWithoutRef<'span'>, 'children'> & {
3
+ shape?: 'text' | 'block' | 'circle';
4
+ };
5
+ /** Decorative placeholder; the owning region provides aria-busy and loading text. */
6
+ export declare const Skeleton: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref">, "children"> & {
7
+ shape?: "text" | "block" | "circle";
8
+ } & React.RefAttributes<HTMLSpanElement>>;
@@ -0,0 +1,8 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import * as React from 'react';
4
+ import { cx } from './parts.js';
5
+ /** Decorative placeholder; the owning region provides aria-busy and loading text. */
6
+ export const Skeleton = /* @__PURE__ */ React.forwardRef(function Skeleton({ shape = 'text', className, ...props }, ref) {
7
+ return (_jsx("span", { ...props, ref: ref, className: cx('pui-skeleton', className), "data-shape": shape, "aria-hidden": 'true' }));
8
+ });
@@ -0,0 +1,40 @@
1
+ import * as React from 'react';
2
+ import { Slider as BaseSlider } from '@base-ui/react/slider';
3
+ declare function SliderRoot<Value extends number | readonly number[]>({ value, defaultValue, onValueChange, ref, className, form, thumbAlignment, ...props }: BaseSlider.Root.Props<Value> & {
4
+ ref?: React.Ref<HTMLDivElement>;
5
+ }): React.JSX.Element;
6
+ export declare const Slider: {
7
+ Root: typeof SliderRoot;
8
+ Label: React.ForwardRefExoticComponent<Omit<Omit<Omit<import("@base-ui/react/slider").SliderLabelProps, "ref"> & React.RefAttributes<HTMLDivElement>, "ref">, "size"> & {
9
+ size?: import("./sizing.js").ComponentSize;
10
+ } & React.RefAttributes<HTMLDivElement>>;
11
+ Value: React.ForwardRefExoticComponent<Omit<Omit<Omit<import("@base-ui/react/slider").SliderValueProps, "ref"> & React.RefAttributes<HTMLOutputElement>, "ref">, "size"> & {
12
+ size?: import("./sizing.js").ComponentSize;
13
+ } & React.RefAttributes<HTMLOutputElement>>;
14
+ Control: React.ForwardRefExoticComponent<Omit<Omit<Omit<import("@base-ui/react/slider").SliderControlProps, "ref"> & React.RefAttributes<HTMLDivElement>, "ref">, "size"> & {
15
+ size?: import("./sizing.js").ComponentSize;
16
+ } & React.RefAttributes<HTMLDivElement>>;
17
+ Track: React.ForwardRefExoticComponent<Omit<Omit<Omit<import("@base-ui/react/slider").SliderTrackProps, "ref"> & React.RefAttributes<HTMLDivElement>, "ref">, "size"> & {
18
+ size?: import("./sizing.js").ComponentSize;
19
+ } & React.RefAttributes<HTMLDivElement>>;
20
+ Indicator: React.ForwardRefExoticComponent<Omit<Omit<Omit<import("@base-ui/react/slider").SliderIndicatorProps, "ref"> & React.RefAttributes<HTMLDivElement>, "ref">, "size"> & {
21
+ size?: import("./sizing.js").ComponentSize;
22
+ } & React.RefAttributes<HTMLDivElement>>;
23
+ Thumb: React.ForwardRefExoticComponent<Omit<Omit<Omit<import("@base-ui/react/slider").SliderThumbProps, "ref"> & React.RefAttributes<HTMLDivElement>, "ref">, "size"> & {
24
+ size?: import("./sizing.js").ComponentSize;
25
+ } & React.RefAttributes<HTMLDivElement>>;
26
+ };
27
+ export { SliderRoot };
28
+ export declare const SliderControl: React.ForwardRefExoticComponent<Omit<Omit<Omit<import("@base-ui/react/slider").SliderControlProps, "ref"> & React.RefAttributes<HTMLDivElement>, "ref">, "size"> & {
29
+ size?: import("./sizing.js").ComponentSize;
30
+ } & React.RefAttributes<HTMLDivElement>>, SliderIndicator: React.ForwardRefExoticComponent<Omit<Omit<Omit<import("@base-ui/react/slider").SliderIndicatorProps, "ref"> & React.RefAttributes<HTMLDivElement>, "ref">, "size"> & {
31
+ size?: import("./sizing.js").ComponentSize;
32
+ } & React.RefAttributes<HTMLDivElement>>, SliderLabel: React.ForwardRefExoticComponent<Omit<Omit<Omit<import("@base-ui/react/slider").SliderLabelProps, "ref"> & React.RefAttributes<HTMLDivElement>, "ref">, "size"> & {
33
+ size?: import("./sizing.js").ComponentSize;
34
+ } & React.RefAttributes<HTMLDivElement>>, SliderThumb: React.ForwardRefExoticComponent<Omit<Omit<Omit<import("@base-ui/react/slider").SliderThumbProps, "ref"> & React.RefAttributes<HTMLDivElement>, "ref">, "size"> & {
35
+ size?: import("./sizing.js").ComponentSize;
36
+ } & React.RefAttributes<HTMLDivElement>>, SliderTrack: React.ForwardRefExoticComponent<Omit<Omit<Omit<import("@base-ui/react/slider").SliderTrackProps, "ref"> & React.RefAttributes<HTMLDivElement>, "ref">, "size"> & {
37
+ size?: import("./sizing.js").ComponentSize;
38
+ } & React.RefAttributes<HTMLDivElement>>, SliderValue: React.ForwardRefExoticComponent<Omit<Omit<Omit<import("@base-ui/react/slider").SliderValueProps, "ref"> & React.RefAttributes<HTMLOutputElement>, "ref">, "size"> & {
39
+ size?: import("./sizing.js").ComponentSize;
40
+ } & React.RefAttributes<HTMLOutputElement>>;
package/dist/slider.js ADDED
@@ -0,0 +1,27 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { Slider as BaseSlider } from '@base-ui/react/slider';
4
+ import { part, skin } from './parts.js';
5
+ import { useResetValue, useRootRef } from './form-state.js';
6
+ function SliderRoot({ value, defaultValue, onValueChange, ref, className, form, thumbAlignment = 'edge', ...props }) {
7
+ const [element, attach] = useRootRef(ref);
8
+ const [selected, setSelected] = useResetValue(value, (defaultValue ?? props.min ?? 0), element, form);
9
+ return (_jsx(BaseSlider.Root, { ...props, form: form, ref: attach, value: selected, thumbAlignment: thumbAlignment, className: skin('pui-slider', className), onValueChange: (next, event) => {
10
+ onValueChange?.(next, event);
11
+ if (value === undefined && !event.isCanceled)
12
+ setSelected(next);
13
+ } }));
14
+ }
15
+ export const Slider = {
16
+ ...BaseSlider,
17
+ Root: SliderRoot,
18
+ Label: /* @__PURE__ */ part(BaseSlider.Label, 'pui-slider-label'),
19
+ Value: /* @__PURE__ */ part(BaseSlider.Value, 'pui-slider-value'),
20
+ Control: /* @__PURE__ */ part(BaseSlider.Control, 'pui-slider-control'),
21
+ Track: /* @__PURE__ */ part(BaseSlider.Track, 'pui-slider-track'),
22
+ Indicator: /* @__PURE__ */ part(BaseSlider.Indicator, 'pui-slider-indicator'),
23
+ Thumb: /* @__PURE__ */ part(BaseSlider.Thumb, 'pui-slider-thumb'),
24
+ };
25
+ // Flat names for React Server Components, which cannot dot into client exports.
26
+ export { SliderRoot };
27
+ export const { Control: SliderControl, Indicator: SliderIndicator, Label: SliderLabel, Thumb: SliderThumb, Track: SliderTrack, Value: SliderValue, } = Slider;
@@ -0,0 +1,41 @@
1
+ import * as React from 'react';
2
+ import type { ComponentSizeAlias } from './sizing.js';
3
+ export type SparklineTrend = 'auto' | 'up' | 'down' | 'flat' | 'neutral';
4
+ export type SparklineProps = Omit<React.ComponentPropsWithoutRef<'svg'>, 'children' | 'role' | 'aria-label'> & {
5
+ /** Values in order. A missing value leaves a gap. */
6
+ data: readonly (number | null | undefined)[];
7
+ /** What the line shows and how it moved, such as "KOSPI, 30 days, up 2.3%". The
8
+ * line is an image; this is its name. */
9
+ label: string;
10
+ /** 24, 32 or 48px tall. Set --sparkline-height for another height. */
11
+ size?: ComponentSizeAlias;
12
+ /** A reference line: a value, the first value, or none. */
13
+ baseline?: number | 'first' | 'none';
14
+ /** Marks the last value with a dot. */
15
+ marker?: boolean;
16
+ /** The line's color. auto compares the last value with the baseline, or with the
17
+ * first value when there is none. */
18
+ trend?: SparklineTrend;
19
+ /** For measures where a fall is good: the colors swap. */
20
+ lowerIsBetter?: boolean;
21
+ };
22
+ /** A small trend line for cards and table cells: no axes, legend or tooltip. Use Chart
23
+ * when people need to read values. */
24
+ export declare const Sparkline: React.ForwardRefExoticComponent<Omit<Omit<React.SVGProps<SVGSVGElement>, "ref">, "children" | "role" | "aria-label"> & {
25
+ /** Values in order. A missing value leaves a gap. */
26
+ data: readonly (number | null | undefined)[];
27
+ /** What the line shows and how it moved, such as "KOSPI, 30 days, up 2.3%". The
28
+ * line is an image; this is its name. */
29
+ label: string;
30
+ /** 24, 32 or 48px tall. Set --sparkline-height for another height. */
31
+ size?: ComponentSizeAlias;
32
+ /** A reference line: a value, the first value, or none. */
33
+ baseline?: number | "first" | "none";
34
+ /** Marks the last value with a dot. */
35
+ marker?: boolean;
36
+ /** The line's color. auto compares the last value with the baseline, or with the
37
+ * first value when there is none. */
38
+ trend?: SparklineTrend;
39
+ /** For measures where a fall is good: the colors swap. */
40
+ lowerIsBetter?: boolean;
41
+ } & React.RefAttributes<SVGSVGElement>>;
@@ -0,0 +1,50 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import * as React from 'react';
4
+ import { cx, sizeName } from './parts.js';
5
+ const finite = (value) => typeof value === 'number' && Number.isFinite(value);
6
+ /** A small trend line for cards and table cells: no axes, legend or tooltip. Use Chart
7
+ * when people need to read values. */
8
+ export const Sparkline = /* @__PURE__ */ React.forwardRef(function Sparkline({ data, label, size, baseline = 'none', marker = true, trend = 'auto', lowerIsBetter = false, className, ...props }, ref) {
9
+ const values = data.filter(finite);
10
+ const first = values[0];
11
+ const last = values[values.length - 1];
12
+ const reference = baseline === 'first' ? first : baseline === 'none' ? undefined : baseline;
13
+ const bounds = finite(reference) ? [...values, reference] : values;
14
+ const min = Math.min(...bounds);
15
+ const max = Math.max(...bounds);
16
+ const span = max - min || 1;
17
+ // The line keeps clear of the edges by a tenth of the height.
18
+ const y = (value) => 95 - ((value - min) / span) * 90;
19
+ const x = (index) => data.length > 1 ? (index / (data.length - 1)) * 100 : 50;
20
+ let path = '';
21
+ let pen = false;
22
+ data.forEach((value, index) => {
23
+ if (!finite(value))
24
+ return void (pen = false);
25
+ path += `${pen ? 'L' : 'M'}${x(index)} ${y(value)}`;
26
+ pen = true;
27
+ });
28
+ const from = finite(reference) ? reference : first;
29
+ const way = trend !== 'auto'
30
+ ? trend
31
+ : !finite(last) || !finite(from)
32
+ ? 'neutral'
33
+ : last > from
34
+ ? 'up'
35
+ : last < from
36
+ ? 'down'
37
+ : 'flat';
38
+ const tone = lowerIsBetter && way === 'up'
39
+ ? 'down'
40
+ : lowerIsBetter && way === 'down'
41
+ ? 'up'
42
+ : way;
43
+ let end = data.length - 1;
44
+ while (end >= 0 && !finite(data[end]))
45
+ end--;
46
+ return (_jsxs("svg", { ...props, ref: ref, role: 'img', "aria-label": label, className: cx('pui-sparkline', className), "data-size": sizeName(size), "data-tone": tone, viewBox: '0 0 100 100', preserveAspectRatio: 'none', focusable: 'false', children: [finite(reference) && (_jsx("path", { className: 'pui-sparkline-baseline', d: `M0 ${y(reference)}H100`, vectorEffect: 'non-scaling-stroke' })), _jsx("path", { className: 'pui-sparkline-line', d: path, vectorEffect: 'non-scaling-stroke' }), marker && end >= 0 && (
47
+ // A zero-length segment with a round cap stays a circle however the
48
+ // line stretches.
49
+ _jsx("path", { className: 'pui-sparkline-marker', d: `M${x(end)} ${y(data[end])}h0`, vectorEffect: 'non-scaling-stroke' }))] }));
50
+ });
@@ -0,0 +1,13 @@
1
+ import * as React from 'react';
2
+ import { type ComponentSizeAlias } from './sizing.js';
3
+ export type SpinnerProps = Omit<React.ComponentPropsWithoutRef<'span'>, 'children'> & {
4
+ label?: string;
5
+ decorative?: boolean;
6
+ size?: ComponentSizeAlias;
7
+ };
8
+ /** Use decorative within a loading region that already owns the announcement. */
9
+ export declare const Spinner: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref">, "children"> & {
10
+ label?: string;
11
+ decorative?: boolean;
12
+ size?: ComponentSizeAlias;
13
+ } & React.RefAttributes<HTMLSpanElement>>;
@@ -0,0 +1,10 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import * as React from 'react';
4
+ import { useComponentSize } from './sizing.js';
5
+ import { sizeName, cx } from './parts.js';
6
+ /** Use decorative within a loading region that already owns the announcement. */
7
+ export const Spinner = /* @__PURE__ */ React.forwardRef(function Spinner({ label = 'Loading', decorative = false, size, className, ...props }, ref) {
8
+ const scheme = useComponentSize(size);
9
+ return (_jsxs("span", { ...props, ref: ref, className: cx('pui-spinner', className), "data-size": sizeName(size), "data-ui-size": scheme, role: decorative ? undefined : 'status', "aria-hidden": decorative || undefined, children: [_jsxs("svg", { viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor', strokeWidth: '2', "aria-hidden": 'true', children: [_jsx("circle", { cx: '12', cy: '12', r: '9', opacity: '.2' }), _jsx("path", { d: 'M12 3a9 9 0 0 1 9 9', strokeLinecap: 'round' })] }), !decorative && _jsx("span", { className: 'pui-feedback-sr', children: label })] }));
10
+ });