@particle-network/ui-react 0.7.0-beta.2 → 0.7.0-beta.20

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 (62) hide show
  1. package/dist/components/ProgressWrapper/index.js +47 -45
  2. package/dist/components/UXButton/button-theme.js +8 -8
  3. package/dist/components/UXColorPicker/color-fields.js +1 -1
  4. package/dist/components/UXHint/index.d.ts +6 -3
  5. package/dist/components/UXHint/index.js +9 -19
  6. package/dist/components/UXSimplePopover/index.d.ts +1 -0
  7. package/dist/components/UXSimplePopover/index.js +1 -0
  8. package/dist/components/UXSimplePopover/provider.d.ts +22 -0
  9. package/dist/components/UXSimplePopover/provider.js +197 -0
  10. package/dist/components/UXSimplePopover/simple-popover.d.ts +8 -3
  11. package/dist/components/UXSimplePopover/simple-popover.js +114 -104
  12. package/dist/components/UXTable/base/index.d.ts +10 -0
  13. package/dist/components/UXTable/base/index.js +6 -0
  14. package/dist/components/UXTable/base/table-body.d.ts +20 -0
  15. package/dist/components/UXTable/base/table-body.js +4 -0
  16. package/dist/components/UXTable/base/table-cell.d.ts +6 -0
  17. package/dist/components/UXTable/base/table-cell.js +4 -0
  18. package/dist/components/UXTable/base/table-column.d.ts +6 -0
  19. package/dist/components/UXTable/base/table-column.js +4 -0
  20. package/dist/components/UXTable/base/table-header.d.ts +6 -0
  21. package/dist/components/UXTable/base/table-header.js +4 -0
  22. package/dist/components/UXTable/base/table-row.d.ts +6 -0
  23. package/dist/components/UXTable/base/table-row.js +4 -0
  24. package/dist/components/UXTable/index.d.ts +7 -37
  25. package/dist/components/UXTable/index.js +5 -14
  26. package/dist/components/UXTable/table-body.d.ts +15 -0
  27. package/dist/components/UXTable/table-body.js +87 -0
  28. package/dist/components/UXTable/table-cell.d.ts +19 -0
  29. package/dist/components/UXTable/table-cell.js +45 -0
  30. package/dist/components/UXTable/table-checkbox-cell.d.ts +23 -0
  31. package/dist/components/UXTable/table-checkbox-cell.js +48 -0
  32. package/dist/components/UXTable/table-column-header.d.ts +25 -0
  33. package/dist/components/UXTable/table-column-header.js +66 -0
  34. package/dist/components/UXTable/table-header-row.d.ts +14 -0
  35. package/dist/components/UXTable/table-header-row.js +29 -0
  36. package/dist/components/UXTable/table-row-group.d.ts +8 -0
  37. package/dist/components/UXTable/table-row-group.js +24 -0
  38. package/dist/components/UXTable/table-row.d.ts +15 -0
  39. package/dist/components/UXTable/table-row.js +61 -0
  40. package/dist/components/UXTable/table-select-all-checkbox.d.ts +18 -0
  41. package/dist/components/UXTable/table-select-all-checkbox.js +46 -0
  42. package/dist/components/UXTable/table-theme.d.ts +452 -0
  43. package/dist/components/UXTable/table-theme.js +282 -0
  44. package/dist/components/UXTable/table.d.ts +8 -0
  45. package/dist/components/UXTable/table.js +96 -0
  46. package/dist/components/UXTable/use-table.d.ts +145 -0
  47. package/dist/components/UXTable/use-table.js +127 -0
  48. package/dist/components/UXTable/virtualized-table-body.d.ts +17 -0
  49. package/dist/components/UXTable/virtualized-table-body.js +107 -0
  50. package/dist/components/UXTable/virtualized-table.d.ts +8 -0
  51. package/dist/components/UXTable/virtualized-table.js +115 -0
  52. package/dist/components/UXThemeSwitch/theme-switch.js +8 -1
  53. package/dist/components/UXThemeSwitch/use-theme.js +1 -1
  54. package/dist/components/UXToast/index.d.ts +4 -1
  55. package/dist/components/UXToast/index.js +2 -2
  56. package/dist/components/layout/Box/box-theme.d.ts +2 -2
  57. package/dist/components/layout/Box/box-theme.js +1 -1
  58. package/dist/components/typography/text-theme.d.ts +2 -2
  59. package/dist/components/typography/text-theme.js +1 -1
  60. package/package.json +10 -4
  61. package/dist/components/UXTable/table.extend.d.ts +0 -34
  62. package/dist/components/UXTable/table.extend.js +0 -145
