@factorialco/f0-react 1.380.0 → 1.382.0

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/f0.d.ts CHANGED
@@ -2217,13 +2217,14 @@ export declare const defaultTranslations: {
2217
2217
  readonly toggle: "Toggle";
2218
2218
  readonly toggleDropdownMenu: "Toggle dropdown menu";
2219
2219
  readonly selectAll: "Select all";
2220
+ readonly selectAllItems: "Select all {{total}} items";
2220
2221
  };
2221
2222
  readonly status: {
2222
2223
  readonly selected: {
2223
2224
  readonly singular: "Selected";
2224
2225
  readonly plural: "Selected";
2225
2226
  readonly all: "All selected";
2226
- readonly allOnPage: "All items on this page are selected";
2227
+ readonly allOnPage: "All {{count}} items on this page are selected";
2227
2228
  readonly selectAllItems: "Select all {{total}} items";
2228
2229
  readonly allItemsSelected: "All {{total}} items selected";
2229
2230
  };
@@ -2583,6 +2584,18 @@ export declare const defaultTranslations: {
2583
2584
  readonly other: "{{count}} issues";
2584
2585
  };
2585
2586
  };
2587
+ readonly file: {
2588
+ readonly dropzone: "Drag and drop a file, or click to select";
2589
+ readonly dropzoneActive: "Drop the file here";
2590
+ readonly dropzoneMultiple: "Drag and drop files, or click to select";
2591
+ readonly acceptedTypes: "Accepted formats: {{types}}";
2592
+ readonly remove: "Remove";
2593
+ readonly uploading: "Uploading…";
2594
+ readonly processing: "Processing…";
2595
+ readonly uploadFailed: "Upload failed";
2596
+ readonly fileTooLarge: "File exceeds {{maxSize}} MB limit";
2597
+ readonly invalidFileType: "File type not accepted. Accepted formats: {{types}}";
2598
+ };
2586
2599
  readonly validation: {
2587
2600
  readonly required: "This field is required";
2588
2601
  readonly invalidType: "Invalid value";
@@ -2880,11 +2893,26 @@ export declare interface F0AlertProps {
2880
2893
  }
2881
2894
 
2882
2895
  /**
2883
- * Config for array fields (multi-select)
2896
+ * Config for array fields (multi-select or multi-file)
2884
2897
  * @typeParam T - The value type (string or number)
2885
2898
  * @typeParam R - Record type for data source (when using source instead of options)
2886
2899
  */
2887
- export declare type F0ArrayConfig<T extends string | number = string, R extends Record<string, unknown> = Record<string, unknown>> = F0BaseConfig & F0SelectConfig<T, R> & {
2900
+ export declare type F0ArrayConfig<T extends string | number = string, R extends Record<string, unknown> = Record<string, unknown>> = F0ArraySelectConfig<T, R> | F0ArrayFileConfig;
2901
+
2902
+ /**
2903
+ * Config for file fields (multiple file upload, form value is string[])
2904
+ */
2905
+ declare type F0ArrayFileConfig = F0BaseConfig & F0FileConfig & {
2906
+ fieldType: "file";
2907
+ multiple: true;
2908
+ };
2909
+
2910
+ /**
2911
+ * Config for array fields with select (multi-select)
2912
+ * @typeParam T - The value type (string or number)
2913
+ * @typeParam R - Record type for data source (when using source instead of options)
2914
+ */
2915
+ declare type F0ArraySelectConfig<T extends string | number = string, R extends Record<string, unknown> = Record<string, unknown>> = F0BaseConfig & F0SelectConfig<T, R> & {
2888
2916
  fieldType?: "select";
2889
2917
  };
2890
2918
 
@@ -3740,19 +3768,66 @@ export declare function F0EventCatcherProvider({ children, onEvent, enabled, cat
3740
3768
  /**
3741
3769
  * Union of all F0 field types used for rendering
3742
3770
  */
3743
- export declare type F0Field = F0TextField | F0NumberField | F0TextareaField | F0SelectField | F0CheckboxField | F0SwitchField | F0DateField | F0TimeField | F0DateTimeField | F0DateRangeField | F0RichTextField | F0CustomField;
3771
+ export declare type F0Field = F0TextField | F0NumberField | F0TextareaField | F0SelectField | F0CheckboxField | F0SwitchField | F0DateField | F0TimeField | F0DateTimeField | F0DateRangeField | F0RichTextField | F0FileField | F0CustomField;
3744
3772
 
3745
3773
  /**
3746
3774
  * Complete F0 field configuration (union of all possible configs)
3747
3775
  * @typeParam T - The value type for select fields (string or number)
3748
3776
  * @typeParam R - Record type for data source (when using source instead of options)
3749
3777
  */
3750
- export declare type F0FieldConfig<T extends string | number = string | number, R extends Record<string, unknown> = Record<string, unknown>> = F0StringConfig<string, undefined, R> | F0NumberFieldConfig<R> | F0BooleanConfig | F0DateFieldConfig | F0TimeFieldConfig | F0DateTimeFieldConfig | F0ArrayConfig<T, R> | F0ObjectConfig;
3778
+ export declare type F0FieldConfig<T extends string | number = string | number, R extends Record<string, unknown> = Record<string, unknown>> = F0StringConfig<string, undefined, R> | F0NumberFieldConfig<R> | F0BooleanConfig | F0DateFieldConfig | F0TimeFieldConfig | F0DateTimeFieldConfig | F0ArrayConfig<T, R> | F0FileFieldConfig | F0ObjectConfig;
3751
3779
 
3752
3780
  /**
3753
3781
  * Field types for rendering
3754
3782
  */
3755
- export declare type F0FieldType = "text" | "number" | "textarea" | "select" | "checkbox" | "switch" | "date" | "time" | "datetime" | "daterange" | "richtext" | "custom";
3783
+ export declare type F0FieldType = "text" | "number" | "textarea" | "select" | "checkbox" | "switch" | "date" | "time" | "datetime" | "daterange" | "richtext" | "file" | "custom";
3784
+
3785
+ /**
3786
+ * F0 config options specific to file fields
3787
+ */
3788
+ export declare interface F0FileConfig {
3789
+ /**
3790
+ * Accepted MIME types.
3791
+ *
3792
+ * @example
3793
+ * accept: ["image"] // all image types
3794
+ * accept: ["image/png", "image/jpeg"] // specific types
3795
+ * accept: ["image", "application/pdf"] // mix of category and specific
3796
+ */
3797
+ accept?: MimeType_2[];
3798
+ /** Maximum file size in megabytes (per file) */
3799
+ maxSizeMB?: number;
3800
+ /** Allow multiple file uploads (form value becomes `string[]`) */
3801
+ multiple?: boolean;
3802
+ /** Helper text shown in the dropzone area */
3803
+ description?: string;
3804
+ /** Consumer-provided hook that returns upload capabilities */
3805
+ useUpload: UseFileUpload;
3806
+ }
3807
+
3808
+ /**
3809
+ * File field with all properties for rendering (runtime type)
3810
+ */
3811
+ export declare type F0FileField = F0BaseField & {
3812
+ type: "file";
3813
+ /** Accepted MIME types */
3814
+ accept?: MimeType_2[];
3815
+ /** Maximum file size in megabytes */
3816
+ maxSizeMB?: number;
3817
+ /** Allow multiple files */
3818
+ multiple?: boolean;
3819
+ /** Dropzone description text */
3820
+ description?: string;
3821
+ /** Consumer-provided upload hook */
3822
+ useUpload: UseFileUpload;
3823
+ /** Conditional rendering */
3824
+ renderIf?: FileFieldRenderIf;
3825
+ };
3826
+
3827
+ /**
3828
+ * Union of all file field configs
3829
+ */
3830
+ export declare type F0FileFieldConfig = F0StringFileConfig | F0ArrayFileConfig;
3756
3831
 
3757
3832
  export declare const F0FilterPickerContent: F0FilterPickerContentGeneric;
3758
3833
 
@@ -3970,6 +4045,12 @@ export declare interface F0FormPropsWithPerSectionSchema<T extends F0PerSectionS
3970
4045
  * Ref to control the form programmatically from outside.
3971
4046
  */
3972
4047
  formRef?: React.MutableRefObject<F0FormRef | null>;
4048
+ /**
4049
+ * Pre-existing file metadata shared across all file fields.
4050
+ * Each file field automatically resolves its entries by matching
4051
+ * `defaultValues` against `InitialFile.value`.
4052
+ */
4053
+ initialFiles?: InitialFile[];
3973
4054
  }
3974
4055
 
3975
4056
  /**
@@ -4008,6 +4089,12 @@ export declare interface F0FormPropsWithSingleSchema<TSchema extends F0FormSchem
4008
4089
  * Use with the `useF0Form` hook to get a ref and submit/reset functions.
4009
4090
  */
4010
4091
  formRef?: React.MutableRefObject<F0FormRef | null>;
4092
+ /**
4093
+ * Pre-existing file metadata shared across all file fields.
4094
+ * Each file field automatically resolves its entries by matching
4095
+ * `defaultValues` against `InitialFile.value`.
4096
+ */
4097
+ initialFiles?: InitialFile[];
4011
4098
  }
4012
4099
 
4013
4100
  /**
@@ -4594,7 +4681,15 @@ export declare type F0Source = {
4594
4681
  * @typeParam TConfig - Type of the fieldConfig object (for custom fields)
4595
4682
  * @typeParam R - Record type for data source (when using source instead of options)
4596
4683
  */
4597
- export declare type F0StringConfig<TValue = string, TConfig = undefined, R extends Record<string, unknown> = Record<string, unknown>> = F0StringTextConfig | F0StringTextareaConfig | F0StringSelectConfig<R> | F0CustomFieldConfig<TValue, TConfig>;
4684
+ export declare type F0StringConfig<TValue = string, TConfig = undefined, R extends Record<string, unknown> = Record<string, unknown>> = F0StringTextConfig | F0StringTextareaConfig | F0StringSelectConfig<R> | F0StringFileConfig | F0CustomFieldConfig<TValue, TConfig>;
4685
+
4686
+ /**
4687
+ * Config for file fields (single file upload, form value is a string identifier)
4688
+ */
4689
+ declare type F0StringFileConfig = F0BaseConfig & F0FileConfig & {
4690
+ fieldType: "file";
4691
+ multiple?: false;
4692
+ };
4598
4693
 
4599
4694
  /**
4600
4695
  * Config for string fields with select options
@@ -4822,7 +4917,7 @@ export declare interface F0ZodType<T extends ZodTypeAny = ZodTypeAny> {
4822
4917
  /**
4823
4918
  * Field types for rendering
4824
4919
  */
4825
- export declare type FieldType = "text" | "number" | "textarea" | "select" | "checkbox" | "switch" | "date" | "time" | "datetime" | "daterange" | "richtext" | "custom";
4920
+ export declare type FieldType = "text" | "number" | "textarea" | "select" | "checkbox" | "switch" | "date" | "time" | "datetime" | "daterange" | "richtext" | "file" | "custom";
4826
4921
 
4827
4922
  export declare type FileAvatarVariant = Extract<AvatarVariant, {
4828
4923
  type: "file";
@@ -4833,6 +4928,41 @@ declare type FileDef = {
4833
4928
  type: string;
4834
4929
  };
4835
4930
 
4931
+ /**
4932
+ * All valid renderIf conditions for file fields
4933
+ */
4934
+ declare type FileFieldRenderIf = CommonRenderIfCondition | F0BaseFieldRenderIfFunction;
4935
+
4936
+ /**
4937
+ * Return type of the consumer-provided upload hook
4938
+ */
4939
+ export declare interface FileUploadHookReturn {
4940
+ /** Uploads a file and returns the result */
4941
+ upload: (file: File) => Promise<FileUploadResult>;
4942
+ /** Cancels the in-flight upload */
4943
+ cancelUpload?: () => void;
4944
+ /** Upload progress from 0 to 1 */
4945
+ progress: number;
4946
+ /** Current upload status */
4947
+ status: FileUploadStatus;
4948
+ }
4949
+
4950
+ /**
4951
+ * Result of a file upload operation.
4952
+ * `value` is the identifier stored as the form value (e.g. a signedId, URL, or any string).
4953
+ */
4954
+ export declare type FileUploadResult = {
4955
+ type: "success";
4956
+ value: string;
4957
+ } | {
4958
+ type: "aborted";
4959
+ };
4960
+
4961
+ /**
4962
+ * Upload status states
4963
+ */
4964
+ export declare type FileUploadStatus = "idle" | "processing" | "uploading" | "success";
4965
+
4836
4966
  /**
4837
4967
  * Union of all available filter types.
4838
4968
  * Used to define possible filter configurations in a collection.
@@ -5391,6 +5521,21 @@ export declare type InfiniteScrollPaginatedResponse<TRecord> = BasePaginatedResp
5391
5521
  hasMore: boolean;
5392
5522
  };
5393
5523
 
5524
+ /**
5525
+ * Metadata for a file that already exists (e.g. from a previous upload).
5526
+ * Passed via `initialFiles` so the field can display it without re-uploading.
5527
+ */
5528
+ export declare interface InitialFile {
5529
+ /** The identifier that matches the form's default value (signedId, URL, etc.) */
5530
+ value: string;
5531
+ /** Display name (e.g. "report.pdf") */
5532
+ name: string;
5533
+ /** MIME type for icon display (e.g. "application/pdf") */
5534
+ type?: string;
5535
+ /** File size in bytes */
5536
+ size?: number;
5537
+ }
5538
+
5394
5539
  declare const INPUTFIELD_SIZES: readonly ["sm", "md"];
5395
5540
 
5396
5541
  declare type InputFieldInheritedProps = (typeof inputFieldInheritedProps)[number];
@@ -5655,6 +5800,20 @@ declare type MentionsConfig = {
5655
5800
  users: MentionedUser[];
5656
5801
  };
5657
5802
 
5803
+ /**
5804
+ * Known MIME types for the file field `accept` prop.
5805
+ *
5806
+ * Supports three formats:
5807
+ * - Specific types: `"image/png"`, `"application/pdf"`
5808
+ * - Wildcard categories: `"image/*"`, `"video/*"`
5809
+ * - Bare categories (shorthand for wildcard): `"image"`, `"video"`
5810
+ *
5811
+ * The `string & {}` escape hatch allows unlisted MIME types while
5812
+ * still providing autocomplete for known ones.
5813
+ */
5814
+ declare type MimeType_2 = "image" | "video" | "audio" | "text" | "application" | "image/*" | "video/*" | "audio/*" | "text/*" | "application/*" | "image/jpeg" | "image/png" | "image/gif" | "image/webp" | "image/svg+xml" | "image/heic" | "image/bmp" | "image/tiff" | "image/avif" | "video/mp4" | "video/webm" | "video/quicktime" | "audio/mpeg" | "audio/ogg" | "audio/wav" | "application/pdf" | "application/msword" | "application/vnd.openxmlformats-officedocument.wordprocessingml.document" | "application/vnd.ms-excel" | "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" | "application/vnd.ms-powerpoint" | "application/vnd.openxmlformats-officedocument.presentationml.presentation" | "application/zip" | "application/json" | "text/plain" | "text/csv" | "text/html" | "text/markdown";
5815
+ export { MimeType_2 as MimeType }
5816
+
5658
5817
  declare const moduleAvatarVariants: (props?: ({
5659
5818
  size?: "lg" | "md" | "sm" | "xs" | "xxs" | undefined;
5660
5819
  } & ({
@@ -7597,6 +7756,22 @@ export declare interface UseF0FormReturn {
7597
7756
  hasErrors: boolean;
7598
7757
  }
7599
7758
 
7759
+ /**
7760
+ * A hook that returns upload capabilities for a single file.
7761
+ * Each call creates an independent upload instance with its own state.
7762
+ *
7763
+ * @example
7764
+ * ```tsx
7765
+ * const useMyUpload: UseFileUpload = () => {
7766
+ * const { upload, progress, status, cancelUpload } = useDirectUpload({
7767
+ * resourceType: "MyModule::Document",
7768
+ * })
7769
+ * return { upload, progress, status, cancelUpload }
7770
+ * }
7771
+ * ```
7772
+ */
7773
+ export declare type UseFileUpload = () => FileUploadHookReturn;
7774
+
7600
7775
  export declare const useGroups: <R extends RecordType>(groups: GroupRecord<R>[], defaultOpenGroups?: boolean | GroupRecord<R>["key"][]) => {
7601
7776
  openGroups: Record<string, boolean>;
7602
7777
  setGroupOpen: (key: string, open: boolean) => void;