@central-ui/react 0.2.0 → 0.4.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 (79) hide show
  1. package/dist/components/accordion/index.d.ts +14 -14
  2. package/dist/components/accordion/index.js +19 -19
  3. package/dist/components/autocomplete/index.d.ts +57 -49
  4. package/dist/components/autocomplete/index.js +69 -60
  5. package/dist/components/avatar/index.d.ts +7 -6
  6. package/dist/components/avatar/index.js +9 -9
  7. package/dist/components/banner/index.js +1 -1
  8. package/dist/components/carousel/index.d.ts +189 -0
  9. package/dist/components/carousel/index.js +303 -0
  10. package/dist/components/checkbox/index.d.ts +12 -11
  11. package/dist/components/checkbox/index.js +21 -21
  12. package/dist/components/combobox/index.d.ts +67 -71
  13. package/dist/components/combobox/index.js +80 -72
  14. package/dist/components/datepicker/index.d.ts +8 -9
  15. package/dist/components/datepicker/index.js +13 -13
  16. package/dist/components/dialog/index.d.ts +18 -18
  17. package/dist/components/dialog/index.js +22 -21
  18. package/dist/components/drawer/index.d.ts +24 -24
  19. package/dist/components/drawer/index.js +28 -27
  20. package/dist/components/empty/index.d.ts +2 -1
  21. package/dist/components/empty/index.js +2 -1
  22. package/dist/components/exception/index.d.ts +98 -0
  23. package/dist/components/exception/index.js +116 -0
  24. package/dist/components/fileupload/index.d.ts +8 -8
  25. package/dist/components/input/index.d.ts +14 -14
  26. package/dist/components/input/index.js +27 -27
  27. package/dist/components/menu/index.d.ts +37 -37
  28. package/dist/components/menu/index.js +47 -47
  29. package/dist/components/numberinput/index.d.ts +22 -22
  30. package/dist/components/numberinput/index.js +35 -35
  31. package/dist/components/otpinput/index.d.ts +12 -12
  32. package/dist/components/otpinput/index.js +21 -21
  33. package/dist/components/passwordinput/index.d.ts +15 -15
  34. package/dist/components/passwordinput/index.js +27 -27
  35. package/dist/components/popover/index.d.ts +16 -16
  36. package/dist/components/popover/index.js +20 -19
  37. package/dist/components/radio/index.d.ts +12 -12
  38. package/dist/components/radio/index.js +25 -25
  39. package/dist/components/ratinginput/index.d.ts +1 -1
  40. package/dist/components/ratinginput/index.js +3 -3
  41. package/dist/components/select/index.d.ts +32 -29
  42. package/dist/components/select/index.js +45 -35
  43. package/dist/components/slider/index.d.ts +20 -20
  44. package/dist/components/slider/index.js +27 -27
  45. package/dist/components/stepper/index.d.ts +8 -7
  46. package/dist/components/stepper/index.js +4 -2
  47. package/dist/components/switch/index.d.ts +9 -9
  48. package/dist/components/switch/index.js +17 -17
  49. package/dist/components/table/index.d.ts +2 -2
  50. package/dist/components/table/index.js +16 -16
  51. package/dist/components/tabs/index.d.ts +10 -10
  52. package/dist/components/tabs/index.js +11 -11
  53. package/dist/components/textarea/index.d.ts +13 -13
  54. package/dist/components/textarea/index.js +25 -25
  55. package/dist/components/toast/index.d.ts +11 -11
  56. package/dist/components/toast/index.js +11 -11
  57. package/dist/components/toggle/index.d.ts +7 -7
  58. package/dist/components/toggle/index.js +9 -9
  59. package/dist/components/tooltip/index.d.ts +6 -6
  60. package/dist/components/tooltip/index.js +6 -7
  61. package/dist/components/tour/index.d.ts +2 -2
  62. package/dist/components/tour/index.js +5 -4
  63. package/dist/index.d.ts +2 -0
  64. package/dist/index.js +2 -0
  65. package/dist/utils/icons.d.ts +92 -23
  66. package/dist/utils/icons.js +3 -3
  67. package/package.json +69 -67
  68. package/src/presets/shopify-polaris/shopify-polaris-accordion.css +28 -28
  69. package/src/presets/shopify-polaris/shopify-polaris-carousel.css +62 -0
  70. package/src/presets/shopify-polaris/shopify-polaris-exception.css +40 -0
  71. package/src/presets/shopify-polaris/shopify-polaris.css +2 -0
  72. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-accordion.css +28 -28
  73. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-carousel.css +55 -0
  74. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-exception.css +40 -0
  75. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy.css +2 -0
  76. package/dist/types/Tone.d.ts +0 -3
  77. package/dist/types/Tone.js +0 -1
  78. package/dist/utils/Tone.d.ts +0 -2
  79. package/dist/utils/Tone.js +0 -6
@@ -1,7 +1,7 @@
1
1
  import type { StyleProps } from '../../types/Style.ts';
2
2
  import type { AsChildProps } from '../../utils/asChild.ts';
3
3
  import { Drawer as BaseDrawer } from '@base-ui/react/drawer';
4
- import type { ReactElement } from 'react';
4
+ import type { ComponentProps, ReactElement } from 'react';
5
5
  import type { SVGIconProps } from '../../types/Icon.ts';
6
6
  /**
7
7
  * Choose swipeDirection on Root and keep trigger and Popup in that Root. Popup already includes its portal. Provider and Indent parts are for an optional indented-background composition, not required for a basic drawer.
@@ -47,44 +47,44 @@ export declare function Root<Payload = unknown>({ swipeDirection, ...props }: Ba
47
47
  /** Optional: use around IndentBackground, Indent and drawers when app indentation is needed. */
