@faasjs/ant-design 0.0.2-beta.328 → 0.0.2-beta.329
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 +6 -25
- package/dist/index.d.ts +2 -2
- package/dist/index.js +14 -2
- package/dist/index.mjs +14 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -27,33 +27,14 @@ type FaasItemProps = {
|
|
|
27
27
|
}
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
-
###
|
|
30
|
+
### Form
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
Form are based on [Ant Design's Form component](https://ant.design/components/form/#Form).
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
<iframe src="https://codesandbox.io/embed/recursing-lumiere-8wn11" style="width:100%;height:500px;border:0;overflow:hidden;" title="faasjs-ant-design-form" sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts"></iframe>
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
type DescriptionItemProps<T = any> = FaasItemProps & {
|
|
38
|
-
content?: (props: {
|
|
39
|
-
value: T
|
|
40
|
-
}) => JSX.Element
|
|
41
|
-
}
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
#### FormItemProps
|
|
45
|
-
|
|
46
|
-
```ts
|
|
47
|
-
type FormItemProps<T = any> = AntdFormItemProps<T> & FaasItemProps & {
|
|
48
|
-
input?: (args: {
|
|
49
|
-
value?: T
|
|
50
|
-
onChange?: (value: T) => void
|
|
51
|
-
}) => JSX.Element
|
|
52
|
-
}
|
|
53
|
-
```
|
|
36
|
+
### FormItem
|
|
54
37
|
|
|
55
|
-
|
|
38
|
+
Form are based on [Ant Design's Form.Item component](https://ant.design/components/form/#Form.Item).
|
|
56
39
|
|
|
57
|
-
|
|
58
|
-
type TableItemProps<T = any> = AntdTableColumnProps<T> & FaasItemProps
|
|
59
|
-
```
|
|
40
|
+
<iframe src="https://codesandbox.io/s/faasjs-ant-design-formitem-olqg5" style="width:100%;height:500px;border:0;overflow:hidden;" title="faasjs-ant-design-formitem" sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts"></iframe>
|
package/dist/index.d.ts
CHANGED
|
@@ -33,7 +33,7 @@ declare type OptionType<T = any> = {
|
|
|
33
33
|
children?: Omit<OptionType<T>, 'children'>[];
|
|
34
34
|
};
|
|
35
35
|
declare type OptionsProps<T = any> = {
|
|
36
|
-
options?: OptionType<T>[];
|
|
36
|
+
options?: OptionType<T>[] | string[] | number[];
|
|
37
37
|
type?: 'string' | 'string[]' | 'number' | 'number[]';
|
|
38
38
|
input?: SelectProps<any>;
|
|
39
39
|
};
|
|
@@ -46,7 +46,7 @@ declare type FormItemProps<T = any> = {
|
|
|
46
46
|
declare function FormItem<T = any>(props: FormItemProps<T>): JSX.Element;
|
|
47
47
|
|
|
48
48
|
declare type FormProps<T = any> = {
|
|
49
|
-
items
|
|
49
|
+
items?: FormItemProps[];
|
|
50
50
|
} & FormProps$1<T>;
|
|
51
51
|
declare const Form: {
|
|
52
52
|
<T = any>(props: FormProps<T>): JSX.Element;
|
package/dist/index.js
CHANGED
|
@@ -93,7 +93,18 @@ function FormItem(props) {
|
|
|
93
93
|
if (!propsCopy.input)
|
|
94
94
|
propsCopy.input = {};
|
|
95
95
|
if (propsCopy.options) {
|
|
96
|
-
|
|
96
|
+
const options = [];
|
|
97
|
+
if (propsCopy.options.length > 0)
|
|
98
|
+
for (const option of propsCopy.options) {
|
|
99
|
+
if (typeof option === "object")
|
|
100
|
+
options.push(option);
|
|
101
|
+
else
|
|
102
|
+
options.push({
|
|
103
|
+
label: (0, import_lodash.upperFirst)(option.toString()),
|
|
104
|
+
value: option
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
propsCopy.input.options = options;
|
|
97
108
|
}
|
|
98
109
|
switch (propsCopy.type) {
|
|
99
110
|
case "boolean":
|
|
@@ -199,7 +210,8 @@ function FormItem(props) {
|
|
|
199
210
|
|
|
200
211
|
// src/components/Form.tsx
|
|
201
212
|
var Form = function(props) {
|
|
202
|
-
|
|
213
|
+
var _a;
|
|
214
|
+
return /* @__PURE__ */ import_react.default.createElement(import_antd2.Form, __spreadValues({}, props), (_a = props.items) == null ? void 0 : _a.map((item) => /* @__PURE__ */ import_react.default.createElement(FormItem, __spreadValues({
|
|
203
215
|
key: item.id
|
|
204
216
|
}, item))), /* @__PURE__ */ import_react.default.createElement(import_antd2.Button, {
|
|
205
217
|
htmlType: "submit",
|
package/dist/index.mjs
CHANGED
|
@@ -76,7 +76,18 @@ function FormItem(props) {
|
|
|
76
76
|
if (!propsCopy.input)
|
|
77
77
|
propsCopy.input = {};
|
|
78
78
|
if (propsCopy.options) {
|
|
79
|
-
|
|
79
|
+
const options = [];
|
|
80
|
+
if (propsCopy.options.length > 0)
|
|
81
|
+
for (const option of propsCopy.options) {
|
|
82
|
+
if (typeof option === "object")
|
|
83
|
+
options.push(option);
|
|
84
|
+
else
|
|
85
|
+
options.push({
|
|
86
|
+
label: upperFirst(option.toString()),
|
|
87
|
+
value: option
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
propsCopy.input.options = options;
|
|
80
91
|
}
|
|
81
92
|
switch (propsCopy.type) {
|
|
82
93
|
case "boolean":
|
|
@@ -182,7 +193,8 @@ function FormItem(props) {
|
|
|
182
193
|
|
|
183
194
|
// src/components/Form.tsx
|
|
184
195
|
var Form = function(props) {
|
|
185
|
-
|
|
196
|
+
var _a;
|
|
197
|
+
return /* @__PURE__ */ React.createElement(AntdForm2, __spreadValues({}, props), (_a = props.items) == null ? void 0 : _a.map((item) => /* @__PURE__ */ React.createElement(FormItem, __spreadValues({
|
|
186
198
|
key: item.id
|
|
187
199
|
}, item))), /* @__PURE__ */ React.createElement(Button2, {
|
|
188
200
|
htmlType: "submit",
|