@particle-network/ui-react 0.7.0-beta.1 → 0.7.0-beta.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/ProgressWrapper/index.js +1 -1
- package/dist/components/UXColorPicker/color-fields.js +1 -1
- package/dist/components/UXSimplePopover/simple-popover.d.ts +1 -3
- package/dist/components/UXSimplePopover/simple-popover.js +4 -4
- package/dist/components/UXTable/base/index.d.ts +10 -0
- package/dist/components/UXTable/base/index.js +6 -0
- package/dist/components/UXTable/base/table-body.d.ts +20 -0
- package/dist/components/UXTable/base/table-body.js +4 -0
- package/dist/components/UXTable/base/table-cell.d.ts +6 -0
- package/dist/components/UXTable/base/table-cell.js +4 -0
- package/dist/components/UXTable/base/table-column.d.ts +6 -0
- package/dist/components/UXTable/base/table-column.js +4 -0
- package/dist/components/UXTable/base/table-header.d.ts +6 -0
- package/dist/components/UXTable/base/table-header.js +4 -0
- package/dist/components/UXTable/base/table-row.d.ts +6 -0
- package/dist/components/UXTable/base/table-row.js +4 -0
- package/dist/components/UXTable/index.d.ts +7 -37
- package/dist/components/UXTable/index.js +5 -14
- package/dist/components/UXTable/table-body.d.ts +15 -0
- package/dist/components/UXTable/table-body.js +87 -0
- package/dist/components/UXTable/table-cell.d.ts +19 -0
- package/dist/components/UXTable/table-cell.js +45 -0
- package/dist/components/UXTable/table-checkbox-cell.d.ts +23 -0
- package/dist/components/UXTable/table-checkbox-cell.js +48 -0
- package/dist/components/UXTable/table-column-header.d.ts +25 -0
- package/dist/components/UXTable/table-column-header.js +66 -0
- package/dist/components/UXTable/table-header-row.d.ts +14 -0
- package/dist/components/UXTable/table-header-row.js +29 -0
- package/dist/components/UXTable/table-row-group.d.ts +8 -0
- package/dist/components/UXTable/table-row-group.js +24 -0
- package/dist/components/UXTable/table-row.d.ts +15 -0
- package/dist/components/UXTable/table-row.js +61 -0
- package/dist/components/UXTable/table-select-all-checkbox.d.ts +18 -0
- package/dist/components/UXTable/table-select-all-checkbox.js +46 -0
- package/dist/components/UXTable/table-theme.d.ts +452 -0
- package/dist/components/UXTable/table-theme.js +282 -0
- package/dist/components/UXTable/table.d.ts +8 -0
- package/dist/components/UXTable/table.js +96 -0
- package/dist/components/UXTable/use-table.d.ts +145 -0
- package/dist/components/UXTable/use-table.js +127 -0
- package/dist/components/UXTable/virtualized-table-body.d.ts +17 -0
- package/dist/components/UXTable/virtualized-table-body.js +107 -0
- package/dist/components/UXTable/virtualized-table.d.ts +8 -0
- package/dist/components/UXTable/virtualized-table.js +115 -0
- package/dist/components/UXThemeSwitch/theme-switch.js +2 -1
- package/package.json +11 -5
- package/dist/components/UXTable/table.extend.d.ts +0 -34
- package/dist/components/UXTable/table.extend.js +0 -145
|
@@ -82,7 +82,7 @@ const ProgressWrapper = ({ className, value = 0, width, height, radius = 'sm', s
|
|
|
82
82
|
...restProps,
|
|
83
83
|
children: [
|
|
84
84
|
/*#__PURE__*/ jsxs("svg", {
|
|
85
|
-
className: cn('absolute
|
|
85
|
+
className: cn('absolute top-0 left-0', svgClassName),
|
|
86
86
|
width: widthValue,
|
|
87
87
|
height: heightValue,
|
|
88
88
|
children: [
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useCallback, useState } from "react";
|
|
4
|
-
import
|
|
4
|
+
import Switch3Icon from "@particle-network/icons/web/Switch3Icon";
|
|
5
5
|
import { Flex, VStack } from "../layout/index.js";
|
|
6
6
|
import { Text } from "../typography/Text.js";
|
|
7
7
|
import { UXButton } from "../UXButton/index.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
export type SimplePopoverPlacement = 'top' | 'bottom' | 'left' | 'right'
|
|
2
|
+
export type SimplePopoverPlacement = 'top' | 'bottom' | 'left' | 'right';
|
|
3
3
|
export type SimplePopoverTriggerType = 'click' | 'hover';
|
|
4
4
|
export interface UXSimplePopoverProps {
|
|
5
5
|
/** Popover content */
|
|
@@ -19,7 +19,5 @@ export interface UXSimplePopoverProps {
|
|
|
19
19
|
trigger?: string;
|
|
20
20
|
content?: string;
|
|
21
21
|
};
|
|
22
|
-
/** popovertargetaction when triggerType is click: 'toggle' | 'show' | 'hide' */
|
|
23
|
-
popoverTargetAction?: 'toggle' | 'show' | 'hide';
|
|
24
22
|
}
|
|
25
23
|
export declare const UXSimplePopover: React.FC<UXSimplePopoverProps>;
|
|
@@ -5,7 +5,7 @@ const UXSimplePopover = (props)=>{
|
|
|
5
5
|
const { content, children, triggerType = 'hover', placement = 'top', delay = 300, closeDelay = 100, classNames = {
|
|
6
6
|
trigger: '',
|
|
7
7
|
content: ''
|
|
8
|
-
}
|
|
8
|
+
} } = props;
|
|
9
9
|
const id = useId().replace(/:/g, '');
|
|
10
10
|
const popoverId = `simple-popover-${id}`;
|
|
11
11
|
const anchorName = `--simple-popover-${id}`;
|
|
@@ -61,8 +61,8 @@ const UXSimplePopover = (props)=>{
|
|
|
61
61
|
const isClick = 'click' === triggerType;
|
|
62
62
|
const trigger = isClick ? /*#__PURE__*/ jsx("button", {
|
|
63
63
|
type: "button",
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
popoverTarget: popoverId,
|
|
65
|
+
popoverTargetAction: "toggle",
|
|
66
66
|
className: classNames.trigger,
|
|
67
67
|
style: {
|
|
68
68
|
margin: 0,
|
|
@@ -105,7 +105,7 @@ const UXSimplePopover = (props)=>{
|
|
|
105
105
|
ref: popoverRef,
|
|
106
106
|
id: popoverId,
|
|
107
107
|
popover: isClick ? 'auto' : 'manual',
|
|
108
|
-
className: cn('bg-content1 text-foreground-300 shadow-box text-tiny leading-1.4
|
|
108
|
+
className: cn('bg-content1 text-foreground-300 shadow-box text-tiny leading-1.4 rounded-medium max-w-[300px] p-2.5 break-words wrap-break-word antialiased', classNames.content),
|
|
109
109
|
style: popoverAnchorStyle,
|
|
110
110
|
children: content
|
|
111
111
|
})
|
|
@@ -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,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,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,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,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;
|
|
@@ -1,37 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
|
|
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 {
|
|
2
|
-
import "
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
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 };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ReactNode } 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 SortIconProps {
|
|
6
|
+
'aria-hidden'?: boolean;
|
|
7
|
+
'data-direction'?: 'ascending' | 'descending';
|
|
8
|
+
'data-visible'?: boolean | 'true' | 'false';
|
|
9
|
+
className?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface TableColumnHeaderProps<T = object> extends HTMLHeroUIProps<'th'> {
|
|
12
|
+
slots: ValuesType['slots'];
|
|
13
|
+
state: ValuesType['state'];
|
|
14
|
+
classNames?: ValuesType['classNames'];
|
|
15
|
+
/**
|
|
16
|
+
* Custom Icon to be displayed in the table header - overrides the default chevron one
|
|
17
|
+
*/
|
|
18
|
+
sortIcon?: ReactNode | ((props: SortIconProps) => ReactNode);
|
|
19
|
+
/**
|
|
20
|
+
* The table node to render.
|
|
21
|
+
*/
|
|
22
|
+
node: GridNode<T>;
|
|
23
|
+
}
|
|
24
|
+
declare const TableColumnHeader: import("@heroui/system-rsc").InternalForwardRefRenderFunction<"th", TableColumnHeaderProps<object>, never>;
|
|
25
|
+
export default TableColumnHeader;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cloneElement, isValidElement } from "react";
|
|
3
|
+
import { filterDOMProps, useDOMRef } from "@heroui/react-utils";
|
|
4
|
+
import { ChevronDownIcon } from "@heroui/shared-icons";
|
|
5
|
+
import { dataAttr, mergeProps } from "@heroui/shared-utils";
|
|
6
|
+
import { forwardRef } from "@heroui/system";
|
|
7
|
+
import { cn } from "@heroui/theme";
|
|
8
|
+
import { useFocusRing } from "@react-aria/focus";
|
|
9
|
+
import { useHover } from "@react-aria/interactions";
|
|
10
|
+
import { useTableColumnHeader } from "@react-aria/table";
|
|
11
|
+
import { VisuallyHidden } from "@react-aria/visually-hidden";
|
|
12
|
+
const normalizeWidth = (value)=>'number' == typeof value ? `${value}px` : value;
|
|
13
|
+
const TableColumnHeader = forwardRef((props, ref)=>{
|
|
14
|
+
const { as, className, state, node, slots, classNames, sortIcon, ...otherProps } = props;
|
|
15
|
+
const Component = as || 'th';
|
|
16
|
+
const shouldFilterDOMProps = 'string' == typeof Component;
|
|
17
|
+
const domRef = useDOMRef(ref);
|
|
18
|
+
const { columnHeaderProps } = useTableColumnHeader({
|
|
19
|
+
node
|
|
20
|
+
}, state, domRef);
|
|
21
|
+
const thStyles = cn(classNames?.th, className, node.props?.className);
|
|
22
|
+
const { isFocusVisible, focusProps } = useFocusRing();
|
|
23
|
+
const { isHovered, hoverProps } = useHover({});
|
|
24
|
+
const { hideHeader, align, width, minWidth, maxWidth, ...columnProps } = node.props;
|
|
25
|
+
const { allowsSorting } = columnProps;
|
|
26
|
+
const columnStyles = {};
|
|
27
|
+
if (width) columnStyles.width = normalizeWidth(width);
|
|
28
|
+
if (minWidth) columnStyles.minWidth = normalizeWidth(minWidth);
|
|
29
|
+
if (maxWidth) columnStyles.maxWidth = normalizeWidth(maxWidth);
|
|
30
|
+
const sortIconProps = {
|
|
31
|
+
'aria-hidden': true,
|
|
32
|
+
'data-direction': state.sortDescriptor?.direction,
|
|
33
|
+
'data-visible': dataAttr(state.sortDescriptor?.column === node.key),
|
|
34
|
+
className: slots.sortIcon?.({
|
|
35
|
+
class: classNames?.sortIcon
|
|
36
|
+
})
|
|
37
|
+
};
|
|
38
|
+
const customSortIcon = 'function' == typeof sortIcon ? sortIcon(sortIconProps) : /*#__PURE__*/ isValidElement(sortIcon) && /*#__PURE__*/ cloneElement(sortIcon, sortIconProps);
|
|
39
|
+
return /*#__PURE__*/ jsxs(Component, {
|
|
40
|
+
ref: domRef,
|
|
41
|
+
colSpan: node.colspan,
|
|
42
|
+
"data-focus-visible": dataAttr(isFocusVisible),
|
|
43
|
+
"data-hover": dataAttr(isHovered),
|
|
44
|
+
"data-sortable": dataAttr(allowsSorting),
|
|
45
|
+
style: columnStyles,
|
|
46
|
+
...mergeProps(columnHeaderProps, focusProps, filterDOMProps(columnProps, {
|
|
47
|
+
enabled: shouldFilterDOMProps
|
|
48
|
+
}), allowsSorting ? hoverProps : {}, otherProps),
|
|
49
|
+
className: slots.th?.({
|
|
50
|
+
align,
|
|
51
|
+
class: thStyles
|
|
52
|
+
}),
|
|
53
|
+
children: [
|
|
54
|
+
hideHeader ? /*#__PURE__*/ jsx(VisuallyHidden, {
|
|
55
|
+
children: node.rendered
|
|
56
|
+
}) : node.rendered,
|
|
57
|
+
allowsSorting && (customSortIcon || /*#__PURE__*/ jsx(ChevronDownIcon, {
|
|
58
|
+
strokeWidth: 3,
|
|
59
|
+
...sortIconProps
|
|
60
|
+
}))
|
|
61
|
+
]
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
TableColumnHeader.displayName = 'HeroUI.TableColumnHeader';
|
|
65
|
+
const table_column_header = TableColumnHeader;
|
|
66
|
+
export { table_column_header as default };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { HTMLHeroUIProps } from '@heroui/system';
|
|
2
|
+
import type { GridNode } from '@react-types/grid';
|
|
3
|
+
import type { ValuesType } from './use-table';
|
|
4
|
+
export interface TableHeaderRowProps<T = object> extends HTMLHeroUIProps<'tr'> {
|
|
5
|
+
/**
|
|
6
|
+
* The table node to render.
|
|
7
|
+
*/
|
|
8
|
+
node: GridNode<T>;
|
|
9
|
+
slots: ValuesType['slots'];
|
|
10
|
+
state: ValuesType['state'];
|
|
11
|
+
classNames?: ValuesType['classNames'];
|
|
12
|
+
}
|
|
13
|
+
declare const TableHeaderRow: import("@heroui/system-rsc").InternalForwardRefRenderFunction<"tr", TableHeaderRowProps<object>, never>;
|
|
14
|
+
export default TableHeaderRow;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { filterDOMProps, useDOMRef } from "@heroui/react-utils";
|
|
3
|
+
import { mergeProps } from "@heroui/shared-utils";
|
|
4
|
+
import { forwardRef } from "@heroui/system";
|
|
5
|
+
import { cn } from "@heroui/theme";
|
|
6
|
+
import { useTableHeaderRow } from "@react-aria/table";
|
|
7
|
+
const TableHeaderRow = forwardRef((props, ref)=>{
|
|
8
|
+
const { as, className, children, node, slots, classNames, state, ...otherProps } = props;
|
|
9
|
+
const Component = as || 'tr';
|
|
10
|
+
const shouldFilterDOMProps = 'string' == typeof Component;
|
|
11
|
+
const domRef = useDOMRef(ref);
|
|
12
|
+
const { rowProps } = useTableHeaderRow({
|
|
13
|
+
node
|
|
14
|
+
}, state, domRef);
|
|
15
|
+
const trStyles = cn(classNames?.tr, className, node.props?.className);
|
|
16
|
+
return /*#__PURE__*/ jsx(Component, {
|
|
17
|
+
ref: domRef,
|
|
18
|
+
...mergeProps(rowProps, filterDOMProps(node.props, {
|
|
19
|
+
enabled: shouldFilterDOMProps
|
|
20
|
+
}), otherProps),
|
|
21
|
+
className: slots.tr?.({
|
|
22
|
+
class: trStyles
|
|
23
|
+
}),
|
|
24
|
+
children: children
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
TableHeaderRow.displayName = 'HeroUI.TableHeaderRow';
|
|
28
|
+
const table_header_row = TableHeaderRow;
|
|
29
|
+
export { table_header_row as default };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { HTMLHeroUIProps } from '@heroui/system';
|
|
2
|
+
import type { ValuesType } from './use-table';
|
|
3
|
+
export interface TableRowGroupProps extends HTMLHeroUIProps<'thead'> {
|
|
4
|
+
slots: ValuesType['slots'];
|
|
5
|
+
classNames?: ValuesType['classNames'];
|
|
6
|
+
}
|
|
7
|
+
declare const TableRowGroup: import("react").ForwardRefExoticComponent<TableRowGroupProps & import("react").RefAttributes<HTMLTableSectionElement>>;
|
|
8
|
+
export default TableRowGroup;
|