@faasjs/ant-design 8.0.0-beta.34 → 8.0.0-beta.36

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.ts CHANGED
@@ -1,19 +1,11 @@
1
1
  import { ErrorBoundaryProps, FaasDataInjection, FaasDataInjection as FaasDataInjection$1, FaasDataWrapperProps as FaasDataWrapperProps$1, FaasDataWrapperRef, FaasReactClient, FaasReactClientOptions, faas, useFaas } from "@faasjs/react";
2
2
  import { ButtonProps, ConfigProviderProps as ConfigProviderProps$1, DatePickerProps, DescriptionsProps, Drawer, DrawerProps as DrawerProps$1, FormInstance, FormItemProps as FormItemProps$1, FormProps as FormProps$1, GlobalToken, InputNumberProps, InputProps, Modal, ModalProps as ModalProps$1, RadioProps, SelectProps, SwitchProps, TableColumnProps, TablePaginationConfig, TableProps as TableProps$1, TabsProps as TabsProps$1 } from "antd";
3
3
  import { BrowserRouterProps, RouteProps } from "react-router-dom";
4
- import * as _$react from "react";
5
4
  import { CSSProperties, ComponentType, Dispatch, FC, JSX, LazyExoticComponent, ReactElement, ReactNode, SetStateAction, lazy } from "react";
6
- import * as _$react_jsx_runtime0 from "react/jsx-runtime";
7
5
  import { Dayjs } from "dayjs";
8
6
  import { FaasActionPaths, FaasParams } from "@faasjs/types";
9
- import * as _$antd_es_form0 from "antd/es/form/index.js";
10
7
  import { RuleObject } from "antd/es/form/index.js";
11
8
  import { FilterValue, SorterResult, TableCurrentDataSource } from "antd/es/table/interface.js";
12
- import * as _$antd_es_form_Form0 from "antd/es/form/Form.js";
13
- import * as _$antd_es_form_hooks_useFormInstance0 from "antd/es/form/hooks/useFormInstance.js";
14
- import * as _$_rc_component_form0 from "@rc-component/form";
15
- import * as _$antd_es_form_context0 from "antd/es/form/context.js";
16
- import * as _$antd_es_form_FormItem0 from "antd/es/form/FormItem/index.js";
17
9
  import { Tab } from "@rc-component/tabs/lib/interface.js";
18
10
  import { MessageInstance } from "antd/es/message/interface.js";
19
11
  import { NotificationInstance } from "antd/es/notification/interface.js";
@@ -59,7 +51,7 @@ type LoadingProps = {
59
51
  * }
60
52
  * ```
61
53
  */
62
- declare function Loading(props: LoadingProps): _$react_jsx_runtime0.JSX.Element;
54
+ declare function Loading(props: LoadingProps): import("react").JSX.Element;
63
55
  //#endregion
64
56
  //#region src/FaasDataWrapper/index.d.ts
65
57
  /**
@@ -299,7 +291,7 @@ interface ConfigProviderProps {
299
291
  * }
300
292
  * ```
301
293
  */
302
- declare const ConfigContext: _$react.Context<ConfigContextValue>;
294
+ declare const ConfigContext: import("react").Context<ConfigContextValue>;
303
295
  /**
304
296
  * Provide theme overrides and optional FaasJS client initialization for descendants.
305
297
  *
@@ -330,7 +322,7 @@ declare const ConfigContext: _$react.Context<ConfigContextValue>;
330
322
  * }
331
323
  * ```
332
324
  */
333
- declare function ConfigProvider(props: ConfigProviderProps): _$react_jsx_runtime0.JSX.Element | null;
325
+ declare function ConfigProvider(props: ConfigProviderProps): import("react").JSX.Element | null;
334
326
  /**
335
327
  * Read the current `@faasjs/ant-design` config context.
336
328
  *
@@ -389,7 +381,7 @@ declare function useConfigContext(): ConfigContextValue;
389
381
  * }
390
382
  * ```
391
383
  */
392
- declare function ErrorBoundary(props: ErrorBoundaryProps): _$react_jsx_runtime0.JSX.Element;
384
+ declare function ErrorBoundary(props: ErrorBoundaryProps): import("react").JSX.Element;
393
385
  //#endregion
394
386
  //#region src/App/index.d.ts
395
387
  /**
@@ -458,7 +450,7 @@ declare function createOnErrorHandler(messageApi: {
458
450
  * }
459
451
  * ```
460
452
  */
461
- declare function App(props: AppProps): _$react_jsx_runtime0.JSX.Element;
453
+ declare function App(props: AppProps): import("react").JSX.Element;
462
454
  //#endregion
463
455
  //#region src/Blank/index.d.ts
464
456
  /**
@@ -490,10 +482,23 @@ interface BlankProps {
490
482
  declare function Blank(options?: BlankProps): JSX.Element;
491
483
  //#endregion
492
484
  //#region src/FormItem/types.d.ts
485
+ /**
486
+ * Type-level extension payload for custom form item types.
487
+ *
488
+ * @template T - Value type rendered or edited by the form item.
489
+ */
493
490
  type ExtendFormTypeProps<T = any> = BaseExtendTypeProps<T>;
491
+ /**
492
+ * Dictionary of custom form item type renderers keyed by item type name.
493
+ */
494
494
  type ExtendTypes = {
495
495
  [type: string]: ExtendFormTypeProps;
496
496
  };
