@particle-network/ui-react 0.6.2-beta.0 → 0.7.0-beta.10

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 (49) 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.d.ts +1 -3
  4. package/dist/components/UXSimplePopover/simple-popover.js +4 -4
  5. package/dist/components/UXTable/base/index.d.ts +10 -0
  6. package/dist/components/UXTable/base/index.js +6 -0
  7. package/dist/components/UXTable/base/table-body.d.ts +20 -0
  8. package/dist/components/UXTable/base/table-body.js +4 -0
  9. package/dist/components/UXTable/base/table-cell.d.ts +6 -0
  10. package/dist/components/UXTable/base/table-cell.js +4 -0
  11. package/dist/components/UXTable/base/table-column.d.ts +6 -0
  12. package/dist/components/UXTable/base/table-column.js +4 -0
  13. package/dist/components/UXTable/base/table-header.d.ts +6 -0
  14. package/dist/components/UXTable/base/table-header.js +4 -0
  15. package/dist/components/UXTable/base/table-row.d.ts +6 -0
  16. package/dist/components/UXTable/base/table-row.js +4 -0
  17. package/dist/components/UXTable/index.d.ts +7 -37
  18. package/dist/components/UXTable/index.js +5 -14
  19. package/dist/components/UXTable/table-body.d.ts +15 -0
  20. package/dist/components/UXTable/table-body.js +87 -0
  21. package/dist/components/UXTable/table-cell.d.ts +19 -0
  22. package/dist/components/UXTable/table-cell.js +45 -0
  23. package/dist/components/UXTable/table-checkbox-cell.d.ts +23 -0
  24. package/dist/components/UXTable/table-checkbox-cell.js +48 -0
  25. package/dist/components/UXTable/table-column-header.d.ts +25 -0
  26. package/dist/components/UXTable/table-column-header.js +66 -0
  27. package/dist/components/UXTable/table-header-row.d.ts +14 -0
  28. package/dist/components/UXTable/table-header-row.js +29 -0
  29. package/dist/components/UXTable/table-row-group.d.ts +8 -0
  30. package/dist/components/UXTable/table-row-group.js +24 -0
  31. package/dist/components/UXTable/table-row.d.ts +15 -0
  32. package/dist/components/UXTable/table-row.js +61 -0
  33. package/dist/components/UXTable/table-select-all-checkbox.d.ts +18 -0
  34. package/dist/components/UXTable/table-select-all-checkbox.js +46 -0
  35. package/dist/components/UXTable/table-theme.d.ts +452 -0
  36. package/dist/components/UXTable/table-theme.js +282 -0
  37. package/dist/components/UXTable/table.d.ts +8 -0
  38. package/dist/components/UXTable/table.js +96 -0
  39. package/dist/components/UXTable/use-table.d.ts +145 -0
  40. package/dist/components/UXTable/use-table.js +127 -0
  41. package/dist/components/UXTable/virtualized-table-body.d.ts +17 -0
  42. package/dist/components/UXTable/virtualized-table-body.js +107 -0
  43. package/dist/components/UXTable/virtualized-table.d.ts +8 -0
  44. package/dist/components/UXTable/virtualized-table.js +115 -0
  45. package/dist/components/UXThemeSwitch/theme-switch.js +2 -1
  46. package/dist/utils/input-classes.js +4 -4
  47. package/package.json +11 -5
  48. package/dist/components/UXTable/table.extend.d.ts +0 -34
  49. package/dist/components/UXTable/table.extend.js +0 -145
@@ -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";
@@ -201,7 +201,7 @@ const inputClasses = {
201
201
  color: 'default',
202
202
  isInvalid: false,
203
203
  class: {
204
- inputWrapper: 'group-data-[focus=true]:border-foreground'
204
+ inputWrapper: 'group-data-[focus=true]:border-secondary'
205
205
  }
206
206
  },
