@factorialco/f0-react 1.401.1 → 1.402.3

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
@@ -48,6 +48,7 @@ import { F0AvatarListProps as F0AvatarListProps_2 } from './types';
48
48
  import { F0AvatarPersonProps as F0AvatarPersonProps_2 } from './types';
49
49
  import { F0AvatarTeamProps as F0AvatarTeamProps_2 } from './F0AvatarTeam';
50
50
  import { F0DialogInternalProps } from './internal-types';
51
+ import { F0DurationInputProps as F0DurationInputProps_2 } from './types';
51
52
  import { F0FormDefinitionPerSection as F0FormDefinitionPerSection_2 } from './f0';
52
53
  import { F0FormDefinitionSingleSchema as F0FormDefinitionSingleSchema_2 } from './f0';
53
54
  import { F0GridStackProps as F0GridStackProps_2 } from './F0GridStack';
@@ -858,6 +859,33 @@ declare type BaseFilterDefinition<T extends FilterTypeKey> = {
858
859
  hideSelector?: boolean;
859
860
  };
860
861
 
862
+ declare function BaseHeader({ title, avatar, deactivated, description, primaryAction, secondaryActions, otherActions, status, metadata, }: BaseHeaderProps_2): JSX_2.Element;
863
+
864
+ declare type BaseHeaderProps = ComponentProps<typeof BaseHeader>;
865
+
866
+ declare interface BaseHeaderProps_2 {
867
+ title: string;
868
+ deactivated?: boolean;
869
+ avatar?: {
870
+ type: "generic";
871
+ name: string;
872
+ src?: string;
873
+ } | AvatarVariant;
874
+ description?: string;
875
+ primaryAction?: PrimaryActionButton | PrimaryDropdownAction<string>;
876
+ secondaryActions?: HeaderSecondaryAction[];
877
+ otherActions?: (DropdownItem & {
878
+ isVisible?: boolean;
879
+ })[];
880
+ status?: {
881
+ label: string;
882
+ text: string;
883
+ variant: StatusVariant;
884
+ actions?: MetadataAction[];
885
+ };
886
+ metadata?: MetadataProps["items"];
887
+ }
888
+
861
889
  /**
862
890
  * Represents a base structure for paginated API responses, providing
863
891
  * details about the records on the current page and pagination metadata.
@@ -3045,6 +3073,31 @@ export declare type DropIntent = {
3045
3073
  type: "cancel";
3046
3074
  };
3047
3075
 
3076
+ export declare interface DurationFieldConfig {
3077
+ suffix?: string;
3078
+ max?: number;
3079
+ /**
3080
+ * Maximum number of visible digits for this segment input.
3081
+ * Defaults to 2 when omitted.
3082
+ */
3083
+ maxVisibleDigits?: number;
3084
+ ariaLabel?: string;
3085
+ }
3086
+
3087
+ declare type DurationFieldRenderIf = DurationRenderIfCondition | CommonRenderIfCondition | F0BaseFieldRenderIfFunction;
3088
+
3089
+ export declare type DurationFields = Record<DurationUnit, number>;
3090
+
3091
+ export declare type DurationInputSize = (typeof durationInputSizes)[number];
3092
+
3093
+ export declare const durationInputSizes: readonly ["sm", "md"];
3094
+
3095
+ declare type DurationRenderIfCondition = NumberRenderIfCondition;
3096
+
3097
+ export declare type DurationUnit = (typeof durationUnits)[number];
3098
+
3099
+ export declare const durationUnits: readonly ["days", "hours", "minutes", "seconds"];
3100
+
3048
3101
  /** The edit mode for a column cell in the editable table. */
3049
3102
  declare type EditableTableCellEditType = "text" | "date" | "select" | "multiselect" | "display-only" | "disabled";
3050
3103
 