497
+ /**
498
+ * Map from {@link FaasItemType} to the Ant Design input component props accepted by {@link FormItem}.
499
+ *
500
+ * @template T - Value type rendered or edited by the form item.
501
+ */
497
502
  type InputTypeMap<T> = {
498
503
  string: InputProps | SelectProps<T> | RadioProps;
499
504
  'string[]': InputProps | SelectProps<T> | RadioProps;
@@ -505,24 +510,51 @@ type InputTypeMap<T> = {
505
510
  object: never;
506
511
  'object[]': never;
507
512
  };
513
+ /**
514
+ * Props for the {@link FormItem} component.
515
+ *
516
+ * Each field can render as a single form control, a list of controls, or a nested object/object-list
517
+ * group of child form items.
518
+ *
519
+ * @template T - Value type rendered or edited by the form item.
520
+ */
508
521
  interface FormItemProps<T = any> extends BaseItemProps, Omit<FormItemProps$1<T>, 'id' | 'children' | 'render'> {
522
+ /** Item type that determines which Ant Design control is rendered. */
509
523
  type?: FaasItemType;
524
+ /** Props forwarded to the Ant Design input component used for this field. */
510
525
  input?: InputTypeMap<T>[FaasItemType];
526
+ /** Maximum number of entries allowed in a list item. */
511
527
  maxCount?: number;
528
+ /** Nested item definitions used by `object` and `object[]` item types. */
512
529
  object?: FormItemProps[];
530
+ /** Whether the field is disabled. */
513
531
  disabled?: boolean;
532
+ /** Whether the field is required. When `true`, a required validation rule is appended. */
514
533
  required?: boolean;
534
+ /** Number of columns taken by this field in the Ant Design grid. */
515
535
  col?: number;
536
+ /** Generic custom element rendered when no form-specific child overrides it. */
516
537
  children?: UnionFaasItemElement<T> | null;
538
+ /** Form-specific custom element. */
517
539
  formChildren?: UnionFaasItemElement<T> | null;
540
+ /** Generic custom render callback. */
518
541
  render?: UnionFaasItemRender<T> | null;
542
+ /** Form-specific custom render callback. */
519
543
  formRender?: UnionFaasItemRender<T> | null;
544
+ /** Validation rules appended to the field. */
520
545
  rules?: RuleObject[];
546
+ /** Field label text, or `false` to hide the label. */
521
547
  label?: string | false;
548
+ /** Custom type renderers keyed by item type. */
522
549
  extendTypes?: ExtendTypes;
550
+ /** Called when the field value changes. */
523
551
  onValueChange?: (value: T, values: any, form: FormInstance) => void;
552
+ /** Conditional visibility predicate. When `false`, the field is hidden and rendered as a hidden input. */
524
553
  if?: (values: Record<string, any>) => boolean;
525
554
  }
555
+ /**
556
+ * Extensible form item props that accept any string `type`.
557
+ */
526
558
  interface ExtendFormItemProps extends Omit<FormItemProps, 'type'> {
527
559
  type?: string;
528
560
  }
@@ -547,6 +579,11 @@ interface TableItemProps<T = any> extends FaasItemProps, Omit<TableColumnProps<T
547
579
  /** Nested item definitions used by `object` and `object[]` item types. */
548
580
  object?: TableItemProps<T>[];
549
581
  }
582
+ /**
583
+ * Type-level extension payload for custom table column types.
584
+ *
585
+ * @template T - Row record type rendered by the table.
586
+ */
550
587
  type ExtendTableTypeProps<T = any> = BaseExtendTypeProps<T>;
551
588
  /**
552
589
  * Shared fields for extending table item unions.
@@ -605,7 +642,15 @@ type TableFaasDataResponse<T = any> = {
605
642
  };
606
643
  //#endregion
607
644
  //#region src/data/types.d.ts
645
+ /**
646
+ * Supported item types used across {@link Form}, {@link Description}, and {@link Table}.
647
+ *
648
+ * Each type maps to a built-in Ant Design control or a nested renderer for `object` and `object[]`.
649
+ */
608
650
  type FaasItemType = 'string' | 'string[]' | 'number' | 'number[]' | 'boolean' | 'date' | 'time' | 'object' | 'object[]';
