@faasjs/ant-design 0.0.3-beta.87 → 0.0.3-beta.89

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/dist/index.d.mts CHANGED
@@ -15,7 +15,6 @@ import { Dayjs } from 'dayjs';
15
15
  import { RuleObject } from 'rc-field-form/lib/interface';
16
16
  import { FilterValue, SorterResult, TableCurrentDataSource } from 'antd/es/table/interface';
17
17
  import * as antd_es_form_context from 'antd/es/form/context';
18
- import * as antd_es_form_ErrorList from 'antd/es/form/ErrorList';
19
18
  import * as antd_es_form from 'antd/es/form';
20
19
  import * as rc_field_form_es_useWatch from 'rc-field-form/es/useWatch';
21
20
  import * as antd_es_form_hooks_useFormInstance from 'antd/es/form/hooks/useFormInstance';
@@ -266,9 +265,9 @@ interface DescriptionItemProps<T = any> extends FaasItemProps {
266
265
  if?: (values: Record<string, any>) => boolean;
267
266
  object?: DescriptionItemProps<T>[];
268
267
  }
269
- interface DescriptionProps<T = any, ExtendItemProps = any> extends DescriptionsProps {
268
+ interface DescriptionProps<T = any, ExtendItemProps = any> extends Omit<DescriptionsProps, 'items'> {
270
269
  renderTitle?(values: T): ReactNode;
271
- items: (DescriptionItemProps | ExtendItemProps)[];
270
+ items: ((DescriptionItemProps | ExtendItemProps))[];
272
271
  extendTypes?: {
273
272
  [key: string]: ExtendDescriptionTypeProps;
274
273
  };
@@ -450,7 +449,7 @@ declare namespace Form {
450
449
  var useWatch: typeof rc_field_form_es_useWatch.default;
451
450
  var Item: typeof FormItem;
452
451
  var List: react.FC<antd_es_form.FormListProps>;
453
- var ErrorList: typeof antd_es_form_ErrorList.default;
452
+ var ErrorList: react.FC<antd_es_form.ErrorListProps>;
454
453
  var Provider: react.FC<antd_es_form_context.FormProviderProps>;
455
454
  }
456
455
 
package/dist/index.d.ts CHANGED
@@ -15,7 +15,6 @@ import { Dayjs } from 'dayjs';
15
15
  import { RuleObject } from 'rc-field-form/lib/interface';
16
16
  import { FilterValue, SorterResult, TableCurrentDataSource } from 'antd/es/table/interface';
17
17
  import * as antd_es_form_context from 'antd/es/form/context';
18
- import * as antd_es_form_ErrorList from 'antd/es/form/ErrorList';
19
18
  import * as antd_es_form from 'antd/es/form';
20
19
  import * as rc_field_form_es_useWatch from 'rc-field-form/es/useWatch';
21
20
  import * as antd_es_form_hooks_useFormInstance from 'antd/es/form/hooks/useFormInstance';
@@ -266,9 +265,9 @@ interface DescriptionItemProps<T = any> extends FaasItemProps {
266
265
  if?: (values: Record<string, any>) => boolean;
267
266
  object?: DescriptionItemProps<T>[];
268
267
  }
269
- interface DescriptionProps<T = any, ExtendItemProps = any> extends DescriptionsProps {
268
+ interface DescriptionProps<T = any, ExtendItemProps = any> extends Omit<DescriptionsProps, 'items'> {
270
269
  renderTitle?(values: T): ReactNode;
271
- items: (DescriptionItemProps | ExtendItemProps)[];
270
+ items: ((DescriptionItemProps | ExtendItemProps))[];
272
271
  extendTypes?: {
273
272
  [key: string]: ExtendDescriptionTypeProps;
274
273
  };
@@ -450,7 +449,7 @@ declare namespace Form {
450
449
  var useWatch: typeof rc_field_form_es_useWatch.default;
451
450
  var Item: typeof FormItem;
452
451
  var List: react.FC<antd_es_form.FormListProps>;
453
- var ErrorList: typeof antd_es_form_ErrorList.default;
452
+ var ErrorList: react.FC<antd_es_form.ErrorListProps>;
454
453
  var Provider: react.FC<antd_es_form_context.FormProviderProps>;
455
454
  }
456
455
 
package/dist/index.js CHANGED
@@ -332,60 +332,41 @@ function DescriptionItemContent(props) {
332
332
  }
333
333
  }
334
334
  function Description(props) {
335
- if (props.dataSource)
336
- return /* @__PURE__ */ jsxRuntime.jsx(
337
- antd.Descriptions,
338
- {
339
- ...props,
340
- title: lodashEs.isFunction(props.renderTitle) ? props.renderTitle(props.dataSource) : props.title,
341
- children: props.items.map((item) => item && (!item.if || item.if(props.dataSource)) ? /* @__PURE__ */ jsxRuntime.jsx(
342
- antd.Descriptions.Item,
335
+ const [computedProps, setComputedProps] = react$1.useState();
336
+ react$1.useEffect(() => {
337
+ setComputedProps({
338
+ ...props,
339
+ title: lodashEs.isFunction(props.renderTitle) ? props.renderTitle(props.dataSource) : props.title,
340
+ items: props.items.filter((item) => item && (!item.if || item.if(props.dataSource))).map((item) => ({
341
+ ...item,
342
+ key: item.id,
343
+ label: item.title || lodashEs.upperFirst(item.id),
344
+ children: /* @__PURE__ */ jsxRuntime.jsx(
345
+ DescriptionItemContent,
343
346
  {
344
- label: item.title || lodashEs.upperFirst(item.id),
345
- children: /* @__PURE__ */ jsxRuntime.jsx(
346
- DescriptionItemContent,
347
- {
348
- item,
349
- value: props.dataSource[item.id],
350
- values: props.dataSource,
351
- extendTypes: props.extendTypes
352
- }
353
- )
354
- },
355
- item.id
356
- ) : null).filter(Boolean)
357
- }
358
- );
347
+ item,
348
+ value: props.dataSource ? props.dataSource[item.id] : null,
349
+ values: props.dataSource,
350
+ extendTypes: props.extendTypes
351
+ }
352
+ )
353
+ }))
354
+ });
355
+ }, [props]);
356
+ if (!computedProps)
357
+ return null;
358
+ if (props.dataSource)
359
+ return /* @__PURE__ */ jsxRuntime.jsx(antd.Descriptions, { ...computedProps });
359
360
  return /* @__PURE__ */ jsxRuntime.jsx(
360
361
  FaasDataWrapper,
361
362
  {
362
- render: ({ data }) => {
363
- return /* @__PURE__ */ jsxRuntime.jsx(
364
- antd.Descriptions,
365
- {
366
- ...props,
367
- title: lodashEs.isFunction(props.renderTitle) ? props.renderTitle(data) : props.title,
368
- children: props.items.map((item) => {
369
- return !item.if || item.if(data) ? /* @__PURE__ */ jsxRuntime.jsx(
370
- antd.Descriptions.Item,
371
- {
372
- label: item.title || lodashEs.upperFirst(item.id),
373
- children: /* @__PURE__ */ jsxRuntime.jsx(
374
- DescriptionItemContent,
375
- {
376
- item,
377
- value: data[item.id],
378
- values: data,
379
- extendTypes: props.extendTypes
380
- }
381
- )
382
- },
383
- item.id
384
- ) : null;
385
- }).filter(Boolean)
386
- }
387
- );
388
- },
363
+ render: ({ data }) => /* @__PURE__ */ jsxRuntime.jsx(
364
+ Description,
365
+ {
366
+ ...computedProps,
367
+ dataSource: data
368
+ }
369
+ ),
389
370
  ...props.faasData
390
371
  }
391
372
  );
package/dist/index.mjs CHANGED
@@ -329,60 +329,41 @@ function DescriptionItemContent(props) {
329
329
  }
330
330
  }
331
331
  function Description(props) {
332
- if (props.dataSource)
333
- return /* @__PURE__ */ jsx(
334
- Descriptions,
335
- {
336
- ...props,
337
- title: isFunction(props.renderTitle) ? props.renderTitle(props.dataSource) : props.title,
338
- children: props.items.map((item) => item && (!item.if || item.if(props.dataSource)) ? /* @__PURE__ */ jsx(
339
- Descriptions.Item,
332
+ const [computedProps, setComputedProps] = useState();
333
+ useEffect(() => {
334
+ setComputedProps({
335
+ ...props,
336
+ title: isFunction(props.renderTitle) ? props.renderTitle(props.dataSource) : props.title,
337
+ items: props.items.filter((item) => item && (!item.if || item.if(props.dataSource))).map((item) => ({
338
+ ...item,
339
+ key: item.id,
340
+ label: item.title || upperFirst(item.id),
341
+ children: /* @__PURE__ */ jsx(
342
+ DescriptionItemContent,
340
343
  {
341
- label: item.title || upperFirst(item.id),
342
- children: /* @__PURE__ */ jsx(
343
- DescriptionItemContent,
344
- {
345
- item,
346
- value: props.dataSource[item.id],
347
- values: props.dataSource,
348
- extendTypes: props.extendTypes
349
- }
350
- )
351
- },
352
- item.id
353
- ) : null).filter(Boolean)
354
- }
355
- );
344
+ item,
345
+ value: props.dataSource ? props.dataSource[item.id] : null,
346
+ values: props.dataSource,
347
+ extendTypes: props.extendTypes
348
+ }
349
+ )
350
+ }))
351
+ });
352
+ }, [props]);
353
+ if (!computedProps)
354
+ return null;
355
+ if (props.dataSource)
356
+ return /* @__PURE__ */ jsx(Descriptions, { ...computedProps });
356
357
  return /* @__PURE__ */ jsx(
357
358
  FaasDataWrapper,
358
359
  {
359
- render: ({ data }) => {
360
- return /* @__PURE__ */ jsx(
361
- Descriptions,
362
- {
363
- ...props,
364
- title: isFunction(props.renderTitle) ? props.renderTitle(data) : props.title,
365
- children: props.items.map((item) => {
366
- return !item.if || item.if(data) ? /* @__PURE__ */ jsx(
367
- Descriptions.Item,
368
- {
369
- label: item.title || upperFirst(item.id),
370
- children: /* @__PURE__ */ jsx(
371
- DescriptionItemContent,
372
- {
373
- item,
374
- value: data[item.id],
375
- values: data,
376
- extendTypes: props.extendTypes
377
- }
378
- )
379
- },
380
- item.id
381
- ) : null;
382
- }).filter(Boolean)
383
- }
384
- );
385
- },
360
+ render: ({ data }) => /* @__PURE__ */ jsx(
361
+ Description,
362
+ {
363
+ ...computedProps,
364
+ dataSource: data
365
+ }
366
+ ),
386
367
  ...props.faasData
387
368
  }
388
369
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faasjs/ant-design",
3
- "version": "0.0.3-beta.87",
3
+ "version": "0.0.3-beta.89",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -22,7 +22,7 @@
22
22
  "dist"
23
23
  ],
24
24
  "dependencies": {
25
- "@faasjs/react": "^0.0.3-beta.87",
25
+ "@faasjs/react": "^0.0.3-beta.89",
26
26
  "@ant-design/icons": "*",
27
27
  "lodash-es": "*",
28
28
  "dayjs": "*"