@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
@@ -1,115 +1,125 @@
1
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
- import react, { cloneElement, isValidElement, useCallback, useId, useRef } from "react";
1
+ import { jsx } from "react/jsx-runtime";
2
+ import react, { useCallback, useRef } from "react";
3
3
  import { cn } from "../../utils/index.js";
4
- const UXSimplePopover = (props)=>{
5
- const { content, children, triggerType = 'hover', placement = 'top', delay = 300, closeDelay = 100, classNames = {
6
- trigger: '',
7
- content: ''
8
- } } = props;
9
- const id = useId().replace(/:/g, '');
10
- const popoverId = `simple-popover-${id}`;
11
- const anchorName = `--simple-popover-${id}`;
12
- const popoverRef = useRef(null);
13
- const openTimerRef = useRef(null);
14
- const closeTimerRef = useRef(null);
15
- const clearOpenTimer = useCallback(()=>{
16
- if (null !== openTimerRef.current) {
17
- clearTimeout(openTimerRef.current);
18
- openTimerRef.current = null;
19
- }
20
- }, []);
21
- const clearCloseTimer = useCallback(()=>{
22
- if (null !== closeTimerRef.current) {
23
- clearTimeout(closeTimerRef.current);
24
- closeTimerRef.current = null;
25
- }
26
- }, []);
27
- const showPopover = useCallback(()=>{
28
- clearCloseTimer();
29
- openTimerRef.current = setTimeout(()=>{
30
- openTimerRef.current = null;
31
- popoverRef.current?.showPopover();
32
- }, delay);
33
- }, [
4
+ import { useSimplePopoverContext } from "./provider.js";
5
+ const warnedRef = {
6
+ current: false
7
+ };
8
+ const warnedChildRef = {
9
+ current: false
10
+ };
11
+ function composeEventHandlers(original, next) {
12
+ return (event)=>{
13
+ original?.(event);
14
+ if (!event.defaultPrevented) next?.(event);
15
+ };
16
+ }
17
+ function isIntrinsicInteractiveElement(element) {
18
+ return 'string' == typeof element.type && [
19
+ 'button',
20
+ 'a',
21
+ 'input',
22
+ 'select',
23
+ 'textarea',
24
+ 'summary'
25
+ ].includes(element.type);
26
+ }
27
+ const UXSimplePopover = ({ content, children, triggerType = 'hover', placement = 'top', size = 'md', offset = 8, delay = 300, closeDelay = 100, classNames })=>{
28
+ const ctx = useSimplePopoverContext();
29
+ const contentRef = useRef(content);
30
+ contentRef.current = content;
31
+ const optionsRef = useRef({
32
+ placement,
33
+ size,
34
+ offset,
35
+ delay,
36
+ closeDelay,
37
+ contentClassName: classNames?.content
38
+ });
39
+ optionsRef.current = {
40
+ placement,
41
+ size,
42
+ offset,
34
43
  delay,
35
- clearCloseTimer
44
+ closeDelay,
45
+ contentClassName: classNames?.content
46
+ };
47
+ const isClick = 'click' === triggerType;
48
+ const handleEnter = useCallback((e)=>{
49
+ if (ctx && !isClick) ctx.show(e.currentTarget, contentRef.current, optionsRef.current);
50
+ }, [
51
+ ctx,
52
+ isClick
36
53
  ]);
37
- const hidePopover = useCallback(()=>{
38
- clearOpenTimer();
39
- closeTimerRef.current = setTimeout(()=>{
40
- closeTimerRef.current = null;
41
- popoverRef.current?.hidePopover();
42
- }, closeDelay);
54
+ const handleLeave = useCallback(()=>{
55
+ if (ctx && !isClick) ctx.hide(optionsRef.current.closeDelay);
43
56
  }, [
44
- closeDelay,
45
- clearOpenTimer
57
+ ctx,
58
+ isClick
46
59
  ]);
47
- react.useEffect(()=>()=>{
48
- clearOpenTimer();
49
- clearCloseTimer();
50
- }, [
51
- clearOpenTimer,
52
- clearCloseTimer
60
+ const handlePointerDown = useCallback((e)=>{
61
+ if (ctx && isClick) ctx.prepare(e.currentTarget, contentRef.current, optionsRef.current);
62
+ }, [
63
+ ctx,
64
+ isClick
53
65
  ]);
54
- const triggerAnchorStyle = {
55
- anchorName
56
- };
57
- const popoverAnchorStyle = {
58
- positionAnchor: anchorName,
59
- positionArea: placement
60
- };
61
- const isClick = 'click' === triggerType;
62
- const trigger = isClick ? /*#__PURE__*/ jsx("button", {
63
- type: "button",
64
- popoverTarget: popoverId,
65
- popoverTargetAction: "toggle",
66
- className: classNames.trigger,
67
- style: {
68
- margin: 0,
69
- padding: 0,
70
- border: 'none',
71
- font: 'inherit',
72
- color: 'inherit',
73
- backgroundColor: 'transparent',
74
- cursor: 'pointer',
75
- ...triggerAnchorStyle
76
- },
77
- children: children
78
- }) : (()=>{
79
- const childElement = /*#__PURE__*/ isValidElement(children) && 1 === react.Children.count(children) ? children : null;
80
- return childElement ? /*#__PURE__*/ cloneElement(childElement, {
81
- onMouseEnter: showPopover,
82
- onMouseLeave: hidePopover,
83
- className: [
84
- classNames.trigger,
85
- childElement.props?.className
86
- ].filter(Boolean).join(' '),
87
- style: {
88
- ...childElement.props?.style,
89
- ...triggerAnchorStyle
66
+ const handleClick = useCallback((e)=>{
67
+ if (ctx && isClick) {
68
+ ctx.prepare(e.currentTarget, contentRef.current, optionsRef.current);
69
+ ctx.toggle();
70
+ }
71
+ }, [
72
+ ctx,
73
+ isClick
74
+ ]);
75
+ const handleKeyDown = useCallback((e)=>{
76
+ if (isClick && ('Enter' === e.key || ' ' === e.key)) {
77
+ e.preventDefault();
78
+ if (ctx) {
79
+ ctx.prepare(e.currentTarget, contentRef.current, optionsRef.current);
80
+ ctx.toggle();
90
81
  }
91
- }) : /*#__PURE__*/ jsx("span", {
92
- className: classNames.trigger,
93
- style: triggerAnchorStyle,
94
- role: "button",
95
- tabIndex: 0,
96
- onMouseEnter: showPopover,
97
- onMouseLeave: hidePopover,
98
- children: children
82
+ }
83
+ }, [
84
+ ctx,
85
+ isClick
86
+ ]);
87
+ if (!ctx && !warnedRef.current) {
88
+ warnedRef.current = true;
89
+ console.warn('[UXSimplePopover] must be used inside <UXSimplePopoverProvider>. Popover will not work.');
90
+ }
91
+ if (/*#__PURE__*/ react.isValidElement(children) && children.type !== react.Fragment) {
92
+ const child = children;
93
+ const interactiveElement = isIntrinsicInteractiveElement(child);
94
+ return /*#__PURE__*/ react.cloneElement(child, {
95
+ className: cn(child.props.className, classNames?.trigger),
96
+ onMouseEnter: composeEventHandlers(child.props.onMouseEnter, handleEnter),
97
+ onMouseLeave: composeEventHandlers(child.props.onMouseLeave, handleLeave),
98
+ ...isClick ? {
99
+ role: child.props.role ?? (interactiveElement ? void 0 : 'button'),
100
+ tabIndex: child.props.tabIndex ?? (interactiveElement ? void 0 : 0),
101
+ onPointerDown: composeEventHandlers(child.props.onPointerDown, handlePointerDown),
102
+ onClick: composeEventHandlers(child.props.onClick, handleClick),
103
+ onKeyDown: composeEventHandlers(child.props.onKeyDown, handleKeyDown)
104
+ } : {}
99
105
  });
100
- })();
101
- return /*#__PURE__*/ jsxs(Fragment, {
102
- children: [
103
- trigger,
104
- /*#__PURE__*/ jsx("div", {
105
- ref: popoverRef,
106
- id: popoverId,
107
- popover: isClick ? 'auto' : 'manual',
108
- className: cn('bg-content1 text-foreground-300 shadow-box text-tiny leading-1.4 wrap-break-word rounded-medium max-w-[300px] break-words p-2.5 antialiased', classNames.content),
109
- style: popoverAnchorStyle,
110
- children: content
111
- })
112
- ]
106
+ }
107
+ if (!warnedChildRef.current) {
108
+ warnedChildRef.current = true;
109
+ console.warn('[UXSimplePopover] children should be a single React element to avoid the fallback <span> wrapper.');
110
+ }
111
+ return /*#__PURE__*/ jsx("span", {
112
+ className: classNames?.trigger,
113
+ onMouseEnter: handleEnter,
114
+ onMouseLeave: handleLeave,
115
+ ...isClick ? {
116
+ role: 'button',
117
+ tabIndex: 0,
118
+ onPointerDown: handlePointerDown,
119
+ onClick: handleClick,
120
+ onKeyDown: handleKeyDown
121
+ } : {},
122
+ children: children
113
123
  });
114
124
  };
115
125
  UXSimplePopover.displayName = 'UXSimplePopover';
@@ -0,0 +1,10 @@
1
+ export { default as TableBody } from './table-body';
2
+ export { default as TableCell } from './table-cell';
3
+ export { default as TableColumn } from './table-column';
4
+ export { default as TableHeader } from './table-header';
5
+ export { default as TableRow } from './table-row';
6
+ export type { TableBodyProps } from './table-body';
7
+ export type { TableCellProps } from './table-cell';
8
+ export type { TableColumnProps } from './table-column';
9
+ export type { TableHeaderProps } from './table-header';
10
+ export type { TableRowProps } from './table-row';
@@ -0,0 +1,6 @@
1
+ import table_body from "./table-body.js";
2
+ import table_cell from "./table-cell.js";
3
+ import table_column from "./table-column.js";
4
+ import table_header from "./table-header.js";
5
+ import table_row from "./table-row.js";
6
+ export { table_body as TableBody, table_cell as TableCell, table_column as TableColumn, table_header as TableHeader, table_row as TableRow };
@@ -0,0 +1,20 @@
1
+ import type { JSX, ReactNode } from 'react';
2
+ import type { HTMLHeroUIProps } from '@heroui/system';
3
+ import type { TableBodyProps as TableBodyBaseProps } from '@react-types/table';
4
+ export interface TableBodyProps<T> extends TableBodyBaseProps<T>, Omit<HTMLHeroUIProps<'tbody'>, keyof TableBodyBaseProps<T>> {
5
+ /**
6
+ * Provides content to display a loading component when the `loadingState` is `loading` or `loadingMore`.
7
+ */
8
+ loadingContent?: ReactNode;
9
+ /**
10
+ * Whether the table data is currently loading.
11
+ * @default false
12
+ */
13
+ isLoading?: boolean;
14
+ /**
15
+ * Provides content to display when there are no rows in the table.
16
+ * */
17
+ emptyContent?: ReactNode;
18
+ }
19
+ declare const TableBody: <T>(props: TableBodyProps<T>) => JSX.Element;
20
+ export default TableBody;
@@ -0,0 +1,4 @@
1
+ import { TableBody } from "@react-stately/table";
2
+ const table_body_TableBody = TableBody;
3
+ const table_body = table_body_TableBody;
4
+ export { table_body as default };
@@ -0,0 +1,6 @@
1
+ import type { JSX } from 'react';
2
+ import type { HTMLHeroUIProps } from '@heroui/system';
3
+ import type { CellProps } from '@react-types/table';
4
+ export type TableCellProps = CellProps & HTMLHeroUIProps<'td'>;
5
+ declare const TableCell: (props: TableCellProps) => JSX.Element;
6
+ export default TableCell;
@@ -0,0 +1,4 @@
1
+ import { Cell } from "@react-stately/table";
2
+ const TableCell = Cell;
3
+ const table_cell = TableCell;
4
+ export { table_cell as default };
@@ -0,0 +1,6 @@
1
+ import type { JSX } from 'react';
2
+ import type { HTMLHeroUIProps } from '@heroui/system';
3
+ import type { SpectrumColumnProps } from '@react-types/table';
4
+ export type TableColumnProps<T> = Omit<SpectrumColumnProps<T>, 'showDivider'> & Omit<HTMLHeroUIProps<'th'>, keyof SpectrumColumnProps<T>>;
5
+ declare const TableColumn: <T>(props: TableColumnProps<T>) => JSX.Element;
6
+ export default TableColumn;
@@ -0,0 +1,4 @@
1
+ import { Column } from "@react-stately/table";
2
+ const TableColumn = Column;
3
+ const table_column = TableColumn;
4
+ export { table_column as default };
@@ -0,0 +1,6 @@
1
+ import type { JSX } from 'react';
2
+ import type { HTMLHeroUIProps } from '@heroui/system';
3
+ import type { TableHeaderProps as TableHeaderBaseProps } from '@react-types/table';
4
+ export type TableHeaderProps<T> = TableHeaderBaseProps<T> & Omit<HTMLHeroUIProps<'thead'>, keyof TableHeaderBaseProps<T>>;
5
+ declare const TableHeader: <T>(props: TableHeaderProps<T>) => JSX.Element;
6
+ export default TableHeader;
@@ -0,0 +1,4 @@
1
+ import { TableHeader } from "@react-stately/table";
2
+ const table_header_TableHeader = TableHeader;
3
+ const table_header = table_header_TableHeader;
4
+ export { table_header as default };
@@ -0,0 +1,6 @@
1
+ import type { JSX } from 'react';
2
+ import type { HTMLHeroUIProps } from '@heroui/system';
3
+ import type { RowProps } from '@react-types/table';
4
+ export type TableRowProps<T = object> = RowProps<T> & Omit<HTMLHeroUIProps<'tr'>, keyof RowProps<T>>;
5
+ declare const TableRow: (props: TableRowProps) => JSX.Element;
6
+ export default TableRow;
@@ -0,0 +1,4 @@
1
+ import { Row } from "@react-stately/table";
2
+ const TableRow = Row;
3
+ const table_row = TableRow;
4
+ export { table_row as default };
@@ -1,37 +1,7 @@
1
- import React from 'react';
2
- import ExtendedTable from './table.extend';
3
- export type UXTableProps = React.ComponentPropsWithRef<typeof ExtendedTable>;
4
- export declare const UXTable: import("@heroui/system-rsc").InternalForwardRefRenderFunction<"table", (Omit<import("@heroui/system-rsc").OmitCommonProps<Omit<React.DetailedHTMLProps<React.TableHTMLAttributes<HTMLTableElement>, HTMLTableElement>, "ref">, keyof import("@heroui/table").TableProps<object>> & import("@heroui/table").TableProps<object> & {
5
- as?: import("@heroui/system-rsc").As<any> | undefined;
6
- } & {
7
- color?: "default" | undefined;
8
- size?: "md" | "lg" | undefined;
9
- layout?: "auto" | "fixed" | undefined;
10
- radius?: "sm" | "md" | "lg" | "none" | undefined;
11
- shadow?: "sm" | "md" | "lg" | "none" | undefined;
12
- hideHeader?: boolean | undefined;
13
- isStriped?: boolean | undefined;
14
- isCompact?: boolean | undefined;
15
- isHeaderSticky?: boolean | undefined;
16
- isSelectable?: boolean | undefined;
17
- isMultiSelectable?: boolean | undefined;
18
- fullWidth?: boolean | undefined;
19
- align?: "start" | "end" | "center" | undefined;
20
- }, "ref"> | Omit<import("@heroui/system-rsc").OmitCommonProps<Omit<Omit<any, "ref">, never>, keyof import("@heroui/table").TableProps<object>> & import("@heroui/table").TableProps<object> & {
21
- as?: import("@heroui/system-rsc").As<any> | undefined;
22
- } & {
23
- color?: "default" | undefined;
24
- size?: "md" | "lg" | undefined;
25
- layout?: "auto" | "fixed" | undefined;
26
- radius?: "sm" | "md" | "lg" | "none" | undefined;
27
- shadow?: "sm" | "md" | "lg" | "none" | undefined;
28
- hideHeader?: boolean | undefined;
29
- isStriped?: boolean | undefined;
30
- isCompact?: boolean | undefined;
31
- isHeaderSticky?: boolean | undefined;
32
- isSelectable?: boolean | undefined;
33
- isMultiSelectable?: boolean | undefined;
34
- fullWidth?: boolean | undefined;
35
- align?: "start" | "end" | "center" | undefined;
36
- }, "ref">) & React.RefAttributes<HTMLElement>, never>;
37
- export { TableBody as UXTableBody, TableCell as UXTableCell, TableColumn as UXTableColumn, TableHeader as UXTableHeader, TableRow as UXTableRow, } from '@heroui/table';
1
+ export type { TableProps as UXTableProps } from './table';
2
+ export type { DisabledBehavior, Selection, SelectionBehavior, SelectionMode, SortDescriptor, } from '@react-types/shared';
3
+ export { useTable } from './use-table';
4
+ export { getKeyValue } from '@heroui/shared-utils';
5
+ export { default as UXTable } from './table';
6
+ export type { TableBodyProps as UXTableBodyProps, TableCellProps as UXTableCellProps, TableColumnProps as UXTableColumnProps, TableHeaderProps as UXTableHeaderProps, TableRowProps as UXTableRowProps, } from './base';
7
+ export { TableBody as UXTableBody, TableCell as UXTableCell, TableColumn as UXTableColumn, TableHeader as UXTableHeader, TableRow as UXTableRow, } from './base';
@@ -1,14 +1,5 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import "react";
3
- import { forwardRef } from "@heroui/system";
4
- import table_extend from "./table.extend.js";
5
- import { TableBody, TableCell, TableColumn, TableHeader, TableRow } from "@heroui/table";
6
- const UXTable = forwardRef((props, ref)=>{
7
- const { selectionMode = 'single', ...restProps } = props;
8
- return /*#__PURE__*/ jsx(table_extend, {
9
- selectionMode: selectionMode,
10
- ...restProps,
11
- ref: ref
12
- });
13
- });
14
- export { UXTable, TableBody as UXTableBody, TableCell as UXTableCell, TableColumn as UXTableColumn, TableHeader as UXTableHeader, TableRow as UXTableRow };
1
+ import { useTable } from "./use-table.js";
2
+ import { getKeyValue } from "@heroui/shared-utils";
3
+ import table from "./table.js";
4
+ import { TableBody, TableCell, TableColumn, TableHeader, TableRow } from "./base/index.js";
5
+ export { table as UXTable, TableBody as UXTableBody, TableCell as UXTableCell, TableColumn as UXTableColumn, TableHeader as UXTableHeader, TableRow as UXTableRow, getKeyValue, useTable };
@@ -0,0 +1,15 @@
1
+ import type { HTMLHeroUIProps } from '@heroui/system';
2
+ import type { ValuesType } from './use-table';
3
+ export interface TableBodyProps extends HTMLHeroUIProps<'tbody'> {
4
+ slots: ValuesType['slots'];
5
+ collection: ValuesType['collection'];
6
+ state: ValuesType['state'];
7
+ isSelectable: ValuesType['isSelectable'];
8
+ color: ValuesType['color'];
9
+ disableAnimation: ValuesType['disableAnimation'];
10
+ checkboxesProps: ValuesType['checkboxesProps'];
11
+ selectionMode: ValuesType['selectionMode'];
12
+ classNames?: ValuesType['classNames'];
13
+ }
14
+ declare const TableBody: import("@heroui/system-rsc").InternalForwardRefRenderFunction<"tbody", TableBodyProps, never>;
15
+ export default TableBody;
@@ -0,0 +1,87 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { useMemo } from "react";
3
+ import { filterDOMProps, useDOMRef } from "@heroui/react-utils";
4
+ import { dataAttr, mergeProps } from "@heroui/shared-utils";
5
+ import { forwardRef } from "@heroui/system";
6
+ import { cn } from "@heroui/theme";
7
+ import { useTableRowGroup } from "@react-aria/table";
8
+ import { UXEmpty } from "../UXEmpty/index.js";
9
+ import table_cell from "./table-cell.js";
10
+ import table_checkbox_cell from "./table-checkbox-cell.js";
11
+ import table_row from "./table-row.js";
12
+ const TableBody = forwardRef((props, ref)=>{
13
+ const { as, className, slots, state, collection, isSelectable, color, disableAnimation, checkboxesProps, selectionMode, classNames, ...otherProps } = props;
14
+ const Component = as || 'tbody';
15
+ const shouldFilterDOMProps = 'string' == typeof Component;
16
+ const domRef = useDOMRef(ref);
17
+ const { rowGroupProps } = useTableRowGroup();
18
+ const tbodyStyles = cn(classNames?.tbody, className);
19
+ const bodyProps = collection?.body.props;
20
+ const isLoading = bodyProps?.isLoading || bodyProps?.loadingState === 'loading' || bodyProps?.loadingState === 'loadingMore';
21
+ const renderRows = useMemo(()=>[
22
+ ...collection.body.childNodes
23
+ ].map((row)=>/*#__PURE__*/ jsx(table_row, {
24
+ classNames: classNames,
25
+ isSelectable: isSelectable,
26
+ node: row,
27
+ slots: slots,
28
+ state: state,
29
+ children: [
30
+ ...row.childNodes
31
+ ].map((cell)=>cell.props.isSelectionCell ? /*#__PURE__*/ jsx(table_checkbox_cell, {
32
+ checkboxesProps: checkboxesProps,
33
+ classNames: classNames,
34
+ color: color,
35
+ disableAnimation: disableAnimation,
36
+ node: cell,
37
+ rowKey: row.key,
38
+ selectionMode: selectionMode,
39
+ slots: slots,
40
+ state: state
41
+ }, cell.key) : /*#__PURE__*/ jsx(table_cell, {
42
+ classNames: classNames,
43
+ node: cell,
44
+ rowKey: row.key,
45
+ slots: slots,
46
+ state: state
47
+ }, cell.key))
48
+ }, row.key)), [
49
+ collection.body.childNodes,
50
+ classNames,
51
+ isSelectable,
52
+ slots,
53
+ state
54
+ ]);
55
+ let emptyContent;
56
+ let loadingContent;
57
+ if (0 === collection.size) emptyContent = /*#__PURE__*/ jsx("tr", {
58
+ role: "row",
59
+ children: /*#__PURE__*/ jsx("td", {
60
+ className: slots?.emptyWrapper({
61
+ class: classNames?.emptyWrapper
62
+ }),
63
+ colSpan: collection.columnCount,
64
+ role: "gridcell",
65
+ children: !isLoading && /*#__PURE__*/ jsx(UXEmpty, {})
66
+ })
67
+ });
68
+ return /*#__PURE__*/ jsxs(Component, {
69
+ ref: domRef,
70
+ ...mergeProps(rowGroupProps, filterDOMProps(bodyProps, {
71
+ enabled: shouldFilterDOMProps
72
+ }), otherProps),
73
+ className: slots.tbody?.({
74
+ class: tbodyStyles
75
+ }),
76
+ "data-empty": dataAttr(0 === collection.size),
77
+ "data-loading": dataAttr(isLoading),
78
+ children: [
79
+ renderRows,
80
+ loadingContent,
81
+ emptyContent
82
+ ]
83
+ });
84
+ });
85
+ TableBody.displayName = 'HeroUI.TableBody';
86
+ const table_body = TableBody;
87
+ export { table_body as default };
@@ -0,0 +1,19 @@
1
+ import type { Key as ReactKey } from 'react';
2
+ import type { HTMLHeroUIProps } from '@heroui/system';
3
+ import type { GridNode } from '@react-types/grid';
4
+ import type { ValuesType } from './use-table';
5
+ export interface TableCellProps<T = object> extends HTMLHeroUIProps<'td'> {
6
+ /**
7
+ * The key of the table row.
8
+ */
9
+ rowKey: ReactKey;
10
+ /**
11
+ * The table cell.
12
+ */
13
+ node: GridNode<T>;
14
+ slots: ValuesType['slots'];
15
+ state: ValuesType['state'];
16
+ classNames?: ValuesType['classNames'];
17
+ }
18
+ declare const TableCell: import("@heroui/system-rsc").InternalForwardRefRenderFunction<"td", TableCellProps<object>, never>;
19
+ export default TableCell;
@@ -0,0 +1,45 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { useMemo } from "react";
3
+ import { filterDOMProps, useDOMRef } from "@heroui/react-utils";
4
+ import { dataAttr, mergeProps } from "@heroui/shared-utils";
5
+ import { forwardRef } from "@heroui/system";
6
+ import { cn } from "@heroui/theme";
7
+ import { useFocusRing } from "@react-aria/focus";
8
+ import { useTableCell } from "@react-aria/table";
9
+ const TableCell = forwardRef((props, ref)=>{
10
+ const { as, className, node, rowKey, slots, state, classNames, ...otherProps } = props;
11
+ const Component = as || 'td';
12
+ const shouldFilterDOMProps = 'string' == typeof Component;
13
+ const domRef = useDOMRef(ref);
14
+ const { gridCellProps } = useTableCell({
15
+ node
16
+ }, state, domRef);
17
+ const tdStyles = cn(classNames?.td, className, node.props?.className);
18
+ const { isFocusVisible, focusProps } = useFocusRing();
19
+ const isRowSelected = state.selectionManager.isSelected(rowKey);
20
+ const cell = useMemo(()=>{
21
+ const cellType = typeof node.rendered;
22
+ return 'object' !== cellType && 'function' !== cellType ? /*#__PURE__*/ jsx("span", {
23
+ children: node.rendered
24
+ }) : node.rendered;
25
+ }, [
26
+ node.rendered
27
+ ]);
28
+ const columnProps = node.column?.props || {};
29
+ return /*#__PURE__*/ jsx(Component, {
30
+ ref: domRef,
31
+ "data-focus-visible": dataAttr(isFocusVisible),
32
+ "data-selected": dataAttr(isRowSelected),
33
+ ...mergeProps(gridCellProps, focusProps, filterDOMProps(node.props, {
34
+ enabled: shouldFilterDOMProps
35
+ }), otherProps),
36
+ className: slots.td?.({
37
+ align: columnProps.align,
38
+ class: tdStyles
39
+ }),
40
+ children: cell
41
+ });
42
+ });
43
+ TableCell.displayName = 'HeroUI.TableCell';
44
+ const table_cell = TableCell;
45
+ export { table_cell as default };
@@ -0,0 +1,23 @@
1
+ import type { Key as ReactKey } from 'react';
2
+ import type { HTMLHeroUIProps } from '@heroui/system';
3
+ import type { GridNode } from '@react-types/grid';
4
+ import type { ValuesType } from './use-table';
5
+ export interface TableCheckboxCellProps<T = object> extends HTMLHeroUIProps<'td'> {
6
+ /**
7
+ * The key of the table row.
8
+ */
9
+ rowKey: ReactKey;
10
+ /**
11
+ * The table cell.
12
+ */
13
+ node: GridNode<T>;
14
+ slots: ValuesType['slots'];
15
+ state: ValuesType['state'];
16
+ color: ValuesType['color'];
17
+ disableAnimation: ValuesType['disableAnimation'];
18
+ checkboxesProps: ValuesType['checkboxesProps'];
19
+ selectionMode: ValuesType['selectionMode'];
20
+ classNames?: ValuesType['classNames'];
21
+ }
22
+ declare const TableCheckboxCell: import("@heroui/system-rsc").InternalForwardRefRenderFunction<"td", TableCheckboxCellProps<object>, never>;
23
+ export default TableCheckboxCell;
@@ -0,0 +1,48 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { Checkbox } from "@heroui/checkbox";
3
+ import { filterDOMProps, useDOMRef } from "@heroui/react-utils";
4
+ import { dataAttr, mergeProps } from "@heroui/shared-utils";
5
+ import { forwardRef } from "@heroui/system";
6
+ import { cn } from "@heroui/theme";
7
+ import { useFocusRing } from "@react-aria/focus";
8
+ import { useTableCell, useTableSelectionCheckbox } from "@react-aria/table";
9
+ import { VisuallyHidden } from "@react-aria/visually-hidden";
10
+ const TableCheckboxCell = forwardRef((props, ref)=>{
11
+ const { as, className, node, rowKey, slots, state, color, disableAnimation, checkboxesProps, selectionMode, classNames, ...otherProps } = props;
12
+ const Component = as || 'td';
13
+ const shouldFilterDOMProps = 'string' == typeof Component;
14
+ const domRef = useDOMRef(ref);
15
+ const { gridCellProps } = useTableCell({
16
+ node
17
+ }, state, domRef);
18
+ const { isFocusVisible, focusProps } = useFocusRing();
19
+ const { checkboxProps } = useTableSelectionCheckbox({
20
+ key: node?.parentKey || node.key
21
+ }, state);
22
+ const tdStyles = cn(classNames?.td, className, node.props?.className);
23
+ const isSingleSelectionMode = 'single' === selectionMode;
24
+ const { onChange, ...otherCheckboxProps } = checkboxProps;
25
+ const isRowSelected = state.selectionManager.isSelected(rowKey);
26
+ return /*#__PURE__*/ jsx(Component, {
27
+ ref: domRef,
28
+ "data-focus-visible": dataAttr(isFocusVisible),
29
+ "data-selected": dataAttr(isRowSelected),
30
+ ...mergeProps(gridCellProps, focusProps, filterDOMProps(node.props, {
31
+ enabled: shouldFilterDOMProps
32
+ }), otherProps),
33
+ className: slots.td?.({
34
+ class: tdStyles
35
+ }),
36
+ children: isSingleSelectionMode ? /*#__PURE__*/ jsx(VisuallyHidden, {
37
+ children: checkboxProps['aria-label']
38
+ }) : /*#__PURE__*/ jsx(Checkbox, {
39
+ color: color,
40
+ disableAnimation: disableAnimation,
41
+ onValueChange: onChange,
42
+ ...mergeProps(checkboxesProps, otherCheckboxProps)
43
+ })
44
+ });
45
+ });
46
+ TableCheckboxCell.displayName = 'HeroUI.TableCheckboxCell';
47
+ const table_checkbox_cell = TableCheckboxCell;
48
+ export { table_checkbox_cell as default };