@canlooks/can-ui 0.0.181 → 0.0.183

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 (41) hide show
  1. package/dist/cjs/components/clickAway/clickAway.d.ts +1 -1
  2. package/dist/cjs/components/clickAway/clickAway.js +2 -2
  3. package/dist/cjs/components/curd/curd.d.ts +5 -2
  4. package/dist/cjs/components/curd/curd.js +3 -3
  5. package/dist/cjs/components/curd/curdColumnConfig.d.ts +2 -0
  6. package/dist/cjs/components/curd/curdColumnConfig.js +3 -2
  7. package/dist/cjs/components/curd/curdResizable.d.ts +3 -1
  8. package/dist/cjs/components/curd/curdResizable.js +2 -2
  9. package/dist/cjs/components/dataGrid/dataGridHead.js +0 -1
  10. package/dist/cjs/components/dateTimeRangePicker/dateTimeRangePicker.js +4 -2
  11. package/dist/cjs/components/overlayBase/overlayBase.d.ts +1 -1
  12. package/dist/cjs/components/popper/popper.js +110 -97
  13. package/dist/cjs/components/popper/popper.style.d.ts +1 -1
  14. package/dist/cjs/components/popper/popper.style.js +28 -22
  15. package/dist/cjs/components/snackbarBase/snackbarBase.d.ts +1 -1
  16. package/dist/cjs/types.d.ts +1 -1
  17. package/dist/cjs/utils/hooks.d.ts +1 -1
  18. package/dist/cjs/utils/hooks.js +4 -2
  19. package/dist/cjs/utils/utils.d.ts +0 -5
  20. package/dist/cjs/utils/utils.js +0 -13
  21. package/dist/esm/components/clickAway/clickAway.d.ts +1 -1
  22. package/dist/esm/components/clickAway/clickAway.js +2 -2
  23. package/dist/esm/components/curd/curd.d.ts +5 -2
  24. package/dist/esm/components/curd/curd.js +3 -3
  25. package/dist/esm/components/curd/curdColumnConfig.d.ts +2 -0
  26. package/dist/esm/components/curd/curdColumnConfig.js +3 -2
  27. package/dist/esm/components/curd/curdResizable.d.ts +3 -1
  28. package/dist/esm/components/curd/curdResizable.js +2 -2
  29. package/dist/esm/components/dataGrid/dataGridHead.js +0 -1
  30. package/dist/esm/components/dateTimeRangePicker/dateTimeRangePicker.js +4 -2
  31. package/dist/esm/components/overlayBase/overlayBase.d.ts +1 -1
  32. package/dist/esm/components/popper/popper.js +110 -97
  33. package/dist/esm/components/popper/popper.style.d.ts +1 -1
  34. package/dist/esm/components/popper/popper.style.js +28 -22
  35. package/dist/esm/components/snackbarBase/snackbarBase.d.ts +1 -1
  36. package/dist/esm/types.d.ts +1 -1
  37. package/dist/esm/utils/hooks.d.ts +1 -1
  38. package/dist/esm/utils/hooks.js +4 -2
  39. package/dist/esm/utils/utils.d.ts +0 -5
  40. package/dist/esm/utils/utils.js +0 -12
  41. 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.addEventListener(standardEventType, onClick);
27
+ containerEl?.addEventListener(standardEventType, onClick);
28
28
  return () => {
29
- containerEl.removeEventListener(standardEventType, onClick);
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
- defaultSize?: Size;
73
- onSizeChange?(size: Size): void;
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, columnConfigurable = true, defaultSize = 'medium', onSizeChange, 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;
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, { css: curdColumnConfig_style_1.style, open: open, onOpenChange: openChangeHandler, placement: "bottomRight", trigger: ['hover', 'click'], 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
+ 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
  });
