@canlooks/can-ui 0.0.48 → 0.0.51

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 (55) hide show
  1. package/dist/cjs/components/boundary/errorBoundary.js +1 -1
  2. package/dist/cjs/components/calendar/calendar.style.js +124 -124
  3. package/dist/cjs/components/calendar/panelYear.js +1 -1
  4. package/dist/cjs/components/curd/curd.js +2 -2
  5. package/dist/cjs/components/curd/curdColumnConfig.js +1 -1
  6. package/dist/cjs/components/curd/curdFilter.js +5 -3
  7. package/dist/cjs/components/curd/curdResizable.js +1 -1
  8. package/dist/cjs/components/dataGrid/dataGrid.d.ts +1 -1
  9. package/dist/cjs/components/dataGrid/dataGrid.js +15 -9
  10. package/dist/cjs/components/dialog/dialog.js +1 -1
  11. package/dist/cjs/components/drawer/drawer.js +1 -1
  12. package/dist/cjs/components/form/form.js +0 -1
  13. package/dist/cjs/components/inputBase/inputBase.js +1 -1
  14. package/dist/cjs/components/pagination/pager.js +1 -1
  15. package/dist/cjs/components/palette/palette.js +1 -1
  16. package/dist/cjs/components/pickerDialog/pickerDialog.js +1 -1
  17. package/dist/cjs/components/transitionBase/collapse.js +1 -1
  18. package/dist/cjs/components/tree/tree.style.js +2 -2
  19. package/dist/cjs/components/tree/treeNode.js +2 -2
  20. package/dist/cjs/components/treeSelect/treeSelect.js +6 -6
  21. package/dist/cjs/components/upload/imageItem.js +1 -1
  22. package/dist/cjs/utils/curd.d.ts +1 -0
  23. package/dist/cjs/utils/curd.js +3 -2
  24. package/dist/cjs/utils/tree.js +2 -0
  25. package/dist/esm/components/boundary/errorBoundary.js +1 -1
  26. package/dist/esm/components/calendar/calendar.style.js +124 -124
  27. package/dist/esm/components/calendar/panelYear.js +1 -1
  28. package/dist/esm/components/curd/curd.js +2 -2
  29. package/dist/esm/components/curd/curdColumnConfig.js +1 -1
  30. package/dist/esm/components/curd/curdFilter.js +5 -3
  31. package/dist/esm/components/curd/curdResizable.js +1 -1
  32. package/dist/esm/components/dataGrid/dataGrid.d.ts +1 -1
  33. package/dist/esm/components/dataGrid/dataGrid.js +15 -9
  34. package/dist/esm/components/dialog/dialog.js +1 -1
  35. package/dist/esm/components/drawer/drawer.js +1 -1
  36. package/dist/esm/components/form/form.js +0 -1
  37. package/dist/esm/components/inputBase/inputBase.js +1 -1
  38. package/dist/esm/components/pagination/pager.js +1 -1
  39. package/dist/esm/components/palette/palette.js +1 -1
  40. package/dist/esm/components/pickerDialog/pickerDialog.js +1 -1
  41. package/dist/esm/components/transitionBase/collapse.js +1 -1
  42. package/dist/esm/components/tree/tree.style.js +2 -2
  43. package/dist/esm/components/tree/treeNode.js +2 -2
  44. package/dist/esm/components/treeSelect/treeSelect.js +6 -6
  45. package/dist/esm/components/upload/imageItem.js +1 -1
  46. package/dist/esm/utils/curd.d.ts +1 -0
  47. package/dist/esm/utils/curd.js +3 -2
  48. package/dist/esm/utils/tree.js +3 -1
  49. package/documentation/dist/assets/{index-UW3tEkHN.js → index-Db8Y9DzG.js} +2901 -2901
  50. package/documentation/dist/index.html +1 -1
  51. package/documentation/vite.config.mjs +18 -0
  52. package/extensions/curd.cjs +5 -5
  53. package/extensions/documentViewer.cjs +5 -5
  54. package/extensions/textFormatter.cjs +5 -5
  55. package/package.json +1 -1
@@ -13,128 +13,128 @@ export const classes = defineInnerClasses('calendar', [
13
13
  'yearItem',
14
14
  'foot'
15
15
  ]);
