@cimpress-ui/react 1.20.0 → 1.22.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/app-header/side-nav.js +1 -1
- package/dist/commonjs/components/app-header/side-nav.js.map +1 -1
- package/dist/commonjs/components/breadcrumbs/breadcrumbs.d.ts.map +1 -1
- package/dist/commonjs/components/breadcrumbs/breadcrumbs.js +3 -2
- package/dist/commonjs/components/breadcrumbs/breadcrumbs.js.map +1 -1
- package/dist/commonjs/components/combo-box/combo-box.d.ts +7 -1
- package/dist/commonjs/components/combo-box/combo-box.d.ts.map +1 -1
- package/dist/commonjs/components/combo-box/combo-box.js +6 -2
- package/dist/commonjs/components/combo-box/combo-box.js.map +1 -1
- package/dist/commonjs/components/date-picker/views/view-grid-cell.js +5 -5
- package/dist/commonjs/components/date-picker/views/view-grid-cell.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 +4 -3
- package/dist/commonjs/components/file-picker/file-picker.js.map +1 -1
- package/dist/commonjs/components/internal/focusable-container/focusable-container.js +4 -4
- package/dist/commonjs/components/internal/focusable-container/focusable-container.js.map +1 -1
- package/dist/commonjs/components/link-tabs/link-tabs.d.ts.map +1 -1
- package/dist/commonjs/components/link-tabs/link-tabs.js +4 -4
- package/dist/commonjs/components/link-tabs/link-tabs.js.map +1 -1
- package/dist/commonjs/components/progress-bar/progress-bar.js +2 -2
- package/dist/commonjs/components/progress-bar/progress-bar.js.map +1 -1
- package/dist/commonjs/components/slider/slider.js +2 -2
- package/dist/commonjs/components/slider/slider.js.map +1 -1
- package/dist/commonjs/components/table/contexts/table-state.d.ts.map +1 -1
- package/dist/commonjs/components/table/contexts/table-state.js +2 -1
- package/dist/commonjs/components/table/contexts/table-state.js.map +1 -1
- package/dist/commonjs/components/table/hooks/use-table-cell.d.ts.map +1 -1
- package/dist/commonjs/components/table/hooks/use-table-cell.js +3 -2
- package/dist/commonjs/components/table/hooks/use-table-cell.js.map +1 -1
- package/dist/commonjs/components/table/hooks/use-table.d.ts.map +1 -1
- package/dist/commonjs/components/table/hooks/use-table.js +4 -3
- package/dist/commonjs/components/table/hooks/use-table.js.map +1 -1
- package/dist/commonjs/components/table/table-body-cell.d.ts.map +1 -1
- package/dist/commonjs/components/table/table-body-cell.js +3 -3
- package/dist/commonjs/components/table/table-body-cell.js.map +1 -1
- package/dist/commonjs/components/table/table-body-row.d.ts.map +1 -1
- package/dist/commonjs/components/table/table-body-row.js +2 -3
- package/dist/commonjs/components/table/table-body-row.js.map +1 -1
- package/dist/commonjs/components/table/table-empty-state.d.ts.map +1 -1
- package/dist/commonjs/components/table/table-empty-state.js +4 -4
- package/dist/commonjs/components/table/table-empty-state.js.map +1 -1
- package/dist/commonjs/components/table/table-header-cell.d.ts.map +1 -1
- package/dist/commonjs/components/table/table-header-cell.js +4 -4
- package/dist/commonjs/components/table/table-header-cell.js.map +1 -1
- package/dist/commonjs/components/table/table-header-row.d.ts.map +1 -1
- package/dist/commonjs/components/table/table-header-row.js +2 -2
- package/dist/commonjs/components/table/table-header-row.js.map +1 -1
- package/dist/commonjs/components/table/table.d.ts.map +1 -1
- package/dist/commonjs/components/table/table.js +3 -3
- package/dist/commonjs/components/table/table.js.map +1 -1
- package/dist/commonjs/components/tag-field/tag-field-input.js +8 -15
- package/dist/commonjs/components/tag-field/tag-field-input.js.map +1 -1
- package/dist/commonjs/components/tag-field/tag-field-list-box.js +2 -36
- 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.d.ts.map +1 -1
- package/dist/commonjs/components/tag-field/tag-field.js +17 -92
- package/dist/commonjs/components/tag-field/tag-field.js.map +1 -1
- package/dist/commonjs/components/text-inputs/text-field.js +4 -4
- package/dist/commonjs/components/text-inputs/text-field.js.map +1 -1
- package/dist/commonjs/components/toggle-button/internal-toggle-button.d.ts.map +1 -1
- package/dist/commonjs/components/toggle-button/internal-toggle-button.js +2 -1
- package/dist/commonjs/components/toggle-button/internal-toggle-button.js.map +1 -1
- package/dist/commonjs/components/typography/link.d.ts +1 -1
- package/dist/commonjs/components/typography/link.d.ts.map +1 -1
- package/dist/commonjs/components/typography/link.js.map +1 -1
- package/dist/commonjs/icons/{unstable-expand.d.ts → bookmark-fill.d.ts} +3 -3
- package/dist/commonjs/icons/bookmark-fill.d.ts.map +1 -0
- package/dist/commonjs/icons/{unstable-expand.js → bookmark-fill.js} +6 -6
- package/dist/commonjs/icons/bookmark-fill.js.map +1 -0
- package/dist/{esm/icons/unstable-expand.d.ts → commonjs/icons/bookmark.d.ts} +3 -3
- package/dist/commonjs/icons/bookmark.d.ts.map +1 -0
- package/dist/commonjs/icons/bookmark.js +24 -0
- package/dist/commonjs/icons/bookmark.js.map +1 -0
- package/dist/commonjs/icons/carousel.d.ts +8 -0
- package/dist/commonjs/icons/carousel.d.ts.map +1 -0
- package/dist/commonjs/icons/carousel.js +24 -0
- package/dist/commonjs/icons/carousel.js.map +1 -0
- package/dist/commonjs/icons/cloud-links.d.ts +8 -0
- package/dist/commonjs/icons/cloud-links.d.ts.map +1 -0
- package/dist/commonjs/icons/cloud-links.js +24 -0
- package/dist/commonjs/icons/cloud-links.js.map +1 -0
- package/dist/commonjs/icons/columns.d.ts +8 -0
- package/dist/commonjs/icons/columns.d.ts.map +1 -0
- package/dist/commonjs/icons/columns.js +24 -0
- package/dist/commonjs/icons/columns.js.map +1 -0
- package/dist/commonjs/icons/crop.d.ts +8 -0
- package/dist/commonjs/icons/crop.d.ts.map +1 -0
- package/dist/commonjs/icons/crop.js +24 -0
- package/dist/commonjs/icons/crop.js.map +1 -0
- package/dist/commonjs/icons/expand.d.ts +8 -0
- package/dist/commonjs/icons/expand.d.ts.map +1 -0
- package/dist/commonjs/icons/expand.js +24 -0
- package/dist/commonjs/icons/expand.js.map +1 -0
- package/dist/commonjs/icons/fill.d.ts +8 -0
- package/dist/commonjs/icons/fill.d.ts.map +1 -0
- package/dist/commonjs/icons/fill.js +24 -0
- package/dist/commonjs/icons/fill.js.map +1 -0
- package/dist/commonjs/icons/fit.d.ts +8 -0
- package/dist/commonjs/icons/fit.d.ts.map +1 -0
- package/dist/commonjs/icons/fit.js +24 -0
- package/dist/commonjs/icons/fit.js.map +1 -0
- package/dist/commonjs/icons/flow.d.ts +8 -0
- package/dist/commonjs/icons/flow.d.ts.map +1 -0
- package/dist/commonjs/icons/flow.js +24 -0
- package/dist/commonjs/icons/flow.js.map +1 -0
- package/dist/commonjs/icons/folder-database.d.ts +8 -0
- package/dist/commonjs/icons/folder-database.d.ts.map +1 -0
- package/dist/commonjs/icons/folder-database.js +24 -0
- package/dist/commonjs/icons/folder-database.js.map +1 -0
- package/dist/commonjs/icons/grid.d.ts +8 -0
- package/dist/commonjs/icons/grid.d.ts.map +1 -0
- package/dist/commonjs/icons/grid.js +24 -0
- package/dist/commonjs/icons/grid.js.map +1 -0
- package/dist/commonjs/icons/index.d.ts +19 -1
- package/dist/commonjs/icons/index.d.ts.map +1 -1
- package/dist/commonjs/icons/index.js +43 -7
- package/dist/commonjs/icons/index.js.map +1 -1
- package/dist/commonjs/icons/placement.d.ts +8 -0
- package/dist/commonjs/icons/placement.d.ts.map +1 -0
- package/dist/commonjs/icons/placement.js +24 -0
- package/dist/commonjs/icons/placement.js.map +1 -0
- package/dist/commonjs/icons/query.d.ts +8 -0
- package/dist/commonjs/icons/query.d.ts.map +1 -0
- package/dist/commonjs/icons/query.js +24 -0
- package/dist/commonjs/icons/query.js.map +1 -0
- package/dist/commonjs/icons/rows.d.ts +8 -0
- package/dist/commonjs/icons/rows.d.ts.map +1 -0
- package/dist/commonjs/icons/rows.js +24 -0
- package/dist/commonjs/icons/rows.js.map +1 -0
- package/dist/commonjs/icons/rules.d.ts +8 -0
- package/dist/commonjs/icons/rules.d.ts.map +1 -0
- package/dist/commonjs/icons/rules.js +24 -0
- package/dist/commonjs/icons/rules.js.map +1 -0
- package/dist/commonjs/icons/table.d.ts +8 -0
- package/dist/commonjs/icons/table.d.ts.map +1 -0
- package/dist/commonjs/icons/table.js +24 -0
- package/dist/commonjs/icons/table.js.map +1 -0
- package/dist/commonjs/icons/tags.d.ts +8 -0
- package/dist/commonjs/icons/tags.d.ts.map +1 -0
- package/dist/commonjs/icons/tags.js +24 -0
- package/dist/commonjs/icons/tags.js.map +1 -0
- package/dist/commonjs/icons/variants.d.ts +8 -0
- package/dist/commonjs/icons/variants.d.ts.map +1 -0
- package/dist/commonjs/icons/variants.js +24 -0
- package/dist/commonjs/icons/variants.js.map +1 -0
- package/dist/esm/components/app-header/side-nav.js +2 -2
- package/dist/esm/components/app-header/side-nav.js.map +1 -1
- package/dist/esm/components/breadcrumbs/breadcrumbs.d.ts.map +1 -1
- package/dist/esm/components/breadcrumbs/breadcrumbs.js +2 -1
- package/dist/esm/components/breadcrumbs/breadcrumbs.js.map +1 -1
- package/dist/esm/components/combo-box/combo-box.d.ts +7 -1
- package/dist/esm/components/combo-box/combo-box.d.ts.map +1 -1
- package/dist/esm/components/combo-box/combo-box.js +6 -2
- package/dist/esm/components/combo-box/combo-box.js.map +1 -1
- package/dist/esm/components/date-picker/views/view-grid-cell.js +3 -3
- package/dist/esm/components/date-picker/views/view-grid-cell.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 +2 -1
- package/dist/esm/components/file-picker/file-picker.js.map +1 -1
- package/dist/esm/components/internal/focusable-container/focusable-container.js +2 -2
- package/dist/esm/components/internal/focusable-container/focusable-container.js.map +1 -1
- package/dist/esm/components/link-tabs/link-tabs.d.ts.map +1 -1
- package/dist/esm/components/link-tabs/link-tabs.js +1 -1
- package/dist/esm/components/link-tabs/link-tabs.js.map +1 -1
- package/dist/esm/components/progress-bar/progress-bar.js +1 -1
- package/dist/esm/components/progress-bar/progress-bar.js.map +1 -1
- package/dist/esm/components/slider/slider.js +1 -1
- package/dist/esm/components/slider/slider.js.map +1 -1
- package/dist/esm/components/table/contexts/table-state.d.ts.map +1 -1
- package/dist/esm/components/table/contexts/table-state.js +2 -1
- package/dist/esm/components/table/contexts/table-state.js.map +1 -1
- package/dist/esm/components/table/hooks/use-table-cell.d.ts.map +1 -1
- package/dist/esm/components/table/hooks/use-table-cell.js +3 -2
- package/dist/esm/components/table/hooks/use-table-cell.js.map +1 -1
- package/dist/esm/components/table/hooks/use-table.d.ts.map +1 -1
- package/dist/esm/components/table/hooks/use-table.js +4 -3
- package/dist/esm/components/table/hooks/use-table.js.map +1 -1
- package/dist/esm/components/table/table-body-cell.d.ts.map +1 -1
- package/dist/esm/components/table/table-body-cell.js +1 -1
- package/dist/esm/components/table/table-body-cell.js.map +1 -1
- package/dist/esm/components/table/table-body-row.d.ts.map +1 -1
- package/dist/esm/components/table/table-body-row.js +1 -2
- package/dist/esm/components/table/table-body-row.js.map +1 -1
- package/dist/esm/components/table/table-empty-state.d.ts.map +1 -1
- package/dist/esm/components/table/table-empty-state.js +1 -1
- package/dist/esm/components/table/table-empty-state.js.map +1 -1
- package/dist/esm/components/table/table-header-cell.d.ts.map +1 -1
- package/dist/esm/components/table/table-header-cell.js +1 -1
- package/dist/esm/components/table/table-header-cell.js.map +1 -1
- package/dist/esm/components/table/table-header-row.d.ts.map +1 -1
- package/dist/esm/components/table/table-header-row.js +1 -1
- package/dist/esm/components/table/table-header-row.js.map +1 -1
- package/dist/esm/components/table/table.d.ts.map +1 -1
- package/dist/esm/components/table/table.js +1 -1
- package/dist/esm/components/table/table.js.map +1 -1
- package/dist/esm/components/tag-field/tag-field-input.js +9 -16
- package/dist/esm/components/tag-field/tag-field-input.js.map +1 -1
- package/dist/esm/components/tag-field/tag-field-list-box.js +4 -38
- 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.d.ts.map +1 -1
- package/dist/esm/components/tag-field/tag-field.js +19 -94
- package/dist/esm/components/tag-field/tag-field.js.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-button/internal-toggle-button.d.ts.map +1 -1
- package/dist/esm/components/toggle-button/internal-toggle-button.js +2 -1
- package/dist/esm/components/toggle-button/internal-toggle-button.js.map +1 -1
- package/dist/esm/components/typography/link.d.ts +1 -1
- package/dist/esm/components/typography/link.d.ts.map +1 -1
- package/dist/esm/components/typography/link.js.map +1 -1
- package/dist/esm/icons/bookmark-fill.d.ts +8 -0
- package/dist/esm/icons/bookmark-fill.d.ts.map +1 -0
- package/dist/esm/icons/bookmark-fill.js +19 -0
- package/dist/esm/icons/bookmark-fill.js.map +1 -0
- package/dist/esm/icons/bookmark.d.ts +8 -0
- package/dist/esm/icons/bookmark.d.ts.map +1 -0
- package/dist/esm/icons/bookmark.js +19 -0
- package/dist/esm/icons/bookmark.js.map +1 -0
- package/dist/esm/icons/carousel.d.ts +8 -0
- package/dist/esm/icons/carousel.d.ts.map +1 -0
- package/dist/esm/icons/carousel.js +19 -0
- package/dist/esm/icons/carousel.js.map +1 -0
- package/dist/esm/icons/cloud-links.d.ts +8 -0
- package/dist/esm/icons/cloud-links.d.ts.map +1 -0
- package/dist/esm/icons/cloud-links.js +19 -0
- package/dist/esm/icons/cloud-links.js.map +1 -0
- package/dist/esm/icons/columns.d.ts +8 -0
- package/dist/esm/icons/columns.d.ts.map +1 -0
- package/dist/esm/icons/columns.js +19 -0
- package/dist/esm/icons/columns.js.map +1 -0
- package/dist/esm/icons/crop.d.ts +8 -0
- package/dist/esm/icons/crop.d.ts.map +1 -0
- package/dist/esm/icons/crop.js +19 -0
- package/dist/esm/icons/crop.js.map +1 -0
- package/dist/esm/icons/expand.d.ts +8 -0
- package/dist/esm/icons/expand.d.ts.map +1 -0
- package/dist/esm/icons/expand.js +19 -0
- package/dist/esm/icons/expand.js.map +1 -0
- package/dist/esm/icons/fill.d.ts +8 -0
- package/dist/esm/icons/fill.d.ts.map +1 -0
- package/dist/esm/icons/fill.js +19 -0
- package/dist/esm/icons/fill.js.map +1 -0
- package/dist/esm/icons/fit.d.ts +8 -0
- package/dist/esm/icons/fit.d.ts.map +1 -0
- package/dist/esm/icons/fit.js +19 -0
- package/dist/esm/icons/fit.js.map +1 -0
- package/dist/esm/icons/flow.d.ts +8 -0
- package/dist/esm/icons/flow.d.ts.map +1 -0
- package/dist/esm/icons/flow.js +19 -0
- package/dist/esm/icons/flow.js.map +1 -0
- package/dist/esm/icons/folder-database.d.ts +8 -0
- package/dist/esm/icons/folder-database.d.ts.map +1 -0
- package/dist/esm/icons/folder-database.js +19 -0
- package/dist/esm/icons/folder-database.js.map +1 -0
- package/dist/esm/icons/grid.d.ts +8 -0
- package/dist/esm/icons/grid.d.ts.map +1 -0
- package/dist/esm/icons/grid.js +19 -0
- package/dist/esm/icons/grid.js.map +1 -0
- package/dist/esm/icons/index.d.ts +19 -1
- package/dist/esm/icons/index.d.ts.map +1 -1
- package/dist/esm/icons/index.js +19 -1
- package/dist/esm/icons/index.js.map +1 -1
- package/dist/esm/icons/placement.d.ts +8 -0
- package/dist/esm/icons/placement.d.ts.map +1 -0
- package/dist/esm/icons/placement.js +19 -0
- package/dist/esm/icons/placement.js.map +1 -0
- package/dist/esm/icons/query.d.ts +8 -0
- package/dist/esm/icons/query.d.ts.map +1 -0
- package/dist/esm/icons/query.js +19 -0
- package/dist/esm/icons/query.js.map +1 -0
- package/dist/esm/icons/rows.d.ts +8 -0
- package/dist/esm/icons/rows.d.ts.map +1 -0
- package/dist/esm/icons/rows.js +19 -0
- package/dist/esm/icons/rows.js.map +1 -0
- package/dist/esm/icons/rules.d.ts +8 -0
- package/dist/esm/icons/rules.d.ts.map +1 -0
- package/dist/esm/icons/rules.js +19 -0
- package/dist/esm/icons/rules.js.map +1 -0
- package/dist/esm/icons/table.d.ts +8 -0
- package/dist/esm/icons/table.d.ts.map +1 -0
- package/dist/esm/icons/table.js +19 -0
- package/dist/esm/icons/table.js.map +1 -0
- package/dist/esm/icons/tags.d.ts +8 -0
- package/dist/esm/icons/tags.d.ts.map +1 -0
- package/dist/esm/icons/tags.js +19 -0
- package/dist/esm/icons/tags.js.map +1 -0
- package/dist/esm/icons/variants.d.ts +8 -0
- package/dist/esm/icons/variants.d.ts.map +1 -0
- package/dist/esm/icons/variants.js +19 -0
- package/dist/esm/icons/variants.js.map +1 -0
- package/dist-styles/core.css +1 -1
- package/dist-styles/styles.css +1 -1
- package/package.json +12 -12
- package/dist/commonjs/components/tag-field/tag-field-tags.d.ts +0 -2
- package/dist/commonjs/components/tag-field/tag-field-tags.d.ts.map +0 -1
- package/dist/commonjs/components/tag-field/tag-field-tags.js +0 -31
- package/dist/commonjs/components/tag-field/tag-field-tags.js.map +0 -1
- package/dist/commonjs/icons/unstable-expand.d.ts.map +0 -1
- package/dist/commonjs/icons/unstable-expand.js.map +0 -1
- package/dist/esm/components/tag-field/tag-field-tags.d.ts +0 -2
- package/dist/esm/components/tag-field/tag-field-tags.d.ts.map +0 -1
- package/dist/esm/components/tag-field/tag-field-tags.js +0 -28
- package/dist/esm/components/tag-field/tag-field-tags.js.map +0 -1
- package/dist/esm/icons/unstable-expand.d.ts.map +0 -1
- package/dist/esm/icons/unstable-expand.js +0 -19
- package/dist/esm/icons/unstable-expand.js.map +0 -1
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.TableHeaderCell = void 0;
|
|
5
5
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
-
const utils_1 = require("@react-aria/utils");
|
|
7
6
|
const react_1 = require("react");
|
|
7
|
+
const react_aria_1 = require("react-aria");
|
|
8
8
|
const forward_ref_js_1 = require("../../forward-ref.js");
|
|
9
9
|
const index_js_1 = require("../../icons/index.js");
|
|
10
10
|
const use_server_layout_effect_js_1 = require("../../utils/use-server-layout-effect.js");
|
|
@@ -18,13 +18,13 @@ const SORT_ORDER_ICONS = {
|
|
|
18
18
|
descending: (0, jsx_runtime_1.jsx)(index_js_1.IconSortDescending, {}),
|
|
19
19
|
};
|
|
20
20
|
function TableHeaderCell({ children, UNSAFE_className, UNSAFE_style, columnKey, columnNumber, columnWidth, columnContentAlignment = 'start', sortOrder, onSortOrderToggle, iconStart, iconEnd, ...props }, ref) {
|
|
21
|
-
const cellRef = (0,
|
|
21
|
+
const cellRef = (0, react_aria_1.useObjectRef)(ref);
|
|
22
22
|
const { rowKey } = (0, row_state_js_1.useTableRowState)();
|
|
23
23
|
const { cellProps } = (0, use_table_cell_js_1.useTableCell)(cellRef, rowKey, columnKey);
|
|
24
24
|
const registerColumn = (0, column_collection_js_1.useColumnRegistration)();
|
|
25
25
|
const unregisterRef = (0, react_1.useRef)(null);
|
|
26
26
|
const { sortLabelId } = (0, table_state_js_1.useTableState)();
|
|
27
|
-
const contentId = (0,
|
|
27
|
+
const contentId = (0, react_aria_1.useId)();
|
|
28
28
|
const isSortable = typeof onSortOrderToggle === 'function';
|
|
29
29
|
// Columns need to be registered during SSR to prevent layout shifting on hydration
|
|
30
30
|
(0, use_server_layout_effect_js_1.useServerLayoutEffect)(() => {
|
|
@@ -38,7 +38,7 @@ function TableHeaderCell({ children, UNSAFE_className, UNSAFE_style, columnKey,
|
|
|
38
38
|
unregisterRef.current = null;
|
|
39
39
|
};
|
|
40
40
|
}, [registerColumn, columnKey, columnNumber, columnWidth, columnContentAlignment]);
|
|
41
|
-
return ((0, jsx_runtime_1.jsx)("th", { ...(0,
|
|
41
|
+
return ((0, jsx_runtime_1.jsx)("th", { ...(0, react_aria_1.mergeProps)(props, cellProps), ref: cellRef, className: UNSAFE_className, style: columnWidth ? { ...UNSAFE_style, width: columnWidth } : UNSAFE_style, scope: "col", "aria-colindex": columnNumber, "aria-sort": sortOrder, "data-alignment": columnContentAlignment, children: (0, jsx_runtime_1.jsxs)("div", { className: "cim-table-header-cell-container", children: [iconStart, (0, jsx_runtime_1.jsx)("span", { id: contentId, children: children }), iconEnd, isSortable ? ((0, jsx_runtime_1.jsx)(table_header_button_js_1.TableHeaderButton, { UNSAFE_className: "cim-table-header-sort-button", "aria-labelledby": `${sortLabelId} ${contentId}`, icon: sortOrder ? SORT_ORDER_ICONS[sortOrder] : (0, jsx_runtime_1.jsx)(index_js_1.IconSortUnsorted, {}), onPress: () => onSortOrderToggle(), "data-highlighted": !!sortOrder || undefined })) : sortOrder ? (SORT_ORDER_ICONS[sortOrder]) : undefined] }) }));
|
|
42
42
|
}
|
|
43
43
|
/**
|
|
44
44
|
* Renders a header cell within a table header row.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table-header-cell.js","sourceRoot":"","sources":["../../../../src/components/table/table-header-cell.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;AAEb,
|
|
1
|
+
{"version":3,"file":"table-header-cell.js","sourceRoot":"","sources":["../../../../src/components/table/table-header-cell.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;AAEb,iCAAkE;AAClE,2CAA6D;AAC7D,yDAAkD;AAClD,mDAA+F;AAC/F,yFAAgF;AAEhF,0EAAqG;AACrG,0DAA2D;AAC3D,8DAA0D;AAC1D,iEAAyD;AACzD,qEAA6D;AAgD7D,MAAM,gBAAgB,GAA4C;IAChE,SAAS,EAAE,uBAAC,4BAAiB,KAAG;IAChC,UAAU,EAAE,uBAAC,6BAAkB,KAAG;CACnC,CAAC;AAEF,SAAS,eAAe,CACtB,EACE,QAAQ,EACR,gBAAgB,EAChB,YAAY,EACZ,SAAS,EACT,YAAY,EACZ,WAAW,EACX,sBAAsB,GAAG,OAAO,EAChC,SAAS,EACT,iBAAiB,EACjB,SAAS,EACT,OAAO,EACP,GAAG,KAAK,EACa,EACvB,GAAuC;IAEvC,MAAM,OAAO,GAAG,IAAA,yBAAY,EAAC,GAAG,CAAC,CAAC;IAClC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAA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C,OAAO,EACP,UAAU,CAAC,CAAC,CAAC,CACZ,uBAAC,0CAAiB,IAChB,gBAAgB,EAAC,8BAA8B,qBAC9B,GAAG,WAAW,IAAI,SAAS,EAAE,EAC9C,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,uBAAC,2BAAgB,KAAG,EACpE,OAAO,EAAE,GAAG,EAAE,CAAC,iBAAiB,EAAE,sBAChB,CAAC,CAAC,SAAS,IAAI,SAAS,GAC1C,CACH,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CACd,gBAAgB,CAAC,SAAS,CAAC,CAC5B,CAAC,CAAC,CAAC,SAAS,IACT,GACH,CACN,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,gBAAgB,GAAG,IAAA,2BAAU,EAAC,eAAe,EAAE,iBAAiB,CAAC,CAAC;AAE3C,2CAAe","sourcesContent":["'use client';\n\nimport { useRef, type ForwardedRef, type ReactNode } from 'react';\nimport { mergeProps, useId, useObjectRef } from 'react-aria';\nimport { forwardRef } from '../../forward-ref.js';\nimport { IconSortAscending, IconSortDescending, IconSortUnsorted } from '../../icons/index.js';\nimport { useServerLayoutEffect } from '../../utils/use-server-layout-effect.js';\nimport type { CommonProps } from '../types.js';\nimport { type ColumnContentAlignment, useColumnRegistration } from './contexts/column-collection.js';\nimport { useTableRowState } from './contexts/row-state.js';\nimport { useTableState } from './contexts/table-state.js';\nimport { useTableCell } from './hooks/use-table-cell.js';\nimport { TableHeaderButton } from './table-header-button.js';\n\n/** Represents the sort order of a table column. */\nexport type TableColumnSortOrder = 'ascending' | 'descending';\n\nexport interface TableHeaderCellProps extends CommonProps {\n /** The contents of the header cell. */\n children: ReactNode;\n /**\n * A unique identifier for the column that this cell belongs to.\n * Cells that belong to the same column must have the same `columnKey`.\n */\n columnKey: string;\n /**\n * The position of the column that this cell belongs to within the full dataset.\n *\n * Provide this value if your table presents a subset of columns, such as when the user toggles column visibility.\n *\n * This number must be:\n * - greater than or equal to `1`\n * - greater than the `columnNumber` of any previous cells in the current row\n * - less than or equal to the `totalColumnCount` of the parent `Table`\n *\n * Use together with `totalColumnCount` on the `Table` component.\n */\n columnNumber?: number;\n /** The width of the column. Can be any valid value of the `width` CSS property. */\n columnWidth?: string | number;\n /**\n * Horizontal alignment of cell content within the column.\n * @default 'start'\n */\n columnContentAlignment?: ColumnContentAlignment;\n /**\n * The current sort order of the column.\n */\n sortOrder?: TableColumnSortOrder;\n /**\n * A function called when the column's sort order should change.\n * If not provided, the column will not be sortable.\n */\n onSortOrderToggle?: () => void;\n /** An icon displayed before the header text. */\n iconStart?: ReactNode;\n /** An icon displayed after the header text. */\n iconEnd?: ReactNode;\n}\n\nconst SORT_ORDER_ICONS: Record<TableColumnSortOrder, ReactNode> = {\n ascending: <IconSortAscending />,\n descending: <IconSortDescending />,\n};\n\nfunction TableHeaderCell(\n {\n children,\n UNSAFE_className,\n UNSAFE_style,\n columnKey,\n columnNumber,\n columnWidth,\n columnContentAlignment = 'start',\n sortOrder,\n onSortOrderToggle,\n iconStart,\n iconEnd,\n ...props\n }: TableHeaderCellProps,\n ref: ForwardedRef<HTMLTableCellElement>,\n) {\n const cellRef = useObjectRef(ref);\n const { rowKey } = useTableRowState();\n const { cellProps } = useTableCell(cellRef, rowKey, columnKey);\n const registerColumn = useColumnRegistration();\n const unregisterRef = useRef<(() => void) | null>(null);\n\n const { sortLabelId } = useTableState();\n const contentId = useId();\n\n const isSortable = typeof onSortOrderToggle === 'function';\n\n // Columns need to be registered during SSR to prevent layout shifting on hydration\n useServerLayoutEffect(() => {\n unregisterRef.current = registerColumn(columnKey, {\n number: columnNumber,\n width: columnWidth,\n contentAlignment: columnContentAlignment,\n });\n\n return () => {\n unregisterRef.current?.();\n unregisterRef.current = null;\n };\n }, [registerColumn, columnKey, columnNumber, columnWidth, columnContentAlignment]);\n\n return (\n <th\n {...mergeProps(props, cellProps)}\n ref={cellRef}\n className={UNSAFE_className}\n style={columnWidth ? { ...UNSAFE_style, width: columnWidth } : UNSAFE_style}\n scope=\"col\"\n aria-colindex={columnNumber}\n aria-sort={sortOrder}\n data-alignment={columnContentAlignment}\n >\n <div className=\"cim-table-header-cell-container\">\n {iconStart}\n <span id={contentId}>{children}</span>\n {iconEnd}\n {isSortable ? (\n <TableHeaderButton\n UNSAFE_className=\"cim-table-header-sort-button\"\n aria-labelledby={`${sortLabelId} ${contentId}`}\n icon={sortOrder ? SORT_ORDER_ICONS[sortOrder] : <IconSortUnsorted />}\n onPress={() => onSortOrderToggle()}\n data-highlighted={!!sortOrder || undefined}\n />\n ) : sortOrder ? (\n SORT_ORDER_ICONS[sortOrder]\n ) : undefined}\n </div>\n </th>\n );\n}\n\n/**\n * Renders a header cell within a table header row.\n *\n * See [table usage guidelines](https://ui.cimpress.io/components/table/) and [table building guide](https://ui.cimpress.io/dev-guides/tables/).\n */\nconst _TableHeaderCell = forwardRef(TableHeaderCell, 'TableHeaderCell');\n\nexport { _TableHeaderCell as TableHeaderCell };\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table-header-row.d.ts","sourceRoot":"","sources":["../../../../src/components/table/table-header-row.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"table-header-row.d.ts","sourceRoot":"","sources":["../../../../src/components/table/table-header-row.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAgB,SAAS,EAAE,MAAM,OAAO,CAAC;AAGrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/C,MAAM,WAAW,mBAAoB,SAAQ,WAAW;IACtD,uDAAuD;IACvD,QAAQ,EAAE,SAAS,CAAC;IACpB;;;;;;;;;;;OAWG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAeD;;;;GAIG;AACH,QAAA,MAAM,eAAe,yHAA+C,CAAC;AAErE,OAAO,EAAE,eAAe,IAAI,cAAc,EAAE,CAAC"}
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.TableHeaderRow = void 0;
|
|
5
5
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
-
const
|
|
6
|
+
const react_aria_1 = require("react-aria");
|
|
7
7
|
const forward_ref_js_1 = require("../../forward-ref.js");
|
|
8
8
|
const row_state_js_1 = require("./contexts/row-state.js");
|
|
9
9
|
function TableHeaderRow({ children, UNSAFE_className, UNSAFE_style, rowNumber, ...props }, ref) {
|
|
10
|
-
const rowKey = (0,
|
|
10
|
+
const rowKey = (0, react_aria_1.useId)();
|
|
11
11
|
return ((0, jsx_runtime_1.jsx)("tr", { ...props, ref: ref, className: UNSAFE_className, style: UNSAFE_style, "aria-rowindex": rowNumber, children: (0, jsx_runtime_1.jsx)(row_state_js_1.TableRowStateProvider, { rowKey: rowKey, children: children }) }));
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table-header-row.js","sourceRoot":"","sources":["../../../../src/components/table/table-header-row.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;
|
|
1
|
+
{"version":3,"file":"table-header-row.js","sourceRoot":"","sources":["../../../../src/components/table/table-header-row.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;AAGb,2CAAmC;AACnC,yDAAkD;AAElD,0DAAgE;AAoBhE,SAAS,cAAc,CACrB,EAAE,QAAQ,EAAE,gBAAgB,EAAE,YAAY,EAAE,SAAS,EAAE,GAAG,KAAK,EAAuB,EACtF,GAAsC;IAEtC,MAAM,MAAM,GAAG,IAAA,kBAAK,GAAE,CAAC;IAEvB,OAAO,CACL,kCAAQ,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,gBAAgB,EAAE,KAAK,EAAE,YAAY,mBAAiB,SAAS,YACjG,uBAAC,oCAAqB,IAAC,MAAM,EAAE,MAAM,YAAG,QAAQ,GAAyB,GACtE,CACN,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,eAAe,GAAG,IAAA,2BAAU,EAAC,cAAc,EAAE,gBAAgB,CAAC,CAAC;AAEzC,yCAAc","sourcesContent":["'use client';\n\nimport type { ForwardedRef, ReactNode } from 'react';\nimport { useId } from 'react-aria';\nimport { forwardRef } from '../../forward-ref.js';\nimport type { CommonProps } from '../types.js';\nimport { TableRowStateProvider } from './contexts/row-state.js';\n\nexport interface TableHeaderRowProps extends CommonProps {\n /** The header cells that belong to this header row. */\n children: ReactNode;\n /**\n * The row's position within the full dataset, including headers.\n *\n * Provide this value if your table presents a subset of rows, such as when using pagination.\n *\n * This number must be:\n * - greater than or equal to `1`\n * - greater than the `rowNumber` of any previous rows\n * - less than or equal to the `totalRowCount` of the parent `Table`\n *\n * Use together with `totalRowCount` on the `Table` component.\n */\n rowNumber?: number;\n}\n\nfunction TableHeaderRow(\n { children, UNSAFE_className, UNSAFE_style, rowNumber, ...props }: TableHeaderRowProps,\n ref: ForwardedRef<HTMLTableRowElement>,\n) {\n const rowKey = useId();\n\n return (\n <tr {...props} ref={ref} className={UNSAFE_className} style={UNSAFE_style} aria-rowindex={rowNumber}>\n <TableRowStateProvider rowKey={rowKey}>{children}</TableRowStateProvider>\n </tr>\n );\n}\n\n/**\n * Renders a row within a table header.\n *\n * See [table usage guidelines](https://ui.cimpress.io/components/table/) and [table building guide](https://ui.cimpress.io/dev-guides/tables/).\n */\nconst _TableHeaderRow = forwardRef(TableHeaderRow, 'TableHeaderRow');\n\nexport { _TableHeaderRow as TableHeaderRow };\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../../../src/components/table/table.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../../../src/components/table/table.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAgB,SAAS,EAAE,MAAM,OAAO,CAAC;AAIrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAIlE,OAAO,EAAE,KAAK,gBAAgB,EAAqC,MAAM,2BAA2B,CAAC;AAGrG,MAAM,WAAW,UAAW,SAAQ,WAAW,EAAE,iBAAiB;IAChE,iCAAiC;IACjC,QAAQ,EAAE,SAAS,CAAC;IACpB;;;;;;;OAOG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;;;;OAOG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;OAGG;IACH,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC;;;OAGG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;;;;OAKG;IACH,wBAAwB,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IACrD;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAwED;;;;GAIG;AACH,QAAA,MAAM,MAAM,6GAA6B,CAAC;AAE1C,OAAO,EAAE,MAAM,IAAI,KAAK,EAAE,CAAC"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.Table = void 0;
|
|
5
5
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
-
const
|
|
6
|
+
const react_aria_1 = require("react-aria");
|
|
7
7
|
const forward_ref_js_1 = require("../../forward-ref.js");
|
|
8
8
|
const use_production_warning_js_1 = require("../../utils/use-production-warning.js");
|
|
9
9
|
const column_collection_js_1 = require("./contexts/column-collection.js");
|
|
@@ -21,10 +21,10 @@ function Table({ isLoading = false, rowSelectionMode = 'none', areAllRowsSelecte
|
|
|
21
21
|
return ((0, jsx_runtime_1.jsx)(focus_js_1.TableFocusProvider, { children: (0, jsx_runtime_1.jsx)(table_state_js_1.TableStateProvider, { rowSelectionMode: rowSelectionMode, areAllRowsSelected: areAllRowsSelected, areSomeRowsSelected: areSomeRowsSelected, onAllRowsSelectionToggle: onAllRowsSelectionToggle, children: (0, jsx_runtime_1.jsx)(loading_js_1.TableLoadingProvider, { isLoading: isLoading, children: (0, jsx_runtime_1.jsxs)(column_collection_js_1.ColumnCollectionProvider, { children: [(0, jsx_runtime_1.jsx)("span", { tabIndex: -1, "data-cim-table-guard": true, "aria-hidden": true }), (0, jsx_runtime_1.jsx)(TableInner, { props: props, forwardedRef: ref }), (0, jsx_runtime_1.jsx)("span", { tabIndex: -1, "data-cim-table-guard": true, "aria-hidden": true })] }) }) }) }));
|
|
22
22
|
}
|
|
23
23
|
function TableInner({ props: { children, UNSAFE_className, UNSAFE_style, totalRowCount, totalColumnCount, ...props }, forwardedRef, }) {
|
|
24
|
-
const tableRef = (0,
|
|
24
|
+
const tableRef = (0, react_aria_1.useObjectRef)(forwardedRef);
|
|
25
25
|
const { tableProps } = (0, use_table_js_1.useTable)(tableRef);
|
|
26
26
|
const { rowSelectionMode } = (0, table_state_js_1.useTableState)();
|
|
27
|
-
return ((0, jsx_runtime_1.jsx)("table", { ...(0,
|
|
27
|
+
return ((0, jsx_runtime_1.jsx)("table", { ...(0, react_aria_1.mergeProps)(props, tableProps), ref: tableRef, className: UNSAFE_className, style: UNSAFE_style, "aria-rowcount": totalRowCount, "aria-colcount": totalColumnCount, "aria-multiselectable": rowSelectionMode === 'multiple' ? true : undefined, children: children }));
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
30
|
* Displays data in an organized, tabular way.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.js","sourceRoot":"","sources":["../../../../src/components/table/table.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;
|
|
1
|
+
{"version":3,"file":"table.js","sourceRoot":"","sources":["../../../../src/components/table/table.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;AAGb,2CAAsD;AACtD,yDAAkD;A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UAAU,EAAE,GAAG,IAAA,uBAAQ,EAAC,QAAQ,CAAC,CAAC;IAC1C,MAAM,EAAE,gBAAgB,EAAE,GAAG,IAAA,8BAAa,GAAE,CAAC;IAE7C,OAAO,CACL,qCACM,IAAA,uBAAU,EAAC,KAAK,EAAE,UAAU,CAAC,EACjC,GAAG,EAAE,QAAQ,EACb,SAAS,EAAE,gBAAgB,EAC3B,KAAK,EAAE,YAAY,mBACJ,aAAa,mBACb,gBAAgB,0BACT,gBAAgB,KAAK,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,YAEvE,QAAQ,GACH,CACT,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,MAAM,GAAG,IAAA,2BAAU,EAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AAEvB,uBAAK","sourcesContent":["'use client';\n\nimport type { ForwardedRef, ReactNode } from 'react';\nimport { mergeProps, useObjectRef } from 'react-aria';\nimport { forwardRef } from '../../forward-ref.js';\nimport { useProductionWarning } from '../../utils/use-production-warning.js';\nimport type { AriaLabelingProps, CommonProps } from '../types.js';\nimport { ColumnCollectionProvider } from './contexts/column-collection.js';\nimport { TableFocusProvider } from './contexts/focus.js';\nimport { TableLoadingProvider } from './contexts/loading.js';\nimport { type RowSelectionMode, TableStateProvider, useTableState } from './contexts/table-state.js';\nimport { useTable } from './hooks/use-table.js';\n\nexport interface TableProps extends CommonProps, AriaLabelingProps {\n /** The contents of the table. */\n children: ReactNode;\n /**\n * The number of rows in the full dataset, including headers.\n *\n * Provide this value if your table presents a subset of rows, such as when using pagination.\n * Use `-1` if the number of rows is not known.\n *\n * You must provide `rowNumber` on each table row if `totalRowCount` is defined.\n */\n totalRowCount?: number;\n /**\n * The number of columns in the full dataset.\n *\n * Provide this value if your table presents a subset of columns, such as when the user toggles column visibility.\n * Use `-1` if the number of columns is not known.\n *\n * You must provide `columnNumber` on each table header cell if `totalColumnCount` is defined.\n */\n totalColumnCount?: number;\n /**\n * The type of row selection that is allowed within the table.\n * @default 'none'\n */\n rowSelectionMode?: RowSelectionMode;\n /**\n * Whether all of the table's rows are selected.\n * The meaning of \"all rows\" is dictated by the consumer.\n */\n areAllRowsSelected?: boolean;\n /**\n * Whether some (but not all) of the table's rows are selected.\n * The meaning of \"some rows\" is dictated by the consumer.\n */\n areSomeRowsSelected?: boolean;\n /**\n * A function called when the selection state of all rows should change.\n *\n * If called without an argument, you are free to pick the new selection state based on your own logic.\n * If called with an argument, you must set the selection state to the provided value.\n */\n onAllRowsSelectionToggle?: (value?: boolean) => void;\n /**\n * Whether the table is currently in a loading state.\n * @default false\n */\n isLoading?: boolean;\n}\n\nfunction Table(\n {\n isLoading = false,\n rowSelectionMode = 'none',\n areAllRowsSelected,\n areSomeRowsSelected,\n onAllRowsSelectionToggle,\n ...props\n }: TableProps,\n ref: ForwardedRef<HTMLTableElement>,\n) {\n const { 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy } = props;\n\n useProductionWarning(() => {\n if (!ariaLabel && !ariaLabelledBy) {\n console.warn('Table requires one of aria-label / aria-labelledby for accessibility');\n }\n }, [ariaLabel, ariaLabelledBy]);\n\n return (\n <TableFocusProvider>\n <TableStateProvider\n rowSelectionMode={rowSelectionMode}\n areAllRowsSelected={areAllRowsSelected}\n areSomeRowsSelected={areSomeRowsSelected}\n onAllRowsSelectionToggle={onAllRowsSelectionToggle}\n >\n <TableLoadingProvider isLoading={isLoading}>\n <ColumnCollectionProvider>\n <span tabIndex={-1} data-cim-table-guard aria-hidden />\n <TableInner props={props} forwardedRef={ref} />\n <span tabIndex={-1} data-cim-table-guard aria-hidden />\n </ColumnCollectionProvider>\n </TableLoadingProvider>\n </TableStateProvider>\n </TableFocusProvider>\n );\n}\n\ninterface TableInnerProps {\n props: Omit<\n TableProps,\n 'isLoading' | 'rowSelectionMode' | 'areAllRowsSelected' | 'areSomeRowsSelected' | 'onAllRowsSelectionToggle'\n >;\n forwardedRef: ForwardedRef<HTMLTableElement>;\n}\n\nfunction TableInner({\n props: { children, UNSAFE_className, UNSAFE_style, totalRowCount, totalColumnCount, ...props },\n forwardedRef,\n}: TableInnerProps) {\n const tableRef = useObjectRef(forwardedRef);\n const { tableProps } = useTable(tableRef);\n const { rowSelectionMode } = useTableState();\n\n return (\n <table\n {...mergeProps(props, tableProps)}\n ref={tableRef}\n className={UNSAFE_className}\n style={UNSAFE_style}\n aria-rowcount={totalRowCount}\n aria-colcount={totalColumnCount}\n aria-multiselectable={rowSelectionMode === 'multiple' ? true : undefined}\n >\n {children}\n </table>\n );\n}\n\n/**\n * Displays data in an organized, tabular way.\n *\n * See [table usage guidelines](https://ui.cimpress.io/components/table/) and [table building guide](https://ui.cimpress.io/dev-guides/tables/).\n */\nconst _Table = forwardRef(Table, 'Table');\n\nexport { _Table as Table };\n"]}
|
|
@@ -8,23 +8,16 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
8
8
|
const clsx_1 = __importDefault(require("clsx"));
|
|
9
9
|
const react_1 = require("react");
|
|
10
10
|
const react_aria_components_1 = require("react-aria-components");
|
|
11
|
+
const localization_provider_js_1 = require("../../i18n/localization-provider.js");
|
|
11
12
|
const utils_js_1 = require("../typography/utils.js");
|
|
12
13
|
/** @internal */
|
|
13
|
-
function TagFieldInput({ inputRef, isReadOnly,
|
|
14
|
+
function TagFieldInput({ inputRef, isReadOnly, placeholder, }) {
|
|
14
15
|
const comboBoxState = (0, react_1.useContext)(react_aria_components_1.ComboBoxStateContext);
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
// Change `required` to `aria-required` so that form submission isn't blocked, but required state is still announced by screen readers
|
|
22
|
-
required: false,
|
|
23
|
-
'aria-required': isRequired,
|
|
24
|
-
'aria-invalid': isInvalid || undefined,
|
|
25
|
-
}, children: (0, jsx_runtime_1.jsx)(react_aria_components_1.Input, { ref: inputRef, className: (0, clsx_1.default)('cim-combo-box-input', (0, utils_js_1.textStyle)({ variant: 'body' })),
|
|
26
|
-
// Ensure the popover opens when the input is clicked.
|
|
27
|
-
// By default, React Aria only opens the popover when the input is focused.
|
|
28
|
-
onClick: () => !isReadOnly && comboBoxState.open(), placeholder: placeholder, onFocus: () => onFocusChange(true), onBlur: () => onFocusChange(false), "aria-describedby": [descriptionId, errorMessageId, ariaDescribedby].filter(Boolean).join(' ') || undefined }) }));
|
|
16
|
+
const messages = (0, localization_provider_js_1.useLocalizedMessages)('tagField');
|
|
17
|
+
const selectedItemCount = comboBoxState?.selectedItems.length ?? 0;
|
|
18
|
+
return ((0, jsx_runtime_1.jsx)(react_aria_components_1.Input, { ref: inputRef, className: (0, clsx_1.default)('cim-combo-box-input', (0, utils_js_1.textStyle)({ variant: 'body' })),
|
|
19
|
+
// Ensure the popover opens when the input is clicked.
|
|
20
|
+
// By default, React Aria only opens the popover when the input is focused.
|
|
21
|
+
onClick: () => !isReadOnly && comboBoxState.open(), placeholder: selectedItemCount === 0 && placeholder ? placeholder : messages.format('itemsSelected', { selectedItemCount }) }));
|
|
29
22
|
}
|
|
30
23
|
//# sourceMappingURL=tag-field-input.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tag-field-input.js","sourceRoot":"","sources":["../../../../src/components/tag-field/tag-field-input.tsx"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"tag-field-input.js","sourceRoot":"","sources":["../../../../src/components/tag-field/tag-field-input.tsx"],"names":[],"mappings":";;;;;AAOA,sCA0BC;;AAjCD,gDAAwB;AACxB,iCAA0D;AAC1D,iEAA2G;AAC3G,kFAA2E;AAC3E,qDAAmD;AAEnD,gBAAgB;AAChB,SAAgB,aAAa,CAAC,EAC5B,QAAQ,EACR,UAAU,EACV,WAAW,GAKZ;IACC,MAAM,aAAa,GAAG,IAAA,kBAAU,EAAC,4CAAuB,CAAC,CAAC;IAC1D,MAAM,QAAQ,GAAG,IAAA,+CAAoB,EAAC,UAAU,CAAC,CAAC;IAElD,MAAM,iBAAiB,GAAG,aAAa,EAAE,aAAa,CAAC,MAAM,IAAI,CAAC,CAAC;IAEnE,OAAO,CACL,uBAAC,6BAAQ,IACP,GAAG,EAAE,QAAQ,EACb,SAAS,EAAE,IAAA,cAAI,EAAC,qBAAqB,EAAE,IAAA,oBAAS,EAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;QACtE,sDAAsD;QACtD,2EAA2E;QAC3E,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,UAAU,IAAI,aAAc,CAAC,IAAI,EAAE,EACnD,WAAW,EACT,iBAAiB,KAAK,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,eAAe,EAAE,EAAE,iBAAiB,EAAE,CAAC,GAEhH,CACH,CAAC;AACJ,CAAC","sourcesContent":["import clsx from 'clsx';\nimport { type MutableRefObject, useContext } from 'react';\nimport { ComboBoxStateContext as RACComboBoxStateContext, Input as RACInput } from 'react-aria-components';\nimport { useLocalizedMessages } from '../../i18n/localization-provider.js';\nimport { textStyle } from '../typography/utils.js';\n\n/** @internal */\nexport function TagFieldInput({\n inputRef,\n isReadOnly,\n placeholder,\n}: {\n inputRef: MutableRefObject<HTMLInputElement | null>;\n isReadOnly: boolean | undefined;\n placeholder: string | undefined;\n}) {\n const comboBoxState = useContext(RACComboBoxStateContext);\n const messages = useLocalizedMessages('tagField');\n\n const selectedItemCount = comboBoxState?.selectedItems.length ?? 0;\n\n return (\n <RACInput\n ref={inputRef}\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={\n selectedItemCount === 0 && placeholder ? placeholder : messages.format('itemsSelected', { selectedItemCount })\n }\n />\n );\n}\n"]}
|
|
@@ -12,44 +12,10 @@ const VIRTUAL_LAYOUT_OPTIONS = {
|
|
|
12
12
|
gap: 0,
|
|
13
13
|
};
|
|
14
14
|
/** @internal */
|
|
15
|
-
function TagFieldListBox({ children,
|
|
15
|
+
function TagFieldListBox({ children, items, onScroll, isVirtualized, }) {
|
|
16
16
|
const comboBoxState = (0, react_1.useContext)(react_aria_components_1.ComboBoxStateContext);
|
|
17
|
-
const listState = (0, react_1.useContext)(react_aria_components_1.ListStateContext);
|
|
18
17
|
(0, react_aria_1.usePreventScroll)({ isDisabled: !comboBoxState?.isOpen });
|
|
19
|
-
// Override RACListStateContext to allow multiple selection within the list
|
|
20
|
-
const updatedListState = (0, react_1.useMemo)(() => {
|
|
21
|
-
if (!listState || !listState.selectionManager) {
|
|
22
|
-
return listState;
|
|
23
|
-
}
|
|
24
|
-
// This is a temporary mutation before a context update, so this is fine
|
|
25
|
-
// @ts-expect-error `selectionManager.state` is private
|
|
26
|
-
// eslint-disable-next-line react-hooks/immutability
|
|
27
|
-
listState.selectionManager.state.selectionMode = 'multiple';
|
|
28
|
-
// @ts-expect-error `selectionManager.state` is private
|
|
29
|
-
// eslint-disable-next-line react-hooks/immutability
|
|
30
|
-
listState.selectionManager.state.selectedKeys = selectedKeys;
|
|
31
|
-
// @ts-expect-error `selectionManager.state` is private
|
|
32
|
-
// eslint-disable-next-line react-hooks/immutability
|
|
33
|
-
listState.selectionManager.state.setSelectedKeys = (keys) => {
|
|
34
|
-
if (keys === 'all') {
|
|
35
|
-
// When the end-user presses Ctrl/Cmd + A on a list which has `selectionMode` set to `'multiple'`,
|
|
36
|
-
// the selection manager emits the `'all'` string as an indication to select all items.
|
|
37
|
-
// We don't want to do that - instead, we select the contents of the input field.
|
|
38
|
-
// Querying by ID because RACInputContext has a null ref for some reason.
|
|
39
|
-
document.getElementById(inputId)?.select();
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
setSelectedKeys(keys);
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
// @ts-expect-error `selectionManager.state` is private
|
|
46
|
-
// eslint-disable-next-line react-hooks/immutability
|
|
47
|
-
listState.selectionManager.state.disallowEmptySelection = false;
|
|
48
|
-
return {
|
|
49
|
-
...listState,
|
|
50
|
-
};
|
|
51
|
-
}, [listState, selectedKeys, setSelectedKeys, inputId]);
|
|
52
18
|
const listBox = ((0, jsx_runtime_1.jsx)(react_aria_components_1.ListBox, { className: "cim-combo-box-listbox", onScroll: onScroll, items: items, children: children }));
|
|
53
|
-
return
|
|
19
|
+
return isVirtualized ? ((0, jsx_runtime_1.jsx)(react_aria_components_1.Virtualizer, { layout: react_aria_components_1.ListLayout, layoutOptions: VIRTUAL_LAYOUT_OPTIONS, children: listBox })) : (listBox);
|
|
54
20
|
}
|
|
55
21
|
//# sourceMappingURL=tag-field-list-box.js.map
|
|
@@ -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":";;AAoBA,0CAuBC;;AA3CD,iCAAmC;AACnC,2CAA8C;AAC9C,iEAM+B;AAI/B,MAAM,sBAAsB,GAAyB;IACnD,kBAAkB,EAAE,EAAE;IACtB,sBAAsB,EAAE,EAAE;IAC1B,OAAO,EAAE,CAAC;IACV,GAAG,EAAE,CAAC;CACP,CAAC;AAEF,gBAAgB;AAChB,SAAgB,eAAe,CAA2B,EACxD,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,aAAa,GAC+D;IAC5E,MAAM,aAAa,GAAG,IAAA,kBAAU,EAAC,4CAAuB,CAAC,CAAC;IAE1D,IAAA,6BAAgB,EAAC,EAAE,UAAU,EAAE,CAAC,aAAa,EAAE,MAAM,EAAE,CAAC,CAAC;IAEzD,MAAM,OAAO,GAAG,CACd,uBAAC,+BAAU,IAAC,SAAS,EAAC,uBAAuB,EAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,YAC3E,QAAQ,GACE,CACd,CAAC;IAEF,OAAO,aAAa,CAAC,CAAC,CAAC,CACrB,uBAAC,mCAAc,IAAC,MAAM,EAAE,kCAAa,EAAE,aAAa,EAAE,sBAAsB,YACzE,OAAO,GACO,CAClB,CAAC,CAAC,CAAC,CACF,OAAO,CACR,CAAC;AACJ,CAAC","sourcesContent":["import { useContext } from 'react';\nimport { usePreventScroll } from 'react-aria';\nimport {\n ComboBoxStateContext as RACComboBoxStateContext,\n ListBox as RACListBox,\n ListLayout as RACListLayout,\n type ListLayoutOptions as RACListLayoutOptions,\n Virtualizer as RACVirtualizer,\n} from 'react-aria-components';\nimport type { CollectionItem } from '../types.js';\nimport type { TagFieldProps } from './tag-field.js';\n\nconst VIRTUAL_LAYOUT_OPTIONS: RACListLayoutOptions = {\n estimatedRowHeight: 36,\n estimatedHeadingHeight: 32,\n padding: 0,\n gap: 0,\n};\n\n/** @internal */\nexport function TagFieldListBox<T extends CollectionItem>({\n children,\n items,\n onScroll,\n isVirtualized,\n}: Pick<TagFieldProps<T>, 'children' | 'items' | 'onScroll' | 'isVirtualized'>) {\n const comboBoxState = useContext(RACComboBoxStateContext);\n\n usePreventScroll({ isDisabled: !comboBoxState?.isOpen });\n\n const listBox = (\n <RACListBox className=\"cim-combo-box-listbox\" onScroll={onScroll} items={items}>\n {children}\n </RACListBox>\n );\n\n return isVirtualized ? (\n <RACVirtualizer layout={RACListLayout} layoutOptions={VIRTUAL_LAYOUT_OPTIONS}>\n {listBox}\n </RACVirtualizer>\n ) : (\n listBox\n );\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type UIEventHandler } from 'react';
|
|
2
2
|
import { type ComboBoxProps as RACComboBoxProps, type ListBoxItemProps as RACListBoxItemProps } from 'react-aria-components';
|
|
3
|
-
import type
|
|
3
|
+
import { type TagGroupProps } from '../tag/tag-group.js';
|
|
4
4
|
import type { ApiProps, CollectionItem, CollectionProps, CommonProps, FieldWithPlaceholderProps, Key, StringLikeChildren } from '../types.js';
|
|
5
5
|
/** Represents the state of the `TagField` component for validation purposes. */
|
|
6
6
|
export interface TagFieldValidationValue {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tag-field.d.ts","sourceRoot":"","sources":["../../../../src/components/tag-field/tag-field.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tag-field.d.ts","sourceRoot":"","sources":["../../../../src/components/tag-field/tag-field.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAqB,KAAK,cAAc,EAA+B,MAAM,OAAO,CAAC;AAE5F,OAAO,EASL,KAAK,aAAa,IAAI,gBAAgB,EACtC,KAAK,gBAAgB,IAAI,mBAAmB,EAE7C,MAAM,uBAAuB,CAAC;AAS/B,OAAO,EAAY,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEnE,OAAO,KAAK,EACV,QAAQ,EACR,cAAc,EACd,eAAe,EACf,WAAW,EACX,yBAAyB,EACzB,GAAG,EACH,kBAAkB,EACnB,MAAM,aAAa,CAAC;AAKrB,gFAAgF;AAChF,MAAM,WAAW,uBAAuB;IACtC,yCAAyC;IACzC,YAAY,EAAE,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;IAC9B,uCAAuC;IACvC,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,aAAa,CAAC,CAAC,SAAS,cAAc,GAAG,cAAc,CACtE,SACE,WAAW,EACX,yBAAyB,CAAC,uBAAuB,CAAC,EAClD,eAAe,CAAC,CAAC,CAAC,EAClB,QAAQ,CAAC,WAAW,CAAC,EACrB,IAAI,CACF,gBAAgB,CAAC,CAAC,CAAC,EACjB,YAAY,GACZ,YAAY,GACZ,WAAW,GACX,YAAY,GACZ,YAAY,GACZ,mBAAmB,GACnB,WAAW,GACX,eAAe,GACf,SAAS,GACT,QAAQ,GACR,cAAc,CACjB,EACD,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,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AC1D,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"}
|
|
@@ -8,15 +8,11 @@ exports.TagField = void 0;
|
|
|
8
8
|
exports.TagFieldItem = TagFieldItem;
|
|
9
9
|
exports.TagFieldSection = TagFieldSection;
|
|
10
10
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
11
|
-
const form_1 = require("@react-aria/form");
|
|
12
|
-
const utils_1 = require("@react-aria/utils");
|
|
13
|
-
const form_2 = require("@react-stately/form");
|
|
14
|
-
const utils_2 = require("@react-stately/utils");
|
|
15
11
|
const clsx_1 = __importDefault(require("clsx"));
|
|
16
12
|
const react_1 = require("react");
|
|
13
|
+
const react_aria_1 = require("react-aria");
|
|
17
14
|
const react_aria_components_1 = require("react-aria-components");
|
|
18
15
|
const forward_ref_js_1 = require("../../forward-ref.js");
|
|
19
|
-
const localization_provider_js_1 = require("../../i18n/localization-provider.js");
|
|
20
16
|
const index_js_1 = require("../../icons/index.js");
|
|
21
17
|
const is_production_js_1 = require("../../utils/is-production.js");
|
|
22
18
|
const use_production_warning_js_1 = require("../../utils/use-production-warning.js");
|
|
@@ -24,13 +20,14 @@ const with_style_props_js_1 = require("../../with-style-props.js");
|
|
|
24
20
|
const checkbox_indicator_js_1 = require("../internal/checkbox-indicator/checkbox-indicator.js");
|
|
25
21
|
const collapsible_list_js_1 = require("../internal/collapsible-list/collapsible-list.js");
|
|
26
22
|
const form_field_js_1 = require("../internal/form-field/form-field.js");
|
|
23
|
+
const tag_group_js_1 = require("../tag/tag-group.js");
|
|
24
|
+
const tag_js_1 = require("../tag/tag.js");
|
|
27
25
|
const utils_js_1 = require("../typography/utils.js");
|
|
28
26
|
const tag_field_input_js_1 = require("./tag-field-input.js");
|
|
29
27
|
const tag_field_list_box_js_1 = require("./tag-field-list-box.js");
|
|
30
|
-
|
|
31
|
-
function TagField({ label, description, error, items, children, placeholder, UNSAFE_className, UNSAFE_style, isReadOnly, inputValue: consumerInputValue, defaultInputValue: defaultConsumerInputValue, onInputChange, form, name, validate, onScroll, selectedKeys: consumerSelectedKeys, defaultSelectedKeys: defaultConsumerSelectedKeys, onSelectionChange, id, renderEmptyState, isVirtualized = false, apiRef, ...props }, ref) {
|
|
28
|
+
function TagField({ label, description, error, items, children, placeholder, UNSAFE_className, UNSAFE_style, validate, isReadOnly, onScroll, selectedKeys, defaultSelectedKeys, onSelectionChange, id, renderEmptyState, isVirtualized = false, apiRef, ...props }, ref) {
|
|
32
29
|
const inputRef = (0, react_1.useRef)(null);
|
|
33
|
-
const { 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, isRequired, isDisabled
|
|
30
|
+
const { 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, isRequired, isDisabled } = props;
|
|
34
31
|
(0, use_production_warning_js_1.useProductionWarning)(() => {
|
|
35
32
|
if (!label && !ariaLabel && !ariaLabelledBy) {
|
|
36
33
|
console.warn('TagField requires one of label / aria-label / aria-labelledby for accessibility');
|
|
@@ -39,93 +36,21 @@ function TagField({ label, description, error, items, children, placeholder, UNS
|
|
|
39
36
|
if (!(0, is_production_js_1.isProduction)() && items != null && typeof children !== 'function') {
|
|
40
37
|
console.warn('`TagField` requires `children` to be a function when using `items` prop');
|
|
41
38
|
}
|
|
42
|
-
const
|
|
39
|
+
const inputId = (0, react_aria_1.useId)(id);
|
|
43
40
|
(0, react_1.useImperativeHandle)(apiRef, () => ({
|
|
44
41
|
focus: () => inputRef.current?.focus(),
|
|
45
42
|
}), []);
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
// Validation
|
|
58
|
-
const inputId = (0, utils_1.useId)(id);
|
|
59
|
-
const formInputRef = (0, react_1.useRef)(null);
|
|
60
|
-
const validationState = (0, form_2.useFormValidationState)({
|
|
61
|
-
name,
|
|
62
|
-
value: (0, react_1.useMemo)(() => ({ selectedKeys: selectedSet, inputValue }), [selectedSet, inputValue]),
|
|
63
|
-
isInvalid,
|
|
64
|
-
isRequired,
|
|
65
|
-
validate,
|
|
66
|
-
validationBehavior: 'native',
|
|
67
|
-
});
|
|
68
|
-
const [initialSelectedKeys] = (0, react_1.useState)(selectedKeys);
|
|
69
|
-
const [initialInputValue] = (0, react_1.useState)(inputValue);
|
|
70
|
-
(0, utils_1.useFormReset)(formInputRef, [defaultConsumerSelectedKeys ?? initialSelectedKeys, defaultConsumerInputValue ?? initialInputValue], ([a, b]) => {
|
|
71
|
-
setSelectedKeys(a);
|
|
72
|
-
setInputValue(b);
|
|
73
|
-
});
|
|
74
|
-
(0, form_1.useFormValidation)({
|
|
75
|
-
focus: () => {
|
|
76
|
-
// Querying by element ID because a ref is always null here, I don't know why :(
|
|
77
|
-
document.getElementById(inputId)?.focus();
|
|
78
|
-
},
|
|
79
|
-
isInvalid,
|
|
80
|
-
isRequired,
|
|
81
|
-
validate,
|
|
82
|
-
validationBehavior: 'native',
|
|
83
|
-
}, validationState, formInputRef);
|
|
84
|
-
// Event handlers
|
|
85
|
-
// Commit validation on input blur if the values have changed
|
|
86
|
-
const inputValueOnFocus = (0, react_1.useRef)(inputValue);
|
|
87
|
-
const selectedSetOnFocus = (0, react_1.useRef)(selectedSet);
|
|
88
|
-
const onFocusChange = (isFocused) => {
|
|
89
|
-
if (isFocused) {
|
|
90
|
-
inputValueOnFocus.current = inputValue;
|
|
91
|
-
selectedSetOnFocus.current = selectedSet;
|
|
92
|
-
}
|
|
93
|
-
else if (inputValue !== inputValueOnFocus.current || selectedSet !== selectedSetOnFocus.current) {
|
|
94
|
-
validationState.commitValidation();
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
const onItemSelectionChange = (key) => {
|
|
98
|
-
if (selectedSet.has(key)) {
|
|
99
|
-
// This is a temporary mutation followed immediately by a state update, so this is fine
|
|
100
|
-
// eslint-disable-next-line react-hooks/immutability
|
|
101
|
-
selectedSet.delete(key);
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
selectedSet.add(key);
|
|
105
|
-
}
|
|
106
|
-
setSelectedKeys(new Set(selectedSet.values()));
|
|
107
|
-
validationState.commitValidation();
|
|
108
|
-
};
|
|
109
|
-
// Text slots
|
|
110
|
-
const descriptionId = (0, utils_1.useSlotId)([Boolean(description)]);
|
|
111
|
-
const errorMessageId = (0, utils_1.useSlotId)([
|
|
112
|
-
Boolean(error || validationState.displayValidation.validationErrors),
|
|
113
|
-
validationState.displayValidation.isInvalid,
|
|
114
|
-
]);
|
|
115
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_aria_components_1.ComboBox, { ...props, ref: ref, id: inputId, className: (0, clsx_1.default)('cim-combo-box', 'cim-tag-field', UNSAFE_className), style: UNSAFE_style,
|
|
116
|
-
// Force no internal selection - we handle selection manually
|
|
117
|
-
selectedKey: null, inputValue: inputValue, onInputChange: setInputValue, menuTrigger: "focus", isReadOnly: isReadOnly, "data-readonly": isReadOnly ? true : undefined, onSelectionChange: (key) => {
|
|
118
|
-
if (key) {
|
|
119
|
-
onItemSelectionChange(key);
|
|
120
|
-
}
|
|
121
|
-
}, children: (0, jsx_runtime_1.jsxs)(react_aria_components_1.Provider, { values: [
|
|
122
|
-
[react_aria_components_1.TextContext, { slots: { description: { id: descriptionId }, errorMessage: { id: errorMessageId } } }],
|
|
123
|
-
[react_aria_components_1.GroupContext, { isInvalid: validationState.displayValidation.isInvalid, isDisabled }],
|
|
124
|
-
[react_aria_components_1.FieldErrorContext, validationState.displayValidation],
|
|
125
|
-
], children: [(0, jsx_runtime_1.jsx)(form_field_js_1.FormFieldLabel, { isRequired: isRequired, isDisabled: 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)(tag_field_input_js_1.TagFieldInput, { inputRef: inputRef, "aria-describedby": props['aria-describedby'], isReadOnly: isReadOnly, isRequired: isRequired, isInvalid: validationState.displayValidation.isInvalid, placeholder: selectedSet.size === 0 && placeholder
|
|
126
|
-
? placeholder
|
|
127
|
-
: messages.format('itemsSelected', { selectedItemCount: selectedSet.size }), onFocusChange: onFocusChange }), (0, jsx_runtime_1.jsx)(react_aria_components_1.Button, { className: "cim-combo-box-button", children: (0, jsx_runtime_1.jsx)(index_js_1.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)(tag_field_tags_js_1.TagFieldTags, { inputId: inputId, selectedKeys: selectedSet, isDisabled: isDisabled, isReadOnly: isReadOnly, renderEmptyState: renderEmptyState, onRemove: onItemSelectionChange }), (0, jsx_runtime_1.jsx)(collapsible_list_js_1.CollapsibleList, { offset: 5, maxHeight: 315, children: (0, jsx_runtime_1.jsx)(tag_field_list_box_js_1.TagFieldListBox, { inputId: inputId, items: items, selectedKeys: selectedSet, setSelectedKeys: setSelectedKeys, onScroll: onScroll, isVirtualized: isVirtualized, children: children }) })] }) }), (0, jsx_runtime_1.jsx)(react_aria_components_1.Input, { ref: formInputRef, style: { display: 'none' }, value: selectedSet.size || '', required: isRequired, "aria-invalid": validationState.displayValidation.isInvalid || undefined, onChange: () => { } }), name &&
|
|
128
|
-
[...selectedSet].map((value) => (0, jsx_runtime_1.jsx)("input", { type: "hidden", form: form, name: name, value: value }, value))] }));
|
|
43
|
+
return ((0, jsx_runtime_1.jsxs)(react_aria_components_1.ComboBox, { ...props, ref: ref, className: (0, clsx_1.default)('cim-combo-box', 'cim-tag-field', UNSAFE_className), style: UNSAFE_style, id: inputId, selectionMode: "multiple", value: selectedKeys ? Array.from(selectedKeys) : undefined, defaultValue: defaultSelectedKeys ? Array.from(defaultSelectedKeys) : undefined, onChange: (keys) => onSelectionChange?.(new Set(keys)), menuTrigger: "focus", isReadOnly: isReadOnly, "data-readonly": isReadOnly ? true : undefined, validate: validate
|
|
44
|
+
? ({ inputValue, value }) => {
|
|
45
|
+
return validate({ inputValue, selectedKeys: new Set(value) });
|
|
46
|
+
}
|
|
47
|
+
: undefined, children: [(0, jsx_runtime_1.jsx)(form_field_js_1.FormFieldLabel, { isRequired: isRequired, isDisabled: 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)(tag_field_input_js_1.TagFieldInput, { inputRef: inputRef, "aria-describedby": props['aria-describedby'], 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_1.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)(react_aria_components_1.ComboBoxValue, { children: ({ state }) => ((0, jsx_runtime_1.jsx)(tag_group_js_1.TagGroup, { "aria-labelledby": inputId, disabledKeys: isDisabled ? state.selectedItems.map((item) => item.key) : undefined, renderEmptyState: renderEmptyState, onRemove: isReadOnly
|
|
48
|
+
? undefined
|
|
49
|
+
: (keys) => {
|
|
50
|
+
if (Array.isArray(state.value)) {
|
|
51
|
+
state.setValue(state.value.filter((k) => !keys.has(k)));
|
|
52
|
+
}
|
|
53
|
+
}, children: state.selectedItems.map((item) => ((0, jsx_runtime_1.jsx)(tag_js_1.Tag, { id: item.key, isDisabled: item.props.isDisabled, children: item.textValue }, item.key))) })) }), (0, jsx_runtime_1.jsx)(collapsible_list_js_1.CollapsibleList, { offset: 5, maxHeight: 315, children: (0, jsx_runtime_1.jsx)(tag_field_list_box_js_1.TagFieldListBox, { items: items, onScroll: onScroll, isVirtualized: isVirtualized, children: children }) })] }));
|
|
129
54
|
}
|
|
130
55
|
/**
|
|
131
56
|
* Allows users to filter a collapsible list and select multiple items from it.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tag-field.js","sourceRoot":"","sources":["../../../../src/components/tag-field/tag-field.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;AAmXb,oCAiBC;AAYD,0CAoBC;;AAlaD,2CAAqD;AACrD,6CAAmE;AACnE,8CAA6D;AAC7D,gDAA0D;AAC1D,gDAAwB;AACxB,iCAA+G;AAC/G,iEAgB+B;AAC/B,yDAAkD;AAClD,kFAA2E;AAC3E,mDAAuD;AACvD,mEAA4D;AAC5D,qFAA6E;AAC7E,mEAA2D;AAC3D,gGAAyF;AACzF,0FAAmF;AACnF,wEAA4G;AAW5G,qDAAmD;AACnD,6DAAqD;AACrD,mEAA0D;AAC1D,2DAAmD;AAoDnD,SAAS,QAAQ,CACf,EACE,KAAK,EACL,WAAW,EACX,KAAK,EACL,KAAK,EACL,QAAQ,EACR,WAAW,EACX,gBAAgB,EAChB,YAAY,EACZ,UAAU,EACV,UAAU,EAAE,kBAAkB,EAC9B,iBAAiB,EAAE,yBAAyB,EAC5C,aAAa,EACb,IAAI,EACJ,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,YAAY,EAAE,oBAAoB,EAClC,mBAAmB,EAAE,2BAA2B,EAChD,iBAAiB,EACjB,EAAE,EACF,gBAAgB,EAChB,aAAa,GAAG,KAAK,EACrB,MAAM,EACN,GAAG,KAAK,EACS,EACnB,GAAiC;IAEjC,MAAM,QAAQ,GAAG,IAAA,cAAM,EAAmB,IAAI,CAAC,CAAC;IAEhD,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,iBAAiB,EAAE,cAAc,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,KAAK,CAAC;IAEhH,IAAA,gDAAoB,EAAC,G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AAC,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 { useFormValidation } from '@react-aria/form';\nimport { useFormReset, useId, useSlotId } from '@react-aria/utils';\nimport { useFormValidationState } from '@react-stately/form';\nimport { useControlledState } from '@react-stately/utils';\nimport clsx from 'clsx';\nimport { type ForwardedRef, type UIEventHandler, useImperativeHandle, useMemo, useRef, useState } from 'react';\nimport {\n Button as RACButton,\n Collection as RACCollection,\n ComboBox as RACComboBox,\n Group as RACGroup,\n Header as RACHeader,\n Input as RACInput,\n ListBoxItem as RACListBoxItem,\n ListBoxSection as RACListBoxSection,\n Text as RACText,\n type ComboBoxProps as RACComboBoxProps,\n type ListBoxItemProps as RACListBoxItemProps,\n Provider as RACProvider,\n TextContext as RACTextContext,\n GroupContext as RACGroupContext,\n FieldErrorContext as RACFieldErrorContext,\n} from 'react-aria-components';\nimport { forwardRef } from '../../forward-ref.js';\nimport { useLocalizedMessages } from '../../i18n/localization-provider.js';\nimport { 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 { CheckboxIndicator } from '../internal/checkbox-indicator/checkbox-indicator.js';\nimport { CollapsibleList } from '../internal/collapsible-list/collapsible-list.js';\nimport { FormFieldDescription, FormFieldError, FormFieldLabel } from '../internal/form-field/form-field.js';\nimport type { TagGroupProps } from '../tag/tag-group.js';\nimport type {\n ApiProps,\n CollectionItem,\n CollectionProps,\n CommonProps,\n FieldWithPlaceholderProps,\n Key,\n StringLikeChildren,\n} from '../types.js';\nimport { textStyle } from '../typography/utils.js';\nimport { TagFieldInput } from './tag-field-input.js';\nimport { TagFieldListBox } from './tag-field-list-box.js';\nimport { TagFieldTags } from './tag-field-tags.js';\n\n/** Represents the state of the `TagField` component for validation purposes. */\nexport interface TagFieldValidationValue {\n /** The selected keys in the TagField. */\n selectedKeys: Set<Key> | null;\n /** The value of the TagField input. */\n inputValue: string;\n}\n\nexport interface TagFieldProps<T extends CollectionItem = CollectionItem>\n extends\n CommonProps,\n FieldWithPlaceholderProps<TagFieldValidationValue>,\n CollectionProps<T>,\n ApiProps<TagFieldApi>,\n Pick<\n RACComboBoxProps<T>,\n | 'isRequired'\n | 'isDisabled'\n | 'isInvalid'\n | 'isReadOnly'\n | 'inputValue'\n | 'defaultInputValue'\n | 'autoFocus'\n | 'onInputChange'\n | 'onFocus'\n | 'onBlur'\n | 'onOpenChange'\n >,\n Pick<TagGroupProps<T>, 'renderEmptyState'> {\n /** The currently selected keys in the collection (controlled). */\n selectedKeys?: Iterable<Key>;\n /** The initial selected keys in the collection (uncontrolled). */\n defaultSelectedKeys?: Iterable<Key>;\n /** Handler that is called when the selection changes. */\n onSelectionChange?: (keys: Set<Key>) => void;\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 /** Handler that is called when the list of items is scrolled. */\n onScroll?: UIEventHandler<HTMLDivElement>;\n}\n\n/** The imperative API exposed by the `TagField` component. */\nexport interface TagFieldApi {\n /** Focuses the input field and opens the list of items. */\n focus: () => void;\n}\n\nfunction TagField<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 inputValue: consumerInputValue,\n defaultInputValue: defaultConsumerInputValue,\n onInputChange,\n form,\n name,\n validate,\n onScroll,\n selectedKeys: consumerSelectedKeys,\n defaultSelectedKeys: defaultConsumerSelectedKeys,\n onSelectionChange,\n id,\n renderEmptyState,\n isVirtualized = false,\n apiRef,\n ...props\n }: TagFieldProps<T>,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const inputRef = useRef<HTMLInputElement>(null);\n\n const { 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, isRequired, isDisabled, isInvalid } = props;\n\n useProductionWarning(() => {\n if (!label && !ariaLabel && !ariaLabelledBy) {\n console.warn('TagField 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('`TagField` requires `children` to be a function when using `items` prop');\n }\n\n const messages = useLocalizedMessages('tagField');\n\n useImperativeHandle(\n apiRef,\n () => ({\n focus: () => inputRef.current?.focus(),\n }),\n [],\n );\n\n // State\n\n const [defaultSelectedKeys] = useState(() => defaultConsumerSelectedKeys ?? new Set<Key>());\n const [selectedKeys, setSelectedKeys] = useControlledState(\n consumerSelectedKeys,\n defaultSelectedKeys,\n onSelectionChange,\n );\n const [inputValue, setInputValue] = useControlledState(\n consumerInputValue,\n defaultConsumerInputValue ?? '',\n onInputChange,\n );\n\n const selectedSet = useMemo(() => {\n // eslint-disable-next-line unicorn/no-instanceof-builtins\n if (selectedKeys instanceof Set) {\n return new Set<Key>(selectedKeys.values());\n }\n\n return new Set<Key>(selectedKeys);\n }, [selectedKeys]);\n\n // Validation\n\n const inputId = useId(id);\n const formInputRef = useRef<HTMLInputElement>(null);\n\n const validationState = useFormValidationState({\n name,\n value: useMemo(() => ({ selectedKeys: selectedSet, inputValue }), [selectedSet, inputValue]),\n isInvalid,\n isRequired,\n validate,\n validationBehavior: 'native',\n });\n\n const [initialSelectedKeys] = useState(selectedKeys);\n const [initialInputValue] = useState(inputValue);\n\n useFormReset<[Iterable<Key>, string]>(\n formInputRef,\n [defaultConsumerSelectedKeys ?? initialSelectedKeys, defaultConsumerInputValue ?? initialInputValue],\n ([a, b]) => {\n setSelectedKeys(a);\n setInputValue(b);\n },\n );\n\n useFormValidation(\n {\n focus: () => {\n // Querying by element ID because a ref is always null here, I don't know why :(\n document.getElementById(inputId)?.focus();\n },\n isInvalid,\n isRequired,\n validate,\n validationBehavior: 'native',\n },\n validationState,\n formInputRef,\n );\n\n // Event handlers\n\n // Commit validation on input blur if the values have changed\n const inputValueOnFocus = useRef(inputValue);\n const selectedSetOnFocus = useRef(selectedSet);\n\n const onFocusChange = (isFocused: boolean) => {\n if (isFocused) {\n inputValueOnFocus.current = inputValue;\n selectedSetOnFocus.current = selectedSet;\n } else if (inputValue !== inputValueOnFocus.current || selectedSet !== selectedSetOnFocus.current) {\n validationState.commitValidation();\n }\n };\n\n const onItemSelectionChange = (key: Key) => {\n if (selectedSet.has(key)) {\n // This is a temporary mutation followed immediately by a state update, so this is fine\n // eslint-disable-next-line react-hooks/immutability\n selectedSet.delete(key);\n } else {\n selectedSet.add(key);\n }\n\n setSelectedKeys(new Set(selectedSet.values()));\n validationState.commitValidation();\n };\n\n // Text slots\n\n const descriptionId = useSlotId([Boolean(description)]);\n\n const errorMessageId = useSlotId([\n Boolean(error || validationState.displayValidation.validationErrors),\n validationState.displayValidation.isInvalid,\n ]);\n\n return (\n <>\n <RACComboBox\n {...props}\n ref={ref}\n id={inputId}\n className={clsx('cim-combo-box', 'cim-tag-field', UNSAFE_className)}\n style={UNSAFE_style}\n // Force no internal selection - we handle selection manually\n selectedKey={null}\n inputValue={inputValue}\n onInputChange={setInputValue}\n menuTrigger=\"focus\"\n isReadOnly={isReadOnly}\n data-readonly={isReadOnly ? true : undefined}\n onSelectionChange={(key) => {\n if (key) {\n onItemSelectionChange(key);\n }\n }}\n >\n <RACProvider\n values={[\n [RACTextContext, { slots: { description: { id: descriptionId }, errorMessage: { id: errorMessageId } } }],\n [RACGroupContext, { isInvalid: validationState.displayValidation.isInvalid, isDisabled }],\n [RACFieldErrorContext, validationState.displayValidation],\n ]}\n >\n <FormFieldLabel isRequired={isRequired} isDisabled={isDisabled}>\n {label}\n </FormFieldLabel>\n\n <RACGroup className=\"cim-combo-box-input-group\">\n <TagFieldInput\n inputRef={inputRef}\n aria-describedby={props['aria-describedby']}\n isReadOnly={isReadOnly}\n isRequired={isRequired}\n isInvalid={validationState.displayValidation.isInvalid}\n placeholder={\n selectedSet.size === 0 && placeholder\n ? placeholder\n : messages.format('itemsSelected', { selectedItemCount: selectedSet.size })\n }\n onFocusChange={onFocusChange}\n />\n <RACButton className=\"cim-combo-box-button\">\n <IconChevronDown />\n </RACButton>\n </RACGroup>\n\n <FormFieldError>{error}</FormFieldError>\n <FormFieldDescription>{description}</FormFieldDescription>\n\n <TagFieldTags<T>\n inputId={inputId}\n selectedKeys={selectedSet}\n isDisabled={isDisabled}\n isReadOnly={isReadOnly}\n renderEmptyState={renderEmptyState}\n onRemove={onItemSelectionChange}\n />\n\n <CollapsibleList\n offset={5} // 1px border + 4px actual offset\n maxHeight={315}\n >\n <TagFieldListBox<T>\n inputId={inputId}\n items={items}\n selectedKeys={selectedSet}\n setSelectedKeys={setSelectedKeys}\n onScroll={onScroll}\n isVirtualized={isVirtualized}\n >\n {children}\n </TagFieldListBox>\n </CollapsibleList>\n </RACProvider>\n </RACComboBox>\n\n {/* This input is used for native form validation. We can't use the combo box input because its value has no relation to the selected values. */}\n <RACInput\n ref={formInputRef}\n style={{ display: 'none' }}\n value={selectedSet.size || ''}\n required={isRequired}\n aria-invalid={validationState.displayValidation.isInvalid || undefined}\n onChange={() => {}}\n />\n\n {/* These hidden inputs provide values when a form is submitted. */}\n {name &&\n [...selectedSet].map((value) => <input type=\"hidden\" key={value} form={form} name={name} value={value} />)}\n </>\n );\n}\n\n/**\n * Allows users to filter a collapsible list and select multiple items from it.\n *\n * See [tag field usage guidelines](https://ui.cimpress.io/components/tag-field).\n */\nconst _TagField = withStyleProps(forwardRef(TagField), 'TagField');\n\nexport { _TagField as TagField };\n\nexport interface TagFieldItemProps<T extends CollectionItem> extends Pick<\n RACListBoxItemProps<T>,\n 'isDisabled' | 'onHoverStart' | 'onHoverEnd'\n> {\n /** The ID of the item. Has to be unique across all sections and items. */\n id?: Key;\n /** The content to display as the label. */\n children: StringLikeChildren;\n}\n\n/** Renders a single list item within `TagField`. */\nexport function TagFieldItem<T extends CollectionItem>({ children, ...props }: TagFieldItemProps<T>) {\n const textValue =\n typeof children === 'string' ? children : typeof children === 'number' ? String(children) : children.join('');\n\n return (\n <RACListBoxItem {...props} className=\"cim-tag-field-item cim-checkbox-indicator-wrapper\" textValue={textValue}>\n {({ isDisabled }) => (\n <>\n <CheckboxIndicator />\n\n <RACText slot=\"label\" className={textStyle({ variant: 'medium', tone: isDisabled ? 'muted' : 'base' })}>\n {children}\n </RACText>\n </>\n )}\n </RACListBoxItem>\n );\n}\n\nTagFieldItem.displayName = 'TagFieldItem';\n\nexport interface TagFieldSectionProps<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 `TagField` into a section. */\nexport function TagFieldSection<T extends CollectionItem>({\n title,\n children,\n items,\n ...props\n}: TagFieldSectionProps<T>) {\n if (!isProduction() && items != null && typeof children !== 'function') {\n console.warn('`TagFieldSection` 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\nTagFieldSection.displayName = 'TagFieldSection';\n"]}
|
|
1
|
+
{"version":3,"file":"tag-field.js","sourceRoot":"","sources":["../../../../src/components/tag-field/tag-field.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;AA6Ob,oCAiBC;AAYD,0CAoBC;;AA5RD,gDAAwB;AACxB,iCAA4F;AAC5F,2CAAmC;AACnC,iEAY+B;AAC/B,yDAAkD;AAClD,mDAAuD;AACvD,mEAA4D;AAC5D,qFAA6E;AAC7E,mEAA2D;A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I,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 { type ForwardedRef, type UIEventHandler, useImperativeHandle, useRef } from 'react';\nimport { useId } from 'react-aria';\nimport {\n Button as RACButton,\n Collection as RACCollection,\n ComboBox as RACComboBox,\n Group as RACGroup,\n Header as RACHeader,\n ListBoxItem as RACListBoxItem,\n ListBoxSection as RACListBoxSection,\n Text as RACText,\n type ComboBoxProps as RACComboBoxProps,\n type ListBoxItemProps as RACListBoxItemProps,\n ComboBoxValue as RACComboBoxValue,\n} from 'react-aria-components';\nimport { forwardRef } from '../../forward-ref.js';\nimport { 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 { CheckboxIndicator } from '../internal/checkbox-indicator/checkbox-indicator.js';\nimport { CollapsibleList } from '../internal/collapsible-list/collapsible-list.js';\nimport { FormFieldDescription, FormFieldError, FormFieldLabel } from '../internal/form-field/form-field.js';\nimport { TagGroup, type TagGroupProps } from '../tag/tag-group.js';\nimport { Tag, type TagProps } from '../tag/tag.js';\nimport type {\n ApiProps,\n CollectionItem,\n CollectionProps,\n CommonProps,\n FieldWithPlaceholderProps,\n Key,\n StringLikeChildren,\n} from '../types.js';\nimport { textStyle } from '../typography/utils.js';\nimport { TagFieldInput } from './tag-field-input.js';\nimport { TagFieldListBox } from './tag-field-list-box.js';\n\n/** Represents the state of the `TagField` component for validation purposes. */\nexport interface TagFieldValidationValue {\n /** The selected keys in the TagField. */\n selectedKeys: Set<Key> | null;\n /** The value of the TagField input. */\n inputValue: string;\n}\n\nexport interface TagFieldProps<T extends CollectionItem = CollectionItem>\n extends\n CommonProps,\n FieldWithPlaceholderProps<TagFieldValidationValue>,\n CollectionProps<T>,\n ApiProps<TagFieldApi>,\n Pick<\n RACComboBoxProps<T>,\n | 'isRequired'\n | 'isDisabled'\n | 'isInvalid'\n | 'isReadOnly'\n | 'inputValue'\n | 'defaultInputValue'\n | 'autoFocus'\n | 'onInputChange'\n | 'onFocus'\n | 'onBlur'\n | 'onOpenChange'\n >,\n Pick<TagGroupProps<T>, 'renderEmptyState'> {\n /** The currently selected keys in the collection (controlled). */\n selectedKeys?: Iterable<Key>;\n /** The initial selected keys in the collection (uncontrolled). */\n defaultSelectedKeys?: Iterable<Key>;\n /** Handler that is called when the selection changes. */\n onSelectionChange?: (keys: Set<Key>) => void;\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 /** Handler that is called when the list of items is scrolled. */\n onScroll?: UIEventHandler<HTMLDivElement>;\n}\n\n/** The imperative API exposed by the `TagField` component. */\nexport interface TagFieldApi {\n /** Focuses the input field and opens the list of items. */\n focus: () => void;\n}\n\nfunction TagField<T extends CollectionItem>(\n {\n label,\n description,\n error,\n items,\n children,\n placeholder,\n UNSAFE_className,\n UNSAFE_style,\n validate,\n isReadOnly,\n onScroll,\n selectedKeys,\n defaultSelectedKeys,\n onSelectionChange,\n id,\n renderEmptyState,\n isVirtualized = false,\n apiRef,\n ...props\n }: TagFieldProps<T>,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const inputRef = useRef<HTMLInputElement>(null);\n\n const { 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, isRequired, isDisabled } = props;\n\n useProductionWarning(() => {\n if (!label && !ariaLabel && !ariaLabelledBy) {\n console.warn('TagField 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('`TagField` requires `children` to be a function when using `items` prop');\n }\n\n const inputId = useId(id);\n\n useImperativeHandle(\n apiRef,\n () => ({\n focus: () => inputRef.current?.focus(),\n }),\n [],\n );\n\n return (\n <RACComboBox\n {...props}\n ref={ref}\n className={clsx('cim-combo-box', 'cim-tag-field', UNSAFE_className)}\n style={UNSAFE_style}\n id={inputId}\n selectionMode=\"multiple\"\n value={selectedKeys ? Array.from(selectedKeys) : undefined}\n defaultValue={defaultSelectedKeys ? Array.from(defaultSelectedKeys) : undefined}\n onChange={(keys) => onSelectionChange?.(new Set(keys))}\n menuTrigger=\"focus\"\n isReadOnly={isReadOnly}\n data-readonly={isReadOnly ? true : undefined}\n validate={\n validate\n ? ({ inputValue, value }) => {\n return validate({ inputValue, selectedKeys: new Set(value as unknown as Key[]) });\n }\n : undefined\n }\n >\n <FormFieldLabel isRequired={isRequired} isDisabled={isDisabled}>\n {label}\n </FormFieldLabel>\n\n <RACGroup className=\"cim-combo-box-input-group\">\n <TagFieldInput\n inputRef={inputRef}\n aria-describedby={props['aria-describedby']}\n isReadOnly={isReadOnly}\n placeholder={placeholder}\n />\n <RACButton className=\"cim-combo-box-button\">\n <IconChevronDown />\n </RACButton>\n </RACGroup>\n\n <FormFieldError>{error}</FormFieldError>\n <FormFieldDescription>{description}</FormFieldDescription>\n\n <RACComboBoxValue>\n {({ state }) => (\n <TagGroup\n aria-labelledby={inputId}\n disabledKeys={isDisabled ? state.selectedItems.map((item) => item.key) : undefined}\n renderEmptyState={renderEmptyState}\n onRemove={\n isReadOnly\n ? undefined\n : (keys) => {\n if (Array.isArray(state.value)) {\n state.setValue(state.value.filter((k) => !keys.has(k)));\n }\n }\n }\n >\n {state.selectedItems.map((item) => (\n <Tag key={item.key} id={item.key} isDisabled={(item.props as TagProps).isDisabled}>\n {item.textValue}\n </Tag>\n ))}\n </TagGroup>\n )}\n </RACComboBoxValue>\n\n <CollapsibleList\n offset={5} // 1px border + 4px actual offset\n maxHeight={315}\n >\n <TagFieldListBox<T> items={items} onScroll={onScroll} isVirtualized={isVirtualized}>\n {children}\n </TagFieldListBox>\n </CollapsibleList>\n </RACComboBox>\n );\n}\n\n/**\n * Allows users to filter a collapsible list and select multiple items from it.\n *\n * See [tag field usage guidelines](https://ui.cimpress.io/components/tag-field).\n */\nconst _TagField = withStyleProps(forwardRef(TagField), 'TagField');\n\nexport { _TagField as TagField };\n\nexport interface TagFieldItemProps<T extends CollectionItem> extends Pick<\n RACListBoxItemProps<T>,\n 'isDisabled' | 'onHoverStart' | 'onHoverEnd'\n> {\n /** The ID of the item. Has to be unique across all sections and items. */\n id?: Key;\n /** The content to display as the label. */\n children: StringLikeChildren;\n}\n\n/** Renders a single list item within `TagField`. */\nexport function TagFieldItem<T extends CollectionItem>({ children, ...props }: TagFieldItemProps<T>) {\n const textValue =\n typeof children === 'string' ? children : typeof children === 'number' ? String(children) : children.join('');\n\n return (\n <RACListBoxItem {...props} className=\"cim-tag-field-item cim-checkbox-indicator-wrapper\" textValue={textValue}>\n {({ isDisabled }) => (\n <>\n <CheckboxIndicator />\n\n <RACText slot=\"label\" className={textStyle({ variant: 'medium', tone: isDisabled ? 'muted' : 'base' })}>\n {children}\n </RACText>\n </>\n )}\n </RACListBoxItem>\n );\n}\n\nTagFieldItem.displayName = 'TagFieldItem';\n\nexport interface TagFieldSectionProps<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 `TagField` into a section. */\nexport function TagFieldSection<T extends CollectionItem>({\n title,\n children,\n items,\n ...props\n}: TagFieldSectionProps<T>) {\n if (!isProduction() && items != null && typeof children !== 'function') {\n console.warn('`TagFieldSection` 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\nTagFieldSection.displayName = 'TagFieldSection';\n"]}
|