@canlooks/can-ui 0.0.81 → 0.0.83

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.
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CascadePanel = CascadePanel;
4
+ const react_1 = require("@emotion/react");
4
5
  const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
5
6
  const loading_1 = require("../loading");
6
7
  const loadingIndicator_1 = require("../loadingIndicator");
@@ -39,9 +40,8 @@ function CascadePanel({ options, index = 0 }) {
39
40
  const status = selectionStatus?.get(optVal);
40
41
  const opened = openedPanels[index] === optVal;
41
42
  const hasChildren = !!opt[childrenKey]?.length;
42
- return ((0, jsx_runtime_1.jsx)(menuItem_1.MenuItem, { ...(0, utils_1.mergeComponentProps)({
43
- showCheckbox,
44
- key: optVal
43
+ return ((0, react_1.createElement)(menuItem_1.MenuItem, { ...(0, utils_1.mergeComponentProps)({
44
+ showCheckbox
45
45
  }, opt, {
46
46
  checkboxProps: (0, utils_1.mergeComponentProps)(opt?.checkboxProps, showCheckbox
47
47
  ? {
@@ -62,7 +62,7 @@ function CascadePanel({ options, index = 0 }) {
62
62
  ? (0, jsx_runtime_1.jsx)(loadingIndicator_1.LoadingIndicator, {})
63
63
  : hasChildren && (0, jsx_runtime_1.jsx)(icon_1.Icon, { icon: faChevronRight_1.faChevronRight }),
64
64
  children: null
65
- }) }));
65
+ }), key: optVal }));
66
66
  });
67
67
  };
68
68
  const nextOptions = optionsMap.get(openedPanels[index])?.[childrenKey];
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DataGridRows = void 0;
4
- const react_1 = require("@emotion/react");
5
4
  const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
5
+ const react_1 = require("@emotion/react");
6
6
  const react_2 = require("react");
7
7
  const dataGrid_1 = require("./dataGrid");
8
8
  const selectionContext_1 = require("../selectionContext");
@@ -33,43 +33,42 @@ exports.DataGridRows = (0, react_2.memo)(({ rows, _level = 0 }) => {
33
33
  const currentExpanded = expandable && expandedSet.has(trKey);
34
34
  let expandableIndex = -2;
35
35
  const ret = [
36
- (0, jsx_runtime_1.jsx)(Tr, { ...(0, utils_1.mergeComponentProps)(TrProps, _rowProps, {
37
- key: trKey,
36
+ (0, react_1.createElement)(Tr, { ...(0, utils_1.mergeComponentProps)(TrProps, _rowProps, {
38
37
  className: (0, utils_1.clsx)(_rowProps, _level > 0 && dataGrid_style_1.classes.sub),
39
38
  onClick() {
40
39
  clickRowToSelect && toggleSelected(trKey, row);
41
40
  }
42
- }), "data-selected": status === 2, children: flattedColumns?.flatMap((col, j) => {
43
- if (typeof col === 'symbol') {
44
- if (col === dataGrid_1.DataGrid.EXPAND_COLUMN) {
45
- expandableIndex = j;
46
- return [];
47
- }
48
- // col === DataGrid.SELECT_COLUMN
49
- if (expandableIndex === j - 1) {
50
- // select column紧跟在expand column后面,需要顺延expandableIndex
51
- expandableIndex = j;
52
- }
53
- const Component = multiple ? checkbox_1.Checkbox : radio_1.Radio;
54
- return ((0, jsx_runtime_1.jsx)(table_1.TdCell, { className: dataGrid_style_1.classes.selectable, sticky: j === 0 ? 'left' : void 0, children: (0, jsx_runtime_1.jsx)(Component, { checked: status === 2, indeterminate: status === 1, onChange: () => {
55
- toggleSelected(trKey, row);
56
- }, onClick: e => e.stopPropagation() }) }, j + '_selectable'));
41
+ }), key: trKey, "data-selected": status === 2 }, flattedColumns?.flatMap((col, j) => {
42
+ if (typeof col === 'symbol') {
43
+ if (col === dataGrid_1.DataGrid.EXPAND_COLUMN) {
44
+ expandableIndex = j;
45
+ return [];
46
+ }
47
+ // col === DataGrid.SELECT_COLUMN
48
+ if (expandableIndex === j - 1) {
49
+ // select column紧跟在expand column后面,需要顺延expandableIndex
50
+ expandableIndex = j;
57
51
  }
58
- const {
59
- // 排除无需加入dom节点的属性
60
- // width属性只需加入thead列中,普通列需排除
61
- // rowSpan与colSpan需排除
62
- title, key, children, sticky, field, render, sorter, filter, width, _key, _negativeRowSpan, rowSpan, colSpan, ..._colProps } = col;
63
- const renderedContent = (0, utils_1.renderCell)({ render, field }, row, i, arr);
64
- const shouldRenderExpand = expandableIndex === j - 1;
65
- return ((0, react_1.createElement)(table_1.TdCell, { ..._colProps, key: _key, className: shouldRenderExpand ? dataGrid_style_1.classes.expandable : void 0, sticky: sticky }, shouldRenderExpand
66
- ? (0, jsx_runtime_1.jsxs)("div", { className: dataGrid_style_1.classes.expandableWrap, style: { paddingLeft: _level * indent }, children: [(0, jsx_runtime_1.jsx)(button_1.Button, { variant: "text", shape: "circular", color: "text.disabled", onClick: () => toggleExpanded(trKey), style: expandable ? void 0 : { visibility: 'hidden' }, children: renderExpandIcon
67
- ? renderExpandIcon(trKey, currentExpanded, [...expandedSet])
68
- : currentExpanded
69
- ? (0, jsx_runtime_1.jsx)(icon_1.Icon, { icon: faMinusSquare_1.faMinusSquare })
70
- : (0, jsx_runtime_1.jsx)(icon_1.Icon, { icon: faPlusSquare_1.faPlusSquare }) }), renderedContent] })
71
- : renderedContent));
72
- }) })
52
+ const Component = multiple ? checkbox_1.Checkbox : radio_1.Radio;
53
+ return ((0, jsx_runtime_1.jsx)(table_1.TdCell, { className: dataGrid_style_1.classes.selectable, sticky: j === 0 ? 'left' : void 0, children: (0, jsx_runtime_1.jsx)(Component, { checked: status === 2, indeterminate: status === 1, onChange: () => {
54
+ toggleSelected(trKey, row);
55
+ }, onClick: e => e.stopPropagation() }) }, j + '_selectable'));
56
+ }
57
+ const {
58
+ // 排除无需加入dom节点的属性
59
+ // width属性只需加入thead列中,普通列需排除
60
+ // rowSpan与colSpan需排除
61
+ title, key, children, sticky, field, render, sorter, filter, width, _key, _negativeRowSpan, rowSpan, colSpan, ..._colProps } = col;
62
+ const renderedContent = (0, utils_1.renderCell)({ render, field }, row, i, arr);
63
+ const shouldRenderExpand = expandableIndex === j - 1;
64
+ return ((0, react_1.createElement)(table_1.TdCell, { ..._colProps, key: _key, className: shouldRenderExpand ? dataGrid_style_1.classes.expandable : void 0, sticky: sticky }, shouldRenderExpand
65
+ ? (0, jsx_runtime_1.jsxs)("div", { className: dataGrid_style_1.classes.expandableWrap, style: { paddingLeft: _level * indent }, children: [(0, jsx_runtime_1.jsx)(button_1.Button, { variant: "text", shape: "circular", color: "text.disabled", onClick: () => toggleExpanded(trKey), style: expandable ? void 0 : { visibility: 'hidden' }, children: renderExpandIcon
66
+ ? renderExpandIcon(trKey, currentExpanded, [...expandedSet])
67
+ : currentExpanded
68
+ ? (0, jsx_runtime_1.jsx)(icon_1.Icon, { icon: faMinusSquare_1.faMinusSquare })
69
+ : (0, jsx_runtime_1.jsx)(icon_1.Icon, { icon: faPlusSquare_1.faPlusSquare }) }), renderedContent] })
70
+ : renderedContent));
71
+ }))
73
72
  ];
74
73
  if (Array.isArray(children)) {
75
74
  currentExpanded && ret.push((0, jsx_runtime_1.jsx)(exports.DataGridRows, { rows: children, _level: _level + 1 }, trKey + '_children'));
@@ -25,12 +25,18 @@ export interface DialogProps extends Omit<ModalProps, 'title' | 'prefix'> {
25
25
  cancelText?: ReactNode;
26
26
  cancelProps?: ButtonProps;
27
27
  onCancel?(e: React.MouseEvent<HTMLButtonElement | HTMLDivElement> | KeyboardEvent): void;
28
+ /**
29
+ * 滚动的行为,默认为`card`
30
+ * @enum 'card' 卡片内部滚动
31
+ * @enum 'body' 对话框整体滚动
32
+ */
33
+ scrollBehavior?: 'card' | 'body';
28
34
  draggable?: boolean;
29
- /** 是否可通过点击遮罩层关闭对话框,默认为true */
35
+ /** 是否可通过点击遮罩层关闭对话框,默认为`true` */
30
36
  maskClosable?: boolean;
31
- /** 是否可通过键盘的【ESC】键关闭对话框,默认为true */
37
+ /** 是否可通过键盘的【ESC】键关闭对话框,默认为`true` */
32
38
  escapeClosable?: boolean;
33
39
  defaultOpen?: boolean;
34
40
  onClose?(closeReason: DialogCloseReason): void;
35
41
  }
36
- export declare function Dialog({ icon, title, footer, prefix, suffix, width, minWidth, maxWidth, showClose, closeProps, showConfirm, confirmText, confirmProps, onConfirm, confirmLoading, showCancel, cancelText, cancelProps, onCancel, draggable, maskClosable, escapeClosable, defaultOpen, open, onClose, ...props }: DialogProps): import("@emotion/react/jsx-runtime").JSX.Element;
42
+ export declare function Dialog({ icon, title, footer, prefix, suffix, width, minWidth, maxWidth, showClose, closeProps, showConfirm, confirmText, confirmProps, onConfirm, confirmLoading, showCancel, cancelText, cancelProps, onCancel, scrollBehavior, draggable, maskClosable, escapeClosable, defaultOpen, open, onClose, ...props }: DialogProps): import("@emotion/react/jsx-runtime").JSX.Element;
@@ -10,7 +10,7 @@ const button_1 = require("../button");
10
10
  const draggable_1 = require("../draggable");
11
11
  const icon_1 = require("../icon");
12
12
  const faXmark_1 = require("@fortawesome/free-solid-svg-icons/faXmark");
13
- function Dialog({ icon, title, footer, prefix, suffix, width = 420, minWidth, maxWidth = '100%', showClose = true, closeProps, showConfirm = true, confirmText = '确 定', confirmProps, onConfirm, confirmLoading = false, showCancel = true, cancelText = '取 消', cancelProps, onCancel, draggable = true, maskClosable = true, escapeClosable = true, defaultOpen = false, open, onClose, ...props }) {
13
+ function Dialog({ icon, title, footer, prefix, suffix, width = 420, minWidth, maxWidth = '100%', showClose = true, closeProps, showConfirm = true, confirmText = '确 定', confirmProps, onConfirm, confirmLoading = false, showCancel = true, cancelText = '取 消', cancelProps, onCancel, scrollBehavior = 'card', draggable = true, maskClosable = true, escapeClosable = true, defaultOpen = false, open, onClose, ...props }) {
14
14
  const [innerOpen, _setInnerOpen] = (0, utils_1.useControlled)(defaultOpen, open);
15
15
  const close = (closeReason) => {
16
16
  if (!innerLoading.current || closeReason === 'confirmed') {
@@ -81,7 +81,7 @@ function Dialog({ icon, title, footer, prefix, suffix, width = 420, minWidth, ma
81
81
  }
82
82
  return footer;
83
83
  };
84
- return ((0, jsx_runtime_1.jsx)(modal_1.Modal, { ...props, ref: (0, utils_1.cloneRef)(overlayRef, props.ref), css: dialog_style_1.style, className: (0, utils_1.clsx)(dialog_style_1.classes.root, props.className), open: innerOpen.current, onMaskClick: onMaskClick, "data-draggable": draggable, children: (0, jsx_runtime_1.jsx)(draggable_1.Draggable, { container: () => overlayRef.current, children: (targetProps, handleProps) => (0, jsx_runtime_1.jsxs)("div", { className: dialog_style_1.classes.card, ...targetProps, style: { width, minWidth, maxWidth, ...targetProps.style }, children: [!!icon &&
84
+ return ((0, jsx_runtime_1.jsx)(modal_1.Modal, { ...props, ref: (0, utils_1.cloneRef)(overlayRef, props.ref), css: dialog_style_1.style, className: (0, utils_1.clsx)(dialog_style_1.classes.root, props.className), open: innerOpen.current, onMaskClick: onMaskClick, "data-scroll-behavior": scrollBehavior, "data-draggable": draggable, children: (0, jsx_runtime_1.jsx)(draggable_1.Draggable, { container: () => overlayRef.current, children: (targetProps, handleProps) => (0, jsx_runtime_1.jsxs)("div", { className: dialog_style_1.classes.card, ...targetProps, style: { width, minWidth, maxWidth, ...targetProps.style }, children: [!!icon &&
85
85
  (0, jsx_runtime_1.jsx)("div", { className: dialog_style_1.classes.icon, children: icon }), (0, jsx_runtime_1.jsxs)("div", { className: dialog_style_1.classes.content, children: [!!(title || showClose) &&
86
86
  (0, jsx_runtime_1.jsxs)("div", { className: dialog_style_1.classes.titleRow, ...handleProps, children: [(0, jsx_runtime_1.jsx)("div", { className: dialog_style_1.classes.title, children: title }), showClose &&
87
87
  (0, jsx_runtime_1.jsx)(button_1.Button, { shape: "circular", variant: "text", color: "text.secondary", ...closeProps, className: (0, utils_1.clsx)(dialog_style_1.classes.close, closeProps?.className), onClick: closeHandler, children: (0, jsx_runtime_1.jsx)(icon_1.Icon, { icon: faXmark_1.faXmark }) })] }), (0, jsx_runtime_1.jsxs)("div", { ref: bodyRef, className: dialog_style_1.classes.body, onScroll: onScroll, children: [!!prefix &&
@@ -3,6 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.style = exports.classes = void 0;
4
4
  const react_1 = require("@emotion/react");
5
5
  const utils_1 = require("../../utils");
6
+ const modal_style_1 = require("../modal/modal.style");
7
+ const overlayBase_style_1 = require("../overlayBase/overlayBase.style");
6
8
  exports.classes = (0, utils_1.defineInnerClasses)('dialog', [
7
9
  'card',
8
10
  'icon',
@@ -18,13 +20,36 @@ exports.classes = (0, utils_1.defineInnerClasses)('dialog', [
18
20
  ]);
19
21
  exports.style = (0, utils_1.defineCss)(({ background, borderRadius, boxShadow, spacing, colors, divider }) => (0, react_1.css) `
20
22
  .${exports.classes.card} {
21
- max-height: 100%;
22
23
  display: flex;
23
24
  background-color: ${background.content};
24
25
  border-radius: ${borderRadius}px;
25
26
  box-shadow: ${boxShadow[0]};
26
27
  }
27
28
 
29
+ .${modal_style_1.classes.childrenWrap} {
30
+ padding: 40px;
31
+ }
32
+
33
+ &[data-scroll-behavior=card] {
34
+ .${modal_style_1.classes.childrenWrap} {
35
+ height: 100%;
36
+ }
37
+
38
+ .${exports.classes.card} {
39
+ max-height: 100%;
40
+ }
41
+ }
42
+
43
+ &[data-scroll-behavior=body] {
44
+ .${modal_style_1.classes.modal} {
45
+ height: auto;
46
+ }
47
+
48
+ .${overlayBase_style_1.classes.childrenWrap} {
49
+ overflow: hidden auto;
50
+ }
51
+ }
52
+
28
53
  .${exports.classes.icon} {
29
54
  color: ${colors.primary.main};
30
55
  font-size: ${21 / 14}em;
@@ -51,7 +76,7 @@ exports.style = (0, utils_1.defineCss)(({ background, borderRadius, boxShadow, s
51
76
  font-size: ${16 / 14}em;
52
77
  font-weight: bold;
53
78
  margin-right: -${spacing[8]}px;
54
-
79
+
55
80
  .${exports.classes.title} {
56
81
  flex: 1;
57
82
  padding: ${spacing[6]}px 0 ${spacing[3]}px;
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.style = exports.classes = void 0;
4
4
  const react_1 = require("@emotion/react");
5
5
  const utils_1 = require("../../utils");
6
- const modal_style_1 = require("../modal/modal.style");
7
6
  exports.classes = (0, utils_1.defineInnerClasses)('image-preview', [
8
7
  'button',
9
8
  'control',
@@ -69,10 +68,6 @@ exports.style = (0, utils_1.defineCss)(({ spacing, easing, breakpoints }) => (0,
69
68
  }
70
69
  }
71
70
 
72
- .${modal_style_1.classes.modal} {
73
- padding: 0;
74
- }
75
-
76
71
  .${exports.classes.galleryContainer} {
77
72
  &, .${exports.classes.galleryWrapper}, .${exports.classes.imageItem}, .${exports.classes.image} {
78
73
  width: 100%;
@@ -22,5 +22,5 @@ function Modal({ modalProps, ...props }) {
22
22
  return ((0, jsx_runtime_1.jsx)(overlayBase_1.OverlayBase, { ...props, css: modal_style_1.style, className: (0, utils_1.clsx)(modal_style_1.classes.root, props.className), children: (0, jsx_runtime_1.jsx)(transitionBase_1.Grow, { timeout: overlayBase_1.overlayBaseTransitionDuration, ...modalProps, in: props.open, className: (0, utils_1.clsx)(modal_style_1.classes.modal, modalProps?.className), style: {
23
23
  transformOrigin: transformOrigin.current,
24
24
  ...modalProps?.style
25
- }, children: props.children }) }));
25
+ }, children: (0, jsx_runtime_1.jsx)("div", { className: modal_style_1.classes.childrenWrap, onClick: e => e.stopPropagation(), children: props.children }) }) }));
26
26
  }
@@ -1,4 +1,5 @@
1
1
  export declare const classes: {
2
+ childrenWrap: string;
2
3
  modal: string;
3
4
  } & {
4
5
  root: string;
@@ -4,20 +4,15 @@ exports.style = exports.classes = void 0;
4
4
  const react_1 = require("@emotion/react");
5
5
  const utils_1 = require("../../utils");
6
6
  exports.classes = (0, utils_1.defineInnerClasses)('modal', [
7
- 'modal'
7
+ 'modal',
8
+ 'childrenWrap'
8
9
  ]);
9
10
  exports.style = (0, react_1.css) `
10
11
  .${exports.classes.modal} {
11
12
  width: 100%;
12
13
  height: 100%;
13
- padding: 40px;
14
- pointer-events: none;
15
14
  display: flex;
16
15
  align-items: center;
17
16
  justify-content: center;
18
-
19
- > * {
20
- pointer-events: all;
21
- }
22
17
  }
23
18
  `;
@@ -37,11 +37,11 @@ function OverlayBase({ container, effectContainer, forceRender, open, onMaskClic
37
37
  onClosed?.();
38
38
  forceRender === false && setShouldRender(false);
39
39
  };
40
- return shouldRender.current && (0, react_dom_1.createPortal)((0, jsx_runtime_1.jsxs)("div", { ...props, css: overlayBase_style_1.style, className: (0, utils_1.clsx)(overlayBase_style_1.classes.root, props.className), "data-open": open, "data-custom-container": containerEl.current !== document.body, children: [(0, jsx_runtime_1.jsx)(transitionBase_1.Fade, { timeout: exports.overlayBaseTransitionDuration, ...(0, utils_1.mergeComponentProps)(maskProps, {
41
- in: open,
42
- className: overlayBase_style_1.classes.mask,
43
- onClick,
44
- onEntered,
45
- onExited
46
- }) }), props.children] }), containerEl.current);
40
+ return shouldRender.current && (0, react_dom_1.createPortal)((0, jsx_runtime_1.jsx)("div", { ...props, css: overlayBase_style_1.style, className: (0, utils_1.clsx)(overlayBase_style_1.classes.root, props.className), "data-open": open, "data-custom-container": containerEl.current !== document.body, children: (0, jsx_runtime_1.jsx)(transitionBase_1.Fade, { timeout: exports.overlayBaseTransitionDuration, ...(0, utils_1.mergeComponentProps)(maskProps, {
41
+ in: open,
42
+ className: overlayBase_style_1.classes.mask,
43
+ onClick,
44
+ onEntered,
45
+ onExited
46
+ }), children: (0, jsx_runtime_1.jsx)("div", { className: overlayBase_style_1.classes.childrenWrap, children: props.children }) }) }), containerEl.current);
47
47
  }
@@ -1,5 +1,6 @@
1
1
  export declare const classes: {
2
2
  mask: string;
3
+ childrenWrap: string;
3
4
  } & {
4
5
  root: string;
5
6
  };
@@ -6,29 +6,35 @@ 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)('overlay-base', [
9
- 'mask'
9
+ 'mask',
10
+ 'childrenWrap'
10
11
  ]);
11
12
  exports.style = (0, utils_1.defineCss)(theme => {
12
13
  return [
13
14
  (0, app_style_1.appStyleCallback)(theme),
14
15
  (0, react_1.css) `
15
- position: fixed;
16
- inset: 0;
17
- z-index: ${theme_1.zIndex.overlay};
18
-
19
- &[data-custom-container=true] {
20
- position: absolute;
21
- }
22
-
23
- .${exports.classes.mask} {
24
- background-color: rgba(0, 0, 0, .5);
25
- position: absolute;
16
+ position: fixed;
26
17
  inset: 0;
27
- }
18
+ z-index: ${theme_1.zIndex.overlay};
19
+
20
+ &[data-custom-container=true] {
21
+ position: absolute;
22
+ }
23
+
24
+ .${exports.classes.mask} {
25
+ background-color: rgba(0, 0, 0, .5);
26
+ position: absolute;
27
+ inset: 0;
28
+ }
28
29
 
29
- &:not([data-open=true]) {
30
- pointer-events: none;
31
- }
32
- `
30
+ &:not([data-open=true]) {
31
+ pointer-events: none;
32
+ }
33
+
34
+ .${exports.classes.childrenWrap} {
35
+ height: 100%;
36
+ position: relative;
37
+ }
38
+ `
33
39
  ];
34
40
  });
@@ -1,3 +1,4 @@
1
+ import { createElement as _createElement } from "@emotion/react";
1
2
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
3
  import { Loading } from '../loading';
3
4
  import { LoadingIndicator } from '../loadingIndicator';
@@ -36,9 +37,8 @@ export function CascadePanel({ options, index = 0 }) {
36
37
  const status = selectionStatus?.get(optVal);
37
38
  const opened = openedPanels[index] === optVal;
38
39
  const hasChildren = !!opt[childrenKey]?.length;
39
- return (_jsx(MenuItem, { ...mergeComponentProps({
40
- showCheckbox,
41
- key: optVal
40
+ return (_createElement(MenuItem, { ...mergeComponentProps({
41
+ showCheckbox
42
42
  }, opt, {
43
43
  checkboxProps: mergeComponentProps(opt?.checkboxProps, showCheckbox
44
44
  ? {
@@ -59,7 +59,7 @@ export function CascadePanel({ options, index = 0 }) {
59
59
  ? _jsx(LoadingIndicator, {})
60
60
  : hasChildren && _jsx(Icon, { icon: faChevronRight }),
61
61
  children: null
62
- }) }));
62
+ }), key: optVal }));
63
63
  });
64
64
  };
65
65
  const nextOptions = optionsMap.get(openedPanels[index])?.[childrenKey];
@@ -1,5 +1,5 @@
1
- import { createElement as _createElement } from "@emotion/react";
2
1
  import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
+ import { createElement as _createElement } from "@emotion/react";
3
3
  import { memo } from 'react';
4
4
  import { DataGrid, useDataGridContext } from './dataGrid';
5
5
  import { useSelectionContext } from '../selectionContext';
@@ -30,43 +30,42 @@ export const DataGridRows = memo(({ rows, _level = 0 }) => {
30
30
  const currentExpanded = expandable && expandedSet.has(trKey);
31
31
  let expandableIndex = -2;
32
32
  const ret = [
33
- _jsx(Tr, { ...mergeComponentProps(TrProps, _rowProps, {
34
- key: trKey,
33
+ _createElement(Tr, { ...mergeComponentProps(TrProps, _rowProps, {
35
34
  className: clsx(_rowProps, _level > 0 && classes.sub),
36
35
  onClick() {
37
36
  clickRowToSelect && toggleSelected(trKey, row);
38
37
  }
39
- }), "data-selected": status === 2, children: flattedColumns?.flatMap((col, j) => {
40
- if (typeof col === 'symbol') {
41
- if (col === DataGrid.EXPAND_COLUMN) {
42
- expandableIndex = j;
43
- return [];
44
- }
45
- // col === DataGrid.SELECT_COLUMN
46
- if (expandableIndex === j - 1) {
47
- // select column紧跟在expand column后面,需要顺延expandableIndex
48
- expandableIndex = j;
49
- }
50
- const Component = multiple ? Checkbox : Radio;
51
- return (_jsx(TdCell, { className: classes.selectable, sticky: j === 0 ? 'left' : void 0, children: _jsx(Component, { checked: status === 2, indeterminate: status === 1, onChange: () => {
52
- toggleSelected(trKey, row);
53
- }, onClick: e => e.stopPropagation() }) }, j + '_selectable'));
38
+ }), key: trKey, "data-selected": status === 2 }, flattedColumns?.flatMap((col, j) => {
39
+ if (typeof col === 'symbol') {
40
+ if (col === DataGrid.EXPAND_COLUMN) {
41
+ expandableIndex = j;
42
+ return [];
43
+ }
44
+ // col === DataGrid.SELECT_COLUMN
45
+ if (expandableIndex === j - 1) {
46
+ // select column紧跟在expand column后面,需要顺延expandableIndex
47
+ expandableIndex = j;
54
48
  }
55
- const {
56
- // 排除无需加入dom节点的属性
57
- // width属性只需加入thead列中,普通列需排除
58
- // rowSpan与colSpan需排除
59
- title, key, children, sticky, field, render, sorter, filter, width, _key, _negativeRowSpan, rowSpan, colSpan, ..._colProps } = col;
60
- const renderedContent = renderCell({ render, field }, row, i, arr);
61
- const shouldRenderExpand = expandableIndex === j - 1;
62
- return (_createElement(TdCell, { ..._colProps, key: _key, className: shouldRenderExpand ? classes.expandable : void 0, sticky: sticky }, shouldRenderExpand
63
- ? _jsxs("div", { className: classes.expandableWrap, style: { paddingLeft: _level * indent }, children: [_jsx(Button, { variant: "text", shape: "circular", color: "text.disabled", onClick: () => toggleExpanded(trKey), style: expandable ? void 0 : { visibility: 'hidden' }, children: renderExpandIcon
64
- ? renderExpandIcon(trKey, currentExpanded, [...expandedSet])
65
- : currentExpanded
66
- ? _jsx(Icon, { icon: faMinusSquare })
67
- : _jsx(Icon, { icon: faPlusSquare }) }), renderedContent] })
68
- : renderedContent));
69
- }) })
49
+ const Component = multiple ? Checkbox : Radio;
50
+ return (_jsx(TdCell, { className: classes.selectable, sticky: j === 0 ? 'left' : void 0, children: _jsx(Component, { checked: status === 2, indeterminate: status === 1, onChange: () => {
51
+ toggleSelected(trKey, row);
52
+ }, onClick: e => e.stopPropagation() }) }, j + '_selectable'));
53
+ }
54
+ const {
55
+ // 排除无需加入dom节点的属性
56
+ // width属性只需加入thead列中,普通列需排除
57
+ // rowSpan与colSpan需排除
58
+ title, key, children, sticky, field, render, sorter, filter, width, _key, _negativeRowSpan, rowSpan, colSpan, ..._colProps } = col;
59
+ const renderedContent = renderCell({ render, field }, row, i, arr);
60
+ const shouldRenderExpand = expandableIndex === j - 1;
61
+ return (_createElement(TdCell, { ..._colProps, key: _key, className: shouldRenderExpand ? classes.expandable : void 0, sticky: sticky }, shouldRenderExpand
62
+ ? _jsxs("div", { className: classes.expandableWrap, style: { paddingLeft: _level * indent }, children: [_jsx(Button, { variant: "text", shape: "circular", color: "text.disabled", onClick: () => toggleExpanded(trKey), style: expandable ? void 0 : { visibility: 'hidden' }, children: renderExpandIcon
63
+ ? renderExpandIcon(trKey, currentExpanded, [...expandedSet])
64
+ : currentExpanded
65
+ ? _jsx(Icon, { icon: faMinusSquare })
66
+ : _jsx(Icon, { icon: faPlusSquare }) }), renderedContent] })
67
+ : renderedContent));
68
+ }))
70
69
  ];
71
70
  if (Array.isArray(children)) {
72
71
  currentExpanded && ret.push(_jsx(DataGridRows, { rows: children, _level: _level + 1 }, trKey + '_children'));
@@ -25,12 +25,18 @@ export interface DialogProps extends Omit<ModalProps, 'title' | 'prefix'> {
25
25
  cancelText?: ReactNode;
26
26
  cancelProps?: ButtonProps;
27
27
  onCancel?(e: React.MouseEvent<HTMLButtonElement | HTMLDivElement> | KeyboardEvent): void;
28
+ /**
29
+ * 滚动的行为,默认为`card`
30
+ * @enum 'card' 卡片内部滚动
31
+ * @enum 'body' 对话框整体滚动
32
+ */
33
+ scrollBehavior?: 'card' | 'body';
28
34
  draggable?: boolean;
29
- /** 是否可通过点击遮罩层关闭对话框,默认为true */
35
+ /** 是否可通过点击遮罩层关闭对话框,默认为`true` */
30
36
  maskClosable?: boolean;
31
- /** 是否可通过键盘的【ESC】键关闭对话框,默认为true */
37
+ /** 是否可通过键盘的【ESC】键关闭对话框,默认为`true` */
32
38
  escapeClosable?: boolean;
33
39
  defaultOpen?: boolean;
34
40
  onClose?(closeReason: DialogCloseReason): void;
35
41
  }
36
- export declare function Dialog({ icon, title, footer, prefix, suffix, width, minWidth, maxWidth, showClose, closeProps, showConfirm, confirmText, confirmProps, onConfirm, confirmLoading, showCancel, cancelText, cancelProps, onCancel, draggable, maskClosable, escapeClosable, defaultOpen, open, onClose, ...props }: DialogProps): import("@emotion/react/jsx-runtime").JSX.Element;
42
+ export declare function Dialog({ icon, title, footer, prefix, suffix, width, minWidth, maxWidth, showClose, closeProps, showConfirm, confirmText, confirmProps, onConfirm, confirmLoading, showCancel, cancelText, cancelProps, onCancel, scrollBehavior, draggable, maskClosable, escapeClosable, defaultOpen, open, onClose, ...props }: DialogProps): import("@emotion/react/jsx-runtime").JSX.Element;
@@ -7,7 +7,7 @@ import { Button } from '../button';
7
7
  import { Draggable } from '../draggable';
8
8
  import { Icon } from '../icon';
9
9
  import { faXmark } from '@fortawesome/free-solid-svg-icons/faXmark';
10
- export function Dialog({ icon, title, footer, prefix, suffix, width = 420, minWidth, maxWidth = '100%', showClose = true, closeProps, showConfirm = true, confirmText = '确 定', confirmProps, onConfirm, confirmLoading = false, showCancel = true, cancelText = '取 消', cancelProps, onCancel, draggable = true, maskClosable = true, escapeClosable = true, defaultOpen = false, open, onClose, ...props }) {
10
+ export function Dialog({ icon, title, footer, prefix, suffix, width = 420, minWidth, maxWidth = '100%', showClose = true, closeProps, showConfirm = true, confirmText = '确 定', confirmProps, onConfirm, confirmLoading = false, showCancel = true, cancelText = '取 消', cancelProps, onCancel, scrollBehavior = 'card', draggable = true, maskClosable = true, escapeClosable = true, defaultOpen = false, open, onClose, ...props }) {
11
11
  const [innerOpen, _setInnerOpen] = useControlled(defaultOpen, open);
12
12
  const close = (closeReason) => {
13
13
  if (!innerLoading.current || closeReason === 'confirmed') {
@@ -78,7 +78,7 @@ export function Dialog({ icon, title, footer, prefix, suffix, width = 420, minWi
78
78
  }
79
79
  return footer;
80
80
  };
81
- return (_jsx(Modal, { ...props, ref: cloneRef(overlayRef, props.ref), css: style, className: clsx(classes.root, props.className), open: innerOpen.current, onMaskClick: onMaskClick, "data-draggable": draggable, children: _jsx(Draggable, { container: () => overlayRef.current, children: (targetProps, handleProps) => _jsxs("div", { className: classes.card, ...targetProps, style: { width, minWidth, maxWidth, ...targetProps.style }, children: [!!icon &&
81
+ return (_jsx(Modal, { ...props, ref: cloneRef(overlayRef, props.ref), css: style, className: clsx(classes.root, props.className), open: innerOpen.current, onMaskClick: onMaskClick, "data-scroll-behavior": scrollBehavior, "data-draggable": draggable, children: _jsx(Draggable, { container: () => overlayRef.current, children: (targetProps, handleProps) => _jsxs("div", { className: classes.card, ...targetProps, style: { width, minWidth, maxWidth, ...targetProps.style }, children: [!!icon &&
82
82
  _jsx("div", { className: classes.icon, children: icon }), _jsxs("div", { className: classes.content, children: [!!(title || showClose) &&
83
83
  _jsxs("div", { className: classes.titleRow, ...handleProps, children: [_jsx("div", { className: classes.title, children: title }), showClose &&
84
84
  _jsx(Button, { shape: "circular", variant: "text", color: "text.secondary", ...closeProps, className: clsx(classes.close, closeProps?.className), onClick: closeHandler, children: _jsx(Icon, { icon: faXmark }) })] }), _jsxs("div", { ref: bodyRef, className: classes.body, onScroll: onScroll, children: [!!prefix &&
@@ -1,5 +1,7 @@
1
1
  import { css } from '@emotion/react';
2
2
  import { defineInnerClasses, defineCss } from '../../utils';
3
+ import { classes as modalClasses } from '../modal/modal.style';
4
+ import { classes as overlayBaseClasses } from '../overlayBase/overlayBase.style';
3
5
  export const classes = defineInnerClasses('dialog', [
4
6
  'card',
5
7
  'icon',
@@ -15,13 +17,36 @@ export const classes = defineInnerClasses('dialog', [
15
17
  ]);
16
18
  export const style = defineCss(({ background, borderRadius, boxShadow, spacing, colors, divider }) => css `
17
19
  .${classes.card} {
18
- max-height: 100%;
19
20
  display: flex;
20
21
  background-color: ${background.content};
21
22
  border-radius: ${borderRadius}px;
22
23
  box-shadow: ${boxShadow[0]};
23
24
  }
24
25
 
26
+ .${modalClasses.childrenWrap} {
27
+ padding: 40px;
28
+ }
29
+
30
+ &[data-scroll-behavior=card] {
31
+ .${modalClasses.childrenWrap} {
32
+ height: 100%;
33
+ }
34
+
35
+ .${classes.card} {
36
+ max-height: 100%;
37
+ }
38
+ }
39
+
40
+ &[data-scroll-behavior=body] {
41
+ .${modalClasses.modal} {
42
+ height: auto;
43
+ }
44
+
45
+ .${overlayBaseClasses.childrenWrap} {
46
+ overflow: hidden auto;
47
+ }
48
+ }
49
+
25
50
  .${classes.icon} {
26
51
  color: ${colors.primary.main};
27
52
  font-size: ${21 / 14}em;
@@ -48,7 +73,7 @@ export const style = defineCss(({ background, borderRadius, boxShadow, spacing,
48
73
  font-size: ${16 / 14}em;
49
74
  font-weight: bold;
50
75
  margin-right: -${spacing[8]}px;
51
-
76
+
52
77
  .${classes.title} {
53
78
  flex: 1;
54
79
  padding: ${spacing[6]}px 0 ${spacing[3]}px;
@@ -1,6 +1,5 @@
1
1
  import { css } from '@emotion/react';
2
2
  import { defineInnerClasses, defineCss } from '../../utils';
3
- import { classes as modalClasses } from '../modal/modal.style';
4
3
  export const classes = defineInnerClasses('image-preview', [
5
4
  'button',
6
5
  'control',
@@ -66,10 +65,6 @@ export const style = defineCss(({ spacing, easing, breakpoints }) => css `
66
65
  }
67
66
  }
68
67
 
69
- .${modalClasses.modal} {
70
- padding: 0;
71
- }
72
-
73
68
  .${classes.galleryContainer} {
74
69
  &, .${classes.galleryWrapper}, .${classes.imageItem}, .${classes.image} {
75
70
  width: 100%;
@@ -19,5 +19,5 @@ export function Modal({ modalProps, ...props }) {
19
19
  return (_jsx(OverlayBase, { ...props, css: style, className: clsx(classes.root, props.className), children: _jsx(Grow, { timeout: overlayBaseTransitionDuration, ...modalProps, in: props.open, className: clsx(classes.modal, modalProps?.className), style: {
20
20
  transformOrigin: transformOrigin.current,
21
21
  ...modalProps?.style
22
- }, children: props.children }) }));
22
+ }, children: _jsx("div", { className: classes.childrenWrap, onClick: e => e.stopPropagation(), children: props.children }) }) }));
23
23
  }
@@ -1,4 +1,5 @@
1
1
  export declare const classes: {
2
+ childrenWrap: string;
2
3
  modal: string;
3
4
  } & {
4
5
  root: string;
@@ -1,20 +1,15 @@
1
1
  import { css } from '@emotion/react';
2
2
  import { defineInnerClasses } from '../../utils';
3
3
  export const classes = defineInnerClasses('modal', [
4
- 'modal'
4
+ 'modal',
5
+ 'childrenWrap'
5
6
  ]);
6
7
  export const style = css `
7
8
  .${classes.modal} {
8
9
  width: 100%;
9
10
  height: 100%;
10
- padding: 40px;
11
- pointer-events: none;
12
11
  display: flex;
13
12
  align-items: center;
14
13
  justify-content: center;
15
-
16
- > * {
17
- pointer-events: all;
18
- }
19
14
  }
20
15
  `;
@@ -1,4 +1,4 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
1
+ import { jsx as _jsx } from "@emotion/react/jsx-runtime";
2
2
  import { useEffect } from 'react';
3
3
  import { classes, style } from './overlayBase.style';
4
4
  import { clsx, mergeComponentProps, useContainer, useDerivedState } from '../../utils';
@@ -33,11 +33,11 @@ export function OverlayBase({ container, effectContainer, forceRender, open, onM
33
33
  onClosed?.();
34
34
  forceRender === false && setShouldRender(false);
35
35
  };
36
- return shouldRender.current && createPortal(_jsxs("div", { ...props, css: style, className: clsx(classes.root, props.className), "data-open": open, "data-custom-container": containerEl.current !== document.body, children: [_jsx(Fade, { timeout: overlayBaseTransitionDuration, ...mergeComponentProps(maskProps, {
37
- in: open,
38
- className: classes.mask,
39
- onClick,
40
- onEntered,
41
- onExited
42
- }) }), props.children] }), containerEl.current);
36
+ return shouldRender.current && createPortal(_jsx("div", { ...props, css: style, className: clsx(classes.root, props.className), "data-open": open, "data-custom-container": containerEl.current !== document.body, children: _jsx(Fade, { timeout: overlayBaseTransitionDuration, ...mergeComponentProps(maskProps, {
37
+ in: open,
38
+ className: classes.mask,
39
+ onClick,
40
+ onEntered,
41
+ onExited
42
+ }), children: _jsx("div", { className: classes.childrenWrap, children: props.children }) }) }), containerEl.current);
43
43
  }
@@ -1,5 +1,6 @@
1
1
  export declare const classes: {
2
2
  mask: string;
3
+ childrenWrap: string;
3
4
  } & {
4
5
  root: string;
5
6
  };
@@ -3,29 +3,35 @@ import { defineInnerClasses, defineCss } from '../../utils';
3
3
  import { appStyleCallback } from '../app/app.style';
4
4
  import { zIndex } from '../theme';
5
5
  export const classes = defineInnerClasses('overlay-base', [
6
- 'mask'
6
+ 'mask',
7
+ 'childrenWrap'
7
8
  ]);
8
9
  export const style = defineCss(theme => {
9
10
  return [
10
11
  appStyleCallback(theme),
11
12
  css `
12
- position: fixed;
13
- inset: 0;
14
- z-index: ${zIndex.overlay};
15
-
16
- &[data-custom-container=true] {
17
- position: absolute;
18
- }
19
-
20
- .${classes.mask} {
21
- background-color: rgba(0, 0, 0, .5);
22
- position: absolute;
13
+ position: fixed;
23
14
  inset: 0;
24
- }
15
+ z-index: ${zIndex.overlay};
16
+
17
+ &[data-custom-container=true] {
18
+ position: absolute;
19
+ }
20
+
21
+ .${classes.mask} {
22
+ background-color: rgba(0, 0, 0, .5);
23
+ position: absolute;
24
+ inset: 0;
25
+ }
25
26
 
26
- &:not([data-open=true]) {
27
- pointer-events: none;
28
- }
29
- `
27
+ &:not([data-open=true]) {
28
+ pointer-events: none;
29
+ }
30
+
31
+ .${classes.childrenWrap} {
32
+ height: 100%;
33
+ position: relative;
34
+ }
35
+ `
30
36
  ];
31
37
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canlooks/can-ui",
3
- "version": "0.0.81",
3
+ "version": "0.0.83",
4
4
  "author": "C.CanLiang <canlooks@gmail.com>",
5
5
  "description": "My ui framework",
6
6
  "license": "MIT",