@faasjs/ant-design 0.0.2-beta.363 → 0.0.2-beta.364

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 CHANGED
@@ -439,6 +439,18 @@ ___
439
439
 
440
440
  ▸ **FormItem**<`T`\>(`props`): `Element`
441
441
 
442
+ FormItem, can be used without Form.
443
+ Example:
444
+ ```ts
445
+ // use inline type
446
+ <FormItem item={{ type: 'string', id: 'name' }} />
447
+
448
+ // use custom type
449
+ <FormItem item={{ id: 'password' }}>
450
+ <Input.Password />
451
+ </>
452
+ ```
453
+
442
454
  #### Type parameters
443
455
 
444
456
  | Name | Type |
package/dist/index.d.ts CHANGED
@@ -163,6 +163,19 @@ declare type FormItemProps<T = any> = {
163
163
  [type: string]: ExtendFormTypeProps;
164
164
  };
165
165
  } & FormItemInputProps<T> & FaasItemProps & FormItemProps$1<T>;
166
+ /**
167
+ * FormItem, can be used without Form.
168
+ * Example:
169
+ * ```ts
170
+ * // use inline type
171
+ * <FormItem item={{ type: 'string', id: 'name' }} />
172
+ *
173
+ * // use custom type
174
+ * <FormItem item={{ id: 'password' }}>
175
+ * <Input.Password />
176
+ * </>
177
+ * ```
178
+ */
166
179
  declare function FormItem<T = any>(props: FormItemProps<T>): JSX.Element;
167
180
 
168
181
  declare type FormProps<Values = any, ExtendItemProps = any> = {
package/dist/index.js CHANGED
@@ -302,35 +302,41 @@ function FormItem(props) {
302
302
  return /* @__PURE__ */ import_react.default.createElement(import_antd4.Form.List, {
303
303
  name: computedProps.name,
304
304
  rules: computedProps.rules
305
- }, (fields, { add, remove }, { errors }) => /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, computedProps.label && /* @__PURE__ */ import_react.default.createElement("div", {
306
- className: "ant-form-item-label"
307
- }, /* @__PURE__ */ import_react.default.createElement("label", {
308
- className: computedProps.rules.find((r) => r.required) && "ant-form-item-required"
309
- }, computedProps.label)), fields.map((field) => /* @__PURE__ */ import_react.default.createElement(import_antd4.Form.Item, {
310
- key: field.key
311
- }, /* @__PURE__ */ import_react.default.createElement(import_antd4.Row, {
312
- gutter: 24,
313
- style: { flexFlow: "row nowrap" }
314
- }, /* @__PURE__ */ import_react.default.createElement(import_antd4.Col, {
315
- span: 23
316
- }, /* @__PURE__ */ import_react.default.createElement(import_antd4.Form.Item, __spreadProps(__spreadValues({}, field), {
317
- noStyle: true
318
- }), /* @__PURE__ */ import_react.default.createElement(import_antd4.Input, __spreadValues({}, computedProps.input)))), /* @__PURE__ */ import_react.default.createElement(import_antd4.Col, {
319
- span: 1
320
- }, (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ import_react.default.createElement(import_antd4.Button, {
321
- danger: true,
322
- type: "link",
323
- style: { float: "right" },
324
- icon: /* @__PURE__ */ import_react.default.createElement(import_icons2.MinusCircleOutlined, null),
325
- onClick: () => remove(field.name)
326
- }))))), /* @__PURE__ */ import_react.default.createElement(import_antd4.Form.Item, null, (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ import_react.default.createElement(import_antd4.Button, {
327
- type: "dashed",
328
- block: true,
329
- onClick: () => add(),
330
- icon: /* @__PURE__ */ import_react.default.createElement(import_icons2.PlusOutlined, null)
331
- }), /* @__PURE__ */ import_react.default.createElement(import_antd4.Form.ErrorList, {
332
- errors
333
- }))));
305
+ }, (fields, { add, remove }, { errors }) => {
306
+ var _a;
307
+ return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, computedProps.label && /* @__PURE__ */ import_react.default.createElement("div", {
308
+ className: "ant-form-item-label"
309
+ }, /* @__PURE__ */ import_react.default.createElement("label", {
310
+ className: computedProps.rules.find((r) => r.required) && "ant-form-item-required"
311
+ }, computedProps.label)), fields.map((field) => {
312
+ var _a2;
313
+ return /* @__PURE__ */ import_react.default.createElement(import_antd4.Form.Item, {
314
+ key: field.key
315
+ }, /* @__PURE__ */ import_react.default.createElement(import_antd4.Row, {
316
+ gutter: 24,
317
+ style: { flexFlow: "row nowrap" }
318
+ }, /* @__PURE__ */ import_react.default.createElement(import_antd4.Col, {
319
+ span: 23
320
+ }, /* @__PURE__ */ import_react.default.createElement(import_antd4.Form.Item, __spreadProps(__spreadValues({}, field), {
321
+ noStyle: true
322
+ }), /* @__PURE__ */ import_react.default.createElement(import_antd4.Input, __spreadValues({}, computedProps.input)))), /* @__PURE__ */ import_react.default.createElement(import_antd4.Col, {
323
+ span: 1
324
+ }, !((_a2 = computedProps.input) == null ? void 0 : _a2.disabled) && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ import_react.default.createElement(import_antd4.Button, {
325
+ danger: true,
326
+ type: "link",
327
+ style: { float: "right" },
328
+ icon: /* @__PURE__ */ import_react.default.createElement(import_icons2.MinusCircleOutlined, null),
329
+ onClick: () => remove(field.name)
330
+ }))));
331
+ }), /* @__PURE__ */ import_react.default.createElement(import_antd4.Form.Item, null, !((_a = computedProps.input) == null ? void 0 : _a.disabled) && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ import_react.default.createElement(import_antd4.Button, {
332
+ type: "dashed",
333
+ block: true,
334
+ onClick: () => add(),
335
+ icon: /* @__PURE__ */ import_react.default.createElement(import_icons2.PlusOutlined, null)
336
+ }), /* @__PURE__ */ import_react.default.createElement(import_antd4.Form.ErrorList, {
337
+ errors
338
+ })));
339
+ });
334
340
  case "number":