651
+ /**
652
+ * Map from {@link FaasItemType} to the expected JavaScript value type.
653
+ */
609
654
  type FaasItemTypeValue = {
610
655
  string: string;
611
656
  'string[]': string[];
@@ -617,68 +662,162 @@ type FaasItemTypeValue = {
617
662
  object: any;
618
663
  'object[]': any[];
619
664
  };
665
+ /**
666
+ * Accepted form of a select/dropdown option before normalization.
667
+ */
620
668
  type BaseOption = string | number | {
621
669
  label: string;
622
670
  value?: any;
623
671
  };
672
+ /**
673
+ * Minimal common shape shared by all item definition types.
674
+ */
624
675
  interface BaseItemProps {
625
676
  id: string | number;
626
677
  title?: string;
627
678
  options?: BaseOption[];
628
679
  }
680
+ /**
681
+ * Minimal FaasJS-aware item definition that includes an optional type.
682
+ */
629
683
  interface FaasItemProps extends BaseItemProps {
630
684
  type?: FaasItemType;
631
685
  }
686
+ /**
687
+ * Rendering surface that determines the available per-type defaults.
688
+ */
632
689
  type UnionScene = 'form' | 'description' | 'table';
690
+ /**
691
+ * Props injected into a {@link UnionFaasItemElement} by the rendering host.
692
+ */
633
693
  type UnionFaasItemInjection<Value = any, Values = any> = {
634
694
  scene?: UnionScene;
635
695
  value?: Value;
636
696
  values?: Values;
637
697
  index?: number;
638
698
  };
699
+ /**
700
+ * Render callback shared by form items, description items, and table columns.
701
+ *
702
+ * @param value - Normalized value for the field or column.
703
+ * @param values - Full record for the current row or form.
704
+ * @param index - Position of the item inside a list (always 0 for single items).
705
+ * @param scene - Rendering surface that triggered the callback.
706
+ */
639
707
  type UnionFaasItemRender<Value = any, Values = any> = (value: Value, values: Values, index: number, scene: UnionScene) => React.ReactNode;
708
+ /**
709
+ * Shared element type accepted by `children` and `render` props across all surfaces.
710
+ */
640
711
  type UnionFaasItemElement<Value = any, Values = any> = ReactElement<UnionFaasItemInjection<Value, Values>> | FC<UnionFaasItemInjection<Value, Values>>;
712
+ /**
713
+ * Combined item props that spans form, description, and table definitions.
714
+ */
641
715
  interface UnionFaasItemProps<Value = any, Values = any> extends FormItemProps, DescriptionItemProps, TableItemProps {
642
716
  children?: UnionFaasItemElement<Value, Values> | null;
643
717
  render?: UnionFaasItemRender<Value, Values> | null;
644
718
  object?: UnionFaasItemProps<Value, Values>[];
645
719
  }
720
+ /**
721
+ * Base shape for custom item type definitions accepted by `extendTypes`.
722
+ *
723
+ * @template T - Value type rendered or edited by the custom type.
724
+ */
646
725
  type BaseExtendTypeProps<T = any> = {
647
726
  children?: UnionFaasItemElement<T>;
648
727
  render?: UnionFaasItemRender<T>;
649
728
  };
650
729
  //#endregion
651
730
  //#region src/Description/types.d.ts
731
+ /**
732
+ * Type-level extension payload for custom description item types.
733
+ *
734
+ * @template T - Data record shape rendered by the description list.
735
+ */
652
736
  type ExtendDescriptionTypeProps<T = any> = BaseExtendTypeProps<T>;
737
+ /**
738
+ * Extensible description item props that accept any item shape.
739
+ */
653
740
  type ExtendDescriptionItemProps = BaseItemProps;
741
+ /**
742
+ * Description item meta-object consumed by the {@link Description} component.
743
+ *
744
+ * @template T - Data record shape rendered by the description list.
745
+ */
654
746
  interface DescriptionItemProps<T = any> extends FaasItemProps {
747
+ /** Generic custom element rendered when no description-specific child overrides it. */
655
748
  children?: UnionFaasItemElement<T> | null;
749
+ /** Description-specific custom element. */
656
750
  descriptionChildren?: UnionFaasItemElement<T> | null;
751
+ /** Generic custom render callback. */
657
752
  render?: UnionFaasItemRender<T> | null;
753
+ /** Description-specific custom render callback. */
658
754
  descriptionRender?: UnionFaasItemRender<T> | null;
755
+ /** Conditional visibility predicate. When `false`, the item is hidden from the description list. */
659
756
  if?: (values: Record<string, any>) => boolean;
757
+ /** Nested item definitions used by `object` and `object[]` item types. */
660
758
  object?: DescriptionItemProps<T>[];
661
759
  }
760
+ /**
761
+ * Shared props used by both local-data and Faas-data description lists.
762
+ *
763
+ * @template T - Data record shape rendered by the description list.
764
+ * @template ExtendItemProps - Additional item prop shape accepted by `items`.
765
+ */
662
766
  interface DescriptionCommonProps<T = any, ExtendItemProps = any> extends Omit<DescriptionsProps, 'items'> {
767
+ /** Callback that returns a custom React node for the title. */
663
768
  renderTitle?(this: void, values: T): ReactNode;
769
+ /** Item metadata definitions rendered as description entries. */
664
770
  items: (DescriptionItemProps | ExtendItemProps)[];
771
+ /** Custom type renderers keyed by item type. */
665
772
  extendTypes?: {
666
773
  [key: string]: ExtendDescriptionTypeProps;
667
774
  };
668
775
  }
776
+ /**
777
+ * Props for the {@link Description} component when rendering a local data source.
778
+ *
779
+ * @template T - Data record shape rendered by the description list.
780
+ * @template ExtendItemProps - Additional item prop shape accepted by `items`.
781
+ */
669
782
  interface DescriptionWithoutFaasProps<T = any, ExtendItemProps = any> extends DescriptionCommonProps<T, ExtendItemProps> {
783
+ /** Local data source rendered by the description list. */
670
784
  dataSource?: T;
785
+ /** Must not be set when using a local `dataSource`. */
671
786
  faasData?: never;
672
787
  }
788
+ /**
789
+ * Props for the {@link Description} component when fetching data via FaasJS.
790
+ *
791
+ * @template Path - Action path type inferred from `faasData.action`.
792
+ * @template T - Data record shape rendered by the description list.
793
+ * @template ExtendItemProps - Additional item prop shape accepted by `items`.
794
+ */
673
795
  interface DescriptionWithFaasProps<Path extends FaasActionPaths = any, T = any, ExtendItemProps = any> extends DescriptionCommonProps<T, ExtendItemProps> {
796
+ /** Must not be set when using `faasData`. */
674
797
  dataSource?: never;
798
+ /** FaasJS data wrapper configuration that fetches the data source. */
675
799
  faasData?: FaasDataWrapperProps<Path>;
676
800
  }
801
+ /**
802
+ * Full props union accepted by the {@link Description} component.
803
+ *
804
+ * @template T - Data record shape rendered by the description list.
805
+ * @template ExtendItemProps - Additional item prop shape accepted by `items`.
806
+ */
677
807
  type DescriptionProps<T = any, ExtendItemProps = any> = DescriptionWithoutFaasProps<T, ExtendItemProps> | DescriptionWithFaasProps<any, T, ExtendItemProps>;
808
+ /**
809
+ * Props passed to the {@link DescriptionItemContent} internal renderer.
810
+ *
811
+ * @template T - Data record shape rendered by the description list.
812
+ */
678
813
  interface DescriptionItemContentProps<T = any> {
814
+ /** The item definition being rendered. */
679
815
  item: DescriptionItemProps;
816
+ /** Raw value read from the data source for this item's `id`. */
680
817
  value: T;
818
+ /** Entire data source record (optional). */
681
819
  values?: any;
820
+ /** Custom type renderers keyed by item type. */
682
821
  extendTypes?: {
683
822
  [key: string]: ExtendDescriptionTypeProps;
684
823
  };
@@ -795,25 +934,74 @@ type setDrawerProps = Dispatch<SetStateAction<DrawerProps>>;
795
934
  * ```
796
935
  */
797
936
  declare function useDrawer(init?: DrawerProps): {
798
- drawer: _$react_jsx_runtime0.JSX.Element;
937
+ drawer: JSX.Element;
799
938
  drawerProps: DrawerProps;
800
939
  setDrawerProps: setDrawerProps;
801
940
  };
802
941
  //#endregion
803
942
  //#region src/data/render.d.ts
943
+ /**
944
+ * Render a display value using FaasJS item-type-aware formatting.
945
+ *
946
+ * Arrays are joined by comma, booleans render as icons, date/time values are formatted,
947
+ * and option-backed values resolve the corresponding label before rendering. Empty values
948
+ * produce a {@link Blank} placeholder.
949
+ *
950
+ * @param type - Item type that controls the formatting logic.
951
+ * @param value - Raw value to display.
952
+ * @param options - Optional list of options used for label resolution.
953
+ * @returns React node representing the formatted display value.
954
+ */
804
955
  declare function renderDisplayValue(type: FaasItemType, value: any, options?: {
805
956
  label: string;
806
957
  value?: string | number;
807
958
  }[]): JSX.Element | string | number | boolean | null;
808
959
  //#endregion
809
960
  //#region src/data/utils.d.ts
961
+ /**
962
+ * Derive a human-readable title from a raw identifier.
963
+ *
964
+ * Splits on whitespace, underscores, and hyphens, then capitalises each segment.
965
+ *
966
+ * @param id - Raw identifier.
967
+ * @returns Title-cased string derived from the identifier.
968
+ */
810
969
  declare function idToTitle(id: string | number): string;
970
+ /**
971
+ * Normalise raw option entries into a stable shape with `label` and `value`.
972
+ *
973
+ * String and number options receive a title-cased label derived from the raw value.
974
+ *
975
+ * @param options - Raw options accepted by form items, description items, and table columns.
976
+ * @returns Normalised option objects.
977
+ */
811
978
  declare function transferOptions(options: BaseOption[]): {
812
979
  label: string;
813
980
  value?: string | number;
814
981
  }[];
982
+ /**
983
+ * Coerce a raw value into the expected JavaScript type for a given {@link FaasItemType}.
984
+ *
985
+ * Falsy scalar values (including the strings `"null"` and `"undefined"`) are normalised to `null`.
986
+ * Array-typed values are coerced element-by-element. Date/time values are parsed into Dayjs objects
987
+ * and unix timestamps are auto-detected.
988
+ *
989
+ * @param type - Target item type (defaults to `"string"` when falsy).
990
+ * @param value - Raw value to normalise.
991
+ * @returns Normalised value matching the expected type.
992
+ */
815
993
  declare function transferValue(type: FaasItemType | null | undefined, value: any): any;
816
- declare function cloneUnionFaasItemElement(element: UnionFaasItemElement, props: any): _$react.ReactElement<UnionFaasItemInjection<any, any>, string | _$react.JSXElementConstructor<any>>;
994
+ /**
995
+ * Clone a {@link UnionFaasItemElement} while injecting additional React props.
996
+ *
997
+ * If the element is a React element it is cloned in-place; if it is a function component
998
+ * it is instantiated via `createElement` with the given props.
999
+ *
1000
+ * @param element - React element or function component to clone.
1001
+ * @param props - Props injected into the cloned element.
1002
+ * @returns Cloned React element with the injected props.
1003
+ */
1004
+ declare function cloneUnionFaasItemElement(element: UnionFaasItemElement, props: any): import("react").ReactElement<UnionFaasItemInjection<any, any>, string | import("react").JSXElementConstructor<any>>;
817
1005
  //#endregion
818
1006
  //#region src/FormItem/index.d.ts
819
1007
  /**
@@ -843,45 +1031,80 @@ declare function cloneUnionFaasItemElement(element: UnionFaasItemElement, props:
843
1031
  * }
844
1032
  * ```
845
1033
  */
846
- declare function FormItem<T = any>(props: FormItemProps<T>): _$react_jsx_runtime0.JSX.Element | null;
1034
+ declare function FormItem<T = any>(props: FormItemProps<T>): import("react").JSX.Element | null;
847
1035
  declare namespace FormItem {
848
1036
  var useStatus: () => {
849
- status?: _$antd_es_form_FormItem0.ValidateStatus;
1037
+ status?: import("antd/es/form/FormItem").ValidateStatus;
850
1038
  errors: React.ReactNode[];
851
1039
  warnings: React.ReactNode[];
852
1040
  };
853
1041
  }
854
1042
  //#endregion
855
1043
  //#region src/Form/types.d.ts
1044
+ /**
1045
+ * Submit button configuration for the {@link Form} component.
1046
+ */
856
1047
  type FormSubmitProps = {
857
- text?: string;
1048
+ /** Submit button label. */text?: string; /** Props forwarded to the Ant Design submit button. */
858
1049
  buttonProps?: ButtonProps;
859
1050
  };
1051
+ /**
1052
+ * Configures FaasJS-backed form submission.
1053
+ *
1054
+ * @template Values - Form values shape.
1055
+ * @template Path - Action path type inferred from the registered FaasJS actions.
1056
+ */
860
1057
  type FormFaasProps<Values extends Record<string, any> = any, Path extends FaasActionPaths = any> = {
861
- action: Path;
862
- params?: FaasParams<Path> | ((values: Record<string, any>) => FaasParams<Path>);
863
- transformValues?: (values: Values) => Record<string, any> | Promise<Record<string, any>>;
864
- onSuccess?: (result: any, values: Record<string, any>) => void;
865
- onError?: (error: any, values: Record<string, any>) => void;
1058
+ /** Fully qualified FaasJS action path. */action: Path; /** Static params or a factory that receives the current form values and returns the params payload. */
1059
+ params?: FaasParams<Path> | ((values: Record<string, any>) => FaasParams<Path>); /** Transformer applied to form values before the FaasJS request is fired. */
1060
+ transformValues?: (values: Values) => Record<string, any> | Promise<Record<string, any>>; /** Called after a successful FaasJS response. */
1061
+ onSuccess?: (result: any, values: Record<string, any>) => void; /** Called after a failed FaasJS request. */
1062
+ onError?: (error: any, values: Record<string, any>) => void; /** Called after the request settles, regardless of success or failure. */
866
1063
  onFinally?: () => void;
867
1064
  };
1065
+ /**
1066
+ * Shared props used by both Faas-backed and manually-submitted forms.
1067
+ *
1068
+ * @template Values - Form values shape.
1069
+ * @template ExtendItemProps - Additional item prop shape accepted by `items`.
1070
+ */
868
1071
  type FormCommonProps<Values extends Record<string, any>, ExtendItemProps extends ExtendFormItemProps = ExtendFormItemProps> = Omit<FormProps$1<Values>, 'onFinish' | 'children' | 'initialValues'> & {
869
- items?: ((ExtendItemProps extends ExtendFormItemProps ? ExtendItemProps | FormItemProps : FormItemProps) | JSX.Element)[];
870
- submit?: false | FormSubmitProps;
871
- beforeItems?: JSX.Element | JSX.Element[];
872
- footer?: JSX.Element | JSX.Element[];
873
- extendTypes?: ExtendTypes;
874
- children?: ReactNode;
1072
+ /** Item definitions rendered as form fields. */items?: ((ExtendItemProps extends ExtendFormItemProps ? ExtendItemProps | FormItemProps : FormItemProps) | JSX.Element)[]; /** Submit button config, or `false` to hide the built-in submit button. */
1073
+ submit?: false | FormSubmitProps; /** Elements rendered before the form items. */
1074
+ beforeItems?: JSX.Element | JSX.Element[]; /** Elements rendered after the submit button. */
1075
+ footer?: JSX.Element | JSX.Element[]; /** Custom type renderers keyed by item type. */
1076
+ extendTypes?: ExtendTypes; /** Arbitrary children rendered between items and the submit button. */
1077
+ children?: ReactNode; /** Initial field values for the form. */
875
1078
  initialValues?: Partial<Values>;
876
1079
  };
1080
+ /**
1081
+ * Props for the {@link Form} component when NO FaasJS integration is used.
1082
+ *
1083
+ * @template Values - Form values shape.
1084
+ * @template ExtendItemProps - Additional item prop shape accepted by `items`.
1085
+ */
877
1086
  type FormWithoutFaasProps<Values extends Record<string, any> = any, ExtendItemProps extends ExtendFormItemProps = ExtendFormItemProps> = FormCommonProps<Values, ExtendItemProps> & {
878
- faas?: never;
1087
+ /** Must not be set when using a custom `onFinish` handler. */faas?: never; /** Custom submit handler that replaces the built-in FaasJS flow. */
879
1088
  onFinish?: (values: Values) => void | Promise<void>;
880
1089
  };
1090
+ /**
1091
+ * Props for the {@link Form} component when FaasJS integration IS used.
1092
+ *
1093
+ * @template Path - Action path type inferred from the registered FaasJS actions.
1094
+ * @template Values - Form values shape.
1095
+ * @template ExtendItemProps - Additional item prop shape accepted by `items`.
1096
+ */
881
1097
  type FormWithFaasProps<Path extends FaasActionPaths = any, Values extends Record<string, any> = any, ExtendItemProps extends ExtendFormItemProps = ExtendFormItemProps> = FormCommonProps<Values, ExtendItemProps> & {
882
- faas?: FormFaasProps<Values, Path>;
1098
+ /** FaasJS integration configuration. */faas?: FormFaasProps<Values, Path>; /** Must not be set when `faas` is provided. */
883
1099
  onFinish?: never;
884
1100
  };
1101
+ /**
1102
+ * Full props union accepted by the {@link Form} component.
1103
+ *
1104
+ * @template Values - Form values shape.
1105
+ * @template Path - Action path type (only relevant when `faas` is provided).
1106
+ * @template ExtendItemProps - Additional item prop shape accepted by `items`.
1107
+ */
885
1108
  type FormProps<Values extends Record<string, any> = any, Path extends FaasActionPaths = any, ExtendItemProps extends ExtendFormItemProps = ExtendFormItemProps> = FormWithoutFaasProps<Values, ExtendItemProps> | FormWithFaasProps<Path, Values, ExtendItemProps>;
886
1109
  //#endregion
887
1110
  //#region src/Form/index.d.ts
@@ -956,13 +1179,13 @@ declare function Form<Path extends FaasActionPaths, Values extends Record<string
956
1179
  */
957
1180
  declare function Form<Values extends Record<string, any> = any, Path extends FaasActionPaths = any>(props: FormProps<Values, Path>): JSX.Element;
958
1181
  declare namespace Form {
959
- var useForm: typeof _$antd_es_form_Form0.useForm;
960
- var useFormInstance: typeof _$antd_es_form_hooks_useFormInstance0.default;
961
- var useWatch: typeof _$_rc_component_form0.useWatch;
1182
+ var useForm: typeof import("antd/es/form/Form").useForm;
1183
+ var useFormInstance: typeof import("antd/es/form/hooks/useFormInstance").default;
1184
+ var useWatch: typeof import("@rc-component/form").useWatch;
962
1185
  var Item: typeof FormItem;
963
- var List: _$react.FC<_$antd_es_form0.FormListProps>;
964
- var ErrorList: _$react.FC<_$antd_es_form0.ErrorListProps>;
965
- var Provider: _$react.FC<_$antd_es_form_context0.FormProviderProps>;
1186
+ var List: import("react").FC<import("antd/es/form").FormListProps>;
1187
+ var ErrorList: import("react").FC<import("antd/es/form").ErrorListProps>;
1188
+ var Provider: import("react").FC<import("antd/es/form/context").FormProviderProps>;
966
1189
  }
967
1190
  //#endregion
968
1191
  //#region src/Link/index.d.ts
@@ -1013,7 +1236,7 @@ interface LinkProps {
1013
1236
  * }
1014
1237
  * ```
1015
1238
  */
1016
- declare function Link(props: LinkProps): _$react_jsx_runtime0.JSX.Element;
1239
+ declare function Link(props: LinkProps): import("react").JSX.Element;
1017
1240
  //#endregion
1018
1241
  //#region src/Modal/index.d.ts
1019
1242
  /**
@@ -1056,7 +1279,7 @@ type setModalProps = Dispatch<SetStateAction<ModalProps>>;
1056
1279
  * ```
1057
1280
  */
1058
1281
  declare function useModal(init?: ModalProps): {
1059
- modal: _$react_jsx_runtime0.JSX.Element;
1282
+ modal: JSX.Element;
1060
1283
  modalProps: ModalProps;
1061
1284
  setModalProps: setModalProps;
1062
1285
  };
@@ -1079,7 +1302,7 @@ declare function useModal(init?: ModalProps): {
1079
1302
  * }
1080
1303
  * ```
1081
1304
  */
1082
- declare function PageNotFound(): _$react_jsx_runtime0.JSX.Element;
1305
+ declare function PageNotFound(): JSX.Element;
1083
1306
  /**
1084
1307
  * Props for the lazy-loading {@link Routes} wrapper.
1085
1308
  */
@@ -1113,7 +1336,7 @@ interface RoutesProps {
1113
1336
  * routes={[
1114
1337
  * {
1115
1338
  * path: '/',
1116
- * page: lazy(() => import('./pages/home')),
1339
+ * page: lazy(() => import('./features/home')),
1117
1340
  * },
1118
1341
  * ]}
1119
1342
  * />
@@ -1122,7 +1345,7 @@ interface RoutesProps {
1122
1345
  * }
1123
1346
  * ```
1124
1347
  */
1125
- declare function Routes(props: RoutesProps): _$react_jsx_runtime0.JSX.Element;
1348
+ declare function Routes(props: RoutesProps): JSX.Element;
1126
1349
  //#endregion
1127
1350
  //#region src/Table/table.d.ts
1128
1351
  /**
@@ -1160,7 +1383,7 @@ declare function Routes(props: RoutesProps): _$react_jsx_runtime0.JSX.Element;
1160
1383
  * }
1161
1384
  * ```
1162
1385
  */
1163
- declare function Table<T extends Record<string, any>, ExtendTypes = any>(props: TableProps<T, ExtendTypes>): _$react_jsx_runtime0.JSX.Element;
1386
+ declare function Table<T extends Record<string, any>, ExtendTypes = any>(props: TableProps<T, ExtendTypes>): import("react").JSX.Element;
1164
1387
  //#endregion
1165
1388
  //#region src/Tabs/index.d.ts
1166
1389
  /**
@@ -1210,7 +1433,7 @@ interface TabsProps extends Omit<TabsProps$1, 'items'> {
1210
1433
  * }
1211
1434
  * ```
1212
1435
  */
1213
- declare function Tabs(props: TabsProps): _$react_jsx_runtime0.JSX.Element;
1436
+ declare function Tabs(props: TabsProps): import("react").JSX.Element;
1214
1437
  //#endregion
1215
1438
  //#region src/Title/index.d.ts
1216
1439
  /**
package/dist/index.mjs CHANGED
@@ -655,6 +655,18 @@ function resolveOptionLabel(value, options) {
655
655
  for (const option of options) if (option.value === value) return option.label ?? value;
656
656
  return value;
657
657
  }
658
+ /**
659
+ * Render a display value using FaasJS item-type-aware formatting.
660
+ *
661
+ * Arrays are joined by comma, booleans render as icons, date/time values are formatted,
662
+ * and option-backed values resolve the corresponding label before rendering. Empty values
663
+ * produce a {@link Blank} placeholder.
664
+ *
665
+ * @param type - Item type that controls the formatting logic.
666
+ * @param value - Raw value to display.
667
+ * @param options - Optional list of options used for label resolution.
668
+ * @returns React node representing the formatted display value.
669
+ */
658
670
  function renderDisplayValue(type, value, options) {
659
671
  if (value === null || value === void 0 || Array.isArray(value) && value.length === 0) return /* @__PURE__ */ jsx(Blank, {});
660
672
  if (options?.length) {
@@ -676,11 +688,27 @@ function renderDisplayValue(type, value, options) {
676
688
  }
677
689
  //#endregion
678
690
  //#region src/data/utils.ts
691
+ /**
692
+ * Derive a human-readable title from a raw identifier.
693
+ *
694
+ * Splits on whitespace, underscores, and hyphens, then capitalises each segment.
695
+ *
696
+ * @param id - Raw identifier.
697
+ * @returns Title-cased string derived from the identifier.
698
+ */
679
699
  function idToTitle(id) {
680
700
  if (typeof id === "number") return id.toString();
681
701
  const splitted = id.split(/(\s|_|-)/).filter((word) => !/(\s|_|-)/.test(word)).map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
682
702
  return splitted.charAt(0).toUpperCase() + splitted.slice(1);
683
703
  }
704
+ /**
705
+ * Normalise raw option entries into a stable shape with `label` and `value`.
706
+ *
707
+ * String and number options receive a title-cased label derived from the raw value.
708
+ *
709
+ * @param options - Raw options accepted by form items, description items, and table columns.
710
+ * @returns Normalised option objects.
711
+ */
684
712
  function transferOptions(options) {
685
713
  if (!options) return [];
686
714
  return options.map((item) => typeof item === "object" ? item : {
@@ -688,6 +716,17 @@ function transferOptions(options) {
688
716
  value: item
689
717
  });
690
718
  }
719
+ /**
720
+ * Coerce a raw value into the expected JavaScript type for a given {@link FaasItemType}.
721
+ *
722
+ * Falsy scalar values (including the strings `"null"` and `"undefined"`) are normalised to `null`.
723
+ * Array-typed values are coerced element-by-element. Date/time values are parsed into Dayjs objects
724
+ * and unix timestamps are auto-detected.
725
+ *
726
+ * @param type - Target item type (defaults to `"string"` when falsy).
727
+ * @param value - Raw value to normalise.
728
+ * @returns Normalised value matching the expected type.
729
+ */
691
730
  function transferValue(type, value) {
692
731
  if (!type) type = "string";
693
732
  if (!type.endsWith("[]") && (typeof value === "undefined" || value === null || value === "" || value === "null" || value === "undefined")) return null;
@@ -712,6 +751,16 @@ function transferValue(type, value) {
712
751
  }
713
752
  return value;
714
753
  }
754
+ /**
755
+ * Clone a {@link UnionFaasItemElement} while injecting additional React props.
756
+ *
757
+ * If the element is a React element it is cloned in-place; if it is a function component
758
+ * it is instantiated via `createElement` with the given props.
759
+ *
760
+ * @param element - React element or function component to clone.
761
+ * @param props - Props injected into the cloned element.
762
+ * @returns Cloned React element with the injected props.
763
+ */
715
764
  function cloneUnionFaasItemElement(element, props) {
716
765
  return cloneElement(isValidElement(element) ? element : createElement(element), props);
717
766
  }
@@ -1374,7 +1423,7 @@ function PageNotFound() {
1374
1423
  * routes={[
1375
1424
  * {
1376
1425
  * path: '/',
1377
- * page: lazy(() => import('./pages/home')),
1426
+ * page: lazy(() => import('./features/home')),
1378
1427
  * },
1379
1428
  * ]}
1380
1429
  * />
@@ -1403,10 +1452,24 @@ function Routes(props) {
1403
1452
  }
1404
1453
  //#endregion
1405
1454
  //#region src/Table/utils.tsx
1455
+ /**
1456
+ * Transfer and render a display value for a table cell.
1457
+ *
1458
+ * @param item - Column definition being rendered.
1459
+ * @param value - Raw cell value.
1460
+ * @returns Formatted React node.
1461
+ */
1406
1462
  function processValue(item, value) {
1407
1463
  const itemType = item.type ?? "string";
1408
1464
  return renderDisplayValue(itemType, transferValue(itemType, value), item.options);
1409
1465
  }
1466
+ /**
1467
+ * Convert normalized options into Ant Design table filter entries.
1468
+ *
1469
+ * @param options - Normalized column options.
1470
+ * @param includeBlank - Whether to append a blank/null filter option.
1471
+ * @returns Array of filter entries compatible with Ant Design column `filters`.
1472
+ */
1410
1473
  function toTableFilters(options, includeBlank = false) {
1411
1474
  const filters = options.map((option) => ({
1412
1475
  text: option.label,
@@ -1418,6 +1481,15 @@ function toTableFilters(options, includeBlank = false) {
1418
1481
  });
1419
1482
  return filters;
1420
1483
  }
1484
+ /**
1485
+ * Generate filter dropdown UI for a table column based on its options.
1486
+ *
1487
+ * Mutates the column item in place. Options with fewer than 11 entries use simple filters;
1488
+ * larger option sets use a searchable multi-select dropdown.
1489
+ *
1490
+ * @param item - Column definition to populate with filter UI.
1491
+ * @param search - Localized search placeholder text.
1492
+ */
1421
1493
  function generateFilterDropdown(item, search) {
1422
1494
  if (item.filterDropdown && item.filterDropdown !== true) return;
1423
1495
  if (!item.options?.length) return;
@@ -1452,6 +1524,14 @@ function generateFilterDropdown(item, search) {
1452
1524
  })
1453
1525
  });
1454
1526
  }
1527
+ /**
1528
+ * Create a text-search filter dropdown for a table column.
1529
+ *
1530
+ * @param item - Column definition providing the column title.
1531
+ * @param search - Localized search placeholder text.
1532
+ * @param transformValue - Optional value transformer applied to the search input before setting the filter key.
1533
+ * @returns An Ant Design filter dropdown render function.
1534
+ */
1455
1535
  function createTextSearchFilterDropdown(item, search, transformValue) {
1456
1536
  return ({ setSelectedKeys, confirm, clearFilters }) => /* @__PURE__ */ jsx(Input.Search, {
1457
1537
  placeholder: `${search} ${item.title}`,
@@ -1466,6 +1546,16 @@ function createTextSearchFilterDropdown(item, search, transformValue) {
1466
1546
  }
1467
1547
  });
1468
1548
  }
1549
+ /**
1550
+ * Apply server-supplied options to table columns when using `faasData`.
1551
+ *
1552
+ * When the response includes an `options` map, matching columns receive option-driven
1553
+ * filters and renders automatically.
1554
+ *
1555
+ * @param columns - Current column definitions.
1556
+ * @param data - FaasJS response data object that may contain an `options` map.
1557
+ * @returns Updated column definitions, or the original array when no options are present.
1558
+ */
1469
1559
  function applyFaasDataColumnOptions(columns, data) {
1470
1560
  if (!data?.options) return columns;
1471
1561
  let updated = false;
@@ -1483,6 +1573,18 @@ function applyFaasDataColumnOptions(columns, data) {
1483
1573
  }
1484
1574
  //#endregion
1485
1575
  //#region src/Table/column-builder.tsx
1576
+ /**
1577
+ * Build Ant Design table column definitions from FaasJS item metadata.
1578
+ *
1579
+ * The function applies default titles, data indices, renderers, sorters, and filter dropdowns
1580
+ * for each built-in item type. Custom types registered via `extendTypes` are resolved
1581
+ * through the configured children or render callbacks.
1582
+ *
1583
+ * @param items - Raw item metadata definitions.
1584
+ * @param options - Configuration including theme strings, custom type renderers, and optional FaasJS or local data.
1585
+ * @returns Fully populated column definitions ready for the Ant Design table.
1586
+ * @throws {Error} When a custom type in `extendTypes` omits both `children` and `render`.
1587
+ */
1486
1588
  function createTableColumns(items, options) {
1487
1589
  const columns = cloneDeep(items).filter((item) => !(item.tableChildren === null || item.children === null || item.tableRender === null || item.render === null));
1488
1590
  for (const item of columns) {
@@ -1755,6 +1857,13 @@ function Table(props) {
1755
1857
  })
1756
1858
  });
1757
1859
  }
1860
+ /**
1861
+ * Internal table renderer that binds FaasJS data injection props to an Ant Design table.
1862
+ *
1863
+ * @param props - Combined FaasJS data injection and table props.
1864
+ *
1865
+ * @internal
1866
+ */
1758
1867
  function FaasDataTable({ props, columns, data, params, reload, loading }) {
1759
1868
  const currentColumns = useEqualMemo(() => !data || Array.isArray(data) ? columns : applyFaasDataColumnOptions(columns, data), [columns, data]);
1760
1869
  const tableDataSource = !data ? [] : Array.isArray(data) ? data : data.rows;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faasjs/ant-design",
3
- "version": "8.0.0-beta.34",
3
+ "version": "8.0.0-beta.36",
4
4
  "homepage": "https://faasjs.com/doc/ant-design",
5
5
  "bugs": {
6
6
  "url": "https://github.com/faasjs/faasjs/issues"
@@ -27,9 +27,9 @@
27
27
  },
28
28
  "devDependencies": {
29
29
  "@ant-design/icons": "*",
30
- "@faasjs/react": ">=8.0.0-beta.34",
31
- "@faasjs/types": ">=8.0.0-beta.34",
32
- "@faasjs/utils": ">=8.0.0-beta.34",
30
+ "@faasjs/react": ">=8.0.0-beta.36",
31
+ "@faasjs/types": ">=8.0.0-beta.36",
32
+ "@faasjs/utils": ">=8.0.0-beta.36",
33
33
  "@types/lodash-es": "*",
34
34
  "@types/react": "^19.0.0",
35
35
  "@types/react-dom": "^19.0.0",
@@ -41,9 +41,9 @@
41
41
  },
42
42
  "peerDependencies": {
43
43
  "@ant-design/icons": "*",
44
- "@faasjs/react": ">=8.0.0-beta.34",
45
- "@faasjs/types": ">=8.0.0-beta.34",
46
- "@faasjs/utils": ">=8.0.0-beta.34",
44
+ "@faasjs/react": ">=8.0.0-beta.36",
45
+ "@faasjs/types": ">=8.0.0-beta.36",
46
+ "@faasjs/utils": ">=8.0.0-beta.36",
47
47
  "antd": "^6.0.0",
48
48
  "lodash-es": "*",
49
49
  "react": "^19.0.0",