tntd 3.0.0-beta.9 → 3.0.1
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/es/array-input/index.js +57 -42
- package/es/array-input/index.js.map +1 -1
- package/es/array-input/index.less +4 -1
- package/es/button/button.js +3 -7
- package/es/button/button.js.map +1 -1
- package/es/button/button.less +17 -12
- package/es/collapse/collapse.less +3 -3
- package/es/date-picker/index.less +6 -6
- package/es/date-picker/style/Calendar.less +1 -1
- package/es/date-picker/style/RangePicker.less +3 -3
- package/es/descriptions/descriptions.js +36 -18
- package/es/descriptions/descriptions.js.map +1 -1
- package/es/descriptions/descriptions.less +6 -2
- package/es/descriptions/style/index.less +1 -0
- package/es/drawer/drawer.js +32 -22
- package/es/drawer/drawer.js.map +1 -1
- package/es/drawer/index.less +13 -14
- package/es/drawer/style/drawer.less +2 -4
- package/es/form/form.less +12 -6
- package/es/form/style/index.less +6 -6
- package/es/handle-icon/index.js +201 -0
- package/es/handle-icon/index.js.map +1 -0
- package/es/handle-icon/index.less +53 -0
- package/es/icon/style/style.less +1 -1
- package/es/index.js +1 -0
- package/es/index.js.map +1 -1
- package/es/input/input.js +10 -6
- package/es/input/input.js.map +1 -1
- package/es/input/style/mixin.less +1 -2
- package/es/locale/en_US.js +3 -0
- package/es/locale/en_US.js.map +1 -1
- package/es/locale/zh_CN.js +3 -0
- package/es/locale/zh_CN.js.map +1 -1
- package/es/mentions/style/index.less +1 -0
- package/es/modal/style/confirm.less +6 -10
- package/es/modal/style/modal.less +1 -1
- package/es/page-container/index.js +1 -1
- package/es/page-container/index.js.map +1 -1
- package/es/page-container/index.less +1 -0
- package/es/page-loading/index.js +1 -1
- package/es/page-loading/index.js.map +1 -1
- package/es/query-form/Field/SelectInput.js +4 -22
- package/es/query-form/Field/SelectInput.js.map +1 -1
- package/es/query-form/Field/fieldsMap.js +2 -2
- package/es/query-form/Field/fieldsMap.js.map +1 -1
- package/es/query-form/Field/index.js +0 -1
- package/es/query-form/Field/index.js.map +1 -1
- package/es/query-form/index.js +127 -117
- package/es/query-form/index.js.map +1 -1
- package/es/query-form/index.less +9 -12
- package/es/{query-form → query-form-backup}/Field/Composition/index.less +1 -1
- package/es/query-form-backup/index.less +90 -0
- package/es/query-list-scene/QueryForm.js +1 -3
- package/es/query-list-scene/QueryForm.js.map +1 -1
- package/es/select/select.js +5 -3
- package/es/select/select.js.map +1 -1
- package/es/select/select.less +1 -3
- package/es/select/style/index.less +7 -6
- package/es/spin/index.js +3 -2
- package/es/spin/index.js.map +1 -1
- package/es/spin/spin.js +36 -0
- package/es/spin/spin.js.map +1 -0
- package/es/spin/spin.less +9 -0
- package/es/style/themes/default.less +1 -1
- package/es/table/expand.less +49 -0
- package/es/table/hooks/index.js +2 -1
- package/es/table/hooks/index.js.map +1 -1
- package/es/table/hooks/use-expand-fixed.js +80 -0
- package/es/table/hooks/use-expand-fixed.js.map +1 -0
- package/es/table/index.js +1 -0
- package/es/table/index.js.map +1 -1
- package/es/table/style/index.less +58 -88
- package/es/table/table.js +48 -14
- package/es/table/table.js.map +1 -1
- package/es/table/table.less +13 -22
- package/es/table/table.stories.js +413 -2
- package/es/table/table.stories.js.map +1 -1
- package/es/table/utils.js +11 -0
- package/es/table/utils.js.map +1 -1
- package/es/table-container/index.js +1 -1
- package/es/table-container/index.js.map +1 -1
- package/es/table-container/index.less +14 -14
- package/es/tabs/tabs.js +9 -1
- package/es/tabs/tabs.js.map +1 -1
- package/es/tabs/tabs.less +52 -62
- package/es/tabs-container/index.js +1 -1
- package/es/tabs-container/index.js.map +1 -1
- package/es/tag/color.less +28 -18
- package/es/tag/index.js +1 -1
- package/es/tag/index.js.map +1 -1
- package/es/tag/tag.less +41 -5
- package/es/title/index.js +4 -3
- package/es/title/index.js.map +1 -1
- package/es/tntd-action/Action.js +58 -12
- package/es/tntd-action/Action.js.map +1 -1
- package/es/tntd-action/index.less +5 -3
- package/es/tntd-cascader/AntdCascader/component/defaultRenderEmpty.js +5 -11
- package/es/tntd-cascader/AntdCascader/component/defaultRenderEmpty.js.map +1 -1
- package/es/tntd-cascader/AntdCascader/index.less +14 -2
- package/es/tntd-cascader/rc-cascader/OptionList/Column.js +3 -2
- package/es/tntd-cascader/rc-cascader/OptionList/Column.js.map +1 -1
- package/es/tntd-cascader/rc-cascader/OptionList/index.js +1 -0
- package/es/tntd-cascader/rc-cascader/OptionList/index.js.map +1 -1
- package/es/tntd-form/FormItem/ItemHolder.js +1 -6
- package/es/tntd-form/FormItem/ItemHolder.js.map +1 -1
- package/es/tntd-form/FormItemLabel.js +2 -0
- package/es/tntd-form/FormItemLabel.js.map +1 -1
- package/es/tntd-select/index.js +13 -9
- package/es/tntd-select/index.js.map +1 -1
- package/es/tntd-select/index.less +7 -0
- package/es/tooltip/index.js +1 -0
- package/es/tooltip/index.js.map +1 -1
- package/es/tooltip/index.less +1 -2
- package/lib/array-input/index.d.ts +1 -12
- package/lib/array-input/index.d.ts.map +1 -1
- package/lib/array-input/index.js +62 -55
- package/lib/array-input/index.js.map +1 -1
- package/lib/array-input/index.less +4 -1
- package/lib/button/button.d.ts.map +1 -1
- package/lib/button/button.js +3 -15
- package/lib/button/button.js.map +1 -1
- package/lib/button/button.less +17 -12
- package/lib/collapse/collapse.less +3 -3
- package/lib/date-picker/index.less +6 -6
- package/lib/date-picker/style/Calendar.less +1 -1
- package/lib/date-picker/style/RangePicker.less +3 -3
- package/lib/descriptions/descriptions.d.ts.map +1 -1
- package/lib/descriptions/descriptions.js +40 -20
- package/lib/descriptions/descriptions.js.map +1 -1
- package/lib/descriptions/descriptions.less +6 -2
- package/lib/descriptions/style/index.less +1 -0
- package/lib/drawer/drawer.d.ts +3 -0
- package/lib/drawer/drawer.d.ts.map +1 -1
- package/lib/drawer/drawer.js +30 -20
- package/lib/drawer/drawer.js.map +1 -1
- package/lib/drawer/index.less +13 -14
- package/lib/drawer/style/drawer.less +2 -4
- package/lib/form/form.less +12 -6
- package/lib/form/style/index.less +6 -6
- package/lib/handle-icon/index.d.ts +7 -0
- package/lib/handle-icon/index.d.ts.map +1 -0
- package/lib/handle-icon/index.js +221 -0
- package/lib/handle-icon/index.js.map +1 -0
- package/lib/handle-icon/index.less +53 -0
- package/lib/icon/style/style.less +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +7 -0
- package/lib/index.js.map +1 -1
- package/lib/input/input.js +8 -4
- package/lib/input/input.js.map +1 -1
- package/lib/input/style/mixin.less +1 -2
- package/lib/locale/default.d.ts +3 -0
- package/lib/locale/default.d.ts.map +1 -1
- package/lib/locale/en_US.d.ts +3 -0
- package/lib/locale/en_US.d.ts.map +1 -1
- package/lib/locale/en_US.js +3 -0
- package/lib/locale/en_US.js.map +1 -1
- package/lib/locale/zh_CN.d.ts +3 -0
- package/lib/locale/zh_CN.d.ts.map +1 -1
- package/lib/locale/zh_CN.js +3 -0
- package/lib/locale/zh_CN.js.map +1 -1
- package/lib/mentions/style/index.less +1 -0
- package/lib/modal/style/confirm.less +6 -10
- package/lib/modal/style/modal.less +1 -1
- package/lib/page-container/index.js +1 -1
- package/lib/page-container/index.js.map +1 -1
- package/lib/page-container/index.less +1 -0
- package/lib/page-loading/index.js +1 -1
- package/lib/page-loading/index.js.map +1 -1
- package/lib/query-form/Field/SelectInput.d.ts.map +1 -1
- package/lib/query-form/Field/SelectInput.js +3 -15
- package/lib/query-form/Field/SelectInput.js.map +1 -1
- package/lib/query-form/Field/fieldsMap.d.ts +3 -6
- package/lib/query-form/Field/fieldsMap.js +2 -2
- package/lib/query-form/Field/fieldsMap.js.map +1 -1
- package/lib/query-form/Field/index.d.ts.map +1 -1
- package/lib/query-form/Field/index.js +0 -1
- package/lib/query-form/Field/index.js.map +1 -1
- package/lib/query-form/index.d.ts +7 -4
- package/lib/query-form/index.d.ts.map +1 -1
- package/lib/query-form/index.js +149 -143
- package/lib/query-form/index.js.map +1 -1
- package/lib/query-form/index.less +9 -12
- package/lib/{query-form → query-form-backup}/Field/Composition/index.less +1 -1
- package/lib/query-form-backup/index.less +90 -0
- package/lib/query-list-scene/QueryForm.js +2 -3
- package/lib/query-list-scene/QueryForm.js.map +1 -1
- package/lib/select/select.d.ts.map +1 -1
- package/lib/select/select.js +4 -2
- package/lib/select/select.js.map +1 -1
- package/lib/select/select.less +1 -3
- package/lib/select/style/index.less +7 -6
- package/lib/spin/index.d.ts +3 -2
- package/lib/spin/index.d.ts.map +1 -1
- package/lib/spin/index.js +4 -6
- package/lib/spin/index.js.map +1 -1
- package/lib/spin/spin.d.ts +9 -0
- package/lib/spin/spin.d.ts.map +1 -0
- package/lib/spin/spin.js +44 -0
- package/lib/spin/spin.js.map +1 -0
- package/lib/spin/spin.less +9 -0
- package/lib/style/themes/default.less +1 -1
- package/lib/table/expand.less +49 -0
- package/lib/table/hooks/index.d.ts +1 -0
- package/lib/table/hooks/index.d.ts.map +1 -1
- package/lib/table/hooks/index.js +11 -0
- package/lib/table/hooks/index.js.map +1 -1
- package/lib/table/hooks/use-expand-fixed.d.ts +4 -0
- package/lib/table/hooks/use-expand-fixed.d.ts.map +1 -0
- package/lib/table/hooks/use-expand-fixed.js +110 -0
- package/lib/table/hooks/use-expand-fixed.js.map +1 -0
- package/lib/table/index.d.ts +1 -0
- package/lib/table/index.d.ts.map +1 -1
- package/lib/table/index.js +1 -0
- package/lib/table/index.js.map +1 -1
- package/lib/table/style/index.less +58 -88
- package/lib/table/table.d.ts +3 -1
- package/lib/table/table.d.ts.map +1 -1
- package/lib/table/table.js +49 -11
- package/lib/table/table.js.map +1 -1
- package/lib/table/table.less +13 -22
- package/lib/table/table.stories.d.ts +106 -29
- package/lib/table/table.stories.d.ts.map +1 -1
- package/lib/table/table.stories.js +426 -3
- package/lib/table/table.stories.js.map +1 -1
- package/lib/table/utils.d.ts +1 -0
- package/lib/table/utils.d.ts.map +1 -1
- package/lib/table/utils.js +13 -0
- package/lib/table/utils.js.map +1 -1
- package/lib/table-container/index.d.ts.map +1 -1
- package/lib/table-container/index.js +1 -1
- package/lib/table-container/index.js.map +1 -1
- package/lib/table-container/index.less +14 -14
- package/lib/tabs/tabs.d.ts.map +1 -1
- package/lib/tabs/tabs.js +8 -0
- package/lib/tabs/tabs.js.map +1 -1
- package/lib/tabs/tabs.less +52 -62
- package/lib/tabs-container/index.js +1 -1
- package/lib/tabs-container/index.js.map +1 -1
- package/lib/tag/color.less +28 -18
- package/lib/tag/index.js +1 -1
- package/lib/tag/index.js.map +1 -1
- package/lib/tag/tag.less +41 -5
- package/lib/title/index.d.ts +1 -0
- package/lib/title/index.d.ts.map +1 -1
- package/lib/title/index.js +3 -2
- package/lib/title/index.js.map +1 -1
- package/lib/tntd-action/Action.d.ts +1 -1
- package/lib/tntd-action/Action.js +63 -13
- package/lib/tntd-action/Action.js.map +1 -1
- package/lib/tntd-action/index.less +5 -3
- package/lib/tntd-cascader/AntdCascader/component/defaultRenderEmpty.d.ts.map +1 -1
- package/lib/tntd-cascader/AntdCascader/component/defaultRenderEmpty.js +5 -11
- package/lib/tntd-cascader/AntdCascader/component/defaultRenderEmpty.js.map +1 -1
- package/lib/tntd-cascader/AntdCascader/index.less +14 -2
- package/lib/tntd-cascader/rc-cascader/OptionList/Column.d.ts +1 -1
- package/lib/tntd-cascader/rc-cascader/OptionList/Column.d.ts.map +1 -1
- package/lib/tntd-cascader/rc-cascader/OptionList/Column.js +3 -2
- package/lib/tntd-cascader/rc-cascader/OptionList/Column.js.map +1 -1
- package/lib/tntd-cascader/rc-cascader/OptionList/index.d.ts.map +1 -1
- package/lib/tntd-cascader/rc-cascader/OptionList/index.js +1 -0
- package/lib/tntd-cascader/rc-cascader/OptionList/index.js.map +1 -1
- package/lib/tntd-form/FormItem/ItemHolder.js +1 -6
- package/lib/tntd-form/FormItem/ItemHolder.js.map +1 -1
- package/lib/tntd-form/FormItemLabel.d.ts.map +1 -1
- package/lib/tntd-form/FormItemLabel.js +2 -0
- package/lib/tntd-form/FormItemLabel.js.map +1 -1
- package/lib/tntd-select/index.d.ts.map +1 -1
- package/lib/tntd-select/index.js +12 -8
- package/lib/tntd-select/index.js.map +1 -1
- package/lib/tntd-select/index.less +7 -0
- package/lib/tooltip/index.d.ts +1 -0
- package/lib/tooltip/index.d.ts.map +1 -1
- package/lib/tooltip/index.js +1 -0
- package/lib/tooltip/index.js.map +1 -1
- package/lib/tooltip/index.less +1 -2
- package/package.json +4 -3
- package/themes/default/variables.less +2 -2
- package/themes/default/variablesVar.less +2 -2
- package/es/array-input/1.png +0 -1
- package/es/array-input/111.gif +0 -0
- package/es/array-input/icon.js +0 -25
- package/es/array-input/icon.js.map +0 -1
- package/es/query-form/Field/Composition/FieldPopover.js +0 -308
- package/es/query-form/Field/Composition/FieldPopover.js.map +0 -1
- package/es/query-form/Field/Composition/Select.js +0 -104
- package/es/query-form/Field/Composition/Select.js.map +0 -1
- package/es/query-form/Field/Composition/index.js +0 -299
- package/es/query-form/Field/Composition/index.js.map +0 -1
- package/es/query-form/Field/Composition/utils.js +0 -19
- package/es/query-form/Field/Composition/utils.js.map +0 -1
- package/lib/array-input/1.png +0 -1
- package/lib/array-input/111.gif +0 -0
- package/lib/array-input/icon.d.ts +0 -4
- package/lib/array-input/icon.d.ts.map +0 -1
- package/lib/array-input/icon.js +0 -32
- package/lib/array-input/icon.js.map +0 -1
- package/lib/query-form/Field/Composition/FieldPopover.d.ts +0 -19
- package/lib/query-form/Field/Composition/FieldPopover.d.ts.map +0 -1
- package/lib/query-form/Field/Composition/FieldPopover.js +0 -347
- package/lib/query-form/Field/Composition/FieldPopover.js.map +0 -1
- package/lib/query-form/Field/Composition/Select.d.ts +0 -4
- package/lib/query-form/Field/Composition/Select.d.ts.map +0 -1
- package/lib/query-form/Field/Composition/Select.js +0 -128
- package/lib/query-form/Field/Composition/Select.js.map +0 -1
- package/lib/query-form/Field/Composition/index.d.ts +0 -14
- package/lib/query-form/Field/Composition/index.d.ts.map +0 -1
- package/lib/query-form/Field/Composition/index.js +0 -349
- package/lib/query-form/Field/Composition/index.js.map +0 -1
- package/lib/query-form/Field/Composition/utils.d.ts +0 -6
- package/lib/query-form/Field/Composition/utils.d.ts.map +0 -1
- package/lib/query-form/Field/Composition/utils.js +0 -27
- package/lib/query-form/Field/Composition/utils.js.map +0 -1
- /package/es/{query-form → query-form-backup}/Field/Composition/FieldPopover.less +0 -0
- /package/lib/{query-form → query-form-backup}/Field/Composition/FieldPopover.less +0 -0
package/es/drawer/drawer.js
CHANGED
|
@@ -10,13 +10,12 @@ import { ConfigConsumer } from 'antd/es/config-provider';
|
|
|
10
10
|
import { default as AntdDrawer } from 'antd/es/drawer';
|
|
11
11
|
import LocaleReceiver from 'antd/es/locale-provider/LocaleReceiver';
|
|
12
12
|
import classNames from 'classnames';
|
|
13
|
-
import
|
|
13
|
+
import { doUpperTitle } from '../utils';
|
|
14
|
+
import React, { useCallback, useEffect } from 'react';
|
|
14
15
|
import { Button } from '../button';
|
|
15
16
|
import Icon from '../icon';
|
|
16
17
|
const DefaultFooter = ({
|
|
17
18
|
locale,
|
|
18
|
-
onClose,
|
|
19
|
-
onSubmit,
|
|
20
19
|
onCancel,
|
|
21
20
|
onOk,
|
|
22
21
|
okText,
|
|
@@ -28,13 +27,10 @@ const DefaultFooter = ({
|
|
|
28
27
|
cancelType
|
|
29
28
|
}) => {
|
|
30
29
|
return React.createElement(React.Fragment, null, React.createElement(Button, Object.assign({
|
|
31
|
-
onClick: onCancel
|
|
32
|
-
|
|
33
|
-
marginRight: 8
|
|
34
|
-
},
|
|
35
|
-
type: cancelType || 'tertiary'
|
|
30
|
+
onClick: onCancel,
|
|
31
|
+
type: cancelType || 'default'
|
|
36
32
|
}, cancelButtonProps), cancelText || (locale === null || locale === void 0 ? void 0 : locale.cancelText)), React.createElement(Button, Object.assign({
|
|
37
|
-
onClick: onOk
|
|
33
|
+
onClick: onOk,
|
|
38
34
|
type: okType || 'primary',
|
|
39
35
|
loading: confirmLoading
|
|
40
36
|
}, okButtonProps), okText || (locale === null || locale === void 0 ? void 0 : locale.okText)));
|
|
@@ -46,6 +42,7 @@ export const Drawer = _a => {
|
|
|
46
42
|
footer,
|
|
47
43
|
showFooter,
|
|
48
44
|
onClose,
|
|
45
|
+
afterClose,
|
|
49
46
|
onSubmit,
|
|
50
47
|
onCancel,
|
|
51
48
|
onOk,
|
|
@@ -57,11 +54,24 @@ export const Drawer = _a => {
|
|
|
57
54
|
confirmLoading = false,
|
|
58
55
|
okButtonProps = {},
|
|
59
56
|
cancelButtonProps = {},
|
|
60
|
-
clickOnBlankToClose = false
|
|
57
|
+
clickOnBlankToClose = false,
|
|
58
|
+
upperCaseIgnore,
|
|
59
|
+
unUpperConverted,
|
|
60
|
+
title
|
|
61
61
|
} = _a,
|
|
62
|
-
rest = __rest(_a, ["closable", "className", "footer", "showFooter", "onClose", "onSubmit", "onCancel", "onOk", "okText", "cancelText", "locale", "okType", "cancelType", "confirmLoading", "okButtonProps", "cancelButtonProps", "clickOnBlankToClose"]);
|
|
62
|
+
rest = __rest(_a, ["closable", "className", "footer", "showFooter", "onClose", "afterClose", "onSubmit", "onCancel", "onOk", "okText", "cancelText", "locale", "okType", "cancelType", "confirmLoading", "okButtonProps", "cancelButtonProps", "clickOnBlankToClose", "upperCaseIgnore", "unUpperConverted", "title"]);
|
|
63
63
|
const drawerDom = React.useRef(null);
|
|
64
|
-
const _onCancel =
|
|
64
|
+
const _onCancel = useCallback(() => {
|
|
65
|
+
if (onCancel) {
|
|
66
|
+
onCancel();
|
|
67
|
+
} else if (onClose) {
|
|
68
|
+
onClose();
|
|
69
|
+
}
|
|
70
|
+
if (afterClose) {
|
|
71
|
+
afterClose();
|
|
72
|
+
}
|
|
73
|
+
}, [onCancel, onClose, afterClose]);
|
|
74
|
+
const _onOk = onOk || onSubmit;
|
|
65
75
|
useEffect(() => {
|
|
66
76
|
if (clickOnBlankToClose) {
|
|
67
77
|
const handleOutsideClick = event => {
|
|
@@ -101,15 +111,17 @@ export const Drawer = _a => {
|
|
|
101
111
|
[`${prefixCls}-footer`]: showFooter || footer
|
|
102
112
|
}),
|
|
103
113
|
closable: false,
|
|
104
|
-
onClose:
|
|
114
|
+
onClose: _onCancel,
|
|
105
115
|
width: 480
|
|
106
|
-
}, rest
|
|
116
|
+
}, rest, {
|
|
117
|
+
title: !unUpperConverted ? doUpperTitle(title, upperCaseIgnore) : title
|
|
118
|
+
}), React.createElement(React.Fragment, null, closable !== false && React.createElement(Icon, {
|
|
107
119
|
type: "close",
|
|
108
120
|
className: `${prefixCls}-close`,
|
|
109
|
-
onClick:
|
|
110
|
-
}), rest.children, React.createElement("div", {
|
|
121
|
+
onClick: _onCancel
|
|
122
|
+
}), rest.children, (showFooter || footer) && React.createElement("div", {
|
|
111
123
|
className: `${prefixCls}-footer-style`
|
|
112
|
-
},
|
|
124
|
+
}, footer || React.createElement(DefaultFooter, {
|
|
113
125
|
confirmLoading: confirmLoading,
|
|
114
126
|
okButtonProps: okButtonProps,
|
|
115
127
|
cancelButtonProps: cancelButtonProps,
|
|
@@ -118,11 +130,9 @@ export const Drawer = _a => {
|
|
|
118
130
|
okText: okText,
|
|
119
131
|
cancelType: cancelType,
|
|
120
132
|
cancelText: cancelText,
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
onCancel: onCancel
|
|
125
|
-
}) : footer))));
|
|
133
|
+
onOk: _onOk,
|
|
134
|
+
onCancel: _onCancel
|
|
135
|
+
})))));
|
|
126
136
|
});
|
|
127
137
|
});
|
|
128
138
|
};
|
package/es/drawer/drawer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drawer.js","sourceRoot":"","sources":["../../src/drawer/drawer.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAExD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,gBAAgB,CAAA;AACtD,OAAO,cAAc,MAAM,wCAAwC,CAAA;AACnE,OAAO,UAAU,MAAM,YAAY,CAAA;
|
|
1
|
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,OAAO,EAAE,SAAS,GAAI,CAC3E;wBACA,IAAI,CAAC,QAAQ;wBACb,CAAC,UAAU,IAAI,MAAM,CAAC,IAAI,CACzB,6BAAK,SAAS,EAAE,GAAG,SAAS,eAAe,IACxC,MAAM,IAAI,CACT,oBAAC,aAAa,IACZ,cAAc,EAAE,cAAc,EAC9B,aAAa,EAAE,aAAa,EAC5B,iBAAiB,EAAE,iBAAiB,EACpC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,UAAU,EACtB,IAAI,EAAE,KAAK,EACX,QAAQ,EAAE,SAAS,GACnB,CACH,CACG,CACP,CACA,CACQ,CACT,CACP,CAAA;QACH,CAAC,CACc,CAClB,CAAA;IACH,CAAC,CACc,CAClB,CAAA;AACH,CAAC,CAAA","sourcesContent":["import { ConfigConsumer } from 'antd/es/config-provider'\nimport type { DrawerProps as AntdDrawerProps } from 'antd/es/drawer'\nimport { default as AntdDrawer } from 'antd/es/drawer'\nimport LocaleReceiver from 'antd/es/locale-provider/LocaleReceiver'\nimport classNames from 'classnames'\nimport type { BaseButtonProps } from 'antd/es/button/button'\nimport type { TntButtonType } from '../button/button'\nimport { doUpperTitle } from '../utils'\nimport React, { FC, useCallback, useEffect, useRef } from 'react'\nimport { Button } from '../button'\nimport Icon from '../icon'\nconst DefaultFooter = ({\n locale,\n onCancel,\n onOk,\n okText,\n okType,\n cancelText,\n confirmLoading,\n okButtonProps,\n cancelButtonProps,\n cancelType,\n}: {\n locale?: {\n okText?: string\n cancelText?: string\n }\n onCancel?: () => void\n onOk?: () => void\n okText: string\n cancelText: string\n okType?: TntButtonType\n cancelType: TntButtonType\n confirmLoading?: boolean\n okButtonProps?: BaseButtonProps\n cancelButtonProps?: BaseButtonProps\n}) => {\n return (\n <>\n <Button onClick={onCancel} type={cancelType || 'default'} {...cancelButtonProps}>\n {cancelText || locale?.cancelText}\n </Button>\n <Button onClick={onOk} type={okType || 'primary'} loading={confirmLoading} {...okButtonProps}>\n {okText || locale?.okText}\n </Button>\n </>\n )\n}\n\ninterface CustomDrawerProps extends AntdDrawerProps {\n footer?: React.ReactNode\n showFooter?: boolean\n onClose?: () => void\n onSubmit?: () => void\n onCancel?: () => void\n afterClose?: () => void\n onOk?: () => void\n okText?: string\n cancelText?: string\n locale?: {\n okText?: string\n cancelText?: string\n }\n okType?: TntButtonType\n cancelType?: TntButtonType\n confirmLoading?: boolean\n okButtonProps?: BaseButtonProps\n cancelButtonProps?: BaseButtonProps\n clickOnBlankToClose: boolean\n upperCaseIgnore?: []\n unUpperConverted: boolean\n}\n\nexport const Drawer: FC<CustomDrawerProps> = ({\n closable = true,\n className,\n footer,\n showFooter,\n onClose,\n afterClose,\n onSubmit,\n onCancel,\n onOk,\n okText = '',\n cancelText = '',\n locale,\n okType = 'primary',\n cancelType = 'default',\n confirmLoading = false,\n okButtonProps = {},\n cancelButtonProps = {},\n clickOnBlankToClose = false,\n upperCaseIgnore,\n unUpperConverted,\n title,\n ...rest\n}) => {\n const drawerDom = React.useRef<EventTarget | null>(null)\n const _onCancel = useCallback(() => {\n if (onCancel) {\n onCancel()\n } else if (onClose) {\n onClose()\n }\n if (afterClose) {\n afterClose()\n }\n }, [onCancel, onClose, afterClose])\n const _onOk = onOk || onSubmit\n\n useEffect(() => {\n if (clickOnBlankToClose) {\n const handleOutsideClick = (event: Event) => {\n const drawer = drawerDom.current as Node\n const targetElement = event.target as Node\n\n let isInDrawer = false\n if (drawer && targetElement) {\n isInDrawer = drawer.contains(targetElement as Node) || targetElement === drawer\n }\n drawerDom.current = null\n if (rest.visible && !isInDrawer && _onCancel) {\n _onCancel()\n }\n }\n document.removeEventListener('click', handleOutsideClick)\n document.addEventListener('click', handleOutsideClick)\n return () => {\n document.removeEventListener('click', handleOutsideClick)\n }\n }\n }, [rest.visible, clickOnBlankToClose, _onCancel])\n\n return (\n <ConfigConsumer>\n {({ getPrefixCls }) => {\n const prefixCls = getPrefixCls('drawer')\n return (\n <LocaleReceiver componentName=\"Drawer\" defaultLocale={locale}>\n {(locale) => {\n return (\n <div\n onClick={(event: React.MouseEvent<HTMLDivElement>) => {\n drawerDom.current = event.target\n }}\n >\n <AntdDrawer\n className={classNames(prefixCls, 'tnt-drawer', className, {\n [`${prefixCls}-contain-closable`]: closable !== false,\n [`${prefixCls}-footer`]: showFooter || footer,\n })}\n closable={false}\n onClose={_onCancel}\n width={480}\n {...rest}\n title={!unUpperConverted ? doUpperTitle(title, upperCaseIgnore) : title}\n >\n <>\n {closable !== false && (\n <Icon type=\"close\" className={`${prefixCls}-close`} onClick={_onCancel} />\n )}\n {rest.children}\n {(showFooter || footer) && (\n <div className={`${prefixCls}-footer-style`}>\n {footer || (\n <DefaultFooter\n confirmLoading={confirmLoading}\n okButtonProps={okButtonProps}\n cancelButtonProps={cancelButtonProps}\n okType={okType}\n locale={locale}\n okText={okText}\n cancelType={cancelType}\n cancelText={cancelText}\n onOk={_onOk}\n onCancel={_onCancel}\n />\n )}\n </div>\n )}\n </>\n </AntdDrawer>\n </div>\n )\n }}\n </LocaleReceiver>\n )\n }}\n </ConfigConsumer>\n )\n}\n"]}
|
package/es/drawer/index.less
CHANGED
|
@@ -20,12 +20,12 @@
|
|
|
20
20
|
|
|
21
21
|
.@{drawer-prefix-cls}-wrapper-body {
|
|
22
22
|
margin-top: 48px;
|
|
23
|
-
max-height: ~'calc(100vh -
|
|
23
|
+
max-height: ~'calc(100vh - 48px)';
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
&-footer {
|
|
27
27
|
.@{drawer-prefix-cls}-header {
|
|
28
|
-
border-bottom: none;
|
|
28
|
+
// border-bottom: none;
|
|
29
29
|
position: absolute;
|
|
30
30
|
right: 0;
|
|
31
31
|
top: 0;
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
.@{drawer-prefix-cls}-wrapper-body {
|
|
37
|
-
max-height: ~'calc(100vh -
|
|
37
|
+
max-height: ~'calc(100vh - 96px)' !important;
|
|
38
38
|
margin-top: 48px !important;
|
|
39
39
|
margin-bottom: 48px !important;
|
|
40
40
|
}
|
|
@@ -42,16 +42,11 @@
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
.@{drawer-prefix-cls}-title {
|
|
45
|
-
font-size:
|
|
46
|
-
font-weight:
|
|
45
|
+
font-size: 16px !important;
|
|
46
|
+
font-weight: 500 !important;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
.@{drawer-prefix-cls}-close {
|
|
50
|
-
color: fade(@text-color, 50%);
|
|
51
|
-
width: 62px;
|
|
52
|
-
top: -4px;
|
|
53
|
-
|
|
54
|
-
|
|
55
50
|
position: absolute;
|
|
56
51
|
top: -2px;
|
|
57
52
|
right: 0;
|
|
@@ -124,20 +119,19 @@
|
|
|
124
119
|
|
|
125
120
|
.@{drawer-prefix-cls}-header {
|
|
126
121
|
padding: 13px 24px;
|
|
127
|
-
border-bottom: none;
|
|
128
122
|
position: absolute;
|
|
129
123
|
right: 0;
|
|
130
124
|
top: 0;
|
|
131
125
|
width: 100%;
|
|
132
126
|
background: #fff;
|
|
127
|
+
border-bottom: 1px solid #E9EDF3;
|
|
128
|
+
|
|
133
129
|
}
|
|
134
130
|
|
|
135
131
|
.@{drawer-prefix-cls}-body {
|
|
136
|
-
padding:
|
|
137
|
-
|
|
132
|
+
padding: 24px !important;
|
|
138
133
|
}
|
|
139
134
|
|
|
140
|
-
|
|
141
135
|
.@{drawer-prefix-cls}-wrapper-body {
|
|
142
136
|
|
|
143
137
|
.@{drawer-prefix-cls}-footer-style {
|
|
@@ -148,6 +142,11 @@
|
|
|
148
142
|
padding: 8px 24px;
|
|
149
143
|
background: #fff;
|
|
150
144
|
text-align: right;
|
|
145
|
+
border-top: 1px solid #E9EDF3;
|
|
146
|
+
|
|
147
|
+
.@{ant-prefix}-btn {
|
|
148
|
+
margin-left: 15px;
|
|
149
|
+
}
|
|
151
150
|
}
|
|
152
151
|
|
|
153
152
|
}
|
|
@@ -168,7 +168,7 @@
|
|
|
168
168
|
padding: 0;
|
|
169
169
|
color: @text-color-secondary;
|
|
170
170
|
font-weight: 700;
|
|
171
|
-
font-size:
|
|
171
|
+
font-size: @font-size-lg;
|
|
172
172
|
font-style: normal;
|
|
173
173
|
line-height: 56px;
|
|
174
174
|
text-align: center;
|
|
@@ -180,9 +180,7 @@
|
|
|
180
180
|
cursor: pointer;
|
|
181
181
|
transition: color @animation-duration-slow;
|
|
182
182
|
text-rendering: auto;
|
|
183
|
-
|
|
184
|
-
font-size: 20px;
|
|
185
|
-
}
|
|
183
|
+
|
|
186
184
|
&:focus,
|
|
187
185
|
&:hover {
|
|
188
186
|
color: @icon-color-hover;
|
package/es/form/form.less
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
@form-prefix-cls: ~'@{ant-prefix}-form';
|
|
2
2
|
|
|
3
|
-
.tnt-form{
|
|
4
|
-
.@{form-prefix-cls}-item{
|
|
5
|
-
min-height: @input-height-base;
|
|
3
|
+
.tnt-form {
|
|
4
|
+
.@{form-prefix-cls}-item {
|
|
5
|
+
// min-height: @input-height-base;
|
|
6
6
|
|
|
7
7
|
.@{form-prefix-cls}-item-required::before {
|
|
8
8
|
top: 2px;
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
line-height: @input-height-base;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
&-children{
|
|
25
|
+
&-children {
|
|
26
26
|
line-height: calc(@input-height-base - 2px);
|
|
27
27
|
}
|
|
28
28
|
}
|
|
@@ -31,6 +31,12 @@
|
|
|
31
31
|
.@{form-prefix-cls}-extra {
|
|
32
32
|
margin-top: 4px;
|
|
33
33
|
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
34
|
|
|
35
|
+
&.@{form-prefix-cls}-vertical{
|
|
36
|
+
.@{form-prefix-cls}-item {
|
|
37
|
+
&-label {
|
|
38
|
+
line-height: @line-height-base;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
package/es/form/style/index.less
CHANGED
|
@@ -83,9 +83,9 @@
|
|
|
83
83
|
position: relative;
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
&-with-help {
|
|
87
|
-
|
|
88
|
-
}
|
|
86
|
+
// &-with-help {
|
|
87
|
+
// margin-bottom: max(0, @form-item-margin-bottom - @form-explain-height - @form-help-margin-top);
|
|
88
|
+
// }
|
|
89
89
|
|
|
90
90
|
&-label {
|
|
91
91
|
display: inline-block;
|
|
@@ -310,9 +310,9 @@ form {
|
|
|
310
310
|
}
|
|
311
311
|
|
|
312
312
|
.@{form-prefix-cls}-vertical {
|
|
313
|
-
.@{form-prefix-cls}-item {
|
|
314
|
-
|
|
315
|
-
}
|
|
313
|
+
// .@{form-prefix-cls}-item {
|
|
314
|
+
// padding-bottom: 8px;
|
|
315
|
+
// }
|
|
316
316
|
.@{form-prefix-cls}-item-control {
|
|
317
317
|
line-height: @line-height-base;
|
|
318
318
|
}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
var __rest = this && this.__rest || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
4
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
5
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
6
|
+
}
|
|
7
|
+
return t;
|
|
8
|
+
};
|
|
9
|
+
import React from 'react';
|
|
10
|
+
import LocaleReceiver from 'antd/es/locale-provider/LocaleReceiver';
|
|
11
|
+
import toArray from "rc-util/es/Children/toArray";
|
|
12
|
+
import Icon from '../icon';
|
|
13
|
+
import PopConfirm from "../popconfirm";
|
|
14
|
+
import Divider from '../divider';
|
|
15
|
+
import Dropdown from '../dropdown';
|
|
16
|
+
import Tooltip from '../tooltip';
|
|
17
|
+
import { doUpperTitle } from '../utils';
|
|
18
|
+
import Menu from '../menu';
|
|
19
|
+
import './index.less';
|
|
20
|
+
const HandleIcon = props => {
|
|
21
|
+
return React.createElement(LocaleReceiver, {
|
|
22
|
+
componentName: "HandleIcon"
|
|
23
|
+
}, () => {
|
|
24
|
+
const _a = props || {},
|
|
25
|
+
{
|
|
26
|
+
children = [],
|
|
27
|
+
num = 5,
|
|
28
|
+
divider = false,
|
|
29
|
+
stopPropagation = true,
|
|
30
|
+
size = 'large'
|
|
31
|
+
} = _a,
|
|
32
|
+
rest = __rest(_a, ["children", "num", "divider", "stopPropagation", "size"]);
|
|
33
|
+
let newChildren = [];
|
|
34
|
+
if (Array.isArray(children)) {
|
|
35
|
+
newChildren = (children === null || children === void 0 ? void 0 : children.filter(item => !!item)) || [];
|
|
36
|
+
} else if (children) {
|
|
37
|
+
newChildren.push(children);
|
|
38
|
+
}
|
|
39
|
+
const flattenChildren = children => {
|
|
40
|
+
if (!children) {
|
|
41
|
+
return [];
|
|
42
|
+
}
|
|
43
|
+
return toArray(children).reduce(function (flatChildren, child) {
|
|
44
|
+
if (child && child.type === React.Fragment) {
|
|
45
|
+
return flatChildren.concat(flattenChildren(child.props.children));
|
|
46
|
+
}
|
|
47
|
+
flatChildren.push(child);
|
|
48
|
+
return flatChildren;
|
|
49
|
+
}, []);
|
|
50
|
+
};
|
|
51
|
+
// 解决需要Fragment包的场景
|
|
52
|
+
newChildren = flattenChildren(newChildren);
|
|
53
|
+
let [preChildPart, lastChildPart] = [newChildren, null];
|
|
54
|
+
// 只有1个时不适配
|
|
55
|
+
if (newChildren.length - num === 1) {
|
|
56
|
+
preChildPart = newChildren;
|
|
57
|
+
} else if (newChildren && num && !isNaN(num) && newChildren.length > num) {
|
|
58
|
+
preChildPart = newChildren.slice(0, num);
|
|
59
|
+
lastChildPart = newChildren.slice(num);
|
|
60
|
+
}
|
|
61
|
+
if (divider && preChildPart) {
|
|
62
|
+
preChildPart = preChildPart === null || preChildPart === void 0 ? void 0 : preChildPart.map((dom, i) => React.createElement(React.Fragment, null, dom, !(i === (preChildPart === null || preChildPart === void 0 ? void 0 : preChildPart.length) - 1 && !(lastChildPart === null || lastChildPart === void 0 ? void 0 : lastChildPart.length) // 没有更多 且 是最后一个时 不显示 Divider
|
|
63
|
+
) && React.createElement(Divider, {
|
|
64
|
+
type: "vertical"
|
|
65
|
+
})));
|
|
66
|
+
}
|
|
67
|
+
const decoratePopconfirm = (element, parentElement) => {
|
|
68
|
+
if (React.isValidElement(element)) {
|
|
69
|
+
const {
|
|
70
|
+
type,
|
|
71
|
+
props
|
|
72
|
+
} = element;
|
|
73
|
+
if (type === PopConfirm) {
|
|
74
|
+
const placement = {
|
|
75
|
+
placement: 'left'
|
|
76
|
+
};
|
|
77
|
+
const {
|
|
78
|
+
disabled
|
|
79
|
+
} = (parentElement === null || parentElement === void 0 ? void 0 : parentElement.props) || {};
|
|
80
|
+
let disableProps = {};
|
|
81
|
+
if (disabled) {
|
|
82
|
+
disableProps = {
|
|
83
|
+
disabled,
|
|
84
|
+
onConfirm: () => {}
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
return React.cloneElement(element, Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({
|
|
88
|
+
overlayStyle: {
|
|
89
|
+
width: 180
|
|
90
|
+
}
|
|
91
|
+
}, props || {}), {
|
|
92
|
+
onClick: e => e.stopPropagation()
|
|
93
|
+
}), placement), {
|
|
94
|
+
trigger: 'hover',
|
|
95
|
+
getPopupContainer: trigger => trigger.parentNode
|
|
96
|
+
}), disableProps || {}));
|
|
97
|
+
}
|
|
98
|
+
if (props && props.children) {
|
|
99
|
+
const modifiedChildren = React.Children.map(props.children, child => {
|
|
100
|
+
return decoratePopconfirm(child, element);
|
|
101
|
+
});
|
|
102
|
+
return React.cloneElement(element, props, modifiedChildren);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return element;
|
|
106
|
+
};
|
|
107
|
+
// 对更多的popConfirm
|
|
108
|
+
if (lastChildPart === null || lastChildPart === void 0 ? void 0 : lastChildPart.length) {
|
|
109
|
+
lastChildPart === null || lastChildPart === void 0 ? void 0 : lastChildPart.forEach((v, i) => {
|
|
110
|
+
v = decoratePopconfirm(v);
|
|
111
|
+
lastChildPart[i] = React.cloneElement(v, Object.assign(Object.assign({}, (v === null || v === void 0 ? void 0 : v.props) || {}), {
|
|
112
|
+
inMore: true
|
|
113
|
+
}));
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
const menu = childArr => React.createElement(Menu, {
|
|
117
|
+
className: `menu-handle-icon-more tnt-handle-icon-${size}`
|
|
118
|
+
}, childArr === null || childArr === void 0 ? void 0 : childArr.map((child, i) => React.createElement(Menu.Item, {
|
|
119
|
+
key: i
|
|
120
|
+
}, child)));
|
|
121
|
+
return React.createElement("div", Object.assign({
|
|
122
|
+
onClick: e => {
|
|
123
|
+
if (stopPropagation) {
|
|
124
|
+
e.stopPropagation();
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}, rest, {
|
|
128
|
+
className: `tnt-handle-icon-wrap tnt-handle-icon-${size} ${(rest === null || rest === void 0 ? void 0 : rest.className) || ''}`
|
|
129
|
+
}), preChildPart, !!(lastChildPart === null || lastChildPart === void 0 ? void 0 : lastChildPart.length) && React.createElement(Dropdown, {
|
|
130
|
+
overlay: menu(lastChildPart || []),
|
|
131
|
+
arrow: true,
|
|
132
|
+
onClick: e => {
|
|
133
|
+
stopPropagation && e.stopPropagation();
|
|
134
|
+
}
|
|
135
|
+
}, React.createElement(Icon, {
|
|
136
|
+
type: "more",
|
|
137
|
+
className: 'tnt-handle-icon-more'
|
|
138
|
+
})));
|
|
139
|
+
});
|
|
140
|
+
};
|
|
141
|
+
HandleIcon.Item = props => {
|
|
142
|
+
const {
|
|
143
|
+
children,
|
|
144
|
+
title,
|
|
145
|
+
desc,
|
|
146
|
+
tooltip = true,
|
|
147
|
+
inMore,
|
|
148
|
+
disabled,
|
|
149
|
+
upperCaseIgnore = []
|
|
150
|
+
} = props,
|
|
151
|
+
rest = __rest(props, ["children", "title", "desc", "tooltip", "inMore", "disabled", "upperCaseIgnore"]);
|
|
152
|
+
const upTitle = doUpperTitle(title, upperCaseIgnore);
|
|
153
|
+
;
|
|
154
|
+
const replaceIconWithText = element => {
|
|
155
|
+
if (React.isValidElement(element)) {
|
|
156
|
+
const {
|
|
157
|
+
type,
|
|
158
|
+
props: eleProps
|
|
159
|
+
} = element;
|
|
160
|
+
let disabledProps = {};
|
|
161
|
+
if (disabled) {
|
|
162
|
+
disabledProps = {
|
|
163
|
+
disabled,
|
|
164
|
+
onClick: e => {
|
|
165
|
+
e.stopPropagation();
|
|
166
|
+
},
|
|
167
|
+
className: ((eleProps === null || eleProps === void 0 ? void 0 : eleProps.className) || "") + (disabled ? ' disabled' : "")
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
// 如果是更多需要替换文字
|
|
171
|
+
if (type === Icon || type === 'img') {
|
|
172
|
+
if (inMore) {
|
|
173
|
+
return React.createElement("a", Object.assign({}, eleProps, disabledProps), upTitle);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
if (disabled && (type === Icon || ['img', 'a'].includes(type))) {
|
|
177
|
+
return React.cloneElement(element, Object.assign(Object.assign({}, (element === null || element === void 0 ? void 0 : element.props) || {}), disabledProps || {}));
|
|
178
|
+
}
|
|
179
|
+
if (eleProps && eleProps.children) {
|
|
180
|
+
const modifiedChildren = React.Children.map(eleProps.children, child => {
|
|
181
|
+
return replaceIconWithText(child);
|
|
182
|
+
});
|
|
183
|
+
return React.cloneElement(element, eleProps, modifiedChildren);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return element;
|
|
187
|
+
};
|
|
188
|
+
let newChildren = children;
|
|
189
|
+
if (Array.isArray(newChildren)) {
|
|
190
|
+
newChildren = children === null || children === void 0 ? void 0 : children.map(child => replaceIconWithText(child));
|
|
191
|
+
} else {
|
|
192
|
+
newChildren = replaceIconWithText(children);
|
|
193
|
+
}
|
|
194
|
+
if ((inMore && desc || !inMore) && tooltip) {
|
|
195
|
+
return React.createElement(Tooltip, Object.assign({
|
|
196
|
+
title: disabled ? desc || upTitle : upTitle
|
|
197
|
+
}, rest || {}), newChildren);
|
|
198
|
+
}
|
|
199
|
+
return newChildren;
|
|
200
|
+
};
|
|
201
|
+
export default HandleIcon;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/handle-icon/index.js"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,cAAc,MAAM,wCAAwC,CAAA;AACnE,OAAO,OAAO,MAAM,6BAA6B,CAAC;AAClD,OAAO,IAAI,MAAM,SAAS,CAAA;AAC1B,OAAO,UAAU,MAAM,eAAe,CAAA;AACtC,OAAO,OAAO,MAAM,YAAY,CAAA;AAChC,OAAO,QAAQ,MAAM,aAAa,CAAA;AAClC,OAAO,OAAO,MAAM,YAAY,CAAA;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AACvC,OAAO,IAAI,MAAM,SAAS,CAAA;AAC1B,OAAO,cAAc,CAAA;AAErB,MAAM,UAAU,GAAI,CAAC,KAAK,EAAE,EAAE;IAC5B,OAAO,CACL,oBAAC,cAAc,IAAC,aAAa,EAAC,YAAY,IACvC,GAAG,EAAE;QACJ,MAAM,KAOF,KAAK,IAAI,EAAE,EAPT,EACF,QAAQ,GAAG,EAAE,EACb,GAAG,GAAG,CAAC,EACP,OAAO,GAAG,KAAK,EACf,eAAe,GAAC,IAAI,EACpB,IAAI,GAAE,OAAO,OAEF,EADR,IAAI,cANL,yDAOL,CAAc,CAAA;QAGf,IAAI,WAAW,GAAG,EAAE,CAAA;QACpB,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;YAC3B,WAAW,GAAG,C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AAW,GAAE,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,GAAG,CAAC,KAAK,CAAA,EAAE,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC,CAAA;KACjE;SAAI;QACD,WAAW,GAAE,mBAAmB,CAAC,QAAQ,CAAC,CAAA;KAC7C;IAGD,IAAG,CAAC,CAAC,MAAM,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,OAAO,EAAC;QACxC,OAAO,CACH,oBAAC,OAAO,kBAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,IAAE,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,IAAM,CAAC,IAAI,IAAE,EAAE,CAAC,GAC/D,WAAW,CACN,CACb,CAAA;KACJ;IAED,OAAO,WAAW,CAAA;AAEtB,CAAC,CAAA;AACD,eAAe,UAAU,CAAA","sourcesContent":["import React from 'react'\nimport LocaleReceiver from 'antd/es/locale-provider/LocaleReceiver'\nimport toArray from \"rc-util/es/Children/toArray\";\nimport Icon from '../icon'\nimport PopConfirm from \"../popconfirm\"\nimport Divider from '../divider'\nimport Dropdown from '../dropdown'\nimport Tooltip from '../tooltip'\nimport { doUpperTitle } from '../utils'\nimport Menu from '../menu'\nimport './index.less'\n\nconst HandleIcon = (props) => {\n return (\n <LocaleReceiver componentName=\"HandleIcon\">\n {() => {\n const {\n children = [],\n num = 5,\n divider = false,\n stopPropagation=true,\n size= 'large',\n ...rest\n } = props || {}\n\n \n let newChildren = []\n if (Array.isArray(children)) {\n newChildren = children?.filter((item) => !!item) || []\n } else if (children) {\n newChildren.push(children)\n }\n\n const flattenChildren = (children) => {\n if (!children) {\n return [];\n }\n return toArray(children).reduce(function (flatChildren, child) {\n if (child && child.type === React.Fragment) {\n return flatChildren.concat(flattenChildren(child.props.children));\n }\n \n flatChildren.push(child);\n return flatChildren;\n }, []);\n }\n\n // 解决需要Fragment包的场景\n newChildren = flattenChildren(newChildren);\n\n let [preChildPart, lastChildPart] = [newChildren, null];\n \n // 只有1个时不适配\n if (newChildren.length - num === 1) {\n preChildPart = newChildren\n } else if (newChildren && num && !isNaN(num) && newChildren.length > num) {\n preChildPart = newChildren.slice(0, num)\n lastChildPart = newChildren.slice(num)\n }\n \n if (divider && preChildPart) {\n preChildPart = preChildPart?.map((dom, i) => (\n <>\n {dom}\n {!(\n (i === preChildPart?.length - 1 && !lastChildPart?.length) // 没有更多 且 是最后一个时 不显示 Divider\n ) && <Divider type=\"vertical\" />}\n </>\n ))\n }\n\n const decoratePopconfirm = (element, parentElement) => {\n if (React.isValidElement(element)) {\n const { type, props } = element;\n if (type === PopConfirm ) {\n const placement = { placement: 'left' }\n const {disabled} = parentElement?.props||{}\n let disableProps={};\n if(disabled){\n disableProps={\n disabled,\n onConfirm:()=>{}\n };\n }\n return React.cloneElement(element, {\n overlayStyle: { width: 180 },\n ...(props || {}),\n onClick: (e) => e.stopPropagation(),\n ...placement,\n trigger: 'hover',\n getPopupContainer: (trigger) => trigger.parentNode,\n ...disableProps||{}\n })\n }\n if (props && props.children) {\n const modifiedChildren = React.Children.map(props.children, (child) => {\n return decoratePopconfirm(child,element);\n });\n return React.cloneElement(element, props, modifiedChildren);\n }\n }\n return element;\n };\n \n\n // 对更多的popConfirm\n if(lastChildPart?.length){\n lastChildPart?.forEach((v, i) => {\n v = decoratePopconfirm(v);\n lastChildPart[i] = React.cloneElement(v, {\n ...(v?.props || {}),\n inMore:true,\n })\n }) \n }\n \n const menu = (childArr)=>(\n <Menu className={`menu-handle-icon-more tnt-handle-icon-${size}`}>\n {\n childArr?.map(\n (child,i) => (\n <Menu.Item key={i}>\n {child}\n </Menu.Item>\n )\n )\n }\n </Menu>\n );\n\n return (\n <div\n onClick={(e) => {\n if(stopPropagation){\n e.stopPropagation()\n }\n }}\n {...rest}\n className={`tnt-handle-icon-wrap tnt-handle-icon-${size} ${rest?.className||''}`}\n >\n {preChildPart}\n {!!lastChildPart?.length && (\n <Dropdown \n overlay={menu(lastChildPart || [])} \n arrow \n onClick={(e)=>{\n stopPropagation && e.stopPropagation()\n }}\n >\n <Icon type=\"more\" className='tnt-handle-icon-more'/>\n </Dropdown>\n )}\n </div>\n )\n }}\n </LocaleReceiver>\n )\n}\n\nHandleIcon.Item = (props) => {\n const {children, title, desc, tooltip=true, inMore, disabled,upperCaseIgnore=[],...rest} = props\n const upTitle = doUpperTitle(title,upperCaseIgnore);;\n\n const replaceIconWithText = (element) => {\n if (React.isValidElement(element)) {\n const { type, props:eleProps } = element;\n let disabledProps = {}\n if(disabled){\n disabledProps = {\n disabled,\n onClick:(e)=>{\n e.stopPropagation()\n },\n className:(eleProps?.className || \"\")+ (disabled?' disabled':\"\")\n }\n }\n // 如果是更多需要替换文字\n if (type === Icon || type ==='img') {\n if(inMore){\n return (\n <a \n {...eleProps}\n {...disabledProps}\n \n >{upTitle}</a>\n );\n }\n }\n\n if(disabled && (type===Icon || ['img','a'].includes(type))){\n return React.cloneElement(element, {\n ...element?.props || {} ,\n ...disabledProps||{}\n })\n }\n\n if (eleProps && eleProps.children) {\n const modifiedChildren = React.Children.map(eleProps.children, (child) => {\n return replaceIconWithText(child);\n });\n return React.cloneElement(element, eleProps, modifiedChildren);\n }\n }\n return element;\n };\n\n let newChildren = children;\n if(Array.isArray(newChildren)){\n newChildren= children?.map(child=> replaceIconWithText(child))\n }else{\n newChildren= replaceIconWithText(children)\n }\n\n\n if(((inMore && desc) || !inMore) && tooltip){\n return (\n <Tooltip title={disabled ? (desc||upTitle) : upTitle} {...(rest||{})}>\n {newChildren}\n </Tooltip>\n )\n }\n\n return newChildren\n \n}\nexport default HandleIcon"]}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
@small-size: 16px;
|
|
2
|
+
@middle-size: 18px;
|
|
3
|
+
@large-size: 20px;
|
|
4
|
+
.tnt-handle-icon-wrap{
|
|
5
|
+
>*:not(:last-child){
|
|
6
|
+
margin-right: 8px;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.menu-handle-icon-more{
|
|
11
|
+
min-width: 100px;
|
|
12
|
+
max-width: 300px;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
[class*=tnt-handle-icon]{
|
|
16
|
+
a{
|
|
17
|
+
display: block;
|
|
18
|
+
overflow: hidden;
|
|
19
|
+
white-space: nowrap;
|
|
20
|
+
text-overflow: ellipsis;
|
|
21
|
+
color:@text-color;
|
|
22
|
+
}
|
|
23
|
+
.icon-disabled,.disabled{
|
|
24
|
+
cursor: not-allowed;
|
|
25
|
+
pointer-events: auto;
|
|
26
|
+
color: @disabled-color;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
}
|
|
30
|
+
.tnt-handle-icon-small{
|
|
31
|
+
.tntd-anticon{
|
|
32
|
+
font-size: @small-size;
|
|
33
|
+
cursor: pointer;
|
|
34
|
+
}
|
|
35
|
+
font-size: @small-size;
|
|
36
|
+
line-height: 22px;
|
|
37
|
+
}
|
|
38
|
+
.tnt-handle-icon-middle{
|
|
39
|
+
.tntd-anticon{
|
|
40
|
+
font-size: @middle-size;
|
|
41
|
+
cursor: pointer;
|
|
42
|
+
}
|
|
43
|
+
font-size: @middle-size;
|
|
44
|
+
line-height: 22px;
|
|
45
|
+
}
|
|
46
|
+
.tnt-handle-icon-large{
|
|
47
|
+
.tntd-anticon{
|
|
48
|
+
font-size: @large-size;
|
|
49
|
+
cursor: pointer;
|
|
50
|
+
}
|
|
51
|
+
font-size: @large-size;
|
|
52
|
+
line-height: 22px;
|
|
53
|
+
}
|
package/es/icon/style/style.less
CHANGED
package/es/index.js
CHANGED
|
@@ -84,6 +84,7 @@ export { default as Columns } from './columns';
|
|
|
84
84
|
export { default as DevelopmentLogin } from './development-login';
|
|
85
85
|
export { default as LoadingButton } from './loading-button';
|
|
86
86
|
export { default as Handle } from './handle';
|
|
87
|
+
export { default as HandleIcon } from './handle-icon';
|
|
87
88
|
export { default as Page } from './page';
|
|
88
89
|
export { default as TntdSelect } from './tntd-select';
|
|
89
90
|
export { default as TntdRcSelect } from './tntd-rc-select';
|