{
  "version": 3,
  "sources": ["../../src/types/field-api.ts"],
  "sourcesContent": ["/**\n * External dependencies\n */\nimport type { ReactElement, ComponentType } from 'react';\n\n/**\n * Utility type that makes all properties of T optional recursively.\n * Used by field setValue functions to allow partial item updates.\n */\nexport type DeepPartial< T > = {\n\t[ P in keyof T ]?: T[ P ] extends object ? DeepPartial< T[ P ] > : T[ P ];\n};\n\nexport type SortDirection = 'asc' | 'desc';\n\n/**\n * Generic option type.\n */\nexport interface Option< Value extends any = any > {\n\tvalue: Value;\n\tlabel: string;\n\tdescription?: string;\n}\n\nexport interface FilterByConfig {\n\t/**\n\t * The list of operators supported by the field.\n\t */\n\toperators?: Operator[];\n\n\t/**\n\t * Whether it is a primary filter.\n\t *\n\t * A primary filter is always visible and is not listed in the \"Add filter\" component,\n\t * except for the list layout where it behaves like a secondary filter.\n\t */\n\tisPrimary?: boolean;\n}\n\nexport type Operator =\n\t| 'is'\n\t| 'isNot'\n\t| 'isAny'\n\t| 'isNone'\n\t| 'isAll'\n\t| 'isNotAll'\n\t| 'lessThan'\n\t| 'greaterThan'\n\t| 'lessThanOrEqual'\n\t| 'greaterThanOrEqual'\n\t| 'before'\n\t| 'after'\n\t| 'beforeInc'\n\t| 'afterInc'\n\t| 'contains'\n\t| 'notContains'\n\t| 'startsWith'\n\t| 'between'\n\t| 'on'\n\t| 'notOn'\n\t| 'inThePast'\n\t| 'over';\n\nexport type FieldTypeName =\n\t| 'text'\n\t| 'integer'\n\t| 'number'\n\t| 'datetime'\n\t| 'date'\n\t| 'media'\n\t| 'boolean'\n\t| 'email'\n\t| 'password'\n\t| 'telephone'\n\t| 'color'\n\t| 'url'\n\t| 'array';\n\nexport type Rules< Item > = {\n\trequired?: boolean;\n\telements?: boolean;\n\tpattern?: string;\n\tminLength?: number;\n\tmaxLength?: number;\n\tmin?: number;\n\tmax?: number;\n\tcustom?:\n\t\t| ( ( item: Item, field: NormalizedField< Item > ) => null | string )\n\t\t| ( (\n\t\t\t\titem: Item,\n\t\t\t\tfield: NormalizedField< Item >\n\t\t  ) => Promise< null | string > );\n};\n\nexport type Validator< Item > = (\n\titem: Item,\n\tfield: NormalizedField< Item >\n) => boolean;\n\nexport type CustomValidator< Item > =\n\t| ( ( item: Item, field: NormalizedField< Item > ) => null | string )\n\t| ( (\n\t\t\titem: Item,\n\t\t\tfield: NormalizedField< Item >\n\t  ) => Promise< null | string > );\n\nexport type FilterOperator< Item > = (\n\titem: Item,\n\tfield: NormalizedField< Item >,\n\tfilterValue: any\n) => boolean;\n\nexport type FilterOperatorMap< Item > = Partial<\n\tRecord< Operator, FilterOperator< Item > >\n>;\n\ntype NormalizedRule< Item, ConstraintType > = {\n\tconstraint: ConstraintType;\n\tvalidate: Validator< Item >;\n};\n\nexport type NormalizedRules< Item > = {\n\trequired?: NormalizedRule< Item, boolean >;\n\telements?: NormalizedRule< Item, boolean >;\n\tpattern?: NormalizedRule< Item, string >;\n\tminLength?: NormalizedRule< Item, number >;\n\tmaxLength?: NormalizedRule< Item, number >;\n\tmin?: NormalizedRule< Item, number >;\n\tmax?: NormalizedRule< Item, number >;\n\tcustom?: CustomValidator< Item >;\n};\n\n/**\n * Edit configuration for textarea controls.\n */\nexport type EditConfigTextarea = {\n\tcontrol: 'textarea';\n\t/**\n\t * Number of rows for the textarea.\n\t */\n\trows?: number;\n};\n\n/**\n * Edit configuration for text controls.\n */\nexport type EditConfigText = {\n\tcontrol: 'text';\n\t/**\n\t * Prefix component to display before the input.\n\t */\n\tprefix?: React.ComponentType;\n\t/**\n\t * Suffix component to display after the input.\n\t */\n\tsuffix?: React.ComponentType;\n};\n\n/**\n * Edit configuration for datetime controls.\n */\nexport type EditConfigDatetime = {\n\tcontrol: 'datetime';\n\t/**\n\t * Whether to render a compact version without the calendar widget.\n\t */\n\tcompact?: boolean;\n};\n\n/**\n * Edit configuration for other control types (excluding 'text', 'textarea', and 'datetime').\n */\nexport type EditConfigGeneric = {\n\tcontrol: Exclude< FieldTypeName, 'text' | 'textarea' | 'datetime' >;\n};\n\n/**\n * Edit configuration object with type-safe control options.\n * Each control type has its own specific configuration properties.\n */\nexport type EditConfig =\n\t| EditConfigTextarea\n\t| EditConfigText\n\t| EditConfigDatetime\n\t| EditConfigGeneric;\n\n/**\n * A dataview field for a specific property of a data type.\n */\nexport type Field< Item > = {\n\t/**\n\t * Type of the fields.\n\t */\n\ttype?: FieldTypeName;\n\n\t/**\n\t * The unique identifier of the field.\n\t */\n\tid: string;\n\n\t/**\n\t * The label of the field. Defaults to the id.\n\t */\n\tlabel?: string;\n\n\t/**\n\t * The header of the field. Defaults to the label.\n\t * It allows the usage of a React Element to render the field labels.\n\t */\n\theader?: string | ReactElement;\n\n\t/**\n\t * A description of the field.\n\t */\n\tdescription?: string | ReactElement;\n\n\t/**\n\t * Placeholder for the field.\n\t */\n\tplaceholder?: string;\n\n\t/**\n\t * Callback used to render the field. Defaults to `field.getValue`.\n\t */\n\trender?: ComponentType< DataViewRenderFieldProps< Item > >;\n\n\t/**\n\t * Callback used to render an edit control for the field.\n\t */\n\tEdit?: ComponentType< DataFormControlProps< Item > > | string | EditConfig;\n\n\t/**\n\t * Callback used to sort the field.\n\t */\n\tsort?: ( a: Item, b: Item, direction: SortDirection ) => number;\n\n\t/**\n\t * Callback used to validate the field.\n\t */\n\tisValid?: Rules< Item >;\n\n\t/**\n\t * Callback used to decide if a field should be displayed.\n\t */\n\tisVisible?: ( item: Item ) => boolean;\n\n\t/**\n\t * Whether the field is sortable.\n\t */\n\tenableSorting?: boolean;\n\n\t/**\n\t * Whether the field is searchable.\n\t */\n\tenableGlobalSearch?: boolean;\n\n\t/**\n\t * Whether the field can be hidden in the UI.\n\t */\n\tenableHiding?: boolean;\n\n\t/**\n\t * The list of options to pick from when using the field as a filter.\n\t */\n\telements?: Option[];\n\n\t/**\n\t * Retrieval function for elements.\n\t */\n\tgetElements?: () => Promise< Option[] >;\n\n\t/**\n\t * Filter config for the field.\n\t */\n\tfilterBy?: FilterByConfig | false;\n\n\t/**\n\t * Whether the field is readOnly.\n\t * If `true`, the value will be rendered using the `render` callback.\n\t */\n\treadOnly?: boolean;\n\n\t/**\n\t * Callback used to retrieve the value of the field from the item.\n\t * Defaults to `item[ field.id ]`.\n\t */\n\tgetValue?: ( args: { item: Item } ) => any;\n\n\t/**\n\t * Callback used to set the value of the field on the item.\n\t * Used for editing operations to update field values.\n\t */\n\tsetValue?: ( args: { item: Item; value: any } ) => DeepPartial< Item >;\n\n\t/**\n\t * Display format configuration for fields.\n\t */\n\tformat?: FormatDatetime | FormatDate | FormatNumber | FormatInteger;\n\n\t/**\n\t * Callback used to format the value of the field for display.\n\t */\n\tgetValueFormatted?: ( {\n\t\titem,\n\t\tfield,\n\t}: {\n\t\titem: Item;\n\t\tfield: NormalizedField< Item >;\n\t} ) => string;\n};\n\n/**\n * Format for datetime fields:\n *\n * - datetime: the format string (e.g., \"M j, Y g:i a\" for \"Jan 1, 2021 2:30 pm\").\n * - weekStartsOn: to specify the first day of the week (0 for 'sunday', 1 for 'monday', etc.).\n *\n * If not provided, defaults to WordPress date format settings.\n */\nexport type FormatDatetime = {\n\tdatetime?: string;\n\tweekStartsOn?: DayNumber;\n};\n\n/**\n * Format for date fields:\n *\n * - date: the format string (e.g., 'F j, Y' for 'March 10, 2023')\n * - weekStartsOn: to specify the first day of the week (0 for 'sunday', 1 for 'monday', etc.).\n *\n * If not provided, defaults to WordPress date format settings.\n */\nexport type FormatDate = {\n\tdate?: string;\n\tweekStartsOn?: DayNumber;\n};\nexport type DayNumber = 0 | 1 | 2 | 3 | 4 | 5 | 6;\n\n/**\n * Format for number fields:\n *\n * - separatorThousand: character to use for thousand separators (e.g., ',')\n * - separatorDecimal: character to use for decimal point (e.g., '.')\n * - decimals: number of decimal places to display (e.g., 2)\n *\n * If not provided, defaults to ',' for thousands, '.' for decimal, 2 decimals.\n */\nexport type FormatNumber = {\n\tseparatorThousand?: string;\n\tseparatorDecimal?: string;\n\tdecimals?: number;\n};\n\n/**\n * Format for integer fields:\n *\n * - separatorThousand: character to use for thousand separators (e.g., ',')\n *\n * If not provided, defaults to ',' for thousands.\n */\nexport type FormatInteger = {\n\tseparatorThousand?: string;\n};\n\nexport type NormalizedField< Item > = Omit<\n\tField< Item >,\n\t'Edit' | 'isValid'\n> & {\n\tlabel: string;\n\theader: string | ReactElement;\n\tgetValue: ( args: { item: Item } ) => any;\n\tsetValue: ( args: { item: Item; value: any } ) => DeepPartial< Item >;\n\trender: ComponentType< DataViewRenderFieldProps< Item > >;\n\tEdit: ComponentType< DataFormControlProps< Item > > | null;\n\thasElements: boolean;\n\tsort: ( a: Item, b: Item, direction: SortDirection ) => number;\n\tisValid: NormalizedRules< Item >;\n\tenableHiding: boolean;\n\tenableSorting: boolean;\n\tfilterBy: Required< FilterByConfig > | false;\n\tfilter: FilterOperatorMap< Item >;\n\treadOnly: boolean;\n\tformat:\n\t\t| {}\n\t\t| Required< FormatDate >\n\t\t| Required< FormatInteger >\n\t\t| Required< FormatNumber >;\n\tgetValueFormatted: ( {\n\t\titem,\n\t\tfield,\n\t}: {\n\t\titem: Item;\n\t\tfield: NormalizedField< Item >;\n\t} ) => string;\n};\n\n/**\n * A collection of dataview fields for a data type.\n */\nexport type Fields< Item > = Field< Item >[];\n\nexport type FieldValidity = {\n\trequired?: {\n\t\ttype: 'valid' | 'invalid' | 'validating';\n\t\tmessage?: string;\n\t};\n\tpattern?: {\n\t\ttype: 'valid' | 'invalid' | 'validating';\n\t\tmessage: string;\n\t};\n\tmin?: {\n\t\ttype: 'valid' | 'invalid' | 'validating';\n\t\tmessage: string;\n\t};\n\tmax?: {\n\t\ttype: 'valid' | 'invalid' | 'validating';\n\t\tmessage: string;\n\t};\n\tminLength?: {\n\t\ttype: 'valid' | 'invalid' | 'validating';\n\t\tmessage: string;\n\t};\n\tmaxLength?: {\n\t\ttype: 'valid' | 'invalid' | 'validating';\n\t\tmessage: string;\n\t};\n\telements?: {\n\t\ttype: 'valid' | 'invalid' | 'validating';\n\t\tmessage: string;\n\t};\n\tcustom?: {\n\t\ttype: 'valid' | 'invalid' | 'validating';\n\t\tmessage: string;\n\t};\n\tchildren?: Record< string, FieldValidity >;\n};\n\nexport type DataFormControlProps< Item > = {\n\tdata: Item;\n\tfield: NormalizedField< Item >;\n\tonChange: ( value: DeepPartial< Item > ) => void;\n\thideLabelFromVision?: boolean;\n\t/**\n\t * Label the control as \"optional\" when _not_ required, instead of showing \"required\".\n\t */\n\tmarkWhenOptional?: boolean;\n\t/**\n\t * The currently selected filter operator for this field.\n\t *\n\t * Used by DataViews filters to determine which control to render based on the operator type.\n\t */\n\toperator?: Operator;\n\t/**\n\t * Validity information for the field, if any.\n\t */\n\tvalidity?: FieldValidity;\n\t/**\n\t * Configuration object for the control.\n\t */\n\tconfig?: {\n\t\tprefix?: React.ComponentType;\n\t\tsuffix?: React.ComponentType;\n\t\trows?: number;\n\t\tcompact?: boolean;\n\t};\n};\n\nexport type DataViewRenderFieldProps< Item > = {\n\titem: Item;\n\tfield: NormalizedField< Item >;\n\tconfig?: {\n\t\tsizes: string;\n\t};\n};\n"],
  "mappings": ";;;;;;;;;;;;;;;;AAAA;AAAA;",
  "names": []
}