207
207
  {
@@ -266,9 +266,9 @@ const inputClasses = {
266
266
  isInvalid: false,
267
267
  class: {
268
268
  inputWrapper: [
269
- 'border-foreground',
270
- 'data-[hover=true]:border-foreground',
271
- 'group-data-[focus=true]:border-foreground'
269
+ 'border-secondary',
270
+ 'data-[hover=true]:border-secondary',
271
+ 'group-data-[focus=true]:border-secondary'
272
272
  ]
273
273
  }
274
274
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@particle-network/ui-react",
3
- "version": "0.6.2-beta.0",
3
+ "version": "0.7.0-beta.10",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -33,26 +33,32 @@
33
33
  "tailwind-preset.js"
34
34
  ],
35
35
  "devDependencies": {
36
- "@heroui/react": "^2.8.2",
37
36
  "@rsbuild/plugin-react": "^1.3.5",
38
37
  "@rslib/core": "^0.12.3",
39
38
  "@types/react": "^19.1.10",
40
39
  "react": "^19.1.0",
41
- "@particle-network/eslint-config": "0.3.0",
42
- "@particle-network/lintstaged-config": "0.1.0"
40
+ "@particle-network/lintstaged-config": "0.1.0",
41
+ "@particle-network/eslint-config": "0.3.0"
43
42
  },
44
43
  "peerDependencies": {
45
44
  "react": ">=16.9.0",
46
45
  "react-dom": ">=16.9.0"
47
46
  },
48
47
  "dependencies": {
48
+ "@heroui/react": "^2.8.2",
49
+ "@tanstack/react-virtual": "^3.13.21",
49
50
  "ahooks": "^3.9.4",
51
+ "clsx": "^2.1.1",
52
+ "color2k": "^2.0.3",
50
53
  "copy-to-clipboard": "^3.3.3",
51
54
  "immer": "^11.1.3",
52
55
  "react-aria-components": "^1.14.0",
56
+ "react-stately": "^3.45.0",
57
+ "tailwind-merge": "2.6.0",
58
+ "tailwind-variants": "^3.2.2",
53
59
  "values.js": "^2.1.1",
54
60
  "zustand": "^5.0.8",
55
- "@particle-network/icons": "0.6.1",
61
+ "@particle-network/icons": "0.7.0-beta.5",
56
62
  "@particle-network/ui-shared": "0.5.0"
57
63
  },
58
64
  "scripts": {
@@ -1,34 +0,0 @@
1
- declare const ExtendedTable: import("react").ForwardRefExoticComponent<(Omit<import("@heroui/system-rsc").OmitCommonProps<Omit<import("react").DetailedHTMLProps<import("react").TableHTMLAttributes<HTMLTableElement>, HTMLTableElement>, "ref">, keyof import("@heroui/table").TableProps<object>> & import("@heroui/table").TableProps<object> & {
2
- as?: import("@heroui/system-rsc").As<any> | undefined;
3
- } & {
4
- color?: "default" | undefined;
5
- size?: "md" | "lg" | undefined;
6
- layout?: "auto" | "fixed" | undefined;
7
- radius?: "sm" | "md" | "lg" | "none" | undefined;
8
- shadow?: "sm" | "md" | "lg" | "none" | undefined;
9
- hideHeader?: boolean | undefined;
10
- isStriped?: boolean | undefined;
11
- isCompact?: boolean | undefined;
12
- isHeaderSticky?: boolean | undefined;
13
- isSelectable?: boolean | undefined;
14
- isMultiSelectable?: boolean | undefined;
15
- fullWidth?: boolean | undefined;
16
- align?: "start" | "end" | "center" | undefined;
17
- }, "ref"> | Omit<import("@heroui/system-rsc").OmitCommonProps<Omit<Omit<any, "ref">, never>, keyof import("@heroui/table").TableProps<object>> & import("@heroui/table").TableProps<object> & {
18
- as?: import("@heroui/system-rsc").As<any> | undefined;
19
- } & {
20
- color?: "default" | undefined;
21
- size?: "md" | "lg" | undefined;
22
- layout?: "auto" | "fixed" | undefined;
23
- radius?: "sm" | "md" | "lg" | "none" | undefined;
24
- shadow?: "sm" | "md" | "lg" | "none" | undefined;
25
- hideHeader?: boolean | undefined;
26
- isStriped?: boolean | undefined;
27
- isCompact?: boolean | undefined;
28
- isHeaderSticky?: boolean | undefined;
29
- isSelectable?: boolean | undefined;
30
- isMultiSelectable?: boolean | undefined;
31
- fullWidth?: boolean | undefined;
32
- align?: "start" | "end" | "center" | undefined;
33
- }, "ref">) & import("react").RefAttributes<HTMLElement>>;
34
- export default ExtendedTable;
@@ -1,145 +0,0 @@
1
- import { extendVariants } from "@heroui/system-rsc";
2
- import { Table } from "@heroui/table";
3
- const ExtendedTable = extendVariants(Table, {
4
- variants: {
5
- color: {
6
- default: {
7
- wrapper: 'p-0 gap-5',
8
- thead: '[&>tr]:first:border-b [&>tr]:first:border-divider',
9
- th: 'bg-transparent !text-caption1 text-foreground-300 font-medium px-lg h-auto',
10
- td: 'before:bg-default/60 data-[selected=true]:text-default-foreground font-medium first:rounded-l-md last:rounded-r-md'
11
- }
12
- },
13
- size: {
14
- md: {
15
- th: 'py-md'
16
- },
17
- lg: {
18
- th: 'py-5',
19
- td: 'py-lg'
20
- }
21
- },
22
- layout: {
23
- auto: {
24
- table: 'table-auto'
25
- },
26
- fixed: {
27
- table: 'table-fixed'
28
- }
29
- },
30
- radius: {
31
- none: {
32
- wrapper: 'rounded-none'
33
- },
34
- sm: {
35
- wrapper: 'rounded-small'
36
- },
37
- md: {
38
- wrapper: 'rounded-medium'
39
- },
40
- lg: {
41
- wrapper: 'rounded-large'
42
- }
43
- },
44
- shadow: {
45
- none: {
46
- wrapper: 'shadow-none'
47
- },
48
- sm: {
49
- wrapper: 'shadow-small'
50
- },
51
- md: {
52
- wrapper: 'shadow-medium'
53
- },
54
- lg: {
55
- wrapper: 'shadow-large'
56
- }
57
- },
58
- hideHeader: {
59
- true: {
60
- thead: 'hidden'
61
- }
62
- },
63
- isStriped: {
64
- true: {
65
- td: [
66
- 'group-data-[odd=true]/tr:before:bg-default-100',
67
- 'group-data-[odd=true]/tr:before:opacity-100',
68
- 'group-data-[odd=true]/tr:before:-z-10'
69
- ]
70
- }
71
- },
72
- isCompact: {
73
- true: {
74
- td: 'py-1'
75
- },
76
- false: {}
77
- },
78
- isHeaderSticky: {
79
- true: {
80
- thead: 'sticky top-0 z-20 [&>tr]:first:shadow-small'
81
- }
82
- },
83
- isSelectable: {
84
- true: {
85
- tr: 'cursor-default',
86
- td: [
87
- 'group-aria-[selected=false]/tr:group-data-[hover=true]/tr:before:bg-background-200',
88
- 'group-aria-[selected=false]/tr:group-data-[hover=true]/tr:before:opacity-70'
89
- ]
90
- }
91
- },
92
- isMultiSelectable: {
93
- true: {
94
- td: [
95
- 'group-data-[first=true]/tr:first:before:rounded-ss-lg',
96
- 'group-data-[first=true]/tr:last:before:rounded-se-lg',
97
- 'group-data-[middle=true]/tr:before:rounded-none',
98
- 'group-data-[last=true]/tr:first:before:rounded-es-lg',
99
- 'group-data-[last=true]/tr:last:before:rounded-ee-lg'
100
- ]
101
- },
102
- false: {
103
- td: [
104
- 'first:before:rounded-s-lg',
105
- 'last:before:rounded-e-lg'
106
- ]
107
- }
108
- },
109
- fullWidth: {
110
- true: {
111
- base: 'w-full',
112
- wrapper: 'w-full',
113
- table: 'w-full'
114
- }
115
- },
116
- align: {
117
- start: {
118
- th: 'text-start',
119
- td: 'text-start'
120
- },
121
- center: {
122
- th: 'text-center',
123
- td: 'text-center'
124
- },
125
- end: {
126
- th: 'text-end',
127
- td: 'text-end'
128
- }
129
- }
130
- },
131
- defaultVariants: {
132
- layout: 'auto',
133
- shadow: 'none',
134
- radius: 'none',
135
- color: 'default',
136
- size: 'md',
137
- isCompact: false,
138
- hideHeader: false,
139
- isStriped: false,
140
- fullWidth: true,
141
- align: 'start'
142
- }
143
- });
144
- const table_extend = ExtendedTable;
145
- export { table_extend as default };