@@ -107,7 +107,6 @@ exports.DataGridHead = (0, react_2.memo)(({ allowSelectAll, columnResizable, fla
107
107
  : (0, jsx_runtime_1.jsx)(bubble_1.Bubble, { ...(0, utils_1.mergeComponentProps)({
108
108
  style: { maxWidth: 360 },
109
109
  trigger: 'click',
110
- placement: 'bottomRight',
111
110
  autoClose: false,
112
111
  content: ((0, jsx_runtime_1.jsx)(filterBubbleContent_1.FilterBubbleContent, { columnKey: _key, columnFilterProps: filter })),
113
112
  onClick: e => e.stopPropagation()
@@ -40,8 +40,10 @@ variant, size, color, disabled, readOnly, autoFocus, ...props }) => {
40
40
  onChange: value => {
41
41
  setInnerValue(o => [value, o?.[1] || null]);
42
42
  if (value && !showTimer) {
43
- endPickerInputRef.current.focus();
44
- innerOpen.current === 'start' && setInnerOpen('end');
43
+ requestAnimationFrame(() => {
44
+ endPickerInputRef.current.focus();
45
+ innerOpen.current === 'start' && setInnerOpen('end');
46
+ });
45
47
  }
46
48
  }
47
49
  }
@@ -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;
@@ -22,6 +22,20 @@ const getAttemptOrder = (placement) => {
22
22
  }
23
23
  return order;
24
24
  };
25
+ const splitPlacement = {
26
+ top: ['top'],
27
+ bottom: ['bottom'],
28
+ left: ['left'],
29
+ right: ['right'],
30
+ topLeft: ['top', 'left'],
31
+ topRight: ['top', 'right'],
32
+ bottomLeft: ['bottom', 'left'],
33
+ bottomRight: ['bottom', 'right'],
34
+ leftTop: ['left', 'top'],
35
+ leftBottom: ['left', 'bottom'],
36
+ rightTop: ['right', 'top'],
37
+ rightBottom: ['right', 'bottom']
38
+ };
25
39
  function Popper({ ref, popperRef, anchorElement, container, effectContainer, content, offset, trigger = 'hover', clickToClose, placement = 'top', variant = 'zoom', sizeAdaptable = variant === 'collapse', mouseEnterDelay = 150, mouseLeaveDelay = 150, defaultOpen = false, open, onOpenChange, onOpenChangeEnd, disabled, autoClose = false, forceRender, animation = true, children, ...props }) {
26
40
  const { spacing } = (0, theme_1.useTheme)();
27
41
  offset ??= spacing[2];
@@ -118,7 +132,7 @@ function Popper({ ref, popperRef, anchorElement, container, effectContainer, con
118
132
  const popperEl = innerPopperRef.current;
119
133
  let { offsetWidth: popperWidth, offsetHeight: popperHeight } = popperEl;
120
134
  let pA, pB;
121
- let left, top;
135
+ let top, bottom, left, right;
122
136
  let width, height;
123
137
  let originX, originY;
124
138
  let attempt;
@@ -127,69 +141,64 @@ function Popper({ ref, popperRef, anchorElement, container, effectContainer, con
127
141
  const mouseX = contextMenuEvent.current.clientX - containerRect.left;
128
142
  const mouseY = contextMenuEvent.current.clientY - containerRect.top;
129
143
  attempt = placement => {
130
- [, pA, pB] = placement.match(/^(top|bottom|left|right)(Top|Bottom|Left|Right)?/);
131
- if (pB) {
132
- switch (placement) {
133
- case 'topLeft':
134
- case 'leftTop':
135
- left = mouseX - popperWidth;
136
- top = mouseY - popperHeight;
137
- originX = '100%';
138
- originY = '100%';
139
- break;
140
- case 'topRight':
141
- case 'rightTop':
142
- left = mouseX;
143
- top = mouseY - popperHeight;
144
- originX = '0%';
145
- originY = '100%';
146
- break;
147
- case 'bottomLeft':
148
- case 'leftBottom':
149
- left = mouseX - popperWidth;
150
- top = mouseY;
151
- originX = '100%';
152
- originY = '0%';
153
- break;
154
- case 'bottomRight':
155
- case 'rightBottom':
156
- left = mouseX;
157
- top = mouseY;
158
- originX = '0%';
159
- originY = '0%';
160
- break;
161
- }
162
- }
163
- else {
164
- switch (pA) {
165
- case 'top':
166
- top = mouseY - popperHeight;
167
- originY = '100%';
168
- break;
169
- case 'bottom':
170
- top = mouseY;
171
- originY = '0%';
172
- break;
173
- case 'left':
174
- left = mouseX - popperWidth;
175
- originX = '100%';
176
- break;
177
- case 'right':
178
- left = mouseX;
179
- originX = '0%';
180
- break;
181
- }
182
- if (pA === 'top' || pA === 'bottom') {
144
+ switch (placement) {
145
+ case 'topLeft':
146
+ case 'leftTop':
147
+ bottom = -mouseY;
148
+ right = containerRect.width - mouseX;
149
+ originX = '100%';
150
+ originY = '100%';
151
+ break;
152
+ case 'topRight':
153
+ case 'rightTop':
154
+ bottom = -mouseY;
155
+ left = mouseX;
156
+ originX = '0%';
157
+ originY = '100%';
158
+ break;
159
+ case 'bottomLeft':
160
+ case 'leftBottom':
161
+ top = mouseY;
162
+ right = containerRect.width - mouseX;
163
+ originX = '100%';
164
+ originY = '0%';
165
+ break;
166
+ case 'bottomRight':
167
+ case 'rightBottom':
168
+ top = mouseY;
169
+ left = mouseX;
170
+ originX = '0%';
171
+ originY = '0%';
172
+ break;
173
+ case 'top':
174
+ top = mouseY - popperHeight;
183
175
  left = mouseX - popperWidth / 2;
184
176
  originX = '50%';
185
- }
186
- else {
177
+ originY = '100%';
178
+ break;
179
+ case 'bottom':
180
+ top = mouseY;
181
+ left = mouseX - popperWidth / 2;
182
+ originX = '50%';
183
+ originY = '0%';
184
+ break;
185
+ case 'left':
187
186
  top = mouseY - popperHeight / 2;
187
+ left = mouseX - popperWidth;
188
+ originX = '100%';
188
189
  originY = '50%';
189
- }
190
+ break;
191
+ case 'right':
192
+ top = mouseY - popperHeight / 2;
193
+ left = mouseX;
194
+ originX = '0%';
195
+ originY = '50%';
196
+ break;
190
197
  }
191
- popperEl.style.left = left + 'px';
192
- popperEl.style.top = top + 'px';
198
+ popperEl.style.top = typeof top === 'undefined' ? '' : top + 'px';
199
+ popperEl.style.bottom = typeof bottom === 'undefined' ? '' : bottom + 'px';
200
+ popperEl.style.left = typeof left === 'undefined' ? '' : left + 'px';
201
+ popperEl.style.right = typeof right === 'undefined' ? '' : right + 'px';
193
202
  return (0, utils_1.isElementOverflowed)(popperEl, containerEl.current === document.body ? void 0 : containerEl.current);
194
203
  };
195
204
  }
@@ -197,9 +206,11 @@ function Popper({ ref, popperRef, anchorElement, container, effectContainer, con
197
206
  // 非右键菜单
198
207
  const anchorRect = getAnchorElement().getBoundingClientRect();
199
208
  const topEdge = anchorRect.top - containerRect.top;
209
+ const bottomEdge = anchorRect.bottom - containerRect.top;
200
210
  const leftEdge = anchorRect.left - containerRect.left;
211
+ const rightEdge = containerRect.left + containerRect.width - anchorRect.right;
201
212
  attempt = placement => {
202
- [, pA, pB] = placement.match(/^(top|bottom|left|right)(Top|Bottom|Left|Right)?/);
213
+ [pA, pB] = splitPlacement[placement];
203
214
  if (sizeAdaptable) {
204
215
  if (pA === 'top' || pA === 'bottom') {
205
216
  width = popperWidth = anchorRect.width;
@@ -217,39 +228,48 @@ function Popper({ ref, popperRef, anchorElement, container, effectContainer, con
217
228
  }
218
229
  switch (pA) {
219
230
  case 'top':
220
- top = topEdge - popperHeight - offset;
231
+ top = void 0;
232
+ bottom = -(topEdge - offset);
221
233
  originY = '100%';
222
234
  break;
223
235
  case 'bottom':
224
- top = topEdge + anchorRect.height + offset;
236
+ bottom = void 0;
237
+ top = bottomEdge + offset;
225
238
  originY = '0%';
226
239
  break;
227
240
  case 'left':
228
- left = leftEdge - popperWidth - offset;
241
+ left = void 0;
242
+ right = leftEdge - offset;
229
243
  originX = '100%';
230
244
  break;
231
245
  case 'right':
232
- left = leftEdge + anchorRect.width + offset;
246
+ right = void 0;
247
+ left = rightEdge + offset;
233
248
  originX = '0%';
234
249
  }
235
250
  switch (pB) {
236
- case 'Left':
251
+ case 'left':
237
252
  left = leftEdge;
253
+ right = void 0;
238
254
  originX = '0%';
239
255
  break;
240
- case 'Right':
241
- left = leftEdge - popperWidth + anchorRect.width;
256
+ case 'right':
257
+ left = void 0;
258
+ right = rightEdge;
242
259
  originX = '100%';
243
260
  break;
244
- case 'Top':
261
+ case 'top':
245
262
  top = topEdge;
263
+ bottom = void 0;
246
264
  originY = '0%';
247
265
  break;
248
- case 'Bottom':
249
- top = topEdge - popperHeight + anchorRect.height;
266
+ case 'bottom':
267
+ top = void 0;
268
+ bottom = bottomEdge;
250
269
  originY = '100%';
251
270
  break;
252
271
  default:
272
+ // pB === undefined
253
273
  if (pA === 'top' || pA === 'bottom') {
254
274
  left = leftEdge + (anchorRect.width - popperWidth) / 2;
255
275
  originX = '50%';
@@ -259,8 +279,12 @@ function Popper({ ref, popperRef, anchorElement, container, effectContainer, con
259
279
  originY = '50%';
260
280
  }
261
281
  }
262
- popperEl.style.left = left + 'px';
263
- popperEl.style.top = top + 'px';
282
+ popperEl.style.top = typeof top === 'undefined' ? '' : top + 'px';
283
+ popperEl.style.bottom = typeof bottom === 'undefined' ? '' : bottom + 'px';
284
+ popperEl.style.left = typeof left === 'undefined' ? '' : left + 'px';
285
+ popperEl.style.right = typeof right === 'undefined' ? '' : right + 'px';
286
+ popperEl.style.width = typeof width === 'undefined' ? '' : width + 'px';
287
+ popperEl.style.height = typeof height === 'undefined' ? '' : height + 'px';
264
288
  return (0, utils_1.isElementOverflowed)(popperEl, containerEl.current === document.body ? void 0 : containerEl.current);
265
289
  };
266
290
  }
@@ -270,40 +294,29 @@ function Popper({ ref, popperRef, anchorElement, container, effectContainer, con
270
294
  else {
271
295
  const attemptOrder = getAttemptOrder(placement);
272
296
  for (let i = 0; i < attemptOrder.length; i++) {
273
- if (attempt(attemptOrder[i]) === false) {
297
+ const t = attempt(attemptOrder[i]);
298
+ if (t === false) {
274
299
  break;
275
300
  }
276
301
  }
277
302
  }
303
+ beforeOpen?.();
278
304
  const settle = () => {
279
305
  setPopperBounding({
280
- left, top, width, height,
306
+ top, bottom, left, right, width, height,
281
307
  transformOrigin: `${originX} ${originY}`
282
308
  });
283
309
  placeA.current = pA;
284
310
  placeB.current = pB;
285
311
  };
286
- if (beforeOpen) {
287
- if (sizeAdaptable) {
288
- // 自适应尺寸需要在打开前设置
289
- popperEl.style.width = width ? width + 'px' : '';
290
- popperEl.style.height = height ? height + 'px' : '';
291
- }
292
- beforeOpen();
293
- }
294
312
  if (options?.openAnimation) {
295
313
  popperEl.style.transform = variant === 'collapse'
296
314
  ? pA === 'top' || pA === 'bottom' ? 'scaleY(0)' : 'scaleX(0)'
297
315
  : 'scale(0)';
298
316
  animating.current = true;
299
- requestAnimationFrame(() => {
300
- settle();
301
- setOpenNextFrame(true);
302
- });
303
- }
304
- else {
305
- settle();
317
+ setOpenNextFrame(true);
306
318
  }
319
+ settle();
307
320
  };
308
321
  (0, react_1.useLayoutEffect)(() => {
309
322
  if (innerOpen.current) {
@@ -539,12 +552,12 @@ function Popper({ ref, popperRef, anchorElement, container, effectContainer, con
539
552
  })
540
553
  : children, renderedOnce.current && containerEl.current && (0, react_dom_1.createPortal)((0, jsx_runtime_1.jsx)(clickAway_1.ClickAway, { disabled: !clickable && !enterable && !contextMenuable,
541
554
  // 右键菜单点击anchor需要关闭弹框
542
- targets: () => contextMenuEvent.current ? void 0 : getAnchorElement(), onClickAway: onClickAway, children: (0, jsx_runtime_1.jsx)("div", { ...props, ref: innerPopperRef, css: popper_style_1.style, className: (0, utils_1.clsx)(popper_style_1.classes.root, props.className), style: {
543
- ...popperBounding,
544
- ...!openNextFrame.current && {
545
- transition: 'none',
546
- transform: 'scale(1)'
547
- },
548
- ...props.style
549
- }, "data-open": innerOpen.current, "data-variant": variant, "data-place-a": placeA.current, "data-place-b": placeB.current, "data-animation": animation, onTransitionEnd: onTransitionEnd, children: (0, jsx_runtime_1.jsx)(popperContext_1.PopperContext, { value: contextValue, children: content }) }) }), containerEl.current)] }));
555
+ targets: () => contextMenuEvent.current ? void 0 : getAnchorElement(), onClickAway: onClickAway, children: (0, jsx_runtime_1.jsx)("div", { css: popper_style_1.style, className: popper_style_1.classes.placeHelper, children: (0, jsx_runtime_1.jsx)("div", { ...props, ref: innerPopperRef, className: (0, utils_1.clsx)(popper_style_1.classes.root, props.className), style: {
556
+ ...popperBounding,
557
+ ...!openNextFrame.current && {
558
+ transition: 'none',
559
+ transform: 'scale(1)'
560
+ },
561
+ ...props.style
562
+ }, "data-open": innerOpen.current, "data-variant": variant, "data-place-a": placeA.current, "data-place-b": placeB.current, "data-animation": animation, onTransitionEnd: onTransitionEnd, children: (0, jsx_runtime_1.jsx)(popperContext_1.PopperContext, { value: contextValue, children: content }) }) }) }), containerEl.current)] }));
550
563
  }
@@ -1,6 +1,6 @@
1
1
  import { Theme } from '../theme';
2
2
  export declare const classes: {
3
- popper: string;
3
+ placeHelper: string;
4
4
  } & {
5
5
  root: string;
6
6
  };
@@ -6,7 +6,7 @@ const utils_1 = require("../../utils");
6
6
  const app_style_1 = require("../app/app.style");
7
7
  const theme_1 = require("../theme");
8
8
  exports.classes = (0, utils_1.defineInnerClasses)('popper', [
9
- 'popper',
9
+ 'placeHelper'
10
10
  ]);
11
11
  exports.style = (0, utils_1.defineCss)(theme => {
12
12
  const { easing } = theme;
@@ -14,37 +14,43 @@ exports.style = (0, utils_1.defineCss)(theme => {
14
14
  (0, app_style_1.appStyleCallback)(theme),
15
15
  (0, react_1.css) `
16
16
  @layer reset {
17
+ width: 100%;
18
+ height: 0;
17
19
  position: absolute;
18
20
  top: 0;
19
21
  left: 0;
20
- z-index: ${theme_1.zIndex.popper};
21
- transition-property: transform, opacity;
22
22
 
23
- &[data-animation=true] {
24
- transition-duration: .25s;
25
- }
26
-
27
- &[data-open=true] {
28
- transition-timing-function: ${easing.bounce}, ${easing.easeOut};
29
- opacity: 1;
30
- transform: scale(1);
31
- }
23
+ .${exports.classes.root} {
24
+ position: absolute;
25
+ z-index: ${theme_1.zIndex.popper};
26
+ transition-property: transform, opacity;
32
27
 
33
- &:not([data-open=true]) {
34
- transition-timing-function: ${easing.easeIn};
35
- opacity: 0;
28
+ &[data-animation=true] {
29
+ transition-duration: .25s;
30
+ }
36
31
 
37
- &[data-variant=zoom] {
38
- transform: scale(0);
32
+ &[data-open=true] {
33
+ transition-timing-function: ${easing.bounce}, ${easing.easeOut};
34
+ opacity: 1;
35
+ transform: scale(1);
39
36
  }
40
37
 
41
- &[data-variant=collapse] {
42
- &[data-place-a=top], &[data-place-a=bottom] {
43
- transform: scaleY(0);
38
+ &:not([data-open=true]) {
39
+ transition-timing-function: ${easing.easeIn};
40
+ opacity: 0;
41
+
42
+ &[data-variant=zoom] {
43
+ transform: scale(0);
44
44
  }
45
45
 
46
- &[data-place-a=left], &[data-place-a=right] {
47
- transform: scaleX(0);
46
+ &[data-variant=collapse] {
47
+ &[data-place-a=top], &[data-place-a=bottom] {
48
+ transform: scaleY(0);
49
+ }
50
+
51
+ &[data-place-a=left], &[data-place-a=right] {
52
+ transform: scaleX(0);
53
+ }
48
54
  }
49
55
  }
50
56
  }
@@ -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;
@@ -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> = T | (() => T);
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
  */
@@ -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,10 @@ function useContainer(container, effectContainer, defaultContainer) {
146
145
  if (container) {
147
146
  return typeof container === 'function' ? container() : container;
148
147
  }
149
- return prev || null;
148
+ if (!prev && typeof document !== 'undefined') {
149
+ return document.body;
150
+ }
151
+ return prev;
150
152
  }, [container]);
151
153
  (0, react_1.useEffect)(() => {
152
154
  let _container = effectContainer || defaultContainer;
@@ -50,11 +50,6 @@ export type OverflowEdge = 'top' | 'bottom' | 'left' | 'right';
50
50
  * @returns 'top' | 'bottom' | 'left' | 'right' | false
51
51
  */
52
52
  export declare function isElementOverflowed(target: Element, container?: Element): OverflowEdge | false;
53
- /**
54
- * 下一个事件循环
55
- * @param callback
56
- */
57
- export declare function nextTick(callback?: () => void): Promise<void>;
58
53
  /**
59
54
  * 克隆Ref
60
55
  * @param refs