tntd 2.7.27 → 2.7.29-beta.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/_util/context.js +14 -0
- package/es/_util/context.js.map +1 -0
- package/es/_util/defaultRenderEmpty.js +20 -0
- package/es/_util/defaultRenderEmpty.js.map +1 -0
- package/es/_util/hooks/useFlexGapSupport.js +10 -0
- package/es/_util/hooks/useFlexGapSupport.js.map +1 -0
- package/es/_util/hooks/useForceUpdate.js +6 -0
- package/es/_util/hooks/useForceUpdate.js.map +1 -0
- package/es/_util/motion.js +22 -0
- package/es/_util/motion.js.map +1 -1
- package/es/_util/reactNode.js +15 -0
- package/es/_util/reactNode.js.map +1 -0
- package/es/_util/responsiveObserve.js +58 -0
- package/es/_util/responsiveObserve.js.map +1 -0
- package/es/_util/styleChecker.js +27 -0
- package/es/_util/styleChecker.js.map +1 -0
- package/es/_util/type.js.map +1 -1
- package/es/_util/warning.js.map +1 -1
- package/es/button/button.js +5 -17
- package/es/button/button.js.map +1 -1
- package/es/grid/RowContext.js +4 -0
- package/es/grid/RowContext.js.map +1 -0
- package/es/grid/col.js +78 -0
- package/es/grid/col.js.map +1 -0
- package/es/grid/hooks/useBreakpoint.js +19 -0
- package/es/grid/hooks/useBreakpoint.js.map +1 -0
- package/es/grid/index.js +13 -0
- package/es/grid/index.js.map +1 -0
- package/es/grid/row.js +141 -0
- package/es/grid/row.js.map +1 -0
- package/es/grid/style/index.js +3 -0
- package/es/grid/style/index.js.map +1 -0
- package/es/grid/style/index.less +124 -0
- package/es/grid/style/mixin.less +57 -0
- package/es/grid/style/rtl.less +69 -0
- package/es/handle/index.js +4 -29
- package/es/handle/index.js.map +1 -1
- package/es/index.js +2 -0
- package/es/index.js.map +1 -1
- package/es/modal/modal.js +2 -2
- package/es/modal/modal.js.map +1 -1
- package/es/table/constants.js +0 -53
- package/es/table/constants.js.map +1 -1
- package/es/table/table.js +8 -48
- package/es/table/table.js.map +1 -1
- package/es/tntd-form/ErrorList.js +1 -1
- package/es/tntd-form/ErrorList.js.map +1 -1
- package/es/tntd-form/FormItem/ItemHolder.js +1 -1
- package/es/tntd-form/FormItem/ItemHolder.js.map +1 -1
- package/es/tntd-form/FormItem/index.js +3 -3
- package/es/tntd-form/FormItem/index.js.map +1 -1
- package/es/tntd-form/FormItemInput.js +1 -1
- package/es/tntd-form/FormItemInput.js.map +1 -1
- package/es/tntd-form/FormItemLabel.js +1 -1
- package/es/tntd-form/FormItemLabel.js.map +1 -1
- package/es/tntd-form/FormList.js +1 -1
- package/es/tntd-form/FormList.js.map +1 -1
- package/es/tntd-form/hooks/useFormItemStatus.js +1 -1
- package/es/tntd-form/hooks/useFormItemStatus.js.map +1 -1
- package/es/tntd-form/index.js +0 -1
- package/es/tntd-form/index.js.map +1 -1
- package/es/utils/lang.js +8 -8
- package/es/utils/lang.js.map +1 -1
- package/lib/_util/context.d.ts +42 -0
- package/lib/_util/context.d.ts.map +1 -0
- package/lib/_util/context.js +20 -0
- package/lib/_util/context.js.map +1 -0
- package/lib/_util/defaultRenderEmpty.d.ts +5 -0
- package/lib/_util/defaultRenderEmpty.d.ts.map +1 -0
- package/lib/_util/defaultRenderEmpty.js +48 -0
- package/lib/_util/defaultRenderEmpty.js.map +1 -0
- package/lib/_util/hooks/useFlexGapSupport.d.ts +3 -0
- package/lib/_util/hooks/useFlexGapSupport.d.ts.map +1 -0
- package/lib/_util/hooks/useFlexGapSupport.js +35 -0
- package/lib/_util/hooks/useFlexGapSupport.js.map +1 -0
- package/lib/_util/hooks/useForceUpdate.d.ts +3 -0
- package/lib/_util/hooks/useForceUpdate.d.ts.map +1 -0
- package/lib/_util/hooks/useForceUpdate.js +32 -0
- package/lib/_util/hooks/useForceUpdate.js.map +1 -0
- package/lib/_util/motion.d.ts +3 -0
- package/lib/_util/motion.d.ts.map +1 -1
- package/lib/_util/motion.js +22 -0
- package/lib/_util/motion.js.map +1 -1
- package/lib/_util/reactNode.d.ts +9 -0
- package/lib/_util/reactNode.d.ts.map +1 -0
- package/lib/_util/reactNode.js +44 -0
- package/lib/_util/reactNode.js.map +1 -0
- package/lib/_util/responsiveObserve.d.ts +22 -0
- package/lib/_util/responsiveObserve.d.ts.map +1 -0
- package/lib/_util/responsiveObserve.js +61 -0
- package/lib/_util/responsiveObserve.js.map +1 -0
- package/lib/_util/styleChecker.d.ts +5 -0
- package/lib/_util/styleChecker.d.ts.map +1 -0
- package/lib/_util/styleChecker.js +35 -0
- package/lib/_util/styleChecker.js.map +1 -0
- package/lib/_util/type.d.ts.map +1 -1
- package/lib/_util/type.js.map +1 -1
- package/lib/_util/warning.d.ts.map +1 -1
- package/lib/_util/warning.js.map +1 -1
- package/lib/button/button.d.ts +5 -1
- package/lib/button/button.d.ts.map +1 -1
- package/lib/button/button.js +5 -17
- package/lib/button/button.js.map +1 -1
- package/lib/checkbox/checkbox-group.d.ts +1 -1
- package/lib/descriptions/descriptions.d.ts +1 -1
- package/lib/descriptions/descriptions.d.ts.map +1 -1
- package/lib/grid/RowContext.d.ts +9 -0
- package/lib/grid/RowContext.d.ts.map +1 -0
- package/lib/grid/RowContext.js +6 -0
- package/lib/grid/RowContext.js.map +1 -0
- package/lib/grid/col.d.ts +29 -0
- package/lib/grid/col.d.ts.map +1 -0
- package/lib/grid/col.js +106 -0
- package/lib/grid/col.js.map +1 -0
- package/lib/grid/hooks/useBreakpoint.d.ts +4 -0
- package/lib/grid/hooks/useBreakpoint.d.ts.map +1 -0
- package/lib/grid/hooks/useBreakpoint.js +24 -0
- package/lib/grid/hooks/useBreakpoint.js.map +1 -0
- package/lib/grid/index.d.ts +12 -0
- package/lib/grid/index.d.ts.map +1 -0
- package/lib/grid/index.js +20 -0
- package/lib/grid/index.js.map +1 -0
- package/lib/grid/row.d.ts +21 -0
- package/lib/grid/row.d.ts.map +1 -0
- package/lib/grid/row.js +169 -0
- package/lib/grid/row.js.map +1 -0
- package/lib/grid/style/index.d.ts +2 -0
- package/lib/grid/style/index.d.ts.map +1 -0
- package/lib/grid/style/index.js +5 -0
- package/lib/grid/style/index.js.map +1 -0
- package/lib/grid/style/index.less +124 -0
- package/lib/grid/style/mixin.less +57 -0
- package/lib/grid/style/rtl.less +69 -0
- package/lib/handle/index.d.ts.map +1 -1
- package/lib/handle/index.js +4 -29
- package/lib/handle/index.js.map +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +5 -1
- package/lib/index.js.map +1 -1
- package/lib/input/input.d.ts +4 -4
- package/lib/input/input.d.ts.map +1 -1
- package/lib/input-number/index.d.ts +1 -1
- package/lib/modal/modal.d.ts +5 -1
- package/lib/modal/modal.d.ts.map +1 -1
- package/lib/modal/modal.js +2 -2
- package/lib/modal/modal.js.map +1 -1
- package/lib/query-form/Field/fieldsMap.d.ts +3 -3
- package/lib/radio/radio-group.d.ts +1 -1
- package/lib/segmented/index.d.ts +1 -1
- package/lib/segmented/index.d.ts.map +1 -1
- package/lib/svg-components/illustration-403.d.ts +1 -1
- package/lib/svg-components/illustration-404.d.ts +1 -1
- package/lib/svg-components/illustration-500.d.ts +1 -1
- package/lib/svg-components/illustration-empty.d.ts +1 -1
- package/lib/svg-components/illustration-failure.d.ts +1 -1
- package/lib/svg-components/illustration-no-access.d.ts +1 -1
- package/lib/svg-components/illustration-no-chart.d.ts +1 -1
- package/lib/svg-components/illustration-no-result.d.ts +1 -1
- package/lib/svg-components/illustration-offline.d.ts +1 -1
- package/lib/svg-components/illustration-success.d.ts +1 -1
- package/lib/table/assets/image-loading-background.d.ts +1 -1
- package/lib/table/assets/image-loading.d.ts +1 -1
- package/lib/table/constants.d.ts +0 -2
- package/lib/table/constants.d.ts.map +1 -1
- package/lib/table/constants.js +1 -54
- package/lib/table/constants.js.map +1 -1
- package/lib/table/table.d.ts +1 -1
- package/lib/table/table.d.ts.map +1 -1
- package/lib/table/table.js +9 -49
- package/lib/table/table.js.map +1 -1
- package/lib/time-picker/index.d.ts +1 -1
- package/lib/tntd-cascader/AntdCascader/config/utils.d.ts +1 -1
- package/lib/tntd-form/ErrorList.js +1 -1
- package/lib/tntd-form/ErrorList.js.map +1 -1
- package/lib/tntd-form/FormItem/ItemHolder.js +2 -2
- package/lib/tntd-form/FormItem/ItemHolder.js.map +1 -1
- package/lib/tntd-form/FormItem/index.js +3 -3
- package/lib/tntd-form/FormItem/index.js.map +1 -1
- package/lib/tntd-form/FormItemInput.d.ts +1 -1
- package/lib/tntd-form/FormItemInput.d.ts.map +1 -1
- package/lib/tntd-form/FormItemInput.js +1 -1
- package/lib/tntd-form/FormItemInput.js.map +1 -1
- package/lib/tntd-form/FormItemLabel.d.ts +1 -1
- package/lib/tntd-form/FormItemLabel.d.ts.map +1 -1
- package/lib/tntd-form/FormItemLabel.js +1 -1
- package/lib/tntd-form/FormItemLabel.js.map +1 -1
- package/lib/tntd-form/FormList.js +1 -1
- package/lib/tntd-form/FormList.js.map +1 -1
- package/lib/tntd-form/hooks/useFormItemStatus.js +1 -1
- package/lib/tntd-form/hooks/useFormItemStatus.js.map +1 -1
- package/lib/tntd-form/index.d.ts.map +1 -1
- package/lib/tntd-form/index.js +0 -1
- package/lib/tntd-form/index.js.map +1 -1
- package/lib/tntd-form/tntd-form.stories.d.ts +1 -1
- package/lib/utils/lang.d.ts +5 -1
- package/lib/utils/lang.d.ts.map +1 -1
- package/lib/utils/lang.js +14 -12
- package/lib/utils/lang.js.map +1 -1
- package/package.json +104 -105
- package/themes/default/variables.less +124 -7
- package/themes/utils/colorPalette.less +12 -0
package/es/table/table.js
CHANGED
|
@@ -20,9 +20,9 @@ import Ellipsis from '../ellipsis';
|
|
|
20
20
|
import { TableContext } from './context';
|
|
21
21
|
import { useColumnSetting } from './hooks';
|
|
22
22
|
import { normalizeColumns } from './utils';
|
|
23
|
+
import { titleCaseUpper } from '../utils/lang';
|
|
23
24
|
import { TotalShower } from './total-shower';
|
|
24
25
|
import { getLanguage } from '../prev-locale';
|
|
25
|
-
import { articles, prepositions } from './constants';
|
|
26
26
|
const sizeWidthMap = {
|
|
27
27
|
default: 40,
|
|
28
28
|
middle: 20,
|
|
@@ -32,47 +32,6 @@ const sizeWidthMap = {
|
|
|
32
32
|
const getDefaultPagination = (locale) => ({
|
|
33
33
|
showTotal: (total) => React.createElement(TotalShower, { total: total, locale: locale }),
|
|
34
34
|
});
|
|
35
|
-
const titleHandle = (str, upperCaseIgnore, isPrompt) => {
|
|
36
|
-
if (isPrompt) {
|
|
37
|
-
const lowerCaseWord = str.toLowerCase();
|
|
38
|
-
return lowerCaseWord.charAt(0).toUpperCase() + lowerCaseWord.slice(1);
|
|
39
|
-
}
|
|
40
|
-
const words = str.split(' ');
|
|
41
|
-
const capitalizedWords = words.map((word, i) => {
|
|
42
|
-
const lowerCaseWord = word.toLowerCase();
|
|
43
|
-
let ignoreList = prepositions.concat(articles);
|
|
44
|
-
if (upperCaseIgnore === null || upperCaseIgnore === void 0 ? void 0 : upperCaseIgnore.length) {
|
|
45
|
-
ignoreList = ignoreList.concat(upperCaseIgnore);
|
|
46
|
-
ignoreList = Array.from(new Set(ignoreList));
|
|
47
|
-
}
|
|
48
|
-
if (ignoreList.includes(lowerCaseWord) && i !== 0) {
|
|
49
|
-
return lowerCaseWord;
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
return word.charAt(0).toUpperCase() + word.slice(1);
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
return capitalizedWords.join(' ');
|
|
56
|
-
};
|
|
57
|
-
// 表头转换为首字母大写
|
|
58
|
-
const titleCaseUpper = (str, upperCaseIgnore, isPrompt) => {
|
|
59
|
-
if (!str) {
|
|
60
|
-
return str;
|
|
61
|
-
}
|
|
62
|
-
if (typeof str === 'string') {
|
|
63
|
-
// 有斜杠根据斜杠划分
|
|
64
|
-
if (str === null || str === void 0 ? void 0 : str.includes('/')) {
|
|
65
|
-
const parWords = str.split('/');
|
|
66
|
-
return parWords
|
|
67
|
-
.map((str1) => {
|
|
68
|
-
return titleHandle(str1, upperCaseIgnore, isPrompt);
|
|
69
|
-
})
|
|
70
|
-
.join('/');
|
|
71
|
-
}
|
|
72
|
-
return titleHandle(str, upperCaseIgnore, isPrompt);
|
|
73
|
-
}
|
|
74
|
-
return str;
|
|
75
|
-
};
|
|
76
35
|
// 判断是否是特殊的tooltip
|
|
77
36
|
// const checkIsPrompt = (dom: any): boolean => {
|
|
78
37
|
// let isPrompt: boolean = false
|
|
@@ -110,26 +69,27 @@ export const Table = (_a) => {
|
|
|
110
69
|
}
|
|
111
70
|
if (React.isValidElement(title)) {
|
|
112
71
|
const renderChildren = (children) => {
|
|
72
|
+
var _a;
|
|
113
73
|
if (React.isValidElement(children) || Array.isArray(children)) {
|
|
114
|
-
return React.Children.map(children, (child) => {
|
|
74
|
+
return (_a = React === null || React === void 0 ? void 0 : React.Children) === null || _a === void 0 ? void 0 : _a.map(children, (child) => {
|
|
115
75
|
var _a;
|
|
116
76
|
if (React.isValidElement(child)) {
|
|
117
77
|
const childProps = (child.props || {});
|
|
118
78
|
return React.cloneElement(child, Object.assign(Object.assign({}, childProps), { children: ((_a = childProps.children) === null || _a === void 0 ? void 0 : _a.length)
|
|
119
79
|
? renderChildren(childProps.children)
|
|
120
|
-
: childProps.children, title: titleCaseUpper(childProps === null || childProps === void 0 ? void 0 : childProps.title, upperCaseIgnore
|
|
80
|
+
: childProps.children, title: titleCaseUpper(childProps === null || childProps === void 0 ? void 0 : childProps.title, upperCaseIgnore) }));
|
|
121
81
|
}
|
|
122
82
|
else {
|
|
123
|
-
return titleCaseUpper(child, upperCaseIgnore
|
|
83
|
+
return titleCaseUpper(child, upperCaseIgnore);
|
|
124
84
|
}
|
|
125
85
|
});
|
|
126
86
|
}
|
|
127
|
-
return titleCaseUpper(children, upperCaseIgnore
|
|
87
|
+
return titleCaseUpper(children, upperCaseIgnore);
|
|
128
88
|
};
|
|
129
89
|
return renderChildren(title.props.children);
|
|
130
90
|
}
|
|
131
91
|
if (typeof title === 'string') {
|
|
132
|
-
return titleCaseUpper(title, upperCaseIgnore
|
|
92
|
+
return titleCaseUpper(title, upperCaseIgnore);
|
|
133
93
|
}
|
|
134
94
|
} });
|
|
135
95
|
});
|
|
@@ -149,7 +109,7 @@ export const Table = (_a) => {
|
|
|
149
109
|
if (column.width && !String(column.width).includes('%')) {
|
|
150
110
|
let width = column.width;
|
|
151
111
|
if (typeof width === 'string') {
|
|
152
|
-
width = width.replace(/[^\d]/g, ' ');
|
|
112
|
+
width = width === null || width === void 0 ? void 0 : width.replace(/[^\d]/g, ' ');
|
|
153
113
|
}
|
|
154
114
|
widthLimitObj = {
|
|
155
115
|
widthLimit: Number(width) -
|
package/es/table/table.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.js","sourceRoot":"","sources":["../../src/table/table.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO,cAAc,MAAM,wCAAwC,CAAA;AAOnE,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,eAAe,CAAA;AACpD,OAAO,MAAM,MAAM,sBAAsB,CAAA;AACzC,OAAO,WAAW,MAAM,2BAA2B,CAAA;AACnD,OAAO,UAAU,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAC9C,OAAO,QAAQ,MAAM,aAAa,CAAA;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAEpD,MAAM,YAAY,GAAG;IAC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AY,EAAE,EAAE,EAAE;YACpB,MAAM,SAAS,GAAG,YAAY,CAAC,OAAO,CAAC,CAAA;YACvC,OAAO,CACL,6BAAK,GAAG,EAAE,cAAc;gBACtB,oBAAC,cAAc,IAAC,aAAa,EAAC,OAAO,EAAC,aAAa,EAAE,MAAM,IACxD,CAAC,YAAY,EAAE,EAAE;oBAChB,0DAA0D;oBAC1D,oFAAoF;oBACpF,OAAO,CACL,oBAAC,SAAS,kBACR,SAAS,EAAE,UAAU;wBACnB,aAAa;wBACb,mBAAmB,EACnB;4BACE,CAAC,GAAG,SAAS,aAAa,CAAC,EAAE,CAAC,QAAQ;4BACtC,CAAC,GAAG,SAAS,oBAAoB,CAAC,EAAE,CAAC,eAAe;4BACpD,CAAC,GAAG,SAAS,aAAa,CAAC,EAAE,IAAI,KAAK,OAAO;4BAC7C,CAAC,GAAG,SAAS,cAAc,CAAC,EAAE,IAAI,KAAK,QAAQ;4BAC/C,CAAC,GAAG,SAAS,cAAc,CAAC,EAAE,IAAI,KAAK,QAAQ;4BAC/C,CAAC,GAAG,SAAS,UAAU,CAAC,EAAE,OAAO;4BACjC,CAAC,GAAG,SAAS,WAAW,CAAC,EAAE,QAAQ;yBACpC,EACD,SAAS,CACV,EACD,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,UAAU,IACf,IAAI,EACR,CACH,CAAA;gBACH,CAAC,CACc,CACb,CACP,CAAA;QACH,CAAC,CACc,CACK,CACzB,CAAA;AACH,CAAC,CAAA;AAED,KAAK,CAAC,MAAM,GAAG,MAAM,CAAA;AACrB,KAAK,CAAC,WAAW,GAAG,WAAW,CAAA;AAC/B,KAAK,CAAC,WAAW,GAAG,OAAO,CAAA;AAC3B,KAAK,CAAC,cAAc,GAAG,cAAc,CAAA","sourcesContent":["import { ConfigConsumer } from 'antd/es/config-provider'\nimport LocaleReceiver from 'antd/es/locale-provider/LocaleReceiver'\nimport type {\n TableProps as AntdTableProps,\n ColumnProps,\n TableStateFilters,\n SortOrder,\n} from 'antd/es/table'\nimport { default as AntdTable } from 'antd/es/table'\nimport Column from 'antd/es/table/Column'\nimport ColumnGroup from 'antd/es/table/ColumnGroup'\nimport classNames from 'classnames'\nimport React, { useMemo, useRef } from 'react'\nimport Ellipsis from '../ellipsis'\nimport { TableContext } from './context'\nimport { useColumnSetting } from './hooks'\nimport { normalizeColumns } from './utils'\nimport { TotalShower } from './total-shower'\nimport { getLanguage } from '../prev-locale'\nimport { articles, prepositions } from './constants'\n\nconst sizeWidthMap = {\n default: 40, //20\n middle: 20, //10\n small: 20, //10\n xs: 16, // 8\n}\n\nexport type TableProps<T> = Omit<AntdTableProps<T>, 'locale'> & {\n storageKey?: string\n enableToolbar?: boolean\n showCellBorders?: boolean\n striped?: boolean\n shadowed?: boolean\n locale?: AntdTableProps<T>['locale'] & {\n loadingDescription?: string\n emptyText?: string\n }\n refresh?(): void\n unUpperConverted?: boolean // 不要转换表头\n unTooltip?: boolean // 不要tooltip\n upperCaseIgnore?: string[]\n}\n\nconst getDefaultPagination = (locale: NonNullable<AntdTableProps<unknown>['locale']>) => ({\n showTotal: (total: number) => <TotalShower total={total} locale={locale} />,\n})\n\nconst titleHandle = (\n str: string,\n upperCaseIgnore: string[] | undefined,\n isPrompt: boolean | undefined\n): string => {\n if (isPrompt) {\n const lowerCaseWord = str.toLowerCase()\n return lowerCaseWord.charAt(0).toUpperCase() + lowerCaseWord.slice(1)\n }\n const words: string[] = str.split(' ')\n const capitalizedWords: string[] = words.map((word: string, i: number) => {\n const lowerCaseWord: string = word.toLowerCase()\n let ignoreList = prepositions.concat(articles)\n if (upperCaseIgnore?.length) {\n ignoreList = ignoreList.concat(upperCaseIgnore)\n ignoreList = Array.from(new Set(ignoreList))\n }\n if (ignoreList.includes(lowerCaseWord) && i !== 0) {\n return lowerCaseWord\n } else {\n return word.charAt(0).toUpperCase() + word.slice(1)\n }\n })\n return capitalizedWords.join(' ')\n}\n\n// 表头转换为首字母大写\nconst titleCaseUpper = (\n str: string,\n upperCaseIgnore: string[] | undefined,\n isPrompt: boolean | undefined\n) => {\n if (!str) {\n return str\n }\n if (typeof str === 'string') {\n // 有斜杠根据斜杠划分\n if (str?.includes('/')) {\n const parWords: string[] = str.split('/')\n return parWords\n .map((str1) => {\n return titleHandle(str1, upperCaseIgnore, isPrompt)\n })\n .join('/')\n }\n return titleHandle(str, upperCaseIgnore, isPrompt)\n }\n return str\n}\n\n// 判断是否是特殊的tooltip\n// const checkIsPrompt = (dom: any): boolean => {\n// let isPrompt: boolean = false\n// if (React.isValidElement(dom)) {\n// if (dom?.type && typeof dom?.type === 'function') {\n// if (['Tooltip', 'Popconfirm'].includes(dom?.type?.name)) {\n// isPrompt = true\n// }\n// }\n// }\n// return isPrompt\n// }\n\nexport const Table = <T,>({\n className,\n locale,\n bordered,\n size,\n storageKey,\n columns,\n children,\n shadowed = !bordered,\n striped = false,\n showCellBorders = false,\n // pagination,\n enableToolbar = false,\n refresh,\n upperCaseIgnore,\n unUpperConverted, // 强制不要转换\n unTooltip,\n ...rest\n}: TableProps<T>) => {\n const tableContainer = useRef<HTMLDivElement>(null)\n // const [innerSize, setInnerSize] = useLocalStorage<TableProps<T>['size']>(\n // TABLE_SIZE_STORAGE_KEY,\n // 'default'\n // )\n const normalizedColumns = useMemo(\n () => columns || normalizeColumns<T>(children as React.ReactChildren),\n [children, columns]\n )\n const [displayColumns, columnSetting, setColumnSetting] = useColumnSetting(\n normalizedColumns,\n storageKey\n )\n\n const lang = getLanguage()\n let newColumns = displayColumns\n // 非中文做处理\n if (lang !== 'cn') {\n if (!unUpperConverted) {\n newColumns = displayColumns?.map((column) => {\n return {\n ...column,\n title: (options: {\n filters: TableStateFilters\n sortOrder?: SortOrder\n sortColumn?: ColumnProps<T> | null\n }) => {\n let title = column.title\n if (typeof title === 'function') {\n title = title(options)\n }\n if (React.isValidElement(title)) {\n const renderChildren = (children: [] | string): React.ReactNode => {\n if (React.isValidElement(children) || Array.isArray(children)) {\n return React.Children.map(children, (child) => {\n if (React.isValidElement(child)) {\n const childProps = (child.props || {}) as any\n return React.cloneElement(child, {\n ...childProps,\n children: childProps.children?.length\n ? renderChildren(childProps.children)\n : childProps.children,\n title: titleCaseUpper(childProps?.title, upperCaseIgnore, true),\n })\n } else {\n return titleCaseUpper(child, upperCaseIgnore, false)\n }\n })\n }\n\n return titleCaseUpper(children, upperCaseIgnore, false)\n }\n\n return renderChildren(title.props.children)\n }\n if (typeof title === 'string') {\n return titleCaseUpper(title, upperCaseIgnore, false)\n }\n },\n }\n })\n }\n if (!unTooltip) {\n newColumns = newColumns?.map((column) => {\n if (!(column.width && !String(column.width).includes('%'))) {\n return column\n } else {\n return {\n ...column,\n title: (options: {\n filters: TableStateFilters\n sortOrder?: SortOrder\n sortColumn?: ColumnProps<T> | null\n }) => {\n let title = column.title\n if (typeof title === 'function') {\n title = title(options)\n }\n\n let widthLimitObj = {}\n if (column.width && !String(column.width).includes('%')) {\n let width = column.width\n if (typeof width === 'string') {\n width = width.replace(/[^\\d]/g, ' ')\n }\n widthLimitObj = {\n widthLimit:\n Number(width) -\n Number(sizeWidthMap[size || 'default']) -\n (column.sorter ? 20 : 0),\n }\n }\n return (\n <Ellipsis\n {...widthLimitObj}\n placement={column?.placement || 'topLeft'}\n title={title}\n />\n )\n },\n }\n }\n })\n }\n }\n\n /**\n * update the innerSize when props size changes\n */\n // useEffect(() => {\n // if (size) {\n // setInnerSize(size)\n // }\n // }, [setInnerSize, size])\n\n return (\n <TableContext.Provider\n value={{\n // size: innerSize,\n tableContainer,\n columnSetting,\n refresh,\n upperCaseIgnore,\n // setSize: setInnerSize,\n setColumnSetting,\n }}\n >\n <ConfigConsumer>\n {({ getPrefixCls }) => {\n const prefixCls = getPrefixCls('table')\n return (\n <div ref={tableContainer}>\n <LocaleReceiver componentName=\"Table\" defaultLocale={locale}>\n {(localeObject) => {\n // const locale = localeObject as Record<string, string>\n // const paginationConfig = pagination ? getDefaultPagination(locale) : pagination\n return (\n <AntdTable\n className={classNames(\n // prefixCls,\n 'tnt-table-wrapper',\n {\n [`${prefixCls}-borderless`]: !bordered,\n [`${prefixCls}-hide-cell-borders`]: !showCellBorders,\n [`${prefixCls}-size-small`]: size === 'small',\n [`${prefixCls}-size-middle`]: size === 'middle',\n [`${prefixCls}-size-middle`]: size === 'middle',\n [`${prefixCls}-striped`]: striped,\n [`${prefixCls}-shadowed`]: shadowed,\n },\n className\n )}\n locale={locale}\n bordered={bordered}\n size={size}\n columns={newColumns}\n {...rest}\n />\n )\n }}\n </LocaleReceiver>\n </div>\n )\n }}\n </ConfigConsumer>\n </TableContext.Provider>\n )\n}\n\nTable.Column = Column\nTable.ColumnGroup = ColumnGroup\nTable.displayName = 'Table'\nTable.titleCaseUpper = titleCaseUpper\n"]}
|
|
1
|
+
{"version":3,"file":"table.js","sourceRoot":"","sources":["../../src/table/table.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO,cAAc,MAAM,wCAAwC,CAAA;AAOnE,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,eAAe,CAAA;AACpD,OAAO,MAAM,MAAM,sBAAsB,CAAA;AACzC,OAAO,WAAW,MAAM,2BAA2B,CAAA;AACnD,OAAO,UAAU,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAC9C,OAAO,QAAQ,MAAM,aAAa,CAAA;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,EAAE,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EAAE,CAAC,eAAe;4BACpD,CAAC,GAAG,SAAS,aAAa,CAAC,EAAE,IAAI,KAAK,OAAO;4BAC7C,CAAC,GAAG,SAAS,cAAc,CAAC,EAAE,IAAI,KAAK,QAAQ;4BAC/C,CAAC,GAAG,SAAS,cAAc,CAAC,EAAE,IAAI,KAAK,QAAQ;4BAC/C,CAAC,GAAG,SAAS,UAAU,CAAC,EAAE,OAAO;4BACjC,CAAC,GAAG,SAAS,WAAW,CAAC,EAAE,QAAQ;yBACpC,EACD,SAAS,CACV,EACD,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,UAAU,IACf,IAAI,EACR,CACH,CAAA;gBACH,CAAC,CACc,CACb,CACP,CAAA;QACH,CAAC,CACc,CACK,CACzB,CAAA;AACH,CAAC,CAAA;AAED,KAAK,CAAC,MAAM,GAAG,MAAM,CAAA;AACrB,KAAK,CAAC,WAAW,GAAG,WAAW,CAAA;AAC/B,KAAK,CAAC,WAAW,GAAG,OAAO,CAAA;AAC3B,KAAK,CAAC,cAAc,GAAG,cAAc,CAAA","sourcesContent":["import { ConfigConsumer } from 'antd/es/config-provider'\nimport LocaleReceiver from 'antd/es/locale-provider/LocaleReceiver'\nimport type {\n TableProps as AntdTableProps,\n ColumnProps,\n TableStateFilters,\n SortOrder,\n} from 'antd/es/table'\nimport { default as AntdTable } from 'antd/es/table'\nimport Column from 'antd/es/table/Column'\nimport ColumnGroup from 'antd/es/table/ColumnGroup'\nimport classNames from 'classnames'\nimport React, { useMemo, useRef } from 'react'\nimport Ellipsis from '../ellipsis'\nimport { TableContext } from './context'\nimport { useColumnSetting } from './hooks'\nimport { normalizeColumns } from './utils'\nimport { titleCaseUpper } from '../utils/lang'\nimport { TotalShower } from './total-shower'\nimport { getLanguage } from '../prev-locale'\n\nconst sizeWidthMap = {\n default: 40, //20\n middle: 20, //10\n small: 20, //10\n xs: 16, // 8\n}\n\nexport type TableProps<T> = Omit<AntdTableProps<T>, 'locale'> & {\n storageKey?: string\n enableToolbar?: boolean\n showCellBorders?: boolean\n striped?: boolean\n shadowed?: boolean\n locale?: AntdTableProps<T>['locale'] & {\n loadingDescription?: string\n emptyText?: string\n }\n refresh?(): void\n unUpperConverted?: boolean // 不要转换表头\n unTooltip?: boolean // 不要tooltip\n upperCaseIgnore?: string[]\n}\n\nconst getDefaultPagination = (locale: NonNullable<AntdTableProps<unknown>['locale']>) => ({\n showTotal: (total: number) => <TotalShower total={total} locale={locale} />,\n})\n\n// 判断是否是特殊的tooltip\n// const checkIsPrompt = (dom: any): boolean => {\n// let isPrompt: boolean = false\n// if (React.isValidElement(dom)) {\n// if (dom?.type && typeof dom?.type === 'function') {\n// if (['Tooltip', 'Popconfirm'].includes(dom?.type?.name)) {\n// isPrompt = true\n// }\n// }\n// }\n// return isPrompt\n// }\n\nexport const Table = <T,>({\n className,\n locale,\n bordered,\n size,\n storageKey,\n columns,\n children,\n shadowed = !bordered,\n striped = false,\n showCellBorders = false,\n // pagination,\n enableToolbar = false,\n refresh,\n upperCaseIgnore,\n unUpperConverted, // 强制不要转换\n unTooltip,\n ...rest\n}: TableProps<T>) => {\n const tableContainer = useRef<HTMLDivElement>(null)\n // const [innerSize, setInnerSize] = useLocalStorage<TableProps<T>['size']>(\n // TABLE_SIZE_STORAGE_KEY,\n // 'default'\n // )\n const normalizedColumns = useMemo(\n () => columns || normalizeColumns<T>(children as React.ReactChildren),\n [children, columns]\n )\n const [displayColumns, columnSetting, setColumnSetting] = useColumnSetting(\n normalizedColumns,\n storageKey\n )\n\n const lang = getLanguage()\n let newColumns = displayColumns\n // 非中文做处理\n if (lang !== 'cn') {\n if (!unUpperConverted) {\n newColumns = displayColumns?.map((column) => {\n return {\n ...column,\n title: (options: {\n filters: TableStateFilters\n sortOrder?: SortOrder\n sortColumn?: ColumnProps<T> | null\n }) => {\n let title = column.title\n if (typeof title === 'function') {\n title = title(options)\n }\n\n if (React.isValidElement(title)) {\n const renderChildren = (children: [] | string): React.ReactNode => {\n if (React.isValidElement(children) || Array.isArray(children)) {\n return React?.Children?.map(children, (child) => {\n if (React.isValidElement(child)) {\n const childProps = (child.props || {}) as any\n return React.cloneElement(child, {\n ...childProps,\n children: childProps.children?.length\n ? renderChildren(childProps.children)\n : childProps.children,\n title: titleCaseUpper(childProps?.title, upperCaseIgnore),\n })\n } else {\n return titleCaseUpper(child, upperCaseIgnore)\n }\n })\n }\n\n return titleCaseUpper(children, upperCaseIgnore)\n }\n\n return renderChildren(title.props.children)\n }\n\n if (typeof title === 'string') {\n return titleCaseUpper(title, upperCaseIgnore)\n }\n },\n }\n })\n }\n if (!unTooltip) {\n newColumns = newColumns?.map((column) => {\n if (!(column.width && !String(column.width).includes('%'))) {\n return column\n } else {\n return {\n ...column,\n title: (options: {\n filters: TableStateFilters\n sortOrder?: SortOrder\n sortColumn?: ColumnProps<T> | null\n }) => {\n let title = column.title\n if (typeof title === 'function') {\n title = title(options)\n }\n\n let widthLimitObj = {}\n if (column.width && !String(column.width).includes('%')) {\n let width = column.width\n if (typeof width === 'string') {\n width = width?.replace(/[^\\d]/g, ' ')\n }\n widthLimitObj = {\n widthLimit:\n Number(width) -\n Number(sizeWidthMap[size || 'default']) -\n (column.sorter ? 20 : 0),\n }\n }\n return (\n <Ellipsis\n {...widthLimitObj}\n placement={column?.placement || 'topLeft'}\n title={title}\n />\n )\n },\n }\n }\n })\n }\n }\n\n /**\n * update the innerSize when props size changes\n */\n // useEffect(() => {\n // if (size) {\n // setInnerSize(size)\n // }\n // }, [setInnerSize, size])\n\n return (\n <TableContext.Provider\n value={{\n // size: innerSize,\n tableContainer,\n columnSetting,\n refresh,\n upperCaseIgnore,\n // setSize: setInnerSize,\n setColumnSetting,\n }}\n >\n <ConfigConsumer>\n {({ getPrefixCls }) => {\n const prefixCls = getPrefixCls('table')\n return (\n <div ref={tableContainer}>\n <LocaleReceiver componentName=\"Table\" defaultLocale={locale}>\n {(localeObject) => {\n // const locale = localeObject as Record<string, string>\n // const paginationConfig = pagination ? getDefaultPagination(locale) : pagination\n return (\n <AntdTable\n className={classNames(\n // prefixCls,\n 'tnt-table-wrapper',\n {\n [`${prefixCls}-borderless`]: !bordered,\n [`${prefixCls}-hide-cell-borders`]: !showCellBorders,\n [`${prefixCls}-size-small`]: size === 'small',\n [`${prefixCls}-size-middle`]: size === 'middle',\n [`${prefixCls}-size-middle`]: size === 'middle',\n [`${prefixCls}-striped`]: striped,\n [`${prefixCls}-shadowed`]: shadowed,\n },\n className\n )}\n locale={locale}\n bordered={bordered}\n size={size}\n columns={newColumns}\n {...rest}\n />\n )\n }}\n </LocaleReceiver>\n </div>\n )\n }}\n </ConfigConsumer>\n </TableContext.Provider>\n )\n}\n\nTable.Column = Column\nTable.ColumnGroup = ColumnGroup\nTable.displayName = 'Table'\nTable.titleCaseUpper = titleCaseUpper\n"]}
|
|
@@ -2,7 +2,7 @@ import classNames from 'classnames';
|
|
|
2
2
|
import CSSMotion, { CSSMotionList } from 'rc-motion';
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { ConfigContext } from '../config-provider';
|
|
5
|
-
import collapseMotion from '
|
|
5
|
+
import collapseMotion from '../_util/motion';
|
|
6
6
|
import { FormItemPrefixContext } from './context';
|
|
7
7
|
import useDebounce from './hooks/useDebounce';
|
|
8
8
|
const EMPTY_LIST = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorList.js","sourceRoot":"","sources":["../../src/tntd-form/ErrorList.tsx"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,YAAY,CAAA;AACnC,OAAO,SAAS,EAAE,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AACpD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,cAAc,MAAM,
|
|
1
|
+
{"version":3,"file":"ErrorList.js","sourceRoot":"","sources":["../../src/tntd-form/ErrorList.tsx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,GAAG,aAAa,iBAAiB,EAC7C,SAAS,EAAE,KAAK,KAEf,CAAC,SAAS,EAAE,EAAE;gBACb,MAAM,EACJ,GAAG,EACH,KAAK,EACL,WAAW,EACX,SAAS,EAAE,aAAa,EACxB,KAAK,EAAE,SAAS,GACjB,GAAG,SAAS,CAAA;gBAEb,OAAO,CACL,6BACE,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,UAAU,CAAC,aAAa,EAAE;wBACnC,CAAC,GAAG,aAAa,IAAI,WAAW,EAAE,CAAC,EAAE,WAAW;qBACjD,CAAC,EACF,KAAK,EAAE,SAAS,IAEf,KAAK,CACF,CACP,CAAA;YACH,CAAC,CACa,CACZ,CACP,CAAA;IACH,CAAC,CACS,CACb,CAAA;AACH,CAAC","sourcesContent":["import classNames from 'classnames'\nimport CSSMotion, { CSSMotionList } from 'rc-motion'\nimport * as React from 'react'\nimport { ConfigContext } from '../config-provider'\nimport collapseMotion from '../_util/motion'\nimport { FormItemPrefixContext } from './context'\nimport useDebounce from './hooks/useDebounce'\nimport type { ValidateStatus } from './FormItem'\n\nconst EMPTY_LIST: React.ReactNode[] = []\n\ninterface ErrorEntity {\n error: React.ReactNode\n errorStatus?: ValidateStatus\n key: string\n}\n\nfunction toErrorEntity(\n error: React.ReactNode,\n errorStatus: ValidateStatus | undefined,\n prefix: string,\n index: number = 0\n): ErrorEntity {\n return {\n key: typeof error === 'string' ? error : `${prefix}-${index}`,\n error,\n errorStatus,\n }\n}\n\nexport interface ErrorListProps {\n fieldId?: string\n help?: React.ReactNode\n helpStatus?: ValidateStatus\n errors?: React.ReactNode[]\n warnings?: React.ReactNode[]\n className?: string\n onVisibleChanged?: (visible: boolean) => void\n}\n\nexport default function ErrorList({\n help,\n helpStatus,\n errors = EMPTY_LIST,\n warnings = EMPTY_LIST,\n className: rootClassName,\n fieldId,\n onVisibleChanged,\n}: ErrorListProps) {\n const { prefixCls } = React.useContext(FormItemPrefixContext)\n // TODO\n // @ts-ignore\n const { getPrefixCls } = React.useContext(ConfigContext)\n\n const baseClassName = `${prefixCls}-item-explain`\n // TODO:\n // @ts-ignore\n const rootPrefixCls = getPrefixCls()\n\n // We have to debounce here again since somewhere use ErrorList directly still need no shaking\n // ref: https://github.com/ant-design/ant-design/issues/36336\n const debounceErrors = useDebounce(errors)\n const debounceWarnings = useDebounce(warnings)\n\n const fullKeyList = React.useMemo(() => {\n if (help !== undefined && help !== null) {\n return [toErrorEntity(help, helpStatus, 'help')]\n }\n\n return [\n ...debounceErrors.map((error, index) => toErrorEntity(error, 'error', 'error', index)),\n ...debounceWarnings.map((warning, index) =>\n toErrorEntity(warning, 'warning', 'warning', index)\n ),\n ]\n }, [help, helpStatus, debounceErrors, debounceWarnings])\n\n const helpProps: { id?: string } = {}\n\n if (fieldId) {\n helpProps.id = `${fieldId}_help`\n }\n\n return (\n <CSSMotion\n motionDeadline={collapseMotion.motionDeadline}\n motionName={`${rootPrefixCls}-show-help`}\n visible={!!fullKeyList.length}\n onVisibleChanged={onVisibleChanged}\n >\n {(holderProps) => {\n const { className: holderClassName, style: holderStyle } = holderProps\n\n return (\n <div\n {...helpProps}\n className={classNames(baseClassName, holderClassName, rootClassName)}\n style={holderStyle}\n role=\"alert\"\n >\n <CSSMotionList\n keys={fullKeyList}\n {...collapseMotion}\n motionName={`${rootPrefixCls}-show-help-item`}\n component={false}\n >\n {(itemProps) => {\n const {\n key,\n error,\n errorStatus,\n className: itemClassName,\n style: itemStyle,\n } = itemProps\n\n return (\n <div\n key={key}\n className={classNames(itemClassName, {\n [`${baseClassName}-${errorStatus}`]: errorStatus,\n })}\n style={itemStyle}\n >\n {error}\n </div>\n )\n }}\n </CSSMotionList>\n </div>\n )\n }}\n </CSSMotion>\n )\n}\n"]}
|
|
@@ -13,7 +13,7 @@ import useLayoutEffect from 'rc-util/lib/hooks/useLayoutEffect';
|
|
|
13
13
|
import classNames from 'classnames';
|
|
14
14
|
import * as React from 'react';
|
|
15
15
|
import omit from 'rc-util/lib/omit';
|
|
16
|
-
import Row from '../../
|
|
16
|
+
import { Row } from '../../grid';
|
|
17
17
|
import FormItemLabel from '../FormItemLabel';
|
|
18
18
|
import FormItemInput from '../FormItemInput';
|
|
19
19
|
import { FormContext, FormItemInputContext, NoStyleItemContext } from '../context';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ItemHolder.js","sourceRoot":"","sources":["../../../src/tntd-form/FormItem/ItemHolder.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,eAAe,MAAM,mCAAmC,CAAA;AAC/D,OAAO,UAAU,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,IAAI,MAAM,kBAAkB,CAAA;AAEnC,OAAO,GAAG,MAAM,WAAW,CAAA;AAC3B,OAAO,aAAa,MAAM,kBAAkB,CAAA;AAC5C,OAAO,aAAa,MAAM,kBAAkB,CAAA;AAE5C,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAElF,OAAO,WAAW,MAAM,sBAAsB,CAAA;AAC9C,OAAO,IAAI,MAAM,YAAY,CAAA;AAE7B,MAAM,OAAO,GAAG;IACd,OAAO,EAAE,GAAG,EAAE,CAAC,oBAAC,IAAI,IAAC,IAAI,EAAC,cAAc,GAAG;IAC3C,OAAO,EAAE,GAAG,EAAE,CAAC,oBAAC,IAAI,IAAC,IAAI,EAAC,oBAAoB,GAAG;IACjD,KAAK,EAAE,GAAG,EAAE,CAAC,oBAAC,IAAI,IAAC,IAAI,EAAC,cAAc,GAAG;IACzC,UAAU,EAAE,GAAG,EAAE,CAAC,oBAAC,IAAI,IAAC,IAAI,EAAC,SAAS,GAAG;CAC1C,CAAA;AAeD,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,KAAsB;IACvD,MAAM,EACJ,SAAS,EACT,SAAS,EACT,KAAK,EACL,IAAI,EACJ,MAAM,EACN,QAAQ,EACR,cAAc,EACd,IAAI,E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BAE5C,oBAAC,kBAAkB,CAAC,QAAQ,IAAC,KAAK,EAAE,mBAAmB;oBACrD,oBAAC,oBAAoB,CAAC,QAAQ,IAAC,KAAK,EAAE,qBAAqB,IACxD,QAAQ,CACqB,CACJ,CAChB,CACZ;QAEL,CAAC,CAAC,YAAY,IAAI,CACjB,6BACE,SAAS,EAAE,GAAG,aAAa,gBAAgB,EAC3C,KAAK,EAAE;gBACL,YAAY,EAAE,CAAC,YAAY;aAC5B,GACD,CACH,CACG,CACP,CAAA;AACH,CAAC","sourcesContent":["import useLayoutEffect from 'rc-util/lib/hooks/useLayoutEffect'\nimport classNames from 'classnames'\nimport * as React from 'react'\nimport omit from 'rc-util/lib/omit'\nimport type { Meta } from 'rc-field-form/lib/interface'\nimport Row from '../../row'\nimport FormItemLabel from '../FormItemLabel'\nimport FormItemInput from '../FormItemInput'\nimport type { FormItemStatusContextProps, ReportMetaChange } from '../context'\nimport { FormContext, FormItemInputContext, NoStyleItemContext } from '../context'\nimport type { FormItemProps, ValidateStatus } from '.'\nimport useDebounce from '../hooks/useDebounce'\nimport Icon from '../../icon'\n\nconst iconMap = {\n success: () => <Icon type=\"check-circle\" />,\n warning: () => <Icon type=\"exclamation-circle\" />,\n error: () => <Icon type=\"close-circle\" />,\n validating: () => <Icon type=\"loading\" />,\n}\n\nexport interface ItemHolderProps extends FormItemProps {\n prefixCls: string\n className?: string\n style?: React.CSSProperties\n errors: React.ReactNode[]\n warnings: React.ReactNode[]\n meta: Meta\n children?: React.ReactNode\n fieldId?: string\n isRequired?: boolean\n onSubItemMetaChange: ReportMetaChange\n}\n\nexport default function ItemHolder(props: ItemHolderProps) {\n const {\n prefixCls,\n className,\n style,\n help,\n errors,\n warnings,\n validateStatus,\n meta,\n hasFeedback,\n hidden,\n children,\n fieldId,\n isRequired,\n onSubItemMetaChange,\n ...restProps\n } = props\n\n const itemPrefixCls = `${prefixCls}-item`\n const { requiredMark } = React.useContext(FormContext)\n\n // ======================== Margin ========================\n const itemRef = React.useRef<HTMLDivElement>(null)\n const debounceErrors = useDebounce(errors)\n const debounceWarnings = useDebounce(warnings)\n const hasHelp = help !== undefined && help !== null\n const hasError = !!(hasHelp || errors.length || warnings.length)\n const [marginBottom, setMarginBottom] = React.useState<number | null>(null)\n\n useLayoutEffect(() => {\n if (hasError && itemRef.current) {\n const itemStyle = getComputedStyle(itemRef.current)\n setMarginBottom(parseInt(itemStyle.marginBottom, 10))\n }\n }, [hasError])\n\n const onErrorVisibleChanged = (nextVisible: boolean) => {\n if (!nextVisible) {\n setMarginBottom(null)\n }\n }\n\n // ======================== Status ========================\n let mergedValidateStatus: ValidateStatus = ''\n if (validateStatus !== undefined) {\n mergedValidateStatus = validateStatus\n } else if (meta.validating) {\n mergedValidateStatus = 'validating'\n } else if (debounceErrors.length) {\n mergedValidateStatus = 'error'\n } else if (debounceWarnings.length) {\n mergedValidateStatus = 'warning'\n } else if (meta.touched) {\n mergedValidateStatus = 'success'\n }\n\n const formItemStatusContext = React.useMemo<FormItemStatusContextProps>(() => {\n let feedbackIcon: React.ReactNode\n if (hasFeedback) {\n const IconNode = mergedValidateStatus && iconMap[mergedValidateStatus]\n feedbackIcon = IconNode ? (\n <span\n className={classNames(\n `${itemPrefixCls}-feedback-icon`,\n `${itemPrefixCls}-feedback-icon-${mergedValidateStatus}`\n )}\n >\n <IconNode />\n </span>\n ) : null\n }\n\n return {\n status: mergedValidateStatus,\n hasFeedback,\n feedbackIcon,\n isFormItemInput: true,\n }\n }, [mergedValidateStatus, hasFeedback])\n\n // ======================== Render ========================\n const itemClassName = {\n [itemPrefixCls]: true,\n [`${itemPrefixCls}-with-help`]: hasHelp || debounceErrors.length || debounceWarnings.length,\n [`${className}`]: !!className,\n\n // Status\n [`${itemPrefixCls}-has-feedback has-feedback`]: mergedValidateStatus && hasFeedback,\n [`${itemPrefixCls}-has-success has-success`]: mergedValidateStatus === 'success',\n [`${itemPrefixCls}-has-warning has-warning`]: mergedValidateStatus === 'warning',\n [`${itemPrefixCls}-has-error has-error`]: mergedValidateStatus === 'error',\n [`${itemPrefixCls}-is-validating is-validating`]: mergedValidateStatus === 'validating',\n [`${itemPrefixCls}-hidden hidden`]: hidden,\n }\n\n return (\n <div className={classNames(itemClassName)} style={style} ref={itemRef}>\n <Row\n className={`${itemPrefixCls}-row`}\n {...omit(restProps, [\n '_internalItemRender' as any,\n 'colon',\n 'dependencies',\n 'extra',\n 'fieldKey',\n 'getValueFromEvent',\n 'getValueProps',\n 'htmlFor',\n 'id', // It is deprecated because `htmlFor` is its replacement.\n 'initialValue',\n 'isListField',\n 'label',\n 'labelAlign',\n 'labelCol',\n 'labelWrap',\n 'messageVariables',\n 'name',\n 'normalize',\n 'noStyle',\n 'preserve',\n 'required',\n 'requiredMark',\n 'rules',\n 'shouldUpdate',\n 'trigger',\n 'tooltip',\n 'validateFirst',\n 'validateTrigger',\n 'valuePropName',\n 'wrapperCol',\n ])}\n >\n {/* Label */}\n <FormItemLabel\n htmlFor={fieldId}\n required={isRequired}\n requiredMark={requiredMark}\n {...props}\n prefixCls={prefixCls}\n />\n {/* Input Group */}\n <FormItemInput\n {...props}\n {...meta}\n errors={debounceErrors}\n warnings={debounceWarnings}\n prefixCls={prefixCls}\n status={mergedValidateStatus}\n help={help}\n marginBottom={marginBottom}\n onErrorVisibleChanged={onErrorVisibleChanged}\n >\n <NoStyleItemContext.Provider value={onSubItemMetaChange}>\n <FormItemInputContext.Provider value={formItemStatusContext}>\n {children}\n </FormItemInputContext.Provider>\n </NoStyleItemContext.Provider>\n </FormItemInput>\n </Row>\n\n {!!marginBottom && (\n <div\n className={`${itemPrefixCls}-margin-offset`}\n style={{\n marginBottom: -marginBottom,\n }}\n />\n )}\n </div>\n )\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ItemHolder.js","sourceRoot":"","sources":["../../../src/tntd-form/FormItem/ItemHolder.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,eAAe,MAAM,mCAAmC,CAAA;AAC/D,OAAO,UAAU,M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useLayoutEffect from 'rc-util/lib/hooks/useLayoutEffect'\nimport classNames from 'classnames'\nimport * as React from 'react'\nimport omit from 'rc-util/lib/omit'\nimport type { Meta } from 'rc-field-form/lib/interface'\nimport { Row } from '../../grid'\nimport FormItemLabel from '../FormItemLabel'\nimport FormItemInput from '../FormItemInput'\nimport type { FormItemStatusContextProps, ReportMetaChange } from '../context'\nimport { FormContext, FormItemInputContext, NoStyleItemContext } from '../context'\nimport type { FormItemProps, ValidateStatus } from '.'\nimport useDebounce from '../hooks/useDebounce'\nimport Icon from '../../icon'\n\nconst iconMap = {\n success: () => <Icon type=\"check-circle\" />,\n warning: () => <Icon type=\"exclamation-circle\" />,\n error: () => <Icon type=\"close-circle\" />,\n validating: () => <Icon type=\"loading\" />,\n}\n\nexport interface ItemHolderProps extends FormItemProps {\n prefixCls: string\n className?: string\n style?: React.CSSProperties\n errors: React.ReactNode[]\n warnings: React.ReactNode[]\n meta: Meta\n children?: React.ReactNode\n fieldId?: string\n isRequired?: boolean\n onSubItemMetaChange: ReportMetaChange\n}\n\nexport default function ItemHolder(props: ItemHolderProps) {\n const {\n prefixCls,\n className,\n style,\n help,\n errors,\n warnings,\n validateStatus,\n meta,\n hasFeedback,\n hidden,\n children,\n fieldId,\n isRequired,\n onSubItemMetaChange,\n ...restProps\n } = props\n\n const itemPrefixCls = `${prefixCls}-item`\n const { requiredMark } = React.useContext(FormContext)\n\n // ======================== Margin ========================\n const itemRef = React.useRef<HTMLDivElement>(null)\n const debounceErrors = useDebounce(errors)\n const debounceWarnings = useDebounce(warnings)\n const hasHelp = help !== undefined && help !== null\n const hasError = !!(hasHelp || errors.length || warnings.length)\n const [marginBottom, setMarginBottom] = React.useState<number | null>(null)\n\n useLayoutEffect(() => {\n if (hasError && itemRef.current) {\n const itemStyle = getComputedStyle(itemRef.current)\n setMarginBottom(parseInt(itemStyle.marginBottom, 10))\n }\n }, [hasError])\n\n const onErrorVisibleChanged = (nextVisible: boolean) => {\n if (!nextVisible) {\n setMarginBottom(null)\n }\n }\n\n // ======================== Status ========================\n let mergedValidateStatus: ValidateStatus = ''\n if (validateStatus !== undefined) {\n mergedValidateStatus = validateStatus\n } else if (meta.validating) {\n mergedValidateStatus = 'validating'\n } else if (debounceErrors.length) {\n mergedValidateStatus = 'error'\n } else if (debounceWarnings.length) {\n mergedValidateStatus = 'warning'\n } else if (meta.touched) {\n mergedValidateStatus = 'success'\n }\n\n const formItemStatusContext = React.useMemo<FormItemStatusContextProps>(() => {\n let feedbackIcon: React.ReactNode\n if (hasFeedback) {\n const IconNode = mergedValidateStatus && iconMap[mergedValidateStatus]\n feedbackIcon = IconNode ? (\n <span\n className={classNames(\n `${itemPrefixCls}-feedback-icon`,\n `${itemPrefixCls}-feedback-icon-${mergedValidateStatus}`\n )}\n >\n <IconNode />\n </span>\n ) : null\n }\n\n return {\n status: mergedValidateStatus,\n hasFeedback,\n feedbackIcon,\n isFormItemInput: true,\n }\n }, [mergedValidateStatus, hasFeedback])\n\n // ======================== Render ========================\n const itemClassName = {\n [itemPrefixCls]: true,\n [`${itemPrefixCls}-with-help`]: hasHelp || debounceErrors.length || debounceWarnings.length,\n [`${className}`]: !!className,\n\n // Status\n [`${itemPrefixCls}-has-feedback has-feedback`]: mergedValidateStatus && hasFeedback,\n [`${itemPrefixCls}-has-success has-success`]: mergedValidateStatus === 'success',\n [`${itemPrefixCls}-has-warning has-warning`]: mergedValidateStatus === 'warning',\n [`${itemPrefixCls}-has-error has-error`]: mergedValidateStatus === 'error',\n [`${itemPrefixCls}-is-validating is-validating`]: mergedValidateStatus === 'validating',\n [`${itemPrefixCls}-hidden hidden`]: hidden,\n }\n\n return (\n <div className={classNames(itemClassName)} style={style} ref={itemRef}>\n <Row\n className={`${itemPrefixCls}-row`}\n {...omit(restProps, [\n '_internalItemRender' as any,\n 'colon',\n 'dependencies',\n 'extra',\n 'fieldKey',\n 'getValueFromEvent',\n 'getValueProps',\n 'htmlFor',\n 'id', // It is deprecated because `htmlFor` is its replacement.\n 'initialValue',\n 'isListField',\n 'label',\n 'labelAlign',\n 'labelCol',\n 'labelWrap',\n 'messageVariables',\n 'name',\n 'normalize',\n 'noStyle',\n 'preserve',\n 'required',\n 'requiredMark',\n 'rules',\n 'shouldUpdate',\n 'trigger',\n 'tooltip',\n 'validateFirst',\n 'validateTrigger',\n 'valuePropName',\n 'wrapperCol',\n ])}\n >\n {/* Label */}\n <FormItemLabel\n htmlFor={fieldId}\n required={isRequired}\n requiredMark={requiredMark}\n {...props}\n prefixCls={prefixCls}\n />\n {/* Input Group */}\n <FormItemInput\n {...props}\n {...meta}\n errors={debounceErrors}\n warnings={debounceWarnings}\n prefixCls={prefixCls}\n status={mergedValidateStatus}\n help={help}\n marginBottom={marginBottom}\n onErrorVisibleChanged={onErrorVisibleChanged}\n >\n <NoStyleItemContext.Provider value={onSubItemMetaChange}>\n <FormItemInputContext.Provider value={formItemStatusContext}>\n {children}\n </FormItemInputContext.Provider>\n </NoStyleItemContext.Provider>\n </FormItemInput>\n </Row>\n\n {!!marginBottom && (\n <div\n className={`${itemPrefixCls}-margin-offset`}\n style={{\n marginBottom: -marginBottom,\n }}\n />\n )}\n </div>\n )\n}\n"]}
|
|
@@ -6,9 +6,9 @@ import { useContext } from 'react';
|
|
|
6
6
|
import useFormItemStatus from '../hooks/useFormItemStatus';
|
|
7
7
|
import { ConfigContext } from '../../config-provider';
|
|
8
8
|
import DisabledContext from '../../config-provider/DisabledContext';
|
|
9
|
-
import { cloneElement, isValidElement } from '
|
|
10
|
-
import { tuple } from '
|
|
11
|
-
import warning from '
|
|
9
|
+
import { cloneElement, isValidElement } from '../../_util/reactNode';
|
|
10
|
+
import { tuple } from '../../_util/type';
|
|
11
|
+
import warning from '../../_util/warning';
|
|
12
12
|
import { FormContext, NoStyleItemContext } from '../context';
|
|
13
13
|
import useFrameState from '../hooks/useFrameState';
|
|
14
14
|
import useItemRef from '../hooks/useItemRef';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","source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rc-field-form'\nimport type { FieldProps } from 'rc-field-form/lib/Field'\nimport type { Meta, NamePath } from 'rc-field-form/lib/interface'\nimport useState from 'rc-util/lib/hooks/useState'\nimport { supportRef } from 'rc-util/lib/ref'\nimport * as React from 'react'\nimport { useContext } from 'react'\nimport useFormItemStatus from '../hooks/useFormItemStatus'\nimport { ConfigContext } from '../../config-provider'\nimport DisabledContext from '../../config-provider/DisabledContext'\nimport { cloneElement, isValidElement } from '../_util/reactNode'\nimport { tuple } from '../_util/type'\nimport warning from '../_util/warning'\nimport { FormContext, NoStyleItemContext } from '../context'\nimport type { FormItemInputProps } from '../FormItemInput'\nimport type { FormItemLabelProps, LabelTooltipType } from '../FormItemLabel'\nimport useFrameState from '../hooks/useFrameState'\nimport useItemRef from '../hooks/useItemRef'\nimport { getFieldId, toArray } from '../util'\nimport ItemHolder from './ItemHolder'\n\nconst NAME_SPLIT = '__SPLIT__'\n\ninterface FieldError {\n errors: string[]\n warnings: string[]\n}\n\nconst ValidateStatuses = tuple('success', 'warning', 'error', 'validating', '')\nexport type ValidateStatus = typeof ValidateStatuses[number]\n\ntype RenderChildren<Values = any> = (form: FormInstance<Values>) => React.ReactNode\ntype RcFieldProps<Values = any> = Omit<FieldProps<Values>, 'children'>\ntype ChildrenType<Values = any> = RenderChildren<Values> | React.ReactNode\n\ninterface MemoInputProps {\n value: any\n update: any\n children: React.ReactNode\n childProps: any[]\n}\n\nconst MemoInput = React.memo(\n ({ children }: MemoInputProps) => children as JSX.Element,\n (prev, next) =>\n prev.value === next.value &&\n prev.update === next.update &&\n prev.childProps.length === next.childProps.length &&\n prev.childProps.every((value, index) => value === next.childProps[index])\n)\n\nexport interface FormItemProps<Values = any>\n extends FormItemLabelProps,\n FormItemInputProps,\n RcFieldProps<Values> {\n prefixCls?: string\n noStyle?: boolean\n style?: React.CSSProperties\n className?: string\n children?: ChildrenType<Values>\n id?: string\n hasFeedback?: boolean\n validateStatus?: ValidateStatus\n required?: boolean\n hidden?: boolean\n initialValue?: any\n messageVariables?: Record<string, string>\n tooltip?: LabelTooltipType\n /** @deprecated No need anymore */\n fieldKey?: React.Key | React.Key[]\n}\n\nfunction hasValidName(name?: NamePath): boolean {\n if (name === null) {\n warning(false, 'Form.Item', '`null` is passed as `name` property')\n }\n return !(name === undefined || name === null)\n}\n\nfunction genEmptyMeta(): Meta {\n return {\n errors: [],\n warnings: [],\n touched: false,\n validating: false,\n validated: false,\n name: [],\n }\n}\n\nfunction InternalFormItem<Values = any>(props: FormItemProps<Values>): React.ReactElement {\n const {\n name,\n noStyle,\n dependencies,\n prefixCls: customizePrefixCls,\n shouldUpdate,\n rules,\n children,\n required,\n label,\n messageVariables,\n trigger = 'onChange',\n validateTrigger,\n hidden,\n } = props\n // TODO\n // @ts-ignore\n const { getPrefixCls } = useContext(ConfigContext)\n const { name: formName } = useContext(FormContext)\n const isRenderProps = typeof children === 'function'\n const notifyParentMetaChange = useContext(NoStyleItemContext)\n const contextDisabled = useContext(DisabledContext)\n const { readonly: contextReadonly } = useContext(FormContext)\n\n const { validateTrigger: contextValidateTrigger } = useContext(FieldContext)\n const mergedValidateTrigger =\n validateTrigger !== undefined ? validateTrigger : contextValidateTrigger\n\n const hasName = hasValidName(name)\n\n const prefixCls = getPrefixCls('form', customizePrefixCls)\n\n // ========================= MISC =========================\n // Get `noStyle` required info\n const listContext = React.useContext(ListContext)\n const fieldKeyPathRef = React.useRef<React.Key[]>()\n\n // ======================== Errors ========================\n // >>>>> Collect sub field errors\n const [subFieldErrors, setSubFieldErrors] = useFrameState<Record<string, FieldError>>({})\n\n // >>>>> Current field errors\n const [meta, setMeta] = useState<Meta>(() => genEmptyMeta())\n\n const onMetaChange = (nextMeta: Meta & { destroy?: boolean }) => {\n // This keyInfo is not correct when field is removed\n // Since origin keyManager no longer keep the origin key anymore\n // Which means we need cache origin one and reuse when removed\n const keyInfo = listContext?.getKey(nextMeta.name)\n\n // Destroy will reset all the meta\n setMeta(nextMeta.destroy ? genEmptyMeta() : nextMeta, true)\n\n // Bump to parent since noStyle\n if (noStyle && notifyParentMetaChange) {\n let namePath = nextMeta.name\n\n if (!nextMeta.destroy) {\n if (keyInfo !== undefined) {\n const [fieldKey, restPath] = keyInfo\n namePath = [fieldKey, ...restPath]\n fieldKeyPathRef.current = namePath\n }\n } else {\n // Use origin cache data\n namePath = fieldKeyPathRef.current || namePath\n }\n notifyParentMetaChange(nextMeta, namePath)\n }\n }\n\n // >>>>> Collect noStyle Field error to the top FormItem\n const onSubItemMetaChange = (subMeta: Meta & { destroy: boolean }, uniqueKeys: React.Key[]) => {\n // Only `noStyle` sub item will trigger\n setSubFieldErrors((prevSubFieldErrors) => {\n const clone = {\n ...prevSubFieldErrors,\n }\n\n // name: ['user', 1] + key: [4] = ['user', 4]\n const mergedNamePath = [...subMeta.name.slice(0, -1), ...uniqueKeys]\n const mergedNameKey = mergedNamePath.join(NAME_SPLIT)\n\n if (subMeta.destroy) {\n // Remove\n delete clone[mergedNameKey]\n } else {\n // Update\n clone[mergedNameKey] = subMeta\n }\n\n return clone\n })\n }\n\n // >>>>> Get merged errors\n const [mergedErrors, mergedWarnings] = React.useMemo(() => {\n const errorList: string[] = [...meta.errors]\n const warningList: string[] = [...meta.warnings]\n\n Object.values(subFieldErrors).forEach((subFieldError) => {\n errorList.push(...(subFieldError.errors || []))\n warningList.push(...(subFieldError.warnings || []))\n })\n\n return [errorList, warningList]\n }, [subFieldErrors, meta.errors, meta.warnings])\n\n // ===================== Children Ref =====================\n const getItemRef = useItemRef()\n\n // ======================== Render ========================\n function renderLayout(\n baseChildren: React.ReactNode,\n fieldId?: string,\n isRequired?: boolean\n ): React.ReactNode {\n if (noStyle && !hidden) {\n return baseChildren\n }\n\n return (\n <ItemHolder\n key=\"row\"\n {...props}\n prefixCls={prefixCls}\n fieldId={fieldId}\n isRequired={isRequired}\n errors={mergedErrors}\n warnings={mergedWarnings}\n meta={meta}\n // TODO\n // @ts-ignore\n onSubItemMetaChange={onSubItemMetaChange}\n >\n {baseChildren}\n </ItemHolder>\n )\n }\n\n if (!hasName && !isRenderProps && !dependencies) {\n if (isValidElement(children)) {\n return renderLayout(\n cloneElement(children, {\n ...children.props,\n disabled: children.props?.disabled ?? contextDisabled,\n readonly: children.props?.readonly ?? contextReadonly,\n })\n ) as JSX.Element\n }\n return renderLayout(children) as JSX.Element\n }\n\n let variables: Record<string, string> = {}\n if (typeof label === 'string') {\n variables.label = label\n } else if (name) {\n variables.label = String(name)\n }\n if (messageVariables) {\n variables = { ...variables, ...messageVariables }\n }\n\n // >>>>> With Field\n return (\n <Field\n {...props}\n messageVariables={variables}\n trigger={trigger}\n validateTrigger={mergedValidateTrigger}\n onMetaChange={onMetaChange}\n >\n {(control, renderMeta, context) => {\n const mergedName = toArray(name).length && renderMeta ? renderMeta.name : []\n const fieldId = getFieldId(mergedName, formName)\n\n const isRequired =\n required !== undefined\n ? required\n : !!(\n rules &&\n rules.some((rule) => {\n if (rule && typeof rule === 'object' && rule.required && !rule.warningOnly) {\n return true\n }\n if (typeof rule === 'function') {\n const ruleEntity = rule(context)\n return ruleEntity && ruleEntity.required && !ruleEntity.warningOnly\n }\n return false\n })\n )\n\n // ======================= Children =======================\n const mergedControl: typeof control = {\n ...control,\n }\n\n let childNode: React.ReactNode = null\n\n warning(\n !(shouldUpdate && dependencies),\n 'Form.Item',\n \"`shouldUpdate` and `dependencies` shouldn't be used together. See https://u.ant.design/form-deps.\"\n )\n if (Array.isArray(children) && hasName) {\n warning(\n false,\n 'Form.Item',\n 'A `Form.Item` with a `name` prop must have a single child element. For information on how to render more complex form items, see https://u.ant.design/complex-form-item.'\n )\n childNode = children\n } else if (isRenderProps && (!(shouldUpdate || dependencies) || hasName)) {\n warning(\n !!(shouldUpdate || dependencies),\n 'Form.Item',\n 'A `Form.Item` with a render function must have either `shouldUpdate` or `dependencies`.'\n )\n warning(\n !hasName,\n 'Form.Item',\n 'A `Form.Item` with a render function cannot be a field, and thus cannot have a `name` prop.'\n )\n } else if (dependencies && !isRenderProps && !hasName) {\n warning(\n false,\n 'Form.Item',\n 'Must set `name` or use a render function when `dependencies` is set.'\n )\n } else if (isValidElement(children)) {\n warning(\n children.props.defaultValue === undefined,\n 'Form.Item',\n '`defaultValue` will not work on controlled Field. You should use `initialValues` of Form instead.'\n )\n\n const childProps = {\n ...children.props,\n ...mergedControl,\n disabled: children.props?.disabled ?? contextDisabled,\n }\n\n if (contextReadonly !== undefined) {\n childProps.readonly = children.props?.readonly ?? contextReadonly\n }\n\n if (!childProps.id) {\n childProps.id = fieldId\n }\n\n if (props.help || mergedErrors.length > 0 || mergedWarnings.length > 0 || props.extra) {\n const describedbyArr = []\n if (props.help || mergedErrors.length > 0) {\n describedbyArr.push(`${fieldId}_help`)\n }\n if (props.extra) {\n describedbyArr.push(`${fieldId}_extra`)\n }\n childProps['aria-describedby'] = describedbyArr.join(' ')\n }\n\n if (mergedErrors.length > 0) {\n childProps['aria-invalid'] = 'true'\n }\n\n if (isRequired) {\n childProps['aria-required'] = 'true'\n }\n\n if (supportRef(children)) {\n childProps.ref = getItemRef(mergedName, children)\n }\n\n // We should keep user origin event handler\n const triggers = new Set<string>([...toArray(trigger), ...toArray(mergedValidateTrigger)])\n\n triggers.forEach((eventName) => {\n childProps[eventName] = (...args: any[]) => {\n mergedControl[eventName]?.(...args)\n // @ts-ignore\n children?.props?.[eventName]?.(...args)\n }\n })\n\n // List of props that need to be watched for changes -> if changes are detected in MemoInput -> rerender\n const watchingChildProps = [\n childProps['aria-required'],\n childProps['aria-invalid'],\n childProps['aria-describedby'],\n childProps.disabled,\n childProps.readonly,\n ]\n\n childNode = (\n <MemoInput\n value={mergedControl[props.valuePropName || 'value']}\n update={children}\n childProps={watchingChildProps}\n >\n {cloneElement(children, childProps)}\n </MemoInput>\n )\n } else if (isRenderProps && (shouldUpdate || dependencies) && !hasName) {\n childNode = (children as RenderChildren)(context)\n } else {\n warning(\n !mergedName.length,\n 'Form.Item',\n '`name` is only used for validate React element. If you are using Form.Item as layout display, please remove `name` instead.'\n )\n childNode = children as React.ReactNode\n }\n\n return renderLayout(childNode, fieldId, isRequired)\n }}\n </Field>\n )\n}\n\ntype InternalFormItemType = typeof InternalFormItem\n\ntype CompoundedComponent = InternalFormItemType & {\n useStatus: typeof useFormItemStatus\n}\n\nconst FormItem = InternalFormItem as CompoundedComponent\nFormItem.useStatus = useFormItemStatus\n\nexport default FormItem\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tntd-form/FormItem/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAGhE,OAAO,QAAQ,MAAM,4BAA4B,CAAA;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAClC,OAAO,iBAAiB,MAAM,4BAA4B,CAAA;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AACrD,OAAO,eAAe,MAAM,uCAAuC,CAAA;AACnE,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACpE,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AACxC,OAAO,OAAO,MAAM,qBAAqB,CAAA;AACzC,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAG5D,OAAO,aAAa,MAAM,wBAAwB,CAAA;AAClD,OAAO,UAAU,MAAM,qBAAqB,CAAA;AAC5C,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAC7C,OAAO,UAAU,MAAM,cAAc,CAAA;AAErC,MAAM,UAAU,GAAG,WAAW,CAAA;AAO9B,MAAM,gBAAgB,GAAG,KAAK,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,YAAY,EAAE,EAAE,CAAC,C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AO,YAAY,CAAC,SAAS,EAAE,OAAO,EAAE,UAAU,CAAC,CAAA;IACrD,CAAC,CACK,CACT,CAAA;AACH,CAAC;AAQD,MAAM,QAAQ,GAAG,gBAAuC,CAAA;AACxD,QAAQ,CAAC,SAAS,GAAG,iBAAiB,CAAA;AAEtC,eAAe,QAAQ,CAAA","sourcesContent":["import type { FormInstance } from 'rc-field-form'\nimport { Field, FieldContext, ListContext } from 'rc-field-form'\nimport type { FieldProps } from 'rc-field-form/lib/Field'\nimport type { Meta, NamePath } from 'rc-field-form/lib/interface'\nimport useState from 'rc-util/lib/hooks/useState'\nimport { supportRef } from 'rc-util/lib/ref'\nimport * as React from 'react'\nimport { useContext } from 'react'\nimport useFormItemStatus from '../hooks/useFormItemStatus'\nimport { ConfigContext } from '../../config-provider'\nimport DisabledContext from '../../config-provider/DisabledContext'\nimport { cloneElement, isValidElement } from '../../_util/reactNode'\nimport { tuple } from '../../_util/type'\nimport warning from '../../_util/warning'\nimport { FormContext, NoStyleItemContext } from '../context'\nimport type { FormItemInputProps } from '../FormItemInput'\nimport type { FormItemLabelProps, LabelTooltipType } from '../FormItemLabel'\nimport useFrameState from '../hooks/useFrameState'\nimport useItemRef from '../hooks/useItemRef'\nimport { getFieldId, toArray } from '../util'\nimport ItemHolder from './ItemHolder'\n\nconst NAME_SPLIT = '__SPLIT__'\n\ninterface FieldError {\n errors: string[]\n warnings: string[]\n}\n\nconst ValidateStatuses = tuple('success', 'warning', 'error', 'validating', '')\nexport type ValidateStatus = typeof ValidateStatuses[number]\n\ntype RenderChildren<Values = any> = (form: FormInstance<Values>) => React.ReactNode\ntype RcFieldProps<Values = any> = Omit<FieldProps<Values>, 'children'>\ntype ChildrenType<Values = any> = RenderChildren<Values> | React.ReactNode\n\ninterface MemoInputProps {\n value: any\n update: any\n children: React.ReactNode\n childProps: any[]\n}\n\nconst MemoInput = React.memo(\n ({ children }: MemoInputProps) => children as JSX.Element,\n (prev, next) =>\n prev.value === next.value &&\n prev.update === next.update &&\n prev.childProps.length === next.childProps.length &&\n prev.childProps.every((value, index) => value === next.childProps[index])\n)\n\nexport interface FormItemProps<Values = any>\n extends FormItemLabelProps,\n FormItemInputProps,\n RcFieldProps<Values> {\n prefixCls?: string\n noStyle?: boolean\n style?: React.CSSProperties\n className?: string\n children?: ChildrenType<Values>\n id?: string\n hasFeedback?: boolean\n validateStatus?: ValidateStatus\n required?: boolean\n hidden?: boolean\n initialValue?: any\n messageVariables?: Record<string, string>\n tooltip?: LabelTooltipType\n /** @deprecated No need anymore */\n fieldKey?: React.Key | React.Key[]\n}\n\nfunction hasValidName(name?: NamePath): boolean {\n if (name === null) {\n warning(false, 'Form.Item', '`null` is passed as `name` property')\n }\n return !(name === undefined || name === null)\n}\n\nfunction genEmptyMeta(): Meta {\n return {\n errors: [],\n warnings: [],\n touched: false,\n validating: false,\n validated: false,\n name: [],\n }\n}\n\nfunction InternalFormItem<Values = any>(props: FormItemProps<Values>): React.ReactElement {\n const {\n name,\n noStyle,\n dependencies,\n prefixCls: customizePrefixCls,\n shouldUpdate,\n rules,\n children,\n required,\n label,\n messageVariables,\n trigger = 'onChange',\n validateTrigger,\n hidden,\n } = props\n // TODO\n // @ts-ignore\n const { getPrefixCls } = useContext(ConfigContext)\n const { name: formName } = useContext(FormContext)\n const isRenderProps = typeof children === 'function'\n const notifyParentMetaChange = useContext(NoStyleItemContext)\n const contextDisabled = useContext(DisabledContext)\n const { readonly: contextReadonly } = useContext(FormContext)\n\n const { validateTrigger: contextValidateTrigger } = useContext(FieldContext)\n const mergedValidateTrigger =\n validateTrigger !== undefined ? validateTrigger : contextValidateTrigger\n\n const hasName = hasValidName(name)\n\n const prefixCls = getPrefixCls('form', customizePrefixCls)\n\n // ========================= MISC =========================\n // Get `noStyle` required info\n const listContext = React.useContext(ListContext)\n const fieldKeyPathRef = React.useRef<React.Key[]>()\n\n // ======================== Errors ========================\n // >>>>> Collect sub field errors\n const [subFieldErrors, setSubFieldErrors] = useFrameState<Record<string, FieldError>>({})\n\n // >>>>> Current field errors\n const [meta, setMeta] = useState<Meta>(() => genEmptyMeta())\n\n const onMetaChange = (nextMeta: Meta & { destroy?: boolean }) => {\n // This keyInfo is not correct when field is removed\n // Since origin keyManager no longer keep the origin key anymore\n // Which means we need cache origin one and reuse when removed\n const keyInfo = listContext?.getKey(nextMeta.name)\n\n // Destroy will reset all the meta\n setMeta(nextMeta.destroy ? genEmptyMeta() : nextMeta, true)\n\n // Bump to parent since noStyle\n if (noStyle && notifyParentMetaChange) {\n let namePath = nextMeta.name\n\n if (!nextMeta.destroy) {\n if (keyInfo !== undefined) {\n const [fieldKey, restPath] = keyInfo\n namePath = [fieldKey, ...restPath]\n fieldKeyPathRef.current = namePath\n }\n } else {\n // Use origin cache data\n namePath = fieldKeyPathRef.current || namePath\n }\n notifyParentMetaChange(nextMeta, namePath)\n }\n }\n\n // >>>>> Collect noStyle Field error to the top FormItem\n const onSubItemMetaChange = (subMeta: Meta & { destroy: boolean }, uniqueKeys: React.Key[]) => {\n // Only `noStyle` sub item will trigger\n setSubFieldErrors((prevSubFieldErrors) => {\n const clone = {\n ...prevSubFieldErrors,\n }\n\n // name: ['user', 1] + key: [4] = ['user', 4]\n const mergedNamePath = [...subMeta.name.slice(0, -1), ...uniqueKeys]\n const mergedNameKey = mergedNamePath.join(NAME_SPLIT)\n\n if (subMeta.destroy) {\n // Remove\n delete clone[mergedNameKey]\n } else {\n // Update\n clone[mergedNameKey] = subMeta\n }\n\n return clone\n })\n }\n\n // >>>>> Get merged errors\n const [mergedErrors, mergedWarnings] = React.useMemo(() => {\n const errorList: string[] = [...meta.errors]\n const warningList: string[] = [...meta.warnings]\n\n Object.values(subFieldErrors).forEach((subFieldError) => {\n errorList.push(...(subFieldError.errors || []))\n warningList.push(...(subFieldError.warnings || []))\n })\n\n return [errorList, warningList]\n }, [subFieldErrors, meta.errors, meta.warnings])\n\n // ===================== Children Ref =====================\n const getItemRef = useItemRef()\n\n // ======================== Render ========================\n function renderLayout(\n baseChildren: React.ReactNode,\n fieldId?: string,\n isRequired?: boolean\n ): React.ReactNode {\n if (noStyle && !hidden) {\n return baseChildren\n }\n\n return (\n <ItemHolder\n key=\"row\"\n {...props}\n prefixCls={prefixCls}\n fieldId={fieldId}\n isRequired={isRequired}\n errors={mergedErrors}\n warnings={mergedWarnings}\n meta={meta}\n // TODO\n // @ts-ignore\n onSubItemMetaChange={onSubItemMetaChange}\n >\n {baseChildren}\n </ItemHolder>\n )\n }\n\n if (!hasName && !isRenderProps && !dependencies) {\n if (isValidElement(children)) {\n return renderLayout(\n cloneElement(children, {\n ...children.props,\n disabled: children.props?.disabled ?? contextDisabled,\n readonly: children.props?.readonly ?? contextReadonly,\n })\n ) as JSX.Element\n }\n return renderLayout(children) as JSX.Element\n }\n\n let variables: Record<string, string> = {}\n if (typeof label === 'string') {\n variables.label = label\n } else if (name) {\n variables.label = String(name)\n }\n if (messageVariables) {\n variables = { ...variables, ...messageVariables }\n }\n\n // >>>>> With Field\n return (\n <Field\n {...props}\n messageVariables={variables}\n trigger={trigger}\n validateTrigger={mergedValidateTrigger}\n onMetaChange={onMetaChange}\n >\n {(control, renderMeta, context) => {\n const mergedName = toArray(name).length && renderMeta ? renderMeta.name : []\n const fieldId = getFieldId(mergedName, formName)\n\n const isRequired =\n required !== undefined\n ? required\n : !!(\n rules &&\n rules.some((rule) => {\n if (rule && typeof rule === 'object' && rule.required && !rule.warningOnly) {\n return true\n }\n if (typeof rule === 'function') {\n const ruleEntity = rule(context)\n return ruleEntity && ruleEntity.required && !ruleEntity.warningOnly\n }\n return false\n })\n )\n\n // ======================= Children =======================\n const mergedControl: typeof control = {\n ...control,\n }\n\n let childNode: React.ReactNode = null\n\n warning(\n !(shouldUpdate && dependencies),\n 'Form.Item',\n \"`shouldUpdate` and `dependencies` shouldn't be used together. See https://u.ant.design/form-deps.\"\n )\n if (Array.isArray(children) && hasName) {\n warning(\n false,\n 'Form.Item',\n 'A `Form.Item` with a `name` prop must have a single child element. For information on how to render more complex form items, see https://u.ant.design/complex-form-item.'\n )\n childNode = children\n } else if (isRenderProps && (!(shouldUpdate || dependencies) || hasName)) {\n warning(\n !!(shouldUpdate || dependencies),\n 'Form.Item',\n 'A `Form.Item` with a render function must have either `shouldUpdate` or `dependencies`.'\n )\n warning(\n !hasName,\n 'Form.Item',\n 'A `Form.Item` with a render function cannot be a field, and thus cannot have a `name` prop.'\n )\n } else if (dependencies && !isRenderProps && !hasName) {\n warning(\n false,\n 'Form.Item',\n 'Must set `name` or use a render function when `dependencies` is set.'\n )\n } else if (isValidElement(children)) {\n warning(\n children.props.defaultValue === undefined,\n 'Form.Item',\n '`defaultValue` will not work on controlled Field. You should use `initialValues` of Form instead.'\n )\n\n const childProps = {\n ...children.props,\n ...mergedControl,\n disabled: children.props?.disabled ?? contextDisabled,\n }\n\n if (contextReadonly !== undefined) {\n childProps.readonly = children.props?.readonly ?? contextReadonly\n }\n\n if (!childProps.id) {\n childProps.id = fieldId\n }\n\n if (props.help || mergedErrors.length > 0 || mergedWarnings.length > 0 || props.extra) {\n const describedbyArr = []\n if (props.help || mergedErrors.length > 0) {\n describedbyArr.push(`${fieldId}_help`)\n }\n if (props.extra) {\n describedbyArr.push(`${fieldId}_extra`)\n }\n childProps['aria-describedby'] = describedbyArr.join(' ')\n }\n\n if (mergedErrors.length > 0) {\n childProps['aria-invalid'] = 'true'\n }\n\n if (isRequired) {\n childProps['aria-required'] = 'true'\n }\n\n if (supportRef(children)) {\n childProps.ref = getItemRef(mergedName, children)\n }\n\n // We should keep user origin event handler\n const triggers = new Set<string>([...toArray(trigger), ...toArray(mergedValidateTrigger)])\n\n triggers.forEach((eventName) => {\n childProps[eventName] = (...args: any[]) => {\n mergedControl[eventName]?.(...args)\n // @ts-ignore\n children?.props?.[eventName]?.(...args)\n }\n })\n\n // List of props that need to be watched for changes -> if changes are detected in MemoInput -> rerender\n const watchingChildProps = [\n childProps['aria-required'],\n childProps['aria-invalid'],\n childProps['aria-describedby'],\n childProps.disabled,\n childProps.readonly,\n ]\n\n childNode = (\n <MemoInput\n value={mergedControl[props.valuePropName || 'value']}\n update={children}\n childProps={watchingChildProps}\n >\n {cloneElement(children, childProps)}\n </MemoInput>\n )\n } else if (isRenderProps && (shouldUpdate || dependencies) && !hasName) {\n childNode = (children as RenderChildren)(context)\n } else {\n warning(\n !mergedName.length,\n 'Form.Item',\n '`name` is only used for validate React element. If you are using Form.Item as layout display, please remove `name` instead.'\n )\n childNode = children as React.ReactNode\n }\n\n return renderLayout(childNode, fieldId, isRequired)\n }}\n </Field>\n )\n}\n\ntype InternalFormItemType = typeof InternalFormItem\n\ntype CompoundedComponent = InternalFormItemType & {\n useStatus: typeof useFormItemStatus\n}\n\nconst FormItem = InternalFormItem as CompoundedComponent\nFormItem.useStatus = useFormItemStatus\n\nexport default FormItem\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import classNames from 'classnames';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import Col from '../col';
|
|
3
|
+
import Col from '../grid/col';
|
|
4
4
|
import { FormContext, FormItemPrefixContext } from './context';
|
|
5
5
|
import ErrorList from './ErrorList';
|
|
6
6
|
const FormItemInput = (props) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormItemInput.js","sourceRoot":"","sources":["../../src/tntd-form/FormItemInput.tsx"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"FormItemInput.js","sourceRoot":"","sources":["../../src/tntd-form/FormItemInput.tsx"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAA;AAC9D,OAAO,SAAS,MAAM,aAAa,CAAA;AAgCn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AAA;AAED,eAAe,aAAa,CAAA","sourcesContent":["import classNames from 'classnames'\nimport * as React from 'react'\nimport type { ColProps } from '../grid/col'\nimport Col from '../grid/col'\nimport { FormContext, FormItemPrefixContext } from './context'\nimport ErrorList from './ErrorList'\nimport type { ValidateStatus } from './FormItem'\n\ninterface FormItemInputMiscProps {\n prefixCls: string\n children: React.ReactNode\n errors: React.ReactNode[]\n warnings: React.ReactNode[]\n marginBottom?: number | null\n onErrorVisibleChanged?: (visible: boolean) => void\n /** @internal do not use in any of your production. */\n _internalItemRender?: {\n mark: string\n render: (\n props: FormItemInputProps & FormItemInputMiscProps,\n domList: {\n input: JSX.Element\n errorList: JSX.Element | null\n extra: JSX.Element | null\n }\n ) => React.ReactNode\n }\n}\n\nexport interface FormItemInputProps {\n wrapperCol?: ColProps\n extra?: React.ReactNode\n status?: ValidateStatus\n help?: React.ReactNode\n fieldId?: string\n}\n\nconst FormItemInput: React.FC<FormItemInputProps & FormItemInputMiscProps> = (props) => {\n const {\n prefixCls,\n status,\n wrapperCol,\n children,\n errors,\n warnings,\n _internalItemRender: formItemRender,\n extra,\n help,\n fieldId,\n marginBottom,\n onErrorVisibleChanged,\n } = props\n const baseClassName = `${prefixCls}-item`\n\n const formContext = React.useContext(FormContext)\n\n const mergedWrapperCol: ColProps = wrapperCol || formContext.wrapperCol || {}\n\n const className = classNames(`${baseClassName}-control`, mergedWrapperCol.className)\n\n // Pass to sub FormItem should not with col info\n const subFormContext = React.useMemo(() => ({ ...formContext }), [formContext])\n delete subFormContext.labelCol\n delete subFormContext.wrapperCol\n\n const inputDom = (\n <div className={`${baseClassName}-control-input`}>\n <div className={`${baseClassName}-control-input-content`}>{children}</div>\n </div>\n )\n const formItemContext = React.useMemo(() => ({ prefixCls, status }), [prefixCls, status])\n const errorListDom =\n marginBottom !== null || errors.length || warnings.length ? (\n <div style={{ display: 'flex', flexWrap: 'nowrap' }}>\n <FormItemPrefixContext.Provider value={formItemContext}>\n <ErrorList\n fieldId={fieldId}\n errors={errors}\n warnings={warnings}\n help={help}\n helpStatus={status}\n className={`${baseClassName}-explain-connected`}\n onVisibleChanged={onErrorVisibleChanged}\n />\n </FormItemPrefixContext.Provider>\n {!!marginBottom && <div style={{ width: 0, height: marginBottom }} />}\n </div>\n ) : null\n\n const extraProps: { id?: string } = {}\n\n if (fieldId) {\n extraProps.id = `${fieldId}_extra`\n }\n\n // If extra = 0, && will goes wrong\n // 0&&error -> 0\n const extraDom = extra ? (\n <div {...extraProps} className={`${baseClassName}-extra`}>\n {extra}\n </div>\n ) : null\n\n const dom =\n formItemRender && formItemRender.mark === 'pro_table_render' && formItemRender.render ? (\n formItemRender.render(props, { input: inputDom, errorList: errorListDom, extra: extraDom })\n ) : (\n <>\n {inputDom}\n {errorListDom}\n {extraDom}\n </>\n )\n return (\n <FormContext.Provider value={subFormContext}>\n <Col {...mergedWrapperCol} className={className}>\n {dom}\n </Col>\n </FormContext.Provider>\n )\n}\n\nexport default FormItemInput\n"]}
|
|
@@ -12,7 +12,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
import Icon from '../icon';
|
|
13
13
|
import classNames from 'classnames';
|
|
14
14
|
import * as React from 'react';
|
|
15
|
-
import Col from '../col';
|
|
15
|
+
import Col from '../grid/col';
|
|
16
16
|
import Tooltip from '../tooltip';
|
|
17
17
|
import { FormContext } from './context';
|
|
18
18
|
function toTooltipProps(tooltip) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormItemLabel.js","sourceRoot":"","sources":["../../src/tntd-form/FormItemLabel.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,IAAI,MAAM,SAAS,CAAA;AAC1B,OAAO,UAAU,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"FormItemLabel.js","sourceRoot":"","sources":["../../src/tntd-form/FormItemLabel.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO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;YACxC,CAAC,GAAG,SAAS,8BAA8B,CAAC,EAAE,YAAY,KAAK,UAAU;YACzE,CAAC,GAAG,SAAS,gBAAgB,CAAC,EAAE,CAAC,aAAa;SAC/C,CAAC,CAAA;QAEF,OAAO,CACL,oBAAC,GAAG,oBAAK,cAAc,IAAE,SAAS,EAAE,iBAAiB;YACnD,+BACE,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,cAAc,EACzB,KAAK,EAAE,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,IAE5C,aAAa,CACR,CACJ,CACP,CAAA;IACH,CAAC,CACoB,CACxB,CAAA;AACH,CAAC,CAAA;AAED,eAAe,aAAa,CAAA","sourcesContent":["import Icon from '../icon'\nimport classNames from 'classnames'\nimport * as React from 'react'\nimport type { ColProps } from '../grid/col'\nimport Col from '../grid/col'\n// import { useLocaleReceiver } from '../locale-provider/LocaleReceiver';\n// import defaultLocale from '../locale/default';\nimport type { TooltipProps } from '../tooltip'\nimport Tooltip from '../tooltip'\nimport type { FormContextProps } from './context'\nimport { FormContext } from './context'\nimport type { RequiredMark } from './Form'\nimport type { FormLabelAlign } from './interface'\n\nexport type WrapperTooltipProps = TooltipProps & {\n icon?: React.ReactElement\n}\n\nexport type LabelTooltipType = WrapperTooltipProps | React.ReactNode\n\nfunction toTooltipProps(tooltip: LabelTooltipType): WrapperTooltipProps | null {\n if (!tooltip) {\n return null\n }\n\n if (typeof tooltip === 'object' && !React.isValidElement(tooltip)) {\n return tooltip as WrapperTooltipProps\n }\n\n return {\n title: tooltip,\n }\n}\n\nexport interface FormItemLabelProps {\n colon?: boolean\n htmlFor?: string\n label?: React.ReactNode\n labelAlign?: FormLabelAlign\n labelCol?: ColProps\n requiredMark?: RequiredMark\n tooltip?: LabelTooltipType\n}\n\nconst FormItemLabel: React.FC<FormItemLabelProps & { required?: boolean; prefixCls: string }> = ({\n prefixCls,\n label,\n htmlFor,\n labelCol,\n labelAlign,\n colon,\n required,\n requiredMark,\n tooltip,\n}) => {\n // const [formLocale] = useLocaleReceiver('Form');\n\n if (!label) return null\n\n return (\n <FormContext.Consumer key=\"label\">\n {({\n vertical,\n labelAlign: contextLabelAlign,\n labelCol: contextLabelCol,\n labelWrap,\n colon: contextColon,\n }: FormContextProps) => {\n const mergedLabelCol: ColProps = labelCol || contextLabelCol || {}\n\n const mergedLabelAlign: FormLabelAlign | undefined = labelAlign || contextLabelAlign\n\n const labelClsBasic = `${prefixCls}-item-label`\n const labelColClassName = classNames(\n labelClsBasic,\n mergedLabelAlign === 'left' && `${labelClsBasic}-left`,\n mergedLabelCol.className,\n {\n [`${labelClsBasic}-wrap`]: !!labelWrap,\n }\n )\n\n let labelChildren = label\n // Keep label is original where there should have no colon\n const computedColon = colon === true || (contextColon !== false && colon !== false)\n const haveColon = computedColon && !vertical\n // Remove duplicated user input colon\n if (haveColon && typeof label === 'string' && (label as string).trim() !== '') {\n labelChildren = (label as string).replace(/[:|:]\\s*$/, '')\n }\n\n // Tooltip\n const tooltipProps = toTooltipProps(tooltip)\n if (tooltipProps) {\n const { icon = <Icon type=\"question-circle\" />, ...restTooltipProps } = tooltipProps\n const tooltipNode = (\n <Tooltip {...restTooltipProps}>\n {React.cloneElement(icon, { className: `${prefixCls}-item-tooltip`, title: '' })}\n </Tooltip>\n )\n\n labelChildren = (\n <>\n {labelChildren}\n {tooltipNode}\n </>\n )\n }\n\n // Add required mark if optional\n if (requiredMark === 'optional' && !required) {\n labelChildren = (\n <>\n {labelChildren}\n <span className={`${prefixCls}-item-optional`} title=\"\">\n {/* {formLocale?.optional || defaultLocale.Form?.optional} */}\n </span>\n </>\n )\n }\n\n const labelClassName = classNames({\n [`${prefixCls}-item-required`]: required,\n [`${prefixCls}-item-required-mark-optional`]: requiredMark === 'optional',\n [`${prefixCls}-item-no-colon`]: !computedColon,\n })\n\n return (\n <Col {...mergedLabelCol} className={labelColClassName}>\n <label\n htmlFor={htmlFor}\n className={labelClassName}\n title={typeof label === 'string' ? label : ''}\n >\n {labelChildren}\n </label>\n </Col>\n )\n }}\n </FormContext.Consumer>\n )\n}\n\nexport default FormItemLabel\n"]}
|
package/es/tntd-form/FormList.js
CHANGED
|
@@ -12,7 +12,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
import { List } from 'rc-field-form';
|
|
13
13
|
import * as React from 'react';
|
|
14
14
|
import { ConfigContext } from '../config-provider';
|
|
15
|
-
import warning from '
|
|
15
|
+
import warning from '../_util/warning';
|
|
16
16
|
import { FormItemPrefixContext } from './context';
|
|
17
17
|
const FormList = (_a) => {
|
|
18
18
|
var { prefixCls: customizePrefixCls, children } = _a, props = __rest(_a, ["prefixCls", "children"]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormList.js","sourceRoot":"","sources":["../../src/tntd-form/FormList.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AAEpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,OAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"FormList.js","sourceRoot":"","sources":["../../src/tntd-form/FormList.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AAEpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,OAAO,MAAM,kBAAkB,CAAA;AACtC,OAAO,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAA;AA2BjD,MAAM,QAAQ,GAA4B,CAAC,EAI1C,EAAE,EAAE;QAJsC,EACzC,SAAS,EAAE,kBAAkB,EAC7B,QAAQ,OAET,EADI,KAAK,cAHiC,yBAI1C,CADS;IAER,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,WAAW,EAAE,mBAAmB,CAAC,CAAA;IAEvD,OAAO;IACP,aAAa;IACb,MAAM,EAAE,YAAY,EAAE,GAAG,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,CAAA;IACxD,MAAM,SAAS,GAAG,YAAY,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAA;IAC1D,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAChC,GAAG,EAAE,CAAC,CAAC;QACL,SAAS;QACT,MAAM,EAAE,OAAgB;KACzB,CAAC,EACF,CAAC,SAAS,CAAC,CACZ,CAAA;IAED,OAAO,CACL,oBAAC,IAAI,oBAAK,KAAK,GACZ,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,CAAC,CAC5B,oBAAC,qBAAqB,CAAC,QAAQ,IAAC,KAAK,EAAE,YAAY,IAChD,QAAQ,CACP,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,iCAAM,KAAK,KAAE,QAAQ,EAAE,KAAK,CAAC,GAAG,IAAG,CAAC,EAC1D,SAAS,EACT;QACE,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,QAAQ,EAAE,IAAI,CAAC,QAAQ;KACxB,CACF,CAC8B,CAClC,CACI,CACR,CAAA;AACH,CAAC,CAAA;AAED,eAAe,QAAQ,CAAA","sourcesContent":["import { List } from 'rc-field-form'\nimport type { StoreValue, ValidatorRule } from 'rc-field-form/lib/interface'\nimport * as React from 'react'\nimport { ConfigContext } from '../config-provider'\nimport warning from '../_util/warning'\nimport { FormItemPrefixContext } from './context'\n\nexport interface FormListFieldData {\n name: number\n key: number\n /** @deprecated No need anymore Use key instead */\n fieldKey?: number\n}\n\nexport interface FormListOperation {\n add: (defaultValue?: StoreValue, insertIndex?: number) => void\n remove: (index: number | number[]) => void\n move: (from: number, to: number) => void\n}\n\nexport interface FormListProps {\n prefixCls?: string\n name: string | number | (string | number)[]\n rules?: ValidatorRule[]\n initialValue?: any[]\n children: (\n fields: FormListFieldData[],\n operation: FormListOperation,\n meta: { errors: React.ReactNode[]; warnings: React.ReactNode[] }\n ) => React.ReactNode\n}\n\nconst FormList: React.FC<FormListProps> = ({\n prefixCls: customizePrefixCls,\n children,\n ...props\n}) => {\n warning(!!props.name, 'Form.List', 'Miss `name` prop.')\n\n // TODO\n // @ts-ignore\n const { getPrefixCls } = React.useContext(ConfigContext)\n const prefixCls = getPrefixCls('form', customizePrefixCls)\n const contextValue = React.useMemo(\n () => ({\n prefixCls,\n status: 'error' as const,\n }),\n [prefixCls]\n )\n\n return (\n <List {...props}>\n {(fields, operation, meta) => (\n <FormItemPrefixContext.Provider value={contextValue}>\n {children(\n fields.map((field) => ({ ...field, fieldKey: field.key })),\n operation,\n {\n errors: meta.errors,\n warnings: meta.warnings,\n }\n )}\n </FormItemPrefixContext.Provider>\n )}\n </List>\n )\n}\n\nexport default FormList\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useContext } from 'react';
|
|
2
2
|
import { FormItemInputContext } from '../context';
|
|
3
|
-
import warning from '
|
|
3
|
+
import warning from '../../_util/warning';
|
|
4
4
|
const useFormItemStatus = () => {
|
|
5
5
|
const { status } = useContext(FormItemInputContext);
|
|
6
6
|
warning(status !== undefined, 'Form.Item', `Form.Item.useStatus should be used under Form.Item component. For more information: ${window.location.protocol}//${window.location.host}/components/form-cn/#Form.Item.useStatus`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFormItemStatus.js","sourceRoot":"","sources":["../../../src/tntd-form/hooks/useFormItemStatus.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAElC,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AACjD,OAAO,OAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"useFormItemStatus.js","sourceRoot":"","sources":["../../../src/tntd-form/hooks/useFormItemStatus.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAElC,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AACjD,OAAO,OAAO,MAAM,qBAAqB,CAAA;AAMzC,MAAM,iBAAiB,GAAsB,GAAG,EAAE;IAChD,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,oBAAoB,CAAC,CAAA;IAEnD,OAAO,CACL,MAAM,KAAK,SAAS,EACpB,WAAW,EACX,uFAAuF,MAAM,CAAC,QAAQ,CAAC,QAAQ,KAAK,MAAM,CAAC,QAAQ,CAAC,IAAI,0CAA0C,CACnL,CAAA;IAED,OAAO,EAAE,MAAM,EAAE,CAAA;AACnB,CAAC,CAAA;AAED,eAAe,iBAAiB,CAAA","sourcesContent":["import { useContext } from 'react'\nimport type { ValidateStatus } from '../FormItem'\nimport { FormItemInputContext } from '../context'\nimport warning from '../../_util/warning'\n\ntype UseFormItemStatus = () => {\n status?: ValidateStatus\n}\n\nconst useFormItemStatus: UseFormItemStatus = () => {\n const { status } = useContext(FormItemInputContext)\n\n warning(\n status !== undefined,\n 'Form.Item',\n `Form.Item.useStatus should be used under Form.Item component. For more information: ${window.location.protocol}//${window.location.host}/components/form-cn/#Form.Item.useStatus`\n )\n\n return { status }\n}\n\nexport default useFormItemStatus\n"]}
|
package/es/tntd-form/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tntd-form/index.tsx"],"names":[],"mappings":"AACA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tntd-form/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AACxC,OAAO,SAA6B,MAAM,aAAa,CAAA;AACvD,OAAO,YAAY,EAAE,EAA2B,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AACjF,OAAO,IAAuB,MAAM,YAAY,CAAA;AAChD,OAAO,IAA6D,MAAM,YAAY,CAAA;AACtF,OAAO,eAAe,MAAM,yBAAyB,CAAA;AAErD,OAAO,oBAAoB,CAAA;AAiB3B,MAAM,IAAI,GAAG,YAAmC,CAAA;AAEhD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;AAChB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;AAChB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;AAC1B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;AACtB,IAAI,CAAC,eAAe,GAAG,eAAe,CAAA;AACtC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;AACxB,IAAI,CAAC,QAAQ,GAAG,YAAY,CAAA;AAsB5B,eAAe,IAAI,CAAA","sourcesContent":["import type { Rule, RuleObject, RuleRender } from 'rc-field-form/lib/interface'\nimport { FormProvider } from './context'\nimport ErrorList, { ErrorListProps } from './ErrorList'\nimport InternalForm, { FormInstance, FormProps, useForm, useWatch } from './Form'\nimport Item, { FormItemProps } from './FormItem'\nimport List, { FormListFieldData, FormListOperation, FormListProps } from './FormList'\nimport useFormInstance from './hooks/useFormInstance'\n\nimport './style/index.less'\n\ntype InternalFormType = typeof InternalForm\n\ntype CompoundedComponent = InternalFormType & {\n useForm: typeof useForm\n useFormInstance: typeof useFormInstance\n useWatch: typeof useWatch\n Item: typeof Item\n List: typeof List\n ErrorList: typeof ErrorList\n Provider: typeof FormProvider\n\n /** @deprecated Only for warning usage. Do not use. */\n create: () => void\n}\n\nconst Form = InternalForm as CompoundedComponent\n\nForm.Item = Item\nForm.List = List\nForm.ErrorList = ErrorList\nForm.useForm = useForm\nForm.useFormInstance = useFormInstance\nForm.useWatch = useWatch\nForm.Provider = FormProvider\n// Form.create = () => {\n// warning(\n// false,\n// 'Form',\n// 'antd v4 removed `Form.create`. Please remove or use `@ant-design/compatible` instead.',\n// );\n// };\n\nexport {\n FormInstance,\n FormProps,\n FormItemProps,\n ErrorListProps,\n Rule,\n RuleObject,\n RuleRender,\n FormListProps,\n FormListFieldData,\n FormListOperation,\n}\n\nexport default Form\n"]}
|