@@ -3615,6 +3668,8 @@ export declare interface F0BaseConfig {
3615
3668
  placeholder?: string;
3616
3669
  /** Helper text displayed below the field */
3617
3670
  helpText?: string;
3671
+ /** Optional non-validation field status (warning/info/error/default) */
3672
+ status?: InputFieldStatus;
3618
3673
  /**
3619
3674
  * Whether the field is disabled.
3620
3675
  * Can be a boolean or a function that receives form values.
@@ -3659,6 +3714,8 @@ export declare interface F0BaseField {
3659
3714
  validation?: ZodTypeAny;
3660
3715
  /** Helper text displayed below the field */
3661
3716
  helpText?: string;
3717
+ /** Optional non-validation field status (warning/info/error/default) */
3718
+ status?: InputFieldStatus;
3662
3719
  /** Placeholder text for the input */
3663
3720
  placeholder?: string;
3664
3721
  /**
@@ -4474,12 +4531,57 @@ export declare type F0DropdownButtonProps<T = string> = {
4474
4531
  onClick: (value: T, item: ButtonDropdownItem<T>) => void;
4475
4532
  };
4476
4533
 
4534
+ declare interface F0DurationConfig {
4535
+ units?: DurationUnit[];
4536
+ fields?: Partial<Record<DurationUnit, DurationFieldConfig>>;
4537
+ readonly?: boolean;
4538
+ size?: DurationInputSize;
4539
+ }
4540
+
4541
+ declare type F0DurationField = F0BaseField & F0DurationConfig & {
4542
+ type: "duration";
4543
+ /** Conditional rendering based on another field's value */
4544
+ renderIf?: DurationFieldRenderIf;
4545
+ };
4546
+
4547
+ /**
4548
+ * Config for duration fields (stores total seconds as number)
4549
+ */
4550
+ declare type F0DurationFieldConfig = F0BaseConfig & {
4551
+ fieldType: "duration";
4552
+ units?: DurationUnit[];
4553
+ fields?: Partial<Record<DurationUnit, DurationFieldConfig>>;
4554
+ readonly?: boolean;
4555
+ size?: DurationInputSize;
4556
+ };
4557
+
4558
+ export declare const F0DurationInput: WithDataTestIdReturnType_3<ForwardRefExoticComponent<Omit<F0DurationInputProps_2 & RefAttributes<HTMLDivElement>, "ref"> & RefAttributes<HTMLElement | SVGElement>>>;
4559
+
4560
+ export declare interface F0DurationInputProps {
4561
+ id?: string;
4562
+ "aria-describedby"?: string;
4563
+ "aria-invalid"?: AriaAttributes["aria-invalid"];
4564
+ label: string;
4565
+ ariaLabel?: string;
4566
+ hideLabel?: boolean;
4567
+ value: number;
4568
+ onChange: (seconds: number) => void;
4569
+ onBlur?: () => void;
4570
+ units?: DurationUnit[];
4571
+ fields?: Partial<Record<DurationUnit, DurationFieldConfig>>;
4572
+ status?: InputFieldStatus;
4573
+ disabled?: boolean;
4574
+ required?: boolean;
4575
+ readonly?: boolean;
4576
+ size?: DurationInputSize;
4577
+ }
4578
+
4477
4579
  export declare function F0EventCatcherProvider({ children, onEvent, enabled, catchEvents, }: EventCatcherProviderProps): JSX.Element;
4478
4580
 
4479
4581
  /**
4480
4582
  * Union of all F0 field types used for rendering
4481
4583
  */
4482
- export declare type F0Field = F0TextField | F0NumberField | F0TextareaField | F0SelectField | F0CheckboxField | F0SwitchField | F0DateField | F0TimeField | F0DateTimeField | F0DateRangeField | F0RichTextField | F0FileField | F0CustomField;
4584
+ export declare type F0Field = F0TextField | F0NumberField | F0DurationField | F0TextareaField | F0SelectField | F0CheckboxField | F0SwitchField | F0DateField | F0TimeField | F0DateTimeField | F0DateRangeField | F0RichTextField | F0FileField | F0CustomField;
4483
4585
 
