@particle-network/ui-react 0.7.0-beta.6 → 0.7.0-beta.8

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.
Files changed (47) hide show
  1. package/dist/components/ProgressWrapper/index.js +1 -1
  2. package/dist/components/UXColorPicker/color-fields.js +1 -1
  3. package/dist/components/UXSimplePopover/simple-popover.js +1 -1
  4. package/dist/components/UXTable/base/index.d.ts +10 -0
  5. package/dist/components/UXTable/base/index.js +6 -0
  6. package/dist/components/UXTable/base/table-body.d.ts +20 -0
  7. package/dist/components/UXTable/base/table-body.js +4 -0
  8. package/dist/components/UXTable/base/table-cell.d.ts +6 -0
  9. package/dist/components/UXTable/base/table-cell.js +4 -0
  10. package/dist/components/UXTable/base/table-column.d.ts +6 -0
  11. package/dist/components/UXTable/base/table-column.js +4 -0
  12. package/dist/components/UXTable/base/table-header.d.ts +6 -0
  13. package/dist/components/UXTable/base/table-header.js +4 -0
  14. package/dist/components/UXTable/base/table-row.d.ts +6 -0
  15. package/dist/components/UXTable/base/table-row.js +4 -0
  16. package/dist/components/UXTable/index.d.ts +7 -37
  17. package/dist/components/UXTable/index.js +5 -14
  18. package/dist/components/UXTable/table-body.d.ts +15 -0
  19. package/dist/components/UXTable/table-body.js +87 -0
  20. package/dist/components/UXTable/table-cell.d.ts +19 -0
  21. package/dist/components/UXTable/table-cell.js +45 -0
  22. package/dist/components/UXTable/table-checkbox-cell.d.ts +23 -0
  23. package/dist/components/UXTable/table-checkbox-cell.js +48 -0
  24. package/dist/components/UXTable/table-column-header.d.ts +25 -0
  25. package/dist/components/UXTable/table-column-header.js +66 -0
  26. package/dist/components/UXTable/table-header-row.d.ts +14 -0
  27. package/dist/components/UXTable/table-header-row.js +29 -0
  28. package/dist/components/UXTable/table-row-group.d.ts +8 -0
  29. package/dist/components/UXTable/table-row-group.js +24 -0
  30. package/dist/components/UXTable/table-row.d.ts +15 -0
  31. package/dist/components/UXTable/table-row.js +61 -0
  32. package/dist/components/UXTable/table-select-all-checkbox.d.ts +18 -0
  33. package/dist/components/UXTable/table-select-all-checkbox.js +46 -0
  34. package/dist/components/UXTable/table-theme.d.ts +452 -0
  35. package/dist/components/UXTable/table-theme.js +282 -0
  36. package/dist/components/UXTable/table.d.ts +8 -0
  37. package/dist/components/UXTable/table.js +96 -0
  38. package/dist/components/UXTable/use-table.d.ts +145 -0
  39. package/dist/components/UXTable/use-table.js +127 -0
  40. package/dist/components/UXTable/virtualized-table-body.d.ts +17 -0
  41. package/dist/components/UXTable/virtualized-table-body.js +107 -0
  42. package/dist/components/UXTable/virtualized-table.d.ts +8 -0
  43. package/dist/components/UXTable/virtualized-table.js +115 -0
  44. package/dist/components/UXThemeSwitch/theme-switch.js +2 -1
  45. package/package.json +9 -3
  46. package/dist/components/UXTable/table.extend.d.ts +0 -34
  47. package/dist/components/UXTable/table.extend.js +0 -145