16
- export const style = defineCss(({ divider, text, spacing }) => css `
17
- .${classes.head} {
18
- height: 40px;
19
- display: flex;
20
- align-items: center;
21
- justify-content: space-between;
22
- border-bottom: 1px solid ${divider};
23
- padding: 0 ${menuListPadding}px;
24
- position: relative;
25
-
26
- .${classes.headSide} {
27
- z-index: 1;
28
- }
29
-
30
- .${classes.headControl} {
31
- color: ${text.placeholder};
32
- }
33
-
34
- .${classes.headCenter} {
35
- display: flex;
36
- align-items: center;
37
- justify-content: center;
38
- position: absolute;
39
- inset: 0;
40
-
41
- .${classes.headButton} {
42
- font-weight: bold;
43
- color: ${text.primary};
44
- }
45
- }
46
- }
47
-
48
- .${classes.body} {
49
- padding: ${spacing[3]}px ${spacing[4]}px;
50
- display: grid;
51
- place-items: center;
52
-
53
- &[data-view-type=date] {
54
- font-size: ${13 / 14}em;
55
- grid-template-columns: repeat(7, 36px);
56
- grid-template-rows: repeat(7, 36px);
57
-
58
- .${classes.dateItem} {
59
- width: 24px;
60
- height: 24px;
61
-
62
- &:not([data-variant=filled]) {
63
- color: ${text.primary};
64
- border-color: ${text.disabled};
65
-
66
- &[data-other-month=true] {
67
- color: ${text.placeholder};
68
- }
69
- }
70
-
71
- &:disabled {
72
- width: 100%;
73
- border-radius: 0;
74
- }
75
- }
76
- }
77
-
78
- &[data-view-type=month], &[data-view-type=year] {
79
- grid-template-columns: repeat(3, 84px);
80
- grid-template-rows: repeat(4, 63px);
81
-
82
- .${classes.monthItem},
83
- .${classes.yearItem} {
84
- width: 72px;
85
- padding-inline: 0;
86
-
87
- &:not([data-variant=filled]) {
88
- color: ${text.primary};
89
- }
90
- }
91
- }
92
- }
93
-
94
- &[data-size=small] {
95
- .${classes.body} {
96
- &[data-view-type=date] {
97
- grid-template-columns: repeat(7, 30px);
98
- grid-template-rows: repeat(7, 30px);
99
- }
100
-
101
- &[data-view-type=month], &[data-view-type=year] {
102
- grid-template-columns: repeat(3, 70px);
103
- grid-template-rows: repeat(4, 52.5px);
104
-
105
- .${classes.monthItem},
106
- .${classes.yearItem} {
107
- width: 60px;
108
- }
109
- }
110
- }
111
- }
112
-
113
- &[data-size=large] {
114
- .${classes.body} {
115
- &[data-view-type=date] {
116
- font-size: 1em;
117
- grid-template-columns: repeat(7, 42px);
118
- grid-template-rows: repeat(7, 42px);
119
-
120
- .${classes.dateItem} {
121
- width: 32px;
122
- height: 32px;
123
- }
124
- }
125
-
126
- &[data-view-type=month], &[data-view-type=year] {
127
- grid-template-columns: repeat(3, 98px);
128
- grid-template-rows: repeat(4, 73.5px);
129
- }
130
- }
131
- }
132
-
133
- .${classes.foot} {
134
- height: 41px;
135
- display: flex;
136
- align-items: center;
137
- justify-content: center;
138
- border-top: 1px solid ${divider};
139
- }
16
+ export const style = defineCss(({ divider, text, spacing }) => css `
17
+ .${classes.head} {
18
+ height: 40px;
19
+ display: flex;
20
+ align-items: center;
21
+ justify-content: space-between;
22
+ border-bottom: 1px solid ${divider};
23
+ padding: 0 ${menuListPadding}px;
24
+ position: relative;
25
+
26
+ .${classes.headSide} {
27
+ z-index: 1;
28
+ }
29
+
30
+ .${classes.headControl} {
31
+ color: ${text.placeholder};
32
+ }
33
+
34
+ .${classes.headCenter} {
35
+ display: flex;
36
+ align-items: center;
37
+ justify-content: center;
38
+ position: absolute;
39
+ inset: 0;
40
+
41
+ .${classes.headButton} {
42
+ font-weight: bold;
43
+ color: ${text.primary};
44
+ }
45
+ }
46
+ }
47
+
48
+ .${classes.body} {
49
+ padding: ${spacing[3]}px ${spacing[4]}px;
50
+ display: grid;
51
+ place-items: center;
52
+
53
+ &[data-view-type=date] {
54
+ font-size: ${13 / 14}em;
55
+ grid-template-columns: repeat(7, 36px);
56
+ grid-template-rows: repeat(7, 36px);
57
+
58
+ .${classes.dateItem} {
59
+ width: 24px;
60
+ height: 24px;
61
+
62
+ &:not([data-variant=filled]) {
63
+ color: ${text.primary};
64
+ border-color: ${text.disabled};
65
+
66
+ &[data-other-month=true] {
67
+ color: ${text.placeholder};
68
+ }
69
+ }
70
+
71
+ &:disabled {
72
+ width: 100%;
73
+ border-radius: 0;
74
+ }
75
+ }
76
+ }
77
+
78
+ &[data-view-type=month], &[data-view-type=year] {
79
+ grid-template-columns: repeat(3, 84px);
80
+ grid-template-rows: repeat(4, 63px);
81
+
82
+ .${classes.monthItem},
83
+ .${classes.yearItem} {
84
+ width: 72px;
85
+ padding-inline: 0;
86
+
87
+ &:not([data-variant=filled]) {
88
+ color: ${text.primary};
89
+ }
90
+ }
91
+ }
92
+ }
93
+
94
+ &[data-size=small] {
95
+ .${classes.body} {
96
+ &[data-view-type=date] {
97
+ grid-template-columns: repeat(7, 30px);
98
+ grid-template-rows: repeat(7, 30px);
99
+ }
100
+
101
+ &[data-view-type=month], &[data-view-type=year] {
102
+ grid-template-columns: repeat(3, 70px);
103
+ grid-template-rows: repeat(4, 52.5px);
104
+
105
+ .${classes.monthItem},
106
+ .${classes.yearItem} {
107
+ width: 60px;
108
+ }
109
+ }
110
+ }
111
+ }
112
+
113
+ &[data-size=large] {
114
+ .${classes.body} {
115
+ &[data-view-type=date] {
116
+ font-size: 1em;
117
+ grid-template-columns: repeat(7, 42px);
118
+ grid-template-rows: repeat(7, 42px);
119
+
120
+ .${classes.dateItem} {
121
+ width: 32px;
122
+ height: 32px;
123
+ }
124
+ }
125
+
126
+ &[data-view-type=month], &[data-view-type=year] {
127
+ grid-template-columns: repeat(3, 98px);
128
+ grid-template-rows: repeat(4, 73.5px);
129
+ }
130
+ }
131
+ }
132
+
133
+ .${classes.foot} {
134
+ height: 41px;
135
+ display: flex;
136
+ align-items: center;
137
+ justify-content: center;
138
+ border-top: 1px solid ${divider};
139
+ }
140
140
  `);
@@ -13,7 +13,7 @@ export const PanelYear = memo(({ innerD, setInnerD, onSelected, min, max }) => {
13
13
  onSelected(d);
14
14
  };
15
15
  const [page, setPage] = useState(() => Math.floor(currentYear / 12));
16
- const renderHeadControl = (icon, title, onClick) => (_jsx(Tooltip, { title: title, children: _jsx(Button, { className: classes.headControl, variant: "text", size: "small", color: "text", onClick: onClick, children: icon }) }));
16
+ const renderHeadControl = (icon, title, onClick) => (_jsx(Tooltip, { title: title, children: _jsx(Button, { className: classes.headControl, variant: "text", size: "small", color: "text.secondary", onClick: onClick, children: icon }) }));
17
17
  const isDisabled = (d) => {
18
18
  if (min && min.isAfter(d)) {
19
19
  return true;
@@ -68,7 +68,7 @@ export const Curd = memo((props) => {
68
68
  }
69
69
  };
70
70
  return [...columns || [], controlColumn];
71
- }, [columns, updatable, deletable]);
71
+ }, [columns, updatable, deletable, renderExtraControl, controlColumnTitle, updateButtonProps, deleteButtonProps, dataName, deleteConfirmProps]);
72
72
  const { orderedColumns, actualColumns, innerVisible, setInnerVisible, setInnerOrder } = useCurdColumns({
73
73
  columns: completedColumns,
74
74
  columnConfigurable
@@ -174,7 +174,7 @@ export const Curd = memo((props) => {
174
174
  _jsxs("div", { className: classes.toolbar, children: [_jsxs("div", { className: classes.toolbarLeft, children: [creatable &&
175
175
  _jsxs(Button, { prefix: _jsx(Icon, { icon: faPlus }), ...createButtonProps, onClick: createHandler, children: [createName, dataName] }), toolbarLeft] }), _jsxs("div", { className: classes.toolbarRight, children: [!!toolbarRight &&
176
176
  _jsxs(_Fragment, { children: [toolbarRight, _jsx(Divider, { className: classes.divider, orientation: "vertical" })] }), reloadable &&
177
- _jsx(Tooltip, { title: "\u5237\u65B0", children: _jsx(Button, { shape: "circular", variant: "text", color: "text", prefix: _jsx(Icon, { icon: faRotateRight }), loading: innerLoading.current, onClick: reloadHandler }) }), resizable &&
177
+ _jsx(Tooltip, { title: "\u5237\u65B0", children: _jsx(Button, { shape: "circular", variant: "text", color: "text.secondary", prefix: _jsx(Icon, { icon: faRotateRight }), loading: innerLoading.current, onClick: reloadHandler }) }), resizable &&
178
178
  _jsx(CurdResizable, { innerSize: innerSize.current, setInnerSize: setInnerSize }), columnConfigurable &&
179
179
  _jsx(CurdColumnConfig, { columns: orderedColumns, innerVisible: innerVisible.current, setInnerVisible: setInnerVisible, setInnerOrder: setInnerOrder })] })] }), _jsx("div", { className: classes.card, children: _jsx(DataGrid, { ...dataGridProps, columns: actualColumns, tableProps: {
180
180
  ...props.tableProps,
@@ -24,5 +24,5 @@ export const CurdColumnConfig = memo(({ columns = [], innerVisible, setInnerVisi
24
24
  ? [...o, key]
25
25
  : o.filter(k => k !== key));
26
26
  };
27
- return (_jsx(Bubble, { css: style, placement: "bottomRight", content: _jsx(DndContext, { sensors: useDndSensors(), onDragEnd: dragEndHandler, children: _jsx(SortableContext, { items: columns?.map((col, i) => col._key ?? i), children: _jsxs("div", { className: classes.content, children: [_jsx("div", { className: classes.title, children: "\u5217\u8BBE\u7F6E" }), columns?.map((col, i) => _jsx(SortableItem, { id: col._key ?? i, component: MenuItem, className: classes.item, prefix: _jsx(Checkbox, { className: classes.checkbox, checked: !isUnset(col._key) && visibleSet.has(col._key), onChange: e => !isUnset(col._key) && toggleVisible(col._key, e.target.checked) }), label: col.title }, col._key ?? i))] }) }) }), children: _jsx(Button, { shape: "circular", variant: "text", color: "text", children: _jsx(Icon, { icon: faGear }) }) }));
27
+ return (_jsx(Bubble, { css: style, placement: "bottomRight", content: _jsx(DndContext, { sensors: useDndSensors(), onDragEnd: dragEndHandler, children: _jsx(SortableContext, { items: columns?.map((col, i) => col._key ?? i), children: _jsxs("div", { className: classes.content, children: [_jsx("div", { className: classes.title, children: "\u5217\u8BBE\u7F6E" }), columns?.map((col, i) => _jsx(SortableItem, { id: col._key ?? i, component: MenuItem, className: classes.item, prefix: _jsx(Checkbox, { className: classes.checkbox, checked: !isUnset(col._key) && visibleSet.has(col._key), onChange: e => !isUnset(col._key) && toggleVisible(col._key, e.target.checked) }), label: col.title }, col._key ?? i))] }) }) }), autoClose: false, children: _jsx(Button, { shape: "circular", variant: "text", color: "text.secondary", children: _jsx(Icon, { icon: faGear }) }) }));
28
28
  });
@@ -22,9 +22,11 @@ export const CurdFilter = memo(({ ref, columns, expandable, showButton, renderCo
22
22
  */
23
23
  const firstItemRef = useRef(null);
24
24
  const [expanded, setExpanded] = useState(false);
25
- const renderedGrid = (_jsx(Grid, { className: classes.filterGrid, columnGap: spacing[8], children: items?.map((item, i) => isValidElement(item)
26
- ? item
27
- : _createElement(FormItem, { span: { xs: 12, md: 6, lg: 4 }, ...item, key: item.key ?? i, wrapperRef: !i ? firstItemRef : void 0 })) }));
25
+ const renderedGrid = (_jsx(Grid, { className: classes.filterGrid, columnGap: spacing[8], children: items?.map((item, i) => {
26
+ return isValidElement(item)
27
+ ? item
28
+ : _createElement(FormItem, { span: { xs: 12, md: 6, lg: 4 }, variant: "grid", ...item, key: item.key ?? i, wrapperRef: !i ? firstItemRef : void 0 });
29
+ }) }));
28
30
  /**
29
31
  * --------------------------------------------------------------
30
32
  * 触发筛选
@@ -7,5 +7,5 @@ import { Button } from '../button';
7
7
  import { Icon } from '../..';
8
8
  import { faArrowsUpDown } from '@fortawesome/free-solid-svg-icons/faArrowsUpDown';
9
9
  export const CurdResizable = memo(({ innerSize, setInnerSize }) => {
10
- return (_jsx(Tooltip, { title: "\u8868\u683C\u5C3A\u5BF8", children: _jsx(Bubble, { placement: "bottom", content: _jsxs(_Fragment, { children: [_jsx(MenuItem, { value: "small", label: "\u5C0F", selected: innerSize === 'small', onClick: () => setInnerSize('small') }), _jsx(MenuItem, { value: "medium", label: "\u4E2D", selected: innerSize === 'medium', onClick: () => setInnerSize('medium') }), _jsx(MenuItem, { value: "large", label: "\u5927", selected: innerSize === 'large', onClick: () => setInnerSize('large') })] }), children: _jsx(Button, { shape: "circular", variant: "text", color: "text", children: _jsx(Icon, { icon: faArrowsUpDown }) }) }) }));
10
+ return (_jsx(Tooltip, { title: "\u8868\u683C\u5C3A\u5BF8", children: _jsx(Bubble, { placement: "bottom", content: _jsxs(_Fragment, { children: [_jsx(MenuItem, { value: "small", label: "\u5C0F", selected: innerSize === 'small', onClick: () => setInnerSize('small') }), _jsx(MenuItem, { value: "medium", label: "\u4E2D", selected: innerSize === 'medium', onClick: () => setInnerSize('medium') }), _jsx(MenuItem, { value: "large", label: "\u5927", selected: innerSize === 'large', onClick: () => setInnerSize('large') })] }), children: _jsx(Button, { shape: "circular", variant: "text", color: "text.secondary", children: _jsx(Icon, { icon: faArrowsUpDown }) }) }) }));
11
11
  });
@@ -30,7 +30,7 @@ type DataGridSharedProps<R extends RowType> = {
30
30
  /** 数据的主键名,默认为`id` */
31
31
  primaryKey?: keyof R;
32
32
  /**
33
- * 当数据中存在该字段,则会渲染可展开的子行,默认为`null`表示不使用子行功能,
33
+ * 当数据中存在该字段,则会渲染可展开的子行,默认为`null`,表示不使用子行功能,
34
34
  * children允许的值类型:
35
35
  * @types {R[] | ReactNode | ((parent: R, expanded: boolean) => ReactNode)}
36
36
  */
@@ -2,6 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
2
  import { createContext, memo, useContext, useMemo } from 'react';
3
3
  import { classes, style } from './dataGrid.style';
4
4
  import { SelectionContext, useSelectionContext } from '../selectionContext';
5
+ import { Pagination } from '../pagination';
5
6
  import { Table, TableContainer } from '../table';
6
7
  import { clsx, cloneRef, useControlled, useDataGridColumns } from '../../utils';
7
8
  import { Loading } from '../loading';
@@ -92,21 +93,26 @@ export const DataGrid = memo(({ columns, rows, rowProps, primaryKey = 'id', chil
92
93
  pageSize: innerPageSize.current,
93
94
  onChange: pageChangeHandler
94
95
  };
96
+ const renderPaginationFn = () => {
97
+ return renderPagination
98
+ ? renderPagination(_paginationProps)
99
+ : _jsx(Pagination, { ..._paginationProps });
100
+ };
95
101
  const paginatedRows = useMemo(() => {
96
102
  if (!paginatable) {
97
103
  return orderedRows;
98
104
  }
99
105
  const { page, pageSize } = _paginationProps;
100
106
  return orderedRows?.slice((page - 1) * pageSize, page * pageSize);
101
- }, [orderedRows, _paginationProps.page, _paginationProps.pageSize]);
102
- return (_jsx(Loading, { ...props, css: style, className: clsx(classes.root, props.className), open: loading, "data-column-resizable": columnResizable, children: _jsx(ColumnResizeContext, { columnResizable: columnResizable, children: ({ scrollerRef, tableRef }) => _jsxs(TableContainer, { ref: scrollerRef, className: classes.container, children: [_jsx(Table, { size: size, bordered: bordered, striped: striped, ...tableProps, ref: cloneRef(tableProps?.ref, tableRef), children: _jsxs(SelectionContext, { options: rows, primaryKey: primaryKey, childrenKey: childrenKey !== null ? childrenKey : void 0, relation: relation, integration: integration, disabled: !selectable, multiple: multiple, defaultValue: defaultValue, value: value, onChange: onChange, children: [_jsx(DataGridHead, { flattedColumns: flattedColumns, completedColumns: completedColumns, rows: rows, primaryKey: primaryKey, orderColumn: innerOrderColumn.current, orderType: innerOrderType.current, onOrderChange: orderChangeHandler, allowSelectAll: allowSelectAll, columnResizable: columnResizable }), _jsx("tbody", { children: _jsx(DataGridContext, { value: useMemo(() => ({
103
- rowProps, primaryKey, childrenKey, clickRowToSelect, indent, renderExpandIcon,
104
- expandedSet, flattedColumns, toggleExpanded
105
- }), [
106
- rowProps, primaryKey, childrenKey, clickRowToSelect, indent, renderExpandIcon,
107
- expandedSet, flattedColumns
108
- ]), children: !!paginatedRows?.length &&
109
- _jsx(DataGridRows, { rows: paginatedRows }) }) })] }) }), !paginatedRows?.length && (emptyPlaceholder ?? _jsx(Placeholder, { className: classes.empty }))] }) }) }));
107
+ }, [orderedRows, _paginationProps.page, _paginationProps.pageSize, paginatable]);
108
+ return (_jsxs(Loading, { ...props, css: style, className: clsx(classes.root, props.className), open: loading, "data-column-resizable": columnResizable, children: [_jsx(ColumnResizeContext, { columnResizable: columnResizable, children: ({ scrollerRef, tableRef }) => _jsxs(TableContainer, { ref: scrollerRef, className: classes.container, children: [_jsx(Table, { size: size, bordered: bordered, striped: striped, ...tableProps, ref: cloneRef(tableProps?.ref, tableRef), children: _jsxs(SelectionContext, { options: rows, primaryKey: primaryKey, childrenKey: childrenKey !== null ? childrenKey : void 0, relation: relation, integration: integration, disabled: !selectable, multiple: multiple, defaultValue: defaultValue, value: value, onChange: onChange, children: [_jsx(DataGridHead, { flattedColumns: flattedColumns, completedColumns: completedColumns, rows: rows, primaryKey: primaryKey, orderColumn: innerOrderColumn.current, orderType: innerOrderType.current, onOrderChange: orderChangeHandler, allowSelectAll: allowSelectAll, columnResizable: columnResizable }), _jsx("tbody", { children: _jsx(DataGridContext, { value: useMemo(() => ({
109
+ rowProps, primaryKey, childrenKey, clickRowToSelect, indent, renderExpandIcon,
110
+ expandedSet, flattedColumns, toggleExpanded
111
+ }), [
112
+ rowProps, primaryKey, childrenKey, clickRowToSelect, indent, renderExpandIcon,
113
+ expandedSet, flattedColumns
114
+ ]), children: !!paginatedRows?.length &&
115
+ _jsx(DataGridRows, { rows: paginatedRows }) }) })] }) }), !paginatedRows?.length && (emptyPlaceholder ?? _jsx(Placeholder, { className: classes.empty }))] }) }), renderPaginationFn()] }));
110
116
  });
111
117
  DataGrid.EXPAND_COLUMN = Symbol('expand-column');
112
118
  DataGrid.SELECT_COLUMN = Symbol('select-column');
@@ -81,7 +81,7 @@ export function Dialog({ ref, icon, title, footer, prefix, suffix, width = 420,
81
81
  return (_jsx(Modal, { ...props, ref: cloneRef(ref, overlayRef), css: style, className: clsx(classes.root, props.className), open: innerOpen.current, onMaskClick: onMaskClick, "data-draggable": draggable, children: _jsx(Draggable, { container: () => overlayRef.current, children: (targetProps, handleProps) => _jsxs("div", { className: classes.card, ...targetProps, style: { width, minWidth, maxWidth, ...targetProps.style }, children: [!!icon &&
82
82
  _jsx("div", { className: classes.icon, children: icon }), _jsxs("div", { className: classes.content, children: [!!(title || showClose) &&
83
83
  _jsxs("div", { className: classes.titleRow, ...handleProps, children: [_jsx("div", { className: classes.title, children: title }), showClose &&
84
- _jsx(Button, { shape: "circular", variant: "text", color: "text", ...closeProps, className: clsx(classes.close, closeProps?.className), onClick: closeHandler, children: _jsx(Icon, { icon: faXmark }) })] }), _jsxs("div", { ref: bodyRef, className: classes.body, onScroll: onScroll, children: [!!prefix &&
84
+ _jsx(Button, { shape: "circular", variant: "text", color: "text.secondary", ...closeProps, className: clsx(classes.close, closeProps?.className), onClick: closeHandler, children: _jsx(Icon, { icon: faXmark }) })] }), _jsxs("div", { ref: bodyRef, className: classes.body, onScroll: onScroll, children: [!!prefix &&
85
85
  _jsx("div", { className: classes.prefix, children: prefix }), _jsx("div", { ref: bodyWrapRef, className: classes.bodyWrap, children: props.children }), !!suffix &&
86
86
  _jsx("div", { className: classes.suffix, children: suffix })] }), (typeof footer === 'undefined' || !!footer) &&
87
87
  _jsx("div", { className: classes.footer, children: renderFooter() })] })] }) }) }));
@@ -48,7 +48,7 @@ export function Drawer({ title, footer, showClose = true, size = { xs: '100%', s
48
48
  }, [innerOpen.current]);
49
49
  return (_jsx(OverlayBase, { ...props, css: useStyle({ size: typeof size === 'object' ? size : { xs: size } }), className: clsx(classes.root, props.className), open: innerOpen.current, onMaskClick: onMaskClick, "data-placement": placement, children: _jsx(Slide, { direction: placementToDirection[placement], ...slideProps, in: innerOpen.current, className: clsx(classes.drawer, slideProps?.className), children: _jsxs("div", { className: classes.drawerWrap, children: [!!(title || showClose) &&
50
50
  _jsxs("div", { className: classes.titleRow, children: [_jsx("div", { className: classes.title, children: title }), showClose &&
51
- _jsx(Button, { className: classes.close, shape: "circular", variant: "text", color: "text", onClick: closeHandler, children: _jsx(Icon, { icon: faAnglesRight, style: {
51
+ _jsx(Button, { className: classes.close, shape: "circular", variant: "text", color: "text.secondary", onClick: closeHandler, children: _jsx(Icon, { icon: faAnglesRight, style: {
52
52
  rotate: {
53
53
  left: '180deg',
54
54
  right: '0',
@@ -39,7 +39,6 @@ inline, columnCount = 1, gap, columnGap, rowGap, ...props }) => {
39
39
  */
40
40
  const itemsContainer = useRef(new Map());
41
41
  const submitHandler = async (e) => {
42
- console.log(e);
43
42
  e?.preventDefault();
44
43
  try {
45
44
  await Promise.all([...itemsContainer.current].map(async ([, item]) => {
@@ -73,6 +73,6 @@ min, max, step, precision, placeholder, disabled, readOnly, autoFocus, defaultVa
73
73
  onKeyDown: (e) => e.key === 'Enter' && blurHandler(e)
74
74
  }) }), loading &&
75
75
  _jsx(LoadingIndicator, {}), clearable && !disabled && !readOnly && (Array.isArray(innerValue.current) ? !!innerValue.current.length : !!innerValue.current) &&
76
- _jsx(Button, { className: classes.clear, variant: "plain", color: "text.disabled", onClick: clear, children: _jsx(Icon, { icon: faCircleXmark }) }), !!suffix &&
76
+ _jsx(Button, { className: classes.clear, variant: "plain", color: "text.disabled", onClick: clear, tabIndex: -1, children: _jsx(Icon, { icon: faCircleXmark }) }), !!suffix &&
77
77
  _jsx("div", { className: classes.suffix, children: suffix })] }));
78
78
  });
@@ -49,5 +49,5 @@ export const PaginationPager = memo((props) => {
49
49
  : renderPageButton(page + i - 5, i === 1 || i === 7);
50
50
  });
51
51
  };
52
- return (_jsxs("div", { ...props, className: clsx(classes.pager, props.className), children: [_jsx(Button, { className: classes.button, variant: "text", size: size, color: "text", disabled: page === 1, onClick: () => onPageChange(page - 1), children: _jsx(Icon, { icon: faAngleLeft }) }), renderPageList(), _jsx(Button, { className: classes.button, variant: "text", size: size, color: "text", disabled: page === pageCount, onClick: () => onPageChange(page + 1), children: _jsx(Icon, { icon: faAngleRight }) })] }));
52
+ return (_jsxs("div", { ...props, className: clsx(classes.pager, props.className), children: [_jsx(Button, { className: classes.button, variant: "text", size: size, color: "text.secondary", disabled: page === 1, onClick: () => onPageChange(page - 1), children: _jsx(Icon, { icon: faAngleLeft }) }), renderPageList(), _jsx(Button, { className: classes.button, variant: "text", size: size, color: "text.secondary", disabled: page === pageCount, onClick: () => onPageChange(page + 1), children: _jsx(Icon, { icon: faAngleRight }) })] }));
53
53
  });
@@ -110,5 +110,5 @@ export const Palette = memo(({ defaultValue, value, onChange, gestureOptions, ..
110
110
  }, ...draggableHandles })] }), _jsxs("div", { className: classes.slidersRow, children: [_jsxs("div", { className: classes.sliders, children: [_jsx(Slider, { ...sliderProps, className: classes.hue, value: colorObject.hue / 359 * 100, onChange: hueChangeHandler }), _jsx(Slider, { ...sliderProps, className: classes.alpha, renderRail: (_, railProps) => _jsxs("div", { ...railProps, children: [railProps.children, _jsx("div", { className: classes.alphaMask, style: { backgroundImage: `linear-gradient(90deg, transparent, ${colorObject.saturated})` } })] }), value: colorObject.alpha * 100, onChange: alphaChangeHandler })] }), _jsx("div", { className: classes.preview, children: _jsx("div", { className: classes.previewColor, style: {
111
111
  backgroundColor: colorObject.hex,
112
112
  opacity: colorObject.alpha
113
- } }) })] }), _jsxs("div", { className: classes.inputRow, children: [_jsx(Button, { variant: "plain", color: "text", suffix: _jsx(Icon, { icon: faChevronDown }), onClick: formatChangeHandler, children: availableFormat[activeFormat] }), renderInputs()] })] }));
113
+ } }) })] }), _jsxs("div", { className: classes.inputRow, children: [_jsx(Button, { variant: "plain", color: "text.secondary", suffix: _jsx(Icon, { icon: faChevronDown }), onClick: formatChangeHandler, children: availableFormat[activeFormat] }), renderInputs()] })] }));
114
114
  });
@@ -67,6 +67,6 @@ options = rows ?? nodes, primaryKey = 'id', childrenKey = 'children', relation =
67
67
  ...props.modalProps
68
68
  }, ...showSelectedList && {
69
69
  [selectedListPlacement === 'left' ? 'prefix' : 'suffix']: (_jsxs("div", { className: classes.selectedArea, children: [_jsxs(Divider, { className: classes.count, textAlign: "start", children: [_jsxs("div", { children: ["\u5DF2\u9009\u62E9", _jsx("b", { children: selectedCount }), "\u9879"] }), clearable &&
70
- _jsx(Button, { prefix: _jsx(Icon, { icon: faTrashCan }), variant: "plain", color: "text", onClick: () => setInnerValue(multiple ? [] : null), children: "\u6E05\u7A7A" })] }), _jsx(SelectedList, { itemProps: selectedItemProps, ...selectedListProps, className: clsx(classes.list, selectedListProps?.className) }), _jsx(Button, { className: classes.confirm, disabled: selectedCount === 0, onClick: () => confirmHandler(), children: "\u786E\u5B9A" })] }))
70
+ _jsx(Button, { prefix: _jsx(Icon, { icon: faTrashCan }), variant: "plain", color: "text.secondary", onClick: () => setInnerValue(multiple ? [] : null), children: "\u6E05\u7A7A" })] }), _jsx(SelectedList, { itemProps: selectedItemProps, ...selectedListProps, className: clsx(classes.list, selectedListProps?.className) }), _jsx(Button, { className: classes.confirm, disabled: selectedCount === 0, onClick: () => confirmHandler(), children: "\u786E\u5B9A" })] }))
71
71
  }, children: renderChildren() }) }));
72
72
  });
@@ -18,7 +18,7 @@ const Sweeping = ({ ref, in: _in = false, appear = true, orientation = 'vertical
18
18
  useEffect(() => {
19
19
  if (_in && size.current !== 'auto') {
20
20
  requestAnimationFrame(() => {
21
- setSize(innerRef.current[orientation === 'vertical' ? 'scrollHeight' : 'scrollWidth']);
21
+ innerRef.current && setSize(innerRef.current[orientation === 'vertical' ? 'scrollHeight' : 'scrollWidth']);
22
22
  });
23
23
  }
24
24
  }, [_in]);
@@ -72,8 +72,8 @@ export const style = defineCss(({ spacing, mode, borderRadius, text, easing, gra
72
72
  align-items: center;
73
73
  justify-content: center;
74
74
 
75
- .${classes.icon} > svg {
76
- transition: transform .25s ${easing.easeOut};
75
+ .${classes.icon} {
76
+ transition: rotate .25s ${easing.easeOut};
77
77
  }
78
78
  }
79
79
 
@@ -20,14 +20,14 @@ export const TreeNode = memo(({ value, label, prefix, suffix, disabled, _level =
20
20
  clickLabelToExpand && toggleExpanded?.(value);
21
21
  };
22
22
  const hasChildren = !!props.children && (!Array.isArray(props.children) || props.children.length > 0);
23
- return (_jsxs(_Fragment, { children: [_jsxs("div", { ...props, className: clsx(classes.node, props.className), "data-selected": status === 2, "data-read-only": readOnly, "data-disabled": disabled, onClick: clickHandler, children: [Array(_level).fill(void 0).map((_, i) => _jsx("div", { className: classes.indent, style: { width: indent } }, i)), _jsx(Button, { className: classes.expand, variant: "plain", color: "text", onClick: e => {
23
+ return (_jsxs(_Fragment, { children: [_jsxs("div", { ...props, className: clsx(classes.node, props.className), "data-selected": status === 2, "data-read-only": readOnly, "data-disabled": disabled, onClick: clickHandler, children: [Array(_level).fill(void 0).map((_, i) => _jsx("div", { className: classes.indent, style: { width: indent } }, i)), _jsx(Button, { className: classes.expand, variant: "plain", color: "text.secondary", onClick: e => {
24
24
  e.stopPropagation();
25
25
  toggleExpanded?.(value);
26
26
  }, children: renderExpandIcon
27
27
  ? renderExpandIcon(value, !!currentExpanded, [...expandedSet])
28
28
  : hasChildren &&
29
29
  _jsx(Icon, { icon: faChevronRight, className: classes.icon, style: {
30
- rotate: currentExpanded ? '90deg' : '0'
30
+ rotate: currentExpanded ? '90deg' : '0deg'
31
31
  } }) }), showCheckbox &&
32
32
  _jsx(Checkbox, { className: classes.checkbox, checked: status === 2, indeterminate: status === 1, onClick: e => {
33
33
  e.stopPropagation();
@@ -54,24 +54,24 @@ placeholder = '请选择', autoFocus, clearable, onClear, ...props }) => {
54
54
  useMemo(() => {
55
55
  // 单选模式下,选中一次就自动关闭弹框
56
56
  !props.multiple && setInnerOpen(false);
57
- }, [innerValue.current, props.multiple]);
57
+ }, [innerValue, props.multiple]);
58
58
  const clearHandler = () => {
59
59
  onClear?.();
60
60
  setInnerValue(props.multiple ? [] : void 0);
61
61
  };
62
62
  const renderBackfillFn = () => {
63
63
  if (renderBackfill) {
64
- return renderBackfill(innerValue.current);
64
+ return renderBackfill(innerValue);
65
65
  }
66
66
  if (props.multiple) {
67
- return toArray(innerValue.current)?.map(v => _jsx(Tag, { closable: true, onClose: () => toggleSelected(v), children: optionsMap.get(v)?.[props.labelKey] ?? v }, v));
67
+ return toArray(innerValue)?.map(v => _jsx(Tag, { closable: true, onClose: () => toggleSelected(v), children: optionsMap.get(v)?.[props.labelKey] ?? v }, v));
68
68
  }
69
- return (_jsx("div", { className: classes.backfillWrap, children: optionsMap.get(innerValue.current)?.[props.labelKey] ?? innerValue.current }));
69
+ return (_jsx("div", { className: classes.backfillWrap, children: optionsMap.get(innerValue)?.[props.labelKey] ?? innerValue }));
70
70
  };
71
- return (_jsx(Popper, { css: popperStyle, open: innerOpen.current, onOpenChange: openChangeHandler, placement: "bottom", variant: "collapse", trigger: ['click', 'enter'], disabled: props.disabled || props.readOnly, sizeAdaptable: sizeAdaptable, content: _jsx(Tree, { ...props, nodes: options, value: innerValue.current, onChange: setInnerValue }), ...popperProps, popperRef: popperRef, onPointerDown: e => {
71
+ return (_jsx(Popper, { css: popperStyle, open: innerOpen.current, onOpenChange: openChangeHandler, placement: "bottom", variant: "collapse", trigger: ['click', 'enter'], disabled: props.disabled || props.readOnly, sizeAdaptable: sizeAdaptable, content: _jsx(Tree, { ...props, nodes: options, value: innerValue, onChange: setInnerValue }), ...popperProps, popperRef: popperRef, onPointerDown: e => {
72
72
  popperProps?.onPointerDown?.(e);
73
73
  e.preventDefault();
74
- }, children: _jsx(InputBase, { clearable: !!props.multiple, css: style, className: clsx(classes.root, props.className), "data-focused": open, value: innerValue.current, onClear: clearHandler, placeholder: placeholder, autoFocus: autoFocus, disabled: props.disabled, readOnly: props.readOnly, children: ({ ref, ...rest }) => _jsxs("div", { className: classes.contentWrap, children: [!toArray(innerValue.current)?.length
74
+ }, children: _jsx(InputBase, { clearable: !!props.multiple, css: style, className: clsx(classes.root, props.className), "data-focused": open, value: innerValue, onClear: clearHandler, placeholder: placeholder, autoFocus: autoFocus, disabled: props.disabled, readOnly: props.readOnly, children: ({ ref, ...rest }) => _jsxs("div", { className: classes.contentWrap, children: [!toArray(innerValue)?.length
75
75
  ? _jsx("div", { className: classes.placeholder, children: placeholder })
76
76
  : _jsx("div", { className: classes.backfill, children: renderBackfillFn() }), _jsx("input", { size: 1, ...rest, ...inputProps, ref: cloneRef(ref, inputProps?.ref), "data-hidden": "true" }), _jsx("div", { className: classes.arrow, "data-open": open, children: loading
77
77
  ? _jsx(LoadingIndicator, {})
@@ -16,7 +16,7 @@ export const ImageItem = memo((props) => {
16
16
  open: previewOpen,
17
17
  onOpenChange: setPreviewOpen
18
18
  }, actions: [
19
- _jsx(Button, { size: "small", variant: "text", shape: "circular", color: "text", onClick: () => setPreviewOpen(true), children: _jsx(Icon, { icon: faEye }) }, "preview"),
19
+ _jsx(Button, { size: "small", variant: "text", shape: "circular", color: "text.secondary", onClick: () => setPreviewOpen(true), children: _jsx(Icon, { icon: faEye }) }, "preview"),
20
20
  _jsx(Button, { size: "small", variant: "text", shape: "circular", color: "error", onClick: props.onRemove, children: _jsx(Icon, { icon: faTrashCan }) }, "delete")
21
21
  ], children: status !== 'default' &&
22
22
  _jsx("div", { className: clsx(classes.progress), children: _jsx(Progress, { variant: "circular", showInfo: status !== 'uploading', value: progress, status: status === 'uploading' ? 'processing' : status }) }) }) }));
@@ -10,6 +10,7 @@ export declare function columnsToFilterItem(columns?: (CurdColumn<any> | symbol)
10
10
  /**
11
11
  * 将Curd的Columns转换为FormItem
12
12
  * @param columns
13
+ * @param row
13
14
  */
14
15
  export declare function columnsToFormItem(columns?: (CurdColumn<any> | symbol)[], row?: Obj): CurdFormItemProps[] | undefined;
15
16
  /**
@@ -12,6 +12,7 @@ export function columnsToFilterItem(columns) {
12
12
  /**
13
13
  * 将Curd的Columns转换为FormItem
14
14
  * @param columns
15
+ * @param row
15
16
  */
16
17
  export function columnsToFormItem(columns, row) {
17
18
  return columnsTransfer(columns, 'form', row);
@@ -31,7 +32,7 @@ function columnsTransfer(columns, type = 'filter', row) {
31
32
  return item.key ? item : cloneElement(item, { key });
32
33
  }
33
34
  if (item === true) {
34
- // filter为true当作空对象处理
35
+ // item为true当作空对象处理
35
36
  item = {};
36
37
  }
37
38
  if (typeof item === 'object') {
@@ -62,7 +63,7 @@ export function useCurdColumns({ columns, columnConfigurable }) {
62
63
  }
63
64
  let { defaultVisible, visible, onVisibleChange, defaultOrder, order, onOrderChange } = columnConfigurable;
64
65
  if (!defaultVisible || !defaultOrder) {
65
- const defaultKeys = columns?.flatMap((col) => col._key ?? []) || [];
66
+ const defaultKeys = columns?.flatMap((col) => col.hideInTable ? [] : (col._key ?? [])) || [];
66
67
  defaultVisible ||= defaultKeys;
67
68
  defaultOrder ||= defaultKeys;
68
69
  }
@@ -1,11 +1,13 @@
1
1
  import { useCallback, useDeferredValue, useMemo } from 'react';
2
- import { useControlled } from './hooks';
2
+ import { useControlled, useSync } from './hooks';
3
3
  export function useTreeSearch({ nodes, primaryKey = 'id', labelKey = 'label', childrenKey = 'children', searchTokenKey = 'searchToken', defaultExpanded = [], expanded, onExpandedChange, defaultSearchValue = '', searchValue, onSearchChange }) {
4
4
  const [innerExpanded, setInnerExpanded] = useControlled(defaultExpanded, expanded);
5
5
  const expandedSet = useMemo(() => {
6
6
  return new Set(innerExpanded.current);
7
7
  }, [innerExpanded.current]);
8
+ const sync = useSync({ expandedSet, onExpandedChange });
8
9
  const toggleExpanded = useCallback((value) => {
10
+ const { expandedSet, onExpandedChange } = sync.current;
9
11
  const currentExpanded = expandedSet.has(value);
10
12
  setInnerExpanded(o => {
11
13
  const newExpanded = currentExpanded