48
48
  export declare const Provider: typeof BaseDrawer.Provider;
49
49
  /** Optional: background layer for app indentation; use with Indent inside Provider. */
50
- export declare const IndentBackground: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").DrawerIndentBackgroundProps, "className"> & {
50
+ export declare function IndentBackground({ disableStyle, className, ref, ...props }: (Omit<BaseDrawer.IndentBackground.Props, 'className' | 'render'> & {
51
51
  className?: string;
52
- } & StyleProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
52
+ }) & StyleProps): import("react").JSX.Element;
53
53
  /** Optional: wraps the app content when indentation is needed; use inside Provider. */
54
- export declare const Indent: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").DrawerIndentProps, "className"> & {
54
+ export declare function Indent({ disableStyle, className, ref, ...props }: (Omit<BaseDrawer.Indent.Props, 'className' | 'render'> & {
55
55
  className?: string;
56
- } & StyleProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
56
+ }) & StyleProps): import("react").JSX.Element;
57
57
  /** Optional: a custom swipe-to-open area outside Popup but inside Root. Unpainted by default; style its size and position at the call site. */
58
- export declare const SwipeArea: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").DrawerSwipeAreaProps, "className"> & {
58
+ export declare function SwipeArea({ disableStyle, className, ref, ...props }: (Omit<BaseDrawer.SwipeArea.Props, 'className' | 'render'> & {
59
59
  className?: string;
60
- } & StyleProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
60
+ }) & StyleProps): import("react").JSX.Element;
61
61
  /** Opens the drawer. Pass asChild to give this behavior to your own element, like your app's Button. */
62
- export declare const OpenButton: import("react").ForwardRefExoticComponent<Omit<Omit<BaseDrawer.Trigger.Props<unknown>, "className" | "render"> & {
62
+ export declare function OpenButton({ asChild, disableStyle, children, ref, ...props }: Omit<BaseDrawer.Trigger.Props, 'className' | 'render'> & {
63
63
  className?: string;
64
- } & AsChildProps & StyleProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
65
- export type PopupProps = Omit<BaseDrawer.Popup.Props, 'className'> & {
64
+ } & AsChildProps & StyleProps): import("react").JSX.Element;
65
+ export type PopupProps = Omit<BaseDrawer.Popup.Props, 'className' | 'render'> & {
66
66
  className?: string;
67
67
  } & Pick<BaseDrawer.Portal.Props, 'container' | 'keepMounted'> & StyleProps;
68
68
  /** Already includes the portal. Keep it in the matching Root and let the native open state control visibility. */
69
- export declare const Popup: import("react").ForwardRefExoticComponent<Omit<PopupProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
70
- export declare const Backdrop: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").DrawerBackdropProps, "className"> & {
69
+ export declare function Popup({ disableStyle, container, keepMounted, className, style, ref, ...props }: PopupProps): import("react").JSX.Element;
70
+ export declare function Backdrop({ disableStyle, container, keepMounted, className, ref, ...props }: (Omit<BaseDrawer.Backdrop.Props, 'className' | 'render'> & {
71
71
  className?: string;
72
- } & Pick<import("@base-ui/react").DrawerPortalProps, "keepMounted" | "container"> & StyleProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
73
- export declare const Header: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & StyleProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
74
- export declare const Body: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & StyleProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
75
- export declare const Footer: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & StyleProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
76
- export declare const Title: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").DrawerTitleProps, "className"> & {
72
+ } & Pick<BaseDrawer.Portal.Props, 'container' | 'keepMounted'>) & StyleProps): import("react").JSX.Element;
73
+ export declare function Header({ disableStyle, className, ref, ...props }: ComponentProps<'div'> & StyleProps): import("react").JSX.Element;
74
+ export declare function Body({ disableStyle, className, ref, ...props }: ComponentProps<'div'> & StyleProps): import("react").JSX.Element;
75
+ export declare function Footer({ disableStyle, className, ref, ...props }: ComponentProps<'div'> & StyleProps): import("react").JSX.Element;
76
+ export declare function Title({ disableStyle, className, ref, ...props }: (Omit<BaseDrawer.Title.Props, 'className' | 'render'> & {
77
77
  className?: string;
78
- } & StyleProps, "ref"> & import("react").RefAttributes<HTMLHeadingElement>>;
79
- export declare const Description: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").DrawerDescriptionProps, "className"> & {
78
+ }) & StyleProps): import("react").JSX.Element;
79
+ export declare function Description({ disableStyle, className, ref, ...props }: (Omit<BaseDrawer.Description.Props, 'className' | 'render'> & {
80
80
  className?: string;
81
- } & StyleProps, "ref"> & import("react").RefAttributes<HTMLParagraphElement>>;
81
+ }) & StyleProps): import("react").JSX.Element;
82
82
  /** Icon-only: put just a CloseButtonIcon inside, never text like "Close". Name it for screen readers with aria-label instead, e.g. aria-label="Close drawer". Pass asChild to give closing behavior to your own button instead, like a "Done" Button. */
83
- export declare const CloseButton: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").DrawerCloseProps, "className" | "render"> & {
83
+ export declare function CloseButton({ asChild, disableStyle, children, ref, ...props }: Omit<BaseDrawer.Close.Props, 'className' | 'render'> & {
84
84
  className?: string;
85
- } & AsChildProps & StyleProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
85
+ } & AsChildProps & StyleProps): import("react").JSX.Element;
86
86
  /** A default icon is supplied. Omit children for the usual case; pass an icon only to replace that visual. */