335
341
  return /* @__PURE__ */ import_react.default.createElement(import_antd4.Form.Item, __spreadValues({}, computedProps), computedProps.options ? /* @__PURE__ */ import_react.default.createElement(import_antd4.Select, __spreadValues({}, computedProps.input)) : /* @__PURE__ */ import_react.default.createElement(import_antd4.InputNumber, __spreadValues({
336
342
  style: { width: "100%" }
@@ -344,31 +350,34 @@ function FormItem(props) {
344
350
  name: computedProps.name,
345
351
  rules: computedProps.rules
346
352
  }, (fields, { add, remove }, { errors }) => {
347
- var _a;
353
+ var _a, _b;
348
354
  return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, computedProps.label && /* @__PURE__ */ import_react.default.createElement("div", {
349
355
  className: "ant-form-item-label"
350
356
  }, /* @__PURE__ */ import_react.default.createElement("label", {
351
357
  className: ((_a = computedProps.rules) == null ? void 0 : _a.find((r) => r.required)) && "ant-form-item-required"
352
- }, computedProps.label)), fields.map((field) => /* @__PURE__ */ import_react.default.createElement(import_antd4.Form.Item, {
353
- key: field.key
354
- }, /* @__PURE__ */ import_react.default.createElement(import_antd4.Row, {
355
- gutter: 24,
356
- style: { flexFlow: "row nowrap" }
357
- }, /* @__PURE__ */ import_react.default.createElement(import_antd4.Col, {
358
- span: 23
359
- }, /* @__PURE__ */ import_react.default.createElement(import_antd4.Form.Item, __spreadProps(__spreadValues({}, field), {
360
- noStyle: true
361
- }), /* @__PURE__ */ import_react.default.createElement(import_antd4.InputNumber, __spreadValues({
362
- style: { width: "100%" }
363
- }, computedProps.input)))), /* @__PURE__ */ import_react.default.createElement(import_antd4.Col, {
364
- span: 1
365
- }, (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ import_react.default.createElement(import_antd4.Button, {
366
- danger: true,
367
- type: "link",
368
- style: { float: "right" },
369
- icon: /* @__PURE__ */ import_react.default.createElement(import_icons2.MinusCircleOutlined, null),
370
- onClick: () => remove(field.name)
371
- }))))), /* @__PURE__ */ import_react.default.createElement(import_antd4.Form.Item, null, (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ import_react.default.createElement(import_antd4.Button, {
358
+ }, computedProps.label)), fields.map((field) => {
359
+ var _a2;
360
+ return /* @__PURE__ */ import_react.default.createElement(import_antd4.Form.Item, {
361
+ key: field.key
362
+ }, /* @__PURE__ */ import_react.default.createElement(import_antd4.Row, {
363
+ gutter: 24,
364
+ style: { flexFlow: "row nowrap" }
365
+ }, /* @__PURE__ */ import_react.default.createElement(import_antd4.Col, {
366
+ span: 23
367
+ }, /* @__PURE__ */ import_react.default.createElement(import_antd4.Form.Item, __spreadProps(__spreadValues({}, field), {
368
+ noStyle: true
369
+ }), /* @__PURE__ */ import_react.default.createElement(import_antd4.InputNumber, __spreadValues({
370
+ style: { width: "100%" }
371
+ }, computedProps.input)))), /* @__PURE__ */ import_react.default.createElement(import_antd4.Col, {
372
+ span: 1
373
+ }, !((_a2 = computedProps.input) == null ? void 0 : _a2.disabled) && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ import_react.default.createElement(import_antd4.Button, {
374
+ danger: true,
375
+ type: "link",
376
+ style: { float: "right" },
377
+ icon: /* @__PURE__ */ import_react.default.createElement(import_icons2.MinusCircleOutlined, null),
378
+ onClick: () => remove(field.name)
379
+ }))));
380
+ }), /* @__PURE__ */ import_react.default.createElement(import_antd4.Form.Item, null, !((_b = computedProps.input) == null ? void 0 : _b.disabled) && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ import_react.default.createElement(import_antd4.Button, {
372
381
  type: "dashed",
373
382
  block: true,
374
383
  onClick: () => add(),
package/dist/index.mjs CHANGED
@@ -279,35 +279,41 @@ function FormItem(props) {
279
279
  return /* @__PURE__ */ React.createElement(AntdForm.List, {
280
280
  name: computedProps.name,
281
281
  rules: computedProps.rules
282
- }, (fields, { add, remove }, { errors }) => /* @__PURE__ */ React.createElement(React.Fragment, null, computedProps.label && /* @__PURE__ */ React.createElement("div", {
283
- className: "ant-form-item-label"
284
- }, /* @__PURE__ */ React.createElement("label", {
285
- className: computedProps.rules.find((r) => r.required) && "ant-form-item-required"
286
- }, computedProps.label)), fields.map((field) => /* @__PURE__ */ React.createElement(AntdForm.Item, {
287
- key: field.key
288
- }, /* @__PURE__ */ React.createElement(Row, {
289
- gutter: 24,
290
- style: { flexFlow: "row nowrap" }
291
- }, /* @__PURE__ */ React.createElement(Col, {
292
- span: 23
293
- }, /* @__PURE__ */ React.createElement(AntdForm.Item, __spreadProps(__spreadValues({}, field), {
294
- noStyle: true
295
- }), /* @__PURE__ */ React.createElement(Input, __spreadValues({}, computedProps.input)))), /* @__PURE__ */ React.createElement(Col, {
296
- span: 1
297
- }, (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ React.createElement(Button, {
298
- danger: true,
299
- type: "link",
300
- style: { float: "right" },
301
- icon: /* @__PURE__ */ React.createElement(MinusCircleOutlined, null),
302
- onClick: () => remove(field.name)
303
- }))))), /* @__PURE__ */ React.createElement(AntdForm.Item, null, (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ React.createElement(Button, {
304
- type: "dashed",
305
- block: true,
306
- onClick: () => add(),
307
- icon: /* @__PURE__ */ React.createElement(PlusOutlined, null)
308
- }), /* @__PURE__ */ React.createElement(AntdForm.ErrorList, {
309
- errors
310
- }))));
282
+ }, (fields, { add, remove }, { errors }) => {
283
+ var _a;
284
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, computedProps.label && /* @__PURE__ */ React.createElement("div", {
285
+ className: "ant-form-item-label"
286
+ }, /* @__PURE__ */ React.createElement("label", {
287
+ className: computedProps.rules.find((r) => r.required) && "ant-form-item-required"
288
+ }, computedProps.label)), fields.map((field) => {
289
+ var _a2;
290
+ return /* @__PURE__ */ React.createElement(AntdForm.Item, {
291
+ key: field.key
292
+ }, /* @__PURE__ */ React.createElement(Row, {
293
+ gutter: 24,
294
+ style: { flexFlow: "row nowrap" }
295
+ }, /* @__PURE__ */ React.createElement(Col, {
296
+ span: 23
297
+ }, /* @__PURE__ */ React.createElement(AntdForm.Item, __spreadProps(__spreadValues({}, field), {
298
+ noStyle: true
299
+ }), /* @__PURE__ */ React.createElement(Input, __spreadValues({}, computedProps.input)))), /* @__PURE__ */ React.createElement(Col, {
300
+ span: 1
301
+ }, !((_a2 = computedProps.input) == null ? void 0 : _a2.disabled) && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ React.createElement(Button, {
302
+ danger: true,
303
+ type: "link",
304
+ style: { float: "right" },
305
+ icon: /* @__PURE__ */ React.createElement(MinusCircleOutlined, null),
306
+ onClick: () => remove(field.name)
307
+ }))));
308
+ }), /* @__PURE__ */ React.createElement(AntdForm.Item, null, !((_a = computedProps.input) == null ? void 0 : _a.disabled) && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ React.createElement(Button, {
309
+ type: "dashed",
310
+ block: true,
311
+ onClick: () => add(),
312
+ icon: /* @__PURE__ */ React.createElement(PlusOutlined, null)
313
+ }), /* @__PURE__ */ React.createElement(AntdForm.ErrorList, {
314
+ errors
315
+ })));
316
+ });
311
317
  case "number":
312
318
  return /* @__PURE__ */ React.createElement(AntdForm.Item, __spreadValues({}, computedProps), computedProps.options ? /* @__PURE__ */ React.createElement(Select, __spreadValues({}, computedProps.input)) : /* @__PURE__ */ React.createElement(InputNumber, __spreadValues({
313
319
  style: { width: "100%" }
@@ -321,31 +327,34 @@ function FormItem(props) {
321
327
  name: computedProps.name,
322
328
  rules: computedProps.rules
323
329
  }, (fields, { add, remove }, { errors }) => {
324
- var _a;
330
+ var _a, _b;
325
331
  return /* @__PURE__ */ React.createElement(React.Fragment, null, computedProps.label && /* @__PURE__ */ React.createElement("div", {
326
332
  className: "ant-form-item-label"
327
333
  }, /* @__PURE__ */ React.createElement("label", {
328
334
  className: ((_a = computedProps.rules) == null ? void 0 : _a.find((r) => r.required)) && "ant-form-item-required"
329
- }, computedProps.label)), fields.map((field) => /* @__PURE__ */ React.createElement(AntdForm.Item, {
330
- key: field.key
331
- }, /* @__PURE__ */ React.createElement(Row, {
332
- gutter: 24,
333
- style: { flexFlow: "row nowrap" }
334
- }, /* @__PURE__ */ React.createElement(Col, {
335
- span: 23
336
- }, /* @__PURE__ */ React.createElement(AntdForm.Item, __spreadProps(__spreadValues({}, field), {
337
- noStyle: true
338
- }), /* @__PURE__ */ React.createElement(InputNumber, __spreadValues({
339
- style: { width: "100%" }
340
- }, computedProps.input)))), /* @__PURE__ */ React.createElement(Col, {
341
- span: 1
342
- }, (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ React.createElement(Button, {
343
- danger: true,
344
- type: "link",
345
- style: { float: "right" },
346
- icon: /* @__PURE__ */ React.createElement(MinusCircleOutlined, null),
347
- onClick: () => remove(field.name)
348
- }))))), /* @__PURE__ */ React.createElement(AntdForm.Item, null, (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ React.createElement(Button, {
335
+ }, computedProps.label)), fields.map((field) => {
336
+ var _a2;
337
+ return /* @__PURE__ */ React.createElement(AntdForm.Item, {
338
+ key: field.key
339
+ }, /* @__PURE__ */ React.createElement(Row, {
340
+ gutter: 24,
341
+ style: { flexFlow: "row nowrap" }
342
+ }, /* @__PURE__ */ React.createElement(Col, {
343
+ span: 23
344
+ }, /* @__PURE__ */ React.createElement(AntdForm.Item, __spreadProps(__spreadValues({}, field), {
345
+ noStyle: true
346
+ }), /* @__PURE__ */ React.createElement(InputNumber, __spreadValues({
347
+ style: { width: "100%" }
348
+ }, computedProps.input)))), /* @__PURE__ */ React.createElement(Col, {
349
+ span: 1
350
+ }, !((_a2 = computedProps.input) == null ? void 0 : _a2.disabled) && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ React.createElement(Button, {
351
+ danger: true,
352
+ type: "link",
353
+ style: { float: "right" },
354
+ icon: /* @__PURE__ */ React.createElement(MinusCircleOutlined, null),
355
+ onClick: () => remove(field.name)
356
+ }))));
357
+ }), /* @__PURE__ */ React.createElement(AntdForm.Item, null, !((_b = computedProps.input) == null ? void 0 : _b.disabled) && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ React.createElement(Button, {
349
358
  type: "dashed",
350
359
  block: true,
351
360
  onClick: () => add(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faasjs/ant-design",
3
- "version": "0.0.2-beta.363",
3
+ "version": "0.0.2-beta.364",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -28,7 +28,7 @@
28
28
  "lodash": "*",
29
29
  "react": "*",
30
30
  "react-dom": "*",
31
- "@faasjs/react": "^0.0.2-beta.363",
31
+ "@faasjs/react": "^0.0.2-beta.364",
32
32
  "react-use": "*",
33
33
  "react-router-dom": "*"
34
34
  },