@canlooks/can-ui 0.0.163 → 0.0.165
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/cjs/components/accordion/accordion.style.d.ts +1 -1
- package/dist/cjs/components/actionSheet/actionSheet.style.d.ts +1 -1
- package/dist/cjs/components/alert/alert.style.d.ts +1 -1
- package/dist/cjs/components/anchorList/anchorList.style.d.ts +1 -1
- package/dist/cjs/components/app/app.style.d.ts +2 -2
- package/dist/cjs/components/avatar/avatar.style.d.ts +1 -1
- package/dist/cjs/components/avatar/avatarGroup.style.d.ts +1 -1
- package/dist/cjs/components/backdrop/backdrop.style.d.ts +1 -1
- package/dist/cjs/components/badge/badge.style.d.ts +1 -1
- package/dist/cjs/components/bottomNavigation/bottomNavigation.style.d.ts +1 -1
- package/dist/cjs/components/boundary/errorBoundary.style.d.ts +1 -1
- package/dist/cjs/components/breadcrumb/breadcrumb.style.d.ts +1 -1
- package/dist/cjs/components/bubble/bubble.style.d.ts +1 -1
- package/dist/cjs/components/bubbleConfirm/bubbleConfirm.style.d.ts +1 -1
- package/dist/cjs/components/button/button.style.d.ts +1 -1
- package/dist/cjs/components/calendar/calendar.style.d.ts +1 -1
- package/dist/cjs/components/card/card.style.d.ts +1 -1
- package/dist/cjs/components/cascade/cascade.style.d.ts +2 -2
- package/dist/cjs/components/checkboxBase/checkboxBase.style.d.ts +1 -1
- package/dist/cjs/components/colorPicker/colorPicker.style.d.ts +2 -2
- package/dist/cjs/components/counter/counter.style.d.ts +1 -1
- package/dist/cjs/components/curd/curd.js +6 -2
- package/dist/cjs/components/curd/curd.style.d.ts +2 -2
- package/dist/cjs/components/curd/curdColumnConfig.js +27 -15
- package/dist/cjs/components/curd/curdColumnConfig.style.d.ts +1 -1
- package/dist/cjs/components/dataGrid/dataGrid.d.ts +1 -0
- package/dist/cjs/components/dataGrid/dataGrid.js +6 -1
- package/dist/cjs/components/dataGrid/dataGrid.style.d.ts +1 -1
- package/dist/cjs/components/dataGrid/filterBubbleContent.style.d.ts +1 -1
- package/dist/cjs/components/dateTimePicker/dateTimePicker.style.d.ts +2 -2
- package/dist/cjs/components/dateTimePicker/timer.style.d.ts +1 -1
- package/dist/cjs/components/dateTimeRangePicker/dateTimeRangePicker.style.d.ts +1 -1
- package/dist/cjs/components/descriptions/descriptions.style.d.ts +2 -2
- package/dist/cjs/components/dialog/dialog.style.d.ts +1 -1
- package/dist/cjs/components/divider/divider.style.d.ts +1 -1
- package/dist/cjs/components/drawer/drawer.style.d.ts +1 -1
- package/dist/cjs/components/dropdown/dropdown.style.d.ts +1 -1
- package/dist/cjs/components/flex/flex.style.d.ts +1 -1
- package/dist/cjs/components/form/form.style.d.ts +1 -1
- package/dist/cjs/components/gallery/gallery.style.d.ts +1 -1
- package/dist/cjs/components/grid/grid.style.d.ts +2 -2
- package/dist/cjs/components/image/image.style.d.ts +1 -1
- package/dist/cjs/components/image/image.style.js +2 -0
- package/dist/cjs/components/input/input.style.d.ts +2 -2
- package/dist/cjs/components/inputBase/inputBase.style.d.ts +1 -1
- package/dist/cjs/components/loading/loading.style.d.ts +1 -1
- package/dist/cjs/components/loadingIndicator/loadingIndicator.style.d.ts +1 -1
- package/dist/cjs/components/loadingMask/loadingMask.style.d.ts +1 -1
- package/dist/cjs/components/menu/menu.style.d.ts +1 -1
- package/dist/cjs/components/menuItem/menuItem.style.d.ts +2 -2
- package/dist/cjs/components/modal/modal.style.d.ts +1 -1
- package/dist/cjs/components/optionsBase/optionsBase.style.d.ts +1 -1
- package/dist/cjs/components/overlayBase/overlayBase.style.d.ts +1 -1
- package/dist/cjs/components/pagination/pagination.style.d.ts +1 -1
- package/dist/cjs/components/palette/palette.style.d.ts +1 -1
- package/dist/cjs/components/pickerDialog/pickerDialog.style.d.ts +1 -1
- package/dist/cjs/components/pinchable/pinchable.style.d.ts +1 -1
- package/dist/cjs/components/placeholder/placeholder.style.d.ts +1 -1
- package/dist/cjs/components/popper/popper.style.d.ts +4 -4
- package/dist/cjs/components/progress/progress.style.d.ts +1 -1
- package/dist/cjs/components/rating/rating.style.d.ts +1 -1
- package/dist/cjs/components/resizable/resizable.style.d.ts +1 -1
- package/dist/cjs/components/scrollbar/scrollbar.style.d.ts +1 -1
- package/dist/cjs/components/segmented/segmented.style.d.ts +1 -1
- package/dist/cjs/components/selectBase/selectBase.style.d.ts +1 -1
- package/dist/cjs/components/selectedList/selectedList.style.d.ts +1 -1
- package/dist/cjs/components/serialInput/serialInput.style.d.ts +1 -1
- package/dist/cjs/components/skeleton/skeleton.style.d.ts +3 -3
- package/dist/cjs/components/slidableActions/slidableActions.style.d.ts +1 -1
- package/dist/cjs/components/slider/slider.style.d.ts +2 -2
- package/dist/cjs/components/snackbarBase/snackbarBase.style.d.ts +1 -1
- package/dist/cjs/components/sortableItem/sortableItem.d.ts +3 -2
- package/dist/cjs/components/sortableItem/sortableItem.js +7 -31
- package/dist/cjs/components/sortableItem/sortableItem.style.d.ts +0 -2
- package/dist/cjs/components/sortableItem/sortableItem.style.js +1 -20
- package/dist/cjs/components/status/status.style.d.ts +1 -1
- package/dist/cjs/components/stepper/step.style.d.ts +1 -1
- package/dist/cjs/components/stepper/stepper.style.d.ts +1 -1
- package/dist/cjs/components/switch/switch.style.d.ts +1 -1
- package/dist/cjs/components/table/table.style.d.ts +1 -1
- package/dist/cjs/components/table/tableSticky.style.d.ts +1 -1
- package/dist/cjs/components/tabs/tab.d.ts +3 -1
- package/dist/cjs/components/tabs/tab.js +2 -2
- package/dist/cjs/components/tabs/tabs.d.ts +2 -2
- package/dist/cjs/components/tabs/tabs.js +15 -18
- package/dist/cjs/components/tabs/tabs.style.d.ts +1 -1
- package/dist/cjs/components/tabs/tabsEllipsis.style.d.ts +1 -1
- package/dist/cjs/components/tag/tag.style.d.ts +1 -1
- package/dist/cjs/components/textarea/textarea.style.d.ts +1 -1
- package/dist/cjs/components/timeline/timeline.style.d.ts +2 -2
- package/dist/cjs/components/toggleButton/toggleButton.style.d.ts +1 -1
- package/dist/cjs/components/tooltip/tooltip.style.d.ts +1 -1
- package/dist/cjs/components/touchRipple/touchRipple.style.d.ts +1 -1
- package/dist/cjs/components/transfer/transfer.style.d.ts +1 -1
- package/dist/cjs/components/transitionBase/transitionBase.style.d.ts +5 -5
- package/dist/cjs/components/tree/tree.style.d.ts +1 -1
- package/dist/cjs/components/tree/treeDnd.style.d.ts +2 -2
- package/dist/cjs/components/typography/typography.style.d.ts +2 -2
- package/dist/cjs/components/upload/dropArea.style.d.ts +1 -1
- package/dist/cjs/components/upload/upload.js +13 -14
- package/dist/cjs/components/upload/upload.style.d.ts +2 -2
- package/dist/cjs/components/upload/upload.style.js +4 -10
- package/dist/cjs/components/waterfall/waterfall.style.d.ts +1 -1
- package/dist/cjs/extensions/documentViewer/documentViewer.style.d.ts +2 -2
- package/dist/cjs/extensions/textFormatter/textFormatter.style.d.ts +1 -1
- package/dist/cjs/utils/dnd.d.ts +8 -6
- package/dist/cjs/utils/dnd.js +48 -21
- package/dist/esm/components/accordion/accordion.style.d.ts +1 -1
- package/dist/esm/components/actionSheet/actionSheet.style.d.ts +1 -1
- package/dist/esm/components/alert/alert.style.d.ts +1 -1
- package/dist/esm/components/anchorList/anchorList.style.d.ts +1 -1
- package/dist/esm/components/app/app.style.d.ts +2 -2
- package/dist/esm/components/avatar/avatar.style.d.ts +1 -1
- package/dist/esm/components/avatar/avatarGroup.style.d.ts +1 -1
- package/dist/esm/components/backdrop/backdrop.style.d.ts +1 -1
- package/dist/esm/components/badge/badge.style.d.ts +1 -1
- package/dist/esm/components/bottomNavigation/bottomNavigation.style.d.ts +1 -1
- package/dist/esm/components/boundary/errorBoundary.style.d.ts +1 -1
- package/dist/esm/components/breadcrumb/breadcrumb.style.d.ts +1 -1
- package/dist/esm/components/bubble/bubble.style.d.ts +1 -1
- package/dist/esm/components/bubbleConfirm/bubbleConfirm.style.d.ts +1 -1
- package/dist/esm/components/button/button.style.d.ts +1 -1
- package/dist/esm/components/calendar/calendar.style.d.ts +1 -1
- package/dist/esm/components/card/card.style.d.ts +1 -1
- package/dist/esm/components/cascade/cascade.style.d.ts +2 -2
- package/dist/esm/components/checkboxBase/checkboxBase.style.d.ts +1 -1
- package/dist/esm/components/colorPicker/colorPicker.style.d.ts +2 -2
- package/dist/esm/components/counter/counter.style.d.ts +1 -1
- package/dist/esm/components/curd/curd.js +7 -3
- package/dist/esm/components/curd/curd.style.d.ts +2 -2
- package/dist/esm/components/curd/curdColumnConfig.js +29 -17
- package/dist/esm/components/curd/curdColumnConfig.style.d.ts +1 -1
- package/dist/esm/components/dataGrid/dataGrid.d.ts +1 -0
- package/dist/esm/components/dataGrid/dataGrid.js +6 -1
- package/dist/esm/components/dataGrid/dataGrid.style.d.ts +1 -1
- package/dist/esm/components/dataGrid/filterBubbleContent.style.d.ts +1 -1
- package/dist/esm/components/dateTimePicker/dateTimePicker.style.d.ts +2 -2
- package/dist/esm/components/dateTimePicker/timer.style.d.ts +1 -1
- package/dist/esm/components/dateTimeRangePicker/dateTimeRangePicker.style.d.ts +1 -1
- package/dist/esm/components/descriptions/descriptions.style.d.ts +2 -2
- package/dist/esm/components/dialog/dialog.style.d.ts +1 -1
- package/dist/esm/components/divider/divider.style.d.ts +1 -1
- package/dist/esm/components/drawer/drawer.style.d.ts +1 -1
- package/dist/esm/components/dropdown/dropdown.style.d.ts +1 -1
- package/dist/esm/components/flex/flex.style.d.ts +1 -1
- package/dist/esm/components/form/form.style.d.ts +1 -1
- package/dist/esm/components/gallery/gallery.style.d.ts +1 -1
- package/dist/esm/components/grid/grid.style.d.ts +2 -2
- package/dist/esm/components/image/image.style.d.ts +1 -1
- package/dist/esm/components/image/image.style.js +2 -0
- package/dist/esm/components/input/input.style.d.ts +2 -2
- package/dist/esm/components/inputBase/inputBase.style.d.ts +1 -1
- package/dist/esm/components/loading/loading.style.d.ts +1 -1
- package/dist/esm/components/loadingIndicator/loadingIndicator.style.d.ts +1 -1
- package/dist/esm/components/loadingMask/loadingMask.style.d.ts +1 -1
- package/dist/esm/components/menu/menu.style.d.ts +1 -1
- package/dist/esm/components/menuItem/menuItem.style.d.ts +2 -2
- package/dist/esm/components/modal/modal.style.d.ts +1 -1
- package/dist/esm/components/optionsBase/optionsBase.style.d.ts +1 -1
- package/dist/esm/components/overlayBase/overlayBase.style.d.ts +1 -1
- package/dist/esm/components/pagination/pagination.style.d.ts +1 -1
- package/dist/esm/components/palette/palette.style.d.ts +1 -1
- package/dist/esm/components/pickerDialog/pickerDialog.style.d.ts +1 -1
- package/dist/esm/components/pinchable/pinchable.style.d.ts +1 -1
- package/dist/esm/components/placeholder/placeholder.style.d.ts +1 -1
- package/dist/esm/components/popper/popper.style.d.ts +4 -4
- package/dist/esm/components/progress/progress.style.d.ts +1 -1
- package/dist/esm/components/rating/rating.style.d.ts +1 -1
- package/dist/esm/components/resizable/resizable.style.d.ts +1 -1
- package/dist/esm/components/scrollbar/scrollbar.style.d.ts +1 -1
- package/dist/esm/components/segmented/segmented.style.d.ts +1 -1
- package/dist/esm/components/selectBase/selectBase.style.d.ts +1 -1
- package/dist/esm/components/selectedList/selectedList.style.d.ts +1 -1
- package/dist/esm/components/serialInput/serialInput.style.d.ts +1 -1
- package/dist/esm/components/skeleton/skeleton.style.d.ts +3 -3
- package/dist/esm/components/slidableActions/slidableActions.style.d.ts +1 -1
- package/dist/esm/components/slider/slider.style.d.ts +2 -2
- package/dist/esm/components/snackbarBase/snackbarBase.style.d.ts +1 -1
- package/dist/esm/components/sortableItem/sortableItem.d.ts +3 -2
- package/dist/esm/components/sortableItem/sortableItem.js +10 -34
- package/dist/esm/components/sortableItem/sortableItem.style.d.ts +0 -2
- package/dist/esm/components/sortableItem/sortableItem.style.js +0 -19
- package/dist/esm/components/status/status.style.d.ts +1 -1
- package/dist/esm/components/stepper/step.style.d.ts +1 -1
- package/dist/esm/components/stepper/stepper.style.d.ts +1 -1
- package/dist/esm/components/switch/switch.style.d.ts +1 -1
- package/dist/esm/components/table/table.style.d.ts +1 -1
- package/dist/esm/components/table/tableSticky.style.d.ts +1 -1
- package/dist/esm/components/tabs/tab.d.ts +3 -1
- package/dist/esm/components/tabs/tab.js +2 -2
- package/dist/esm/components/tabs/tabs.d.ts +2 -2
- package/dist/esm/components/tabs/tabs.js +16 -19
- package/dist/esm/components/tabs/tabs.style.d.ts +1 -1
- package/dist/esm/components/tabs/tabsEllipsis.style.d.ts +1 -1
- package/dist/esm/components/tag/tag.style.d.ts +1 -1
- package/dist/esm/components/textarea/textarea.style.d.ts +1 -1
- package/dist/esm/components/timeline/timeline.style.d.ts +2 -2
- package/dist/esm/components/toggleButton/toggleButton.style.d.ts +1 -1
- package/dist/esm/components/tooltip/tooltip.style.d.ts +1 -1
- package/dist/esm/components/touchRipple/touchRipple.style.d.ts +1 -1
- package/dist/esm/components/transfer/transfer.style.d.ts +1 -1
- package/dist/esm/components/transitionBase/transitionBase.style.d.ts +5 -5
- package/dist/esm/components/tree/tree.style.d.ts +1 -1
- package/dist/esm/components/tree/treeDnd.style.d.ts +2 -2
- package/dist/esm/components/typography/typography.style.d.ts +2 -2
- package/dist/esm/components/upload/dropArea.style.d.ts +1 -1
- package/dist/esm/components/upload/upload.js +14 -15
- package/dist/esm/components/upload/upload.style.d.ts +2 -2
- package/dist/esm/components/upload/upload.style.js +4 -10
- package/dist/esm/components/waterfall/waterfall.style.d.ts +1 -1
- package/dist/esm/extensions/documentViewer/documentViewer.style.d.ts +2 -2
- package/dist/esm/extensions/textFormatter/textFormatter.style.d.ts +1 -1
- package/dist/esm/utils/dnd.d.ts +8 -6
- package/dist/esm/utils/dnd.js +45 -20
- package/package.json +13 -13
package/dist/cjs/utils/dnd.js
CHANGED
|
@@ -1,38 +1,65 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.defaultSensors = void 0;
|
|
4
4
|
exports.onDndDragEnd = onDndDragEnd;
|
|
5
|
+
exports.arrayMove = arrayMove;
|
|
5
6
|
exports.onTreeNodeSort = onTreeNodeSort;
|
|
6
7
|
exports.edgeBounce = edgeBounce;
|
|
7
|
-
const core_1 = require("@dnd-kit/core");
|
|
8
|
-
const sortable_1 = require("@dnd-kit/sortable");
|
|
9
8
|
const utils_1 = require("./utils");
|
|
10
9
|
const bezier_1 = require("./bezier");
|
|
10
|
+
const react_1 = require("@dnd-kit/react");
|
|
11
|
+
const dom_1 = require("@dnd-kit/dom");
|
|
11
12
|
/**
|
|
12
|
-
* 默认提供给@dnd-kit
|
|
13
|
+
* 默认提供给@dnd-kit<DragDropProvider/>的sensors属性
|
|
13
14
|
*/
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
15
|
+
const defaultSensors = defaults => [
|
|
16
|
+
...defaults,
|
|
17
|
+
react_1.PointerSensor.configure({
|
|
18
|
+
activationConstraints: [
|
|
19
|
+
new dom_1.PointerActivationConstraints.Distance({ value: 5 })
|
|
20
|
+
]
|
|
21
|
+
})
|
|
22
|
+
];
|
|
23
|
+
exports.defaultSensors = defaultSensors;
|
|
21
24
|
/**
|
|
22
|
-
* <
|
|
25
|
+
* <DragDropProvider>组件通用的onDragEnd方法
|
|
23
26
|
* @param e 事件
|
|
24
|
-
* @param
|
|
27
|
+
* @param items 传入需要排序的数组
|
|
25
28
|
* @param primaryKey 索引用的主键,默认为`id`
|
|
29
|
+
* @return 返回新的数组,但如果顺序未改变,会得到null
|
|
26
30
|
*/
|
|
27
|
-
function onDndDragEnd(
|
|
28
|
-
const {
|
|
29
|
-
if (!
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
function onDndDragEnd({ operation }, items, primaryKey = 'id') {
|
|
32
|
+
const { source, target, canceled } = operation;
|
|
33
|
+
if (!source || !target || canceled) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
const sourceIndex = items.findIndex(item => item[primaryKey] === source.id);
|
|
37
|
+
const targetIndex = items.findIndex(item => item[primaryKey] === target.id);
|
|
38
|
+
if (sourceIndex === -1 || targetIndex === -1) {
|
|
39
|
+
if (typeof source.initialIndex === 'number' && typeof source.index === 'number') {
|
|
40
|
+
const from = source.initialIndex;
|
|
41
|
+
const to = source.index;
|
|
42
|
+
if (from === to || from < 0 || from >= items.length) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
return arrayMove(items, from, to);
|
|
46
|
+
}
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
if (typeof source.index === 'number') {
|
|
50
|
+
if (source.index !== sourceIndex) {
|
|
51
|
+
return arrayMove(items, sourceIndex, source.index);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return arrayMove(items, sourceIndex, targetIndex);
|
|
55
|
+
}
|
|
56
|
+
function arrayMove(array, from, to) {
|
|
57
|
+
if (from === to) {
|
|
58
|
+
return array;
|
|
32
59
|
}
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
return
|
|
60
|
+
const newArray = [...array];
|
|
61
|
+
newArray.splice(to, 0, newArray.splice(from, 1)[0]);
|
|
62
|
+
return newArray;
|
|
36
63
|
}
|
|
37
64
|
/**
|
|
38
65
|
* <Tree>组件通用的onSort方法,注意:该方法会原地修改{@link treeNodes}
|
|
@@ -2,5 +2,5 @@ import { Theme } from '../theme/index.js';
|
|
|
2
2
|
export declare const classes: {
|
|
3
3
|
root: string;
|
|
4
4
|
};
|
|
5
|
-
export declare const appStyleCallback: (theme: Theme) => import("@emotion/
|
|
6
|
-
export declare const style: () => import("@emotion/
|
|
5
|
+
export declare const appStyleCallback: (theme: Theme) => import("@emotion/utils").SerializedStyles;
|
|
6
|
+
export declare const style: () => import("@emotion/utils").SerializedStyles;
|
|
@@ -2,4 +2,4 @@ import { BackdropProps } from './backdrop.js';
|
|
|
2
2
|
export declare const classes: {
|
|
3
3
|
root: string;
|
|
4
4
|
};
|
|
5
|
-
export declare function useStyle({ variant }: Pick<BackdropProps, 'variant'>): import("@emotion/
|
|
5
|
+
export declare function useStyle({ variant }: Pick<BackdropProps, 'variant'>): import("@emotion/utils").SerializedStyles;
|
|
@@ -11,5 +11,5 @@ export declare const classes: {
|
|
|
11
11
|
} & {
|
|
12
12
|
root: string;
|
|
13
13
|
};
|
|
14
|
-
export declare const style: () => import("@emotion/
|
|
15
|
-
export declare const cascadePopperStyle: () => import("@emotion/
|
|
14
|
+
export declare const style: () => import("@emotion/utils").SerializedStyles;
|
|
15
|
+
export declare const cascadePopperStyle: () => import("@emotion/utils").SerializedStyles[];
|
|
@@ -10,4 +10,4 @@ export declare const classes: {
|
|
|
10
10
|
} & {
|
|
11
11
|
root: string;
|
|
12
12
|
};
|
|
13
|
-
export declare function useStyle({ color }: Required<Pick<CheckboxBaseProps, 'color'>>): import("@emotion/
|
|
13
|
+
export declare function useStyle({ color }: Required<Pick<CheckboxBaseProps, 'color'>>): import("@emotion/utils").SerializedStyles;
|
|
@@ -6,5 +6,5 @@ export declare const classes: {
|
|
|
6
6
|
} & {
|
|
7
7
|
root: string;
|
|
8
8
|
};
|
|
9
|
-
export declare const style: () => import("@emotion/
|
|
10
|
-
export declare const colorPickerPopperStyle: () => import("@emotion/
|
|
9
|
+
export declare const style: () => import("@emotion/utils").SerializedStyles;
|
|
10
|
+
export declare const colorPickerPopperStyle: () => import("@emotion/utils").SerializedStyles[];
|
|
@@ -4,7 +4,7 @@ import { DataGrid } from '../dataGrid/index.js';
|
|
|
4
4
|
import { Form } from '../form/index.js';
|
|
5
5
|
import { CurdFilterable } from './curdFilterable.js';
|
|
6
6
|
import { classes, style } from './curd.style.js';
|
|
7
|
-
import { clsx, useControlled, useCurdColumns, useDerivedState, useLoading, useSync, mergeComponentProps, CONTROL_COLUMN_KEY, useStrictEffect } from '../../utils/index.js';
|
|
7
|
+
import { clsx, useControlled, useCurdColumns, useDerivedState, useLoading, useSync, mergeComponentProps, CONTROL_COLUMN_KEY, useStrictEffect, cloneRef } from '../../utils/index.js';
|
|
8
8
|
import { Button } from '../button/index.js';
|
|
9
9
|
import { Tooltip } from '../tooltip/index.js';
|
|
10
10
|
import { CurdColumnConfig } from './curdColumnConfig.js';
|
|
@@ -131,6 +131,7 @@ export const Curd = memo((props) => {
|
|
|
131
131
|
* -------------------------------------------------------------
|
|
132
132
|
* 行数据
|
|
133
133
|
*/
|
|
134
|
+
const containerRef = useRef(null);
|
|
134
135
|
const { setOptions } = useSelectionContext();
|
|
135
136
|
const [innerRows, _setInnerRows] = useDerivedState(props.rows);
|
|
136
137
|
useEffect(() => {
|
|
@@ -139,6 +140,7 @@ export const Curd = memo((props) => {
|
|
|
139
140
|
const setInnerRows = (data) => {
|
|
140
141
|
setOptions?.(data);
|
|
141
142
|
_setInnerRows(data);
|
|
143
|
+
containerRef.current.scrollTop = 0;
|
|
142
144
|
};
|
|
143
145
|
const [innerTotal, setInnerTotal] = useDerivedState(props.paginationProps?.total || 0);
|
|
144
146
|
const suppressReload = useRef(false);
|
|
@@ -242,10 +244,12 @@ export const Curd = memo((props) => {
|
|
|
242
244
|
_jsxs(_Fragment, { children: [toolbarRight, _jsx(Divider, { className: classes.divider, orientation: "vertical" })] }), reloadable &&
|
|
243
245
|
_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 &&
|
|
244
246
|
_jsx(CurdResizable, { innerSize: innerSize.current, setInnerSize: setInnerSize }), columnConfigurable &&
|
|
245
|
-
_jsx(CurdColumnConfig, { columns: orderedColumns, innerVisible: innerVisible.current, setInnerVisible: setInnerVisible, setInnerOrder: setInnerOrder })] })] }), _jsx("div", { className: classes.card, children: _jsx(DataGrid, { ...dataGridProps,
|
|
247
|
+
_jsx(CurdColumnConfig, { columns: orderedColumns, innerVisible: innerVisible.current, setInnerVisible: setInnerVisible, setInnerOrder: setInnerOrder })] })] }), _jsx("div", { className: classes.card, children: _jsx(DataGrid, { ...dataGridProps, slotProps: {
|
|
248
|
+
container: { ref: cloneRef(containerRef, dataGridProps?.slotProps?.container?.ref) }
|
|
249
|
+
}, tableProps: {
|
|
246
250
|
...props.tableProps,
|
|
247
251
|
...resizable && { size: innerSize.current }
|
|
248
|
-
}, loading: innerLoading.current, rows: innerRows.current, paginatable: !loadRows && props.paginatable, renderPagination: loadRows && props.paginatable !== false
|
|
252
|
+
}, columns: actualColumns, loading: innerLoading.current, rows: innerRows.current, paginatable: !loadRows && props.paginatable, renderPagination: loadRows && props.paginatable !== false
|
|
249
253
|
? () => _jsx(Pagination, { ...props.paginationProps, total: innerTotal.current, page: innerPage.current, onPageChange: setInnerPage, pageSize: innerPageSize.current, onPageSizeChange: setInnerPageSize })
|
|
250
254
|
: props.renderPagination, orderColumn: innerOrderColumn.current, orderType: innerOrderType.current, onOrderChange: orderChangeHandler, _noRenderFormTag: true }) })] }), (creatable || updatable) &&
|
|
251
255
|
_jsx(CurdDialog, { ...dialogProps, ref: curdDialogRef, onFinish: finishHandler, curdProps: props })] }));
|
|
@@ -19,5 +19,5 @@ export declare const classes: {
|
|
|
19
19
|
} & {
|
|
20
20
|
root: string;
|
|
21
21
|
};
|
|
22
|
-
export declare const style: () => import("@emotion/
|
|
23
|
-
export declare const dialogStyle: () => import("@emotion/
|
|
22
|
+
export declare const style: () => import("@emotion/utils").SerializedStyles;
|
|
23
|
+
export declare const dialogStyle: () => import("@emotion/utils").SerializedStyles;
|
|
@@ -1,21 +1,33 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
-
import { memo, useMemo } from 'react';
|
|
2
|
+
import { memo, useMemo, useState, useRef } from 'react';
|
|
3
3
|
import { Button } from '../button/index.js';
|
|
4
4
|
import { Bubble } from '../bubble/index.js';
|
|
5
5
|
import { classes, style } from './curdColumnConfig.style.js';
|
|
6
6
|
import { MenuItem } from '../menuItem/index.js';
|
|
7
7
|
import { Checkbox } from '../checkbox/index.js';
|
|
8
8
|
import { SortableItem } from '../sortableItem/index.js';
|
|
9
|
-
import {
|
|
10
|
-
import { SortableContext } from '@dnd-kit/sortable';
|
|
11
|
-
import { isUnset, onDndDragEnd, useDndSensors } from '../../utils/index.js';
|
|
9
|
+
import { defaultSensors, isUnset, onDndDragEnd } from '../../utils/index.js';
|
|
12
10
|
import { Icon } from '../icon/index.js';
|
|
13
11
|
import { faGear } from '@fortawesome/free-solid-svg-icons/faGear';
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const dragEndHandler =
|
|
17
|
-
const newColumns = onDndDragEnd(e, columns, '_key');
|
|
18
|
-
newColumns && setInnerOrder(newColumns.flatMap(col => col._key ?? []));
|
|
12
|
+
import { DragDropProvider, useDragDropMonitor } from '@dnd-kit/react';
|
|
13
|
+
export const CurdColumnConfig = memo((props) => {
|
|
14
|
+
const dragEndHandler = e => {
|
|
15
|
+
const newColumns = onDndDragEnd(e, props.columns || [], '_key');
|
|
16
|
+
newColumns && props.setInnerOrder(newColumns.flatMap(col => col._key ?? []));
|
|
17
|
+
};
|
|
18
|
+
return (_jsx(DragDropProvider, { sensors: defaultSensors, onDragEnd: dragEndHandler, children: _jsx(CurdColumnConfigContent, { ...props }) }));
|
|
19
|
+
});
|
|
20
|
+
const CurdColumnConfigContent = memo(({ columns, innerVisible, setInnerVisible }) => {
|
|
21
|
+
const isDragging = useRef(false);
|
|
22
|
+
useDragDropMonitor({
|
|
23
|
+
onDragStart: () => isDragging.current = true,
|
|
24
|
+
onDragEnd: () => isDragging.current = false
|
|
25
|
+
});
|
|
26
|
+
const [open, setOpen] = useState(false);
|
|
27
|
+
const openChangeHandler = (open) => {
|
|
28
|
+
if (open || !isDragging.current) {
|
|
29
|
+
setOpen(open);
|
|
30
|
+
}
|
|
19
31
|
};
|
|
20
32
|
const visibleSet = useMemo(() => {
|
|
21
33
|
return new Set(innerVisible);
|
|
@@ -25,12 +37,12 @@ export const CurdColumnConfig = memo(({ columns, innerVisible, setInnerVisible,
|
|
|
25
37
|
? [...o, key]
|
|
26
38
|
: o.filter(k => k !== key));
|
|
27
39
|
};
|
|
28
|
-
return (_jsx(Bubble, { css: style,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
40
|
+
return (_jsx(Bubble, { css: style, open: open, onOpenChange: openChangeHandler, placement: "bottomRight", trigger: ['hover', 'click'], content: _jsxs("div", { className: classes.content, children: [_jsxs("div", { className: classes.title, children: [_jsx("div", { className: classes.titleText, children: "\u5217\u8BBE\u7F6E" }), _jsx("div", { className: classes.description, children: "\u62D6\u62FD\u8C03\u6574\u987A\u5E8F" })] }), columns?.map((col, i) => {
|
|
41
|
+
const id = col._key;
|
|
42
|
+
const checked = !isUnset(id) && visibleSet.has(id);
|
|
43
|
+
return (_jsx(SortableItem, { id: id ?? i, index: i, component: MenuItem, className: classes.item, prefix: _jsx(Checkbox, { className: classes.checkbox, checked: checked, onChange: e => {
|
|
44
|
+
e.stopPropagation();
|
|
45
|
+
toggleVisible(id, e.target.checked);
|
|
46
|
+
} }), onClick: () => toggleVisible(id, !checked), label: col.titleText ?? col.title, noStyle: true }, id ?? i));
|
|
47
|
+
})] }), autoClose: false, children: _jsx(Button, { shape: "circular", variant: "text", color: "text.secondary", children: _jsx(Icon, { icon: faGear }) }) }));
|
|
36
48
|
});
|
|
@@ -53,6 +53,7 @@ export interface ColumnType<R extends RowType = RowType> extends Omit<ComponentP
|
|
|
53
53
|
_negativeRowSpan?: number;
|
|
54
54
|
}
|
|
55
55
|
interface DataGridSharedProps<R extends RowType = RowType> extends SlotsAndProps<{
|
|
56
|
+
container: ComponentProps<'div'>;
|
|
56
57
|
tr: ComponentProps<'tr'>;
|
|
57
58
|
}> {
|
|
58
59
|
rowProps?(row: R, index: number, rows: R[]): ComponentProps<'tr'>;
|
|
@@ -126,7 +126,12 @@ export const DataGrid = memo(({ slots, slotProps, columns, rows, rowProps, prima
|
|
|
126
126
|
const { page, pageSize } = _paginationProps;
|
|
127
127
|
return orderedRows?.slice((page - 1) * pageSize, page * pageSize);
|
|
128
128
|
}, [orderedRows, _paginationProps.page, _paginationProps.pageSize, paginatable]);
|
|
129
|
-
const
|
|
129
|
+
const { container: Container = TableContainer } = slots || {};
|
|
130
|
+
const { container: containerProps } = slotProps || {};
|
|
131
|
+
const renderedContent = (_jsx(ColumnResizeContext, { columnResizable: columnResizable, children: ({ scrollerRef, tableRef }) => _jsxs(Container, { ...mergeComponentProps(containerProps, {
|
|
132
|
+
ref: scrollerRef,
|
|
133
|
+
className: classes.container
|
|
134
|
+
}), 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, { rows: rows, flattedColumns: flattedColumns, completedColumns: completedColumns, primaryKey: primaryKey, allowSelectAll: allowSelectAll, columnResizable: columnResizable, orderColumn: innerOrderColumn.current, orderType: innerOrderType.current, onOrderChange: orderChangeHandler, filterBubbleProps: filterBubbleProps, onFilterClick: onFilterClick }), _jsx("tbody", { children: _jsx(DataGridContext, { value: useMemo(() => ({
|
|
130
135
|
slots, slotProps,
|
|
131
136
|
rowProps, primaryKey, childrenKey, clickRowToSelect, indent, renderExpandIcon,
|
|
132
137
|
expandedSet, flattedColumns, toggleExpanded
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const filterOptionsStyle: import("@emotion/
|
|
1
|
+
export declare const filterOptionsStyle: import("@emotion/utils").SerializedStyles;
|
|
@@ -6,5 +6,5 @@ export declare const classes: {
|
|
|
6
6
|
} & {
|
|
7
7
|
root: string;
|
|
8
8
|
};
|
|
9
|
-
export declare const style: () => import("@emotion/
|
|
10
|
-
export declare const datePickerPopperStyle: () => import("@emotion/
|
|
9
|
+
export declare const style: () => import("@emotion/utils").SerializedStyles;
|
|
10
|
+
export declare const datePickerPopperStyle: () => import("@emotion/utils").SerializedStyles[];
|
|
@@ -11,5 +11,5 @@ export declare const classes: {
|
|
|
11
11
|
} & {
|
|
12
12
|
root: string;
|
|
13
13
|
};
|
|
14
|
-
export declare const tableStyle: () => import("@emotion/
|
|
15
|
-
export declare const gridItemStyle: () => import("@emotion/
|
|
14
|
+
export declare const tableStyle: () => import("@emotion/utils").SerializedStyles;
|
|
15
|
+
export declare const gridItemStyle: () => import("@emotion/utils").SerializedStyles;
|
|
@@ -8,8 +8,8 @@ export declare function useContainerStyle({ columnCount, columnGap, rowGap }: {
|
|
|
8
8
|
columnCount: ResponsiveValue;
|
|
9
9
|
columnGap: ResponsiveValue;
|
|
10
10
|
rowGap: ResponsiveValue;
|
|
11
|
-
}): import("@emotion/
|
|
11
|
+
}): import("@emotion/utils").SerializedStyles;
|
|
12
12
|
export declare function useItemStyle({ span, offset }: {
|
|
13
13
|
span: ResponsiveValue;
|
|
14
14
|
offset: ResponsiveValue;
|
|
15
|
-
}): import("@emotion/
|
|
15
|
+
}): import("@emotion/utils").SerializedStyles;
|
|
@@ -40,6 +40,7 @@ export const style = defineCss(({ background, easing, spacing }) => {
|
|
|
40
40
|
align-items: center;
|
|
41
41
|
justify-content: center;
|
|
42
42
|
opacity: 0;
|
|
43
|
+
z-index: -1;
|
|
43
44
|
transition: opacity .25s ${easing.easeOut};
|
|
44
45
|
|
|
45
46
|
.${classes.previewButton} {
|
|
@@ -56,6 +57,7 @@ export const style = defineCss(({ background, easing, spacing }) => {
|
|
|
56
57
|
&:hover {
|
|
57
58
|
.${classes.mask} {
|
|
58
59
|
opacity: 1;
|
|
60
|
+
z-index: 0;
|
|
59
61
|
}
|
|
60
62
|
}
|
|
61
63
|
}
|
|
@@ -4,5 +4,5 @@ export declare const classes: {
|
|
|
4
4
|
} & {
|
|
5
5
|
root: string;
|
|
6
6
|
};
|
|
7
|
-
export declare const commonNativeInputStyle: import("@emotion/
|
|
8
|
-
export declare const style: import("@emotion/
|
|
7
|
+
export declare const commonNativeInputStyle: import("@emotion/utils").SerializedStyles;
|
|
8
|
+
export declare const style: import("@emotion/utils").SerializedStyles;
|
|
@@ -7,4 +7,4 @@ export declare const classes: {
|
|
|
7
7
|
} & {
|
|
8
8
|
root: string;
|
|
9
9
|
};
|
|
10
|
-
export declare function useStyle({ color }: Required<Pick<InputBaseProps<any>, 'color'>>): import("@emotion/
|
|
10
|
+
export declare function useStyle({ color }: Required<Pick<InputBaseProps<any>, 'color'>>): import("@emotion/utils").SerializedStyles;
|
|
@@ -4,4 +4,4 @@ export declare const classes: {
|
|
|
4
4
|
} & {
|
|
5
5
|
root: string;
|
|
6
6
|
};
|
|
7
|
-
export declare function useStyle({ color, borderWidth }: Required<Pick<LoadingIndicatorProps, 'color' | 'borderWidth'>>): import("@emotion/
|
|
7
|
+
export declare function useStyle({ color, borderWidth }: Required<Pick<LoadingIndicatorProps, 'color' | 'borderWidth'>>): import("@emotion/utils").SerializedStyles;
|
|
@@ -15,6 +15,6 @@ export declare const paddingHorizontal: {
|
|
|
15
15
|
medium: number;
|
|
16
16
|
large: number;
|
|
17
17
|
};
|
|
18
|
-
export declare function useStyle({ color }: Required<Pick<MenuItemProps, 'color'>>): import("@emotion/
|
|
18
|
+
export declare function useStyle({ color }: Required<Pick<MenuItemProps, 'color'>>): import("@emotion/utils").SerializedStyles;
|
|
19
19
|
export declare const menuListPadding = 4;
|
|
20
|
-
export declare const childrenStyle: () => import("@emotion/
|
|
20
|
+
export declare const childrenStyle: () => import("@emotion/utils").SerializedStyles;
|