@factorialco/f0-react 1.401.0 → 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.
@@ -2827,6 +2855,13 @@ export declare const defaultTranslations: {
2827
2855
  readonly expand: "Expand";
2828
2856
  readonly collapse: "Collapse";
2829
2857
  };
2858
+ readonly labels: {
2859
+ readonly empty: {
2860
+ readonly title: "No questions to answer";
2861
+ readonly description: "This survey has no questions yet.";
2862
+ readonly emoji: "📝";
2863
+ };
2864
+ };
2830
2865
  };
2831
2866
  readonly richTextEditor: {
2832
2867
  readonly bold: "Bold";
@@ -3038,6 +3073,31 @@ export declare type DropIntent = {
3038
3073
  type: "cancel";
3039
3074
  };
3040
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
+
3041
3101
  /** The edit mode for a column cell in the editable table. */
3042
3102
  declare type EditableTableCellEditType = "text" | "date" | "select" | "multiselect" | "display-only" | "disabled";
3043
3103
 
@@ -3608,6 +3668,8 @@ export declare interface F0BaseConfig {
3608
3668
  placeholder?: string;
3609
3669
  /** Helper text displayed below the field */
3610
3670
  helpText?: string;
3671
+ /** Optional non-validation field status (warning/info/error/default) */
3672
+ status?: InputFieldStatus;
3611
3673
  /**
3612
3674
  * Whether the field is disabled.
3613
3675
  * Can be a boolean or a function that receives form values.
@@ -3652,6 +3714,8 @@ export declare interface F0BaseField {
3652
3714
  validation?: ZodTypeAny;
3653
3715
  /** Helper text displayed below the field */
3654
3716
  helpText?: string;
3717
+ /** Optional non-validation field status (warning/info/error/default) */
3718
+ status?: InputFieldStatus;
3655
3719
  /** Placeholder text for the input */
3656
3720
  placeholder?: string;
3657
3721
  /**
@@ -4467,12 +4531,57 @@ export declare type F0DropdownButtonProps<T = string> = {
4467
4531
  onClick: (value: T, item: ButtonDropdownItem<T>) => void;
4468
4532
  };
4469
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
+
4470
4579
  export declare function F0EventCatcherProvider({ children, onEvent, enabled, catchEvents, }: EventCatcherProviderProps): JSX.Element;
4471
4580
 
4472
4581
  /**
4473
4582
  * Union of all F0 field types used for rendering
4474
4583
  */
4475
- 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;
4476
4585
 
4477
4586
  /**
4478
4587
  * Complete F0 field configuration (union of all possible configs)
@@ -4484,7 +4593,7 @@ export declare type F0FieldConfig<T extends string | number = string | number, R
4484
4593
  /**
4485
4594
  * Field types for rendering
4486
4595
  */
4487
- 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";
4488
4597
 
4489
4598
  /**
4490
4599
  * F0 config options specific to file fields
@@ -4673,10 +4782,10 @@ export declare type F0FormErrorTriggerMode = "on-blur" | "on-change" | "on-submi
4673
4782
  * without requiring a react-hook-form context.
4674
4783
  *
4675
4784
  * Supports all field types that F0Form supports: text, number, textarea,
4676
- * select, checkbox, switch, date, time, datetime, daterange, richtext, custom,
4785
+ * duration, select, checkbox, switch, date, time, datetime, daterange, richtext, custom,
4677
4786
  * and file.
4678
4787
  */
4679
- 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;
4680
4789
 
4681
4790
  export declare namespace F0FormField {
4682
4791
  var displayName: string;
@@ -4689,7 +4798,7 @@ export declare namespace F0FormField {
4689
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>;
4690
4799
 
4691
4800
  /**
4692
- * Number field - number input or select
4801
+ * Number field - number input, duration, or select
4693
4802
  * @typeParam R - Record type for data source (when using source instead of options)
4694
4803
  */
4695
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>;
@@ -4769,6 +4878,8 @@ declare interface F0FormFieldCommonProps {
4769
4878
  error?: boolean;
4770
4879
  /** Error message to display */
4771
4880
  errorMessage?: string;
4881
+ /** Field status for warning/info/error/default messages */
4882
+ status?: InputFieldStatus;
4772
4883
  /** Whether the field is in a loading/validating state */
4773
4884
  loading?: boolean;
4774
4885
  /** Whether the field is required */
@@ -5131,7 +5242,7 @@ export declare type F0NumberField = F0BaseField & F0NumberConfig & {
5131
5242
  * Config for number fields
5132
5243
  * @typeParam R - Record type for data source (when using source instead of options)
5133
5244
  */
5134
- 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;
5135
5246
 
5136
5247
  /**
5137
5248
  * Config for number fields - number input
@@ -5311,6 +5422,8 @@ export declare interface F0SectionConfig {
5311
5422
  title: string;
5312
5423
  /** Section description */
5313
5424
  description?: string;
5425
+ /** Applies default horizontal inset to the section header (title/subtitle/action row) */
5426
+ withInset?: boolean;
5314
5427
  /** Conditional rendering for the entire section */
5315
5428
  renderIf?: SectionRenderIf;
5316
5429
  /** Optional action button for the section */
@@ -5861,10 +5974,12 @@ export declare interface F0ZodType<T extends ZodTypeAny = ZodTypeAny> {
5861
5974
 
5862
5975
  /* Excluded from this release type: FieldItem */
5863
5976
 
5977
+ export declare function fieldsToSeconds(fields: DurationFields): number;
5978
+
5864
5979
  /**
5865
5980
  * Field types for rendering
5866
5981
  */
5867
- 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";
5868
5983
 
5869
5984
  export declare type FileAvatarVariant = Extract<AvatarVariant, {
5870
5985
  type: "file";
@@ -6391,6 +6506,10 @@ export declare function H3({ children, ...props }: React.HTMLAttributes<HTMLHead
6391
6506
  */
6392
6507
  export declare function hasF0Config(schema: ZodTypeAny): boolean;
6393
6508
 
6509
+ declare type HeaderSecondaryAction = SecondaryAction & {
6510
+ hideLabel?: boolean;
6511
+ };
6512
+
6394
6513
  declare type HeadingTags = (typeof headingTags)[number];
6395
6514
 
6396
6515
  declare const headingTags: readonly ["h1", "h2", "h3", "h4", "h5", "h6"];
@@ -6675,7 +6794,7 @@ declare type InputFieldSize = (typeof INPUTFIELD_SIZES)[number];
6675
6794
 
6676
6795
  declare type InputFieldStatus = {
6677
6796
  type: Exclude<InputFieldStatusType, "error">;
6678
- message: string;
6797
+ message?: string;
6679
6798
  } | {
6680
6799
  type: "error";
6681
6800
  message?: string;
@@ -6928,6 +7047,90 @@ declare type MentionsConfig = {
6928
7047
  users: MentionedUser[];
6929
7048
  };
6930
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
+
6931
7134
  /** How to format the metric value */
6932
7135
  export declare type MetricFormat = {
6933
7136
  type: "number";
@@ -7576,6 +7779,18 @@ declare type PrevNextDateNavigation = {
7576
7779
  next: DateRange | false;
7577
7780
  };
7578
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
+
7579
7794
  declare type PrimaryActionItemDefinition = Pick<DropdownItemObject, "label" | "icon" | "description"> & {
7580
7795
  loading?: boolean;
7581
7796
  onClick?: () => void | Promise<void>;
@@ -7588,6 +7803,12 @@ declare type PrimaryActionItemDefinition = Pick<DropdownItemObject, "label" | "i
7588
7803
  */
7589
7804
  declare type PrimaryActionsDefinitionFn = () => PrimaryActionItemDefinition | PrimaryActionItemDefinition[] | undefined;
7590
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
+
7591
7812
  export declare const PrivacyModeProvider: React_2.FC<{
7592
7813
  initiallyEnabled?: boolean;
7593
7814
  children: ReactNode;
@@ -7795,6 +8016,8 @@ declare type Props_3 = {
7795
8016
  list?: TagCounterItem[];
7796
8017
  };
7797
8018
 
8019
+ declare type Props_4 = {} & Pick<BaseHeaderProps, "avatar" | "title" | "description" | "primaryAction" | "secondaryActions" | "otherActions" | "metadata" | "status" | "deactivated">;
8020
+
7798
8021
  export declare type QuestionActionParams = {
7799
8022
  questionId: string;
7800
8023
  type: ActionType;
@@ -7895,6 +8118,8 @@ export declare type RenderIfCondition = CommonRenderIfCondition | TextRenderIfCo
7895
8118
 
7896
8119
  export declare type ResolvedRecordType<R> = R extends RecordType ? R : RecordType;
7897
8120
 
8121
+ declare type ResourceHeaderProps = Props_4;
8122
+
7898
8123
  /** All styling props that can be overridden per breakpoint */
7899
8124
  export declare interface ResponsiveStyleProps {
7900
8125
  display?: DisplayToken;
@@ -7985,6 +8210,10 @@ declare type SearchOptions = {
7985
8210
  debounceTime?: number;
7986
8211
  };
7987
8212
 
8213
+ declare interface SecondaryAction extends PrimaryActionButton {
8214
+ variant?: "outline" | "critical" | "outlinePromote" | "promote";
8215
+ }
8216
+
7988
8217
  declare type SecondaryActionGroup = {
7989
8218
  label?: string;
7990
8219
  items: SecondaryActionItem[];
@@ -8009,6 +8238,10 @@ declare type SecondaryActionsDefinition = {
8009
8238
 
8010
8239
  declare type SecondaryActionsItems = SecondaryActionItem[] | SecondaryActionItem[][] | SecondaryActionGroup[];
8011
8240
 
8241
+ export declare function secondsToFields(totalSeconds: number): DurationFields;
8242
+
8243
+ export declare function secondsToVisibleFields(totalSeconds: number, visibleUnits: DurationUnit[]): DurationFields;
8244
+
8012
8245
  export declare type SectionActionParams = {
8013
8246
  sectionId: string;
8014
8247
  type: ActionType;
@@ -8243,23 +8476,51 @@ declare type SummaryKey<Definition extends SummariesDefinition> = Definition ext
8243
8476
 
8244
8477
  declare type SummaryType = "sum";
8245
8478
 
8246
- export declare function SurveyAnsweringForm({ elements, onSubmit, mode, title, isOpen, onClose, fullscreen: fullscreenProp, allowToChangeFullscreen, defaultValues, errorTriggerMode, }: SurveyAnsweringFormProps): JSX_2.Element;
8247
-
8248
- export declare type SurveyAnsweringFormMode = "stepped" | "all-questions";
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;
8249
8480
 
8250
- export declare interface SurveyAnsweringFormProps {
8481
+ declare interface SurveyAnsweringFormBaseProps {
8251
8482
  elements: SurveyFormBuilderElement[];
8252
- onSubmit: (answers: SurveySubmitAnswers) => Promise<SurveyFormSubmitResult> | SurveyFormSubmitResult;
8253
8483
  mode: SurveyAnsweringFormMode;
8254
8484
  title: string;
8485
+ description?: string;
8486
+ resourceHeader?: Omit<ResourceHeaderProps, "title" | "description">;
8487
+ module: SurveyAnsweringFormModule;
8488
+ position?: DialogPosition;
8255
8489
  isOpen: boolean;
8256
8490
  onClose: () => void;
8257
- fullscreen?: boolean;
8258
8491
  allowToChangeFullscreen?: boolean;
8259
8492
  defaultValues?: Partial<SurveyAnswers>;
8260
8493
  errorTriggerMode?: F0FormErrorTriggerMode;
8494
+ loading?: boolean;
8495
+ labels?: {
8496
+ empty?: {
8497
+ title?: string;
8498
+ description?: string;
8499
+ emoji?: string;
8500
+ };
8501
+ };
8261
8502
  }
8262
8503
 
8504
+ declare type SurveyAnsweringFormDefaultProps = SurveyAnsweringFormBaseProps & {
8505
+ preview?: false;
8506
+ onSubmit: (answers: SurveySubmitAnswers) => Promise<SurveyFormSubmitResult> | SurveyFormSubmitResult;
8507
+ };
8508
+
8509
+ export declare type SurveyAnsweringFormMode = "stepped" | "all-questions";
8510
+
8511
+ declare type SurveyAnsweringFormModule = {
8512
+ id: ModuleId;
8513
+ label: string;
8514
+ href: string;
8515
+ };
8516
+
8517
+ declare type SurveyAnsweringFormPreviewProps = SurveyAnsweringFormBaseProps & {
8518
+ preview: true;
8519
+ onSubmit?: never;
8520
+ };
8521
+
8522
+ export declare type SurveyAnsweringFormProps = SurveyAnsweringFormDefaultProps | SurveyAnsweringFormPreviewProps;
8523
+
8263
8524
  export declare type SurveyAnswers = Record<string, SurveyAnswerValue>;
8264
8525
 
8265
8526
  export declare type SurveyAnswerValue = {