@payloadcms/ui 3.0.0-beta.52 → 3.0.0-beta.54
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/@types/assets.d.js.map +1 -1
- package/dist/assets/index.js.map +1 -1
- package/dist/elements/AppHeader/index.js.map +1 -1
- package/dist/elements/ArrayAction/index.js.map +1 -1
- package/dist/elements/Autosave/index.js.map +1 -1
- package/dist/elements/Banner/index.js.map +1 -1
- package/dist/elements/Button/index.js.map +1 -1
- package/dist/elements/Button/types.js.map +1 -1
- package/dist/elements/Card/index.js.map +1 -1
- package/dist/elements/CodeEditor/CodeEditor.js.map +1 -1
- package/dist/elements/CodeEditor/index.js.map +1 -1
- package/dist/elements/CodeEditor/types.js.map +1 -1
- package/dist/elements/Collapsible/index.js.map +1 -1
- package/dist/elements/Collapsible/provider.js.map +1 -1
- package/dist/elements/ColumnSelector/index.js.map +1 -1
- package/dist/elements/CopyToClipboard/index.js.map +1 -1
- package/dist/elements/DatePicker/DatePicker.js.map +1 -1
- package/dist/elements/DatePicker/getFormattedLocale.js.map +1 -1
- package/dist/elements/DatePicker/index.js.map +1 -1
- package/dist/elements/DatePicker/types.js.map +1 -1
- package/dist/elements/DeleteDocument/index.js.map +1 -1
- package/dist/elements/DeleteMany/index.js.map +1 -1
- package/dist/elements/DocumentControls/index.js.map +1 -1
- package/dist/elements/DocumentDrawer/DrawerContent.js +2 -2
- package/dist/elements/DocumentDrawer/DrawerContent.js.map +1 -1
- package/dist/elements/DocumentDrawer/index.js.map +1 -1
- package/dist/elements/DocumentDrawer/types.js.map +1 -1
- package/dist/elements/DocumentFields/index.js.map +1 -1
- package/dist/elements/DraggableSortable/DraggableSortableItem/index.js.map +1 -1
- package/dist/elements/DraggableSortable/DraggableSortableItem/types.js.map +1 -1
- package/dist/elements/DraggableSortable/index.js.map +1 -1
- package/dist/elements/DraggableSortable/types.js.map +1 -1
- package/dist/elements/DraggableSortable/useDraggableSortable/index.js.map +1 -1
- package/dist/elements/DraggableSortable/useDraggableSortable/types.js.map +1 -1
- package/dist/elements/Drawer/index.js.map +1 -1
- package/dist/elements/Drawer/types.js.map +1 -1
- package/dist/elements/Drawer/useDrawerSlug.js.map +1 -1
- package/dist/elements/Dropzone/index.js.map +1 -1
- package/dist/elements/DuplicateDocument/index.js.map +1 -1
- package/dist/elements/EditMany/index.js.map +1 -1
- package/dist/elements/EditUpload/index.d.ts.map +1 -1
- package/dist/elements/EditUpload/index.js +28 -11
- package/dist/elements/EditUpload/index.js.map +1 -1
- package/dist/elements/ErrorPill/index.js.map +1 -1
- package/dist/elements/FieldSelect/index.js.map +1 -1
- package/dist/elements/FileDetails/FileMeta/index.js.map +1 -1
- package/dist/elements/FileDetails/index.js.map +1 -1
- package/dist/elements/GenerateConfirmation/index.js.map +1 -1
- package/dist/elements/Gutter/index.js.map +1 -1
- package/dist/elements/Hamburger/index.js.map +1 -1
- package/dist/elements/HydrateClientUser/index.d.ts +0 -1
- package/dist/elements/HydrateClientUser/index.d.ts.map +1 -1
- package/dist/elements/HydrateClientUser/index.js.map +1 -1
- package/dist/elements/IDLabel/index.js.map +1 -1
- package/dist/elements/ListControls/getTextFieldsToBeSearched.d.ts.map +1 -1
- package/dist/elements/ListControls/getTextFieldsToBeSearched.js.map +1 -1
- package/dist/elements/ListControls/index.js.map +1 -1
- package/dist/elements/ListDrawer/DrawerContent.js.map +1 -1
- package/dist/elements/ListDrawer/index.js.map +1 -1
- package/dist/elements/ListDrawer/types.js.map +1 -1
- package/dist/elements/ListSelection/index.js.map +1 -1
- package/dist/elements/Loading/index.js.map +1 -1
- package/dist/elements/LoadingOverlay/index.js.map +1 -1
- package/dist/elements/LoadingOverlay/reducer.js.map +1 -1
- package/dist/elements/LoadingOverlay/types.js.map +1 -1
- package/dist/elements/Localizer/LocalizerLabel/index.js.map +1 -1
- package/dist/elements/Localizer/index.js.map +1 -1
- package/dist/elements/Logout/index.js.map +1 -1
- package/dist/elements/Modal/index.js.map +1 -1
- package/dist/elements/Nav/NavToggler/index.js.map +1 -1
- package/dist/elements/Nav/context.js.map +1 -1
- package/dist/elements/NavGroup/index.js.map +1 -1
- package/dist/elements/Pagination/ClickableArrow/index.js.map +1 -1
- package/dist/elements/Pagination/Page/index.js.map +1 -1
- package/dist/elements/Pagination/Separator/index.js.map +1 -1
- package/dist/elements/Pagination/index.js.map +1 -1
- package/dist/elements/PerPage/index.js.map +1 -1
- package/dist/elements/Pill/index.js.map +1 -1
- package/dist/elements/Popup/PopupButtonList/index.js.map +1 -1
- package/dist/elements/Popup/PopupTrigger/index.js.map +1 -1
- package/dist/elements/Popup/PopupTrigger/types.js.map +1 -1
- package/dist/elements/Popup/index.js.map +1 -1
- package/dist/elements/PreviewButton/index.js.map +1 -1
- package/dist/elements/PreviewButton/usePreviewURL.js.map +1 -1
- package/dist/elements/PreviewSizes/index.js.map +1 -1
- package/dist/elements/PublishButton/index.js.map +1 -1
- package/dist/elements/PublishMany/index.js.map +1 -1
- package/dist/elements/ReactSelect/ClearIndicator/index.js.map +1 -1
- package/dist/elements/ReactSelect/Control/index.js.map +1 -1
- package/dist/elements/ReactSelect/DropdownIndicator/index.js +1 -1
- package/dist/elements/ReactSelect/DropdownIndicator/index.js.map +1 -1
- package/dist/elements/ReactSelect/Input/index.js.map +1 -1
- package/dist/elements/ReactSelect/MultiValue/index.js.map +1 -1
- package/dist/elements/ReactSelect/MultiValueLabel/index.js.map +1 -1
- package/dist/elements/ReactSelect/MultiValueRemove/index.js.map +1 -1
- package/dist/elements/ReactSelect/SingleValue/index.js.map +1 -1
- package/dist/elements/ReactSelect/ValueContainer/index.js.map +1 -1
- package/dist/elements/ReactSelect/index.js.map +1 -1
- package/dist/elements/ReactSelect/types.d.ts +0 -1
- package/dist/elements/ReactSelect/types.d.ts.map +1 -1
- package/dist/elements/ReactSelect/types.js.map +1 -1
- package/dist/elements/RenderCustomClientComponent/index.js.map +1 -1
- package/dist/elements/RenderCustomComponent/index.js.map +1 -1
- package/dist/elements/RenderTitle/index.js.map +1 -1
- package/dist/elements/SaveButton/index.js.map +1 -1
- package/dist/elements/SaveDraftButton/index.js.map +1 -1
- package/dist/elements/SearchFilter/index.js.map +1 -1
- package/dist/elements/SelectAll/index.js.map +1 -1
- package/dist/elements/SelectRow/index.js.map +1 -1
- package/dist/elements/ShimmerEffect/index.js.map +1 -1
- package/dist/elements/SortColumn/index.js.map +1 -1
- package/dist/elements/SortComplex/index.js +2 -2
- package/dist/elements/SortComplex/index.js.map +1 -1
- package/dist/elements/Status/index.js.map +1 -1
- package/dist/elements/StayLoggedIn/index.js.map +1 -1
- package/dist/elements/StepNav/SetStepNav.d.ts +0 -1
- package/dist/elements/StepNav/SetStepNav.d.ts.map +1 -1
- package/dist/elements/StepNav/SetStepNav.js.map +1 -1
- package/dist/elements/StepNav/context.js.map +1 -1
- package/dist/elements/StepNav/index.d.ts.map +1 -1
- package/dist/elements/StepNav/index.js +1 -1
- package/dist/elements/StepNav/index.js.map +1 -1
- package/dist/elements/StepNav/types.js.map +1 -1
- package/dist/elements/Table/DefaultCell/fields/Array/index.js.map +1 -1
- package/dist/elements/Table/DefaultCell/fields/Blocks/index.js.map +1 -1
- package/dist/elements/Table/DefaultCell/fields/Checkbox/index.js.map +1 -1
- package/dist/elements/Table/DefaultCell/fields/Code/index.js.map +1 -1
- package/dist/elements/Table/DefaultCell/fields/Date/index.js.map +1 -1
- package/dist/elements/Table/DefaultCell/fields/File/index.js.map +1 -1
- package/dist/elements/Table/DefaultCell/fields/JSON/index.js.map +1 -1
- package/dist/elements/Table/DefaultCell/fields/Relationship/index.js.map +1 -1
- package/dist/elements/Table/DefaultCell/fields/Select/index.js.map +1 -1
- package/dist/elements/Table/DefaultCell/fields/Textarea/index.js.map +1 -1
- package/dist/elements/Table/DefaultCell/fields/index.d.ts +0 -1
- package/dist/elements/Table/DefaultCell/fields/index.d.ts.map +1 -1
- package/dist/elements/Table/DefaultCell/fields/index.js.map +1 -1
- package/dist/elements/Table/DefaultCell/index.js.map +1 -1
- package/dist/elements/Table/RelationshipProvider/index.d.ts.map +1 -1
- package/dist/elements/Table/RelationshipProvider/index.js +11 -10
- package/dist/elements/Table/RelationshipProvider/index.js.map +1 -1
- package/dist/elements/Table/RelationshipProvider/reducer.js.map +1 -1
- package/dist/elements/Table/TableCellProvider/index.js.map +1 -1
- package/dist/elements/Table/index.js.map +1 -1
- package/dist/elements/TableColumns/buildColumnState.js.map +1 -1
- package/dist/elements/TableColumns/filterFields.d.ts.map +1 -1
- package/dist/elements/TableColumns/filterFields.js.map +1 -1
- package/dist/elements/TableColumns/getInitialColumns.d.ts.map +1 -1
- package/dist/elements/TableColumns/getInitialColumns.js.map +1 -1
- package/dist/elements/TableColumns/index.js.map +1 -1
- package/dist/elements/Thumbnail/index.js.map +1 -1
- package/dist/elements/ThumbnailCard/index.js.map +1 -1
- package/dist/elements/Tooltip/index.js.map +1 -1
- package/dist/elements/Translation/index.js.map +1 -1
- package/dist/elements/UnpublishMany/index.js.map +1 -1
- package/dist/elements/Upload/index.js.map +1 -1
- package/dist/elements/ViewDescription/index.js.map +1 -1
- package/dist/elements/ViewDescription/types.js.map +1 -1
- package/dist/elements/WhereBuilder/Condition/Date/index.js.map +1 -1
- package/dist/elements/WhereBuilder/Condition/Date/types.js.map +1 -1
- package/dist/elements/WhereBuilder/Condition/Number/index.js.map +1 -1
- package/dist/elements/WhereBuilder/Condition/Number/types.js.map +1 -1
- package/dist/elements/WhereBuilder/Condition/Relationship/index.d.ts.map +1 -1
- package/dist/elements/WhereBuilder/Condition/Relationship/index.js +8 -8
- package/dist/elements/WhereBuilder/Condition/Relationship/index.js.map +1 -1
- package/dist/elements/WhereBuilder/Condition/Relationship/optionsReducer.js.map +1 -1
- package/dist/elements/WhereBuilder/Condition/Relationship/types.js.map +1 -1
- package/dist/elements/WhereBuilder/Condition/Select/index.js.map +1 -1
- package/dist/elements/WhereBuilder/Condition/Select/types.js.map +1 -1
- package/dist/elements/WhereBuilder/Condition/Text/index.js.map +1 -1
- package/dist/elements/WhereBuilder/Condition/Text/types.js.map +1 -1
- package/dist/elements/WhereBuilder/Condition/index.js.map +1 -1
- package/dist/elements/WhereBuilder/Condition/types.js.map +1 -1
- package/dist/elements/WhereBuilder/field-types.js.map +1 -1
- package/dist/elements/WhereBuilder/index.js.map +1 -1
- package/dist/elements/WhereBuilder/reduceFieldMap.js.map +1 -1
- package/dist/elements/WhereBuilder/transformWhereQuery.js.map +1 -1
- package/dist/elements/WhereBuilder/types.js.map +1 -1
- package/dist/elements/WhereBuilder/validateWhereQuery.d.ts.map +1 -1
- package/dist/elements/WhereBuilder/validateWhereQuery.js.map +1 -1
- package/dist/elements/WindowInfo/index.js.map +1 -1
- package/dist/elements/WithServerSideProps/index.js.map +1 -1
- package/dist/elements/withMergedProps/index.js.map +1 -1
- package/dist/exports/client/index.d.ts +31 -24
- package/dist/exports/client/index.d.ts.map +1 -1
- package/dist/exports/client/index.js +26 -18
- package/dist/exports/client/index.js.map +4 -4
- package/dist/exports/shared/index.d.ts +2 -1
- package/dist/exports/shared/index.d.ts.map +1 -1
- package/dist/exports/shared/index.js +2 -2
- package/dist/exports/shared/index.js.map +4 -4
- package/dist/fields/Array/ArrayRow.js.map +1 -1
- package/dist/fields/Array/index.js.map +1 -1
- package/dist/fields/Blocks/BlockRow.js.map +1 -1
- package/dist/fields/Blocks/BlocksDrawer/BlockSearch/index.js.map +1 -1
- package/dist/fields/Blocks/BlocksDrawer/index.js.map +1 -1
- package/dist/fields/Blocks/RowActions.js.map +1 -1
- package/dist/fields/Blocks/SectionTitle/index.js.map +1 -1
- package/dist/fields/Blocks/index.js.map +1 -1
- package/dist/fields/Checkbox/Input.js.map +1 -1
- package/dist/fields/Checkbox/index.d.ts +1 -1
- package/dist/fields/Checkbox/index.d.ts.map +1 -1
- package/dist/fields/Checkbox/index.js +2 -2
- package/dist/fields/Checkbox/index.js.map +1 -1
- package/dist/fields/Checkbox/types.js.map +1 -1
- package/dist/fields/Code/index.d.ts +1 -1
- package/dist/fields/Code/index.d.ts.map +1 -1
- package/dist/fields/Code/index.js +2 -2
- package/dist/fields/Code/index.js.map +1 -1
- package/dist/fields/Collapsible/index.d.ts +1 -1
- package/dist/fields/Collapsible/index.d.ts.map +1 -1
- package/dist/fields/Collapsible/index.js +2 -2
- package/dist/fields/Collapsible/index.js.map +1 -1
- package/dist/fields/ConfirmPassword/index.d.ts +1 -1
- package/dist/fields/ConfirmPassword/index.d.ts.map +1 -1
- package/dist/fields/ConfirmPassword/index.js +1 -1
- package/dist/fields/ConfirmPassword/index.js.map +1 -1
- package/dist/fields/DateTime/index.d.ts +1 -1
- package/dist/fields/DateTime/index.d.ts.map +1 -1
- package/dist/fields/DateTime/index.js +2 -2
- package/dist/fields/DateTime/index.js.map +1 -1
- package/dist/fields/Email/index.d.ts +1 -1
- package/dist/fields/Email/index.d.ts.map +1 -1
- package/dist/fields/Email/index.js +2 -2
- package/dist/fields/Email/index.js.map +1 -1
- package/dist/fields/FieldDescription/index.js.map +1 -1
- package/dist/fields/FieldError/index.js.map +1 -1
- package/dist/fields/FieldLabel/index.js.map +1 -1
- package/dist/fields/Group/index.d.ts +2 -1
- package/dist/fields/Group/index.d.ts.map +1 -1
- package/dist/fields/Group/index.js +2 -2
- package/dist/fields/Group/index.js.map +1 -1
- package/dist/fields/Group/provider.js.map +1 -1
- package/dist/fields/{HiddenInput → Hidden}/index.d.ts +1 -1
- package/dist/fields/Hidden/index.d.ts.map +1 -0
- package/dist/fields/{HiddenInput → Hidden}/index.js +2 -2
- package/dist/fields/Hidden/index.js.map +1 -0
- package/dist/fields/JSON/index.d.ts.map +1 -1
- package/dist/fields/JSON/index.js +2 -2
- package/dist/fields/JSON/index.js.map +1 -1
- package/dist/fields/Number/index.d.ts.map +1 -1
- package/dist/fields/Number/index.js +2 -2
- package/dist/fields/Number/index.js.map +1 -1
- package/dist/fields/Password/index.d.ts +1 -1
- package/dist/fields/Password/index.d.ts.map +1 -1
- package/dist/fields/Password/index.js +2 -2
- package/dist/fields/Password/index.js.map +1 -1
- package/dist/fields/Point/index.d.ts +2 -1
- package/dist/fields/Point/index.d.ts.map +1 -1
- package/dist/fields/Point/index.js +2 -2
- package/dist/fields/Point/index.js.map +1 -1
- package/dist/fields/RadioGroup/Radio/index.js.map +1 -1
- package/dist/fields/RadioGroup/index.d.ts +1 -1
- package/dist/fields/RadioGroup/index.d.ts.map +1 -1
- package/dist/fields/RadioGroup/index.js +2 -2
- package/dist/fields/RadioGroup/index.js.map +1 -1
- package/dist/fields/Relationship/AddNew/index.js.map +1 -1
- package/dist/fields/Relationship/AddNew/types.js.map +1 -1
- package/dist/fields/Relationship/AddNew/useRelatedCollections.js.map +1 -1
- package/dist/fields/Relationship/createRelationMap.js.map +1 -1
- package/dist/fields/Relationship/findOptionsByValue.js.map +1 -1
- package/dist/fields/Relationship/index.d.ts +1 -1
- package/dist/fields/Relationship/index.d.ts.map +1 -1
- package/dist/fields/Relationship/index.js +2 -2
- package/dist/fields/Relationship/index.js.map +1 -1
- package/dist/fields/Relationship/optionsReducer.js.map +1 -1
- package/dist/fields/Relationship/select-components/MultiValueLabel/index.js.map +1 -1
- package/dist/fields/Relationship/select-components/SingleValue/index.js.map +1 -1
- package/dist/fields/Relationship/types.js.map +1 -1
- package/dist/fields/RichText/index.d.ts +1 -1
- package/dist/fields/RichText/index.d.ts.map +1 -1
- package/dist/fields/RichText/index.js +1 -1
- package/dist/fields/RichText/index.js.map +1 -1
- package/dist/fields/Row/index.d.ts +2 -1
- package/dist/fields/Row/index.d.ts.map +1 -1
- package/dist/fields/Row/index.js +2 -2
- package/dist/fields/Row/index.js.map +1 -1
- package/dist/fields/Row/provider.js.map +1 -1
- package/dist/fields/Row/types.js.map +1 -1
- package/dist/fields/Select/Input.js.map +1 -1
- package/dist/fields/Select/index.d.ts +1 -1
- package/dist/fields/Select/index.d.ts.map +1 -1
- package/dist/fields/Select/index.js +6 -4
- package/dist/fields/Select/index.js.map +1 -1
- package/dist/fields/Tabs/Tab/index.js.map +1 -1
- package/dist/fields/Tabs/index.d.ts +1 -1
- package/dist/fields/Tabs/index.d.ts.map +1 -1
- package/dist/fields/Tabs/index.js +2 -2
- package/dist/fields/Tabs/index.js.map +1 -1
- package/dist/fields/Tabs/provider.js.map +1 -1
- package/dist/fields/Text/Input.js.map +1 -1
- package/dist/fields/Text/index.d.ts +1 -1
- package/dist/fields/Text/index.d.ts.map +1 -1
- package/dist/fields/Text/index.js +2 -2
- package/dist/fields/Text/index.js.map +1 -1
- package/dist/fields/Text/types.js.map +1 -1
- package/dist/fields/Textarea/Input.js.map +1 -1
- package/dist/fields/Textarea/index.d.ts +1 -1
- package/dist/fields/Textarea/index.d.ts.map +1 -1
- package/dist/fields/Textarea/index.js +2 -2
- package/dist/fields/Textarea/index.js.map +1 -1
- package/dist/fields/Textarea/types.js.map +1 -1
- package/dist/fields/UI/index.d.ts +1 -1
- package/dist/fields/UI/index.d.ts.map +1 -1
- package/dist/fields/UI/index.js +1 -1
- package/dist/fields/UI/index.js.map +1 -1
- package/dist/fields/Upload/Input.js.map +1 -1
- package/dist/fields/Upload/index.d.ts +1 -1
- package/dist/fields/Upload/index.d.ts.map +1 -1
- package/dist/fields/Upload/index.js +1 -1
- package/dist/fields/Upload/index.js.map +1 -1
- package/dist/fields/Upload/types.js.map +1 -1
- package/dist/fields/index.js +48 -48
- package/dist/fields/index.js.map +1 -1
- package/dist/fields/shared/index.d.ts +0 -1
- package/dist/fields/shared/index.d.ts.map +1 -1
- package/dist/fields/shared/index.js.map +1 -1
- package/dist/forms/FieldPropsProvider/index.js.map +1 -1
- package/dist/forms/Form/context.d.ts +0 -1
- package/dist/forms/Form/context.d.ts.map +1 -1
- package/dist/forms/Form/context.js.map +1 -1
- package/dist/forms/Form/createNestedFieldPath.js.map +1 -1
- package/dist/forms/Form/errorMessages.js.map +1 -1
- package/dist/forms/Form/fieldReducer.js +2 -2
- package/dist/forms/Form/fieldReducer.js.map +1 -1
- package/dist/forms/Form/getDataByPath.d.ts.map +1 -1
- package/dist/forms/Form/getDataByPath.js +1 -2
- package/dist/forms/Form/getDataByPath.js.map +1 -1
- package/dist/forms/Form/getSiblingData.d.ts.map +1 -1
- package/dist/forms/Form/getSiblingData.js +2 -5
- package/dist/forms/Form/getSiblingData.js.map +1 -1
- package/dist/forms/Form/index.js +5 -5
- package/dist/forms/Form/index.js.map +1 -1
- package/dist/forms/Form/initContextState.js.map +1 -1
- package/dist/forms/Form/mergeErrorPaths.js.map +1 -1
- package/dist/forms/Form/mergeServerFormState.js +2 -2
- package/dist/forms/Form/mergeServerFormState.js.map +1 -1
- package/dist/forms/Form/rows.js.map +1 -1
- package/dist/forms/Form/types.js.map +1 -1
- package/dist/forms/NullifyField/index.js +2 -2
- package/dist/forms/NullifyField/index.js.map +1 -1
- package/dist/forms/RenderFields/RenderField.js +2 -2
- package/dist/forms/RenderFields/RenderField.js.map +1 -1
- package/dist/forms/RenderFields/index.js.map +1 -1
- package/dist/forms/RenderFields/types.js.map +1 -1
- package/dist/forms/RowLabel/Context/index.d.ts.map +1 -1
- package/dist/forms/RowLabel/Context/index.js.map +1 -1
- package/dist/forms/RowLabel/index.js.map +1 -1
- package/dist/forms/RowLabel/types.js.map +1 -1
- package/dist/forms/Submit/index.js.map +1 -1
- package/dist/forms/WatchChildErrors/buildPathSegments.d.ts.map +1 -1
- package/dist/forms/WatchChildErrors/buildPathSegments.js.map +1 -1
- package/dist/forms/WatchChildErrors/getFieldStateFromPaths.js.map +1 -1
- package/dist/forms/WatchChildErrors/getNestedFieldState.js.map +1 -1
- package/dist/forms/WatchChildErrors/index.js.map +1 -1
- package/dist/forms/buildStateFromSchema/addFieldStatePromise.d.ts.map +1 -1
- package/dist/forms/buildStateFromSchema/addFieldStatePromise.js.map +1 -1
- package/dist/forms/buildStateFromSchema/buildStateFromSchema.spec.js.map +1 -1
- package/dist/forms/buildStateFromSchema/calculateDefaultValues/index.d.ts.map +1 -1
- package/dist/forms/buildStateFromSchema/calculateDefaultValues/index.js.map +1 -1
- package/dist/forms/buildStateFromSchema/calculateDefaultValues/iterateFields.d.ts.map +1 -1
- package/dist/forms/buildStateFromSchema/calculateDefaultValues/iterateFields.js.map +1 -1
- package/dist/forms/buildStateFromSchema/calculateDefaultValues/promise.d.ts.map +1 -1
- package/dist/forms/buildStateFromSchema/calculateDefaultValues/promise.js.map +1 -1
- package/dist/forms/buildStateFromSchema/getFilterOptionsQuery.d.ts +1 -1
- package/dist/forms/buildStateFromSchema/getFilterOptionsQuery.d.ts.map +1 -1
- package/dist/forms/buildStateFromSchema/getFilterOptionsQuery.js.map +1 -1
- package/dist/forms/buildStateFromSchema/index.d.ts.map +1 -1
- package/dist/forms/buildStateFromSchema/index.js.map +1 -1
- package/dist/forms/buildStateFromSchema/iterateFields.d.ts.map +1 -1
- package/dist/forms/buildStateFromSchema/iterateFields.js.map +1 -1
- package/dist/forms/useField/index.d.ts.map +1 -1
- package/dist/forms/useField/index.js.map +1 -1
- package/dist/forms/useField/types.js.map +1 -1
- package/dist/forms/withCondition/WatchCondition.js.map +1 -1
- package/dist/forms/withCondition/index.d.ts.map +1 -1
- package/dist/forms/withCondition/index.js.map +1 -1
- package/dist/graphics/Account/Default/index.js.map +1 -1
- package/dist/graphics/Account/Gravatar/index.d.ts.map +1 -1
- package/dist/graphics/Account/Gravatar/index.js +4 -4
- package/dist/graphics/Account/Gravatar/index.js.map +1 -1
- package/dist/graphics/Account/index.js.map +1 -1
- package/dist/graphics/DefaultBlockImage/index.js.map +1 -1
- package/dist/graphics/ExternalLink/index.js.map +1 -1
- package/dist/graphics/File/index.js.map +1 -1
- package/dist/graphics/Icon/index.js.map +1 -1
- package/dist/graphics/Logo/index.js.map +1 -1
- package/dist/hooks/useDebounce.js.map +1 -1
- package/dist/hooks/useDebouncedCallback.js.map +1 -1
- package/dist/hooks/useDebouncedEffect.js.map +1 -1
- package/dist/hooks/useDelay.d.ts.map +1 -1
- package/dist/hooks/useDelay.js.map +1 -1
- package/dist/hooks/useDelayedRender.js.map +1 -1
- package/dist/hooks/useHotkey.js.map +1 -1
- package/dist/hooks/useIntersect.d.ts +0 -1
- package/dist/hooks/useIntersect.d.ts.map +1 -1
- package/dist/hooks/useIntersect.js.map +1 -1
- package/dist/hooks/usePayloadAPI.d.ts +0 -1
- package/dist/hooks/usePayloadAPI.d.ts.map +1 -1
- package/dist/hooks/usePayloadAPI.js +2 -2
- package/dist/hooks/usePayloadAPI.js.map +1 -1
- package/dist/hooks/useResize.js.map +1 -1
- package/dist/hooks/useThrottledEffect.d.ts +0 -1
- package/dist/hooks/useThrottledEffect.d.ts.map +1 -1
- package/dist/hooks/useThrottledEffect.js.map +1 -1
- package/dist/hooks/useUseAsTitle.d.ts.map +1 -1
- package/dist/hooks/useUseAsTitle.js.map +1 -1
- package/dist/icons/Calendar/index.js.map +1 -1
- package/dist/icons/Check/index.js.map +1 -1
- package/dist/icons/Chevron/index.js.map +1 -1
- package/dist/icons/CloseMenu/index.js.map +1 -1
- package/dist/icons/CodeBlock/index.js.map +1 -1
- package/dist/icons/Copy/index.js.map +1 -1
- package/dist/icons/DragHandle/index.js.map +1 -1
- package/dist/icons/Edit/index.js.map +1 -1
- package/dist/icons/Line/index.js.map +1 -1
- package/dist/icons/Link/index.js.map +1 -1
- package/dist/icons/LogOut/index.js.map +1 -1
- package/dist/icons/Menu/index.js.map +1 -1
- package/dist/icons/MinimizeMaximize/index.js.map +1 -1
- package/dist/icons/More/index.js.map +1 -1
- package/dist/icons/Plus/index.js.map +1 -1
- package/dist/icons/Search/index.js.map +1 -1
- package/dist/icons/Swap/index.js.map +1 -1
- package/dist/icons/X/index.js.map +1 -1
- package/dist/providers/Actions/SetViewActions/index.js.map +1 -1
- package/dist/providers/Actions/index.js.map +1 -1
- package/dist/providers/Auth/index.d.ts.map +1 -1
- package/dist/providers/Auth/index.js.map +1 -1
- package/dist/providers/ClientFunction/index.js.map +1 -1
- package/dist/providers/ComponentMap/buildComponentMap/actions.js.map +1 -1
- package/dist/providers/ComponentMap/buildComponentMap/collections.d.ts +1 -1
- package/dist/providers/ComponentMap/buildComponentMap/collections.d.ts.map +1 -1
- package/dist/providers/ComponentMap/buildComponentMap/collections.js.map +1 -1
- package/dist/providers/ComponentMap/buildComponentMap/fields.d.ts.map +1 -1
- package/dist/providers/ComponentMap/buildComponentMap/fields.js +2 -2
- package/dist/providers/ComponentMap/buildComponentMap/fields.js.map +1 -1
- package/dist/providers/ComponentMap/buildComponentMap/globals.d.ts +1 -1
- package/dist/providers/ComponentMap/buildComponentMap/globals.d.ts.map +1 -1
- package/dist/providers/ComponentMap/buildComponentMap/globals.js.map +1 -1
- package/dist/providers/ComponentMap/buildComponentMap/index.d.ts +1 -1
- package/dist/providers/ComponentMap/buildComponentMap/index.d.ts.map +1 -1
- package/dist/providers/ComponentMap/buildComponentMap/index.js.map +1 -1
- package/dist/providers/ComponentMap/buildComponentMap/types.d.ts +1 -2
- package/dist/providers/ComponentMap/buildComponentMap/types.d.ts.map +1 -1
- package/dist/providers/ComponentMap/buildComponentMap/types.js.map +1 -1
- package/dist/providers/ComponentMap/index.js.map +1 -1
- package/dist/providers/Config/index.js.map +1 -1
- package/dist/providers/DocumentEvents/index.js.map +1 -1
- package/dist/providers/DocumentInfo/index.js.map +1 -1
- package/dist/providers/DocumentInfo/types.js.map +1 -1
- package/dist/providers/EditDepth/index.js.map +1 -1
- package/dist/providers/EntityVisibility/index.js.map +1 -1
- package/dist/providers/FieldComponents/index.js.map +1 -1
- package/dist/providers/FormQueryParams/index.d.ts.map +1 -1
- package/dist/providers/FormQueryParams/index.js.map +1 -1
- package/dist/providers/FormQueryParams/types.js.map +1 -1
- package/dist/providers/ListInfo/index.js.map +1 -1
- package/dist/providers/ListQuery/index.js.map +1 -1
- package/dist/providers/Locale/index.js.map +1 -1
- package/dist/providers/Operation/index.js.map +1 -1
- package/dist/providers/Params/index.js.map +1 -1
- package/dist/providers/Preferences/index.js +3 -3
- package/dist/providers/Preferences/index.js.map +1 -1
- package/dist/providers/Root/index.js.map +1 -1
- package/dist/providers/RouteCache/index.js.map +1 -1
- package/dist/providers/ScrollInfo/index.d.ts +0 -1
- package/dist/providers/ScrollInfo/index.d.ts.map +1 -1
- package/dist/providers/ScrollInfo/index.js.map +1 -1
- package/dist/providers/SearchParams/index.js.map +1 -1
- package/dist/providers/Selection/index.js +2 -2
- package/dist/providers/Selection/index.js.map +1 -1
- package/dist/providers/Theme/index.js.map +1 -1
- package/dist/providers/ToastContainer/icons/Error.js.map +1 -1
- package/dist/providers/ToastContainer/icons/Info.js.map +1 -1
- package/dist/providers/ToastContainer/icons/Success.js.map +1 -1
- package/dist/providers/ToastContainer/icons/Warning.js.map +1 -1
- package/dist/providers/ToastContainer/index.js.map +1 -1
- package/dist/providers/Translation/index.d.ts.map +1 -1
- package/dist/providers/Translation/index.js.map +1 -1
- package/dist/providers/WindowInfo/index.d.ts +0 -1
- package/dist/providers/WindowInfo/index.d.ts.map +1 -1
- package/dist/providers/WindowInfo/index.js.map +1 -1
- package/dist/utilities/api.d.ts.map +1 -1
- package/dist/utilities/api.js.map +1 -1
- package/dist/utilities/arraysHaveSameStrings.js.map +1 -1
- package/dist/utilities/buildComponentMap.js.map +1 -1
- package/dist/utilities/buildFieldSchemaMap/index.d.ts.map +1 -1
- package/dist/utilities/buildFieldSchemaMap/index.js.map +1 -1
- package/dist/utilities/buildFieldSchemaMap/traverseFields.js.map +1 -1
- package/dist/utilities/buildFieldSchemaMap/types.js.map +1 -1
- package/dist/utilities/buildFormState.d.ts.map +1 -1
- package/dist/utilities/buildFormState.js.map +1 -1
- package/dist/utilities/canUseDOM.js.map +1 -1
- package/dist/utilities/dateLocales.js.map +1 -1
- package/dist/utilities/findLocaleFromCode.js.map +1 -1
- package/dist/utilities/flattenFieldMap.d.ts.map +1 -1
- package/dist/utilities/flattenFieldMap.js.map +1 -1
- package/dist/utilities/formatDate.js.map +1 -1
- package/dist/utilities/formatDocTitle.d.ts +1 -1
- package/dist/utilities/formatDocTitle.d.ts.map +1 -1
- package/dist/utilities/formatDocTitle.js.map +1 -1
- package/dist/utilities/formatFields.js.map +1 -1
- package/dist/utilities/generateFieldID.js.map +1 -1
- package/dist/utilities/getFormState.d.ts +2 -2
- package/dist/utilities/getFormState.d.ts.map +1 -1
- package/dist/utilities/getFormState.js.map +1 -1
- package/dist/utilities/getOffsetTop.js.map +1 -1
- package/dist/utilities/getRequestLanguage.js.map +1 -1
- package/dist/utilities/getSupportedMonacoLocale.js.map +1 -1
- package/dist/utilities/groupNavItems.js.map +1 -1
- package/dist/utilities/hasSavePermission.js.map +1 -1
- package/dist/utilities/isEditing.js.map +1 -1
- package/dist/utilities/reduceFieldsToValues.d.ts.map +1 -1
- package/dist/utilities/reduceFieldsToValues.js +2 -5
- package/dist/utilities/reduceFieldsToValues.js.map +1 -1
- package/dist/utilities/reduceFieldsToValuesWithValidation.d.ts.map +1 -1
- package/dist/utilities/reduceFieldsToValuesWithValidation.js +2 -5
- package/dist/utilities/reduceFieldsToValuesWithValidation.js.map +1 -1
- package/dist/utilities/scrollToID.js.map +1 -1
- package/dist/utilities/setsAreEqual.d.ts.map +1 -1
- package/dist/utilities/setsAreEqual.js.map +1 -1
- package/dist/utilities/unflatten.d.ts +9 -0
- package/dist/utilities/unflatten.d.ts.map +1 -0
- package/dist/utilities/unflatten.js +58 -0
- package/dist/utilities/unflatten.js.map +1 -0
- package/package.json +49 -59
- package/dist/fields/HiddenInput/index.d.ts.map +0 -1
- package/dist/fields/HiddenInput/index.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/forms/Form/index.tsx"],"sourcesContent":["'use client'\nimport type { FormState } from 'payload'\n\n/* eslint-disable jsx-a11y/no-noninteractive-element-interactions */\nimport isDeepEqual from 'deep-equal'\nimport { useRouter } from 'next/navigation.js'\nimport { serialize } from 'object-to-formdata'\nimport { wait } from 'payload/shared'\nimport QueryString from 'qs'\nimport React, { useCallback, useEffect, useReducer, useRef, useState } from 'react'\nimport { toast } from 'sonner'\n\nimport type {\n Context as FormContextType,\n FormProps,\n GetDataByPath,\n SubmitOptions,\n} from './types.js'\n\nimport { useDebouncedEffect } from '../../hooks/useDebouncedEffect.js'\nimport { useThrottledEffect } from '../../hooks/useThrottledEffect.js'\nimport { useAuth } from '../../providers/Auth/index.js'\nimport { useConfig } from '../../providers/Config/index.js'\nimport { useDocumentInfo } from '../../providers/DocumentInfo/index.js'\nimport { useFormQueryParams } from '../../providers/FormQueryParams/index.js'\nimport { useLocale } from '../../providers/Locale/index.js'\nimport { useOperation } from '../../providers/Operation/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { requests } from '../../utilities/api.js'\nimport { getFormState } from '../../utilities/getFormState.js'\nimport { reduceFieldsToValues } from '../../utilities/reduceFieldsToValues.js'\nimport {\n FormContext,\n FormFieldsContext,\n FormWatchContext,\n InitializingContext,\n ModifiedContext,\n ProcessingContext,\n SubmittedContext,\n} from './context.js'\nimport { errorMessages } from './errorMessages.js'\nimport { fieldReducer } from './fieldReducer.js'\nimport { getDataByPath as getDataByPathFunc } from './getDataByPath.js'\nimport { getSiblingData as getSiblingDataFunc } from './getSiblingData.js'\nimport { initContextState } from './initContextState.js'\nimport { mergeServerFormState } from './mergeServerFormState.js'\n\nconst baseClass = 'form'\n\nexport const Form: React.FC<FormProps> = (props) => {\n const { id, collectionSlug, globalSlug } = useDocumentInfo()\n\n const {\n action,\n beforeSubmit,\n children,\n className,\n disableSuccessStatus,\n disableValidationOnSubmit,\n disabled: disabledFromProps,\n // fields: fieldsFromProps = collection?.fields || global?.fields,\n handleResponse,\n initialState, // fully formed initial field state\n isInitializing: initializingFromProps,\n onChange,\n onSubmit,\n onSuccess,\n redirect,\n submitted: submittedFromProps,\n uuid,\n waitForAutocomplete,\n } = props\n\n const method = 'method' in props ? props?.method : undefined\n\n const router = useRouter()\n\n const { code: locale } = useLocale()\n const { i18n, t } = useTranslation()\n const { refreshCookie, user } = useAuth()\n const operation = useOperation()\n const { formQueryParams } = useFormQueryParams()\n\n const config = useConfig()\n const {\n routes: { api: apiRoute },\n serverURL,\n } = config\n\n const [disabled, setDisabled] = useState(disabledFromProps || false)\n const [isMounted, setIsMounted] = useState(false)\n const [modified, setModified] = useState(false)\n const [initializing, setInitializing] = useState(initializingFromProps)\n const [processing, setProcessing] = useState(false)\n const [submitted, setSubmitted] = useState(false)\n const formRef = useRef<HTMLFormElement>(null)\n const contextRef = useRef({} as FormContextType)\n\n const fieldsReducer = useReducer(fieldReducer, {}, () => initialState)\n\n /**\n * `fields` is the current, up-to-date state/data of all fields in the form. It can be modified by using dispatchFields,\n * which calls the fieldReducer, which then updates the state.\n */\n const [fields, dispatchFields] = fieldsReducer\n\n contextRef.current.fields = fields\n\n const validateForm = useCallback(async () => {\n const validatedFieldState = {}\n let isValid = true\n\n const dataFromContext = contextRef.current.getData()\n const data = dataFromContext\n\n const validationPromises = Object.entries(contextRef.current.fields).map(\n async ([path, field]) => {\n const validatedField = field\n\n if (field.passesCondition !== false) {\n let validationResult: boolean | string = validatedField.valid\n\n if (typeof field.validate === 'function') {\n let valueToValidate = field.value\n\n if (field?.rows && Array.isArray(field.rows)) {\n valueToValidate = contextRef.current.getDataByPath(path)\n }\n\n validationResult = await field.validate(valueToValidate, {\n id,\n config,\n data,\n operation,\n siblingData: contextRef.current.getSiblingData(path),\n t,\n user,\n })\n\n if (typeof validationResult === 'string') {\n validatedField.errorMessage = validationResult\n validatedField.valid = false\n } else {\n validatedField.valid = true\n validatedField.errorMessage = undefined\n }\n }\n\n if (validatedField.valid === false) {\n isValid = false\n }\n }\n\n validatedFieldState[path] = validatedField\n },\n )\n\n await Promise.all(validationPromises)\n\n if (!isDeepEqual(contextRef.current.fields, validatedFieldState)) {\n dispatchFields({ type: 'REPLACE_STATE', state: validatedFieldState })\n }\n\n return isValid\n }, [id, user, operation, t, dispatchFields, config])\n\n const submit = useCallback(\n async (options: SubmitOptions = {}, e): Promise<void> => {\n const {\n action: actionArg,\n method: methodToUse = method,\n overrides = {},\n skipValidation,\n } = options\n\n if (disabled) {\n if (e) {\n e.preventDefault()\n }\n return\n }\n\n // create new toast promise which will resolve manually later\n let successToast, errorToast\n const promise = new Promise((resolve, reject) => {\n successToast = resolve\n errorToast = reject\n })\n\n const hasFormSubmitAction =\n actionArg || typeof action === 'string' || typeof action === 'function'\n\n if (redirect || disableSuccessStatus || !hasFormSubmitAction) {\n // Do not show submitting toast, as the promise toast may never disappear under these conditions.\n // Instead, make successToast() or errorToast() throw toast.success / toast.error\n successToast = (data) => toast.success(data)\n errorToast = (data) => toast.error(data)\n } else {\n toast.promise(promise, {\n error: (data) => {\n return data as string\n },\n loading: t('general:submitting'),\n success: (data) => {\n return data as string\n },\n })\n }\n\n if (e) {\n e.stopPropagation()\n e.preventDefault()\n }\n\n setProcessing(true)\n setDisabled(true)\n\n if (waitForAutocomplete) await wait(100)\n\n // Execute server side validations\n if (Array.isArray(beforeSubmit)) {\n let revalidatedFormState: FormState\n\n await beforeSubmit.reduce(async (priorOnChange, beforeSubmitFn) => {\n await priorOnChange\n\n const result = await beforeSubmitFn({\n formState: fields,\n })\n\n revalidatedFormState = result\n }, Promise.resolve())\n\n const isValid = Object.entries(revalidatedFormState).every(([, field]) => field.valid)\n\n if (!isValid) {\n setProcessing(false)\n setSubmitted(true)\n setDisabled(false)\n return dispatchFields({ type: 'REPLACE_STATE', state: revalidatedFormState })\n }\n }\n\n const isValid =\n skipValidation || disableValidationOnSubmit ? true : await contextRef.current.validateForm()\n\n // If not valid, prevent submission\n if (!isValid) {\n errorToast(t('error:correctInvalidFields'))\n setProcessing(false)\n setSubmitted(true)\n setDisabled(false)\n return\n }\n\n // If submit handler comes through via props, run that\n if (onSubmit) {\n const data = {\n ...reduceFieldsToValues(fields, true),\n ...overrides,\n }\n\n onSubmit(fields, data)\n }\n\n if (!hasFormSubmitAction) {\n // No action provided, so we should return. An example where this happens are lexical link drawers. Upon submitting the drawer, we\n // want to close it without submitting the form. Stuff like validation would be handled by lexical before this, through beforeSubmit\n setProcessing(false)\n setSubmitted(true)\n setDisabled(false)\n return\n }\n\n const formData = contextRef.current.createFormData(overrides)\n\n try {\n let res\n const actionEndpoint =\n actionArg ||\n (typeof action === 'string'\n ? `${action}${QueryString.stringify(formQueryParams, { addQueryPrefix: true })}`\n : null)\n\n if (actionEndpoint) {\n res = await requests[methodToUse.toLowerCase()](actionEndpoint, {\n body: formData,\n headers: {\n 'Accept-Language': i18n.language,\n },\n })\n } else if (typeof action === 'function') {\n res = await action(formData)\n }\n\n setModified(false)\n setDisabled(false)\n\n if (typeof handleResponse === 'function') {\n handleResponse(res, successToast, errorToast)\n return\n }\n\n const contentType = res.headers.get('content-type')\n const isJSON = contentType && contentType.indexOf('application/json') !== -1\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let json: Record<string, any> = {}\n\n if (isJSON) json = await res.json()\n if (res.status < 400) {\n if (typeof onSuccess === 'function') await onSuccess(json)\n setSubmitted(false)\n setProcessing(false)\n\n if (redirect) {\n router.push(redirect)\n } else if (!disableSuccessStatus) {\n successToast(json.message || t('general:submissionSuccessful'))\n }\n } else {\n setProcessing(false)\n setSubmitted(true)\n\n contextRef.current = { ...contextRef.current } // triggers rerender of all components that subscribe to form\n if (json.message) {\n errorToast(json.message)\n\n return\n }\n\n if (Array.isArray(json.errors)) {\n const [fieldErrors, nonFieldErrors] = json.errors.reduce(\n ([fieldErrs, nonFieldErrs], err) => {\n const newFieldErrs = []\n const newNonFieldErrs = []\n\n if (err?.message) {\n newNonFieldErrs.push(err)\n }\n\n if (Array.isArray(err?.data)) {\n err.data.forEach((dataError) => {\n if (dataError?.field) {\n newFieldErrs.push(dataError)\n } else {\n newNonFieldErrs.push(dataError)\n }\n })\n }\n\n return [\n [...fieldErrs, ...newFieldErrs],\n [...nonFieldErrs, ...newNonFieldErrs],\n ]\n },\n [[], []],\n )\n\n dispatchFields({\n type: 'ADD_SERVER_ERRORS',\n errors: fieldErrors,\n })\n\n nonFieldErrors.forEach((err) => {\n errorToast(err.message || t('error:unknown'))\n })\n\n return\n }\n\n const message = errorMessages?.[res.status] || res?.statusText || t('error:unknown')\n\n errorToast(message)\n }\n } catch (err) {\n console.error('Error submitting form', err)\n setProcessing(false)\n setSubmitted(true)\n setDisabled(false)\n\n errorToast(err.message)\n }\n },\n [\n beforeSubmit,\n action,\n disableSuccessStatus,\n disableValidationOnSubmit,\n disabled,\n dispatchFields,\n fields,\n handleResponse,\n method,\n onSubmit,\n onSuccess,\n redirect,\n router,\n t,\n i18n,\n waitForAutocomplete,\n formQueryParams,\n ],\n )\n\n const getFields = useCallback(() => contextRef.current.fields, [])\n\n const getField = useCallback((path: string) => contextRef.current.fields[path], [])\n\n const getData = useCallback(() => reduceFieldsToValues(contextRef.current.fields, true), [])\n\n const getSiblingData = useCallback(\n (path: string) => getSiblingDataFunc(contextRef.current.fields, path),\n [],\n )\n const getDataByPath = useCallback<GetDataByPath>(\n (path: string) => getDataByPathFunc(contextRef.current.fields, path),\n [],\n )\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const createFormData = useCallback((overrides: any = {}) => {\n const data = reduceFieldsToValues(contextRef.current.fields, true)\n\n const file = data?.file\n\n if (file) {\n delete data.file\n }\n\n const dataWithOverrides = {\n ...data,\n ...overrides,\n }\n\n const dataToSerialize = {\n _payload: JSON.stringify(dataWithOverrides),\n file,\n }\n\n // nullAsUndefineds is important to allow uploads and relationship fields to clear themselves\n const formData = serialize(dataToSerialize, { indices: true, nullsAsUndefineds: false })\n\n return formData\n }, [])\n\n const reset = useCallback(\n async (data: unknown) => {\n const newState = await getFormState({\n apiRoute,\n body: {\n id,\n collectionSlug,\n data,\n globalSlug,\n operation,\n schemaPath: collectionSlug || globalSlug,\n },\n serverURL,\n })\n\n contextRef.current = { ...initContextState } as FormContextType\n setModified(false)\n dispatchFields({ type: 'REPLACE_STATE', state: newState })\n },\n [apiRoute, collectionSlug, dispatchFields, globalSlug, id, operation, serverURL],\n )\n\n const replaceState = useCallback(\n (state: FormState) => {\n contextRef.current = { ...initContextState } as FormContextType\n setModified(false)\n dispatchFields({ type: 'REPLACE_STATE', state })\n },\n [dispatchFields],\n )\n\n const getFieldStateBySchemaPath = useCallback(\n async ({ data, schemaPath }) => {\n const fieldSchema = await getFormState({\n apiRoute,\n body: {\n collectionSlug,\n data,\n globalSlug,\n schemaPath,\n },\n serverURL,\n })\n return fieldSchema\n },\n [apiRoute, collectionSlug, globalSlug, serverURL],\n )\n\n const addFieldRow: FormContextType['addFieldRow'] = useCallback(\n async ({ data, path, rowIndex, schemaPath }) => {\n const subFieldState = await getFieldStateBySchemaPath({ data, schemaPath })\n\n dispatchFields({\n type: 'ADD_ROW',\n blockType: data?.blockType,\n path,\n rowIndex,\n subFieldState,\n })\n },\n [getFieldStateBySchemaPath, dispatchFields],\n )\n\n const removeFieldRow: FormContextType['removeFieldRow'] = useCallback(\n ({ path, rowIndex }) => {\n dispatchFields({ type: 'REMOVE_ROW', path, rowIndex })\n },\n [dispatchFields],\n )\n\n const replaceFieldRow: FormContextType['replaceFieldRow'] = useCallback(\n async ({ data, path, rowIndex, schemaPath }) => {\n const subFieldState = await getFieldStateBySchemaPath({ data, schemaPath })\n\n dispatchFields({\n type: 'REPLACE_ROW',\n blockType: data?.blockType,\n path,\n rowIndex,\n subFieldState,\n })\n },\n [getFieldStateBySchemaPath, dispatchFields],\n )\n\n useEffect(() => {\n if (initializingFromProps !== undefined) {\n setInitializing(initializingFromProps)\n }\n }, [initializingFromProps])\n\n contextRef.current.submit = submit\n contextRef.current.getFields = getFields\n contextRef.current.getField = getField\n contextRef.current.getData = getData\n contextRef.current.getSiblingData = getSiblingData\n contextRef.current.getDataByPath = getDataByPath\n contextRef.current.validateForm = validateForm\n contextRef.current.createFormData = createFormData\n contextRef.current.setModified = setModified\n contextRef.current.setProcessing = setProcessing\n contextRef.current.setSubmitted = setSubmitted\n contextRef.current.disabled = disabled\n contextRef.current.setDisabled = setDisabled\n contextRef.current.formRef = formRef\n contextRef.current.reset = reset\n contextRef.current.replaceState = replaceState\n contextRef.current.dispatchFields = dispatchFields\n contextRef.current.addFieldRow = addFieldRow\n contextRef.current.removeFieldRow = removeFieldRow\n contextRef.current.replaceFieldRow = replaceFieldRow\n contextRef.current.uuid = uuid\n contextRef.current.initializing = initializing\n\n useEffect(() => {\n setIsMounted(true)\n }, [])\n\n useEffect(() => {\n if (typeof disabledFromProps === 'boolean') setDisabled(disabledFromProps)\n }, [disabledFromProps])\n\n useEffect(() => {\n if (typeof submittedFromProps === 'boolean') setSubmitted(submittedFromProps)\n }, [submittedFromProps])\n\n useEffect(() => {\n if (initialState) {\n contextRef.current = { ...initContextState } as FormContextType\n dispatchFields({ type: 'REPLACE_STATE', optimize: false, state: initialState })\n }\n }, [initialState, dispatchFields])\n\n useThrottledEffect(\n () => {\n refreshCookie()\n },\n 15000,\n [fields],\n )\n\n useEffect(() => {\n contextRef.current = { ...contextRef.current } // triggers rerender of all components that subscribe to form\n setModified(false)\n }, [locale])\n\n const classes = [className, baseClass].filter(Boolean).join(' ')\n\n useDebouncedEffect(\n () => {\n const executeOnChange = async () => {\n if (Array.isArray(onChange)) {\n let revalidatedFormState: FormState = contextRef.current.fields\n\n for (const onChangeFn of onChange) {\n revalidatedFormState = await onChangeFn({\n formState: revalidatedFormState,\n })\n }\n\n const { changed, newState } = mergeServerFormState(\n contextRef.current.fields || {},\n revalidatedFormState,\n )\n\n if (changed) {\n dispatchFields({\n type: 'REPLACE_STATE',\n optimize: false,\n state: newState,\n })\n }\n }\n }\n\n if (modified) void executeOnChange()\n },\n 150,\n // Make sure we trigger this whenever modified changes (not just when `fields` changes), otherwise we will miss merging server form state for the first form update/onChange. Here's why:\n // `fields` updates before `modified`, because setModified is in a setTimeout. So on the first change, modified is false, so we don't trigger the effect even though we should.\n [contextRef.current.fields, dispatchFields, onChange, modified],\n )\n\n const actionString =\n typeof action === 'string'\n ? `${action}${QueryString.stringify(formQueryParams, { addQueryPrefix: true })}`\n : ''\n\n return (\n <form\n action={method ? actionString : (action as string)}\n className={classes}\n method={method}\n noValidate\n onSubmit={(e) => contextRef.current.submit({}, e)}\n ref={formRef}\n >\n <FormContext.Provider value={contextRef.current}>\n <FormWatchContext.Provider\n value={{\n fields,\n ...contextRef.current,\n }}\n >\n <SubmittedContext.Provider value={submitted}>\n <InitializingContext.Provider value={!isMounted || (isMounted && initializing)}>\n <ProcessingContext.Provider value={processing}>\n <ModifiedContext.Provider value={modified}>\n <FormFieldsContext.Provider value={fieldsReducer}>\n {children}\n </FormFieldsContext.Provider>\n </ModifiedContext.Provider>\n </ProcessingContext.Provider>\n </InitializingContext.Provider>\n </SubmittedContext.Provider>\n </FormWatchContext.Provider>\n </FormContext.Provider>\n </form>\n )\n}\n\nexport {\n FormContext,\n FormFieldsContext,\n FormWatchContext,\n ModifiedContext,\n ProcessingContext,\n SubmittedContext,\n useAllFormFields,\n useForm,\n useFormFields,\n useFormModified,\n useFormProcessing,\n useFormSubmitted,\n useWatchForm,\n} from './context.js'\n\nexport { FormProps }\n"],"names":["isDeepEqual","useRouter","serialize","wait","QueryString","React","useCallback","useEffect","useReducer","useRef","useState","toast","useDebouncedEffect","useThrottledEffect","useAuth","useConfig","useDocumentInfo","useFormQueryParams","useLocale","useOperation","useTranslation","requests","getFormState","reduceFieldsToValues","FormContext","FormFieldsContext","FormWatchContext","InitializingContext","ModifiedContext","ProcessingContext","SubmittedContext","errorMessages","fieldReducer","getDataByPath","getDataByPathFunc","getSiblingData","getSiblingDataFunc","initContextState","mergeServerFormState","baseClass","Form","props","id","collectionSlug","globalSlug","action","beforeSubmit","children","className","disableSuccessStatus","disableValidationOnSubmit","disabled","disabledFromProps","handleResponse","initialState","isInitializing","initializingFromProps","onChange","onSubmit","onSuccess","redirect","submitted","submittedFromProps","uuid","waitForAutocomplete","method","undefined","router","code","locale","i18n","t","refreshCookie","user","operation","formQueryParams","config","routes","api","apiRoute","serverURL","setDisabled","isMounted","setIsMounted","modified","setModified","initializing","setInitializing","processing","setProcessing","setSubmitted","formRef","contextRef","fieldsReducer","fields","dispatchFields","current","validateForm","validatedFieldState","isValid","dataFromContext","getData","data","validationPromises","Object","entries","map","path","field","validatedField","passesCondition","validationResult","valid","validate","valueToValidate","value","rows","Array","isArray","siblingData","errorMessage","Promise","all","type","state","submit","options","e","actionArg","methodToUse","overrides","skipValidation","preventDefault","successToast","errorToast","promise","resolve","reject","hasFormSubmitAction","success","error","loading","stopPropagation","revalidatedFormState","reduce","priorOnChange","beforeSubmitFn","result","formState","every","formData","createFormData","res","actionEndpoint","stringify","addQueryPrefix","toLowerCase","body","headers","language","contentType","get","isJSON","indexOf","json","status","push","message","errors","fieldErrors","nonFieldErrors","fieldErrs","nonFieldErrs","err","newFieldErrs","newNonFieldErrs","forEach","dataError","statusText","console","getFields","getField","file","dataWithOverrides","dataToSerialize","_payload","JSON","indices","nullsAsUndefineds","reset","newState","schemaPath","replaceState","getFieldStateBySchemaPath","fieldSchema","addFieldRow","rowIndex","subFieldState","blockType","removeFieldRow","replaceFieldRow","optimize","classes","filter","Boolean","join","executeOnChange","onChangeFn","changed","actionString","form","noValidate","ref","Provider","useAllFormFields","useForm","useFormFields","useFormModified","useFormProcessing","useFormSubmitted","useWatchForm"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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CACjC,cAAA,KAAC5D,gBAAgByL,QAAQ;gCAAClG,OAAO/B;0CAC/B,cAAA,KAAC3D,kBAAkB4L,QAAQ;oCAAClG,OAAOtB;8CAChC9C;;;;;;;;;AAUrB,EAAC;AAED,SACEvB,WAAW,EACXC,iBAAiB,EACjBC,gBAAgB,EAChBE,eAAe,EACfC,iBAAiB,EACjBC,gBAAgB,EAChBwL,gBAAgB,EAChBC,OAAO,EACPC,aAAa,EACbC,eAAe,EACfC,iBAAiB,EACjBC,gBAAgB,EAChBC,YAAY,QACP,eAAc"}
|
|
1
|
+
{"version":3,"sources":["../../../src/forms/Form/index.tsx"],"sourcesContent":["'use client'\nimport type { FormState } from 'payload'\n\n/* eslint-disable jsx-a11y/no-noninteractive-element-interactions */\nimport { dequal } from 'dequal/lite' // lite: no need for Map and Set support\nimport { useRouter } from 'next/navigation.js'\nimport { serialize } from 'object-to-formdata'\nimport { wait } from 'payload/shared'\nimport qs from 'qs'\nimport React, { useCallback, useEffect, useReducer, useRef, useState } from 'react'\nimport { toast } from 'sonner'\n\nimport type {\n Context as FormContextType,\n FormProps,\n GetDataByPath,\n SubmitOptions,\n} from './types.js'\n\nimport { useDebouncedEffect } from '../../hooks/useDebouncedEffect.js'\nimport { useThrottledEffect } from '../../hooks/useThrottledEffect.js'\nimport { useAuth } from '../../providers/Auth/index.js'\nimport { useConfig } from '../../providers/Config/index.js'\nimport { useDocumentInfo } from '../../providers/DocumentInfo/index.js'\nimport { useFormQueryParams } from '../../providers/FormQueryParams/index.js'\nimport { useLocale } from '../../providers/Locale/index.js'\nimport { useOperation } from '../../providers/Operation/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { requests } from '../../utilities/api.js'\nimport { getFormState } from '../../utilities/getFormState.js'\nimport { reduceFieldsToValues } from '../../utilities/reduceFieldsToValues.js'\nimport {\n FormContext,\n FormFieldsContext,\n FormWatchContext,\n InitializingContext,\n ModifiedContext,\n ProcessingContext,\n SubmittedContext,\n} from './context.js'\nimport { errorMessages } from './errorMessages.js'\nimport { fieldReducer } from './fieldReducer.js'\nimport { getDataByPath as getDataByPathFunc } from './getDataByPath.js'\nimport { getSiblingData as getSiblingDataFunc } from './getSiblingData.js'\nimport { initContextState } from './initContextState.js'\nimport { mergeServerFormState } from './mergeServerFormState.js'\n\nconst baseClass = 'form'\n\nexport const Form: React.FC<FormProps> = (props) => {\n const { id, collectionSlug, globalSlug } = useDocumentInfo()\n\n const {\n action,\n beforeSubmit,\n children,\n className,\n disableSuccessStatus,\n disableValidationOnSubmit,\n disabled: disabledFromProps,\n // fields: fieldsFromProps = collection?.fields || global?.fields,\n handleResponse,\n initialState, // fully formed initial field state\n isInitializing: initializingFromProps,\n onChange,\n onSubmit,\n onSuccess,\n redirect,\n submitted: submittedFromProps,\n uuid,\n waitForAutocomplete,\n } = props\n\n const method = 'method' in props ? props?.method : undefined\n\n const router = useRouter()\n\n const { code: locale } = useLocale()\n const { i18n, t } = useTranslation()\n const { refreshCookie, user } = useAuth()\n const operation = useOperation()\n const { formQueryParams } = useFormQueryParams()\n\n const config = useConfig()\n const {\n routes: { api: apiRoute },\n serverURL,\n } = config\n\n const [disabled, setDisabled] = useState(disabledFromProps || false)\n const [isMounted, setIsMounted] = useState(false)\n const [modified, setModified] = useState(false)\n const [initializing, setInitializing] = useState(initializingFromProps)\n const [processing, setProcessing] = useState(false)\n const [submitted, setSubmitted] = useState(false)\n const formRef = useRef<HTMLFormElement>(null)\n const contextRef = useRef({} as FormContextType)\n\n const fieldsReducer = useReducer(fieldReducer, {}, () => initialState)\n\n /**\n * `fields` is the current, up-to-date state/data of all fields in the form. It can be modified by using dispatchFields,\n * which calls the fieldReducer, which then updates the state.\n */\n const [fields, dispatchFields] = fieldsReducer\n\n contextRef.current.fields = fields\n\n const validateForm = useCallback(async () => {\n const validatedFieldState = {}\n let isValid = true\n\n const dataFromContext = contextRef.current.getData()\n const data = dataFromContext\n\n const validationPromises = Object.entries(contextRef.current.fields).map(\n async ([path, field]) => {\n const validatedField = field\n\n if (field.passesCondition !== false) {\n let validationResult: boolean | string = validatedField.valid\n\n if (typeof field.validate === 'function') {\n let valueToValidate = field.value\n\n if (field?.rows && Array.isArray(field.rows)) {\n valueToValidate = contextRef.current.getDataByPath(path)\n }\n\n validationResult = await field.validate(valueToValidate, {\n id,\n config,\n data,\n operation,\n siblingData: contextRef.current.getSiblingData(path),\n t,\n user,\n })\n\n if (typeof validationResult === 'string') {\n validatedField.errorMessage = validationResult\n validatedField.valid = false\n } else {\n validatedField.valid = true\n validatedField.errorMessage = undefined\n }\n }\n\n if (validatedField.valid === false) {\n isValid = false\n }\n }\n\n validatedFieldState[path] = validatedField\n },\n )\n\n await Promise.all(validationPromises)\n\n if (!dequal(contextRef.current.fields, validatedFieldState)) {\n dispatchFields({ type: 'REPLACE_STATE', state: validatedFieldState })\n }\n\n return isValid\n }, [id, user, operation, t, dispatchFields, config])\n\n const submit = useCallback(\n async (options: SubmitOptions = {}, e): Promise<void> => {\n const {\n action: actionArg,\n method: methodToUse = method,\n overrides = {},\n skipValidation,\n } = options\n\n if (disabled) {\n if (e) {\n e.preventDefault()\n }\n return\n }\n\n // create new toast promise which will resolve manually later\n let successToast, errorToast\n const promise = new Promise((resolve, reject) => {\n successToast = resolve\n errorToast = reject\n })\n\n const hasFormSubmitAction =\n actionArg || typeof action === 'string' || typeof action === 'function'\n\n if (redirect || disableSuccessStatus || !hasFormSubmitAction) {\n // Do not show submitting toast, as the promise toast may never disappear under these conditions.\n // Instead, make successToast() or errorToast() throw toast.success / toast.error\n successToast = (data) => toast.success(data)\n errorToast = (data) => toast.error(data)\n } else {\n toast.promise(promise, {\n error: (data) => {\n return data as string\n },\n loading: t('general:submitting'),\n success: (data) => {\n return data as string\n },\n })\n }\n\n if (e) {\n e.stopPropagation()\n e.preventDefault()\n }\n\n setProcessing(true)\n setDisabled(true)\n\n if (waitForAutocomplete) await wait(100)\n\n // Execute server side validations\n if (Array.isArray(beforeSubmit)) {\n let revalidatedFormState: FormState\n\n await beforeSubmit.reduce(async (priorOnChange, beforeSubmitFn) => {\n await priorOnChange\n\n const result = await beforeSubmitFn({\n formState: fields,\n })\n\n revalidatedFormState = result\n }, Promise.resolve())\n\n const isValid = Object.entries(revalidatedFormState).every(([, field]) => field.valid)\n\n if (!isValid) {\n setProcessing(false)\n setSubmitted(true)\n setDisabled(false)\n return dispatchFields({ type: 'REPLACE_STATE', state: revalidatedFormState })\n }\n }\n\n const isValid =\n skipValidation || disableValidationOnSubmit ? true : await contextRef.current.validateForm()\n\n // If not valid, prevent submission\n if (!isValid) {\n errorToast(t('error:correctInvalidFields'))\n setProcessing(false)\n setSubmitted(true)\n setDisabled(false)\n return\n }\n\n // If submit handler comes through via props, run that\n if (onSubmit) {\n const data = {\n ...reduceFieldsToValues(fields, true),\n ...overrides,\n }\n\n onSubmit(fields, data)\n }\n\n if (!hasFormSubmitAction) {\n // No action provided, so we should return. An example where this happens are lexical link drawers. Upon submitting the drawer, we\n // want to close it without submitting the form. Stuff like validation would be handled by lexical before this, through beforeSubmit\n setProcessing(false)\n setSubmitted(true)\n setDisabled(false)\n return\n }\n\n const formData = contextRef.current.createFormData(overrides)\n\n try {\n let res\n const actionEndpoint =\n actionArg ||\n (typeof action === 'string'\n ? `${action}${qs.stringify(formQueryParams, { addQueryPrefix: true })}`\n : null)\n\n if (actionEndpoint) {\n res = await requests[methodToUse.toLowerCase()](actionEndpoint, {\n body: formData,\n headers: {\n 'Accept-Language': i18n.language,\n },\n })\n } else if (typeof action === 'function') {\n res = await action(formData)\n }\n\n setModified(false)\n setDisabled(false)\n\n if (typeof handleResponse === 'function') {\n handleResponse(res, successToast, errorToast)\n return\n }\n\n const contentType = res.headers.get('content-type')\n const isJSON = contentType && contentType.indexOf('application/json') !== -1\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let json: Record<string, any> = {}\n\n if (isJSON) json = await res.json()\n if (res.status < 400) {\n if (typeof onSuccess === 'function') await onSuccess(json)\n setSubmitted(false)\n setProcessing(false)\n\n if (redirect) {\n router.push(redirect)\n } else if (!disableSuccessStatus) {\n successToast(json.message || t('general:submissionSuccessful'))\n }\n } else {\n setProcessing(false)\n setSubmitted(true)\n\n contextRef.current = { ...contextRef.current } // triggers rerender of all components that subscribe to form\n if (json.message) {\n errorToast(json.message)\n\n return\n }\n\n if (Array.isArray(json.errors)) {\n const [fieldErrors, nonFieldErrors] = json.errors.reduce(\n ([fieldErrs, nonFieldErrs], err) => {\n const newFieldErrs = []\n const newNonFieldErrs = []\n\n if (err?.message) {\n newNonFieldErrs.push(err)\n }\n\n if (Array.isArray(err?.data)) {\n err.data.forEach((dataError) => {\n if (dataError?.field) {\n newFieldErrs.push(dataError)\n } else {\n newNonFieldErrs.push(dataError)\n }\n })\n }\n\n return [\n [...fieldErrs, ...newFieldErrs],\n [...nonFieldErrs, ...newNonFieldErrs],\n ]\n },\n [[], []],\n )\n\n dispatchFields({\n type: 'ADD_SERVER_ERRORS',\n errors: fieldErrors,\n })\n\n nonFieldErrors.forEach((err) => {\n errorToast(err.message || t('error:unknown'))\n })\n\n return\n }\n\n const message = errorMessages?.[res.status] || res?.statusText || t('error:unknown')\n\n errorToast(message)\n }\n } catch (err) {\n console.error('Error submitting form', err)\n setProcessing(false)\n setSubmitted(true)\n setDisabled(false)\n\n errorToast(err.message)\n }\n },\n [\n beforeSubmit,\n action,\n disableSuccessStatus,\n disableValidationOnSubmit,\n disabled,\n dispatchFields,\n fields,\n handleResponse,\n method,\n onSubmit,\n onSuccess,\n redirect,\n router,\n t,\n i18n,\n waitForAutocomplete,\n formQueryParams,\n ],\n )\n\n const getFields = useCallback(() => contextRef.current.fields, [])\n\n const getField = useCallback((path: string) => contextRef.current.fields[path], [])\n\n const getData = useCallback(() => reduceFieldsToValues(contextRef.current.fields, true), [])\n\n const getSiblingData = useCallback(\n (path: string) => getSiblingDataFunc(contextRef.current.fields, path),\n [],\n )\n const getDataByPath = useCallback<GetDataByPath>(\n (path: string) => getDataByPathFunc(contextRef.current.fields, path),\n [],\n )\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const createFormData = useCallback((overrides: any = {}) => {\n const data = reduceFieldsToValues(contextRef.current.fields, true)\n\n const file = data?.file\n\n if (file) {\n delete data.file\n }\n\n const dataWithOverrides = {\n ...data,\n ...overrides,\n }\n\n const dataToSerialize = {\n _payload: JSON.stringify(dataWithOverrides),\n file,\n }\n\n // nullAsUndefineds is important to allow uploads and relationship fields to clear themselves\n const formData = serialize(dataToSerialize, { indices: true, nullsAsUndefineds: false })\n\n return formData\n }, [])\n\n const reset = useCallback(\n async (data: unknown) => {\n const newState = await getFormState({\n apiRoute,\n body: {\n id,\n collectionSlug,\n data,\n globalSlug,\n operation,\n schemaPath: collectionSlug || globalSlug,\n },\n serverURL,\n })\n\n contextRef.current = { ...initContextState } as FormContextType\n setModified(false)\n dispatchFields({ type: 'REPLACE_STATE', state: newState })\n },\n [apiRoute, collectionSlug, dispatchFields, globalSlug, id, operation, serverURL],\n )\n\n const replaceState = useCallback(\n (state: FormState) => {\n contextRef.current = { ...initContextState } as FormContextType\n setModified(false)\n dispatchFields({ type: 'REPLACE_STATE', state })\n },\n [dispatchFields],\n )\n\n const getFieldStateBySchemaPath = useCallback(\n async ({ data, schemaPath }) => {\n const fieldSchema = await getFormState({\n apiRoute,\n body: {\n collectionSlug,\n data,\n globalSlug,\n schemaPath,\n },\n serverURL,\n })\n return fieldSchema\n },\n [apiRoute, collectionSlug, globalSlug, serverURL],\n )\n\n const addFieldRow: FormContextType['addFieldRow'] = useCallback(\n async ({ data, path, rowIndex, schemaPath }) => {\n const subFieldState = await getFieldStateBySchemaPath({ data, schemaPath })\n\n dispatchFields({\n type: 'ADD_ROW',\n blockType: data?.blockType,\n path,\n rowIndex,\n subFieldState,\n })\n },\n [getFieldStateBySchemaPath, dispatchFields],\n )\n\n const removeFieldRow: FormContextType['removeFieldRow'] = useCallback(\n ({ path, rowIndex }) => {\n dispatchFields({ type: 'REMOVE_ROW', path, rowIndex })\n },\n [dispatchFields],\n )\n\n const replaceFieldRow: FormContextType['replaceFieldRow'] = useCallback(\n async ({ data, path, rowIndex, schemaPath }) => {\n const subFieldState = await getFieldStateBySchemaPath({ data, schemaPath })\n\n dispatchFields({\n type: 'REPLACE_ROW',\n blockType: data?.blockType,\n path,\n rowIndex,\n subFieldState,\n })\n },\n [getFieldStateBySchemaPath, dispatchFields],\n )\n\n useEffect(() => {\n if (initializingFromProps !== undefined) {\n setInitializing(initializingFromProps)\n }\n }, [initializingFromProps])\n\n contextRef.current.submit = submit\n contextRef.current.getFields = getFields\n contextRef.current.getField = getField\n contextRef.current.getData = getData\n contextRef.current.getSiblingData = getSiblingData\n contextRef.current.getDataByPath = getDataByPath\n contextRef.current.validateForm = validateForm\n contextRef.current.createFormData = createFormData\n contextRef.current.setModified = setModified\n contextRef.current.setProcessing = setProcessing\n contextRef.current.setSubmitted = setSubmitted\n contextRef.current.disabled = disabled\n contextRef.current.setDisabled = setDisabled\n contextRef.current.formRef = formRef\n contextRef.current.reset = reset\n contextRef.current.replaceState = replaceState\n contextRef.current.dispatchFields = dispatchFields\n contextRef.current.addFieldRow = addFieldRow\n contextRef.current.removeFieldRow = removeFieldRow\n contextRef.current.replaceFieldRow = replaceFieldRow\n contextRef.current.uuid = uuid\n contextRef.current.initializing = initializing\n\n useEffect(() => {\n setIsMounted(true)\n }, [])\n\n useEffect(() => {\n if (typeof disabledFromProps === 'boolean') setDisabled(disabledFromProps)\n }, [disabledFromProps])\n\n useEffect(() => {\n if (typeof submittedFromProps === 'boolean') setSubmitted(submittedFromProps)\n }, [submittedFromProps])\n\n useEffect(() => {\n if (initialState) {\n contextRef.current = { ...initContextState } as FormContextType\n dispatchFields({ type: 'REPLACE_STATE', optimize: false, state: initialState })\n }\n }, [initialState, dispatchFields])\n\n useThrottledEffect(\n () => {\n refreshCookie()\n },\n 15000,\n [fields],\n )\n\n useEffect(() => {\n contextRef.current = { ...contextRef.current } // triggers rerender of all components that subscribe to form\n setModified(false)\n }, [locale])\n\n const classes = [className, baseClass].filter(Boolean).join(' ')\n\n useDebouncedEffect(\n () => {\n const executeOnChange = async () => {\n if (Array.isArray(onChange)) {\n let revalidatedFormState: FormState = contextRef.current.fields\n\n for (const onChangeFn of onChange) {\n revalidatedFormState = await onChangeFn({\n formState: revalidatedFormState,\n })\n }\n\n const { changed, newState } = mergeServerFormState(\n contextRef.current.fields || {},\n revalidatedFormState,\n )\n\n if (changed) {\n dispatchFields({\n type: 'REPLACE_STATE',\n optimize: false,\n state: newState,\n })\n }\n }\n }\n\n if (modified) void executeOnChange()\n },\n 150,\n // Make sure we trigger this whenever modified changes (not just when `fields` changes), otherwise we will miss merging server form state for the first form update/onChange. Here's why:\n // `fields` updates before `modified`, because setModified is in a setTimeout. So on the first change, modified is false, so we don't trigger the effect even though we should.\n [contextRef.current.fields, dispatchFields, onChange, modified],\n )\n\n const actionString =\n typeof action === 'string'\n ? `${action}${qs.stringify(formQueryParams, { addQueryPrefix: true })}`\n : ''\n\n return (\n <form\n action={method ? actionString : (action as string)}\n className={classes}\n method={method}\n noValidate\n onSubmit={(e) => contextRef.current.submit({}, e)}\n ref={formRef}\n >\n <FormContext.Provider value={contextRef.current}>\n <FormWatchContext.Provider\n value={{\n fields,\n ...contextRef.current,\n }}\n >\n <SubmittedContext.Provider value={submitted}>\n <InitializingContext.Provider value={!isMounted || (isMounted && initializing)}>\n <ProcessingContext.Provider value={processing}>\n <ModifiedContext.Provider value={modified}>\n <FormFieldsContext.Provider value={fieldsReducer}>\n {children}\n </FormFieldsContext.Provider>\n </ModifiedContext.Provider>\n </ProcessingContext.Provider>\n </InitializingContext.Provider>\n </SubmittedContext.Provider>\n </FormWatchContext.Provider>\n </FormContext.Provider>\n </form>\n )\n}\n\nexport {\n FormContext,\n FormFieldsContext,\n FormWatchContext,\n ModifiedContext,\n ProcessingContext,\n SubmittedContext,\n useAllFormFields,\n useForm,\n useFormFields,\n useFormModified,\n useFormProcessing,\n useFormSubmitted,\n useWatchForm,\n} from './context.js'\n\nexport { FormProps }\n"],"names":["dequal","useRouter","serialize","wait","qs","React","useCallback","useEffect","useReducer","useRef","useState","toast","useDebouncedEffect","useThrottledEffect","useAuth","useConfig","useDocumentInfo","useFormQueryParams","useLocale","useOperation","useTranslation","requests","getFormState","reduceFieldsToValues","FormContext","FormFieldsContext","FormWatchContext","InitializingContext","ModifiedContext","ProcessingContext","SubmittedContext","errorMessages","fieldReducer","getDataByPath","getDataByPathFunc","getSiblingData","getSiblingDataFunc","initContextState","mergeServerFormState","baseClass","Form","props","id","collectionSlug","globalSlug","action","beforeSubmit","children","className","disableSuccessStatus","disableValidationOnSubmit","disabled","disabledFromProps","handleResponse","initialState","isInitializing","initializingFromProps","onChange","onSubmit","onSuccess","redirect","submitted","submittedFromProps","uuid","waitForAutocomplete","method","undefined","router","code","locale","i18n","t","refreshCookie","user","operation","formQueryParams","config","routes","api","apiRoute","serverURL","setDisabled","isMounted","setIsMounted","modified","setModified","initializing","setInitializing","processing","setProcessing","setSubmitted","formRef","contextRef","fieldsReducer","fields","dispatchFields","current","validateForm","validatedFieldState","isValid","dataFromContext","getData","data","validationPromises","Object","entries","map","path","field","validatedField","passesCondition","validationResult","valid","validate","valueToValidate","value","rows","Array","isArray","siblingData","errorMessage","Promise","all","type","state","submit","options","e","actionArg","methodToUse","overrides","skipValidation","preventDefault","successToast","errorToast","promise","resolve","reject","hasFormSubmitAction","success","error","loading","stopPropagation","revalidatedFormState","reduce","priorOnChange","beforeSubmitFn","result","formState","every","formData","createFormData","res","actionEndpoint","stringify","addQueryPrefix","toLowerCase","body","headers","language","contentType","get","isJSON","indexOf","json","status","push","message","errors","fieldErrors","nonFieldErrors","fieldErrs","nonFieldErrs","err","newFieldErrs","newNonFieldErrs","forEach","dataError","statusText","console","getFields","getField","file","dataWithOverrides","dataToSerialize","_payload","JSON","indices","nullsAsUndefineds","reset","newState","schemaPath","replaceState","getFieldStateBySchemaPath","fieldSchema","addFieldRow","rowIndex","subFieldState","blockType","removeFieldRow","replaceFieldRow","optimize","classes","filter","Boolean","join","executeOnChange","onChangeFn","changed","actionString","form","noValidate","ref","Provider","useAllFormFields","useForm","useFormFields","useFormModified","useFormProcessing","useFormSubmitted","useWatchForm"],"mappings":"AAAA;;AAGA,kEAAkE,GAClE,SAASA,MAAM,QAAQ,cAAa,CAAC,wCAAwC;AAC7E,SAASC,SAAS,QAAQ,qBAAoB;AAC9C,SAASC,SAAS,QAAQ,qBAAoB;AAC9C,SAASC,IAAI,QAAQ,iBAAgB;AACrC,OAAOC,QAAQ,KAAI;AACnB,OAAOC,SAASC,WAAW,EAAEC,SAAS,EAAEC,UAAU,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAO;AACnF,SAASC,KAAK,QAAQ,SAAQ;AAS9B,SAASC,kBAAkB,QAAQ,oCAAmC;AACtE,SAASC,kBAAkB,QAAQ,oCAAmC;AACtE,SAASC,OAAO,QAAQ,gCAA+B;AACvD,SAASC,SAAS,QAAQ,kCAAiC;AAC3D,SAASC,eAAe,QAAQ,wCAAuC;AACvE,SAASC,kBAAkB,QAAQ,2CAA0C;AAC7E,SAASC,SAAS,QAAQ,kCAAiC;AAC3D,SAASC,YAAY,QAAQ,qCAAoC;AACjE,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,QAAQ,QAAQ,yBAAwB;AACjD,SAASC,YAAY,QAAQ,kCAAiC;AAC9D,SAASC,oBAAoB,QAAQ,0CAAyC;AAC9E,SACEC,WAAW,EACXC,iBAAiB,EACjBC,gBAAgB,EAChBC,mBAAmB,EACnBC,eAAe,EACfC,iBAAiB,EACjBC,gBAAgB,QACX,eAAc;AACrB,SAASC,aAAa,QAAQ,qBAAoB;AAClD,SAASC,YAAY,QAAQ,oBAAmB;AAChD,SAASC,iBAAiBC,iBAAiB,QAAQ,qBAAoB;AACvE,SAASC,kBAAkBC,kBAAkB,QAAQ,sBAAqB;AAC1E,SAASC,gBAAgB,QAAQ,wBAAuB;AACxD,SAASC,oBAAoB,QAAQ,4BAA2B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;gCAAClG,OAAO/B;0CAC/B,cAAA,KAAC3D,kBAAkB4L,QAAQ;oCAAClG,OAAOtB;8CAChC9C;;;;;;;;;AAUrB,EAAC;AAED,SACEvB,WAAW,EACXC,iBAAiB,EACjBC,gBAAgB,EAChBE,eAAe,EACfC,iBAAiB,EACjBC,gBAAgB,EAChBwL,gBAAgB,EAChBC,OAAO,EACPC,aAAa,EACbC,eAAe,EACfC,iBAAiB,EACjBC,gBAAgB,EAChBC,YAAY,QACP,eAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/forms/Form/initContextState.ts"],"sourcesContent":["import type { Data, FormField, FormState } from 'payload'\n\nimport type {\n Context,\n CreateFormData,\n DispatchFields,\n GetSiblingData,\n Reset,\n SetModified,\n SetProcessing,\n SetSubmitted,\n Submit,\n ValidateForm,\n} from './types.js'\n\nconst submit: Submit = () => undefined\nconst getSiblingData: GetSiblingData = () => undefined\nconst dispatchFields: DispatchFields = () => undefined\nconst validateForm: ValidateForm = () => undefined\nconst createFormData: CreateFormData = () => undefined\n\nconst setModified: SetModified = () => undefined\nconst setProcessing: SetProcessing = () => undefined\nconst setSubmitted: SetSubmitted = () => undefined\nconst reset: Reset = () => undefined\n\nexport const initContextState: Context = {\n addFieldRow: () => undefined,\n buildRowErrors: () => undefined,\n createFormData,\n disabled: false,\n dispatchFields,\n fields: {},\n formRef: null,\n getData: (): Data => undefined,\n getDataByPath: () => undefined,\n getField: (): FormField => undefined,\n getFields: (): FormState => ({}),\n getSiblingData,\n initializing: undefined,\n removeFieldRow: () => undefined,\n replaceFieldRow: () => undefined,\n replaceState: () => undefined,\n reset,\n setDisabled: () => undefined,\n setModified,\n setProcessing,\n setSubmitted,\n submit,\n validateForm,\n}\n"],"names":["submit","undefined","getSiblingData","dispatchFields","validateForm","createFormData","setModified","setProcessing","setSubmitted","reset","initContextState","addFieldRow","buildRowErrors","disabled","fields","formRef","getData","getDataByPath","getField","getFields","initializing","removeFieldRow","replaceFieldRow","replaceState","setDisabled"],"
|
|
1
|
+
{"version":3,"sources":["../../../src/forms/Form/initContextState.ts"],"sourcesContent":["import type { Data, FormField, FormState } from 'payload'\n\nimport type {\n Context,\n CreateFormData,\n DispatchFields,\n GetSiblingData,\n Reset,\n SetModified,\n SetProcessing,\n SetSubmitted,\n Submit,\n ValidateForm,\n} from './types.js'\n\nconst submit: Submit = () => undefined\nconst getSiblingData: GetSiblingData = () => undefined\nconst dispatchFields: DispatchFields = () => undefined\nconst validateForm: ValidateForm = () => undefined\nconst createFormData: CreateFormData = () => undefined\n\nconst setModified: SetModified = () => undefined\nconst setProcessing: SetProcessing = () => undefined\nconst setSubmitted: SetSubmitted = () => undefined\nconst reset: Reset = () => undefined\n\nexport const initContextState: Context = {\n addFieldRow: () => undefined,\n buildRowErrors: () => undefined,\n createFormData,\n disabled: false,\n dispatchFields,\n fields: {},\n formRef: null,\n getData: (): Data => undefined,\n getDataByPath: () => undefined,\n getField: (): FormField => undefined,\n getFields: (): FormState => ({}),\n getSiblingData,\n initializing: undefined,\n removeFieldRow: () => undefined,\n replaceFieldRow: () => undefined,\n replaceState: () => undefined,\n reset,\n setDisabled: () => undefined,\n setModified,\n setProcessing,\n setSubmitted,\n submit,\n validateForm,\n}\n"],"names":["submit","undefined","getSiblingData","dispatchFields","validateForm","createFormData","setModified","setProcessing","setSubmitted","reset","initContextState","addFieldRow","buildRowErrors","disabled","fields","formRef","getData","getDataByPath","getField","getFields","initializing","removeFieldRow","replaceFieldRow","replaceState","setDisabled"],"mappings":"AAeA,MAAMA,SAAiB,IAAMC;AAC7B,MAAMC,iBAAiC,IAAMD;AAC7C,MAAME,iBAAiC,IAAMF;AAC7C,MAAMG,eAA6B,IAAMH;AACzC,MAAMI,iBAAiC,IAAMJ;AAE7C,MAAMK,cAA2B,IAAML;AACvC,MAAMM,gBAA+B,IAAMN;AAC3C,MAAMO,eAA6B,IAAMP;AACzC,MAAMQ,QAAe,IAAMR;AAE3B,OAAO,MAAMS,mBAA4B;IACvCC,aAAa,IAAMV;IACnBW,gBAAgB,IAAMX;IACtBI;IACAQ,UAAU;IACVV;IACAW,QAAQ,CAAC;IACTC,SAAS;IACTC,SAAS,IAAYf;IACrBgB,eAAe,IAAMhB;IACrBiB,UAAU,IAAiBjB;IAC3BkB,WAAW,IAAkB,CAAA,CAAC,CAAA;IAC9BjB;IACAkB,cAAcnB;IACdoB,gBAAgB,IAAMpB;IACtBqB,iBAAiB,IAAMrB;IACvBsB,cAAc,IAAMtB;IACpBQ;IACAe,aAAa,IAAMvB;IACnBK;IACAC;IACAC;IACAR;IACAI;AACF,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/forms/Form/mergeErrorPaths.ts"],"sourcesContent":["import { arraysHaveSameStrings } from '../../utilities/arraysHaveSameStrings.js'\n\nexport const mergeErrorPaths = (\n existing?: string[],\n incoming?: string[],\n): {\n changed: boolean\n result?: string[]\n} => {\n if (!existing) {\n return {\n changed: false,\n result: undefined,\n }\n }\n\n const existingErrorPaths: string[] = []\n const incomingErrorPaths: string[] = []\n\n if (Array.isArray(incoming) && incoming?.length) {\n incoming.forEach((path) => incomingErrorPaths.push(path))\n }\n\n if (Array.isArray(existing) && existing?.length) {\n existing.forEach((path) => existingErrorPaths.push(path))\n }\n\n if (!arraysHaveSameStrings(existingErrorPaths, incomingErrorPaths)) {\n return {\n changed: true,\n result: incomingErrorPaths,\n }\n }\n return {\n changed: false,\n result: existing,\n }\n}\n"],"names":["arraysHaveSameStrings","mergeErrorPaths","existing","incoming","changed","result","undefined","existingErrorPaths","incomingErrorPaths","Array","isArray","length","forEach","path","push"],"
|
|
1
|
+
{"version":3,"sources":["../../../src/forms/Form/mergeErrorPaths.ts"],"sourcesContent":["import { arraysHaveSameStrings } from '../../utilities/arraysHaveSameStrings.js'\n\nexport const mergeErrorPaths = (\n existing?: string[],\n incoming?: string[],\n): {\n changed: boolean\n result?: string[]\n} => {\n if (!existing) {\n return {\n changed: false,\n result: undefined,\n }\n }\n\n const existingErrorPaths: string[] = []\n const incomingErrorPaths: string[] = []\n\n if (Array.isArray(incoming) && incoming?.length) {\n incoming.forEach((path) => incomingErrorPaths.push(path))\n }\n\n if (Array.isArray(existing) && existing?.length) {\n existing.forEach((path) => existingErrorPaths.push(path))\n }\n\n if (!arraysHaveSameStrings(existingErrorPaths, incomingErrorPaths)) {\n return {\n changed: true,\n result: incomingErrorPaths,\n }\n }\n return {\n changed: false,\n result: existing,\n }\n}\n"],"names":["arraysHaveSameStrings","mergeErrorPaths","existing","incoming","changed","result","undefined","existingErrorPaths","incomingErrorPaths","Array","isArray","length","forEach","path","push"],"mappings":"AAAA,SAASA,qBAAqB,QAAQ,2CAA0C;AAEhF,OAAO,MAAMC,kBAAkB,CAC7BC,UACAC;IAKA,IAAI,CAACD,UAAU;QACb,OAAO;YACLE,SAAS;YACTC,QAAQC;QACV;IACF;IAEA,MAAMC,qBAA+B,EAAE;IACvC,MAAMC,qBAA+B,EAAE;IAEvC,IAAIC,MAAMC,OAAO,CAACP,aAAaA,UAAUQ,QAAQ;QAC/CR,SAASS,OAAO,CAAC,CAACC,OAASL,mBAAmBM,IAAI,CAACD;IACrD;IAEA,IAAIJ,MAAMC,OAAO,CAACR,aAAaA,UAAUS,QAAQ;QAC/CT,SAASU,OAAO,CAAC,CAACC,OAASN,mBAAmBO,IAAI,CAACD;IACrD;IAEA,IAAI,CAACb,sBAAsBO,oBAAoBC,qBAAqB;QAClE,OAAO;YACLJ,SAAS;YACTC,QAAQG;QACV;IACF;IACA,OAAO;QACLJ,SAAS;QACTC,QAAQH;IACV;AACF,EAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { dequal } from 'dequal/lite'; // lite: no need for Map and Set support
|
|
2
2
|
import { mergeErrorPaths } from './mergeErrorPaths.js';
|
|
3
3
|
const serverPropsToAccept = [
|
|
4
4
|
'passesCondition',
|
|
@@ -29,7 +29,7 @@ const serverPropsToAccept = [
|
|
|
29
29
|
/**
|
|
30
30
|
* Handle filterOptions
|
|
31
31
|
*/ if (incomingState[path]?.filterOptions || newFieldState.filterOptions) {
|
|
32
|
-
if (!
|
|
32
|
+
if (!dequal(incomingState[path]?.filterOptions, newFieldState.filterOptions)) {
|
|
33
33
|
changed = true;
|
|
34
34
|
newFieldState.filterOptions = incomingState[path].filterOptions;
|
|
35
35
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/forms/Form/mergeServerFormState.ts"],"sourcesContent":["import type { FormState } from 'payload'\n\nimport
|
|
1
|
+
{"version":3,"sources":["../../../src/forms/Form/mergeServerFormState.ts"],"sourcesContent":["import type { FormState } from 'payload'\n\nimport { dequal } from 'dequal/lite' // lite: no need for Map and Set support\n\nimport { mergeErrorPaths } from './mergeErrorPaths.js'\n\nconst serverPropsToAccept = ['passesCondition', 'valid', 'errorMessage']\n\n/**\n * Merges certain properties from the server state into the client state. These do not include values,\n * as we do not want to update them on the client like that, which would cause flickering.\n *\n * We want to use this to update the error state, and other properties that are not user input, as the error state\n * is the thing we want to keep in sync with the server (where it's calculated) on the client.\n */\nexport const mergeServerFormState = (\n existingState: FormState,\n incomingState: FormState,\n): { changed: boolean; newState: FormState } => {\n let changed = false\n\n const newState = {}\n\n if (existingState) {\n Object.entries(existingState).forEach(([path, newFieldState]) => {\n if (!incomingState[path]) return\n\n /**\n * Handle error paths\n */\n\n const errorPathsResult = mergeErrorPaths(\n newFieldState.errorPaths,\n incomingState[path].errorPaths as unknown as string[],\n )\n if (errorPathsResult.result) {\n if (errorPathsResult.changed) {\n changed = errorPathsResult.changed\n }\n newFieldState.errorPaths = errorPathsResult.result\n }\n\n /**\n * Handle filterOptions\n */\n if (incomingState[path]?.filterOptions || newFieldState.filterOptions) {\n if (!dequal(incomingState[path]?.filterOptions, newFieldState.filterOptions)) {\n changed = true\n newFieldState.filterOptions = incomingState[path].filterOptions\n }\n }\n\n /**\n * Handle the rest which is in serverPropsToAccept\n */\n serverPropsToAccept.forEach((prop) => {\n if (incomingState[path]?.[prop] !== newFieldState[prop]) {\n changed = true\n if (!(prop in incomingState[path])) {\n delete newFieldState[prop]\n } else {\n newFieldState[prop] = incomingState[path][prop]\n }\n }\n })\n\n // Conditions don't work if we don't memcopy the new state, as the object references would otherwise be the same\n newState[path] = { ...newFieldState }\n })\n }\n\n return { changed, newState }\n}\n"],"names":["dequal","mergeErrorPaths","serverPropsToAccept","mergeServerFormState","existingState","incomingState","changed","newState","Object","entries","forEach","path","newFieldState","errorPathsResult","errorPaths","result","filterOptions","prop"],"mappings":"AAEA,SAASA,MAAM,QAAQ,cAAa,CAAC,wCAAwC;AAE7E,SAASC,eAAe,QAAQ,uBAAsB;AAEtD,MAAMC,sBAAsB;IAAC;IAAmB;IAAS;CAAe;AAExE;;;;;;CAMC,GACD,OAAO,MAAMC,uBAAuB,CAClCC,eACAC;IAEA,IAAIC,UAAU;IAEd,MAAMC,WAAW,CAAC;IAElB,IAAIH,eAAe;QACjBI,OAAOC,OAAO,CAACL,eAAeM,OAAO,CAAC,CAAC,CAACC,MAAMC,cAAc;YAC1D,IAAI,CAACP,aAAa,CAACM,KAAK,EAAE;YAE1B;;OAEC,GAED,MAAME,mBAAmBZ,gBACvBW,cAAcE,UAAU,EACxBT,aAAa,CAACM,KAAK,CAACG,UAAU;YAEhC,IAAID,iBAAiBE,MAAM,EAAE;gBAC3B,IAAIF,iBAAiBP,OAAO,EAAE;oBAC5BA,UAAUO,iBAAiBP,OAAO;gBACpC;gBACAM,cAAcE,UAAU,GAAGD,iBAAiBE,MAAM;YACpD;YAEA;;OAEC,GACD,IAAIV,aAAa,CAACM,KAAK,EAAEK,iBAAiBJ,cAAcI,aAAa,EAAE;gBACrE,IAAI,CAAChB,OAAOK,aAAa,CAACM,KAAK,EAAEK,eAAeJ,cAAcI,aAAa,GAAG;oBAC5EV,UAAU;oBACVM,cAAcI,aAAa,GAAGX,aAAa,CAACM,KAAK,CAACK,aAAa;gBACjE;YACF;YAEA;;OAEC,GACDd,oBAAoBQ,OAAO,CAAC,CAACO;gBAC3B,IAAIZ,aAAa,CAACM,KAAK,EAAE,CAACM,KAAK,KAAKL,aAAa,CAACK,KAAK,EAAE;oBACvDX,UAAU;oBACV,IAAI,CAAEW,CAAAA,QAAQZ,aAAa,CAACM,KAAK,AAAD,GAAI;wBAClC,OAAOC,aAAa,CAACK,KAAK;oBAC5B,OAAO;wBACLL,aAAa,CAACK,KAAK,GAAGZ,aAAa,CAACM,KAAK,CAACM,KAAK;oBACjD;gBACF;YACF;YAEA,gHAAgH;YAChHV,QAAQ,CAACI,KAAK,GAAG;gBAAE,GAAGC,aAAa;YAAC;QACtC;IACF;IAEA,OAAO;QAAEN;QAASC;IAAS;AAC7B,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/forms/Form/rows.ts"],"sourcesContent":["import type { FormState } from 'payload'\n\ntype Result = {\n remainingFields: FormState\n rows: FormState[]\n}\n\nexport const separateRows = (path: string, fields: FormState): Result => {\n const remainingFields: FormState = {}\n\n const rows = Object.entries(fields).reduce((incomingRows, [fieldPath, field]) => {\n const newRows = incomingRows\n\n if (fieldPath.indexOf(`${path}.`) === 0) {\n const [rowIndex] = fieldPath.replace(`${path}.`, '').split('.')\n if (!newRows[rowIndex]) newRows[rowIndex] = {}\n newRows[rowIndex][fieldPath.replace(`${path}.${String(rowIndex)}.`, '')] = { ...field }\n } else {\n remainingFields[fieldPath] = field\n }\n\n return newRows\n }, [])\n\n return {\n remainingFields,\n rows,\n }\n}\n\nexport const flattenRows = (path: string, rows: FormState[]): FormState => {\n return rows.reduce(\n (fields, row, i) => ({\n ...fields,\n ...Object.entries(row).reduce((subFields, [subPath, subField]) => {\n return {\n ...subFields,\n [`${path}.${i}.${subPath}`]: { ...subField },\n }\n }, {}),\n }),\n {},\n )\n}\n"],"names":["separateRows","path","fields","remainingFields","rows","Object","entries","reduce","incomingRows","fieldPath","field","newRows","indexOf","rowIndex","replace","split","String","flattenRows","row","i","subFields","subPath","subField"],"
|
|
1
|
+
{"version":3,"sources":["../../../src/forms/Form/rows.ts"],"sourcesContent":["import type { FormState } from 'payload'\n\ntype Result = {\n remainingFields: FormState\n rows: FormState[]\n}\n\nexport const separateRows = (path: string, fields: FormState): Result => {\n const remainingFields: FormState = {}\n\n const rows = Object.entries(fields).reduce((incomingRows, [fieldPath, field]) => {\n const newRows = incomingRows\n\n if (fieldPath.indexOf(`${path}.`) === 0) {\n const [rowIndex] = fieldPath.replace(`${path}.`, '').split('.')\n if (!newRows[rowIndex]) newRows[rowIndex] = {}\n newRows[rowIndex][fieldPath.replace(`${path}.${String(rowIndex)}.`, '')] = { ...field }\n } else {\n remainingFields[fieldPath] = field\n }\n\n return newRows\n }, [])\n\n return {\n remainingFields,\n rows,\n }\n}\n\nexport const flattenRows = (path: string, rows: FormState[]): FormState => {\n return rows.reduce(\n (fields, row, i) => ({\n ...fields,\n ...Object.entries(row).reduce((subFields, [subPath, subField]) => {\n return {\n ...subFields,\n [`${path}.${i}.${subPath}`]: { ...subField },\n }\n }, {}),\n }),\n {},\n )\n}\n"],"names":["separateRows","path","fields","remainingFields","rows","Object","entries","reduce","incomingRows","fieldPath","field","newRows","indexOf","rowIndex","replace","split","String","flattenRows","row","i","subFields","subPath","subField"],"mappings":"AAOA,OAAO,MAAMA,eAAe,CAACC,MAAcC;IACzC,MAAMC,kBAA6B,CAAC;IAEpC,MAAMC,OAAOC,OAAOC,OAAO,CAACJ,QAAQK,MAAM,CAAC,CAACC,cAAc,CAACC,WAAWC,MAAM;QAC1E,MAAMC,UAAUH;QAEhB,IAAIC,UAAUG,OAAO,CAAC,CAAC,EAAEX,KAAK,CAAC,CAAC,MAAM,GAAG;YACvC,MAAM,CAACY,SAAS,GAAGJ,UAAUK,OAAO,CAAC,CAAC,EAAEb,KAAK,CAAC,CAAC,EAAE,IAAIc,KAAK,CAAC;YAC3D,IAAI,CAACJ,OAAO,CAACE,SAAS,EAAEF,OAAO,CAACE,SAAS,GAAG,CAAC;YAC7CF,OAAO,CAACE,SAAS,CAACJ,UAAUK,OAAO,CAAC,CAAC,EAAEb,KAAK,CAAC,EAAEe,OAAOH,UAAU,CAAC,CAAC,EAAE,IAAI,GAAG;gBAAE,GAAGH,KAAK;YAAC;QACxF,OAAO;YACLP,eAAe,CAACM,UAAU,GAAGC;QAC/B;QAEA,OAAOC;IACT,GAAG,EAAE;IAEL,OAAO;QACLR;QACAC;IACF;AACF,EAAC;AAED,OAAO,MAAMa,cAAc,CAAChB,MAAcG;IACxC,OAAOA,KAAKG,MAAM,CAChB,CAACL,QAAQgB,KAAKC,IAAO,CAAA;YACnB,GAAGjB,MAAM;YACT,GAAGG,OAAOC,OAAO,CAACY,KAAKX,MAAM,CAAC,CAACa,WAAW,CAACC,SAASC,SAAS;gBAC3D,OAAO;oBACL,GAAGF,SAAS;oBACZ,CAAC,CAAC,EAAEnB,KAAK,CAAC,EAAEkB,EAAE,CAAC,EAAEE,QAAQ,CAAC,CAAC,EAAE;wBAAE,GAAGC,QAAQ;oBAAC;gBAC7C;YACF,GAAG,CAAC,EAAE;QACR,CAAA,GACA,CAAC;AAEL,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/forms/Form/types.ts"],"sourcesContent":["import type { Data, Field, FormField, FormState, User } from 'payload'\nimport type React from 'react'\nimport type { Dispatch } from 'react'\n\nexport type Preferences = {\n [key: string]: unknown\n}\n\nexport type FormProps = (\n | {\n action: (formData: FormData) => Promise<void>\n }\n | {\n action?: string\n method?: 'DELETE' | 'GET' | 'PATCH' | 'POST'\n }\n) & {\n beforeSubmit?: ((args: { formState: FormState }) => Promise<FormState>)[]\n children?: React.ReactNode\n className?: string\n disableSuccessStatus?: boolean\n /**\n * If you would like to solely leverage server-side validation on submit,\n * you can disable checks that the form makes before it submits\n */\n disableValidationOnSubmit?: boolean\n disabled?: boolean\n /**\n * By default, the form will get the field schema (not data) from the current document. If you pass this in, you can override that behavior.\n * This is very useful for sub-forms, where the form's field schema is not necessarily the field schema of the current document (e.g. for the Blocks\n * feature of the Lexical Rich Text field)\n */\n fields?: Field[]\n handleResponse?: (\n res: Response,\n successToast: (value: string) => void,\n errorToast: (value: string) => void,\n ) => void\n initialState?: FormState\n isInitializing?: boolean\n log?: boolean\n onChange?: ((args: { formState: FormState }) => Promise<FormState>)[]\n onSubmit?: (fields: FormState, data: Data) => void\n onSuccess?: (json: unknown) => Promise<void> | void\n redirect?: string\n submitted?: boolean\n uuid?: string\n validationOperation?: 'create' | 'update'\n waitForAutocomplete?: boolean\n}\n\nexport type SubmitOptions = {\n action?: string\n method?: string\n overrides?: Record<string, unknown>\n skipValidation?: boolean\n}\n\nexport type DispatchFields = React.Dispatch<any>\nexport type Submit = (\n options?: SubmitOptions,\n e?: React.FormEvent<HTMLFormElement>,\n) => Promise<void>\nexport type ValidateForm = () => Promise<boolean>\nexport type CreateFormData = (overrides?: any) => FormData\nexport type GetFields = () => FormState\nexport type GetField = (path: string) => FormField\nexport type GetData = () => Data\nexport type GetSiblingData = (path: string) => Data\nexport type GetDataByPath = <T = unknown>(path: string) => T\nexport type SetModified = (modified: boolean) => void\nexport type SetSubmitted = (submitted: boolean) => void\nexport type SetProcessing = (processing: boolean) => void\n\nexport type Reset = (data: unknown) => Promise<void>\n\nexport type REPLACE_STATE = {\n optimize?: boolean\n state: FormState\n type: 'REPLACE_STATE'\n}\n\nexport type REMOVE = {\n path: string\n type: 'REMOVE'\n}\n\nexport type MODIFY_CONDITION = {\n path: string\n result: boolean\n type: 'MODIFY_CONDITION'\n user: User\n}\n\nexport type UPDATE = {\n path: string\n type: 'UPDATE'\n} & Partial<FormField>\n\nexport type REMOVE_ROW = {\n path: string\n rowIndex: number\n type: 'REMOVE_ROW'\n}\n\nexport type ADD_ROW = {\n blockType?: string\n path: string\n rowIndex?: number\n subFieldState?: FormState\n type: 'ADD_ROW'\n}\n\nexport type REPLACE_ROW = {\n blockType?: string\n path: string\n rowIndex: number\n subFieldState?: FormState\n type: 'REPLACE_ROW'\n}\n\nexport type DUPLICATE_ROW = {\n path: string\n rowIndex: number\n type: 'DUPLICATE_ROW'\n}\n\nexport type MOVE_ROW = {\n moveFromIndex: number\n moveToIndex: number\n path: string\n type: 'MOVE_ROW'\n}\n\nexport type ADD_SERVER_ERRORS = {\n errors: {\n field: string\n message: string\n }[]\n type: 'ADD_SERVER_ERRORS'\n}\n\nexport type SET_ROW_COLLAPSED = {\n collapsed: boolean\n path: string\n rowID: string\n setDocFieldPreferences: (field: string, fieldPreferences: { [key: string]: unknown }) => void\n type: 'SET_ROW_COLLAPSED'\n}\n\nexport type SET_ALL_ROWS_COLLAPSED = {\n collapsed: boolean\n path: string\n setDocFieldPreferences: (field: string, fieldPreferences: { [key: string]: unknown }) => void\n type: 'SET_ALL_ROWS_COLLAPSED'\n}\n\nexport type FieldAction =\n | ADD_ROW\n | ADD_SERVER_ERRORS\n | DUPLICATE_ROW\n | MODIFY_CONDITION\n | MOVE_ROW\n | REMOVE\n | REMOVE_ROW\n | REPLACE_ROW\n | REPLACE_STATE\n | SET_ALL_ROWS_COLLAPSED\n | SET_ROW_COLLAPSED\n | UPDATE\n\nexport type FormFieldsContext = [FormState, Dispatch<FieldAction>]\n\nexport type Context = {\n addFieldRow: ({\n data,\n path,\n rowIndex,\n schemaPath,\n }: {\n data?: Data\n path: string\n /*\n * by default the new row will be added to the end of the list\n */\n rowIndex?: number\n schemaPath: string\n }) => Promise<void>\n buildRowErrors: () => void\n createFormData: CreateFormData\n disabled: boolean\n dispatchFields: Dispatch<FieldAction>\n /**\n * Form context fields may be outdated and should not be relied on. Instead, prefer `useFormFields`.\n */\n fields: FormState\n formRef: React.MutableRefObject<HTMLFormElement>\n getData: GetData\n getDataByPath: GetDataByPath\n getField: GetField\n getFields: GetFields\n getSiblingData: GetSiblingData\n initializing: boolean\n removeFieldRow: ({ path, rowIndex }: { path: string; rowIndex: number }) => void\n replaceFieldRow: ({\n data,\n path,\n rowIndex,\n schemaPath,\n }: {\n data?: Data\n path: string\n rowIndex: number\n schemaPath: string\n }) => Promise<void>\n replaceState: (state: FormState) => void\n reset: Reset\n setDisabled: (disabled: boolean) => void\n setModified: SetModified\n setProcessing: SetProcessing\n setSubmitted: SetSubmitted\n submit: Submit\n uuid?: string\n validateForm: ValidateForm\n}\n"],"names":[],"
|
|
1
|
+
{"version":3,"sources":["../../../src/forms/Form/types.ts"],"sourcesContent":["import type { Data, Field, FormField, FormState, User } from 'payload'\nimport type React from 'react'\nimport type { Dispatch } from 'react'\n\nexport type Preferences = {\n [key: string]: unknown\n}\n\nexport type FormProps = (\n | {\n action: (formData: FormData) => Promise<void>\n }\n | {\n action?: string\n method?: 'DELETE' | 'GET' | 'PATCH' | 'POST'\n }\n) & {\n beforeSubmit?: ((args: { formState: FormState }) => Promise<FormState>)[]\n children?: React.ReactNode\n className?: string\n disableSuccessStatus?: boolean\n /**\n * If you would like to solely leverage server-side validation on submit,\n * you can disable checks that the form makes before it submits\n */\n disableValidationOnSubmit?: boolean\n disabled?: boolean\n /**\n * By default, the form will get the field schema (not data) from the current document. If you pass this in, you can override that behavior.\n * This is very useful for sub-forms, where the form's field schema is not necessarily the field schema of the current document (e.g. for the Blocks\n * feature of the Lexical Rich Text field)\n */\n fields?: Field[]\n handleResponse?: (\n res: Response,\n successToast: (value: string) => void,\n errorToast: (value: string) => void,\n ) => void\n initialState?: FormState\n isInitializing?: boolean\n log?: boolean\n onChange?: ((args: { formState: FormState }) => Promise<FormState>)[]\n onSubmit?: (fields: FormState, data: Data) => void\n onSuccess?: (json: unknown) => Promise<void> | void\n redirect?: string\n submitted?: boolean\n uuid?: string\n validationOperation?: 'create' | 'update'\n waitForAutocomplete?: boolean\n}\n\nexport type SubmitOptions = {\n action?: string\n method?: string\n overrides?: Record<string, unknown>\n skipValidation?: boolean\n}\n\nexport type DispatchFields = React.Dispatch<any>\nexport type Submit = (\n options?: SubmitOptions,\n e?: React.FormEvent<HTMLFormElement>,\n) => Promise<void>\nexport type ValidateForm = () => Promise<boolean>\nexport type CreateFormData = (overrides?: any) => FormData\nexport type GetFields = () => FormState\nexport type GetField = (path: string) => FormField\nexport type GetData = () => Data\nexport type GetSiblingData = (path: string) => Data\nexport type GetDataByPath = <T = unknown>(path: string) => T\nexport type SetModified = (modified: boolean) => void\nexport type SetSubmitted = (submitted: boolean) => void\nexport type SetProcessing = (processing: boolean) => void\n\nexport type Reset = (data: unknown) => Promise<void>\n\nexport type REPLACE_STATE = {\n optimize?: boolean\n state: FormState\n type: 'REPLACE_STATE'\n}\n\nexport type REMOVE = {\n path: string\n type: 'REMOVE'\n}\n\nexport type MODIFY_CONDITION = {\n path: string\n result: boolean\n type: 'MODIFY_CONDITION'\n user: User\n}\n\nexport type UPDATE = {\n path: string\n type: 'UPDATE'\n} & Partial<FormField>\n\nexport type REMOVE_ROW = {\n path: string\n rowIndex: number\n type: 'REMOVE_ROW'\n}\n\nexport type ADD_ROW = {\n blockType?: string\n path: string\n rowIndex?: number\n subFieldState?: FormState\n type: 'ADD_ROW'\n}\n\nexport type REPLACE_ROW = {\n blockType?: string\n path: string\n rowIndex: number\n subFieldState?: FormState\n type: 'REPLACE_ROW'\n}\n\nexport type DUPLICATE_ROW = {\n path: string\n rowIndex: number\n type: 'DUPLICATE_ROW'\n}\n\nexport type MOVE_ROW = {\n moveFromIndex: number\n moveToIndex: number\n path: string\n type: 'MOVE_ROW'\n}\n\nexport type ADD_SERVER_ERRORS = {\n errors: {\n field: string\n message: string\n }[]\n type: 'ADD_SERVER_ERRORS'\n}\n\nexport type SET_ROW_COLLAPSED = {\n collapsed: boolean\n path: string\n rowID: string\n setDocFieldPreferences: (field: string, fieldPreferences: { [key: string]: unknown }) => void\n type: 'SET_ROW_COLLAPSED'\n}\n\nexport type SET_ALL_ROWS_COLLAPSED = {\n collapsed: boolean\n path: string\n setDocFieldPreferences: (field: string, fieldPreferences: { [key: string]: unknown }) => void\n type: 'SET_ALL_ROWS_COLLAPSED'\n}\n\nexport type FieldAction =\n | ADD_ROW\n | ADD_SERVER_ERRORS\n | DUPLICATE_ROW\n | MODIFY_CONDITION\n | MOVE_ROW\n | REMOVE\n | REMOVE_ROW\n | REPLACE_ROW\n | REPLACE_STATE\n | SET_ALL_ROWS_COLLAPSED\n | SET_ROW_COLLAPSED\n | UPDATE\n\nexport type FormFieldsContext = [FormState, Dispatch<FieldAction>]\n\nexport type Context = {\n addFieldRow: ({\n data,\n path,\n rowIndex,\n schemaPath,\n }: {\n data?: Data\n path: string\n /*\n * by default the new row will be added to the end of the list\n */\n rowIndex?: number\n schemaPath: string\n }) => Promise<void>\n buildRowErrors: () => void\n createFormData: CreateFormData\n disabled: boolean\n dispatchFields: Dispatch<FieldAction>\n /**\n * Form context fields may be outdated and should not be relied on. Instead, prefer `useFormFields`.\n */\n fields: FormState\n formRef: React.MutableRefObject<HTMLFormElement>\n getData: GetData\n getDataByPath: GetDataByPath\n getField: GetField\n getFields: GetFields\n getSiblingData: GetSiblingData\n initializing: boolean\n removeFieldRow: ({ path, rowIndex }: { path: string; rowIndex: number }) => void\n replaceFieldRow: ({\n data,\n path,\n rowIndex,\n schemaPath,\n }: {\n data?: Data\n path: string\n rowIndex: number\n schemaPath: string\n }) => Promise<void>\n replaceState: (state: FormState) => void\n reset: Reset\n setDisabled: (disabled: boolean) => void\n setModified: SetModified\n setProcessing: SetProcessing\n setSubmitted: SetSubmitted\n submit: Submit\n uuid?: string\n validateForm: ValidateForm\n}\n"],"names":[],"mappings":"AA6KA,WAmDC"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { Banner } from '../../elements/Banner/index.js';
|
|
5
|
-
import {
|
|
5
|
+
import { CheckboxField } from '../../fields/Checkbox/index.js';
|
|
6
6
|
import { useConfig } from '../../providers/Config/index.js';
|
|
7
7
|
import { useLocale } from '../../providers/Locale/index.js';
|
|
8
8
|
import { useTranslation } from '../../providers/Translation/index.js';
|
|
@@ -39,7 +39,7 @@ export const NullifyLocaleField = ({ fieldValue, localized, path })=>{
|
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
return /*#__PURE__*/ _jsx(Banner, {
|
|
42
|
-
children: /*#__PURE__*/ _jsx(
|
|
42
|
+
children: /*#__PURE__*/ _jsx(CheckboxField, {
|
|
43
43
|
checked: checked,
|
|
44
44
|
id: `field-${path.replace(/\./g, '__')}`,
|
|
45
45
|
label: t('general:fallbackToDefaultLocale')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/forms/NullifyField/index.tsx"],"sourcesContent":["'use client'\n\nimport * as React from 'react'\n\nimport { Banner } from '../../elements/Banner/index.js'\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/forms/NullifyField/index.tsx"],"sourcesContent":["'use client'\n\nimport * as React from 'react'\n\nimport { Banner } from '../../elements/Banner/index.js'\nimport { CheckboxField } from '../../fields/Checkbox/index.js'\nimport { useConfig } from '../../providers/Config/index.js'\nimport { useLocale } from '../../providers/Locale/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { useForm } from '../Form/context.js'\n\ntype NullifyLocaleFieldProps = {\n fieldValue?: [] | null | number\n localized: boolean\n path: string\n}\n\nexport const NullifyLocaleField: React.FC<NullifyLocaleFieldProps> = ({\n fieldValue,\n localized,\n path,\n}) => {\n const { dispatchFields, setModified } = useForm()\n const { code: currentLocale } = useLocale()\n const { localization } = useConfig()\n const [checked, setChecked] = React.useState<boolean>(typeof fieldValue !== 'number')\n const defaultLocale =\n localization && localization.defaultLocale ? localization.defaultLocale : 'en'\n const { t } = useTranslation()\n\n const onChange = () => {\n const useFallback = !checked\n\n dispatchFields({\n type: 'UPDATE',\n path,\n value: useFallback ? null : fieldValue || 0,\n })\n setModified(true)\n setChecked(useFallback)\n }\n\n if (!localized || currentLocale === defaultLocale || (localization && !localization.fallback)) {\n // hide when field is not localized or editing default locale or when fallback is disabled\n return null\n }\n\n if (fieldValue) {\n let hideCheckbox = false\n if (typeof fieldValue === 'number' && fieldValue > 0) hideCheckbox = true\n if (Array.isArray(fieldValue) && fieldValue.length > 0) hideCheckbox = true\n\n if (hideCheckbox) {\n if (checked) setChecked(false) // uncheck when field has value\n return null\n }\n }\n\n return (\n <Banner>\n <CheckboxField\n checked={checked}\n id={`field-${path.replace(/\\./g, '__')}`}\n label={t('general:fallbackToDefaultLocale')}\n // onToggle={onChange}\n />\n </Banner>\n )\n}\n"],"names":["React","Banner","CheckboxField","useConfig","useLocale","useTranslation","useForm","NullifyLocaleField","fieldValue","localized","path","dispatchFields","setModified","code","currentLocale","localization","checked","setChecked","useState","defaultLocale","t","onChange","useFallback","type","value","fallback","hideCheckbox","Array","isArray","length","id","replace","label"],"mappings":"AAAA;;AAEA,YAAYA,WAAW,QAAO;AAE9B,SAASC,MAAM,QAAQ,iCAAgC;AACvD,SAASC,aAAa,QAAQ,iCAAgC;AAC9D,SAASC,SAAS,QAAQ,kCAAiC;AAC3D,SAASC,SAAS,QAAQ,kCAAiC;AAC3D,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,OAAO,QAAQ,qBAAoB;AAQ5C,OAAO,MAAMC,qBAAwD,CAAC,EACpEC,UAAU,EACVC,SAAS,EACTC,IAAI,EACL;IACC,MAAM,EAAEC,cAAc,EAAEC,WAAW,EAAE,GAAGN;IACxC,MAAM,EAAEO,MAAMC,aAAa,EAAE,GAAGV;IAChC,MAAM,EAAEW,YAAY,EAAE,GAAGZ;IACzB,MAAM,CAACa,SAASC,WAAW,GAAGjB,MAAMkB,QAAQ,CAAU,OAAOV,eAAe;IAC5E,MAAMW,gBACJJ,gBAAgBA,aAAaI,aAAa,GAAGJ,aAAaI,aAAa,GAAG;IAC5E,MAAM,EAAEC,CAAC,EAAE,GAAGf;IAEd,MAAMgB,WAAW;QACf,MAAMC,cAAc,CAACN;QAErBL,eAAe;YACbY,MAAM;YACNb;YACAc,OAAOF,cAAc,OAAOd,cAAc;QAC5C;QACAI,YAAY;QACZK,WAAWK;IACb;IAEA,IAAI,CAACb,aAAaK,kBAAkBK,iBAAkBJ,gBAAgB,CAACA,aAAaU,QAAQ,EAAG;QAC7F,0FAA0F;QAC1F,OAAO;IACT;IAEA,IAAIjB,YAAY;QACd,IAAIkB,eAAe;QACnB,IAAI,OAAOlB,eAAe,YAAYA,aAAa,GAAGkB,eAAe;QACrE,IAAIC,MAAMC,OAAO,CAACpB,eAAeA,WAAWqB,MAAM,GAAG,GAAGH,eAAe;QAEvE,IAAIA,cAAc;YAChB,IAAIV,SAASC,WAAW,OAAO,+BAA+B;;YAC9D,OAAO;QACT;IACF;IAEA,qBACE,KAAChB;kBACC,cAAA,KAACC;YACCc,SAASA;YACTc,IAAI,CAAC,MAAM,EAAEpB,KAAKqB,OAAO,CAAC,OAAO,MAAM,CAAC;YACxCC,OAAOZ,EAAE;;;AAKjB,EAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import React from 'react';
|
|
4
|
-
import {
|
|
4
|
+
import { HiddenField } from '../../fields/Hidden/index.js';
|
|
5
5
|
import { useFieldComponents } from '../../providers/FieldComponents/index.js';
|
|
6
6
|
import { useOperation } from '../../providers/Operation/index.js';
|
|
7
7
|
import { FieldPropsProvider, useFieldProps } from '../FieldPropsProvider/index.js';
|
|
@@ -30,7 +30,7 @@ export const RenderField = ({ name, type, CustomField, custom, disabled, fieldCo
|
|
|
30
30
|
if (permissions?.[operation]?.permission === false) {
|
|
31
31
|
readOnly = true;
|
|
32
32
|
}
|
|
33
|
-
const DefaultField = isHidden ?
|
|
33
|
+
const DefaultField = isHidden ? HiddenField : fieldComponents[type];
|
|
34
34
|
if (CustomField === undefined && !DefaultField) {
|
|
35
35
|
return null;
|
|
36
36
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/forms/RenderFields/RenderField.tsx"],"sourcesContent":["'use client'\n\nimport type { FieldPermissions, FieldTypes } from 'payload'\n\nimport React from 'react'\n\nimport type {\n FieldComponentProps,\n MappedField,\n} from '../../providers/ComponentMap/buildComponentMap/types.js'\n\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/forms/RenderFields/RenderField.tsx"],"sourcesContent":["'use client'\n\nimport type { FieldPermissions, FieldTypes } from 'payload'\n\nimport React from 'react'\n\nimport type {\n FieldComponentProps,\n MappedField,\n} from '../../providers/ComponentMap/buildComponentMap/types.js'\n\nimport { HiddenField } from '../../fields/Hidden/index.js'\nimport { useFieldComponents } from '../../providers/FieldComponents/index.js'\nimport { useOperation } from '../../providers/Operation/index.js'\nimport { FieldPropsProvider, useFieldProps } from '../FieldPropsProvider/index.js'\n\ntype Props = {\n CustomField: MappedField['CustomField']\n custom?: Record<any, string>\n disabled: boolean\n fieldComponentProps?: FieldComponentProps\n indexPath?: string\n isHidden?: boolean\n name?: string\n path: string\n permissions?: FieldPermissions\n readOnly?: boolean\n schemaPath: string\n siblingPermissions: {\n [fieldName: string]: FieldPermissions\n }\n type: keyof FieldTypes\n}\n\nexport const RenderField: React.FC<Props> = ({\n name,\n type,\n CustomField,\n custom,\n disabled,\n fieldComponentProps,\n indexPath,\n isHidden,\n path: pathFromProps,\n permissions,\n readOnly: readOnlyFromProps,\n schemaPath: schemaPathFromProps,\n siblingPermissions,\n}) => {\n const operation = useOperation()\n const { readOnly: readOnlyFromContext } = useFieldProps()\n const fieldComponents = useFieldComponents()\n\n const path = [pathFromProps, name].filter(Boolean).join('.')\n const schemaPath = [schemaPathFromProps, name].filter(Boolean).join('.')\n\n // if the user cannot read the field, then filter it out\n // this is different from `admin.readOnly` which is executed based on `operation`\n if (permissions?.read?.permission === false || disabled) {\n return null\n }\n\n // `admin.readOnly` displays the value but prevents the field from being edited\n let readOnly = readOnlyFromProps\n\n // if parent field is `readOnly: true`, but this field is `readOnly: false`, the field should still be editable\n if (readOnlyFromContext && readOnly !== false) readOnly = true\n\n // if the user does not have access control to begin with, force it to be read-only\n if (permissions?.[operation]?.permission === false) {\n readOnly = true\n }\n\n const DefaultField = isHidden ? HiddenField : fieldComponents[type]\n\n if (CustomField === undefined && !DefaultField) {\n return null\n }\n\n return (\n <FieldPropsProvider\n custom={custom}\n indexPath={indexPath}\n path={path}\n permissions={permissions}\n readOnly={readOnly}\n schemaPath={schemaPath}\n siblingPermissions={siblingPermissions}\n type={type}\n >\n {CustomField !== undefined ? CustomField : <DefaultField {...fieldComponentProps} />}\n </FieldPropsProvider>\n )\n}\n"],"names":["React","HiddenField","useFieldComponents","useOperation","FieldPropsProvider","useFieldProps","RenderField","name","type","CustomField","custom","disabled","fieldComponentProps","indexPath","isHidden","path","pathFromProps","permissions","readOnly","readOnlyFromProps","schemaPath","schemaPathFromProps","siblingPermissions","operation","readOnlyFromContext","fieldComponents","filter","Boolean","join","read","permission","DefaultField","undefined"],"mappings":"AAAA;;AAIA,OAAOA,WAAW,QAAO;AAOzB,SAASC,WAAW,QAAQ,+BAA8B;AAC1D,SAASC,kBAAkB,QAAQ,2CAA0C;AAC7E,SAASC,YAAY,QAAQ,qCAAoC;AACjE,SAASC,kBAAkB,EAAEC,aAAa,QAAQ,iCAAgC;AAoBlF,OAAO,MAAMC,cAA+B,CAAC,EAC3CC,IAAI,EACJC,IAAI,EACJC,WAAW,EACXC,MAAM,EACNC,QAAQ,EACRC,mBAAmB,EACnBC,SAAS,EACTC,QAAQ,EACRC,MAAMC,aAAa,EACnBC,WAAW,EACXC,UAAUC,iBAAiB,EAC3BC,YAAYC,mBAAmB,EAC/BC,kBAAkB,EACnB;IACC,MAAMC,YAAYpB;IAClB,MAAM,EAAEe,UAAUM,mBAAmB,EAAE,GAAGnB;IAC1C,MAAMoB,kBAAkBvB;IAExB,MAAMa,OAAO;QAACC;QAAeT;KAAK,CAACmB,MAAM,CAACC,SAASC,IAAI,CAAC;IACxD,MAAMR,aAAa;QAACC;QAAqBd;KAAK,CAACmB,MAAM,CAACC,SAASC,IAAI,CAAC;IAEpE,wDAAwD;IACxD,iFAAiF;IACjF,IAAIX,aAAaY,MAAMC,eAAe,SAASnB,UAAU;QACvD,OAAO;IACT;IAEA,+EAA+E;IAC/E,IAAIO,WAAWC;IAEf,+GAA+G;IAC/G,IAAIK,uBAAuBN,aAAa,OAAOA,WAAW;IAE1D,mFAAmF;IACnF,IAAID,aAAa,CAACM,UAAU,EAAEO,eAAe,OAAO;QAClDZ,WAAW;IACb;IAEA,MAAMa,eAAejB,WAAWb,cAAcwB,eAAe,CAACjB,KAAK;IAEnE,IAAIC,gBAAgBuB,aAAa,CAACD,cAAc;QAC9C,OAAO;IACT;IAEA,qBACE,KAAC3B;QACCM,QAAQA;QACRG,WAAWA;QACXE,MAAMA;QACNE,aAAaA;QACbC,UAAUA;QACVE,YAAYA;QACZE,oBAAoBA;QACpBd,MAAMA;kBAELC,gBAAgBuB,YAAYvB,4BAAc,KAACsB;YAAc,GAAGnB,mBAAmB;;;AAGtF,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/forms/RenderFields/index.tsx"],"sourcesContent":["'use client'\nimport React from 'react'\n\nimport type { Props } from './types.js'\n\nimport { useIntersect } from '../../hooks/useIntersect.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { RenderField } from './RenderField.js'\nimport './index.scss'\n\nconst baseClass = 'render-fields'\n\nexport { Props }\n\nexport const RenderFields: React.FC<Props> = (props) => {\n const { className, fieldMap, forceRender, indexPath, margins, path, permissions, schemaPath } =\n props\n\n const { i18n } = useTranslation()\n const [hasRendered, setHasRendered] = React.useState(Boolean(forceRender))\n const [intersectionRef, entry] = useIntersect(\n {\n rootMargin: '1000px',\n },\n Boolean(forceRender),\n )\n\n const isIntersecting = Boolean(entry?.isIntersecting)\n const isAboveViewport = entry?.boundingClientRect?.top < 0\n const shouldRender = forceRender || isIntersecting || isAboveViewport\n\n React.useEffect(() => {\n if (shouldRender && !hasRendered) {\n setHasRendered(true)\n }\n }, [shouldRender, hasRendered])\n\n if (!fieldMap || (Array.isArray(fieldMap) && fieldMap.length === 0)) {\n return null\n }\n\n if (!i18n) {\n console.error('Need to implement i18n when calling RenderFields') // eslint-disable-line no-console\n }\n\n if (fieldMap) {\n return (\n <div\n className={[\n baseClass,\n className,\n margins && `${baseClass}--margins-${margins}`,\n margins === false && `${baseClass}--margins-none`,\n ]\n .filter(Boolean)\n .join(' ')}\n ref={intersectionRef}\n >\n {hasRendered &&\n fieldMap?.map((f, fieldIndex) => {\n const {\n type,\n CustomField,\n custom,\n disabled,\n fieldComponentProps,\n fieldComponentProps: { readOnly },\n isHidden,\n } = f\n\n const forceRenderChildren =\n (typeof forceRender === 'number' && fieldIndex <= forceRender) || true\n\n const name = 'name' in f ? f.name : undefined\n\n return (\n <RenderField\n CustomField={CustomField}\n custom={custom}\n disabled={disabled}\n fieldComponentProps={{ ...fieldComponentProps, forceRender: forceRenderChildren }}\n indexPath={indexPath !== undefined ? `${indexPath}.${fieldIndex}` : `${fieldIndex}`}\n isHidden={isHidden}\n key={fieldIndex}\n name={name}\n path={path}\n permissions={permissions?.[name]}\n readOnly={readOnly}\n schemaPath={schemaPath}\n siblingPermissions={permissions}\n type={type}\n />\n )\n })}\n </div>\n )\n }\n\n return null\n}\n"],"names":["React","useIntersect","useTranslation","RenderField","baseClass","RenderFields","props","className","fieldMap","forceRender","indexPath","margins","path","permissions","schemaPath","i18n","hasRendered","setHasRendered","useState","Boolean","intersectionRef","entry","rootMargin","isIntersecting","isAboveViewport","boundingClientRect","top","shouldRender","useEffect","Array","isArray","length","console","error","div","filter","join","ref","map","f","fieldIndex","type","CustomField","custom","disabled","fieldComponentProps","readOnly","isHidden","forceRenderChildren","name","undefined","siblingPermissions"],"
|
|
1
|
+
{"version":3,"sources":["../../../src/forms/RenderFields/index.tsx"],"sourcesContent":["'use client'\nimport React from 'react'\n\nimport type { Props } from './types.js'\n\nimport { useIntersect } from '../../hooks/useIntersect.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { RenderField } from './RenderField.js'\nimport './index.scss'\n\nconst baseClass = 'render-fields'\n\nexport { Props }\n\nexport const RenderFields: React.FC<Props> = (props) => {\n const { className, fieldMap, forceRender, indexPath, margins, path, permissions, schemaPath } =\n props\n\n const { i18n } = useTranslation()\n const [hasRendered, setHasRendered] = React.useState(Boolean(forceRender))\n const [intersectionRef, entry] = useIntersect(\n {\n rootMargin: '1000px',\n },\n Boolean(forceRender),\n )\n\n const isIntersecting = Boolean(entry?.isIntersecting)\n const isAboveViewport = entry?.boundingClientRect?.top < 0\n const shouldRender = forceRender || isIntersecting || isAboveViewport\n\n React.useEffect(() => {\n if (shouldRender && !hasRendered) {\n setHasRendered(true)\n }\n }, [shouldRender, hasRendered])\n\n if (!fieldMap || (Array.isArray(fieldMap) && fieldMap.length === 0)) {\n return null\n }\n\n if (!i18n) {\n console.error('Need to implement i18n when calling RenderFields') // eslint-disable-line no-console\n }\n\n if (fieldMap) {\n return (\n <div\n className={[\n baseClass,\n className,\n margins && `${baseClass}--margins-${margins}`,\n margins === false && `${baseClass}--margins-none`,\n ]\n .filter(Boolean)\n .join(' ')}\n ref={intersectionRef}\n >\n {hasRendered &&\n fieldMap?.map((f, fieldIndex) => {\n const {\n type,\n CustomField,\n custom,\n disabled,\n fieldComponentProps,\n fieldComponentProps: { readOnly },\n isHidden,\n } = f\n\n const forceRenderChildren =\n (typeof forceRender === 'number' && fieldIndex <= forceRender) || true\n\n const name = 'name' in f ? f.name : undefined\n\n return (\n <RenderField\n CustomField={CustomField}\n custom={custom}\n disabled={disabled}\n fieldComponentProps={{ ...fieldComponentProps, forceRender: forceRenderChildren }}\n indexPath={indexPath !== undefined ? `${indexPath}.${fieldIndex}` : `${fieldIndex}`}\n isHidden={isHidden}\n key={fieldIndex}\n name={name}\n path={path}\n permissions={permissions?.[name]}\n readOnly={readOnly}\n schemaPath={schemaPath}\n siblingPermissions={permissions}\n type={type}\n />\n )\n })}\n </div>\n )\n }\n\n return null\n}\n"],"names":["React","useIntersect","useTranslation","RenderField","baseClass","RenderFields","props","className","fieldMap","forceRender","indexPath","margins","path","permissions","schemaPath","i18n","hasRendered","setHasRendered","useState","Boolean","intersectionRef","entry","rootMargin","isIntersecting","isAboveViewport","boundingClientRect","top","shouldRender","useEffect","Array","isArray","length","console","error","div","filter","join","ref","map","f","fieldIndex","type","CustomField","custom","disabled","fieldComponentProps","readOnly","isHidden","forceRenderChildren","name","undefined","siblingPermissions"],"mappings":"AAAA;;AACA,OAAOA,WAAW,QAAO;AAIzB,SAASC,YAAY,QAAQ,8BAA6B;AAC1D,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,WAAW,QAAQ,mBAAkB;AAC9C,OAAO,eAAc;AAErB,MAAMC,YAAY;AAIlB,OAAO,MAAMC,eAAgC,CAACC;IAC5C,MAAM,EAAEC,SAAS,EAAEC,QAAQ,EAAEC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,IAAI,EAAEC,WAAW,EAAEC,UAAU,EAAE,GAC3FR;IAEF,MAAM,EAAES,IAAI,EAAE,GAAGb;IACjB,MAAM,CAACc,aAAaC,eAAe,GAAGjB,MAAMkB,QAAQ,CAACC,QAAQV;IAC7D,MAAM,CAACW,iBAAiBC,MAAM,GAAGpB,aAC/B;QACEqB,YAAY;IACd,GACAH,QAAQV;IAGV,MAAMc,iBAAiBJ,QAAQE,OAAOE;IACtC,MAAMC,kBAAkBH,OAAOI,oBAAoBC,MAAM;IACzD,MAAMC,eAAelB,eAAec,kBAAkBC;IAEtDxB,MAAM4B,SAAS,CAAC;QACd,IAAID,gBAAgB,CAACX,aAAa;YAChCC,eAAe;QACjB;IACF,GAAG;QAACU;QAAcX;KAAY;IAE9B,IAAI,CAACR,YAAaqB,MAAMC,OAAO,CAACtB,aAAaA,SAASuB,MAAM,KAAK,GAAI;QACnE,OAAO;IACT;IAEA,IAAI,CAAChB,MAAM;QACTiB,QAAQC,KAAK,CAAC,oDAAoD,iCAAiC;;IACrG;IAEA,IAAIzB,UAAU;QACZ,qBACE,KAAC0B;YACC3B,WAAW;gBACTH;gBACAG;gBACAI,WAAW,CAAC,EAAEP,UAAU,UAAU,EAAEO,QAAQ,CAAC;gBAC7CA,YAAY,SAAS,CAAC,EAAEP,UAAU,cAAc,CAAC;aAClD,CACE+B,MAAM,CAAChB,SACPiB,IAAI,CAAC;YACRC,KAAKjB;sBAEJJ,eACCR,UAAU8B,IAAI,CAACC,GAAGC;gBAChB,MAAM,EACJC,IAAI,EACJC,WAAW,EACXC,MAAM,EACNC,QAAQ,EACRC,mBAAmB,EACnBA,qBAAqB,EAAEC,QAAQ,EAAE,EACjCC,QAAQ,EACT,GAAGR;gBAEJ,MAAMS,sBACJ,AAAC,OAAOvC,gBAAgB,YAAY+B,cAAc/B,eAAgB;gBAEpE,MAAMwC,OAAO,UAAUV,IAAIA,EAAEU,IAAI,GAAGC;gBAEpC,qBACE,KAAC/C;oBACCuC,aAAaA;oBACbC,QAAQA;oBACRC,UAAUA;oBACVC,qBAAqB;wBAAE,GAAGA,mBAAmB;wBAAEpC,aAAauC;oBAAoB;oBAChFtC,WAAWA,cAAcwC,YAAY,CAAC,EAAExC,UAAU,CAAC,EAAE8B,WAAW,CAAC,GAAG,CAAC,EAAEA,WAAW,CAAC;oBACnFO,UAAUA;oBAEVE,MAAMA;oBACNrC,MAAMA;oBACNC,aAAaA,aAAa,CAACoC,KAAK;oBAChCH,UAAUA;oBACVhC,YAAYA;oBACZqC,oBAAoBtC;oBACpB4B,MAAMA;mBAPDD;YAUX;;IAGR;IAEA,OAAO;AACT,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/forms/RenderFields/types.ts"],"sourcesContent":["import type { FieldPermissions, Operation } from 'payload'\n\nimport type { FieldMap } from '../../providers/ComponentMap/buildComponentMap/types.js'\n\nexport type Props = {\n className?: string\n fieldMap: FieldMap\n /**\n * Controls the rendering behavior of the fields, i.e. defers rendering until they intersect with the viewport using the Intersection Observer API.\n *\n * If true, the fields will be rendered immediately, rather than waiting for them to intersect with the viewport.\n *\n * If a number is provided, will immediately render fields _up to that index_.\n */\n forceRender?: boolean | number\n indexPath?: string\n margins?: 'small' | false\n operation?: Operation\n path: string\n permissions?: {\n [fieldName: string]: FieldPermissions\n }\n readOnly: boolean\n schemaPath: string\n}\n"],"names":[],"
|
|
1
|
+
{"version":3,"sources":["../../../src/forms/RenderFields/types.ts"],"sourcesContent":["import type { FieldPermissions, Operation } from 'payload'\n\nimport type { FieldMap } from '../../providers/ComponentMap/buildComponentMap/types.js'\n\nexport type Props = {\n className?: string\n fieldMap: FieldMap\n /**\n * Controls the rendering behavior of the fields, i.e. defers rendering until they intersect with the viewport using the Intersection Observer API.\n *\n * If true, the fields will be rendered immediately, rather than waiting for them to intersect with the viewport.\n *\n * If a number is provided, will immediately render fields _up to that index_.\n */\n forceRender?: boolean | number\n indexPath?: string\n margins?: 'small' | false\n operation?: Operation\n path: string\n permissions?: {\n [fieldName: string]: FieldPermissions\n }\n readOnly: boolean\n schemaPath: string\n}\n"],"names":[],"mappings":"AAIA,WAoBC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/forms/RowLabel/Context/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,KAAK,YAAY,CAAC,CAAC,GAAG,OAAO,IAAI;IAC/B,IAAI,EAAE,CAAC,CAAA;IACP,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AAQD,KAAK,KAAK,CAAC,CAAC,IAAI,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,GAAG;IAC9C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAC1B,CAAA;AAED,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAOrD,CAAA;AAED,eAAO,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/forms/RowLabel/Context/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,KAAK,YAAY,CAAC,CAAC,GAAG,OAAO,IAAI;IAC/B,IAAI,EAAE,CAAC,CAAA;IACP,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AAQD,KAAK,KAAK,CAAC,CAAC,IAAI,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,GAAG;IAC9C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAC1B,CAAA;AAED,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAOrD,CAAA;AAED,eAAO,MAAM,WAAW,GAAI,CAAC,OACU,YAAY,CAAC,CAAC,CACpD,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/forms/RowLabel/Context/index.tsx"],"sourcesContent":["'use client'\n\nimport React from 'react'\n\nimport { useWatchForm } from '../../Form/context.js'\n\ntype RowLabelType<T = unknown> = {\n data: T\n path: string\n rowNumber?: number\n}\n\nconst RowLabel = React.createContext<RowLabelType>({\n data: {},\n path: '',\n rowNumber: undefined,\n})\n\ntype Props<T> = Omit<RowLabelType<T>, 'data'> & {\n children: React.ReactNode\n}\n\nexport const RowLabelProvider: React.FC<Props<unknown>> = ({ children, path, rowNumber }) => {\n const { getDataByPath, getSiblingData } = useWatchForm()\n const collapsibleData = getSiblingData(path)\n const arrayData = getDataByPath(path)\n const data = arrayData || collapsibleData\n\n return <RowLabel.Provider value={{ data, path, rowNumber }}>{children}</RowLabel.Provider>\n}\n\nexport const useRowLabel = <T,>() => {\n return React.useContext(RowLabel) as RowLabelType<T>\n}\n"],"names":["React","useWatchForm","RowLabel","createContext","data","path","rowNumber","undefined","RowLabelProvider","children","getDataByPath","getSiblingData","collapsibleData","arrayData","Provider","value","useRowLabel","useContext"],"
|
|
1
|
+
{"version":3,"sources":["../../../../src/forms/RowLabel/Context/index.tsx"],"sourcesContent":["'use client'\n\nimport React from 'react'\n\nimport { useWatchForm } from '../../Form/context.js'\n\ntype RowLabelType<T = unknown> = {\n data: T\n path: string\n rowNumber?: number\n}\n\nconst RowLabel = React.createContext<RowLabelType>({\n data: {},\n path: '',\n rowNumber: undefined,\n})\n\ntype Props<T> = Omit<RowLabelType<T>, 'data'> & {\n children: React.ReactNode\n}\n\nexport const RowLabelProvider: React.FC<Props<unknown>> = ({ children, path, rowNumber }) => {\n const { getDataByPath, getSiblingData } = useWatchForm()\n const collapsibleData = getSiblingData(path)\n const arrayData = getDataByPath(path)\n const data = arrayData || collapsibleData\n\n return <RowLabel.Provider value={{ data, path, rowNumber }}>{children}</RowLabel.Provider>\n}\n\nexport const useRowLabel = <T,>() => {\n return React.useContext(RowLabel) as RowLabelType<T>\n}\n"],"names":["React","useWatchForm","RowLabel","createContext","data","path","rowNumber","undefined","RowLabelProvider","children","getDataByPath","getSiblingData","collapsibleData","arrayData","Provider","value","useRowLabel","useContext"],"mappings":"AAAA;;AAEA,OAAOA,WAAW,QAAO;AAEzB,SAASC,YAAY,QAAQ,wBAAuB;AAQpD,MAAMC,yBAAWF,MAAMG,aAAa,CAAe;IACjDC,MAAM,CAAC;IACPC,MAAM;IACNC,WAAWC;AACb;AAMA,OAAO,MAAMC,mBAA6C,CAAC,EAAEC,QAAQ,EAAEJ,IAAI,EAAEC,SAAS,EAAE;IACtF,MAAM,EAAEI,aAAa,EAAEC,cAAc,EAAE,GAAGV;IAC1C,MAAMW,kBAAkBD,eAAeN;IACvC,MAAMQ,YAAYH,cAAcL;IAChC,MAAMD,OAAOS,aAAaD;IAE1B,qBAAO,KAACV,SAASY,QAAQ;QAACC,OAAO;YAAEX;YAAMC;YAAMC;QAAU;kBAAIG;;AAC/D,EAAC;AAED,OAAO,MAAMO,cAAc;IACzB,OAAOhB,MAAMiB,UAAU,CAACf;AAC1B,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/forms/RowLabel/index.tsx"],"sourcesContent":["import { getTranslation } from '@payloadcms/translations'\nimport React from 'react'\n\nimport type { RowLabelProps } from './types.js'\nexport type { RowLabelProps }\n\nimport { RowLabelProvider } from '../RowLabel/Context/index.js'\n\nconst baseClass = 'row-label'\n\nexport const RowLabel: React.FC<RowLabelProps> = (props) => {\n const { RowLabelComponent, className, i18n, path, rowLabel, rowNumber } = props\n\n if (RowLabelComponent) {\n return (\n <RowLabelProvider path={path} rowNumber={rowNumber}>\n {RowLabelComponent}\n </RowLabelProvider>\n )\n }\n\n const label = rowLabel\n ? typeof rowLabel === 'object'\n ? getTranslation(rowLabel, i18n)\n : typeof rowLabel === 'string'\n ? rowLabel\n : ''\n : ''\n\n return (\n <span\n className={[baseClass, className].filter(Boolean).join(' ')}\n style={{\n pointerEvents: 'none',\n }}\n >\n {label}\n </span>\n )\n}\n"],"names":["getTranslation","React","RowLabelProvider","baseClass","RowLabel","props","RowLabelComponent","className","i18n","path","rowLabel","rowNumber","label","span","filter","Boolean","join","style","pointerEvents"],"
|
|
1
|
+
{"version":3,"sources":["../../../src/forms/RowLabel/index.tsx"],"sourcesContent":["import { getTranslation } from '@payloadcms/translations'\nimport React from 'react'\n\nimport type { RowLabelProps } from './types.js'\nexport type { RowLabelProps }\n\nimport { RowLabelProvider } from '../RowLabel/Context/index.js'\n\nconst baseClass = 'row-label'\n\nexport const RowLabel: React.FC<RowLabelProps> = (props) => {\n const { RowLabelComponent, className, i18n, path, rowLabel, rowNumber } = props\n\n if (RowLabelComponent) {\n return (\n <RowLabelProvider path={path} rowNumber={rowNumber}>\n {RowLabelComponent}\n </RowLabelProvider>\n )\n }\n\n const label = rowLabel\n ? typeof rowLabel === 'object'\n ? getTranslation(rowLabel, i18n)\n : typeof rowLabel === 'string'\n ? rowLabel\n : ''\n : ''\n\n return (\n <span\n className={[baseClass, className].filter(Boolean).join(' ')}\n style={{\n pointerEvents: 'none',\n }}\n >\n {label}\n </span>\n )\n}\n"],"names":["getTranslation","React","RowLabelProvider","baseClass","RowLabel","props","RowLabelComponent","className","i18n","path","rowLabel","rowNumber","label","span","filter","Boolean","join","style","pointerEvents"],"mappings":";AAAA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,OAAOC,WAAW,QAAO;AAKzB,SAASC,gBAAgB,QAAQ,+BAA8B;AAE/D,MAAMC,YAAY;AAElB,OAAO,MAAMC,WAAoC,CAACC;IAChD,MAAM,EAAEC,iBAAiB,EAAEC,SAAS,EAAEC,IAAI,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,SAAS,EAAE,GAAGN;IAE1E,IAAIC,mBAAmB;QACrB,qBACE,KAACJ;YAAiBO,MAAMA;YAAME,WAAWA;sBACtCL;;IAGP;IAEA,MAAMM,QAAQF,WACV,OAAOA,aAAa,WAClBV,eAAeU,UAAUF,QACzB,OAAOE,aAAa,WAClBA,WACA,KACJ;IAEJ,qBACE,KAACG;QACCN,WAAW;YAACJ;YAAWI;SAAU,CAACO,MAAM,CAACC,SAASC,IAAI,CAAC;QACvDC,OAAO;YACLC,eAAe;QACjB;kBAECN;;AAGP,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/forms/RowLabel/types.ts"],"sourcesContent":["import type { I18nClient } from '@payloadcms/translations'\nimport type { LabelProps } from 'payload'\nimport type React from 'react'\n\nexport type RowLabelProps = {\n RowLabelComponent?: React.ReactNode\n className?: string\n i18n: I18nClient\n path: string\n rowLabel?: LabelProps['label']\n rowNumber?: number\n}\n"],"names":[],"
|
|
1
|
+
{"version":3,"sources":["../../../src/forms/RowLabel/types.ts"],"sourcesContent":["import type { I18nClient } from '@payloadcms/translations'\nimport type { LabelProps } from 'payload'\nimport type React from 'react'\n\nexport type RowLabelProps = {\n RowLabelComponent?: React.ReactNode\n className?: string\n i18n: I18nClient\n path: string\n rowLabel?: LabelProps['label']\n rowNumber?: number\n}\n"],"names":[],"mappings":"AAIA,WAOC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/forms/Submit/index.tsx"],"sourcesContent":["'use client'\nimport React, { forwardRef } from 'react'\n\nimport type { Props } from '../../elements/Button/types.js'\n\nimport { Button } from '../../elements/Button/index.js'\nimport { useForm, useFormInitializing, useFormProcessing } from '../Form/context.js'\nimport './index.scss'\n\nconst baseClass = 'form-submit'\n\nexport const FormSubmit = forwardRef<HTMLButtonElement, Props>((props, ref) => {\n const { type = 'submit', buttonId: id, children, disabled: disabledFromProps } = props\n const processing = useFormProcessing()\n const initializing = useFormInitializing()\n const { disabled } = useForm()\n\n const canSave = !(disabledFromProps || initializing || processing || disabled)\n\n return (\n <div className={baseClass}>\n <Button ref={ref} {...props} disabled={canSave ? undefined : true} id={id} type={type}>\n {children}\n </Button>\n </div>\n )\n})\n"],"names":["React","forwardRef","Button","useForm","useFormInitializing","useFormProcessing","baseClass","FormSubmit","props","ref","type","buttonId","id","children","disabled","disabledFromProps","processing","initializing","canSave","div","className","undefined"],"
|
|
1
|
+
{"version":3,"sources":["../../../src/forms/Submit/index.tsx"],"sourcesContent":["'use client'\nimport React, { forwardRef } from 'react'\n\nimport type { Props } from '../../elements/Button/types.js'\n\nimport { Button } from '../../elements/Button/index.js'\nimport { useForm, useFormInitializing, useFormProcessing } from '../Form/context.js'\nimport './index.scss'\n\nconst baseClass = 'form-submit'\n\nexport const FormSubmit = forwardRef<HTMLButtonElement, Props>((props, ref) => {\n const { type = 'submit', buttonId: id, children, disabled: disabledFromProps } = props\n const processing = useFormProcessing()\n const initializing = useFormInitializing()\n const { disabled } = useForm()\n\n const canSave = !(disabledFromProps || initializing || processing || disabled)\n\n return (\n <div className={baseClass}>\n <Button ref={ref} {...props} disabled={canSave ? undefined : true} id={id} type={type}>\n {children}\n </Button>\n </div>\n )\n})\n"],"names":["React","forwardRef","Button","useForm","useFormInitializing","useFormProcessing","baseClass","FormSubmit","props","ref","type","buttonId","id","children","disabled","disabledFromProps","processing","initializing","canSave","div","className","undefined"],"mappings":"AAAA;;AACA,OAAOA,SAASC,UAAU,QAAQ,QAAO;AAIzC,SAASC,MAAM,QAAQ,iCAAgC;AACvD,SAASC,OAAO,EAAEC,mBAAmB,EAAEC,iBAAiB,QAAQ,qBAAoB;AACpF,OAAO,eAAc;AAErB,MAAMC,YAAY;AAElB,OAAO,MAAMC,2BAAaN,WAAqC,CAACO,OAAOC;IACrE,MAAM,EAAEC,OAAO,QAAQ,EAAEC,UAAUC,EAAE,EAAEC,QAAQ,EAAEC,UAAUC,iBAAiB,EAAE,GAAGP;IACjF,MAAMQ,aAAaX;IACnB,MAAMY,eAAeb;IACrB,MAAM,EAAEU,QAAQ,EAAE,GAAGX;IAErB,MAAMe,UAAU,CAAEH,CAAAA,qBAAqBE,gBAAgBD,cAAcF,QAAO;IAE5E,qBACE,KAACK;QAAIC,WAAWd;kBACd,cAAA,KAACJ;YAAOO,KAAKA;YAAM,GAAGD,KAAK;YAAEM,UAAUI,UAAUG,YAAY;YAAMT,IAAIA;YAAIF,MAAMA;sBAC9EG;;;AAIT,GAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildPathSegments.d.ts","sourceRoot":"","sources":["../../../src/forms/WatchChildErrors/buildPathSegments.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yDAAyD,CAAA;AAEvF,eAAO,MAAM,iBAAiB,eAAgB,MAAM,
|
|
1
|
+
{"version":3,"file":"buildPathSegments.d.ts","sourceRoot":"","sources":["../../../src/forms/WatchChildErrors/buildPathSegments.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yDAAyD,CAAA;AAEvF,eAAO,MAAM,iBAAiB,eAAgB,MAAM,YAAY,QAAQ,KAAG,MAAM,EAmChF,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/forms/WatchChildErrors/buildPathSegments.ts"],"sourcesContent":["import type { FieldMap } from '../../providers/ComponentMap/buildComponentMap/types.js'\n\nexport const buildPathSegments = (parentPath: string, fieldMap: FieldMap): string[] => {\n const pathNames = fieldMap.reduce((acc, field) => {\n const fieldMap =\n 'fieldMap' in field.fieldComponentProps ? field.fieldComponentProps.fieldMap : undefined\n\n if (fieldMap) {\n if (field.isFieldAffectingData) {\n // group, block, array\n const name = 'name' in field ? field.name : 'unnamed'\n acc.push(parentPath ? `${parentPath}.${name}.` : `${name}.`)\n } else {\n // rows, collapsibles, unnamed-tab\n acc.push(...buildPathSegments(parentPath, fieldMap))\n }\n } else if (field.type === 'tabs') {\n // tabs\n if ('tabs' in field.fieldComponentProps) {\n field.fieldComponentProps.tabs?.forEach((tab) => {\n let tabPath = parentPath\n if ('name' in tab) {\n tabPath = parentPath ? `${parentPath}.${tab.name}` : tab.name\n }\n acc.push(...buildPathSegments(tabPath, tab.fieldMap))\n })\n }\n } else if (field.isFieldAffectingData) {\n // text, number, date, etc.\n const name = 'name' in field ? field.name : 'unnamed'\n acc.push(parentPath ? `${parentPath}.${name}` : name)\n }\n\n return acc\n }, [])\n\n return pathNames\n}\n"],"names":["buildPathSegments","parentPath","fieldMap","pathNames","reduce","acc","field","fieldComponentProps","undefined","isFieldAffectingData","name","push","type","tabs","forEach","tab","tabPath"],"
|
|
1
|
+
{"version":3,"sources":["../../../src/forms/WatchChildErrors/buildPathSegments.ts"],"sourcesContent":["import type { FieldMap } from '../../providers/ComponentMap/buildComponentMap/types.js'\n\nexport const buildPathSegments = (parentPath: string, fieldMap: FieldMap): string[] => {\n const pathNames = fieldMap.reduce((acc, field) => {\n const fieldMap =\n 'fieldMap' in field.fieldComponentProps ? field.fieldComponentProps.fieldMap : undefined\n\n if (fieldMap) {\n if (field.isFieldAffectingData) {\n // group, block, array\n const name = 'name' in field ? field.name : 'unnamed'\n acc.push(parentPath ? `${parentPath}.${name}.` : `${name}.`)\n } else {\n // rows, collapsibles, unnamed-tab\n acc.push(...buildPathSegments(parentPath, fieldMap))\n }\n } else if (field.type === 'tabs') {\n // tabs\n if ('tabs' in field.fieldComponentProps) {\n field.fieldComponentProps.tabs?.forEach((tab) => {\n let tabPath = parentPath\n if ('name' in tab) {\n tabPath = parentPath ? `${parentPath}.${tab.name}` : tab.name\n }\n acc.push(...buildPathSegments(tabPath, tab.fieldMap))\n })\n }\n } else if (field.isFieldAffectingData) {\n // text, number, date, etc.\n const name = 'name' in field ? field.name : 'unnamed'\n acc.push(parentPath ? `${parentPath}.${name}` : name)\n }\n\n return acc\n }, [])\n\n return pathNames\n}\n"],"names":["buildPathSegments","parentPath","fieldMap","pathNames","reduce","acc","field","fieldComponentProps","undefined","isFieldAffectingData","name","push","type","tabs","forEach","tab","tabPath"],"mappings":"AAEA,OAAO,MAAMA,oBAAoB,CAACC,YAAoBC;IACpD,MAAMC,YAAYD,SAASE,MAAM,CAAC,CAACC,KAAKC;QACtC,MAAMJ,WACJ,cAAcI,MAAMC,mBAAmB,GAAGD,MAAMC,mBAAmB,CAACL,QAAQ,GAAGM;QAEjF,IAAIN,UAAU;YACZ,IAAII,MAAMG,oBAAoB,EAAE;gBAC9B,sBAAsB;gBACtB,MAAMC,OAAO,UAAUJ,QAAQA,MAAMI,IAAI,GAAG;gBAC5CL,IAAIM,IAAI,CAACV,aAAa,CAAC,EAAEA,WAAW,CAAC,EAAES,KAAK,CAAC,CAAC,GAAG,CAAC,EAAEA,KAAK,CAAC,CAAC;YAC7D,OAAO;gBACL,kCAAkC;gBAClCL,IAAIM,IAAI,IAAIX,kBAAkBC,YAAYC;YAC5C;QACF,OAAO,IAAII,MAAMM,IAAI,KAAK,QAAQ;YAChC,OAAO;YACP,IAAI,UAAUN,MAAMC,mBAAmB,EAAE;gBACvCD,MAAMC,mBAAmB,CAACM,IAAI,EAAEC,QAAQ,CAACC;oBACvC,IAAIC,UAAUf;oBACd,IAAI,UAAUc,KAAK;wBACjBC,UAAUf,aAAa,CAAC,EAAEA,WAAW,CAAC,EAAEc,IAAIL,IAAI,CAAC,CAAC,GAAGK,IAAIL,IAAI;oBAC/D;oBACAL,IAAIM,IAAI,IAAIX,kBAAkBgB,SAASD,IAAIb,QAAQ;gBACrD;YACF;QACF,OAAO,IAAII,MAAMG,oBAAoB,EAAE;YACrC,2BAA2B;YAC3B,MAAMC,OAAO,UAAUJ,QAAQA,MAAMI,IAAI,GAAG;YAC5CL,IAAIM,IAAI,CAACV,aAAa,CAAC,EAAEA,WAAW,CAAC,EAAES,KAAK,CAAC,GAAGA;QAClD;QAEA,OAAOL;IACT,GAAG,EAAE;IAEL,OAAOF;AACT,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/forms/WatchChildErrors/getFieldStateFromPaths.ts"],"sourcesContent":["import type { FormState } from 'payload'\n\nexport const getFieldStateFromPaths = ({\n formState,\n pathSegments,\n}: {\n formState: FormState\n pathSegments: string[]\n}): {\n errorCount: number\n fieldState: FormState\n} => {\n const fieldState: FormState = {}\n let errorCount = 0\n\n Object.entries(formState).forEach(([key]) => {\n const matchingSegment = pathSegments?.some((segment) => {\n if (segment.endsWith('.')) {\n return key.startsWith(segment)\n }\n return key === segment\n })\n\n if (matchingSegment) {\n const pathState = formState[key]\n fieldState[key] = pathState\n if ('valid' in pathState && !pathState.valid) {\n errorCount += 1\n }\n }\n })\n\n return {\n errorCount,\n fieldState,\n }\n}\n"],"names":["getFieldStateFromPaths","formState","pathSegments","fieldState","errorCount","Object","entries","forEach","key","matchingSegment","some","segment","endsWith","startsWith","pathState","valid"],"
|
|
1
|
+
{"version":3,"sources":["../../../src/forms/WatchChildErrors/getFieldStateFromPaths.ts"],"sourcesContent":["import type { FormState } from 'payload'\n\nexport const getFieldStateFromPaths = ({\n formState,\n pathSegments,\n}: {\n formState: FormState\n pathSegments: string[]\n}): {\n errorCount: number\n fieldState: FormState\n} => {\n const fieldState: FormState = {}\n let errorCount = 0\n\n Object.entries(formState).forEach(([key]) => {\n const matchingSegment = pathSegments?.some((segment) => {\n if (segment.endsWith('.')) {\n return key.startsWith(segment)\n }\n return key === segment\n })\n\n if (matchingSegment) {\n const pathState = formState[key]\n fieldState[key] = pathState\n if ('valid' in pathState && !pathState.valid) {\n errorCount += 1\n }\n }\n })\n\n return {\n errorCount,\n fieldState,\n }\n}\n"],"names":["getFieldStateFromPaths","formState","pathSegments","fieldState","errorCount","Object","entries","forEach","key","matchingSegment","some","segment","endsWith","startsWith","pathState","valid"],"mappings":"AAEA,OAAO,MAAMA,yBAAyB,CAAC,EACrCC,SAAS,EACTC,YAAY,EAIb;IAIC,MAAMC,aAAwB,CAAC;IAC/B,IAAIC,aAAa;IAEjBC,OAAOC,OAAO,CAACL,WAAWM,OAAO,CAAC,CAAC,CAACC,IAAI;QACtC,MAAMC,kBAAkBP,cAAcQ,KAAK,CAACC;YAC1C,IAAIA,QAAQC,QAAQ,CAAC,MAAM;gBACzB,OAAOJ,IAAIK,UAAU,CAACF;YACxB;YACA,OAAOH,QAAQG;QACjB;QAEA,IAAIF,iBAAiB;YACnB,MAAMK,YAAYb,SAAS,CAACO,IAAI;YAChCL,UAAU,CAACK,IAAI,GAAGM;YAClB,IAAI,WAAWA,aAAa,CAACA,UAAUC,KAAK,EAAE;gBAC5CX,cAAc;YAChB;QACF;IACF;IAEA,OAAO;QACLA;QACAD;IACF;AACF,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/forms/WatchChildErrors/getNestedFieldState.ts"],"sourcesContent":["import type { Field, FormState } from 'payload'\n\n// import { buildPathSegments } from './buildPathSegments'\nimport { getFieldStateFromPaths } from './getFieldStateFromPaths.js'\n\nexport const getNestedFieldState = ({\n fieldSchema,\n formState,\n // path,\n pathSegments: pathSegmentsFromProps,\n}: {\n fieldSchema?: Field[]\n formState?: FormState\n path: string\n pathSegments?: string[]\n}): {\n errorCount: number\n fieldState: FormState\n pathSegments: string[]\n} => {\n const pathSegments = pathSegmentsFromProps\n\n if (!pathSegments && fieldSchema) {\n // pathSegments = buildPathSegments(path, fieldSchema)\n }\n\n const result = getFieldStateFromPaths({ formState, pathSegments })\n\n return {\n ...result,\n pathSegments,\n }\n}\n"],"names":["getFieldStateFromPaths","getNestedFieldState","fieldSchema","formState","pathSegments","pathSegmentsFromProps","result"],"
|
|
1
|
+
{"version":3,"sources":["../../../src/forms/WatchChildErrors/getNestedFieldState.ts"],"sourcesContent":["import type { Field, FormState } from 'payload'\n\n// import { buildPathSegments } from './buildPathSegments'\nimport { getFieldStateFromPaths } from './getFieldStateFromPaths.js'\n\nexport const getNestedFieldState = ({\n fieldSchema,\n formState,\n // path,\n pathSegments: pathSegmentsFromProps,\n}: {\n fieldSchema?: Field[]\n formState?: FormState\n path: string\n pathSegments?: string[]\n}): {\n errorCount: number\n fieldState: FormState\n pathSegments: string[]\n} => {\n const pathSegments = pathSegmentsFromProps\n\n if (!pathSegments && fieldSchema) {\n // pathSegments = buildPathSegments(path, fieldSchema)\n }\n\n const result = getFieldStateFromPaths({ formState, pathSegments })\n\n return {\n ...result,\n pathSegments,\n }\n}\n"],"names":["getFieldStateFromPaths","getNestedFieldState","fieldSchema","formState","pathSegments","pathSegmentsFromProps","result"],"mappings":"AAEA,0DAA0D;AAC1D,SAASA,sBAAsB,QAAQ,8BAA6B;AAEpE,OAAO,MAAMC,sBAAsB,CAAC,EAClCC,WAAW,EACXC,SAAS,EACT,QAAQ;AACRC,cAAcC,qBAAqB,EAMpC;IAKC,MAAMD,eAAeC;IAErB,IAAI,CAACD,gBAAgBF,aAAa;IAChC,sDAAsD;IACxD;IAEA,MAAMI,SAASN,uBAAuB;QAAEG;QAAWC;IAAa;IAEhE,OAAO;QACL,GAAGE,MAAM;QACTF;IACF;AACF,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/forms/WatchChildErrors/index.tsx"],"sourcesContent":["'use client'\nimport type React from 'react'\n\nimport type { FieldMap } from '../../providers/ComponentMap/buildComponentMap/types.js'\n\nimport { useThrottledEffect } from '../../hooks/useThrottledEffect.js'\nimport { useAllFormFields, useFormSubmitted } from '../Form/context.js'\nimport { buildPathSegments } from './buildPathSegments.js'\nimport { getFieldStateFromPaths } from './getFieldStateFromPaths.js'\n\ntype TrackSubSchemaErrorCountProps = {\n fieldMap?: FieldMap\n path: string\n setErrorCount: (count: number) => void\n}\n\nexport const WatchChildErrors: React.FC<TrackSubSchemaErrorCountProps> = ({\n fieldMap,\n path,\n setErrorCount,\n}) => {\n const [formState] = useAllFormFields()\n const hasSubmitted = useFormSubmitted()\n\n const pathSegments = buildPathSegments(path, fieldMap)\n\n useThrottledEffect(\n () => {\n if (hasSubmitted) {\n const { errorCount } = getFieldStateFromPaths({ formState, pathSegments })\n setErrorCount(errorCount)\n }\n },\n 250,\n [formState, hasSubmitted, fieldMap],\n )\n\n return null\n}\n"],"names":["useThrottledEffect","useAllFormFields","useFormSubmitted","buildPathSegments","getFieldStateFromPaths","WatchChildErrors","fieldMap","path","setErrorCount","formState","hasSubmitted","pathSegments","errorCount"],"
|
|
1
|
+
{"version":3,"sources":["../../../src/forms/WatchChildErrors/index.tsx"],"sourcesContent":["'use client'\nimport type React from 'react'\n\nimport type { FieldMap } from '../../providers/ComponentMap/buildComponentMap/types.js'\n\nimport { useThrottledEffect } from '../../hooks/useThrottledEffect.js'\nimport { useAllFormFields, useFormSubmitted } from '../Form/context.js'\nimport { buildPathSegments } from './buildPathSegments.js'\nimport { getFieldStateFromPaths } from './getFieldStateFromPaths.js'\n\ntype TrackSubSchemaErrorCountProps = {\n fieldMap?: FieldMap\n path: string\n setErrorCount: (count: number) => void\n}\n\nexport const WatchChildErrors: React.FC<TrackSubSchemaErrorCountProps> = ({\n fieldMap,\n path,\n setErrorCount,\n}) => {\n const [formState] = useAllFormFields()\n const hasSubmitted = useFormSubmitted()\n\n const pathSegments = buildPathSegments(path, fieldMap)\n\n useThrottledEffect(\n () => {\n if (hasSubmitted) {\n const { errorCount } = getFieldStateFromPaths({ formState, pathSegments })\n setErrorCount(errorCount)\n }\n },\n 250,\n [formState, hasSubmitted, fieldMap],\n )\n\n return null\n}\n"],"names":["useThrottledEffect","useAllFormFields","useFormSubmitted","buildPathSegments","getFieldStateFromPaths","WatchChildErrors","fieldMap","path","setErrorCount","formState","hasSubmitted","pathSegments","errorCount"],"mappings":"AAAA;AAKA,SAASA,kBAAkB,QAAQ,oCAAmC;AACtE,SAASC,gBAAgB,EAAEC,gBAAgB,QAAQ,qBAAoB;AACvE,SAASC,iBAAiB,QAAQ,yBAAwB;AAC1D,SAASC,sBAAsB,QAAQ,8BAA6B;AAQpE,OAAO,MAAMC,mBAA4D,CAAC,EACxEC,QAAQ,EACRC,IAAI,EACJC,aAAa,EACd;IACC,MAAM,CAACC,UAAU,GAAGR;IACpB,MAAMS,eAAeR;IAErB,MAAMS,eAAeR,kBAAkBI,MAAMD;IAE7CN,mBACE;QACE,IAAIU,cAAc;YAChB,MAAM,EAAEE,UAAU,EAAE,GAAGR,uBAAuB;gBAAEK;gBAAWE;YAAa;YACxEH,cAAcI;QAChB;IACF,GACA,KACA;QAACH;QAAWC;QAAcJ;KAAS;IAGrC,OAAO;AACT,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addFieldStatePromise.d.ts","sourceRoot":"","sources":["../../../src/forms/buildStateFromSchema/addFieldStatePromise.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,IAAI,EACJ,mBAAmB,EACnB,KAAK,EAEL,SAAS,EACT,sBAAsB,EACvB,MAAM,SAAS,CAAA;AAWhB,MAAM,MAAM,wBAAwB,GAAG;IACrC,oBAAoB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IAC5C;;OAEG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,IAAI,EAAE,IAAI,CAAA;IACV,KAAK,EAAE,KAAK,CAAA;IACZ,UAAU,EAAE,MAAM,CAAA;IAClB;;OAEG;IACH,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,wBAAwB,KAAK,OAAO,CAAA;IACpD;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,QAAQ,EAAE,IAAI,CAAA;IACd,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;IACnB;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,SAAS,EAAE,QAAQ,GAAG,QAAQ,CAAA;IAC9B,eAAe,EAAE,OAAO,CAAA;IACxB,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,mBAAmB,CAAA;IAEhC;;;OAGG;IACH,GAAG,EAAE,sBAAsB,CAAA;IAC3B;;OAEG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,KAAK,EAAE,SAAS,CAAA;CACjB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,oBAAoB,SAAgB,wBAAwB,KAAG,
|
|
1
|
+
{"version":3,"file":"addFieldStatePromise.d.ts","sourceRoot":"","sources":["../../../src/forms/buildStateFromSchema/addFieldStatePromise.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,IAAI,EACJ,mBAAmB,EACnB,KAAK,EAEL,SAAS,EACT,sBAAsB,EACvB,MAAM,SAAS,CAAA;AAWhB,MAAM,MAAM,wBAAwB,GAAG;IACrC,oBAAoB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IAC5C;;OAEG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,IAAI,EAAE,IAAI,CAAA;IACV,KAAK,EAAE,KAAK,CAAA;IACZ,UAAU,EAAE,MAAM,CAAA;IAClB;;OAEG;IACH,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,wBAAwB,KAAK,OAAO,CAAA;IACpD;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,QAAQ,EAAE,IAAI,CAAA;IACd,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;IACnB;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,SAAS,EAAE,QAAQ,GAAG,QAAQ,CAAA;IAC9B,eAAe,EAAE,OAAO,CAAA;IACxB,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,mBAAmB,CAAA;IAEhC;;;OAGG;IACH,GAAG,EAAE,sBAAsB,CAAA;IAC3B;;OAEG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,KAAK,EAAE,SAAS,CAAA;CACjB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,oBAAoB,SAAgB,wBAAwB,KAAG,OAAO,CAAC,IAAI,CA8evF,CAAA"}
|