@faasjs/ant-design 2.8.1 → 3.0.0-canary.1

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
@@ -29,7 +29,7 @@ declare const Modal: react.FC<ModalProps$1> & antd_es_modal_confirm.ModalStaticF
29
29
  useModal: typeof antd_es_modal_useModal.default;
30
30
  destroyAll: () => void;
31
31
  config: typeof antd_es_modal_confirm.modalGlobalConfig;
32
- _InternalPanelDoNotUseOrYouWillBeFired: (props: antd_es_modal_PurePanel.PurePanelProps) => react.JSX.Element;
32
+ _InternalPanelDoNotUseOrYouWillBeFired: (props: antd_es_modal_PurePanel.PurePanelProps) => React.JSX.Element;
33
33
  };
34
34
  interface ModalProps extends ModalProps$1 {
35
35
  children?: JSX.Element | JSX.Element[] | string;
@@ -447,7 +447,7 @@ interface DescriptionItemContentProps<T = any> {
447
447
  * />
448
448
  * ```
449
449
  */
450
- declare function Description<T = any>(props: DescriptionProps<T>): react_jsx_runtime.JSX.Element;
450
+ declare function Description<T extends Record<string, any> = any>(props: DescriptionProps<T>): react_jsx_runtime.JSX.Element;
451
451
  declare namespace Description {
452
452
  var whyDidYouRender: boolean;
453
453
  }
package/dist/index.d.ts CHANGED
@@ -29,7 +29,7 @@ declare const Modal: react.FC<ModalProps$1> & antd_es_modal_confirm.ModalStaticF
29
29
  useModal: typeof antd_es_modal_useModal.default;
30
30
  destroyAll: () => void;
31
31
  config: typeof antd_es_modal_confirm.modalGlobalConfig;
32
- _InternalPanelDoNotUseOrYouWillBeFired: (props: antd_es_modal_PurePanel.PurePanelProps) => react.JSX.Element;
32
+ _InternalPanelDoNotUseOrYouWillBeFired: (props: antd_es_modal_PurePanel.PurePanelProps) => React.JSX.Element;
33
33
  };
34
34
  interface ModalProps extends ModalProps$1 {
35
35
  children?: JSX.Element | JSX.Element[] | string;
@@ -447,7 +447,7 @@ interface DescriptionItemContentProps<T = any> {
447
447
  * />
448
448
  * ```
449
449
  */
450
- declare function Description<T = any>(props: DescriptionProps<T>): react_jsx_runtime.JSX.Element;
450
+ declare function Description<T extends Record<string, any> = any>(props: DescriptionProps<T>): react_jsx_runtime.JSX.Element;
451
451
  declare namespace Description {
452
452
  var whyDidYouRender: boolean;
453
453
  }
package/dist/index.js CHANGED
@@ -136,8 +136,7 @@ var ConfigContext = react$1.createContext({
136
136
  function ConfigProvider(props) {
137
137
  const [theme, setTheme] = react$1.useState();
138
138
  react$1.useEffect(() => {
139
- var _a;
140
- if (((_a = props.theme) == null ? void 0 : _a.lang) === "zh") {
139
+ if (props.theme?.lang === "zh") {
141
140
  setTheme(
142
141
  lodashEs.defaultsDeep(
143
142
  props.theme,
@@ -240,7 +239,7 @@ App.useApp = useApp;
240
239
  App.whyDidYouRender = true;
241
240
  function Blank(options) {
242
241
  const { theme } = useConfigContext();
243
- return !options || lodashEs.isNil(options.value) || Array.isArray(options.value) && !options.value.length || options.value === "" ? /* @__PURE__ */ jsxRuntime.jsx(antd.Typography.Text, { disabled: true, children: (options == null ? void 0 : options.text) || theme.Blank.text }) : options.value;
242
+ return !options || lodashEs.isNil(options.value) || Array.isArray(options.value) && !options.value.length || options.value === "" ? /* @__PURE__ */ jsxRuntime.jsx(antd.Typography.Text, { disabled: true, children: options?.text || theme.Blank.text }) : options.value;
244
243
  }
245
244
  Blank.whyDidYouRender = true;
246
245
  function transferOptions(options) {
@@ -314,33 +313,28 @@ function withFaasData(Component, faasProps) {
314
313
  });
315
314
  }
316
315
  function DescriptionItemContent(props) {
317
- var _a, _b;
318
316
  const [computedProps, setComputedProps] = react$1.useState();
319
317
  react$1.useEffect(() => {
320
- var _a2, _b2;
321
318
  const propsCopy = { ...props };
322
319
  if (!propsCopy.item.title)
323
320
  propsCopy.item.title = lodashEs.upperFirst(propsCopy.item.id);
324
321
  if (!propsCopy.item.type) propsCopy.item.type = "string";
325
- if ((_a2 = propsCopy.item.options) == null ? void 0 : _a2.length) {
322
+ if (propsCopy.item.options?.length) {
326
323
  propsCopy.item.options = transferOptions(propsCopy.item.options);
327
324
  }
328
325
  propsCopy.value = transferValue(propsCopy.item.type, propsCopy.value);
329
326
  if (propsCopy.item.options && propsCopy.value !== null) {
330
327
  if (propsCopy.item.type.endsWith("[]"))
331
328
  propsCopy.value = propsCopy.value.map(
332
- (v) => {
333
- var _a3;
334
- return ((_a3 = propsCopy.item.options.find((option) => option.value === v)) == null ? void 0 : _a3.label) || v;
335
- }
329
+ (v) => propsCopy.item.options.find((option) => option.value === v)?.label || v
336
330
  );
337
331
  else if (["string", "number", "boolean"].includes(propsCopy.item.type))
338
- propsCopy.value = ((_b2 = props.item.options.find((option) => option.value === props.value)) == null ? void 0 : _b2.label) || props.value;
332
+ propsCopy.value = props.item.options.find((option) => option.value === props.value)?.label || props.value;
339
333
  }
340
334
  setComputedProps(propsCopy);
341
335
  }, [props]);
342
336
  if (!computedProps) return null;
343
- if ((_a = computedProps.extendTypes) == null ? void 0 : _a[computedProps.item.type]) {
337
+ if (computedProps.extendTypes?.[computedProps.item.type]) {
344
338
  if (computedProps.extendTypes[computedProps.item.type].children)
345
339
  return react$1.cloneElement(
346
340
  computedProps.extendTypes[computedProps.item.type].children,
@@ -429,7 +423,7 @@ function DescriptionItemContent(props) {
429
423
  }
430
424
  );
431
425
  case "object[]":
432
- if (!((_b = computedProps.value) == null ? void 0 : _b.length))
426
+ if (!computedProps.value?.length)
433
427
  return /* @__PURE__ */ jsxRuntime.jsx(Blank, {});
434
428
  return /* @__PURE__ */ jsxRuntime.jsx(antd.Space, { direction: "vertical", children: computedProps.value.map(
435
429
  (value, index) => /* @__PURE__ */ jsxRuntime.jsx(
@@ -524,7 +518,6 @@ function processProps(propsCopy, config) {
524
518
  return propsCopy;
525
519
  }
526
520
  function FormItem(props) {
527
- var _a;
528
521
  const [computedProps, setComputedProps] = react$1.useState();
529
522
  const [extendTypes, setExtendTypes] = react$1.useState();
530
523
  const { theme } = useConfigContext();
@@ -553,7 +546,7 @@ function FormItem(props) {
553
546
  if (!computedProps) return null;
554
547
  if (hidden)
555
548
  return /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { ...computedProps, noStyle: true, rules: [], children: /* @__PURE__ */ jsxRuntime.jsx(antd.Input, { hidden: true }) });
556
- if (extendTypes == null ? void 0 : extendTypes[computedProps.type])
549
+ if (extendTypes?.[computedProps.type])
557
550
  return /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { ...computedProps, children: extendTypes[computedProps.type].children });
558
551
  if (computedProps.formChildren === null) return null;
559
552
  if (computedProps.formChildren)
@@ -578,47 +571,41 @@ function FormItem(props) {
578
571
  {
579
572
  name: computedProps.name,
580
573
  rules: computedProps.rules,
581
- children: (fields, { add, remove }, { errors }) => {
582
- var _a2;
583
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
584
- computedProps.label && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ant-form-item-label", children: /* @__PURE__ */ jsxRuntime.jsx(
585
- "label",
574
+ children: (fields, { add, remove }, { errors }) => /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
575
+ computedProps.label && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ant-form-item-label", children: /* @__PURE__ */ jsxRuntime.jsx(
576
+ "label",
577
+ {
578
+ className: computedProps.rules.find((r) => r.required) && "ant-form-item-required",
579
+ children: computedProps.label
580
+ }
581
+ ) }),
582
+ fields.map((field) => /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Row, { gutter: 24, style: { flexFlow: "row nowrap" }, children: [
583
+ /* @__PURE__ */ jsxRuntime.jsx(antd.Col, { span: 23, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { ...field, noStyle: true, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Input, { ...computedProps.input }) }) }),
584
+ /* @__PURE__ */ jsxRuntime.jsx(antd.Col, { span: 1, children: !computedProps.input?.disabled && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ jsxRuntime.jsx(
585
+ antd.Button,
586
586
  {
587
- className: computedProps.rules.find((r) => r.required) && "ant-form-item-required",
588
- children: computedProps.label
587
+ danger: true,
588
+ type: "link",
589
+ style: { float: "right" },
590
+ icon: /* @__PURE__ */ jsxRuntime.jsx(icons.MinusCircleOutlined, {}),
591
+ onClick: () => remove(field.name)
589
592
  }
590
- ) }),
591
- fields.map((field) => {
592
- var _a3;
593
- return /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Row, { gutter: 24, style: { flexFlow: "row nowrap" }, children: [
594
- /* @__PURE__ */ jsxRuntime.jsx(antd.Col, { span: 23, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { ...field, noStyle: true, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Input, { ...computedProps.input }) }) }),
595
- /* @__PURE__ */ jsxRuntime.jsx(antd.Col, { span: 1, children: !((_a3 = computedProps.input) == null ? void 0 : _a3.disabled) && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ jsxRuntime.jsx(
596
- antd.Button,
597
- {
598
- danger: true,
599
- type: "link",
600
- style: { float: "right" },
601
- icon: /* @__PURE__ */ jsxRuntime.jsx(icons.MinusCircleOutlined, {}),
602
- onClick: () => remove(field.name)
603
- }
604
- ) })
605
- ] }) }, field.key);
606
- }),
607
- /* @__PURE__ */ jsxRuntime.jsxs(antd.Form.Item, { children: [
608
- !((_a2 = computedProps.input) == null ? void 0 : _a2.disabled) && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ jsxRuntime.jsx(
609
- antd.Button,
610
- {
611
- type: "dashed",
612
- block: true,
613
- onClick: () => add(),
614
- icon: /* @__PURE__ */ jsxRuntime.jsx(icons.PlusOutlined, {})
615
- }
616
- ),
617
- computedProps.extra && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ant-form-item-extra", children: computedProps.extra }),
618
- /* @__PURE__ */ jsxRuntime.jsx(antd.Form.ErrorList, { errors })
619
- ] })
620
- ] });
621
- }
593
+ ) })
594
+ ] }) }, field.key)),
595
+ /* @__PURE__ */ jsxRuntime.jsxs(antd.Form.Item, { children: [
596
+ !computedProps.input?.disabled && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ jsxRuntime.jsx(
597
+ antd.Button,
598
+ {
599
+ type: "dashed",
600
+ block: true,
601
+ onClick: () => add(),
602
+ icon: /* @__PURE__ */ jsxRuntime.jsx(icons.PlusOutlined, {})
603
+ }
604
+ ),
605
+ computedProps.extra && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ant-form-item-extra", children: computedProps.extra }),
606
+ /* @__PURE__ */ jsxRuntime.jsx(antd.Form.ErrorList, { errors })
607
+ ] })
608
+ ] })
622
609
  }