@@ -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;
@@ -0,0 +1,107 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { filterDOMProps, useDOMRef } from "@heroui/react-utils";
3
+ import { dataAttr, mergeProps } from "@heroui/shared-utils";
4
+ import { forwardRef } from "@heroui/system";
5
+ import { cn } from "@heroui/theme";
6
+ import { useTableRowGroup } from "@react-aria/table";
7
+ import { UXEmpty } from "../UXEmpty/index.js";
8
+ import table_cell from "./table-cell.js";
9
+ import table_checkbox_cell from "./table-checkbox-cell.js";
10
+ import table_row from "./table-row.js";
11
+ const VirtualizedTableBody = forwardRef((props, ref)=>{
12
+ const { as, className, slots, state, collection, isSelectable, color, disableAnimation, checkboxesProps, selectionMode, classNames, rowVirtualizer, ...otherProps } = props;
13
+ const Component = as || 'tbody';
14
+ const shouldFilterDOMProps = 'string' == typeof Component;
15
+ const domRef = useDOMRef(ref);
16
+ const { rowGroupProps } = useTableRowGroup();
17
+ const tbodyStyles = cn(classNames?.tbody, className);
18
+ const bodyProps = collection?.body.props;
19
+ const isLoading = bodyProps?.isLoading || bodyProps?.loadingState === 'loading' || bodyProps?.loadingState === 'loadingMore';
20
+ const items = [
21
+ ...collection.body.childNodes
22
+ ];
23
+ const virtualItems = rowVirtualizer.getVirtualItems();
24
+ let emptyContent;
25
+ let loadingContent;
26
+ if (0 === collection.size) emptyContent = /*#__PURE__*/ jsx("tr", {
27
+ role: "row",
28
+ children: /*#__PURE__*/ jsx("td", {
29
+ className: slots?.emptyWrapper({
30
+ class: classNames?.emptyWrapper
31
+ }),
32
+ colSpan: collection.columnCount,
33
+ role: "gridcell",
34
+ children: !isLoading && /*#__PURE__*/ jsx(UXEmpty, {})
35
+ })
36
+ });
37
+ if (isLoading && bodyProps.loadingContent) loadingContent = /*#__PURE__*/ jsxs("tr", {
38
+ role: "row",
39
+ children: [
40
+ /*#__PURE__*/ jsx("td", {
41
+ className: slots?.loadingWrapper({
42
+ class: classNames?.loadingWrapper
43
+ }),
44
+ colSpan: collection.columnCount,
45
+ role: "gridcell",
46
+ children: bodyProps.loadingContent
47
+ }),
48
+ emptyContent || 0 !== collection.size ? null : /*#__PURE__*/ jsx("td", {
49
+ className: slots?.emptyWrapper({
50
+ class: classNames?.emptyWrapper
51
+ })
52
+ })
53
+ ]
54
+ });
55
+ return /*#__PURE__*/ jsxs(Component, {
56
+ ref: domRef,
57
+ ...mergeProps(rowGroupProps, filterDOMProps(bodyProps, {
58
+ enabled: shouldFilterDOMProps
59
+ }), otherProps),
60
+ className: slots.tbody?.({
61
+ class: tbodyStyles
62
+ }),
63
+ "data-empty": dataAttr(0 === collection.size),
64
+ "data-loading": dataAttr(isLoading),
65
+ children: [
66
+ virtualItems.map((virtualRow, index)=>{
67
+ const row = items[virtualRow.index];
68
+ if (!row) return null;
69
+ return /*#__PURE__*/ jsx(table_row, {
70
+ classNames: classNames,
71
+ isSelectable: isSelectable,
72
+ node: row,
73
+ slots: slots,
74
+ state: state,
75
+ style: {
76
+ transform: `translateY(${virtualRow.start - index * virtualRow.size}px)`,
77
+ height: `${virtualRow.size}px`
78
+ },
79
+ children: [
80
+ ...row.childNodes
81
+ ].map((cell)=>cell.props.isSelectionCell ? /*#__PURE__*/ jsx(table_checkbox_cell, {
82
+ checkboxesProps: checkboxesProps,
83
+ classNames: classNames,
84
+ color: color,
85
+ disableAnimation: disableAnimation,
86
+ node: cell,
87
+ rowKey: row.key,
88
+ selectionMode: selectionMode,
89
+ slots: slots,
90
+ state: state
91
+ }, String(cell.key)) : /*#__PURE__*/ jsx(table_cell, {
92
+ classNames: classNames,
93
+ node: cell,
94
+ rowKey: row.key,
95
+ slots: slots,
96
+ state: state
97
+ }, String(cell.key)))
98
+ }, String(row.key));
99
+ }),
100
+ loadingContent,
101
+ emptyContent
102
+ ]
103
+ });
104
+ });
105
+ VirtualizedTableBody.displayName = 'HeroUI.VirtualizedTableBody';
106
+ const virtualized_table_body = VirtualizedTableBody;
107
+ export { virtualized_table_body as default };
@@ -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 VirtualizedTable: import("@heroui/system-rsc").InternalForwardRefRenderFunction<"table", TableProps<object>, never>;
8
+ export default VirtualizedTable;
@@ -0,0 +1,115 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { useCallback, useLayoutEffect, useRef, useState } from "react";
3
+ import { forwardRef } from "@heroui/system";
4
+ import { useVirtualizer } from "@tanstack/react-virtual";
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_body from "./virtualized-table-body.js";
11
+ const VirtualizedTable = forwardRef((props, ref)=>{
12
+ const { BaseComponent, Component, collection, values, topContent, topContentPlacement, bottomContentPlacement, bottomContent, getBaseProps, getWrapperProps, getTableProps } = useTable({
13
+ ...props,
14
+ ref
15
+ });
16
+ const { rowHeight = 40, maxTableHeight = 600 } = props;
17
+ const parentRef = useRef(null);
18
+ const Wrapper = useCallback(({ children })=>/*#__PURE__*/ jsx(BaseComponent, {
19
+ ...getWrapperProps(),
20
+ ref: parentRef,
21
+ style: {
22
+ height: maxTableHeight,
23
+ display: 'block'
24
+ },
25
+ children: children
26
+ }), [
27
+ getWrapperProps,
28
+ maxTableHeight
29
+ ]);
30
+ const items = [
31
+ ...collection.body.childNodes
32
+ ];
33
+ const count = items.length;
34
+ const [headerHeight, setHeaderHeight] = useState(0);
35
+ const headerRef = useRef(null);
36
+ useLayoutEffect(()=>{
37
+ if (headerRef.current) setHeaderHeight(headerRef.current.getBoundingClientRect().height);
38
+ }, [
39
+ headerRef
40
+ ]);
41
+ const rowVirtualizer = useVirtualizer({
42
+ count,
43
+ getScrollElement: ()=>parentRef.current,
44
+ estimateSize: ()=>rowHeight,
45
+ overscan: 5
46
+ });
47
+ const tableProps = getTableProps();
48
+ return /*#__PURE__*/ jsxs("div", {
49
+ ...getBaseProps(),
50
+ children: [
51
+ 'outside' === topContentPlacement && topContent,
52
+ /*#__PURE__*/ jsx(Wrapper, {
53
+ children: /*#__PURE__*/ jsxs(Fragment, {
54
+ children: [
55
+ 'inside' === topContentPlacement && topContent,
56
+ /*#__PURE__*/ jsxs(Component, {
57
+ ...tableProps,
58
+ style: {
59
+ height: `calc(${rowVirtualizer.getTotalSize() + headerHeight}px)`,
60
+ ...tableProps.style
61
+ },
62
+ children: [
63
+ /*#__PURE__*/ jsx(table_row_group, {
64
+ ref: headerRef,
65
+ classNames: values.classNames,
66
+ slots: values.slots,
67
+ children: collection.headerRows.map((headerRow)=>/*#__PURE__*/ jsx(table_header_row, {
68
+ classNames: values.classNames,
69
+ node: headerRow,
70
+ slots: values.slots,
71
+ state: values.state,
72
+ children: [
73
+ ...headerRow.childNodes
74
+ ].map((column)=>column?.props?.isSelectionCell ? /*#__PURE__*/ jsx(table_select_all_checkbox, {
75
+ checkboxesProps: values.checkboxesProps,
76
+ classNames: values.classNames,
77
+ color: values.color,
78
+ disableAnimation: values.disableAnimation,
79
+ node: column,
80
+ selectionMode: values.selectionMode,
81
+ slots: values.slots,
82
+ state: values.state
83
+ }, column?.key) : /*#__PURE__*/ jsx(table_column_header, {
84
+ classNames: values.classNames,
85
+ node: column,
86
+ slots: values.slots,
87
+ state: values.state
88
+ }, column?.key))
89
+ }, headerRow?.key))
90
+ }),
91
+ /*#__PURE__*/ jsx(virtualized_table_body, {
92
+ checkboxesProps: values.checkboxesProps,
93
+ classNames: values.classNames,
94
+ collection: values.collection,
95
+ color: values.color,
96
+ disableAnimation: values.disableAnimation,
97
+ isSelectable: values.isSelectable,
98
+ rowVirtualizer: rowVirtualizer,
99
+ selectionMode: values.selectionMode,
100
+ slots: values.slots,
101
+ state: values.state
102
+ })
103
+ ]
104
+ }),
105
+ 'inside' === bottomContentPlacement && bottomContent
106
+ ]
107
+ })
108
+ }),
109
+ 'outside' === bottomContentPlacement && bottomContent
110
+ ]
111
+ });
112
+ });
113
+ VirtualizedTable.displayName = 'HeroUI.VirtualizedTable';
114
+ const virtualized_table = VirtualizedTable;
115
+ export { virtualized_table as default };
@@ -1,7 +1,8 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  import { useEffect, useMemo, useState } from "react";
3
3
  import { useDisclosure } from "@heroui/use-disclosure";
