@accelint/design-toolkit 9.9.0 → 9.9.2
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/catalog-info.yaml +7 -4
- package/dist/components/accordion/context.d.ts +2 -2
- package/dist/components/accordion/group.d.ts +2 -2
- package/dist/components/accordion/header.d.ts +2 -2
- package/dist/components/accordion/index.d.ts +2 -2
- package/dist/components/accordion/panel.d.ts +2 -2
- package/dist/components/accordion/trigger.d.ts +2 -2
- package/dist/components/action-bar/index.d.ts +2 -2
- package/dist/components/audio/index.d.ts +2 -2
- package/dist/components/avatar/context.d.ts +4 -4
- package/dist/components/avatar/index.d.ts +2 -2
- package/dist/components/badge/index.d.ts +2 -2
- package/dist/components/breadcrumbs/index.d.ts +2 -2
- package/dist/components/breadcrumbs/item.d.ts +2 -2
- package/dist/components/button/context.d.ts +4 -4
- package/dist/components/button/index.d.ts +2 -2
- package/dist/components/button/link.d.ts +2 -2
- package/dist/components/checkbox/index.d.ts +2 -2
- package/dist/components/chip/context.d.ts +4 -4
- package/dist/components/chip/deletable.d.ts +2 -2
- package/dist/components/chip/index.d.ts +2 -2
- package/dist/components/chip/list.d.ts +4 -4
- package/dist/components/chip/selectable.d.ts +2 -2
- package/dist/components/classification-badge/context.d.ts +4 -4
- package/dist/components/classification-badge/index.d.ts +2 -2
- package/dist/components/classification-banner/context.d.ts +4 -4
- package/dist/components/classification-banner/index.d.ts +2 -2
- package/dist/components/clock/index.d.ts +2 -2
- package/dist/components/color-picker/index.d.ts +2 -2
- package/dist/components/combobox-field/context.d.ts +2 -2
- package/dist/components/combobox-field/index.d.ts +2 -2
- package/dist/components/coordinate-field/context.d.ts +6 -6
- package/dist/components/coordinate-field/index.d.ts +2 -2
- package/dist/components/coordinate-field/segment.d.ts +2 -2
- package/dist/components/date-field/index.d.ts +2 -2
- package/dist/components/deferred-collection/index.d.ts +2 -2
- package/dist/components/details-list/context.d.ts +4 -4
- package/dist/components/details-list/index.d.ts +2 -2
- package/dist/components/details-list/label.d.ts +2 -2
- package/dist/components/details-list/value.d.ts +2 -2
- package/dist/components/dialog/content.d.ts +2 -2
- package/dist/components/dialog/context.d.ts +2 -2
- package/dist/components/dialog/footer.d.ts +2 -2
- package/dist/components/dialog/index.d.ts +2 -2
- package/dist/components/dialog/title.d.ts +2 -2
- package/dist/components/divider/context.d.ts +4 -4
- package/dist/components/divider/index.d.ts +2 -2
- package/dist/components/drawer/back.d.ts +2 -2
- package/dist/components/drawer/close.d.ts +2 -2
- package/dist/components/drawer/content.d.ts +2 -2
- package/dist/components/drawer/context.d.ts +2 -2
- package/dist/components/drawer/header-title.d.ts +2 -2
- package/dist/components/drawer/header.d.ts +2 -2
- package/dist/components/drawer/index.d.ts +2 -2
- package/dist/components/drawer/layout-main.d.ts +2 -2
- package/dist/components/drawer/layout.d.ts +2 -2
- package/dist/components/drawer/menu-item.d.ts +2 -2
- package/dist/components/drawer/menu.d.ts +2 -2
- package/dist/components/drawer/panel.d.ts +2 -2
- package/dist/components/drawer/trigger.d.ts +2 -2
- package/dist/components/drawer/view.d.ts +2 -2
- package/dist/components/flashcard/index.d.ts +9 -9
- package/dist/components/floating-card/context.d.ts +2 -2
- package/dist/components/floating-card/index.d.ts +2 -2
- package/dist/components/floating-card/provider.d.ts +2 -2
- package/dist/components/hero/context.d.ts +2 -2
- package/dist/components/hero/index.d.ts +2 -2
- package/dist/components/hero/subtitle.d.ts +2 -2
- package/dist/components/hero/title.d.ts +2 -2
- package/dist/components/hotkey/context.d.ts +4 -4
- package/dist/components/hotkey/index.d.ts +2 -2
- package/dist/components/hotkey/set.d.ts +2 -2
- package/dist/components/icon/context.d.ts +4 -4
- package/dist/components/icon/index.d.ts +2 -2
- package/dist/components/input/context.d.ts +2 -2
- package/dist/components/input/index.d.ts +2 -2
- package/dist/components/kanban/card-body.d.ts +2 -2
- package/dist/components/kanban/card-header-actions.d.ts +2 -2
- package/dist/components/kanban/card-header-title.d.ts +2 -2
- package/dist/components/kanban/card-header.d.ts +2 -2
- package/dist/components/kanban/card.d.ts +2 -2
- package/dist/components/kanban/column-actions.d.ts +2 -2
- package/dist/components/kanban/column-container.d.ts +2 -2
- package/dist/components/kanban/column-content.d.ts +2 -2
- package/dist/components/kanban/column-header-actions.d.ts +2 -2
- package/dist/components/kanban/column-header-drag-handle.d.ts +2 -2
- package/dist/components/kanban/column-header-title.d.ts +2 -2
- package/dist/components/kanban/column-header.d.ts +2 -2
- package/dist/components/kanban/column.d.ts +2 -2
- package/dist/components/kanban/context.d.ts +2 -2
- package/dist/components/kanban/header-actions.d.ts +2 -2
- package/dist/components/kanban/header-search.d.ts +2 -2
- package/dist/components/kanban/header-title.d.ts +2 -2
- package/dist/components/kanban/header.d.ts +2 -2
- package/dist/components/kanban/kanban.d.ts +4 -4
- package/dist/components/kanban/styles.module.css +5 -0
- package/dist/components/label/context.d.ts +4 -4
- package/dist/components/label/index.d.ts +2 -2
- package/dist/components/lines/index.d.ts +2 -2
- package/dist/components/link/context.d.ts +2 -2
- package/dist/components/link/index.d.ts +2 -2
- package/dist/components/list/context.d.ts +2 -2
- package/dist/components/list/index.d.ts +2 -2
- package/dist/components/list/item-content.d.ts +2 -2
- package/dist/components/list/item-description.d.ts +2 -2
- package/dist/components/list/item-title.d.ts +2 -2
- package/dist/components/list/item.d.ts +2 -2
- package/dist/components/media-controls/context.d.ts +4 -4
- package/dist/components/media-controls/fullscreen-button.d.ts +2 -2
- package/dist/components/media-controls/index.d.ts +2 -2
- package/dist/components/media-controls/mute-button.d.ts +2 -2
- package/dist/components/media-controls/play-button.d.ts +2 -2
- package/dist/components/media-controls/playback-rate.d.ts +2 -2
- package/dist/components/media-controls/seek-button.d.ts +2 -2
- package/dist/components/media-controls/time-display.d.ts +2 -2
- package/dist/components/media-controls/time-range.d.ts +2 -2
- package/dist/components/media-controls/volume-slider.d.ts +2 -2
- package/dist/components/menu/context.d.ts +2 -2
- package/dist/components/menu/index.d.ts +2 -2
- package/dist/components/menu/item-description.d.ts +2 -2
- package/dist/components/menu/item-label.d.ts +2 -2
- package/dist/components/menu/item.d.ts +2 -2
- package/dist/components/menu/section.d.ts +2 -2
- package/dist/components/menu/separator.d.ts +2 -2
- package/dist/components/menu/submenu.d.ts +2 -2
- package/dist/components/notice/index.d.ts +2 -2
- package/dist/components/notice/list.d.ts +2 -2
- package/dist/components/notice/notice-icon.d.ts +2 -2
- package/dist/components/options/context.d.ts +2 -2
- package/dist/components/options/index.d.ts +2 -2
- package/dist/components/options/item-content.d.ts +2 -2
- package/dist/components/options/item-description.d.ts +2 -2
- package/dist/components/options/item-label.d.ts +2 -2
- package/dist/components/options/item.d.ts +2 -2
- package/dist/components/options/section.d.ts +2 -2
- package/dist/components/pagination/context.d.ts +2 -2
- package/dist/components/pagination/index.d.ts +2 -2
- package/dist/components/pagination/next.d.ts +2 -2
- package/dist/components/pagination/pages.d.ts +2 -2
- package/dist/components/pagination/prev.d.ts +2 -2
- package/dist/components/popover/content.d.ts +2 -2
- package/dist/components/popover/footer.d.ts +2 -2
- package/dist/components/popover/index.d.ts +2 -2
- package/dist/components/popover/title.d.ts +2 -2
- package/dist/components/popover/trigger.d.ts +2 -2
- package/dist/components/query-builder/action-element.d.ts +2 -2
- package/dist/components/query-builder/actions.d.ts +4 -4
- package/dist/components/query-builder/combinator-selector.d.ts +2 -2
- package/dist/components/query-builder/index.d.ts +2 -2
- package/dist/components/query-builder/rule-group.d.ts +4 -4
- package/dist/components/query-builder/rule.d.ts +2 -2
- package/dist/components/query-builder/styles.module.css +4 -1
- package/dist/components/query-builder/value-editor.d.ts +2 -2
- package/dist/components/query-builder/value-editor.js +1 -1
- package/dist/components/query-builder/value-editor.js.map +1 -1
- package/dist/components/query-builder/value-selector.d.ts +2 -2
- package/dist/components/radio/context.d.ts +3 -3
- package/dist/components/radio/group.d.ts +2 -2
- package/dist/components/radio/index.d.ts +2 -2
- package/dist/components/search-field/context.d.ts +4 -4
- package/dist/components/search-field/index.d.ts +2 -2
- package/dist/components/select-field/context.d.ts +4 -4
- package/dist/components/select-field/index.d.ts +2 -2
- package/dist/components/sidenav/avatar.d.ts +2 -2
- package/dist/components/sidenav/content.d.ts +2 -2
- package/dist/components/sidenav/context.d.ts +2 -2
- package/dist/components/sidenav/footer.d.ts +2 -2
- package/dist/components/sidenav/header.d.ts +2 -2
- package/dist/components/sidenav/index.d.ts +2 -2
- package/dist/components/sidenav/item.d.ts +2 -2
- package/dist/components/sidenav/link.d.ts +2 -2
- package/dist/components/sidenav/menu-item.d.ts +2 -2
- package/dist/components/sidenav/menu.d.ts +2 -2
- package/dist/components/sidenav/styles.module.css +20 -8
- package/dist/components/sidenav/trigger.d.ts +2 -2
- package/dist/components/skeleton/index.d.ts +2 -2
- package/dist/components/slider/index.d.ts +2 -2
- package/dist/components/status-indicator/index.d.ts +2 -2
- package/dist/components/switch/context.d.ts +4 -4
- package/dist/components/switch/index.d.ts +2 -2
- package/dist/components/table/body.d.ts +2 -2
- package/dist/components/table/cell.d.ts +2 -2
- package/dist/components/table/context.d.ts +2 -2
- package/dist/components/table/header-cell.d.ts +2 -2
- package/dist/components/table/header.d.ts +2 -2
- package/dist/components/table/index.d.ts +6 -2
- package/dist/components/table/index.js +17 -4
- package/dist/components/table/index.js.map +1 -1
- package/dist/components/table/row.d.ts +2 -2
- package/dist/components/table/types.d.ts +17 -0
- package/dist/components/tabs/context.d.ts +6 -6
- package/dist/components/tabs/index.d.ts +2 -2
- package/dist/components/tabs/list.d.ts +2 -2
- package/dist/components/tabs/panel.d.ts +2 -2
- package/dist/components/tabs/tab.d.ts +2 -2
- package/dist/components/text-area-field/context.d.ts +4 -4
- package/dist/components/text-area-field/index.d.ts +2 -2
- package/dist/components/text-field/context.d.ts +4 -4
- package/dist/components/text-field/index.d.ts +2 -2
- package/dist/components/time-field/index.d.ts +2 -2
- package/dist/components/tooltip/context.d.ts +2 -2
- package/dist/components/tooltip/index.d.ts +2 -2
- package/dist/components/tooltip/trigger.d.ts +2 -2
- package/dist/components/tree/context.d.ts +3 -3
- package/dist/components/tree/index.d.ts +2 -2
- package/dist/components/tree/index.js +6 -4
- package/dist/components/tree/index.js.map +1 -1
- package/dist/components/tree/item-actions.d.ts +2 -2
- package/dist/components/tree/item-content.d.ts +2 -2
- package/dist/components/tree/item-content.js +9 -5
- package/dist/components/tree/item-content.js.map +1 -1
- package/dist/components/tree/item-description.d.ts +2 -2
- package/dist/components/tree/item-label.d.ts +2 -2
- package/dist/components/tree/item-prefix-icon.d.ts +2 -2
- package/dist/components/tree/item.d.ts +2 -2
- package/dist/components/tree/lines.d.ts +4 -2
- package/dist/components/tree/lines.js +8 -4
- package/dist/components/tree/lines.js.map +1 -1
- package/dist/components/tree/styles.module.css +23 -3
- package/dist/components/video/index.d.ts +2 -2
- package/dist/components/view-stack/context.d.ts +2 -2
- package/dist/components/view-stack/index.d.ts +2 -2
- package/dist/components/view-stack/trigger.d.ts +2 -2
- package/dist/components/view-stack/view.d.ts +2 -2
- package/dist/hooks/use-tree/state/index.js +7 -14
- package/dist/hooks/use-tree/state/index.js.map +1 -1
- package/dist/providers/portal.d.ts +2 -2
- package/dist/providers/theme-provider.d.ts +2 -2
- package/package.json +8 -8
|
@@ -28,9 +28,10 @@ import { useCallback, useContext, useMemo, useState } from "react";
|
|
|
28
28
|
import { clsx } from "@accelint/design-foundation/lib/utils";
|
|
29
29
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
30
30
|
import Kebab from "@accelint/icons/kebab";
|
|
31
|
+
import { useControlledState } from "@react-stately/utils";
|
|
31
32
|
import Pin from "@accelint/icons/pin";
|
|
32
33
|
import { useListData } from "@react-stately/data";
|
|
33
|
-
import { getCoreRowModel, getSortedRowModel, useReactTable } from "@tanstack/react-table";
|
|
34
|
+
import { getCoreRowModel, getPaginationRowModel, getSortedRowModel, useReactTable } from "@tanstack/react-table";
|
|
34
35
|
import styles from "./styles.module.css";
|
|
35
36
|
|
|
36
37
|
//#region src/components/table/index.tsx
|
|
@@ -93,7 +94,7 @@ function RowActionsMenu({ moveRowsDown, moveRowsUp, row, rows }) {
|
|
|
93
94
|
* <Table columns={columns} data={rows} enableSorting showCheckbox />
|
|
94
95
|
* ```
|
|
95
96
|
*/
|
|
96
|
-
function Table({ children, columns: columnsProp, data: dataProp, showCheckbox, rowSelection: rowSelectionProp, kebabPosition = "right", persistRowKebabMenu = true, persistHeaderKebabMenu = true, persistNumerals = false, enableSorting = true, enableColumnReordering = true, enableRowActions = true, manualSorting = false, onSortChange, onColumnReorderChange, onRowSelectionChange, fullWidth = false, ...rest }) {
|
|
97
|
+
function Table({ children, columns: columnsProp, data: dataProp, showCheckbox, rowSelection: rowSelectionProp, kebabPosition = "right", persistRowKebabMenu = true, persistHeaderKebabMenu = true, persistNumerals = false, enableSorting = true, enableColumnReordering = true, enableRowActions = true, manualSorting = false, onSortChange, onColumnReorderChange, onRowSelectionChange, fullWidth = false, pageSize, page: pageProp, defaultPage = 1, onPageChange, ...rest }) {
|
|
97
98
|
const { items: data, moveAfter, moveBefore } = useListData({ initialItems: dataProp });
|
|
98
99
|
const [rowSelection, setRowSelection] = useState(rowSelectionProp ?? {});
|
|
99
100
|
const [columnSelection, setColumnSelection] = useState(null);
|
|
@@ -101,6 +102,15 @@ function Table({ children, columns: columnsProp, data: dataProp, showCheckbox, r
|
|
|
101
102
|
top: [],
|
|
102
103
|
bottom: []
|
|
103
104
|
});
|
|
105
|
+
const [currentPage, setCurrentPage] = useControlledState(pageProp, defaultPage, onPageChange);
|
|
106
|
+
const pagination = useMemo(() => pageSize != null ? {
|
|
107
|
+
pageIndex: currentPage - 1,
|
|
108
|
+
pageSize
|
|
109
|
+
} : void 0, [currentPage, pageSize]);
|
|
110
|
+
const handlePaginationChange = useCallback((updater) => {
|
|
111
|
+
if (pagination == null) return;
|
|
112
|
+
setCurrentPage((typeof updater === "function" ? updater(pagination) : updater).pageIndex + 1);
|
|
113
|
+
}, [pagination, setCurrentPage]);
|
|
104
114
|
/**
|
|
105
115
|
* moveUpSelectedRows moves the selected rows up in the table.
|
|
106
116
|
* It finds the first selected row, determines its index,
|
|
@@ -202,7 +212,8 @@ function Table({ children, columns: columnsProp, data: dataProp, showCheckbox, r
|
|
|
202
212
|
},
|
|
203
213
|
state: {
|
|
204
214
|
rowSelection,
|
|
205
|
-
rowPinning
|
|
215
|
+
rowPinning,
|
|
216
|
+
...pagination != null && { pagination }
|
|
206
217
|
},
|
|
207
218
|
getRowId: (row, index) => {
|
|
208
219
|
return row.id ? row.id.toString() : index.toString();
|
|
@@ -212,8 +223,10 @@ function Table({ children, columns: columnsProp, data: dataProp, showCheckbox, r
|
|
|
212
223
|
manualSorting,
|
|
213
224
|
onRowSelectionChange: handleRowSelectionChange,
|
|
214
225
|
onRowPinningChange: setRowPinning,
|
|
226
|
+
onPaginationChange: handlePaginationChange,
|
|
215
227
|
getCoreRowModel: getCoreRowModel(),
|
|
216
|
-
getSortedRowModel: getSortedRowModel()
|
|
228
|
+
getSortedRowModel: getSortedRowModel(),
|
|
229
|
+
...pageSize != null && { getPaginationRowModel: getPaginationRowModel() }
|
|
217
230
|
});
|
|
218
231
|
const moveColumnLeft = useCallback((oldIndex) => {
|
|
219
232
|
setColumnOrder((order) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["actionColumn: NonNullable<typeof columnsProp>[number]"],"sources":["../../../src/components/table/index.tsx"],"sourcesContent":["/*\n * Copyright 2026 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n'use client';\nimport 'client-only';\nimport { clsx } from '@accelint/design-foundation/lib/utils';\nimport Kebab from '@accelint/icons/kebab';\nimport Pin from '@accelint/icons/pin';\nimport { useListData } from '@react-stately/data';\nimport {\n getCoreRowModel,\n getSortedRowModel,\n type Row,\n type RowPinningState,\n type RowSelectionState,\n useReactTable,\n} from '@tanstack/react-table';\nimport { useCallback, useContext, useMemo, useState } from 'react';\nimport { Button } from '../button';\nimport { Checkbox } from '../checkbox';\nimport { Icon } from '../icon';\nimport { Menu } from '../menu';\nimport { MenuItem } from '../menu/item';\nimport { MenuSeparator } from '../menu/separator';\nimport { MenuTrigger } from '../menu/trigger';\nimport { TableBody } from './body';\nimport { TableContext } from './context';\nimport { TableHeader } from './header';\nimport styles from './styles.module.css';\nimport type { Key } from '@react-types/shared';\nimport type { TableProps } from './types';\n\n// This width is for columns in the table that provide features:\n// - Row count\n// - Row actions kebab\n// - Row selection (checkbox)\n// These columns should not need to grow with table width\nconst META_COLUMN_WIDTH = 32;\n\ntype RowActionsMenuProps<T> = {\n row: Row<T>;\n rows: Row<T>[];\n moveRowsDown: (row: Row<T>, rows: Row<T>[]) => void;\n moveRowsUp: (row: Row<T>, rows: Row<T>[]) => void;\n};\n\nfunction RowActionsMenu<T>({\n moveRowsDown,\n moveRowsUp,\n row,\n rows,\n}: RowActionsMenuProps<T>) {\n const { enableRowActions, persistRowKebabMenu } = useContext(TableContext);\n const isPinned = !!row.getIsPinned();\n const hideRowKebab = !persistRowKebabMenu;\n\n return (\n enableRowActions && (\n <div className={clsx(hideRowKebab && styles.hideInRow)}>\n <MenuTrigger>\n <Button variant='icon' aria-label={`row ${row.index + 1} actions`}>\n <Icon>\n <Kebab />\n </Icon>\n </Button>\n <Menu>\n <MenuItem onAction={() => row.pin(isPinned ? false : 'top')}>\n {isPinned ? 'Unpin' : 'Pin'}\n </MenuItem>\n <MenuSeparator />\n <MenuItem\n onAction={() => moveRowsUp(row, rows)}\n isDisabled={isPinned || row.index === 0}\n >\n Move Up\n </MenuItem>\n <MenuItem\n onAction={() => moveRowsDown(row, rows)}\n isDisabled={isPinned || row.index === rows.length - 1}\n >\n Move Down\n </MenuItem>\n </Menu>\n </MenuTrigger>\n </div>\n )\n );\n}\n\n/**\n * Table - Configurable data table with sorting, selection, and row actions\n *\n * Supports data-driven mode with TanStack column definitions or static mode with subcomponents.\n *\n * @param props - {@link TableProps}\n * @param props.children - Custom children for static mode.\n * @param props.columns - Column definitions for data-driven mode.\n * @param props.data - Data array for data-driven mode.\n * @param props.showCheckbox - Whether to show selection checkboxes.\n * @param props.rowSelection - Initial row selection state.\n * @param props.kebabPosition - Position of row action menu.\n * @param props.persistRowKebabMenu - Keep row kebab menu visible.\n * @param props.persistHeaderKebabMenu - Keep header kebab menu visible.\n * @param props.persistNumerals - Keep row numerals visible.\n * @param props.enableSorting - Enable column sorting.\n * @param props.enableColumnReordering - Enable column reordering.\n * @param props.enableRowActions - Enable row action menu.\n * @param props.manualSorting - Use server-side sorting.\n * @param props.onSortChange - Callback when sort changes.\n * @param props.onColumnReorderChange - Callback when column order changes.\n * @param props.onRowSelectionChange - Callback when row selection changes.\n * @param props.fullWidth - Whether table uses full width.\n * @returns The rendered Table component.\n *\n * @example\n * ```tsx\n * <Table columns={columns} data={rows} enableSorting showCheckbox />\n * ```\n */\nexport function Table<T extends { id: Key }>({\n children,\n columns: columnsProp,\n data: dataProp,\n showCheckbox,\n rowSelection: rowSelectionProp,\n kebabPosition = 'right',\n persistRowKebabMenu = true,\n persistHeaderKebabMenu = true,\n persistNumerals = false,\n enableSorting = true,\n enableColumnReordering = true,\n enableRowActions = true,\n manualSorting = false,\n onSortChange,\n onColumnReorderChange,\n onRowSelectionChange,\n fullWidth = false,\n ...rest\n}: TableProps<T>) {\n const {\n items: data,\n moveAfter,\n moveBefore,\n } = useListData({\n initialItems: dataProp,\n });\n const [rowSelection, setRowSelection] = useState<RowSelectionState>(\n rowSelectionProp ?? {},\n );\n const [columnSelection, setColumnSelection] = useState<string | null>(null);\n const [rowPinning, setRowPinning] = useState<RowPinningState>({\n top: [],\n bottom: [],\n });\n\n /**\n * moveUpSelectedRows moves the selected rows up in the table.\n * It finds the first selected row, determines its index,\n * and moves it before the previous row if it exists.\n */\n const moveRowsUp = useCallback(\n (row: Row<T>, rows: Row<T>[]) => {\n const isSelected = rowSelection[row.id];\n const rowsToMove = isSelected\n ? rows.filter(({ id }) => rowSelection[id])\n : [row];\n const firstRowToMove = rowsToMove[0];\n\n if (!firstRowToMove || firstRowToMove.index === 0) {\n return;\n }\n\n const prevRowId = rows[firstRowToMove.index - 1]?.id;\n\n if (!prevRowId) {\n return;\n }\n\n moveBefore(\n prevRowId,\n rowsToMove.map(({ id }) => id),\n );\n },\n [rowSelection, moveBefore],\n );\n\n /**\n * moveDownRows moves the selected or active rows down in the table.\n * It finds the last selected row, determines its index,\n * and moves it after the next row if it exists.\n */\n const moveRowsDown = useCallback(\n (row: Row<T>, rows: Row<T>[]) => {\n const isSelected = rowSelection[row.id];\n const rowsToMove = isSelected\n ? rows.filter(({ id }) => rowSelection[id])\n : [row];\n const lastRowToMove = rowsToMove[rowsToMove.length - 1];\n\n if (!lastRowToMove || lastRowToMove.index === rows.length - 1) {\n return;\n }\n\n const nextRowId = rows[lastRowToMove.index + 1]?.id;\n\n if (!nextRowId) {\n return;\n }\n\n moveAfter(\n nextRowId,\n rowsToMove.map(({ id }) => id),\n );\n },\n [rowSelection, moveAfter],\n );\n\n /**\n * actionColumn defines the actions available in the kebab menu for each row.\n * It includes options to move the row up or down in the table.\n */\n // biome-ignore lint/correctness/useExhaustiveDependencies: can of worms to fix ticket added\n const actionColumn: NonNullable<typeof columnsProp>[number] = useMemo(\n () => ({\n id: 'kebab',\n cell: ({ row }) => (\n <RowActionsMenu\n moveRowsUp={moveRowsUp}\n moveRowsDown={moveRowsDown}\n row={row}\n rows={getRowModel().rows}\n />\n ),\n size: META_COLUMN_WIDTH,\n }),\n [moveRowsUp, moveRowsDown],\n );\n\n /**\n * columns defines the structure of the table.\n * It includes the action column and optionally a checkbox column.\n * The kebab menu position can be set to 'left' or 'right'.\n * If showCheckbox is true, a checkbox column is added.\n */\n const columns = useMemo<NonNullable<typeof columnsProp>>(\n () => [\n {\n id: 'numeral',\n cell: ({ row }) =>\n row.getIsPinned() ? (\n <Icon size='small'>\n <Pin />\n </Icon>\n ) : (\n <span data-testid='numeral'>{row.index + 1}</span>\n ),\n size: META_COLUMN_WIDTH,\n },\n ...(showCheckbox\n ? ([\n {\n id: 'selection',\n header: ({ table }) => (\n <Checkbox\n isSelected={table.getIsAllRowsSelected()}\n isIndeterminate={table.getIsSomeRowsSelected()}\n onChange={table.toggleAllRowsSelected}\n />\n ),\n cell: ({ row }) => (\n <Checkbox\n isSelected={row.getIsSelected()}\n isIndeterminate={row.getIsSomeSelected()}\n onChange={row.toggleSelected}\n />\n ),\n size: META_COLUMN_WIDTH,\n },\n ] satisfies NonNullable<typeof columnsProp>)\n : []),\n ...(kebabPosition === 'left' ? [actionColumn] : []),\n ...(columnsProp ?? []),\n ...(kebabPosition === 'right' ? [actionColumn] : []),\n ],\n [showCheckbox, columnsProp, kebabPosition, actionColumn],\n );\n\n const handleSortChange = (\n columnId: string,\n sortDirection: 'asc' | 'desc' | null,\n ) => {\n onSortChange?.(columnId, sortDirection);\n };\n\n const handleColumnReordering = (index: number) => {\n onColumnReorderChange?.(index);\n };\n\n const handleRowSelectionChange = useCallback(\n (\n updaterOrValue:\n | RowSelectionState\n | ((old: RowSelectionState) => RowSelectionState),\n ) => {\n setRowSelection(updaterOrValue);\n onRowSelectionChange?.(updaterOrValue);\n },\n [onRowSelectionChange],\n );\n\n const {\n getHeaderGroups,\n getTopRows,\n getCenterRows,\n getBottomRows,\n getRowModel,\n setColumnOrder,\n } = useReactTable<T>({\n data,\n columns,\n enableSorting,\n initialState: {\n columnOrder: columns.map(({ id }) => id ?? ''),\n rowSelection: rowSelectionProp ?? {},\n },\n state: {\n rowSelection,\n rowPinning,\n },\n getRowId: (row, index) => {\n // Use the index as the row ID if no unique identifier is available\n return row.id ? row.id.toString() : index.toString();\n },\n enableRowSelection: true,\n enableRowPinning: true,\n manualSorting: manualSorting,\n onRowSelectionChange: handleRowSelectionChange,\n onRowPinningChange: setRowPinning,\n getCoreRowModel: getCoreRowModel<T>(),\n getSortedRowModel: getSortedRowModel<T>(),\n });\n\n const moveColumnLeft = useCallback(\n (oldIndex: number) => {\n setColumnOrder((order) => {\n const newColumnOrder = [...order];\n const newIndex = oldIndex - 1;\n\n if (newIndex < 0) {\n return order;\n }\n\n [newColumnOrder[oldIndex], newColumnOrder[newIndex]] = [\n newColumnOrder[newIndex] as string,\n newColumnOrder[oldIndex] as string,\n ];\n\n return newColumnOrder;\n });\n },\n [setColumnOrder],\n );\n\n const moveColumnRight = useCallback(\n (oldIndex: number) => {\n setColumnOrder((order) => {\n const newColumnOrder = [...order];\n const newIndex = oldIndex + 1;\n\n if (newIndex >= order.length) {\n return order;\n }\n\n [newColumnOrder[oldIndex], newColumnOrder[newIndex]] = [\n newColumnOrder[newIndex] as string,\n newColumnOrder[oldIndex] as string,\n ];\n\n return newColumnOrder;\n });\n },\n [setColumnOrder],\n );\n\n const className = clsx(fullWidth && 'w-full table-fixed', rest.className);\n\n if (children) {\n return (\n <table {...rest} className={className}>\n {children}\n </table>\n );\n }\n\n return (\n <TableContext.Provider\n value={{\n persistRowKebabMenu,\n persistHeaderKebabMenu,\n persistNumerals,\n enableSorting,\n enableColumnReordering,\n enableRowActions,\n columnSelection,\n setColumnSelection,\n moveColumnLeft,\n moveColumnRight,\n manualSorting,\n handleSortChange,\n handleColumnReordering,\n }}\n >\n <table {...rest} className={className}>\n <TableHeader\n headerGroups={getHeaderGroups()}\n columnSelection={columnSelection}\n />\n <TableBody\n rows={[...getTopRows(), ...getCenterRows(), ...getBottomRows()]}\n />\n </table>\n </TableContext.Provider>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CA,MAAM,oBAAoB;AAS1B,SAAS,eAAkB,EACzB,cACA,YACA,KACA,QACyB;CACzB,MAAM,EAAE,kBAAkB,wBAAwB,WAAW,aAAa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ChB;AAED,UAAO;IACP;IAEJ,CAAC,eAAe,CACjB;CAED,MAAM,YAAY,KAAK,aAAa,sBAAsB,KAAK,UAAU;AAEzE,KAAI,SACF,QACE,oBAAC;EAAM,GAAI;EAAiB;EACzB;GACK;AAIZ,QACE,oBAAC,aAAa;EACZ,OAAO;GACL;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACD;YAED,qBAAC;GAAM,GAAI;GAAiB;cAC1B,oBAAC;IACC,cAAc,iBAAiB;IACd;KACjB,EACF,oBAAC,aACC,MAAM;IAAC,GAAG,YAAY;IAAE,GAAG,eAAe;IAAE,GAAG,eAAe;IAAC,GAC/D;IACI;GACc"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["actionColumn: NonNullable<typeof columnsProp>[number]"],"sources":["../../../src/components/table/index.tsx"],"sourcesContent":["/*\n * Copyright 2026 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n'use client';\nimport 'client-only';\nimport { clsx } from '@accelint/design-foundation/lib/utils';\nimport Kebab from '@accelint/icons/kebab';\nimport Pin from '@accelint/icons/pin';\nimport { useListData } from '@react-stately/data';\nimport { useControlledState } from '@react-stately/utils';\nimport {\n getCoreRowModel,\n getPaginationRowModel,\n getSortedRowModel,\n type OnChangeFn,\n type PaginationState,\n type Row,\n type RowPinningState,\n type RowSelectionState,\n useReactTable,\n} from '@tanstack/react-table';\nimport { useCallback, useContext, useMemo, useState } from 'react';\nimport { Button } from '../button';\nimport { Checkbox } from '../checkbox';\nimport { Icon } from '../icon';\nimport { Menu } from '../menu';\nimport { MenuItem } from '../menu/item';\nimport { MenuSeparator } from '../menu/separator';\nimport { MenuTrigger } from '../menu/trigger';\nimport { TableBody } from './body';\nimport { TableContext } from './context';\nimport { TableHeader } from './header';\nimport styles from './styles.module.css';\nimport type { Key } from '@react-types/shared';\nimport type { TableProps } from './types';\n\n// This width is for columns in the table that provide features:\n// - Row count\n// - Row actions kebab\n// - Row selection (checkbox)\n// These columns should not need to grow with table width\nconst META_COLUMN_WIDTH = 32;\n\ntype RowActionsMenuProps<T> = {\n row: Row<T>;\n rows: Row<T>[];\n moveRowsDown: (row: Row<T>, rows: Row<T>[]) => void;\n moveRowsUp: (row: Row<T>, rows: Row<T>[]) => void;\n};\n\nfunction RowActionsMenu<T>({\n moveRowsDown,\n moveRowsUp,\n row,\n rows,\n}: RowActionsMenuProps<T>) {\n const { enableRowActions, persistRowKebabMenu } = useContext(TableContext);\n const isPinned = !!row.getIsPinned();\n const hideRowKebab = !persistRowKebabMenu;\n\n return (\n enableRowActions && (\n <div className={clsx(hideRowKebab && styles.hideInRow)}>\n <MenuTrigger>\n <Button variant='icon' aria-label={`row ${row.index + 1} actions`}>\n <Icon>\n <Kebab />\n </Icon>\n </Button>\n <Menu>\n <MenuItem onAction={() => row.pin(isPinned ? false : 'top')}>\n {isPinned ? 'Unpin' : 'Pin'}\n </MenuItem>\n <MenuSeparator />\n <MenuItem\n onAction={() => moveRowsUp(row, rows)}\n isDisabled={isPinned || row.index === 0}\n >\n Move Up\n </MenuItem>\n <MenuItem\n onAction={() => moveRowsDown(row, rows)}\n isDisabled={isPinned || row.index === rows.length - 1}\n >\n Move Down\n </MenuItem>\n </Menu>\n </MenuTrigger>\n </div>\n )\n );\n}\n\n/**\n * Table - Configurable data table with sorting, selection, and row actions\n *\n * Supports data-driven mode with TanStack column definitions or static mode with subcomponents.\n *\n * @param props - {@link TableProps}\n * @param props.children - Custom children for static mode.\n * @param props.columns - Column definitions for data-driven mode.\n * @param props.data - Data array for data-driven mode.\n * @param props.showCheckbox - Whether to show selection checkboxes.\n * @param props.rowSelection - Initial row selection state.\n * @param props.kebabPosition - Position of row action menu.\n * @param props.persistRowKebabMenu - Keep row kebab menu visible.\n * @param props.persistHeaderKebabMenu - Keep header kebab menu visible.\n * @param props.persistNumerals - Keep row numerals visible.\n * @param props.enableSorting - Enable column sorting.\n * @param props.enableColumnReordering - Enable column reordering.\n * @param props.enableRowActions - Enable row action menu.\n * @param props.manualSorting - Use server-side sorting.\n * @param props.onSortChange - Callback when sort changes.\n * @param props.onColumnReorderChange - Callback when column order changes.\n * @param props.onRowSelectionChange - Callback when row selection changes.\n * @param props.fullWidth - Whether table uses full width.\n * @returns The rendered Table component.\n *\n * @example\n * ```tsx\n * <Table columns={columns} data={rows} enableSorting showCheckbox />\n * ```\n */\nexport function Table<T extends { id: Key }>({\n children,\n columns: columnsProp,\n data: dataProp,\n showCheckbox,\n rowSelection: rowSelectionProp,\n kebabPosition = 'right',\n persistRowKebabMenu = true,\n persistHeaderKebabMenu = true,\n persistNumerals = false,\n enableSorting = true,\n enableColumnReordering = true,\n enableRowActions = true,\n manualSorting = false,\n onSortChange,\n onColumnReorderChange,\n onRowSelectionChange,\n fullWidth = false,\n pageSize,\n page: pageProp,\n defaultPage = 1,\n onPageChange,\n ...rest\n}: TableProps<T>) {\n const {\n items: data,\n moveAfter,\n moveBefore,\n } = useListData({\n initialItems: dataProp,\n });\n const [rowSelection, setRowSelection] = useState<RowSelectionState>(\n rowSelectionProp ?? {},\n );\n const [columnSelection, setColumnSelection] = useState<string | null>(null);\n const [rowPinning, setRowPinning] = useState<RowPinningState>({\n top: [],\n bottom: [],\n });\n\n const [currentPage, setCurrentPage] = useControlledState(\n pageProp,\n defaultPage,\n onPageChange,\n );\n\n const pagination = useMemo(\n () =>\n pageSize != null ? { pageIndex: currentPage - 1, pageSize } : undefined,\n [currentPage, pageSize],\n );\n\n const handlePaginationChange = useCallback<OnChangeFn<PaginationState>>(\n (updater) => {\n if (pagination == null) {\n return;\n }\n const next =\n typeof updater === 'function' ? updater(pagination) : updater;\n setCurrentPage(next.pageIndex + 1);\n },\n [pagination, setCurrentPage],\n );\n\n /**\n * moveUpSelectedRows moves the selected rows up in the table.\n * It finds the first selected row, determines its index,\n * and moves it before the previous row if it exists.\n */\n const moveRowsUp = useCallback(\n (row: Row<T>, rows: Row<T>[]) => {\n const isSelected = rowSelection[row.id];\n const rowsToMove = isSelected\n ? rows.filter(({ id }) => rowSelection[id])\n : [row];\n const firstRowToMove = rowsToMove[0];\n\n if (!firstRowToMove || firstRowToMove.index === 0) {\n return;\n }\n\n const prevRowId = rows[firstRowToMove.index - 1]?.id;\n\n if (!prevRowId) {\n return;\n }\n\n moveBefore(\n prevRowId,\n rowsToMove.map(({ id }) => id),\n );\n },\n [rowSelection, moveBefore],\n );\n\n /**\n * moveDownRows moves the selected or active rows down in the table.\n * It finds the last selected row, determines its index,\n * and moves it after the next row if it exists.\n */\n const moveRowsDown = useCallback(\n (row: Row<T>, rows: Row<T>[]) => {\n const isSelected = rowSelection[row.id];\n const rowsToMove = isSelected\n ? rows.filter(({ id }) => rowSelection[id])\n : [row];\n const lastRowToMove = rowsToMove[rowsToMove.length - 1];\n\n if (!lastRowToMove || lastRowToMove.index === rows.length - 1) {\n return;\n }\n\n const nextRowId = rows[lastRowToMove.index + 1]?.id;\n\n if (!nextRowId) {\n return;\n }\n\n moveAfter(\n nextRowId,\n rowsToMove.map(({ id }) => id),\n );\n },\n [rowSelection, moveAfter],\n );\n\n /**\n * actionColumn defines the actions available in the kebab menu for each row.\n * It includes options to move the row up or down in the table.\n */\n // biome-ignore lint/correctness/useExhaustiveDependencies: can of worms to fix ticket added\n const actionColumn: NonNullable<typeof columnsProp>[number] = useMemo(\n () => ({\n id: 'kebab',\n cell: ({ row }) => (\n <RowActionsMenu\n moveRowsUp={moveRowsUp}\n moveRowsDown={moveRowsDown}\n row={row}\n rows={getRowModel().rows}\n />\n ),\n size: META_COLUMN_WIDTH,\n }),\n [moveRowsUp, moveRowsDown],\n );\n\n /**\n * columns defines the structure of the table.\n * It includes the action column and optionally a checkbox column.\n * The kebab menu position can be set to 'left' or 'right'.\n * If showCheckbox is true, a checkbox column is added.\n */\n const columns = useMemo<NonNullable<typeof columnsProp>>(\n () => [\n {\n id: 'numeral',\n cell: ({ row }) =>\n row.getIsPinned() ? (\n <Icon size='small'>\n <Pin />\n </Icon>\n ) : (\n <span data-testid='numeral'>{row.index + 1}</span>\n ),\n size: META_COLUMN_WIDTH,\n },\n ...(showCheckbox\n ? ([\n {\n id: 'selection',\n header: ({ table }) => (\n <Checkbox\n isSelected={table.getIsAllRowsSelected()}\n isIndeterminate={table.getIsSomeRowsSelected()}\n onChange={table.toggleAllRowsSelected}\n />\n ),\n cell: ({ row }) => (\n <Checkbox\n isSelected={row.getIsSelected()}\n isIndeterminate={row.getIsSomeSelected()}\n onChange={row.toggleSelected}\n />\n ),\n size: META_COLUMN_WIDTH,\n },\n ] satisfies NonNullable<typeof columnsProp>)\n : []),\n ...(kebabPosition === 'left' ? [actionColumn] : []),\n ...(columnsProp ?? []),\n ...(kebabPosition === 'right' ? [actionColumn] : []),\n ],\n [showCheckbox, columnsProp, kebabPosition, actionColumn],\n );\n\n const handleSortChange = (\n columnId: string,\n sortDirection: 'asc' | 'desc' | null,\n ) => {\n onSortChange?.(columnId, sortDirection);\n };\n\n const handleColumnReordering = (index: number) => {\n onColumnReorderChange?.(index);\n };\n\n const handleRowSelectionChange = useCallback(\n (\n updaterOrValue:\n | RowSelectionState\n | ((old: RowSelectionState) => RowSelectionState),\n ) => {\n setRowSelection(updaterOrValue);\n onRowSelectionChange?.(updaterOrValue);\n },\n [onRowSelectionChange],\n );\n\n const {\n getHeaderGroups,\n getTopRows,\n getCenterRows,\n getBottomRows,\n getRowModel,\n setColumnOrder,\n } = useReactTable<T>({\n data,\n columns,\n enableSorting,\n initialState: {\n columnOrder: columns.map(({ id }) => id ?? ''),\n rowSelection: rowSelectionProp ?? {},\n },\n state: {\n rowSelection,\n rowPinning,\n ...(pagination != null && { pagination }),\n },\n getRowId: (row, index) => {\n // Use the index as the row ID if no unique identifier is available\n return row.id ? row.id.toString() : index.toString();\n },\n enableRowSelection: true,\n enableRowPinning: true,\n manualSorting: manualSorting,\n onRowSelectionChange: handleRowSelectionChange,\n onRowPinningChange: setRowPinning,\n onPaginationChange: handlePaginationChange,\n getCoreRowModel: getCoreRowModel<T>(),\n getSortedRowModel: getSortedRowModel<T>(),\n ...(pageSize != null && {\n getPaginationRowModel: getPaginationRowModel<T>(),\n }),\n });\n\n const moveColumnLeft = useCallback(\n (oldIndex: number) => {\n setColumnOrder((order) => {\n const newColumnOrder = [...order];\n const newIndex = oldIndex - 1;\n\n if (newIndex < 0) {\n return order;\n }\n\n [newColumnOrder[oldIndex], newColumnOrder[newIndex]] = [\n newColumnOrder[newIndex] as string,\n newColumnOrder[oldIndex] as string,\n ];\n\n return newColumnOrder;\n });\n },\n [setColumnOrder],\n );\n\n const moveColumnRight = useCallback(\n (oldIndex: number) => {\n setColumnOrder((order) => {\n const newColumnOrder = [...order];\n const newIndex = oldIndex + 1;\n\n if (newIndex >= order.length) {\n return order;\n }\n\n [newColumnOrder[oldIndex], newColumnOrder[newIndex]] = [\n newColumnOrder[newIndex] as string,\n newColumnOrder[oldIndex] as string,\n ];\n\n return newColumnOrder;\n });\n },\n [setColumnOrder],\n );\n\n const className = clsx(fullWidth && 'w-full table-fixed', rest.className);\n\n if (children) {\n return (\n <table {...rest} className={className}>\n {children}\n </table>\n );\n }\n\n return (\n <TableContext.Provider\n value={{\n persistRowKebabMenu,\n persistHeaderKebabMenu,\n persistNumerals,\n enableSorting,\n enableColumnReordering,\n enableRowActions,\n columnSelection,\n setColumnSelection,\n moveColumnLeft,\n moveColumnRight,\n manualSorting,\n handleSortChange,\n handleColumnReordering,\n }}\n >\n <table {...rest} className={className}>\n <TableHeader\n headerGroups={getHeaderGroups()}\n columnSelection={columnSelection}\n />\n <TableBody\n rows={[...getTopRows(), ...getCenterRows(), ...getBottomRows()]}\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AAoB;EACpB,kBAAkB;EACH;EACf,sBAAsB;EACtB,oBAAoB;EACpB,oBAAoB;EACpB,iBAAiB,iBAAoB;EACrC,mBAAmB,mBAAsB;EACzC,GAAI,YAAY,QAAQ,EACtB,uBAAuB,uBAA0B,EAClD;EACF,CAAC;CAEF,MAAM,iBAAiB,aACpB,aAAqB;AACpB,kBAAgB,UAAU;GACxB,MAAM,iBAAiB,CAAC,GAAG,MAAM;GACjC,MAAM,WAAW,WAAW;AAE5B,OAAI,WAAW,EACb,QAAO;AAGT,IAAC,eAAe,WAAW,eAAe,aAAa,CACrD,eAAe,WACf,eAAe,UAChB;AAED,UAAO;IACP;IAEJ,CAAC,eAAe,CACjB;CAED,MAAM,kBAAkB,aACrB,aAAqB;AACpB,kBAAgB,UAAU;GACxB,MAAM,iBAAiB,CAAC,GAAG,MAAM;GACjC,MAAM,WAAW,WAAW;AAE5B,OAAI,YAAY,MAAM,OACpB,QAAO;AAGT,IAAC,eAAe,WAAW,eAAe,aAAa,CACrD,eAAe,WACf,eAAe,UAChB;AAED,UAAO;IACP;IAEJ,CAAC,eAAe,CACjB;CAED,MAAM,YAAY,KAAK,aAAa,sBAAsB,KAAK,UAAU;AAEzE,KAAI,SACF,QACE,oBAAC;EAAM,GAAI;EAAiB;EACzB;GACK;AAIZ,QACE,oBAAC,aAAa;EACZ,OAAO;GACL;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACD;YAED,qBAAC;GAAM,GAAI;GAAiB;cAC1B,oBAAC;IACC,cAAc,iBAAiB;IACd;KACjB,EACF,oBAAC,aACC,MAAM;IAAC,GAAG,YAAY;IAAE,GAAG,eAAe;IAAE,GAAG,eAAe;IAAC,GAC/D;IACI;GACc"}
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import { TableRowProps } from "./types.js";
|
|
14
|
-
import * as
|
|
14
|
+
import * as react_jsx_runtime124 from "react/jsx-runtime";
|
|
15
15
|
|
|
16
16
|
//#region src/components/table/row.d.ts
|
|
17
17
|
|
|
@@ -44,7 +44,7 @@ declare function TableRow<T>({
|
|
|
44
44
|
className,
|
|
45
45
|
row,
|
|
46
46
|
...rest
|
|
47
|
-
}: TableRowProps<T>):
|
|
47
|
+
}: TableRowProps<T>): react_jsx_runtime124.JSX.Element;
|
|
48
48
|
//#endregion
|
|
49
49
|
export { TableRow };
|
|
50
50
|
//# sourceMappingURL=row.d.ts.map
|
|
@@ -123,6 +123,23 @@ type ExtendedTableProps<T extends {
|
|
|
123
123
|
* @default false
|
|
124
124
|
*/
|
|
125
125
|
fullWidth?: boolean;
|
|
126
|
+
/**
|
|
127
|
+
* Number of rows per page. Enables built-in pagination when set.
|
|
128
|
+
*/
|
|
129
|
+
pageSize?: number;
|
|
130
|
+
/**
|
|
131
|
+
* Controlled current page (1-indexed).
|
|
132
|
+
*/
|
|
133
|
+
page?: number;
|
|
134
|
+
/**
|
|
135
|
+
* Uncontrolled default page (1-indexed).
|
|
136
|
+
* @default 1
|
|
137
|
+
*/
|
|
138
|
+
defaultPage?: number;
|
|
139
|
+
/**
|
|
140
|
+
* Callback when the page changes.
|
|
141
|
+
*/
|
|
142
|
+
onPageChange?: (page: number) => void;
|
|
126
143
|
};
|
|
127
144
|
/**
|
|
128
145
|
* Props for the Table component.
|
|
@@ -13,13 +13,13 @@
|
|
|
13
13
|
import { ProviderProps } from "../../lib/types.js";
|
|
14
14
|
import { TabProps as TabProps$1, TabsProps as TabsProps$1 } from "./types.js";
|
|
15
15
|
import "client-only";
|
|
16
|
-
import * as
|
|
16
|
+
import * as react30 from "react";
|
|
17
17
|
import { ContextValue } from "react-aria-components";
|
|
18
|
-
import * as
|
|
18
|
+
import * as react_jsx_runtime95 from "react/jsx-runtime";
|
|
19
19
|
|
|
20
20
|
//#region src/components/tabs/context.d.ts
|
|
21
21
|
/** Context for sharing props across Tabs components */
|
|
22
|
-
declare const TabsContext:
|
|
22
|
+
declare const TabsContext: react30.Context<ContextValue<TabsProps$1, HTMLDivElement>>;
|
|
23
23
|
/**
|
|
24
24
|
* Sets default props for all Tabs components within.
|
|
25
25
|
*
|
|
@@ -42,12 +42,12 @@ declare const TabsContext: react46.Context<ContextValue<TabsProps$1, HTMLDivElem
|
|
|
42
42
|
declare function TabsProvider({
|
|
43
43
|
children,
|
|
44
44
|
...props
|
|
45
|
-
}: ProviderProps<TabsProps$1>):
|
|
46
|
-
declare const TabContext:
|
|
45
|
+
}: ProviderProps<TabsProps$1>): react_jsx_runtime95.JSX.Element;
|
|
46
|
+
declare const TabContext: react30.Context<ContextValue<TabProps$1, Element>>;
|
|
47
47
|
declare function TabProvider({
|
|
48
48
|
children,
|
|
49
49
|
...props
|
|
50
|
-
}: ProviderProps<TabProps$1>):
|
|
50
|
+
}: ProviderProps<TabProps$1>): react_jsx_runtime95.JSX.Element;
|
|
51
51
|
//#endregion
|
|
52
52
|
export { TabContext, TabProvider, TabsContext, TabsProvider };
|
|
53
53
|
//# sourceMappingURL=context.d.ts.map
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
import { TabsProps } from "./types.js";
|
|
14
14
|
import "client-only";
|
|
15
|
-
import * as
|
|
15
|
+
import * as react_jsx_runtime125 from "react/jsx-runtime";
|
|
16
16
|
|
|
17
17
|
//#region src/components/tabs/index.d.ts
|
|
18
18
|
|
|
@@ -44,7 +44,7 @@ import * as react_jsx_runtime189 from "react/jsx-runtime";
|
|
|
44
44
|
declare function Tabs({
|
|
45
45
|
ref,
|
|
46
46
|
...props
|
|
47
|
-
}: TabsProps):
|
|
47
|
+
}: TabsProps): react_jsx_runtime125.JSX.Element;
|
|
48
48
|
//#endregion
|
|
49
49
|
export { Tabs };
|
|
50
50
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
import "client-only";
|
|
14
14
|
import { TabListProps } from "react-aria-components";
|
|
15
|
-
import * as
|
|
15
|
+
import * as react_jsx_runtime117 from "react/jsx-runtime";
|
|
16
16
|
|
|
17
17
|
//#region src/components/tabs/list.d.ts
|
|
18
18
|
|
|
@@ -40,7 +40,7 @@ declare function TabList<T extends object>({
|
|
|
40
40
|
children,
|
|
41
41
|
className,
|
|
42
42
|
...rest
|
|
43
|
-
}: TabListProps<T>):
|
|
43
|
+
}: TabListProps<T>): react_jsx_runtime117.JSX.Element;
|
|
44
44
|
//#endregion
|
|
45
45
|
export { TabList };
|
|
46
46
|
//# sourceMappingURL=list.d.ts.map
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
import "client-only";
|
|
14
14
|
import { TabPanelProps } from "react-aria-components";
|
|
15
|
-
import * as
|
|
15
|
+
import * as react_jsx_runtime126 from "react/jsx-runtime";
|
|
16
16
|
|
|
17
17
|
//#region src/components/tabs/panel.d.ts
|
|
18
18
|
|
|
@@ -41,7 +41,7 @@ declare function TabPanel({
|
|
|
41
41
|
children,
|
|
42
42
|
className,
|
|
43
43
|
...rest
|
|
44
|
-
}: TabPanelProps):
|
|
44
|
+
}: TabPanelProps): react_jsx_runtime126.JSX.Element;
|
|
45
45
|
//#endregion
|
|
46
46
|
export { TabPanel };
|
|
47
47
|
//# sourceMappingURL=panel.d.ts.map
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
import { TabProps } from "./types.js";
|
|
14
14
|
import "client-only";
|
|
15
|
-
import * as
|
|
15
|
+
import * as react_jsx_runtime97 from "react/jsx-runtime";
|
|
16
16
|
|
|
17
17
|
//#region src/components/tabs/tab.d.ts
|
|
18
18
|
|
|
@@ -38,7 +38,7 @@ import * as react_jsx_runtime193 from "react/jsx-runtime";
|
|
|
38
38
|
declare function Tab({
|
|
39
39
|
ref,
|
|
40
40
|
...props
|
|
41
|
-
}: TabProps):
|
|
41
|
+
}: TabProps): react_jsx_runtime97.JSX.Element;
|
|
42
42
|
//#endregion
|
|
43
43
|
export { Tab };
|
|
44
44
|
//# sourceMappingURL=tab.d.ts.map
|
|
@@ -13,13 +13,13 @@
|
|
|
13
13
|
import { ProviderProps } from "../../lib/types.js";
|
|
14
14
|
import { TextAreaFieldProps } from "./types.js";
|
|
15
15
|
import "client-only";
|
|
16
|
-
import * as
|
|
16
|
+
import * as react39 from "react";
|
|
17
17
|
import { ContextValue } from "react-aria-components";
|
|
18
|
-
import * as
|
|
18
|
+
import * as react_jsx_runtime114 from "react/jsx-runtime";
|
|
19
19
|
|
|
20
20
|
//#region src/components/text-area-field/context.d.ts
|
|
21
21
|
/** Context for sharing props across TextAreaField components */
|
|
22
|
-
declare const TextAreaFieldContext:
|
|
22
|
+
declare const TextAreaFieldContext: react39.Context<ContextValue<TextAreaFieldProps, HTMLDivElement>>;
|
|
23
23
|
/**
|
|
24
24
|
* Sets default props for all TextAreaField components within.
|
|
25
25
|
*
|
|
@@ -42,7 +42,7 @@ declare const TextAreaFieldContext: react52.Context<ContextValue<TextAreaFieldPr
|
|
|
42
42
|
declare function TextAreaFieldProvider({
|
|
43
43
|
children,
|
|
44
44
|
...props
|
|
45
|
-
}: ProviderProps<TextAreaFieldProps>):
|
|
45
|
+
}: ProviderProps<TextAreaFieldProps>): react_jsx_runtime114.JSX.Element;
|
|
46
46
|
//#endregion
|
|
47
47
|
export { TextAreaFieldContext, TextAreaFieldProvider };
|
|
48
48
|
//# sourceMappingURL=context.d.ts.map
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
import { TextAreaFieldProps } from "./types.js";
|
|
14
14
|
import "client-only";
|
|
15
|
-
import * as
|
|
15
|
+
import * as react_jsx_runtime98 from "react/jsx-runtime";
|
|
16
16
|
|
|
17
17
|
//#region src/components/text-area-field/index.d.ts
|
|
18
18
|
|
|
@@ -44,7 +44,7 @@ import * as react_jsx_runtime186 from "react/jsx-runtime";
|
|
|
44
44
|
declare function TextAreaField({
|
|
45
45
|
ref,
|
|
46
46
|
...props
|
|
47
|
-
}: TextAreaFieldProps):
|
|
47
|
+
}: TextAreaFieldProps): react_jsx_runtime98.JSX.Element;
|
|
48
48
|
//#endregion
|
|
49
49
|
export { TextAreaField };
|
|
50
50
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -13,13 +13,13 @@
|
|
|
13
13
|
import { ProviderProps } from "../../lib/types.js";
|
|
14
14
|
import { TextFieldProps as TextFieldProps$1 } from "./types.js";
|
|
15
15
|
import "client-only";
|
|
16
|
-
import * as
|
|
16
|
+
import * as react40 from "react";
|
|
17
17
|
import { ContextValue } from "react-aria-components";
|
|
18
|
-
import * as
|
|
18
|
+
import * as react_jsx_runtime116 from "react/jsx-runtime";
|
|
19
19
|
|
|
20
20
|
//#region src/components/text-field/context.d.ts
|
|
21
21
|
/** Context for sharing props across TextField components */
|
|
22
|
-
declare const TextFieldContext:
|
|
22
|
+
declare const TextFieldContext: react40.Context<ContextValue<TextFieldProps$1, HTMLDivElement>>;
|
|
23
23
|
/**
|
|
24
24
|
* Sets default props for all TextField components within.
|
|
25
25
|
*
|
|
@@ -42,7 +42,7 @@ declare const TextFieldContext: react49.Context<ContextValue<TextFieldProps$1, H
|
|
|
42
42
|
declare function TextFieldProvider({
|
|
43
43
|
children,
|
|
44
44
|
...props
|
|
45
|
-
}: ProviderProps<TextFieldProps$1>):
|
|
45
|
+
}: ProviderProps<TextFieldProps$1>): react_jsx_runtime116.JSX.Element;
|
|
46
46
|
//#endregion
|
|
47
47
|
export { TextFieldContext, TextFieldProvider };
|
|
48
48
|
//# sourceMappingURL=context.d.ts.map
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
import { TextFieldProps } from "./types.js";
|
|
14
14
|
import "client-only";
|
|
15
|
-
import * as
|
|
15
|
+
import * as react_jsx_runtime99 from "react/jsx-runtime";
|
|
16
16
|
|
|
17
17
|
//#region src/components/text-field/index.d.ts
|
|
18
18
|
|
|
@@ -40,7 +40,7 @@ import * as react_jsx_runtime195 from "react/jsx-runtime";
|
|
|
40
40
|
declare function TextField({
|
|
41
41
|
ref,
|
|
42
42
|
...props
|
|
43
|
-
}: TextFieldProps):
|
|
43
|
+
}: TextFieldProps): react_jsx_runtime99.JSX.Element;
|
|
44
44
|
//#endregion
|
|
45
45
|
export { TextField };
|
|
46
46
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
import { TimeFieldProps as TimeFieldProps$1 } from "./types.js";
|
|
14
14
|
import "client-only";
|
|
15
15
|
import { TimeValue } from "react-aria-components";
|
|
16
|
-
import * as
|
|
16
|
+
import * as react_jsx_runtime100 from "react/jsx-runtime";
|
|
17
17
|
|
|
18
18
|
//#region src/components/time-field/index.d.ts
|
|
19
19
|
|
|
@@ -58,7 +58,7 @@ declare function TimeField<T extends TimeValue>({
|
|
|
58
58
|
isRequired,
|
|
59
59
|
isReadOnly,
|
|
60
60
|
...rest
|
|
61
|
-
}: TimeFieldProps$1<T>):
|
|
61
|
+
}: TimeFieldProps$1<T>): react_jsx_runtime100.JSX.Element;
|
|
62
62
|
//#endregion
|
|
63
63
|
export { TimeField };
|
|
64
64
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -12,12 +12,12 @@
|
|
|
12
12
|
|
|
13
13
|
import { TooltipTriggerProps } from "./types.js";
|
|
14
14
|
import "client-only";
|
|
15
|
-
import * as
|
|
15
|
+
import * as react32 from "react";
|
|
16
16
|
import { ContextValue } from "react-aria-components";
|
|
17
17
|
|
|
18
18
|
//#region src/components/tooltip/context.d.ts
|
|
19
19
|
/** Context for sharing props across TooltipTrigger components */
|
|
20
|
-
declare const TooltipContext:
|
|
20
|
+
declare const TooltipContext: react32.Context<ContextValue<TooltipTriggerProps, HTMLDivElement>>;
|
|
21
21
|
//#endregion
|
|
22
22
|
export { TooltipContext };
|
|
23
23
|
//# sourceMappingURL=context.d.ts.map
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
import { TooltipProps } from "./types.js";
|
|
14
14
|
import "client-only";
|
|
15
|
-
import * as
|
|
15
|
+
import * as react_jsx_runtime120 from "react/jsx-runtime";
|
|
16
16
|
|
|
17
17
|
//#region src/components/tooltip/index.d.ts
|
|
18
18
|
|
|
@@ -44,7 +44,7 @@ declare function Tooltip({
|
|
|
44
44
|
offset,
|
|
45
45
|
placement,
|
|
46
46
|
...props
|
|
47
|
-
}: TooltipProps):
|
|
47
|
+
}: TooltipProps): react_jsx_runtime120.JSX.Element;
|
|
48
48
|
//#endregion
|
|
49
49
|
export { Tooltip };
|
|
50
50
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
import { TooltipTriggerProps } from "./types.js";
|
|
14
14
|
import "client-only";
|
|
15
|
-
import * as
|
|
15
|
+
import * as react_jsx_runtime169 from "react/jsx-runtime";
|
|
16
16
|
|
|
17
17
|
//#region src/components/tooltip/trigger.d.ts
|
|
18
18
|
|
|
@@ -38,7 +38,7 @@ import * as react_jsx_runtime198 from "react/jsx-runtime";
|
|
|
38
38
|
declare function TooltipTrigger({
|
|
39
39
|
ref,
|
|
40
40
|
...props
|
|
41
|
-
}: TooltipTriggerProps):
|
|
41
|
+
}: TooltipTriggerProps): react_jsx_runtime169.JSX.Element;
|
|
42
42
|
//#endregion
|
|
43
43
|
export { TooltipTrigger };
|
|
44
44
|
//# sourceMappingURL=trigger.d.ts.map
|
|
@@ -12,13 +12,13 @@
|
|
|
12
12
|
|
|
13
13
|
import { TreeContextValue, TreeItemContextValue } from "./types.js";
|
|
14
14
|
import "client-only";
|
|
15
|
-
import * as
|
|
15
|
+
import * as react33 from "react";
|
|
16
16
|
|
|
17
17
|
//#region src/components/tree/context.d.ts
|
|
18
18
|
/** Context for sharing state across Tree components */
|
|
19
|
-
declare const TreeContext:
|
|
19
|
+
declare const TreeContext: react33.Context<TreeContextValue>;
|
|
20
20
|
/** Context for sharing state within a TreeItem */
|
|
21
|
-
declare const TreeItemContext:
|
|
21
|
+
declare const TreeItemContext: react33.Context<TreeItemContextValue>;
|
|
22
22
|
//#endregion
|
|
23
23
|
export { TreeContext, TreeItemContext };
|
|
24
24
|
//# sourceMappingURL=context.d.ts.map
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
import { TreeProps } from "./types.js";
|
|
14
14
|
import "client-only";
|
|
15
|
-
import * as
|
|
15
|
+
import * as react_jsx_runtime121 from "react/jsx-runtime";
|
|
16
16
|
|
|
17
17
|
//#region src/components/tree/index.d.ts
|
|
18
18
|
|
|
@@ -75,7 +75,7 @@ declare function Tree<T>({
|
|
|
75
75
|
onVisibilityChange,
|
|
76
76
|
onSelectionChange,
|
|
77
77
|
...rest
|
|
78
|
-
}: TreeProps<T>):
|
|
78
|
+
}: TreeProps<T>): react_jsx_runtime121.JSX.Element;
|
|
79
79
|
//#endregion
|
|
80
80
|
export { Tree };
|
|
81
81
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -23,10 +23,12 @@ import { jsx } from "react/jsx-runtime";
|
|
|
23
23
|
import styles from "./styles.module.css";
|
|
24
24
|
|
|
25
25
|
//#region src/components/tree/index.tsx
|
|
26
|
-
const defaultRenderDropIndicator = (target) =>
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
const defaultRenderDropIndicator = (target) => {
|
|
27
|
+
return /* @__PURE__ */ jsx(DropIndicator, {
|
|
28
|
+
target,
|
|
29
|
+
className: target.type === "item" && (target.dropPosition === "before" || target.dropPosition === "after") ? styles.dropIndicatorBetween : styles.dropIndicator
|
|
30
|
+
});
|
|
31
|
+
};
|
|
30
32
|
/**
|
|
31
33
|
* Tree - Hierarchical tree view with selection, visibility, and drag-and-drop
|
|
32
34
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["acc","AriaTree","className"],"sources":["../../../src/components/tree/index.tsx"],"sourcesContent":["/*\n * Copyright 2026 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n'use client';\n\nimport { Cache } from '@/hooks/use-tree/actions/cache';\nimport type { Key, Selection } from '@react-types/shared';\nimport 'client-only';\nimport { clsx } from '@accelint/design-foundation/lib/utils';\nimport { useMemo } from 'react';\nimport {\n Tree as AriaTree,\n composeRenderProps,\n DropIndicator,\n type DropTarget,\n useDragAndDrop,\n} from 'react-aria-components';\nimport { TreeContext } from './context';\nimport styles from './styles.module.css';\nimport type { TreeProps } from './types';\n\nconst defaultRenderDropIndicator = (target: DropTarget) => (\n
|
|
1
|
+
{"version":3,"file":"index.js","names":["acc","AriaTree","className"],"sources":["../../../src/components/tree/index.tsx"],"sourcesContent":["/*\n * Copyright 2026 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n'use client';\n\nimport { Cache } from '@/hooks/use-tree/actions/cache';\nimport type { Key, Selection } from '@react-types/shared';\nimport 'client-only';\nimport { clsx } from '@accelint/design-foundation/lib/utils';\nimport { useMemo } from 'react';\nimport {\n Tree as AriaTree,\n composeRenderProps,\n DropIndicator,\n type DropTarget,\n useDragAndDrop,\n} from 'react-aria-components';\nimport { TreeContext } from './context';\nimport styles from './styles.module.css';\nimport type { TreeProps } from './types';\n\nconst defaultRenderDropIndicator = (target: DropTarget) => {\n const isBetweenItems =\n target.type === 'item' &&\n (target.dropPosition === 'before' || target.dropPosition === 'after');\n return (\n <DropIndicator\n target={target}\n className={\n isBetweenItems ? styles.dropIndicatorBetween : styles.dropIndicator\n }\n />\n );\n};\n\n/**\n * Tree - Hierarchical tree view with selection, visibility, and drag-and-drop\n *\n * Supports static or dynamic collections with keyboard navigation and accessibility.\n *\n * @param props - {@link TreeProps}\n * @param props.children - Tree items or render function for dynamic collections.\n * @param props.className - CSS class for the tree container.\n * @param props.disabledKeys - Set of disabled item keys.\n * @param props.dragAndDropConfig - Configuration for drag and drop behavior.\n * @param props.expandedKeys - Set of expanded item keys.\n * @param props.items - Data source for dynamic collections.\n * @param props.selectedKeys - Set of selected item keys.\n * @param props.showRuleLines - Whether to show connecting lines between items.\n * @param props.showVisibility - Whether to show visibility toggle buttons.\n * @param props.selectionMode - Selection mode for the tree.\n * @param props.variant - Visual density variant.\n * @param props.visibleKeys - Set of visible item keys.\n * @param props.onVisibilityChange - Callback when item visibility changes.\n * @param props.onSelectionChange - Callback when selection changes.\n * @returns The rendered Tree component.\n *\n * @example\n * // Dynamic collection\n * ```tsx\n * <Tree items={items} expandedKeys={expandedKeys}>\n * {(node) => <TreeItem key={node.key}>{node.label}</TreeItem>}\n * </Tree>\n * ```\n *\n * @example\n * ```tsx\n * // Static collection\n * <Tree>\n * <TreeItem id=\"one\" textValue=\"one\">\n * <TreeItemContent>One</TreeItemContent>\n * <TreeItem id=\"two\" textValue=\"two\">\n * <TreeItemContent>Two</TreeItemContent>\n * </TreeItem>\n * </TreeItem>\n * </Tree>\n * ```\n */\nexport function Tree<T>({\n children,\n className,\n disabledKeys: disabledKeysProp,\n dragAndDropConfig,\n expandedKeys: expandedKeysProp,\n items,\n selectedKeys: selectedKeysProp,\n showRuleLines = true,\n showVisibility = true,\n selectionMode = 'multiple',\n variant = 'cozy',\n visibleKeys: visibleKeysProp,\n onVisibilityChange,\n onSelectionChange,\n ...rest\n}: TreeProps<T>) {\n /**\n * A static collection is hard-coded. Dynamic is data-driven from an external source.\n * https://react-spectrum.adobe.com/react-aria/Tree.html#content\n *\n * Controlled state should only be used on a static tree.\n */\n if (\n items &&\n (disabledKeysProp ||\n expandedKeysProp ||\n selectedKeysProp ||\n visibleKeysProp)\n ) {\n throw new Error(\n 'Tree should only be controlled with state from either `items` or keys props, not both',\n );\n }\n\n /**\n * A static tree won't support the node iterator pattern.\n */\n if (!!items !== (typeof children === 'function')) {\n throw new Error(\n 'Tree `items` and node iterator `children` must be used together',\n );\n }\n\n const { dragAndDropHooks } = useDragAndDrop({\n renderDropIndicator: defaultRenderDropIndicator,\n getAllowedDropOperations: () => ['move'],\n getDropOperation: () => 'move',\n ...dragAndDropConfig,\n });\n const cache = useMemo(() => (items ? new Cache([...items]) : null), [items]);\n const nodes = useMemo(() => cache?.getAllNodes(), [cache]);\n const {\n disabledKeys,\n expandedKeys,\n selectedKeys,\n visibleKeys,\n visibilityComputedKeys,\n } = useMemo(() => {\n const acc = {\n disabledKeys: nodes ? new Set<Key>() : disabledKeysProp,\n expandedKeys: nodes ? new Set<Key>() : expandedKeysProp,\n selectedKeys: nodes ? new Set<Key>() : selectedKeysProp,\n visibleKeys: nodes ? new Set<Key>() : visibleKeysProp,\n visibilityComputedKeys: new Set<Key>(),\n };\n\n if (!nodes) {\n return acc;\n }\n\n return nodes.reduce(\n (\n acc,\n {\n key,\n isDisabled,\n isExpanded,\n isSelected,\n isVisible,\n isVisibleComputed,\n },\n ) => {\n if (isDisabled) {\n acc.disabledKeys?.add(key);\n }\n if (isExpanded) {\n acc.expandedKeys?.add(key);\n }\n if (isSelected) {\n acc.selectedKeys?.add(key);\n }\n if (isVisible) {\n acc.visibleKeys?.add(key);\n }\n if (isVisibleComputed) {\n acc.visibilityComputedKeys.add(key);\n }\n return acc;\n },\n acc,\n );\n }, [\n nodes,\n disabledKeysProp,\n expandedKeysProp,\n selectedKeysProp,\n visibleKeysProp,\n ]);\n\n const handleSelectionChange = selectedKeys\n ? (selection: Selection) => {\n if (selection !== 'all') {\n onSelectionChange?.(selection);\n }\n }\n : undefined;\n\n return (\n <TreeContext.Provider\n value={{\n disabledKeys,\n expandedKeys,\n selectedKeys,\n showRuleLines,\n showVisibility,\n variant,\n visibleKeys,\n visibilityComputedKeys,\n isStatic: typeof children !== 'function',\n onVisibilityChange: onVisibilityChange ?? (() => undefined), // TODO: improve\n }}\n >\n <AriaTree\n {...rest}\n className={composeRenderProps(className, (className) =>\n clsx(styles.tree, className),\n )}\n disabledKeys={disabledKeys}\n dragAndDropHooks={dragAndDropHooks}\n expandedKeys={expandedKeys}\n items={items}\n selectedKeys={selectedKeys}\n onSelectionChange={handleSelectionChange}\n selectionMode={selectionMode}\n >\n {children}\n </AriaTree>\n </TreeContext.Provider>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,MAAM,8BAA8B,WAAuB;AAIzD,QACE,oBAAC;EACS;EACR,WALF,OAAO,SAAS,WACf,OAAO,iBAAiB,YAAY,OAAO,iBAAiB,WAKxC,OAAO,uBAAuB,OAAO;GAExD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CN,SAAgB,KAAQ,EACtB,UACA,WACA,cAAc,kBACd,mBACA,cAAc,kBACd,OACA,cAAc,kBACd,gBAAgB,MAChB,iBAAiB,MACjB,gBAAgB,YAChB,UAAU,QACV,aAAa,iBACb,oBACA,mBACA,GAAG,QACY;;;;;;;AAOf,KACE,UACC,oBACC,oBACA,oBACA,iBAEF,OAAM,IAAI,MACR,wFACD;;;;AAMH,KAAI,CAAC,CAAC,WAAW,OAAO,aAAa,YACnC,OAAM,IAAI,MACR,kEACD;CAGH,MAAM,EAAE,qBAAqB,eAAe;EAC1C,qBAAqB;EACrB,gCAAgC,CAAC,OAAO;EACxC,wBAAwB;EACxB,GAAG;EACJ,CAAC;CACF,MAAM,QAAQ,cAAe,QAAQ,IAAI,MAAM,CAAC,GAAG,MAAM,CAAC,GAAG,MAAO,CAAC,MAAM,CAAC;CAC5E,MAAM,QAAQ,cAAc,OAAO,aAAa,EAAE,CAAC,MAAM,CAAC;CAC1D,MAAM,EACJ,cACA,cACA,cACA,aACA,2BACE,cAAc;EAChB,MAAM,MAAM;GACV,cAAc,wBAAQ,IAAI,KAAU,GAAG;GACvC,cAAc,wBAAQ,IAAI,KAAU,GAAG;GACvC,cAAc,wBAAQ,IAAI,KAAU,GAAG;GACvC,aAAa,wBAAQ,IAAI,KAAU,GAAG;GACtC,wCAAwB,IAAI,KAAU;GACvC;AAED,MAAI,CAAC,MACH,QAAO;AAGT,SAAO,MAAM,QAET,OACA,EACE,KACA,YACA,YACA,YACA,WACA,wBAEC;AACH,OAAI,WACF,OAAI,cAAc,IAAI,IAAI;AAE5B,OAAI,WACF,OAAI,cAAc,IAAI,IAAI;AAE5B,OAAI,WACF,OAAI,cAAc,IAAI,IAAI;AAE5B,OAAI,UACF,OAAI,aAAa,IAAI,IAAI;AAE3B,OAAI,kBACF,OAAI,uBAAuB,IAAI,IAAI;AAErC,UAAOA;KAET,IACD;IACA;EACD;EACA;EACA;EACA;EACA;EACD,CAAC;CAEF,MAAM,wBAAwB,gBACzB,cAAyB;AACxB,MAAI,cAAc,MAChB,qBAAoB,UAAU;KAGlC;AAEJ,QACE,oBAAC,YAAY;EACX,OAAO;GACL;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA,UAAU,OAAO,aAAa;GAC9B,oBAAoB,6BAA6B;GAClD;YAED,oBAACC;GACC,GAAI;GACJ,WAAW,mBAAmB,YAAY,gBACxC,KAAK,OAAO,MAAMC,YAAU,CAC7B;GACa;GACI;GACJ;GACP;GACO;GACd,mBAAmB;GACJ;GAEd;IACQ;GACU"}
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import { PropsWithChildren } from "react";
|
|
14
|
-
import * as
|
|
14
|
+
import * as react_jsx_runtime134 from "react/jsx-runtime";
|
|
15
15
|
|
|
16
16
|
//#region src/components/tree/item-actions.d.ts
|
|
17
17
|
|
|
@@ -39,7 +39,7 @@ declare function TreeItemActions({
|
|
|
39
39
|
className
|
|
40
40
|
}: PropsWithChildren & {
|
|
41
41
|
className?: string;
|
|
42
|
-
}):
|
|
42
|
+
}): react_jsx_runtime134.JSX.Element;
|
|
43
43
|
//#endregion
|
|
44
44
|
export { TreeItemActions };
|
|
45
45
|
//# sourceMappingURL=item-actions.d.ts.map
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import { TreeItemContentProps } from "./types.js";
|
|
14
|
-
import * as
|
|
14
|
+
import * as react_jsx_runtime101 from "react/jsx-runtime";
|
|
15
15
|
|
|
16
16
|
//#region src/components/tree/item-content.d.ts
|
|
17
17
|
|
|
@@ -35,7 +35,7 @@ import * as react_jsx_runtime99 from "react/jsx-runtime";
|
|
|
35
35
|
*/
|
|
36
36
|
declare function TreeItemContent({
|
|
37
37
|
children
|
|
38
|
-
}: TreeItemContentProps):
|
|
38
|
+
}: TreeItemContentProps): react_jsx_runtime101.JSX.Element;
|
|
39
39
|
//#endregion
|
|
40
40
|
export { TreeItemContent };
|
|
41
41
|
//# sourceMappingURL=item-content.d.ts.map
|