@central-ui/react 0.3.0 → 0.5.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 (75) 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 +51 -47
  4. package/dist/components/autocomplete/index.js +57 -57
  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 +31 -11
  9. package/dist/components/carousel/index.js +25 -21
  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 +56 -56
  13. package/dist/components/combobox/index.js +67 -68
  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/exception/index.d.ts +23 -11
  21. package/dist/components/exception/index.js +17 -17
  22. package/dist/components/fileupload/index.d.ts +8 -8
  23. package/dist/components/input/index.d.ts +14 -14
  24. package/dist/components/input/index.js +27 -27
  25. package/dist/components/menu/index.d.ts +37 -37
  26. package/dist/components/menu/index.js +47 -47
  27. package/dist/components/numberinput/index.d.ts +22 -22
  28. package/dist/components/numberinput/index.js +35 -35
  29. package/dist/components/otpinput/index.d.ts +12 -12
  30. package/dist/components/otpinput/index.js +21 -21
  31. package/dist/components/pagination/index.d.ts +158 -0
  32. package/dist/components/pagination/index.js +157 -0
  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 +29 -29
  42. package/dist/components/select/index.js +33 -33
  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 +135 -44
  46. package/dist/components/stepper/index.js +185 -62
  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 +1 -0
  64. package/dist/index.js +1 -0
  65. package/dist/utils/icons.d.ts +104 -23
  66. package/dist/utils/icons.js +16 -3
  67. package/package.json +69 -69
  68. package/src/presets/shopify-polaris/shopify-polaris-accordion.css +28 -28
  69. package/src/presets/shopify-polaris/shopify-polaris-pagination.css +55 -0
  70. package/src/presets/shopify-polaris/shopify-polaris-stepper.css +63 -27
  71. package/src/presets/shopify-polaris/shopify-polaris.css +1 -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-pagination.css +49 -0
  74. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-stepper.css +64 -26
  75. package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy.css +1 -0
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { NumberField as BaseNumber } from '@base-ui/react/number-field';
3
3
  import { ChevronUp, ChevronDown, LoaderCircle } from "../../utils/icons.js";
4
4
  import { useForwardClickToInput } from "../../utils/useForwardClickToInput.js";
5
- import { cloneElement, createContext, forwardRef, useContext, useEffect, useId, useState, } from 'react';
5
+ import { cloneElement, createContext, useContext, useEffect, useId, useState, } from 'react';
6
6
  import { twMerge } from 'tailwind-merge';
7
7
  import { readValidation, validationAttributes, validationMessageContent } from "../../utils/Validation.js";
8
8
  /**
@@ -41,7 +41,7 @@ import { readValidation, validationAttributes, validationMessageContent } from "
41
41
  * }
42
42
  * </NumberInput.Root>
43
43
  */
44
- export const Root = /* @__PURE__ */ forwardRef(function Root({ id, validation, children, ...props }, ref) {
44
+ export function Root({ id, validation, children, ref, ...props }) {
45
45
  const generatedId = useId();
46
46
  const inputId = id ?? generatedId;
47
47
  // Holding the ids of Description, Error and Success, so the control announces them to screen readers through aria-describedby
@@ -55,59 +55,59 @@ export const Root = /* @__PURE__ */ forwardRef(function Root({ id, validation, c
55
55
  max: props.max,
56
56
  validation: readValidation(validation),
57
57
  }, children: _jsx("div", { ...rootProps }) })), children: children }));
