@pisell/materials 1.0.1 → 1.0.2
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/.tmp/assets-daily.json +93 -0
- package/.tmp/assets-dev.json +93 -0
- package/.tmp/assets-prod.json +93 -0
- package/.tmp/default.view.js +24 -0
- package/.tmp/index.jsx +279 -0
- package/.tmp/meta.js +251 -0
- package/.tmp/preview.jsx +72 -0
- package/.tmp/view.js +25 -0
- package/CHANGELOG.md +6 -0
- package/build/lowcode/assets-daily.json +93 -0
- package/build/lowcode/assets-dev.json +93 -0
- package/build/lowcode/assets-prod.json +93 -0
- package/build/lowcode/designer.html +303 -0
- package/build/lowcode/index.html +305 -0
- package/build/lowcode/index.js +1 -0
- package/build/lowcode/meta.js +9 -0
- package/build/lowcode/preview.css +1 -0
- package/build/lowcode/preview.html +35 -0
- package/build/lowcode/preview.js +304 -0
- package/build/lowcode/render/default/view.js +22 -0
- package/build/lowcode/view.js +22 -0
- package/build.lowcode.js +46 -0
- package/lowcode/_setters/antd-icon-setter/index.tsx +285 -0
- package/lowcode/_setters/antd-icon-setter/style.less +69 -0
- package/lowcode/_setters/index.tsx +1 -0
- package/lowcode/_utils/hoc.tsx +93 -0
- package/lowcode/_utils/transform-meta.ts +343 -0
- package/lowcode/_utils/utils.ts +6 -0
- package/lowcode/affix/__screenshots__/affix-1.jpg +0 -0
- package/lowcode/affix/meta.ts +68 -0
- package/lowcode/affix/snippets.ts +20 -0
- package/lowcode/alert/__screenshots__/alert-1.png +0 -0
- package/lowcode/alert/__screenshots__/alert-2.png +0 -0
- package/lowcode/alert/__screenshots__/alert-3.png +0 -0
- package/lowcode/alert/__screenshots__/alert-4.png +0 -0
- package/lowcode/alert/meta.ts +102 -0
- package/lowcode/alert/snippets.ts +54 -0
- package/lowcode/anchor/__screenshots__/anchor-1.png +0 -0
- package/lowcode/anchor/snippets.ts +30 -0
- package/lowcode/anchor.link/meta.ts +29 -0
- package/lowcode/anchor.link/snippets.ts +1 -0
- package/lowcode/auto-complete/__screenshots__/auto-complete-1.png +0 -0
- package/lowcode/auto-complete/meta.ts +453 -0
- package/lowcode/auto-complete/snippets.ts +26 -0
- package/lowcode/avatar/__screenshots__/avatar-1.jpg +0 -0
- package/lowcode/avatar/meta.ts +82 -0
- package/lowcode/avatar/snippets.ts +12 -0
- package/lowcode/badge/__screenshots__/badge-1.png +0 -0
- package/lowcode/badge/meta.ts +94 -0
- package/lowcode/badge/snippets.ts +12 -0
- package/lowcode/breadcrumb/__screenshots__/breadcrumb-1.jpg +0 -0
- package/lowcode/breadcrumb/meta.ts +136 -0
- package/lowcode/breadcrumb/snippets.ts +44 -0
- package/lowcode/button/__screenshots__/button-1.png +0 -0
- package/lowcode/button/__screenshots__/button-2.png +0 -0
- package/lowcode/button/__screenshots__/button-3.png +0 -0
- package/lowcode/button/__screenshots__/button-4.png +0 -0
- package/lowcode/button/__screenshots__/button-5.png +0 -0
- package/lowcode/button/__screenshots__/button-6.png +0 -0
- package/lowcode/button/meta.ts +510 -0
- package/lowcode/button/snippets.ts +68 -0
- package/lowcode/calendar/__screenshots__/calendar-1.jpg +0 -0
- package/lowcode/calendar/meta.ts +133 -0
- package/lowcode/calendar/snippets.ts +10 -0
- package/lowcode/card/__screenshots__/card-1.png +0 -0
- package/lowcode/card/meta.ts +97 -0
- package/lowcode/card/snippets.ts +12 -0
- package/lowcode/carousel/__screenshots__/carousel-1.jpg +0 -0
- package/lowcode/carousel/meta.ts +148 -0
- package/lowcode/carousel/snippets.ts +23 -0
- package/lowcode/cascader/__screenshots__/cascader-1.png +0 -0
- package/lowcode/cascader/meta.ts +175 -0
- package/lowcode/cascader/snippets.ts +46 -0
- package/lowcode/checkbox/__screenshots__/checkbox-1.png +0 -0
- package/lowcode/checkbox/meta.ts +85 -0
- package/lowcode/checkbox/snippets.ts +35 -0
- package/lowcode/checkbox.group/__screenshots__/checkbox-group-1.png +0 -0
- package/lowcode/checkbox.group/meta.ts +150 -0
- package/lowcode/collapse/__screenshots__/collapse-1.png +0 -0
- package/lowcode/collapse/meta.ts +221 -0
- package/lowcode/collapse/snippets.ts +28 -0
- package/lowcode/collapse.pane/meta.ts +84 -0
- package/lowcode/config-provider/__screenshots__/config-provider-1.jpg +0 -0
- package/lowcode/config-provider/meta.ts +140 -0
- package/lowcode/config-provider/snippets.ts +10 -0
- package/lowcode/date-picker/__screenshots__/date-picker-1.png +0 -0
- package/lowcode/date-picker/__screenshots__/date-picker-2.png +0 -0
- package/lowcode/date-picker/__screenshots__/date-picker-3.png +0 -0
- package/lowcode/date-picker/__screenshots__/date-picker-4.png +0 -0
- package/lowcode/date-picker/__screenshots__/date-picker-5.png +0 -0
- package/lowcode/date-picker/meta.ts +281 -0
- package/lowcode/date-picker/snippets.ts +50 -0
- package/lowcode/date-picker.range-picker/__screenshots__/date-picker-range-picker-1.png +0 -0
- package/lowcode/date-picker.range-picker/__screenshots__/date-picker-range-picker-2.png +0 -0
- package/lowcode/date-picker.range-picker/__screenshots__/date-picker-range-picker-3.png +0 -0
- package/lowcode/date-picker.range-picker/__screenshots__/date-picker-range-picker-4.png +0 -0
- package/lowcode/date-picker.range-picker/meta.ts +356 -0
- package/lowcode/date-picker.range-picker/snippets.ts +44 -0
- package/lowcode/descriptions/__screenshots__/descriptions-1.jpg +0 -0
- package/lowcode/descriptions/meta.ts +230 -0
- package/lowcode/descriptions/snippets.ts +18 -0
- package/lowcode/descriptions.item/meta.ts +37 -0
- package/lowcode/directory-tree/meta.ts +2747 -0
- package/lowcode/divider/__screenshots__/divider-1.png +0 -0
- package/lowcode/divider/__screenshots__/divider-2.png +0 -0
- package/lowcode/divider/meta.ts +70 -0
- package/lowcode/divider/snippets.ts +27 -0
- package/lowcode/drawer/__screenshots__/drawer-1.png +0 -0
- package/lowcode/drawer/__screenshots__/drawer-2.png +0 -0
- package/lowcode/drawer/meta.ts +420 -0
- package/lowcode/drawer/snippets.ts +40 -0
- package/lowcode/dropdown/__screenshots__/dropdown-1.png +0 -0
- package/lowcode/dropdown/meta.ts +143 -0
- package/lowcode/dropdown/snippets.ts +73 -0
- package/lowcode/empty/__screenshots__/empty-1.png +0 -0
- package/lowcode/empty/meta.ts +40 -0
- package/lowcode/empty/snippets.ts +10 -0
- package/lowcode/form/__screenshots__/form-1.png +0 -0
- package/lowcode/form/meta.ts +380 -0
- package/lowcode/form/snippets.ts +511 -0
- package/lowcode/form.item/__screenshots__/form-item-1.jpg +0 -0
- package/lowcode/form.item/meta.ts +348 -0
- package/lowcode/form.item/snippets.ts +12 -0
- package/lowcode/form.list/meta.ts +42 -0
- package/lowcode/form.list/snippets.ts +11 -0
- package/lowcode/grid.col/meta.ts +116 -0
- package/lowcode/grid.col/snippets.ts +1 -0
- package/lowcode/grid.row/__screenshots__/1-1-1-1.png +0 -0
- package/lowcode/grid.row/__screenshots__/1-1-1.png +0 -0
- package/lowcode/grid.row/__screenshots__/1-1.png +0 -0
- package/lowcode/grid.row/__screenshots__/1-3.png +0 -0
- package/lowcode/grid.row/meta.ts +118 -0
- package/lowcode/grid.row/snippets.ts +108 -0
- package/lowcode/icon/__screenshots__/icon-1.jpg +0 -0
- package/lowcode/icon/meta.ts +74 -0
- package/lowcode/icon/snippets.ts +13 -0
- package/lowcode/image/__screenshots__/image-1.png +0 -0
- package/lowcode/image/meta.ts +53 -0
- package/lowcode/image/snippets.ts +14 -0
- package/lowcode/input/__screenshots__/input-1.png +0 -0
- package/lowcode/input/meta.ts +190 -0
- package/lowcode/input/snippets.ts +12 -0
- package/lowcode/input-number/__screenshots__/input-number-1.png +0 -0
- package/lowcode/input-number/meta.ts +213 -0
- package/lowcode/input-number/snippets.ts +12 -0
- package/lowcode/input.group/__screenshots__/input-group-1.jpg +0 -0
- package/lowcode/input.group/meta.ts +53 -0
- package/lowcode/input.group/snippets.ts +24 -0
- package/lowcode/input.password/__screenshots__/input-password-1.png +0 -0
- package/lowcode/input.password/meta.ts +192 -0
- package/lowcode/input.password/snippets.ts +12 -0
- package/lowcode/input.search/__screenshots__/input-search-1.png +0 -0
- package/lowcode/input.search/meta.ts +206 -0
- package/lowcode/input.search/snippets.ts +12 -0
- package/lowcode/input.text-area/__screenshots__/input-text-area-1.png +0 -0
- package/lowcode/input.text-area/meta.ts +210 -0
- package/lowcode/input.text-area/snippets.ts +16 -0
- package/lowcode/list/__screenshots__/list-1.png +0 -0
- package/lowcode/list/meta.ts +499 -0
- package/lowcode/list/snippets.ts +201 -0
- package/lowcode/list.item/meta.ts +58 -0
- package/lowcode/list.item.meta/meta.ts +49 -0
- package/lowcode/login/meta.ts +56 -0
- package/lowcode/mentions/__screenshots__/mentions-1.png +0 -0
- package/lowcode/mentions/meta.ts +159 -0
- package/lowcode/mentions/snippets.ts +10 -0
- package/lowcode/menu/__screenshots__/menu-1.jpg +0 -0
- package/lowcode/menu/meta.ts +248 -0
- package/lowcode/menu/snippets.ts +22 -0
- package/lowcode/menu/utils.ts +97 -0
- package/lowcode/menu.item/meta.ts +63 -0
- package/lowcode/menu.item/snippets.ts +1 -0
- package/lowcode/menu.item-group/__screenshots__/menu-item-group-1.png +0 -0
- package/lowcode/menu.item-group/meta.ts +110 -0
- package/lowcode/menu.item-group/snippets.ts +1 -0
- package/lowcode/menu.sub-menu/meta.ts +131 -0
- package/lowcode/menu.sub-menu/snippets.ts +1 -0
- package/lowcode/modal/__screenshots__/modal-1.png +0 -0
- package/lowcode/modal/__screenshots__/modal-2.png +0 -0
- package/lowcode/modal/meta.ts +270 -0
- package/lowcode/modal/snippets.ts +33 -0
- package/lowcode/page-header/__screenshots__/page-header-1.jpg +0 -0
- package/lowcode/page-header/meta.ts +157 -0
- package/lowcode/page-header/snippets.ts +13 -0
- package/lowcode/pagination/__screenshots__/pagination-1.jpg +0 -0
- package/lowcode/pagination/meta.ts +231 -0
- package/lowcode/pagination/snippets.ts +14 -0
- package/lowcode/popconfirm/__screenshots__/popconfirm-1.jpg +0 -0
- package/lowcode/popconfirm/meta.ts +121 -0
- package/lowcode/popconfirm/snippets.ts +21 -0
- package/lowcode/popover/__screenshots__/popover-1.jpg +0 -0
- package/lowcode/popover/meta.ts +332 -0
- package/lowcode/popover/snippets.ts +10 -0
- package/lowcode/progress/__screenshots__/progress-1.png +0 -0
- package/lowcode/progress/__screenshots__/progress-2.png +0 -0
- package/lowcode/progress/meta.ts +142 -0
- package/lowcode/progress/snippets.ts +24 -0
- package/lowcode/radio/__screenshots__/radio-1.png +0 -0
- package/lowcode/radio/meta.ts +69 -0
- package/lowcode/radio/snippets.ts +35 -0
- package/lowcode/radio.group/__screenshots__/radio-group-1.png +0 -0
- package/lowcode/radio.group/meta.ts +213 -0
- package/lowcode/rate/__screenshots__/rate-1.png +0 -0
- package/lowcode/rate/meta.ts +132 -0
- package/lowcode/rate/snippets.ts +12 -0
- package/lowcode/result/__screenshots__/result-1.png +0 -0
- package/lowcode/result/meta.ts +53 -0
- package/lowcode/result/snippets.ts +14 -0
- package/lowcode/select/__screenshots__/select-1.png +0 -0
- package/lowcode/select/meta.ts +427 -0
- package/lowcode/select/snippets.ts +28 -0
- package/lowcode/skeleton/__screenshots__/skeleton-1.png +0 -0
- package/lowcode/skeleton/meta.ts +63 -0
- package/lowcode/skeleton/snippets.ts +13 -0
- package/lowcode/slider/__screenshots__/slider-1.png +0 -0
- package/lowcode/slider/meta.ts +218 -0
- package/lowcode/slider/snippets.ts +12 -0
- package/lowcode/slot/meta.ts +61 -0
- package/lowcode/slot/view.tsx +58 -0
- package/lowcode/space/__screenshots__/space-1.png +0 -0
- package/lowcode/space/meta.ts +65 -0
- package/lowcode/space/snippets.ts +24 -0
- package/lowcode/spin/__screenshots__/spin-1.png +0 -0
- package/lowcode/spin/meta.ts +60 -0
- package/lowcode/spin/snippets.ts +13 -0
- package/lowcode/statistic/__screenshots__/statistic-1.png +0 -0
- package/lowcode/statistic/meta.ts +67 -0
- package/lowcode/statistic/snippets.ts +13 -0
- package/lowcode/steps/__screenshots__/steps-1.png +0 -0
- package/lowcode/steps/meta.ts +281 -0
- package/lowcode/steps/snippets.ts +36 -0
- package/lowcode/steps.step/meta.ts +54 -0
- package/lowcode/steps.step/snippets.ts +1 -0
- package/lowcode/switch/__screenshots__/switch-1.png +0 -0
- package/lowcode/switch/meta.ts +122 -0
- package/lowcode/switch/snippets.ts +12 -0
- package/lowcode/table/__screenshots__/table-1.png +0 -0
- package/lowcode/table/meta.ts +847 -0
- package/lowcode/table/snippets.ts +43 -0
- package/lowcode/tabs/__screenshots__/tabs-1.jpg +0 -0
- package/lowcode/tabs/__screenshots__/tabs-2.jpg +0 -0
- package/lowcode/tabs/__screenshots__/tabs-3.jpg +0 -0
- package/lowcode/tabs/meta.ts +415 -0
- package/lowcode/tabs/snippets.ts +86 -0
- package/lowcode/tabs.tab-pane/meta.ts +78 -0
- package/lowcode/tag/__screenshots__/tag-1.png +0 -0
- package/lowcode/tag/meta.ts +69 -0
- package/lowcode/tag/snippets.ts +13 -0
- package/lowcode/time-picker/__screenshots__/time-picker-1.png +0 -0
- package/lowcode/time-picker/meta.ts +224 -0
- package/lowcode/time-picker/snippets.ts +10 -0
- package/lowcode/timeline/__screenshots__/timeline-1.jpg +0 -0
- package/lowcode/timeline/meta.ts +189 -0
- package/lowcode/timeline/snippets.ts +21 -0
- package/lowcode/timeline.item/__screenshots__/timeline-1.jpg +0 -0
- package/lowcode/timeline.item/meta.ts +53 -0
- package/lowcode/timeline.item/snippets.ts +10 -0
- package/lowcode/tooltip/__screenshots__/tooltip-1.jpg +0 -0
- package/lowcode/tooltip/meta.ts +306 -0
- package/lowcode/tooltip/snippets.ts +12 -0
- package/lowcode/transfer/__screenshots__/transfer-1.png +0 -0
- package/lowcode/transfer/meta.ts +304 -0
- package/lowcode/transfer/snippets.ts +42 -0
- package/lowcode/tree/__screenshots__/tree-1.jpg +0 -0
- package/lowcode/tree/meta.ts +377 -0
- package/lowcode/tree/snippets.ts +30 -0
- package/lowcode/tree-select/__screenshots__/tree-select-1.png +0 -0
- package/lowcode/tree-select/meta.ts +314 -0
- package/lowcode/tree-select/snippets.ts +34 -0
- package/lowcode/typography.link/__screenshots__/typography-link-1.png +0 -0
- package/lowcode/typography.link/meta.ts +44 -0
- package/lowcode/typography.link/snippets.ts +14 -0
- package/lowcode/typography.paragraph/__screenshots__/typography-paragraph-1.png +0 -0
- package/lowcode/typography.paragraph/meta.ts +129 -0
- package/lowcode/typography.paragraph/snippets.ts +14 -0
- package/lowcode/typography.text/__screenshots__/typography-text-1.png +0 -0
- package/lowcode/typography.text/__screenshots__/typography-text-2.png +0 -0
- package/lowcode/typography.text/__screenshots__/typography-text-3.png +0 -0
- package/lowcode/typography.text/meta.ts +200 -0
- package/lowcode/typography.text/snippets.ts +34 -0
- package/lowcode/typography.title/__screenshots__/typography-title-1.png +0 -0
- package/lowcode/typography.title/__screenshots__/typography-title-2.png +0 -0
- package/lowcode/typography.title/__screenshots__/typography-title-3.png +0 -0
- package/lowcode/typography.title/__screenshots__/typography-title-4.png +0 -0
- package/lowcode/typography.title/meta.ts +130 -0
- package/lowcode/typography.title/snippets.ts +46 -0
- package/lowcode/upload/__screenshots__/upload-1.png +0 -0
- package/lowcode/upload/meta.ts +439 -0
- package/lowcode/upload/snippets.ts +16 -0
- package/package.json +29 -3
- package/src/components/auto-complete/index.tsx +6 -0
- package/src/components/button/index.tsx +12 -0
- package/src/components/calendar/index.tsx +10 -0
- package/src/components/cascader/index.tsx +6 -0
- package/src/components/checkbox/index.tsx +7 -0
- package/src/components/config-provider/index.tsx +27 -0
- package/src/components/date-picker/index.tsx +22 -0
- package/src/components/drawer/index.tsx +13 -0
- package/src/components/dropdown/index.tsx +13 -0
- package/src/components/form/index.tsx +97 -0
- package/src/components/icon/index.tsx +34 -0
- package/src/components/input/index.tsx +18 -0
- package/src/components/modal/index.tsx +18 -0
- package/src/components/radio/index.tsx +7 -0
- package/src/components/select/index.tsx +6 -0
- package/src/components/skeleton/index.tsx +6 -0
- package/src/components/slider/index.tsx +18 -0
- package/src/components/table/index.tsx +10 -0
- package/src/components/tabs/index.tsx +67 -0
- package/src/components/time-picker/index.tsx +9 -0
- package/src/components/tree-select/index.tsx +8 -0
- package/src/components/upload/index.tsx +5 -0
- package/src/index.tsx +141 -0
- package/src/utils/hoc.tsx +92 -0
- package/src/utils/warning.ts +3 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import React, { Component, createRef } from 'react';
|
|
2
|
+
import { Form as OriginalForm } from 'antd';
|
|
3
|
+
|
|
4
|
+
import { withSingleFunctionChild } from '../../utils/hoc';
|
|
5
|
+
|
|
6
|
+
class Form extends Component<any, any> {
|
|
7
|
+
formRef = createRef<any>();
|
|
8
|
+
|
|
9
|
+
componentDidUpdate(prevProps: any) {
|
|
10
|
+
const { values: prevValues } = prevProps;
|
|
11
|
+
const { values: currentValues } = this.props;
|
|
12
|
+
|
|
13
|
+
if (prevValues !== currentValues) {
|
|
14
|
+
if (currentValues && Object.keys(currentValues).length > 0) {
|
|
15
|
+
this.formRef.current!.setFieldsValue(currentValues);
|
|
16
|
+
} else {
|
|
17
|
+
this.formRef.current!.resetFields();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
componentDidMount() {
|
|
23
|
+
const { values } = this.props;
|
|
24
|
+
|
|
25
|
+
Object.defineProperties(
|
|
26
|
+
this,
|
|
27
|
+
Object.keys(this.formRef.current).reduce((out, key) => {
|
|
28
|
+
const property = this.formRef.current[key];
|
|
29
|
+
let getter = () => property;
|
|
30
|
+
if (typeof property === 'function') {
|
|
31
|
+
getter = () => property.bind(this.formRef.current);
|
|
32
|
+
}
|
|
33
|
+
out[key] = { get: getter };
|
|
34
|
+
return out;
|
|
35
|
+
}, {} as Record<string, any>),
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
// 绑定表达式的时候,初次不生效,需要第一次调用一下 setFieldsValue
|
|
39
|
+
if (values) {
|
|
40
|
+
this.formRef.current!.setFieldsValue(values);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
render() {
|
|
45
|
+
const { values, ...rest } = this.props;
|
|
46
|
+
|
|
47
|
+
return <OriginalForm ref={this.formRef} {...rest} />;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
(Form as any).Item = (props: any) => {
|
|
52
|
+
const { name, requiredobj, typeobj, patternobj, lenobj, validator } = props;
|
|
53
|
+
|
|
54
|
+
const rules = [];
|
|
55
|
+
if (requiredobj && requiredobj.required) {
|
|
56
|
+
rules.push(requiredobj);
|
|
57
|
+
}
|
|
58
|
+
if (typeobj && typeobj.type) {
|
|
59
|
+
rules.push(typeobj);
|
|
60
|
+
}
|
|
61
|
+
if (patternobj && patternobj.pattern) {
|
|
62
|
+
rules.push(patternobj);
|
|
63
|
+
}
|
|
64
|
+
if (lenobj && (lenobj.max || lenobj.min)) {
|
|
65
|
+
rules.push(lenobj);
|
|
66
|
+
}
|
|
67
|
+
if (validator && typeof validator === 'function') {
|
|
68
|
+
rules.push({
|
|
69
|
+
validator: (_: any, value: any) => validator(value),
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const namePath =
|
|
74
|
+
typeof name === 'string' && name.indexOf('.') > 0 ? name.split('.') : name;
|
|
75
|
+
|
|
76
|
+
// https://ant.design/components/form-cn/#components-form-demo-complex-form-control
|
|
77
|
+
// <Form.Item name="field" /> 只会对它的直接子元素绑定表单功能
|
|
78
|
+
const { children, ...other } = props
|
|
79
|
+
let node = children
|
|
80
|
+
if (Array.isArray(children) && children.length === 1) { // 如果 children.length > 1, 说明 Form.Item 只充当布局的作用
|
|
81
|
+
node = children[0]
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return (
|
|
85
|
+
<OriginalForm.Item
|
|
86
|
+
{...other}
|
|
87
|
+
name={namePath}
|
|
88
|
+
rules={rules}
|
|
89
|
+
>
|
|
90
|
+
{ node }
|
|
91
|
+
</OriginalForm.Item>
|
|
92
|
+
);
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
(Form as any).List = withSingleFunctionChild(OriginalForm.List);
|
|
96
|
+
|
|
97
|
+
export default Form;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React, { forwardRef, Ref } from 'react';
|
|
2
|
+
import * as icons from '@ant-design/icons';
|
|
3
|
+
|
|
4
|
+
const createFromIconfontCN = icons.createFromIconfontCN;
|
|
5
|
+
interface IconProps {
|
|
6
|
+
type: string;
|
|
7
|
+
className?: string;
|
|
8
|
+
size?: number;
|
|
9
|
+
color?: string;
|
|
10
|
+
rotate?: number;
|
|
11
|
+
spin?: boolean;
|
|
12
|
+
style?: React.CSSProperties;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const Icon = (props: IconProps, ref: Ref<any>) => {
|
|
16
|
+
const { type = '', size, color, ...rest } = props;
|
|
17
|
+
|
|
18
|
+
const IconComp = ((icons || {}) as any)[type];
|
|
19
|
+
|
|
20
|
+
const style = {
|
|
21
|
+
...rest.style,
|
|
22
|
+
fontSize: size,
|
|
23
|
+
color,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
if (!IconComp) {
|
|
27
|
+
const IconFont = createFromIconfontCN();
|
|
28
|
+
return <IconFont type={type} {...rest} style={style} ref={ref} />;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return <IconComp {...rest} style={style} twoToneColor={color} ref={ref} />;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export default forwardRef(Icon);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Input as OriginalInput } from 'antd';
|
|
2
|
+
import { withWrap } from '../../utils/hoc';
|
|
3
|
+
|
|
4
|
+
const {
|
|
5
|
+
Group: OriginalGroup,
|
|
6
|
+
TextArea: OriginalTextArea,
|
|
7
|
+
Password: OriginalPassword,
|
|
8
|
+
Search: OriginalSearch,
|
|
9
|
+
} = OriginalInput;
|
|
10
|
+
|
|
11
|
+
const Input = withWrap(OriginalInput);
|
|
12
|
+
|
|
13
|
+
(Input as any).Group = OriginalGroup;
|
|
14
|
+
(Input as any).TextArea = withWrap(OriginalTextArea);
|
|
15
|
+
(Input as any).Password = withWrap(OriginalPassword);
|
|
16
|
+
(Input as any).Search = withWrap(OriginalSearch);
|
|
17
|
+
|
|
18
|
+
export default Input;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Modal as OriginalModal } from 'antd';
|
|
3
|
+
|
|
4
|
+
const Modal: any = (props: any) => {
|
|
5
|
+
const innerProps: any = {};
|
|
6
|
+
if (props.__designMode === 'design') {
|
|
7
|
+
// 低代码编辑态中强制显示,将控制权交给引擎侧
|
|
8
|
+
innerProps.open = true;
|
|
9
|
+
}
|
|
10
|
+
return <OriginalModal {...props} {...innerProps} />;
|
|
11
|
+
};
|
|
12
|
+
Modal.info = OriginalModal.info;
|
|
13
|
+
Modal.success = OriginalModal.success;
|
|
14
|
+
Modal.error = OriginalModal.error;
|
|
15
|
+
Modal.warning = OriginalModal.warning;
|
|
16
|
+
Modal.warn = OriginalModal.warn;
|
|
17
|
+
Modal.confirm = OriginalModal.confirm;
|
|
18
|
+
export default Modal;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Slider } from 'antd';
|
|
3
|
+
const SliderOuter = (props: any) => {
|
|
4
|
+
const { range } = props;
|
|
5
|
+
let { defaultValue } = props;
|
|
6
|
+
if (range) {
|
|
7
|
+
defaultValue = Array.isArray(defaultValue)
|
|
8
|
+
? defaultValue
|
|
9
|
+
: [0, defaultValue];
|
|
10
|
+
} else {
|
|
11
|
+
defaultValue = Array.isArray(defaultValue)
|
|
12
|
+
? defaultValue[1] || defaultValue[0]
|
|
13
|
+
: defaultValue;
|
|
14
|
+
}
|
|
15
|
+
return <Slider {...props} defaultValue={defaultValue}></Slider>;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default SliderOuter;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Table as OriginalTable } from 'antd';
|
|
3
|
+
|
|
4
|
+
const Table = (props: any) => {
|
|
5
|
+
const columns = (props.columns || []).filter((item: any) => !item?.hidden);
|
|
6
|
+
|
|
7
|
+
return <OriginalTable {...props} columns={columns} />;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export default Table;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import { TabPaneProps, Tabs as OriginalTabs } from 'antd';
|
|
3
|
+
import { warning } from '../../utils/warning'
|
|
4
|
+
import type { Tab } from 'rc-tabs/lib/interface';
|
|
5
|
+
|
|
6
|
+
class Tabs extends Component<any> {
|
|
7
|
+
state = {
|
|
8
|
+
activeKey: this.props.activeKey ?? this.props.defaultActiveKey,
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
private _handleChange = (key: string) => {
|
|
12
|
+
this.setActiveKey(key);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
// 编辑器里可以通过 this.$(refId).setActiveKey(key) 调用
|
|
16
|
+
setActiveKey = (key: string) => {
|
|
17
|
+
const { onChange = () => {} } = this.props;
|
|
18
|
+
this.setState({ activeKey: key });
|
|
19
|
+
onChange(key);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
// 编辑器里可以通过 this.$(refId).getActiveKey() 调用
|
|
23
|
+
getActiveKey = () => {
|
|
24
|
+
return this.state.activeKey;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
render() {
|
|
28
|
+
const { props } = this;
|
|
29
|
+
const { activeKey } = this.state;
|
|
30
|
+
|
|
31
|
+
const { children } = props
|
|
32
|
+
|
|
33
|
+
let items = props.items
|
|
34
|
+
|
|
35
|
+
// props.items 存在,只认 props.items
|
|
36
|
+
// 兼容代码:props.childrens 反推 props.items
|
|
37
|
+
if (!props.items && Array.isArray(children) && children.length > 0) {
|
|
38
|
+
warning('Tabs.TabPane is deprecated. Please use `items` directly.')
|
|
39
|
+
items = children.map((node: React.ReactElement<TabPaneProps>) => {
|
|
40
|
+
if (React.isValidElement(node)) {
|
|
41
|
+
const { key, props } = node;
|
|
42
|
+
const { tab, ...restProps } = props || {};
|
|
43
|
+
const item: Tab = {
|
|
44
|
+
key: String(key),
|
|
45
|
+
...restProps,
|
|
46
|
+
label: tab,
|
|
47
|
+
};
|
|
48
|
+
return item;
|
|
49
|
+
}
|
|
50
|
+
return null
|
|
51
|
+
}).filter(Boolean)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<OriginalTabs
|
|
56
|
+
{...props}
|
|
57
|
+
items={items}
|
|
58
|
+
activeKey={activeKey}
|
|
59
|
+
onChange={this._handleChange}
|
|
60
|
+
/>
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
(Tabs as any).TabPane = OriginalTabs.TabPane;
|
|
66
|
+
|
|
67
|
+
export default Tabs;
|
package/src/index.tsx
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
export { Affix } from 'antd';
|
|
2
|
+
|
|
3
|
+
export { Anchor } from 'antd';
|
|
4
|
+
|
|
5
|
+
export { Alert } from 'antd';
|
|
6
|
+
|
|
7
|
+
export { Avatar } from 'antd';
|
|
8
|
+
|
|
9
|
+
export { Badge } from 'antd';
|
|
10
|
+
|
|
11
|
+
export { Breadcrumb } from 'antd';
|
|
12
|
+
|
|
13
|
+
export { Card } from 'antd';
|
|
14
|
+
|
|
15
|
+
export { Collapse } from 'antd';
|
|
16
|
+
|
|
17
|
+
export { Carousel } from 'antd';
|
|
18
|
+
|
|
19
|
+
// export { Cascader } from 'antd';
|
|
20
|
+
|
|
21
|
+
// export { Checkbox } from 'antd';
|
|
22
|
+
|
|
23
|
+
export { Col } from 'antd';
|
|
24
|
+
|
|
25
|
+
export { Descriptions } from 'antd';
|
|
26
|
+
|
|
27
|
+
export { Divider } from 'antd';
|
|
28
|
+
|
|
29
|
+
// export { Drawer } from 'antd';
|
|
30
|
+
|
|
31
|
+
export { Empty } from 'antd';
|
|
32
|
+
|
|
33
|
+
export { Grid } from 'antd';
|
|
34
|
+
|
|
35
|
+
// export { Input } from 'antd';
|
|
36
|
+
|
|
37
|
+
export { Image } from 'antd';
|
|
38
|
+
|
|
39
|
+
export { InputNumber } from 'antd';
|
|
40
|
+
|
|
41
|
+
export { List } from 'antd';
|
|
42
|
+
|
|
43
|
+
export { message } from 'antd';
|
|
44
|
+
|
|
45
|
+
export { Menu } from 'antd';
|
|
46
|
+
|
|
47
|
+
export { Mentions } from 'antd';
|
|
48
|
+
|
|
49
|
+
export { Statistic } from 'antd';
|
|
50
|
+
|
|
51
|
+
export { notification } from 'antd';
|
|
52
|
+
|
|
53
|
+
export { PageHeader } from 'antd';
|
|
54
|
+
|
|
55
|
+
export { Pagination } from 'antd';
|
|
56
|
+
|
|
57
|
+
export { Popconfirm } from 'antd';
|
|
58
|
+
|
|
59
|
+
export { Popover } from 'antd';
|
|
60
|
+
|
|
61
|
+
export { Progress } from 'antd';
|
|
62
|
+
|
|
63
|
+
// export { Radio } from 'antd';
|
|
64
|
+
|
|
65
|
+
export { Rate } from 'antd';
|
|
66
|
+
|
|
67
|
+
export { Result } from 'antd';
|
|
68
|
+
|
|
69
|
+
export { Row } from 'antd';
|
|
70
|
+
|
|
71
|
+
// export { Skeleton } from 'antd';
|
|
72
|
+
|
|
73
|
+
export { Space } from 'antd';
|
|
74
|
+
|
|
75
|
+
export { Spin } from 'antd';
|
|
76
|
+
|
|
77
|
+
export { Steps } from 'antd';
|
|
78
|
+
|
|
79
|
+
export { Switch } from 'antd';
|
|
80
|
+
|
|
81
|
+
export { Transfer } from 'antd';
|
|
82
|
+
|
|
83
|
+
export { Tree } from 'antd';
|
|
84
|
+
|
|
85
|
+
// export { TreeSelect } from 'antd';
|
|
86
|
+
|
|
87
|
+
// export { Tabs } from 'antd';
|
|
88
|
+
|
|
89
|
+
export { Tag } from 'antd';
|
|
90
|
+
|
|
91
|
+
export { Timeline } from 'antd';
|
|
92
|
+
|
|
93
|
+
export { Tooltip } from 'antd';
|
|
94
|
+
|
|
95
|
+
export { Typography } from 'antd';
|
|
96
|
+
|
|
97
|
+
export { version } from 'antd';
|
|
98
|
+
|
|
99
|
+
export { default as Skeleton } from './components/skeleton';
|
|
100
|
+
|
|
101
|
+
export { default as Checkbox } from './components/checkbox';
|
|
102
|
+
|
|
103
|
+
export { default as Button } from './components/button';
|
|
104
|
+
|
|
105
|
+
export { default as Radio } from './components/radio';
|
|
106
|
+
|
|
107
|
+
export { default as Upload } from './components/upload';
|
|
108
|
+
|
|
109
|
+
export { default as Icon } from './components/icon';
|
|
110
|
+
|
|
111
|
+
export { default as Form } from './components/form';
|
|
112
|
+
|
|
113
|
+
export { default as Dropdown } from './components/dropdown';
|
|
114
|
+
|
|
115
|
+
export { default as Calendar } from './components/calendar';
|
|
116
|
+
|
|
117
|
+
export { default as ConfigProvider } from './components/config-provider';
|
|
118
|
+
|
|
119
|
+
export { default as DatePicker } from './components/date-picker';
|
|
120
|
+
|
|
121
|
+
export { default as Tabs } from './components/tabs';
|
|
122
|
+
|
|
123
|
+
export { default as TimePicker } from './components/time-picker';
|
|
124
|
+
|
|
125
|
+
export { default as Slider } from './components/slider';
|
|
126
|
+
|
|
127
|
+
export { default as Table } from './components/table';
|
|
128
|
+
|
|
129
|
+
export { default as Modal } from './components/modal';
|
|
130
|
+
|
|
131
|
+
export { default as Drawer } from './components/drawer';
|
|
132
|
+
|
|
133
|
+
export { default as TreeSelect } from './components/tree-select';
|
|
134
|
+
|
|
135
|
+
export { default as Input } from './components/input';
|
|
136
|
+
|
|
137
|
+
export { default as Select } from './components/select'
|
|
138
|
+
|
|
139
|
+
export { default as Cascader } from './components/cascader';
|
|
140
|
+
|
|
141
|
+
export { default as AutoComplete } from './components/auto-complete';
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import React, { ComponentType, forwardRef, Ref } from 'react';
|
|
2
|
+
import { get, set, has } from 'lodash';
|
|
3
|
+
|
|
4
|
+
function convertProps(
|
|
5
|
+
props: Record<string, any>,
|
|
6
|
+
list: string[],
|
|
7
|
+
mapper: (v: any, key: string) => any,
|
|
8
|
+
) {
|
|
9
|
+
const out: Record<string, any> = {};
|
|
10
|
+
list.forEach(key => {
|
|
11
|
+
if (has(props, key)) {
|
|
12
|
+
set(out, key, mapper(get(props, key), key));
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
return out;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* 简单包装,不做任何处理
|
|
20
|
+
* 部分组件ref比较特殊,包一层会解决这个问题
|
|
21
|
+
*/
|
|
22
|
+
export function withWrap(Comp: ComponentType<any>) {
|
|
23
|
+
return forwardRef((props: any, ref: Ref<any>) => {
|
|
24
|
+
return <Comp {...props} ref={ref} />;
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* 某些组件会用React.Children.only检查子节点
|
|
30
|
+
* 需要做处理避免报错
|
|
31
|
+
*/
|
|
32
|
+
export function withSingleChild(
|
|
33
|
+
Comp: ComponentType<any>,
|
|
34
|
+
needsConvert = ['children'],
|
|
35
|
+
) {
|
|
36
|
+
return (props: any) => {
|
|
37
|
+
const convertedProps = convertProps(props, needsConvert, prop => {
|
|
38
|
+
let node = React.Children.toArray(prop)[0];
|
|
39
|
+
if (node === null || typeof node !== 'object') {
|
|
40
|
+
node = <div>{node}</div>;
|
|
41
|
+
}
|
|
42
|
+
return node;
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
return <Comp {...(props as any)} {...(convertedProps as any)} />;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function withSingleFunctionChild(Comp: ComponentType<any>) {
|
|
50
|
+
return (props: any) => {
|
|
51
|
+
const { children } = props;
|
|
52
|
+
|
|
53
|
+
let node;
|
|
54
|
+
if (typeof children === 'function') {
|
|
55
|
+
node = children;
|
|
56
|
+
}
|
|
57
|
+
if (
|
|
58
|
+
Array.isArray(children) &&
|
|
59
|
+
children.length === 1 &&
|
|
60
|
+
typeof children[0] === 'function'
|
|
61
|
+
) {
|
|
62
|
+
node = children[0];
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (node) {
|
|
66
|
+
return <Comp {...(props as any)}>{node}</Comp>;
|
|
67
|
+
}
|
|
68
|
+
return <div>{children}</div>;
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* moment对象在序列化后会被转为字符串
|
|
74
|
+
* 需要让日期类组件支持接受字符串值
|
|
75
|
+
*/
|
|
76
|
+
export function withMomentProps(
|
|
77
|
+
Comp: ComponentType<any>,
|
|
78
|
+
needsConvert = ['value', 'defaultValue'],
|
|
79
|
+
) {
|
|
80
|
+
return (props: any) => {
|
|
81
|
+
const convertedProps = convertProps(props, needsConvert, prop => {
|
|
82
|
+
if (prop) {
|
|
83
|
+
if (Array.isArray(prop)) {
|
|
84
|
+
return prop.map(v => (moment.isMoment(v) ? v : moment(v)));
|
|
85
|
+
}
|
|
86
|
+
return moment.isMoment(prop) ? prop : moment(prop);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
return <Comp {...(props as any)} {...(convertedProps as any)} />;
|
|
91
|
+
};
|
|
92
|
+
}
|