@@ -0,0 +1,282 @@
1
+ import { tv } from "@heroui/theme";
2
+ import { dataFocusVisibleClasses } from "../../utils/index.js";
3
+ const table = tv({
4
+ slots: {
5
+ base: 'flex flex-col relative gap-4',
6
+ wrapper: [
7
+ 'p-0',
8
+ 'z-0',
9
+ 'flex',
10
+ 'flex-col',
11
+ 'relative',
12
+ 'justify-between',
13
+ 'gap-5',
14
+ 'shadow-small',
15
+ 'bg-content1',
16
+ 'overflow-auto'
17
+ ],
18
+ table: 'min-w-full h-auto',
19
+ thead: "[&>tr]:first:rounded-lg after:content-[''] after:table-row after:h-[5px] [&>tr]:first:border-b [&>tr]:first:border-divider",
20
+ tbody: 'after:block',
21
+ tr: [
22
+ 'group/tr',
23
+ 'outline-solid outline-transparent',
24
+ ...dataFocusVisibleClasses
25
+ ],
26
+ th: [
27
+ 'group/th',
28
+ 'px-2.5',
29
+ 'h-auto',
30
+ 'text-start',
31
+ 'align-middle',
32
+ 'bg-transparent',
33
+ 'whitespace-nowrap',
34
+ 'text-foreground-300',
35
+ 'text-[11px]',
36
+ 'font-medium',
37
+ 'first:rounded-s-lg',
38
+ 'last:rounded-e-lg',
39
+ 'outline-solid outline-transparent',
40
+ 'data-[sortable=true]:cursor-pointer',
41
+ 'data-[hover=true]:text-foreground-400',
42
+ ...dataFocusVisibleClasses
43
+ ],
44
+ td: [
45
+ 'py-2',
46
+ 'px-2.5',
47
+ 'relative',
48
+ 'align-middle',
49
+ 'whitespace-normal',
50
+ 'text-small',
51
+ 'font-medium',
52
+ 'outline-solid outline-transparent',
53
+ '[&>*]:z-1',
54
+ '[&>*]:relative',
55
+ ...dataFocusVisibleClasses,
56
+ 'before:pointer-events-none',
57
+ "before:content-['']",
58
+ 'before:absolute',
59
+ 'before:z-0',
60
+ 'before:inset-0',
61
+ 'before:opacity-0',
62
+ 'data-[selected=true]:before:opacity-100',
63
+ 'before:bg-default/60',
64
+ 'data-[selected=true]:text-default-foreground',
65
+ 'first:before:rounded-l-md last:before:rounded-r-md',
66
+ 'group-data-[disabled=true]/tr:text-foreground-300',
67
+ 'group-data-[disabled=true]/tr:cursor-not-allowed'
68
+ ],
69
+ tfoot: '',
70
+ sortIcon: [
71
+ 'ms-2',
72
+ 'mb-px',
73
+ 'opacity-0',
74
+ 'text-inherit',
75
+ 'inline-block',
76
+ 'transition-transform-opacity',
77
+ 'data-[visible=true]:opacity-100',
78
+ 'group-data-[hover=true]/th:opacity-100',
79
+ 'data-[direction=ascending]:rotate-180'
80
+ ],
81
+ emptyWrapper: 'text-foreground-400 align-middle text-center h-40',
82
+ loadingWrapper: 'absolute inset-0 flex items-center justify-center'
83
+ },
84
+ variants: {
85
+ color: {
86
+ default: {
87
+ td: 'before:bg-default/60 data-[selected=true]:text-default-foreground'
88
+ },
89
+ primary: {
90
+ td: 'before:bg-primary/20 data-[selected=true]:text-primary'
91
+ },
92
+ secondary: {
93
+ td: 'before:bg-secondary/20 data-[selected=true]:text-secondary'
94
+ },
95
+ success: {
96
+ td: 'before:bg-success/20 data-[selected=true]:text-success-600 dark:data-[selected=true]:text-success'
97
+ },
98
+ warning: {
99
+ td: 'before:bg-warning/20 data-[selected=true]:text-warning-600 dark:data-[selected=true]:text-warning'
100
+ },
101
+ danger: {
102
+ td: 'before:bg-danger/20 data-[selected=true]:text-danger dark:data-[selected=true]:text-danger-500'
103
+ }
104
+ },
105
+ size: {
106
+ md: {
107
+ th: 'py-md'
108
+ },
109
+ lg: {
110
+ th: 'py-5',
111
+ td: 'py-lg'
112
+ }
113
+ },
114
+ layout: {
115
+ auto: {
116
+ table: 'table-auto'
117
+ },
118
+ fixed: {
119
+ table: 'table-fixed'
120
+ }
121
+ },
122
+ shadow: {
123
+ none: {
124
+ wrapper: 'shadow-none'
125
+ },
126
+ sm: {
127
+ wrapper: 'shadow-small'
128
+ },
129
+ md: {
130
+ wrapper: 'shadow-medium'
131
+ },
132
+ lg: {
133
+ wrapper: 'shadow-large'
134
+ }
135
+ },
136
+ hideHeader: {
137
+ true: {
138
+ thead: 'hidden'
139
+ }
140
+ },
141
+ isStriped: {
142
+ true: {
143
+ td: [
144
+ 'group-data-[odd=true]/tr:before:bg-default-100',
145
+ 'group-data-[odd=true]/tr:before:opacity-100',
146
+ 'group-data-[odd=true]/tr:before:-z-10'
147
+ ]
148
+ }
149
+ },
150
+ isCompact: {
151
+ true: {
152
+ td: 'py-1'
153
+ },
154
+ false: {}
155
+ },
156
+ isHeaderSticky: {
157
+ true: {
158
+ thead: 'sticky top-0 z-20 [&>tr]:first:shadow-small'
159
+ }
160
+ },
161
+ isSelectable: {
162
+ true: {
163
+ tr: 'cursor-default',
164
+ td: [
165
+ 'group-aria-[selected=false]/tr:group-data-[hover=true]/tr:before:bg-default-100',
166
+ 'group-aria-[selected=false]/tr:group-data-[hover=true]/tr:before:opacity-70'
167
+ ]
168
+ }
169
+ },
170
+ isMultiSelectable: {
171
+ true: {
172
+ td: [
173
+ 'group-data-[first=true]/tr:first:before:rounded-ss-lg',
174
+ 'group-data-[first=true]/tr:last:before:rounded-se-lg',
175
+ 'group-data-[middle=true]/tr:before:rounded-none',
176
+ 'group-data-[last=true]/tr:first:before:rounded-es-lg',
177
+ 'group-data-[last=true]/tr:last:before:rounded-ee-lg'
178
+ ]
179
+ },
180
+ false: {
181
+ td: [
182
+ 'first:before:rounded-s-lg',
183
+ 'last:before:rounded-e-lg'
184
+ ]
185
+ }
186
+ },
187
+ radius: {
188
+ none: {
189
+ wrapper: 'rounded-none',
190
+ th: [],
191
+ td: []
192
+ },
193
+ sm: {
194
+ wrapper: 'rounded-small'
195
+ },
196
+ md: {
197
+ wrapper: 'rounded-medium'
198
+ },
199
+ lg: {
200
+ wrapper: 'rounded-large'
201
+ }
202
+ },
203
+ fullWidth: {
204
+ true: {
205
+ base: 'w-full',
206
+ wrapper: 'w-full',
207
+ table: 'w-full'
208
+ }
209
+ },
210
+ align: {
211
+ start: {
212
+ th: 'text-start',
213
+ td: 'text-start'
214
+ },
215
+ center: {
216
+ th: 'text-center',
217
+ td: 'text-center'
218
+ },
219
+ end: {
220
+ th: 'text-end',
221
+ td: 'text-end'
222
+ }
223
+ }
224
+ },
225
+ defaultVariants: {
226
+ layout: 'auto',
227
+ shadow: 'none',
228
+ radius: 'none',
229
+ color: 'default',
230
+ size: 'md',
231
+ isCompact: false,
232
+ hideHeader: false,
233
+ isStriped: false,
234
+ fullWidth: true,
235
+ align: 'start'
236
+ },
237
+ compoundVariants: [
238
+ {
239
+ isStriped: true,
240
+ color: 'default',
241
+ class: {
242
+ td: 'group-data-[odd=true]/tr:data-[selected=true]/tr:before:bg-default/60'
243
+ }
244
+ },
245
+ {
246
+ isStriped: true,
247
+ color: 'primary',
248
+ class: {
249
+ td: 'group-data-[odd=true]/tr:data-[selected=true]/tr:before:bg-primary/20'
250
+ }
251
+ },
252
+ {
253
+ isStriped: true,
254
+ color: 'secondary',
255
+ class: {
256
+ td: 'group-data-[odd=true]/tr:data-[selected=true]/tr:before:bg-secondary/20'
257
+ }
258
+ },
259
+ {
260
+ isStriped: true,
261
+ color: 'success',
262
+ class: {
263
+ td: 'group-data-[odd=true]/tr:data-[selected=true]/tr:before:bg-success/20'
264
+ }
265
+ },
266
+ {
267
+ isStriped: true,
268
+ color: 'warning',
269
+ class: {
270
+ td: 'group-data-[odd=true]/tr:data-[selected=true]/tr:before:bg-warning/20'
271
+ }
272
+ },
273
+ {
274
+ isStriped: true,
275
+ color: 'danger',
276
+ class: {
277
+ td: 'group-data-[odd=true]/tr:data-[selected=true]/tr:before:bg-danger/20'
278
+ }
279
+ }
280
+ ]
281
+ });
282
+ export { table };
@@ -0,0 +1,8 @@
1
+ import type { UseTableProps } from './use-table';
2
+ export interface TableProps<T = object> extends Omit<UseTableProps<T>, 'isSelectable' | 'isMultiSelectable'> {
3
+ isVirtualized?: boolean;
4
+ rowHeight?: number;
5
+ maxTableHeight?: number;
6
+ }
7
+ declare const Table: import("@heroui/system-rsc").InternalForwardRefRenderFunction<"table", TableProps<object>, never>;
8
+ export default Table;
@@ -0,0 +1,96 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { useCallback } from "react";
3
+ import { forwardRef } from "@heroui/system";
4
+ import table_body from "./table-body.js";
5
+ import table_column_header from "./table-column-header.js";
6
+ import table_header_row from "./table-header-row.js";
7
+ import table_row_group from "./table-row-group.js";
8
+ import table_select_all_checkbox from "./table-select-all-checkbox.js";
9
+ import { useTable } from "./use-table.js";
10
+ import virtualized_table from "./virtualized-table.js";
11
+ const Table = forwardRef((props, ref)=>{
12
+ const { BaseComponent, Component, collection, values, topContent, topContentPlacement, bottomContentPlacement, bottomContent, removeWrapper, sortIcon, getBaseProps, getWrapperProps, getTableProps } = useTable({
13
+ ...props,
14
+ ref
15
+ });
16
+ const { isVirtualized, rowHeight = 40, maxTableHeight = 600 } = props;
17
+ const shouldVirtualize = isVirtualized;
18
+ const Wrapper = useCallback(({ children })=>{
19
+ if (removeWrapper) return children;
20
+ return /*#__PURE__*/ jsx(BaseComponent, {
21
+ ...getWrapperProps(),
22
+ children: children
23
+ });
24
+ }, [
25
+ removeWrapper,
26
+ getWrapperProps
27
+ ]);
28
+ if (shouldVirtualize) return /*#__PURE__*/ jsx(virtualized_table, {
29
+ ...props,
30
+ ref: ref,
31
+ maxTableHeight: maxTableHeight,
32
+ rowHeight: rowHeight
33
+ });
34
+ return /*#__PURE__*/ jsxs("div", {
35
+ ...getBaseProps(),
36
+ children: [
37
+ 'outside' === topContentPlacement && topContent,
38
+ /*#__PURE__*/ jsx(Wrapper, {
39
+ children: /*#__PURE__*/ jsxs(Fragment, {
40
+ children: [
41
+ 'inside' === topContentPlacement && topContent,
42
+ /*#__PURE__*/ jsxs(Component, {
43
+ ...getTableProps(),
44
+ children: [
45
+ /*#__PURE__*/ jsx(table_row_group, {
46
+ classNames: values.classNames,
47
+ slots: values.slots,
48
+ children: collection.headerRows.map((headerRow)=>/*#__PURE__*/ jsx(table_header_row, {
49
+ classNames: values.classNames,
50
+ node: headerRow,
51
+ slots: values.slots,
52
+ state: values.state,
53
+ children: [
54
+ ...headerRow.childNodes
55
+ ].map((column)=>column?.props?.isSelectionCell ? /*#__PURE__*/ jsx(table_select_all_checkbox, {
56
+ checkboxesProps: values.checkboxesProps,
57
+ classNames: values.classNames,
58
+ color: values.color,
59
+ disableAnimation: values.disableAnimation,
60
+ node: column,
61
+ selectionMode: values.selectionMode,
62
+ slots: values.slots,
63
+ state: values.state
64
+ }, column?.key) : /*#__PURE__*/ jsx(table_column_header, {
65
+ classNames: values.classNames,
66
+ node: column,
67
+ slots: values.slots,
68
+ sortIcon: sortIcon,
69
+ state: values.state
70
+ }, column?.key))
71
+ }, headerRow?.key))
72
+ }),
73
+ /*#__PURE__*/ jsx(table_body, {
74
+ checkboxesProps: values.checkboxesProps,
75
+ classNames: values.classNames,
76
+ collection: values.collection,
77
+ color: values.color,
78
+ disableAnimation: values.disableAnimation,
79
+ isSelectable: values.isSelectable,
80
+ selectionMode: values.selectionMode,
81
+ slots: values.slots,
82
+ state: values.state
83
+ })
84
+ ]
85
+ }),
86
+ 'inside' === bottomContentPlacement && bottomContent
87
+ ]
88
+ })
89
+ }),
90
+ 'outside' === bottomContentPlacement && bottomContent
91
+ ]
92
+ });
93
+ });
94
+ Table.displayName = 'HeroUI.Table';
95
+ const table = Table;
96
+ export { table as default };
@@ -0,0 +1,145 @@
1
+ import type React from 'react';
2
+ import type { Key, ReactNode } from 'react';
3
+ import type { CheckboxProps } from '@heroui/checkbox';
4
+ import type { ReactRef } from '@heroui/react-utils';
5
+ import type { HTMLHeroUIProps, PropGetter } from '@heroui/system';
6
+ import type { SlotsToClasses } from '@heroui/theme';
7
+ import type { AriaTableProps } from '@react-aria/table';
8
+ import type { TableState, TableStateProps } from '@react-stately/table';
9
+ import type { Layout } from '@react-stately/virtualizer';
10
+ import type { DisabledBehavior, Node, SelectionBehavior } from '@react-types/shared';
11
+ import type { TableCollection } from '@react-types/table';
12
+ import type { TableReturnType, TableSlots, TableVariantProps } from './table-theme';
13
+ type TableContentPlacement = 'inside' | 'outside';
14
+ interface Props<T> extends HTMLHeroUIProps<'table'> {
15
+ /**
16
+ * Ref to the DOM node.
17
+ */
18
+ ref?: ReactRef<HTMLElement | null>;
19
+ children?: ReactNode;
20
+ layoutNode?: Layout<Node<T>>;
21
+ /**
22
+ * A custom wrapper component for the table.
23
+ * @default "div"
24
+ */
25
+ BaseComponent?: React.ComponentType<any>;
26
+ /**
27
+ * Ref to the container element.
28
+ */
29
+ baseRef?: ReactRef<HTMLElement | null>;
30
+ /**
31
+ * Where to place the `topContent` component.
32
+ * @default "inside"
33
+ */
34
+ topContentPlacement?: TableContentPlacement;
35
+ /**
36
+ * Provides content to include a component in the top of the table.
37
+ */
38
+ topContent?: ReactNode;
39
+ /**
40
+ * Where to place the `bottomContent` component.
41
+ * @default "inside"
42
+ */
43
+ bottomContentPlacement?: TableContentPlacement;
44
+ /**
45
+ * Provides content to include a component in the bottom of the table.
46
+ */
47
+ bottomContent?: ReactNode;
48
+ /**
49
+ * Whether the table base container should not be rendered.
50
+ * @default false
51
+ */
52
+ removeWrapper?: boolean;
53
+ /**
54
+ * How multiple selection should behave in the collection.
55
+ * The selection behavior for the table. If selectionMode is `"none"`, this will be `null`.
56
+ * otherwise, this will be `toggle` or `replace`.
57
+ * @default "toggle"
58
+ */
59
+ selectionBehavior?: SelectionBehavior | null;
60
+ /**
61
+ * Whether `disabledKeys` applies to all interactions, or only selection.
62
+ * @default "selection"
63
+ */
64
+ disabledBehavior?: DisabledBehavior;
65
+ /**
66
+ * Whether to disable the table and checkbox animations.
67
+ * @default false
68
+ */
69
+ disableAnimation?: boolean;
70
+ /**
71
+ * Whether to disable the keyboard navigation functionality.
72
+ * @default false
73
+ */
74
+ isKeyboardNavigationDisabled?: boolean;
75
+ /**
76
+ * Props to be passed to the checkboxes.
77
+ */
78
+ checkboxesProps?: CheckboxProps;
79
+ /**
80
+ * Custom Icon to be displayed in the table header - overrides the default chevron one
81
+ */
82
+ sortIcon?: ReactNode | ((props: unknown) => ReactNode);
83
+ /** Handler that is called when a user performs an action on the row. */
84
+ onRowAction?: (key: Key) => void;
85
+ /** Handler that is called when a user performs an action on the cell. */
86
+ onCellAction?: (key: Key) => void;
87
+ /**
88
+ * Classname or List of classes to change the classNames of the element.
89
+ * if `className` is passed, it will be added to the base slot.
90
+ *
91
+ * @example
92
+ * ```ts
93
+ * <Table classNames={{
94
+ * base:"base-classes", // table wrapper
95
+ * table: "table-classes",
96
+ * thead: "thead-classes",
97
+ * tbody: "tbody-classes",
98
+ * tr: "tr-classes",
99
+ * th: "th-classes",
100
+ * td: "td-classes",
101
+ * tfoot: "tfoot-classes",
102
+ * sortIcon: "sort-icon-classes",
103
+ * emptyWrapper: "empty-wrapper-classes",
104
+ * }} />
105
+ * ```
106
+ */
107
+ classNames?: SlotsToClasses<TableSlots>;
108
+ }
109
+ export type UseTableProps<T = object> = Props<T> & TableStateProps<T> & Omit<AriaTableProps, 'layout'> & TableVariantProps;
110
+ export interface ValuesType<T = object> {
111
+ state: TableState<T>;
112
+ slots: TableReturnType;
113
+ collection: TableCollection<T>;
114
+ color: TableVariantProps['color'];
115
+ isSelectable: boolean;
116
+ selectionMode: UseTableProps<T>['selectionMode'];
117
+ selectionBehavior: SelectionBehavior | null;
118
+ checkboxesProps?: CheckboxProps;
119
+ disabledBehavior: UseTableProps<T>['disabledBehavior'];
120
+ disableAnimation?: UseTableProps<T>['disableAnimation'];
121
+ isHeaderSticky?: UseTableProps<T>['isHeaderSticky'];
122
+ showSelectionCheckboxes: UseTableProps<T>['showSelectionCheckboxes'];
123
+ classNames?: SlotsToClasses<TableSlots>;
124
+ onRowAction?: UseTableProps<T>['onRowAction'];
125
+ onCellAction?: UseTableProps<T>['onCellAction'];
126
+ }
127
+ export declare function useTable<T extends object>(originalProps: UseTableProps<T>): {
128
+ BaseComponent: string | React.ComponentType<any>;
129
+ Component: import("@heroui/system-rsc").As<any>;
130
+ children: ((string | number | bigint | boolean | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | React.ReactPortal | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | null) & [React.ReactElement<import("@react-types/table").TableHeaderProps<T>, string | React.JSXElementConstructor<any>>, React.ReactElement<import("@react-types/table").TableBodyProps<T>, string | React.JSXElementConstructor<any>>]) | undefined;
131
+ state: TableState<T>;
132
+ collection: TableCollection<T>;
133
+ values: ValuesType<T>;
134
+ topContent: React.ReactNode;
135
+ bottomContent: React.ReactNode;
136
+ removeWrapper: boolean;
137
+ topContentPlacement: TableContentPlacement;
138
+ bottomContentPlacement: TableContentPlacement;
139
+ sortIcon: React.ReactNode | ((props: unknown) => ReactNode);
140
+ getBaseProps: PropGetter;
141
+ getWrapperProps: PropGetter;
142
+ getTableProps: PropGetter;
143
+ };
144
+ export type UseTableReturn = ReturnType<typeof useTable>;
145
+ export {};
@@ -0,0 +1,127 @@
1
+ import { useCallback, useMemo } from "react";
2
+ import { filterDOMProps, useDOMRef } from "@heroui/react-utils";
3
+ import { mergeProps, objectToDeps } from "@heroui/shared-utils";
4
+ import { mapPropsVariants, useProviderContext } from "@heroui/system";
5
+ import { cn } from "@heroui/theme";
6
+ import { useTable } from "@react-aria/table";
7
+ import { useTableState } from "@react-stately/table";
8
+ import { table } from "./table-theme.js";
9
+ function use_table_useTable(originalProps) {
10
+ const globalContext = useProviderContext();
11
+ const [props, variantProps] = mapPropsVariants(originalProps, table.variantKeys);
12
+ const { ref, as, baseRef, children, className, classNames, removeWrapper = false, disableAnimation = globalContext?.disableAnimation ?? false, isKeyboardNavigationDisabled = false, selectionMode = 'none', topContentPlacement = 'inside', bottomContentPlacement = 'inside', selectionBehavior = 'none' === selectionMode ? null : 'toggle', disabledBehavior = 'selection', showSelectionCheckboxes = 'multiple' === selectionMode && 'replace' !== selectionBehavior, BaseComponent = 'div', checkboxesProps, topContent, bottomContent, sortIcon, onRowAction, onCellAction, ...otherProps } = props;
13
+ const Component = as || 'table';
14
+ const shouldFilterDOMProps = 'string' == typeof Component;
15
+ const domRef = useDOMRef(ref);
16
+ const domBaseRef = useDOMRef(baseRef);
17
+ const state = useTableState({
18
+ ...originalProps,
19
+ children,
20
+ showSelectionCheckboxes
21
+ });
22
+ if (isKeyboardNavigationDisabled && !state.isKeyboardNavigationDisabled) state.setKeyboardNavigationDisabled(true);
23
+ const { collection } = state;
24
+ const { layout, ...otherOriginalProps } = originalProps;
25
+ const { gridProps } = useTable({
26
+ ...otherOriginalProps
27
+ }, state, domRef);
28
+ const isSelectable = 'none' !== selectionMode;
29
+ const isMultiSelectable = 'multiple' === selectionMode;
30
+ const slots = useMemo(()=>table({
31
+ ...variantProps,
32
+ isSelectable,
33
+ isMultiSelectable
34
+ }), [
35
+ objectToDeps(variantProps),
36
+ isSelectable,
37
+ isMultiSelectable
38
+ ]);
39
+ const baseStyles = cn(classNames?.base, className);
40
+ const values = useMemo(()=>({
41
+ state,
42
+ slots,
43
+ isSelectable,
44
+ collection,
45
+ classNames,
46
+ color: originalProps?.color,
47
+ disableAnimation,
48
+ checkboxesProps,
49
+ isHeaderSticky: originalProps?.isHeaderSticky ?? false,
50
+ selectionMode,
51
+ selectionBehavior,
52
+ disabledBehavior,
53
+ showSelectionCheckboxes,
54
+ onRowAction,
55
+ onCellAction
56
+ }), [
57
+ slots,
58
+ state,
59
+ collection,
60
+ isSelectable,
61
+ classNames,
62
+ selectionMode,
63
+ selectionBehavior,
64
+ checkboxesProps,
65
+ disabledBehavior,
66
+ disableAnimation,
67
+ showSelectionCheckboxes,
68
+ originalProps?.color,
69
+ originalProps?.isHeaderSticky,
70
+ onRowAction,
71
+ onCellAction
72
+ ]);
73
+ const getBaseProps = useCallback((props)=>({
74
+ ...props,
75
+ ref: domBaseRef,
76
+ className: slots.base({
77
+ class: cn(baseStyles, props?.className)
78
+ })
79
+ }), [
80
+ baseStyles,
81
+ slots
82
+ ]);
83
+ const getWrapperProps = useCallback((props)=>({
84
+ ...props,
85
+ ref: domBaseRef,
86
+ className: slots.wrapper({
87
+ class: cn(classNames?.wrapper, props?.className)
88
+ })
89
+ }), [
90
+ classNames?.wrapper,
91
+ slots
92
+ ]);
93
+ const getTableProps = useCallback((props)=>({
94
+ ...mergeProps(gridProps, filterDOMProps(otherProps, {
95
+ enabled: shouldFilterDOMProps
96
+ }), props),
97
+ onKeyDownCapture: void 0,
98
+ ref: domRef,
99
+ className: slots.table({
100
+ class: cn(classNames?.table, props?.className)
101
+ })
102
+ }), [
103
+ classNames?.table,
104
+ shouldFilterDOMProps,
105
+ slots,
106
+ gridProps,
107
+ otherProps
108
+ ]);
109
+ return {
110
+ BaseComponent,
111
+ Component,
112
+ children,
113
+ state,
114
+ collection,
115
+ values,
116
+ topContent,
117
+ bottomContent,
118
+ removeWrapper,
119
+ topContentPlacement,
120
+ bottomContentPlacement,
121
+ sortIcon,
122
+ getBaseProps,
123
+ getWrapperProps,
124
+ getTableProps
125
+ };
126
+ }
127
+ export { use_table_useTable as useTable };
@@ -0,0 +1,17 @@
1
+ import type { HTMLHeroUIProps } from '@heroui/system';
2
+ import type { Virtualizer } from '@tanstack/react-virtual';
3
+ import type { ValuesType } from './use-table';
4
+ export interface VirtualizedTableBodyProps extends HTMLHeroUIProps<'tbody'> {
5
+ slots: ValuesType['slots'];
6
+ collection: ValuesType['collection'];
7
+ state: ValuesType['state'];
8
+ isSelectable: ValuesType['isSelectable'];
9
+ color: ValuesType['color'];
10
+ disableAnimation: ValuesType['disableAnimation'];
11
+ checkboxesProps: ValuesType['checkboxesProps'];
12
+ selectionMode: ValuesType['selectionMode'];
13
+ classNames?: ValuesType['classNames'];
14
+ rowVirtualizer: Virtualizer<any, Element>;
15
+ }
16
+ declare const VirtualizedTableBody: import("@heroui/system-rsc").InternalForwardRefRenderFunction<"tbody", VirtualizedTableBodyProps, never>;
17
+ export default VirtualizedTableBody;