4484
4586
  /**
4485
4587
  * Complete F0 field configuration (union of all possible configs)
@@ -4491,7 +4593,7 @@ export declare type F0FieldConfig<T extends string | number = string | number, R
4491
4593
  /**
4492
4594
  * Field types for rendering
4493
4595
  */
4494
- export declare type F0FieldType = "text" | "number" | "textarea" | "select" | "checkbox" | "switch" | "date" | "time" | "datetime" | "daterange" | "richtext" | "file" | "custom";
4596
+ export declare type F0FieldType = "text" | "number" | "duration" | "textarea" | "select" | "checkbox" | "switch" | "date" | "time" | "datetime" | "daterange" | "richtext" | "file" | "custom";
4495
4597
 
4496
4598
  /**
4497
4599
  * F0 config options specific to file fields
@@ -4680,10 +4782,10 @@ export declare type F0FormErrorTriggerMode = "on-blur" | "on-change" | "on-submi
4680
4782
  * without requiring a react-hook-form context.
4681
4783
  *
4682
4784
  * Supports all field types that F0Form supports: text, number, textarea,
4683
- * select, checkbox, switch, date, time, datetime, daterange, richtext, custom,
4785
+ * duration, select, checkbox, switch, date, time, datetime, daterange, richtext, custom,
4684
4786
  * and file.
4685
4787
  */
4686
- export declare function F0FormField({ field, value, onChange, onBlur, error, errorMessage, loading, required, disabled, hideLabel: hideLabelProp, initialFiles, }: F0FormFieldProps): JSX_2.Element;
4788
+ export declare function F0FormField({ field, value, onChange, onBlur, error, errorMessage, status, loading, required, disabled, hideLabel: hideLabelProp, initialFiles, }: F0FormFieldProps): JSX_2.Element;
4687
4789
 