87
- export declare const CloseButtonIcon: import("react").ForwardRefExoticComponent<Omit<SVGIconProps & {
87
+ export declare function CloseButtonIcon({ disableStyle, children, className, ref, ...props }: (SVGIconProps & {
88
88
  /** Omit for the supplied default icon; pass a child only to replace it. */
89
89
  children?: ReactElement<SVGIconProps>;
90
- } & StyleProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
90
+ }) & StyleProps): import("react").FunctionComponentElement<any>;
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { asChildRendering } from "../../utils/asChild.js";
3
3
  import { Drawer as BaseDrawer } from '@base-ui/react/drawer';
4
- import { cloneElement, forwardRef } from 'react';
4
+ import { cloneElement } from 'react';
5
5
  import { twMerge } from 'tailwind-merge';
6
6
  import { X } from "../../utils/icons.js";
7
7
  /**
@@ -50,24 +50,24 @@ export function Root({ swipeDirection = 'right', ...props }) {
50
50
  /** Optional: use around IndentBackground, Indent and drawers when app indentation is needed. */
51
51
  export const Provider = BaseDrawer.Provider;
52
52
  /** Optional: background layer for app indentation; use with Indent inside Provider. */
53
- export const IndentBackground = /* @__PURE__ */ forwardRef(function IndentBackground({ disableStyle, className, ...props }, ref) {
53
+ export function IndentBackground({ disableStyle, className, ref, ...props }) {
54
54
  return (_jsx(BaseDrawer.IndentBackground, { ...props, ref: ref, "data-component": "drawer-indentbackground", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
55
- });
55
+ }
56
56
  /** Optional: wraps the app content when indentation is needed; use inside Provider. */
57
- export const Indent = /* @__PURE__ */ forwardRef(function Indent({ disableStyle, className, ...props }, ref) {
57
+ export function Indent({ disableStyle, className, ref, ...props }) {
58
58
  return (_jsx(BaseDrawer.Indent, { ...props, ref: ref, "data-component": "drawer-indent", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
59
- });
59
+ }
60
60
  /** Optional: a custom swipe-to-open area outside Popup but inside Root. Unpainted by default; style its size and position at the call site. */
61
- export const SwipeArea = /* @__PURE__ */ forwardRef(function SwipeArea({ disableStyle, className, ...props }, ref) {
61
+ export function SwipeArea({ disableStyle, className, ref, ...props }) {
62
62
  return (_jsx(BaseDrawer.SwipeArea, { ...props, ref: ref, "data-component": "drawer-swipearea", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
63
- });
63
+ }
64
64
  /** Opens the drawer. Pass asChild to give this behavior to your own element, like your app's Button. */
65
- export const OpenButton = /* @__PURE__ */ forwardRef(function OpenButton({ asChild, disableStyle, children, ...props }, ref) {
65
+ export function OpenButton({ asChild, disableStyle, children, ref, ...props }) {
66
66
  const rendering = asChildRendering({ asChild, children, component: 'drawer-openbutton', disableStyle });
67
67
  return _jsx(BaseDrawer.Trigger, { ...props, ref: ref, ...rendering });
68
- });
68
+ }
69
69
  /** Already includes the portal. Keep it in the matching Root and let the native open state control visibility. */
70
- export const Popup = /* @__PURE__ */ forwardRef(function Popup({ disableStyle, container, keepMounted, className, style, ...props }, ref) {
70
+ export function Popup({ disableStyle, container, keepMounted, className, style, ref, ...props }) {
71
71
  return (_jsx(BaseDrawer.Portal, { container: container, keepMounted: keepMounted, children: _jsx(BaseDrawer.Viewport, { children: _jsx(BaseDrawer.Popup, { ...props, ref: ref, "data-component": "drawer-popup", "data-style-disabled": disableStyle ? '' : undefined, className: className, style: (state) => {
72
72
  const vertical = state.swipeDirection === 'up' || state.swipeDirection === 'down';
73
73
  // Sliding in and out from the side it swipes towards, otherwise following the finger (and the snap point, vertically)
@@ -96,32 +96,32 @@ export const Popup = /* @__PURE__ */ forwardRef(function Popup({ disableStyle, c
96
96
  ...(typeof style === 'function' ? style(state) : style),
97
97
  };
98
98
  } }) }) }));
99
- });
100
- export const Backdrop = /* @__PURE__ */ forwardRef(function Backdrop({ disableStyle, container, keepMounted, className, ...props }, ref) {
99
+ }
100
+ export function Backdrop({ disableStyle, container, keepMounted, className, ref, ...props }) {
101
101
  return (_jsx(BaseDrawer.Portal, { container: container, keepMounted: keepMounted, children: _jsx(BaseDrawer.Backdrop, { ...props, ref: ref, "data-component": "drawer-backdrop", "data-style-disabled": disableStyle ? '' : undefined, className: className }) }));
102
- });
103
- export const Header = /* @__PURE__ */ forwardRef(function Header({ disableStyle, className, ...props }, ref) {
102
+ }
103
+ export function Header({ disableStyle, className, ref, ...props }) {
104
104
  return (_jsx("div", { ...props, ref: ref, "data-component": "drawer-header", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
105
- });
106
- export const Body = /* @__PURE__ */ forwardRef(function Body({ disableStyle, className, ...props }, ref) {
105
+ }
106
+ export function Body({ disableStyle, className, ref, ...props }) {
107
107
  return (_jsx("div", { ...props, ref: ref, "data-component": "drawer-body", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
108
- });
109
- export const Footer = /* @__PURE__ */ forwardRef(function Footer({ disableStyle, className, ...props }, ref) {
108
+ }
109
+ export function Footer({ disableStyle, className, ref, ...props }) {
110
110
  return (_jsx("div", { ...props, ref: ref, "data-component": "drawer-footer", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
111
- });
112
- export const Title = /* @__PURE__ */ forwardRef(function Title({ disableStyle, className, ...props }, ref) {
111
+ }
112
+ export function Title({ disableStyle, className, ref, ...props }) {
113
113
  return (_jsx(BaseDrawer.Title, { ...props, ref: ref, "data-component": "drawer-title", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
114
- });
115
- export const Description = /* @__PURE__ */ forwardRef(function Description({ disableStyle, className, ...props }, ref) {
114
+ }
115
+ export function Description({ disableStyle, className, ref, ...props }) {
116
116
  return (_jsx(BaseDrawer.Description, { ...props, ref: ref, "data-component": "drawer-description", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
117
- });
117
+ }
118
118
  /** Icon-only: put just a CloseButtonIcon inside, never text like "Close". Name it for screen readers with aria-label instead, e.g. aria-label="Close drawer". Pass asChild to give closing behavior to your own button instead, like a "Done" Button. */
119
- export const CloseButton = /* @__PURE__ */ forwardRef(function CloseButton({ asChild, disableStyle, children, ...props }, ref) {
119
+ export function CloseButton({ asChild, disableStyle, children, ref, ...props }) {
120
120
  const rendering = asChildRendering({ asChild, children, component: 'drawer-closebutton', disableStyle });
121
121
  return _jsx(BaseDrawer.Close, { ...props, ref: ref, ...rendering });
122
- });
122
+ }
123
123
  /** A default icon is supplied. Omit children for the usual case; pass an icon only to replace that visual. */
124
- export const CloseButtonIcon = /* @__PURE__ */ forwardRef(function CloseButtonIcon({ disableStyle, children, className, ...props }, ref) {
124
+ export function CloseButtonIcon({ disableStyle, children, className, ref, ...props }) {
125
125
  return cloneElement(children ?? _jsx(X, {}), {
126
126
  ...props,
127
127
  ref,
@@ -131,5 +131,6 @@ export const CloseButtonIcon = /* @__PURE__ */ forwardRef(function CloseButtonIc
131
131
  'data-style-disabled': disableStyle ? '' : undefined,
132
132
  },
133
133
  className: twMerge(children?.props.className, className),
134
+ strokeWidth: props.strokeWidth ?? children?.props.strokeWidth ?? 2,
134
135
  });
135
- });
136
+ }
@@ -28,7 +28,8 @@ import type { ComponentProps, HTMLAttributes, ImgHTMLAttributes, ReactElement }
28
28
  */
29
29
  export declare function Surface({ disableStyle, className, ...props }: HTMLAttributes<HTMLDivElement> & StyleProps): import("react").JSX.Element;
30
30
  export declare function Body({ disableStyle, className, ...props }: ComponentProps<'div'> & StyleProps): import("react").JSX.Element;
31
- export declare function Title({ disableStyle, className, ...props }: HTMLAttributes<HTMLParagraphElement> & StyleProps): import("react").JSX.Element;
31
+ /** Renders an h2, so screen-reader users find it when jumping between headings, whether the panel fills a page or one section of it. */
32
+ export declare function Title({ disableStyle, className, ...props }: HTMLAttributes<HTMLHeadingElement> & StyleProps): import("react").JSX.Element;
32
33
  export declare function Description({ disableStyle, className, ...props }: HTMLAttributes<HTMLParagraphElement> & StyleProps): import("react").JSX.Element;
33
34
  export declare function Image({ disableStyle, className, ...props }: ImgHTMLAttributes<HTMLImageElement> & StyleProps): import("react").JSX.Element;
34
35
  /** Supply the decorative icon as a child. Its classes are preserved; interaction belongs to the surrounding control. */
@@ -33,8 +33,9 @@ export function Surface({ disableStyle, className, ...props }) {
33
33
  export function Body({ disableStyle, className, ...props }) {
34
34
  return (_jsx("div", { ...props, "data-component": "empty-body", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
35
35
  }
36
+ /** Renders an h2, so screen-reader users find it when jumping between headings, whether the panel fills a page or one section of it. */
36
37
  export function Title({ disableStyle, className, ...props }) {
37
- return (_jsx("p", { "data-component": "empty-title", "data-style-disabled": disableStyle ? '' : undefined, className: className, ...props }));
38
+ return (_jsx("h2", { "data-component": "empty-title", "data-style-disabled": disableStyle ? '' : undefined, className: className, ...props }));
38
39
  }
39
40
  export function Description({ disableStyle, className, ...props }) {
40
41
  return (_jsx("p", { "data-component": "empty-description", "data-style-disabled": disableStyle ? '' : undefined, className: className, ...props }));
@@ -0,0 +1,98 @@
1
+ import type { StyleProps } from '../../types/Style.ts';
2
+ import type { ComponentProps, HTMLAttributes, ImgHTMLAttributes, ReactElement, ReactNode, Ref } from 'react';
3
+ type Tone = 'neutral' | 'critical';
4
+ /**
5
+ * Explains why something can't be shown, like a page that doesn't exist or a section the user isn't allowed to see. It isn't an error, just a normal state of the app.
6
+ * Root holds the tone and renders nothing itself; Surface and Body render the panel. You decide when it appears. It's a section: put it where the missing content would have been, and it fills that container's height.
7
+ * Image/Icon, ActionsList and HelpText are optional. ActionsList takes your own buttons, since the actions belong to your app.
8
+ *
9
+ * @example A page the user can't access
10
+ * import { Button, Exception, TextLink } from '@central-ui/react'
11
+ * import { Link } from '@tanstack/react-router'
12
+ * import { Lock } from 'lucide-react'
13
+ *
14
+ * function Example() {
15
+ * return (
16
+ * // Inside the body of some page. That page's header shows no title or back button,
17
+ * // since they would describe something the user can't see.
18
+ * <Exception.Root>
19
+ * <Exception.Surface>
20
+ * <Exception.Body>
21
+ * <Exception.Icon>
22
+ * <Lock aria-hidden="true" />
23
+ * </Exception.Icon>
24
+ * <Exception.Title>You don't have access to this page</Exception.Title>
25
+ * <Exception.Description>Ask a store owner to give your account the Orders permission.</Exception.Description>
26
+ * <Exception.ActionsList>
27
+ * <Button.default variant="primary">Go to dashboard</Button.default>
28
+ * </Exception.ActionsList>
29
+ * <Exception.HelpText>
30
+ * Still stuck?{' '}
31
+ * <TextLink.default>
32
+ * <Link to="/support">Contact support</Link>
33
+ * </TextLink.default>
34
+ * </Exception.HelpText>
35
+ * </Exception.Body>
36
+ * </Exception.Surface>
37
+ * </Exception.Root>
38
+ * )
39
+ * }
40
+ *
41
+ * @example A page that doesn't exist
42
+ * // Also inside the body of some page with no title in its header; the code goes in the Title.
43
+ * ;<Exception.Root>
44
+ * <Exception.Surface>
45
+ * <Exception.Body>
46
+ * <Exception.Title>404 · Page not found</Exception.Title>
47
+ * <Exception.Description>The page may have moved, or the link is wrong.</Exception.Description>
48
+ * </Exception.Body>
49
+ * </Exception.Surface>
50
+ * </Exception.Root>
51
+ *
52
+ * @example A section that failed to load, inside a page that otherwise works
53
+ * // In place of that section only; the rest of the page stays.
54
+ * ;<Exception.Root tone="critical">
55
+ * {
56
+ * // Rest of components here
57
+ * }
58
+ * </Exception.Root>
59
+ */
60
+ export declare function Root({ tone, children, }: {
61
+ /**
62
+ * Neutral for expected situations, like no access or a missing page. Critical for failures, like a section that couldn't load; it turns the Title red.
63
+ * Every part carries it as data-tone.
64
+ * @default 'neutral'
65
+ */
66
+ tone?: Tone;
67
+ /** The Surface. */
68
+ children: ReactNode;
69
+ }): import("react").JSX.Element;
70
+ /** Centers the panel and fills its container's height. */
71
+ export declare function Surface({ disableStyle, className, ref, ...props }: HTMLAttributes<HTMLDivElement> & {
72
+ ref?: Ref<HTMLDivElement>;
73
+ } & StyleProps): import("react").JSX.Element;
74
+ export declare function Body({ disableStyle, className, ref, ...props }: ComponentProps<'div'> & StyleProps): import("react").JSX.Element;
75
+ /** Renders an h2, so screen-reader users find it when jumping between headings, whether the panel fills a page or one section of it. */
76
+ export declare function Title({ disableStyle, className, ref, ...props }: HTMLAttributes<HTMLHeadingElement> & {
77
+ ref?: Ref<HTMLHeadingElement>;
78
+ } & StyleProps): import("react").JSX.Element;
79
+ export declare function Description({ disableStyle, className, ref, ...props }: HTMLAttributes<HTMLParagraphElement> & {
80
+ ref?: Ref<HTMLParagraphElement>;
81
+ } & StyleProps): import("react").JSX.Element;
82
+ export declare function Image({ disableStyle, className, ref, ...props }: ImgHTMLAttributes<HTMLImageElement> & {
83
+ ref?: Ref<HTMLImageElement>;
84
+ } & StyleProps): import("react").JSX.Element;
85
+ /** Supply the decorative icon as a child. Its classes are preserved; interaction belongs to the surrounding control. */
86
+ export declare function Icon({ disableStyle, children, className, ref, ...props }: (Omit<ComponentProps<'svg'>, 'children'> & {
87
+ /** Supply the decorative icon; the wrapper forwards the relevant state and preserves its classes. */
88
+ children: ReactElement<ComponentProps<'svg'>>;
89
+ }) & StyleProps): ReactElement<import("react").SVGProps<SVGSVGElement>, string | import("react").JSXElementConstructor<any>>;
90
+ /** Takes your own buttons, like a primary "Go to dashboard"; it creates no actions itself. */
91
+ export declare function ActionsList({ disableStyle, className, ref, ...props }: HTMLAttributes<HTMLDivElement> & {
92
+ ref?: Ref<HTMLDivElement>;
93
+ } & StyleProps): import("react").JSX.Element;
94
+ /** A small footnote below the actions, like "Still stuck? Contact support" with a link. */
95
+ export declare function HelpText({ disableStyle, className, ref, ...props }: HTMLAttributes<HTMLParagraphElement> & {
96
+ ref?: Ref<HTMLParagraphElement>;
97
+ } & StyleProps): import("react").JSX.Element;
98
+ export {};
@@ -0,0 +1,116 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { cloneElement, createContext, useContext } from 'react';
3
+ import { twMerge } from 'tailwind-merge';
4
+ const ToneContext = /* @__PURE__ */ createContext(null);
5
+ /**
6
+ * Explains why something can't be shown, like a page that doesn't exist or a section the user isn't allowed to see. It isn't an error, just a normal state of the app.
7
+ * Root holds the tone and renders nothing itself; Surface and Body render the panel. You decide when it appears. It's a section: put it where the missing content would have been, and it fills that container's height.
8
+ * Image/Icon, ActionsList and HelpText are optional. ActionsList takes your own buttons, since the actions belong to your app.
9
+ *
10
+ * @example A page the user can't access
11
+ * import { Button, Exception, TextLink } from '@central-ui/react'
12
+ * import { Link } from '@tanstack/react-router'
13
+ * import { Lock } from 'lucide-react'
14
+ *
15
+ * function Example() {
16
+ * return (
17
+ * // Inside the body of some page. That page's header shows no title or back button,
18
+ * // since they would describe something the user can't see.
19
+ * <Exception.Root>
20
+ * <Exception.Surface>
21
+ * <Exception.Body>
22
+ * <Exception.Icon>
23
+ * <Lock aria-hidden="true" />
24
+ * </Exception.Icon>
25
+ * <Exception.Title>You don't have access to this page</Exception.Title>
26
+ * <Exception.Description>Ask a store owner to give your account the Orders permission.</Exception.Description>
27
+ * <Exception.ActionsList>
28
+ * <Button.default variant="primary">Go to dashboard</Button.default>
29
+ * </Exception.ActionsList>
30
+ * <Exception.HelpText>
31
+ * Still stuck?{' '}
32
+ * <TextLink.default>
33
+ * <Link to="/support">Contact support</Link>
34
+ * </TextLink.default>
35
+ * </Exception.HelpText>
36
+ * </Exception.Body>
37
+ * </Exception.Surface>
38
+ * </Exception.Root>
39
+ * )
40
+ * }
41
+ *
42
+ * @example A page that doesn't exist
43
+ * // Also inside the body of some page with no title in its header; the code goes in the Title.
44
+ * ;<Exception.Root>
45
+ * <Exception.Surface>
46
+ * <Exception.Body>
47
+ * <Exception.Title>404 · Page not found</Exception.Title>
48
+ * <Exception.Description>The page may have moved, or the link is wrong.</Exception.Description>
49
+ * </Exception.Body>
50
+ * </Exception.Surface>
51
+ * </Exception.Root>
52
+ *
53
+ * @example A section that failed to load, inside a page that otherwise works
54
+ * // In place of that section only; the rest of the page stays.
55
+ * ;<Exception.Root tone="critical">
56
+ * {
57
+ * // Rest of components here
58
+ * }
59
+ * </Exception.Root>
60
+ */
61
+ export function Root({ tone = 'neutral', children, }) {
62
+ return _jsx(ToneContext.Provider, { value: tone, children: children });
63
+ }
64
+ /** Centers the panel and fills its container's height. */
65
+ export function Surface({ disableStyle, className, ref, ...props }) {
66
+ const tone = useTone('Surface');
67
+ return (_jsx("div", { ...props, ref: ref, "data-component": "exception-surface", "data-style-disabled": disableStyle ? '' : undefined, "data-tone": tone, className: className }));
68
+ }
69
+ export function Body({ disableStyle, className, ref, ...props }) {
70
+ const tone = useTone('Body');
71
+ return (_jsx("div", { ...props, ref: ref, "data-component": "exception-body", "data-style-disabled": disableStyle ? '' : undefined, "data-tone": tone, className: className }));
72
+ }
73
+ /** Renders an h2, so screen-reader users find it when jumping between headings, whether the panel fills a page or one section of it. */
74
+ export function Title({ disableStyle, className, ref, ...props }) {
75
+ const tone = useTone('Title');
76
+ return (_jsx("h2", { ...props, ref: ref, "data-component": "exception-title", "data-style-disabled": disableStyle ? '' : undefined, "data-tone": tone, className: className }));
77
+ }
78
+ export function Description({ disableStyle, className, ref, ...props }) {
79
+ const tone = useTone('Description');
80
+ return (_jsx("p", { ...props, ref: ref, "data-component": "exception-description", "data-style-disabled": disableStyle ? '' : undefined, "data-tone": tone, className: className }));
81
+ }
82
+ export function Image({ disableStyle, className, ref, ...props }) {
83
+ const tone = useTone('Image');
84
+ return (_jsx("img", { alt: "", ...props, ref: ref, "data-component": "exception-image", "data-style-disabled": disableStyle ? '' : undefined, "data-tone": tone, className: className }));
85
+ }
86
+ /** Supply the decorative icon as a child. Its classes are preserved; interaction belongs to the surrounding control. */
87
+ export function Icon({ disableStyle, children, className, ref, ...props }) {
88
+ const tone = useTone('Icon');
89
+ return cloneElement(children, {
90
+ ...props,
91
+ ref,
92
+ ...{
93
+ 'data-component': 'exception-icon',
94
+ 'data-style-disabled': disableStyle ? '' : undefined,
95
+ 'data-tone': tone,
96
+ },
97
+ className: twMerge(children.props.className, className),
98
+ strokeWidth: props.strokeWidth ?? children.props.strokeWidth ?? 1.5,
99
+ });
100
+ }
101
+ /** Takes your own buttons, like a primary "Go to dashboard"; it creates no actions itself. */
102
+ export function ActionsList({ disableStyle, className, ref, ...props }) {
103
+ const tone = useTone('ActionsList');
104
+ return (_jsx("div", { ...props, ref: ref, "data-component": "exception-actionslist", "data-style-disabled": disableStyle ? '' : undefined, "data-tone": tone, className: className }));
105
+ }
106
+ /** A small footnote below the actions, like "Still stuck? Contact support" with a link. */
107
+ export function HelpText({ disableStyle, className, ref, ...props }) {
108
+ const tone = useTone('HelpText');
109
+ return (_jsx("p", { ...props, ref: ref, "data-component": "exception-helptext", "data-style-disabled": disableStyle ? '' : undefined, "data-tone": tone, className: className }));
110
+ }
111
+ function useTone(part) {
112
+ const tone = useContext(ToneContext);
113
+ if (!tone)
114
+ throw new Error(`Exception.${part} must be placed inside Exception.Root.`);
115
+ return tone;
116
+ }
@@ -48,8 +48,8 @@ import type { ComponentProps, ReactElement, ReactNode } from 'react';
48
48
  */
49
49
  export declare function Root({ children, ...props }: Omit<ArkFileUpload.RootProps, 'asChild'>): import("react").JSX.Element;
50
50
  export declare function Container({ disableStyle, className, ...props }: ComponentProps<'div'> & StyleProps): import("react").JSX.Element;
51
- export declare function Label({ disableStyle, className, ...props }: ArkFileUpload.LabelProps & StyleProps): import("react").JSX.Element;
52
- export declare function Dropzone({ disableStyle, children, className, ...props }: ArkFileUpload.DropzoneProps & StyleProps): import("react").JSX.Element;
51
+ export declare function Label({ disableStyle, className, ...props }: Omit<ArkFileUpload.LabelProps, 'asChild'> & StyleProps): import("react").JSX.Element;
52
+ export declare function Dropzone({ disableStyle, children, className, ...props }: Omit<ArkFileUpload.DropzoneProps, 'asChild'> & StyleProps): import("react").JSX.Element;
53
53
  /** Opens the file picker. Pass asChild to give this behavior to your own button, like an "Upload" Button; it keeps the state data attributes but none of this part's styling. */
54
54
  export declare function PickerButton({ asChild, disableStyle, ...props }: ArkFileUpload.TriggerProps & StyleProps): import("react").JSX.Element;
55
55
  /** A default icon is supplied. Omit children for the usual case; pass an icon only to replace that visual. */
@@ -70,16 +70,16 @@ export declare function FileList({ disableStyle, children, className, style, onC
70
70
  errors: FileUploadFileRejection['errors'];
71
71
  }) => ReactNode;
72
72
  }) & StyleProps): import("react").JSX.Element;
73
- export declare function File({ disableStyle, status, className, children, ...props }: (ArkFileUpload.ItemProps & {
73
+ export declare function File({ disableStyle, status, className, children, ...props }: (Omit<ArkFileUpload.ItemProps, 'asChild'> & {
74
74
  /** Pass the status from the FileList entry so rejected files get the matching error/removal behavior. */
75
75
  status: 'accepted' | 'rejected';
76
76
  }) & StyleProps): import("react").JSX.Element;
77
77
  /** Reads the surrounding File automatically. Omit children to keep the supplied text; override only for custom presentation. */
78
78
  export declare function FileErrorText({ disableStyle, children, className, ...props }: ComponentProps<'p'> & StyleProps): import("react").JSX.Element;
79
- export declare function FilePreview({ disableStyle, className, ...props }: ArkFileUpload.ItemPreviewProps & StyleProps): import("react").JSX.Element;
80
- export declare function FilePreviewImage({ disableStyle, className, ...props }: ArkFileUpload.ItemPreviewImageProps & StyleProps): import("react").JSX.Element;
79
+ export declare function FilePreview({ disableStyle, className, ...props }: Omit<ArkFileUpload.ItemPreviewProps, 'asChild'> & StyleProps): import("react").JSX.Element;
80
+ export declare function FilePreviewImage({ disableStyle, className, ...props }: Omit<ArkFileUpload.ItemPreviewImageProps, 'asChild'> & StyleProps): import("react").JSX.Element;
81
81
  /** Chooses image preview versus fallback from the file type automatically. Supply fallback content for non-image files; do not add a second file-type condition. */
82
- export declare function FileThumbnail({ disableStyle, children, className, ...props }: Omit<ArkFileUpload.ItemPreviewProps, 'type' | 'children'> & {
82
+ export declare function FileThumbnail({ disableStyle, children, className, ...props }: Omit<ArkFileUpload.ItemPreviewProps, 'asChild' | 'type' | 'children'> & {
83
83
  children?: ReactNode;
84
84
  } & StyleProps): import("react").JSX.Element;
85
85
  /** A default icon is supplied. Omit children for the usual case; pass an icon only to replace that visual. */
@@ -88,9 +88,9 @@ export declare function FileThumbnailIcon({ disableStyle, children, className, .
88
88
  children?: ReactElement<ComponentProps<'svg'>>;
89
89
  }) & StyleProps): ReactElement<import("react").SVGProps<SVGSVGElement>, string | import("react").JSXElementConstructor<any>>;
90
90
  /** Reads the surrounding File automatically. Omit children to keep the supplied text; override only for custom presentation. */
91
- export declare function FileName({ disableStyle, className, ...props }: ArkFileUpload.ItemNameProps & StyleProps): import("react").JSX.Element;
91
+ export declare function FileName({ disableStyle, className, ...props }: Omit<ArkFileUpload.ItemNameProps, 'asChild'> & StyleProps): import("react").JSX.Element;
92
92
  /** Reads the surrounding File automatically. Omit children to keep the supplied text; override only for custom presentation. */
93
- export declare function FileSize({ disableStyle, className, ...props }: ArkFileUpload.ItemSizeTextProps & StyleProps): import("react").JSX.Element;
93
+ export declare function FileSize({ disableStyle, className, ...props }: Omit<ArkFileUpload.ItemSizeTextProps, 'asChild'> & StyleProps): import("react").JSX.Element;
94
94
  /** Removes the surrounding file automatically, including rejected entries. No extra removal click handler needed. */
95
95
  export declare function FileRemoveButton({ disableStyle, children, className, ...props }: (Omit<ArkFileUpload.ItemDeleteTriggerProps, 'asChild' | 'children'> & {
96
96
  children?: ReactNode;
@@ -49,34 +49,34 @@ export declare function Root({ children, id, validation, value, defaultValue, on
49
49
  export type InputProps = Omit<BaseInput.Props, 'id' | 'name' | 'form' | 'value' | 'defaultValue' | 'onValueChange' | 'disabled' | 'readOnly' | 'required' | 'type' | 'className' | 'render'> & {
50
50
  className?: string;
51
51
  } & StyleProps;
52
- export declare const Input: import("react").ForwardRefExoticComponent<Omit<InputProps, "ref"> & import("react").RefAttributes<HTMLInputElement>>;
53
- export declare const InputGroup: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & StyleProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
54
- export declare const Container: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & StyleProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
52
+ export declare function Input({ disableStyle, className, 'aria-describedby': describedBy, ref, ...props }: InputProps): import("react").JSX.Element;
53
+ export declare function InputGroup({ disableStyle, className, onClick, ref, ...props }: ComponentProps<'div'> & StyleProps): import("react").JSX.Element;
54
+ export declare function Container({ disableStyle, className, ref, ...props }: ComponentProps<'div'> & StyleProps): import("react").JSX.Element;
55
55
  /** Labels the associated control automatically. Supply the visible text; do not wire a second label association. */
56
- export declare const Label: import("react").ForwardRefExoticComponent<Omit<Omit<import("react").DetailedHTMLProps<import("react").LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>, "htmlFor"> & StyleProps, "ref"> & import("react").RefAttributes<HTMLLabelElement>>;
57
- export declare const Description: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & StyleProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
56
+ export declare function Label({ disableStyle, className, ref, ...props }: Omit<ComponentProps<'label'>, 'htmlFor'> & StyleProps): import("react").JSX.Element;
57
+ export declare function Description({ disableStyle, className, id, ref, ...props }: ComponentProps<'div'> & StyleProps): import("react").JSX.Element;
58
58
  type MessageProps = Omit<ComponentProps<'div'>, 'children'> & StyleProps & {
59
59
  children?: ValidationMessageChildren;
60
60
  };
61
61
  /** Shows itself only while Root's validation is `'error'`: with no children it shows the message from `['error', message]`, a function children formats that message, and other children replace it. */
62
- export declare const Error: import("react").ForwardRefExoticComponent<Omit<MessageProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
62
+ export declare function Error({ children, ref, ...props }: MessageProps): import("react").JSX.Element | null;
63
63
  /** Shows itself only while Root's validation is `'success'`: with no children it shows the message from `['success', message]`, a function children formats that message, and other children replace it. */
64
- export declare const Success: import("react").ForwardRefExoticComponent<Omit<MessageProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
65
- export declare const Addon: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & StyleProps & {
64
+ export declare function Success({ children, ref, ...props }: MessageProps): import("react").JSX.Element | null;
65
+ export declare function Addon({ disableStyle, className, variant, ref, ...props }: ComponentProps<'div'> & StyleProps & {
66
66
  /** Choose the preset appearance; this does not add action behavior. */
67
- variant?: "normal" | "emphasized";
68
- }, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
69
- export declare const AddonText: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLSpanElement> & import("react").HTMLAttributes<HTMLSpanElement> & StyleProps, "ref"> & import("react").RefAttributes<HTMLSpanElement>>;
67
+ variant?: 'normal' | 'emphasized';
68
+ }): import("react").JSX.Element;
69
+ export declare function AddonText({ disableStyle, className, ref, ...props }: ComponentProps<'span'> & StyleProps): import("react").JSX.Element;
70
70
  /** Supply the decorative icon as a child. Its classes are preserved; interaction belongs to the surrounding control. */
71
71
  export declare function AddonIcon(props: Omit<ComponentProps<'svg'>, 'children'> & StyleProps & {
72
72
  /** Supply the decorative icon; the wrapper forwards the relevant state and preserves its classes. */
73
73
  children: ReactElement<ComponentProps<'svg'>>;
74
74
  }): import("react").JSX.Element;
75
- export declare const AddonButton: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLButtonElement> & import("react").ButtonHTMLAttributes<HTMLButtonElement> & StyleProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
75
+ export declare function AddonButton({ disableStyle, className, disabled, type, ref, ...props }: ComponentProps<'button'> & StyleProps): import("react").JSX.Element;
76
76
  /** Built-in icon; no children needed. Use it inside its matching control. */
77
- export declare const AddonLoadingIcon: import("react").ForwardRefExoticComponent<Omit<Omit<SVGIconProps, "children"> & StyleProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
77
+ export declare function AddonLoadingIcon({ disableStyle, className, strokeWidth, ref, ...props }: Omit<SVGIconProps, 'children'> & StyleProps): import("react").JSX.Element;
78
78
  /** Clears the control automatically; no clearing click handler needed. Supply the clear icon and an accessible name. */
79
- export declare const AddonClearButton: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLButtonElement> & import("react").ButtonHTMLAttributes<HTMLButtonElement> & StyleProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
79
+ export declare function AddonClearButton({ disableStyle, className, disabled, onClick, ref, ...props }: ComponentProps<'button'> & StyleProps): import("react").JSX.Element;
80
80
  /** A default icon is supplied. Omit children for the usual case; pass an icon only to replace that visual. */
81
81
  export declare function AddonClearButtonIcon({ children, ...props }: Omit<ComponentProps<'svg'>, 'children'> & StyleProps & {
82
82
  /** Omit for the supplied default icon; pass a child only to replace it. */