@surflane/ui 0.11.0 → 0.13.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 (137) hide show
  1. package/dist/alert-dialog.d.ts +25 -7
  2. package/dist/alert-dialog.js +9 -4
  3. package/dist/app-shell.d.ts +10 -0
  4. package/dist/app-shell.js +7 -1
  5. package/dist/autocomplete.d.ts +2 -6
  6. package/dist/avatar.d.ts +7 -7
  7. package/dist/avatar.js +2 -2
  8. package/dist/bar-list.d.ts +31 -0
  9. package/dist/bar-list.js +31 -0
  10. package/dist/bottom-navigation.d.ts +6 -2
  11. package/dist/bottom-navigation.js +2 -2
  12. package/dist/button.d.ts +6 -11
  13. package/dist/button.js +8 -8
  14. package/dist/card.d.ts +15 -10
  15. package/dist/card.js +7 -2
  16. package/dist/chart.d.ts +58 -3
  17. package/dist/chart.js +330 -48
  18. package/dist/choice.d.ts +2 -2
  19. package/dist/class-names.d.ts +0 -4
  20. package/dist/class-names.js +0 -14
  21. package/dist/code.d.ts +19 -7
  22. package/dist/code.js +32 -38
  23. package/dist/combobox.d.ts +2 -8
  24. package/dist/combobox.js +2 -2
  25. package/dist/context-menu.d.ts +2 -8
  26. package/dist/context-menu.js +2 -2
  27. package/dist/css/bar-list.css +9 -0
  28. package/dist/css/chart.css +2 -0
  29. package/dist/css/dashboard.css +20 -0
  30. package/dist/css/rules/alert-dialog.css +8 -2
  31. package/dist/css/rules/app-shell.css +57 -10
  32. package/dist/css/rules/bar-list.css +101 -0
  33. package/dist/css/rules/bar.css +5 -12
  34. package/dist/css/rules/bottom-navigation.css +21 -2
  35. package/dist/css/rules/breadcrumbs.css +0 -6
  36. package/dist/css/rules/button.css +4 -12
  37. package/dist/css/rules/card.css +19 -0
  38. package/dist/css/rules/chart.css +87 -8
  39. package/dist/css/rules/choice.css +26 -2
  40. package/dist/css/rules/combobox.css +17 -16
  41. package/dist/css/rules/dashboard.css +118 -0
  42. package/dist/css/rules/date-picker.css +50 -27
  43. package/dist/css/rules/dialog.css +47 -7
  44. package/dist/css/rules/disclosure.css +17 -3
  45. package/dist/css/rules/field-control.css +9 -6
  46. package/dist/css/rules/file-upload.css +9 -5
  47. package/dist/css/rules/filter-bar.css +32 -2
  48. package/dist/css/rules/gauge.css +2 -2
  49. package/dist/css/rules/icon.css +0 -5
  50. package/dist/css/rules/input-group.css +23 -8
  51. package/dist/css/rules/link.css +0 -6
  52. package/dist/css/rules/menu.css +5 -2
  53. package/dist/css/rules/menubar.css +1 -1
  54. package/dist/css/rules/navigation-menu.css +31 -26
  55. package/dist/css/rules/number-field.css +8 -1
  56. package/dist/css/rules/otp-field.css +13 -3
  57. package/dist/css/rules/page-header.css +10 -0
  58. package/dist/css/rules/panel.css +59 -10
  59. package/dist/css/rules/popup.css +50 -0
  60. package/dist/css/rules/preview-card.css +0 -21
  61. package/dist/css/rules/scroll-area.css +20 -1
  62. package/dist/css/rules/select.css +29 -2
  63. package/dist/css/rules/sizing.css +25 -3
  64. package/dist/css/rules/skeleton.css +1 -1
  65. package/dist/css/rules/slider.css +16 -8
  66. package/dist/css/rules/spinner.css +1 -1
  67. package/dist/css/rules/stat.css +66 -0
  68. package/dist/css/rules/tabs.css +14 -6
  69. package/dist/css/rules/textarea.css +28 -0
  70. package/dist/css/rules/time-range-picker.css +14 -0
  71. package/dist/css/rules/toast.css +3 -1
  72. package/dist/css/rules/toggle.css +10 -3
  73. package/dist/css/rules/toolbar.css +10 -3
  74. package/dist/css/rules/tree.css +29 -4
  75. package/dist/css/styles.css +3 -0
  76. package/dist/css/time-range-picker.css +14 -0
  77. package/dist/dashboard.d.ts +58 -0
  78. package/dist/dashboard.js +60 -0
  79. package/dist/date-picker.d.ts +32 -3
  80. package/dist/date-picker.js +43 -4
  81. package/dist/dialog.d.ts +25 -7
  82. package/dist/dialog.js +9 -4
  83. package/dist/drawer.d.ts +10 -2
  84. package/dist/drawer.js +6 -3
  85. package/dist/icon.d.ts +15 -5
  86. package/dist/icon.js +16 -3
  87. package/dist/index.d.ts +9 -6
  88. package/dist/index.js +7 -4
  89. package/dist/inline-message.d.ts +2 -2
  90. package/dist/inline-message.js +7 -2
  91. package/dist/input.d.ts +2 -2
  92. package/dist/layout.d.ts +1 -3
  93. package/dist/layout.js +2 -2
  94. package/dist/native-select.d.ts +2 -2
  95. package/dist/navigation-menu.d.ts +16 -0
  96. package/dist/navigation-menu.js +6 -1
  97. package/dist/page-header.d.ts +10 -2
  98. package/dist/page-header.js +3 -3
  99. package/dist/panel.d.ts +6 -3
  100. package/dist/panel.js +2 -2
  101. package/dist/parts.d.ts +7 -3
  102. package/dist/parts.js +12 -4
  103. package/dist/popover.d.ts +6 -6
  104. package/dist/popover.js +3 -2
  105. package/dist/preview-card.d.ts +2 -8
  106. package/dist/preview-card.js +2 -2
  107. package/dist/select.d.ts +38 -8
  108. package/dist/select.js +110 -22
  109. package/dist/sheet.d.ts +10 -2
  110. package/dist/sheet.js +6 -3
  111. package/dist/size.d.ts +8 -6
  112. package/dist/size.js +2 -7
  113. package/dist/sizing.d.ts +13 -6
  114. package/dist/sizing.js +13 -4
  115. package/dist/sparkline.d.ts +2 -2
  116. package/dist/sparkline.js +2 -2
  117. package/dist/spinner.d.ts +2 -2
  118. package/dist/spinner.js +2 -2
  119. package/dist/stat.d.ts +24 -0
  120. package/dist/stat.js +15 -1
  121. package/dist/table.d.ts +12 -4
  122. package/dist/table.js +8 -3
  123. package/dist/textarea.d.ts +6 -3
  124. package/dist/textarea.js +2 -2
  125. package/dist/time-range-picker.d.ts +42 -0
  126. package/dist/time-range-picker.js +69 -0
  127. package/dist/toggle.d.ts +2 -2
  128. package/dist/toggle.js +2 -2
  129. package/dist/toolbar.d.ts +11 -10
  130. package/dist/toolbar.js +23 -1
  131. package/dist/tooltip.d.ts +1 -3
  132. package/dist/tooltip.js +4 -2
  133. package/dist/tree.d.ts +1 -3
  134. package/dist/tree.js +2 -2
  135. package/dist/typography.d.ts +10 -3
  136. package/dist/typography.js +4 -3
  137. package/package.json +18 -3
