@cimpress-ui/react 1.0.2 → 1.2.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/commonjs/components/checkbox/checkbox-group.d.ts +2 -2
- package/dist/commonjs/components/checkbox/checkbox-group.d.ts.map +1 -1
- package/dist/commonjs/components/checkbox/checkbox-group.js +8 -1
- package/dist/commonjs/components/checkbox/checkbox-group.js.map +1 -1
- package/dist/commonjs/components/checkbox/checkbox.d.ts +1 -1
- package/dist/commonjs/components/checkbox/checkbox.d.ts.map +1 -1
- package/dist/commonjs/components/checkbox/checkbox.js.map +1 -1
- package/dist/commonjs/components/combo-box/combo-box.d.ts +2 -2
- package/dist/commonjs/components/combo-box/combo-box.d.ts.map +1 -1
- package/dist/commonjs/components/combo-box/combo-box.js +9 -5
- package/dist/commonjs/components/combo-box/combo-box.js.map +1 -1
- package/dist/commonjs/components/date-picker/date-picker.d.ts +1 -1
- package/dist/commonjs/components/date-picker/date-picker.d.ts.map +1 -1
- package/dist/commonjs/components/date-picker/date-picker.js.map +1 -1
- package/dist/commonjs/components/drawer/drawer.d.ts +19 -18
- package/dist/commonjs/components/drawer/drawer.d.ts.map +1 -1
- package/dist/commonjs/components/drawer/drawer.js +16 -21
- package/dist/commonjs/components/drawer/drawer.js.map +1 -1
- package/dist/commonjs/components/file-picker/file-picker.d.ts.map +1 -1
- package/dist/commonjs/components/file-picker/file-picker.js +3 -3
- package/dist/commonjs/components/file-picker/file-picker.js.map +1 -1
- package/dist/commonjs/components/modal-dialog/modal-dialog.d.ts +2 -1
- package/dist/commonjs/components/modal-dialog/modal-dialog.d.ts.map +1 -1
- package/dist/commonjs/components/modal-dialog/modal-dialog.js +1 -1
- package/dist/commonjs/components/modal-dialog/modal-dialog.js.map +1 -1
- package/dist/commonjs/components/radio/radio-group.d.ts +2 -2
- package/dist/commonjs/components/radio/radio-group.d.ts.map +1 -1
- package/dist/commonjs/components/radio/radio-group.js +8 -1
- package/dist/commonjs/components/radio/radio-group.js.map +1 -1
- package/dist/commonjs/components/select/select.d.ts +2 -2
- package/dist/commonjs/components/select/select.d.ts.map +1 -1
- package/dist/commonjs/components/select/select.js +9 -5
- package/dist/commonjs/components/select/select.js.map +1 -1
- package/dist/commonjs/components/tabs/tabs.d.ts +1 -1
- package/dist/commonjs/components/tabs/tabs.d.ts.map +1 -1
- package/dist/commonjs/components/tabs/tabs.js +2 -4
- package/dist/commonjs/components/tabs/tabs.js.map +1 -1
- package/dist/commonjs/components/tag/tag-group.d.ts +1 -1
- package/dist/commonjs/components/tag/tag-group.d.ts.map +1 -1
- package/dist/commonjs/components/tag/tag-group.js.map +1 -1
- package/dist/commonjs/components/tag/tag.d.ts +1 -1
- package/dist/commonjs/components/tag/tag.d.ts.map +1 -1
- package/dist/commonjs/components/tag/tag.js.map +1 -1
- package/dist/commonjs/components/tag-field/tag-field.d.ts.map +1 -1
- package/dist/commonjs/components/tag-field/tag-field.js +6 -3
- package/dist/commonjs/components/tag-field/tag-field.js.map +1 -1
- package/dist/commonjs/components/text-inputs/text-field.d.ts.map +1 -1
- package/dist/commonjs/components/text-inputs/text-field.js +1 -1
- package/dist/commonjs/components/text-inputs/text-field.js.map +1 -1
- package/dist/commonjs/components/toggle/toggle.d.ts +1 -1
- package/dist/commonjs/components/toggle/toggle.d.ts.map +1 -1
- package/dist/commonjs/components/toggle/toggle.js.map +1 -1
- package/dist/commonjs/components/toggle-button/context.d.ts +2 -0
- package/dist/commonjs/components/toggle-button/context.d.ts.map +1 -0
- package/dist/commonjs/components/toggle-button/context.js +7 -0
- package/dist/commonjs/components/toggle-button/context.js.map +1 -0
- package/dist/commonjs/components/toggle-button/internal-toggle-button.d.ts +2 -0
- package/dist/commonjs/components/toggle-button/internal-toggle-button.d.ts.map +1 -0
- package/dist/commonjs/components/toggle-button/internal-toggle-button.js +57 -0
- package/dist/commonjs/components/toggle-button/internal-toggle-button.js.map +1 -0
- package/dist/commonjs/components/toggle-button/toggle-button-group.d.ts +10 -6
- package/dist/commonjs/components/toggle-button/toggle-button-group.d.ts.map +1 -1
- package/dist/commonjs/components/toggle-button/toggle-button-group.js +61 -9
- package/dist/commonjs/components/toggle-button/toggle-button-group.js.map +1 -1
- package/dist/commonjs/components/toggle-button/toggle-button.d.ts +8 -8
- package/dist/commonjs/components/toggle-button/toggle-button.d.ts.map +1 -1
- package/dist/commonjs/components/toggle-button/toggle-button.js +6 -6
- package/dist/commonjs/components/toggle-button/toggle-button.js.map +1 -1
- package/dist/commonjs/components/toggle-button/toggle-icon-button.d.ts +7 -6
- package/dist/commonjs/components/toggle-button/toggle-icon-button.d.ts.map +1 -1
- package/dist/commonjs/components/toggle-button/toggle-icon-button.js +7 -10
- package/dist/commonjs/components/toggle-button/toggle-icon-button.js.map +1 -1
- package/dist/commonjs/components/types.d.ts +14 -1
- package/dist/commonjs/components/types.d.ts.map +1 -1
- package/dist/commonjs/components/types.js.map +1 -1
- package/dist/commonjs/i18n/messages/en-US.d.ts.map +1 -1
- package/dist/commonjs/i18n/messages/en-US.js +1 -0
- package/dist/commonjs/i18n/messages/en-US.js.map +1 -1
- package/dist/commonjs/i18n/messages/types.d.ts +6 -0
- package/dist/commonjs/i18n/messages/types.d.ts.map +1 -1
- package/dist/commonjs/i18n/messages/types.js.map +1 -1
- package/dist/commonjs/icons/category-apparel.d.ts.map +1 -1
- package/dist/commonjs/icons/category-apparel.js +1 -1
- package/dist/commonjs/icons/category-apparel.js.map +1 -1
- package/dist/commonjs/icons/clock-user.d.ts +8 -0
- package/dist/commonjs/icons/clock-user.d.ts.map +1 -0
- package/dist/commonjs/icons/clock-user.js +24 -0
- package/dist/commonjs/icons/clock-user.js.map +1 -0
- package/dist/commonjs/icons/external-link.d.ts +8 -0
- package/dist/commonjs/icons/external-link.d.ts.map +1 -0
- package/dist/commonjs/icons/external-link.js +24 -0
- package/dist/commonjs/icons/external-link.js.map +1 -0
- package/dist/commonjs/icons/file-design.d.ts +8 -0
- package/dist/commonjs/icons/file-design.d.ts.map +1 -0
- package/dist/commonjs/icons/file-design.js +24 -0
- package/dist/commonjs/icons/file-design.js.map +1 -0
- package/dist/commonjs/icons/index.d.ts +11 -0
- package/dist/commonjs/icons/index.d.ts.map +1 -1
- package/dist/commonjs/icons/index.js +24 -2
- package/dist/commonjs/icons/index.js.map +1 -1
- package/dist/commonjs/icons/invoice.d.ts +8 -0
- package/dist/commonjs/icons/invoice.d.ts.map +1 -0
- package/dist/commonjs/icons/invoice.js +24 -0
- package/dist/commonjs/icons/invoice.js.map +1 -0
- package/dist/commonjs/icons/print.d.ts +8 -0
- package/dist/commonjs/icons/print.d.ts.map +1 -0
- package/dist/commonjs/icons/print.js +24 -0
- package/dist/commonjs/icons/print.js.map +1 -0
- package/dist/commonjs/icons/refresh.d.ts +8 -0
- package/dist/commonjs/icons/refresh.d.ts.map +1 -0
- package/dist/commonjs/icons/refresh.js +24 -0
- package/dist/commonjs/icons/refresh.js.map +1 -0
- package/dist/commonjs/icons/share-alt.d.ts +8 -0
- package/dist/commonjs/icons/share-alt.d.ts.map +1 -0
- package/dist/commonjs/icons/share-alt.js +24 -0
- package/dist/commonjs/icons/share-alt.js.map +1 -0
- package/dist/commonjs/icons/share.d.ts +8 -0
- package/dist/commonjs/icons/share.d.ts.map +1 -0
- package/dist/commonjs/icons/share.js +24 -0
- package/dist/commonjs/icons/share.js.map +1 -0
- package/dist/commonjs/icons/style-color.d.ts +8 -0
- package/dist/commonjs/icons/style-color.d.ts.map +1 -0
- package/dist/commonjs/icons/style-color.js +24 -0
- package/dist/commonjs/icons/style-color.js.map +1 -0
- package/dist/commonjs/icons/style-embroidery.d.ts +8 -0
- package/dist/commonjs/icons/style-embroidery.d.ts.map +1 -0
- package/dist/commonjs/icons/style-embroidery.js +24 -0
- package/dist/commonjs/icons/style-embroidery.js.map +1 -0
- package/dist/commonjs/icons/style-monochrome.d.ts +8 -0
- package/dist/commonjs/icons/style-monochrome.d.ts.map +1 -0
- package/dist/commonjs/icons/style-monochrome.js +24 -0
- package/dist/commonjs/icons/style-monochrome.js.map +1 -0
- package/dist/commonjs/index.d.ts +5 -5
- package/dist/commonjs/index.d.ts.map +1 -1
- package/dist/commonjs/index.js +5 -5
- package/dist/commonjs/index.js.map +1 -1
- package/dist/esm/components/checkbox/checkbox-group.d.ts +2 -2
- package/dist/esm/components/checkbox/checkbox-group.d.ts.map +1 -1
- package/dist/esm/components/checkbox/checkbox-group.js +8 -1
- package/dist/esm/components/checkbox/checkbox-group.js.map +1 -1
- package/dist/esm/components/checkbox/checkbox.d.ts +1 -1
- package/dist/esm/components/checkbox/checkbox.d.ts.map +1 -1
- package/dist/esm/components/checkbox/checkbox.js.map +1 -1
- package/dist/esm/components/combo-box/combo-box.d.ts +2 -2
- package/dist/esm/components/combo-box/combo-box.d.ts.map +1 -1
- package/dist/esm/components/combo-box/combo-box.js +7 -3
- package/dist/esm/components/combo-box/combo-box.js.map +1 -1
- package/dist/esm/components/date-picker/date-picker.d.ts +1 -1
- package/dist/esm/components/date-picker/date-picker.d.ts.map +1 -1
- package/dist/esm/components/date-picker/date-picker.js.map +1 -1
- package/dist/esm/components/drawer/drawer.d.ts +19 -18
- package/dist/esm/components/drawer/drawer.d.ts.map +1 -1
- package/dist/esm/components/drawer/drawer.js +12 -17
- package/dist/esm/components/drawer/drawer.js.map +1 -1
- package/dist/esm/components/file-picker/file-picker.d.ts.map +1 -1
- package/dist/esm/components/file-picker/file-picker.js +3 -3
- package/dist/esm/components/file-picker/file-picker.js.map +1 -1
- package/dist/esm/components/modal-dialog/modal-dialog.d.ts +2 -1
- package/dist/esm/components/modal-dialog/modal-dialog.d.ts.map +1 -1
- package/dist/esm/components/modal-dialog/modal-dialog.js +1 -1
- package/dist/esm/components/modal-dialog/modal-dialog.js.map +1 -1
- package/dist/esm/components/radio/radio-group.d.ts +2 -2
- package/dist/esm/components/radio/radio-group.d.ts.map +1 -1
- package/dist/esm/components/radio/radio-group.js +8 -1
- package/dist/esm/components/radio/radio-group.js.map +1 -1
- package/dist/esm/components/select/select.d.ts +2 -2
- package/dist/esm/components/select/select.d.ts.map +1 -1
- package/dist/esm/components/select/select.js +7 -3
- package/dist/esm/components/select/select.js.map +1 -1
- package/dist/esm/components/tabs/tabs.d.ts +1 -1
- package/dist/esm/components/tabs/tabs.d.ts.map +1 -1
- package/dist/esm/components/tabs/tabs.js +2 -4
- package/dist/esm/components/tabs/tabs.js.map +1 -1
- package/dist/esm/components/tag/tag-group.d.ts +1 -1
- package/dist/esm/components/tag/tag-group.d.ts.map +1 -1
- package/dist/esm/components/tag/tag-group.js.map +1 -1
- package/dist/esm/components/tag/tag.d.ts +1 -1
- package/dist/esm/components/tag/tag.d.ts.map +1 -1
- package/dist/esm/components/tag/tag.js.map +1 -1
- package/dist/esm/components/tag-field/tag-field.d.ts.map +1 -1
- package/dist/esm/components/tag-field/tag-field.js +6 -3
- package/dist/esm/components/tag-field/tag-field.js.map +1 -1
- package/dist/esm/components/text-inputs/text-field.d.ts.map +1 -1
- package/dist/esm/components/text-inputs/text-field.js +1 -1
- package/dist/esm/components/text-inputs/text-field.js.map +1 -1
- package/dist/esm/components/toggle/toggle.d.ts +1 -1
- package/dist/esm/components/toggle/toggle.d.ts.map +1 -1
- package/dist/esm/components/toggle/toggle.js.map +1 -1
- package/dist/esm/components/toggle-button/context.d.ts +2 -0
- package/dist/esm/components/toggle-button/context.d.ts.map +1 -0
- package/dist/esm/components/toggle-button/context.js +4 -0
- package/dist/esm/components/toggle-button/context.js.map +1 -0
- package/dist/esm/components/toggle-button/internal-toggle-button.d.ts +2 -0
- package/dist/esm/components/toggle-button/internal-toggle-button.d.ts.map +1 -0
- package/dist/esm/components/toggle-button/internal-toggle-button.js +51 -0
- package/dist/esm/components/toggle-button/internal-toggle-button.js.map +1 -0
- package/dist/esm/components/toggle-button/toggle-button-group.d.ts +10 -6
- package/dist/esm/components/toggle-button/toggle-button-group.d.ts.map +1 -1
- package/dist/esm/components/toggle-button/toggle-button-group.js +62 -10
- package/dist/esm/components/toggle-button/toggle-button-group.js.map +1 -1
- package/dist/esm/components/toggle-button/toggle-button.d.ts +8 -8
- package/dist/esm/components/toggle-button/toggle-button.d.ts.map +1 -1
- package/dist/esm/components/toggle-button/toggle-button.js +5 -5
- package/dist/esm/components/toggle-button/toggle-button.js.map +1 -1
- package/dist/esm/components/toggle-button/toggle-icon-button.d.ts +7 -6
- package/dist/esm/components/toggle-button/toggle-icon-button.d.ts.map +1 -1
- package/dist/esm/components/toggle-button/toggle-icon-button.js +6 -6
- package/dist/esm/components/toggle-button/toggle-icon-button.js.map +1 -1
- package/dist/esm/components/types.d.ts +14 -1
- package/dist/esm/components/types.d.ts.map +1 -1
- package/dist/esm/components/types.js.map +1 -1
- package/dist/esm/i18n/messages/en-US.d.ts.map +1 -1
- package/dist/esm/i18n/messages/en-US.js +1 -0
- package/dist/esm/i18n/messages/en-US.js.map +1 -1
- package/dist/esm/i18n/messages/types.d.ts +6 -0
- package/dist/esm/i18n/messages/types.d.ts.map +1 -1
- package/dist/esm/i18n/messages/types.js.map +1 -1
- package/dist/esm/icons/category-apparel.d.ts.map +1 -1
- package/dist/esm/icons/category-apparel.js +1 -1
- package/dist/esm/icons/category-apparel.js.map +1 -1
- package/dist/esm/icons/clock-user.d.ts +8 -0
- package/dist/esm/icons/clock-user.d.ts.map +1 -0
- package/dist/esm/icons/clock-user.js +19 -0
- package/dist/esm/icons/clock-user.js.map +1 -0
- package/dist/esm/icons/external-link.d.ts +8 -0
- package/dist/esm/icons/external-link.d.ts.map +1 -0
- package/dist/esm/icons/external-link.js +19 -0
- package/dist/esm/icons/external-link.js.map +1 -0
- package/dist/esm/icons/file-design.d.ts +8 -0
- package/dist/esm/icons/file-design.d.ts.map +1 -0
- package/dist/esm/icons/file-design.js +19 -0
- package/dist/esm/icons/file-design.js.map +1 -0
- package/dist/esm/icons/index.d.ts +11 -0
- package/dist/esm/icons/index.d.ts.map +1 -1
- package/dist/esm/icons/index.js +11 -0
- package/dist/esm/icons/index.js.map +1 -1
- package/dist/esm/icons/invoice.d.ts +8 -0
- package/dist/esm/icons/invoice.d.ts.map +1 -0
- package/dist/esm/icons/invoice.js +19 -0
- package/dist/esm/icons/invoice.js.map +1 -0
- package/dist/esm/icons/print.d.ts +8 -0
- package/dist/esm/icons/print.d.ts.map +1 -0
- package/dist/esm/icons/print.js +19 -0
- package/dist/esm/icons/print.js.map +1 -0
- package/dist/esm/icons/refresh.d.ts +8 -0
- package/dist/esm/icons/refresh.d.ts.map +1 -0
- package/dist/esm/icons/refresh.js +19 -0
- package/dist/esm/icons/refresh.js.map +1 -0
- package/dist/esm/icons/share-alt.d.ts +8 -0
- package/dist/esm/icons/share-alt.d.ts.map +1 -0
- package/dist/esm/icons/share-alt.js +19 -0
- package/dist/esm/icons/share-alt.js.map +1 -0
- package/dist/esm/icons/share.d.ts +8 -0
- package/dist/esm/icons/share.d.ts.map +1 -0
- package/dist/esm/icons/share.js +19 -0
- package/dist/esm/icons/share.js.map +1 -0
- package/dist/esm/icons/style-color.d.ts +8 -0
- package/dist/esm/icons/style-color.d.ts.map +1 -0
- package/dist/esm/icons/style-color.js +19 -0
- package/dist/esm/icons/style-color.js.map +1 -0
- package/dist/esm/icons/style-embroidery.d.ts +8 -0
- package/dist/esm/icons/style-embroidery.d.ts.map +1 -0
- package/dist/esm/icons/style-embroidery.js +19 -0
- package/dist/esm/icons/style-embroidery.js.map +1 -0
- package/dist/esm/icons/style-monochrome.d.ts +8 -0
- package/dist/esm/icons/style-monochrome.d.ts.map +1 -0
- package/dist/esm/icons/style-monochrome.js +19 -0
- package/dist/esm/icons/style-monochrome.js.map +1 -0
- package/dist/esm/index.d.ts +5 -5
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +5 -5
- package/dist/esm/index.js.map +1 -1
- package/dist-styles/core.css +1 -1
- package/dist-styles/styles.css +1 -1
- package/package.json +19 -15
|
@@ -1,24 +1,21 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import clsx from 'clsx';
|
|
4
|
-
import { Children } from 'react';
|
|
5
4
|
import { Dialog as RACDialog, DialogTrigger as RACDialogTrigger, Heading as RACHeading, Modal as RACModal, ModalOverlay as RACModalOverlay, } from 'react-aria-components';
|
|
6
5
|
import { forwardRef } from '../../forward-ref.js';
|
|
7
6
|
import { useLocalizedMessages } from '../../i18n/index.js';
|
|
8
|
-
import { useMediaQuery } from '../../utils/use-media-query.js';
|
|
9
7
|
import { useProductionWarning } from '../../utils/use-production-warning.js';
|
|
10
|
-
import { FocusableContainer } from '../internal/focusable-container/focusable-container.js';
|
|
11
8
|
import { XButton } from '../internal/x-button/x-button.js';
|
|
12
9
|
import { textStyle } from '../typography/utils.js';
|
|
13
10
|
/**
|
|
14
11
|
* Encapsulates a drawer trigger and its associated drawer.
|
|
15
12
|
* The trigger can be any Cimpress UI button, and the drawer will be displayed when the trigger is activated.
|
|
16
13
|
*/
|
|
17
|
-
export function
|
|
14
|
+
export function DrawerRoot(props) {
|
|
18
15
|
return _jsx(RACDialogTrigger, { ...props });
|
|
19
16
|
}
|
|
20
|
-
|
|
21
|
-
function
|
|
17
|
+
DrawerRoot.displayName = 'DrawerRoot';
|
|
18
|
+
function Drawer({ children, title, size = 'small', UNSAFE_className, UNSAFE_style, isDismissible = true, isOpen, defaultOpen, onOpenChange, ...props }, ref) {
|
|
22
19
|
const { 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy } = props;
|
|
23
20
|
useProductionWarning(() => {
|
|
24
21
|
if (!title && !ariaLabel && !ariaLabelledBy) {
|
|
@@ -26,25 +23,23 @@ function UNSTABLE_Drawer({ children, title, size = 'medium', UNSAFE_className, U
|
|
|
26
23
|
}
|
|
27
24
|
}, [title, ariaLabel, ariaLabelledBy]);
|
|
28
25
|
const messages = useLocalizedMessages('common');
|
|
29
|
-
return (_jsx(RACModalOverlay, { className: "cim-drawer-overlay", isDismissable: isDismissible, isKeyboardDismissDisabled: !isDismissible, isOpen: isOpen, defaultOpen: defaultOpen, onOpenChange: onOpenChange, "data-cim-style-root": true, children: _jsx(RACModal, { className: clsx('cim-drawer', UNSAFE_className), style: UNSAFE_style, "data-size": size, children: _jsx(RACDialog, { ...props, ref: ref, className: "cim-drawer-dialog", children: (renderProps) => (_jsxs(_Fragment, { children: [_jsxs("div", { className: "cim-drawer-header", children: [title && (_jsx(RACHeading, { slot: "title", className: clsx('cim-drawer-title', textStyle({ variant: 'title-5', tone: 'base' })), children: title })), _jsx(XButton, { "aria-label": messages.format('dismiss'), slot: "close" })] }), typeof children === 'function' ? children(renderProps) : children] })) }) }) }));
|
|
26
|
+
return (_jsx(RACModalOverlay, { className: "cim-drawer-overlay", isDismissable: isDismissible, isKeyboardDismissDisabled: !isDismissible, isOpen: isOpen, defaultOpen: defaultOpen, onOpenChange: onOpenChange, "data-cim-style-root": true, children: _jsx(RACModal, { className: clsx('cim-drawer', UNSAFE_className), style: UNSAFE_style, "data-size": size, children: _jsx(RACDialog, { ...props, ref: ref, className: "cim-drawer-dialog", children: (renderProps) => (_jsxs(_Fragment, { children: [_jsxs("div", { className: "cim-drawer-header", children: [title && (_jsx(RACHeading, { slot: "title", className: clsx('cim-drawer-title', textStyle({ variant: 'title-5', tone: 'base' })), children: title })), isDismissible && _jsx(XButton, { "aria-label": messages.format('dismiss'), slot: "close" })] }), typeof children === 'function' ? children(renderProps) : children] })) }) }) }));
|
|
30
27
|
}
|
|
31
28
|
/**
|
|
32
29
|
* Displays an overlay element which blocks interaction with outside elements.
|
|
33
30
|
*
|
|
34
31
|
* See [drawer usage guidelines](https://ui.cimpress.io/components/drawer/).
|
|
35
32
|
*/
|
|
36
|
-
const
|
|
37
|
-
export {
|
|
33
|
+
const _Drawer = forwardRef(Drawer, 'Drawer');
|
|
34
|
+
export { _Drawer as Drawer };
|
|
38
35
|
/** Renders content within `Drawer`. */
|
|
39
|
-
export function
|
|
40
|
-
return _jsx(
|
|
36
|
+
export function DrawerBody(props) {
|
|
37
|
+
return _jsx("div", { ...props, className: "cim-drawer-body" });
|
|
41
38
|
}
|
|
42
|
-
|
|
39
|
+
DrawerBody.displayName = 'DrawerBody';
|
|
43
40
|
/** Renders actions within `Drawer`. */
|
|
44
|
-
export function
|
|
45
|
-
|
|
46
|
-
const componentChildren = matches ? children : Children.toArray(children).reverse();
|
|
47
|
-
return (_jsx("div", { ...props, className: "cim-drawer-actions", children: componentChildren }));
|
|
41
|
+
export function DrawerActions({ children, ...props }) {
|
|
42
|
+
return (_jsx("div", { ...props, className: "cim-drawer-actions", children: children }));
|
|
48
43
|
}
|
|
49
|
-
|
|
44
|
+
DrawerActions.displayName = 'DrawerActions';
|
|
50
45
|
//# sourceMappingURL=drawer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drawer.js","sourceRoot":"","sources":["../../../../src/components/drawer/drawer.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,IAAI,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"drawer.js","sourceRoot":"","sources":["../../../../src/components/drawer/drawer.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EACL,MAAM,IAAI,SAAS,EACnB,aAAa,IAAI,gBAAgB,EACjC,OAAO,IAAI,UAAU,EACrB,KAAK,IAAI,QAAQ,EACjB,YAAY,IAAI,eAAe,GAChC,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAE3D,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAanD;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,KAA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kBAAkB,EAAE,SAAS,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,YAEnF,KAAK,GACK,CACd,EACA,aAAa,IAAI,KAAC,OAAO,kBAAa,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,IAAI,EAAC,OAAO,GAAG,IAC9E,EACL,OAAO,QAAQ,KAAK,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,QAAQ,IACjE,CACJ,GACS,GACH,GACK,CACnB,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AAE7C,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,CAAC;AAO7B,uCAAuC;AACvC,MAAM,UAAU,UAAU,CAAC,KAAsB;IAC/C,OAAO,iBAAS,KAAK,EAAE,SAAS,EAAC,iBAAiB,GAAG,CAAC;AACxD,CAAC;AAED,UAAU,CAAC,WAAW,GAAG,YAAY,CAAC;AAOtC,uCAAuC;AACvC,MAAM,UAAU,aAAa,CAAC,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAsB;IACtE,OAAO,CACL,iBAAS,KAAK,EAAE,SAAS,EAAC,oBAAoB,YAC3C,QAAQ,GACL,CACP,CAAC;AACJ,CAAC;AAED,aAAa,CAAC,WAAW,GAAG,eAAe,CAAC","sourcesContent":["'use client';\n\nimport clsx from 'clsx';\nimport type { ForwardedRef, ReactNode } from 'react';\nimport {\n Dialog as RACDialog,\n DialogTrigger as RACDialogTrigger,\n Heading as RACHeading,\n Modal as RACModal,\n ModalOverlay as RACModalOverlay,\n} from 'react-aria-components';\nimport { forwardRef } from '../../forward-ref.js';\nimport { useLocalizedMessages } from '../../i18n/index.js';\nimport { useProductionWarning } from '../../utils/use-production-warning.js';\nimport { XButton } from '../internal/x-button/x-button.js';\nimport type { AriaLabelingProps, CommonProps } from '../types.js';\nimport { textStyle } from '../typography/utils.js';\n\nexport interface DrawerRootProps {\n /** The drawer trigger with its associated drawer. Provide the trigger as the first child, and the drawer as the second child. */\n children: ReactNode;\n /** Whether the drawer is open (controlled). */\n isOpen?: boolean;\n /** Whether the drawer is open by default (uncontrolled). */\n defaultOpen?: boolean;\n /** Handler that is called when the drawer's open state changes. */\n onOpenChange?: (isOpen: boolean) => void;\n}\n\n/**\n * Encapsulates a drawer trigger and its associated drawer.\n * The trigger can be any Cimpress UI button, and the drawer will be displayed when the trigger is activated.\n */\nexport function DrawerRoot(props: DrawerRootProps) {\n return <RACDialogTrigger {...props} />;\n}\n\nDrawerRoot.displayName = 'DrawerRoot';\n\nexport interface DrawerRenderProps {\n /** Closes the drawer when called. */\n close: () => void;\n}\n\nexport interface DrawerProps extends CommonProps, AriaLabelingProps {\n /** The contents of the drawer. A function may be provided to access a function to close the drawer. */\n children: ReactNode | ((renderProps: DrawerRenderProps) => ReactNode);\n /** The title of the drawer. */\n title: string;\n /**\n * The size of the drawer. This prop is ignored on small devices - drawers on small devices will always take up all available width.\n * @default 'small'\n */\n size?: 'small' | 'medium' | 'large';\n /**\n * Whether the drawer can be closed by clicking the close button, clicking outside of the drawer, or pressing the Escape key.\n * When `false`, the drawer can only be closed programmatically.\n * @default true\n */\n isDismissible?: boolean;\n /**\n * Whether the drawer is open (controlled).\n * If using `DrawerRoot`, this prop has no effect - provide `isOpen` to `DrawerRoot` instead.\n */\n isOpen?: boolean;\n /**\n * Whether the drawer is open by default (uncontrolled).\n * If using `DrawerRoot`, this prop has no effect - provide `defaultOpen` to `DrawerRoot` instead.\n */\n defaultOpen?: boolean;\n /**\n * Handler that is called when the drawer's open state changes.\n * If using `DrawerRoot`, this prop has no effect - provide `onOpenChange` to `DrawerRoot` instead.\n */\n onOpenChange?: (isOpen: boolean) => void;\n}\n\nfunction Drawer(\n {\n children,\n title,\n size = 'small',\n UNSAFE_className,\n UNSAFE_style,\n isDismissible = true,\n isOpen,\n defaultOpen,\n onOpenChange,\n ...props\n }: DrawerProps,\n ref: ForwardedRef<HTMLElement>,\n) {\n const { 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy } = props;\n\n useProductionWarning(() => {\n if (!title && !ariaLabel && !ariaLabelledBy) {\n console.warn('Drawer requires one of title / aria-label / aria-labelledby for accessibility');\n }\n }, [title, ariaLabel, ariaLabelledBy]);\n\n const messages = useLocalizedMessages('common');\n\n return (\n <RACModalOverlay\n className=\"cim-drawer-overlay\"\n isDismissable={isDismissible}\n isKeyboardDismissDisabled={!isDismissible}\n isOpen={isOpen}\n defaultOpen={defaultOpen}\n onOpenChange={onOpenChange}\n data-cim-style-root\n >\n <RACModal className={clsx('cim-drawer', UNSAFE_className)} style={UNSAFE_style} data-size={size}>\n <RACDialog {...props} ref={ref} className=\"cim-drawer-dialog\">\n {(renderProps) => (\n <>\n <div className=\"cim-drawer-header\">\n {title && (\n <RACHeading\n slot=\"title\"\n className={clsx('cim-drawer-title', textStyle({ variant: 'title-5', tone: 'base' }))}\n >\n {title}\n </RACHeading>\n )}\n {isDismissible && <XButton aria-label={messages.format('dismiss')} slot=\"close\" />}\n </div>\n {typeof children === 'function' ? children(renderProps) : children}\n </>\n )}\n </RACDialog>\n </RACModal>\n </RACModalOverlay>\n );\n}\n\n/**\n * Displays an overlay element which blocks interaction with outside elements.\n *\n * See [drawer usage guidelines](https://ui.cimpress.io/components/drawer/).\n */\nconst _Drawer = forwardRef(Drawer, 'Drawer');\n\nexport { _Drawer as Drawer };\n\nexport interface DrawerBodyProps {\n /** The content to render within the drawer. */\n children: ReactNode;\n}\n\n/** Renders content within `Drawer`. */\nexport function DrawerBody(props: DrawerBodyProps) {\n return <div {...props} className=\"cim-drawer-body\" />;\n}\n\nDrawerBody.displayName = 'DrawerBody';\n\nexport interface DrawerActionsProps {\n /** Actions that should be available in the drawer. */\n children: ReactNode;\n}\n\n/** Renders actions within `Drawer`. */\nexport function DrawerActions({ children, ...props }: DrawerActionsProps) {\n return (\n <div {...props} className=\"cim-drawer-actions\">\n {children}\n </div>\n );\n}\n\nDrawerActions.displayName = 'DrawerActions';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-picker.d.ts","sourceRoot":"","sources":["../../../../src/components/file-picker/file-picker.tsx"],"names":[],"mappings":"AAKA,OAAO,EAGL,KAAK,gBAAgB,IAAI,mBAAmB,EAI7C,MAAM,uBAAuB,CAAC;AAM/B,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAI3D,MAAM,WAAW,wBACf,SAAQ,WAAW,EACjB,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,EAAE,YAAY,CAAC,EACtC,IAAI,CAAC,mBAAmB,EAAE,mBAAmB,GAAG,gBAAgB,GAAG,iBAAiB,GAAG,eAAe,CAAC;IACzG,qCAAqC;IACrC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,qCAAqC;IACrC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,oCAAoC;IACpC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,mDAAmD;IACnD,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,8CAA8C;IAC9C,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,8CAA8C;IAC9C,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,IAAI,KAAK,IAAI,CAAC;CAC3C;
|
|
1
|
+
{"version":3,"file":"file-picker.d.ts","sourceRoot":"","sources":["../../../../src/components/file-picker/file-picker.tsx"],"names":[],"mappings":"AAKA,OAAO,EAGL,KAAK,gBAAgB,IAAI,mBAAmB,EAI7C,MAAM,uBAAuB,CAAC;AAM/B,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAI3D,MAAM,WAAW,wBACf,SAAQ,WAAW,EACjB,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,EAAE,YAAY,CAAC,EACtC,IAAI,CAAC,mBAAmB,EAAE,mBAAmB,GAAG,gBAAgB,GAAG,iBAAiB,GAAG,eAAe,CAAC;IACzG,qCAAqC;IACrC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,qCAAqC;IACrC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,oCAAoC;IACpC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,mDAAmD;IACnD,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,8CAA8C;IAC9C,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,8CAA8C;IAC9C,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,IAAI,KAAK,IAAI,CAAC;CAC3C;AAqID,QAAA,MAAM,oBAAoB,0KAAgE,CAAC;AAE3F,OAAO,EAAE,oBAAoB,IAAI,mBAAmB,EAAE,CAAC"}
|
|
@@ -12,7 +12,7 @@ import { Button } from '../button/button.js';
|
|
|
12
12
|
import { FormFieldDescription, FormFieldError, FormFieldLabel } from '../internal/form-field/form-field.js';
|
|
13
13
|
import { Text } from '../typography/text.js';
|
|
14
14
|
import { UNSTABLE_VisuallyHidden } from '../visually-hidden/visually-hidden.js';
|
|
15
|
-
function UNSTABLE_FilePicker({ id, label, description, isDisabled, isRequired, isInvalid, onSelect, acceptedFileTypes, allowsMultiple, acceptDirectory, defaultCamera, error, name, validate, 'aria-labelledby': ariaLabelledBy, 'aria-describedby': ariaDescribedBy, 'aria-details': ariaDetails, UNSAFE_className, UNSAFE_style, ...props }, ref) {
|
|
15
|
+
function UNSTABLE_FilePicker({ id, label, description, isDisabled, isRequired, isInvalid, onSelect, acceptedFileTypes, allowsMultiple, acceptDirectory, defaultCamera, error, form, name, validate, 'aria-labelledby': ariaLabelledBy, 'aria-describedby': ariaDescribedBy, 'aria-details': ariaDetails, UNSAFE_className, UNSAFE_style, ...props }, ref) {
|
|
16
16
|
const buttonId = useId(id);
|
|
17
17
|
const labelId = useId();
|
|
18
18
|
const fileTextId = useId();
|
|
@@ -45,7 +45,7 @@ function UNSTABLE_FilePicker({ id, label, description, isDisabled, isRequired, i
|
|
|
45
45
|
validationBehavior,
|
|
46
46
|
});
|
|
47
47
|
useFormValidation({ isInvalid, isRequired, validate, validationBehavior }, validationState, fileInputRef);
|
|
48
|
-
useFormReset(fileInputRef,
|
|
48
|
+
useFormReset(fileInputRef, null, setFiles);
|
|
49
49
|
const descriptionId = useSlotId([Boolean(description)]);
|
|
50
50
|
const errorMessageId = useSlotId([
|
|
51
51
|
Boolean(error || validationState.displayValidation.validationErrors),
|
|
@@ -55,7 +55,7 @@ function UNSTABLE_FilePicker({ id, label, description, isDisabled, isRequired, i
|
|
|
55
55
|
[RACLabelContext, label != null ? { id: labelId, htmlFor: buttonId } : {}],
|
|
56
56
|
[RACTextContext, { slots: { description: { id: descriptionId }, errorMessage: { id: errorMessageId } } }],
|
|
57
57
|
[RACFieldErrorContext, validationState.displayValidation],
|
|
58
|
-
], children: [_jsxs("div", { ...props, className: clsx('cim-file-picker', UNSAFE_className), style: UNSAFE_style, ref: ref, children: [label && (_jsxs(FormFieldLabel, { isRequired: isRequired, isDisabled: isDisabled, children: [label, isRequired && _jsx(UNSTABLE_VisuallyHidden, { children: labelMessages.format('required') })] })), _jsxs("div", { className: "cim-file-picker-button-container", children: [_jsx(RACFileTrigger, { onSelect: handleSelect, acceptedFileTypes: acceptedFileTypes, allowsMultiple: allowsMultiple, acceptDirectory: acceptDirectory, defaultCamera: defaultCamera, children: _jsx(Button, { id: buttonId, isDisabled: isDisabled, "aria-labelledby": [buttonId, label != null ? labelId : null, ariaLabelledBy].filter(Boolean).join(' '), "aria-describedby": [fileTextId, descriptionId, errorMessageId, ariaDescribedBy].join(' '), "aria-details": ariaDetails, children: messages.format('chooseFile') }) }), _jsx(Text, { id: fileTextId, as: "p", variant: "medium", tone: "base", children: labelText })] }), _jsx(FormFieldError, { children: error }), _jsx(FormFieldDescription, { children: description })] }), name && (_jsx("input", { type: "file", className: "cim-file-picker-hidden-input", name: name, multiple: allowsMultiple, required: isRequired, ref: fileInputRef }))] }));
|
|
58
|
+
], children: [_jsxs("div", { ...props, className: clsx('cim-file-picker', UNSAFE_className), style: UNSAFE_style, ref: ref, children: [label && (_jsxs(FormFieldLabel, { isRequired: isRequired, isDisabled: isDisabled, children: [label, isRequired && _jsx(UNSTABLE_VisuallyHidden, { children: labelMessages.format('required') })] })), _jsxs("div", { className: "cim-file-picker-button-container", children: [_jsx(RACFileTrigger, { onSelect: handleSelect, acceptedFileTypes: acceptedFileTypes, allowsMultiple: allowsMultiple, acceptDirectory: acceptDirectory, defaultCamera: defaultCamera, children: _jsx(Button, { id: buttonId, isDisabled: isDisabled, "aria-labelledby": [buttonId, label != null ? labelId : null, ariaLabelledBy].filter(Boolean).join(' '), "aria-describedby": [fileTextId, descriptionId, errorMessageId, ariaDescribedBy].join(' '), "aria-details": ariaDetails, children: messages.format('chooseFile') }) }), _jsx(Text, { id: fileTextId, as: "p", variant: "medium", tone: "base", children: labelText })] }), _jsx(FormFieldError, { children: error }), _jsx(FormFieldDescription, { children: description })] }), name && (_jsx("input", { type: "file", className: "cim-file-picker-hidden-input", form: form, name: name, multiple: allowsMultiple, required: isRequired, ref: fileInputRef }))] }));
|
|
59
59
|
}
|
|
60
60
|
const _UNSTABLE_FilePicker = withStyleProps(forwardRef(UNSTABLE_FilePicker), 'FilePicker');
|
|
61
61
|
export { _UNSTABLE_FilePicker as UNSTABLE_FilePicker };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-picker.js","sourceRoot":"","sources":["../../../../src/components/file-picker/file-picker.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAA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,YAE5B,KAAC,MAAM,IACL,EAAE,EAAE,QAAQ,EACZ,UAAU,EAAE,UAAU,qBACL,CAAC,QAAQ,EAAE,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,sBACnF,CAAC,UAAU,EAAE,aAAa,EAAE,cAAc,EAAE,eAAe,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,kBAC1E,WAAW,YAExB,QAAQ,CAAC,MAAM,CAAC,YAAY,CAAC,GACvB,GACM,EACjB,KAAC,IAAI,IAAC,EAAE,EAAE,UAAU,EAAE,EAAE,EAAC,GAAG,EAAC,OAAO,EAAC,QAAQ,EAAC,IAAI,EAAC,MAAM,YACtD,SAAS,GACL,IACH,EACN,KAAC,cAAc,cAAE,KAAK,GAAkB,EACxC,KAAC,oBAAoB,cAAE,WAAW,GAAwB,IACtD,EACL,IAAI,IAAI,CACP,gBACE,IAAI,EAAC,MAAM,EACX,SAAS,EAAC,8BAA8B,EACxC,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,cAAc,EACxB,QAAQ,EAAE,UAAU,EACpB,GAAG,EAAE,YAAY,GACjB,CACH,IACW,CACf,CAAC;AACJ,CAAC;AAED,MAAM,oBAAoB,GAAG,cAAc,CAAC,UAAU,CAAC,mBAAmB,CAAC,EAAE,YAAY,CAAC,CAAC;AAE3F,OAAO,EAAE,oBAAoB,IAAI,mBAAmB,EAAE,CAAC","sourcesContent":["import { useFormValidation } from '@react-aria/form';\nimport { useFormReset, useId, useSlotId } from '@react-aria/utils';\nimport { useFormValidationState } from '@react-stately/form';\nimport clsx from 'clsx';\nimport { type ForwardedRef, useRef, useState } from 'react';\nimport {\n FieldErrorContext as RACFieldErrorContext,\n FileTrigger as RACFileTrigger,\n type FileTriggerProps as RACFileTriggerProps,\n LabelContext as RACLabelContext,\n Provider as RACProvider,\n TextContext as RACTextContext,\n} from 'react-aria-components';\nimport { forwardRef } from '../../forward-ref.js';\nimport { useLocalizedMessages } from '../../i18n/index.js';\nimport { withStyleProps } from '../../with-style-props.js';\nimport { Button } from '../button/button.js';\nimport { FormFieldDescription, FormFieldError, FormFieldLabel } from '../internal/form-field/form-field.js';\nimport type { CommonProps, FieldProps } from '../types.js';\nimport { Text } from '../typography/text.js';\nimport { UNSTABLE_VisuallyHidden } from '../visually-hidden/visually-hidden.js';\n\nexport interface UNSTABLE_FilePickerProps\n extends CommonProps,\n Omit<FieldProps<File[]>, 'aria-label'>,\n Pick<RACFileTriggerProps, 'acceptedFileTypes' | 'allowsMultiple' | 'acceptDirectory' | 'defaultCamera'> {\n /** Whether the field is disabled. */\n isDisabled?: boolean;\n /** Whether the field is required. */\n isRequired?: boolean;\n /** Whether the field is invalid. */\n isInvalid?: boolean;\n /** The allowed file types that can be selected. */\n acceptedFileTypes?: string[];\n /** Whether multiple files can be selected. */\n allowsMultiple?: boolean;\n /** Handler called when files are selected. */\n onSelect?: (files: File[] | null) => void;\n}\n\nfunction UNSTABLE_FilePicker(\n {\n id,\n label,\n description,\n isDisabled,\n isRequired,\n isInvalid,\n onSelect,\n acceptedFileTypes,\n allowsMultiple,\n acceptDirectory,\n defaultCamera,\n error,\n name,\n validate,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-details': ariaDetails,\n UNSAFE_className,\n UNSAFE_style,\n ...props\n }: UNSTABLE_FilePickerProps,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const buttonId = useId(id);\n const labelId = useId();\n const fileTextId = useId();\n\n const [files, setFiles] = useState<File[] | null>(null);\n const fileInputRef = useRef<HTMLInputElement>(null);\n const handleSelect = (files: FileList | null) => {\n // Commit validation to clear any previous validation errors when new files are selected\n validationState.commitValidation();\n\n const filesArray = files?.length ? Array.from(files) : null;\n setFiles(filesArray);\n onSelect?.(filesArray);\n\n if (fileInputRef.current) {\n fileInputRef.current.files = files;\n }\n };\n\n const labelMessages = useLocalizedMessages('label');\n const messages = useLocalizedMessages('filePicker');\n const labelText =\n files?.length != null\n ? files.length === 1\n ? files[0]?.name\n : messages.format('multipleFilesSelected', { fileCount: files.length })\n : messages.format('noFilesSelected', { allowsMultiple: allowsMultiple ?? false });\n\n const validationBehavior = 'native';\n const validationState = useFormValidationState({\n value: files,\n isInvalid,\n isRequired,\n name,\n validate,\n validationBehavior,\n });\n useFormValidation({ isInvalid, isRequired, validate, validationBehavior }, validationState, fileInputRef);\n useFormReset(fileInputRef, files, setFiles);\n\n const descriptionId = useSlotId([Boolean(description)]);\n const errorMessageId = useSlotId([\n Boolean(error || validationState.displayValidation.validationErrors),\n validationState.displayValidation.isInvalid,\n ]);\n\n return (\n <RACProvider\n values={[\n [RACLabelContext, label != null ? { id: labelId, htmlFor: buttonId } : {}],\n [RACTextContext, { slots: { description: { id: descriptionId }, errorMessage: { id: errorMessageId } } }],\n [RACFieldErrorContext, validationState.displayValidation],\n ]}\n >\n <div {...props} className={clsx('cim-file-picker', UNSAFE_className)} style={UNSAFE_style} ref={ref}>\n {label && (\n <FormFieldLabel isRequired={isRequired} isDisabled={isDisabled}>\n {label}\n {/*\n * Button elements don't support `aria-required`, so we need to add visually hidden text to indicate that the field is required.\n * See: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-required#examples:~:text=Note%3A%20If%20the%20field%27s%20label%20already%20contains%20the%20word%20%22required%22%2C%20it%20is%20recommended%20to%20leave%20out%20the%20aria%2Drequired%20attribute.%20This%20avoids%20that%20screen%20readers%20read%20out%20the%20term%20%22required%22%20twice.\n */}\n {isRequired && <UNSTABLE_VisuallyHidden>{labelMessages.format('required')}</UNSTABLE_VisuallyHidden>}\n </FormFieldLabel>\n )}\n <div className=\"cim-file-picker-button-container\">\n <RACFileTrigger\n onSelect={handleSelect}\n acceptedFileTypes={acceptedFileTypes}\n allowsMultiple={allowsMultiple}\n acceptDirectory={acceptDirectory}\n defaultCamera={defaultCamera}\n >\n <Button\n id={buttonId}\n isDisabled={isDisabled}\n aria-labelledby={[buttonId, label != null ? labelId : null, ariaLabelledBy].filter(Boolean).join(' ')}\n aria-describedby={[fileTextId, descriptionId, errorMessageId, ariaDescribedBy].join(' ')}\n aria-details={ariaDetails}\n >\n {messages.format('chooseFile')}\n </Button>\n </RACFileTrigger>\n <Text id={fileTextId} as=\"p\" variant=\"medium\" tone=\"base\">\n {labelText}\n </Text>\n </div>\n <FormFieldError>{error}</FormFieldError>\n <FormFieldDescription>{description}</FormFieldDescription>\n </div>\n {name && (\n <input\n type=\"file\"\n className=\"cim-file-picker-hidden-input\"\n name={name}\n multiple={allowsMultiple}\n required={isRequired}\n ref={fileInputRef}\n />\n )}\n </RACProvider>\n );\n}\n\nconst _UNSTABLE_FilePicker = withStyleProps(forwardRef(UNSTABLE_FilePicker), 'FilePicker');\n\nexport { _UNSTABLE_FilePicker as UNSTABLE_FilePicker };\n"]}
|
|
1
|
+
{"version":3,"file":"file-picker.js","sourceRoot":"","sources":["../../../../src/components/file-picker/file-picker.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAqB,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5D,OAAO,EACL,iBAAiB,IAAI,oBAAoB,EACzC,WAAW,IAAI,cAAc,EAE7B,YAAY,IAAI,eAAe,EAC/B,QAAQ,IAAI,WAAW,EACvB,WAAW,IAAI,cAAc,GAC9B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAA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AW,YAExB,QAAQ,CAAC,MAAM,CAAC,YAAY,CAAC,GACvB,GACM,EACjB,KAAC,IAAI,IAAC,EAAE,EAAE,UAAU,EAAE,EAAE,EAAC,GAAG,EAAC,OAAO,EAAC,QAAQ,EAAC,IAAI,EAAC,MAAM,YACtD,SAAS,GACL,IACH,EACN,KAAC,cAAc,cAAE,KAAK,GAAkB,EACxC,KAAC,oBAAoB,cAAE,WAAW,GAAwB,IACtD,EACL,IAAI,IAAI,CACP,gBACE,IAAI,EAAC,MAAM,EACX,SAAS,EAAC,8BAA8B,EACxC,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,cAAc,EACxB,QAAQ,EAAE,UAAU,EACpB,GAAG,EAAE,YAAY,GACjB,CACH,IACW,CACf,CAAC;AACJ,CAAC;AAED,MAAM,oBAAoB,GAAG,cAAc,CAAC,UAAU,CAAC,mBAAmB,CAAC,EAAE,YAAY,CAAC,CAAC;AAE3F,OAAO,EAAE,oBAAoB,IAAI,mBAAmB,EAAE,CAAC","sourcesContent":["import { useFormValidation } from '@react-aria/form';\nimport { useFormReset, useId, useSlotId } from '@react-aria/utils';\nimport { useFormValidationState } from '@react-stately/form';\nimport clsx from 'clsx';\nimport { type ForwardedRef, useRef, useState } from 'react';\nimport {\n FieldErrorContext as RACFieldErrorContext,\n FileTrigger as RACFileTrigger,\n type FileTriggerProps as RACFileTriggerProps,\n LabelContext as RACLabelContext,\n Provider as RACProvider,\n TextContext as RACTextContext,\n} from 'react-aria-components';\nimport { forwardRef } from '../../forward-ref.js';\nimport { useLocalizedMessages } from '../../i18n/index.js';\nimport { withStyleProps } from '../../with-style-props.js';\nimport { Button } from '../button/button.js';\nimport { FormFieldDescription, FormFieldError, FormFieldLabel } from '../internal/form-field/form-field.js';\nimport type { CommonProps, FieldProps } from '../types.js';\nimport { Text } from '../typography/text.js';\nimport { UNSTABLE_VisuallyHidden } from '../visually-hidden/visually-hidden.js';\n\nexport interface UNSTABLE_FilePickerProps\n extends CommonProps,\n Omit<FieldProps<File[]>, 'aria-label'>,\n Pick<RACFileTriggerProps, 'acceptedFileTypes' | 'allowsMultiple' | 'acceptDirectory' | 'defaultCamera'> {\n /** Whether the field is disabled. */\n isDisabled?: boolean;\n /** Whether the field is required. */\n isRequired?: boolean;\n /** Whether the field is invalid. */\n isInvalid?: boolean;\n /** The allowed file types that can be selected. */\n acceptedFileTypes?: string[];\n /** Whether multiple files can be selected. */\n allowsMultiple?: boolean;\n /** Handler called when files are selected. */\n onSelect?: (files: File[] | null) => void;\n}\n\nfunction UNSTABLE_FilePicker(\n {\n id,\n label,\n description,\n isDisabled,\n isRequired,\n isInvalid,\n onSelect,\n acceptedFileTypes,\n allowsMultiple,\n acceptDirectory,\n defaultCamera,\n error,\n form,\n name,\n validate,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-details': ariaDetails,\n UNSAFE_className,\n UNSAFE_style,\n ...props\n }: UNSTABLE_FilePickerProps,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const buttonId = useId(id);\n const labelId = useId();\n const fileTextId = useId();\n\n const [files, setFiles] = useState<File[] | null>(null);\n const fileInputRef = useRef<HTMLInputElement>(null);\n const handleSelect = (files: FileList | null) => {\n // Commit validation to clear any previous validation errors when new files are selected\n validationState.commitValidation();\n\n const filesArray = files?.length ? Array.from(files) : null;\n setFiles(filesArray);\n onSelect?.(filesArray);\n\n if (fileInputRef.current) {\n fileInputRef.current.files = files;\n }\n };\n\n const labelMessages = useLocalizedMessages('label');\n const messages = useLocalizedMessages('filePicker');\n const labelText =\n files?.length != null\n ? files.length === 1\n ? files[0]?.name\n : messages.format('multipleFilesSelected', { fileCount: files.length })\n : messages.format('noFilesSelected', { allowsMultiple: allowsMultiple ?? false });\n\n const validationBehavior = 'native';\n const validationState = useFormValidationState({\n value: files,\n isInvalid,\n isRequired,\n name,\n validate,\n validationBehavior,\n });\n useFormValidation({ isInvalid, isRequired, validate, validationBehavior }, validationState, fileInputRef);\n useFormReset(fileInputRef, null, setFiles);\n\n const descriptionId = useSlotId([Boolean(description)]);\n const errorMessageId = useSlotId([\n Boolean(error || validationState.displayValidation.validationErrors),\n validationState.displayValidation.isInvalid,\n ]);\n\n return (\n <RACProvider\n values={[\n [RACLabelContext, label != null ? { id: labelId, htmlFor: buttonId } : {}],\n [RACTextContext, { slots: { description: { id: descriptionId }, errorMessage: { id: errorMessageId } } }],\n [RACFieldErrorContext, validationState.displayValidation],\n ]}\n >\n <div {...props} className={clsx('cim-file-picker', UNSAFE_className)} style={UNSAFE_style} ref={ref}>\n {label && (\n <FormFieldLabel isRequired={isRequired} isDisabled={isDisabled}>\n {label}\n {/*\n * Button elements don't support `aria-required`, so we need to add visually hidden text to indicate that the field is required.\n * See: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-required#examples:~:text=Note%3A%20If%20the%20field%27s%20label%20already%20contains%20the%20word%20%22required%22%2C%20it%20is%20recommended%20to%20leave%20out%20the%20aria%2Drequired%20attribute.%20This%20avoids%20that%20screen%20readers%20read%20out%20the%20term%20%22required%22%20twice.\n */}\n {isRequired && <UNSTABLE_VisuallyHidden>{labelMessages.format('required')}</UNSTABLE_VisuallyHidden>}\n </FormFieldLabel>\n )}\n <div className=\"cim-file-picker-button-container\">\n <RACFileTrigger\n onSelect={handleSelect}\n acceptedFileTypes={acceptedFileTypes}\n allowsMultiple={allowsMultiple}\n acceptDirectory={acceptDirectory}\n defaultCamera={defaultCamera}\n >\n <Button\n id={buttonId}\n isDisabled={isDisabled}\n aria-labelledby={[buttonId, label != null ? labelId : null, ariaLabelledBy].filter(Boolean).join(' ')}\n aria-describedby={[fileTextId, descriptionId, errorMessageId, ariaDescribedBy].join(' ')}\n aria-details={ariaDetails}\n >\n {messages.format('chooseFile')}\n </Button>\n </RACFileTrigger>\n <Text id={fileTextId} as=\"p\" variant=\"medium\" tone=\"base\">\n {labelText}\n </Text>\n </div>\n <FormFieldError>{error}</FormFieldError>\n <FormFieldDescription>{description}</FormFieldDescription>\n </div>\n {name && (\n <input\n type=\"file\"\n className=\"cim-file-picker-hidden-input\"\n form={form}\n name={name}\n multiple={allowsMultiple}\n required={isRequired}\n ref={fileInputRef}\n />\n )}\n </RACProvider>\n );\n}\n\nconst _UNSTABLE_FilePicker = withStyleProps(forwardRef(UNSTABLE_FilePicker), 'FilePicker');\n\nexport { _UNSTABLE_FilePicker as UNSTABLE_FilePicker };\n"]}
|
|
@@ -15,7 +15,8 @@ export interface ModalDialogProps extends CommonProps, AriaLabelingProps {
|
|
|
15
15
|
*/
|
|
16
16
|
size?: 'small' | 'medium' | 'large';
|
|
17
17
|
/**
|
|
18
|
-
* Whether
|
|
18
|
+
* Whether the modal dialog can be closed by clicking the close button, clicking outside of the modal dialog, or pressing the Escape key.
|
|
19
|
+
* When `false`, the modal dialog can only be closed programmatically.
|
|
19
20
|
* @default true
|
|
20
21
|
*/
|
|
21
22
|
isDismissible?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal-dialog.d.ts","sourceRoot":"","sources":["../../../../src/components/modal-dialog/modal-dialog.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAgB,SAAS,EAAE,MAAM,OAAO,CAAC;AAYrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAGlE,MAAM,WAAW,sBAAsB;IACrC,2CAA2C;IAC3C,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAED,MAAM,WAAW,gBAAiB,SAAQ,WAAW,EAAE,iBAAiB;IACtE,mHAAmH;IACnH,QAAQ,EAAE,SAAS,GAAG,CAAC,CAAC,WAAW,EAAE,sBAAsB,KAAK,SAAS,CAAC,CAAC;IAC3E,qCAAqC;IACrC,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;IACpC
|
|
1
|
+
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EAAE,EAAE,uBAAuB,2CAMjF;yBANe,kBAAkB"}
|
|
@@ -16,7 +16,7 @@ function ModalDialog({ children, title, size = 'medium', UNSAFE_className, UNSAF
|
|
|
16
16
|
}
|
|
17
17
|
}, [title, ariaLabel, ariaLabelledBy]);
|
|
18
18
|
const messages = useLocalizedMessages('common');
|
|
19
|
-
return (_jsx(RACModalOverlay, { className: "cim-modal-overlay", isDismissable: isDismissible, isKeyboardDismissDisabled: !isDismissible, isOpen: isOpen, defaultOpen: defaultOpen, onOpenChange: onOpenChange, "data-cim-style-root": true, children: _jsx(RACModal, { className: clsx('cim-modal', UNSAFE_className), style: UNSAFE_style, "data-size": size, children: _jsx(RACDialog, { ...props, ref: ref, className: "cim-modal-dialog", children: (renderProps) => (_jsxs(_Fragment, { children: [_jsxs("div", { className: "cim-modal-header", children: [title && (_jsx(RACHeading, { slot: "title", className: clsx('cim-modal-title', textStyle({ variant: 'title-5', tone: 'base' })), children: title })), _jsx(XButton, { "aria-label": messages.format('dismiss'), slot: "close" })] }), typeof children === 'function' ? children(renderProps) : children] })) }) }) }));
|
|
19
|
+
return (_jsx(RACModalOverlay, { className: "cim-modal-overlay", isDismissable: isDismissible, isKeyboardDismissDisabled: !isDismissible, isOpen: isOpen, defaultOpen: defaultOpen, onOpenChange: onOpenChange, "data-cim-style-root": true, children: _jsx(RACModal, { className: clsx('cim-modal', UNSAFE_className), style: UNSAFE_style, "data-size": size, children: _jsx(RACDialog, { ...props, ref: ref, className: "cim-modal-dialog", children: (renderProps) => (_jsxs(_Fragment, { children: [_jsxs("div", { className: "cim-modal-header", children: [title && (_jsx(RACHeading, { slot: "title", className: clsx('cim-modal-title', textStyle({ variant: 'title-5', tone: 'base' })), children: title })), isDismissible && _jsx(XButton, { "aria-label": messages.format('dismiss'), slot: "close" })] }), typeof children === 'function' ? children(renderProps) : children] })) }) }) }));
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
22
|
* Displays an overlay element which blocks interaction with outside elements.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal-dialog.js","sourceRoot":"","sources":["../../../../src/components/modal-dialog/modal-dialog.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EACL,MAAM,IAAI,SAAS,EACnB,OAAO,IAAI,UAAU,EACrB,KAAK,IAAI,QAAQ,EACjB,YAAY,IAAI,eAAe,GAChC,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,kBAAkB,EAAE,MAAM,wDAAwD,CAAC;AAC5F,OAAO,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAE3D,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"modal-dialog.js","sourceRoot":"","sources":["../../../../src/components/modal-dialog/modal-dialog.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EACL,MAAM,IAAI,SAAS,EACnB,OAAO,IAAI,UAAU,EACrB,KAAK,IAAI,QAAQ,EACjB,YAAY,IAAI,eAAe,GAChC,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,kBAAkB,EAAE,MAAM,wDAAwD,CAAC;AAC5F,OAAO,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAE3D,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAwCnD,SAAS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aAAa,IAAI,KAAC,OAAO,kBAAa,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,IAAI,EAAC,OAAO,GAAG,IAC9E,EACL,OAAO,QAAQ,KAAK,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,QAAQ,IACjE,CACJ,GACS,GACH,GACK,CACnB,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,YAAY,GAAG,UAAU,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;AAE5D,OAAO,EAAE,YAAY,IAAI,WAAW,EAAE,CAAC;AAOvC,4CAA4C;AAC5C,MAAM,UAAU,eAAe,CAAC,KAA2B;IACzD,OAAO,KAAC,kBAAkB,OAAK,KAAK,EAAE,SAAS,EAAC,gBAAgB,EAAC,eAAe,EAAC,UAAU,GAAG,CAAC;AACjG,CAAC;AAED,eAAe,CAAC,WAAW,GAAG,iBAAiB,CAAC;AAOhD,4CAA4C;AAC5C,MAAM,UAAU,kBAAkB,CAAC,EAAE,QAAQ,EAAE,GAAG,KAAK,EAA2B;IAChF,OAAO,CACL,iBAAS,KAAK,EAAE,SAAS,EAAC,mBAAmB,YAC1C,QAAQ,GACL,CACP,CAAC;AACJ,CAAC;AAED,kBAAkB,CAAC,WAAW,GAAG,oBAAoB,CAAC","sourcesContent":["'use client';\n\nimport clsx from 'clsx';\nimport type { ForwardedRef, ReactNode } from 'react';\nimport {\n Dialog as RACDialog,\n Heading as RACHeading,\n Modal as RACModal,\n ModalOverlay as RACModalOverlay,\n} from 'react-aria-components';\nimport { forwardRef } from '../../forward-ref.js';\nimport { useLocalizedMessages } from '../../i18n/index.js';\nimport { useProductionWarning } from '../../utils/use-production-warning.js';\nimport { FocusableContainer } from '../internal/focusable-container/focusable-container.js';\nimport { XButton } from '../internal/x-button/x-button.js';\nimport type { AriaLabelingProps, CommonProps } from '../types.js';\nimport { textStyle } from '../typography/utils.js';\n\nexport interface ModalDialogRenderProps {\n /** Closes the modal dialog when called. */\n close: () => void;\n}\n\nexport interface ModalDialogProps extends CommonProps, AriaLabelingProps {\n /** The contents of the modal dialog. A function may be provided to access a function to close the modal dialog. */\n children: ReactNode | ((renderProps: ModalDialogRenderProps) => ReactNode);\n /** The title of the modal dialog. */\n title: string;\n /**\n * The size of the modal dialog.\n * @default 'medium'\n */\n size?: 'small' | 'medium' | 'large';\n /**\n * Whether the modal dialog can be closed by clicking the close button, clicking outside of the modal dialog, or pressing the Escape key.\n * When `false`, the modal dialog can only be closed programmatically.\n * @default true\n */\n isDismissible?: boolean;\n /**\n * Whether the modal dialog is open (controlled).\n * If using `DialogRoot`, this prop has no effect - provide `isOpen` to `DialogRoot` instead.\n */\n isOpen?: boolean;\n /**\n * Whether the modal dialog is open by default (uncontrolled).\n * If using `DialogRoot`, this prop has no effect - provide `defaultOpen` to `DialogRoot` instead.\n */\n defaultOpen?: boolean;\n /**\n * Handler that is called when the modal dialog's open state changes.\n * If using `DialogRoot`, this prop has no effect - provide `onOpenChange` to `DialogRoot` instead.\n */\n onOpenChange?: (isOpen: boolean) => void;\n}\n\nfunction ModalDialog(\n {\n children,\n title,\n size = 'medium',\n UNSAFE_className,\n UNSAFE_style,\n isDismissible = true,\n isOpen,\n defaultOpen,\n onOpenChange,\n ...props\n }: ModalDialogProps,\n ref: ForwardedRef<HTMLElement>,\n) {\n const { 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy } = props;\n\n useProductionWarning(() => {\n if (!title && !ariaLabel && !ariaLabelledBy) {\n console.warn('ModalDialog requires one of title / aria-label / aria-labelledby for accessibility');\n }\n }, [title, ariaLabel, ariaLabelledBy]);\n\n const messages = useLocalizedMessages('common');\n\n return (\n <RACModalOverlay\n className=\"cim-modal-overlay\"\n isDismissable={isDismissible}\n isKeyboardDismissDisabled={!isDismissible}\n isOpen={isOpen}\n defaultOpen={defaultOpen}\n onOpenChange={onOpenChange}\n data-cim-style-root\n >\n <RACModal className={clsx('cim-modal', UNSAFE_className)} style={UNSAFE_style} data-size={size}>\n <RACDialog {...props} ref={ref} className=\"cim-modal-dialog\">\n {(renderProps) => (\n <>\n <div className=\"cim-modal-header\">\n {title && (\n <RACHeading\n slot=\"title\"\n className={clsx('cim-modal-title', textStyle({ variant: 'title-5', tone: 'base' }))}\n >\n {title}\n </RACHeading>\n )}\n {isDismissible && <XButton aria-label={messages.format('dismiss')} slot=\"close\" />}\n </div>\n {typeof children === 'function' ? children(renderProps) : children}\n </>\n )}\n </RACDialog>\n </RACModal>\n </RACModalOverlay>\n );\n}\n\n/**\n * Displays an overlay element which blocks interaction with outside elements.\n *\n * See [modal dialog usage guidelines](https://ui.cimpress.io/components/modal-dialog/).\n */\nconst _ModalDialog = forwardRef(ModalDialog, 'ModalDialog');\n\nexport { _ModalDialog as ModalDialog };\n\nexport interface ModalDialogBodyProps {\n /** The content to render within the modal dialog. */\n children: ReactNode;\n}\n\n/** Renders content within `ModalDialog`. */\nexport function ModalDialogBody(props: ModalDialogBodyProps) {\n return <FocusableContainer {...props} className=\"cim-modal-body\" scrollDirection=\"vertical\" />;\n}\n\nModalDialogBody.displayName = 'ModalDialogBody';\n\nexport interface ModalDialogActionsProps {\n /** Actions that should be available in the modal dialog. */\n children: ReactNode;\n}\n\n/** Renders actions within `ModalDialog`. */\nexport function ModalDialogActions({ children, ...props }: ModalDialogActionsProps) {\n return (\n <div {...props} className=\"cim-modal-actions\">\n {children}\n </div>\n );\n}\n\nModalDialogActions.displayName = 'ModalDialogActions';\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
2
|
import { type RadioGroupProps as RACRadioGroupProps } from 'react-aria-components';
|
|
3
3
|
import type { Responsive } from '../spacing/types.js';
|
|
4
|
-
import type { Direction, CommonProps, FieldProps
|
|
5
|
-
export interface RadioGroupProps extends CommonProps,
|
|
4
|
+
import type { Direction, CommonProps, FieldProps } from '../types.js';
|
|
5
|
+
export interface RadioGroupProps extends CommonProps, FieldProps<string | null>, Pick<RACRadioGroupProps, 'isDisabled' | 'isReadOnly' | 'isRequired' | 'isInvalid' | 'value' | 'onChange' | 'defaultValue'> {
|
|
6
6
|
/** Radio buttons belonging to the group. */
|
|
7
7
|
children: ReactNode;
|
|
8
8
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"radio-group.d.ts","sourceRoot":"","sources":["../../../../src/components/radio/radio-group.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAgB,SAAS,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,EAA+B,KAAK,eAAe,IAAI,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"radio-group.d.ts","sourceRoot":"","sources":["../../../../src/components/radio/radio-group.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAgB,SAAS,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,EAA+B,KAAK,eAAe,IAAI,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAMhH,OAAO,KAAK,EAAc,UAAU,EAAW,MAAM,qBAAqB,CAAC;AAC3E,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEtE,MAAM,WAAW,eACf,SAAQ,WAAW,EACjB,UAAU,CAAC,MAAM,GAAG,IAAI,CAAC,EACzB,IAAI,CACF,kBAAkB,EAClB,YAAY,GAAG,YAAY,GAAG,YAAY,GAAG,WAAW,GAAG,OAAO,GAAG,UAAU,GAAG,cAAc,CACjG;IACH,4CAA4C;IAC5C,QAAQ,EAAE,SAAS,CAAC;IACpB;;;OAGG;IACH,SAAS,CAAC,EAAE,UAAU,CAAC,SAAS,CAAC,CAAC;CACnC;AAqCD;;;;GAIG;AACH,QAAA,MAAM,WAAW,iKAAuD,CAAC;AAEzE,OAAO,EAAE,WAAW,IAAI,UAAU,EAAE,CAAC"}
|
|
@@ -3,11 +3,18 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import clsx from 'clsx';
|
|
4
4
|
import { RadioGroup as RACRadioGroup } from 'react-aria-components';
|
|
5
5
|
import { forwardRef } from '../../forward-ref.js';
|
|
6
|
+
import { useProductionWarning } from '../../utils/use-production-warning.js';
|
|
6
7
|
import { withStyleProps } from '../../with-style-props.js';
|
|
7
8
|
import { FormFieldDescription, FormFieldError, FormFieldLabel } from '../internal/form-field/form-field.js';
|
|
8
9
|
import { Stack } from '../spacing/stack/stack.js';
|
|
9
10
|
function RadioGroup({ label, description, error: errorMessage, direction = 'vertical', children, UNSAFE_className, UNSAFE_style, ...props }, ref) {
|
|
10
|
-
|
|
11
|
+
const { 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy } = props;
|
|
12
|
+
useProductionWarning(() => {
|
|
13
|
+
if (!label && !ariaLabel && !ariaLabelledBy) {
|
|
14
|
+
console.warn('RadioGroup requires one of label / aria-label / aria-labelledby for accessibility');
|
|
15
|
+
}
|
|
16
|
+
}, [label, ariaLabel, ariaLabelledBy]);
|
|
17
|
+
return (_jsxs(RACRadioGroup, { ...props, ref: ref, className: clsx('cim-radio-group', UNSAFE_className), style: UNSAFE_style, children: [_jsx(FormFieldLabel, { isRequired: props.isRequired, isDisabled: props.isDisabled, children: label }), _jsx(Stack, { gap: getGapFromDirection(direction), direction: direction, wrap: true, children: children }), _jsx(FormFieldError, { children: errorMessage }), _jsx(FormFieldDescription, { children: description })] }));
|
|
11
18
|
}
|
|
12
19
|
/**
|
|
13
20
|
* Allows users to select a single item from a visible list.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"radio-group.js","sourceRoot":"","sources":["../../../../src/components/radio/radio-group.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,UAAU,IAAI,aAAa,EAA8C,MAAM,uBAAuB,CAAC;AAChH,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAs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AAC,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;YAC5E,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,KAAK,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;YACjD,OAAO,GAAG,CAAC;QACb,CAAC,EAAE,GAAG,CAAC,CAAC;QAER,OAAO,GAAG,CAAC;IACb,CAAC;IAED,OAAO,SAAS,KAAK,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AAC7C,CAAC","sourcesContent":["'use client';\n\nimport clsx from 'clsx';\nimport type { ForwardedRef, ReactNode } from 'react';\nimport { RadioGroup as RACRadioGroup, type RadioGroupProps as RACRadioGroupProps } from 'react-aria-components';\nimport { forwardRef } from '../../forward-ref.js';\nimport { useProductionWarning } from '../../utils/use-production-warning.js';\nimport { withStyleProps } from '../../with-style-props.js';\nimport { FormFieldDescription, FormFieldError, FormFieldLabel } from '../internal/form-field/form-field.js';\nimport { Stack } from '../spacing/stack/stack.js';\nimport type { Breakpoint, Responsive, Spacing } from '../spacing/types.js';\nimport type { Direction, CommonProps, FieldProps } from '../types.js';\n\nexport interface RadioGroupProps\n extends CommonProps,\n FieldProps<string | null>,\n Pick<\n RACRadioGroupProps,\n 'isDisabled' | 'isReadOnly' | 'isRequired' | 'isInvalid' | 'value' | 'onChange' | 'defaultValue'\n > {\n /** Radio buttons belonging to the group. */\n children: ReactNode;\n /**\n * Determines the direction in which radio buttons will be stacked.\n * @default 'vertical'\n */\n direction?: Responsive<Direction>;\n}\n\nfunction RadioGroup(\n {\n label,\n description,\n error: errorMessage,\n direction = 'vertical',\n children,\n UNSAFE_className,\n UNSAFE_style,\n ...props\n }: RadioGroupProps,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const { 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy } = props;\n\n useProductionWarning(() => {\n if (!label && !ariaLabel && !ariaLabelledBy) {\n console.warn('RadioGroup requires one of label / aria-label / aria-labelledby for accessibility');\n }\n }, [label, ariaLabel, ariaLabelledBy]);\n\n return (\n <RACRadioGroup {...props} ref={ref} className={clsx('cim-radio-group', UNSAFE_className)} style={UNSAFE_style}>\n <FormFieldLabel isRequired={props.isRequired} isDisabled={props.isDisabled}>\n {label}\n </FormFieldLabel>\n <Stack gap={getGapFromDirection(direction)} direction={direction} wrap>\n {children}\n </Stack>\n <FormFieldError>{errorMessage}</FormFieldError>\n <FormFieldDescription>{description}</FormFieldDescription>\n </RACRadioGroup>\n );\n}\n\n/**\n * Allows users to select a single item from a visible list.\n *\n * See [radio group usage guidelines](https://ui.cimpress.io/components/radio-group/).\n */\nconst _RadioGroup = withStyleProps(forwardRef(RadioGroup), 'RadioGroup');\n\nexport { _RadioGroup as RadioGroup };\n\n// Make sure that radio buttons are spaced by 16px when stacked horizontally, and 8px otherwise.\nfunction getGapFromDirection(direction: Responsive<Direction>): Responsive<Spacing> {\n if (typeof direction === 'object') {\n const gap: Responsive<Spacing> = { sm: direction.sm === 'horizontal' ? 16 : 8 };\n\n (Object.entries(direction) as [Breakpoint, Direction][]).reduce((acc, curr) => {\n gap[curr[0]] = curr[1] === 'horizontal' ? 16 : 8;\n return acc;\n }, gap);\n\n return gap;\n }\n\n return direction === 'horizontal' ? 16 : 8;\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ListBoxProps as RACListBoxProps, type ListBoxItemProps as RACListBoxItemProps, type SelectProps as RACSelectProps } from 'react-aria-components';
|
|
2
|
-
import type { CollectionItem, CollectionProps, CommonProps, FieldProps, Key, StringLikeChildren } from '../types.js';
|
|
3
|
-
export interface SelectProps<T extends CollectionItem = CollectionItem> extends CommonProps, FieldProps<Key>, CollectionProps<T>, Pick<RACSelectProps<T>, 'isDisabled' | 'isRequired' | 'isInvalid' | 'selectedKey' | 'defaultSelectedKey' | 'autoComplete' | 'autoFocus' | 'onSelectionChange' | 'placeholder' | 'onFocus' | 'onBlur' | 'onOpenChange'>, Pick<RACListBoxProps<T>, 'onScroll'> {
|
|
2
|
+
import type { AsyncItemLoadingProps, CollectionItem, CollectionProps, CommonProps, FieldProps, Key, StringLikeChildren } from '../types.js';
|
|
3
|
+
export interface SelectProps<T extends CollectionItem = CollectionItem> extends CommonProps, FieldProps<Key>, CollectionProps<T>, AsyncItemLoadingProps, Pick<RACSelectProps<T>, 'isDisabled' | 'isRequired' | 'isInvalid' | 'selectedKey' | 'defaultSelectedKey' | 'autoComplete' | 'autoFocus' | 'onSelectionChange' | 'placeholder' | 'onFocus' | 'onBlur' | 'onOpenChange'>, Pick<RACListBoxProps<T>, 'onScroll'> {
|
|
4
4
|
/**
|
|
5
5
|
* Whether the list of options should be virtualized. Use this as a performance optimization for large lists.
|
|
6
6
|
* @default false
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../../../../src/components/select/select.tsx"],"names":[],"mappings":"AAIA,OAAO,EAKL,KAAK,YAAY,IAAI,eAAe,
|
|
1
|
+
{"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../../../../src/components/select/select.tsx"],"names":[],"mappings":"AAIA,OAAO,EAKL,KAAK,YAAY,IAAI,eAAe,EASpC,KAAK,gBAAgB,IAAI,mBAAmB,EAC5C,KAAK,WAAW,IAAI,cAAc,EAEnC,MAAM,uBAAuB,CAAC;AAU/B,OAAO,KAAK,EACV,qBAAqB,EACrB,cAAc,EACd,eAAe,EACf,WAAW,EACX,UAAU,EACV,GAAG,EACH,kBAAkB,EACnB,MAAM,aAAa,CAAC;AAWrB,MAAM,WAAW,WAAW,CAAC,CAAC,SAAS,cAAc,GAAG,cAAc,CACpE,SAAQ,WAAW,EACjB,UAAU,CAAC,GAAG,CAAC,EACf,eAAe,CAAC,CAAC,CAAC,EAClB,qBAAqB,EACrB,IAAI,CACF,cAAc,CAAC,CAAC,CAAC,EACf,YAAY,GACZ,YAAY,GACZ,WAAW,GACX,aAAa,GACb,oBAAoB,GACpB,cAAc,GACd,WAAW,GACX,mBAAmB,GACnB,aAAa,GACb,SAAS,GACT,QAAQ,GACR,cAAc,CACjB,EACD,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC;IACtC;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AA+ED;;;;GAIG;AACH,QAAA,MAAM,OAAO,GAlFG,CAAC,SAAS,cAAc,+JAkFoB,CAAC;AAE7D,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,CAAC;AAE7B,MAAM,WAAW,eACf,SAAQ,IAAI,CAAC,mBAAmB,EAAE,IAAI,GAAG,YAAY,GAAG,cAAc,GAAG,YAAY,CAAC;IACtF,2CAA2C;IAC3C,QAAQ,EAAE,kBAAkB,CAAC;CAC9B;AAED,kDAAkD;AAClD,wBAAgB,UAAU,CAAC,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,eAAe,2CAiBjE;yBAjBe,UAAU;;;AAqB1B,MAAM,WAAW,kBAAkB,CAAC,CAAC,SAAS,cAAc,CAAE,SAAQ,eAAe,CAAC,CAAC,CAAC;IACtF,6EAA6E;IAC7E,EAAE,CAAC,EAAE,GAAG,CAAC;IACT,mDAAmD;IACnD,KAAK,EAAE,MAAM,CAAC;CACf;AAED,wDAAwD;AACxD,wBAAgB,aAAa,CAAC,CAAC,SAAS,cAAc,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,EAAE,kBAAkB,CAAC,CAAC,CAAC,2CAelH;yBAfe,aAAa"}
|
|
@@ -1,22 +1,25 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import clsx from 'clsx';
|
|
4
|
-
import { Button as RACButton, Collection as RACCollection, Header as RACHeader, ListBox as RACListBox, ListBoxItem as RACListBoxItem, ListBoxSection as RACListBoxSection, ListLayout as RACListLayout, Select as RACSelect, SelectValue as RACSelectValue, Text as RACText, Virtualizer as RACVirtualizer, } from 'react-aria-components';
|
|
4
|
+
import { Button as RACButton, Collection as RACCollection, Header as RACHeader, ListBox as RACListBox, ListBoxLoadMoreItem as RACListBoxLoadMoreItem, ListBoxItem as RACListBoxItem, ListBoxSection as RACListBoxSection, ListLayout as RACListLayout, Select as RACSelect, SelectValue as RACSelectValue, Text as RACText, Virtualizer as RACVirtualizer, } from 'react-aria-components';
|
|
5
5
|
import { forwardRef } from '../../forward-ref.js';
|
|
6
|
+
import { useLocalizedMessages } from '../../i18n/index.js';
|
|
6
7
|
import { IconCheck, IconChevronDown } from '../../icons/index.js';
|
|
7
8
|
import { isProduction } from '../../utils/is-production.js';
|
|
8
9
|
import { useProductionWarning } from '../../utils/use-production-warning.js';
|
|
9
10
|
import { withStyleProps } from '../../with-style-props.js';
|
|
10
11
|
import { CollapsibleList } from '../internal/collapsible-list/collapsible-list.js';
|
|
11
12
|
import { FormFieldDescription, FormFieldError, FormFieldLabel } from '../internal/form-field/form-field.js';
|
|
13
|
+
import { Spinner } from '../spinner/spinner.js';
|
|
12
14
|
import { textStyle } from '../typography/utils.js';
|
|
13
15
|
const VIRTUAL_LAYOUT_OPTIONS = {
|
|
14
16
|
rowHeight: 40,
|
|
15
17
|
headingHeight: 32,
|
|
18
|
+
loaderHeight: 40,
|
|
16
19
|
padding: 0,
|
|
17
20
|
gap: 0,
|
|
18
21
|
};
|
|
19
|
-
function Select({ children, items, label, description, error, UNSAFE_className, UNSAFE_style, onScroll, isVirtualized = false, ...props }, ref) {
|
|
22
|
+
function Select({ children, items, label, description, error, UNSAFE_className, UNSAFE_style, onScroll, isVirtualized = false, UNSTABLE_isLoading: isLoading, UNSTABLE_onLoadMore: onLoadMore, ...props }, ref) {
|
|
20
23
|
const { 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy } = props;
|
|
21
24
|
useProductionWarning(() => {
|
|
22
25
|
if (!label && !ariaLabel && !ariaLabelledBy) {
|
|
@@ -26,7 +29,8 @@ function Select({ children, items, label, description, error, UNSAFE_className,
|
|
|
26
29
|
if (!isProduction() && items != null && typeof children !== 'function') {
|
|
27
30
|
console.warn('`Select` requires `children` to be a function when using `items` prop');
|
|
28
31
|
}
|
|
29
|
-
const
|
|
32
|
+
const collectionMessages = useLocalizedMessages('UNSTABLE_collection');
|
|
33
|
+
const listBox = (_jsxs(RACListBox, { className: "cim-select-listbox", onScroll: onScroll, renderEmptyState: () => isLoading ? _jsx(Spinner, { "aria-label": collectionMessages.format('loading'), size: "small", marginY: 8 }) : null, children: [_jsx(RACCollection, { items: items, children: children }), _jsx(RACListBoxLoadMoreItem, { onLoadMore: onLoadMore, isLoading: isLoading, children: _jsx(Spinner, { "aria-label": collectionMessages.format('loadingMore'), size: "small", marginY: 8 }) })] }));
|
|
30
34
|
return (_jsxs(RACSelect, { ...props, ref: ref, className: clsx('cim-select', UNSAFE_className), style: UNSAFE_style, children: [_jsx(FormFieldLabel, { isRequired: props.isRequired, isDisabled: props.isDisabled, children: label }), _jsxs(RACButton, { className: "cim-select-button", children: [_jsx(RACSelectValue, { className: (values) => clsx(values.defaultClassName, textStyle({ variant: 'body', alignment: 'start' })), children: ({ selectedText }) => selectedText }), _jsx(IconChevronDown, {})] }), _jsx(FormFieldError, { children: error }), _jsx(FormFieldDescription, { children: description }), _jsx(CollapsibleList, { offset: 5, maxHeight: 315, children: isVirtualized ? (_jsx(RACVirtualizer, { layout: RACListLayout, layoutOptions: VIRTUAL_LAYOUT_OPTIONS, children: listBox })) : (listBox) })] }));
|
|
31
35
|
}
|
|
32
36
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select.js","sourceRoot":"","sources":["../../../../src/components/select/select.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EACL,MAAM,IAAI,SAAS,EACnB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IAAI,CAAC,8EAA8E,CAAC,CAAC;IAC/F,CAAC;IAED,OAAO,CACL,MAAC,iBAAiB,OAAK,KAAK,EAAE,SAAS,EAAC,oBAAoB,aAC1D,KAAC,SAAS,IACR,SAAS,EAAE,IAAI,CAAC,2BAA2B,EAAE,SAAS,CAAC,EAAE,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC,YAErG,KAAK,GACI,EACZ,KAAC,aAAa,IAAC,KAAK,EAAE,KAAK,YAAG,QAAQ,GAAiB,IACrC,CACrB,CAAC;AACJ,CAAC;AAED,aAAa,CAAC,WAAW,GAAG,eAAe,CAAC","sourcesContent":["'use client';\n\nimport clsx from 'clsx';\nimport type { ForwardedRef } from 'react';\nimport {\n Button as RACButton,\n Collection as RACCollection,\n Header as RACHeader,\n ListBox as RACListBox,\n type ListBoxProps as RACListBoxProps,\n ListBoxItem as RACListBoxItem,\n ListBoxSection as RACListBoxSection,\n ListLayout as RACListLayout,\n type ListLayoutOptions as RACListLayoutOptions,\n Select as RACSelect,\n SelectValue as RACSelectValue,\n Text as RACText,\n type ListBoxItemProps as RACListBoxItemProps,\n type SelectProps as RACSelectProps,\n Virtualizer as RACVirtualizer,\n} from 'react-aria-components';\nimport { forwardRef } from '../../forward-ref.js';\nimport { IconCheck, IconChevronDown } from '../../icons/index.js';\nimport { isProduction } from '../../utils/is-production.js';\nimport { useProductionWarning } from '../../utils/use-production-warning.js';\nimport { withStyleProps } from '../../with-style-props.js';\nimport { CollapsibleList } from '../internal/collapsible-list/collapsible-list.js';\nimport { FormFieldDescription, FormFieldError, FormFieldLabel } from '../internal/form-field/form-field.js';\nimport type { CollectionItem, CollectionProps, CommonProps, FieldProps, Key, StringLikeChildren } from '../types.js';\nimport { textStyle } from '../typography/utils.js';\n\nconst VIRTUAL_LAYOUT_OPTIONS: RACListLayoutOptions = {\n rowHeight: 40,\n headingHeight: 32,\n padding: 0,\n gap: 0,\n};\n\nexport interface SelectProps<T extends CollectionItem = CollectionItem>\n extends CommonProps,\n FieldProps<Key>,\n CollectionProps<T>,\n Pick<\n RACSelectProps<T>,\n | 'isDisabled'\n | 'isRequired'\n | 'isInvalid'\n | 'selectedKey'\n | 'defaultSelectedKey'\n | 'autoComplete'\n | 'autoFocus'\n | 'onSelectionChange'\n | 'placeholder'\n | 'onFocus'\n | 'onBlur'\n | 'onOpenChange'\n >,\n Pick<RACListBoxProps<T>, 'onScroll'> {\n /**\n * Whether the list of options should be virtualized. Use this as a performance optimization for large lists.\n * @default false\n */\n isVirtualized?: boolean;\n}\n\nfunction Select<T extends CollectionItem>(\n {\n children,\n items,\n label,\n description,\n error,\n UNSAFE_className,\n UNSAFE_style,\n onScroll,\n isVirtualized = false,\n ...props\n }: SelectProps<T>,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const { 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy } = props;\n\n useProductionWarning(() => {\n if (!label && !ariaLabel && !ariaLabelledBy) {\n console.warn('Select requires one of label / aria-label / aria-labelledby for accessibility');\n }\n }, [label, ariaLabel, ariaLabelledBy]);\n\n if (!isProduction() && items != null && typeof children !== 'function') {\n console.warn('`Select` requires `children` to be a function when using `items` prop');\n }\n\n const listBox = (\n <RACListBox className=\"cim-select-listbox\" onScroll={onScroll} items={items}>\n {children}\n </RACListBox>\n );\n\n return (\n <RACSelect {...props} ref={ref} className={clsx('cim-select', UNSAFE_className)} style={UNSAFE_style}>\n <FormFieldLabel isRequired={props.isRequired} isDisabled={props.isDisabled}>\n {label}\n </FormFieldLabel>\n <RACButton className=\"cim-select-button\">\n <RACSelectValue\n className={(values) => clsx(values.defaultClassName, textStyle({ variant: 'body', alignment: 'start' }))}\n >\n {({ selectedText }) => selectedText}\n </RACSelectValue>\n <IconChevronDown />\n </RACButton>\n <FormFieldError>{error}</FormFieldError>\n <FormFieldDescription>{description}</FormFieldDescription>\n <CollapsibleList\n offset={5} // 1px border + 4px actual offset\n maxHeight={315}\n >\n {isVirtualized ? (\n <RACVirtualizer layout={RACListLayout} layoutOptions={VIRTUAL_LAYOUT_OPTIONS}>\n {listBox}\n </RACVirtualizer>\n ) : (\n listBox\n )}\n </CollapsibleList>\n </RACSelect>\n );\n}\n\n/**\n * Allows users to select one item from a collapsible list.\n *\n * See [select usage guidelines](https://ui.cimpress.io/components/select/).\n */\nconst _Select = withStyleProps(forwardRef(Select), 'Select');\n\nexport { _Select as Select };\n\nexport interface SelectItemProps\n extends Pick<RACListBoxItemProps, 'id' | 'isDisabled' | 'onHoverStart' | 'onHoverEnd'> {\n /** The content to display as the label. */\n children: StringLikeChildren;\n}\n\n/** Renders a single list item within `Select`. */\nexport function SelectItem({ children, ...props }: SelectItemProps) {\n const textValue =\n typeof children === 'string' ? children : typeof children === 'number' ? String(children) : children.join('');\n\n return (\n <RACListBoxItem {...props} className=\"cim-select-item\" textValue={textValue}>\n {({ isDisabled }) => (\n <>\n <IconCheck />\n\n <RACText slot=\"label\" className={textStyle({ variant: 'body', tone: isDisabled ? 'muted' : 'base' })}>\n {children}\n </RACText>\n </>\n )}\n </RACListBoxItem>\n );\n}\n\nSelectItem.displayName = 'SelectItem';\n\nexport interface SelectSectionProps<T extends CollectionItem> extends CollectionProps<T> {\n /** The ID of the section. Has to be unique across all sections and items. */\n id?: Key;\n /** The content to display as the section title. */\n title: string;\n}\n\n/** Groups list items within `Select` into a section. */\nexport function SelectSection<T extends CollectionItem>({ title, children, items, ...props }: SelectSectionProps<T>) {\n if (!isProduction() && items != null && typeof children !== 'function') {\n console.warn('`SelectSection` requires `children` to be a function when using `items` prop');\n }\n\n return (\n <RACListBoxSection {...props} className=\"cim-select-section\">\n <RACHeader\n className={clsx('cim-select-section-header', textStyle({ variant: 'small-semibold', tone: 'subtle' }))}\n >\n {title}\n </RACHeader>\n <RACCollection items={items}>{children}</RACCollection>\n </RACListBoxSection>\n );\n}\n\nSelectSection.displayName = 'SelectSection';\n"]}
|
|
1
|
+
{"version":3,"file":"select.js","sourceRoot":"","sources":["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","sourcesContent":["'use client';\n\nimport clsx from 'clsx';\nimport type { ForwardedRef } from 'react';\nimport {\n Button as RACButton,\n Collection as RACCollection,\n Header as RACHeader,\n ListBox as RACListBox,\n type ListBoxProps as RACListBoxProps,\n ListBoxLoadMoreItem as RACListBoxLoadMoreItem,\n ListBoxItem as RACListBoxItem,\n ListBoxSection as RACListBoxSection,\n ListLayout as RACListLayout,\n type ListLayoutOptions as RACListLayoutOptions,\n Select as RACSelect,\n SelectValue as RACSelectValue,\n Text as RACText,\n type ListBoxItemProps as RACListBoxItemProps,\n type SelectProps as RACSelectProps,\n Virtualizer as RACVirtualizer,\n} from 'react-aria-components';\nimport { forwardRef } from '../../forward-ref.js';\nimport { useLocalizedMessages } from '../../i18n/index.js';\nimport { IconCheck, IconChevronDown } from '../../icons/index.js';\nimport { isProduction } from '../../utils/is-production.js';\nimport { useProductionWarning } from '../../utils/use-production-warning.js';\nimport { withStyleProps } from '../../with-style-props.js';\nimport { CollapsibleList } from '../internal/collapsible-list/collapsible-list.js';\nimport { FormFieldDescription, FormFieldError, FormFieldLabel } from '../internal/form-field/form-field.js';\nimport { Spinner } from '../spinner/spinner.js';\nimport type {\n AsyncItemLoadingProps,\n CollectionItem,\n CollectionProps,\n CommonProps,\n FieldProps,\n Key,\n StringLikeChildren,\n} from '../types.js';\nimport { textStyle } from '../typography/utils.js';\n\nconst VIRTUAL_LAYOUT_OPTIONS: RACListLayoutOptions = {\n rowHeight: 40,\n headingHeight: 32,\n loaderHeight: 40,\n padding: 0,\n gap: 0,\n};\n\nexport interface SelectProps<T extends CollectionItem = CollectionItem>\n extends CommonProps,\n FieldProps<Key>,\n CollectionProps<T>,\n AsyncItemLoadingProps,\n Pick<\n RACSelectProps<T>,\n | 'isDisabled'\n | 'isRequired'\n | 'isInvalid'\n | 'selectedKey'\n | 'defaultSelectedKey'\n | 'autoComplete'\n | 'autoFocus'\n | 'onSelectionChange'\n | 'placeholder'\n | 'onFocus'\n | 'onBlur'\n | 'onOpenChange'\n >,\n Pick<RACListBoxProps<T>, 'onScroll'> {\n /**\n * Whether the list of options should be virtualized. Use this as a performance optimization for large lists.\n * @default false\n */\n isVirtualized?: boolean;\n}\n\nfunction Select<T extends CollectionItem>(\n {\n children,\n items,\n label,\n description,\n error,\n UNSAFE_className,\n UNSAFE_style,\n onScroll,\n isVirtualized = false,\n UNSTABLE_isLoading: isLoading,\n UNSTABLE_onLoadMore: onLoadMore,\n ...props\n }: SelectProps<T>,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const { 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy } = props;\n\n useProductionWarning(() => {\n if (!label && !ariaLabel && !ariaLabelledBy) {\n console.warn('Select requires one of label / aria-label / aria-labelledby for accessibility');\n }\n }, [label, ariaLabel, ariaLabelledBy]);\n\n if (!isProduction() && items != null && typeof children !== 'function') {\n console.warn('`Select` requires `children` to be a function when using `items` prop');\n }\n\n const collectionMessages = useLocalizedMessages('UNSTABLE_collection');\n\n const listBox = (\n <RACListBox\n className=\"cim-select-listbox\"\n onScroll={onScroll}\n renderEmptyState={() =>\n isLoading ? <Spinner aria-label={collectionMessages.format('loading')} size=\"small\" marginY={8} /> : null\n }\n >\n <RACCollection items={items}>{children}</RACCollection>\n <RACListBoxLoadMoreItem onLoadMore={onLoadMore} isLoading={isLoading}>\n <Spinner aria-label={collectionMessages.format('loadingMore')} size=\"small\" marginY={8} />\n </RACListBoxLoadMoreItem>\n </RACListBox>\n );\n\n return (\n <RACSelect {...props} ref={ref} className={clsx('cim-select', UNSAFE_className)} style={UNSAFE_style}>\n <FormFieldLabel isRequired={props.isRequired} isDisabled={props.isDisabled}>\n {label}\n </FormFieldLabel>\n <RACButton className=\"cim-select-button\">\n <RACSelectValue\n className={(values) => clsx(values.defaultClassName, textStyle({ variant: 'body', alignment: 'start' }))}\n >\n {({ selectedText }) => selectedText}\n </RACSelectValue>\n <IconChevronDown />\n </RACButton>\n <FormFieldError>{error}</FormFieldError>\n <FormFieldDescription>{description}</FormFieldDescription>\n <CollapsibleList\n offset={5} // 1px border + 4px actual offset\n maxHeight={315}\n >\n {isVirtualized ? (\n <RACVirtualizer layout={RACListLayout} layoutOptions={VIRTUAL_LAYOUT_OPTIONS}>\n {listBox}\n </RACVirtualizer>\n ) : (\n listBox\n )}\n </CollapsibleList>\n </RACSelect>\n );\n}\n\n/**\n * Allows users to select one item from a collapsible list.\n *\n * See [select usage guidelines](https://ui.cimpress.io/components/select/).\n */\nconst _Select = withStyleProps(forwardRef(Select), 'Select');\n\nexport { _Select as Select };\n\nexport interface SelectItemProps\n extends Pick<RACListBoxItemProps, 'id' | 'isDisabled' | 'onHoverStart' | 'onHoverEnd'> {\n /** The content to display as the label. */\n children: StringLikeChildren;\n}\n\n/** Renders a single list item within `Select`. */\nexport function SelectItem({ children, ...props }: SelectItemProps) {\n const textValue =\n typeof children === 'string' ? children : typeof children === 'number' ? String(children) : children.join('');\n\n return (\n <RACListBoxItem {...props} className=\"cim-select-item\" textValue={textValue}>\n {({ isDisabled }) => (\n <>\n <IconCheck />\n\n <RACText slot=\"label\" className={textStyle({ variant: 'body', tone: isDisabled ? 'muted' : 'base' })}>\n {children}\n </RACText>\n </>\n )}\n </RACListBoxItem>\n );\n}\n\nSelectItem.displayName = 'SelectItem';\n\nexport interface SelectSectionProps<T extends CollectionItem> extends CollectionProps<T> {\n /** The ID of the section. Has to be unique across all sections and items. */\n id?: Key;\n /** The content to display as the section title. */\n title: string;\n}\n\n/** Groups list items within `Select` into a section. */\nexport function SelectSection<T extends CollectionItem>({ title, children, items, ...props }: SelectSectionProps<T>) {\n if (!isProduction() && items != null && typeof children !== 'function') {\n console.warn('`SelectSection` requires `children` to be a function when using `items` prop');\n }\n\n return (\n <RACListBoxSection {...props} className=\"cim-select-section\">\n <RACHeader\n className={clsx('cim-select-section-header', textStyle({ variant: 'small-semibold', tone: 'subtle' }))}\n >\n {title}\n </RACHeader>\n <RACCollection items={items}>{children}</RACCollection>\n </RACListBoxSection>\n );\n}\n\nSelectSection.displayName = 'SelectSection';\n"]}
|
|
@@ -46,7 +46,7 @@ export interface TabPanelProps {
|
|
|
46
46
|
id?: Key;
|
|
47
47
|
}
|
|
48
48
|
/** Renders a single tab panel within `TabPanels`. */
|
|
49
|
-
export declare function TabPanel({ children,
|
|
49
|
+
export declare function TabPanel({ children, ...props }: TabPanelProps): import("react/jsx-runtime").JSX.Element;
|
|
50
50
|
export declare namespace TabPanel {
|
|
51
51
|
var displayName: string;
|
|
52
52
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tabs.d.ts","sourceRoot":"","sources":["../../../../src/components/tabs/tabs.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAgD,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AACrF,OAAO,EAML,KAAK,SAAS,IAAI,YAAY,EAC9B,KAAK,QAAQ,IAAI,WAAW,EAC7B,MAAM,uBAAuB,CAAC;AAI/B,OAAO,KAAK,EACV,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,WAAW,EACX,GAAG,EACH,kBAAkB,EACnB,MAAM,aAAa,CAAC;AASrB,MAAM,WAAW,SACf,SAAQ,WAAW,EACjB,iBAAiB,EACjB,IAAI,CAAC,YAAY,EAAE,aAAa,GAAG,oBAAoB,GAAG,cAAc,GAAG,mBAAmB,CAAC;IACjG,mGAAmG;IACnG,QAAQ,EAAE,SAAS,CAAC;CACrB;AAgDD;;;;GAIG;AACH,QAAA,MAAM,KAAK,2JAA2C,CAAC;AAEvD,OAAO,EAAE,KAAK,IAAI,IAAI,EAAE,CAAC;AAEzB,MAAM,WAAW,YAAY,CAAC,CAAC,SAAS,cAAc,CAAE,SAAQ,eAAe,CAAC,CAAC,CAAC;CAAG;AAErF,8DAA8D;AAC9D,wBAAgB,OAAO,CAAC,CAAC,SAAS,cAAc,EAAE,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,YAAY,CAAC,CAAC,CAAC,2CAqBxF;yBArBe,OAAO;;;AAyBv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AK,EAAE,EAAE,aAAa,2CAM7D;yBANe,QAAQ"}
|
|
@@ -50,10 +50,8 @@ export function TabPanels({ ...props }) {
|
|
|
50
50
|
}
|
|
51
51
|
TabPanels.displayName = 'TabPanels';
|
|
52
52
|
/** Renders a single tab panel within `TabPanels`. */
|
|
53
|
-
export function TabPanel({ children,
|
|
54
|
-
return (_jsx(RACTabPanel, { ...props, className: "cim-tab-panel",
|
|
55
|
-
// @ts-expect-error -- https://github.com/adobe/react-spectrum/issues/8422
|
|
56
|
-
id: id, children: children }));
|
|
53
|
+
export function TabPanel({ children, ...props }) {
|
|
54
|
+
return (_jsx(RACTabPanel, { ...props, className: "cim-tab-panel", children: children }));
|
|
57
55
|
}
|
|
58
56
|
TabPanel.displayName = 'TabPanel';
|
|
59
57
|
//# sourceMappingURL=tabs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tabs.js","sourceRoot":"","sources":["../../../../src/components/tabs/tabs.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,UAAU,EAAqC,MAAM,OAAO,CAAC;AACrF,OAAO,EACL,UAAU,IAAI,aAAa,EAC3B,GAAG,IAAI,MAAM,EACb,OAAO,IAAI,UAAU,EACrB,QAAQ,IAAI,WAAW,EACvB,IAAI,IAAI,OAAO,GAGhB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAS3D,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAM7C,MAAM,WAAW,GAAG,aAAa,CAAmB,EAAE,CAAC,CAAC;AAUxD,SAAS,IAAI,CACX,EACE,QAAQ,EACR,gBAAgB,EAChB,YAAY;AAEZ,sBAA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AC,CAAC;IAC9C,MAAM,EACJ,YAAY,EAAE,SAAS,EACvB,iBAAiB,EAAE,cAAc,EACjC,kBAAkB,EAAE,eAAe,EACnC,cAAc,EAAE,WAAW,GAC5B,GAAG,SAAS,IAAI,EAAE,CAAC;IAEpB,OAAO,CACL,KAAC,UAAU,OACL,KAAK,EACT,SAAS,EAAC,cAAc,gBACZ,SAAS,qBACJ,cAAc,sBACb,eAAe,kBACnB,WAAW,YAExB,QAAQ,GACE,CACd,CAAC;AACJ,CAAC;AAED,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC;AAWhC,6CAA6C;AAC7C,MAAM,UAAU,GAAG,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,KAAK,EAAY;IACpE,OAAO,CACL,MAAC,MAAM,OAAK,KAAK,EAAE,SAAS,EAAC,cAAc,aACxC,SAAS,EACV,KAAC,IAAI,IAAC,EAAE,EAAC,MAAM,EAAC,OAAO,EAAC,iBAAiB,EAAC,SAAS,EAAC,QAAQ,YACzD,QAAQ,GACJ,EACN,KAAK,IACC,CACV,CAAC;AACJ,CAAC;AAED,GAAG,CAAC,WAAW,GAAG,KAAK,CAAC;AAIxB,mEAAmE;AACnE,MAAM,UAAU,SAAS,CAA2B,EAAE,GAAG,KAAK,EAAqB;IACjF,OAAO,KAAC,aAAa,OAAK,KAAK,GAAI,CAAC;AACtC,CAAC;AAED,SAAS,CAAC,WAAW,GAAG,WAAW,CAAC;AASpC,qDAAqD;AACrD,MAAM,UAAU,QAAQ,CAAC,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAiB;IAC5D,OAAO,CACL,KAAC,WAAW,OAAK,KAAK,EAAE,SAAS,EAAC,eAAe,YAC9C,QAAQ,GACG,CACf,CAAC;AACJ,CAAC;AAED,QAAQ,CAAC,WAAW,GAAG,UAAU,CAAC","sourcesContent":["'use client';\n\nimport clsx from 'clsx';\nimport { createContext, useContext, type ForwardedRef, type ReactNode } from 'react';\nimport {\n Collection as RACCollection,\n Tab as RACTab,\n TabList as RACTabList,\n TabPanel as RACTabPanel,\n Tabs as RACTabs,\n type TabsProps as RACTabsProps,\n type TabProps as RACTabProps,\n} from 'react-aria-components';\nimport { forwardRef } from '../../forward-ref.js';\nimport { useProductionWarning } from '../../utils/use-production-warning.js';\nimport { withStyleProps } from '../../with-style-props.js';\nimport type {\n AriaLabelingProps,\n CollectionItem,\n CollectionProps,\n CommonProps,\n Key,\n StringLikeChildren,\n} from '../types.js';\nimport { Text } from '../typography/text.js';\n\ninterface TabsContextValue {\n tabsProps?: AriaLabelingProps;\n}\n\nconst TabsContext = createContext<TabsContextValue>({});\n\nexport interface TabsProps\n extends CommonProps,\n AriaLabelingProps,\n Pick<RACTabsProps, 'selectedKey' | 'defaultSelectedKey' | 'disabledKeys' | 'onSelectionChange'> {\n /** The children of the `<Tabs>` element. Should include `<TabList>` and `<TabPanels>` elements. */\n children: ReactNode;\n}\n\nfunction Tabs(\n {\n children,\n UNSAFE_className,\n UNSAFE_style,\n\n // Aria labeling props\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-details': ariaDetails,\n\n ...props\n }: TabsProps,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n useProductionWarning(() => {\n if (!ariaLabel && !ariaLabelledBy) {\n console.warn('Tabs requires one of aria-label / aria-labelledby for accessibility');\n }\n }, [ariaLabel, ariaLabelledBy]);\n\n return (\n <TabsContext.Provider\n value={{\n tabsProps: {\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-details': ariaDetails,\n },\n }}\n >\n <RACTabs\n {...props}\n ref={ref}\n className={clsx('cim-tabs', UNSAFE_className)}\n style={UNSAFE_style}\n keyboardActivation=\"manual\"\n >\n {children}\n </RACTabs>\n </TabsContext.Provider>\n );\n}\n\n/**\n * Organizes content into multiple sections that users can switch between.\n *\n * See [tabs usage guidelines](https://ui.cimpress.io/components/tabs/).\n */\nconst _Tabs = withStyleProps(forwardRef(Tabs), 'Tabs');\n\nexport { _Tabs as Tabs };\n\nexport interface TabListProps<T extends CollectionItem> extends CollectionProps<T> {}\n\n/** Renders a collection of `Tab` components within `Tabs`. */\nexport function TabList<T extends CollectionItem>({ children, ...props }: TabListProps<T>) {\n const { tabsProps } = useContext(TabsContext);\n const {\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-details': ariaDetails,\n } = tabsProps ?? {};\n\n return (\n <RACTabList\n {...props}\n className=\"cim-tab-list\"\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-describedby={ariaDescribedBy}\n aria-details={ariaDetails}\n >\n {children}\n </RACTabList>\n );\n}\n\nTabList.displayName = 'TabList';\n\nexport interface TabProps extends Pick<RACTabProps, 'id' | 'isDisabled' | 'onHoverStart' | 'onHoverEnd'> {\n /** The text to display as the tab title. */\n children: StringLikeChildren;\n /** An icon displayed before the tab title. */\n iconStart?: ReactNode;\n /** A badge displayed after the tab title. */\n badge?: ReactNode;\n}\n\n/** Renders a single tab within `TabList`. */\nexport function Tab({ children, iconStart, badge, ...props }: TabProps) {\n return (\n <RACTab {...props} className=\"cim-tab-item\">\n {iconStart}\n <Text as=\"span\" variant=\"medium-semibold\" alignment=\"center\">\n {children}\n </Text>\n {badge}\n </RACTab>\n );\n}\n\nTab.displayName = 'Tab';\n\nexport interface TabPanelsProps<T extends CollectionItem> extends CollectionProps<T> {}\n\n/** Renders a collection of `TabPanel` components within `Tabs`. */\nexport function TabPanels<T extends CollectionItem>({ ...props }: TabPanelsProps<T>) {\n return <RACCollection {...props} />;\n}\n\nTabPanels.displayName = 'TabPanels';\n\nexport interface TabPanelProps {\n /** The content to display in the tab panel. */\n children: ReactNode;\n /** The unique id of the associated tab. */\n id?: Key;\n}\n\n/** Renders a single tab panel within `TabPanels`. */\nexport function TabPanel({ children, ...props }: TabPanelProps) {\n return (\n <RACTabPanel {...props} className=\"cim-tab-panel\">\n {children}\n </RACTabPanel>\n );\n}\n\nTabPanel.displayName = 'TabPanel';\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
2
|
import { type TagGroupProps as RACTagGroupProps, type TagListProps as RACTagListProps } from 'react-aria-components';
|
|
3
3
|
import type { CollectionItem, CommonProps, FieldProps, Key } from '../types.js';
|
|
4
|
-
export interface TagGroupProps<T extends CollectionItem = CollectionItem> extends CommonProps, Omit<FieldProps<Key[]>, 'validate' | 'error' | 'name'>, Pick<RACTagGroupProps, 'selectionMode' | 'defaultSelectedKeys' | 'selectedKeys' | 'disabledKeys' | 'onSelectionChange' | 'onRemove'>, Pick<RACTagListProps<T>, 'children' | 'items'> {
|
|
4
|
+
export interface TagGroupProps<T extends CollectionItem = CollectionItem> extends CommonProps, Omit<FieldProps<Key[]>, 'validate' | 'error' | 'form' | 'name'>, Pick<RACTagGroupProps, 'selectionMode' | 'defaultSelectedKeys' | 'selectedKeys' | 'disabledKeys' | 'onSelectionChange' | 'onRemove'>, Pick<RACTagListProps<T>, 'children' | 'items'> {
|
|
5
5
|
/** Whether the tag group is required. */
|
|
6
6
|
isRequired?: boolean;
|
|
7
7
|
/** The error message to display. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tag-group.d.ts","sourceRoot":"","sources":["../../../../src/components/tag/tag-group.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAgB,SAAS,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,EAGL,KAAK,aAAa,IAAI,gBAAgB,EACtC,KAAK,YAAY,IAAI,eAAe,EACrC,MAAM,uBAAuB,CAAC;AAI/B,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAEhF,MAAM,WAAW,aAAa,CAAC,CAAC,SAAS,cAAc,GAAG,cAAc,CACtE,SAA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