@cimpress-ui/react 1.3.0 → 1.4.1
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/combo-box/combo-box.d.ts +1 -1
- package/dist/commonjs/components/combo-box/combo-box.d.ts.map +1 -1
- package/dist/commonjs/components/combo-box/combo-box.js +9 -3
- package/dist/commonjs/components/combo-box/combo-box.js.map +1 -1
- package/dist/commonjs/components/internal/x-button/x-button.js +7 -2
- package/dist/commonjs/components/internal/x-button/x-button.js.map +1 -1
- package/dist/commonjs/components/pagination/link-pagination.js +2 -3
- package/dist/commonjs/components/pagination/link-pagination.js.map +1 -1
- package/dist/commonjs/components/stepper/context.d.ts +6 -0
- package/dist/commonjs/components/stepper/context.d.ts.map +1 -0
- package/dist/commonjs/components/stepper/context.js +9 -0
- package/dist/commonjs/components/stepper/context.js.map +1 -0
- package/dist/commonjs/components/stepper/stepper-item.d.ts +16 -0
- package/dist/commonjs/components/stepper/stepper-item.d.ts.map +1 -0
- package/dist/commonjs/components/stepper/stepper-item.js +49 -0
- package/dist/commonjs/components/stepper/stepper-item.js.map +1 -0
- package/dist/commonjs/components/stepper/stepper.d.ts +21 -0
- package/dist/commonjs/components/stepper/stepper.d.ts.map +1 -0
- package/dist/commonjs/components/stepper/stepper.js +29 -0
- package/dist/commonjs/components/stepper/stepper.js.map +1 -0
- package/dist/commonjs/components/stepper/types.d.ts +2 -0
- package/dist/commonjs/components/stepper/types.d.ts.map +1 -0
- package/dist/commonjs/components/stepper/types.js +3 -0
- package/dist/commonjs/components/stepper/types.js.map +1 -0
- package/dist/commonjs/components/tag-field/tag-field-list-box.js +3 -0
- package/dist/commonjs/components/tag-field/tag-field-list-box.js.map +1 -1
- package/dist/commonjs/components/tag-field/tag-field.d.ts +1 -1
- package/dist/commonjs/components/tag-field/tag-field.js +1 -1
- package/dist/commonjs/components/tag-field/tag-field.js.map +1 -1
- package/dist/commonjs/components/text-inputs/search-field.d.ts +12 -0
- package/dist/commonjs/components/text-inputs/search-field.d.ts.map +1 -0
- package/dist/commonjs/components/text-inputs/search-field.js +38 -0
- package/dist/commonjs/components/text-inputs/search-field.js.map +1 -0
- package/dist/commonjs/components/text-inputs/text-area.d.ts.map +1 -1
- package/dist/commonjs/components/text-inputs/text-area.js +3 -1
- package/dist/commonjs/components/text-inputs/text-area.js.map +1 -1
- package/dist/commonjs/components/text-inputs/text-field.d.ts +2 -2
- package/dist/commonjs/components/text-inputs/text-field.d.ts.map +1 -1
- package/dist/commonjs/components/text-inputs/text-field.js +6 -2
- package/dist/commonjs/components/text-inputs/text-field.js.map +1 -1
- package/dist/commonjs/components/toggle-button/toggle-button-group.d.ts.map +1 -1
- package/dist/commonjs/components/toggle-button/toggle-button-group.js +0 -1
- package/dist/commonjs/components/toggle-button/toggle-button-group.js.map +1 -1
- package/dist/commonjs/components/types.d.ts +9 -0
- 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.js +1 -1
- package/dist/commonjs/i18n/messages/en-US.js.map +1 -1
- package/dist/commonjs/i18n/messages/types.d.ts +2 -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/close-circle.d.ts +8 -0
- package/dist/commonjs/icons/close-circle.d.ts.map +1 -0
- package/dist/commonjs/icons/close-circle.js +24 -0
- package/dist/commonjs/icons/close-circle.js.map +1 -0
- package/dist/commonjs/icons/index.d.ts +1 -0
- package/dist/commonjs/icons/index.d.ts.map +1 -1
- package/dist/commonjs/icons/index.js +4 -2
- package/dist/commonjs/icons/index.js.map +1 -1
- package/dist/commonjs/index.d.ts +6 -2
- package/dist/commonjs/index.d.ts.map +1 -1
- package/dist/commonjs/index.js +5 -2
- package/dist/commonjs/index.js.map +1 -1
- package/dist/esm/components/combo-box/combo-box.d.ts +1 -1
- package/dist/esm/components/combo-box/combo-box.d.ts.map +1 -1
- package/dist/esm/components/combo-box/combo-box.js +9 -3
- package/dist/esm/components/combo-box/combo-box.js.map +1 -1
- package/dist/esm/components/internal/x-button/x-button.js +8 -3
- package/dist/esm/components/internal/x-button/x-button.js.map +1 -1
- package/dist/esm/components/pagination/link-pagination.js +2 -3
- package/dist/esm/components/pagination/link-pagination.js.map +1 -1
- package/dist/esm/components/stepper/context.d.ts +6 -0
- package/dist/esm/components/stepper/context.d.ts.map +1 -0
- package/dist/esm/components/stepper/context.js +6 -0
- package/dist/esm/components/stepper/context.js.map +1 -0
- package/dist/esm/components/stepper/stepper-item.d.ts +16 -0
- package/dist/esm/components/stepper/stepper-item.d.ts.map +1 -0
- package/dist/esm/components/stepper/stepper-item.js +43 -0
- package/dist/esm/components/stepper/stepper-item.js.map +1 -0
- package/dist/esm/components/stepper/stepper.d.ts +21 -0
- package/dist/esm/components/stepper/stepper.d.ts.map +1 -0
- package/dist/esm/components/stepper/stepper.js +23 -0
- package/dist/esm/components/stepper/stepper.js.map +1 -0
- package/dist/esm/components/stepper/types.d.ts +2 -0
- package/dist/esm/components/stepper/types.d.ts.map +1 -0
- package/dist/esm/components/stepper/types.js +2 -0
- package/dist/esm/components/stepper/types.js.map +1 -0
- package/dist/esm/components/tag-field/tag-field-list-box.js +4 -1
- package/dist/esm/components/tag-field/tag-field-list-box.js.map +1 -1
- package/dist/esm/components/tag-field/tag-field.d.ts +1 -1
- package/dist/esm/components/tag-field/tag-field.js +1 -1
- package/dist/esm/components/tag-field/tag-field.js.map +1 -1
- package/dist/esm/components/text-inputs/search-field.d.ts +12 -0
- package/dist/esm/components/text-inputs/search-field.d.ts.map +1 -0
- package/dist/esm/components/text-inputs/search-field.js +32 -0
- package/dist/esm/components/text-inputs/search-field.js.map +1 -0
- package/dist/esm/components/text-inputs/text-area.d.ts.map +1 -1
- package/dist/esm/components/text-inputs/text-area.js +3 -1
- package/dist/esm/components/text-inputs/text-area.js.map +1 -1
- package/dist/esm/components/text-inputs/text-field.d.ts +2 -2
- package/dist/esm/components/text-inputs/text-field.d.ts.map +1 -1
- package/dist/esm/components/text-inputs/text-field.js +7 -3
- package/dist/esm/components/text-inputs/text-field.js.map +1 -1
- package/dist/esm/components/toggle-button/toggle-button-group.d.ts.map +1 -1
- package/dist/esm/components/toggle-button/toggle-button-group.js +0 -1
- package/dist/esm/components/toggle-button/toggle-button-group.js.map +1 -1
- package/dist/esm/components/types.d.ts +9 -0
- 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.js +1 -1
- package/dist/esm/i18n/messages/en-US.js.map +1 -1
- package/dist/esm/i18n/messages/types.d.ts +2 -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/close-circle.d.ts +8 -0
- package/dist/esm/icons/close-circle.d.ts.map +1 -0
- package/dist/esm/icons/close-circle.js +19 -0
- package/dist/esm/icons/close-circle.js.map +1 -0
- package/dist/esm/icons/index.d.ts +1 -0
- package/dist/esm/icons/index.d.ts.map +1 -1
- package/dist/esm/icons/index.js +1 -0
- package/dist/esm/icons/index.js.map +1 -1
- package/dist/esm/index.d.ts +6 -2
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +5 -2
- 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 +12 -12
|
@@ -17,7 +17,7 @@ export interface ComboBoxProps<T extends CollectionItem = CollectionItem> extend
|
|
|
17
17
|
/**
|
|
18
18
|
* Allows users to filter a collapsible list and select one item from it.
|
|
19
19
|
*
|
|
20
|
-
* See [combo box usage guidelines](https://ui.cimpress.
|
|
20
|
+
* See [combo box usage guidelines](https://ui.cimpress.io/components/combo-box)
|
|
21
21
|
*/
|
|
22
22
|
declare const _ComboBox: <T extends CollectionItem>(props: ComboBoxProps<T> & import("react").RefAttributes<HTMLDivElement> & import("../../with-style-props.js").StyleProps) => import("react").JSX.Element | null;
|
|
23
23
|
export { _ComboBox as ComboBox };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"combo-box.d.ts","sourceRoot":"","sources":["../../../../src/components/combo-box/combo-box.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"combo-box.d.ts","sourceRoot":"","sources":["../../../../src/components/combo-box/combo-box.tsx"],"names":[],"mappings":"AAKA,OAAO,EASL,KAAK,YAAY,IAAI,eAAe,EAOpC,KAAK,aAAa,IAAI,gBAAgB,EACtC,KAAK,gBAAgB,IAAI,mBAAmB,EAE7C,MAAM,uBAAuB,CAAC;AAU/B,OAAO,KAAK,EACV,qBAAqB,EACrB,cAAc,EACd,eAAe,EACf,WAAW,EACX,yBAAyB,EACzB,GAAG,EACH,kBAAkB,EACnB,MAAM,aAAa,CAAC;AAWrB,gFAAgF;AAChF,MAAM,WAAW,uBAAuB;IACtC,wCAAwC;IACxC,WAAW,EAAE,GAAG,GAAG,IAAI,CAAC;IACxB,uCAAuC;IACvC,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,aAAa,CAAC,CAAC,SAAS,cAAc,GAAG,cAAc,CACtE,SAAQ,WAAW,EACjB,yBAAyB,CAAC,uBAAuB,CAAC,EAClD,eAAe,CAAC,CAAC,CAAC,EAClB,qBAAqB,EACrB,IAAI,CACF,gBAAgB,CAAC,CAAC,CAAC,EACjB,YAAY,GACZ,YAAY,GACZ,WAAW,GACX,YAAY,GACZ,aAAa,GACb,oBAAoB,GACpB,YAAY,GACZ,mBAAmB,GACnB,WAAW,GACX,mBAAmB,GACnB,eAAe,GACf,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;AA4ED;;;;GAIG;AACH,QAAA,MAAM,SAAS,GA/EG,CAAC,SAAS,cAAc,iKA+EwB,CAAC;AAEnE,OAAO,EAAE,SAAS,IAAI,QAAQ,EAAE,CAAC;AAqDjC,MAAM,WAAW,iBAAiB,CAAC,CAAC,SAAS,cAAc,CACzD,SAAQ,IAAI,CAAC,mBAAmB,CAAC,CAAC,CAAC,EAAE,IAAI,GAAG,YAAY,GAAG,cAAc,GAAG,YAAY,CAAC;IACzF,2CAA2C;IAC3C,QAAQ,EAAE,kBAAkB,CAAC;CAC9B;AAED,oDAAoD;AACpD,wBAAgB,YAAY,CAAC,CAAC,SAAS,cAAc,EAAE,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,iBAAiB,CAAC,CAAC,CAAC,2CAiBlG;yBAjBe,YAAY;;;AAqB5B,MAAM,WAAW,oBAAoB,CAAC,CAAC,SAAS,cAAc,CAAE,SAAQ,eAAe,CAAC,CAAC,CAAC;IACxF,6EAA6E;IAC7E,EAAE,CAAC,EAAE,GAAG,CAAC;IACT,mDAAmD;IACnD,KAAK,EAAE,MAAM,CAAC;CACf;AAED,0DAA0D;AAC1D,wBAAgB,eAAe,CAAC,CAAC,SAAS,cAAc,EAAE,EACxD,KAAK,EACL,QAAQ,EACR,KAAK,EACL,GAAG,KAAK,EACT,EAAE,oBAAoB,CAAC,CAAC,CAAC,2CAezB;yBApBe,eAAe"}
|
|
@@ -10,6 +10,7 @@ exports.ComboBoxSection = ComboBoxSection;
|
|
|
10
10
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
11
11
|
const clsx_1 = __importDefault(require("clsx"));
|
|
12
12
|
const react_1 = require("react");
|
|
13
|
+
const react_aria_1 = require("react-aria");
|
|
13
14
|
const react_aria_components_1 = require("react-aria-components");
|
|
14
15
|
const forward_ref_js_1 = require("../../forward-ref.js");
|
|
15
16
|
const index_js_1 = require("../../i18n/index.js");
|
|
@@ -38,14 +39,13 @@ function ComboBox({ label, description, error, items, children, placeholder, UNS
|
|
|
38
39
|
if (!(0, is_production_js_1.isProduction)() && items != null && typeof children !== 'function') {
|
|
39
40
|
console.warn('`ComboBox` requires `children` to be a function when using `items` prop');
|
|
40
41
|
}
|
|
41
|
-
const
|
|
42
|
-
const listBox = ((0, jsx_runtime_1.jsxs)(react_aria_components_1.ListBox, { className: "cim-combo-box-listbox", onScroll: onScroll, renderEmptyState: () => isLoading ? (0, jsx_runtime_1.jsx)(spinner_js_1.Spinner, { "aria-label": collectionMessages.format('loading'), size: "small", marginY: 8 }) : null, children: [(0, jsx_runtime_1.jsx)(react_aria_components_1.Collection, { items: items, children: children }), (0, jsx_runtime_1.jsx)(react_aria_components_1.ListBoxLoadMoreItem, { onLoadMore: onLoadMore, isLoading: isLoading, children: (0, jsx_runtime_1.jsx)(spinner_js_1.Spinner, { "aria-label": collectionMessages.format('loadingMore'), size: "small", marginY: 8 }) })] }));
|
|
42
|
+
const listBox = ((0, jsx_runtime_1.jsx)(ComboBoxList, { items: items, isLoading: isLoading, onLoadMore: onLoadMore, onScroll: onScroll, children: children }));
|
|
43
43
|
return ((0, jsx_runtime_1.jsxs)(react_aria_components_1.ComboBox, { ...props, ref: ref, className: (0, clsx_1.default)('cim-combo-box', UNSAFE_className), style: UNSAFE_style, menuTrigger: "focus", isReadOnly: isReadOnly, "data-readonly": isReadOnly ? true : undefined, children: [(0, jsx_runtime_1.jsx)(form_field_js_1.FormFieldLabel, { isRequired: props.isRequired, isDisabled: props.isDisabled, children: label }), (0, jsx_runtime_1.jsxs)(react_aria_components_1.Group, { className: "cim-combo-box-input-group", children: [(0, jsx_runtime_1.jsx)(ComboBoxInput, { isReadOnly: isReadOnly, placeholder: placeholder }), (0, jsx_runtime_1.jsx)(react_aria_components_1.Button, { className: "cim-combo-box-button", children: (0, jsx_runtime_1.jsx)(index_js_2.IconChevronDown, {}) })] }), (0, jsx_runtime_1.jsx)(form_field_js_1.FormFieldError, { children: error }), (0, jsx_runtime_1.jsx)(form_field_js_1.FormFieldDescription, { children: description }), (0, jsx_runtime_1.jsx)(collapsible_list_js_1.CollapsibleList, { offset: 5, maxHeight: 315, children: isVirtualized ? ((0, jsx_runtime_1.jsx)(react_aria_components_1.Virtualizer, { layout: react_aria_components_1.ListLayout, layoutOptions: VIRTUAL_LAYOUT_OPTIONS, children: listBox })) : (listBox) })] }));
|
|
44
44
|
}
|
|
45
45
|
/**
|
|
46
46
|
* Allows users to filter a collapsible list and select one item from it.
|
|
47
47
|
*
|
|
48
|
-
* See [combo box usage guidelines](https://ui.cimpress.
|
|
48
|
+
* See [combo box usage guidelines](https://ui.cimpress.io/components/combo-box)
|
|
49
49
|
*/
|
|
50
50
|
const _ComboBox = (0, with_style_props_js_1.withStyleProps)((0, forward_ref_js_1.forwardRef)(ComboBox), 'ComboBox');
|
|
51
51
|
exports.ComboBox = _ComboBox;
|
|
@@ -56,6 +56,12 @@ function ComboBoxInput({ isReadOnly, placeholder, }) {
|
|
|
56
56
|
// By default, React Aria only opens the popover when the input is focused.
|
|
57
57
|
onClick: () => !isReadOnly && comboBoxState.open(), placeholder: placeholder }));
|
|
58
58
|
}
|
|
59
|
+
function ComboBoxList({ items, children, isLoading, onLoadMore, onScroll, }) {
|
|
60
|
+
const comboBoxState = (0, react_1.useContext)(react_aria_components_1.ComboBoxStateContext);
|
|
61
|
+
const collectionMessages = (0, index_js_1.useLocalizedMessages)('UNSTABLE_collection');
|
|
62
|
+
(0, react_aria_1.usePreventScroll)({ isDisabled: !comboBoxState?.isOpen });
|
|
63
|
+
return ((0, jsx_runtime_1.jsxs)(react_aria_components_1.ListBox, { className: "cim-combo-box-listbox", onScroll: onScroll, renderEmptyState: () => isLoading ? (0, jsx_runtime_1.jsx)(spinner_js_1.Spinner, { "aria-label": collectionMessages.format('loading'), size: "small", marginY: 8 }) : null, children: [(0, jsx_runtime_1.jsx)(react_aria_components_1.Collection, { items: items, children: children }), (0, jsx_runtime_1.jsx)(react_aria_components_1.ListBoxLoadMoreItem, { onLoadMore: onLoadMore, isLoading: isLoading, children: (0, jsx_runtime_1.jsx)(spinner_js_1.Spinner, { "aria-label": collectionMessages.format('loadingMore'), size: "small", marginY: 8 }) })] }));
|
|
64
|
+
}
|
|
59
65
|
/** Renders a single list item within `ComboBox`. */
|
|
60
66
|
function ComboBoxItem({ children, ...props }) {
|
|
61
67
|
const textValue = typeof children === 'string' ? children : typeof children === 'number' ? String(children) : children.join('');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"combo-box.js","sourceRoot":"","sources":["../../../../src/components/combo-box/combo-box.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;AAmNb,oCAiBC;AAYD,0CAoBC;;AAlQD,gDAAwB;AACxB,iCAAsD;AACtD,iEAmB+B;AAC/B,yDAAkD;AAClD,kDAA2D;AAC3D,mDAAkE;AAClE,mEAA4D;AAC5D,qFAA6E;AAC7E,mEAA2D;AAC3D,0FAAmF;AACnF,wEAA4G;AAC5G,sDAAgD;AAUhD,qDAAmD;AAEnD,MAAM,sBAAsB,GAAyB;IACnD,SAAS,EAAE,EAAE;IACb,aAAa,EAAE,EAAE;IACjB,YAAY,EAAE,EAAE;IAChB,OAAO,EAAE,CAAC;IACV,GAAG,EAAE,CAAC;CACP,CAAC;AAwCF,SAAS,QAAQ,CACf,EACE,KAAK,EACL,WAAW,EACX,KAAK,EACL,KAAK,EACL,QAAQ,EACR,WAAW,EACX,gBAAgB,EAChB,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,aAAa,GAAG,KAAK,EACrB,kBAAkB,EAAE,SAAS,EAC7B,mBAAmB,EAAE,UAAU,EAC/B,GAAG,KAAK,EACS,EACnB,GAAiC;IAEjC,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,iBAAiB,EAAE,cAAc,EAAE,GAAG,KAAK,CAAC;IAE7E,IAAA,gDAAoB,EAAC,GAAG,EAAE;QACxB,IAAI,CAAC,KAAK,IAAI,CAAC,SAAS,IAAI,CAAC,cAAc,EAAE,CAAC;YAC5C,OAAO,CAAC,IAAI,CAAC,iFAAiF,CAAC,CAAC;QAClG,CAAC;IACH,C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ACrB,CAAC;AACJ,CAAC;AAED,eAAe,CAAC,WAAW,GAAG,iBAAiB,CAAC","sourcesContent":["'use client';\n\nimport clsx from 'clsx';\nimport { useContext, type ForwardedRef } from 'react';\nimport {\n Button as RACButton,\n Collection as RACCollection,\n ComboBox as RACComboBox,\n ComboBoxStateContext as RACComboBoxStateContext,\n Group as RACGroup,\n Header as RACHeader,\n Input as RACInput,\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 Text as RACText,\n type ComboBoxProps as RACComboBoxProps,\n type ListBoxItemProps as RACListBoxItemProps,\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 FieldWithPlaceholderProps,\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\n/** Represents the state of the `ComboBox` component for validation purposes. */\nexport interface ComboBoxValidationValue {\n /** The selected key in the ComboBox. */\n selectedKey: Key | null;\n /** The value of the ComboBox input. */\n inputValue: string;\n}\n\nexport interface ComboBoxProps<T extends CollectionItem = CollectionItem>\n extends CommonProps,\n FieldWithPlaceholderProps<ComboBoxValidationValue>,\n CollectionProps<T>,\n AsyncItemLoadingProps,\n Pick<\n RACComboBoxProps<T>,\n | 'isDisabled'\n | 'isRequired'\n | 'isInvalid'\n | 'isReadOnly'\n | 'selectedKey'\n | 'defaultSelectedKey'\n | 'inputValue'\n | 'defaultInputValue'\n | 'autoFocus'\n | 'onSelectionChange'\n | 'onInputChange'\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 ComboBox<T extends CollectionItem>(\n {\n label,\n description,\n error,\n items,\n children,\n placeholder,\n UNSAFE_className,\n UNSAFE_style,\n isReadOnly,\n onScroll,\n isVirtualized = false,\n UNSTABLE_isLoading: isLoading,\n UNSTABLE_onLoadMore: onLoadMore,\n ...props\n }: ComboBoxProps<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('ComboBox 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('`ComboBox` 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-combo-box-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 <RACComboBox\n {...props}\n ref={ref}\n className={clsx('cim-combo-box', UNSAFE_className)}\n style={UNSAFE_style}\n menuTrigger=\"focus\"\n isReadOnly={isReadOnly}\n data-readonly={isReadOnly ? true : undefined}\n >\n <FormFieldLabel isRequired={props.isRequired} isDisabled={props.isDisabled}>\n {label}\n </FormFieldLabel>\n <RACGroup className=\"cim-combo-box-input-group\">\n <ComboBoxInput isReadOnly={isReadOnly} placeholder={placeholder} />\n <RACButton className=\"cim-combo-box-button\">\n <IconChevronDown />\n </RACButton>\n </RACGroup>\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 </RACComboBox>\n );\n}\n\n/**\n * Allows users to filter a collapsible list and select one item from it.\n *\n * See [combo box usage guidelines](https://ui.cimpress.com/components/combo-box)\n */\nconst _ComboBox = withStyleProps(forwardRef(ComboBox), 'ComboBox');\n\nexport { _ComboBox as ComboBox };\n\nfunction ComboBoxInput({\n isReadOnly,\n placeholder,\n}: {\n isReadOnly: boolean | undefined;\n placeholder: string | undefined;\n}) {\n const comboBoxState = useContext(RACComboBoxStateContext);\n\n return (\n <RACInput\n className={clsx('cim-combo-box-input', textStyle({ variant: 'body' }))}\n // Ensure the popover opens when the input is clicked.\n // By default, React Aria only opens the popover when the input is focused.\n onClick={() => !isReadOnly && comboBoxState!.open()}\n placeholder={placeholder}\n />\n );\n}\n\nexport interface ComboBoxItemProps<T extends CollectionItem>\n extends Pick<RACListBoxItemProps<T>, 'id' | 'isDisabled' | 'onHoverStart' | 'onHoverEnd'> {\n /** The content to display as the label. */\n children: StringLikeChildren;\n}\n\n/** Renders a single list item within `ComboBox`. */\nexport function ComboBoxItem<T extends CollectionItem>({ children, ...props }: ComboBoxItemProps<T>) {\n const textValue =\n typeof children === 'string' ? children : typeof children === 'number' ? String(children) : children.join('');\n\n return (\n <RACListBoxItem {...props} className=\"cim-combo-box-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\nComboBoxItem.displayName = 'ComboBoxItem';\n\nexport interface ComboBoxSectionProps<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 `ComboBox` into a section. */\nexport function ComboBoxSection<T extends CollectionItem>({\n title,\n children,\n items,\n ...props\n}: ComboBoxSectionProps<T>) {\n if (!isProduction() && items != null && typeof children !== 'function') {\n console.warn('`ComboBoxSection` requires `children` to be a function when using `items` prop');\n }\n\n return (\n <RACListBoxSection {...props} className=\"cim-combo-box-section\">\n <RACHeader\n className={clsx('cim-combo-box-section-header', textStyle({ variant: 'small-semibold', tone: 'subtle' }))}\n >\n {title}\n </RACHeader>\n <RACCollection items={items}>{children}</RACCollection>\n </RACListBoxSection>\n );\n}\n\nComboBoxSection.displayName = 'ComboBoxSection';\n"]}
|
|
1
|
+
{"version":3,"file":"combo-box.js","sourceRoot":"","sources":["../../../../src/components/combo-box/combo-box.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;AAwOb,oCAiBC;AAYD,0CAoBC;;AAvRD,gDAAwB;AACxB,iCAAsD;AACtD,2CAA8C;AAC9C,iEAmB+B;AAC/B,yDAAkD;AAClD,kDAA2D;AAC3D,mDAAkE;AAClE,mEAA4D;AAC5D,qFAA6E;AAC7E,mEAA2D;AAC3D,0FAAmF;AACnF,wEAA4G;AAC5G,sDAAgD;AAUhD,qDAAmD;AAEnD,MAAM,sBAA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CAAC,EAAE,CAAC,CAAC;IAEhH,OAAO,CACL,uBAAC,mCAAc,OAAK,KAAK,EAAE,SAAS,EAAC,oBAAoB,EAAC,SAAS,EAAE,SAAS,YAC3E,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,CACnB,6DACE,uBAAC,oBAAS,KAAG,EAEb,uBAAC,4BAAO,IAAC,IAAI,EAAC,OAAO,EAAC,SAAS,EAAE,IAAA,oBAAS,EAAC,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,YACjG,QAAQ,GACD,IACT,CACJ,GACc,CAClB,CAAC;AACJ,CAAC;AAED,YAAY,CAAC,WAAW,GAAG,cAAc,CAAC;AAS1C,0DAA0D;AAC1D,SAAgB,eAAe,CAA2B,EACxD,KAAK,EACL,QAAQ,EACR,KAAK,EACL,GAAG,KAAK,EACgB;IACxB,IAAI,CAAC,IAAA,+BAAY,GAAE,IAAI,KAAK,IAAI,IAAI,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE,CAAC;QACvE,OAAO,CAAC,IAAI,CAAC,gFAAgF,CAAC,CAAC;IACjG,CAAC;IAED,OAAO,CACL,wBAAC,sCAAiB,OAAK,KAAK,EAAE,SAAS,EAAC,uBAAuB,aAC7D,uBAAC,8BAAS,IACR,SAAS,EAAE,IAAA,cAAI,EAAC,8BAA8B,EAAE,IAAA,oBAAS,EAAC,EAAE,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC,YAExG,KAAK,GACI,EACZ,uBAAC,kCAAa,IAAC,KAAK,EAAE,KAAK,YAAG,QAAQ,GAAiB,IACrC,CACrB,CAAC;AACJ,CAAC;AAED,eAAe,CAAC,WAAW,GAAG,iBAAiB,CAAC","sourcesContent":["'use client';\n\nimport clsx from 'clsx';\nimport { useContext, type ForwardedRef } from 'react';\nimport { usePreventScroll } from 'react-aria';\nimport {\n Button as RACButton,\n Collection as RACCollection,\n ComboBox as RACComboBox,\n ComboBoxStateContext as RACComboBoxStateContext,\n Group as RACGroup,\n Header as RACHeader,\n Input as RACInput,\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 Text as RACText,\n type ComboBoxProps as RACComboBoxProps,\n type ListBoxItemProps as RACListBoxItemProps,\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 FieldWithPlaceholderProps,\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\n/** Represents the state of the `ComboBox` component for validation purposes. */\nexport interface ComboBoxValidationValue {\n /** The selected key in the ComboBox. */\n selectedKey: Key | null;\n /** The value of the ComboBox input. */\n inputValue: string;\n}\n\nexport interface ComboBoxProps<T extends CollectionItem = CollectionItem>\n extends CommonProps,\n FieldWithPlaceholderProps<ComboBoxValidationValue>,\n CollectionProps<T>,\n AsyncItemLoadingProps,\n Pick<\n RACComboBoxProps<T>,\n | 'isDisabled'\n | 'isRequired'\n | 'isInvalid'\n | 'isReadOnly'\n | 'selectedKey'\n | 'defaultSelectedKey'\n | 'inputValue'\n | 'defaultInputValue'\n | 'autoFocus'\n | 'onSelectionChange'\n | 'onInputChange'\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 ComboBox<T extends CollectionItem>(\n {\n label,\n description,\n error,\n items,\n children,\n placeholder,\n UNSAFE_className,\n UNSAFE_style,\n isReadOnly,\n onScroll,\n isVirtualized = false,\n UNSTABLE_isLoading: isLoading,\n UNSTABLE_onLoadMore: onLoadMore,\n ...props\n }: ComboBoxProps<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('ComboBox 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('`ComboBox` requires `children` to be a function when using `items` prop');\n }\n\n const listBox = (\n <ComboBoxList<T> items={items} isLoading={isLoading} onLoadMore={onLoadMore} onScroll={onScroll}>\n {children}\n </ComboBoxList>\n );\n\n return (\n <RACComboBox\n {...props}\n ref={ref}\n className={clsx('cim-combo-box', UNSAFE_className)}\n style={UNSAFE_style}\n menuTrigger=\"focus\"\n isReadOnly={isReadOnly}\n data-readonly={isReadOnly ? true : undefined}\n >\n <FormFieldLabel isRequired={props.isRequired} isDisabled={props.isDisabled}>\n {label}\n </FormFieldLabel>\n <RACGroup className=\"cim-combo-box-input-group\">\n <ComboBoxInput isReadOnly={isReadOnly} placeholder={placeholder} />\n <RACButton className=\"cim-combo-box-button\">\n <IconChevronDown />\n </RACButton>\n </RACGroup>\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 </RACComboBox>\n );\n}\n\n/**\n * Allows users to filter a collapsible list and select one item from it.\n *\n * See [combo box usage guidelines](https://ui.cimpress.io/components/combo-box)\n */\nconst _ComboBox = withStyleProps(forwardRef(ComboBox), 'ComboBox');\n\nexport { _ComboBox as ComboBox };\n\nfunction ComboBoxInput({\n isReadOnly,\n placeholder,\n}: {\n isReadOnly: boolean | undefined;\n placeholder: string | undefined;\n}) {\n const comboBoxState = useContext(RACComboBoxStateContext);\n\n return (\n <RACInput\n className={clsx('cim-combo-box-input', textStyle({ variant: 'body' }))}\n // Ensure the popover opens when the input is clicked.\n // By default, React Aria only opens the popover when the input is focused.\n onClick={() => !isReadOnly && comboBoxState!.open()}\n placeholder={placeholder}\n />\n );\n}\n\nfunction ComboBoxList<T extends CollectionItem = CollectionItem>({\n items,\n children,\n isLoading,\n onLoadMore,\n onScroll,\n}: Pick<ComboBoxProps<T>, 'items' | 'children' | 'onScroll'> & {\n isLoading: ComboBoxProps['UNSTABLE_isLoading'];\n onLoadMore: ComboBoxProps['UNSTABLE_onLoadMore'];\n}) {\n const comboBoxState = useContext(RACComboBoxStateContext);\n const collectionMessages = useLocalizedMessages('UNSTABLE_collection');\n\n usePreventScroll({ isDisabled: !comboBoxState?.isOpen });\n\n return (\n <RACListBox\n className=\"cim-combo-box-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\nexport interface ComboBoxItemProps<T extends CollectionItem>\n extends Pick<RACListBoxItemProps<T>, 'id' | 'isDisabled' | 'onHoverStart' | 'onHoverEnd'> {\n /** The content to display as the label. */\n children: StringLikeChildren;\n}\n\n/** Renders a single list item within `ComboBox`. */\nexport function ComboBoxItem<T extends CollectionItem>({ children, ...props }: ComboBoxItemProps<T>) {\n const textValue =\n typeof children === 'string' ? children : typeof children === 'number' ? String(children) : children.join('');\n\n return (\n <RACListBoxItem {...props} className=\"cim-combo-box-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\nComboBoxItem.displayName = 'ComboBoxItem';\n\nexport interface ComboBoxSectionProps<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 `ComboBox` into a section. */\nexport function ComboBoxSection<T extends CollectionItem>({\n title,\n children,\n items,\n ...props\n}: ComboBoxSectionProps<T>) {\n if (!isProduction() && items != null && typeof children !== 'function') {\n console.warn('`ComboBoxSection` requires `children` to be a function when using `items` prop');\n }\n\n return (\n <RACListBoxSection {...props} className=\"cim-combo-box-section\">\n <RACHeader\n className={clsx('cim-combo-box-section-header', textStyle({ variant: 'small-semibold', tone: 'subtle' }))}\n >\n {title}\n </RACHeader>\n <RACCollection items={items}>{children}</RACCollection>\n </RACListBoxSection>\n );\n}\n\nComboBoxSection.displayName = 'ComboBoxSection';\n"]}
|
|
@@ -8,10 +8,15 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
8
8
|
const clsx_1 = __importDefault(require("clsx"));
|
|
9
9
|
const react_aria_components_1 = require("react-aria-components");
|
|
10
10
|
const index_js_1 = require("../../../icons/index.js");
|
|
11
|
+
const ICON_MAP = {
|
|
12
|
+
standard: index_js_1.IconCloseBold,
|
|
13
|
+
circled: index_js_1.IconCloseCircle,
|
|
14
|
+
};
|
|
11
15
|
/**
|
|
12
16
|
* @internal
|
|
13
17
|
*/
|
|
14
|
-
function XButton({ size = 'medium', variant = 'square', UNSAFE_className, UNSAFE_style, ...props }) {
|
|
15
|
-
|
|
18
|
+
function XButton({ size = 'medium', variant = 'square', iconType = 'standard', UNSAFE_className, UNSAFE_style, ...props }) {
|
|
19
|
+
const Icon = ICON_MAP[iconType];
|
|
20
|
+
return ((0, jsx_runtime_1.jsx)(react_aria_components_1.Button, { ...props, className: (0, clsx_1.default)('cim-x-button', UNSAFE_className), style: UNSAFE_style, "data-size": size, "data-variant": variant, children: (0, jsx_runtime_1.jsx)(Icon, {}) }));
|
|
16
21
|
}
|
|
17
22
|
//# sourceMappingURL=x-button.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"x-button.js","sourceRoot":"","sources":["../../../../../src/components/internal/x-button/x-button.tsx"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"x-button.js","sourceRoot":"","sources":["../../../../../src/components/internal/x-button/x-button.tsx"],"names":[],"mappings":";;;;;AAwBA,0BAqBC;;AA7CD,gDAAwB;AAExB,iEAAgG;AAChG,sDAAyE;AAazE,MAAM,QAAQ,GAAqF;IACjG,QAAQ,EAAE,wBAAa;IACvB,OAAO,EAAE,0BAAe;CACzB,CAAC;AAEF;;GAEG;AACH,SAAgB,OAAO,CAAC,EACtB,IAAI,GAAG,QAAQ,EACf,OAAO,GAAG,QAAQ,EAClB,QAAQ,GAAG,UAAU,EACrB,gBAAgB,EAChB,YAAY,EACZ,GAAG,KAAK,EACK;IACb,MAAM,IAAI,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAEhC,OAAO,CACL,uBAAC,8BAAS,OACJ,KAAK,EACT,SAAS,EAAE,IAAA,cAAI,EAAC,cAAc,EAAE,gBAAgB,CAAC,EACjD,KAAK,EAAE,YAAY,eACR,IAAI,kBACD,OAAO,YAErB,uBAAC,IAAI,KAAG,GACE,CACb,CAAC;AACJ,CAAC","sourcesContent":["import clsx from 'clsx';\nimport type { JSX } from 'react';\nimport { type ButtonProps as RACButtonProps, Button as RACButton } from 'react-aria-components';\nimport { IconCloseBold, IconCloseCircle } from '../../../icons/index.js';\nimport type { CommonProps, IconProps } from '../../types.js';\n\ninterface XButtonProps extends CommonProps, Pick<RACButtonProps, 'isDisabled' | 'onPress' | 'slot'> {\n 'aria-label': string;\n /** @default 'medium' */\n size?: 'small' | 'medium';\n /** @default 'square' */\n variant?: 'circle' | 'square';\n /** @default 'standard' */\n iconType?: 'standard' | 'circled';\n}\n\nconst ICON_MAP: Record<NonNullable<XButtonProps['iconType']>, (props: IconProps) => JSX.Element> = {\n standard: IconCloseBold,\n circled: IconCloseCircle,\n};\n\n/**\n * @internal\n */\nexport function XButton({\n size = 'medium',\n variant = 'square',\n iconType = 'standard',\n UNSAFE_className,\n UNSAFE_style,\n ...props\n}: XButtonProps) {\n const Icon = ICON_MAP[iconType];\n\n return (\n <RACButton\n {...props}\n className={clsx('cim-x-button', UNSAFE_className)}\n style={UNSAFE_style}\n data-size={size}\n data-variant={variant}\n >\n <Icon />\n </RACButton>\n );\n}\n"]}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.LinkPagination = LinkPagination;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const focus_1 = require("@react-aria/focus");
|
|
6
5
|
const utils_1 = require("@react-aria/utils");
|
|
7
6
|
const react_1 = require("react");
|
|
8
7
|
const router_provider_js_1 = require("../../providers/router/router-provider.js");
|
|
@@ -34,11 +33,11 @@ hrefLang, target, download, ping, referrerPolicy, rel, routerOptions, ...props }
|
|
|
34
33
|
const element = listRef.current.querySelector(`[href='${path}']${paginationPrevious ? '[data-previous]' : ':not([data-previous])'}${paginationNext ? '[data-next]' : ':not([data-next])'}`);
|
|
35
34
|
if (paginationPrevious && currentPage === 2) {
|
|
36
35
|
// "Previous" link will become disabled, so move focus to the first page link
|
|
37
|
-
|
|
36
|
+
listRef.current?.querySelector(`[href][data-first]`)?.focus();
|
|
38
37
|
}
|
|
39
38
|
else if (paginationNext && currentPage === pageCount - 1) {
|
|
40
39
|
// "Next" link will become disabled, so move focus to the last page link
|
|
41
|
-
|
|
40
|
+
listRef.current?.querySelector(`[href][data-last]`)?.focus();
|
|
42
41
|
}
|
|
43
42
|
onPageChange?.(Number(element.dataset.page));
|
|
44
43
|
// We don't have access to the modifiers of the original event.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link-pagination.js","sourceRoot":"","sources":["../../../../src/components/pagination/link-pagination.tsx"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"link-pagination.js","sourceRoot":"","sources":["../../../../src/components/pagination/link-pagination.tsx"],"names":[],"mappings":";;AAyBA,wCAoHC;;AA7ID,6CAA8C;AAC9C,iCAA+D;AAC/D,kFAA2E;AAC3E,uEAA+D;AAC/D,6DAAsD;AAEtD,6DAAgF;AAkBhF,gBAAgB;AAChB,SAAgB,cAAc,CAAC,EAC7B,WAAW,EACX,SAAS,EACT,IAAI,EACJ,YAAY;AAEZ,mBAAmB;AACnB,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,IAAI,EACJ,cAAc,EACd,GAAG,EACH,aAAa,EAEb,GAAG,KAAK,EACY;IACpB,MAAM,MAAM,GAAG,IAAA,iBAAS,GAAE,CAAC;IAC3B,MAAM,OAAO,GAAG,IAAA,cAAM,EAAmB,IAAI,CAAC,CAAC;IAE/C,MAAM,eAAe,GAAG;QACtB,QAAQ;QACR,MAAM;QACN,QAAQ;QACR,IAAI;QACJ,cAAc;QACd,GAAG;QACH,aAAa;KACd,CAAC;IAEF,MAAM,qBAAqB,GAAG,I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W,EACxB,SAAS,EAAE,SAAS,EACpB,oBAAoB,EAAE,CAAC,mBAAmB,EAAE,EAAE,CAAC,CAC7C,uBAAC,oCAAc,OACT,eAAe,KACf,mBAAmB,EACvB,IAAI,EAAE,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC,EAC3B,aAAa,EACX;oBACE,GAAG,CAAC,eAAe,CAAC,aAAa,IAAI,EAAE,CAAC;oBACxC,0BAA0B,EAAE;wBAC1B,kBAAkB,EAAE,IAAI;qBACzB;iBAC0C,sCAGpC,WAAW,GAAG,CAAC,GAC1B,CACH,EACD,gBAAgB,EAAE,CAAC,eAAe,EAAE,EAAE,CAAC,CACrC,uBAAC,oCAAc,OACT,eAAe,KACf,eAAe,EACnB,IAAI,EAAE,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC,EAC3B,aAAa,EACX;oBACE,GAAG,CAAC,eAAe,CAAC,aAAa,IAAI,EAAE,CAAC;oBACxC,0BAA0B,EAAE;wBAC1B,cAAc,EAAE,IAAI;qBACrB;iBAC0C,kCAGpC,WAAW,GAAG,CAAC,GAC1B,CACH,EACD,gBAAgB,EAAE,CAAC,EAAE,UAAU,EAAE,aAAa,EAAE,eAAe,EAAE,EAAE,EAAE,CAAC,CACpE,uBAAC,2BAAU,OACL,eAAe,KACf,eAAe,kBACL,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,EAChD,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,eACX,UAAU,GACrB,CACH,GACD,GACa,CAClB,CAAC;AACJ,CAAC","sourcesContent":["import { useRouter } from '@react-aria/utils';\nimport { type ForwardedRef, useCallback, useRef } from 'react';\nimport { RouterProvider } from '../../providers/router/router-provider.js';\nimport { IconLinkButton } from '../button/icon-link-button.js';\nimport { LinkButton } from '../button/link-button.js';\nimport type { FocusableElement, Href, NavigationProps, RouterOptions } from '../types.js';\nimport { BasePagination, type BasePaginationProps } from './base-pagination.js';\n\ninterface PaginationRouterOptions {\n __INTERNAL__CIMPRESS__UI__?: {\n paginationPrevious?: boolean;\n paginationNext?: boolean;\n };\n}\n\n/** @internal */\nexport interface LinkPaginationProps extends BasePaginationProps, Omit<NavigationProps, 'href'> {\n navRef?: ForwardedRef<HTMLElement>;\n /** A callback function that is called when the page number changes. */\n onPageChange?: (page: number) => void;\n /** A function that returns a URL for a given page number. */\n href: (page: number) => string;\n}\n\n/** @internal */\nexport function LinkPagination({\n currentPage,\n pageCount,\n href,\n onPageChange,\n\n // Navigation props\n hrefLang,\n target,\n download,\n ping,\n referrerPolicy,\n rel,\n routerOptions,\n\n ...props\n}: LinkPaginationProps) {\n const router = useRouter();\n const listRef = useRef<HTMLUListElement>(null);\n\n const navigationProps = {\n hrefLang,\n target,\n download,\n ping,\n referrerPolicy,\n rel,\n routerOptions,\n };\n\n const navigationInterceptor = useCallback(\n (path: Href, routerOptions?: RouterOptions) => {\n // If navigation would cause the activated link to become disabled,\n // we have to move focus to a different link beforehand.\n\n if (!listRef.current) {\n return;\n }\n\n const { paginationPrevious, paginationNext } =\n (routerOptions as PaginationRouterOptions | undefined)?.__INTERNAL__CIMPRESS__UI__ ?? {};\n\n const element = listRef.current.querySelector(\n `[href='${path}']${paginationPrevious ? '[data-previous]' : ':not([data-previous])'}${paginationNext ? '[data-next]' : ':not([data-next])'}`,\n )!;\n\n if (paginationPrevious && currentPage === 2) {\n // \"Previous\" link will become disabled, so move focus to the first page link\n (listRef.current?.querySelector(`[href][data-first]`) as FocusableElement | undefined)?.focus();\n } else if (paginationNext && currentPage === pageCount - 1) {\n // \"Next\" link will become disabled, so move focus to the last page link\n (listRef.current?.querySelector(`[href][data-last]`) as FocusableElement | undefined)?.focus();\n }\n\n onPageChange?.(Number((element as HTMLElement).dataset.page));\n\n // We don't have access to the modifiers of the original event.\n // However, this function wouldn't run if the original modifiers impacted routing, so it is safe to pass an empty object.\n router.open(element, {}, path, routerOptions);\n },\n [router, currentPage, pageCount, onPageChange],\n );\n\n return (\n <RouterProvider navigate={navigationInterceptor}>\n <BasePagination\n {...props}\n listRef={listRef}\n currentPage={currentPage}\n pageCount={pageCount}\n renderPreviousButton={(previousButtonProps) => (\n <IconLinkButton\n {...navigationProps}\n {...previousButtonProps}\n href={href(currentPage - 1)}\n routerOptions={\n {\n ...(navigationProps.routerOptions ?? {}),\n __INTERNAL__CIMPRESS__UI__: {\n paginationPrevious: true,\n },\n } as PaginationRouterOptions as RouterOptions\n }\n data-previous\n data-page={currentPage - 1}\n />\n )}\n renderNextButton={(nextButtonProps) => (\n <IconLinkButton\n {...navigationProps}\n {...nextButtonProps}\n href={href(currentPage + 1)}\n routerOptions={\n {\n ...(navigationProps.routerOptions ?? {}),\n __INTERNAL__CIMPRESS__UI__: {\n paginationNext: true,\n },\n } as PaginationRouterOptions as RouterOptions\n }\n data-next\n data-page={currentPage + 1}\n />\n )}\n renderPageButton={({ pageNumber, isCurrentPage, pageButtonProps }) => (\n <LinkButton\n {...navigationProps}\n {...pageButtonProps}\n aria-current={isCurrentPage ? 'page' : undefined}\n href={href(pageNumber)}\n data-page={pageNumber}\n />\n )}\n />\n </RouterProvider>\n );\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../../src/components/stepper/context.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,WAAW;iBACT,MAAM;eACR,MAAM;eACN,MAAM,IAAI;EAIrB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StepContext = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
exports.StepContext = (0, react_1.createContext)({
|
|
6
|
+
currentStep: 0,
|
|
7
|
+
stepIndex: 0,
|
|
8
|
+
});
|
|
9
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../../src/components/stepper/context.ts"],"names":[],"mappings":";;;AAAA,iCAAsC;AAEzB,QAAA,WAAW,GAAG,IAAA,qBAAa,EAIrC;IACD,WAAW,EAAE,CAAC;IACd,SAAS,EAAE,CAAC;CACb,CAAC,CAAC","sourcesContent":["import { createContext } from 'react';\n\nexport const StepContext = createContext<{\n currentStep: number;\n stepIndex: number;\n onChange?: () => void;\n}>({\n currentStep: 0,\n stepIndex: 0,\n});\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { CommonProps } from '../types.js';
|
|
2
|
+
import type { StepperStatus } from './types.js';
|
|
3
|
+
export interface UNSTABLE_StepperItemProps extends CommonProps {
|
|
4
|
+
/** The title of the step. */
|
|
5
|
+
title: string;
|
|
6
|
+
/** The description of the step. */
|
|
7
|
+
description?: string;
|
|
8
|
+
/** The status of the step. */
|
|
9
|
+
status?: StepperStatus;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Represents a single step in a stepper component.
|
|
13
|
+
*/
|
|
14
|
+
declare const _UNSTABLE_StepperItem: (props: UNSTABLE_StepperItemProps & import("react").RefAttributes<HTMLLIElement> & import("../../with-style-props.js").StyleProps) => import("react").JSX.Element | null;
|
|
15
|
+
export { _UNSTABLE_StepperItem as UNSTABLE_StepperItem };
|
|
16
|
+
//# sourceMappingURL=stepper-item.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stepper-item.d.ts","sourceRoot":"","sources":["../../../../src/components/stepper/stepper-item.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,MAAM,WAAW,yBAA0B,SAAQ,WAAW;IAC5D,6BAA6B;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,mCAAmC;IACnC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,8BAA8B;IAC9B,MAAM,CAAC,EAAE,aAAa,CAAC;CACxB;AAmED;;GAEG;AACH,QAAA,MAAM,qBAAqB,0KAAkE,CAAC;AAE9F,OAAO,EAAE,qBAAqB,IAAI,oBAAoB,EAAE,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.UNSTABLE_StepperItem = void 0;
|
|
8
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
9
|
+
const clsx_1 = __importDefault(require("clsx"));
|
|
10
|
+
const react_1 = require("react");
|
|
11
|
+
const react_aria_1 = require("react-aria");
|
|
12
|
+
const forward_ref_js_1 = require("../../forward-ref.js");
|
|
13
|
+
const index_js_1 = require("../../icons/index.js");
|
|
14
|
+
const with_style_props_js_1 = require("../../with-style-props.js");
|
|
15
|
+
const text_js_1 = require("../typography/text.js");
|
|
16
|
+
const context_js_1 = require("./context.js");
|
|
17
|
+
function UNSTABLE_StepperItem({ title, description, status: overrideStatus, UNSAFE_className, UNSAFE_style, ...props }, ref) {
|
|
18
|
+
const labelId = (0, react_aria_1.useId)();
|
|
19
|
+
const { currentStep, stepIndex, onChange } = (0, react_1.useContext)(context_js_1.StepContext);
|
|
20
|
+
const isCurrent = stepIndex === currentStep;
|
|
21
|
+
const isPrevious = stepIndex < currentStep;
|
|
22
|
+
const status = overrideStatus ?? (isCurrent ? 'in-progress' : isPrevious ? 'complete' : undefined);
|
|
23
|
+
const isNavigable = !isCurrent && onChange && (status != null || isPrevious);
|
|
24
|
+
const titleElement = ((0, jsx_runtime_1.jsx)(text_js_1.Text, { id: labelId, as: "span", variant: isCurrent ? 'body-semibold' : 'body', UNSAFE_className: "cim-stepper-item-title", children: title }));
|
|
25
|
+
const iconElement = ((0, jsx_runtime_1.jsx)("div", { className: "cim-stepper-item-icon", children: status && (0, jsx_runtime_1.jsx)(StepperItemIcon, { status: status, isCurrent: isCurrent }) }));
|
|
26
|
+
return ((0, jsx_runtime_1.jsxs)("li", { ...props, ref: ref, className: (0, clsx_1.default)('cim-stepper-item', UNSAFE_className), style: UNSAFE_style, "data-status": status, "aria-current": isCurrent, children: [(0, jsx_runtime_1.jsxs)("div", { className: "cim-stepper-item-icon-container", children: [isNavigable ? ((0, jsx_runtime_1.jsx)("button", { className: "cim-stepper-item-icon-button", type: "button", onClick: onChange, "aria-labelledby": labelId, children: iconElement })) : (iconElement), (0, jsx_runtime_1.jsx)("div", { className: "cim-stepper-item-tail" })] }), (0, jsx_runtime_1.jsxs)("div", { className: "cim-stepper-item-content", children: [isNavigable ? ((0, jsx_runtime_1.jsx)("button", { className: "cim-stepper-item-title-button", type: "button", onClick: onChange, tabIndex: -1, children: titleElement })) : (titleElement), description && ((0, jsx_runtime_1.jsx)(text_js_1.Text, { as: "div", UNSAFE_className: "cim-stepper-item-description", variant: "medium", tone: "muted", children: description }))] })] }));
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Represents a single step in a stepper component.
|
|
30
|
+
*/
|
|
31
|
+
const _UNSTABLE_StepperItem = (0, with_style_props_js_1.withStyleProps)((0, forward_ref_js_1.forwardRef)(UNSTABLE_StepperItem), 'StepperItem');
|
|
32
|
+
exports.UNSTABLE_StepperItem = _UNSTABLE_StepperItem;
|
|
33
|
+
const statusToIcon = {
|
|
34
|
+
complete: index_js_1.IconCheckBold,
|
|
35
|
+
// TODO: replace with icon from library when available
|
|
36
|
+
error: () => ((0, jsx_runtime_1.jsxs)("svg", { width: "32", height: "32", viewBox: "0 0 32 32", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [(0, jsx_runtime_1.jsx)("path", { d: "M24.1421 21.1421C24.9232 21.9232 24.9232 23.1895 24.1421 23.9706C23.3611 24.7516 22.0948 24.7516 21.3137 23.9706L8.58579 11.2426C7.80474 10.4616 7.80474 9.19526 8.58579 8.41421C9.36684 7.63316 10.6332 7.63316 11.4142 8.41421L24.1421 21.1421Z", fill: "currentColor" }), (0, jsx_runtime_1.jsx)("path", { d: "M21.1421 8.85786C21.9232 8.07682 23.1895 8.07682 23.9706 8.85786C24.7516 9.63891 24.7516 10.9052 23.9706 11.6863L11.2426 24.4142C10.4616 25.1953 9.19526 25.1953 8.41421 24.4142C7.63316 23.6332 7.63316 22.3668 8.41421 21.5858L21.1421 8.85786Z", fill: "currentColor" })] })),
|
|
37
|
+
// TODO: replace with icon from library when available
|
|
38
|
+
warning: () => ((0, jsx_runtime_1.jsxs)("svg", { width: "32", height: "32", viewBox: "0 0 32 32", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [(0, jsx_runtime_1.jsx)("path", { d: "M18 24C18 25.1046 17.1046 26 16 26C14.8954 26 14 25.1046 14 24C14 22.8954 14.8954 22 16 22C17.1046 22 18 22.8954 18 24Z", fill: "currentColor" }), (0, jsx_runtime_1.jsx)("line", { x1: "16", y1: "8", x2: "16", y2: "18", stroke: "currentColor", strokeWidth: "4", strokeLinecap: "round" })] })),
|
|
39
|
+
'in-progress': index_js_1.IconCircleBoldFill,
|
|
40
|
+
};
|
|
41
|
+
// eslint-disable-next-line react-refresh/only-export-components
|
|
42
|
+
function StepperItemIcon({ status, isCurrent }) {
|
|
43
|
+
const Icon = statusToIcon[status];
|
|
44
|
+
if (status === 'in-progress' && !isCurrent) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
return (0, jsx_runtime_1.jsx)(Icon, { "aria-hidden": true });
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=stepper-item.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stepper-item.js","sourceRoot":"","sources":["../../../../src/components/stepper/stepper-item.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;AAEb,gDAAwB;AACxB,iCAAsD;AACtD,2CAAmC;AACnC,yDAAk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OAAO,EAAE,GAAG,EAAE,CAAC,CACb,iCAAK,KAAK,EAAC,IAAI,EAAC,MAAM,EAAC,IAAI,EAAC,OAAO,EAAC,WAAW,EAAC,IAAI,EAAC,MAAM,EAAC,KAAK,EAAC,4BAA4B,aAC5F,iCACE,CAAC,EAAC,yHAAyH,EAC3H,IAAI,EAAC,cAAc,GACnB,EACF,iCAAM,EAAE,EAAC,IAAI,EAAC,EAAE,EAAC,GAAG,EAAC,EAAE,EAAC,IAAI,EAAC,EAAE,EAAC,IAAI,EAAC,MAAM,EAAC,cAAc,EAAC,WAAW,EAAC,GAAG,EAAC,aAAa,EAAC,OAAO,GAAG,IAC/F,CACP;IACD,aAAa,EAAE,6BAAkB;CAClC,CAAC;AAEF,gEAAgE;AAChE,SAAS,eAAe,CAAC,EAAE,MAAM,EAAE,SAAS,EAAiD;IAC3F,MAAM,IAAI,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;IAElC,IAAI,MAAM,KAAK,aAAa,IAAI,CAAC,SAAS,EAAE,CAAC;QAC3C,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,uBAAC,IAAI,0BAAe,CAAC;AAC9B,CAAC","sourcesContent":["'use client';\n\nimport clsx from 'clsx';\nimport { useContext, type ForwardedRef } from 'react';\nimport { useId } from 'react-aria';\nimport { forwardRef } from '../../forward-ref.js';\nimport { IconCheckBold, IconCircleBoldFill } from '../../icons/index.js';\nimport { withStyleProps } from '../../with-style-props.js';\nimport type { CommonProps } from '../types.js';\nimport { Text } from '../typography/text.js';\nimport { StepContext } from './context.js';\nimport type { StepperStatus } from './types.js';\n\nexport interface UNSTABLE_StepperItemProps extends CommonProps {\n /** The title of the step. */\n title: string;\n /** The description of the step. */\n description?: string;\n /** The status of the step. */\n status?: StepperStatus;\n}\n\nfunction UNSTABLE_StepperItem(\n { title, description, status: overrideStatus, UNSAFE_className, UNSAFE_style, ...props }: UNSTABLE_StepperItemProps,\n ref: ForwardedRef<HTMLLIElement>,\n) {\n const labelId = useId();\n\n const { currentStep, stepIndex, onChange } = useContext(StepContext);\n const isCurrent = stepIndex === currentStep;\n const isPrevious = stepIndex < currentStep;\n\n const status = overrideStatus ?? (isCurrent ? 'in-progress' : isPrevious ? 'complete' : undefined);\n\n const isNavigable = !isCurrent && onChange && (status != null || isPrevious);\n\n const titleElement = (\n <Text\n id={labelId}\n as=\"span\"\n variant={isCurrent ? 'body-semibold' : 'body'}\n UNSAFE_className=\"cim-stepper-item-title\"\n >\n {title}\n </Text>\n );\n const iconElement = (\n <div className=\"cim-stepper-item-icon\">{status && <StepperItemIcon status={status} isCurrent={isCurrent} />}</div>\n );\n\n return (\n <li\n {...props}\n ref={ref}\n className={clsx('cim-stepper-item', UNSAFE_className)}\n style={UNSAFE_style}\n data-status={status}\n aria-current={isCurrent}\n >\n <div className=\"cim-stepper-item-icon-container\">\n {isNavigable ? (\n <button className=\"cim-stepper-item-icon-button\" type=\"button\" onClick={onChange} aria-labelledby={labelId}>\n {iconElement}\n </button>\n ) : (\n iconElement\n )}\n <div className=\"cim-stepper-item-tail\" />\n </div>\n <div className=\"cim-stepper-item-content\">\n {isNavigable ? (\n <button className=\"cim-stepper-item-title-button\" type=\"button\" onClick={onChange} tabIndex={-1}>\n {titleElement}\n </button>\n ) : (\n titleElement\n )}\n {description && (\n <Text as=\"div\" UNSAFE_className=\"cim-stepper-item-description\" variant=\"medium\" tone=\"muted\">\n {description}\n </Text>\n )}\n </div>\n </li>\n );\n}\n\n/**\n * Represents a single step in a stepper component.\n */\nconst _UNSTABLE_StepperItem = withStyleProps(forwardRef(UNSTABLE_StepperItem), 'StepperItem');\n\nexport { _UNSTABLE_StepperItem as UNSTABLE_StepperItem };\n\nconst statusToIcon = {\n complete: IconCheckBold,\n // TODO: replace with icon from library when available\n error: () => (\n <svg width=\"32\" height=\"32\" viewBox=\"0 0 32 32\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n d=\"M24.1421 21.1421C24.9232 21.9232 24.9232 23.1895 24.1421 23.9706C23.3611 24.7516 22.0948 24.7516 21.3137 23.9706L8.58579 11.2426C7.80474 10.4616 7.80474 9.19526 8.58579 8.41421C9.36684 7.63316 10.6332 7.63316 11.4142 8.41421L24.1421 21.1421Z\"\n fill=\"currentColor\"\n />\n <path\n d=\"M21.1421 8.85786C21.9232 8.07682 23.1895 8.07682 23.9706 8.85786C24.7516 9.63891 24.7516 10.9052 23.9706 11.6863L11.2426 24.4142C10.4616 25.1953 9.19526 25.1953 8.41421 24.4142C7.63316 23.6332 7.63316 22.3668 8.41421 21.5858L21.1421 8.85786Z\"\n fill=\"currentColor\"\n />\n </svg>\n ),\n // TODO: replace with icon from library when available\n warning: () => (\n <svg width=\"32\" height=\"32\" viewBox=\"0 0 32 32\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n d=\"M18 24C18 25.1046 17.1046 26 16 26C14.8954 26 14 25.1046 14 24C14 22.8954 14.8954 22 16 22C17.1046 22 18 22.8954 18 24Z\"\n fill=\"currentColor\"\n />\n <line x1=\"16\" y1=\"8\" x2=\"16\" y2=\"18\" stroke=\"currentColor\" strokeWidth=\"4\" strokeLinecap=\"round\" />\n </svg>\n ),\n 'in-progress': IconCircleBoldFill,\n};\n\n// eslint-disable-next-line react-refresh/only-export-components\nfunction StepperItemIcon({ status, isCurrent }: { status: StepperStatus; isCurrent: boolean }) {\n const Icon = statusToIcon[status];\n\n if (status === 'in-progress' && !isCurrent) {\n return null;\n }\n\n return <Icon aria-hidden />;\n}\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import type { CommonProps } from '../types.js';
|
|
3
|
+
export interface UNSTABLE_StepperProps extends CommonProps {
|
|
4
|
+
/** The steps to display in the stepper. */
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
/** The index of the active step. */
|
|
7
|
+
currentStep?: number;
|
|
8
|
+
/** The callback to call when the current step changes. */
|
|
9
|
+
onChange?: (step: number) => void;
|
|
10
|
+
/** The orientation of the stepper.
|
|
11
|
+
*
|
|
12
|
+
* @default 'horizontal'
|
|
13
|
+
*/
|
|
14
|
+
orientation?: 'vertical' | 'horizontal';
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Displays a series of steps in a process.
|
|
18
|
+
*/
|
|
19
|
+
declare const _UNSTABLE_Stepper: (props: UNSTABLE_StepperProps & import("react").RefAttributes<HTMLOListElement> & import("../../with-style-props.js").StyleProps) => import("react").JSX.Element | null;
|
|
20
|
+
export { _UNSTABLE_Stepper as UNSTABLE_Stepper };
|
|
21
|
+
//# sourceMappingURL=stepper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stepper.d.ts","sourceRoot":"","sources":["../../../../src/components/stepper/stepper.tsx"],"names":[],"mappings":"AAGA,OAAO,EAA+B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAGpE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/C,MAAM,WAAW,qBAAsB,SAAQ,WAAW;IACxD,2CAA2C;IAC3C,QAAQ,EAAE,SAAS,CAAC;IACpB,oCAAoC;IACpC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC;;;OAGG;IACH,WAAW,CAAC,EAAE,UAAU,GAAG,YAAY,CAAC;CACzC;AAyCD;;GAEG;AACH,QAAA,MAAM,iBAAiB,yKAA0D,CAAC;AAElF,OAAO,EAAE,iBAAiB,IAAI,gBAAgB,EAAE,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.UNSTABLE_Stepper = void 0;
|
|
8
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
9
|
+
const clsx_1 = __importDefault(require("clsx"));
|
|
10
|
+
const react_1 = require("react");
|
|
11
|
+
const forward_ref_js_1 = require("../../forward-ref.js");
|
|
12
|
+
const with_style_props_js_1 = require("../../with-style-props.js");
|
|
13
|
+
const context_js_1 = require("./context.js");
|
|
14
|
+
function UNSTABLE_Stepper({ children, currentStep, onChange, orientation = 'horizontal', UNSAFE_className, UNSAFE_style, ...props }, ref) {
|
|
15
|
+
return ((0, jsx_runtime_1.jsx)("ol", { ...props, ref: ref, className: (0, clsx_1.default)('cim-stepper', UNSAFE_className), style: UNSAFE_style, "data-orientation": orientation, children: react_1.Children.map(children, (child, stepIndex) => ((0, jsx_runtime_1.jsx)(context_js_1.StepContext.Provider, { value: {
|
|
16
|
+
currentStep: currentStep ?? -1,
|
|
17
|
+
stepIndex,
|
|
18
|
+
onChange: onChange &&
|
|
19
|
+
(() => {
|
|
20
|
+
onChange(stepIndex);
|
|
21
|
+
}),
|
|
22
|
+
}, children: child }))) }));
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Displays a series of steps in a process.
|
|
26
|
+
*/
|
|
27
|
+
const _UNSTABLE_Stepper = (0, with_style_props_js_1.withStyleProps)((0, forward_ref_js_1.forwardRef)(UNSTABLE_Stepper), 'Stepper');
|
|
28
|
+
exports.UNSTABLE_Stepper = _UNSTABLE_Stepper;
|
|
29
|
+
//# sourceMappingURL=stepper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stepper.js","sourceRoot":"","sources":["../../../../src/components/stepper/stepper.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;AAEb,gDAAwB;AACxB,iCAAoE;AACpE,yDAAkD;AAClD,mEAA2D;AAE3D,6CAA2C;AAgB3C,SAAS,gBAAgB,CACvB,EACE,QAAQ,EACR,WAAW,EACX,QAAQ,EACR,WAAW,GAAG,YAAY,EAC1B,gBAAgB,EAChB,YAAY,EACZ,GAAG,KAAK,EACc,EACxB,GAAmC;IAEnC,OAAO,CACL,kCACM,KAAK,EACT,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,IAAA,cAAI,EAAC,aAAa,EAAE,gBAAgB,CAAC,EAChD,KAAK,EAAE,YAAY,sBACD,WAAW,YAE5B,gBAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE,CAAC,CAC5C,uBAAC,wBAAW,CAAC,QAAQ,IACnB,KAAK,EAAE;gBACL,WAAW,EAAE,WAAW,IAAI,CAAC,CAAC;gBAC9B,SAAS;gBACT,QAAQ,EACN,QAAQ;oBACR,CAAC,GAAG,EAAE;wBACJ,QAAQ,CAAC,SAAS,CAAC,CAAC;oBACtB,CAAC,CAAC;aACL,YAEA,KAAK,GACe,CACxB,CAAC,GACC,CACN,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,iBAAiB,GAAG,IAAA,oCAAc,EAAC,IAAA,2BAAU,EAAC,gBAAgB,CAAC,EAAE,SAAS,CAAC,CAAC;AAEpD,6CAAgB","sourcesContent":["'use client';\n\nimport clsx from 'clsx';\nimport { Children, type ForwardedRef, type ReactNode } from 'react';\nimport { forwardRef } from '../../forward-ref.js';\nimport { withStyleProps } from '../../with-style-props.js';\nimport type { CommonProps } from '../types.js';\nimport { StepContext } from './context.js';\n\nexport interface UNSTABLE_StepperProps extends CommonProps {\n /** The steps to display in the stepper. */\n children: ReactNode;\n /** The index of the active step. */\n currentStep?: number;\n /** The callback to call when the current step changes. */\n onChange?: (step: number) => void;\n /** The orientation of the stepper.\n *\n * @default 'horizontal'\n */\n orientation?: 'vertical' | 'horizontal';\n}\n\nfunction UNSTABLE_Stepper(\n {\n children,\n currentStep,\n onChange,\n orientation = 'horizontal',\n UNSAFE_className,\n UNSAFE_style,\n ...props\n }: UNSTABLE_StepperProps,\n ref: ForwardedRef<HTMLOListElement>,\n) {\n return (\n <ol\n {...props}\n ref={ref}\n className={clsx('cim-stepper', UNSAFE_className)}\n style={UNSAFE_style}\n data-orientation={orientation}\n >\n {Children.map(children, (child, stepIndex) => (\n <StepContext.Provider\n value={{\n currentStep: currentStep ?? -1,\n stepIndex,\n onChange:\n onChange &&\n (() => {\n onChange(stepIndex);\n }),\n }}\n >\n {child}\n </StepContext.Provider>\n ))}\n </ol>\n );\n}\n\n/**\n * Displays a series of steps in a process.\n */\nconst _UNSTABLE_Stepper = withStyleProps(forwardRef(UNSTABLE_Stepper), 'Stepper');\n\nexport { _UNSTABLE_Stepper as UNSTABLE_Stepper };\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/components/stepper/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG,UAAU,GAAG,OAAO,GAAG,SAAS,GAAG,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/components/stepper/types.ts"],"names":[],"mappings":"","sourcesContent":["export type StepperStatus = 'complete' | 'error' | 'warning' | 'in-progress';\n"]}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.TagFieldListBox = TagFieldListBox;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
|
+
const react_aria_1 = require("react-aria");
|
|
6
7
|
const react_aria_components_1 = require("react-aria-components");
|
|
7
8
|
const VIRTUAL_LAYOUT_OPTIONS = {
|
|
8
9
|
rowHeight: 36,
|
|
@@ -12,7 +13,9 @@ const VIRTUAL_LAYOUT_OPTIONS = {
|
|
|
12
13
|
};
|
|
13
14
|
/** @internal */
|
|
14
15
|
function TagFieldListBox({ children, inputId, selectedKeys, setSelectedKeys, items, onScroll, isVirtualized, }) {
|
|
16
|
+
const comboBoxState = (0, react_1.useContext)(react_aria_components_1.ComboBoxStateContext);
|
|
15
17
|
const listState = (0, react_1.useContext)(react_aria_components_1.ListStateContext);
|
|
18
|
+
(0, react_aria_1.usePreventScroll)({ isDisabled: !comboBoxState?.isOpen });
|
|
16
19
|
// Override RACListStateContext to allow multiple selection within the list
|
|
17
20
|
const updatedListState = (0, react_1.useMemo)(() => {
|
|
18
21
|
if (!listState || !listState.selectionManager) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tag-field-list-box.js","sourceRoot":"","sources":["../../../../src/components/tag-field/tag-field-list-box.tsx"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"tag-field-list-box.js","sourceRoot":"","sources":["../../../../src/components/tag-field/tag-field-list-box.tsx"],"names":[],"mappings":";;AAqBA,0CAmEC;;AAxFD,iCAA4C;AAC5C,2CAA8C;AAC9C,iEAO+B;AAI/B,MAAM,sBAAsB,GAAyB;IACnD,SAAS,EAAE,EAAE;IACb,aAAa,EAAE,EAAE;IACjB,OAAO,EAAE,CAAC;IACV,GAAG,EAAE,CAAC;CACP,CAAC;AAEF,gBAAgB;AAChB,SAAgB,eAAe,CAA2B,EACxD,QAAQ,EACR,OAAO,EACP,YAAY,EACZ,eAAe,EACf,KAAK,EACL,QAAQ,EACR,aAAa,GAKd;IACC,MAAM,aAAa,GAAG,IAAA,kBAAU,EAAC,4CAAuB,CAAC,CAAC;IAC1D,MAAM,SAAS,GAAG,IAAA,kBAAU,EAAC,wCAAmB,CAAC,CAAC;IAElD,IAAA,6BAAgB,EAAC,EAAE,UAAU,EAAE,CAAC,aAAa,EAAE,MAAM,EAAE,CAAC,CAAC;IAEzD,2EAA2E;IAC3E,MAAM,gBAAgB,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE;QACpC,IAAI,CAAC,SAAS,IAAI,CAAC,SAAS,CAAC,gBAAgB,EAAE,CAAC;YAC9C,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,uDAAuD;QACvD,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ateContext as RACComboBoxStateContext,\n ListBox as RACListBox,\n ListLayout as RACListLayout,\n type ListLayoutOptions as RACListLayoutOptions,\n ListStateContext as RACListStateContext,\n Virtualizer as RACVirtualizer,\n} from 'react-aria-components';\nimport type { CollectionItem, Key } from '../types.js';\nimport type { TagFieldProps } from './tag-field.js';\n\nconst VIRTUAL_LAYOUT_OPTIONS: RACListLayoutOptions = {\n rowHeight: 36,\n headingHeight: 32,\n padding: 0,\n gap: 0,\n};\n\n/** @internal */\nexport function TagFieldListBox<T extends CollectionItem>({\n children,\n inputId,\n selectedKeys,\n setSelectedKeys,\n items,\n onScroll,\n isVirtualized,\n}: Pick<TagFieldProps<T>, 'children' | 'items' | 'onScroll' | 'isVirtualized'> & {\n inputId: string;\n selectedKeys: Set<Key>;\n setSelectedKeys: (keys: Set<Key>) => void;\n}) {\n const comboBoxState = useContext(RACComboBoxStateContext);\n const listState = useContext(RACListStateContext);\n\n usePreventScroll({ isDisabled: !comboBoxState?.isOpen });\n\n // Override RACListStateContext to allow multiple selection within the list\n const updatedListState = useMemo(() => {\n if (!listState || !listState.selectionManager) {\n return listState;\n }\n\n // @ts-expect-error `selectionManager.state` is private\n // This is a temporary mutation before a context update, so this is fine\n // eslint-disable-next-line react-hooks/react-compiler\n listState.selectionManager.state.selectionMode = 'multiple';\n // @ts-expect-error `selectionManager.state` is private\n listState.selectionManager.state.selectedKeys = selectedKeys;\n // @ts-expect-error `selectionManager.state` is private\n listState.selectionManager.state.setSelectedKeys = (keys: Set<Key> | 'all') => {\n if (keys === 'all') {\n // When the end-user presses Ctrl/Cmd + A on a list which has `selectionMode` set to `'multiple'`,\n // the selection manager emits the `'all'` string as an indication to select all items.\n // We don't want to do that - instead, we select the contents of the input field.\n // Querying by ID because RACInputContext has a null ref for some reason.\n (document.getElementById(inputId) as HTMLInputElement | null)?.select();\n } else {\n setSelectedKeys(keys);\n }\n };\n // @ts-expect-error `selectionManager.state` is private\n listState.selectionManager.state.disallowEmptySelection = false;\n\n return {\n ...listState,\n };\n }, [listState, selectedKeys, setSelectedKeys, inputId]);\n\n const listBox = (\n <RACListBox className=\"cim-combo-box-listbox\" onScroll={onScroll} items={items}>\n {children}\n </RACListBox>\n );\n\n return (\n <RACListStateContext.Provider value={updatedListState}>\n {isVirtualized ? (\n <RACVirtualizer layout={RACListLayout} layoutOptions={VIRTUAL_LAYOUT_OPTIONS}>\n {listBox}\n </RACVirtualizer>\n ) : (\n listBox\n )}\n </RACListStateContext.Provider>\n );\n}\n"]}
|
|
@@ -24,7 +24,7 @@ export interface TagFieldProps<T extends CollectionItem = CollectionItem> extend
|
|
|
24
24
|
/**
|
|
25
25
|
* Allows users to filter a collapsible list and select multiple items from it.
|
|
26
26
|
*
|
|
27
|
-
* See [tag field usage guidelines](https://ui.cimpress.
|
|
27
|
+
* See [tag field usage guidelines](https://ui.cimpress.io/components/tag-field).
|
|
28
28
|
*/
|
|
29
29
|
declare const _TagField: <T extends CollectionItem>(props: TagFieldProps<T> & import("react").RefAttributes<HTMLDivElement> & import("../../with-style-props.js").StyleProps) => import("react").JSX.Element | null;
|
|
30
30
|
export { _TagField as TagField };
|
|
@@ -125,7 +125,7 @@ function TagField({ label, description, error, items, children, placeholder, UNS
|
|
|
125
125
|
/**
|
|
126
126
|
* Allows users to filter a collapsible list and select multiple items from it.
|
|
127
127
|
*
|
|
128
|
-
* See [tag field usage guidelines](https://ui.cimpress.
|
|
128
|
+
* See [tag field usage guidelines](https://ui.cimpress.io/components/tag-field).
|
|
129
129
|
*/
|
|
130
130
|
const _TagField = (0, with_style_props_js_1.withStyleProps)((0, forward_ref_js_1.forwardRef)(TagField), 'TagField');
|
|
131
131
|
exports.TagField = _TagField;
|