@canlooks/can-ui 0.0.180 → 0.0.182
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/clickAway/clickAway.d.ts +1 -1
- package/dist/cjs/components/clickAway/clickAway.js +2 -2
- package/dist/cjs/components/curd/curd.d.ts +5 -2
- package/dist/cjs/components/curd/curd.js +3 -3
- package/dist/cjs/components/curd/curdColumnConfig.d.ts +2 -0
- package/dist/cjs/components/curd/curdColumnConfig.js +3 -2
- package/dist/cjs/components/curd/curdResizable.d.ts +3 -1
- package/dist/cjs/components/curd/curdResizable.js +2 -2
- package/dist/cjs/components/dateTimeRangePicker/dateTimeRangePicker.d.ts +2 -3
- package/dist/cjs/components/overlayBase/overlayBase.d.ts +1 -1
- package/dist/cjs/components/snackbarBase/snackbarBase.d.ts +1 -1
- package/dist/cjs/types.d.ts +1 -1
- package/dist/cjs/utils/hooks.d.ts +1 -1
- package/dist/cjs/utils/hooks.js +1 -2
- package/dist/esm/components/clickAway/clickAway.d.ts +1 -1
- package/dist/esm/components/clickAway/clickAway.js +2 -2
- package/dist/esm/components/curd/curd.d.ts +5 -2
- package/dist/esm/components/curd/curd.js +3 -3
- package/dist/esm/components/curd/curdColumnConfig.d.ts +2 -0
- package/dist/esm/components/curd/curdColumnConfig.js +3 -2
- package/dist/esm/components/curd/curdResizable.d.ts +3 -1
- package/dist/esm/components/curd/curdResizable.js +2 -2
- package/dist/esm/components/dateTimeRangePicker/dateTimeRangePicker.d.ts +2 -3
- package/dist/esm/components/overlayBase/overlayBase.d.ts +1 -1
- package/dist/esm/components/snackbarBase/snackbarBase.d.ts +1 -1
- package/dist/esm/types.d.ts +1 -1
- package/dist/esm/utils/hooks.d.ts +1 -1
- package/dist/esm/utils/hooks.js +1 -2
- package/package.json +1 -1
|
@@ -8,7 +8,7 @@ export interface ClickAwayProps extends DivProps {
|
|
|
8
8
|
disabled?: boolean;
|
|
9
9
|
children?: ReactElement<any>;
|
|
10
10
|
/** 用于参考的目标元素,若为数组,需要点击数组外的元素才会触发clickAway */
|
|
11
|
-
targets?: () => Element | undefined | (Element | undefined)[];
|
|
11
|
+
targets?: () => Element | null | undefined | (Element | null | undefined)[];
|
|
12
12
|
}
|
|
13
13
|
export declare function ClickAway({ ref, container, eventType, onClickAway, disabled, children, targets, ...props }: ClickAwayProps): ReactElement<any, string | import("react").JSXElementConstructor<any>> | import("react").FunctionComponentElement<{
|
|
14
14
|
ref: (ref: Element | null) => void;
|
|
@@ -24,9 +24,9 @@ function ClickAway({ ref, container = self, eventType = 'click', onClickAway, di
|
|
|
24
24
|
};
|
|
25
25
|
const containerEl = typeof container === 'function' ? container() : container;
|
|
26
26
|
const standardEventType = eventType.toLowerCase().replace(/^on/, '');
|
|
27
|
-
containerEl
|
|
27
|
+
containerEl?.addEventListener(standardEventType, onClick);
|
|
28
28
|
return () => {
|
|
29
|
-
containerEl
|
|
29
|
+
containerEl?.removeEventListener(standardEventType, onClick);
|
|
30
30
|
};
|
|
31
31
|
}, [disabled]);
|
|
32
32
|
return !disabled && (0, react_1.isValidElement)(children)
|
|
@@ -7,6 +7,7 @@ import { FieldPath } from '../../utils';
|
|
|
7
7
|
import { ButtonProps } from '../button';
|
|
8
8
|
import { CurdDialogProps } from './curdDialog';
|
|
9
9
|
import { BubbleConfirmProps } from '../bubbleConfirm';
|
|
10
|
+
import { BubbleProps } from '../bubble';
|
|
10
11
|
export type CurdFormItemProps<I = any> = FormItemProps<I> & {
|
|
11
12
|
/** 对filter或form内的字段单独排序,数字越大越靠后,默认为`0` */
|
|
12
13
|
order?: number;
|
|
@@ -61,6 +62,8 @@ export interface CurdBaseProps<R extends RowType = RowType, F extends FormValue
|
|
|
61
62
|
reloadable?: boolean;
|
|
62
63
|
onReload?(): void;
|
|
63
64
|
resizable?: boolean;
|
|
65
|
+
defaultSize?: Size;
|
|
66
|
+
onSizeChange?(size: Size): void;
|
|
64
67
|
columnConfigurable?: boolean | {
|
|
65
68
|
defaultVisible?: Id[];
|
|
66
69
|
visible?: Id[];
|
|
@@ -69,8 +72,8 @@ export interface CurdBaseProps<R extends RowType = RowType, F extends FormValue
|
|
|
69
72
|
order?: Id[];
|
|
70
73
|
onOrderChange?(order: Id[]): void;
|
|
71
74
|
};
|
|
72
|
-
|
|
73
|
-
|
|
75
|
+
resizeBubbleProps?: BubbleProps;
|
|
76
|
+
columnConfigBubbleProps?: BubbleProps;
|
|
74
77
|
filterableProps?: Omit<CurdFilterableProps, 'columns'>;
|
|
75
78
|
renderFilterable?(filterableProps: CurdFilterableProps): ReactNode;
|
|
76
79
|
renderFilterConditions?: CurdFilterableProps['renderFilterConditions'];
|
|
@@ -24,7 +24,7 @@ const faPenToSquare_1 = require("@fortawesome/free-regular-svg-icons/faPenToSqua
|
|
|
24
24
|
const faPlus_1 = require("@fortawesome/free-solid-svg-icons/faPlus");
|
|
25
25
|
const faRotateRight_1 = require("@fortawesome/free-solid-svg-icons/faRotateRight");
|
|
26
26
|
exports.Curd = (0, react_1.memo)((props) => {
|
|
27
|
-
const { ref, wrapperProps, variant = 'standard', loadRows, onLoad, columns, toolbarLeft, toolbarRight, reloadable = true, onReload, resizable = true,
|
|
27
|
+
const { ref, wrapperProps, variant = 'standard', loadRows, onLoad, columns, toolbarLeft, toolbarRight, reloadable = true, onReload, resizable = true, defaultSize = 'medium', onSizeChange, columnConfigurable = true, resizeBubbleProps, columnConfigBubbleProps, filterProps, initialFilterValue, onFilter, filterableProps, renderFilterable, renderFilterConditions, copyable, creatable = true, updatable = true, deletable = true, createButtonProps, updateButtonProps, deleteButtonProps, deleteConfirmProps, controlColumnTitle = '操作', renderExtraControl, titleKey, dataName = '', createName = '添加', updateName = '编辑', deleteName = '删除', onCreate, onUpdate, onDelete, rowToForm, dialogProps, formProps, formRef, onChange, ...dataGridProps } = props;
|
|
28
28
|
/**
|
|
29
29
|
* -------------------------------------------------------------
|
|
30
30
|
* ref
|
|
@@ -248,8 +248,8 @@ exports.Curd = (0, react_1.memo)((props) => {
|
|
|
248
248
|
(0, jsx_runtime_1.jsxs)(button_1.Button, { prefix: (0, jsx_runtime_1.jsx)(icon_1.Icon, { icon: faPlus_1.faPlus }), ...createButtonProps, onClick: createHandler, children: [createName, dataName] }), toolbarLeft] }), (0, jsx_runtime_1.jsxs)("div", { className: curd_style_1.classes.toolbarRight, children: [!!toolbarRight &&
|
|
249
249
|
(0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [toolbarRight, (0, jsx_runtime_1.jsx)(divider_1.Divider, { className: curd_style_1.classes.divider, orientation: "vertical" })] }), reloadable &&
|
|
250
250
|
(0, jsx_runtime_1.jsx)(tooltip_1.Tooltip, { title: "\u5237\u65B0", children: (0, jsx_runtime_1.jsx)(button_1.Button, { shape: "circular", variant: "text", color: "text.secondary", prefix: (0, jsx_runtime_1.jsx)(icon_1.Icon, { icon: faRotateRight_1.faRotateRight }), loading: innerLoading.current, onClick: reloadHandler }) }), resizable &&
|
|
251
|
-
(0, jsx_runtime_1.jsx)(curdResizable_1.CurdResizable, { innerSize: innerSize.current, setInnerSize: setInnerSize }), columnConfigurable &&
|
|
252
|
-
(0, jsx_runtime_1.jsx)(curdColumnConfig_1.CurdColumnConfig, { columns: orderedColumns, innerVisible: innerVisible.current, setInnerVisible: setInnerVisible, setInnerOrder: setInnerOrder })] })] }), (0, jsx_runtime_1.jsx)("div", { className: curd_style_1.classes.card, children: (0, jsx_runtime_1.jsx)(dataGrid_1.DataGrid, { ...dataGridProps, slotProps: {
|
|
251
|
+
(0, jsx_runtime_1.jsx)(curdResizable_1.CurdResizable, { innerSize: innerSize.current, setInnerSize: setInnerSize, resizeBubbleProps: resizeBubbleProps }), columnConfigurable &&
|
|
252
|
+
(0, jsx_runtime_1.jsx)(curdColumnConfig_1.CurdColumnConfig, { columns: orderedColumns, innerVisible: innerVisible.current, setInnerVisible: setInnerVisible, setInnerOrder: setInnerOrder, columnConfigBubbleProps: columnConfigBubbleProps })] })] }), (0, jsx_runtime_1.jsx)("div", { className: curd_style_1.classes.card, children: (0, jsx_runtime_1.jsx)(dataGrid_1.DataGrid, { ...dataGridProps, slotProps: {
|
|
253
253
|
container: { ref: (0, utils_1.cloneRef)(containerRef, dataGridProps?.slotProps?.container?.ref) }
|
|
254
254
|
}, tableProps: {
|
|
255
255
|
...props.tableProps,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Dispatch, ReactElement, SetStateAction } from 'react';
|
|
2
|
+
import { BubbleProps } from '../bubble';
|
|
2
3
|
import { CurdColumn } from './curd';
|
|
3
4
|
import { RowType } from '../dataGrid';
|
|
4
5
|
import { Id } from '../../types';
|
|
@@ -7,5 +8,6 @@ export type CurdColumnConfigProps<R extends RowType> = {
|
|
|
7
8
|
innerVisible: Id[] | undefined;
|
|
8
9
|
setInnerVisible: Dispatch<SetStateAction<Id[] | undefined>>;
|
|
9
10
|
setInnerOrder: Dispatch<SetStateAction<Id[] | undefined>>;
|
|
11
|
+
columnConfigBubbleProps?: BubbleProps;
|
|
10
12
|
};
|
|
11
13
|
export declare const CurdColumnConfig: <R extends RowType>(props: CurdColumnConfigProps<R>) => ReactElement;
|
|
@@ -20,7 +20,7 @@ exports.CurdColumnConfig = (0, react_1.memo)((props) => {
|
|
|
20
20
|
};
|
|
21
21
|
return ((0, jsx_runtime_1.jsx)(react_2.DragDropProvider, { sensors: utils_1.defaultSensors, onDragEnd: dragEndHandler, children: (0, jsx_runtime_1.jsx)(CurdColumnConfigContent, { ...props }) }));
|
|
22
22
|
});
|
|
23
|
-
const CurdColumnConfigContent = (0, react_1.memo)(({ columns, innerVisible, setInnerVisible }) => {
|
|
23
|
+
const CurdColumnConfigContent = (0, react_1.memo)(({ columns, innerVisible, setInnerVisible, columnConfigBubbleProps }) => {
|
|
24
24
|
const isDragging = (0, react_1.useRef)(false);
|
|
25
25
|
(0, react_2.useDragDropMonitor)({
|
|
26
26
|
onDragStart: () => isDragging.current = true,
|
|
@@ -28,6 +28,7 @@ const CurdColumnConfigContent = (0, react_1.memo)(({ columns, innerVisible, setI
|
|
|
28
28
|
});
|
|
29
29
|
const [open, setOpen] = (0, react_1.useState)(false);
|
|
30
30
|
const openChangeHandler = (open) => {
|
|
31
|
+
columnConfigBubbleProps?.onOpenChange?.(open);
|
|
31
32
|
if (open || !isDragging.current) {
|
|
32
33
|
setOpen(open);
|
|
33
34
|
}
|
|
@@ -40,7 +41,7 @@ const CurdColumnConfigContent = (0, react_1.memo)(({ columns, innerVisible, setI
|
|
|
40
41
|
? [...o, key]
|
|
41
42
|
: o.filter(k => k !== key));
|
|
42
43
|
};
|
|
43
|
-
return ((0, jsx_runtime_1.jsx)(bubble_1.Bubble, {
|
|
44
|
+
return ((0, jsx_runtime_1.jsx)(bubble_1.Bubble, { placement: "bottomRight", trigger: ['hover', 'click'], ...columnConfigBubbleProps, css: curdColumnConfig_style_1.style, open: open, onOpenChange: openChangeHandler, content: (0, jsx_runtime_1.jsxs)("div", { className: curdColumnConfig_style_1.classes.content, children: [(0, jsx_runtime_1.jsxs)("div", { className: curdColumnConfig_style_1.classes.title, children: [(0, jsx_runtime_1.jsx)("div", { className: curdColumnConfig_style_1.classes.titleText, children: "\u5217\u8BBE\u7F6E" }), (0, jsx_runtime_1.jsx)("div", { className: curdColumnConfig_style_1.classes.description, children: "\u62D6\u62FD\u8C03\u6574\u987A\u5E8F" })] }), columns?.map((col, i) => {
|
|
44
45
|
const id = col._key;
|
|
45
46
|
const checked = !(0, utils_1.isUnset)(id) && (!visibleSet || visibleSet.has(id));
|
|
46
47
|
return ((0, jsx_runtime_1.jsx)(sortableItem_1.SortableItem, { id: id ?? i, index: i, component: menuItem_1.MenuItem, className: curdColumnConfig_style_1.classes.item, prefix: (0, jsx_runtime_1.jsx)(checkbox_1.Checkbox, { className: curdColumnConfig_style_1.classes.checkbox, checked: checked, onChange: e => {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Dispatch, SetStateAction } from 'react';
|
|
2
|
+
import { BubbleProps } from '../bubble';
|
|
2
3
|
import { Size } from '../../types';
|
|
3
|
-
export declare const CurdResizable: import("react").MemoExoticComponent<({ innerSize, setInnerSize }: {
|
|
4
|
+
export declare const CurdResizable: import("react").MemoExoticComponent<({ innerSize, setInnerSize, resizeBubbleProps }: {
|
|
4
5
|
innerSize: Size;
|
|
5
6
|
setInnerSize: Dispatch<SetStateAction<Size>>;
|
|
7
|
+
resizeBubbleProps?: BubbleProps;
|
|
6
8
|
}) => import("@emotion/react/jsx-runtime").JSX.Element>;
|
|
@@ -9,6 +9,6 @@ const menuItem_1 = require("../menuItem");
|
|
|
9
9
|
const button_1 = require("../button");
|
|
10
10
|
const icon_1 = require("../icon");
|
|
11
11
|
const faArrowsUpDown_1 = require("@fortawesome/free-solid-svg-icons/faArrowsUpDown");
|
|
12
|
-
exports.CurdResizable = (0, react_1.memo)(({ innerSize, setInnerSize }) => {
|
|
13
|
-
return ((0, jsx_runtime_1.jsx)(tooltip_1.Tooltip, { title: "\u8868\u683C\u5C3A\u5BF8", clickToClose: true, children: (0, jsx_runtime_1.jsx)(bubble_1.Bubble, { placement: "bottom", trigger: "click", content: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(menuItem_1.MenuItem, { value: "small", label: "\u5C0F", selected: innerSize === 'small', onClick: () => setInnerSize('small') }), (0, jsx_runtime_1.jsx)(menuItem_1.MenuItem, { value: "medium", label: "\u4E2D", selected: innerSize === 'medium', onClick: () => setInnerSize('medium') }), (0, jsx_runtime_1.jsx)(menuItem_1.MenuItem, { value: "large", label: "\u5927", selected: innerSize === 'large', onClick: () => setInnerSize('large') })] }), children: (0, jsx_runtime_1.jsx)(button_1.Button, { shape: "circular", variant: "text", color: "text.secondary", children: (0, jsx_runtime_1.jsx)(icon_1.Icon, { icon: faArrowsUpDown_1.faArrowsUpDown }) }) }) }));
|
|
12
|
+
exports.CurdResizable = (0, react_1.memo)(({ innerSize, setInnerSize, resizeBubbleProps }) => {
|
|
13
|
+
return ((0, jsx_runtime_1.jsx)(tooltip_1.Tooltip, { title: "\u8868\u683C\u5C3A\u5BF8", clickToClose: true, children: (0, jsx_runtime_1.jsx)(bubble_1.Bubble, { placement: "bottom", trigger: "click", ...resizeBubbleProps, content: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(menuItem_1.MenuItem, { value: "small", label: "\u5C0F", selected: innerSize === 'small', onClick: () => setInnerSize('small') }), (0, jsx_runtime_1.jsx)(menuItem_1.MenuItem, { value: "medium", label: "\u4E2D", selected: innerSize === 'medium', onClick: () => setInnerSize('medium') }), (0, jsx_runtime_1.jsx)(menuItem_1.MenuItem, { value: "large", label: "\u5927", selected: innerSize === 'large', onClick: () => setInnerSize('large') })] }), children: (0, jsx_runtime_1.jsx)(button_1.Button, { shape: "circular", variant: "text", color: "text.secondary", children: (0, jsx_runtime_1.jsx)(icon_1.Icon, { icon: faArrowsUpDown_1.faArrowsUpDown }) }) }) }));
|
|
14
14
|
});
|
|
@@ -2,8 +2,8 @@ import { ReactNode } from 'react';
|
|
|
2
2
|
import { ColorPropsValue, DivProps, Size } from '../../types';
|
|
3
3
|
import { DatePickerSharedProps, DateTimePickerProps } from '../dateTimePicker';
|
|
4
4
|
import { Dayjs } from 'dayjs';
|
|
5
|
-
type DateValueType = [Dayjs | null, Dayjs | null] | null;
|
|
6
|
-
type PickerType = 'start' | 'end';
|
|
5
|
+
export type DateValueType = [Dayjs | null, Dayjs | null] | null;
|
|
6
|
+
export type PickerType = 'start' | 'end';
|
|
7
7
|
export interface DateTimeRangePickerProps extends DatePickerSharedProps, Omit<DivProps, 'defaultValue' | 'onChange'> {
|
|
8
8
|
startPickerProps?: DateTimePickerProps;
|
|
9
9
|
endPickerProps?: DateTimePickerProps;
|
|
@@ -25,4 +25,3 @@ export interface DateTimeRangePickerProps extends DatePickerSharedProps, Omit<Di
|
|
|
25
25
|
autoFocus?: boolean;
|
|
26
26
|
}
|
|
27
27
|
export declare const DateTimeRangePicker: import("react").MemoExoticComponent<({ startPickerProps, endPickerProps, format, defaultValue, value, onChange, defaultOpenPicker, openPicker, onOpenPickerChange, autoClose, separator, min, max, disabledDates, disabledHours, disabledMinutes, disabledSeconds, variant, size, color, disabled, readOnly, autoFocus, ...props }: DateTimeRangePickerProps) => import("@emotion/react/jsx-runtime").JSX.Element>;
|
|
28
|
-
export {};
|
|
@@ -24,4 +24,4 @@ export interface OverlayBaseProps extends DivProps {
|
|
|
24
24
|
removeFocusOnOpen?: boolean;
|
|
25
25
|
}
|
|
26
26
|
export declare const overlayBaseTransitionDuration = 300;
|
|
27
|
-
export declare function OverlayBase({ container, effectContainer, forceRender, open, onMaskClick, singleLayer, onOpened, onClosed, maskProps, removeFocusOnOpen, ...props }: OverlayBaseProps): false | React.ReactPortal | null;
|
|
27
|
+
export declare function OverlayBase({ container, effectContainer, forceRender, open, onMaskClick, singleLayer, onOpened, onClosed, maskProps, removeFocusOnOpen, ...props }: OverlayBaseProps): false | React.ReactPortal | null | undefined;
|
|
@@ -30,7 +30,7 @@ export declare const SnackbarBase: React.MemoExoticComponent<({ methods, useTo,
|
|
|
30
30
|
max?: number;
|
|
31
31
|
container?: DefineElement<HTMLElement>;
|
|
32
32
|
effectContainer?: DefineElement<HTMLElement>;
|
|
33
|
-
}) => React.ReactPortal | null>;
|
|
33
|
+
}) => React.ReactPortal | null | undefined>;
|
|
34
34
|
interface SnackbarBaseItemProps extends Omit<SnackbarBaseProps, 'duration' | 'onAutoClose'> {
|
|
35
35
|
id: string;
|
|
36
36
|
type: keyof SnackbarBaseMethods;
|
package/dist/cjs/types.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ export type Size = 'small' | 'medium' | 'large';
|
|
|
21
21
|
export type CornerPlacement = 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight' | 'leftTop' | 'leftBottom' | 'rightTop' | 'rightBottom';
|
|
22
22
|
export type BlockPlacement = CornerPlacement | 'top' | 'bottom';
|
|
23
23
|
export type Placement = BlockPlacement | 'left' | 'right';
|
|
24
|
-
export type DefineElement<T = Element | null | undefined
|
|
24
|
+
export type DefineElement<T = Element> = T | null | undefined | (() => T | null | undefined);
|
|
25
25
|
/**
|
|
26
26
|
* ----------------------------------------------------------------------------------
|
|
27
27
|
* Responsive
|
|
@@ -51,7 +51,7 @@ export declare function useLoading<A extends any[], R>(fn: (...args: A) => R | P
|
|
|
51
51
|
* @param effectContainer
|
|
52
52
|
* @param defaultContainer 默认为`document.body`
|
|
53
53
|
*/
|
|
54
|
-
export declare function useContainer<T extends HTMLElement | null>(container?: DefineElement<T>, effectContainer?: DefineElement<T>, defaultContainer?: DefineElement<T>): RefObject<T | null>;
|
|
54
|
+
export declare function useContainer<T extends HTMLElement | null>(container?: DefineElement<T>, effectContainer?: DefineElement<T>, defaultContainer?: DefineElement<T>): RefObject<T | null | undefined>;
|
|
55
55
|
/**
|
|
56
56
|
* 使用外部类,该方法可避免`StrictMode`下,React渲染行为与外部类实例生命周期不同步的问题
|
|
57
57
|
*/
|
package/dist/cjs/utils/hooks.js
CHANGED
|
@@ -126,7 +126,6 @@ function useLoading(fn, referredLoading = false) {
|
|
|
126
126
|
return await res;
|
|
127
127
|
}
|
|
128
128
|
finally {
|
|
129
|
-
console.log(157, unmounted.current);
|
|
130
129
|
!unmounted.current && setLoading(false);
|
|
131
130
|
}
|
|
132
131
|
}
|
|
@@ -146,7 +145,7 @@ function useContainer(container, effectContainer, defaultContainer) {
|
|
|
146
145
|
if (container) {
|
|
147
146
|
return typeof container === 'function' ? container() : container;
|
|
148
147
|
}
|
|
149
|
-
return prev
|
|
148
|
+
return prev;
|
|
150
149
|
}, [container]);
|
|
151
150
|
(0, react_1.useEffect)(() => {
|
|
152
151
|
let _container = effectContainer || defaultContainer;
|
|
@@ -8,7 +8,7 @@ export interface ClickAwayProps extends DivProps {
|
|
|
8
8
|
disabled?: boolean;
|
|
9
9
|
children?: ReactElement<any>;
|
|
10
10
|
/** 用于参考的目标元素,若为数组,需要点击数组外的元素才会触发clickAway */
|
|
11
|
-
targets?: () => Element | undefined | (Element | undefined)[];
|
|
11
|
+
targets?: () => Element | null | undefined | (Element | null | undefined)[];
|
|
12
12
|
}
|
|
13
13
|
export declare function ClickAway({ ref, container, eventType, onClickAway, disabled, children, targets, ...props }: ClickAwayProps): ReactElement<any, string | import("react").JSXElementConstructor<any>> | import("react").FunctionComponentElement<{
|
|
14
14
|
ref: (ref: Element | null) => void;
|
|
@@ -21,9 +21,9 @@ export function ClickAway({ ref, container = self, eventType = 'click', onClickA
|
|
|
21
21
|
};
|
|
22
22
|
const containerEl = typeof container === 'function' ? container() : container;
|
|
23
23
|
const standardEventType = eventType.toLowerCase().replace(/^on/, '');
|
|
24
|
-
containerEl
|
|
24
|
+
containerEl?.addEventListener(standardEventType, onClick);
|
|
25
25
|
return () => {
|
|
26
|
-
containerEl
|
|
26
|
+
containerEl?.removeEventListener(standardEventType, onClick);
|
|
27
27
|
};
|
|
28
28
|
}, [disabled]);
|
|
29
29
|
return !disabled && isValidElement(children)
|
|
@@ -7,6 +7,7 @@ import { FieldPath } from '../../utils/index.js';
|
|
|
7
7
|
import { ButtonProps } from '../button/index.js';
|
|
8
8
|
import { CurdDialogProps } from './curdDialog.js';
|
|
9
9
|
import { BubbleConfirmProps } from '../bubbleConfirm/index.js';
|
|
10
|
+
import { BubbleProps } from '../bubble/index.js';
|
|
10
11
|
export type CurdFormItemProps<I = any> = FormItemProps<I> & {
|
|
11
12
|
/** 对filter或form内的字段单独排序,数字越大越靠后,默认为`0` */
|
|
12
13
|
order?: number;
|
|
@@ -61,6 +62,8 @@ export interface CurdBaseProps<R extends RowType = RowType, F extends FormValue
|
|
|
61
62
|
reloadable?: boolean;
|
|
62
63
|
onReload?(): void;
|
|
63
64
|
resizable?: boolean;
|
|
65
|
+
defaultSize?: Size;
|
|
66
|
+
onSizeChange?(size: Size): void;
|
|
64
67
|
columnConfigurable?: boolean | {
|
|
65
68
|
defaultVisible?: Id[];
|
|
66
69
|
visible?: Id[];
|
|
@@ -69,8 +72,8 @@ export interface CurdBaseProps<R extends RowType = RowType, F extends FormValue
|
|
|
69
72
|
order?: Id[];
|
|
70
73
|
onOrderChange?(order: Id[]): void;
|
|
71
74
|
};
|
|
72
|
-
|
|
73
|
-
|
|
75
|
+
resizeBubbleProps?: BubbleProps;
|
|
76
|
+
columnConfigBubbleProps?: BubbleProps;
|
|
74
77
|
filterableProps?: Omit<CurdFilterableProps, 'columns'>;
|
|
75
78
|
renderFilterable?(filterableProps: CurdFilterableProps): ReactNode;
|
|
76
79
|
renderFilterConditions?: CurdFilterableProps['renderFilterConditions'];
|
|
@@ -21,7 +21,7 @@ import { faPenToSquare } from '@fortawesome/free-regular-svg-icons/faPenToSquare
|
|
|
21
21
|
import { faPlus } from '@fortawesome/free-solid-svg-icons/faPlus';
|
|
22
22
|
import { faRotateRight } from '@fortawesome/free-solid-svg-icons/faRotateRight';
|
|
23
23
|
export const Curd = memo((props) => {
|
|
24
|
-
const { ref, wrapperProps, variant = 'standard', loadRows, onLoad, columns, toolbarLeft, toolbarRight, reloadable = true, onReload, resizable = true,
|
|
24
|
+
const { ref, wrapperProps, variant = 'standard', loadRows, onLoad, columns, toolbarLeft, toolbarRight, reloadable = true, onReload, resizable = true, defaultSize = 'medium', onSizeChange, columnConfigurable = true, resizeBubbleProps, columnConfigBubbleProps, filterProps, initialFilterValue, onFilter, filterableProps, renderFilterable, renderFilterConditions, copyable, creatable = true, updatable = true, deletable = true, createButtonProps, updateButtonProps, deleteButtonProps, deleteConfirmProps, controlColumnTitle = '操作', renderExtraControl, titleKey, dataName = '', createName = '添加', updateName = '编辑', deleteName = '删除', onCreate, onUpdate, onDelete, rowToForm, dialogProps, formProps, formRef, onChange, ...dataGridProps } = props;
|
|
25
25
|
/**
|
|
26
26
|
* -------------------------------------------------------------
|
|
27
27
|
* ref
|
|
@@ -245,8 +245,8 @@ export const Curd = memo((props) => {
|
|
|
245
245
|
_jsxs(Button, { prefix: _jsx(Icon, { icon: faPlus }), ...createButtonProps, onClick: createHandler, children: [createName, dataName] }), toolbarLeft] }), _jsxs("div", { className: classes.toolbarRight, children: [!!toolbarRight &&
|
|
246
246
|
_jsxs(_Fragment, { children: [toolbarRight, _jsx(Divider, { className: classes.divider, orientation: "vertical" })] }), reloadable &&
|
|
247
247
|
_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 &&
|
|
248
|
-
_jsx(CurdResizable, { innerSize: innerSize.current, setInnerSize: setInnerSize }), columnConfigurable &&
|
|
249
|
-
_jsx(CurdColumnConfig, { columns: orderedColumns, innerVisible: innerVisible.current, setInnerVisible: setInnerVisible, setInnerOrder: setInnerOrder })] })] }), _jsx("div", { className: classes.card, children: _jsx(DataGrid, { ...dataGridProps, slotProps: {
|
|
248
|
+
_jsx(CurdResizable, { innerSize: innerSize.current, setInnerSize: setInnerSize, resizeBubbleProps: resizeBubbleProps }), columnConfigurable &&
|
|
249
|
+
_jsx(CurdColumnConfig, { columns: orderedColumns, innerVisible: innerVisible.current, setInnerVisible: setInnerVisible, setInnerOrder: setInnerOrder, columnConfigBubbleProps: columnConfigBubbleProps })] })] }), _jsx("div", { className: classes.card, children: _jsx(DataGrid, { ...dataGridProps, slotProps: {
|
|
250
250
|
container: { ref: cloneRef(containerRef, dataGridProps?.slotProps?.container?.ref) }
|
|
251
251
|
}, tableProps: {
|
|
252
252
|
...props.tableProps,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Dispatch, ReactElement, SetStateAction } from 'react';
|
|
2
|
+
import { BubbleProps } from '../bubble/index.js';
|
|
2
3
|
import { CurdColumn } from './curd.js';
|
|
3
4
|
import { RowType } from '../dataGrid/index.js';
|
|
4
5
|
import { Id } from '../../types.js';
|
|
@@ -7,5 +8,6 @@ export type CurdColumnConfigProps<R extends RowType> = {
|
|
|
7
8
|
innerVisible: Id[] | undefined;
|
|
8
9
|
setInnerVisible: Dispatch<SetStateAction<Id[] | undefined>>;
|
|
9
10
|
setInnerOrder: Dispatch<SetStateAction<Id[] | undefined>>;
|
|
11
|
+
columnConfigBubbleProps?: BubbleProps;
|
|
10
12
|
};
|
|
11
13
|
export declare const CurdColumnConfig: <R extends RowType>(props: CurdColumnConfigProps<R>) => ReactElement;
|
|
@@ -17,7 +17,7 @@ export const CurdColumnConfig = memo((props) => {
|
|
|
17
17
|
};
|
|
18
18
|
return (_jsx(DragDropProvider, { sensors: defaultSensors, onDragEnd: dragEndHandler, children: _jsx(CurdColumnConfigContent, { ...props }) }));
|
|
19
19
|
});
|
|
20
|
-
const CurdColumnConfigContent = memo(({ columns, innerVisible, setInnerVisible }) => {
|
|
20
|
+
const CurdColumnConfigContent = memo(({ columns, innerVisible, setInnerVisible, columnConfigBubbleProps }) => {
|
|
21
21
|
const isDragging = useRef(false);
|
|
22
22
|
useDragDropMonitor({
|
|
23
23
|
onDragStart: () => isDragging.current = true,
|
|
@@ -25,6 +25,7 @@ const CurdColumnConfigContent = memo(({ columns, innerVisible, setInnerVisible }
|
|
|
25
25
|
});
|
|
26
26
|
const [open, setOpen] = useState(false);
|
|
27
27
|
const openChangeHandler = (open) => {
|
|
28
|
+
columnConfigBubbleProps?.onOpenChange?.(open);
|
|
28
29
|
if (open || !isDragging.current) {
|
|
29
30
|
setOpen(open);
|
|
30
31
|
}
|
|
@@ -37,7 +38,7 @@ const CurdColumnConfigContent = memo(({ columns, innerVisible, setInnerVisible }
|
|
|
37
38
|
? [...o, key]
|
|
38
39
|
: o.filter(k => k !== key));
|
|
39
40
|
};
|
|
40
|
-
return (_jsx(Bubble, {
|
|
41
|
+
return (_jsx(Bubble, { placement: "bottomRight", trigger: ['hover', 'click'], ...columnConfigBubbleProps, css: style, open: open, onOpenChange: openChangeHandler, 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
42
|
const id = col._key;
|
|
42
43
|
const checked = !isUnset(id) && (!visibleSet || visibleSet.has(id));
|
|
43
44
|
return (_jsx(SortableItem, { id: id ?? i, index: i, component: MenuItem, className: classes.item, prefix: _jsx(Checkbox, { className: classes.checkbox, checked: checked, onChange: e => {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Dispatch, SetStateAction } from 'react';
|
|
2
|
+
import { BubbleProps } from '../bubble/index.js';
|
|
2
3
|
import { Size } from '../../types.js';
|
|
3
|
-
export declare const CurdResizable: import("react").MemoExoticComponent<({ innerSize, setInnerSize }: {
|
|
4
|
+
export declare const CurdResizable: import("react").MemoExoticComponent<({ innerSize, setInnerSize, resizeBubbleProps }: {
|
|
4
5
|
innerSize: Size;
|
|
5
6
|
setInnerSize: Dispatch<SetStateAction<Size>>;
|
|
7
|
+
resizeBubbleProps?: BubbleProps;
|
|
6
8
|
}) => import("@emotion/react/jsx-runtime").JSX.Element>;
|
|
@@ -6,6 +6,6 @@ import { MenuItem } from '../menuItem/index.js';
|
|
|
6
6
|
import { Button } from '../button/index.js';
|
|
7
7
|
import { Icon } from '../icon/index.js';
|
|
8
8
|
import { faArrowsUpDown } from '@fortawesome/free-solid-svg-icons/faArrowsUpDown';
|
|
9
|
-
export const CurdResizable = memo(({ innerSize, setInnerSize }) => {
|
|
10
|
-
return (_jsx(Tooltip, { title: "\u8868\u683C\u5C3A\u5BF8", clickToClose: true, children: _jsx(Bubble, { placement: "bottom", trigger: "click", 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 }) }) }) }));
|
|
9
|
+
export const CurdResizable = memo(({ innerSize, setInnerSize, resizeBubbleProps }) => {
|
|
10
|
+
return (_jsx(Tooltip, { title: "\u8868\u683C\u5C3A\u5BF8", clickToClose: true, children: _jsx(Bubble, { placement: "bottom", trigger: "click", ...resizeBubbleProps, 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
|
});
|
|
@@ -2,8 +2,8 @@ import { ReactNode } from 'react';
|
|
|
2
2
|
import { ColorPropsValue, DivProps, Size } from '../../types.js';
|
|
3
3
|
import { DatePickerSharedProps, DateTimePickerProps } from '../dateTimePicker/index.js';
|
|
4
4
|
import { Dayjs } from 'dayjs';
|
|
5
|
-
type DateValueType = [Dayjs | null, Dayjs | null] | null;
|
|
6
|
-
type PickerType = 'start' | 'end';
|
|
5
|
+
export type DateValueType = [Dayjs | null, Dayjs | null] | null;
|
|
6
|
+
export type PickerType = 'start' | 'end';
|
|
7
7
|
export interface DateTimeRangePickerProps extends DatePickerSharedProps, Omit<DivProps, 'defaultValue' | 'onChange'> {
|
|
8
8
|
startPickerProps?: DateTimePickerProps;
|
|
9
9
|
endPickerProps?: DateTimePickerProps;
|
|
@@ -25,4 +25,3 @@ export interface DateTimeRangePickerProps extends DatePickerSharedProps, Omit<Di
|
|
|
25
25
|
autoFocus?: boolean;
|
|
26
26
|
}
|
|
27
27
|
export declare const DateTimeRangePicker: import("react").MemoExoticComponent<({ startPickerProps, endPickerProps, format, defaultValue, value, onChange, defaultOpenPicker, openPicker, onOpenPickerChange, autoClose, separator, min, max, disabledDates, disabledHours, disabledMinutes, disabledSeconds, variant, size, color, disabled, readOnly, autoFocus, ...props }: DateTimeRangePickerProps) => import("@emotion/react/jsx-runtime").JSX.Element>;
|
|
28
|
-
export {};
|
|
@@ -24,4 +24,4 @@ export interface OverlayBaseProps extends DivProps {
|
|
|
24
24
|
removeFocusOnOpen?: boolean;
|
|
25
25
|
}
|
|
26
26
|
export declare const overlayBaseTransitionDuration = 300;
|
|
27
|
-
export declare function OverlayBase({ container, effectContainer, forceRender, open, onMaskClick, singleLayer, onOpened, onClosed, maskProps, removeFocusOnOpen, ...props }: OverlayBaseProps): false | React.ReactPortal | null;
|
|
27
|
+
export declare function OverlayBase({ container, effectContainer, forceRender, open, onMaskClick, singleLayer, onOpened, onClosed, maskProps, removeFocusOnOpen, ...props }: OverlayBaseProps): false | React.ReactPortal | null | undefined;
|
|
@@ -30,7 +30,7 @@ export declare const SnackbarBase: React.MemoExoticComponent<({ methods, useTo,
|
|
|
30
30
|
max?: number;
|
|
31
31
|
container?: DefineElement<HTMLElement>;
|
|
32
32
|
effectContainer?: DefineElement<HTMLElement>;
|
|
33
|
-
}) => React.ReactPortal | null>;
|
|
33
|
+
}) => React.ReactPortal | null | undefined>;
|
|
34
34
|
interface SnackbarBaseItemProps extends Omit<SnackbarBaseProps, 'duration' | 'onAutoClose'> {
|
|
35
35
|
id: string;
|
|
36
36
|
type: keyof SnackbarBaseMethods;
|
package/dist/esm/types.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ export type Size = 'small' | 'medium' | 'large';
|
|
|
21
21
|
export type CornerPlacement = 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight' | 'leftTop' | 'leftBottom' | 'rightTop' | 'rightBottom';
|
|
22
22
|
export type BlockPlacement = CornerPlacement | 'top' | 'bottom';
|
|
23
23
|
export type Placement = BlockPlacement | 'left' | 'right';
|
|
24
|
-
export type DefineElement<T = Element | null | undefined
|
|
24
|
+
export type DefineElement<T = Element> = T | null | undefined | (() => T | null | undefined);
|
|
25
25
|
/**
|
|
26
26
|
* ----------------------------------------------------------------------------------
|
|
27
27
|
* Responsive
|
|
@@ -51,7 +51,7 @@ export declare function useLoading<A extends any[], R>(fn: (...args: A) => R | P
|
|
|
51
51
|
* @param effectContainer
|
|
52
52
|
* @param defaultContainer 默认为`document.body`
|
|
53
53
|
*/
|
|
54
|
-
export declare function useContainer<T extends HTMLElement | null>(container?: DefineElement<T>, effectContainer?: DefineElement<T>, defaultContainer?: DefineElement<T>): RefObject<T | null>;
|
|
54
|
+
export declare function useContainer<T extends HTMLElement | null>(container?: DefineElement<T>, effectContainer?: DefineElement<T>, defaultContainer?: DefineElement<T>): RefObject<T | null | undefined>;
|
|
55
55
|
/**
|
|
56
56
|
* 使用外部类,该方法可避免`StrictMode`下,React渲染行为与外部类实例生命周期不同步的问题
|
|
57
57
|
*/
|
package/dist/esm/utils/hooks.js
CHANGED
|
@@ -111,7 +111,6 @@ export function useLoading(fn, referredLoading = false) {
|
|
|
111
111
|
return await res;
|
|
112
112
|
}
|
|
113
113
|
finally {
|
|
114
|
-
console.log(157, unmounted.current);
|
|
115
114
|
!unmounted.current && setLoading(false);
|
|
116
115
|
}
|
|
117
116
|
}
|
|
@@ -131,7 +130,7 @@ export function useContainer(container, effectContainer, defaultContainer) {
|
|
|
131
130
|
if (container) {
|
|
132
131
|
return typeof container === 'function' ? container() : container;
|
|
133
132
|
}
|
|
134
|
-
return prev
|
|
133
|
+
return prev;
|
|
135
134
|
}, [container]);
|
|
136
135
|
useEffect(() => {
|
|
137
136
|
let _container = effectContainer || defaultContainer;
|