4688
4790
  export declare namespace F0FormField {
4689
4791
  var displayName: string;
@@ -4696,7 +4798,7 @@ export declare namespace F0FormField {
4696
4798
  export declare function f0FormField<T extends z.ZodString, TConfig = undefined, R extends Record<string, unknown> = Record<string, unknown>>(schema: T, config: F0StringConfig<z.infer<T>, TConfig, R>): T & F0ZodType<T>;
4697
4799
 
4698
4800
  /**
4699
- * Number field - number input or select
4801
+ * Number field - number input, duration, or select
4700
4802
  * @typeParam R - Record type for data source (when using source instead of options)
4701
4803
  */
4702
4804
  export declare function f0FormField<T extends z.ZodNumber, R extends Record<string, unknown> = Record<string, unknown>>(schema: T, config: F0NumberFieldConfig<R>): T & F0ZodType<T>;
@@ -4776,6 +4878,8 @@ declare interface F0FormFieldCommonProps {
4776
4878
  error?: boolean;
4777
4879
  /** Error message to display */
4778
4880
  errorMessage?: string;
4881
+ /** Field status for warning/info/error/default messages */
4882
+ status?: InputFieldStatus;
4779
4883
  /** Whether the field is in a loading/validating state */
4780
4884
  loading?: boolean;
4781
4885
  /** Whether the field is required */
@@ -5138,7 +5242,7 @@ export declare type F0NumberField = F0BaseField & F0NumberConfig & {
5138
5242
  * Config for number fields
5139
5243
  * @typeParam R - Record type for data source (when using source instead of options)
5140
5244
  */
5141
- export declare type F0NumberFieldConfig<R extends Record<string, unknown> = Record<string, unknown>> = F0NumberInputConfig | F0NumberSelectConfig<R>;
5245
+ export declare type F0NumberFieldConfig<R extends Record<string, unknown> = Record<string, unknown>> = F0NumberInputConfig | F0NumberSelectConfig<R> | F0DurationFieldConfig;
5142
5246
 
5143
5247
  /**
5144
5248
  * Config for number fields - number input
@@ -5870,10 +5974,12 @@ export declare interface F0ZodType<T extends ZodTypeAny = ZodTypeAny> {
5870
5974
 
5871
5975
  /* Excluded from this release type: FieldItem */
5872
5976
 
5977
+ export declare function fieldsToSeconds(fields: DurationFields): number;
5978
+
5873
5979
  /**
5874
5980
  * Field types for rendering
5875
5981
  */
5876
- export declare type FieldType = "text" | "number" | "textarea" | "select" | "checkbox" | "switch" | "date" | "time" | "datetime" | "daterange" | "richtext" | "file" | "custom";
5982
+ export declare type FieldType = "text" | "number" | "duration" | "textarea" | "select" | "checkbox" | "switch" | "date" | "time" | "datetime" | "daterange" | "richtext" | "file" | "custom";
5877
5983
 
5878
5984
  export declare type FileAvatarVariant = Extract<AvatarVariant, {
5879
5985
  type: "file";
@@ -6400,6 +6506,10 @@ export declare function H3({ children, ...props }: React.HTMLAttributes<HTMLHead
6400
6506
  */
6401
6507
  export declare function hasF0Config(schema: ZodTypeAny): boolean;
6402
6508
 
6509
+ declare type HeaderSecondaryAction = SecondaryAction & {
6510
+ hideLabel?: boolean;
6511
+ };
6512
+
6403
6513
  declare type HeadingTags = (typeof headingTags)[number];
6404
6514
 
6405
6515
  declare const headingTags: readonly ["h1", "h2", "h3", "h4", "h5", "h6"];
@@ -6684,7 +6794,7 @@ declare type InputFieldSize = (typeof INPUTFIELD_SIZES)[number];
6684
6794
 
6685
6795
  declare type InputFieldStatus = {
6686
6796
  type: Exclude<InputFieldStatusType, "error">;
6687
- message: string;
6797
+ message?: string;
6688
6798
  } | {
6689
6799
  type: "error";
6690
6800
  message?: string;
@@ -6937,6 +7047,90 @@ declare type MentionsConfig = {
6937
7047
  users: MentionedUser[];
6938
7048
  };
6939
7049
 
7050
+ declare type MetadataAction = {
7051
+ icon: IconType;
7052
+ label: string;
7053
+ onClick: () => void;
7054
+ type?: never;
7055
+ };
7056
+
7057
+ declare type MetadataCopyAction = {
7058
+ icon?: never;
7059
+ label?: never;
7060
+ onClick?: never;
7061
+ copyValue?: string;
7062
+ type: "copy";
7063
+ };
7064
+
7065
+ declare function MetadataItem({ item }: {
7066
+ item: MetadataItem;
7067
+ }): JSX_2.Element;
7068
+
7069
+ declare interface MetadataItem {
7070
+ label: string;
7071
+ value: MetadataItemValue;
7072
+ actions?: (MetadataAction | MetadataCopyAction)[];
7073
+ hideLabel?: boolean;
7074
+ /**
7075
+ * Optional info text. When provided, displays an info icon next to the label
7076
+ * that shows this text in a tooltip when hovered.
7077
+ */
7078
+ info?: {
7079
+ title: string;
7080
+ description?: string;
7081
+ };
7082
+ }
7083
+
7084
+ declare type MetadataItemValue = {
7085
+ type: "text";
7086
+ content: string;
7087
+ } | {
7088
+ type: "avatar";
7089
+ variant: AvatarVariant;
7090
+ text: string;
7091
+ } | {
7092
+ type: "status";
7093
+ label: string;
7094
+ variant: StatusVariant;
7095
+ } | ({
7096
+ type: "list";
7097
+ } & ({
7098
+ variant: "person";
7099
+ avatars: (PersonAvatarVariant | (PersonAvatarVariant & Record<string, unknown>))[];
7100
+ } | {
7101
+ variant: "team";
7102
+ avatars: (TeamAvatarVariant | (TeamAvatarVariant & Record<string, unknown>))[];
7103
+ } | {
7104
+ variant: "company";
7105
+ avatars: (CompanyAvatarVariant | (CompanyAvatarVariant & Record<string, unknown>))[];
7106
+ })) | {
7107
+ type: "data-list";
7108
+ data: string[];
7109
+ } | {
7110
+ type: "tag-list";
7111
+ tags: string[];
7112
+ } | {
7113
+ type: "dot-tag";
7114
+ label: string;
7115
+ color: NewColor;
7116
+ } | {
7117
+ type: "date";
7118
+ formattedDate: string;
7119
+ icon?: "warning" | "critical";
7120
+ };
7121
+
7122
+ declare interface MetadataProps {
7123
+ /**
7124
+ * Everything is not a MetadataItem is ignored.
7125
+ * Undefined and boolean enable conditional items
7126
+ **/
7127
+ items: (MetadataItem | undefined | boolean)[];
7128
+ /**
7129
+ * If true and the metadata type is a list, it will be collapsed to the first item
7130
+ */
7131
+ collapse?: boolean;
7132
+ }
7133
+
6940
7134
  /** How to format the metric value */
6941
7135
  export declare type MetricFormat = {
6942
7136
  type: "number";
@@ -7585,6 +7779,18 @@ declare type PrevNextDateNavigation = {
7585
7779
  next: DateRange | false;
7586
7780
  };
7587
7781
 
7782
+ declare interface PrimaryAction {
7783
+ disabled?: boolean;
7784
+ tooltip?: string;
7785
+ isVisible?: boolean;
7786
+ }
7787
+
7788
+ declare interface PrimaryActionButton extends PrimaryAction {
7789
+ label: string;
7790
+ icon?: IconType;
7791
+ onClick: () => void;
7792
+ }
7793
+
7588
7794
  declare type PrimaryActionItemDefinition = Pick<DropdownItemObject, "label" | "icon" | "description"> & {
7589
7795
  loading?: boolean;
7590
7796
  onClick?: () => void | Promise<void>;
@@ -7597,6 +7803,12 @@ declare type PrimaryActionItemDefinition = Pick<DropdownItemObject, "label" | "i
7597
7803
  */
7598
7804
  declare type PrimaryActionsDefinitionFn = () => PrimaryActionItemDefinition | PrimaryActionItemDefinition[] | undefined;
7599
7805
 
7806
+ declare interface PrimaryDropdownAction<T> extends PrimaryAction {
7807
+ items: ButtonDropdownItem<T>[];
7808
+ value?: T;
7809
+ onClick: (value: T, item: ButtonDropdownItem<T>) => void;
7810
+ }
7811
+
7600
7812
  export declare const PrivacyModeProvider: React_2.FC<{
7601
7813
  initiallyEnabled?: boolean;
7602
7814
  children: ReactNode;
@@ -7804,6 +8016,8 @@ declare type Props_3 = {
7804
8016
  list?: TagCounterItem[];
7805
8017
  };
7806
8018
 
8019
+ declare type Props_4 = {} & Pick<BaseHeaderProps, "avatar" | "title" | "description" | "primaryAction" | "secondaryActions" | "otherActions" | "metadata" | "status" | "deactivated">;
8020
+
7807
8021
  export declare type QuestionActionParams = {
7808
8022
  questionId: string;
7809
8023
  type: ActionType;
@@ -7904,6 +8118,8 @@ export declare type RenderIfCondition = CommonRenderIfCondition | TextRenderIfCo
7904
8118
 
7905
8119
  export declare type ResolvedRecordType<R> = R extends RecordType ? R : RecordType;
7906
8120
 
8121
+ declare type ResourceHeaderProps = Props_4;
8122
+
7907
8123
  /** All styling props that can be overridden per breakpoint */
7908
8124
  export declare interface ResponsiveStyleProps {
7909
8125
  display?: DisplayToken;
@@ -7994,6 +8210,10 @@ declare type SearchOptions = {
7994
8210
  debounceTime?: number;
7995
8211
  };
7996
8212
 
8213
+ declare interface SecondaryAction extends PrimaryActionButton {
8214
+ variant?: "outline" | "critical" | "outlinePromote" | "promote";
8215
+ }
8216
+
7997
8217
  declare type SecondaryActionGroup = {
7998
8218
  label?: string;
7999
8219
  items: SecondaryActionItem[];
@@ -8018,6 +8238,10 @@ declare type SecondaryActionsDefinition = {
8018
8238
 
8019
8239
  declare type SecondaryActionsItems = SecondaryActionItem[] | SecondaryActionItem[][] | SecondaryActionGroup[];
8020
8240
 
8241
+ export declare function secondsToFields(totalSeconds: number): DurationFields;
8242
+
8243
+ export declare function secondsToVisibleFields(totalSeconds: number, visibleUnits: DurationUnit[]): DurationFields;
8244
+
8021
8245
  export declare type SectionActionParams = {
8022
8246
  sectionId: string;
8023
8247
  type: ActionType;
@@ -8252,15 +8476,18 @@ declare type SummaryKey<Definition extends SummariesDefinition> = Definition ext
8252
8476
 
8253
8477
  declare type SummaryType = "sum";
8254
8478
 
8255
- export declare function SurveyAnsweringForm({ elements, onSubmit: onSubmitProp, mode, title, isOpen, onClose, fullscreen: fullscreenProp, allowToChangeFullscreen, defaultValues, errorTriggerMode, loading, labels, preview, }: SurveyAnsweringFormProps): JSX_2.Element;
8479
+ export declare function SurveyAnsweringForm({ elements, onSubmit: onSubmitProp, mode, title, description, resourceHeader, isOpen, onClose, position: positionProp, module, allowToChangeFullscreen, defaultValues, errorTriggerMode, loading, labels, preview, }: SurveyAnsweringFormProps): JSX_2.Element;
8256
8480
 
8257
8481
  declare interface SurveyAnsweringFormBaseProps {
8258
8482
  elements: SurveyFormBuilderElement[];
8259
8483
  mode: SurveyAnsweringFormMode;
8260
8484
  title: string;
8485
+ description?: string;
8486
+ resourceHeader?: Omit<ResourceHeaderProps, "title" | "description">;
8487
+ module: SurveyAnsweringFormModule;
8488
+ position?: DialogPosition;
8261
8489
  isOpen: boolean;
8262
8490
  onClose: () => void;
8263
- fullscreen?: boolean;
8264
8491
  allowToChangeFullscreen?: boolean;
8265
8492
  defaultValues?: Partial<SurveyAnswers>;
8266
8493
  errorTriggerMode?: F0FormErrorTriggerMode;
@@ -8274,17 +8501,23 @@ declare interface SurveyAnsweringFormBaseProps {
8274
8501
  };
8275
8502
  }
8276
8503
 
8277
- declare interface SurveyAnsweringFormDefaultProps extends SurveyAnsweringFormBaseProps {
8504
+ declare type SurveyAnsweringFormDefaultProps = SurveyAnsweringFormBaseProps & {
8278
8505
  preview?: false;
8279
8506
  onSubmit: (answers: SurveySubmitAnswers) => Promise<SurveyFormSubmitResult> | SurveyFormSubmitResult;
8280
- }
8507
+ };
8281
8508
 
8282
8509
  export declare type SurveyAnsweringFormMode = "stepped" | "all-questions";
8283
8510
 
8284
- declare interface SurveyAnsweringFormPreviewProps extends SurveyAnsweringFormBaseProps {
8511
+ declare type SurveyAnsweringFormModule = {
8512
+ id: ModuleId;
8513
+ label: string;
8514
+ href: string;
8515
+ };
8516
+
8517
+ declare type SurveyAnsweringFormPreviewProps = SurveyAnsweringFormBaseProps & {
8285
8518
  preview: true;
8286
8519
  onSubmit?: never;
8287
- }
8520
+ };
8288
8521
 
8289
8522
  export declare type SurveyAnsweringFormProps = SurveyAnsweringFormDefaultProps | SurveyAnsweringFormPreviewProps;
8290
8523