@@ -1,35 +1,53 @@
1
1
  import * as React from 'react';
2
- import { type ComponentSizeAlias } from './sizing.js';
2
+ import { type ComponentSize } from './sizing.js';
3
3
  import { AlertDialog as BaseAlertDialog } from '@base-ui/react/alert-dialog';
4
4
  import { DialogFooter, DialogHeader } from './dialog.js';
5
5
  declare const AlertDialogContent: ({ size, className, focusBoundaryLabel, ref, ...props }: React.ComponentPropsWithoutRef<typeof BaseAlertDialog.Popup> & {
6
6
  /** Width and density; an alert dialog is small unless set. */
7
- size?: ComponentSizeAlias;
7
+ size?: ComponentSize;
8
8
  focusBoundaryLabel?: string;
9
9
  } & {
10
10
  ref?: React.Ref<HTMLDivElement>;
11
11
  }) => React.JSX.Element;
12
+ declare const AlertDialogTitle: ({ ref, ...props }: Omit<Omit<Omit<import("@base-ui/react/alert-dialog").AlertDialogTitleProps, "ref"> & React.RefAttributes<HTMLHeadingElement>, "ref">, "size"> & {
13
+ size?: ComponentSize;
14
+ } & {
15
+ ref?: React.Ref<HTMLHeadingElement> | undefined;
16
+ }) => React.JSX.Element;
17
+ declare const AlertDialogDescription: ({ ref, ...props }: Omit<Omit<Omit<import("@base-ui/react/alert-dialog").AlertDialogDescriptionProps, "ref"> & React.RefAttributes<HTMLParagraphElement>, "ref">, "size"> & {
18
+ size?: ComponentSize;
19
+ } & {
20
+ ref?: React.Ref<HTMLParagraphElement> | undefined;
21
+ }) => React.JSX.Element;
12
22
  export declare const AlertDialog: {
13
23
  Content: ({ size, className, focusBoundaryLabel, ref, ...props }: React.ComponentPropsWithoutRef<typeof BaseAlertDialog.Popup> & {
14
24
  /** Width and density; an alert dialog is small unless set. */
15
- size?: ComponentSizeAlias;
25
+ size?: ComponentSize;
16
26
  focusBoundaryLabel?: string;
17
27
  } & {
18
28
  ref?: React.Ref<HTMLDivElement>;
19
29
  }) => React.JSX.Element;
20
30
  Header: typeof DialogHeader;
21
31
  Footer: typeof DialogFooter;
32
+ Title: ({ ref, ...props }: Omit<Omit<Omit<import("@base-ui/react/alert-dialog").AlertDialogTitleProps, "ref"> & React.RefAttributes<HTMLHeadingElement>, "ref">, "size"> & {
33
+ size?: ComponentSize;
34
+ } & {
35
+ ref?: React.Ref<HTMLHeadingElement> | undefined;
36
+ }) => React.JSX.Element;
37
+ Description: ({ ref, ...props }: Omit<Omit<Omit<import("@base-ui/react/alert-dialog").AlertDialogDescriptionProps, "ref"> & React.RefAttributes<HTMLParagraphElement>, "ref">, "size"> & {
38
+ size?: ComponentSize;
39
+ } & {
40
+ ref?: React.Ref<HTMLParagraphElement> | undefined;
41
+ }) => React.JSX.Element;
22
42
  Root: typeof BaseAlertDialog.Root;
23
43
  Backdrop: React.ForwardRefExoticComponent<Omit<import("@base-ui/react/alert-dialog").AlertDialogBackdropProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
24
44
  Close: React.ForwardRefExoticComponent<Omit<import("@base-ui/react/alert-dialog").AlertDialogCloseProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
25
- Description: React.ForwardRefExoticComponent<Omit<import("@base-ui/react/alert-dialog").AlertDialogDescriptionProps, "ref"> & React.RefAttributes<HTMLParagraphElement>>;
26
45
  Popup: React.ForwardRefExoticComponent<Omit<import("@base-ui/react/alert-dialog").AlertDialogPopupProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
27
46
  Portal: React.ForwardRefExoticComponent<Omit<import("@base-ui/react/alert-dialog").AlertDialogPortalProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
28
- Title: React.ForwardRefExoticComponent<Omit<import("@base-ui/react/alert-dialog").AlertDialogTitleProps, "ref"> & React.RefAttributes<HTMLHeadingElement>>;
29
47
  Trigger: BaseAlertDialog.Trigger;
30
48
  Viewport: React.ForwardRefExoticComponent<Omit<import("@base-ui/react/alert-dialog").AlertDialogViewportProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
31
49
  Handle: typeof BaseAlertDialog.Handle;
32
50
  createHandle: typeof BaseAlertDialog.createHandle;
33
51
  };
