@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.
- package/dist/components/accordion/index.d.ts +14 -14
- package/dist/components/accordion/index.js +19 -19
- package/dist/components/autocomplete/index.d.ts +57 -49
- package/dist/components/autocomplete/index.js +69 -60
- package/dist/components/avatar/index.d.ts +7 -6
- package/dist/components/avatar/index.js +9 -9
- package/dist/components/banner/index.js +1 -1
- package/dist/components/carousel/index.d.ts +189 -0
- package/dist/components/carousel/index.js +303 -0
- package/dist/components/checkbox/index.d.ts +12 -11
- package/dist/components/checkbox/index.js +21 -21
- package/dist/components/combobox/index.d.ts +67 -71
- package/dist/components/combobox/index.js +80 -72
- package/dist/components/datepicker/index.d.ts +8 -9
- package/dist/components/datepicker/index.js +13 -13
- package/dist/components/dialog/index.d.ts +18 -18
- package/dist/components/dialog/index.js +22 -21
- package/dist/components/drawer/index.d.ts +24 -24
- package/dist/components/drawer/index.js +28 -27
- package/dist/components/empty/index.d.ts +2 -1
- package/dist/components/empty/index.js +2 -1
- package/dist/components/exception/index.d.ts +98 -0
- package/dist/components/exception/index.js +116 -0
- package/dist/components/fileupload/index.d.ts +8 -8
- package/dist/components/input/index.d.ts +14 -14
- package/dist/components/input/index.js +27 -27
- package/dist/components/menu/index.d.ts +37 -37
- package/dist/components/menu/index.js +47 -47
- package/dist/components/numberinput/index.d.ts +22 -22
- package/dist/components/numberinput/index.js +35 -35
- package/dist/components/otpinput/index.d.ts +12 -12
- package/dist/components/otpinput/index.js +21 -21
- package/dist/components/passwordinput/index.d.ts +15 -15
- package/dist/components/passwordinput/index.js +27 -27
- package/dist/components/popover/index.d.ts +16 -16
- package/dist/components/popover/index.js +20 -19
- package/dist/components/radio/index.d.ts +12 -12
- package/dist/components/radio/index.js +25 -25
- package/dist/components/ratinginput/index.d.ts +1 -1
- package/dist/components/ratinginput/index.js +3 -3
- package/dist/components/select/index.d.ts +32 -29
- package/dist/components/select/index.js +45 -35
- package/dist/components/slider/index.d.ts +20 -20
- package/dist/components/slider/index.js +27 -27
- package/dist/components/stepper/index.d.ts +8 -7
- package/dist/components/stepper/index.js +4 -2
- package/dist/components/switch/index.d.ts +9 -9
- package/dist/components/switch/index.js +17 -17
- package/dist/components/table/index.d.ts +2 -2
- package/dist/components/table/index.js +16 -16
- package/dist/components/tabs/index.d.ts +10 -10
- package/dist/components/tabs/index.js +11 -11
- package/dist/components/textarea/index.d.ts +13 -13
- package/dist/components/textarea/index.js +25 -25
- package/dist/components/toast/index.d.ts +11 -11
- package/dist/components/toast/index.js +11 -11
- package/dist/components/toggle/index.d.ts +7 -7
- package/dist/components/toggle/index.js +9 -9
- package/dist/components/tooltip/index.d.ts +6 -6
- package/dist/components/tooltip/index.js +6 -7
- package/dist/components/tour/index.d.ts +2 -2
- package/dist/components/tour/index.js +5 -4
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/utils/icons.d.ts +92 -23
- package/dist/utils/icons.js +3 -3
- package/package.json +69 -67
- package/src/presets/shopify-polaris/shopify-polaris-accordion.css +28 -28
- package/src/presets/shopify-polaris/shopify-polaris-carousel.css +62 -0
- package/src/presets/shopify-polaris/shopify-polaris-exception.css +40 -0
- package/src/presets/shopify-polaris/shopify-polaris.css +2 -0
- package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-accordion.css +28 -28
- package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-carousel.css +55 -0
- package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-exception.css +40 -0
- package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy.css +2 -0
- package/dist/types/Tone.d.ts +0 -3
- package/dist/types/Tone.js +0 -1
- package/dist/utils/Tone.d.ts +0 -2
- package/dist/utils/Tone.js +0 -6
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Combobox as BaseCombobox } from '@base-ui/react/combobox';
|
|
3
3
|
import { Check, ChevronsUpDown, LoaderCircle, X } from "../../utils/icons.js";
|
|
4
|
-
import { cloneElement, createContext,
|
|
4
|
+
import { cloneElement, createContext, useContext, useEffect, useId, useState } from 'react';
|
|
5
5
|
import { twMerge } from 'tailwind-merge';
|
|
6
6
|
import { readValidation, validationAttributes, validationMessageContent } from "../../utils/Validation.js";
|
|
7
7
|
/**
|
|
@@ -181,23 +181,20 @@ export function Root({ children, id, validation, defaultOpen = false, onOpenChan
|
|
|
181
181
|
}, children: children }) }));
|
|
182
182
|
}
|
|
183
183
|
/** Use for the standard stacked layout, or omit when supplying your own layout. */
|
|
184
|
-
export
|
|
184
|
+
export function Container({ disableStyle, className, ref, ...props }) {
|
|
185
185
|
return (_jsx("div", { ...props, ref: ref, "data-component": "combobox-container", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
186
|
-
}
|
|
186
|
+
}
|
|
187
187
|
/** Labels the input automatically using Root's id. Supply the visible label as children; no htmlFor needed. */
|
|
188
|
-
export
|
|
188
|
+
export function Label({ disableStyle, className, ref, ...props }) {
|
|
189
189
|
const context = useComboboxContext();
|
|
190
190
|
const attributes = usePartAttributes();
|
|
191
191
|
return (_jsx("label", { ...attributes, ...props, ref: ref, htmlFor: context.inputId, "data-component": "combobox-label", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
192
|
-
}
|
|
192
|
+
}
|
|
193
193
|
/** Search input with built-in filtering and selected-label display. Its id is managed by Root. Inside ChipsList, the preset automatically uses the compact chip-input sizing. */
|
|
194
|
-
export
|
|
194
|
+
export function Input({ disableStyle, className, 'aria-describedby': describedBy, ref, ...props }) {
|
|
195
195
|
const context = useComboboxContext();
|
|
196
196
|
const inChips = useContext(ChipsContext);
|
|
197
197
|
return (_jsx(BaseCombobox.Input, { "aria-invalid": context.validation.state === 'error' || undefined, "aria-describedby": [describedBy, ...context.describedByIds].filter(Boolean).join(' ') || undefined, ...props, ref: ref, id: context.inputId, "data-component": "combobox-input", "data-style-disabled": disableStyle ? '' : undefined, "data-in-chips": inChips ? '' : undefined, className: className }));
|
|
198
|
-
});
|
|
199
|
-
function ChipsListInner({ disableStyle, children, className, ...props }, ref) {
|
|
200
|
-
return (_jsx(BaseCombobox.Value, { children: (selected) => (_jsx(ChipsContext.Provider, { value: true, children: _jsx(BaseCombobox.Chips, { ...props, ref: ref, "data-slot": "chips-list", "data-component": "combobox-chipslist", "data-style-disabled": disableStyle ? '' : undefined, className: className, children: typeof children === 'function' ? children(selected) : children }) })) }));
|
|
201
198
|
}
|
|
202
199
|
/**
|
|
203
200
|
* Selected-item chips inside InputGroup for multiple selection.
|
|
@@ -225,13 +222,15 @@ function ChipsListInner({ disableStyle, children, className, ...props }, ref) {
|
|
|
225
222
|
* </Combobox.ChipsList>
|
|
226
223
|
* </Combobox.InputGroup>
|
|
227
224
|
*/
|
|
228
|
-
export
|
|
225
|
+
export function ChipsList({ disableStyle, children, className, ref, ...props }) {
|
|
226
|
+
return (_jsx(BaseCombobox.Value, { children: (selected) => (_jsx(ChipsContext.Provider, { value: true, children: _jsx(BaseCombobox.Chips, { ...props, ref: ref, "data-slot": "chips-list", "data-component": "combobox-chipslist", "data-style-disabled": disableStyle ? '' : undefined, className: className, children: typeof children === 'function' ? children(selected) : children }) })) }));
|
|
227
|
+
}
|
|
229
228
|
/** Reads Base UI selection without rendering its own element. Use its children callback only when you need a custom selection display; Input already displays the selected label automatically. */
|
|
230
229
|
export const Value = BaseCombobox.Value;
|
|
231
230
|
/** Required listbox and scroll viewport inside Popup. Place GroupsList inside it. Owns keyboard/listbox semantics; do not nest another listbox primitive. */
|
|
232
|
-
export
|
|
231
|
+
export function ScrollArea({ disableStyle, className, ref, ...props }) {
|
|
233
232
|
return (_jsx(BaseCombobox.List, { ...props, ref: ref, "data-component": "combobox-scrollarea", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
234
|
-
}
|
|
233
|
+
}
|
|
235
234
|
/** Required groups container inside ScrollArea. A children callback receives each automatically filtered group; do not filter or map the original groups again. Manually annotate group with Combobox.GroupType<typeof rootItems>, using the exact items variable passed to Root. */
|
|
236
235
|
export function GroupsList({ disableStyle, children, className, ...props }) {
|
|
237
236
|
return (_jsx("div", { ...props, "data-component": "combobox-groupslist", "data-style-disabled": disableStyle ? '' : undefined, className: className, children: typeof children === 'function' ? (_jsx(BaseCombobox.Collection, { children: children })) : (children) }));
|
|
@@ -259,15 +258,15 @@ export function Popup({ disableStyle, container, keepMounted, anchor, positionMe
|
|
|
259
258
|
: { ...baseStyle, ...style } }) }) }));
|
|
260
259
|
}
|
|
261
260
|
/** Optional decorative popup arrow. Place inside Popup; the SVG and direction handling are supplied. No children needed. */
|
|
262
|
-
export
|
|
261
|
+
export function Arrow({ disableStyle, className, style, ref, ...props }) {
|
|
263
262
|
return (_jsxs(BaseCombobox.Arrow, { style: style, render: _jsx("svg", { ...props, ref: ref, "aria-hidden": true, width: "20", height: "10", viewBox: "0 0 20 10" }), "data-component": "combobox-arrow", "data-style-disabled": disableStyle ? '' : undefined, className: className, children: [_jsx("path", { d: "M9.66437 2.60207L4.80758 6.97318C4.07308 7.63423 3.11989 8 2.13172 8H0V10H20V8H18.5349C17.5468 8 16.5936 7.63423 15.8591 6.97318L11.0023 2.60207C10.622 2.2598 10.0447 2.25979 9.66437 2.60207Z", "data-component": "combobox-arrow-1" }), _jsx("path", { d: "M8.99542 1.85876C9.75604 1.17425 10.9106 1.17422 11.6713 1.85878L16.5281 6.22989C17.0789 6.72568 17.7938 7.00001 18.5349 7.00001L15.89 7L11.0023 2.60207C10.622 2.2598 10.0447 2.2598 9.66436 2.60207L4.77734 7L2.13171 7.00001C2.87284 7.00001 3.58774 6.72568 4.13861 6.22989L8.99542 1.85876Z", "data-component": "combobox-arrow-2" }), _jsx("path", { d: "M10.3333 3.34539L5.47654 7.71648C4.55842 8.54279 3.36693 9 2.13172 9H0V8H2.13172C3.11989 8 4.07308 7.63423 4.80758 6.97318L9.66437 2.60207C10.0447 2.25979 10.622 2.2598 11.0023 2.60207L15.8591 6.97318C16.5936 7.63423 17.5468 8 18.5349 8H20V9H18.5349C17.2998 9 16.1083 8.54278 15.1901 7.71648L10.3333 3.34539Z", "data-component": "combobox-arrow-3" })] }));
|
|
264
|
-
}
|
|
263
|
+
}
|
|
265
264
|
/** Optional input adornment container inside InputGroup. Wraps icons, text, or buttons without adding trigger behavior. */
|
|
266
|
-
export
|
|
265
|
+
export function Addon({ disableStyle, variant = 'normal', className, ref, ...props }) {
|
|
267
266
|
return (_jsx("div", { ...props, ref: ref, "data-variant": variant, "data-component": "combobox-addon", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
268
|
-
}
|
|
267
|
+
}
|
|
269
268
|
/** Clones one supplied icon element, forwarding its ref and preserving its classes. Decorative only; does not open the popup or perform an action. */
|
|
270
|
-
export
|
|
269
|
+
export function AddonIcon({ disableStyle, children, className, strokeWidth = 1.5, ref, ...props }) {
|
|
271
270
|
const attributes = usePartAttributes();
|
|
272
271
|
return cloneElement(children, {
|
|
273
272
|
...attributes,
|
|
@@ -279,112 +278,121 @@ export const AddonIcon = /* @__PURE__ */ forwardRef(function AddonIcon({ disable
|
|
|
279
278
|
'data-style-disabled': disableStyle ? '' : undefined,
|
|
280
279
|
className: twMerge(children.props.className, className),
|
|
281
280
|
});
|
|
282
|
-
}
|
|
281
|
+
}
|
|
283
282
|
/** Optional general-purpose button inside Addon. Supply its action yourself. Automatically disabled when Root is disabled or readOnly; defaults to type="button". */
|
|
284
|
-
export
|
|
283
|
+
export function AddonButton({ disableStyle, className, disabled, type = 'button', ref, ...props }) {
|
|
285
284
|
const context = useComboboxContext();
|
|
286
285
|
const attributes = usePartAttributes();
|
|
287
286
|
return (_jsx("button", { ...attributes, ...props, ref: ref, type: type, disabled: disabled || context.disabled || context.readOnly, "data-component": "combobox-addonbutton", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
288
|
-
}
|
|
287
|
+
}
|
|
289
288
|
/** Input control wrapper. Place Input (or ChipsList containing Input) and optional Addon controls inside. Root validation controls its preset validation border. */
|
|
290
|
-
export
|
|
289
|
+
export function InputGroup({ disableStyle, className, ref, ...props }) {
|
|
291
290
|
const attributes = usePartAttributes();
|
|
292
291
|
return (_jsx(BaseCombobox.InputGroup, { "data-validation": attributes['data-validation'], ...props, ref: ref, "data-component": "combobox-inputgroup", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
293
|
-
}
|
|
292
|
+
}
|
|
294
293
|
/** Displays one selected item inside ChipsList. Keep chips in selected-item order so Base UI can remove the matching item. Supply the item label and an optional removal control. */
|
|
295
|
-
export
|
|
294
|
+
export function Chip({ disableStyle, className, ref, ...props }) {
|
|
296
295
|
return (_jsx(BaseCombobox.Chip, { ...props, ref: ref, "data-component": "combobox-chip", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
297
|
-
}
|
|
296
|
+
}
|
|
298
297
|
/** Removes the surrounding Chip from selection automatically; no onClick handler needed. Supply its content, normally ChipRemoveButtonIcon, and an accessible label. */
|
|
299
|
-
export
|
|
298
|
+
export function ChipRemoveButton({ disableStyle, className, ref, ...props }) {
|
|
300
299
|
return (_jsx(BaseCombobox.ChipRemove, { ...props, ref: ref, "data-component": "combobox-chipremovebutton", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
301
|
-
}
|
|
300
|
+
}
|
|
302
301
|
/** Opens and closes the popup automatically; no click handler needed. Supply its content, normally AddonOpenButtonIcon, and an accessible label. */
|
|
303
|
-
export
|
|
302
|
+
export function AddonOpenButton({ disableStyle, className, ref, ...props }) {
|
|
304
303
|
return (_jsx(BaseCombobox.Trigger, { ...props, ref: ref, "data-component": "combobox-addonopenbutton", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
305
|
-
}
|
|
304
|
+
}
|
|
306
305
|
/** Clears the selection automatically; no click handler needed. Supply its content, normally AddonClearButtonIcon, and an accessible label. */
|
|
307
|
-
export
|
|
306
|
+
export function AddonClearButton({ disableStyle, className, ref, ...props }) {
|
|
308
307
|
return (_jsx(BaseCombobox.Clear, { ...props, ref: ref, "data-component": "combobox-addonclearbutton", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
309
|
-
}
|
|
308
|
+
}
|
|
310
309
|
/** Optional heading inside Group. Supply group.label as children. Omit this part for an empty label; always keep Group and ItemsList. */
|
|
311
|
-
export
|
|
310
|
+
export function GroupLabel({ disableStyle, className, ref, ...props }) {
|
|
312
311
|
return (_jsx(BaseCombobox.GroupLabel, { ...props, ref: ref, "data-component": "combobox-grouplabel", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
313
|
-
}
|
|
312
|
+
}
|
|
314
313
|
/** Required empty-results message inside Popup, before optional Loading and ScrollArea. Keep mounted statically: Base UI renders its children only when no items match. Do not manually toggle, hide, or conditionally mount it. */
|
|
315
|
-
export
|
|
314
|
+
export function Empty({ disableStyle, className, ref, ...props }) {
|
|
316
315
|
return (_jsx(BaseCombobox.Empty, { ...props, ref: ref, "data-component": "combobox-empty", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
317
|
-
}
|
|
316
|
+
}
|
|
318
317
|
/** Optional visual separator inside the popup. Does not replace Group or any required list containers. */
|
|
319
|
-
export
|
|
318
|
+
export function Separator({ disableStyle, className, ref, ...props }) {
|
|
320
319
|
return (_jsx(BaseCombobox.Separator, { ...props, ref: ref, "data-component": "combobox-separator", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
321
|
-
}
|
|
320
|
+
}
|
|
322
321
|
/** Required label content inside Item. Supply item.label as children; does not derive text from the item automatically. */
|
|
323
|
-
export
|
|
322
|
+
export function ItemText({ disableStyle, className, ref, ...props }) {
|
|
324
323
|
const attributes = usePartAttributes();
|
|
325
324
|
return (_jsx("span", { ...attributes, ...props, ref: ref, "data-component": "combobox-itemtext", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
326
|
-
}
|
|
325
|
+
}
|
|
327
326
|
/** Optional decorative text inside Addon. Supply the text as children. */
|
|
328
|
-
export
|
|
327
|
+
export function AddonText({ disableStyle, className, ref, ...props }) {
|
|
329
328
|
const attributes = usePartAttributes();
|
|
330
329
|
return (_jsx("span", { ...attributes, ...props, ref: ref, "data-component": "combobox-addontext", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
331
|
-
}
|
|
330
|
+
}
|
|
332
331
|
/** Text content inside Empty. Supply your empty-result message; Empty handles its visibility automatically. */
|
|
333
|
-
export
|
|
332
|
+
export function EmptyText({ disableStyle, className, ref, ...props }) {
|
|
334
333
|
const attributes = usePartAttributes();
|
|
335
334
|
return (_jsx("div", { ...attributes, ...props, ref: ref, "data-component": "combobox-emptytext", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
336
|
-
}
|
|
335
|
+
}
|
|
337
336
|
/** Optional supporting text. Supply its content; it describes the input to screen readers automatically. */
|
|
338
|
-
export
|
|
337
|
+
export function Description({ disableStyle, className, id, ref, ...props }) {
|
|
339
338
|
const describedById = useDescribedById(id);
|
|
340
339
|
const attributes = usePartAttributes();
|
|
341
340
|
return (_jsx("div", { ...attributes, ...props, id: describedById, ref: ref, "data-component": "combobox-description", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
342
|
-
}
|
|
341
|
+
}
|
|
343
342
|
/** 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. */
|
|
344
|
-
export
|
|
343
|
+
export function Error({ children, ref, ...props }) {
|
|
345
344
|
const context = useComboboxContext();
|
|
346
345
|
const content = validationMessageContent(context.validation, 'error', children);
|
|
347
346
|
if (content === undefined)
|
|
348
347
|
return null;
|
|
349
348
|
return _jsx(Message, { ...props, ref: ref, role: "alert", component: "combobox-error", children: content });
|
|
350
|
-
}
|
|
349
|
+
}
|
|
351
350
|
/** 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. */
|
|
352
|
-
export
|
|
351
|
+
export function Success({ children, ref, ...props }) {
|
|
353
352
|
const context = useComboboxContext();
|
|
354
353
|
const content = validationMessageContent(context.validation, 'success', children);
|
|
355
354
|
if (content === undefined)
|
|
356
355
|
return null;
|
|
357
356
|
return _jsx(Message, { ...props, ref: ref, role: "status", component: "combobox-success", children: content });
|
|
358
|
-
}
|
|
357
|
+
}
|
|
359
358
|
// The shared body of Error and Success, mounted only while they show, so only visible messages describe the input
|
|
360
|
-
|
|
359
|
+
function Message({ disableStyle, className, id, component, ref, ...props }) {
|
|
361
360
|
const describedById = useDescribedById(id);
|
|
362
361
|
const attributes = usePartAttributes();
|
|
363
362
|
return _jsx("div", { "aria-atomic": "true", ...attributes, ...props, id: describedById, ref: ref, "data-component": component, "data-style-disabled": disableStyle ? '' : undefined, className: className });
|
|
364
|
-
}
|
|
365
|
-
/** Built-in decorative open-button icon. Place inside AddonOpenButton
|
|
366
|
-
export
|
|
363
|
+
}
|
|
364
|
+
/** Built-in decorative open-button icon. Place inside AddonOpenButton. Omit children for the supplied default icon; pass an icon only to replace it. Defaults to strokeWidth 1.5. */
|
|
365
|
+
export function AddonOpenButtonIcon({ ref, ...props }) {
|
|
367
366
|
return _jsx(BuiltInIcon, { ...props, ref: ref, icon: ChevronsUpDown, component: "combobox-addonopenbuttonicon" });
|
|
368
|
-
}
|
|
369
|
-
/** Built-in decorative clear icon. Place inside AddonClearButton
|
|
370
|
-
export
|
|
367
|
+
}
|
|
368
|
+
/** Built-in decorative clear icon. Place inside AddonClearButton. Omit children for the supplied default icon; pass an icon only to replace it. Defaults to strokeWidth 1.5. */
|
|
369
|
+
export function AddonClearButtonIcon({ ref, ...props }) {
|
|
371
370
|
return _jsx(BuiltInIcon, { ...props, ref: ref, icon: X, component: "combobox-addonclearbuttonicon" });
|
|
372
|
-
}
|
|
373
|
-
/** Built-in decorative removal icon. Place inside ChipRemoveButton
|
|
374
|
-
export
|
|
371
|
+
}
|
|
372
|
+
/** Built-in decorative removal icon. Place inside ChipRemoveButton. Omit children for the supplied default icon; pass an icon only to replace it. Defaults to strokeWidth 1.5. */
|
|
373
|
+
export function ChipRemoveButtonIcon({ ref, ...props }) {
|
|
375
374
|
return _jsx(BuiltInIcon, { ...props, ref: ref, icon: X, component: "combobox-chipremovebuttonicon" });
|
|
376
|
-
}
|
|
375
|
+
}
|
|
377
376
|
/** Optional spinner inside Addon. Does not detect requests: you decide when to render it. Defaults to strokeWidth 1.5. */
|
|
378
|
-
export
|
|
377
|
+
export function AddonLoadingIcon({ ref, ...props }) {
|
|
379
378
|
return _jsx(BuiltInIcon, { ...props, ref: ref, icon: LoaderCircle, component: "combobox-addonloadingicon" });
|
|
380
|
-
}
|
|
379
|
+
}
|
|
381
380
|
// The shared body of the built-in decorative icons above, which only differ by their icon and component name
|
|
382
|
-
|
|
381
|
+
function BuiltInIcon({ disableStyle, className, strokeWidth, icon: Icon, component, children, ref, ...props }) {
|
|
383
382
|
const attributes = usePartAttributes();
|
|
384
|
-
return _jsx(Icon, {
|
|
385
|
-
|
|
383
|
+
return cloneElement(children ?? _jsx(Icon, {}), {
|
|
384
|
+
...attributes,
|
|
385
|
+
'aria-hidden': true,
|
|
386
|
+
...props,
|
|
387
|
+
ref,
|
|
388
|
+
strokeWidth: strokeWidth ?? children?.props.strokeWidth ?? 1.5,
|
|
389
|
+
'data-component': component,
|
|
390
|
+
'data-style-disabled': disableStyle ? '' : undefined,
|
|
391
|
+
className: twMerge(children?.props.className, className),
|
|
392
|
+
});
|
|
393
|
+
}
|
|
386
394
|
/** Required selection indicator inside Item. Visibility is automatic and a checkmark is supplied: no children or selection condition needed. Pass children only to replace the built-in checkmark. */
|
|
387
|
-
export
|
|
395
|
+
export function ItemIndicator({ disableStyle, children, keepMounted, ref, ...props }) {
|
|
388
396
|
const iconProps = {
|
|
389
397
|
'aria-hidden': true,
|
|
390
398
|
strokeWidth: 2,
|
|
@@ -394,19 +402,19 @@ export const ItemIndicator = /* @__PURE__ */ forwardRef(function ItemIndicator({
|
|
|
394
402
|
'data-style-disabled': disableStyle ? '' : undefined,
|
|
395
403
|
};
|
|
396
404
|
return (_jsx(BaseCombobox.ItemIndicator, { keepMounted: keepMounted, children: null, render: cloneElement(children ?? _jsx(Check, {}), iconProps) }));
|
|
397
|
-
}
|
|
405
|
+
}
|
|
398
406
|
/** Optional async status inside Popup, below Empty and above ScrollArea. Omit entirely for synchronous items. For async items, keep Loading mounted and conditionally render only LoadingIcon and LoadingText from your request state. Does not detect requests or manage visibility. */
|
|
399
|
-
export
|
|
407
|
+
export function Loading({ disableStyle, className, ref, ...props }) {
|
|
400
408
|
return (_jsx(BaseCombobox.Status, { ...props, ref: ref, "data-component": "combobox-loading", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
401
|
-
}
|
|
409
|
+
}
|
|
402
410
|
/** Text inside Loading. Supply the message only while your request is loading; this part does not detect request state. */
|
|
403
|
-
export
|
|
411
|
+
export function LoadingText({ disableStyle, className, ref, ...props }) {
|
|
404
412
|
return (_jsx("div", { ...props, ref: ref, "data-component": "combobox-loadingtext", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
405
|
-
}
|
|
413
|
+
}
|
|
406
414
|
/** Built-in decorative spinner for Loading. No children needed; you control when it is rendered. */
|
|
407
|
-
export
|
|
415
|
+
export function LoadingIcon({ disableStyle, className, strokeWidth = 2, ref, ...props }) {
|
|
408
416
|
return (_jsx(LoaderCircle, { "aria-hidden": true, ...props, ref: ref, strokeWidth: strokeWidth, "data-component": "combobox-loadingicon", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
409
|
-
}
|
|
417
|
+
}
|
|
410
418
|
const ComboboxContext = /* @__PURE__ */ createContext(null);
|
|
411
419
|
// Telling Input it sits inside ChipsList, so the preset uses the compact chip-input sizing
|
|
412
420
|
const ChipsContext = /* @__PURE__ */ createContext(false);
|
|
@@ -15,7 +15,7 @@ import type { ListBoxProps, ListBoxItemProps } from 'react-aria-components/ListB
|
|
|
15
15
|
import { Text } from 'react-aria-components/Text';
|
|
16
16
|
import { FieldError } from 'react-aria-components/FieldError';
|
|
17
17
|
import type { CalendarDate } from '@internationalized/date';
|
|
18
|
-
import type { ComponentProps, ReactElement, ReactNode } from 'react';
|
|
18
|
+
import type { ComponentProps, ReactElement, ReactNode, Ref } from 'react';
|
|
19
19
|
import type { SVGIconProps } from '../../types/Icon.ts';
|
|
20
20
|
import type { Validation } from '../../types/Validation.ts';
|
|
21
21
|
import type { ValidationMessageChildren } from '../../utils/Validation.ts';
|
|
@@ -53,6 +53,7 @@ type SharedRootProps = {
|
|
|
53
53
|
* Omit it to keep only the picker's own validation, like a required or out-of-range date.
|
|
54
54
|
*/
|
|
55
55
|
validation?: Validation;
|
|
56
|
+
ref?: Ref<HTMLDivElement>;
|
|
56
57
|
};
|
|
57
58
|
type SingleRootProps = Pick<DatePickerProps<CalendarDate>, CoreKeys | 'name' | 'autoComplete'> & SharedRootProps & {
|
|
58
59
|
/** Use range for a start/end selection; single is the default. Choose the corresponding field composition. */
|
|
@@ -158,7 +159,7 @@ export type RootProps = SingleRootProps | RangeRootProps;
|
|
|
158
159
|
* }
|
|
159
160
|
* </DatePicker.PresetsList>
|
|
160
161
|
*/
|
|
161
|
-
export declare
|
|
162
|
+
export declare function Root({ ref, ...props }: RootProps): import("react").JSX.Element;
|
|
162
163
|
export declare function Container({ disableStyle, className, ...props }: ComponentProps<'div'> & StyleProps): import("react").JSX.Element;
|
|
163
164
|
export declare function Label({ disableStyle, className, ...props }: Omit<ComponentProps<typeof AriaLabel>, 'htmlFor' | 'slot' | 'render'> & StyleProps): import("react").JSX.Element;
|
|
164
165
|
export declare function InputGroup({ disableStyle, className, ...props }: (Omit<ComponentProps<typeof AriaGroup>, 'className' | 'style' | 'render' | 'slot' | 'isDisabled' | 'isReadOnly' | 'isInvalid'> & {
|
|
@@ -219,12 +220,10 @@ export declare function OpenButtonIcon({ disableStyle, children, className, ...p
|
|
|
219
220
|
export type PopupProps = Omit<PopoverProps, 'className' | 'style' | 'render' | 'slot' | 'trigger' | 'isOpen' | 'defaultOpen' | 'onOpenChange'> & {
|
|
220
221
|
className?: string;
|
|
221
222
|
style?: ComponentProps<'div'>['style'];
|
|
223
|
+
ref?: Ref<HTMLElement>;
|
|
222
224
|
} & StyleProps;
|
|
223
225
|
/** Use the same calendar composition for both trigger choices. Opening and focus management are handled by the picker; do not add your own popup visibility condition. */
|
|
224
|
-
export declare
|
|
225
|
-
className?: string;
|
|
226
|
-
style?: ComponentProps<"div">["style"];
|
|
227
|
-
} & StyleProps & import("react").RefAttributes<HTMLElement>>;
|
|
226
|
+
export declare function Popup({ disableStyle, ref, ...props }: PopupProps): import("react").JSX.Element;
|
|
228
227
|
export type CalendarConfiguration = Omit<CalendarProps<CalendarDate>, 'children' | 'render' | 'className' | 'style' | 'value' | 'defaultValue' | 'onChange' | 'minValue' | 'maxValue' | 'isDateUnavailable' | 'focusedValue' | 'defaultFocusedValue' | 'onFocusChange' | 'selectionMode' | 'pageBehavior' | 'slot' | 'isDisabled' | 'isReadOnly' | 'isInvalid' | 'firstDayOfWeek' | 'createCalendar' | 'visibleDuration'> & {
|
|
229
228
|
/** Choose how many months to show. TablesList calls its children once for each month. */
|
|
230
229
|
visibleDuration?: Pick<NonNullable<CalendarProps<CalendarDate>['visibleDuration']>, 'months'>;
|
|
@@ -253,12 +252,12 @@ export declare function Item({ disableStyle, value, className, textValue, ...pro
|
|
|
253
252
|
className?: string;
|
|
254
253
|
style?: ComponentProps<'div'>['style'];
|
|
255
254
|
}) & StyleProps): import("react").JSX.Element;
|
|
256
|
-
export declare
|
|
255
|
+
export declare function ItemText({ disableStyle, className, ref, ...props }: Omit<ComponentProps<typeof Text>, 'slot' | 'render'> & StyleProps): import("react").JSX.Element;
|
|
257
256
|
/** Tracks the surrounding item state automatically. Keep it mounted; do not add your own visibility condition. Use the supplied default visual unless customization is needed. */
|
|
258
|
-
export declare
|
|
257
|
+
export declare function ItemIndicator({ disableStyle, children, ref, ...props }: Omit<SVGIconProps, 'children'> & {
|
|
259
258
|
/** Optional replacement SVG icon. It receives this indicator's props and ref. */
|
|
260
259
|
children?: ReactElement<SVGIconProps>;
|
|
261
|
-
} & StyleProps
|
|
260
|
+
} & StyleProps): import("react").FunctionComponentElement<any> | null;
|
|
262
261
|
export declare function Actions({ disableStyle, className, ...props }: ComponentProps<'div'> & StyleProps): import("react").JSX.Element;
|
|
263
262
|
export declare function ViewDateValue({ disableStyle, className, level, ...props }: (Omit<ComponentProps<'h2'>, 'children'> & Pick<ComponentProps<typeof Heading>, 'level'>) & StyleProps): import("react").JSX.Element;
|
|
264
263
|
export declare function PreviousButton({ disableStyle, className, isDisabled, ...props }: StyledButtonProps & StyleProps): import("react").JSX.Element;
|
|
@@ -21,17 +21,17 @@ import { parseDate, toCalendarDate, toCalendar, GregorianCalendar, } from '@inte
|
|
|
21
21
|
import { useLocale } from 'react-aria/I18nProvider';
|
|
22
22
|
import { useDateFormatter } from 'react-aria/useDateFormatter';
|
|
23
23
|
import { mergeProps } from 'react-aria/mergeProps';
|
|
24
|
-
import { cloneElement, createContext,
|
|
24
|
+
import { cloneElement, createContext, useContext, Fragment, useState, useMemo, } from 'react';
|
|
25
25
|
import { CalendarDays, Check, ChevronLeft, ChevronRight, LoaderCircle, } from "../../utils/icons.js";
|
|
26
26
|
import { twMerge } from 'tailwind-merge';
|
|
27
27
|
import { readValidation, validationAttributes, validationMessageContent } from "../../utils/Validation.js";
|
|
28
|
-
|
|
28
|
+
function SinglePicker({ mode, locale, validation, presets, value, defaultValue, minValue, maxValue, placeholderValue, onValueChange, disabled, readOnly, required, open, isDateUnavailable, ref, ...props }) {
|
|
29
29
|
return (_jsx(AriaDatePicker, { ...props, isDisabled: disabled, isReadOnly: readOnly, isRequired: required,
|
|
30
30
|
// An error validation marks it invalid; otherwise Aria keeps running its own validation
|
|
31
31
|
isInvalid: readValidation(validation).state === 'error' || undefined, isOpen: open, ref: ref, style: { display: 'contents' }, granularity: "day", value: parseDateString(value), defaultValue: parseDateString(defaultValue), minValue: parseDateString(minValue), maxValue: parseDateString(maxValue), placeholderValue: parseDateString(placeholderValue), onChange: (date) => onValueChange?.(date ? toGregorianDateString(date) : null), isDateUnavailable: isDateUnavailable &&
|
|
32
32
|
((date) => isDateUnavailable(toGregorianDateString(date))) }));
|
|
33
|
-
}
|
|
34
|
-
|
|
33
|
+
}
|
|
34
|
+
function RangePicker({ mode, locale, validation, presets, value, defaultValue, minValue, maxValue, placeholderValue, onValueChange, disabled, readOnly, required, open, isDateUnavailable, ref, ...props }) {
|
|
35
35
|
return (_jsx(AriaDateRangePicker, { ...props, isDisabled: disabled, isReadOnly: readOnly, isRequired: required,
|
|
36
36
|
// An error validation marks it invalid; otherwise Aria keeps running its own validation
|
|
37
37
|
isInvalid: readValidation(validation).state === 'error' || undefined, isOpen: open, ref: ref, style: { display: 'contents' }, granularity: "day", value: parseDateRange(value), defaultValue: parseDateRange(defaultValue), minValue: parseDateString(minValue), maxValue: parseDateString(maxValue), placeholderValue: parseDateString(placeholderValue), onChange: (range) => onValueChange?.(range
|
|
@@ -41,7 +41,7 @@ const RangePicker = /* @__PURE__ */ forwardRef(function RangePicker({ mode, loca
|
|
|
41
41
|
}
|
|
42
42
|
: null), isDateUnavailable: isDateUnavailable &&
|
|
43
43
|
((date, anchor) => isDateUnavailable(toGregorianDateString(date), anchor ? toGregorianDateString(anchor) : null)) }));
|
|
44
|
-
}
|
|
44
|
+
}
|
|
45
45
|
function Picker({ pickerRef, ...props }) {
|
|
46
46
|
if (props.mode === 'range')
|
|
47
47
|
return _jsx(RangePicker, { ...props, ref: pickerRef });
|
|
@@ -123,7 +123,7 @@ function Picker({ pickerRef, ...props }) {
|
|
|
123
123
|
* }
|
|
124
124
|
* </DatePicker.PresetsList>
|
|
125
125
|
*/
|
|
126
|
-
export
|
|
126
|
+
export function Root({ ref, ...props }) {
|
|
127
127
|
const [buttonAnchor, setButtonAnchor] = useState(null);
|
|
128
128
|
const buttonAnchorRef = useMemo(() => ({ current: buttonAnchor }), [buttonAnchor]);
|
|
129
129
|
return (_jsx(I18nProvider, { locale: props.locale ?? 'en-US', children: _jsx(ConfigurationContext.Provider, { value: {
|
|
@@ -135,7 +135,7 @@ export const Root = /* @__PURE__ */ forwardRef(function Root(props, ref) {
|
|
|
135
135
|
readOnly: props.readOnly ?? false,
|
|
136
136
|
validation: readValidation(props.validation),
|
|
137
137
|
}, children: _jsx(Picker, { ...props, pickerRef: ref }) }) }));
|
|
138
|
-
}
|
|
138
|
+
}
|
|
139
139
|
export function Container({ disableStyle, className, ...props }) {
|
|
140
140
|
return (_jsx("div", { ...props, ...usePartAttributes(), "data-component": "datepicker-container", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
141
141
|
}
|
|
@@ -273,14 +273,14 @@ export function OpenButtonIcon({ disableStyle, children = _jsx(CalendarDays, {})
|
|
|
273
273
|
});
|
|
274
274
|
}
|
|
275
275
|
/** Use the same calendar composition for both trigger choices. Opening and focus management are handled by the picker; do not add your own popup visibility condition. */
|
|
276
|
-
export
|
|
276
|
+
export function Popup({ disableStyle, ref, ...props }) {
|
|
277
277
|
// The Popover supplies dialog semantics itself. Merge DatePicker's generated dialog
|
|
278
278
|
// id/labeling onto that same element instead of adding another Dialog wrapper.
|
|
279
279
|
const context = useContext(ConfigurationContext);
|
|
280
280
|
const [mergedProps, mergedRef] = useContextProps(props, ref, DialogContext);
|
|
281
281
|
const { className, style, placement = 'bottom end', offset = 5, ...rest } = mergedProps;
|
|
282
282
|
return (_jsx(AriaPopover, { ...(context.buttonAnchorRef?.current ? { triggerRef: context.buttonAnchorRef } : {}), ...rest, ref: mergedRef, placement: placement, offset: offset, style: { minWidth: 'var(--trigger-width)', ...style }, "data-component": "datepicker-popup", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
283
|
-
}
|
|
283
|
+
}
|
|
284
284
|
function SingleCalendar({ disableStyle, className, focusedValue, defaultFocusedValue, onFocusChange, ...props }) {
|
|
285
285
|
return (_jsx(AriaCalendar, { ...props, firstDayOfWeek: "mon", pageBehavior: "single", focusedValue: parseDateString(focusedValue), defaultFocusedValue: parseDateString(defaultFocusedValue), onFocusChange: onFocusChange && ((date) => onFocusChange(toGregorianDateString(date))), "data-component": "datepicker-calendar", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
286
286
|
}
|
|
@@ -341,11 +341,11 @@ export function Item({ disableStyle, value, className, textValue, ...props }) {
|
|
|
341
341
|
calendar.isReadOnly ||
|
|
342
342
|
dates.some((date) => calendar.isInvalid(date) || calendar.isCellUnavailable(date)), "data-component": "datepicker-item", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
343
343
|
}
|
|
344
|
-
export
|
|
344
|
+
export function ItemText({ disableStyle, className, ref, ...props }) {
|
|
345
345
|
return (_jsx(Text, { ...props, ref: ref, slot: "label", "data-component": "datepicker-itemtext", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
346
|
-
}
|
|
346
|
+
}
|
|
347
347
|
/** Tracks the surrounding item state automatically. Keep it mounted; do not add your own visibility condition. Use the supplied default visual unless customization is needed. */
|
|
348
|
-
export
|
|
348
|
+
export function ItemIndicator({ disableStyle, children, ref, ...props }) {
|
|
349
349
|
// ListBoxItem supplies this public Aria context, including for controlled selection.
|
|
350
350
|
// Read visibility directly so no measured div or shared-element animation is needed.
|
|
351
351
|
const selection = useSlottedContext(SelectionIndicatorContext);
|
|
@@ -362,7 +362,7 @@ export const ItemIndicator = /* @__PURE__ */ forwardRef(function ItemIndicator({
|
|
|
362
362
|
'data-style-disabled': disableStyle ? '' : undefined,
|
|
363
363
|
};
|
|
364
364
|
return cloneElement(children ?? _jsx(Check, {}), iconProps);
|
|
365
|
-
}
|
|
365
|
+
}
|
|
366
366
|
export function Actions({ disableStyle, className, ...props }) {
|
|
367
367
|
return (_jsx("div", { ...props, "data-component": "datepicker-actions", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
368
368
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { StyleProps } from '../../types/Style.ts';
|
|
2
2
|
import { Dialog as BaseDialog } from '@base-ui/react/dialog';
|
|
3
|
-
import type { ReactElement } from 'react';
|
|
3
|
+
import type { ComponentProps, ReactElement } from 'react';
|
|
4
4
|
import type { SVGIconProps } from '../../types/Icon.ts';
|
|
5
5
|
import type { AsChildProps } from '../../utils/asChild.ts';
|
|
6
6
|
/**
|
|
@@ -43,33 +43,33 @@ import type { AsChildProps } from '../../utils/asChild.ts';
|
|
|
43
43
|
*/
|
|
44
44
|
export declare function Root<Payload = unknown>(props: BaseDialog.Root.Props<Payload>): import("react").JSX.Element;
|
|
45
45
|
/** Opens the dialog. Pass asChild to give this behavior to your own button, like your app's Button. */
|
|
46
|
-
export declare
|
|
46
|
+
export declare function OpenButton({ asChild, disableStyle, children, ref, ...props }: Omit<BaseDialog.Trigger.Props, 'className' | 'render'> & {
|
|
47
47
|
className?: string;
|
|
48
|
-
} & AsChildProps & StyleProps
|
|
49
|
-
export type PopupProps = Omit<BaseDialog.Popup.Props, 'className'> & {
|
|
48
|
+
} & AsChildProps & StyleProps): import("react").JSX.Element;
|
|
49
|
+
export type PopupProps = Omit<BaseDialog.Popup.Props, 'className' | 'render'> & {
|
|
50
50
|
className?: string;
|
|
51
51
|
} & Pick<BaseDialog.Portal.Props, 'container' | 'keepMounted'> & StyleProps;
|
|
52
52
|
/** Already includes the portal. Keep it in the matching Root and let the native open state control visibility. */
|
|
53
|
-
export declare
|
|
54
|
-
export type BackdropProps = Omit<BaseDialog.Backdrop.Props, 'className'> & {
|
|
53
|
+
export declare function Popup({ disableStyle, container, keepMounted, className, style, ref, ...props }: PopupProps): import("react").JSX.Element;
|
|
54
|
+
export type BackdropProps = Omit<BaseDialog.Backdrop.Props, 'className' | 'render'> & {
|
|
55
55
|
className?: string;
|
|
56
56
|
} & Pick<BaseDialog.Portal.Props, 'container' | 'keepMounted'> & StyleProps;
|
|
57
|
-
export declare
|
|
58
|
-
export declare
|
|
59
|
-
export declare
|
|
60
|
-
export declare
|
|
61
|
-
export declare
|
|
57
|
+
export declare function Backdrop({ disableStyle, container, keepMounted, className, ref, ...props }: BackdropProps): import("react").JSX.Element;
|
|
58
|
+
export declare function Header({ disableStyle, className, ref, ...props }: ComponentProps<'div'> & StyleProps): import("react").JSX.Element;
|
|
59
|
+
export declare function Body({ disableStyle, className, ref, ...props }: ComponentProps<'div'> & StyleProps): import("react").JSX.Element;
|
|
60
|
+
export declare function Footer({ disableStyle, className, ref, ...props }: ComponentProps<'div'> & StyleProps): import("react").JSX.Element;
|
|
61
|
+
export declare function Title({ disableStyle, className, ref, ...props }: (Omit<BaseDialog.Title.Props, 'className' | 'render'> & {
|
|
62
62
|
className?: string;
|
|
63
|
-
} & StyleProps
|
|
64
|
-
export declare
|
|
63
|
+
}) & StyleProps): import("react").JSX.Element;
|
|
64
|
+
export declare function Description({ disableStyle, className, ref, ...props }: (Omit<BaseDialog.Description.Props, 'className' | 'render'> & {
|
|
65
65
|
className?: string;
|
|
66
|
-
} & StyleProps
|
|
66
|
+
}) & StyleProps): import("react").JSX.Element;
|
|
67
67
|
/** 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". Pass asChild to give closing behavior to your own button instead, like a "Done" Button. */
|
|
68
|
-
export declare
|
|
68
|
+
export declare function CloseButton({ asChild, disableStyle, children, ref, ...props }: Omit<BaseDialog.Close.Props, 'className' | 'render'> & {
|
|
69
69
|
className?: string;
|
|
70
|
-
} & AsChildProps & StyleProps
|
|
70
|
+
} & AsChildProps & StyleProps): import("react").JSX.Element;
|
|
71
71
|
/** A default icon is supplied. Omit children for the usual case; pass an icon only to replace that visual. */
|
|
72
|
-
export declare
|
|
72
|
+
export declare function CloseButtonIcon({ disableStyle, children, className, ref, ...props }: (SVGIconProps & {
|
|
73
73
|
/** Omit for the supplied default icon; pass a child only to replace it. */
|
|
74
74
|
children?: ReactElement<SVGIconProps>;
|
|
75
|
-
} & StyleProps
|
|
75
|
+
}) & StyleProps): import("react").FunctionComponentElement<any>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Dialog as BaseDialog } from '@base-ui/react/dialog';
|
|
3
|
-
import { cloneElement
|
|
3
|
+
import { cloneElement } from 'react';
|
|
4
4
|
import { twMerge } from 'tailwind-merge';
|
|
5
5
|
import { X } from "../../utils/icons.js";
|
|
6
6
|
import { asChildRendering } from "../../utils/asChild.js";
|
|
@@ -46,12 +46,12 @@ export function Root(props) {
|
|
|
46
46
|
return _jsx(BaseDialog.Root, { ...props });
|
|
47
47
|
}
|
|
48
48
|
/** Opens the dialog. Pass asChild to give this behavior to your own button, like your app's Button. */
|
|
49
|
-
export
|
|
49
|
+
export function OpenButton({ asChild, disableStyle, children, ref, ...props }) {
|
|
50
50
|
const rendering = asChildRendering({ asChild, children, component: 'dialog-openbutton', disableStyle });
|
|
51
51
|
return _jsx(BaseDialog.Trigger, { ...props, ref: ref, ...rendering });
|
|
52
|
-
}
|
|
52
|
+
}
|
|
53
53
|
/** Already includes the portal. Keep it in the matching Root and let the native open state control visibility. */
|
|
54
|
-
export
|
|
54
|
+
export function Popup({ disableStyle, container, keepMounted, className, style, ref, ...props }) {
|
|
55
55
|
const baseStyle = {
|
|
56
56
|
position: 'fixed',
|
|
57
57
|
top: '50%',
|
|
@@ -62,32 +62,32 @@ export const Popup = /* @__PURE__ */ forwardRef(function Popup({ disableStyle, c
|
|
|
62
62
|
return (_jsx(BaseDialog.Portal, { container: container, keepMounted: keepMounted, children: _jsx(BaseDialog.Viewport, { children: _jsx(BaseDialog.Popup, { ...props, ref: ref, "data-component": "dialog-popup", "data-style-disabled": disableStyle ? '' : undefined, className: className, style: typeof style === 'function'
|
|
63
63
|
? (state) => ({ ...baseStyle, ...style(state) })
|
|
64
64
|
: { ...baseStyle, ...style } }) }) }));
|
|
65
|
-
}
|
|
66
|
-
export
|
|
65
|
+
}
|
|
66
|
+
export function Backdrop({ disableStyle, container, keepMounted, className, ref, ...props }) {
|
|
67
67
|
return (_jsx(BaseDialog.Portal, { container: container, keepMounted: keepMounted, children: _jsx(BaseDialog.Backdrop, { ...props, ref: ref, "data-component": "dialog-backdrop", "data-style-disabled": disableStyle ? '' : undefined, className: className }) }));
|
|
68
|
-
}
|
|
69
|
-
export
|
|
68
|
+
}
|
|
69
|
+
export function Header({ disableStyle, className, ref, ...props }) {
|
|
70
70
|
return (_jsx("div", { ...props, ref: ref, "data-component": "dialog-header", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
71
|
-
}
|
|
72
|
-
export
|
|
71
|
+
}
|
|
72
|
+
export function Body({ disableStyle, className, ref, ...props }) {
|
|
73
73
|
return (_jsx("div", { ...props, ref: ref, "data-component": "dialog-body", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
74
|
-
}
|
|
75
|
-
export
|
|
74
|
+
}
|
|
75
|
+
export function Footer({ disableStyle, className, ref, ...props }) {
|
|
76
76
|
return (_jsx("div", { ...props, ref: ref, "data-component": "dialog-footer", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
77
|
-
}
|
|
78
|
-
export
|
|
77
|
+
}
|
|
78
|
+
export function Title({ disableStyle, className, ref, ...props }) {
|
|
79
79
|
return (_jsx(BaseDialog.Title, { ...props, ref: ref, "data-component": "dialog-title", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
80
|
-
}
|
|
81
|
-
export
|
|
80
|
+
}
|
|
81
|
+
export function Description({ disableStyle, className, ref, ...props }) {
|
|
82
82
|
return (_jsx(BaseDialog.Description, { ...props, ref: ref, "data-component": "dialog-description", "data-style-disabled": disableStyle ? '' : undefined, className: className }));
|
|
83
|
-
}
|
|
83
|
+
}
|
|
84
84
|
/** 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". Pass asChild to give closing behavior to your own button instead, like a "Done" Button. */
|
|
85
|
-
export
|
|
85
|
+
export function CloseButton({ asChild, disableStyle, children, ref, ...props }) {
|
|
86
86
|
const rendering = asChildRendering({ asChild, children, component: 'dialog-closebutton', disableStyle });
|
|
87
87
|
return _jsx(BaseDialog.Close, { ...props, ref: ref, ...rendering });
|
|
88
|
-
}
|
|
88
|
+
}
|
|
89
89
|
/** A default icon is supplied. Omit children for the usual case; pass an icon only to replace that visual. */
|
|
90
|
-
export
|
|
90
|
+
export function CloseButtonIcon({ disableStyle, children, className, ref, ...props }) {
|
|
91
91
|
return cloneElement(children ?? _jsx(X, {}), {
|
|
92
92
|
...props,
|
|
93
93
|
ref,
|
|
@@ -97,5 +97,6 @@ export const CloseButtonIcon = /* @__PURE__ */ forwardRef(function CloseButtonIc
|
|
|
97
97
|
'data-style-disabled': disableStyle ? '' : undefined,
|
|
98
98
|
},
|
|
99
99
|
className: twMerge(children?.props.className, className),
|
|
100
|
+
strokeWidth: props.strokeWidth ?? children?.props.strokeWidth ?? 2,
|
|
100
101
|
});
|
|
101
|
-
}
|
|
102
|
+
}
|