tntd 2.7.2 → 2.7.3
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/affix/index.js +2 -1
- package/es/alert/index.js +2 -1
- package/es/anchor/index.js +2 -1
- package/es/array-input/icon.js +6 -24
- package/es/array-input/index.js +119 -203
- package/es/auth-context/index.js +2 -1
- package/es/auto-complete/index.js +2 -1
- package/es/avatar/index.js +2 -1
- package/es/back-top/index.js +2 -1
- package/es/badge/index.js +2 -1
- package/es/breadcrumb/index.js +2 -1
- package/es/button/index.js +2 -1
- package/es/calendar/index.js +2 -1
- package/es/card/index.js +2 -1
- package/es/carousel/index.js +2 -1
- package/es/cascader/index.js +2 -1
- package/es/checkbox/checkbox-group.js +2 -1
- package/es/checkbox/index.js +2 -1
- package/es/col/index.js +2 -1
- package/es/collapse/index.js +2 -1
- package/es/color-picker/ColorPicker.js +80 -126
- package/es/color-picker/index.js +5 -8
- package/es/color-picker/index.less +4 -0
- package/es/columns/index.js +30 -66
- package/es/columns/style/index.js +2 -1
- package/es/comment/index.js +2 -1
- package/es/config-provider/DisabledContext.js +5 -9
- package/es/config-provider/SizeContext.js +3 -7
- package/es/config-provider/config-provider.js +2 -1
- package/es/page/index.js +1 -1
- package/es/page/index.js.map +1 -1
- package/es/switch/switch.js.map +1 -1
- package/es/tntd-form/Form.js +13 -1
- package/es/tntd-form/Form.js.map +1 -1
- package/es/tntd-form/tntd-form.stories.js +7 -5
- package/es/tntd-form/tntd-form.stories.js.map +1 -1
- package/es/tntd-layout/HeaderActions.js +1 -1
- package/es/tntd-layout/HeaderActions.js.map +1 -1
- package/es/tree-select/index.js.map +1 -1
- package/lib/color-picker/index.less +4 -0
- package/lib/page/index.js +1 -1
- package/lib/page/index.js.map +1 -1
- package/lib/switch/switch.d.ts +1 -1
- package/lib/switch/switch.d.ts.map +1 -1
- package/lib/switch/switch.js.map +1 -1
- package/lib/tntd-form/Form.d.ts.map +1 -1
- package/lib/tntd-form/Form.js +12 -0
- package/lib/tntd-form/Form.js.map +1 -1
- package/lib/tntd-form/tntd-form.stories.d.ts.map +1 -1
- package/lib/tntd-form/tntd-form.stories.js +7 -5
- package/lib/tntd-form/tntd-form.stories.js.map +1 -1
- package/lib/tntd-layout/HeaderActions.js +1 -1
- package/lib/tntd-layout/HeaderActions.js.map +1 -1
- package/lib/tree-select/index.d.ts +7 -5
- package/lib/tree-select/index.d.ts.map +1 -1
- package/lib/tree-select/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,136 +1,90 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
12
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
13
|
-
}
|
|
14
|
-
return t;
|
|
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)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
15
11
|
};
|
|
16
12
|
import React, { useState, useCallback, useEffect, useMemo } from 'react';
|
|
17
|
-
import {
|
|
13
|
+
import { Popover, Icon } from 'antd';
|
|
14
|
+
import { AlphaPicker, BlockPicker, ChromePicker, CirclePicker, CompactPicker, GithubPicker, HuePicker, MaterialPicker, PhotoshopPicker, SketchPicker, SliderPicker, SwatchesPicker, TwitterPicker, } from 'react-color';
|
|
18
15
|
import cn from 'classnames';
|
|
16
|
+
import { isObject, upperFirst, toLower } from 'lodash';
|
|
19
17
|
import imgSrc from './tip.svg';
|
|
20
18
|
const prefixCls = 'tnt-color-picker';
|
|
21
19
|
const modeMap = {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
20
|
+
AlphaPicker,
|
|
21
|
+
BlockPicker,
|
|
22
|
+
ChromePicker,
|
|
23
|
+
CirclePicker,
|
|
24
|
+
CompactPicker,
|
|
25
|
+
GithubPicker,
|
|
26
|
+
HuePicker,
|
|
27
|
+
MaterialPicker,
|
|
28
|
+
PhotoshopPicker,
|
|
29
|
+
SketchPicker,
|
|
30
|
+
SliderPicker,
|
|
31
|
+
SwatchesPicker,
|
|
32
|
+
TwitterPicker,
|
|
35
33
|
};
|
|
36
34
|
const propsFormatMap = {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
colors
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
presetColors: colors
|
|
45
|
-
}, otherProps);
|
|
46
|
-
}
|
|
47
|
-
return otherProps;
|
|
48
|
-
}
|
|
35
|
+
SketchPicker: (_a) => {
|
|
36
|
+
var { colors } = _a, otherProps = __rest(_a, ["colors"]);
|
|
37
|
+
if (colors) {
|
|
38
|
+
return Object.assign({ presetColors: colors }, otherProps);
|
|
39
|
+
}
|
|
40
|
+
return otherProps;
|
|
41
|
+
},
|
|
49
42
|
};
|
|
50
43
|
export default function ColorPicker(_a) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
onVisibleChange: setVisible,
|
|
99
|
-
content: React.createElement(ModePicker, Object.assign({}, propsFormat(otherProps), {
|
|
100
|
-
color: value,
|
|
101
|
-
onChangeComplete: handleChange
|
|
102
|
-
})),
|
|
103
|
-
overlayClassName: `${prefixCls}-pop`
|
|
104
|
-
}, React.createElement("div", {
|
|
105
|
-
className: cn(prefixCls, className, {
|
|
106
|
-
[`${prefixCls}-selected`]: !!value,
|
|
107
|
-
[`${prefixCls}-disabled`]: disabled,
|
|
108
|
-
[`${prefixCls}-active`]: visible && !disabled,
|
|
109
|
-
[`${prefixCls}-sm`]: size === 'small',
|
|
110
|
-
[`${prefixCls}-lg`]: size === 'large'
|
|
111
|
-
}),
|
|
112
|
-
style: style,
|
|
113
|
-
onClick: domClick
|
|
114
|
-
}, React.createElement("div", {
|
|
115
|
-
className: `${prefixCls}-inner`
|
|
116
|
-
}, !!value ? React.createElement("div", {
|
|
117
|
-
className: `${prefixCls}-value`
|
|
118
|
-
}, React.createElement("div", {
|
|
119
|
-
className: `${prefixCls}-value-bg`,
|
|
120
|
-
style: {
|
|
121
|
-
background: value
|
|
122
|
-
}
|
|
123
|
-
})) : React.createElement("div", {
|
|
124
|
-
className: `${prefixCls}-placeholder`
|
|
125
|
-
}, placeholder), React.createElement("span", {
|
|
126
|
-
className: `${prefixCls}-img`
|
|
127
|
-
}, React.createElement("img", {
|
|
128
|
-
src: imgSrc
|
|
129
|
-
})), allowClear && !!value && !disabled && React.createElement("span", {
|
|
130
|
-
className: `${prefixCls}-clear`,
|
|
131
|
-
onClick: doClear
|
|
132
|
-
}, React.createElement(_Icon, {
|
|
133
|
-
type: "close-circle",
|
|
134
|
-
theme: "filled"
|
|
135
|
-
})))));
|
|
136
|
-
}
|
|
44
|
+
var { value: _value, onChange, visible: vs, allowClear, disabled, className, mode = 'sketch', style = {}, size, placeholder, placement = 'bottomLeft', locale } = _a, otherProps = __rest(_a, ["value", "onChange", "visible", "allowClear", "disabled", "className", "mode", "style", "size", "placeholder", "placement", "locale"]);
|
|
45
|
+
const [visible, setVisible] = useState(vs);
|
|
46
|
+
const [value, setValue] = useState(_value);
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
setValue(_value);
|
|
49
|
+
}, [_value]);
|
|
50
|
+
const handleChange = useCallback((color) => {
|
|
51
|
+
let value;
|
|
52
|
+
if (isObject(color === null || color === void 0 ? void 0 : color.rgb)) {
|
|
53
|
+
value = `rgba(${color.rgb.r},${color.rgb.g},${color.rgb.b},${color.rgb.a})`;
|
|
54
|
+
}
|
|
55
|
+
if (onChange) {
|
|
56
|
+
onChange(value);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
setValue(value);
|
|
60
|
+
}
|
|
61
|
+
}, [onChange]);
|
|
62
|
+
const domClick = useCallback(() => {
|
|
63
|
+
setVisible(true);
|
|
64
|
+
}, []);
|
|
65
|
+
const doClear = useCallback((e) => {
|
|
66
|
+
e.stopPropagation();
|
|
67
|
+
handleChange();
|
|
68
|
+
}, [handleChange]);
|
|
69
|
+
const [ModePicker, propsFormat] = useMemo(() => {
|
|
70
|
+
const modeKey = upperFirst(toLower(mode)) + 'Picker' || 'SketchPicker';
|
|
71
|
+
const ModePicker = modeMap[modeKey] || SketchPicker;
|
|
72
|
+
return [ModePicker, propsFormatMap[modeKey] || ((p) => p)];
|
|
73
|
+
}, [mode]);
|
|
74
|
+
return (React.createElement(Popover, { placement: placement, trigger: "click", visible: visible && !disabled, onVisibleChange: setVisible, content: React.createElement(ModePicker, Object.assign({}, propsFormat(otherProps), { color: value, onChangeComplete: handleChange })), overlayClassName: `${prefixCls}-pop` },
|
|
75
|
+
React.createElement("div", { className: cn(prefixCls, className, {
|
|
76
|
+
[`${prefixCls}-selected`]: !!value,
|
|
77
|
+
[`${prefixCls}-disabled`]: disabled,
|
|
78
|
+
[`${prefixCls}-active`]: visible && !disabled,
|
|
79
|
+
[`${prefixCls}-sm`]: size === 'small',
|
|
80
|
+
[`${prefixCls}-lg`]: size === 'large',
|
|
81
|
+
}), style: style, onClick: domClick },
|
|
82
|
+
React.createElement("div", { className: `${prefixCls}-inner` },
|
|
83
|
+
!!value ? (React.createElement("div", { className: `${prefixCls}-value` },
|
|
84
|
+
React.createElement("div", { className: `${prefixCls}-value-bg`, style: { background: value } }))) : (React.createElement("div", { className: `${prefixCls}-placeholder` }, placeholder)),
|
|
85
|
+
React.createElement("span", { className: `${prefixCls}-img` },
|
|
86
|
+
React.createElement("img", { src: imgSrc })),
|
|
87
|
+
allowClear && !!value && !disabled && (React.createElement("span", { className: `${prefixCls}-clear`, onClick: doClear },
|
|
88
|
+
React.createElement(Icon, { type: "close-circle", theme: "filled" })))))));
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=ColorPicker.js.map
|
package/es/color-picker/index.js
CHANGED
|
@@ -4,11 +4,8 @@ import LocaleReceiver from 'antd/es/locale-provider/LocaleReceiver';
|
|
|
4
4
|
import ColorPicker from './ColorPicker';
|
|
5
5
|
import './index.less';
|
|
6
6
|
export default function (props) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}, props));
|
|
13
|
-
});
|
|
14
|
-
}
|
|
7
|
+
return (React.createElement(LocaleReceiver, { componentName: "ColorPicker" }, (locale) => {
|
|
8
|
+
return React.createElement(ColorPicker, Object.assign({ locale: locale }, props));
|
|
9
|
+
}));
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
box-sizing: border-box;
|
|
42
42
|
display: inline-block;
|
|
43
43
|
border: @border-width-base @border-style-base @select-border-color;
|
|
44
|
+
background: @component-background;
|
|
44
45
|
border-radius: @border-radius-base;
|
|
45
46
|
cursor: pointer;
|
|
46
47
|
position: relative;
|
|
@@ -96,6 +97,9 @@
|
|
|
96
97
|
&-disabled {
|
|
97
98
|
background: @input-disabled-bg;
|
|
98
99
|
cursor: not-allowed;
|
|
100
|
+
&:hover {
|
|
101
|
+
border-color: @border-width-base;
|
|
102
|
+
}
|
|
99
103
|
.@{prefixCls}-img {
|
|
100
104
|
background: #e9edf3;
|
|
101
105
|
}
|
package/es/columns/index.js
CHANGED
|
@@ -1,75 +1,39 @@
|
|
|
1
|
-
var __rest = this && this.__rest || function (s, e) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
if (
|
|
6
|
-
|
|
7
|
-
|
|
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)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
8
11
|
};
|
|
9
12
|
import classnames from 'classnames';
|
|
10
13
|
import React from 'react';
|
|
11
14
|
import { Row, Col } from '../';
|
|
12
15
|
import './index.less';
|
|
13
16
|
const clsPrefix = 'tnt-columns';
|
|
14
|
-
export const Item = props => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
span,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
className: `${clsPrefix}-col`,
|
|
29
|
-
span: span < 4 ? 4 : span
|
|
30
|
-
}, React.createElement("div", null, (!tabList || tabList.length < 0) && React.createElement("div", {
|
|
31
|
-
className: `${clsPrefix}-col-header`
|
|
32
|
-
}, React.createElement("div", {
|
|
33
|
-
className: "title-left"
|
|
34
|
-
}, title), extra && React.createElement("div", {
|
|
35
|
-
className: "title-extra"
|
|
36
|
-
}, extra)), (tabList === null || tabList === void 0 ? void 0 : tabList.length) > 0 && React.createElement("div", {
|
|
37
|
-
className: `${clsPrefix}-col-tabs`,
|
|
38
|
-
tabType: tabType,
|
|
39
|
-
tabList: tabList
|
|
40
|
-
}, tabList.map(({
|
|
41
|
-
tab,
|
|
42
|
-
key
|
|
43
|
-
}) => React.createElement("span", {
|
|
44
|
-
className: classnames('tab-item', {
|
|
45
|
-
'active-tab': realActiveKey === key
|
|
46
|
-
}),
|
|
47
|
-
style: {
|
|
48
|
-
width: tabList && tabType === 'default' ? 'auto' : `${100 / tabList.length}%`
|
|
49
|
-
},
|
|
50
|
-
key: key,
|
|
51
|
-
onClick: () => onTabChange(key)
|
|
52
|
-
}, tab))), React.createElement("div", {
|
|
53
|
-
className: `${clsPrefix}-col-body`
|
|
54
|
-
}, children)));
|
|
17
|
+
export const Item = (props) => {
|
|
18
|
+
const { children, span, extra, title, tabList, defaultActiveTabKey, activeTabKey, tabType, onTabChange, } = props;
|
|
19
|
+
const realActiveKey = activeTabKey || defaultActiveTabKey;
|
|
20
|
+
return (React.createElement(Col, { className: `${clsPrefix}-col`, span: span < 4 ? 4 : span },
|
|
21
|
+
React.createElement("div", null,
|
|
22
|
+
(!tabList || tabList.length < 0) && (React.createElement("div", { className: `${clsPrefix}-col-header` },
|
|
23
|
+
React.createElement("div", { className: "title-left" }, title),
|
|
24
|
+
extra && React.createElement("div", { className: "title-extra" }, extra))),
|
|
25
|
+
(tabList === null || tabList === void 0 ? void 0 : tabList.length) > 0 && (React.createElement("div", { className: `${clsPrefix}-col-tabs`, tabType: tabType, tabList: tabList }, tabList.map(({ tab, key }) => (React.createElement("span", { className: classnames('tab-item', {
|
|
26
|
+
'active-tab': realActiveKey === key,
|
|
27
|
+
}), style: {
|
|
28
|
+
width: tabList && tabType === 'default' ? 'auto' : `${100 / tabList.length}%`,
|
|
29
|
+
}, key: key, onClick: () => onTabChange(key) }, tab))))),
|
|
30
|
+
React.createElement("div", { className: `${clsPrefix}-col-body` }, children))));
|
|
55
31
|
};
|
|
56
|
-
const Columns = props => {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
gutter = 0,
|
|
61
|
-
style
|
|
62
|
-
} = props,
|
|
63
|
-
rest = __rest(props, ["children", "height", "gutter", "style"]);
|
|
64
|
-
const rowStyle = Object.assign(Object.assign({}, style), {
|
|
65
|
-
height: props.height ? `${props.height}px` : 'calc(100vh)'
|
|
66
|
-
});
|
|
67
|
-
return React.createElement(Row, Object.assign({
|
|
68
|
-
className: classnames(clsPrefix, {
|
|
69
|
-
gutter
|
|
70
|
-
}),
|
|
71
|
-
style: rowStyle
|
|
72
|
-
}, rest), children);
|
|
32
|
+
const Columns = (props) => {
|
|
33
|
+
const { children, height, gutter = 0, style } = props, rest = __rest(props, ["children", "height", "gutter", "style"]);
|
|
34
|
+
const rowStyle = Object.assign(Object.assign({}, style), { height: props.height ? `${props.height}px` : 'calc(100vh)' });
|
|
35
|
+
return (React.createElement(Row, Object.assign({ className: classnames(clsPrefix, { gutter }), style: rowStyle }, rest), children));
|
|
73
36
|
};
|
|
74
37
|
Columns.Item = Item;
|
|
75
|
-
export default Columns;
|
|
38
|
+
export default Columns;
|
|
39
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
package/es/comment/index.js
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
const DisabledContext = React.createContext(false);
|
|
3
|
-
export const DisabledContextProvider = ({
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}) => {
|
|
7
|
-
const originDisabled = React.useContext(DisabledContext);
|
|
8
|
-
return React.createElement(DisabledContext.Provider, {
|
|
9
|
-
value: disabled !== null && disabled !== void 0 ? disabled : originDisabled
|
|
10
|
-
}, children);
|
|
3
|
+
export const DisabledContextProvider = ({ children, disabled }) => {
|
|
4
|
+
const originDisabled = React.useContext(DisabledContext);
|
|
5
|
+
return (React.createElement(DisabledContext.Provider, { value: disabled !== null && disabled !== void 0 ? disabled : originDisabled }, children));
|
|
11
6
|
};
|
|
12
|
-
export default DisabledContext;
|
|
7
|
+
export default DisabledContext;
|
|
8
|
+
//# sourceMappingURL=DisabledContext.js.map
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
const SizeContext = React.createContext(undefined);
|
|
3
|
-
export const SizeContextProvider = ({
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}) => React.createElement(SizeContext.Consumer, null, originSize => React.createElement(SizeContext.Provider, {
|
|
7
|
-
value: size || originSize
|
|
8
|
-
}, children));
|
|
9
|
-
export default SizeContext;
|
|
3
|
+
export const SizeContextProvider = ({ children, size }) => (React.createElement(SizeContext.Consumer, null, (originSize) => (React.createElement(SizeContext.Provider, { value: size || originSize }, children))));
|
|
4
|
+
export default SizeContext;
|
|
5
|
+
//# sourceMappingURL=SizeContext.js.map
|
package/es/page/index.js
CHANGED
|
@@ -82,7 +82,7 @@ const PageLayout = (_a) => {
|
|
|
82
82
|
}
|
|
83
83
|
const extraProps = Object.assign({ headerHeight: computedHeaderHeight, size, height: computedHeight, contentTotalMargin: inLayout ? '32px' : '0px', inLayout }, child.props);
|
|
84
84
|
if (!isPageBox(child)) {
|
|
85
|
-
return React.cloneElement(child,
|
|
85
|
+
return React.cloneElement(child, {}); // 如果是自定义的children,不需要读取参数
|
|
86
86
|
}
|
|
87
87
|
const { mode = 'gray', width } = child.props;
|
|
88
88
|
const style = {
|
package/es/page/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/page/index.js"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,YAAY,CAAA;AAC3B,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,IAAI,MAAM,cAAc,CAAA;AAC/B,OAAO,GAAG,MAAM,OAAO,CAAA;AACvB,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAEvD,OAAO,cAAc,CAAA;AAErB,MAAM,SAAS,GAAG,UAAU,CAAA;AAE5B,MAAM,SAAS,GAAG,CAAC,KAAK,EAAE,EAAE,WAAC,OAAA,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,MAAK,GAAG,KAAI,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,KAAK,0CAAE,OAAO,CAAA,CAAA,EAAA,CAAA;AAEzE,MAAM,UAAU,GAAG,CAAC,EAanB,EAAE,EAAE;;QAbe,EAClB,MAAM,GAAG,OAAO,EAChB,YAAY,GAAG,EAAE,EACjB,QAAQ,EACR,KAAK,EACL,MAAM,EACN,UAAU,EACV,MAAM,EACN,KAAK,EACL,IAAI,GAAG,OAAO,EACd,QAAQ,GAAG,KAAK,EAChB,SAAS,OAEV,EADI,SAAS,cAZM,2HAanB,CADa;IAEZ,mBAAmB;IACnB,IAAI,oBAAoB,GAAG,eAAe,CAAC,YAAY,CAAC,CAAA;IACxD,IAAI,cAAc,GAAG,eAAe,CAAC,MAAM,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,KAAK,CAAC,aAAa,CACxB,KAAK,EACL,EAAE,SAAS,EAAE,KAAK,EAAE,EACpB,KAAK,CAAC,YAAY,CAAC,KAAK,EAAE,UAAU,CAAC,CACtC,CAAA;QACH,CAAC,CAAC,CACE,CACE,CACX,CAAA;AACH,CAAC,CAAA;AAED,UAAU,CAAC,GAAG,GAAG,GAAG,CAAA;AAEpB,eAAe,UAAU,CAAA","sourcesContent":["import cn from 'classnames'\nimport React from 'react'\nimport Icon from '../tntd-icon'\nimport Box from './Box'\nimport { addUnitForValue, computeWidth } from './utils'\n\nimport './index.less'\n\nconst clsPrefix = 'tnt-page'\n\nconst isPageBox = (child) => child?.type === Box || child?.props?.pageBox\n\nconst PageLayout = ({\n height = '100vh',\n headerHeight = 50,\n children,\n title,\n goBack,\n goBackText,\n center,\n extra,\n size = 'small',\n inLayout = false,\n className,\n ...restProps\n}) => {\n // 如果传入只有数字,需要默认加px\n let computedHeaderHeight = addUnitForValue(headerHeight)\n let computedHeight = addUnitForValue(height)\n\n // 判断是否有标题栏\n if (!(title || extra || center)) {\n computedHeaderHeight = '0px'\n }\n\n if (inLayout) {\n computedHeaderHeight = '40px'\n }\n\n // 计算中间的zIndex,灰色递减,白色递增\n let whiteCols = 0\n let childrenToArray = []\n\n // 计算children type是box的数量\n let boxCount = 0\n\n // 如果children是单个节点,统一转为数组处理计算层级\n\n if (typeof children === 'object') {\n childrenToArray = [children]\n } else if (Array.isArray(children)) {\n childrenToArray = [...children]\n }\n\n React.Children.map(children, (child) => {\n if (isPageBox(child)) {\n boxCount += 1\n }\n })\n\n whiteCols = childrenToArray?.filter(({ props }) => props?.mode === 'white')?.length\n const total = childrenToArray?.length + 5\n let startIndex = total - whiteCols - 1\n let endIndex = total - 2\n const headerStyle = {\n height: computedHeaderHeight,\n padding: `${size === 'small' ? 20 : 24}px`,\n zIndex: inLayout ? 1 : total || 1,\n }\n const contentStyle = {\n display: boxCount > 0 ? 'flex' : 'block',\n marginTop: computedHeaderHeight,\n padding: inLayout ? '16px 20px' : '0px',\n }\n\n return (\n <section\n className={cn(clsPrefix, {\n [className]: className,\n 'in-layout': inLayout,\n 'not-in-layout': !inLayout,\n })}\n {...restProps}\n >\n {(title || goBack || center || extra) && (\n <div className={`${clsPrefix}-header`} style={headerStyle}>\n <div className={`${clsPrefix}-header-section`}>\n {goBack && (\n <div\n className=\"page-header-section-back\"\n onClick={() => {\n goBack()\n }}\n >\n <Icon type=\"left\" />\n <span>{goBackText ? goBackText : '返回'}</span>\n </div>\n )}\n {title}\n </div>\n {[center, extra].map((item, i) => (\n <div className={`${clsPrefix}-header-section`} key={i}>\n {item}\n </div>\n ))}\n </div>\n )}\n <div className={`${clsPrefix}-content`} style={contentStyle}>\n {React.Children.map(children, (child) => {\n // 如果children不是Box,就不需要多列布局\n if (!child.type) {\n return React.cloneElement(<div>{child}</div>)\n }\n\n const extraProps = {\n headerHeight: computedHeaderHeight,\n size,\n height: computedHeight,\n contentTotalMargin: inLayout ? '32px' : '0px',\n inLayout,\n ...child.props,\n }\n\n if (!isPageBox(child)) {\n return React.cloneElement(child, {}) // 如果是自定义的children,不需要读取参数\n }\n\n const { mode = 'gray', width } = child.props\n\n const style = {\n flex: computeWidth(width),\n // 设置cols层级关系\n zIndex: mode === 'gray' ? endIndex-- : startIndex++,\n }\n\n const className = cn(`${clsPrefix}-box ${clsPrefix}-box-${mode}`)\n\n return React.createElement(\n 'div',\n { className, style },\n React.cloneElement(child, extraProps)\n )\n })}\n </div>\n </section>\n )\n}\n\nPageLayout.Box = Box\n\nexport default PageLayout\n"]}
|
package/es/switch/switch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"switch.js","sourceRoot":"","sources":["../../src/switch/switch.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"switch.js","sourceRoot":"","sources":["../../src/switch/switch.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAA;AAEzC,OAAO,UAAU,MAAM,gBAAgB,CAAA;AAEvC,OAAO,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAA;AAErD,OAAO,sBAAsB,CAAA;AAE7B,cAAc,gBAAgB,CAAA;AAM9B,MAAM,CAAC,MAAM,MAAM,GAAG,wBAAwB,CAAC,UAAU,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,CACpE,oBAAC,UAAU,oBAAK,KAAK,IAAE,QAAQ,UAAG,CACnC,CAAoB,CAAA;AAErB,MAAM,CAAC,WAAW,GAAG,QAAQ,CAAA;AAE7B,eAAe,MAAM,CAAA","sourcesContent":["import React, { forwardRef } from 'react'\nimport type { FC } from 'react'\nimport AntdSwitch from 'antd/es/switch'\nimport type { SwitchProps as AntdSwitchProps } from 'antd/es/switch'\nimport { connectReadonlyComponent } from '../connect'\n\nimport 'antd/es/switch/style'\n\nexport * from 'antd/es/switch'\n\nexport type SwitchProps = AntdSwitchProps & {\n readonly?: boolean\n}\n\nexport const Switch = connectReadonlyComponent(AntdSwitch, (props) => (\n <AntdSwitch {...props} disabled />\n)) as FC<SwitchProps>\n\nSwitch.displayName = 'Switch'\n\nexport default Switch\n"]}
|
package/es/tntd-form/Form.js
CHANGED
|
@@ -12,7 +12,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
import classNames from 'classnames';
|
|
13
13
|
import FieldForm, { List, useWatch } from 'rc-field-form';
|
|
14
14
|
import * as React from 'react';
|
|
15
|
-
import { useMemo } from 'react';
|
|
15
|
+
import { useMemo, useEffect } from 'react';
|
|
16
16
|
import { ConfigContext } from '../config-provider';
|
|
17
17
|
import DisabledContext, { DisabledContextProvider } from '../config-provider/DisabledContext';
|
|
18
18
|
import SizeContext, { SizeContextProvider } from '../config-provider/SizeContext';
|
|
@@ -86,6 +86,18 @@ const InternalForm = (props, ref) => {
|
|
|
86
86
|
wrapForm.scrollToField(errorInfo.errorFields[0].name, defaultScrollToFirstError);
|
|
87
87
|
}
|
|
88
88
|
};
|
|
89
|
+
useEffect(() => {
|
|
90
|
+
// set initial values
|
|
91
|
+
if (restFormProps.initialValues) {
|
|
92
|
+
form === null || form === void 0 ? void 0 : form.setFieldsValue(restFormProps.initialValues);
|
|
93
|
+
}
|
|
94
|
+
// clear form fields value after unmount
|
|
95
|
+
return () => form.setFieldsValue(Object.keys(form.getFieldsValue() || {}).reduce((acc, cur) => {
|
|
96
|
+
acc[cur] = undefined;
|
|
97
|
+
return acc;
|
|
98
|
+
}, {}));
|
|
99
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
100
|
+
}, []);
|
|
89
101
|
return (React.createElement(DisabledContextProvider, { disabled: disabled },
|
|
90
102
|
React.createElement(SizeContextProvider, { size: size },
|
|
91
103
|
React.createElement(FormProvider, Object.assign({}, {
|
package/es/tntd-form/Form.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Form.js","sourceRoot":"","sources":["../../src/tntd-form/Form.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,UAAU,MAAM,YAAY,CAAA;AACnC,OAAO,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAGzD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"Form.js","sourceRoot":"","sources":["../../src/tntd-form/Form.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,UAAU,MAAM,YAAY,CAAA;AACnC,OAAO,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAGzD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAE1C,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,eAAe,EAAE,EA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,oBACP;gBACF,+CAA+C;gBAC/C,gBAAgB,EAAE,uBAAuB;aAC1C;gBAED,oBAAC,WAAW,CAAC,QAAQ,IAAC,KAAK,EAAE,gBAAgB;oBAC3C,oBAAC,SAAS,kBACR,EAAE,EAAE,IAAI,IACJ,aAAa,IACjB,IAAI,EAAE,IAAI,EACV,cAAc,EAAE,sBAAsB,EACtC,IAAI,EAAE,QAAQ,EACd,SAAS,EAAE,aAAa,IACxB,CACmB,CACV,CACK,CACE,CAC3B,CAAA;AACH,CAAC,CAAA;AAED,MAAM,IAAI,GAAG,KAAK,CAAC,UAAU,CAA0B,YAAY,CAE5C,CAAA;AAEvB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAgB,QAAQ,EAAE,CAAA;AAEhD,eAAe,IAAI,CAAA","sourcesContent":["import classNames from 'classnames'\nimport FieldForm, { List, useWatch } from 'rc-field-form'\nimport type { FormProps as RcFormProps } from 'rc-field-form/lib/Form'\nimport type { ValidateErrorEntity } from 'rc-field-form/lib/interface'\nimport * as React from 'react'\nimport { useMemo, useEffect } from 'react'\nimport type { Options } from 'scroll-into-view-if-needed'\nimport { ConfigContext } from '../config-provider'\nimport DisabledContext, { DisabledContextProvider } from '../config-provider/DisabledContext'\nimport type { SizeType } from '../config-provider/SizeContext'\nimport SizeContext, { SizeContextProvider } from '../config-provider/SizeContext'\nimport type { ColProps } from '../col'\nimport type { FormContextProps } from './context'\nimport { FormContext, FormProvider } from './context'\nimport ValidateMessagesContext from './validateMessagesContext'\nimport useForm, { FormInstance } from './hooks/useForm'\nimport type { FormLabelAlign } from './interface'\n\nexport type RequiredMark = boolean | 'optional'\nexport type FormLayout = 'horizontal' | 'inline' | 'vertical'\n\nexport interface FormProps<Values = any> extends Omit<RcFormProps<Values>, 'form'> {\n prefixCls?: string\n colon?: boolean\n name?: string\n layout?: FormLayout\n labelAlign?: FormLabelAlign\n labelWrap?: boolean\n labelCol?: ColProps\n wrapperCol?: ColProps\n form?: FormInstance<Values>\n size?: SizeType\n disabled?: boolean\n readonly?: boolean\n scrollToFirstError?: Options | boolean\n requiredMark?: RequiredMark\n /** @deprecated Will warning in future branch. Pls use `requiredMark` instead. */\n hideRequiredMark?: boolean\n}\n\nconst InternalForm: React.ForwardRefRenderFunction<FormInstance, FormProps> = (props, ref) => {\n const contextSize = React.useContext(SizeContext)\n const contextDisabled = React.useContext(DisabledContext)\n // TODO\n // @ts-ignore\n const { getPrefixCls, direction, form: contextForm } = React.useContext(ConfigContext)\n\n const {\n prefixCls: customizePrefixCls,\n className = '',\n size = contextSize,\n disabled = contextDisabled,\n form,\n colon,\n labelAlign,\n labelWrap,\n labelCol,\n wrapperCol,\n hideRequiredMark,\n layout = 'horizontal',\n scrollToFirstError,\n requiredMark,\n onFinishFailed,\n name,\n readonly,\n ...restFormProps\n } = props\n\n const contextValidateMessages = React.useContext(ValidateMessagesContext)\n\n const mergedRequiredMark = useMemo(() => {\n if (requiredMark !== undefined) {\n return requiredMark\n }\n\n if (contextForm && contextForm.requiredMark !== undefined) {\n return contextForm.requiredMark\n }\n\n if (hideRequiredMark) {\n return false\n }\n\n return true\n }, [hideRequiredMark, requiredMark, contextForm])\n\n const mergedColon = colon ?? contextForm?.colon\n\n const prefixCls = getPrefixCls('form', customizePrefixCls)\n\n const formClassName = classNames(\n prefixCls,\n {\n [`${prefixCls}-tntd`]: true,\n [`${prefixCls}-${layout}`]: true,\n [`${prefixCls}-hide-required-mark`]: mergedRequiredMark === false,\n [`${prefixCls}-rtl`]: direction === 'rtl',\n [`${prefixCls}-${size}`]: size,\n },\n className\n )\n\n const [wrapForm] = useForm(form)\n const { __INTERNAL__ } = wrapForm\n __INTERNAL__.name = name\n\n const formContextValue = useMemo<FormContextProps>(\n () => ({\n name,\n labelAlign,\n labelCol,\n labelWrap,\n wrapperCol,\n vertical: layout === 'vertical',\n colon: mergedColon,\n requiredMark: mergedRequiredMark,\n itemRef: __INTERNAL__.itemRef,\n form: wrapForm,\n readonly,\n }),\n [\n name,\n labelAlign,\n labelCol,\n labelWrap,\n wrapperCol,\n layout,\n mergedColon,\n mergedRequiredMark,\n wrapForm,\n readonly,\n ]\n )\n\n React.useImperativeHandle(ref, () => wrapForm)\n\n const onInternalFinishFailed = (errorInfo: ValidateErrorEntity) => {\n onFinishFailed?.(errorInfo)\n\n let defaultScrollToFirstError: Options = { block: 'nearest' }\n\n if (scrollToFirstError && errorInfo.errorFields.length) {\n if (typeof scrollToFirstError === 'object') {\n defaultScrollToFirstError = scrollToFirstError\n }\n wrapForm.scrollToField(errorInfo.errorFields[0].name, defaultScrollToFirstError)\n }\n }\n\n useEffect(() => {\n // set initial values\n if (restFormProps.initialValues) {\n form?.setFieldsValue(restFormProps.initialValues)\n }\n\n // clear form fields value after unmount\n return () =>\n form.setFieldsValue(\n Object.keys(form.getFieldsValue() || {}).reduce((acc, cur) => {\n acc[cur] = undefined\n return acc\n }, {})\n )\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [])\n\n return (\n <DisabledContextProvider disabled={disabled}>\n <SizeContextProvider size={size}>\n <FormProvider\n {...{\n // This is not list in API, we pass with spread\n validateMessages: contextValidateMessages,\n }}\n >\n <FormContext.Provider value={formContextValue}>\n <FieldForm\n id={name}\n {...restFormProps}\n name={name}\n onFinishFailed={onInternalFinishFailed}\n form={wrapForm}\n className={formClassName}\n />\n </FormContext.Provider>\n </FormProvider>\n </SizeContextProvider>\n </DisabledContextProvider>\n )\n}\n\nconst Form = React.forwardRef<FormInstance, FormProps>(InternalForm) as <Values = any>(\n props: React.PropsWithChildren<FormProps<Values>> & { ref?: React.Ref<FormInstance<Values>> }\n) => React.ReactElement\n\nexport { useForm, List, FormInstance, useWatch }\n\nexport default Form\n"]}
|
|
@@ -13,8 +13,8 @@ import React, { useEffect, useRef, useState } from 'react';
|
|
|
13
13
|
import Form from './index';
|
|
14
14
|
import { Input, InputNumber, Checkbox, Button, Select, Radio, Row, message, Icon, Modal, Drawer, Cascader, DatePicker, TimePicker, TreeSelect, Switch, Upload, } from '../index';
|
|
15
15
|
import moment from 'moment';
|
|
16
|
-
const { TreeNode } = TreeSelect;
|
|
17
16
|
const { Option } = Select;
|
|
17
|
+
const { TreeNode } = TreeSelect;
|
|
18
18
|
const options = [
|
|
19
19
|
{ label: 'Apple', value: 'apple' },
|
|
20
20
|
{ label: 'Pear', value: 'pear' },
|
|
@@ -50,8 +50,8 @@ Basic.args = {
|
|
|
50
50
|
React.createElement(Input, null)),
|
|
51
51
|
React.createElement(Form.Item, { label: "Password", name: "password", rules: [{ required: true, message: 'Please input your password!' }] },
|
|
52
52
|
React.createElement(Input.Password, null)),
|
|
53
|
-
React.createElement(Form.Item, { label: "TreeSelect", name: "treeSelect" },
|
|
54
|
-
React.createElement(TreeSelect, { treeDefaultExpandAll: true,
|
|
53
|
+
React.createElement(Form.Item, { label: "TreeSelect", name: "treeSelect", rules: [{ required: true, message: 'Please select one node' }] },
|
|
54
|
+
React.createElement(TreeSelect, { showSearch: true, treeDefaultExpandAll: true, allowClear: true },
|
|
55
55
|
React.createElement(TreeNode, { value: "parent 1", title: "parent 1", key: "0-1" },
|
|
56
56
|
React.createElement(TreeNode, { value: "parent 1-0", title: "parent 1-0", key: "0-1-1" },
|
|
57
57
|
React.createElement(TreeNode, { value: "leaf1", title: "my leaf", key: "random" }),
|
|
@@ -268,13 +268,14 @@ export const DynamicItemsComplex = DynamicItemsComplexTpl.bind({});
|
|
|
268
268
|
// 弹窗中表单
|
|
269
269
|
const FormInModalTpl = () => {
|
|
270
270
|
const [data, setData] = useState({});
|
|
271
|
+
const [destroyOnClose, setDestroyOnClose] = useState(true);
|
|
271
272
|
const [popupType, setPopupType] = useState('modal');
|
|
272
273
|
const PopupCom = {
|
|
273
274
|
modal: Modal,
|
|
274
275
|
drawer: Drawer,
|
|
275
276
|
}[popupType];
|
|
276
|
-
const [form] = Form.useForm();
|
|
277
277
|
const close = () => setData(null);
|
|
278
|
+
const [form] = Form.useForm();
|
|
278
279
|
return (React.createElement(React.Fragment, null,
|
|
279
280
|
React.createElement(Button, { type: "primary", onClick: () => setData({}), style: { marginRight: 12 } }, "\u65B0\u5EFA"),
|
|
280
281
|
React.createElement(Button, { type: "primary", style: { marginRight: 12, marginBottom: 12 }, onClick: () => setData({
|
|
@@ -286,7 +287,8 @@ const FormInModalTpl = () => {
|
|
|
286
287
|
React.createElement(Radio.Group, { value: popupType, onChange: (evt) => setPopupType(evt.target.value) },
|
|
287
288
|
React.createElement(Radio.Button, { value: "modal" }, "\u5F39\u7A97"),
|
|
288
289
|
React.createElement(Radio.Button, { value: "drawer" }, "\u62BD\u5C49")),
|
|
289
|
-
React.createElement(
|
|
290
|
+
React.createElement(Switch, { onClick: () => setDestroyOnClose(!destroyOnClose), checked: destroyOnClose, checkedChildren: "\u5173\u95ED\u65F6\u9500\u6BC1\u5B50\u5143\u7D20", unCheckedChildren: "\u5173\u95ED\u65F6\u4E0D\u9500\u6BC1\u5B50\u5143\u7D20" }),
|
|
291
|
+
React.createElement(PopupCom, { title: `${(data === null || data === void 0 ? void 0 : data.id) ? '编辑' : '新建'}`, visible: !!data, width: "40%", destroyOnClose: destroyOnClose, onClose: close, onCancel: close, onOk: close },
|
|
290
292
|
React.createElement(Form, { initialValues: data, form: form },
|
|
291
293
|
React.createElement(Form.Item, { name: "name", label: "\u540D\u79F0" },
|
|
292
294
|
React.createElement(Input, null)),
|