34
- export { AlertDialogContent };
35
- export declare const AlertDialogBackdrop: React.ForwardRefExoticComponent<Omit<import("@base-ui/react/alert-dialog").AlertDialogBackdropProps, "ref"> & React.RefAttributes<HTMLDivElement>>, AlertDialogClose: React.ForwardRefExoticComponent<Omit<import("@base-ui/react/alert-dialog").AlertDialogCloseProps, "ref"> & React.RefAttributes<HTMLButtonElement>>, AlertDialogDescription: React.ForwardRefExoticComponent<Omit<import("@base-ui/react/alert-dialog").AlertDialogDescriptionProps, "ref"> & React.RefAttributes<HTMLParagraphElement>>, AlertDialogHandle: typeof BaseAlertDialog.Handle, AlertDialogPopup: React.ForwardRefExoticComponent<Omit<import("@base-ui/react/alert-dialog").AlertDialogPopupProps, "ref"> & React.RefAttributes<HTMLDivElement>>, AlertDialogPortal: React.ForwardRefExoticComponent<Omit<import("@base-ui/react/alert-dialog").AlertDialogPortalProps, "ref"> & React.RefAttributes<HTMLDivElement>>, AlertDialogRoot: typeof BaseAlertDialog.Root, AlertDialogTitle: React.ForwardRefExoticComponent<Omit<import("@base-ui/react/alert-dialog").AlertDialogTitleProps, "ref"> & React.RefAttributes<HTMLHeadingElement>>, AlertDialogTrigger: BaseAlertDialog.Trigger, AlertDialogViewport: React.ForwardRefExoticComponent<Omit<import("@base-ui/react/alert-dialog").AlertDialogViewportProps, "ref"> & React.RefAttributes<HTMLDivElement>>, AlertDialogHeader: typeof DialogHeader, AlertDialogFooter: typeof DialogFooter;
52
+ export { AlertDialogContent, AlertDialogTitle, AlertDialogDescription };
53
+ export declare const AlertDialogBackdrop: React.ForwardRefExoticComponent<Omit<import("@base-ui/react/alert-dialog").AlertDialogBackdropProps, "ref"> & React.RefAttributes<HTMLDivElement>>, AlertDialogClose: React.ForwardRefExoticComponent<Omit<import("@base-ui/react/alert-dialog").AlertDialogCloseProps, "ref"> & React.RefAttributes<HTMLButtonElement>>, AlertDialogHandle: typeof BaseAlertDialog.Handle, AlertDialogPopup: React.ForwardRefExoticComponent<Omit<import("@base-ui/react/alert-dialog").AlertDialogPopupProps, "ref"> & React.RefAttributes<HTMLDivElement>>, AlertDialogPortal: React.ForwardRefExoticComponent<Omit<import("@base-ui/react/alert-dialog").AlertDialogPortalProps, "ref"> & React.RefAttributes<HTMLDivElement>>, AlertDialogRoot: typeof BaseAlertDialog.Root, AlertDialogTrigger: BaseAlertDialog.Trigger, AlertDialogViewport: React.ForwardRefExoticComponent<Omit<import("@base-ui/react/alert-dialog").AlertDialogViewportProps, "ref"> & React.RefAttributes<HTMLDivElement>>, AlertDialogHeader: typeof DialogHeader, AlertDialogFooter: typeof DialogFooter;
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { sizeName, skin } from './parts.js';
3
+ import { part, skin, usePortalDirection } from './parts.js';
4
4
  import { useDialogFocusBoundary } from './dialog-focus.js';
5
5
  import { useComponentSize } from './sizing.js';
6
6
  import { AlertDialog as BaseAlertDialog } from '@base-ui/react/alert-dialog';
@@ -8,14 +8,19 @@ import { DialogFooter, DialogHeader } from './dialog.js';
8
8
  const AlertDialogContent = function AlertDialogContent({ size, className, focusBoundaryLabel = 'Continue dialog navigation', ref, ...props }) {
9
9
  const scheme = useComponentSize(size);
10
10
  const portalRef = useDialogFocusBoundary(focusBoundaryLabel);
11
- return (_jsxs(BaseAlertDialog.Portal, { ref: portalRef, children: [_jsx(BaseAlertDialog.Backdrop, { className: 'surf-dialog-backdrop' }), _jsx(BaseAlertDialog.Popup, { "data-ui-size": scheme, "data-size": sizeName(size), ...props, ref: ref, className: skin('surf-dialog-popup surf-dialog-content surf-confirm-content', className) })] }));
11
+ const dir = usePortalDirection();
12
+ return (_jsxs(BaseAlertDialog.Portal, { ref: portalRef, children: [_jsx(BaseAlertDialog.Backdrop, { className: 'surf-dialog-backdrop' }), _jsx(BaseAlertDialog.Popup, { dir: dir, "data-ui-size": scheme, "data-size": size, ...props, ref: ref, className: skin('surf-dialog-popup surf-dialog-content surf-confirm-content', className) })] }));
12
13
  };
14
+ const AlertDialogTitle = /* @__PURE__ */ part(BaseAlertDialog.Title, 'surf-dialog-title');
15
+ const AlertDialogDescription = /* @__PURE__ */ part(BaseAlertDialog.Description, 'surf-dialog-description');
13
16
  export const AlertDialog = {
14
17
  ...BaseAlertDialog,
15
18
  Content: AlertDialogContent,
16
19
  Header: DialogHeader,
17
20
  Footer: DialogFooter,
21
+ Title: AlertDialogTitle,
22
+ Description: AlertDialogDescription,
18
23
  };
19
24
  // Flat names for React Server Components, which cannot dot into client exports.
20
- export { AlertDialogContent };
21
- export const { Backdrop: AlertDialogBackdrop, Close: AlertDialogClose, Description: AlertDialogDescription, Handle: AlertDialogHandle, Popup: AlertDialogPopup, Portal: AlertDialogPortal, Root: AlertDialogRoot, Title: AlertDialogTitle, Trigger: AlertDialogTrigger, Viewport: AlertDialogViewport, Header: AlertDialogHeader, Footer: AlertDialogFooter, } = AlertDialog;
25
+ export { AlertDialogContent, AlertDialogTitle, AlertDialogDescription };
26
+ export const { Backdrop: AlertDialogBackdrop, Close: AlertDialogClose, Handle: AlertDialogHandle, Popup: AlertDialogPopup, Portal: AlertDialogPortal, Root: AlertDialogRoot, Trigger: AlertDialogTrigger, Viewport: AlertDialogViewport, Header: AlertDialogHeader, Footer: AlertDialogFooter, } = AlertDialog;
@@ -25,6 +25,11 @@ export type AppShellSidebarToggleProps = Omit<ButtonProps, 'children'> & {
25
25
  labels?: Partial<AppShellSidebarToggleLabels>;
26
26
  children?: React.ReactNode;
27
27
  };
28
+ export type AppShellMenuTriggerProps = Omit<ButtonProps, 'children'> & {
29
+ /** The button's name. Say what it opens. */
30
+ label?: string;
31
+ children?: React.ReactNode;
32
+ };
28
33
  export type AppShellBrandProps = Omit<useRender.ComponentProps<'div'>, 'ref' | 'children'> & {
29
34
  /** The product mark, about 24px. It is decorative: the name names the brand. */
30
35
  mark?: React.ReactNode;
@@ -55,6 +60,9 @@ export declare const AppShell: {
55
60
  SidebarToggle: ({ labels, className, children, onClick, ref, ...props }: AppShellSidebarToggleProps & {
56
61
  ref?: React.Ref<HTMLButtonElement>;
57
62
  }) => React.JSX.Element;
63
+ MenuTrigger: ({ label, className, children, ref, ...props }: AppShellMenuTriggerProps & {
64
+ ref?: React.Ref<HTMLButtonElement>;
65
+ }) => React.JSX.Element;
58
66
  Brand: ({ mark, name, description, render, className, ref, ...props }: AppShellBrandProps & {
59
67
  ref?: React.Ref<HTMLDivElement>;
60
68
  }) => React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
@@ -85,6 +93,8 @@ export declare const AppShellRoot: ({ collapsed, defaultCollapsed, onCollapsedCh
85
93
  ref?: React.Ref<HTMLElement>;
86
94
  }) => React.JSX.Element, AppShellSidebarToggle: ({ labels, className, children, onClick, ref, ...props }: AppShellSidebarToggleProps & {
87
95
  ref?: React.Ref<HTMLButtonElement>;
96
+ }) => React.JSX.Element, AppShellMenuTrigger: ({ label, className, children, ref, ...props }: AppShellMenuTriggerProps & {
97
+ ref?: React.Ref<HTMLButtonElement>;
88
98
  }) => React.JSX.Element, AppShellBrand: ({ mark, name, description, render, className, ref, ...props }: AppShellBrandProps & {
89
99
  ref?: React.Ref<HTMLDivElement>;
90
100
  }) => React.ReactElement<unknown, string | React.JSXElementConstructor<any>>, AppShellNav: ({ label, className, children, ref, ...props }: AppShellNavProps & {
package/dist/app-shell.js CHANGED
@@ -75,6 +75,11 @@ const SidebarToggle = function AppShellSidebarToggle({ labels, className, childr
75
75
  shell.setCollapsed(!shell.collapsed);
76
76
  }, children: children ?? _jsx(Icon, { name: 'sidebar' }) }) }));