623
610
  );
624
611
  case "number":
@@ -639,55 +626,49 @@ function FormItem(props) {
639
626
  {
640
627
  name: computedProps.name,
641
628
  rules: computedProps.rules,
642
- children: (fields, { add, remove }, { errors }) => {
643
- var _a2, _b;
644
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
645
- computedProps.label && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ant-form-item-label", children: /* @__PURE__ */ jsxRuntime.jsx(
646
- "label",
629
+ children: (fields, { add, remove }, { errors }) => /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
630
+ computedProps.label && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ant-form-item-label", children: /* @__PURE__ */ jsxRuntime.jsx(
631
+ "label",
632
+ {
633
+ className: computedProps.rules?.find(
634
+ (r) => r.required
635
+ ) && "ant-form-item-required",
636
+ children: computedProps.label
637
+ }
638
+ ) }),
639
+ fields.map((field) => /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Row, { gutter: 24, style: { flexFlow: "row nowrap" }, children: [
640
+ /* @__PURE__ */ jsxRuntime.jsx(antd.Col, { span: 23, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { ...field, noStyle: true, children: /* @__PURE__ */ jsxRuntime.jsx(
641
+ antd.InputNumber,
647
642
  {
648
- className: ((_a2 = computedProps.rules) == null ? void 0 : _a2.find(
649
- (r) => r.required
650
- )) && "ant-form-item-required",
651
- children: computedProps.label
643
+ style: { width: "100%" },
644
+ ...computedProps.input
652
645
  }
653
- ) }),
654
- fields.map((field) => {
655
- var _a3;
656
- return /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Row, { gutter: 24, style: { flexFlow: "row nowrap" }, children: [
657
- /* @__PURE__ */ jsxRuntime.jsx(antd.Col, { span: 23, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { ...field, noStyle: true, children: /* @__PURE__ */ jsxRuntime.jsx(
658
- antd.InputNumber,
659
- {
660
- style: { width: "100%" },
661
- ...computedProps.input
662
- }
663
- ) }) }),
664
- /* @__PURE__ */ jsxRuntime.jsx(antd.Col, { span: 1, children: !((_a3 = computedProps.input) == null ? void 0 : _a3.disabled) && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ jsxRuntime.jsx(
665
- antd.Button,
666
- {
667
- danger: true,
668
- type: "link",
669
- style: { float: "right" },
670
- icon: /* @__PURE__ */ jsxRuntime.jsx(icons.MinusCircleOutlined, {}),
671
- onClick: () => remove(field.name)
672
- }
673
- ) })
674
- ] }) }, field.key);
675
- }),
676
- /* @__PURE__ */ jsxRuntime.jsxs(antd.Form.Item, { children: [
677
- !((_b = computedProps.input) == null ? void 0 : _b.disabled) && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ jsxRuntime.jsx(
678
- antd.Button,
679
- {
680
- type: "dashed",
681
- block: true,
682
- onClick: () => add(),
683
- icon: /* @__PURE__ */ jsxRuntime.jsx(icons.PlusOutlined, {})
684
- }
685
- ),
686
- computedProps.extra && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ant-form-item-extra", children: computedProps.extra }),
687
- /* @__PURE__ */ jsxRuntime.jsx(antd.Form.ErrorList, { errors })
688
- ] })
689
- ] });
690
- }
646
+ ) }) }),
647
+ /* @__PURE__ */ jsxRuntime.jsx(antd.Col, { span: 1, children: !computedProps.input?.disabled && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ jsxRuntime.jsx(
648
+ antd.Button,
649
+ {
650
+ danger: true,
651
+ type: "link",
652
+ style: { float: "right" },
653
+ icon: /* @__PURE__ */ jsxRuntime.jsx(icons.MinusCircleOutlined, {}),
654
+ onClick: () => remove(field.name)
655
+ }
656
+ ) })
657
+ ] }) }, field.key)),
658
+ /* @__PURE__ */ jsxRuntime.jsxs(antd.Form.Item, { children: [
659
+ !computedProps.input?.disabled && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ jsxRuntime.jsx(
660
+ antd.Button,
661
+ {
662
+ type: "dashed",
663
+ block: true,
664
+ onClick: () => add(),
665
+ icon: /* @__PURE__ */ jsxRuntime.jsx(icons.PlusOutlined, {})
666
+ }
667
+ ),
668
+ computedProps.extra && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ant-form-item-extra", children: computedProps.extra }),
669
+ /* @__PURE__ */ jsxRuntime.jsx(antd.Form.ErrorList, { errors })
670
+ ] })
671
+ ] })
691
672
  }