58
- });
59
- export const Input = /* @__PURE__ */ forwardRef(function Input({ disableStyle, className, 'aria-describedby': describedBy, ...props }, ref) {
58
+ }
59
+ export function Input({ disableStyle, className, 'aria-describedby': describedBy, ref, ...props }) {
60
60
  const context = useInputContext();
61
61
  return (_jsx(BaseNumber.Input, { ...props, ref: ref, ...validationAttributes(context.validation), "aria-invalid": context.validation.state === 'error' || props['aria-invalid'] || undefined, "aria-describedby": [describedBy, ...context.describedByIds]
62
62
  .filter(Boolean)
63
63
  .join(' ') || undefined, "data-component": "numberinput-input", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
64
- });
65
- export const Container = /* @__PURE__ */ forwardRef(function Container({ disableStyle, className, ...props }, ref) {
64
+ }
65
+ export function Container({ disableStyle, className, ref, ...props }) {
66
66
  const attributes = usePartAttributes();
67
67
  return (_jsx("div", { ...attributes, ...props, ref: ref, "data-component": "numberinput-container", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
68
- });
68
+ }
69
69
  /** Labels the associated control automatically. Supply the visible text; do not wire a second label association. */
70
- export const Label = /* @__PURE__ */ forwardRef(function Label({ disableStyle, className, id, ...props }, ref) {
70
+ export function Label({ disableStyle, className, id, ref, ...props }) {
71
71
  const context = useInputContext();
72
72
  const labelId = id ?? context.inputId + '-label';
73
73
  const attributes = usePartAttributes();
74
74
  return (_jsx("label", { ...attributes, ...props, id: labelId, ref: ref, htmlFor: context.inputId, "data-component": "numberinput-label", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
75
- });
76
- export const Description = /* @__PURE__ */ forwardRef(function Description({ disableStyle, className, id, ...props }, ref) {
75
+ }
76
+ export function Description({ disableStyle, className, id, ref, ...props }) {
77
77
  const messageId = useMessageId(id);
78
78
  const attributes = usePartAttributes();
79
79
  return (_jsx("div", { ...attributes, ...props, id: messageId, ref: ref, "data-component": "numberinput-description", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
80
- });
80
+ }
81
81
  /** 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. */
82
- export const Error = /* @__PURE__ */ forwardRef(function Error({ children, ...props }, ref) {
82
+ export function Error({ children, ref, ...props }) {
83
83
  const context = useInputContext();
84
84
  const content = validationMessageContent(context.validation, 'error', children);
85
85
  if (content === undefined)
86
86
  return null;
87
87
  return _jsx(Message, { ...props, ref: ref, role: "alert", component: "numberinput-error", children: content });
88
- });
88
+ }
89
89
  /** 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. */
90
- export const Success = /* @__PURE__ */ forwardRef(function Success({ children, ...props }, ref) {
90
+ export function Success({ children, ref, ...props }) {
91
91
  const context = useInputContext();
92
92
  const content = validationMessageContent(context.validation, 'success', children);
93
93
  if (content === undefined)
94
94
  return null;
95
95
  return _jsx(Message, { ...props, ref: ref, role: "status", component: "numberinput-success", children: content });
96
- });
96
+ }
97
97
  // The shared body of Error and Success, mounted only while they show, so only visible messages describe the number input
98
- const Message = /* @__PURE__ */ forwardRef(function Message({ disableStyle, className, id, component, ...props }, ref) {
98
+ function Message({ disableStyle, className, id, component, ref, ...props }) {
99
99
  const messageId = useMessageId(id);
100
100
  const attributes = usePartAttributes();
101
101
  return _jsx("div", { "aria-atomic": "true", ...attributes, ...props, id: messageId, ref: ref, "data-component": component, "data-style-disabled": disableStyle ? '' : undefined, className: className });
102
- });
103
- export const Addon = /* @__PURE__ */ forwardRef(function Addon({ disableStyle, className, variant = 'normal', ...props }, ref) {
102
+ }
103
+ export function Addon({ disableStyle, className, variant = 'normal', ref, ...props }) {
104
104
  const attributes = usePartAttributes();
105
105
  return (_jsx("div", { ...attributes, ...props, ref: ref, "data-variant": variant, "data-component": "numberinput-addon", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
106
- });
107
- export const AddonText = /* @__PURE__ */ forwardRef(function AddonText({ disableStyle, className, ...props }, ref) {
106
+ }
107
+ export function AddonText({ disableStyle, className, ref, ...props }) {
108
108
  const attributes = usePartAttributes();
109
109
  return (_jsx("span", { ...attributes, ...props, ref: ref, "data-component": "numberinput-addontext", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
110
- });
110
+ }
111
111
  /** Supply the decorative icon as a child. Its classes are preserved; interaction belongs to the surrounding control. */
112
112
  export function AddonIcon({ disableStyle, children, className, ...props }) {
113
113
  const attributes = usePartAttributes();
@@ -123,34 +123,34 @@ export function AddonIcon({ disableStyle, children, className, ...props }) {
123
123
  className: twMerge(children.props.className, className),
124
124
  });
125
125
  }
126
- export const AddonButton = /* @__PURE__ */ forwardRef(function AddonButton({ disableStyle, className, disabled, type = 'button', ...props }, ref) {
126
+ export function AddonButton({ disableStyle, className, disabled, type = 'button', ref, ...props }) {
127
127
  const context = useInputContext();
128
128
  const attributes = usePartAttributes();
129
129
  return (_jsx("button", { ...attributes, ...props, ref: ref, type: type, disabled: disabled || context.disabled || context.readOnly, "data-component": "numberinput-addonbutton", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
130
- });
130
+ }
131
131
  /** Built-in icon; no children needed. Use it inside its matching control. */
132
- export const AddonLoadingIcon = /* @__PURE__ */ forwardRef(function AddonLoadingIcon({ disableStyle, className, strokeWidth = 1.5, ...props }, ref) {
132
+ export function AddonLoadingIcon({ disableStyle, className, strokeWidth = 1.5, ref, ...props }) {
133
133
  const attributes = usePartAttributes();
134
134
  return (_jsx(LoaderCircle, { ...attributes, "aria-hidden": true, ...props, ref: ref, strokeWidth: strokeWidth, "data-component": "numberinput-addonloadingicon", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
135
- });
136
- export const InputGroup = /* @__PURE__ */ forwardRef(function InputGroup({ disableStyle, className, onClick, ...props }, ref) {
135
+ }
136
+ export function InputGroup({ disableStyle, className, onClick, ref, ...props }) {
137
137
  const attributes = usePartAttributes();
138
138
  const forwardClick = useForwardClickToInput('input:not([type="hidden"])', onClick);
139
139
  return (_jsx(BaseNumber.Group, { ...attributes, ...props, ref: ref, onClick: forwardClick, "data-component": "numberinput-inputgroup", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
140
- });
141
- export const ButtonsList = /* @__PURE__ */ forwardRef(function ButtonsList({ disableStyle, className, ...props }, ref) {
140
+ }
141
+ export function ButtonsList({ disableStyle, className, ref, ...props }) {
142
142
  const attributes = usePartAttributes();
143
143
  return (_jsx("div", { ...attributes, ...props, ref: ref, "data-component": "numberinput-buttonslist", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
144
- });
144
+ }
145
145
  /** Formats the current number automatically. Omit children for the default display; customize only when the usual number formatting is insufficient. */
146
- export const ValueText = /* @__PURE__ */ forwardRef(function ValueText({ disableStyle, className, ...props }, ref) {
146
+ export function ValueText({ disableStyle, className, ref, ...props }) {
147
147
  const context = useInputContext();
148
148
  const attributes = usePartAttributes();
149
149
  return (_jsx("span", { ...attributes, ...props, ref: ref, "data-component": "numberinput-valuetext", "data-style-disabled": disableStyle ? '' : undefined, className: className, children: context.inputValue }));
150
- });
151
- export const IncrementButton = /* @__PURE__ */ forwardRef(function IncrementButton({ disableStyle, className, ...props }, ref) {
150
+ }
151
+ export function IncrementButton({ disableStyle, className, ref, ...props }) {
152
152
  return (_jsx(BaseNumber.Increment, { ...props, ref: ref, "data-component": "numberinput-incrementbutton", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
153
- });
153
+ }
154
154
  /** A default icon is supplied. Omit children for the usual case; pass an icon only to replace that visual. */
155
155
  export function IncrementButtonIcon({ disableStyle, children = _jsx(ChevronUp, {}), className, ...props }) {
156
156
  const context = useInputContext();
@@ -173,9 +173,9 @@ export function IncrementButtonIcon({ disableStyle, children = _jsx(ChevronUp, {
173
173
  className: twMerge(children.props.className, className),
174
174
  });
175
175
  }
176
- export const DecrementButton = /* @__PURE__ */ forwardRef(function DecrementButton({ disableStyle, className, ...props }, ref) {
176
+ export function DecrementButton({ disableStyle, className, ref, ...props }) {
177
177
  return (_jsx(BaseNumber.Decrement, { ...props, ref: ref, "data-component": "numberinput-decrementbutton", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
178
- });
178
+ }
179
179
  /** A default icon is supplied. Omit children for the usual case; pass an icon only to replace that visual. */
180
180
  export function DecrementButtonIcon({ disableStyle, children = _jsx(ChevronDown, {}), className, ...props }) {
181
181
  const context = useInputContext();
@@ -42,27 +42,27 @@ export type RootProps = Omit<BaseOtp.Root.Props, 'className' | 'render'> & {
42
42
  * }
43
43
  * </OtpInput.Root>
44
44
  */
45
- export declare const Root: import("react").ForwardRefExoticComponent<Omit<RootProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
46
- export declare const Input: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").OTPFieldInputProps, "className" | "id" | "name" | "form" | "defaultValue" | "disabled" | "value" | "render" | "required" | "readOnly"> & {
45
+ export declare function Root({ id, validation, children, ref, ...props }: RootProps): import("react").JSX.Element;
46
+ export declare function Input({ disableStyle, className, 'aria-describedby': describedBy, ref, ...props }: (Omit<BaseOtp.Input.Props, 'className' | 'id' | 'value' | 'defaultValue' | 'disabled' | 'readOnly' | 'required' | 'name' | 'form' | 'render'> & {
47
47
  className?: string;
48
- } & StyleProps, "ref"> & import("react").RefAttributes<HTMLInputElement>>;
49
- export declare const Container: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & StyleProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
48
+ }) & StyleProps): import("react").JSX.Element;
49
+ export declare function Container({ disableStyle, className, ref, ...props }: ComponentProps<'div'> & StyleProps): import("react").JSX.Element;
50
50
  /** Labels the associated control automatically. Supply the visible text; do not wire a second label association. */
51
- export declare const Label: import("react").ForwardRefExoticComponent<Omit<Omit<import("react").DetailedHTMLProps<import("react").LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>, "htmlFor"> & StyleProps, "ref"> & import("react").RefAttributes<HTMLLabelElement>>;
52
- export declare const Description: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & StyleProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
51
+ export declare function Label({ disableStyle, className, id, ref, ...props }: Omit<ComponentProps<'label'>, 'htmlFor'> & StyleProps): import("react").JSX.Element;
52
+ export declare function Description({ disableStyle, className, id, ref, ...props }: ComponentProps<'div'> & StyleProps): import("react").JSX.Element;
53
53
  type MessageProps = Omit<ComponentProps<'div'>, 'children'> & StyleProps & {
54
54
  children?: ValidationMessageChildren;
55
55
  };
56
56
  /** 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. */
57
- export declare const Error: import("react").ForwardRefExoticComponent<Omit<MessageProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
57
+ export declare function Error({ children, ref, ...props }: MessageProps): import("react").JSX.Element | null;
58
58
  /** 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. */
59
- export declare const Success: import("react").ForwardRefExoticComponent<Omit<MessageProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
59
+ export declare function Success({ children, ref, ...props }: MessageProps): import("react").JSX.Element | null;
60
60
  /** Calls children for each code slot. Render Input inside each callback; the component handles slot ordering and keyboard/paste behavior. */
61
- export declare const List: import("react").ForwardRefExoticComponent<Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "children"> & {
61
+ export declare function List({ disableStyle, className, children, ref, ...props }: (Omit<ComponentProps<'div'>, 'children'> & {
62
62
  /** Render an Input for each slot. Use the index for keys or separator placement; input ordering is automatic. */
63
63
  children: (index: number) => ReactNode;
64
- } & StyleProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
65
- export declare const Separator: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").SeparatorProps, "className"> & {
64
+ }) & StyleProps): import("react").JSX.Element;
65
+ export declare function Separator({ disableStyle, className, ref, ...props }: (Omit<BaseOtp.Separator.Props, 'className' | 'render'> & {
66
66
  className?: string;
67
- } & StyleProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
67
+ }) & StyleProps): import("react").JSX.Element;
68
68
  export {};
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { OTPField as BaseOtp } from '@base-ui/react/otp-field';
3
- import { Fragment, createContext, forwardRef, useContext, useEffect, useId, useState, } from 'react';
3
+ import { Fragment, createContext, useContext, useEffect, useId, useState, } from 'react';
4
4
  import { readValidation, validationAttributes, validationMessageContent } from "../../utils/Validation.js";
5
5
  /**
6
6
  * Configure length and value on Root. Render an Input for each callback invocation from List; slot order is managed automatically. Keyboard navigation and paste distribution are built in; do not split or synchronize the code yourself.
@@ -36,7 +36,7 @@ import { readValidation, validationAttributes, validationMessageContent } from "
36
36
  * }
37
37
  * </OtpInput.Root>
38
38
  */
39
- export const Root = /* @__PURE__ */ forwardRef(function Root({ id, validation, children, ...props }, ref) {
39
+ export function Root({ id, validation, children, ref, ...props }) {
40
40
  const generatedId = useId();
41
41
  const inputId = id ?? generatedId;
42
42
  const [connections, setConnections] = useState({
@@ -45,19 +45,19 @@ export const Root = /* @__PURE__ */ forwardRef(function Root({ id, validation, c
45
45
  return (_jsx(BaseOtp.Root, { ...props, id: inputId, ref: ref, "aria-labelledby": connections.labelId ?? props['aria-labelledby'], "aria-describedby": [props['aria-describedby'], ...connections.descriptionIds]
46
46
  .filter(Boolean)
47
47
  .join(' ') || undefined, render: (rootProps, state) => (_jsx(InputContext.Provider, { value: { ...state, inputId, connections, setConnections, validation: readValidation(validation) }, children: _jsx("div", { ...rootProps }) })), children: children }));
48
- });
49
- export const Input = /* @__PURE__ */ forwardRef(function Input({ disableStyle, className, 'aria-describedby': describedBy, ...props }, ref) {
48
+ }
49
+ export function Input({ disableStyle, className, 'aria-describedby': describedBy, ref, ...props }) {
50
50
  const context = useInputContext();
51
51
  return (_jsx(BaseOtp.Input, { ...props, ref: ref, ...validationAttributes(context.validation), "aria-invalid": context.validation.state === 'error' || props['aria-invalid'] || undefined, "aria-describedby": [describedBy, ...context.connections.descriptionIds]
52
52
  .filter(Boolean)
53
53
  .join(' ') || undefined, "aria-labelledby": props['aria-labelledby'] ?? context.connections.labelId, "data-component": "otpinput-input", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
54
- });
55
- export const Container = /* @__PURE__ */ forwardRef(function Container({ disableStyle, className, ...props }, ref) {
54
+ }
55
+ export function Container({ disableStyle, className, ref, ...props }) {
56
56
  const attributes = usePartAttributes();
57
57
  return (_jsx("div", { ...attributes, ...props, ref: ref, "data-component": "otpinput-container", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
58
- });
58
+ }
59
59
  /** Labels the associated control automatically. Supply the visible text; do not wire a second label association. */
60
- export const Label = /* @__PURE__ */ forwardRef(function Label({ disableStyle, className, id, ...props }, ref) {
60
+ export function Label({ disableStyle, className, id, ref, ...props }) {
61
61
  const context = useInputContext();
62
62
  const labelId = id ?? context.inputId + '-label';
63
63
  const attributes = usePartAttributes();
@@ -69,43 +69,43 @@ export const Label = /* @__PURE__ */ forwardRef(function Label({ disableStyle, c
69
69
  }));
70
70
  }, [labelId, context.setConnections]);
71
71
  return (_jsx("label", { ...attributes, ...props, id: labelId, ref: ref, htmlFor: context.inputId, "data-component": "otpinput-label", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
72
- });
73
- export const Description = /* @__PURE__ */ forwardRef(function Description({ disableStyle, className, id, ...props }, ref) {
72
+ }
73
+ export function Description({ disableStyle, className, id, ref, ...props }) {
74
74
  const messageId = useMessageId(id);
75
75
  const attributes = usePartAttributes();
76
76
  return (_jsx("div", { ...attributes, ...props, id: messageId, ref: ref, "data-component": "otpinput-description", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
77
- });
77
+ }
78
78
  /** 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. */
79
- export const Error = /* @__PURE__ */ forwardRef(function Error({ children, ...props }, ref) {
79
+ export function Error({ children, ref, ...props }) {
80
80
  const context = useInputContext();
81
81
  const content = validationMessageContent(context.validation, 'error', children);
82
82
  if (content === undefined)
83
83
  return null;
84
84
  return _jsx(Message, { ...props, ref: ref, role: "alert", component: "otpinput-error", children: content });
85
- });
85
+ }
86
86
  /** 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. */
87
- export const Success = /* @__PURE__ */ forwardRef(function Success({ children, ...props }, ref) {
87
+ export function Success({ children, ref, ...props }) {
88
88
  const context = useInputContext();
89
89
  const content = validationMessageContent(context.validation, 'success', children);
90
90
  if (content === undefined)
91
91
  return null;
92
92
  return _jsx(Message, { ...props, ref: ref, role: "status", component: "otpinput-success", children: content });
93
- });
93
+ }
94
94
  // The shared body of Error and Success, mounted only while they show, so only visible messages describe the otp input
95
- const Message = /* @__PURE__ */ forwardRef(function Message({ disableStyle, className, id, component, ...props }, ref) {
95
+ function Message({ disableStyle, className, id, component, ref, ...props }) {
96
96
  const messageId = useMessageId(id);
97
97
  const attributes = usePartAttributes();
98
98
  return _jsx("div", { "aria-atomic": "true", ...attributes, ...props, id: messageId, ref: ref, "data-component": component, "data-style-disabled": disableStyle ? '' : undefined, className: className });
99
- });
99
+ }
100
100
  /** Calls children for each code slot. Render Input inside each callback; the component handles slot ordering and keyboard/paste behavior. */
101
- export const List = /* @__PURE__ */ forwardRef(function List({ disableStyle, className, children, ...props }, ref) {
101
+ export function List({ disableStyle, className, children, ref, ...props }) {
102
102
  const context = useInputContext();
103
103
  const attributes = usePartAttributes();
104
104
  return (_jsx("div", { ...attributes, ...props, ref: ref, "data-component": "otpinput-list", "data-style-disabled": disableStyle ? '' : undefined, className: className, children: Array.from({ length: context.length }, (_, index) => (_jsx(Fragment, { children: children(index) }, index))) }));
105
- });
106
- export const Separator = /* @__PURE__ */ forwardRef(function Separator({ disableStyle, className, ...props }, ref) {
105
+ }
106
+ export function Separator({ disableStyle, className, ref, ...props }) {
107
107
  return (_jsx(BaseOtp.Separator, { ...props, ref: ref, "data-component": "otpinput-separator", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
108
- });
108
+ }
109
109
  const InputContext = /* @__PURE__ */ createContext(null);
110
110
  function useInputContext() {
111
111
  const context = useContext(InputContext);
@@ -0,0 +1,158 @@
1
+ import type { StyleProps } from '../../types/Style.ts';
2
+ import type { SVGIconProps } from '../../types/Icon.ts';
3
+ import type { ComponentProps, HTMLAttributes, ReactElement, ReactNode, Ref } from 'react';
4
+ /** One entry of PageList: a page to go to, or a gap standing for the pages hidden between two numbers. */
5
+ export type PageItem = {
6
+ type: 'page';
7
+ value: number;
8
+ } | {
9
+ type: 'ellipsis';
10
+ index: number;
11
+ };
12
+ export type RootProps = {
13
+ /** The total number of data items, like rows in a table; the page count is worked out from it and pageSize. */
14
+ count: number;
15
+ /** The current page, from 1. Use with onPageChange to control it yourself, like reading it from the URL search params. */
16
+ page?: number;
17
+ /**
18
+ * The page shown first, when you don't control page.
19
+ * @default 1
20
+ */
21
+ defaultPage?: number;
22
+ /** Called with the new page whenever it changes, from a click, or from count or pageSize shrinking so the current page no longer exists. */
23
+ onPageChange?: (page: number) => void;
24
+ /**
25
+ * How many data items one page holds. Together with count, it decides how many pages exist: 240 items at 20 per page make 12 pages.
26
+ * To let the user pick it, like from a "Rows per page" select, keep it in your own state and pass it here.
27
+ * @default 10
28
+ */
29
+ pageSize?: number;
30
+ /**
31
+ * How many page numbers show on each side of the current page, before a gap (…) hides the rest.
32
+ * With page 10 of 20: 1 shows "1 … 9 10 11 … 20", 2 shows "1 … 8 9 10 11 12 … 20", 0 shows "1 … 10 … 20". Lower it for narrow screens.
33
+ * @default 1
34
+ */
35
+ siblingCount?: number;
36
+ /**
37
+ * How many page numbers always show at the very start and the very end, however far the current page is from them.
38
+ * With page 10 of 20: 1 shows "1 … 9 10 11 … 20", 2 shows "1 2 … 9 10 11 … 19 20".
39
+ * @default 1
40
+ */
41
+ boundaryCount?: number;
42
+ /** The Container. */
43
+ children: ReactNode;
44
+ };
45
+ /**
46
+ * Splits a long list of items, like a table's rows, into pages and lets the user move between them.
47
+ * Root holds the page state and renders nothing itself; Container renders the row. It only tracks the page: showing that page's items is up to you, from page and pageSize.
48
+ * PageList renders a Page for every page number and gap it decides to show. First/Previous/Next/Last buttons are optional, and disable themselves on the first or last page.
49
+ * Screen readers hear English labels, like "next page" or "page 3"; to translate one, pass your own aria-label to that part.
50
+ *
51
+ * @example Complete composition
52
+ * import { Pagination } from '@central-ui/react'
53
+ *
54
+ * function Example() {
55
+ * return (
56
+ * <Pagination.Root count={240} pageSize={20}>
57
+ * <Pagination.Container>
58
+ * <Pagination.FirstButton>
59
+ * <Pagination.FirstButtonIcon />
60
+ * </Pagination.FirstButton>
61
+ * <Pagination.PreviousButton>
62
+ * <Pagination.PreviousButtonIcon />
63
+ * </Pagination.PreviousButton>
64
+ * <Pagination.PageList>{(item) => <Pagination.Page item={item} />}</Pagination.PageList>
65
+ * <Pagination.NextButton>
66
+ * <Pagination.NextButtonIcon />
67
+ * </Pagination.NextButton>
68
+ * <Pagination.LastButton>
69
+ * <Pagination.LastButtonIcon />
70
+ * </Pagination.LastButton>
71
+ * </Pagination.Container>
72
+ * </Pagination.Root>
73
+ * )
74
+ * }
75
+ *
76
+ * @example Control the page, like keeping it in the URL search params
77
+ * const { page } = Route.useSearch()
78
+ * const navigate = Route.useNavigate()
79
+ *
80
+ * ;<Pagination.Root
81
+ * count={orders.total}
82
+ * pageSize={20}
83
+ * page={page}
84
+ * onPageChange={(page) => navigate({ search: { page } })}
85
+ * >
86
+ * {
87
+ * // Rest of components here
88
+ * }
89
+ * </Pagination.Root>
90
+ *
91
+ * @example Previous and next only, without page numbers
92
+ * ;<Pagination.Root count={240} pageSize={20}>
93
+ * <Pagination.Container>
94
+ * <Pagination.PreviousButton>
95
+ * <Pagination.PreviousButtonIcon />
96
+ * </Pagination.PreviousButton>
97
+ * <Pagination.NextButton>
98
+ * <Pagination.NextButtonIcon />
99
+ * </Pagination.NextButton>
100
+ * </Pagination.Container>
101
+ * </Pagination.Root>
102
+ */
103
+ export declare function Root({ onPageChange, children, ...props }: RootProps): import("react").JSX.Element;
104
+ /** Lays out the buttons and PageList in a row. Renders a nav labeled for screen readers, no setup needed. */
105
+ export declare function Container({ disableStyle, className, ref, ...props }: ComponentProps<'nav'> & StyleProps): import("react").JSX.Element;
106
+ /**
107
+ * Renders one Page per page number and gap through its children function, which receives that entry.
108
+ * Which numbers show, and where gaps go, comes from the current page, siblingCount and boundaryCount.
109
+ *
110
+ * @example
111
+ * ;<Pagination.PageList>{(item) => <Pagination.Page item={item} />}</Pagination.PageList>
112
+ */
113
+ export declare function PageList({ disableStyle, className, children, ref, ...props }: Omit<ComponentProps<'div'>, 'children'> & StyleProps & {
114
+ /** Called once per page number or gap; return a Page. */
115
+ children: (item: PageItem) => ReactNode;
116
+ }): import("react").JSX.Element;
117
+ /**
118
+ * Renders the item it receives from PageList: a page button going to that page on click (no click handler needed), carrying data-selected while current, or a gap.
119
+ * Shows the page number or an ellipsis icon by default. Carries data-type="page" or data-type="ellipsis", to style each its own way.
120
+ *
121
+ * @example Custom content
122
+ * ;<Pagination.PageList>
123
+ * {(item) => (
124
+ * <Pagination.Page item={item}>
125
+ * {(item) => (item.type === 'page' ? `P${item.value}` : '…')}
126
+ * </Pagination.Page>
127
+ * )}
128
+ * </Pagination.PageList>
129
+ */
130
+ export declare function Page({ item, children, disableStyle, className, ref, ...props }: Omit<HTMLAttributes<HTMLElement>, 'children'> & StyleProps & {
131
+ /** The entry received from PageList's children function. */
132
+ item: PageItem;
133
+ /** Omit for the page number, or the ellipsis icon for a gap. Pass a function only to show something else, from the item. */
134
+ children?: ReactNode | ((item: PageItem) => ReactNode);
135
+ ref?: Ref<HTMLButtonElement | HTMLDivElement>;
136
+ }): import("react").JSX.Element;
137
+ type ButtonPartProps = Omit<ComponentProps<'button'>, 'type'> & StyleProps;
138
+ /** Goes to the first page; no click handler needed. Disabled on the first page. Supply its content: normally FirstButtonIcon, optionally next to a text like "First"; it stays square with only the icon and widens for text. */
139
+ export declare function FirstButton({ disableStyle, ...props }: ButtonPartProps): import("react").JSX.Element;
140
+ /** Goes to the previous page; no click handler needed. Disabled on the first page. Supply its content: normally PreviousButtonIcon, optionally next to a text like "Previous"; it stays square with only the icon and widens for text. */
141
+ export declare function PreviousButton({ disableStyle, ...props }: ButtonPartProps): import("react").JSX.Element;
142
+ /** Goes to the next page; no click handler needed. Disabled on the last page. Supply its content: normally NextButtonIcon, optionally next to a text like "Next"; it stays square with only the icon and widens for text. */
143
+ export declare function NextButton({ disableStyle, ...props }: ButtonPartProps): import("react").JSX.Element;
144
+ /** Goes to the last page; no click handler needed. Disabled on the last page. Supply its content: normally LastButtonIcon, optionally next to a text like "Last"; it stays square with only the icon and widens for text. */
145
+ export declare function LastButton({ disableStyle, ...props }: ButtonPartProps): import("react").JSX.Element;
146
+ type BuiltInIconProps = Omit<SVGIconProps, 'children'> & StyleProps & {
147
+ /** Omit for the supplied default icon; pass a child icon only to replace it. */
148
+ children?: ReactElement<SVGIconProps>;
149
+ };
150
+ /** Built-in decorative first-page icon. Place inside FirstButton. Omit children for the supplied default icon; pass an icon only to replace it. Defaults to strokeWidth 2. */
151
+ export declare function FirstButtonIcon(props: BuiltInIconProps): import("react").JSX.Element;
152
+ /** Built-in decorative previous icon. Place inside PreviousButton. Omit children for the supplied default icon; pass an icon only to replace it. Defaults to strokeWidth 2. */
153
+ export declare function PreviousButtonIcon(props: BuiltInIconProps): import("react").JSX.Element;
154
+ /** Built-in decorative next icon. Place inside NextButton. Omit children for the supplied default icon; pass an icon only to replace it. Defaults to strokeWidth 2. */
155
+ export declare function NextButtonIcon(props: BuiltInIconProps): import("react").JSX.Element;
156
+ /** Built-in decorative last-page icon. Place inside LastButton. Omit children for the supplied default icon; pass an icon only to replace it. Defaults to strokeWidth 2. */
157
+ export declare function LastButtonIcon(props: BuiltInIconProps): import("react").JSX.Element;
158
+ export {};
@@ -0,0 +1,157 @@
1
+ import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
2
+ import { ChevronFirst, ChevronLast, ChevronLeft, ChevronRight, Ellipsis } from "../../utils/icons.js";
3
+ import { Pagination as ArkPagination, usePagination, usePaginationContext } from '@ark-ui/react/pagination';
4
+ import { Fragment, cloneElement } from 'react';
5
+ import { twMerge } from 'tailwind-merge';
6
+ /**
7
+ * Splits a long list of items, like a table's rows, into pages and lets the user move between them.
8
+ * Root holds the page state and renders nothing itself; Container renders the row. It only tracks the page: showing that page's items is up to you, from page and pageSize.
9
+ * PageList renders a Page for every page number and gap it decides to show. First/Previous/Next/Last buttons are optional, and disable themselves on the first or last page.
10
+ * Screen readers hear English labels, like "next page" or "page 3"; to translate one, pass your own aria-label to that part.
11
+ *
12
+ * @example Complete composition
13
+ * import { Pagination } from '@central-ui/react'
14
+ *
15
+ * function Example() {
16
+ * return (
17
+ * <Pagination.Root count={240} pageSize={20}>
18
+ * <Pagination.Container>
19
+ * <Pagination.FirstButton>
20
+ * <Pagination.FirstButtonIcon />
21
+ * </Pagination.FirstButton>
22
+ * <Pagination.PreviousButton>
23
+ * <Pagination.PreviousButtonIcon />
24
+ * </Pagination.PreviousButton>
25
+ * <Pagination.PageList>{(item) => <Pagination.Page item={item} />}</Pagination.PageList>
26
+ * <Pagination.NextButton>
27
+ * <Pagination.NextButtonIcon />
28
+ * </Pagination.NextButton>
29
+ * <Pagination.LastButton>
30
+ * <Pagination.LastButtonIcon />
31
+ * </Pagination.LastButton>
32
+ * </Pagination.Container>
33
+ * </Pagination.Root>
34
+ * )
35
+ * }
36
+ *
37
+ * @example Control the page, like keeping it in the URL search params
38
+ * const { page } = Route.useSearch()
39
+ * const navigate = Route.useNavigate()
40
+ *
41
+ * ;<Pagination.Root
42
+ * count={orders.total}
43
+ * pageSize={20}
44
+ * page={page}
45
+ * onPageChange={(page) => navigate({ search: { page } })}
46
+ * >
47
+ * {
48
+ * // Rest of components here
49
+ * }
50
+ * </Pagination.Root>
51
+ *
52
+ * @example Previous and next only, without page numbers
53
+ * ;<Pagination.Root count={240} pageSize={20}>
54
+ * <Pagination.Container>
55
+ * <Pagination.PreviousButton>
56
+ * <Pagination.PreviousButtonIcon />
57
+ * </Pagination.PreviousButton>
58
+ * <Pagination.NextButton>
59
+ * <Pagination.NextButtonIcon />
60
+ * </Pagination.NextButton>
61
+ * </Pagination.Container>
62
+ * </Pagination.Root>
63
+ */
64
+ export function Root({ onPageChange, children, ...props }) {
65
+ const pagination = usePagination({
66
+ ...props,
67
+ onPageChange: onPageChange && ((details) => onPageChange(details.page)),
68
+ });
69
+ return (_jsx(ArkPagination.RootProvider, { value: pagination, asChild: true, children: _jsx(_Fragment, { children: children }) }));
70
+ }
71
+ /** Lays out the buttons and PageList in a row. Renders a nav labeled for screen readers, no setup needed. */
72
+ export function Container({ disableStyle, className, ref, ...props }) {
73
+ const pagination = usePaginationContext();
74
+ return (_jsx("nav", { ...pagination.getRootProps(), ...props, ref: ref, "data-component": "pagination-container", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
75
+ }
76
+ /**
77
+ * Renders one Page per page number and gap through its children function, which receives that entry.
78
+ * Which numbers show, and where gaps go, comes from the current page, siblingCount and boundaryCount.
79
+ *
80
+ * @example
81
+ * ;<Pagination.PageList>{(item) => <Pagination.Page item={item} />}</Pagination.PageList>
82
+ */
83
+ export function PageList({ disableStyle, className, children, ref, ...props }) {
84
+ const pagination = usePaginationContext();
85
+ return (_jsx("div", { ...props, ref: ref, "data-component": "pagination-pagelist", "data-style-disabled": disableStyle ? '' : undefined, className: className, children: pagination.pages.map((page, index) => (_jsx(Fragment, { children: children(page.type === 'page' ? page : { type: 'ellipsis', index }) }, page.type === 'page' ? `page-${page.value}` : `ellipsis-${index}`))) }));
86
+ }
87
+ /**
88
+ * Renders the item it receives from PageList: a page button going to that page on click (no click handler needed), carrying data-selected while current, or a gap.
89
+ * Shows the page number or an ellipsis icon by default. Carries data-type="page" or data-type="ellipsis", to style each its own way.
90
+ *
91
+ * @example Custom content
92
+ * ;<Pagination.PageList>
93
+ * {(item) => (
94
+ * <Pagination.Page item={item}>
95
+ * {(item) => (item.type === 'page' ? `P${item.value}` : '…')}
96
+ * </Pagination.Page>
97
+ * )}
98
+ * </Pagination.PageList>
99
+ */
100
+ export function Page({ item, children, disableStyle, className, ref, ...props }) {
101
+ const content = typeof children === 'function'
102
+ ? children(item)
103
+ : (children ?? (item.type === 'page' ? item.value : _jsx(Ellipsis, { "aria-hidden": true, strokeWidth: 2, "data-component": "pagination-pageicon" })));
104
+ const attributes = {
105
+ 'data-component': 'pagination-page',
106
+ 'data-style-disabled': disableStyle ? '' : undefined,
107
+ 'data-type': item.type,
108
+ className,
109
+ };
110
+ if (item.type === 'ellipsis') {
111
+ return (_jsx(ArkPagination.Ellipsis, { ...props, ...attributes, ref: ref, index: item.index, children: content }));
112
+ }
113
+ return (_jsx(ArkPagination.Item, { ...props, ...attributes, ref: ref, type: "page", value: item.value, children: content }));
114
+ }
115
+ /** Goes to the first page; no click handler needed. Disabled on the first page. Supply its content: normally FirstButtonIcon, optionally next to a text like "First"; it stays square with only the icon and widens for text. */
116
+ export function FirstButton({ disableStyle, ...props }) {
117
+ return _jsx(ArkPagination.FirstTrigger, { ...props, "data-component": "pagination-firstbutton", "data-style-disabled": disableStyle ? '' : undefined });
118
+ }
119
+ /** Goes to the previous page; no click handler needed. Disabled on the first page. Supply its content: normally PreviousButtonIcon, optionally next to a text like "Previous"; it stays square with only the icon and widens for text. */
120
+ export function PreviousButton({ disableStyle, ...props }) {
121
+ return _jsx(ArkPagination.PrevTrigger, { ...props, "data-component": "pagination-previousbutton", "data-style-disabled": disableStyle ? '' : undefined });
122
+ }
123
+ /** Goes to the next page; no click handler needed. Disabled on the last page. Supply its content: normally NextButtonIcon, optionally next to a text like "Next"; it stays square with only the icon and widens for text. */
124
+ export function NextButton({ disableStyle, ...props }) {
125
+ return _jsx(ArkPagination.NextTrigger, { ...props, "data-component": "pagination-nextbutton", "data-style-disabled": disableStyle ? '' : undefined });
126
+ }
127
+ /** Goes to the last page; no click handler needed. Disabled on the last page. Supply its content: normally LastButtonIcon, optionally next to a text like "Last"; it stays square with only the icon and widens for text. */
128
+ export function LastButton({ disableStyle, ...props }) {
129
+ return _jsx(ArkPagination.LastTrigger, { ...props, "data-component": "pagination-lastbutton", "data-style-disabled": disableStyle ? '' : undefined });
130
+ }
131
+ /** Built-in decorative first-page icon. Place inside FirstButton. Omit children for the supplied default icon; pass an icon only to replace it. Defaults to strokeWidth 2. */
132
+ export function FirstButtonIcon(props) {
133
+ return _jsx(BuiltInIcon, { ...props, icon: ChevronFirst, component: "pagination-firstbuttonicon" });
134
+ }
135
+ /** Built-in decorative previous icon. Place inside PreviousButton. Omit children for the supplied default icon; pass an icon only to replace it. Defaults to strokeWidth 2. */
136
+ export function PreviousButtonIcon(props) {
137
+ return _jsx(BuiltInIcon, { ...props, icon: ChevronLeft, component: "pagination-previousbuttonicon" });
138
+ }
139
+ /** Built-in decorative next icon. Place inside NextButton. Omit children for the supplied default icon; pass an icon only to replace it. Defaults to strokeWidth 2. */
140
+ export function NextButtonIcon(props) {
141
+ return _jsx(BuiltInIcon, { ...props, icon: ChevronRight, component: "pagination-nextbuttonicon" });
142
+ }
143
+ /** Built-in decorative last-page icon. Place inside LastButton. Omit children for the supplied default icon; pass an icon only to replace it. Defaults to strokeWidth 2. */
144
+ export function LastButtonIcon(props) {
145
+ return _jsx(BuiltInIcon, { ...props, icon: ChevronLast, component: "pagination-lastbuttonicon" });
146
+ }
147
+ // The shared body of the built-in decorative icons above, which only differ by their icon and component name
148
+ function BuiltInIcon({ disableStyle, className, strokeWidth, icon: Icon, component, children, ...props }) {
149
+ return cloneElement(children ?? _jsx(Icon, {}), {
150
+ 'aria-hidden': true,
151
+ ...props,
152
+ strokeWidth: strokeWidth ?? children?.props.strokeWidth ?? 2,
153
+ 'data-component': component,
154
+ 'data-style-disabled': disableStyle ? '' : undefined,
155
+ className: twMerge(children?.props.className, className),
156
+ });
157
+ }