4
- import { ChartColorSwitchIcon, CopyIcon } from "@particle-network/icons/web";
4
+ import ChartColorSwitchIcon from "@particle-network/icons/web/ChartColorSwitchIcon";
5
+ import CopyIcon from "@particle-network/icons/web/CopyIcon";
5
6
  import { themeData } from "@particle-network/ui-shared";
6
7
  import { useI18n } from "../../hooks/index.js";
7
8
  import { cn } from "../../utils/index.js";
@@ -18,6 +19,7 @@ import { UXTooltip } from "../UXTooltip/index.js";
18
19
  import { CustomThemeConfig } from "./custom-theme-config.js";
19
20
  import { ThemeItem } from "./theme-item.js";
20
21
  import { useTheme } from "./use-theme.js";
22
+ import { preloadFonts } from "./utils.js";
21
23
  const FONT_EXAMPLES = [
22
24
  {
23
25
  title: 'Manrope',
@@ -39,6 +41,11 @@ const UXThemeSwitchModal = ({ as = 'modal', omitThemes = [], backdrop, isOpen, o
39
41
  useEffect(()=>{
40
42
  initTheme();
41
43
  }, []);
44
+ useEffect(()=>{
45
+ if (isOpen) preloadFonts();
46
+ }, [
47
+ isOpen
48
+ ]);
42
49
  const Component = 'modal' === as ? UXModal : UXDrawer;
43
50
  const themes = useMemo(()=>themeData.filter((theme)=>!omitThemes.includes(theme.id)), [
44
51
  omitThemes
@@ -42,7 +42,7 @@ const useTheme = ()=>{
42
42
  wait: 300
43
43
  });
44
44
  const initTheme = ()=>{
45
- preloadFonts();
45
+ if (theme.fontName || fontUrl) preloadFonts();
46
46
  applyTheme(theme);
47
47
  debouncedApplyFont(fontUrl, theme.fontName);
48
48
  };