@hi-ui/schema-fields 4.0.0-experimental.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/README.md +11 -0
- package/lib/cjs/base.js +125 -0
- package/lib/cjs/components/image-preview/index.js +63 -0
- package/lib/cjs/components/span/index.js +33 -0
- package/lib/cjs/components/upload-bridge/index.js +227 -0
- package/lib/cjs/components/upload-bridge/utils.js +73 -0
- package/lib/cjs/ctx.js +70 -0
- package/lib/cjs/editable/ctx.js +45 -0
- package/lib/cjs/editable/editable.js +141 -0
- package/lib/cjs/editable/index.js +62 -0
- package/lib/cjs/editable/readonly.js +36 -0
- package/lib/cjs/editable/simple.js +61 -0
- package/lib/cjs/editable/use-readonly.js +200 -0
- package/lib/cjs/extensible/selectable/index.js +114 -0
- package/lib/cjs/extensible/selectable/match-cascader.js +184 -0
- package/lib/cjs/fields/basic/cascader/index.js +98 -0
- package/lib/cjs/fields/basic/check-cascader/index.js +58 -0
- package/lib/cjs/fields/basic/check-select/index.js +89 -0
- package/lib/cjs/fields/basic/check-tree-select/index.js +61 -0
- package/lib/cjs/fields/basic/checkbox/index.js +84 -0
- package/lib/cjs/fields/basic/counter/index.js +40 -0
- package/lib/cjs/fields/basic/radio/index.js +44 -0
- package/lib/cjs/fields/basic/rating/index.js +40 -0
- package/lib/cjs/fields/basic/select/index.js +98 -0
- package/lib/cjs/fields/basic/slider/index.js +40 -0
- package/lib/cjs/fields/basic/switch/index.js +47 -0
- package/lib/cjs/fields/basic/textarea/index.js +40 -0
- package/lib/cjs/fields/basic/time-picker/index.js +45 -0
- package/lib/cjs/fields/basic/time-picker/index.scss.js +18 -0
- package/lib/cjs/fields/basic/tree-select/index.js +61 -0
- package/lib/cjs/fields/basic/upload/custom.js +29 -0
- package/lib/cjs/fields/basic/upload/index.js +48 -0
- package/lib/cjs/fields/enhance/number-range/index.js +39 -0
- package/lib/cjs/fields/semantic/date/index.js +82 -0
- package/lib/cjs/fields/semantic/image/index.js +65 -0
- package/lib/cjs/fields/semantic/image/upload.js +32 -0
- package/lib/cjs/fields/semantic/link/index.js +96 -0
- package/lib/cjs/fields/semantic/number/index.js +106 -0
- package/lib/cjs/fields/semantic/tag/index.js +164 -0
- package/lib/cjs/fields/semantic/tag/index.scss.js +18 -0
- package/lib/cjs/fields/semantic/text/index.js +61 -0
- package/lib/cjs/index.js +145 -0
- package/lib/cjs/utils/batch-dep-update.js +40 -0
- package/lib/cjs/utils/form-binding.js +40 -0
- package/lib/cjs/utils/label.js +34 -0
- package/lib/cjs/utils.js +35 -0
- package/lib/esm/base.js +111 -0
- package/lib/esm/components/image-preview/index.js +49 -0
- package/lib/esm/components/span/index.js +20 -0
- package/lib/esm/components/upload-bridge/index.js +214 -0
- package/lib/esm/components/upload-bridge/utils.js +66 -0
- package/lib/esm/ctx.js +55 -0
- package/lib/esm/editable/ctx.js +32 -0
- package/lib/esm/editable/editable.js +129 -0
- package/lib/esm/editable/index.js +44 -0
- package/lib/esm/editable/readonly.js +24 -0
- package/lib/esm/editable/simple.js +49 -0
- package/lib/esm/editable/use-readonly.js +193 -0
- package/lib/esm/extensible/selectable/index.js +101 -0
- package/lib/esm/extensible/selectable/match-cascader.js +179 -0
- package/lib/esm/fields/basic/cascader/index.js +83 -0
- package/lib/esm/fields/basic/check-cascader/index.js +44 -0
- package/lib/esm/fields/basic/check-select/index.js +75 -0
- package/lib/esm/fields/basic/check-tree-select/index.js +47 -0
- package/lib/esm/fields/basic/checkbox/index.js +70 -0
- package/lib/esm/fields/basic/counter/index.js +26 -0
- package/lib/esm/fields/basic/radio/index.js +30 -0
- package/lib/esm/fields/basic/rating/index.js +26 -0
- package/lib/esm/fields/basic/select/index.js +83 -0
- package/lib/esm/fields/basic/slider/index.js +26 -0
- package/lib/esm/fields/basic/switch/index.js +33 -0
- package/lib/esm/fields/basic/textarea/index.js +26 -0
- package/lib/esm/fields/basic/time-picker/index.js +31 -0
- package/lib/esm/fields/basic/time-picker/index.scss.js +13 -0
- package/lib/esm/fields/basic/tree-select/index.js +47 -0
- package/lib/esm/fields/basic/upload/custom.js +16 -0
- package/lib/esm/fields/basic/upload/index.js +34 -0
- package/lib/esm/fields/enhance/number-range/index.js +26 -0
- package/lib/esm/fields/semantic/date/index.js +67 -0
- package/lib/esm/fields/semantic/image/index.js +51 -0
- package/lib/esm/fields/semantic/image/upload.js +20 -0
- package/lib/esm/fields/semantic/link/index.js +82 -0
- package/lib/esm/fields/semantic/number/index.js +91 -0
- package/lib/esm/fields/semantic/tag/index.js +149 -0
- package/lib/esm/fields/semantic/tag/index.scss.js +13 -0
- package/lib/esm/fields/semantic/text/index.js +47 -0
- package/lib/esm/index.js +85 -0
- package/lib/esm/utils/batch-dep-update.js +35 -0
- package/lib/esm/utils/form-binding.js +34 -0
- package/lib/esm/utils/label.js +21 -0
- package/lib/esm/utils.js +27 -0
- package/lib/types/base.d.ts +44 -0
- package/lib/types/components/async-refill-placeholder/index.d.ts +7 -0
- package/lib/types/components/image-preview/index.d.ts +5 -0
- package/lib/types/components/span/index.d.ts +8 -0
- package/lib/types/components/upload-bridge/index.d.ts +5 -0
- package/lib/types/components/upload-bridge/type.d.ts +26 -0
- package/lib/types/components/upload-bridge/utils.d.ts +11 -0
- package/lib/types/ctx.d.ts +21 -0
- package/lib/types/editable/ctx.d.ts +5 -0
- package/lib/types/editable/editable.d.ts +18 -0
- package/lib/types/editable/index.d.ts +14 -0
- package/lib/types/editable/readonly.d.ts +8 -0
- package/lib/types/editable/simple.d.ts +8 -0
- package/lib/types/editable/type.d.ts +9 -0
- package/lib/types/editable/use-readonly.d.ts +26 -0
- package/lib/types/extensible/selectable/index.d.ts +31 -0
- package/lib/types/extensible/selectable/match-cascader.d.ts +19 -0
- package/lib/types/extensible/selectable/type.d.ts +16 -0
- package/lib/types/fields/basic/cascader/index.d.ts +10 -0
- package/lib/types/fields/basic/check-cascader/index.d.ts +11 -0
- package/lib/types/fields/basic/check-select/index.d.ts +34 -0
- package/lib/types/fields/basic/check-tree-select/index.d.ts +10 -0
- package/lib/types/fields/basic/checkbox/index.d.ts +19 -0
- package/lib/types/fields/basic/counter/index.d.ts +7 -0
- package/lib/types/fields/basic/radio/index.d.ts +7 -0
- package/lib/types/fields/basic/rating/index.d.ts +7 -0
- package/lib/types/fields/basic/select/index.d.ts +12 -0
- package/lib/types/fields/basic/slider/index.d.ts +7 -0
- package/lib/types/fields/basic/switch/index.d.ts +7 -0
- package/lib/types/fields/basic/textarea/index.d.ts +7 -0
- package/lib/types/fields/basic/time-picker/index.d.ts +8 -0
- package/lib/types/fields/basic/tree-select/index.d.ts +11 -0
- package/lib/types/fields/basic/upload/custom.d.ts +3 -0
- package/lib/types/fields/basic/upload/index.d.ts +8 -0
- package/lib/types/fields/enhance/number-range/index.d.ts +7 -0
- package/lib/types/fields/semantic/date/index.d.ts +15 -0
- package/lib/types/fields/semantic/image/index.d.ts +11 -0
- package/lib/types/fields/semantic/image/upload.d.ts +3 -0
- package/lib/types/fields/semantic/link/index.d.ts +31 -0
- package/lib/types/fields/semantic/number/index.d.ts +21 -0
- package/lib/types/fields/semantic/tag/index.d.ts +78 -0
- package/lib/types/fields/semantic/text/index.d.ts +13 -0
- package/lib/types/index.d.ts +108 -0
- package/lib/types/utils/batch-dep-update.d.ts +13 -0
- package/lib/types/utils/form-binding.d.ts +11 -0
- package/lib/types/utils/label.d.ts +11 -0
- package/lib/types/utils.d.ts +15 -0
- package/package.json +98 -0
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/** @LICENSE
|
|
2
|
+
* @hi-ui/schema-fields
|
|
3
|
+
* https://github.com/XiaoMi/hiui/tree/master/packages/schema/schema-fields#readme
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/
|
|
10
|
+
import _inheritsLoose from '@babel/runtime/helpers/esm/inheritsLoose';
|
|
11
|
+
import React from 'react';
|
|
12
|
+
import { cx } from '@hi-ui/classname';
|
|
13
|
+
import { omit, isNil } from 'lodash-es';
|
|
14
|
+
import { Tag } from '@hi-ui/tag';
|
|
15
|
+
import { ProField } from '../../../base.js';
|
|
16
|
+
import { ReadonlyWrapper } from '../../../components/span/index.js';
|
|
17
|
+
import './index.scss.js';
|
|
18
|
+
|
|
19
|
+
// IPD的标签颜色规范,先记录在这里吧
|
|
20
|
+
// https://www.figma.com/design/R7gUHJaKDPSAaWojTrNUe2/%E7%A0%94%E4%BA%A7%E4%BE%9B%E4%B8%9A%E5%8A%A1%E8%AE%BE%E8%AE%A1%E8%A7%84%E8%8C%83-IPD?node-id=2042-50477&node-type=frame&t=uCEcQbmB9uwVVUIQ-0
|
|
21
|
+
var colorPreset = {
|
|
22
|
+
blue: {
|
|
23
|
+
back: '#EDF7FE',
|
|
24
|
+
fore: '#0744AD'
|
|
25
|
+
},
|
|
26
|
+
yellow: {
|
|
27
|
+
back: '#FEFCE9',
|
|
28
|
+
fore: '#875100'
|
|
29
|
+
},
|
|
30
|
+
green: {
|
|
31
|
+
back: '#EEFEF2',
|
|
32
|
+
fore: '#007D3E'
|
|
33
|
+
},
|
|
34
|
+
red: {
|
|
35
|
+
back: '#FEF1EE',
|
|
36
|
+
fore: '#B32D36'
|
|
37
|
+
},
|
|
38
|
+
orange: {
|
|
39
|
+
back: '#FEF5EE',
|
|
40
|
+
fore: '#B23E1B'
|
|
41
|
+
},
|
|
42
|
+
purple: {
|
|
43
|
+
back: '#F5EEFE',
|
|
44
|
+
fore: '#533DAD'
|
|
45
|
+
},
|
|
46
|
+
/** 蓝绿色 */cyan: {
|
|
47
|
+
back: '#ECFEFC',
|
|
48
|
+
fore: '#0C737A'
|
|
49
|
+
},
|
|
50
|
+
/** 天蓝色 */skyblue: {
|
|
51
|
+
back: '#ECFCFE',
|
|
52
|
+
fore: '#006BB3'
|
|
53
|
+
},
|
|
54
|
+
/** 深紫色 */darkPurple: {
|
|
55
|
+
back: '#EEF2FE',
|
|
56
|
+
fore: '#363AB3'
|
|
57
|
+
},
|
|
58
|
+
/** 蓝灰色 */blueGray: {
|
|
59
|
+
back: '#EEF7FE',
|
|
60
|
+
fore: '#3C5485'
|
|
61
|
+
},
|
|
62
|
+
/** 中灰色 */midGray: {
|
|
63
|
+
back: '#F2F4F7',
|
|
64
|
+
fore: '#1F2733'
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
var ColorEnumPreset = Object.keys(colorPreset);
|
|
68
|
+
function isInvalidTagData(data) {
|
|
69
|
+
if (isNil(data)) return true;
|
|
70
|
+
if (data === '') return true;
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
var ProTag = /*#__PURE__*/function (_ProField) {
|
|
74
|
+
_inheritsLoose(ProTag, _ProField);
|
|
75
|
+
function ProTag() {
|
|
76
|
+
return _ProField.apply(this, arguments) || this;
|
|
77
|
+
}
|
|
78
|
+
var _proto = ProTag.prototype;
|
|
79
|
+
_proto.render = function render(data, ctx) {
|
|
80
|
+
if (isInvalidTagData(data)) return this.dftDom;
|
|
81
|
+
// 统一转换为数组处理
|
|
82
|
+
var dataList = (Array.isArray(data) ? data : [data]).filter(function (el) {
|
|
83
|
+
return !isInvalidTagData(el);
|
|
84
|
+
});
|
|
85
|
+
if (dataList.length === 0) return this.dftDom;
|
|
86
|
+
return this.renderTag(dataList, ctx);
|
|
87
|
+
};
|
|
88
|
+
_proto.renderTag = function renderTag(dataArray, ctx) {
|
|
89
|
+
var _this = this;
|
|
90
|
+
var fieldProps = this.getFieldProps({}, ctx);
|
|
91
|
+
var className = cx(fieldProps.className, {
|
|
92
|
+
'pro-tag--bordered': fieldProps.bordered
|
|
93
|
+
});
|
|
94
|
+
var tagProps = this.getTagProps(fieldProps);
|
|
95
|
+
return /*#__PURE__*/React.createElement(ReadonlyWrapper, {
|
|
96
|
+
style: {
|
|
97
|
+
gap: 4
|
|
98
|
+
}
|
|
99
|
+
}, dataArray.map(function (data, index) {
|
|
100
|
+
var _a;
|
|
101
|
+
var _preset = (_a = fieldProps.colorPreset) === null || _a === void 0 ? void 0 : _a[data];
|
|
102
|
+
var text = _this.getText(data, fieldProps.textMap);
|
|
103
|
+
// 没有预设颜色,则显示默认Tag样式
|
|
104
|
+
if (!_preset) {
|
|
105
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
106
|
+
key: index
|
|
107
|
+
}, /*#__PURE__*/React.createElement(Tag, Object.assign({
|
|
108
|
+
type: "default"
|
|
109
|
+
}, tagProps, {
|
|
110
|
+
className: className
|
|
111
|
+
}), text));
|
|
112
|
+
}
|
|
113
|
+
// 内置类型
|
|
114
|
+
var type = _this.getType(_preset);
|
|
115
|
+
// 自定义颜色(文字色和背景色)
|
|
116
|
+
var color = _this.getColor(_preset);
|
|
117
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
118
|
+
key: index
|
|
119
|
+
}, /*#__PURE__*/React.createElement(Tag, Object.assign({
|
|
120
|
+
type: type,
|
|
121
|
+
color: color === null || color === void 0 ? void 0 : color.fore,
|
|
122
|
+
background: color === null || color === void 0 ? void 0 : color.back
|
|
123
|
+
}, tagProps, {
|
|
124
|
+
className: className
|
|
125
|
+
}), text));
|
|
126
|
+
}));
|
|
127
|
+
};
|
|
128
|
+
_proto.getTagProps = function getTagProps(props) {
|
|
129
|
+
return omit(props, ['bordered', 'colorPreset']);
|
|
130
|
+
};
|
|
131
|
+
_proto.getType = function getType(preset) {
|
|
132
|
+
if (typeof preset !== 'string') return undefined;
|
|
133
|
+
if (preset in colorPreset) return undefined;
|
|
134
|
+
return preset;
|
|
135
|
+
};
|
|
136
|
+
_proto.getColor = function getColor(preset) {
|
|
137
|
+
if (typeof preset !== 'string') return preset;
|
|
138
|
+
if (preset in colorPreset) return colorPreset[preset];
|
|
139
|
+
return undefined;
|
|
140
|
+
};
|
|
141
|
+
_proto.getText = function getText(data, textMap) {
|
|
142
|
+
var _a, _b;
|
|
143
|
+
if (!textMap) return data;
|
|
144
|
+
if (textMap instanceof Map) return (_a = textMap.get(data)) !== null && _a !== void 0 ? _a : data;
|
|
145
|
+
return (_b = textMap[data]) !== null && _b !== void 0 ? _b : data;
|
|
146
|
+
};
|
|
147
|
+
return ProTag;
|
|
148
|
+
}(ProField);
|
|
149
|
+
export { ColorEnumPreset, ProTag, colorPreset };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** @LICENSE
|
|
2
|
+
* @hi-ui/schema-fields
|
|
3
|
+
* https://github.com/XiaoMi/hiui/tree/master/packages/schema/schema-fields#readme
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/
|
|
10
|
+
import __styleInject__ from '@hi-ui/style-inject';
|
|
11
|
+
var css_248z = ".pro-tag--bordered {border: 0.5px solid #dfe2e8;}";
|
|
12
|
+
__styleInject__(css_248z);
|
|
13
|
+
export { css_248z as default };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/** @LICENSE
|
|
2
|
+
* @hi-ui/schema-fields
|
|
3
|
+
* https://github.com/XiaoMi/hiui/tree/master/packages/schema/schema-fields#readme
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/
|
|
10
|
+
import _inheritsLoose from '@babel/runtime/helpers/esm/inheritsLoose';
|
|
11
|
+
import React from 'react';
|
|
12
|
+
import { omit } from 'lodash-es';
|
|
13
|
+
import { Input } from '@hi-ui/input';
|
|
14
|
+
import { mapToDumb } from '@hi-ui/dumb-wrapper';
|
|
15
|
+
import { ProField } from '../../../base.js';
|
|
16
|
+
var DumbInput = mapToDumb(Input, {
|
|
17
|
+
getChangedValue: function getChangedValue(evt, value) {
|
|
18
|
+
return value;
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
var ProText = /*#__PURE__*/function (_ProField) {
|
|
22
|
+
_inheritsLoose(ProText, _ProField);
|
|
23
|
+
function ProText() {
|
|
24
|
+
return _ProField.apply(this, arguments) || this;
|
|
25
|
+
}
|
|
26
|
+
var _proto = ProText.prototype;
|
|
27
|
+
_proto.render = function render(data, ctx) {
|
|
28
|
+
if (!data) return this.dftDom;
|
|
29
|
+
if (typeof data === 'string') {
|
|
30
|
+
return this.renderString(data, ctx);
|
|
31
|
+
}
|
|
32
|
+
try {
|
|
33
|
+
return this.renderString(String(data), ctx);
|
|
34
|
+
} catch (error) {
|
|
35
|
+
return this.dftDom;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
_proto.renderFormItem = function renderFormItem(_, ctx) {
|
|
39
|
+
var fieldProps = this.getFieldProps({
|
|
40
|
+
placeholder: this.getDftPlaceholder(ctx)
|
|
41
|
+
}, ctx);
|
|
42
|
+
var pureInputProps = omit(fieldProps, ['numberOfLines', 'tooltipClassName', 'useRawInput']);
|
|
43
|
+
return fieldProps.useRawInput ? ( /*#__PURE__*/React.createElement(Input, Object.assign({}, pureInputProps))) : ( /*#__PURE__*/React.createElement(DumbInput, Object.assign({}, pureInputProps)));
|
|
44
|
+
};
|
|
45
|
+
return ProText;
|
|
46
|
+
}(ProField);
|
|
47
|
+
export { DumbInput, ProText };
|
package/lib/esm/index.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/** @LICENSE
|
|
2
|
+
* @hi-ui/schema-fields
|
|
3
|
+
* https://github.com/XiaoMi/hiui/tree/master/packages/schema/schema-fields#readme
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/
|
|
10
|
+
import React from 'react';
|
|
11
|
+
import { FieldMapProvider } from './ctx.js';
|
|
12
|
+
export { matchFieldClass, useFieldMap, useMatchFieldClass } from './ctx.js';
|
|
13
|
+
import { ProCascader } from './fields/basic/cascader/index.js';
|
|
14
|
+
import { ProCheckCascader } from './fields/basic/check-cascader/index.js';
|
|
15
|
+
import { ProCheckSelect } from './fields/basic/check-select/index.js';
|
|
16
|
+
import { ProCheckTreeSelect } from './fields/basic/check-tree-select/index.js';
|
|
17
|
+
import { ProCheckbox } from './fields/basic/checkbox/index.js';
|
|
18
|
+
import { ProCounter } from './fields/basic/counter/index.js';
|
|
19
|
+
import { ProDate } from './fields/semantic/date/index.js';
|
|
20
|
+
import { ProImage } from './fields/semantic/image/index.js';
|
|
21
|
+
import { ProLink } from './fields/semantic/link/index.js';
|
|
22
|
+
import { ProNumber } from './fields/semantic/number/index.js';
|
|
23
|
+
import { ProRadio } from './fields/basic/radio/index.js';
|
|
24
|
+
import { ProRating } from './fields/basic/rating/index.js';
|
|
25
|
+
import { ProSelect } from './fields/basic/select/index.js';
|
|
26
|
+
import { ProSlider } from './fields/basic/slider/index.js';
|
|
27
|
+
import { ProSwitch } from './fields/basic/switch/index.js';
|
|
28
|
+
import { ProTag } from './fields/semantic/tag/index.js';
|
|
29
|
+
export { ColorEnumPreset, colorPreset } from './fields/semantic/tag/index.js';
|
|
30
|
+
import { ProText } from './fields/semantic/text/index.js';
|
|
31
|
+
export { DumbInput } from './fields/semantic/text/index.js';
|
|
32
|
+
import { ProTextArea } from './fields/basic/textarea/index.js';
|
|
33
|
+
import { ProTimePicker } from './fields/basic/time-picker/index.js';
|
|
34
|
+
import { ProTreeSelect } from './fields/basic/tree-select/index.js';
|
|
35
|
+
import { ProUpload } from './fields/basic/upload/index.js';
|
|
36
|
+
import { ProNumberRange } from './fields/enhance/number-range/index.js';
|
|
37
|
+
export { ProField } from './base.js';
|
|
38
|
+
export { ReadonlyWrapper, ReadonlyWrapper as Span } from './components/span/index.js';
|
|
39
|
+
export { getFieldProps, getFormItemProps, getWrapperProps } from './utils.js';
|
|
40
|
+
export { ImagePreview } from './components/image-preview/index.js';
|
|
41
|
+
export { UploadBridge } from './components/upload-bridge/index.js';
|
|
42
|
+
export { EditableField } from './editable/index.js';
|
|
43
|
+
export { getLabel } from './utils/label.js';
|
|
44
|
+
export { BatchDepUpdate } from './utils/batch-dep-update.js';
|
|
45
|
+
export { wrapFormBinding } from './utils/form-binding.js';
|
|
46
|
+
export { isReadonly, runDynamicEditable, useReadonly } from './editable/use-readonly.js';
|
|
47
|
+
export { EditableControlProvider, useEditableControlCtx } from './editable/ctx.js';
|
|
48
|
+
export { SimpleCase, isSimpleCase } from './editable/simple.js';
|
|
49
|
+
export { ReadonlyCase } from './editable/readonly.js';
|
|
50
|
+
export { EditableCase } from './editable/editable.js';
|
|
51
|
+
|
|
52
|
+
// export { ProUser, type ProUserProps } from './enhance/user'
|
|
53
|
+
var ProFieldMap = {
|
|
54
|
+
cascader: ProCascader,
|
|
55
|
+
'check-cascader': ProCheckCascader,
|
|
56
|
+
'check-select': ProCheckSelect,
|
|
57
|
+
'check-tree-select': ProCheckTreeSelect,
|
|
58
|
+
checkbox: ProCheckbox,
|
|
59
|
+
counter: ProCounter,
|
|
60
|
+
date: ProDate,
|
|
61
|
+
image: ProImage,
|
|
62
|
+
link: ProLink,
|
|
63
|
+
number: ProNumber,
|
|
64
|
+
radio: ProRadio,
|
|
65
|
+
rating: ProRating,
|
|
66
|
+
select: ProSelect,
|
|
67
|
+
slider: ProSlider,
|
|
68
|
+
"switch": ProSwitch,
|
|
69
|
+
tag: ProTag,
|
|
70
|
+
text: ProText,
|
|
71
|
+
textarea: ProTextArea,
|
|
72
|
+
'time-picker': ProTimePicker,
|
|
73
|
+
'tree-select': ProTreeSelect,
|
|
74
|
+
upload: ProUpload,
|
|
75
|
+
// 'edit-table': ProEditTable,
|
|
76
|
+
'number-range': ProNumberRange
|
|
77
|
+
// user: ProUser,
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
function BuiltinFieldMapProvider(props) {
|
|
81
|
+
return /*#__PURE__*/React.createElement(FieldMapProvider, {
|
|
82
|
+
fields: ProFieldMap
|
|
83
|
+
}, props.children);
|
|
84
|
+
}
|
|
85
|
+
export { BuiltinFieldMapProvider, FieldMapProvider, ProCascader, ProCheckCascader, ProCheckSelect, ProCheckTreeSelect, ProCheckbox, ProCounter, ProDate, ProFieldMap, ProImage, ProLink, ProNumber, ProNumberRange, ProRadio, ProRating, ProSelect, ProSlider, ProSwitch, ProTag, ProText, ProTextArea, ProTimePicker, ProTreeSelect, ProUpload };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
2
|
+
/** @LICENSE
|
|
3
|
+
* @hi-ui/schema-fields
|
|
4
|
+
* https://github.com/XiaoMi/hiui/tree/master/packages/schema/schema-fields#readme
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
|
7
|
+
*
|
|
8
|
+
* This source code is licensed under the MIT license found in the
|
|
9
|
+
* LICENSE file in the root directory of this source tree.
|
|
10
|
+
*/
|
|
11
|
+
import { set } from 'lodash-es';
|
|
12
|
+
var BatchDepUpdate = /*#__PURE__*/function () {
|
|
13
|
+
function BatchDepUpdate() {}
|
|
14
|
+
BatchDepUpdate.update = function update(values) {
|
|
15
|
+
return {
|
|
16
|
+
_IS_BATCH_UPDATE_: true,
|
|
17
|
+
values: values
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
BatchDepUpdate.isBatch = function isBatch(value) {
|
|
21
|
+
return _typeof(value) === 'object' && !!value && '_IS_BATCH_UPDATE_' in value && 'values' in value;
|
|
22
|
+
}
|
|
23
|
+
// key 可能会是普通字符串或路径数组
|
|
24
|
+
;
|
|
25
|
+
|
|
26
|
+
BatchDepUpdate.getValues = function getValues(key, value) {
|
|
27
|
+
if (this.isBatch(value)) return value.values;else {
|
|
28
|
+
var _ref;
|
|
29
|
+
// 仅在明确传入路径数组时,才使用 set 方法
|
|
30
|
+
if (Array.isArray(key)) return set({}, key, value);else return _ref = {}, _ref[key] = value, _ref;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
return BatchDepUpdate;
|
|
34
|
+
}();
|
|
35
|
+
export { BatchDepUpdate };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/** @LICENSE
|
|
2
|
+
* @hi-ui/schema-fields
|
|
3
|
+
* https://github.com/XiaoMi/hiui/tree/master/packages/schema/schema-fields#readme
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/
|
|
10
|
+
// TODO 待完善类型定义
|
|
11
|
+
function wrapFormBinding(formBinding, fieldProps) {
|
|
12
|
+
return Object.assign(Object.assign({}, formBinding), {
|
|
13
|
+
value: formBinding.value,
|
|
14
|
+
onChange: function onChange() {
|
|
15
|
+
var _a2;
|
|
16
|
+
var _a;
|
|
17
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
18
|
+
args[_key] = arguments[_key];
|
|
19
|
+
}
|
|
20
|
+
formBinding.onChange.apply(formBinding, args);
|
|
21
|
+
(_a = fieldProps.onChange) === null || _a === void 0 ? void 0 : (_a2 = _a).call.apply(_a2, [fieldProps].concat(args));
|
|
22
|
+
},
|
|
23
|
+
onBlur: function onBlur() {
|
|
24
|
+
var _a3;
|
|
25
|
+
var _a;
|
|
26
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
27
|
+
args[_key2] = arguments[_key2];
|
|
28
|
+
}
|
|
29
|
+
formBinding.onBlur.apply(formBinding, args);
|
|
30
|
+
(_a = fieldProps.onBlur) === null || _a === void 0 ? void 0 : (_a3 = _a).call.apply(_a3, [fieldProps].concat(args));
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
export { wrapFormBinding };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** @LICENSE
|
|
2
|
+
* @hi-ui/schema-fields
|
|
3
|
+
* https://github.com/XiaoMi/hiui/tree/master/packages/schema/schema-fields#readme
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/
|
|
10
|
+
import React from 'react';
|
|
11
|
+
import EllipsisTooltip from '@hi-ui/ellipsis-tooltip';
|
|
12
|
+
function getLabel(field, ctx) {
|
|
13
|
+
var _a, _b, _c;
|
|
14
|
+
// 在组中时,不需要显示 label
|
|
15
|
+
if ((_a = field.extra) === null || _a === void 0 ? void 0 : _a.mustInGroup) return undefined;
|
|
16
|
+
if (typeof ((_b = field.extra) === null || _b === void 0 ? void 0 : _b.customLabel) === 'function') {
|
|
17
|
+
return (_c = field.extra) === null || _c === void 0 ? void 0 : _c.customLabel(ctx);
|
|
18
|
+
}
|
|
19
|
+
return typeof field.title === 'string' ? ( /*#__PURE__*/React.createElement(EllipsisTooltip, null, field.title)) : field.title;
|
|
20
|
+
}
|
|
21
|
+
export { getLabel };
|
package/lib/esm/utils.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** @LICENSE
|
|
2
|
+
* @hi-ui/schema-fields
|
|
3
|
+
* https://github.com/XiaoMi/hiui/tree/master/packages/schema/schema-fields#readme
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/
|
|
10
|
+
import { getPipeGetterValue, mergeProps } from '@hi-ui/schema-utils';
|
|
11
|
+
import { wrapFormBinding } from './utils/form-binding.js';
|
|
12
|
+
import 'react';
|
|
13
|
+
import '@hi-ui/ellipsis-tooltip';
|
|
14
|
+
import 'lodash-es';
|
|
15
|
+
function getFieldProps(dftProps, ctx) {
|
|
16
|
+
var fieldProps = getPipeGetterValue(dftProps, ctx.field.fieldProps);
|
|
17
|
+
// formBinding 本质是 Form 注入给 field 的属性,因此在此处统一处理
|
|
18
|
+
var formBindingProps = ctx.formBinding ? wrapFormBinding(ctx.formBinding, fieldProps) : {};
|
|
19
|
+
return mergeProps(fieldProps, formBindingProps);
|
|
20
|
+
}
|
|
21
|
+
function getWrapperProps(dftProps, ctx) {
|
|
22
|
+
return getPipeGetterValue(dftProps, ctx.field.wrapperProps);
|
|
23
|
+
}
|
|
24
|
+
function getFormItemProps(dftProps, ctx) {
|
|
25
|
+
return getPipeGetterValue(dftProps, ctx.field.formItemProps);
|
|
26
|
+
}
|
|
27
|
+
export { getFieldProps, getFormItemProps, getWrapperProps, wrapFormBinding };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { InputProps } from '@hi-ui/input';
|
|
3
|
+
import { AbstractProField } from '@hi-ui/schema-core';
|
|
4
|
+
import type { FormItemProps, ProFieldProps, ProFieldRenderCtx, ProFieldRenderCellCtx, ProFieldRenderFooterCellCtx, ProFieldRenderFormItemCtx, ProFieldRenderEditableCtx, ProFieldRenderEditCellCtx, FieldRendererType } from '@hi-ui/schema-core';
|
|
5
|
+
import type { NormalFieldCtxType } from './utils';
|
|
6
|
+
export { ProFieldProps, ProFieldRenderCtx, ProFieldRenderCellCtx, ProFieldRenderFooterCellCtx, ProFieldRenderFormItemCtx, ProFieldRenderEditableCtx, ProFieldRenderEditCellCtx, FieldRendererType, };
|
|
7
|
+
/**
|
|
8
|
+
* 增强型的自定义渲染函数
|
|
9
|
+
* - 用于在字段内部渲染逻辑的基础之上进行额外增强
|
|
10
|
+
*/
|
|
11
|
+
export type EnhancedRenderersType = Partial<{
|
|
12
|
+
[K in keyof AbstractProField as K extends 'constructor' ? never : K]: AbstractProField[K] extends AnyFn ? (dom: React.ReactNode, innerCtx: {
|
|
13
|
+
render: ProField;
|
|
14
|
+
data: Parameters<AbstractProField[K]>[0];
|
|
15
|
+
renderCtx: Parameters<AbstractProField[K]>[1];
|
|
16
|
+
}) => React.ReactNode : never;
|
|
17
|
+
}>;
|
|
18
|
+
export declare class ProField extends AbstractProField {
|
|
19
|
+
dftDom: JSX.Element;
|
|
20
|
+
protected getFieldProps<FieldProps extends AnyObject>(dftProps: FieldProps, ctx: NormalFieldCtxType<FieldProps>): FieldProps;
|
|
21
|
+
protected getWrapperProps<WrapperProps extends AnyObject>(dftProps: WrapperProps, ctx: Pick<ProFieldRenderCtx<AnyObject, WrapperProps>, 'field'>): WrapperProps;
|
|
22
|
+
protected getFormItemProps(dftProps: FormItemProps, ctx: Pick<ProFieldRenderFormItemCtx, 'field'>): FormItemProps;
|
|
23
|
+
/**
|
|
24
|
+
* 渲染字符串的内部方法
|
|
25
|
+
* @desc 很多类型的字段最终渲染时都是文本,因此提取一个公共方法到此处
|
|
26
|
+
* @desc 封装了 EllipsisTooltip 的逻辑 */
|
|
27
|
+
protected renderString(text: string, ctx: ProFieldRenderCtx<ProFieldProps>): JSX.Element;
|
|
28
|
+
/** 只读模式的渲染逻辑 */
|
|
29
|
+
render(data: unknown, ctx: ProFieldRenderCtx<AnyType>): JSX.Element;
|
|
30
|
+
/**
|
|
31
|
+
* 表格单元格渲染逻辑
|
|
32
|
+
* @desc 默认直接使用 render 的逻辑 */
|
|
33
|
+
renderCell(data: unknown, ctx: ProFieldRenderCellCtx<AnyType>): JSX.Element;
|
|
34
|
+
/**
|
|
35
|
+
* 表格 Footer 单元格渲染逻辑
|
|
36
|
+
* @desc 没有默认逻辑,需由字段自行实现 */
|
|
37
|
+
renderFooterCell(ctx: ProFieldRenderFooterCellCtx<AnyType>): React.ReactNode;
|
|
38
|
+
renderFormItem(data: null, ctx: ProFieldRenderFormItemCtx<AnyType>): void;
|
|
39
|
+
protected getEditablePlaceholder(data: unknown, ctx: ProFieldRenderEditableCtx<AnyType>): unknown;
|
|
40
|
+
/** 编辑模式的渲染逻辑,在只读与可编辑之间切换 */
|
|
41
|
+
renderEditable(data: unknown, ctx: ProFieldRenderEditableCtx<AnyType>, extraProps?: InputProps): JSX.Element;
|
|
42
|
+
getDftPlaceholder(ctx: NormalFieldCtxType<AnyType>): string | undefined;
|
|
43
|
+
}
|
|
44
|
+
export type FieldMapType = Record<string, typeof ProField>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export type ReadonlyWrapperProps = {
|
|
3
|
+
children: React.ReactNode;
|
|
4
|
+
dataSet?: Record<string, Primitive | undefined>;
|
|
5
|
+
style?: React.CSSProperties;
|
|
6
|
+
};
|
|
7
|
+
export declare function ReadonlyWrapper(props: ReadonlyWrapperProps): JSX.Element;
|
|
8
|
+
export { ReadonlyWrapper as Span };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { UploadProps } from '@hi-ui/upload';
|
|
3
|
+
import type { UploadBridgeProps } from './type';
|
|
4
|
+
export { UploadBridgeProps };
|
|
5
|
+
export declare function UploadBridge(props: React.PropsWithChildren<UploadBridgeProps>): React.ReactElement<UploadProps, string | React.JSXElementConstructor<any>>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { StandardProps } from 'ahooks/es/useControllableValue';
|
|
2
|
+
import type { UploadProps } from '@hi-ui/upload';
|
|
3
|
+
export type BaseFileInfoType = {
|
|
4
|
+
/** 文件名称 */
|
|
5
|
+
name: string;
|
|
6
|
+
/** 包含协议、域名、路径等的完整文件地址 */
|
|
7
|
+
url: string;
|
|
8
|
+
};
|
|
9
|
+
export type UploadFileType = string | File | (BaseFileInfoType & {
|
|
10
|
+
/** 文件唯一标识 */
|
|
11
|
+
fileId?: string;
|
|
12
|
+
});
|
|
13
|
+
export type UploadBridgeProps = Partial<StandardProps<UploadFileType[]>> & Omit<UploadProps, 'customUpload' | 'onChange' | 'fileList' | 'onRemove' | 'maxSize' | 'uploadAction' | 'data' | 'name' | 'method' | 'headers' | 'withCredentials' | 'beforeUpload'> & {
|
|
14
|
+
/**
|
|
15
|
+
* 上传模式
|
|
16
|
+
* @default 'formData'
|
|
17
|
+
* @desc formData 模式时,响应给外部的是【文件】的列表
|
|
18
|
+
* @desc json 模式时,响应给外部的是【文件基本信息对象】的列表
|
|
19
|
+
* @desc json 模式时需传入 request 方法,用来上传文件
|
|
20
|
+
* @desc json 模式下,返回的信息顺序需与上传的顺序一致,否则可能导致自动去重逻辑失效
|
|
21
|
+
*/
|
|
22
|
+
mode?: 'formData' | 'json';
|
|
23
|
+
request?: (files: File[]) => Promise<(string | BaseFileInfoType)[]>;
|
|
24
|
+
/** 接收上传的文件体积上限(单位:KB) */
|
|
25
|
+
maxSize?: number;
|
|
26
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { UploadFileItem } from '@hi-ui/upload';
|
|
2
|
+
import type { UploadFileType } from './type';
|
|
3
|
+
export declare function toFileList(file?: UploadFileType | UploadFileType[]): {
|
|
4
|
+
fileIdSet?: undefined;
|
|
5
|
+
fileList?: undefined;
|
|
6
|
+
} | {
|
|
7
|
+
fileIdSet: Set<string>;
|
|
8
|
+
fileList: UploadFileItem[];
|
|
9
|
+
};
|
|
10
|
+
export declare function genFileIdentifier(file: UploadFileType): string;
|
|
11
|
+
export declare function sliceToMaxCount<T>(value: T[], maxCount: number | undefined, curCount?: number): T[];
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { FieldConfigType } from '@hi-ui/schema-core';
|
|
3
|
+
import type { ProFieldMapType } from '.';
|
|
4
|
+
export declare function FieldMapProvider(props: React.PropsWithChildren<{
|
|
5
|
+
fields: Partial<ProFieldMapType>;
|
|
6
|
+
}>): JSX.Element;
|
|
7
|
+
export type UseFieldMapOpts = {
|
|
8
|
+
/** 自定义字段渲染器映射配置 */
|
|
9
|
+
fieldMap?: Partial<ProFieldMapType>;
|
|
10
|
+
};
|
|
11
|
+
export declare function useFieldMap(opts?: UseFieldMapOpts): ProFieldMapType;
|
|
12
|
+
export type MatchFieldClassOpts = UseFieldMapOpts & {
|
|
13
|
+
name?: string;
|
|
14
|
+
field: FieldConfigType;
|
|
15
|
+
fieldMap: ProFieldMapType;
|
|
16
|
+
};
|
|
17
|
+
export declare function matchFieldClass(opts: MatchFieldClassOpts): typeof import("./base").ProField;
|
|
18
|
+
export type UseMatchFieldClassOpts = Omit<MatchFieldClassOpts, 'fieldMap'> & {
|
|
19
|
+
fieldMap?: ProFieldMapType;
|
|
20
|
+
};
|
|
21
|
+
export declare function useMatchFieldClass(opts: UseMatchFieldClassOpts): typeof import("./base").ProField;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { FieldControlType } from '@hi-ui/schema-core';
|
|
3
|
+
export type EditableControlCtxType = Partial<Pick<FieldControlType, 'editable' | 'readonly'>>;
|
|
4
|
+
export declare function EditableControlProvider(props: React.PropsWithChildren<EditableControlCtxType>): JSX.Element;
|
|
5
|
+
export declare function useEditableControlCtx(): Partial<Pick<FieldControlType, "readonly" | "editable">>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { FieldConfigType } from '@hi-ui/schema-core';
|
|
2
|
+
import type { ProField, ProFieldRenderEditableCtx } from '../index';
|
|
3
|
+
export { isReadonly } from './use-readonly';
|
|
4
|
+
export type EditableCaseProps = {
|
|
5
|
+
/** 字段配置 */
|
|
6
|
+
field: FieldConfigType;
|
|
7
|
+
/** 字段渲染器 */
|
|
8
|
+
FieldClass: typeof ProField;
|
|
9
|
+
/** 渲染的上下文 */
|
|
10
|
+
ctx: Omit<ProFieldRenderEditableCtx, 'onActivate' | 'onDeactivate'>;
|
|
11
|
+
/** 当前值 */
|
|
12
|
+
value?: unknown;
|
|
13
|
+
/** 失焦时是否保持激活状态,默认为false */
|
|
14
|
+
keepActiveOnBlur?: boolean;
|
|
15
|
+
/** 是否默认激活 */
|
|
16
|
+
defaultActive?: boolean;
|
|
17
|
+
};
|
|
18
|
+
export declare function EditableCase(props: EditableCaseProps): JSX.Element;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { UseFieldMapOpts } from '../ctx';
|
|
2
|
+
import { isSimpleCase, SimpleCase } from './simple';
|
|
3
|
+
import { ReadonlyCase, type ReadonlyCaseProps, type UsedBy } from './readonly';
|
|
4
|
+
import { EditableCase, type EditableCaseProps } from './editable';
|
|
5
|
+
export { isReadonly, useReadonly, runDynamicEditable } from './use-readonly';
|
|
6
|
+
export type EditableFieldProps<T extends UsedBy = 'other'> = UseFieldMapOpts & Omit<EditableCaseProps, 'FieldClass'> & Pick<ReadonlyCaseProps<T>, 'usedBy'> & {
|
|
7
|
+
/** 运行时的可编辑状态(可选),优先级最高 */
|
|
8
|
+
runtimeEditable?: boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare function EditableField<T extends UsedBy = 'other'>(props: EditableFieldProps<T>): JSX.Element;
|
|
11
|
+
export { SimpleCase, ReadonlyCase, EditableCase, isSimpleCase, };
|
|
12
|
+
export type { ReadonlyCaseProps, EditableCaseProps, UsedBy, };
|
|
13
|
+
export * from './ctx';
|
|
14
|
+
export * from './type';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ProFieldRenderCellCtx, ProFieldRenderCtx } from '../index';
|
|
2
|
+
import type { EditableCaseProps } from './editable';
|
|
3
|
+
export type UsedBy = 'table' | 'other';
|
|
4
|
+
export type ReadonlyCaseProps<T extends UsedBy = 'other'> = Omit<EditableCaseProps, 'ctx'> & {
|
|
5
|
+
usedBy: T;
|
|
6
|
+
ctx: T extends 'table' ? ProFieldRenderCellCtx : ProFieldRenderCtx;
|
|
7
|
+
};
|
|
8
|
+
export declare function ReadonlyCase<T extends UsedBy = 'other'>(props: ReadonlyCaseProps<T>): JSX.Element;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { FieldConfigType } from '@hi-ui/schema-core';
|
|
2
|
+
import type { EditableCaseProps } from './editable';
|
|
3
|
+
export type SimpleCaseProps = Pick<EditableCaseProps, 'value'>;
|
|
4
|
+
/**
|
|
5
|
+
* 简单字段且无自定义渲染,使用 SimpleCase
|
|
6
|
+
*/
|
|
7
|
+
export declare function isSimpleCase(field: FieldConfigType): boolean | undefined;
|
|
8
|
+
export declare function SimpleCase(props: SimpleCaseProps): JSX.Element;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { FieldConfigType } from '@hi-ui/schema-core';
|
|
2
|
+
import type { DynamicEditableCtxType } from './type';
|
|
3
|
+
type ReadonlyCtrlType = Partial<Record<'editable' | 'readonly', boolean>>;
|
|
4
|
+
type ReadonlyCtxType = {
|
|
5
|
+
component: ReadonlyCtrlType;
|
|
6
|
+
field: ReadonlyCtrlType;
|
|
7
|
+
runtimeEditable?: boolean;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* 判断字段是否只读
|
|
11
|
+
* @param field 字段配置
|
|
12
|
+
* @param runtimeEditable 运行时的可编辑状态(可选)
|
|
13
|
+
*/
|
|
14
|
+
export declare function useReadonly(field: FieldConfigType, runtimeEditable?: boolean): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* 判断是否只读的工具函数
|
|
17
|
+
*/
|
|
18
|
+
export declare function isReadonly(ctx: ReadonlyCtxType): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* 运行动态可编辑函数
|
|
21
|
+
* - 会在字段内部完成【只读/可编辑/运行时可编辑】的判断后执行
|
|
22
|
+
* - 仅在上述判断为【可编辑】时,才会调用本函数
|
|
23
|
+
* - 本函数返回真值时,字段开启编辑,否则改为只读
|
|
24
|
+
*/
|
|
25
|
+
export declare function runDynamicEditable(field: FieldConfigType, readonly: boolean, getCtx: () => DynamicEditableCtxType): boolean;
|
|
26
|
+
export {};
|