77
77
  };
78
+ /** Opens the caller's navigation, such as a Sheet, where the sidebar is hidden: at
79
+ * 760px and narrower it shows at the header's end, and above that it is hidden. */
80
+ const MenuTrigger = function AppShellMenuTrigger({ label = 'Open navigation', className, children, ref, ...props }) {
81
+ return (_jsx(Button, { variant: 'ghost', size: 'icon', ...props, ref: ref, "aria-label": label, className: skin('surf-app-shell-menu-trigger', className), children: children ?? _jsx(Icon, { name: 'menu', decorative: true }) }));
82
+ };
78
83
  const Header = function AppShellHeader({ className, ref, ...props }) {
79
84
  return (_jsx("div", { ...props, ref: ref, className: cx('surf-app-shell-header', className) }));
80
85
  };
@@ -144,6 +149,7 @@ export const AppShell = {
144
149
  Header,
145
150
  Sidebar,
146
151
  SidebarToggle,
152
+ MenuTrigger,
147
153
  Brand,
148
154
  Nav,
149
155
  Content,
@@ -153,4 +159,4 @@ export const AppShell = {
153
159
  Link,
154
160
  };
155
161
  // Flat names for React Server Components, which cannot dot into client exports.
156
- export const { Root: AppShellRoot, Header: AppShellHeader, Sidebar: AppShellSidebar, SidebarToggle: AppShellSidebarToggle, Brand: AppShellBrand, Nav: AppShellNav, Content: AppShellContent, Page: AppShellPage, Footer: AppShellFooter, Label: AppShellLabel, Link: AppShellLink, } = AppShell;
162
+ export const { Root: AppShellRoot, Header: AppShellHeader, Sidebar: AppShellSidebar, SidebarToggle: AppShellSidebarToggle, MenuTrigger: AppShellMenuTrigger, Brand: AppShellBrand, Nav: AppShellNav, Content: AppShellContent, Page: AppShellPage, Footer: AppShellFooter, Label: AppShellLabel, Link: AppShellLink, } = AppShell;
@@ -4,9 +4,7 @@ declare const AutocompleteRoot: typeof BaseAutocomplete.Root;
4
4
  export declare const Autocomplete: {
5
5
  Root: typeof BaseAutocomplete.Root;
6
6
  Portal: React.ForwardRefExoticComponent<Omit<import("@base-ui/react/autocomplete").AutocompletePortalProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
7
- Content: ({ side, align, sideOffset, collisionPadding, positionerProps, ref, ...props }: React.ComponentPropsWithoutRef<typeof BaseAutocomplete.Popup> & Pick<React.ComponentPropsWithoutRef<typeof BaseAutocomplete.Positioner>, "side" | "align" | "sideOffset" | "collisionPadding"> & {
8
- positionerProps?: React.ComponentPropsWithoutRef<typeof BaseAutocomplete.Positioner>;
9
- } & {
7
+ Content: ({ side, align, sideOffset, collisionPadding, ref, ...props }: React.ComponentPropsWithoutRef<typeof BaseAutocomplete.Popup> & Pick<React.ComponentPropsWithoutRef<typeof BaseAutocomplete.Positioner>, "side" | "align" | "sideOffset" | "collisionPadding"> & {
10
8
  ref?: React.Ref<HTMLDivElement>;
11
9
  }) => React.JSX.Element;
12
10
  Popup: ({ ref, ...props }: Omit<Omit<Omit<import("@base-ui/react/autocomplete").AutocompletePopupProps, "ref"> & React.RefAttributes<HTMLDivElement>, "ref">, "size"> & {
@@ -128,8 +126,6 @@ export declare const AutocompleteArrow: React.ForwardRefExoticComponent<Omit<imp
128
126
  ref?: React.Ref<HTMLDivElement> | undefined;
129
127
  }) => React.JSX.Element, AutocompleteTrigger: ({ className, children, ref, ...props }: React.ComponentPropsWithoutRef<typeof BaseAutocomplete.Trigger> & {
130
128
  ref?: React.Ref<HTMLButtonElement>;
131
- }) => React.JSX.Element, AutocompleteValue: typeof BaseAutocomplete.Value, AutocompleteContent: ({ side, align, sideOffset, collisionPadding, positionerProps, ref, ...props }: React.ComponentPropsWithoutRef<typeof BaseAutocomplete.Popup> & Pick<React.ComponentPropsWithoutRef<typeof BaseAutocomplete.Positioner>, "side" | "align" | "sideOffset" | "collisionPadding"> & {
132
- positionerProps?: React.ComponentPropsWithoutRef<typeof BaseAutocomplete.Positioner>;
133
- } & {
129
+ }) => React.JSX.Element, AutocompleteValue: typeof BaseAutocomplete.Value, AutocompleteContent: ({ side, align, sideOffset, collisionPadding, ref, ...props }: React.ComponentPropsWithoutRef<typeof BaseAutocomplete.Popup> & Pick<React.ComponentPropsWithoutRef<typeof BaseAutocomplete.Positioner>, "side" | "align" | "sideOffset" | "collisionPadding"> & {
134
130
  ref?: React.Ref<HTMLDivElement>;
135
131
  }) => React.JSX.Element;
package/dist/avatar.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import * as React from 'react';
2
2
  import { Avatar as BaseAvatar } from '@base-ui/react/avatar';
3
- import { type ComponentSizeAlias } from './sizing.js';
3
+ import { type ComponentSize } from './sizing.js';
4
4
  declare const AvatarRoot: ({ size, className, ref, ...props }: React.ComponentPropsWithoutRef<typeof BaseAvatar.Root> & {
5
- size?: ComponentSizeAlias;
5
+ size?: ComponentSize;
6
6
  } & {
7
7
  ref?: React.Ref<React.ComponentRef<typeof BaseAvatar.Root>>;
8
8
  }) => React.JSX.Element;
@@ -11,12 +11,12 @@ declare const AvatarFallback: ({ children, className, ref, ...props }: React.Com
11
11
  }) => React.JSX.Element;
12
12
  export declare const Avatar: {
13
13
  Root: ({ size, className, ref, ...props }: React.ComponentPropsWithoutRef<typeof BaseAvatar.Root> & {
14
- size?: ComponentSizeAlias;
14
+ size?: ComponentSize;
15
15
  } & {
16
16
  ref?: React.Ref<React.ComponentRef<typeof BaseAvatar.Root>>;
17
17
  }) => React.JSX.Element;
18
18
  Status: ({ ref, ...props }: Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref">, "size"> & {
19
- size?: import("./size.js").ComponentSize;
19
+ size?: ComponentSize;
20
20
  } & {
21
21
  ref?: React.Ref<HTMLSpanElement> | undefined;
22
22
  }) => React.JSX.Element;
@@ -24,18 +24,18 @@ export declare const Avatar: {
24
24
  ref?: React.Ref<React.ComponentRef<typeof BaseAvatar.Fallback>>;
25
25
  }) => React.JSX.Element;
26
26
  Image: ({ ref, ...props }: Omit<Omit<Omit<import("@base-ui/react/avatar").AvatarImageProps, "ref"> & React.RefAttributes<HTMLImageElement>, "ref">, "size"> & {
27
- size?: import("./size.js").ComponentSize;
27
+ size?: ComponentSize;
28
28
  } & {
29
29
  ref?: React.Ref<HTMLImageElement> | undefined;
30
30
  }) => React.JSX.Element;
31
31
  };
32
32
  export { AvatarFallback, AvatarRoot };
33
33
  export declare const AvatarImage: ({ ref, ...props }: Omit<Omit<Omit<import("@base-ui/react/avatar").AvatarImageProps, "ref"> & React.RefAttributes<HTMLImageElement>, "ref">, "size"> & {
34
- size?: import("./size.js").ComponentSize;
34
+ size?: ComponentSize;
35
35
  } & {
36
36
  ref?: React.Ref<HTMLImageElement> | undefined;
37
37
  }) => React.JSX.Element, AvatarStatus: ({ ref, ...props }: Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref">, "size"> & {
38
- size?: import("./size.js").ComponentSize;
38
+ size?: ComponentSize;
39
39
  } & {
40
40
  ref?: React.Ref<HTMLSpanElement> | undefined;
41
41
  }) => React.JSX.Element;