692
673
  );
693
674
  case "boolean":
@@ -706,7 +687,7 @@ function FormItem(props) {
706
687
  computedProps.label && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ant-form-item-label", children: /* @__PURE__ */ jsxRuntime.jsx(
707
688
  "label",
708
689
  {
709
- className: ((_a = computedProps.rules) == null ? void 0 : _a.find((r) => r.required)) && "ant-form-item-required",
690
+ className: computedProps.rules?.find((r) => r.required) && "ant-form-item-required",
710
691
  children: computedProps.label
711
692
  }
712
693
  ) }),
@@ -767,7 +748,6 @@ function isFormItemProps(item) {
767
748
  return item.id !== void 0;
768
749
  }
769
750
  function Form(props) {
770
- var _a, _b;
771
751
  const [loading, setLoading] = react$1.useState(false);
772
752
  const [computedProps, setComputedProps] = react$1.useState();
773
753
  const config = useConfigContext();
@@ -777,21 +757,20 @@ function Form(props) {
777
757
  props.initialValues
778
758
  );
779
759
  react$1.useEffect(() => {
780
- var _a2, _b2, _c;
781
760
  const propsCopy = {
782
761
  ...props,
783
762
  form
784
763
  };
785
- if (propsCopy.initialValues && ((_a2 = propsCopy.items) == null ? void 0 : _a2.length)) {
764
+ if (propsCopy.initialValues && propsCopy.items?.length) {
786
765
  for (const key in propsCopy.initialValues) {
787
766
  propsCopy.initialValues[key] = transferValue(
788
- (_b2 = propsCopy.items.find((item2) => isFormItemProps(item2) && item2.id === key)) == null ? void 0 : _b2.type,
767
+ propsCopy.items.find((item2) => isFormItemProps(item2) && item2.id === key)?.type,
789
768
  propsCopy.initialValues[key]
790
769
  );
791
770
  const item = propsCopy.items.find(
792
771
  (item2) => isFormItemProps(item2) && item2.id === key
793
772
  );
794
- if (item == null ? void 0 : item.if) item.hidden = !item.if(propsCopy.initialValues);
773
+ if (item?.if) item.hidden = !item.if(propsCopy.initialValues);
795
774
  }
796
775
  for (const item of propsCopy.items) {
797
776
  if (isFormItemProps(item) && item.if)
@@ -802,10 +781,9 @@ function Form(props) {
802
781
  }
803
782
  if (propsCopy.onFinish) {
804
783
  propsCopy.onFinish = async (values) => {
805
- var _a3, _b3;
806
784
  setLoading(true);
807
785
  try {
808
- if ((_b3 = (_a3 = propsCopy.submit) == null ? void 0 : _a3.to) == null ? void 0 : _b3.action) {
786
+ if (propsCopy.submit?.to?.action) {
809
787
  await props.onFinish(
810
788
  values,
811
789
  async (values2) => react.faas(
@@ -822,7 +800,7 @@ function Form(props) {
822
800
  }
823
801
  setLoading(false);
824
802
  };
825
- } else if (propsCopy.submit && ((_c = propsCopy.submit.to) == null ? void 0 : _c.action)) {
803
+ } else if (propsCopy.submit && propsCopy.submit.to?.action) {
826
804
  propsCopy.onFinish = async (values) => {
827
805
  setLoading(true);
828
806
  return react.faas(
@@ -863,7 +841,7 @@ function Form(props) {
863
841
  const item = computedProps.items.find(
864
842
  (i) => isFormItemProps(i) && i.id === key
865
843
  );
866
- if (item == null ? void 0 : item.onValueChange)
844
+ if (item?.onValueChange)
867
845
  item.onValueChange(changedValues[key], allValues, form);
868
846
  }
869
847
  },
@@ -878,13 +856,13 @@ function Form(props) {
878
856
  if (!computedProps) return null;
879
857
  return /* @__PURE__ */ jsxRuntime.jsxs(antd.Form, { ...computedProps, onValuesChange, children: [
880
858
  computedProps.beforeItems,
881
- (_a = computedProps.items) == null ? void 0 : _a.map((item) => {
859
+ computedProps.items?.map((item) => {
882
860
  if (isFormItemProps(item))
883
861
  return /* @__PURE__ */ jsxRuntime.jsx(FormItem, { ...item, extendTypes }, item.id);
884
862
  return item;
885
863
  }),
886
864
  computedProps.children,
887
- computedProps.submit !== false && /* @__PURE__ */ jsxRuntime.jsx(antd.Button, { htmlType: "submit", type: "primary", loading, children: ((_b = computedProps.submit) == null ? void 0 : _b.text) || config.theme.Form.submit.text }),
865
+ computedProps.submit !== false && /* @__PURE__ */ jsxRuntime.jsx(antd.Button, { htmlType: "submit", type: "primary", loading, children: computedProps.submit?.text || config.theme.Form.submit.text }),
888
866
  computedProps.footer
889
867
  ] });
890
868
  }
@@ -897,10 +875,9 @@ Form.List = antd.Form.List;
897
875
  Form.ErrorList = antd.Form.ErrorList;
898
876
  Form.Provider = antd.Form.Provider;
899
877
  function Link(props) {
900
- var _a, _b, _c;
901
878
  const { theme } = useConfigContext();
902
879
  const navigate = reactRouterDom.useNavigate();
903
- const target = props.target || ((_a = theme.Link) == null ? void 0 : _a.target) || (props.href.startsWith("http") ? "_blank" : void 0);
880
+ const target = props.target || theme.Link?.target || (props.href.startsWith("http") ? "_blank" : void 0);
904
881
  let computedStyle = {
905
882
  ...theme.Link.style || {},
906
883
  cursor: "pointer",
@@ -924,7 +901,7 @@ function Link(props) {
924
901
  props.onClick ? props.onClick(e) : target === "_blank" ? window.open(props.href) : navigate(props.href);
925
902
  e.preventDefault();
926
903
  },
927
- children: (_b = props.children) != null ? _b : props.text
904
+ children: props.children ?? props.text
928
905
  }
929
906
  );
930
907
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -946,7 +923,7 @@ function Link(props) {
946
923
  }
947
924
  navigate(props.href);
948
925
  },
949
- children: (_c = props.children) != null ? _c : props.text
926
+ children: props.children ?? props.text
950
927
  }
951
928
  );
952
929
  }
@@ -976,20 +953,16 @@ function Routes(props) {
976
953
  }
977
954
  Routes.whyDidYouRender = true;
978
955
  function processValue(item, value) {
979
- var _a;
980
956
  const transferred = transferValue(item.type, value);
981
957
  if (transferred === null || Array.isArray(transferred) && transferred.length === 0)
982
958
  return /* @__PURE__ */ jsxRuntime.jsx(Blank, {});
983
959
  if (item.options) {
984
960
  if (item.type.endsWith("[]"))
985
961
  return transferred.map(
986
- (v) => {
987
- var _a2;
988
- return ((_a2 = item.options.find((option) => option.value === v)) == null ? void 0 : _a2.label) || v;
989
- }
962
+ (v) => item.options.find((option) => option.value === v)?.label || v
990
963
  ).join(", ");
991
964
  if (["string", "number", "boolean"].includes(item.type))
992
- return ((_a = item.options.find((option) => option.value === transferred)) == null ? void 0 : _a.label) || transferred;
965
+ return item.options.find((option) => option.value === transferred)?.label || transferred;
993
966
  }
994
967
  if (item.type.endsWith("[]")) return transferred.join(", ");
995
968
  if (["date", "time"].includes(item.type))
@@ -1029,7 +1002,7 @@ function Table(props) {
1029
1002
  placeholder: `${theme.common.search} ${item.title}`,
1030
1003
  value: selectedKeys,
1031
1004
  onChange: (v) => {
1032
- setSelectedKeys((v == null ? void 0 : v.length) ? v : []);
1005
+ setSelectedKeys(v?.length ? v : []);
1033
1006
  confirm();
1034
1007
  },
1035
1008
  mode: "multiple",
@@ -1045,14 +1018,13 @@ function Table(props) {
1045
1018
  return item;
1046
1019
  };
1047
1020
  react$1.useEffect(() => {
1048
- var _a, _b, _c;
1049
1021
  const items = lodashEs.cloneDeep(props.items);
1050
1022
  for (const item of items) {
1051
1023
  if (!item.key) item.key = item.id;
1052
1024
  if (!item.dataIndex) item.dataIndex = item.id;
1053
1025
  if (!item.title) item.title = lodashEs.upperFirst(item.id);
1054
1026
  if (!item.type) item.type = "string";
1055
- if ((_a = item.options) == null ? void 0 : _a.length) {
1027
+ if (item.options?.length) {
1056
1028
  item.options = transferOptions(item.options);
1057
1029
  item.filters = item.options.map((o) => ({
1058
1030
  text: o.label,
@@ -1077,7 +1049,7 @@ function Table(props) {
1077
1049
  value,
1078
1050
  values
1079
1051
  });
1080
- if ((_b = props.extendTypes) == null ? void 0 : _b[item.type]) {
1052
+ if (props.extendTypes?.[item.type]) {
1081
1053
  if (props.extendTypes[item.type].children)
1082
1054
  item.render = (value, values) => react$1.cloneElement(props.extendTypes[item.type].children, {
1083
1055
  scene: "table",
@@ -1320,7 +1292,7 @@ function Table(props) {
1320
1292
  {
1321
1293
  onChange: (dates) => {
1322
1294
  setSelectedKeys(
1323
- (dates == null ? void 0 : dates[0]) && dates[1] ? [
1295
+ dates?.[0] && dates[1] ? [
1324
1296
  [
1325
1297
  dates[0].startOf("day").toISOString(),
1326
1298
  dates[1].endOf("day").toISOString()
@@ -1340,7 +1312,7 @@ function Table(props) {
1340
1312
  }
1341
1313
  break;
1342
1314
  case "time":
1343
- item.width = (_c = item.width) != null ? _c : 200;
1315
+ item.width = item.width ?? 200;
1344
1316
  if (!item.render) item.render = (value) => processValue(item, value);
1345
1317
  if (typeof item.sorter === "undefined")
1346
1318
  item.sorter = (a, b, order) => {
@@ -1355,7 +1327,7 @@ function Table(props) {
1355
1327
  {
1356
1328
  onChange: (dates) => {
1357
1329
  setSelectedKeys(
1358
- (dates == null ? void 0 : dates[0]) && dates[1] ? [
1330
+ dates?.[0] && dates[1] ? [
1359
1331
  [
1360
1332
  dates[0].startOf("day").toISOString(),
1361
1333
  dates[1].endOf("day").toISOString()
@@ -1453,10 +1425,9 @@ function FaasDataTable({
1453
1425
  react$1.useEffect(() => {
1454
1426
  if (!data || Array.isArray(data)) return;
1455
1427
  setCurrentColumns((prev) => {
1456
- var _a;
1457
1428
  const newColumns = [...prev];
1458
1429
  for (const column of newColumns) {
1459
- if ((_a = data.options) == null ? void 0 : _a[column.id]) {
1430
+ if (data.options?.[column.id]) {
1460
1431
  column.options = transferOptions(data.options[column.id]);
1461
1432
  column.filters = column.options.map((v) => ({
1462
1433
  text: v.label,
package/dist/index.mjs CHANGED
@@ -132,8 +132,7 @@ var ConfigContext = createContext({
132
132
  function ConfigProvider(props) {
133
133
  const [theme, setTheme] = useState();
134
134
  useEffect(() => {
135
- var _a;
136
- if (((_a = props.theme) == null ? void 0 : _a.lang) === "zh") {
135
+ if (props.theme?.lang === "zh") {
137
136
  setTheme(
138
137
  defaultsDeep(
139
138
  props.theme,
@@ -236,7 +235,7 @@ App.useApp = useApp;
236
235
  App.whyDidYouRender = true;
237
236
  function Blank(options) {
238
237
  const { theme } = useConfigContext();
239
- return !options || isNil(options.value) || Array.isArray(options.value) && !options.value.length || options.value === "" ? /* @__PURE__ */ jsx(Typography.Text, { disabled: true, children: (options == null ? void 0 : options.text) || theme.Blank.text }) : options.value;
238
+ return !options || isNil(options.value) || Array.isArray(options.value) && !options.value.length || options.value === "" ? /* @__PURE__ */ jsx(Typography.Text, { disabled: true, children: options?.text || theme.Blank.text }) : options.value;
240
239
  }
241
240
  Blank.whyDidYouRender = true;
242
241
  function transferOptions(options) {
@@ -310,33 +309,28 @@ function withFaasData(Component, faasProps) {
310
309
  });
311
310
  }
312
311
  function DescriptionItemContent(props) {
313
- var _a, _b;
314
312
  const [computedProps, setComputedProps] = useState();
315
313
  useEffect(() => {
316
- var _a2, _b2;
317
314
  const propsCopy = { ...props };
318
315
  if (!propsCopy.item.title)
319
316
  propsCopy.item.title = upperFirst(propsCopy.item.id);
320
317
  if (!propsCopy.item.type) propsCopy.item.type = "string";
321
- if ((_a2 = propsCopy.item.options) == null ? void 0 : _a2.length) {
318
+ if (propsCopy.item.options?.length) {
322
319
  propsCopy.item.options = transferOptions(propsCopy.item.options);
323
320
  }
324
321
  propsCopy.value = transferValue(propsCopy.item.type, propsCopy.value);
325
322
  if (propsCopy.item.options && propsCopy.value !== null) {
326
323
  if (propsCopy.item.type.endsWith("[]"))
327
324
  propsCopy.value = propsCopy.value.map(
328
- (v) => {
329
- var _a3;
330
- return ((_a3 = propsCopy.item.options.find((option) => option.value === v)) == null ? void 0 : _a3.label) || v;
331
- }
325
+ (v) => propsCopy.item.options.find((option) => option.value === v)?.label || v
332
326
  );
333
327
  else if (["string", "number", "boolean"].includes(propsCopy.item.type))
334
- propsCopy.value = ((_b2 = props.item.options.find((option) => option.value === props.value)) == null ? void 0 : _b2.label) || props.value;
328
+ propsCopy.value = props.item.options.find((option) => option.value === props.value)?.label || props.value;
335
329
  }
336
330
  setComputedProps(propsCopy);
337
331
  }, [props]);
338
332
  if (!computedProps) return null;
339
- if ((_a = computedProps.extendTypes) == null ? void 0 : _a[computedProps.item.type]) {
333
+ if (computedProps.extendTypes?.[computedProps.item.type]) {
340
334
  if (computedProps.extendTypes[computedProps.item.type].children)
341
335
  return cloneElement(
342
336
  computedProps.extendTypes[computedProps.item.type].children,
@@ -425,7 +419,7 @@ function DescriptionItemContent(props) {
425
419
  }
426
420
  );
427
421
  case "object[]":
428
- if (!((_b = computedProps.value) == null ? void 0 : _b.length))
422
+ if (!computedProps.value?.length)
429
423
  return /* @__PURE__ */ jsx(Blank, {});
430
424
  return /* @__PURE__ */ jsx(Space, { direction: "vertical", children: computedProps.value.map(
431
425
  (value, index) => /* @__PURE__ */ jsx(
@@ -520,7 +514,6 @@ function processProps(propsCopy, config) {
520
514
  return propsCopy;
521
515
  }
522
516
  function FormItem(props) {
523
- var _a;
524
517
  const [computedProps, setComputedProps] = useState();
525
518
  const [extendTypes, setExtendTypes] = useState();
526
519
  const { theme } = useConfigContext();
@@ -549,7 +542,7 @@ function FormItem(props) {
549
542
  if (!computedProps) return null;
550
543
  if (hidden)
551
544
  return /* @__PURE__ */ jsx(Form$1.Item, { ...computedProps, noStyle: true, rules: [], children: /* @__PURE__ */ jsx(Input, { hidden: true }) });
552
- if (extendTypes == null ? void 0 : extendTypes[computedProps.type])
545
+ if (extendTypes?.[computedProps.type])
553
546
  return /* @__PURE__ */ jsx(Form$1.Item, { ...computedProps, children: extendTypes[computedProps.type].children });
554
547
  if (computedProps.formChildren === null) return null;
555
548
  if (computedProps.formChildren)
@@ -574,47 +567,41 @@ function FormItem(props) {
574
567
  {
575
568
  name: computedProps.name,
576
569
  rules: computedProps.rules,
577
- children: (fields, { add, remove }, { errors }) => {
578
- var _a2;
579
- return /* @__PURE__ */ jsxs(Fragment, { children: [
580
- computedProps.label && /* @__PURE__ */ jsx("div", { className: "ant-form-item-label", children: /* @__PURE__ */ jsx(
581
- "label",
570
+ children: (fields, { add, remove }, { errors }) => /* @__PURE__ */ jsxs(Fragment, { children: [
571
+ computedProps.label && /* @__PURE__ */ jsx("div", { className: "ant-form-item-label", children: /* @__PURE__ */ jsx(
572
+ "label",
573
+ {
574
+ className: computedProps.rules.find((r) => r.required) && "ant-form-item-required",
575
+ children: computedProps.label
576
+ }
577
+ ) }),
578
+ fields.map((field) => /* @__PURE__ */ jsx(Form$1.Item, { children: /* @__PURE__ */ jsxs(Row, { gutter: 24, style: { flexFlow: "row nowrap" }, children: [
579
+ /* @__PURE__ */ jsx(Col, { span: 23, children: /* @__PURE__ */ jsx(Form$1.Item, { ...field, noStyle: true, children: /* @__PURE__ */ jsx(Input, { ...computedProps.input }) }) }),
580
+ /* @__PURE__ */ jsx(Col, { span: 1, children: !computedProps.input?.disabled && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ jsx(
581
+ Button,
582
582
  {
583
- className: computedProps.rules.find((r) => r.required) && "ant-form-item-required",
584
- children: computedProps.label
583
+ danger: true,
584
+ type: "link",
585
+ style: { float: "right" },
586
+ icon: /* @__PURE__ */ jsx(MinusCircleOutlined, {}),
587
+ onClick: () => remove(field.name)
585
588
  }
586
- ) }),
587
- fields.map((field) => {
588
- var _a3;
589
- return /* @__PURE__ */ jsx(Form$1.Item, { children: /* @__PURE__ */ jsxs(Row, { gutter: 24, style: { flexFlow: "row nowrap" }, children: [
590
- /* @__PURE__ */ jsx(Col, { span: 23, children: /* @__PURE__ */ jsx(Form$1.Item, { ...field, noStyle: true, children: /* @__PURE__ */ jsx(Input, { ...computedProps.input }) }) }),
591
- /* @__PURE__ */ jsx(Col, { span: 1, children: !((_a3 = computedProps.input) == null ? void 0 : _a3.disabled) && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ jsx(
592
- Button,
593
- {
594
- danger: true,
595
- type: "link",
596
- style: { float: "right" },
597
- icon: /* @__PURE__ */ jsx(MinusCircleOutlined, {}),
598
- onClick: () => remove(field.name)
599
- }
600
- ) })
601
- ] }) }, field.key);
602
- }),
603
- /* @__PURE__ */ jsxs(Form$1.Item, { children: [
604
- !((_a2 = computedProps.input) == null ? void 0 : _a2.disabled) && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ jsx(
605
- Button,
606
- {
607
- type: "dashed",
608
- block: true,
609
- onClick: () => add(),
610
- icon: /* @__PURE__ */ jsx(PlusOutlined, {})
611
- }
612
- ),
613
- computedProps.extra && /* @__PURE__ */ jsx("div", { className: "ant-form-item-extra", children: computedProps.extra }),
614
- /* @__PURE__ */ jsx(Form$1.ErrorList, { errors })
615
- ] })
616
- ] });
617
- }
589
+ ) })
590
+ ] }) }, field.key)),
591
+ /* @__PURE__ */ jsxs(Form$1.Item, { children: [
592
+ !computedProps.input?.disabled && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ jsx(
593
+ Button,
594
+ {
595
+ type: "dashed",
596
+ block: true,
597
+ onClick: () => add(),
598
+ icon: /* @__PURE__ */ jsx(PlusOutlined, {})
599
+ }
600
+ ),
601
+ computedProps.extra && /* @__PURE__ */ jsx("div", { className: "ant-form-item-extra", children: computedProps.extra }),
602
+ /* @__PURE__ */ jsx(Form$1.ErrorList, { errors })
603
+ ] })
604
+ ] })
618
605
  }
619
606
  );
620
607
  case "number":
@@ -635,55 +622,49 @@ function FormItem(props) {
635
622
  {
636
623
  name: computedProps.name,
637
624
  rules: computedProps.rules,
638
- children: (fields, { add, remove }, { errors }) => {
639
- var _a2, _b;
640
- return /* @__PURE__ */ jsxs(Fragment, { children: [
641
- computedProps.label && /* @__PURE__ */ jsx("div", { className: "ant-form-item-label", children: /* @__PURE__ */ jsx(
642
- "label",
625
+ children: (fields, { add, remove }, { errors }) => /* @__PURE__ */ jsxs(Fragment, { children: [
626
+ computedProps.label && /* @__PURE__ */ jsx("div", { className: "ant-form-item-label", children: /* @__PURE__ */ jsx(
627
+ "label",
628
+ {
629
+ className: computedProps.rules?.find(
630
+ (r) => r.required
631
+ ) && "ant-form-item-required",
632
+ children: computedProps.label
633
+ }
634
+ ) }),
635
+ fields.map((field) => /* @__PURE__ */ jsx(Form$1.Item, { children: /* @__PURE__ */ jsxs(Row, { gutter: 24, style: { flexFlow: "row nowrap" }, children: [
636
+ /* @__PURE__ */ jsx(Col, { span: 23, children: /* @__PURE__ */ jsx(Form$1.Item, { ...field, noStyle: true, children: /* @__PURE__ */ jsx(
637
+ InputNumber,
643
638
  {
644
- className: ((_a2 = computedProps.rules) == null ? void 0 : _a2.find(
645
- (r) => r.required
646
- )) && "ant-form-item-required",
647
- children: computedProps.label
639
+ style: { width: "100%" },
640
+ ...computedProps.input
648
641
  }
649
- ) }),
650
- fields.map((field) => {
651
- var _a3;
652
- return /* @__PURE__ */ jsx(Form$1.Item, { children: /* @__PURE__ */ jsxs(Row, { gutter: 24, style: { flexFlow: "row nowrap" }, children: [
653
- /* @__PURE__ */ jsx(Col, { span: 23, children: /* @__PURE__ */ jsx(Form$1.Item, { ...field, noStyle: true, children: /* @__PURE__ */ jsx(
654
- InputNumber,
655
- {
656
- style: { width: "100%" },
657
- ...computedProps.input
658
- }
659
- ) }) }),
660
- /* @__PURE__ */ jsx(Col, { span: 1, children: !((_a3 = computedProps.input) == null ? void 0 : _a3.disabled) && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ jsx(
661
- Button,
662
- {
663
- danger: true,
664
- type: "link",
665
- style: { float: "right" },
666
- icon: /* @__PURE__ */ jsx(MinusCircleOutlined, {}),
667
- onClick: () => remove(field.name)
668
- }
669
- ) })
670
- ] }) }, field.key);
671
- }),
672
- /* @__PURE__ */ jsxs(Form$1.Item, { children: [
673
- !((_b = computedProps.input) == null ? void 0 : _b.disabled) && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ jsx(
674
- Button,
675
- {
676
- type: "dashed",
677
- block: true,
678
- onClick: () => add(),
679
- icon: /* @__PURE__ */ jsx(PlusOutlined, {})
680
- }
681
- ),
682
- computedProps.extra && /* @__PURE__ */ jsx("div", { className: "ant-form-item-extra", children: computedProps.extra }),
683
- /* @__PURE__ */ jsx(Form$1.ErrorList, { errors })
684
- ] })
685
- ] });
686
- }
642
+ ) }) }),
643
+ /* @__PURE__ */ jsx(Col, { span: 1, children: !computedProps.input?.disabled && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ jsx(
644
+ Button,
645
+ {
646
+ danger: true,
647
+ type: "link",
648
+ style: { float: "right" },
649
+ icon: /* @__PURE__ */ jsx(MinusCircleOutlined, {}),
650
+ onClick: () => remove(field.name)
651
+ }
652
+ ) })
653
+ ] }) }, field.key)),
654
+ /* @__PURE__ */ jsxs(Form$1.Item, { children: [
655
+ !computedProps.input?.disabled && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ jsx(
656
+ Button,
657
+ {
658
+ type: "dashed",
659
+ block: true,
660
+ onClick: () => add(),
661
+ icon: /* @__PURE__ */ jsx(PlusOutlined, {})
662
+ }
663
+ ),
664
+ computedProps.extra && /* @__PURE__ */ jsx("div", { className: "ant-form-item-extra", children: computedProps.extra }),
665
+ /* @__PURE__ */ jsx(Form$1.ErrorList, { errors })
666
+ ] })
667
+ ] })
687
668
  }
688
669
  );
689
670
  case "boolean":
@@ -702,7 +683,7 @@ function FormItem(props) {
702
683
  computedProps.label && /* @__PURE__ */ jsx("div", { className: "ant-form-item-label", children: /* @__PURE__ */ jsx(
703
684
  "label",
704
685
  {
705
- className: ((_a = computedProps.rules) == null ? void 0 : _a.find((r) => r.required)) && "ant-form-item-required",
686
+ className: computedProps.rules?.find((r) => r.required) && "ant-form-item-required",
706
687
  children: computedProps.label
707
688
  }
708
689
  ) }),
@@ -763,7 +744,6 @@ function isFormItemProps(item) {
763
744
  return item.id !== void 0;
764
745
  }
765
746
  function Form(props) {
766
- var _a, _b;
767
747
  const [loading, setLoading] = useState(false);
768
748
  const [computedProps, setComputedProps] = useState();
769
749
  const config = useConfigContext();
@@ -773,21 +753,20 @@ function Form(props) {
773
753
  props.initialValues
774
754
  );
775
755
  useEffect(() => {
776
- var _a2, _b2, _c;
777
756
  const propsCopy = {
778
757
  ...props,
779
758
  form
780
759
  };
781
- if (propsCopy.initialValues && ((_a2 = propsCopy.items) == null ? void 0 : _a2.length)) {
760
+ if (propsCopy.initialValues && propsCopy.items?.length) {
782
761
  for (const key in propsCopy.initialValues) {
783
762
  propsCopy.initialValues[key] = transferValue(
784
- (_b2 = propsCopy.items.find((item2) => isFormItemProps(item2) && item2.id === key)) == null ? void 0 : _b2.type,
763
+ propsCopy.items.find((item2) => isFormItemProps(item2) && item2.id === key)?.type,
785
764
  propsCopy.initialValues[key]
786
765
  );
787
766
  const item = propsCopy.items.find(
788
767
  (item2) => isFormItemProps(item2) && item2.id === key
789
768
  );
790
- if (item == null ? void 0 : item.if) item.hidden = !item.if(propsCopy.initialValues);
769
+ if (item?.if) item.hidden = !item.if(propsCopy.initialValues);
791
770
  }
792
771
  for (const item of propsCopy.items) {
793
772
  if (isFormItemProps(item) && item.if)
@@ -798,10 +777,9 @@ function Form(props) {
798
777
  }
799
778
  if (propsCopy.onFinish) {
800
779
  propsCopy.onFinish = async (values) => {
801
- var _a3, _b3;
802
780
  setLoading(true);
803
781
  try {
804
- if ((_b3 = (_a3 = propsCopy.submit) == null ? void 0 : _a3.to) == null ? void 0 : _b3.action) {
782
+ if (propsCopy.submit?.to?.action) {
805
783
  await props.onFinish(
806
784
  values,
807
785
  async (values2) => faas(
@@ -818,7 +796,7 @@ function Form(props) {
818
796
  }
819
797
  setLoading(false);
820
798
  };
821
- } else if (propsCopy.submit && ((_c = propsCopy.submit.to) == null ? void 0 : _c.action)) {
799
+ } else if (propsCopy.submit && propsCopy.submit.to?.action) {
822
800
  propsCopy.onFinish = async (values) => {
823
801
  setLoading(true);
824
802
  return faas(
@@ -859,7 +837,7 @@ function Form(props) {
859
837
  const item = computedProps.items.find(
860
838
  (i) => isFormItemProps(i) && i.id === key
861
839
  );
862
- if (item == null ? void 0 : item.onValueChange)
840
+ if (item?.onValueChange)
863
841
  item.onValueChange(changedValues[key], allValues, form);
864
842
  }
865
843
  },
@@ -874,13 +852,13 @@ function Form(props) {
874
852
  if (!computedProps) return null;
875
853
  return /* @__PURE__ */ jsxs(Form$1, { ...computedProps, onValuesChange, children: [
876
854
  computedProps.beforeItems,
877
- (_a = computedProps.items) == null ? void 0 : _a.map((item) => {
855
+ computedProps.items?.map((item) => {
878
856
  if (isFormItemProps(item))
879
857
  return /* @__PURE__ */ jsx(FormItem, { ...item, extendTypes }, item.id);
880
858
  return item;
881
859
  }),
882
860
  computedProps.children,
883
- computedProps.submit !== false && /* @__PURE__ */ jsx(Button, { htmlType: "submit", type: "primary", loading, children: ((_b = computedProps.submit) == null ? void 0 : _b.text) || config.theme.Form.submit.text }),
861
+ computedProps.submit !== false && /* @__PURE__ */ jsx(Button, { htmlType: "submit", type: "primary", loading, children: computedProps.submit?.text || config.theme.Form.submit.text }),
884
862
  computedProps.footer
885
863
  ] });
886
864
  }
@@ -893,10 +871,9 @@ Form.List = Form$1.List;
893
871
  Form.ErrorList = Form$1.ErrorList;
894
872
  Form.Provider = Form$1.Provider;
895
873
  function Link(props) {
896
- var _a, _b, _c;
897
874
  const { theme } = useConfigContext();
898
875
  const navigate = useNavigate();
899
- const target = props.target || ((_a = theme.Link) == null ? void 0 : _a.target) || (props.href.startsWith("http") ? "_blank" : void 0);
876
+ const target = props.target || theme.Link?.target || (props.href.startsWith("http") ? "_blank" : void 0);
900
877
  let computedStyle = {
901
878
  ...theme.Link.style || {},
902
879
  cursor: "pointer",
@@ -920,7 +897,7 @@ function Link(props) {
920
897
  props.onClick ? props.onClick(e) : target === "_blank" ? window.open(props.href) : navigate(props.href);
921
898
  e.preventDefault();
922
899
  },
923
- children: (_b = props.children) != null ? _b : props.text
900
+ children: props.children ?? props.text
924
901
  }
925
902
  );
926
903
  return /* @__PURE__ */ jsx(
@@ -942,7 +919,7 @@ function Link(props) {
942
919
  }
943
920
  navigate(props.href);
944
921
  },
945
- children: (_c = props.children) != null ? _c : props.text
922
+ children: props.children ?? props.text
946
923
  }
947
924
  );
948
925
  }
@@ -972,20 +949,16 @@ function Routes(props) {
972
949
  }
973
950
  Routes.whyDidYouRender = true;
974
951
  function processValue(item, value) {
975
- var _a;
976
952
  const transferred = transferValue(item.type, value);
977
953
  if (transferred === null || Array.isArray(transferred) && transferred.length === 0)
978
954
  return /* @__PURE__ */ jsx(Blank, {});
979
955
  if (item.options) {
980
956
  if (item.type.endsWith("[]"))
981
957
  return transferred.map(
982
- (v) => {
983
- var _a2;
984
- return ((_a2 = item.options.find((option) => option.value === v)) == null ? void 0 : _a2.label) || v;
985
- }
958
+ (v) => item.options.find((option) => option.value === v)?.label || v
986
959
  ).join(", ");
987
960
  if (["string", "number", "boolean"].includes(item.type))
988
- return ((_a = item.options.find((option) => option.value === transferred)) == null ? void 0 : _a.label) || transferred;
961
+ return item.options.find((option) => option.value === transferred)?.label || transferred;
989
962
  }
990
963
  if (item.type.endsWith("[]")) return transferred.join(", ");
991
964
  if (["date", "time"].includes(item.type))
@@ -1025,7 +998,7 @@ function Table(props) {
1025
998
  placeholder: `${theme.common.search} ${item.title}`,
1026
999
  value: selectedKeys,
1027
1000
  onChange: (v) => {
1028
- setSelectedKeys((v == null ? void 0 : v.length) ? v : []);
1001
+ setSelectedKeys(v?.length ? v : []);
1029
1002
  confirm();
1030
1003
  },
1031
1004
  mode: "multiple",
@@ -1041,14 +1014,13 @@ function Table(props) {
1041
1014
  return item;
1042
1015
  };
1043
1016
  useEffect(() => {
1044
- var _a, _b, _c;
1045
1017
  const items = cloneDeep(props.items);
1046
1018
  for (const item of items) {
1047
1019
  if (!item.key) item.key = item.id;
1048
1020
  if (!item.dataIndex) item.dataIndex = item.id;
1049
1021
  if (!item.title) item.title = upperFirst(item.id);
1050
1022
  if (!item.type) item.type = "string";
1051
- if ((_a = item.options) == null ? void 0 : _a.length) {
1023
+ if (item.options?.length) {
1052
1024
  item.options = transferOptions(item.options);
1053
1025
  item.filters = item.options.map((o) => ({
1054
1026
  text: o.label,
@@ -1073,7 +1045,7 @@ function Table(props) {
1073
1045
  value,
1074
1046
  values
1075
1047
  });
1076
- if ((_b = props.extendTypes) == null ? void 0 : _b[item.type]) {
1048
+ if (props.extendTypes?.[item.type]) {
1077
1049
  if (props.extendTypes[item.type].children)
1078
1050
  item.render = (value, values) => cloneElement(props.extendTypes[item.type].children, {
1079
1051
  scene: "table",
@@ -1316,7 +1288,7 @@ function Table(props) {
1316
1288
  {
1317
1289
  onChange: (dates) => {
1318
1290
  setSelectedKeys(
1319
- (dates == null ? void 0 : dates[0]) && dates[1] ? [
1291
+ dates?.[0] && dates[1] ? [
1320
1292
  [
1321
1293
  dates[0].startOf("day").toISOString(),
1322
1294
  dates[1].endOf("day").toISOString()
@@ -1336,7 +1308,7 @@ function Table(props) {
1336
1308
  }
1337
1309
  break;
1338
1310
  case "time":
1339
- item.width = (_c = item.width) != null ? _c : 200;
1311
+ item.width = item.width ?? 200;
1340
1312
  if (!item.render) item.render = (value) => processValue(item, value);
1341
1313
  if (typeof item.sorter === "undefined")
1342
1314
  item.sorter = (a, b, order) => {
@@ -1351,7 +1323,7 @@ function Table(props) {
1351
1323
  {
1352
1324
  onChange: (dates) => {
1353
1325
  setSelectedKeys(
1354
- (dates == null ? void 0 : dates[0]) && dates[1] ? [
1326
+ dates?.[0] && dates[1] ? [
1355
1327
  [
1356
1328
  dates[0].startOf("day").toISOString(),
1357
1329
  dates[1].endOf("day").toISOString()
@@ -1449,10 +1421,9 @@ function FaasDataTable({
1449
1421
  useEffect(() => {
1450
1422
  if (!data || Array.isArray(data)) return;
1451
1423
  setCurrentColumns((prev) => {
1452
- var _a;
1453
1424
  const newColumns = [...prev];
1454
1425
  for (const column of newColumns) {
1455
- if ((_a = data.options) == null ? void 0 : _a[column.id]) {
1426
+ if (data.options?.[column.id]) {
1456
1427
  column.options = transferOptions(data.options[column.id]);
1457
1428
  column.filters = column.options.map((v) => ({
1458
1429
  text: v.label,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faasjs/ant-design",
3
- "version": "2.8.1",
3
+ "version": "3.0.0-canary.1",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -38,7 +38,7 @@
38
38
  "lodash-es": "*"
39
39
  },
40
40
  "peerDependencies": {
41
- "@faasjs/react": "2.8.1",
41
+ "@faasjs/react": "3.0.0-canary.1",
42
42
  "antd": "*",
43
43
  "react": "*",
44
44
  "react-dom": "*",
@@ -46,14 +46,14 @@
46
46
  },
47
47
  "devDependencies": {
48
48
  "@types/lodash-es": "*",
49
- "@faasjs/react": "2.8.1",
49
+ "@faasjs/react": "3.0.0-canary.1",
50
50
  "antd": "*",
51
51
  "react": "*",
52
52
  "react-dom": "*",
53
53
  "react-router-dom": "*"
54
54
  },
55
55
  "engines": {
56
- "npm": ">=9.0.0",
57
- "node": ">=18.0.0"
56
+ "node": ">=22.0.0",
57
+ "npm": ">=10.0.0"
58
58
  }
59
59
  }