@dckj-npm/dc-material 0.1.359 → 0.1.361
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/build/docs/colorful-button.html +3 -3
- package/build/docs/colorful-input.html +3 -3
- package/build/docs/index.html +3 -3
- package/build/docs/{umi.d22560a0.css → umi.a2a18b22.css} +1 -1
- package/build/docs/umi.e8fefa28.js +1 -0
- package/build/docs/~demos/colorful-button-demo.html +3 -3
- package/build/docs/~demos/colorful-input-demo.html +3 -3
- package/build/lowcode/assets-daily.json +13 -13
- package/build/lowcode/assets-dev.json +2 -2
- package/build/lowcode/assets-prod.json +13 -13
- package/build/lowcode/index.js +1 -1
- package/build/lowcode/meta.design.js +1 -1
- package/build/lowcode/meta.js +1 -1
- package/build/lowcode/preview.js +6 -6
- package/build/lowcode/render/default/view.css +1 -1
- package/build/lowcode/render/default/view.js +5 -5
- package/build/lowcode/view.css +1 -1
- package/build/lowcode/view.js +5 -5
- package/dist/BizComps.css +1 -1
- package/dist/BizComps.js +2 -2
- package/dist/BizComps.js.map +1 -1
- package/es/components/custom-form/custom-form.d.ts +37 -0
- package/es/components/custom-form/custom-form.js +158 -0
- package/es/components/custom-form/index.d.ts +6 -0
- package/es/components/custom-form/index.js +6 -0
- package/es/components/custom-form/index.scss +25 -0
- package/es/components/teletext-list/schema.json +1278 -0
- package/es/components/teletext-list/teletext-list-item.js +13 -9
- package/es/components/teletext-list/teletext-list-item.scss +16 -0
- package/es/components/teletext-list/teletext-list.js +2 -1
- package/es/index.d.ts +2 -0
- package/es/index.js +4 -0
- package/es/style.js +8 -0
- package/es/utils/children-node-handle.js +5 -0
- package/lib/components/custom-form/custom-form.d.ts +37 -0
- package/lib/components/custom-form/custom-form.js +164 -0
- package/lib/components/custom-form/index.d.ts +6 -0
- package/lib/components/custom-form/index.js +6 -0
- package/lib/components/custom-form/index.scss +25 -0
- package/lib/components/teletext-list/schema.json +1278 -0
- package/lib/components/teletext-list/teletext-list-item.js +13 -9
- package/lib/components/teletext-list/teletext-list-item.scss +16 -0
- package/lib/components/teletext-list/teletext-list.js +2 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.js +6 -1
- package/lib/style.js +8 -0
- package/lib/utils/children-node-handle.js +5 -0
- package/lowcode/custom-form/meta.ts +307 -0
- package/lowcode_es/custom-form/meta.d.ts +22 -0
- package/lowcode_es/custom-form/meta.js +302 -0
- package/lowcode_es/meta.js +3 -2
- package/lowcode_lib/custom-form/meta.d.ts +22 -0
- package/lowcode_lib/custom-form/meta.js +307 -0
- package/lowcode_lib/meta.js +41 -40
- package/package.json +3 -3
- package/build/docs/umi.d7be81d3.js +0 -1
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './index.scss';
|
|
3
|
+
import { FormProps } from '@alifd/next/lib/form';
|
|
4
|
+
export type CustomFormItemType = 'Input' | 'TextArea' | 'Select' | 'RadioGroup' | 'CheckboxGroup' | 'NumberPicker' | 'DatePicker' | 'Upload';
|
|
5
|
+
export interface CustomFormItemSchema {
|
|
6
|
+
field: string;
|
|
7
|
+
label?: string;
|
|
8
|
+
required?: boolean;
|
|
9
|
+
componentType?: CustomFormItemType;
|
|
10
|
+
componentProps?: Record<string, any>;
|
|
11
|
+
options?: Array<{
|
|
12
|
+
label: string;
|
|
13
|
+
value: any;
|
|
14
|
+
}>;
|
|
15
|
+
columnSpan?: number;
|
|
16
|
+
formItemProps?: Record<string, any>;
|
|
17
|
+
}
|
|
18
|
+
type GridSpacing = [number] | [number, number] | [number, number, number] | [number, number, number, number];
|
|
19
|
+
export interface CustomFormProps extends Omit<FormProps, 'onSubmit'> {
|
|
20
|
+
columns?: number;
|
|
21
|
+
spacing?: GridSpacing;
|
|
22
|
+
emptyContent?: React.ReactNode;
|
|
23
|
+
formItems?: CustomFormItemSchema[];
|
|
24
|
+
showSubmit?: boolean;
|
|
25
|
+
submitText?: string;
|
|
26
|
+
submitValidate?: boolean;
|
|
27
|
+
submitDataSource?: any;
|
|
28
|
+
submitButtonProps?: Record<string, any>;
|
|
29
|
+
showReset?: boolean;
|
|
30
|
+
resetText?: string;
|
|
31
|
+
resetButtonProps?: Record<string, any>;
|
|
32
|
+
onSubmit?: (values: any, errors: any, field: any) => void;
|
|
33
|
+
onSubmitFailed?: (values: any, errors: any, field: any) => void;
|
|
34
|
+
children?: React.ReactNode;
|
|
35
|
+
}
|
|
36
|
+
declare const CustomForm: React.FC<CustomFormProps>;
|
|
37
|
+
export default CustomForm;
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
|
|
2
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
3
|
+
import _Upload from "@alifd/next/es/upload";
|
|
4
|
+
import _NumberPicker from "@alifd/next/es/number-picker";
|
|
5
|
+
import _DatePicker from "@alifd/next/es/date-picker";
|
|
6
|
+
import _Checkbox from "@alifd/next/es/checkbox";
|
|
7
|
+
import _Radio from "@alifd/next/es/radio";
|
|
8
|
+
import _Select from "@alifd/next/es/select";
|
|
9
|
+
import _Input from "@alifd/next/es/input";
|
|
10
|
+
import _ResponsiveGrid from "@alifd/next/es/responsive-grid";
|
|
11
|
+
import _Form from "@alifd/next/es/form";
|
|
12
|
+
var _excluded = ["columns", "spacing", "emptyContent", "formItems", "showSubmit", "submitText", "submitValidate", "submitDataSource", "submitButtonProps", "showReset", "resetText", "resetButtonProps", "onSubmit", "onSubmitFailed", "children"];
|
|
13
|
+
import React, { useCallback } from 'react';
|
|
14
|
+
import "./index.scss";
|
|
15
|
+
var NextFormAny = _Form;
|
|
16
|
+
var ResponsiveGridAny = _ResponsiveGrid;
|
|
17
|
+
var ResponsiveGridCell = _ResponsiveGrid.Cell;
|
|
18
|
+
var FormItemAny = _Form.Item;
|
|
19
|
+
var InputAny = _Input;
|
|
20
|
+
var TextAreaAny = _Input.TextArea;
|
|
21
|
+
var SelectAny = _Select;
|
|
22
|
+
var RadioGroupAny = _Radio.Group;
|
|
23
|
+
var CheckboxGroupAny = _Checkbox.Group;
|
|
24
|
+
var DatePickerAny = _DatePicker;
|
|
25
|
+
var NumberPickerAny = _NumberPicker;
|
|
26
|
+
var UploadAny = _Upload;
|
|
27
|
+
var runSubmitDataSource = function runSubmitDataSource(submitDataSource, values, errors, field) {
|
|
28
|
+
if (!submitDataSource) return;
|
|
29
|
+
if (typeof submitDataSource === 'function') {
|
|
30
|
+
submitDataSource(values, errors, field);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (typeof (submitDataSource === null || submitDataSource === void 0 ? void 0 : submitDataSource.run) === 'function') {
|
|
34
|
+
submitDataSource.run(values, errors, field);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
if (typeof (submitDataSource === null || submitDataSource === void 0 ? void 0 : submitDataSource.execute) === 'function') {
|
|
38
|
+
submitDataSource.execute(values, errors, field);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (typeof (submitDataSource === null || submitDataSource === void 0 ? void 0 : submitDataSource.request) === 'function') {
|
|
42
|
+
submitDataSource.request(values, errors, field);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if (typeof (submitDataSource === null || submitDataSource === void 0 ? void 0 : submitDataSource.submit) === 'function') {
|
|
46
|
+
submitDataSource.submit(values, errors, field);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var renderFormItemComponent = function renderFormItemComponent(item) {
|
|
50
|
+
var componentProps = item.componentProps || {};
|
|
51
|
+
var dataSource = componentProps.dataSource || item.options || [];
|
|
52
|
+
switch (item.componentType) {
|
|
53
|
+
case 'TextArea':
|
|
54
|
+
return /*#__PURE__*/React.createElement(TextAreaAny, componentProps);
|
|
55
|
+
case 'Select':
|
|
56
|
+
return /*#__PURE__*/React.createElement(SelectAny, _extends({
|
|
57
|
+
dataSource: dataSource
|
|
58
|
+
}, componentProps));
|
|
59
|
+
case 'RadioGroup':
|
|
60
|
+
return /*#__PURE__*/React.createElement(RadioGroupAny, _extends({
|
|
61
|
+
dataSource: dataSource
|
|
62
|
+
}, componentProps));
|
|
63
|
+
case 'CheckboxGroup':
|
|
64
|
+
return /*#__PURE__*/React.createElement(CheckboxGroupAny, _extends({
|
|
65
|
+
dataSource: dataSource
|
|
66
|
+
}, componentProps));
|
|
67
|
+
case 'NumberPicker':
|
|
68
|
+
return /*#__PURE__*/React.createElement(NumberPickerAny, componentProps);
|
|
69
|
+
case 'DatePicker':
|
|
70
|
+
return /*#__PURE__*/React.createElement(DatePickerAny, componentProps);
|
|
71
|
+
case 'Upload':
|
|
72
|
+
return /*#__PURE__*/React.createElement(UploadAny, componentProps);
|
|
73
|
+
case 'Input':
|
|
74
|
+
default:
|
|
75
|
+
return /*#__PURE__*/React.createElement(InputAny, componentProps);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
var CustomForm = function CustomForm(_ref) {
|
|
79
|
+
var _ref$columns = _ref.columns,
|
|
80
|
+
columns = _ref$columns === void 0 ? 1 : _ref$columns,
|
|
81
|
+
_ref$spacing = _ref.spacing,
|
|
82
|
+
spacing = _ref$spacing === void 0 ? [0, 16, 16, 0] : _ref$spacing,
|
|
83
|
+
_ref$emptyContent = _ref.emptyContent,
|
|
84
|
+
emptyContent = _ref$emptyContent === void 0 ? '添加表单项' : _ref$emptyContent,
|
|
85
|
+
_ref$formItems = _ref.formItems,
|
|
86
|
+
formItems = _ref$formItems === void 0 ? [] : _ref$formItems,
|
|
87
|
+
_ref$showSubmit = _ref.showSubmit,
|
|
88
|
+
showSubmit = _ref$showSubmit === void 0 ? true : _ref$showSubmit,
|
|
89
|
+
_ref$submitText = _ref.submitText,
|
|
90
|
+
submitText = _ref$submitText === void 0 ? '提交' : _ref$submitText,
|
|
91
|
+
_ref$submitValidate = _ref.submitValidate,
|
|
92
|
+
submitValidate = _ref$submitValidate === void 0 ? true : _ref$submitValidate,
|
|
93
|
+
submitDataSource = _ref.submitDataSource,
|
|
94
|
+
submitButtonProps = _ref.submitButtonProps,
|
|
95
|
+
_ref$showReset = _ref.showReset,
|
|
96
|
+
showReset = _ref$showReset === void 0 ? false : _ref$showReset,
|
|
97
|
+
_ref$resetText = _ref.resetText,
|
|
98
|
+
resetText = _ref$resetText === void 0 ? '重置' : _ref$resetText,
|
|
99
|
+
resetButtonProps = _ref.resetButtonProps,
|
|
100
|
+
onSubmit = _ref.onSubmit,
|
|
101
|
+
onSubmitFailed = _ref.onSubmitFailed,
|
|
102
|
+
children = _ref.children,
|
|
103
|
+
otherProps = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
104
|
+
var handleSubmit = useCallback(function (values, errors, field) {
|
|
105
|
+
if (errors && Object.keys(errors).length) {
|
|
106
|
+
if (onSubmitFailed) {
|
|
107
|
+
onSubmitFailed(values, errors, field);
|
|
108
|
+
}
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
if (onSubmit) {
|
|
112
|
+
onSubmit(values, errors, field);
|
|
113
|
+
}
|
|
114
|
+
runSubmitDataSource(submitDataSource, values, errors, field);
|
|
115
|
+
}, [onSubmit, onSubmitFailed, submitDataSource]);
|
|
116
|
+
var formItemNodes = formItems.map(function (item, index) {
|
|
117
|
+
var colSpan = Math.min(columns, Math.max(1, item.columnSpan || 1));
|
|
118
|
+
var formItemProps = item.formItemProps || {};
|
|
119
|
+
return /*#__PURE__*/React.createElement(ResponsiveGridCell, {
|
|
120
|
+
colSpan: colSpan,
|
|
121
|
+
key: (item.field || index) + "-form-item"
|
|
122
|
+
}, /*#__PURE__*/React.createElement(FormItemAny, _extends({
|
|
123
|
+
label: item.label,
|
|
124
|
+
name: item.field,
|
|
125
|
+
required: item.required
|
|
126
|
+
}, formItemProps), renderFormItemComponent(item)));
|
|
127
|
+
});
|
|
128
|
+
var childrenNodes = React.Children.toArray(children).map(function (child, index) {
|
|
129
|
+
if (/*#__PURE__*/React.isValidElement(child) && child.type === ResponsiveGridCell) {
|
|
130
|
+
return child;
|
|
131
|
+
}
|
|
132
|
+
return /*#__PURE__*/React.createElement(ResponsiveGridCell, {
|
|
133
|
+
colSpan: 1,
|
|
134
|
+
key: "custom-form-child-" + index
|
|
135
|
+
}, child);
|
|
136
|
+
});
|
|
137
|
+
var hasContent = formItemNodes.length > 0 || childrenNodes.length > 0;
|
|
138
|
+
return /*#__PURE__*/React.createElement(NextFormAny, _extends({
|
|
139
|
+
className: "custom-form"
|
|
140
|
+
}, otherProps), hasContent ? /*#__PURE__*/React.createElement(ResponsiveGridAny, {
|
|
141
|
+
className: "custom-form__grid",
|
|
142
|
+
gap: spacing,
|
|
143
|
+
columns: columns
|
|
144
|
+
}, formItemNodes, childrenNodes) : /*#__PURE__*/React.createElement("div", {
|
|
145
|
+
className: "custom-form__empty"
|
|
146
|
+
}, emptyContent), showSubmit || showReset ? /*#__PURE__*/React.createElement("div", {
|
|
147
|
+
className: "custom-form__actions"
|
|
148
|
+
}, showReset ? /*#__PURE__*/React.createElement(NextFormAny.Reset, _extends({
|
|
149
|
+
className: "custom-form__reset"
|
|
150
|
+
}, resetButtonProps), resetText) : null, showSubmit ? /*#__PURE__*/React.createElement(NextFormAny.Submit, _extends({
|
|
151
|
+
className: "custom-form__submit",
|
|
152
|
+
type: "primary",
|
|
153
|
+
validate: submitValidate,
|
|
154
|
+
onClick: handleSubmit
|
|
155
|
+
}, submitButtonProps), submitText) : null) : null);
|
|
156
|
+
};
|
|
157
|
+
CustomForm.displayName = 'CustomForm';
|
|
158
|
+
export default CustomForm;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
.custom-form {
|
|
2
|
+
background-color: #fafafa;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.custom-form__grid {
|
|
6
|
+
width: 100%;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.custom-form__empty {
|
|
10
|
+
color: #999;
|
|
11
|
+
padding: 12px 0;
|
|
12
|
+
text-align: center;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.custom-form__actions {
|
|
16
|
+
display: flex;
|
|
17
|
+
justify-content: center;
|
|
18
|
+
gap: 12px;
|
|
19
|
+
padding: 12px 0 0;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.custom-form__submit,
|
|
23
|
+
.custom-form__reset {
|
|
24
|
+
min-width: 120px;
|
|
25
|
+
}
|