package/dist/avatar.js CHANGED
@@ -3,10 +3,10 @@ import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import { Icon } from './icon.js';
4
4
  import { Avatar as BaseAvatar } from '@base-ui/react/avatar';
5
5
  import { useComponentSize } from './sizing.js';
6
- import { sizeName, skin, part } from './parts.js';
6
+ import { skin, part } from './parts.js';
7
7
  const AvatarRoot = function AvatarRoot({ size, className, ref, ...props }) {
8
8
  const scheme = useComponentSize(size);
9
- return (_jsx(BaseAvatar.Root, { ...props, ref: ref, "data-size": sizeName(size), "data-ui-size": scheme, className: skin('surf-avatar', className) }));
9
+ return (_jsx(BaseAvatar.Root, { ...props, ref: ref, "data-size": size, "data-ui-size": scheme, className: skin('surf-avatar', className) }));
10
10
  };
11
11
  const AvatarFallback = function AvatarFallback({ children, className, ref, ...props }) {
12
12
  return (_jsx(BaseAvatar.Fallback, { ...props, ref: ref, className: skin('surf-avatar-fallback', className), children: children ?? _jsx(Icon, { name: 'user' }) }));
@@ -0,0 +1,31 @@
1
+ import * as React from 'react';
2
+ export type BarListItem = {
3
+ id: string;
4
+ /** What the row measures, such as a directory or a project. */
5
+ label: string;
6
+ /** A second, quieter name under the label, such as a path. */
7
+ detail?: string;
8
+ value: number;
9
+ /** The value as written, such as "412 GiB". Defaults to the formatted value. */
10
+ text?: string;
11
+ };
12
+ export type BarListProps = Omit<React.ComponentPropsWithoutRef<'div'>, 'children'> & {
13
+ /** Names the list, such as "Disk used by directory". */
14
+ label: string;
15
+ items: readonly BarListItem[];
16
+ /** The value a full bar stands for. Defaults to the largest value. */
17
+ max?: number;
18
+ /** Orders the rows from the largest value down. Turn it off to keep your order. */
19
+ sorted?: boolean;
20
+ /** The rows shown before the list scrolls inside itself. */
21
+ maxRows?: number;
22
+ /** Writes a value that has no text. */
23
+ formatValue?: (value: number) => string;
24
+ locale?: string;
25
+ };
26
+ /** A ranked list of named values, each with a bar in proportion to the largest, such
27
+ * as disk by directory or tokens by project. Names and values are text; the bars are
28
+ * decoration. */
29
+ export declare const BarList: ({ label, items, max, sorted, maxRows, formatValue, locale, className, style, ref, ...props }: BarListProps & {
30
+ ref?: React.Ref<HTMLDivElement>;
31
+ }) => React.JSX.Element;
@@ -0,0 +1,31 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { cx } from './class-names.js';
3
+ import { missingValue } from './format.js';
4
+ import { ScrollArea } from './scroll-area.js';
5
+ /** A ranked list of named values, each with a bar in proportion to the largest, such
6
+ * as disk by directory or tokens by project. Names and values are text; the bars are
7
+ * decoration. */
8
+ export const BarList = function BarList({ label, items, max, sorted = true, maxRows, formatValue, locale, className, style, ref, ...props }) {
9
+ const rows = sorted ? [...items].sort((a, b) => b.value - a.value) : items;
10
+ const top = max ?? rows.reduce((largest, item) => Math.max(largest, item.value), 0);
11
+ const number = new Intl.NumberFormat(locale);
12
+ // A value that is missing reads as the dash every other number helper writes.
13
+ const write = (value) => !Number.isFinite(value)
14
+ ? missingValue
15
+ : formatValue
16
+ ? formatValue(value)
17
+ : number.format(value);
18
+ const scrolls = maxRows !== undefined && rows.length > maxRows;
19
+ const list = (_jsx("ol", { className: 'surf-bar-list-items', "aria-label": label, children: rows.map((item) => {
20
+ const share = top > 0 && Number.isFinite(item.value)
21
+ ? Math.min(100, Math.max(0, (item.value / top) * 100))
22
+ : 0;
23
+ return (_jsxs("li", { className: 'surf-bar-list-item', children: [_jsxs("span", { className: 'surf-bar-list-label', children: [_jsx("span", { className: 'surf-bar-list-name', title: item.label, children: item.label }), item.detail && (_jsx("span", { className: 'surf-bar-list-detail', title: item.detail, children: item.detail }))] }), _jsx("span", { className: 'surf-bar-list-bar', "aria-hidden": 'true', children: _jsx("span", { className: 'surf-bar-list-fill', style: { inlineSize: `${share}%` } }) }), _jsx("span", { className: 'surf-bar-list-value', children: item.text ?? write(item.value) })] }, item.id));
24
+ }) }));
25
+ return (_jsx("div", { ...props, ref: ref, className: cx('surf-bar-list', className), "data-detail": items.some((item) => item.detail) || undefined, style: scrolls
26
+ ? {
27
+ ...style,
28
+ '--surf-bar-list-rows': maxRows,
29
+ }
30
+ : style, children: scrolls ? (_jsx(ScrollArea, { orientation: 'vertical', label: label, children: list })) : (list) }));
31
+ };
@@ -1,5 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { useRender } from '@base-ui/react/use-render';
3
+ import type { StatusTone } from './status.js';
3
4
  export type BottomNavigationRootProps = React.ComponentPropsWithoutRef<'nav'> & {
4
5
  /** Names the navigation, such as "Primary". */
5
6
  'aria-label': string;
@@ -20,17 +21,20 @@ export type BottomNavigationItemProps = Omit<useRender.ComponentProps<'a'>, 'ref
20
21
  /** What the badge means, read after the label, such as "3 unread". A count reads
21
22
  * as its number without it; a dot needs it. */
22
23
  badgeLabel?: string;
24
+ /** The badge's color, by what it means: danger for what needs action now,
25
+ * caution for what needs a look soon, neutral for news. */
26
+ badgeTone?: StatusTone;
23
27
  };
24
28
  export declare const BottomNavigation: {
25
29
  Root: ({ visible, position, className, children, ref, ...props }: BottomNavigationRootProps & {
26
30
  ref?: React.Ref<HTMLElement>;
27
31
  }) => React.JSX.Element;
28
- Item: ({ icon, label, current, badge, badgeLabel, render, className, ref, ...props }: BottomNavigationItemProps & {
32
+ Item: ({ icon, label, current, badge, badgeLabel, badgeTone, render, className, ref, ...props }: BottomNavigationItemProps & {
29
33
  ref?: React.Ref<HTMLAnchorElement>;
30
34
  }) => React.JSX.Element;
31
35
  };
32
36
  export declare const BottomNavigationRoot: ({ visible, position, className, children, ref, ...props }: BottomNavigationRootProps & {
33
37
  ref?: React.Ref<HTMLElement>;
34
- }) => React.JSX.Element, BottomNavigationItem: ({ icon, label, current, badge, badgeLabel, render, className, ref, ...props }: BottomNavigationItemProps & {
38
+ }) => React.JSX.Element, BottomNavigationItem: ({ icon, label, current, badge, badgeLabel, badgeTone, render, className, ref, ...props }: BottomNavigationItemProps & {
35
39
  ref?: React.Ref<HTMLAnchorElement>;
36
40
  }) => React.JSX.Element;
@@ -9,7 +9,7 @@ const Root = function BottomNavigationRoot({ visible = 'mobile', position = 'fix
9
9
  };
10
10
  /** One destination: an icon above its label. Pass a router's link element as
11
11
  * `render` to keep client navigation. */
12
- const Item = function BottomNavigationItem({ icon, label, current, badge, badgeLabel, render, className, ref, ...props }) {
12
+ const Item = function BottomNavigationItem({ icon, label, current, badge, badgeLabel, badgeTone = 'danger', render, className, ref, ...props }) {
13
13
  const count = typeof badge === 'number' && badge > 0
14
14
  ? badge > 99
15
15
  ? '99+'
@@ -25,7 +25,7 @@ const Item = function BottomNavigationItem({ icon, label, current, badge, badgeL
25
25
  ...props,
26
26
  'aria-current': current ? 'page' : props['aria-current'],
27
27
  className: cx('surf-bottom-nav-item', className),
28
- children: (_jsxs(_Fragment, { children: [_jsxs("span", { className: 'surf-bottom-nav-icon', "aria-hidden": 'true', children: [icon, shown && (_jsx("span", { className: 'surf-bottom-nav-badge', "data-dot": count ? undefined : '', children: count }))] }), _jsx("span", { className: 'surf-bottom-nav-label', children: label }), shown && spoken && (_jsxs("span", { className: 'surf-feedback-sr', children: [", ", spoken] }))] })),
28
+ children: (_jsxs(_Fragment, { children: [_jsxs("span", { className: 'surf-bottom-nav-icon', "aria-hidden": 'true', children: [icon, shown && (_jsx("span", { className: 'surf-bottom-nav-badge', "data-tone": badgeTone, "data-dot": count ? undefined : '', children: count }))] }), _jsx("span", { className: 'surf-bottom-nav-label', children: label }), shown && spoken && (_jsxs("span", { className: 'surf-feedback-sr', children: [", ", spoken] }))] })),
29
29
  },
30
30
  });
31
31
  return _jsx("li", { className: 'surf-bottom-nav-entry', children: link });
package/dist/button.d.ts CHANGED
@@ -1,17 +1,12 @@
1
1
  import * as React from 'react';
2
2
  import { Button as BaseButton } from '@base-ui/react/button';
3
3
  import { useRender } from '@base-ui/react/use-render';
4
- import { type ComponentSizeAlias } from './sizing.js';
5
- /** Visual priority. `default` is deprecated: it is `primary` under its former name, and
6
- * is removed in a later minor. Without a variant a button is `primary`. */
7
- export type ButtonVariant = 'primary' | 'default' | 'secondary' | 'outline' | 'ghost' | 'destructive' | 'link';
8
- /**
9
- * small, default and large set the size scheme; icon, icon-small and icon-large are
10
- * square icon buttons. Deprecated, removed in a later minor: sm, md and lg (write the
11
- * full names), icon-sm, icon-xs and icon-lg (icon-small, icon-large) and xs, which is
12
- * off the scale and keeps 24px on touch screens.
13
- */
14
- export type ButtonSize = ComponentSizeAlias | 'icon' | 'icon-small' | 'icon-large' | 'xs' | 'icon-xs' | 'icon-sm' | 'icon-lg';
4
+ import { type ComponentSize } from './sizing.js';
5
+ /** Visual priority. Without a variant a button is `primary`. */
6
+ export type ButtonVariant = 'primary' | 'secondary' | 'outline' | 'ghost' | 'destructive' | 'link';
7
+ /** small, default and large set the size scheme; icon, icon-small and icon-large are
8
+ * square icon buttons on the same scale. */
9
+ export type ButtonSize = ComponentSize | 'icon' | 'icon-small' | 'icon-large';
15
10
  export type ButtonProps = Omit<React.ComponentProps<typeof BaseButton>, 'ref'> & {
16
11
  variant?: ButtonVariant;
17
12
  size?: ButtonSize;
package/dist/button.js CHANGED
@@ -3,21 +3,21 @@ import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import { Button as BaseButton } from '@base-ui/react/button';
4
4
  import { useRender } from '@base-ui/react/use-render';
5
5
  import { useComponentSize } from './sizing.js';
6
- import { sizeName, skin, cx } from './parts.js';
7
- /** The size scheme a button size implies: icon sizes follow the scale, xs and icon
8
- * keep the surrounding scheme. */
6
+ import { skin, cx } from './parts.js';
7
+ /** The size scheme a button size implies: icon sizes follow the scale, and icon keeps
8
+ * the surrounding scheme. */
9
9
  function schemeOf(size) {
10
- return size === 'icon-small' || size === 'icon-sm' || size === 'icon-xs'
10
+ return size === 'icon-small'
11
11
  ? 'small'
12
- : size === 'icon-large' || size === 'icon-lg'
12
+ : size === 'icon-large'
13
13
  ? 'large'
14
- : size === 'xs' || size === 'icon'
14
+ : size === 'icon'
15
15
  ? undefined
16
16
  : size;
17
17
  }
18
18
  export const Button = function Button({ className, variant = 'primary', size, ref, ...props }) {
19
19
  const scheme = useComponentSize(schemeOf(size));
20
- return (_jsx(BaseButton, { ref: ref, ...props, className: skin('surf-button', className), "data-variant": variant, "data-size": sizeName(size), "data-ui-size": scheme }));
20
+ return (_jsx(BaseButton, { ref: ref, ...props, className: skin('surf-button', className), "data-variant": variant, "data-size": size, "data-ui-size": scheme }));
21
21
  };
22
22
  /** A link that looks like a Button. It navigates, so it stays a link for assistive
23
23
  * technology; pass a router's link element as `render` to keep client navigation. */
@@ -31,7 +31,7 @@ export const LinkButton = function LinkButton({ render, className, variant = 'pr
31
31
  ...props,
32
32
  className: cx('surf-button', className),
33
33
  'data-variant': variant,
34
- 'data-size': sizeName(size),
34
+ 'data-size': size,
35
35
  'data-ui-size': scheme,
36
36
  },
37
37
  });
package/dist/card.d.ts CHANGED
@@ -1,6 +1,9 @@
1
1
  import * as React from 'react';
2
2
  import { Surface } from './layout.js';
3
- declare const CardRoot: ({ className, padding, ref, ...props }: React.ComponentPropsWithoutRef<typeof Surface> & {
3
+ import { type ComponentSize } from './size.js';
4
+ declare const CardRoot: ({ className, padding, size, ref, ...props }: React.ComponentPropsWithoutRef<typeof Surface> & {
5
+ /** The card's padding, title and the controls inside, as a SizeProvider would set. */
6
+ size?: ComponentSize;
4
7
  ref?: React.Ref<HTMLDivElement>;
5
8
  }) => React.JSX.Element;
6
9
  declare const CardTitle: ({ level, className, ref, ...props }: React.ComponentPropsWithoutRef<"h3"> & {
@@ -292,11 +295,13 @@ declare const CardTitle: ({ level, className, ref, ...props }: React.ComponentPr
292
295
  exportparts?: string | undefined | undefined;
293
296
  }, HTMLHeadingElement>;
294
297
  export declare const Card: {
295
- Root: ({ className, padding, ref, ...props }: React.ComponentPropsWithoutRef<typeof Surface> & {
298
+ Root: ({ className, padding, size, ref, ...props }: React.ComponentPropsWithoutRef<typeof Surface> & {
299
+ /** The card's padding, title and the controls inside, as a SizeProvider would set. */
300
+ size?: ComponentSize;
296
301
  ref?: React.Ref<HTMLDivElement>;
297
302
  }) => React.JSX.Element;
298
303
  Header: ({ className, size, ref, ...rest }: Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "size"> & {
299
- size?: import("./size.js").ComponentSize;
304
+ size?: ComponentSize;
300
305
  ref?: React.Ref<HTMLDivElement> | undefined;
301
306
  }) => React.JSX.Element;
302
307
  Title: ({ level, className, ref, ...props }: React.ComponentPropsWithoutRef<"h3"> & {
@@ -588,29 +593,29 @@ export declare const Card: {
588
593
  exportparts?: string | undefined | undefined;
589
594
  }, HTMLHeadingElement>;
590
595
  Description: ({ className, size, ref, ...rest }: Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, "ref">, "size"> & {
591
- size?: import("./size.js").ComponentSize;
596
+ size?: ComponentSize;
592
597
  ref?: React.Ref<HTMLParagraphElement> | undefined;
593
598
  }) => React.JSX.Element;
594
599
  Body: ({ className, size, ref, ...rest }: Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "size"> & {
595
- size?: import("./size.js").ComponentSize;
600
+ size?: ComponentSize;
596
601
  ref?: React.Ref<HTMLDivElement> | undefined;
597
602
  }) => React.JSX.Element;
598
603
  Footer: ({ className, size, ref, ...rest }: Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "size"> & {
599
- size?: import("./size.js").ComponentSize;
604
+ size?: ComponentSize;
600
605
  ref?: React.Ref<HTMLDivElement> | undefined;
601
606
  }) => React.JSX.Element;
602
607
  };
603
608
  export { CardRoot, CardTitle };
604
609
  export declare const CardHeader: ({ className, size, ref, ...rest }: Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "size"> & {
605
- size?: import("./size.js").ComponentSize;
610
+ size?: ComponentSize;
606
611
  ref?: React.Ref<HTMLDivElement> | undefined;
607
612
  }) => React.JSX.Element, CardDescription: ({ className, size, ref, ...rest }: Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, "ref">, "size"> & {
608
- size?: import("./size.js").ComponentSize;
613
+ size?: ComponentSize;
609
614
  ref?: React.Ref<HTMLParagraphElement> | undefined;
610
615
  }) => React.JSX.Element, CardBody: ({ className, size, ref, ...rest }: Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "size"> & {
611
- size?: import("./size.js").ComponentSize;
616
+ size?: ComponentSize;
612
617
  ref?: React.Ref<HTMLDivElement> | undefined;
613
618
  }) => React.JSX.Element, CardFooter: ({ className, size, ref, ...rest }: Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "size"> & {
614
- size?: import("./size.js").ComponentSize;
619
+ size?: ComponentSize;
615
620
  ref?: React.Ref<HTMLDivElement> | undefined;
616
621
  }) => React.JSX.Element;
package/dist/card.js CHANGED
@@ -3,8 +3,13 @@ import * as React from 'react';
3
3
  import { Surface } from './layout.js';
4
4
  import { cx } from './class-names.js';
5
5
  import { elementPart } from './element-part.js';
6
- const CardRoot = function CardRoot({ className, padding, ref, ...props }) {
7
- return (_jsx(Surface, { ...props, padding: padding, ref: ref, className: cx('surf-card', className) }));
6
+ import { normalizeSize } from './size.js';
7
+ import { SizeScope } from './sizing.js';
8
+ const CardRoot = function CardRoot({ className, padding, size, ref, ...props }) {
9
+ const scheme = normalizeSize(size);
10
+ const card = (_jsx(Surface, { ...props, padding: padding, ref: ref, "data-ui-size": scheme, className: cx('surf-card', className) }));
11
+ // Only an explicit size opens a client boundary, so popups inside keep it.
12
+ return scheme ? _jsx(SizeScope, { size: scheme, children: card }) : card;
8
13
  };
9
14
  const CardTitle = function CardTitle({ level = 3, className, ref, ...props }) {
10
15
  return React.createElement(`h${level}`, {
package/dist/chart.d.ts CHANGED
@@ -1,12 +1,32 @@
1
1
  import * as React from 'react';
2
2
  export type ChartDatum = {
3
3
  id: string;
4
+ /** What the readout and the table call the row, such as its full date and time. */
4
5
  label: string;
6
+ /** When the row was measured, in ms since the epoch or as a Date. Required for
7
+ * xScale="time", where it places the row on the axis. */
8
+ time?: number | Date;
5
9
  values: Readonly<Record<string, number | null | undefined>>;
6
10
  };
7
11
  export type ChartSeries = {
8
12
  key: string;
9
13
  label: string;
14
+ /** A color of your own, such as var(--surf-chart-category-3), in place of the
15
+ * palette's. Marks and dashes still tell the series apart. */
16
+ color?: string;
17
+ };
18
+ export type ChartTone = 'neutral' | 'caution' | 'danger';
19
+ /** A threshold line at y, or a band from one value to another, such as a target
20
+ * range. The legend names it with its value. */
21
+ export type ChartReference = {
22
+ y: number;
23
+ label: string;
24
+ tone?: ChartTone;
25
+ } | {
26
+ from: number;
27
+ to: number;
28
+ label: string;
29
+ tone?: ChartTone;
10
30
  };
11
31
  export type ChartProps = Omit<React.ComponentPropsWithoutRef<'figure'>, 'children' | 'title'> & {
12
32
  title: string;
@@ -17,13 +37,35 @@ export type ChartProps = Omit<React.ComponentPropsWithoutRef<'figure'>, 'childre
17
37
  xLabel: string;
18
38
  yLabel: string;
19
39
  type?: 'line' | 'bar' | 'area';
40
+ /** Plot height in px: 280 by default, 180 when compact. */
20
41
  height?: number;
21
42
  /** Keeps 0 on the value axis. Turn it off for values far from zero, such as
22
43
  * prices, so the line uses the height; bars always start at zero. */
23
44
  includeZero?: boolean;
24
- /** neutral tells series apart by ink, dashes and markers. categorical adds six hues,
25
- * for categories that color must separate, such as buckets or sectors. */
45
+ /** neutral tells series apart by ink, dashes and markers. categorical adds twelve
46
+ * hues, for categories that color must separate, such as buckets or sectors. */
26
47
  palette?: 'neutral' | 'categorical';
48
+ /** category spaces the rows evenly and names them by label. time places them by
49
+ * data[].time, puts ticks on round times and breaks a line where sampling stops. */
50
+ xScale?: 'category' | 'time';
51
+ /** log suits values across orders of magnitude, such as prefill and decode
52
+ * throughput. Zero and negative values stay off the plot and in the table. */
53
+ yScale?: 'linear' | 'log';
54
+ /** step holds each value until the next, for values sampled when they change. */
55
+ curve?: 'linear' | 'step';
56
+ /** Stacks bar and area series, so the top of the stack is their total. */
57
+ stacked?: boolean;
58
+ /** Thresholds and target bands over the plot. The value axis reaches them. */
59
+ references?: readonly ChartReference[];
60
+ /** compact keeps the plot, legend and floating values for a dashboard card; the
61
+ * caption, keyboard help and readout stay for assistive technology. Without it the
62
+ * chart follows a SizeProvider density. Its data table takes the same density. */
63
+ density?: 'default' | 'compact';
64
+ /** Above the plot, beside the value axis name, or below it. */
65
+ legendPosition?: 'top' | 'bottom';
66
+ /** Shows this many series in the legend; the rest fold behind a "+N" button. auto
67
+ * keeps the legend on one line: as many as fit the chart's width, the rest folded. */
68
+ legendLimit?: number | 'auto';
27
69
  locale?: string;
28
70
  /** Formats a value for the readout, the table and the value axis ticks. The unit
29
71
  * follows it in the readout and the table, and names the axis. */
@@ -52,9 +94,22 @@ export type ChartLabels = {
52
94
  legend: (title: string) => string;
53
95
  /** A legend button that shows or hides a series. */
54
96
  series: (label: string) => string;
97
+ /** The button that opens the series past legendLimit. */
98
+ moreSeries: (count: number) => string;
99
+ /** The sum of stacked series in the readout. */
100
+ total: string;
101
+ };
102
+ export type ChartSeriesMarkProps = {
103
+ type?: 'line' | 'bar' | 'area';
104
+ /** The series' place in the chart's series, which sets its dash, marker and color. */
105
+ index: number;
106
+ palette?: 'neutral' | 'categorical';
107
+ color?: string;
55
108
  };
109
+ /** A series' swatch as Chart's legend draws it, for a legend or key of your own. */
110
+ export declare function ChartSeriesMark({ type, index, palette, color, }: ChartSeriesMarkProps): React.JSX.Element;
56
111
  /** Cartesian trends with a persistent, keyboard-readable tooltip region and a
57
112
  * full data-table alternative. Missing values are gaps, never fabricated zeros. */
58
- export declare const Chart: ({ title, description, data, series, unit, xLabel, yLabel, type, height, includeZero, palette, locale, formatValue, labels, hiddenSeries, defaultHiddenSeries, onHiddenSeriesChange, className, ref, ...props }: ChartProps & {
113
+ export declare const Chart: ({ title, description, data, series, unit, xLabel, yLabel, type, height, includeZero, palette, xScale, yScale, curve, stacked, references, density: ownDensity, legendPosition, legendLimit, locale, formatValue, labels, hiddenSeries, defaultHiddenSeries, onHiddenSeriesChange, className, ref, ...props }: ChartProps & {
59
114
  ref?: React.Ref<HTMLElement>;
60
115
  }) => React.JSX.Element;