@payloadcms/ui 3.0.0-beta.43 → 3.0.0-beta.45

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.
Files changed (131) hide show
  1. package/dist/elements/Autosave/index.d.ts.map +1 -1
  2. package/dist/elements/Autosave/index.js +91 -70
  3. package/dist/elements/Autosave/index.js.map +1 -1
  4. package/dist/elements/DeleteDocument/index.d.ts.map +1 -1
  5. package/dist/elements/DeleteDocument/index.js +2 -3
  6. package/dist/elements/DeleteDocument/index.js.map +1 -1
  7. package/dist/elements/DeleteMany/index.d.ts.map +1 -1
  8. package/dist/elements/DeleteMany/index.js +3 -6
  9. package/dist/elements/DeleteMany/index.js.map +1 -1
  10. package/dist/elements/DocumentDrawer/DrawerContent.d.ts.map +1 -1
  11. package/dist/elements/DocumentDrawer/DrawerContent.js +2 -3
  12. package/dist/elements/DocumentDrawer/DrawerContent.js.map +1 -1
  13. package/dist/elements/DocumentDrawer/index.d.ts.map +1 -1
  14. package/dist/elements/DocumentDrawer/index.js +1 -2
  15. package/dist/elements/DocumentDrawer/index.js.map +1 -1
  16. package/dist/elements/Drawer/index.d.ts.map +1 -1
  17. package/dist/elements/Drawer/index.js +1 -3
  18. package/dist/elements/Drawer/index.js.map +1 -1
  19. package/dist/elements/DuplicateDocument/index.d.ts.map +1 -1
  20. package/dist/elements/DuplicateDocument/index.js +4 -9
  21. package/dist/elements/DuplicateDocument/index.js.map +1 -1
  22. package/dist/elements/EditMany/index.d.ts.map +1 -1
  23. package/dist/elements/EditMany/index.js +1 -2
  24. package/dist/elements/EditMany/index.js.map +1 -1
  25. package/dist/elements/EditUpload/index.d.ts.map +1 -1
  26. package/dist/elements/EditUpload/index.js +1 -5
  27. package/dist/elements/EditUpload/index.js.map +1 -1
  28. package/dist/elements/GenerateConfirmation/index.d.ts.map +1 -1
  29. package/dist/elements/GenerateConfirmation/index.js +3 -6
  30. package/dist/elements/GenerateConfirmation/index.js.map +1 -1
  31. package/dist/elements/ListControls/index.d.ts.map +1 -1
  32. package/dist/elements/ListControls/index.js +1 -2
  33. package/dist/elements/ListControls/index.js.map +1 -1
  34. package/dist/elements/ListDrawer/DrawerContent.d.ts.map +1 -1
  35. package/dist/elements/ListDrawer/DrawerContent.js +1 -2
  36. package/dist/elements/ListDrawer/DrawerContent.js.map +1 -1
  37. package/dist/elements/ListDrawer/index.d.ts.map +1 -1
  38. package/dist/elements/ListDrawer/index.js +1 -2
  39. package/dist/elements/ListDrawer/index.js.map +1 -1
  40. package/dist/elements/Modal/index.d.ts +1 -7
  41. package/dist/elements/Modal/index.d.ts.map +1 -1
  42. package/dist/elements/Modal/index.js +1 -7
  43. package/dist/elements/Modal/index.js.map +1 -1
  44. package/dist/elements/Nav/NavToggler/index.d.ts.map +1 -1
  45. package/dist/elements/Nav/NavToggler/index.js +1 -2
  46. package/dist/elements/Nav/NavToggler/index.js.map +1 -1
  47. package/dist/elements/Nav/context.d.ts.map +1 -1
  48. package/dist/elements/Nav/context.js +1 -2
  49. package/dist/elements/Nav/context.js.map +1 -1
  50. package/dist/elements/Popup/index.d.ts.map +1 -1
  51. package/dist/elements/Popup/index.js +1 -2
  52. package/dist/elements/Popup/index.js.map +1 -1
  53. package/dist/elements/PreviewButton/usePreviewURL.js +1 -1
  54. package/dist/elements/PreviewButton/usePreviewURL.js.map +1 -1
  55. package/dist/elements/PublishMany/index.d.ts.map +1 -1
  56. package/dist/elements/PublishMany/index.js +2 -3
  57. package/dist/elements/PublishMany/index.js.map +1 -1
  58. package/dist/elements/Status/index.d.ts.map +1 -1
  59. package/dist/elements/Status/index.js +2 -3
  60. package/dist/elements/Status/index.js.map +1 -1
  61. package/dist/elements/StayLoggedIn/index.d.ts.map +1 -1
  62. package/dist/elements/StayLoggedIn/index.js +1 -2
  63. package/dist/elements/StayLoggedIn/index.js.map +1 -1
  64. package/dist/elements/TableColumns/buildColumnState.d.ts.map +1 -1
  65. package/dist/elements/TableColumns/buildColumnState.js +2 -1
  66. package/dist/elements/TableColumns/buildColumnState.js.map +1 -1
  67. package/dist/elements/UnpublishMany/index.d.ts.map +1 -1
  68. package/dist/elements/UnpublishMany/index.js +2 -3
  69. package/dist/elements/UnpublishMany/index.js.map +1 -1
  70. package/dist/elements/WindowInfo/index.d.ts +1 -3
  71. package/dist/elements/WindowInfo/index.d.ts.map +1 -1
  72. package/dist/elements/WindowInfo/index.js +1 -7
  73. package/dist/elements/WindowInfo/index.js.map +1 -1
  74. package/dist/exports/elements.d.ts +2 -10
  75. package/dist/exports/elements.d.ts.map +1 -1
  76. package/dist/exports/elements.js +2 -10
  77. package/dist/exports/elements.js.map +1 -1
  78. package/dist/fields/Blocks/BlocksDrawer/index.d.ts.map +1 -1
  79. package/dist/fields/Blocks/BlocksDrawer/index.js +1 -2
  80. package/dist/fields/Blocks/BlocksDrawer/index.js.map +1 -1
  81. package/dist/fields/Blocks/RowActions.d.ts.map +1 -1
  82. package/dist/fields/Blocks/RowActions.js +1 -2
  83. package/dist/fields/Blocks/RowActions.js.map +1 -1
  84. package/dist/fields/Checkbox/Input.d.ts.map +1 -1
  85. package/dist/fields/Checkbox/Input.js +1 -0
  86. package/dist/fields/Checkbox/Input.js.map +1 -1
  87. package/dist/fields/Tabs/index.d.ts.map +1 -1
  88. package/dist/fields/Tabs/index.js +10 -1
  89. package/dist/fields/Tabs/index.js.map +1 -1
  90. package/dist/forms/Form/index.d.ts.map +1 -1
  91. package/dist/forms/Form/index.js +39 -9
  92. package/dist/forms/Form/index.js.map +1 -1
  93. package/dist/hooks/useHotkey.d.ts.map +1 -1
  94. package/dist/hooks/useHotkey.js +1 -2
  95. package/dist/hooks/useHotkey.js.map +1 -1
  96. package/dist/providers/Auth/index.d.ts.map +1 -1
  97. package/dist/providers/Auth/index.js +2 -3
  98. package/dist/providers/Auth/index.js.map +1 -1
  99. package/dist/providers/ComponentMap/buildComponentMap/fields.d.ts.map +1 -1
  100. package/dist/providers/ComponentMap/buildComponentMap/fields.js +10 -1
  101. package/dist/providers/ComponentMap/buildComponentMap/fields.js.map +1 -1
  102. package/dist/providers/Root/index.d.ts.map +1 -1
  103. package/dist/providers/Root/index.js +5 -19
  104. package/dist/providers/Root/index.js.map +1 -1
  105. package/dist/providers/ToastContainer/icons/Error.d.ts +3 -0
  106. package/dist/providers/ToastContainer/icons/Error.d.ts.map +1 -0
  107. package/dist/providers/ToastContainer/icons/Error.js +25 -0
  108. package/dist/providers/ToastContainer/icons/Error.js.map +1 -0
  109. package/dist/providers/ToastContainer/icons/Info.d.ts +3 -0
  110. package/dist/providers/ToastContainer/icons/Info.d.ts.map +1 -0
  111. package/dist/providers/ToastContainer/icons/Info.js +25 -0
  112. package/dist/providers/ToastContainer/icons/Info.js.map +1 -0
  113. package/dist/providers/ToastContainer/icons/Success.d.ts +3 -0
  114. package/dist/providers/ToastContainer/icons/Success.d.ts.map +1 -0
  115. package/dist/providers/ToastContainer/icons/Success.js +25 -0
  116. package/dist/providers/ToastContainer/icons/Success.js.map +1 -0
  117. package/dist/providers/ToastContainer/icons/Warning.d.ts +3 -0
  118. package/dist/providers/ToastContainer/icons/Warning.d.ts.map +1 -0
  119. package/dist/providers/ToastContainer/icons/Warning.js +25 -0
  120. package/dist/providers/ToastContainer/icons/Warning.js.map +1 -0
  121. package/dist/providers/ToastContainer/index.d.ts +3 -0
  122. package/dist/providers/ToastContainer/index.d.ts.map +1 -0
  123. package/dist/providers/ToastContainer/index.js +39 -0
  124. package/dist/providers/ToastContainer/index.js.map +1 -0
  125. package/dist/scss/app.scss +1 -1
  126. package/dist/scss/toasts.scss +111 -0
  127. package/dist/utilities/reduceFieldsToValuesWithValidation.d.ts +15 -0
  128. package/dist/utilities/reduceFieldsToValuesWithValidation.d.ts.map +1 -0
  129. package/dist/utilities/reduceFieldsToValuesWithValidation.js +29 -0
  130. package/dist/utilities/reduceFieldsToValuesWithValidation.js.map +1 -0
  131. package/package.json +9 -9
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/fields/Blocks/RowActions.tsx"],"sourcesContent":["'use client'\nimport type { Labels } from 'payload/types'\n\nimport * as facelessUIImport from '@faceless-ui/modal'\nimport React from 'react'\n\nimport type {\n FieldMap,\n ReducedBlock,\n} from '../../providers/ComponentMap/buildComponentMap/types.js'\n\nimport { ArrayAction } from '../../elements/ArrayAction/index.js'\nimport { useDrawerSlug } from '../../elements/Drawer/useDrawerSlug.js'\nimport { BlocksDrawer } from './BlocksDrawer/index.js'\n\nexport const RowActions: React.FC<{\n addRow: (rowIndex: number, blockType: string) => void\n blockType: string\n blocks: ReducedBlock[]\n duplicateRow: (rowIndex: number, blockType: string) => void\n fieldMap: FieldMap\n hasMaxRows?: boolean\n isSortable?: boolean\n labels: Labels\n moveRow: (fromIndex: number, toIndex: number) => void\n removeRow: (rowIndex: number) => void\n rowCount: number\n rowIndex: number\n}> = (props) => {\n const {\n addRow,\n blockType,\n blocks,\n duplicateRow,\n hasMaxRows,\n isSortable,\n labels,\n moveRow,\n removeRow,\n rowCount,\n rowIndex,\n } = props\n const { useModal } = facelessUIImport\n\n const { closeModal, openModal } = useModal()\n const drawerSlug = useDrawerSlug('blocks-drawer')\n\n const [indexToAdd, setIndexToAdd] = React.useState<null | number>(null)\n\n return (\n <React.Fragment>\n <BlocksDrawer\n addRow={(_, rowBlockType) => {\n if (typeof addRow === 'function') {\n addRow(indexToAdd, rowBlockType)\n }\n closeModal(drawerSlug)\n }}\n addRowIndex={rowIndex}\n blocks={blocks}\n drawerSlug={drawerSlug}\n labels={labels}\n />\n <ArrayAction\n addRow={(index) => {\n setIndexToAdd(index)\n openModal(drawerSlug)\n }}\n duplicateRow={() => duplicateRow(rowIndex, blockType)}\n hasMaxRows={hasMaxRows}\n index={rowIndex}\n isSortable={isSortable}\n moveRow={moveRow}\n removeRow={removeRow}\n rowCount={rowCount}\n />\n </React.Fragment>\n )\n}\n"],"names":["facelessUIImport","React","ArrayAction","useDrawerSlug","BlocksDrawer","RowActions","props","addRow","blockType","blocks","duplicateRow","hasMaxRows","isSortable","labels","moveRow","removeRow","rowCount","rowIndex","useModal","closeModal","openModal","drawerSlug","indexToAdd","setIndexToAdd","useState","Fragment","_","rowBlockType","addRowIndex","index"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;;AAGA,YAAYA,sBAAsB,qBAAoB;AACtD,OAAOC,WAAW,QAAO;AAOzB,SAASC,WAAW,QAAQ,sCAAqC;AACjE,SAASC,aAAa,QAAQ,yCAAwC;AACtE,SAASC,YAAY,QAAQ,0BAAyB;AAEtD,OAAO,MAAMC,aAaR,CAACC;IACJ,MAAM,EACJC,MAAM,EACNC,SAAS,EACTC,MAAM,EACNC,YAAY,EACZC,UAAU,EACVC,UAAU,EACVC,MAAM,EACNC,OAAO,EACPC,SAAS,EACTC,QAAQ,EACRC,QAAQ,EACT,GAAGX;IACJ,MAAM,EAAEY,QAAQ,EAAE,GAAGlB;IAErB,MAAM,EAAEmB,UAAU,EAAEC,SAAS,EAAE,GAAGF;IAClC,MAAMG,aAAalB,cAAc;IAEjC,MAAM,CAACmB,YAAYC,cAAc,GAAGtB,MAAMuB,QAAQ,CAAgB;IAElE,qBACE,MAACvB,MAAMwB,QAAQ;;0BACb,KAACrB;gBACCG,QAAQ,CAACmB,GAAGC;oBACV,IAAI,OAAOpB,WAAW,YAAY;wBAChCA,OAAOe,YAAYK;oBACrB;oBACAR,WAAWE;gBACb;gBACAO,aAAaX;gBACbR,QAAQA;gBACRY,YAAYA;gBACZR,QAAQA;;0BAEV,KAACX;gBACCK,QAAQ,CAACsB;oBACPN,cAAcM;oBACdT,UAAUC;gBACZ;gBACAX,cAAc,IAAMA,aAAaO,UAAUT;gBAC3CG,YAAYA;gBACZkB,OAAOZ;gBACPL,YAAYA;gBACZE,SAASA;gBACTC,WAAWA;gBACXC,UAAUA;;;;AAIlB,EAAC"}
1
+ {"version":3,"sources":["../../../src/fields/Blocks/RowActions.tsx"],"sourcesContent":["'use client'\nimport type { Labels } from 'payload/types'\n\nimport { useModal } from '@faceless-ui/modal'\nimport React from 'react'\n\nimport type {\n FieldMap,\n ReducedBlock,\n} from '../../providers/ComponentMap/buildComponentMap/types.js'\n\nimport { ArrayAction } from '../../elements/ArrayAction/index.js'\nimport { useDrawerSlug } from '../../elements/Drawer/useDrawerSlug.js'\nimport { BlocksDrawer } from './BlocksDrawer/index.js'\n\nexport const RowActions: React.FC<{\n addRow: (rowIndex: number, blockType: string) => void\n blockType: string\n blocks: ReducedBlock[]\n duplicateRow: (rowIndex: number, blockType: string) => void\n fieldMap: FieldMap\n hasMaxRows?: boolean\n isSortable?: boolean\n labels: Labels\n moveRow: (fromIndex: number, toIndex: number) => void\n removeRow: (rowIndex: number) => void\n rowCount: number\n rowIndex: number\n}> = (props) => {\n const {\n addRow,\n blockType,\n blocks,\n duplicateRow,\n hasMaxRows,\n isSortable,\n labels,\n moveRow,\n removeRow,\n rowCount,\n rowIndex,\n } = props\n\n const { closeModal, openModal } = useModal()\n const drawerSlug = useDrawerSlug('blocks-drawer')\n\n const [indexToAdd, setIndexToAdd] = React.useState<null | number>(null)\n\n return (\n <React.Fragment>\n <BlocksDrawer\n addRow={(_, rowBlockType) => {\n if (typeof addRow === 'function') {\n addRow(indexToAdd, rowBlockType)\n }\n closeModal(drawerSlug)\n }}\n addRowIndex={rowIndex}\n blocks={blocks}\n drawerSlug={drawerSlug}\n labels={labels}\n />\n <ArrayAction\n addRow={(index) => {\n setIndexToAdd(index)\n openModal(drawerSlug)\n }}\n duplicateRow={() => duplicateRow(rowIndex, blockType)}\n hasMaxRows={hasMaxRows}\n index={rowIndex}\n isSortable={isSortable}\n moveRow={moveRow}\n removeRow={removeRow}\n rowCount={rowCount}\n />\n </React.Fragment>\n )\n}\n"],"names":["useModal","React","ArrayAction","useDrawerSlug","BlocksDrawer","RowActions","props","addRow","blockType","blocks","duplicateRow","hasMaxRows","isSortable","labels","moveRow","removeRow","rowCount","rowIndex","closeModal","openModal","drawerSlug","indexToAdd","setIndexToAdd","useState","Fragment","_","rowBlockType","addRowIndex","index"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;;AAGA,SAASA,QAAQ,QAAQ,qBAAoB;AAC7C,OAAOC,WAAW,QAAO;AAOzB,SAASC,WAAW,QAAQ,sCAAqC;AACjE,SAASC,aAAa,QAAQ,yCAAwC;AACtE,SAASC,YAAY,QAAQ,0BAAyB;AAEtD,OAAO,MAAMC,aAaR,CAACC;IACJ,MAAM,EACJC,MAAM,EACNC,SAAS,EACTC,MAAM,EACNC,YAAY,EACZC,UAAU,EACVC,UAAU,EACVC,MAAM,EACNC,OAAO,EACPC,SAAS,EACTC,QAAQ,EACRC,QAAQ,EACT,GAAGX;IAEJ,MAAM,EAAEY,UAAU,EAAEC,SAAS,EAAE,GAAGnB;IAClC,MAAMoB,aAAajB,cAAc;IAEjC,MAAM,CAACkB,YAAYC,cAAc,GAAGrB,MAAMsB,QAAQ,CAAgB;IAElE,qBACE,MAACtB,MAAMuB,QAAQ;;0BACb,KAACpB;gBACCG,QAAQ,CAACkB,GAAGC;oBACV,IAAI,OAAOnB,WAAW,YAAY;wBAChCA,OAAOc,YAAYK;oBACrB;oBACAR,WAAWE;gBACb;gBACAO,aAAaV;gBACbR,QAAQA;gBACRW,YAAYA;gBACZP,QAAQA;;0BAEV,KAACX;gBACCK,QAAQ,CAACqB;oBACPN,cAAcM;oBACdT,UAAUC;gBACZ;gBACAV,cAAc,IAAMA,aAAaO,UAAUT;gBAC3CG,YAAYA;gBACZiB,OAAOX;gBACPL,YAAYA;gBACZE,SAASA;gBACTC,WAAWA;gBACXC,UAAUA;;;;AAIlB,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"Input.d.ts","sourceRoot":"","sources":["../../../src/fields/Checkbox/Input.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AAEpE,OAAO,KAAK,MAAM,OAAO,C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E,OAAO,CAAA;IACjB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAA;IACnD,KAAK,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC,CAAA;IAC3B,UAAU,CAAC,EAAE,mBAAmB,CAAA;IAChC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,WAAW,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAA;IAC9D,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAA;AAED,eAAO,MAAM,cAAc,mBAAmB,CAAA;AAE9C,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CA2DtD,CAAA"}
@@ -44,6 +44,7 @@ export const CheckboxInput = ({ id, name, AfterInput, BeforeInput, CustomLabel,
44
44
  }),
45
45
  /*#__PURE__*/ _jsx(FieldLabel, {
46
46
  CustomLabel: CustomLabel,
47
+ htmlFor: id,
47
48
  label: label,
48
49
  required: required,
49
50
  ...labelProps || {}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/fields/Checkbox/Input.tsx"],"sourcesContent":["'use client'\nimport type { LabelProps, SanitizedLabelProps } from 'payload/types'\n\nimport React from 'react'\n\nimport { FieldLabel } from '../../forms/FieldLabel/index.js'\nimport { Check } from '../../icons/Check/index.js'\nimport { Line } from '../../icons/Line/index.js'\n\nexport type CheckboxInputProps = {\n AfterInput?: React.ReactNode\n BeforeInput?: React.ReactNode\n CustomLabel?: React.ReactNode\n checked?: boolean\n className?: string\n id?: string\n inputRef?: React.RefObject<HTMLInputElement | null>\n label?: LabelProps['label']\n labelProps?: SanitizedLabelProps\n name?: string\n onToggle: (event: React.ChangeEvent<HTMLInputElement>) => void\n partialChecked?: boolean\n readOnly?: boolean\n required?: boolean\n}\n\nexport const inputBaseClass = 'checkbox-input'\n\nexport const CheckboxInput: React.FC<CheckboxInputProps> = ({\n id,\n name,\n AfterInput,\n BeforeInput,\n CustomLabel,\n checked,\n className,\n inputRef,\n label,\n labelProps,\n onToggle,\n partialChecked,\n readOnly,\n required,\n}) => {\n return (\n <div\n className={[\n className,\n inputBaseClass,\n checked && `${inputBaseClass}--checked`,\n readOnly && `${inputBaseClass}--read-only`,\n ]\n .filter(Boolean)\n .join(' ')}\n >\n <div className={`${inputBaseClass}__input`}>\n {BeforeInput}\n <input\n aria-label=\"\"\n defaultChecked={Boolean(checked)}\n disabled={readOnly}\n id={id}\n name={name}\n onInput={onToggle}\n ref={inputRef}\n required={required}\n type=\"checkbox\"\n />\n <span\n className={[`${inputBaseClass}__icon`, !checked && partialChecked ? 'check' : 'partial']\n .filter(Boolean)\n .join(' ')}\n >\n {checked && <Check />}\n {!checked && partialChecked && <Line />}\n </span>\n {AfterInput}\n </div>\n <FieldLabel\n CustomLabel={CustomLabel}\n label={label}\n required={required}\n {...(labelProps || {})}\n />\n </div>\n )\n}\n"],"names":["React","FieldLabel","Check","Line","inputBaseClass","CheckboxInput","id","name","AfterInput","BeforeInput","CustomLabel","checked","className","inputRef","label","labelProps","onToggle","partialChecked","readOnly","required","div","filter","Boolean","join","input","aria-label","defaultChecked","disabled","onInput","ref","type","span"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;;AAGA,OAAOA,WAAW,QAAO;AAEzB,SAASC,UAAU,QAAQ,kCAAiC;AAC5D,SAASC,KAAK,QAAQ,6BAA4B;AAClD,SAASC,IAAI,QAAQ,4BAA2B;AAmBhD,OAAO,MAAMC,iBAAiB,iBAAgB;AAE9C,OAAO,MAAMC,gBAA8C,CAAC,EAC1DC,EAAE,EACFC,IAAI,EACJC,UAAU,EACVC,WAAW,EACXC,WAAW,EACXC,OAAO,EACPC,SAAS,EACTC,QAAQ,EACRC,KAAK,EACLC,UAAU,EACVC,QAAQ,EACRC,cAAc,EACdC,QAAQ,EACRC,QAAQ,EACT;IACC,qBACE,MAACC;QACCR,WAAW;YACTA;YACAR;YACAO,WAAW,CAAC,EAAEP,eAAe,SAAS,CAAC;YACvCc,YAAY,CAAC,EAAEd,eAAe,WAAW,CAAC;SAC3C,CACEiB,MAAM,CAACC,SACPC,IAAI,CAAC;;0BAER,MAACH;gBAAIR,WAAW,CAAC,EAAER,eAAe,OAAO,CAAC;;oBACvCK;kCACD,KAACe;wBACCC,cAAW;wBACXC,gBAAgBJ,QAAQX;wBACxBgB,UAAUT;wBACVZ,IAAIA;wBACJC,MAAMA;wBACNqB,SAASZ;wBACTa,KAAKhB;wBACLM,UAAUA;wBACVW,MAAK;;kCAEP,MAACC;wBACCnB,WAAW;4BAAC,CAAC,EAAER,eAAe,MAAM,CAAC;4BAAE,CAACO,WAAWM,iBAAiB,UAAU;yBAAU,CACrFI,MAAM,CAACC,SACPC,IAAI,CAAC;;4BAEPZ,yBAAW,KAACT;4BACZ,CAACS,WAAWM,gCAAkB,KAACd;;;oBAEjCK;;;0BAEH,KAACP;gBACCS,aAAaA;gBACbI,OAAOA;gBACPK,UAAUA;gBACT,GAAIJ,cAAc,CAAC,CAAC;;;;AAI7B,EAAC"}
1
+ {"version":3,"sources":["../../../src/fields/Checkbox/Input.tsx"],"sourcesContent":["'use client'\nimport type { LabelProps, SanitizedLabelProps } from 'payload/types'\n\nimport React from 'react'\n\nimport { FieldLabel } from '../../forms/FieldLabel/index.js'\nimport { Check } from '../../icons/Check/index.js'\nimport { Line } from '../../icons/Line/index.js'\n\nexport type CheckboxInputProps = {\n AfterInput?: React.ReactNode\n BeforeInput?: React.ReactNode\n CustomLabel?: React.ReactNode\n checked?: boolean\n className?: string\n id?: string\n inputRef?: React.RefObject<HTMLInputElement | null>\n label?: LabelProps['label']\n labelProps?: SanitizedLabelProps\n name?: string\n onToggle: (event: React.ChangeEvent<HTMLInputElement>) => void\n partialChecked?: boolean\n readOnly?: boolean\n required?: boolean\n}\n\nexport const inputBaseClass = 'checkbox-input'\n\nexport const CheckboxInput: React.FC<CheckboxInputProps> = ({\n id,\n name,\n AfterInput,\n BeforeInput,\n CustomLabel,\n checked,\n className,\n inputRef,\n label,\n labelProps,\n onToggle,\n partialChecked,\n readOnly,\n required,\n}) => {\n return (\n <div\n className={[\n className,\n inputBaseClass,\n checked && `${inputBaseClass}--checked`,\n readOnly && `${inputBaseClass}--read-only`,\n ]\n .filter(Boolean)\n .join(' ')}\n >\n <div className={`${inputBaseClass}__input`}>\n {BeforeInput}\n <input\n aria-label=\"\"\n defaultChecked={Boolean(checked)}\n disabled={readOnly}\n id={id}\n name={name}\n onInput={onToggle}\n ref={inputRef}\n required={required}\n type=\"checkbox\"\n />\n <span\n className={[`${inputBaseClass}__icon`, !checked && partialChecked ? 'check' : 'partial']\n .filter(Boolean)\n .join(' ')}\n >\n {checked && <Check />}\n {!checked && partialChecked && <Line />}\n </span>\n {AfterInput}\n </div>\n <FieldLabel\n CustomLabel={CustomLabel}\n htmlFor={id}\n label={label}\n required={required}\n {...(labelProps || {})}\n />\n </div>\n )\n}\n"],"names":["React","FieldLabel","Check","Line","inputBaseClass","CheckboxInput","id","name","AfterInput","BeforeInput","CustomLabel","checked","className","inputRef","label","labelProps","onToggle","partialChecked","readOnly","required","div","filter","Boolean","join","input","aria-label","defaultChecked","disabled","onInput","ref","type","span","htmlFor"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;;AAGA,OAAOA,WAAW,QAAO;AAEzB,SAASC,UAAU,QAAQ,kCAAiC;AAC5D,SAASC,KAAK,QAAQ,6BAA4B;AAClD,SAASC,IAAI,QAAQ,4BAA2B;AAmBhD,OAAO,MAAMC,iBAAiB,iBAAgB;AAE9C,OAAO,MAAMC,gBAA8C,CAAC,EAC1DC,EAAE,EACFC,IAAI,EACJC,UAAU,EACVC,WAAW,EACXC,WAAW,EACXC,OAAO,EACPC,SAAS,EACTC,QAAQ,EACRC,KAAK,EACLC,UAAU,EACVC,QAAQ,EACRC,cAAc,EACdC,QAAQ,EACRC,QAAQ,EACT;IACC,qBACE,MAACC;QACCR,WAAW;YACTA;YACAR;YACAO,WAAW,CAAC,EAAEP,eAAe,SAAS,CAAC;YACvCc,YAAY,CAAC,EAAEd,eAAe,WAAW,CAAC;SAC3C,CACEiB,MAAM,CAACC,SACPC,IAAI,CAAC;;0BAER,MAACH;gBAAIR,WAAW,CAAC,EAAER,eAAe,OAAO,CAAC;;oBACvCK;kCACD,KAACe;wBACCC,cAAW;wBACXC,gBAAgBJ,QAAQX;wBACxBgB,UAAUT;wBACVZ,IAAIA;wBACJC,MAAMA;wBACNqB,SAASZ;wBACTa,KAAKhB;wBACLM,UAAUA;wBACVW,MAAK;;kCAEP,MAACC;wBACCnB,WAAW;4BAAC,CAAC,EAAER,eAAe,MAAM,CAAC;4BAAE,CAACO,WAAWM,iBAAiB,UAAU;yBAAU,CACrFI,MAAM,CAACC,SACPC,IAAI,CAAC;;4BAEPZ,yBAAW,KAACT;4BACZ,CAACS,WAAWM,gCAAkB,KAACd;;;oBAEjCK;;;0BAEH,KAACP;gBACCS,aAAaA;gBACbsB,SAAS1B;gBACTQ,OAAOA;gBACPK,UAAUA;gBACT,GAAIJ,cAAc,CAAC,CAAC;;;;AAI7B,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/Tabs/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAKpD,OAAO,KAA2C,MAAM,OAAO,CAAA;AAE/D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yDAAyD,CAAA;AACxF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAYvD,OAAO,cAAc,CAAA;AACrB,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAI5C,OAAO,EAAE,YAAY,EAAE,CAAA;AAEvB,MAAM,MAAM,cAAc,GAAG,aAAa,GAAG;IAC3C,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,gBAAgB,CAAA;IAC7B,IAAI,CAAC,EAAE,SAAS,EAAE,CAAA;IAClB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAyJD,eAAO,MAAM,IAAI,0BAA2B,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/Tabs/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAKpD,OAAO,KAA2C,MAAM,OAAO,CAAA;AAE/D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yDAAyD,CAAA;AACxF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAYvD,OAAO,cAAc,CAAA;AACrB,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAI5C,OAAO,EAAE,YAAY,EAAE,CAAA;AAEvB,MAAM,MAAM,cAAc,GAAG,aAAa,GAAG;IAC3C,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,gBAAgB,CAAA;IAC7B,IAAI,CAAC,EAAE,SAAS,EAAE,CAAA;IAClB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAoKD,eAAO,MAAM,IAAI,0BAA2B,CAAA"}
@@ -75,6 +75,15 @@ const TabsField = (props)=>{
75
75
  tabsPrefKey
76
76
  ]);
77
77
  const activeTabConfig = tabs[activeTabIndex];
78
+ function generateTabPath() {
79
+ let tabPath = path;
80
+ if (path && activeTabConfig.name) {
81
+ tabPath = `${path}.${activeTabConfig.name}`;
82
+ } else if (!path && activeTabConfig.name) {
83
+ tabPath = activeTabConfig.name;
84
+ }
85
+ return tabPath;
86
+ }
78
87
  return /*#__PURE__*/ _jsx("div", {
79
88
  className: [
80
89
  fieldBaseClass,
@@ -114,7 +123,7 @@ const TabsField = (props)=>{
114
123
  fieldMap: activeTabConfig.fieldMap,
115
124
  forceRender: forceRender,
116
125
  margins: "small",
117
- path: `${path ? `${path}.` : ''}${activeTabConfig.name ? `${activeTabConfig.name}` : ''}`,
126
+ path: generateTabPath(),
118
127
  permissions: 'name' in activeTabConfig && permissions?.fields?.[activeTabConfig.name]?.fields ? permissions?.fields?.[activeTabConfig.name]?.fields : permissions?.fields,
119
128
  readOnly: readOnly,
120
129
  schemaPath: `${schemaPath ? `${schemaPath}` : ''}${activeTabConfig.name ? `.${activeTabConfig.name}` : ''}`
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/fields/Tabs/index.tsx"],"sourcesContent":["'use client'\nimport type { FieldPermissions } from 'payload/auth'\nimport type { DocumentPreferences } from 'payload/types'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { toKebabCase } from 'payload/utilities'\nimport React, { useCallback, useEffect, useState } from 'react'\n\nimport type { MappedTab } from '../../providers/ComponentMap/buildComponentMap/types.js'\nimport type { FormFieldBase } from '../shared/index.js'\n\nimport { useCollapsible } from '../../elements/Collapsible/provider.js'\nimport { FieldDescription } from '../../forms/FieldDescription/index.js'\nimport { useFieldProps } from '../../forms/FieldPropsProvider/index.js'\nimport { RenderFields } from '../../forms/RenderFields/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { useDocumentInfo } from '../../providers/DocumentInfo/index.js'\nimport { usePreferences } from '../../providers/Preferences/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { fieldBaseClass } from '../shared/index.js'\nimport { TabComponent } from './Tab/index.js'\nimport './index.scss'\nimport { TabsProvider } from './provider.js'\n\nconst baseClass = 'tabs-field'\n\nexport { TabsProvider }\n\nexport type TabsFieldProps = FormFieldBase & {\n forceRender?: boolean\n name?: string\n path?: string\n permissions: FieldPermissions\n tabs?: MappedTab[]\n width?: string\n}\n\nconst TabsField: React.FC<TabsFieldProps> = (props) => {\n const {\n name,\n CustomDescription,\n className,\n descriptionProps,\n forceRender = false,\n path: pathFromProps,\n readOnly: readOnlyFromProps,\n tabs = [],\n } = props\n\n const {\n indexPath,\n path: pathFromContext,\n permissions,\n readOnly: readOnlyFromContext,\n schemaPath,\n } = useFieldProps()\n\n const readOnly = readOnlyFromProps || readOnlyFromContext\n const path = pathFromContext || pathFromProps || name\n const { getPreference, setPreference } = usePreferences()\n const { preferencesKey } = useDocumentInfo()\n const { i18n } = useTranslation()\n const { isWithinCollapsible } = useCollapsible()\n const [activeTabIndex, setActiveTabIndex] = useState<number>(0)\n const tabsPrefKey = `tabs-${indexPath}`\n\n useEffect(() => {\n if (preferencesKey) {\n const getInitialPref = async () => {\n const existingPreferences: DocumentPreferences = await getPreference(preferencesKey)\n const initialIndex = path\n ? existingPreferences?.fields?.[path]?.tabIndex\n : existingPreferences?.fields?.[tabsPrefKey]?.tabIndex\n setActiveTabIndex(initialIndex || 0)\n }\n void getInitialPref()\n }\n }, [path, getPreference, preferencesKey, tabsPrefKey])\n\n const handleTabChange = useCallback(\n async (incomingTabIndex: number) => {\n setActiveTabIndex(incomingTabIndex)\n\n const existingPreferences: DocumentPreferences = await getPreference(preferencesKey)\n\n if (preferencesKey) {\n void setPreference(preferencesKey, {\n ...existingPreferences,\n ...(path\n ? {\n fields: {\n ...(existingPreferences?.fields || {}),\n [path]: {\n ...existingPreferences?.fields?.[path],\n tabIndex: incomingTabIndex,\n },\n },\n }\n : {\n fields: {\n ...existingPreferences?.fields,\n [tabsPrefKey]: {\n ...existingPreferences?.fields?.[tabsPrefKey],\n tabIndex: incomingTabIndex,\n },\n },\n }),\n })\n }\n },\n [preferencesKey, getPreference, setPreference, path, tabsPrefKey],\n )\n\n const activeTabConfig = tabs[activeTabIndex]\n\n return (\n <div\n className={[\n fieldBaseClass,\n className,\n baseClass,\n isWithinCollapsible && `${baseClass}--within-collapsible`,\n ]\n .filter(Boolean)\n .join(' ')}\n >\n <TabsProvider>\n <div className={`${baseClass}__tabs-wrap`}>\n <div className={`${baseClass}__tabs`}>\n {tabs.map((tab, tabIndex) => {\n return (\n <TabComponent\n isActive={activeTabIndex === tabIndex}\n key={tabIndex}\n parentPath={path}\n setIsActive={() => handleTabChange(tabIndex)}\n tab={tab}\n />\n )\n })}\n </div>\n </div>\n <div className={`${baseClass}__content-wrap`}>\n {activeTabConfig && (\n <React.Fragment>\n <div\n className={[\n `${baseClass}__tab`,\n activeTabConfig.label &&\n `${baseClass}__tabConfigLabel-${toKebabCase(\n getTranslation(activeTabConfig.label, i18n),\n )}`,\n ]\n .filter(Boolean)\n .join(' ')}\n >\n {CustomDescription ? (\n CustomDescription\n ) : (\n <FieldDescription {...(descriptionProps || {})} />\n )}\n <RenderFields\n fieldMap={activeTabConfig.fieldMap}\n forceRender={forceRender}\n key={\n activeTabConfig.label\n ? getTranslation(activeTabConfig.label, i18n)\n : activeTabConfig['name']\n }\n margins=\"small\"\n path={`${path ? `${path}.` : ''}${activeTabConfig.name ? `${activeTabConfig.name}` : ''}`}\n permissions={\n 'name' in activeTabConfig && permissions?.fields?.[activeTabConfig.name]?.fields\n ? permissions?.fields?.[activeTabConfig.name]?.fields\n : permissions?.fields\n }\n readOnly={readOnly}\n schemaPath={`${schemaPath ? `${schemaPath}` : ''}${activeTabConfig.name ? `.${activeTabConfig.name}` : ''}`}\n />\n </div>\n </React.Fragment>\n )}\n </div>\n </TabsProvider>\n </div>\n )\n}\n\nexport const Tabs = withCondition(TabsField)\n"],"names":["getTranslation","toKebabCase","React","useCallback","useEffect","useState","useCollapsible","FieldDescription","useFieldProps","RenderFields","withCondition","useDocumentInfo","usePreferences","useTranslation","fieldBaseClass","TabComponent","TabsProvider","baseClass","TabsField","props","name","CustomDescription","className","descriptionProps","forceRender","path","pathFromProps","readOnly","readOnlyFromProps","tabs","indexPath","pathFromContext","permissions","readOnlyFromContext","schemaPath","getPreference","setPreference","preferencesKey","i18n","isWithinCollapsible","activeTabIndex","setActiveTabIndex","tabsPrefKey","getInitialPref","existingPreferences","initialIndex","fields","tabIndex","handleTabChange","incomingTabIndex","activeTabConfig","div","filter","Boolean","join","map","tab","isActive","parentPath","setIsActive","Fragment","label","fieldMap","margins","Tabs"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;;AAIA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,SAASC,WAAW,QAAQ,oBAAmB;AAC/C,OAAOC,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAK/D,SAASC,cAAc,QAAQ,yCAAwC;AACvE,SAASC,gBAAgB,QAAQ,wCAAuC;AACxE,SAASC,aAAa,QAAQ,0CAAyC;AACvE,SAASC,YAAY,QAAQ,oCAAmC;AAChE,SAASC,aAAa,QAAQ,qCAAoC;AAClE,SAASC,eAAe,QAAQ,wCAAuC;AACvE,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,cAAc,QAAQ,qBAAoB;AACnD,SAASC,YAAY,QAAQ,iBAAgB;AAE7C,SAASC,YAAY,QAAQ,gBAAe;AAE5C,MAAMC,YAAY;AAElB,SAASD,YAAY,GAAE;AAWvB,MAAME,YAAsC,CAACC;IAC3C,MAAM,EACJC,IAAI,EACJC,iBAAiB,EACjBC,SAAS,EACTC,gBAAgB,EAChBC,cAAc,KAAK,EACnBC,MAAMC,aAAa,EACnBC,UAAUC,iB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AAgB9B,IAAI,GAAG,CAAC,EAAE8B,gBAAgB9B,IAAI,CAAC,CAAC,GAAG,GAAG,CAAC;oCACzFY,aACE,UAAUkB,mBAAmBlB,aAAac,QAAQ,CAACI,gBAAgB9B,IAAI,CAAC,EAAE0B,SACtEd,aAAac,QAAQ,CAACI,gBAAgB9B,IAAI,CAAC,EAAE0B,SAC7Cd,aAAac;oCAEnBnB,UAAUA;oCACVO,YAAY,CAAC,EAAEA,aAAa,CAAC,EAAEA,WAAW,CAAC,GAAG,GAAG,EAAEgB,gBAAgB9B,IAAI,GAAG,CAAC,CAAC,EAAE8B,gBAAgB9B,IAAI,CAAC,CAAC,GAAG,GAAG,CAAC;mCAZzG8B,gBAAgBW,KAAK,GACjB7D,eAAekD,gBAAgBW,KAAK,EAAEvB,QACtCY,eAAe,CAAC,OAAO;;;;;;;;AAmB/C;AAEA,OAAO,MAAMc,OAAOtD,cAAcQ,WAAU"}
1
+ {"version":3,"sources":["../../../src/fields/Tabs/index.tsx"],"sourcesContent":["'use client'\nimport type { FieldPermissions } from 'payload/auth'\nimport type { DocumentPreferences } from 'payload/types'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { toKebabCase } from 'payload/utilities'\nimport React, { useCallback, useEffect, useState } from 'react'\n\nimport type { MappedTab } from '../../providers/ComponentMap/buildComponentMap/types.js'\nimport type { FormFieldBase } from '../shared/index.js'\n\nimport { useCollapsible } from '../../elements/Collapsible/provider.js'\nimport { FieldDescription } from '../../forms/FieldDescription/index.js'\nimport { useFieldProps } from '../../forms/FieldPropsProvider/index.js'\nimport { RenderFields } from '../../forms/RenderFields/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { useDocumentInfo } from '../../providers/DocumentInfo/index.js'\nimport { usePreferences } from '../../providers/Preferences/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { fieldBaseClass } from '../shared/index.js'\nimport { TabComponent } from './Tab/index.js'\nimport './index.scss'\nimport { TabsProvider } from './provider.js'\n\nconst baseClass = 'tabs-field'\n\nexport { TabsProvider }\n\nexport type TabsFieldProps = FormFieldBase & {\n forceRender?: boolean\n name?: string\n path?: string\n permissions: FieldPermissions\n tabs?: MappedTab[]\n width?: string\n}\n\nconst TabsField: React.FC<TabsFieldProps> = (props) => {\n const {\n name,\n CustomDescription,\n className,\n descriptionProps,\n forceRender = false,\n path: pathFromProps,\n readOnly: readOnlyFromProps,\n tabs = [],\n } = props\n\n const {\n indexPath,\n path: pathFromContext,\n permissions,\n readOnly: readOnlyFromContext,\n schemaPath,\n } = useFieldProps()\n\n const readOnly = readOnlyFromProps || readOnlyFromContext\n const path = pathFromContext || pathFromProps || name\n const { getPreference, setPreference } = usePreferences()\n const { preferencesKey } = useDocumentInfo()\n const { i18n } = useTranslation()\n const { isWithinCollapsible } = useCollapsible()\n const [activeTabIndex, setActiveTabIndex] = useState<number>(0)\n const tabsPrefKey = `tabs-${indexPath}`\n\n useEffect(() => {\n if (preferencesKey) {\n const getInitialPref = async () => {\n const existingPreferences: DocumentPreferences = await getPreference(preferencesKey)\n const initialIndex = path\n ? existingPreferences?.fields?.[path]?.tabIndex\n : existingPreferences?.fields?.[tabsPrefKey]?.tabIndex\n setActiveTabIndex(initialIndex || 0)\n }\n void getInitialPref()\n }\n }, [path, getPreference, preferencesKey, tabsPrefKey])\n\n const handleTabChange = useCallback(\n async (incomingTabIndex: number) => {\n setActiveTabIndex(incomingTabIndex)\n\n const existingPreferences: DocumentPreferences = await getPreference(preferencesKey)\n\n if (preferencesKey) {\n void setPreference(preferencesKey, {\n ...existingPreferences,\n ...(path\n ? {\n fields: {\n ...(existingPreferences?.fields || {}),\n [path]: {\n ...existingPreferences?.fields?.[path],\n tabIndex: incomingTabIndex,\n },\n },\n }\n : {\n fields: {\n ...existingPreferences?.fields,\n [tabsPrefKey]: {\n ...existingPreferences?.fields?.[tabsPrefKey],\n tabIndex: incomingTabIndex,\n },\n },\n }),\n })\n }\n },\n [preferencesKey, getPreference, setPreference, path, tabsPrefKey],\n )\n\n const activeTabConfig = tabs[activeTabIndex]\n\n function generateTabPath() {\n let tabPath = path\n if (path && activeTabConfig.name) {\n tabPath = `${path}.${activeTabConfig.name}`\n } else if (!path && activeTabConfig.name) {\n tabPath = activeTabConfig.name\n }\n\n return tabPath\n }\n\n return (\n <div\n className={[\n fieldBaseClass,\n className,\n baseClass,\n isWithinCollapsible && `${baseClass}--within-collapsible`,\n ]\n .filter(Boolean)\n .join(' ')}\n >\n <TabsProvider>\n <div className={`${baseClass}__tabs-wrap`}>\n <div className={`${baseClass}__tabs`}>\n {tabs.map((tab, tabIndex) => {\n return (\n <TabComponent\n isActive={activeTabIndex === tabIndex}\n key={tabIndex}\n parentPath={path}\n setIsActive={() => handleTabChange(tabIndex)}\n tab={tab}\n />\n )\n })}\n </div>\n </div>\n <div className={`${baseClass}__content-wrap`}>\n {activeTabConfig && (\n <React.Fragment>\n <div\n className={[\n `${baseClass}__tab`,\n activeTabConfig.label &&\n `${baseClass}__tabConfigLabel-${toKebabCase(\n getTranslation(activeTabConfig.label, i18n),\n )}`,\n ]\n .filter(Boolean)\n .join(' ')}\n >\n {CustomDescription ? (\n CustomDescription\n ) : (\n <FieldDescription {...(descriptionProps || {})} />\n )}\n <RenderFields\n fieldMap={activeTabConfig.fieldMap}\n forceRender={forceRender}\n key={\n activeTabConfig.label\n ? getTranslation(activeTabConfig.label, i18n)\n : activeTabConfig['name']\n }\n margins=\"small\"\n path={generateTabPath()}\n permissions={\n 'name' in activeTabConfig && permissions?.fields?.[activeTabConfig.name]?.fields\n ? permissions?.fields?.[activeTabConfig.name]?.fields\n : permissions?.fields\n }\n readOnly={readOnly}\n schemaPath={`${schemaPath ? `${schemaPath}` : ''}${activeTabConfig.name ? `.${activeTabConfig.name}` : ''}`}\n />\n </div>\n </React.Fragment>\n )}\n </div>\n </TabsProvider>\n </div>\n )\n}\n\nexport const Tabs = withCondition(TabsField)\n"],"names":["getTranslation","toKebabCase","React","useCallback","useEffect","useState","useCollapsible","FieldDescription","useFieldProps","RenderFields","withCondition","useDocumentInfo","usePreferences","useTranslation","fieldBaseClass","TabComponent","TabsProvider","baseClass","TabsField","props","name","CustomDescription","className","descriptionProps","forceRender","path","pathFromProps","readOnly","readOnlyFromProps","tabs","indexPath","pathFromContext","permissions","readOnlyFromContext","schemaPath","getPreference","setPreference","preferencesKey","i18n","isWithinCollapsible","activeTabIndex","setActiveTabIndex","tabsPrefKey","getInitialPref","existingPreferences","initialIndex","fields","tabIndex","handleTabChange","incomingTabIndex","activeTabConfig","generateTabPath","tabPath","div","filter","Boolean","join","map","tab","isActive","parentPath","setIsActive","Fragment","label","fieldMap","margins","Tabs"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;;AAIA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,SAASC,WAAW,QAAQ,oBAAmB;AAC/C,OAAOC,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAK/D,SAASC,cAAc,QAAQ,yCAAwC;AACvE,SAASC,gBAAgB,QAAQ,wCAAuC;AACxE,SAASC,aAAa,QAAQ,0CAAyC;AACvE,SAASC,YAAY,QAAQ,oCAAmC;AAChE,SAASC,aAAa,QAAQ,qCAAoC;AAClE,SAASC,eAAe,QAAQ,wCAAuC;AACvE,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,cAAc,QAAQ,qBAAoB;AACnD,SAASC,YAAY,QAAQ,iBAAgB;AAE7C,SAASC,YAAY,QAAQ,gBAAe;AAE5C,MAAMC,YAAY;AAElB,SAASD,YAAY,GAAE;AAWvB,MAAME,YAAsC,CAACC;IAC3C,MAAM,EACJC,IAAI,EACJC,iBAAiB,EACjBC,SAAS,EACTC,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AE,SAAS,EAAE,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/forms/Form/index.tsx"],"names":[],"mappings":"AASA,OAAO,KAA+D,MAAM,OAAO,CAAA;AAGnF,OAAO,KAAK,EAEV,SAAS,EAGV,MAAM,YAAY,CAAA;AAgCnB,eAAO,MAAM,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,CAwmBpC,CAAA;AAED,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,OAAO,EACP,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,YAAY,GACb,MAAM,cAAc,CAAA;AAErB,OAAO,EAAE,SAAS,EAAE,CAAA"}
@@ -6,7 +6,7 @@ import { serialize } from 'object-to-formdata';
6
6
  import { wait } from 'payload/utilities';
7
7
  import QueryString from 'qs';
8
8
  import React, { useCallback, useEffect, useReducer, useRef, useState } from 'react';
9
- import { toast } from 'react-toastify';
9
+ import { toast } from 'sonner';
10
10
  import { useDebouncedEffect } from '../../hooks/useDebouncedEffect.js';
11
11
  import useThrottledEffect from '../../hooks/useThrottledEffect.js';
12
12
  import { useAuth } from '../../providers/Auth/index.js';
@@ -115,6 +115,29 @@ export const Form = (props)=>{
115
115
  }
116
116
  return;
117
117
  }
118
+ // create new toast promise which will resolve manually later
119
+ let successToast, errorToast;
120
+ const promise = new Promise((resolve, reject)=>{
121
+ successToast = resolve;
122
+ errorToast = reject;
123
+ });
124
+ const hasFormSubmitAction = actionArg || typeof action === 'string' || typeof action === 'function';
125
+ if (redirect || disableSuccessStatus || !hasFormSubmitAction) {
126
+ // Do not show submitting toast, as the promise toast may never disappear under these conditions.
127
+ // Instead, make successToast() or errorToast() throw toast.success / toast.error
128
+ successToast = (data)=>toast.success(data);
129
+ errorToast = (data)=>toast.error(data);
130
+ } else {
131
+ toast.promise(promise, {
132
+ error: (data)=>{
133
+ return data;
134
+ },
135
+ loading: t('general:submitting'),
136
+ success: (data)=>{
137
+ return data;
138
+ }
139
+ });
140
+ }
118
141
  if (e) {
119
142
  e.stopPropagation();
120
143
  e.preventDefault();
@@ -146,7 +169,7 @@ export const Form = (props)=>{
146
169
  const isValid = skipValidation || disableValidationOnSubmit ? true : await contextRef.current.validateForm();
147
170
  // If not valid, prevent submission
148
171
  if (!isValid) {
149
- toast.error(t('error:correctInvalidFields'));
172
+ errorToast(t('error:correctInvalidFields'));
150
173
  setProcessing(false);
151
174
  setSubmitted(true);
152
175
  setDisabled(false);
@@ -160,6 +183,14 @@ export const Form = (props)=>{
160
183
  };
161
184
  onSubmit(fields, data);
162
185
  }
186
+ if (!hasFormSubmitAction) {
187
+ // No action provided, so we should return. An example where this happens are lexical link drawers. Upon submitting the drawer, we
188
+ // want to close it without submitting the form. Stuff like validation would be handled by lexical before this, through beforeSubmit
189
+ setProcessing(false);
190
+ setSubmitted(true);
191
+ setDisabled(false);
192
+ return;
193
+ }
163
194
  const formData = contextRef.current.createFormData(overrides);
164
195
  try {
165
196
  let res;
@@ -194,9 +225,7 @@ export const Form = (props)=>{
194
225
  if (redirect) {
195
226
  router.push(redirect);
196
227
  } else if (!disableSuccessStatus) {
197
- toast.success(json.message || t('general:submissionSuccessful'), {
198
- autoClose: 3000
199
- });
228
+ successToast(json.message || t('general:submissionSuccessful'));
200
229
  }
201
230
  } else {
202
231
  setProcessing(false);
@@ -206,7 +235,7 @@ export const Form = (props)=>{
206
235
  } // triggers rerender of all components that subscribe to form
207
236
  ;
208
237
  if (json.message) {
209
- toast.error(json.message);
238
+ errorToast(json.message);
210
239
  return;
211
240
  }
212
241
  if (Array.isArray(json.errors)) {
@@ -244,18 +273,19 @@ export const Form = (props)=>{
244
273
  errors: fieldErrors
245
274
  });
246
275
  nonFieldErrors.forEach((err)=>{
247
- toast.error(err.message || t('error:unknown'));
276
+ errorToast(err.message || t('error:unknown'));
248
277
  });
249
278
  return;
250
279
  }
251
280
  const message = errorMessages?.[res.status] || res?.statusText || t('error:unknown');
252
- toast.error(message);
281
+ errorToast(message);
253
282
  }
254
283
  } catch (err) {
284
+ console.error('Error submitting form', err);
255
285
  setProcessing(false);
256
286
  setSubmitted(true);
257
287
  setDisabled(false);
258
- toast.error(err);
288
+ errorToast(err.message);
259
289
  }
260
290
  }, [
261
291
  beforeSubmit,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/forms/Form/index.tsx"],"sourcesContent":["'use client'\nimport type { FormState } from 'payload/types'\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/utilities'\nimport QueryString from 'qs'\nimport React, { useCallback, useEffect, useReducer, useRef, useState } from 'react'\nimport { toast } from 'react-toastify'\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 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 toast.error(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 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)\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\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 toast.success(json.message || t('general:submissionSuccessful'), { autoClose: 3000 })\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 toast.error(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 toast.error(err.message || t('error:unknown'))\n })\n\n return\n }\n\n const message = errorMessages?.[res.status] || res?.statusText || t('error:unknown')\n\n toast.error(message)\n }\n } catch (err) {\n setProcessing(false)\n setSubmitted(true)\n setDisabled(false)\n\n toast.error(err)\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","stopPropagation","revalidatedFormState","reduce","priorOnChange","beforeSubmitFn","result","formState","resolve","every","error","formData","createFormData","res","actionEndpoint","stringify","addQueryPrefix","toLowerCase","body","headers","language","contentType","get","isJSON","indexOf","json","status","push","success","message","autoClose","errors","fieldErrors","nonFieldErrors","fieldErrs","nonFieldErrs","err","newFieldErrs","newNonFieldErrs","forEach","dataError","statusText","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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AAgB;IAAK,GAAG,CAAC,GAC9E;IAEN,qBACE,KAACwD;QACC/J,QAAQoB,SAAS0I,eAAgB9J;QACjCG,WAAWoJ;QACXnI,QAAQA;QACR4I,UAAU;QACVnJ,UAAU,CAACqE,IAAMnC,WAAWI,OAAO,CAAC6B,MAAM,CAAC,CAAC,GAAGE;QAC/C+E,KAAKnH;kBAEL,cAAA,KAACnE,YAAYuL,QAAQ;YAAC5F,OAAOvB,WAAWI,OAAO;sBAC7C,cAAA,KAACtE,iBAAiBqL,QAAQ;gBACxB5F,OAAO;oBACLrB;oBACA,GAAGF,WAAWI,OAAO;gBACvB;0BAEA,cAAA,KAAClE,iBAAiBiL,QAAQ;oBAAC5F,OAAOtD;8BAChC,cAAA,KAAClC,oBAAoBoL,QAAQ;wBAAC5F,OAAO,CAACjC,aAAcA,aAAaI;kCAC/D,cAAA,KAACzD,kBAAkBkL,QAAQ;4BAAC5F,OAAO3B;sCACjC,cAAA,KAAC5D,gBAAgBmL,QAAQ;gCAAC5F,OAAO/B;0CAC/B,cAAA,KAAC3D,kBAAkBsL,QAAQ;oCAAC5F,OAAOtB;8CAChC9C;;;;;;;;;AAUrB,EAAC;AAED,SACEvB,WAAW,EACXC,iBAAiB,EACjBC,gBAAgB,EAChBE,eAAe,EACfC,iBAAiB,EACjBC,gBAAgB,EAChBkL,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/types'\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/utilities'\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)\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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AQ;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,"file":"useHotkey.d.ts","sourceRoot":"","sources":["../../src/hooks/useHotkey.ts"],"names":[],"mappings":"AA6DA;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,YACX;IACP,UAAU,EAAE,OAAO,CAAA;IACnB,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,EAAE,CAAA;CACnB,QACK,CAAC,CAAC,EAAE,aAAa,KAAK,IAAI,KAC/B,IAiEF,CAAA"}
1
+ {"version":3,"file":"useHotkey.d.ts","sourceRoot":"","sources":["../../src/hooks/useHotkey.ts"],"names":[],"mappings":"AA6DA;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,YACX;IACP,UAAU,EAAE,OAAO,CAAA;IACnB,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,EAAE,CAAA;CACnB,QACK,CAAC,CAAC,EAAE,aAAa,KAAK,IAAI,KAC/B,IA+DF,CAAA"}
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- /* eslint-disable no-shadow */ import * as facelessUIImport from '@faceless-ui/modal';
2
+ /* eslint-disable no-shadow */ import { useModal } from '@faceless-ui/modal';
3
3
  import { setsAreEqual } from 'payload/utilities';
4
4
  import { useCallback, useEffect } from 'react';
5
5
  // Required to be outside of hook, else debounce would be necessary
@@ -53,7 +53,6 @@ const removeFromKeys = (code)=>{
53
53
  * @param param0.editDepth {boolean} This ensures that the hotkey is only triggered for the most top-level drawer in case there are nested drawers
54
54
  * @param func The callback function
55
55
  */ export const useHotkey = (options, func)=>{
56
- const { useModal } = facelessUIImport;
57
56
  const { cmdCtrlKey, editDepth, keyCodes } = options;
58
57
  const { modalState } = useModal();
59
58
  const keydown = useCallback((event)=>{
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/hooks/useHotkey.ts"],"sourcesContent":["'use client'\n/* eslint-disable no-shadow */\nimport * as facelessUIImport from '@faceless-ui/modal'\nimport { setsAreEqual } from 'payload/utilities'\nimport { useCallback, useEffect } from 'react'\n\n// Required to be outside of hook, else debounce would be necessary\n// and then one could not prevent the default behaviour.\n\n// It maps the pressed keys with the time they were pressed, in order to implement a maximum time\n// for the user to press the next key in the sequence\n\n// This is necessary to prevent a bug where the keyup event, which unsets the key as pressed\n// is not fired when the window is not focused.\n// When the user then comes back to the window, the key is still registered as pressed, even though it's not.\nconst pressedKeys = new Map<string, number>([])\n\nconst map = {\n altleft: 'alt',\n altright: 'alt',\n controlleft: 'ctrl',\n controlright: 'ctrl',\n ctrlleft: 'ctrl',\n ctrlright: 'ctrl',\n escape: 'esc',\n metaleft: 'meta',\n metaright: 'meta',\n osleft: 'meta',\n osright: 'meta',\n shiftleft: 'shift',\n shiftright: 'shift',\n}\n\nconst stripKey = (key: string) => {\n return (map[key.toLowerCase()] || key).trim().toLowerCase().replace('key', '')\n}\n\nconst pushToKeys = (code: string) => {\n const key = stripKey(code)\n\n // There is a weird bug with macos that if the keys are not cleared they remain in the\n // pressed keys set.\n if (key === 'meta') {\n pressedKeys.forEach(\n (time, pressedKey) => pressedKey !== 'meta' && pressedKeys.delete(pressedKey),\n )\n }\n\n pressedKeys.set(key, Date.now())\n}\n\nconst removeFromKeys = (code: string) => {\n const key = stripKey(code)\n // There is a weird bug with macos that if the keys are not cleared they remain in the\n // pressed keys set.\n if (key === 'meta') {\n pressedKeys.clear()\n }\n pressedKeys.delete(key)\n}\n\n/**\n * Hook function to work with hotkeys.\n * @param param0.keyCode {string[]} The keys to listen for (`Event.code` without `'Key'` and lowercased)\n * @param param0.cmdCtrlKey {boolean} Whether Ctrl on windows or Cmd on mac must be pressed\n * @param param0.editDepth {boolean} This ensures that the hotkey is only triggered for the most top-level drawer in case there are nested drawers\n * @param func The callback function\n */\nexport const useHotkey = (\n options: {\n cmdCtrlKey: boolean\n editDepth: number\n keyCodes: string[]\n },\n func: (e: KeyboardEvent) => void,\n): void => {\n const { useModal } = facelessUIImport\n\n const { cmdCtrlKey, editDepth, keyCodes } = options\n\n const { modalState } = useModal()\n\n const keydown = useCallback(\n (event: CustomEvent | KeyboardEvent) => {\n const e: KeyboardEvent = event.detail?.key ? event.detail : event\n if (e.key === undefined) {\n // Autofill events, or other synthetic events, can be ignored\n return\n }\n\n // Filter out pressed keys which have been pressed > 3 seconds ago\n pressedKeys.forEach((time, key) => {\n if (Date.now() - time > 3000) {\n pressedKeys.delete(key)\n }\n })\n\n if (e.code) pushToKeys(e.code)\n\n // Check for Mac and iPad\n const hasCmd = window.navigator.userAgent.includes('Mac OS X')\n const pressedWithoutModifier = [...pressedKeys.keys()].filter(\n (key) => !['alt', 'ctrl', 'meta', 'shift'].includes(key),\n )\n\n // Check whether arrays contain the same values (regardless of number of occurrences)\n if (\n setsAreEqual(new Set(pressedWithoutModifier), new Set(keyCodes)) &&\n (!cmdCtrlKey || (hasCmd && pressedKeys.has('meta')) || (!hasCmd && e.ctrlKey))\n ) {\n // get the maximum edit depth by counting the number of open drawers. modalState is and object which contains the state of all drawers.\n const maxEditDepth =\n Object.keys(modalState).filter((key) => modalState[key]?.isOpen)?.length + 1 ?? 1\n\n if (maxEditDepth !== editDepth) {\n // We only want to execute the hotkey from the most top-level drawer / edit depth.\n return\n }\n // execute the function associated with the maximum edit depth\n func(e)\n }\n },\n [keyCodes, cmdCtrlKey, editDepth, modalState, func],\n )\n\n const keyup = useCallback((e: KeyboardEvent) => {\n if (e.code) removeFromKeys(e.code)\n }, [])\n\n useEffect(() => {\n document.addEventListener('keydown', keydown, false)\n document.addEventListener('bypassKeyDown', keydown, false) // this is called if the keydown event's propagation is stopped by react-select\n document.addEventListener('keyup', keyup, false)\n\n return () => {\n document.removeEventListener('keydown', keydown)\n document.removeEventListener('bypassKeyDown', keydown)\n document.removeEventListener('keyup', keyup)\n }\n }, [keydown, keyup])\n}\n"],"names":["facelessUIImport","setsAreEqual","useCallback","useEffect","pressedKeys","Map","map","altleft","altright","controlleft","controlright","ctrlleft","ctrlright","escape","metaleft","metaright","osleft","osright","shiftleft","shiftright","stripKey","key","toLowerCase","trim","replace","pushToKeys","code","forEach","time","pressedKey","delete","set","Date","now","removeFromKeys","clear","useHotkey","options","func","useModal","cmdCtrlKey","editDepth","keyCodes","modalState","keydown","event","e","detail","undefined","hasCmd","window","navigator","userAgent","includes","pressedWithoutModifier","keys","filter","Set","has","ctrlKey","maxEditDepth","Object","isOpen","length","keyup","document","addEventListener","removeEventListener"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AACA,4BAA4B,GAC5B,YAAYA,sBAAsB,qBAAoB;AACtD,SAASC,YAAY,QAAQ,oBAAmB;AAChD,SAASC,WAAW,EAAEC,SAAS,QAAQ,QAAO;AAE9C,mEAAmE;AACnE,wDAAwD;AAExD,iGAAiG;AACjG,qDAAqD;AAErD,4FAA4F;AAC5F,+CAA+C;AAC/C,6GAA6G;AAC7G,MAAMC,cAAc,IAAIC,IAAoB,EAAE;AAE9C,MAAMC,MAAM;IACVC,SAAS;IACTC,UAAU;IACVC,aAAa;IACbC,cAAc;IACdC,UAAU;IACVC,WAAW;IACXC,QAAQ;IACRC,UAAU;IACVC,WAAW;IACXC,QAAQ;IACRC,SAAS;IACTC,WAAW;IACXC,YAAY;AACd;AAEA,MAAMC,WAAW,CAACC;IAChB,OAAO,AAACf,CAAAA,GAAG,CAACe,IAAIC,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AM,CAC3D,CAACnC,MAAQ,CAAC;gBAAC;gBAAO;gBAAQ;gBAAQ;aAAQ,CAACgC,QAAQ,CAAChC;QAGtD,qFAAqF;QACrF,IACEpB,aAAa,IAAIwD,IAAIH,yBAAyB,IAAIG,IAAIf,cACrD,CAAA,CAACF,cAAeS,UAAU7C,YAAYsD,GAAG,CAAC,WAAa,CAACT,UAAUH,EAAEa,OAAO,GAC5E;YACA,uIAAuI;YACvI,MAAMC,eACJC,CAAAA,OAAON,IAAI,CAACZ,YAAYa,MAAM,CAAC,CAACnC,MAAQsB,UAAU,CAACtB,IAAI,EAAEyC,SAASC,SAAS,CAAA,KAAK;YAElF,IAAIH,iBAAiBnB,WAAW;gBAC9B,kFAAkF;gBAClF;YACF;YACA,8DAA8D;YAC9DH,KAAKQ;QACP;IACF,GACA;QAACJ;QAAUF;QAAYC;QAAWE;QAAYL;KAAK;IAGrD,MAAM0B,QAAQ9D,YAAY,CAAC4C;QACzB,IAAIA,EAAEpB,IAAI,EAAEQ,eAAeY,EAAEpB,IAAI;IACnC,GAAG,EAAE;IAELvB,UAAU;QACR8D,SAASC,gBAAgB,CAAC,WAAWtB,SAAS;QAC9CqB,SAASC,gBAAgB,CAAC,iBAAiBtB,SAAS,OAAO,+EAA+E;;QAC1IqB,SAASC,gBAAgB,CAAC,SAASF,OAAO;QAE1C,OAAO;YACLC,SAASE,mBAAmB,CAAC,WAAWvB;YACxCqB,SAASE,mBAAmB,CAAC,iBAAiBvB;YAC9CqB,SAASE,mBAAmB,CAAC,SAASH;QACxC;IACF,GAAG;QAACpB;QAASoB;KAAM;AACrB,EAAC"}
1
+ {"version":3,"sources":["../../src/hooks/useHotkey.ts"],"sourcesContent":["'use client'\n/* eslint-disable no-shadow */\nimport { useModal } from '@faceless-ui/modal'\nimport { setsAreEqual } from 'payload/utilities'\nimport { useCallback, useEffect } from 'react'\n\n// Required to be outside of hook, else debounce would be necessary\n// and then one could not prevent the default behaviour.\n\n// It maps the pressed keys with the time they were pressed, in order to implement a maximum time\n// for the user to press the next key in the sequence\n\n// This is necessary to prevent a bug where the keyup event, which unsets the key as pressed\n// is not fired when the window is not focused.\n// When the user then comes back to the window, the key is still registered as pressed, even though it's not.\nconst pressedKeys = new Map<string, number>([])\n\nconst map = {\n altleft: 'alt',\n altright: 'alt',\n controlleft: 'ctrl',\n controlright: 'ctrl',\n ctrlleft: 'ctrl',\n ctrlright: 'ctrl',\n escape: 'esc',\n metaleft: 'meta',\n metaright: 'meta',\n osleft: 'meta',\n osright: 'meta',\n shiftleft: 'shift',\n shiftright: 'shift',\n}\n\nconst stripKey = (key: string) => {\n return (map[key.toLowerCase()] || key).trim().toLowerCase().replace('key', '')\n}\n\nconst pushToKeys = (code: string) => {\n const key = stripKey(code)\n\n // There is a weird bug with macos that if the keys are not cleared they remain in the\n // pressed keys set.\n if (key === 'meta') {\n pressedKeys.forEach(\n (time, pressedKey) => pressedKey !== 'meta' && pressedKeys.delete(pressedKey),\n )\n }\n\n pressedKeys.set(key, Date.now())\n}\n\nconst removeFromKeys = (code: string) => {\n const key = stripKey(code)\n // There is a weird bug with macos that if the keys are not cleared they remain in the\n // pressed keys set.\n if (key === 'meta') {\n pressedKeys.clear()\n }\n pressedKeys.delete(key)\n}\n\n/**\n * Hook function to work with hotkeys.\n * @param param0.keyCode {string[]} The keys to listen for (`Event.code` without `'Key'` and lowercased)\n * @param param0.cmdCtrlKey {boolean} Whether Ctrl on windows or Cmd on mac must be pressed\n * @param param0.editDepth {boolean} This ensures that the hotkey is only triggered for the most top-level drawer in case there are nested drawers\n * @param func The callback function\n */\nexport const useHotkey = (\n options: {\n cmdCtrlKey: boolean\n editDepth: number\n keyCodes: string[]\n },\n func: (e: KeyboardEvent) => void,\n): void => {\n const { cmdCtrlKey, editDepth, keyCodes } = options\n\n const { modalState } = useModal()\n\n const keydown = useCallback(\n (event: CustomEvent | KeyboardEvent) => {\n const e: KeyboardEvent = event.detail?.key ? event.detail : event\n if (e.key === undefined) {\n // Autofill events, or other synthetic events, can be ignored\n return\n }\n\n // Filter out pressed keys which have been pressed > 3 seconds ago\n pressedKeys.forEach((time, key) => {\n if (Date.now() - time > 3000) {\n pressedKeys.delete(key)\n }\n })\n\n if (e.code) pushToKeys(e.code)\n\n // Check for Mac and iPad\n const hasCmd = window.navigator.userAgent.includes('Mac OS X')\n const pressedWithoutModifier = [...pressedKeys.keys()].filter(\n (key) => !['alt', 'ctrl', 'meta', 'shift'].includes(key),\n )\n\n // Check whether arrays contain the same values (regardless of number of occurrences)\n if (\n setsAreEqual(new Set(pressedWithoutModifier), new Set(keyCodes)) &&\n (!cmdCtrlKey || (hasCmd && pressedKeys.has('meta')) || (!hasCmd && e.ctrlKey))\n ) {\n // get the maximum edit depth by counting the number of open drawers. modalState is and object which contains the state of all drawers.\n const maxEditDepth =\n Object.keys(modalState).filter((key) => modalState[key]?.isOpen)?.length + 1 ?? 1\n\n if (maxEditDepth !== editDepth) {\n // We only want to execute the hotkey from the most top-level drawer / edit depth.\n return\n }\n // execute the function associated with the maximum edit depth\n func(e)\n }\n },\n [keyCodes, cmdCtrlKey, editDepth, modalState, func],\n )\n\n const keyup = useCallback((e: KeyboardEvent) => {\n if (e.code) removeFromKeys(e.code)\n }, [])\n\n useEffect(() => {\n document.addEventListener('keydown', keydown, false)\n document.addEventListener('bypassKeyDown', keydown, false) // this is called if the keydown event's propagation is stopped by react-select\n document.addEventListener('keyup', keyup, false)\n\n return () => {\n document.removeEventListener('keydown', keydown)\n document.removeEventListener('bypassKeyDown', keydown)\n document.removeEventListener('keyup', keyup)\n }\n }, [keydown, keyup])\n}\n"],"names":["useModal","setsAreEqual","useCallback","useEffect","pressedKeys","Map","map","altleft","altright","controlleft","controlright","ctrlleft","ctrlright","escape","metaleft","metaright","osleft","osright","shiftleft","shiftright","stripKey","key","toLowerCase","trim","replace","pushToKeys","code","forEach","time","pressedKey","delete","set","Date","now","removeFromKeys","clear","useHotkey","options","func","cmdCtrlKey","editDepth","keyCodes","modalState","keydown","event","e","detail","undefined","hasCmd","window","navigator","userAgent","includes","pressedWithoutModifier","keys","filter","Set","has","ctrlKey","maxEditDepth","Object","isOpen","length","keyup","document","addEventListener","removeEventListener"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AACA,4BAA4B,GAC5B,SAASA,QAAQ,QAAQ,qBAAoB;AAC7C,SAASC,YAAY,QAAQ,oBAAmB;AAChD,SAASC,WAAW,EAAEC,SAAS,QAAQ,QAAO;AAE9C,mEAAmE;AACnE,wDAAwD;AAExD,iGAAiG;AACjG,qDAAqD;AAErD,4FAA4F;AAC5F,+CAA+C;AAC/C,6GAA6G;AAC7G,MAAMC,cAAc,IAAIC,IAAoB,EAAE;AAE9C,MAAMC,MAAM;IACVC,SAAS;IACTC,UAAU;IACVC,aAAa;IACbC,cAAc;IACdC,UAAU;IACVC,WAAW;IACXC,QAAQ;IACRC,UAAU;IACVC,WAAW;IACXC,QAAQ;IACRC,SAAS;IACTC,WAAW;IACXC,YAAY;AACd;AAEA,MAAMC,WAAW,CAACC;IAChB,OAAO,AAACf,CAAAA,GAAG,CAACe,IAAIC,WAAW,GAAG,IAAID,GAAE,EAAGE,IAAI,GAAGD,WAAW,GAAGE,OAAO,CAAC,OAAO;AAC7E;AAEA,MAAMC,aAAa,CAACC;IAClB,MAAML,MAAMD,SAASM;IAErB,sFAAsF;IACtF,oBAAoB;IACpB,IAAIL,QAAQ,QAAQ;QAClBjB,YAAYuB,OAAO,CACjB,CAACC,MAAMC,aAAeA,eAAe,UAAUzB,YAAY0B,MAAM,CAACD;IAEtE;IAEAzB,YAAY2B,GAAG,CAACV,KAAKW,KAAKC,GAAG;AAC/B;AAEA,MAAMC,iBAAiB,CAACR;IACtB,MAAML,MAAMD,SAASM;IACrB,sFAAsF;IACtF,oBAAoB;IACpB,IAAIL,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} from "react/jsx-runtime";
3
- import * as facelessUIImport from '@faceless-ui/modal';
3
+ import { useModal } from '@faceless-ui/modal';
4
4
  import { usePathname, useRouter } from 'next/navigation.js';
5
5
  import qs from 'qs';
6
6
  import React, { createContext, useCallback, useContext, useEffect, useState } from 'react';
7
- import { toast } from 'react-toastify';
7
+ import { toast } from 'sonner';
8
8
  import { stayLoggedInModalSlug } from '../../elements/StayLoggedIn/index.js';
9
9
  import { useDebounce } from '../../hooks/useDebounce.js';
10
10
  import { useTranslation } from '../../providers/Translation/index.js';
@@ -14,7 +14,6 @@ import { useSearchParams } from '../SearchParams/index.js';
14
14
  const Context = /*#__PURE__*/ createContext({});
15
15
  const maxTimeoutTime = 2147483647;
16
16
  export const AuthProvider = ({ children })=>{
17
- const { useModal } = facelessUIImport;
18
17
  const { searchParams } = useSearchParams();
19
18
  const [user, setUser] = useState();
20
19
  const [tokenInMemory, setTokenInMemory] = useState();