@payloadcms/ui 3.0.0-beta.31 → 3.0.0-beta.33

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 (251) hide show
  1. package/dist/assets/index.d.ts +4 -4
  2. package/dist/assets/index.d.ts.map +1 -1
  3. package/dist/assets/index.js +4 -4
  4. package/dist/assets/index.js.map +1 -1
  5. package/dist/elements/AppHeader/index.d.ts.map +1 -1
  6. package/dist/elements/AppHeader/index.js +2 -2
  7. package/dist/elements/AppHeader/index.js.map +1 -1
  8. package/dist/elements/Autosave/index.d.ts.map +1 -1
  9. package/dist/elements/Autosave/index.js +1 -1
  10. package/dist/elements/Autosave/index.js.map +1 -1
  11. package/dist/elements/Banner/index.js +1 -1
  12. package/dist/elements/Banner/index.js.map +1 -1
  13. package/dist/elements/DocumentControls/index.d.ts.map +1 -1
  14. package/dist/elements/DocumentControls/index.js +1 -1
  15. package/dist/elements/DocumentControls/index.js.map +1 -1
  16. package/dist/elements/ListControls/getTextFieldsToBeSearched.d.ts.map +1 -1
  17. package/dist/elements/ListControls/getTextFieldsToBeSearched.js +1 -1
  18. package/dist/elements/ListControls/getTextFieldsToBeSearched.js.map +1 -1
  19. package/dist/elements/ListControls/index.d.ts.map +1 -1
  20. package/dist/elements/ListControls/index.js +1 -1
  21. package/dist/elements/ListControls/index.js.map +1 -1
  22. package/dist/elements/Logout/index.d.ts.map +1 -1
  23. package/dist/elements/Logout/index.js +1 -1
  24. package/dist/elements/Logout/index.js.map +1 -1
  25. package/dist/elements/Nav/index.client.d.ts.map +1 -1
  26. package/dist/elements/Nav/index.client.js +1 -1
  27. package/dist/elements/Nav/index.client.js.map +1 -1
  28. package/dist/elements/Nav/index.d.ts +2 -4
  29. package/dist/elements/Nav/index.d.ts.map +1 -1
  30. package/dist/elements/Nav/index.js +20 -4
  31. package/dist/elements/Nav/index.js.map +1 -1
  32. package/dist/elements/Pill/index.js +1 -1
  33. package/dist/elements/Pill/index.js.map +1 -1
  34. package/dist/elements/ReactSelect/ClearIndicator/index.d.ts.map +1 -1
  35. package/dist/elements/ReactSelect/ClearIndicator/index.js +10 -2
  36. package/dist/elements/ReactSelect/ClearIndicator/index.js.map +1 -1
  37. package/dist/elements/ReactSelect/ClearIndicator/index.scss +4 -0
  38. package/dist/elements/ReactSelect/DropdownIndicator/index.d.ts +8 -0
  39. package/dist/elements/ReactSelect/DropdownIndicator/index.d.ts.map +1 -0
  40. package/dist/elements/ReactSelect/DropdownIndicator/index.js +19 -0
  41. package/dist/elements/ReactSelect/DropdownIndicator/index.js.map +1 -0
  42. package/dist/elements/ReactSelect/DropdownIndicator/index.scss +16 -0
  43. package/dist/elements/ReactSelect/MultiValue/index.d.ts.map +1 -1
  44. package/dist/elements/ReactSelect/MultiValue/index.js +3 -3
  45. package/dist/elements/ReactSelect/MultiValue/index.js.map +1 -1
  46. package/dist/elements/ReactSelect/MultiValueLabel/index.scss +4 -0
  47. package/dist/elements/ReactSelect/MultiValueRemove/index.d.ts.map +1 -1
  48. package/dist/elements/ReactSelect/MultiValueRemove/index.js +6 -0
  49. package/dist/elements/ReactSelect/MultiValueRemove/index.js.map +1 -1
  50. package/dist/elements/ReactSelect/index.js +3 -3
  51. package/dist/elements/ReactSelect/index.js.map +1 -1
  52. package/dist/elements/ReactSelect/index.scss +1 -1
  53. package/dist/elements/RenderCustomComponent/index.d.ts +3 -3
  54. package/dist/elements/RenderCustomComponent/index.d.ts.map +1 -1
  55. package/dist/elements/RenderCustomComponent/index.js +4 -4
  56. package/dist/elements/RenderCustomComponent/index.js.map +1 -1
  57. package/dist/elements/StayLoggedIn/index.d.ts.map +1 -1
  58. package/dist/elements/StayLoggedIn/index.js +2 -2
  59. package/dist/elements/StayLoggedIn/index.js.map +1 -1
  60. package/dist/elements/StepNav/index.d.ts.map +1 -1
  61. package/dist/elements/StepNav/index.js +13 -3
  62. package/dist/elements/StepNav/index.js.map +1 -1
  63. package/dist/elements/StepNav/index.scss +11 -0
  64. package/dist/elements/Table/DefaultCell/fields/Array/index.d.ts.map +1 -1
  65. package/dist/elements/Table/DefaultCell/fields/Array/index.js +1 -1
  66. package/dist/elements/Table/DefaultCell/fields/Array/index.js.map +1 -1
  67. package/dist/elements/Table/DefaultCell/fields/Blocks/index.d.ts.map +1 -1
  68. package/dist/elements/Table/DefaultCell/fields/Blocks/index.js +1 -1
  69. package/dist/elements/Table/DefaultCell/fields/Blocks/index.js.map +1 -1
  70. package/dist/elements/Table/DefaultCell/fields/Checkbox/index.d.ts.map +1 -1
  71. package/dist/elements/Table/DefaultCell/fields/Checkbox/index.js +1 -1
  72. package/dist/elements/Table/DefaultCell/fields/Checkbox/index.js.map +1 -1
  73. package/dist/elements/Table/DefaultCell/fields/Date/index.d.ts.map +1 -1
  74. package/dist/elements/Table/DefaultCell/fields/Date/index.js +3 -3
  75. package/dist/elements/Table/DefaultCell/fields/Date/index.js.map +1 -1
  76. package/dist/elements/Table/DefaultCell/fields/File/index.d.ts.map +1 -1
  77. package/dist/elements/Table/DefaultCell/fields/File/index.js +1 -1
  78. package/dist/elements/Table/DefaultCell/fields/File/index.js.map +1 -1
  79. package/dist/elements/Table/DefaultCell/fields/Relationship/index.d.ts.map +1 -1
  80. package/dist/elements/Table/DefaultCell/fields/Relationship/index.js +5 -5
  81. package/dist/elements/Table/DefaultCell/fields/Relationship/index.js.map +1 -1
  82. package/dist/elements/Table/DefaultCell/fields/Select/index.d.ts.map +1 -1
  83. package/dist/elements/Table/DefaultCell/fields/Select/index.js +1 -1
  84. package/dist/elements/Table/DefaultCell/fields/Select/index.js.map +1 -1
  85. package/dist/elements/Table/DefaultCell/index.js +3 -3
  86. package/dist/elements/Table/DefaultCell/index.js.map +1 -1
  87. package/dist/elements/Table/RelationshipProvider/index.d.ts.map +1 -1
  88. package/dist/elements/Table/RelationshipProvider/index.js +4 -4
  89. package/dist/elements/Table/RelationshipProvider/index.js.map +1 -1
  90. package/dist/elements/TableColumns/buildColumnState.d.ts.map +1 -1
  91. package/dist/elements/TableColumns/buildColumnState.js +1 -1
  92. package/dist/elements/TableColumns/buildColumnState.js.map +1 -1
  93. package/dist/elements/Upload/index.d.ts.map +1 -1
  94. package/dist/elements/Upload/index.js +2 -2
  95. package/dist/elements/Upload/index.js.map +1 -1
  96. package/dist/elements/WithServerSideProps/index.d.ts +2 -2
  97. package/dist/elements/WithServerSideProps/index.d.ts.map +1 -1
  98. package/dist/elements/WithServerSideProps/index.js +4 -6
  99. package/dist/elements/WithServerSideProps/index.js.map +1 -1
  100. package/dist/fields/Array/index.d.ts.map +1 -1
  101. package/dist/fields/Array/index.js +5 -5
  102. package/dist/fields/Array/index.js.map +1 -1
  103. package/dist/fields/Blocks/index.d.ts.map +1 -1
  104. package/dist/fields/Blocks/index.js +5 -5
  105. package/dist/fields/Blocks/index.js.map +1 -1
  106. package/dist/fields/Checkbox/Input.d.ts.map +1 -1
  107. package/dist/fields/Checkbox/Input.js +1 -1
  108. package/dist/fields/Checkbox/Input.js.map +1 -1
  109. package/dist/fields/Checkbox/index.d.ts.map +1 -1
  110. package/dist/fields/Checkbox/index.js +4 -4
  111. package/dist/fields/Checkbox/index.js.map +1 -1
  112. package/dist/fields/Code/index.d.ts.map +1 -1
  113. package/dist/fields/Code/index.js +4 -4
  114. package/dist/fields/Code/index.js.map +1 -1
  115. package/dist/fields/Collapsible/index.d.ts.map +1 -1
  116. package/dist/fields/Collapsible/index.js +1 -1
  117. package/dist/fields/Collapsible/index.js.map +1 -1
  118. package/dist/fields/DateTime/index.d.ts.map +1 -1
  119. package/dist/fields/DateTime/index.js +3 -3
  120. package/dist/fields/DateTime/index.js.map +1 -1
  121. package/dist/fields/Email/index.d.ts.map +1 -1
  122. package/dist/fields/Email/index.js +4 -4
  123. package/dist/fields/Email/index.js.map +1 -1
  124. package/dist/fields/Group/index.d.ts.map +1 -1
  125. package/dist/fields/Group/index.js +1 -1
  126. package/dist/fields/Group/index.js.map +1 -1
  127. package/dist/fields/HiddenInput/index.d.ts.map +1 -1
  128. package/dist/fields/HiddenInput/index.js +1 -1
  129. package/dist/fields/HiddenInput/index.js.map +1 -1
  130. package/dist/fields/JSON/index.d.ts.map +1 -1
  131. package/dist/fields/JSON/index.js +3 -3
  132. package/dist/fields/JSON/index.js.map +1 -1
  133. package/dist/fields/Number/index.d.ts.map +1 -1
  134. package/dist/fields/Number/index.js +4 -4
  135. package/dist/fields/Number/index.js.map +1 -1
  136. package/dist/fields/Password/index.d.ts.map +1 -1
  137. package/dist/fields/Password/index.js +2 -2
  138. package/dist/fields/Password/index.js.map +1 -1
  139. package/dist/fields/Point/index.d.ts.map +1 -1
  140. package/dist/fields/Point/index.js +4 -4
  141. package/dist/fields/Point/index.js.map +1 -1
  142. package/dist/fields/RadioGroup/Radio/index.d.ts.map +1 -1
  143. package/dist/fields/RadioGroup/Radio/index.js +1 -1
  144. package/dist/fields/RadioGroup/Radio/index.js.map +1 -1
  145. package/dist/fields/RadioGroup/index.d.ts.map +1 -1
  146. package/dist/fields/RadioGroup/index.js +3 -3
  147. package/dist/fields/RadioGroup/index.js.map +1 -1
  148. package/dist/fields/Relationship/index.d.ts.map +1 -1
  149. package/dist/fields/Relationship/index.js +5 -5
  150. package/dist/fields/Relationship/index.js.map +1 -1
  151. package/dist/fields/Relationship/select-components/MultiValueLabel/index.d.ts.map +1 -1
  152. package/dist/fields/Relationship/select-components/MultiValueLabel/index.js +8 -1
  153. package/dist/fields/Relationship/select-components/MultiValueLabel/index.js.map +1 -1
  154. package/dist/fields/Relationship/select-components/MultiValueLabel/index.scss +4 -0
  155. package/dist/fields/Relationship/select-components/SingleValue/index.d.ts.map +1 -1
  156. package/dist/fields/Relationship/select-components/SingleValue/index.js +5 -0
  157. package/dist/fields/Relationship/select-components/SingleValue/index.js.map +1 -1
  158. package/dist/fields/Relationship/select-components/SingleValue/index.scss +2 -2
  159. package/dist/fields/Select/index.d.ts.map +1 -1
  160. package/dist/fields/Select/index.js +4 -4
  161. package/dist/fields/Select/index.js.map +1 -1
  162. package/dist/fields/Tabs/index.d.ts.map +1 -1
  163. package/dist/fields/Tabs/index.js +1 -1
  164. package/dist/fields/Tabs/index.js.map +1 -1
  165. package/dist/fields/Text/Input.d.ts.map +1 -1
  166. package/dist/fields/Text/Input.js +3 -3
  167. package/dist/fields/Text/Input.js.map +1 -1
  168. package/dist/fields/Text/index.d.ts.map +1 -1
  169. package/dist/fields/Text/index.js +1 -1
  170. package/dist/fields/Text/index.js.map +1 -1
  171. package/dist/fields/Textarea/Input.d.ts.map +1 -1
  172. package/dist/fields/Textarea/Input.js +3 -3
  173. package/dist/fields/Textarea/Input.js.map +1 -1
  174. package/dist/fields/Textarea/index.d.ts.map +1 -1
  175. package/dist/fields/Textarea/index.js +1 -1
  176. package/dist/fields/Textarea/index.js.map +1 -1
  177. package/dist/fields/Upload/Input.d.ts.map +1 -1
  178. package/dist/fields/Upload/Input.js +3 -3
  179. package/dist/fields/Upload/Input.js.map +1 -1
  180. package/dist/fields/Upload/index.d.ts.map +1 -1
  181. package/dist/fields/Upload/index.js +2 -2
  182. package/dist/fields/Upload/index.js.map +1 -1
  183. package/dist/forms/FieldLabel/index.d.ts.map +1 -1
  184. package/dist/forms/FieldLabel/index.js +1 -1
  185. package/dist/forms/FieldLabel/index.js.map +1 -1
  186. package/dist/forms/Form/index.js.map +1 -1
  187. package/dist/forms/Form/mergeErrorPaths.js +1 -1
  188. package/dist/forms/Form/mergeErrorPaths.js.map +1 -1
  189. package/dist/forms/Submit/index.d.ts.map +1 -1
  190. package/dist/forms/Submit/index.js.map +1 -1
  191. package/dist/graphics/Account/index.d.ts +0 -1
  192. package/dist/graphics/Account/index.d.ts.map +1 -1
  193. package/dist/graphics/Account/index.js +2 -11
  194. package/dist/graphics/Account/index.js.map +1 -1
  195. package/dist/graphics/Icon/index.d.ts +3 -1
  196. package/dist/graphics/Icon/index.d.ts.map +1 -1
  197. package/dist/graphics/Icon/index.js +10 -36
  198. package/dist/graphics/Icon/index.js.map +1 -1
  199. package/dist/graphics/Logo/index.d.ts +2 -4
  200. package/dist/graphics/Logo/index.d.ts.map +1 -1
  201. package/dist/graphics/Logo/index.js +10 -2
  202. package/dist/graphics/Logo/index.js.map +1 -1
  203. package/dist/icons/Edit/index.d.ts +3 -1
  204. package/dist/icons/Edit/index.d.ts.map +1 -1
  205. package/dist/icons/Edit/index.js +5 -2
  206. package/dist/icons/Edit/index.js.map +1 -1
  207. package/dist/providers/Auth/index.d.ts.map +1 -1
  208. package/dist/providers/Auth/index.js +5 -4
  209. package/dist/providers/Auth/index.js.map +1 -1
  210. package/dist/providers/ComponentMap/buildComponentMap/actions.d.ts +3 -2
  211. package/dist/providers/ComponentMap/buildComponentMap/actions.d.ts.map +1 -1
  212. package/dist/providers/ComponentMap/buildComponentMap/actions.js.map +1 -1
  213. package/dist/providers/ComponentMap/buildComponentMap/collections.d.ts +3 -2
  214. package/dist/providers/ComponentMap/buildComponentMap/collections.d.ts.map +1 -1
  215. package/dist/providers/ComponentMap/buildComponentMap/collections.js +4 -3
  216. package/dist/providers/ComponentMap/buildComponentMap/collections.js.map +1 -1
  217. package/dist/providers/ComponentMap/buildComponentMap/fields.d.ts +3 -2
  218. package/dist/providers/ComponentMap/buildComponentMap/fields.d.ts.map +1 -1
  219. package/dist/providers/ComponentMap/buildComponentMap/fields.js +1 -1
  220. package/dist/providers/ComponentMap/buildComponentMap/fields.js.map +1 -1
  221. package/dist/providers/ComponentMap/buildComponentMap/globals.d.ts +3 -2
  222. package/dist/providers/ComponentMap/buildComponentMap/globals.d.ts.map +1 -1
  223. package/dist/providers/ComponentMap/buildComponentMap/globals.js +3 -2
  224. package/dist/providers/ComponentMap/buildComponentMap/globals.js.map +1 -1
  225. package/dist/providers/ComponentMap/buildComponentMap/index.d.ts +4 -4
  226. package/dist/providers/ComponentMap/buildComponentMap/index.d.ts.map +1 -1
  227. package/dist/providers/ComponentMap/buildComponentMap/index.js +6 -2
  228. package/dist/providers/ComponentMap/buildComponentMap/index.js.map +1 -1
  229. package/dist/providers/ComponentMap/buildComponentMap/types.d.ts +1 -1
  230. package/dist/providers/ComponentMap/buildComponentMap/types.d.ts.map +1 -1
  231. package/dist/providers/ComponentMap/buildComponentMap/types.js.map +1 -1
  232. package/dist/providers/DocumentInfo/index.d.ts.map +1 -1
  233. package/dist/providers/DocumentInfo/index.js +44 -31
  234. package/dist/providers/DocumentInfo/index.js.map +1 -1
  235. package/dist/providers/Root/index.d.ts.map +1 -1
  236. package/dist/providers/Root/index.js +1 -1
  237. package/dist/providers/Root/index.js.map +1 -1
  238. package/dist/templates/Default/index.d.ts +4 -4
  239. package/dist/templates/Default/index.d.ts.map +1 -1
  240. package/dist/templates/Default/index.js +18 -4
  241. package/dist/templates/Default/index.js.map +1 -1
  242. package/dist/utilities/hasSavePermission.d.ts +8 -0
  243. package/dist/utilities/hasSavePermission.d.ts.map +1 -0
  244. package/dist/utilities/hasSavePermission.js +12 -0
  245. package/dist/utilities/hasSavePermission.js.map +1 -0
  246. package/dist/utilities/isEditing.d.ts +6 -0
  247. package/dist/utilities/isEditing.d.ts.map +1 -0
  248. package/dist/utilities/isEditing.js +3 -0
  249. package/dist/utilities/isEditing.js.map +1 -0
  250. package/package.json +11 -11
  251. /package/dist/assets/{og-image.png → static-og-image.png} +0 -0
@@ -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 { FieldDescription } from '@payloadcms/ui/forms/FieldDescription'\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 { 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 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","FieldDescription","toKebabCase","React","useCallback","useEffect","useState","useCollapsible","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","key","parentPath","setIsActive","Fragment","label","fieldMap","margins","Tabs"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAIA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,SAASC,gBAAgB,QAAQ,wCAAuC;AACxE,SAASC,WAAW,QAAQ,oBAAmB;AAC/C,OAAOC,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAK/D,SAASC,cAAc,QAAQ,yCAAwC;AACvE,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,YAAs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BAAgBY,KAAK,GACjB9D,eAAekD,gBAAgBY,KAAK,EAAExB,QACtCY,eAAe,CAAC,OAAO;QAE7Bc,SAAQ;QACRvC,MAAM,CAAC,EAAEA,OAAO,CAAC,EAAEA,KAAK,CAAC,CAAC,GAAG,GAAG,EAAEyB,gBAAgB9B,IAAI,GAAG,CAAC,EAAE8B,gBAAgB9B,IAAI,CAAC,CAAC,GAAG,GAAG,CAAC;QACzFY,aACE,UAAUkB,mBAAmBlB,aAAac,QAAQ,CAACI,gBAAgB9B,IAAI,CAAC,EAAE0B,SACtEd,aAAac,QAAQ,CAACI,gBAAgB9B,IAAI,CAAC,EAAE0B,SAC7Cd,aAAac;QAEnBnB,UAAUA;QACVO,YAAY,CAAC,EAAEA,aAAa,CAAC,EAAEA,WAAW,CAAC,GAAG,GAAG,EAAEgB,gBAAgB9B,IAAI,GAAG,CAAC,CAAC,EAAE8B,gBAAgB9B,IAAI,CAAC,CAAC,GAAG,GAAG,CAAC;;AAS7H;AAEA,OAAO,MAAM6C,OAAOvD,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 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","key","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,UA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,CAAC,EAAEA,KAAK,CAAC,CAAC,GAAG,GAAG,EAAEyB,gBAAgB9B,IAAI,GAAG,CAAC,EAAE8B,gBAAgB9B,IAAI,CAAC,CAAC,GAAG,GAAG,CAAC;QACzFY,aACE,UAAUkB,mBAAmBlB,aAAac,QAAQ,CAACI,gBAAgB9B,IAAI,CAAC,EAAE0B,SACtEd,aAAac,QAAQ,CAACI,gBAAgB9B,IAAI,CAAC,EAAE0B,SAC7Cd,aAAac;QAEnBnB,UAAUA;QACVO,YAAY,CAAC,EAAEA,aAAa,CAAC,EAAEA,WAAW,CAAC,GAAG,GAAG,EAAEgB,gBAAgB9B,IAAI,GAAG,CAAC,CAAC,EAAE8B,gBAAgB9B,IAAI,CAAC,CAAC,GAAG,GAAG,CAAC;;AAS7H;AAEA,OAAO,MAAM6C,OAAOvD,cAAcQ,WAAU"}
@@ -1 +1 @@
1
- {"version":3,"file":"Input.d.ts","sourceRoot":"","sources":["../../../src/fields/Text/Input.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAKhD,OAAO,cAAc,CAAA;AAErB,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAyG9C,CAAA"}
1
+ {"version":3,"file":"Input.d.ts","sourceRoot":"","sources":["../../../src/fields/Text/Input.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAQhD,OAAO,cAAc,CAAA;AAErB,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAyG9C,CAAA"}
@@ -1,10 +1,10 @@
1
1
  'use client';
2
2
  import { getTranslation } from '@payloadcms/translations';
3
- import { FieldDescription } from '@payloadcms/ui/forms/FieldDescription';
4
- import { FieldError } from '@payloadcms/ui/forms/FieldError';
5
- import { FieldLabel } from '@payloadcms/ui/forms/FieldLabel';
6
3
  import React from 'react';
7
4
  import { ReactSelect } from '../../elements/ReactSelect/index.js';
5
+ import { FieldDescription } from '../../forms/FieldDescription/index.js';
6
+ import { FieldError } from '../../forms/FieldError/index.js';
7
+ import { FieldLabel } from '../../forms/FieldLabel/index.js';
8
8
  import { useTranslation } from '../../providers/Translation/index.js';
9
9
  import { fieldBaseClass } from '../shared/index.js';
10
10
  export const TextInput = (props)=>{
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/fields/Text/Input.tsx"],"sourcesContent":["'use client'\nimport { getTranslation } from '@payloadcms/translations'\nimport { FieldDescription } from '@payloadcms/ui/forms/FieldDescription'\nimport { FieldError } from '@payloadcms/ui/forms/FieldError'\nimport { FieldLabel } from '@payloadcms/ui/forms/FieldLabel'\nimport React from 'react'\n\nimport type { TextInputProps } from './types.js'\n\nimport { ReactSelect } from '../../elements/ReactSelect/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { fieldBaseClass } from '../shared/index.js'\nimport './index.scss'\n\nexport const TextInput: React.FC<TextInputProps> = (props) => {\n const {\n AfterInput,\n BeforeInput,\n CustomDescription,\n CustomError,\n CustomLabel,\n className,\n descriptionProps,\n errorProps,\n hasMany,\n inputRef,\n label,\n labelProps,\n maxRows,\n onChange,\n onKeyDown,\n path,\n placeholder,\n readOnly,\n required,\n rtl,\n showError,\n style,\n value,\n valueToRender,\n width,\n } = props\n\n const { i18n, t } = useTranslation()\n\n return (\n <div\n className={[\n fieldBaseClass,\n 'text',\n className,\n showError && 'error',\n readOnly && 'read-only',\n hasMany && 'has-many',\n ]\n .filter(Boolean)\n .join(' ')}\n style={{\n ...style,\n width,\n }}\n >\n <FieldError CustomError={CustomError} path={path} {...(errorProps || {})} />\n <FieldLabel\n CustomLabel={CustomLabel}\n label={label}\n required={required}\n {...(labelProps || {})}\n />\n {hasMany ? (\n <ReactSelect\n className={`field-${path.replace(/\\./g, '__')}`}\n disabled={readOnly}\n // prevent adding additional options if maxRows is reached\n filterOption={() =>\n !maxRows ? true : !(Array.isArray(value) && maxRows && value.length >= maxRows)\n }\n isClearable\n isCreatable\n isMulti\n isSortable\n noOptionsMessage={() => {\n const isOverHasMany = Array.isArray(value) && value.length >= maxRows\n if (isOverHasMany) {\n return t('validation:limitReached', { max: maxRows, value: value.length + 1 })\n }\n return null\n }}\n onChange={onChange}\n options={[]}\n placeholder={t('general:enterAValue')}\n showError={showError}\n value={valueToRender}\n />\n ) : (\n <div>\n {BeforeInput}\n <input\n data-rtl={rtl}\n disabled={readOnly}\n id={`field-${path?.replace(/\\./g, '__')}`}\n name={path}\n onChange={onChange}\n onKeyDown={onKeyDown}\n placeholder={getTranslation(placeholder, i18n)}\n ref={inputRef}\n type=\"text\"\n value={value || ''}\n />\n {AfterInput}\n </div>\n )}\n {CustomDescription !== undefined ? (\n CustomDescription\n ) : (\n <FieldDescription {...(descriptionProps || {})} />\n )}\n </div>\n )\n}\n"],"names":["getTranslation","FieldDescription","FieldError","FieldLabel","React","ReactSelect","useTranslation","fieldBaseClass","TextInput","props","AfterInput","BeforeInput","CustomDescription","CustomError","CustomLabel","className","descriptionProps","errorProps","hasMany","inputRef","label","labelProps","maxRows","onChange","onKeyDown","path","placeholder","readOnly","required","rtl","showError","style","value","valueToRender","width","i18n","t","div","filter","Boolean","join","replace","disabled","filterOption","Array","isArray","length","isClearable","isCreatable","isMulti","isSortable","noOptionsMessage","isOverHasMany","max","options","input","data-rtl","id","name","ref","type","undefined"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AACA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,SAASC,gBAAgB,QAAQ,wCAAuC;AACxE,SAASC,UAAU,QAAQ,kCAAiC;AAC5D,SAASC,UAAU,QAAQ,kCAAiC;AAC5D,OAAOC,WAAW,QAAO;AAIzB,SAASC,WAAW,QAAQ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8B,eAAe;gBACjB,OAAOhB,EAAE,2BAA2B;oBAAEiB,KAAK/B;oBAASU,OAAOA,MAAMc,MAAM,GAAG;gBAAE;YAC9E;YACA,OAAO;QACT;QACAvB,UAAUA;QACV+B,SAAS,EAAE;QACX5B,aAAaU,EAAE;QACfN,WAAWA;QACXE,OAAOC;uBAGT,oBAACI,aACE1B,2BACD,oBAAC4C;QACCC,YAAU3B;QACVa,UAAUf;QACV8B,IAAI,CAAC,MAAM,EAAEhC,MAAMgB,QAAQ,OAAO,MAAM,CAAC;QACzCiB,MAAMjC;QACNF,UAAUA;QACVC,WAAWA;QACXE,aAAa1B,eAAe0B,aAAaS;QACzCwB,KAAKxC;QACLyC,MAAK;QACL5B,OAAOA,SAAS;QAEjBtB,aAGJE,sBAAsBiD,YACrBjD,kCAEA,oBAACX,kBAAsBe,oBAAoB,CAAC;AAIpD,EAAC"}
1
+ {"version":3,"sources":["../../../src/fields/Text/Input.tsx"],"sourcesContent":["'use client'\nimport { getTranslation } from '@payloadcms/translations'\nimport React from 'react'\n\nimport type { TextInputProps } from './types.js'\n\nimport { ReactSelect } from '../../elements/ReactSelect/index.js'\nimport { FieldDescription } from '../../forms/FieldDescription/index.js'\nimport { FieldError } from '../../forms/FieldError/index.js'\nimport { FieldLabel } from '../../forms/FieldLabel/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { fieldBaseClass } from '../shared/index.js'\nimport './index.scss'\n\nexport const TextInput: React.FC<TextInputProps> = (props) => {\n const {\n AfterInput,\n BeforeInput,\n CustomDescription,\n CustomError,\n CustomLabel,\n className,\n descriptionProps,\n errorProps,\n hasMany,\n inputRef,\n label,\n labelProps,\n maxRows,\n onChange,\n onKeyDown,\n path,\n placeholder,\n readOnly,\n required,\n rtl,\n showError,\n style,\n value,\n valueToRender,\n width,\n } = props\n\n const { i18n, t } = useTranslation()\n\n return (\n <div\n className={[\n fieldBaseClass,\n 'text',\n className,\n showError && 'error',\n readOnly && 'read-only',\n hasMany && 'has-many',\n ]\n .filter(Boolean)\n .join(' ')}\n style={{\n ...style,\n width,\n }}\n >\n <FieldError CustomError={CustomError} path={path} {...(errorProps || {})} />\n <FieldLabel\n CustomLabel={CustomLabel}\n label={label}\n required={required}\n {...(labelProps || {})}\n />\n {hasMany ? (\n <ReactSelect\n className={`field-${path.replace(/\\./g, '__')}`}\n disabled={readOnly}\n // prevent adding additional options if maxRows is reached\n filterOption={() =>\n !maxRows ? true : !(Array.isArray(value) && maxRows && value.length >= maxRows)\n }\n isClearable\n isCreatable\n isMulti\n isSortable\n noOptionsMessage={() => {\n const isOverHasMany = Array.isArray(value) && value.length >= maxRows\n if (isOverHasMany) {\n return t('validation:limitReached', { max: maxRows, value: value.length + 1 })\n }\n return null\n }}\n onChange={onChange}\n options={[]}\n placeholder={t('general:enterAValue')}\n showError={showError}\n value={valueToRender}\n />\n ) : (\n <div>\n {BeforeInput}\n <input\n data-rtl={rtl}\n disabled={readOnly}\n id={`field-${path?.replace(/\\./g, '__')}`}\n name={path}\n onChange={onChange}\n onKeyDown={onKeyDown}\n placeholder={getTranslation(placeholder, i18n)}\n ref={inputRef}\n type=\"text\"\n value={value || ''}\n />\n {AfterInput}\n </div>\n )}\n {CustomDescription !== undefined ? (\n CustomDescription\n ) : (\n <FieldDescription {...(descriptionProps || {})} />\n )}\n </div>\n )\n}\n"],"names":["getTranslation","React","ReactSelect","FieldDescription","FieldError","FieldLabel","useTranslation","fieldBaseClass","TextInput","props","AfterInput","BeforeInput","CustomDescription","CustomError","CustomLabel","className","descriptionProps","errorProps","hasMany","inputRef","label","labelProps","maxRows","onChange","onKeyDown","path","placeholder","readOnly","required","rtl","showError","style","value","valueToRender","width","i18n","t","div","filter","Boolean","join","replace","disabled","filterOption","Array","isArray","length","isClearable","isCreatable","isMulti","isSortable","noOptionsMessage","isOverHasMany","max","options","input","data-rtl","id","name","ref","type","undefined"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AEsB,CAAAA,MAAMC,OAAO,CAACb,UAAUV,WAAWU,MAAMc,MAAM,IAAIxB,OAAM;QAE/EyB,aAAAA;QACAC,aAAAA;QACAC,SAAAA;QACAC,YAAAA;QACAC,kBAAkB;YAChB,MAAMC,gBAAgBR,MAAMC,OAAO,CAACb,UAAUA,MAAMc,MAAM,IAAIxB;YAC9D,IAAI8B,eAAe;gBACjB,OAAOhB,EAAE,2BAA2B;oBAAEiB,KAAK/B;oBAASU,OAAOA,MAAMc,MAAM,GAAG;gBAAE;YAC9E;YACA,OAAO;QACT;QACAvB,UAAUA;QACV+B,SAAS,EAAE;QACX5B,aAAaU,EAAE;QACfN,WAAWA;QACXE,OAAOC;uBAGT,oBAACI,aACE1B,2BACD,oBAAC4C;QACCC,YAAU3B;QACVa,UAAUf;QACV8B,IAAI,CAAC,MAAM,EAAEhC,MAAMgB,QAAQ,OAAO,MAAM,CAAC;QACzCiB,MAAMjC;QACNF,UAAUA;QACVC,WAAWA;QACXE,aAAa1B,eAAe0B,aAAaS;QACzCwB,KAAKxC;QACLyC,MAAK;QACL5B,OAAOA,SAAS;QAEjBtB,aAGJE,sBAAsBiD,YACrBjD,kCAEA,oBAACT,kBAAsBa,oBAAoB,CAAC;AAIpD,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/Text/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAA2C,MAAM,OAAO,CAAA;AAG/D,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAOhE,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AACtC,OAAO,cAAc,CAAA;AAErB,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,cAAc,EAAE,CAAA;AAyIpD,eAAO,MAAM,IAAI,0BAA2B,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/Text/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAA2C,MAAM,OAAO,CAAA;AAG/D,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAQhE,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AACtC,OAAO,cAAc,CAAA;AAErB,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,cAAc,EAAE,CAAA;AAyIpD,eAAO,MAAM,IAAI,0BAA2B,CAAA"}
@@ -1,6 +1,6 @@
1
1
  'use client';
2
- import { useFieldProps } from '@payloadcms/ui/forms/FieldPropsProvider';
3
2
  import React, { useCallback, useEffect, useState } from 'react';
3
+ import { useFieldProps } from '../../forms/FieldPropsProvider/index.js';
4
4
  import { useField } from '../../forms/useField/index.js';
5
5
  import { withCondition } from '../../forms/withCondition/index.js';
6
6
  import { useConfig } from '../../providers/Config/index.js';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/fields/Text/index.tsx"],"sourcesContent":["'use client'\nimport type { ClientValidate } from 'payload/types'\nimport type {} from 'payload/types'\n\nimport { useFieldProps } from '@payloadcms/ui/forms/FieldPropsProvider'\nimport React, { useCallback, useEffect, useState } from 'react'\n\nimport type { Option } from '../../elements/ReactSelect/types.js'\nimport type { TextFieldProps, TextInputProps } from './types.js'\n\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { useConfig } from '../../providers/Config/index.js'\nimport { useLocale } from '../../providers/Locale/index.js'\nimport { isFieldRTL } from '../shared/index.js'\nimport { TextInput } from './Input.js'\nimport './index.scss'\n\nexport { TextFieldProps, TextInput, TextInputProps }\n\nconst TextField: React.FC<TextFieldProps> = (props) => {\n const {\n name,\n AfterInput,\n BeforeInput,\n CustomDescription,\n CustomError,\n CustomLabel,\n className,\n descriptionProps,\n errorProps,\n hasMany,\n inputRef,\n label,\n labelProps,\n localized,\n maxLength,\n maxRows,\n minLength,\n minRows,\n path: pathFromProps,\n placeholder,\n readOnly: readOnlyFromProps,\n required,\n rtl,\n style,\n validate,\n width,\n } = props\n\n const locale = useLocale()\n\n const { localization: localizationConfig } = useConfig()\n\n const memoizedValidate: ClientValidate = useCallback(\n (value, options) => {\n if (typeof validate === 'function')\n return validate(value, { ...options, maxLength, minLength, required })\n },\n [validate, minLength, maxLength, required],\n )\n\n const { path: pathFromContext, readOnly: readOnlyFromContext } = useFieldProps()\n const readOnly = readOnlyFromProps || readOnlyFromContext\n\n const { formProcessing, path, setValue, showError, value } = useField({\n path: pathFromContext || pathFromProps || name,\n validate: memoizedValidate,\n })\n\n const renderRTL = isFieldRTL({\n fieldLocalized: localized,\n fieldRTL: rtl,\n locale,\n localizationConfig: localizationConfig || undefined,\n })\n\n const [valueToRender, setValueToRender] = useState<\n { id: string; label: string; value: { value: number } }[]\n >([]) // Only for hasMany\n\n const handleHasManyChange = useCallback(\n (selectedOption) => {\n if (!readOnly) {\n let newValue\n if (!selectedOption) {\n newValue = []\n } else if (Array.isArray(selectedOption)) {\n newValue = selectedOption.map((option) => option.value?.value || option.value)\n } else {\n newValue = [selectedOption.value?.value || selectedOption.value]\n }\n\n setValue(newValue)\n }\n },\n [readOnly, setValue],\n )\n\n // useEffect update valueToRender:\n useEffect(() => {\n if (hasMany && Array.isArray(value)) {\n setValueToRender(\n value.map((val, index) => {\n return {\n id: `${val}${index}`, // append index to avoid duplicate keys but allow duplicate numbers\n label: `${val}`,\n value: {\n // React-select automatically uses \"label-value\" as a key, so we will get that react duplicate key warning if we just pass in the value as multiple values can be the same. So we need to append the index to the toString() of the value to avoid that warning, as it uses that as the key.\n toString: () => `${val}${index}`,\n value: val?.value || val,\n },\n }\n }),\n )\n }\n }, [value, hasMany])\n\n return (\n <TextInput\n AfterInput={AfterInput}\n BeforeInput={BeforeInput}\n CustomDescription={CustomDescription}\n CustomError={CustomError}\n CustomLabel={CustomLabel}\n className={className}\n descriptionProps={descriptionProps}\n errorProps={errorProps}\n hasMany={hasMany}\n inputRef={inputRef}\n label={label}\n labelProps={labelProps}\n maxRows={maxRows}\n minRows={minRows}\n onChange={\n hasMany\n ? handleHasManyChange\n : (e) => {\n setValue(e.target.value)\n }\n }\n path={path}\n placeholder={placeholder}\n readOnly={formProcessing || readOnly}\n required={required}\n rtl={renderRTL}\n showError={showError}\n style={style}\n value={(value as string) || ''}\n valueToRender={valueToRender as Option[]}\n width={width}\n />\n )\n}\n\nexport const Text = withCondition(TextField)\n"],"names":["useFieldProps","React","useCallback","useEffect","useState","useField","withCondition","useConfig","useLocale","isFieldRTL","TextInput","TextField","props","name","AfterInput","BeforeInput","CustomDescription","CustomError","CustomLabel","className","descriptionProps","errorProps","hasMany","inputRef","label","labelProps","localized","maxLength","maxRows","minLength","minRows","path","pathFromProps","placeholder","readOnly","readOnlyFromProps","required","rtl","style","validate","width","locale","localization","localizationConfig","memoizedValidate","value","options","pathFromContext","readOnlyFromContext","formProcessing","setValue","showError","renderRTL","fieldLocalized","fieldRTL","undefined","valueToRender","setValueToRender","handleHasManyChange","selectedOption","newValue","Array","isArray","map","option","val","index","id","toString","onChange","e","target","Text"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAIA,SAASA,aAAa,QAAQ,0CAAyC;AACvE,OAAOC,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAK/D,SAASC,QAAQ,QAAQ,gCAA+B;AACxD,SAASC,aAAa,QAAQ,qCAAoC;AAClE,SAASC,SAAS,QAAQ,kCAAiC;AAC3D,SAASC,SAAS,QAAQ,kCAAiC;AAC3D,SAASC,UAAU,QAAQ,qBAAoB;AAC/C,SAASC,SAAS,QAAQ,aAAY;AAGtC,SAAyBA,SAAS,GAAkB;AAEpD,MAAMC,YAAsC,CAACC;IAC3C,MAAM,EACJC,IAAI,EACJC,UAAU,EACVC,WAAW,EACXC,iBAAiB,EACjBC,WA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K,EAAEA,SAASmB,OAAOnB,KAAK;YAC/E,OAAO;gBACLe,WAAW;oBAACD,eAAed,KAAK,EAAEA,SAASc,eAAed,KAAK;iBAAC;YAClE;YAEAK,SAASU;QACX;IACF,GACA;QAAC1B;QAAUgB;KAAS;IAGtB,kCAAkC;IAClC/C,UAAU;QACR,IAAImB,WAAWuC,MAAMC,OAAO,CAACjB,QAAQ;YACnCY,iBACEZ,MAAMkB,GAAG,CAAC,CAACE,KAAKC;gBACd,OAAO;oBACLC,IAAI,CAAC,EAAEF,IAAI,EAAEC,MAAM,CAAC;oBACpB1C,OAAO,CAAC,EAAEyC,IAAI,CAAC;oBACfpB,OAAO;wBACL,4RAA4R;wBAC5RuB,UAAU,IAAM,CAAC,EAAEH,IAAI,EAAEC,MAAM,CAAC;wBAChCrB,OAAOoB,KAAKpB,SAASoB;oBACvB;gBACF;YACF;QAEJ;IACF,GAAG;QAACpB;QAAOvB;KAAQ;IAEnB,qBACE,oBAACZ;QACCI,YAAYA;QACZC,aAAaA;QACbC,mBAAmBA;QACnBC,aAAaA;QACbC,aAAaA;QACbC,WAAWA;QACXC,kBAAkBA;QAClBC,YAAYA;QACZC,SAASA;QACTC,UAAUA;QACVC,OAAOA;QACPC,YAAYA;QACZG,SAASA;QACTE,SAASA;QACTuC,UACE/C,UACIoC,sBACA,CAACY;YACCpB,SAASoB,EAAEC,MAAM,CAAC1B,KAAK;QACzB;QAENd,MAAMA;QACNE,aAAaA;QACbC,UAAUe,kBAAkBf;QAC5BE,UAAUA;QACVC,KAAKe;QACLD,WAAWA;QACXb,OAAOA;QACPO,OAAO,AAACA,SAAoB;QAC5BW,eAAeA;QACfhB,OAAOA;;AAGb;AAEA,OAAO,MAAMgC,OAAOlE,cAAcK,WAAU"}
1
+ {"version":3,"sources":["../../../src/fields/Text/index.tsx"],"sourcesContent":["'use client'\nimport type { ClientValidate } from 'payload/types'\n\nimport React, { useCallback, useEffect, useState } from 'react'\n\nimport type { Option } from '../../elements/ReactSelect/types.js'\nimport type { TextFieldProps, TextInputProps } from './types.js'\n\nimport { useFieldProps } from '../../forms/FieldPropsProvider/index.js'\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { useConfig } from '../../providers/Config/index.js'\nimport { useLocale } from '../../providers/Locale/index.js'\nimport { isFieldRTL } from '../shared/index.js'\nimport { TextInput } from './Input.js'\nimport './index.scss'\n\nexport { TextFieldProps, TextInput, TextInputProps }\n\nconst TextField: React.FC<TextFieldProps> = (props) => {\n const {\n name,\n AfterInput,\n BeforeInput,\n CustomDescription,\n CustomError,\n CustomLabel,\n className,\n descriptionProps,\n errorProps,\n hasMany,\n inputRef,\n label,\n labelProps,\n localized,\n maxLength,\n maxRows,\n minLength,\n minRows,\n path: pathFromProps,\n placeholder,\n readOnly: readOnlyFromProps,\n required,\n rtl,\n style,\n validate,\n width,\n } = props\n\n const locale = useLocale()\n\n const { localization: localizationConfig } = useConfig()\n\n const memoizedValidate: ClientValidate = useCallback(\n (value, options) => {\n if (typeof validate === 'function')\n return validate(value, { ...options, maxLength, minLength, required })\n },\n [validate, minLength, maxLength, required],\n )\n\n const { path: pathFromContext, readOnly: readOnlyFromContext } = useFieldProps()\n const readOnly = readOnlyFromProps || readOnlyFromContext\n\n const { formProcessing, path, setValue, showError, value } = useField({\n path: pathFromContext || pathFromProps || name,\n validate: memoizedValidate,\n })\n\n const renderRTL = isFieldRTL({\n fieldLocalized: localized,\n fieldRTL: rtl,\n locale,\n localizationConfig: localizationConfig || undefined,\n })\n\n const [valueToRender, setValueToRender] = useState<\n { id: string; label: string; value: { value: number } }[]\n >([]) // Only for hasMany\n\n const handleHasManyChange = useCallback(\n (selectedOption) => {\n if (!readOnly) {\n let newValue\n if (!selectedOption) {\n newValue = []\n } else if (Array.isArray(selectedOption)) {\n newValue = selectedOption.map((option) => option.value?.value || option.value)\n } else {\n newValue = [selectedOption.value?.value || selectedOption.value]\n }\n\n setValue(newValue)\n }\n },\n [readOnly, setValue],\n )\n\n // useEffect update valueToRender:\n useEffect(() => {\n if (hasMany && Array.isArray(value)) {\n setValueToRender(\n value.map((val, index) => {\n return {\n id: `${val}${index}`, // append index to avoid duplicate keys but allow duplicate numbers\n label: `${val}`,\n value: {\n // React-select automatically uses \"label-value\" as a key, so we will get that react duplicate key warning if we just pass in the value as multiple values can be the same. So we need to append the index to the toString() of the value to avoid that warning, as it uses that as the key.\n toString: () => `${val}${index}`,\n value: val?.value || val,\n },\n }\n }),\n )\n }\n }, [value, hasMany])\n\n return (\n <TextInput\n AfterInput={AfterInput}\n BeforeInput={BeforeInput}\n CustomDescription={CustomDescription}\n CustomError={CustomError}\n CustomLabel={CustomLabel}\n className={className}\n descriptionProps={descriptionProps}\n errorProps={errorProps}\n hasMany={hasMany}\n inputRef={inputRef}\n label={label}\n labelProps={labelProps}\n maxRows={maxRows}\n minRows={minRows}\n onChange={\n hasMany\n ? handleHasManyChange\n : (e) => {\n setValue(e.target.value)\n }\n }\n path={path}\n placeholder={placeholder}\n readOnly={formProcessing || readOnly}\n required={required}\n rtl={renderRTL}\n showError={showError}\n style={style}\n value={(value as string) || ''}\n valueToRender={valueToRender as Option[]}\n width={width}\n />\n )\n}\n\nexport const Text = withCondition(TextField)\n"],"names":["React","useCallback","useEffect","useState","useFieldProps","useField","withCondition","useConfig","useLocale","isFieldRTL","TextInput","TextField","props","name","AfterInput","BeforeInput","CustomDescription","CustomError","CustomLabel","className","descriptionProps","errorProps","hasMany","inputRef","label","labelProps","localized","maxLength","maxRows","minLength","minRows","path","pathFromProps","placeholder","readOnly","readOnlyFromProps","required","rtl","style","validate","width","locale","localization","localizationConfig","memoizedValidate","value","options","pathFromContext","readOnlyFromContext","formProcessing","setValue","showError","renderRTL","fieldLocalized","fieldRTL","undefined","valueToRender","setValueToRender","handleHasManyChange","selectedOption","newValue","Array","isArray","map","option","val","index","id","toString","onChange","e","target","Text"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AClBC,YAAYA;QACZC,SAASA;QACTC,UAAUA;QACVC,OAAOA;QACPC,YAAYA;QACZG,SAASA;QACTE,SAASA;QACTuC,UACE/C,UACIoC,sBACA,CAACY;YACCpB,SAASoB,EAAEC,MAAM,CAAC1B,KAAK;QACzB;QAENd,MAAMA;QACNE,aAAaA;QACbC,UAAUe,kBAAkBf;QAC5BE,UAAUA;QACVC,KAAKe;QACLD,WAAWA;QACXb,OAAOA;QACPO,OAAO,AAACA,SAAoB;QAC5BW,eAAeA;QACfhB,OAAOA;;AAGb;AAEA,OAAO,MAAMgC,OAAOlE,cAAcK,WAAU"}
@@ -1 +1 @@
1
- {"version":3,"file":"Input.d.ts","sourceRoot":"","sources":["../../../src/fields/Textarea/Input.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAIpD,OAAO,cAAc,CAAA;AAErB,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CA2EtD,CAAA"}
1
+ {"version":3,"file":"Input.d.ts","sourceRoot":"","sources":["../../../src/fields/Textarea/Input.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAOpD,OAAO,cAAc,CAAA;AAErB,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CA2EtD,CAAA"}
@@ -1,9 +1,9 @@
1
1
  'use client';
2
2
  import { getTranslation } from '@payloadcms/translations';
3
- import { FieldDescription } from '@payloadcms/ui/forms/FieldDescription';
4
- import { FieldError } from '@payloadcms/ui/forms/FieldError';
5
- import { FieldLabel } from '@payloadcms/ui/forms/FieldLabel';
6
3
  import React from 'react';
4
+ import { FieldDescription } from '../../forms/FieldDescription/index.js';
5
+ import { FieldError } from '../../forms/FieldError/index.js';
6
+ import { FieldLabel } from '../../forms/FieldLabel/index.js';
7
7
  import { useTranslation } from '../../providers/Translation/index.js';
8
8
  import { fieldBaseClass } from '../shared/index.js';
9
9
  export const TextareaInput = (props)=>{
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/fields/Textarea/Input.tsx"],"sourcesContent":["'use client'\nimport { getTranslation } from '@payloadcms/translations'\nimport { FieldDescription } from '@payloadcms/ui/forms/FieldDescription'\nimport { FieldError } from '@payloadcms/ui/forms/FieldError'\nimport { FieldLabel } from '@payloadcms/ui/forms/FieldLabel'\nimport React from 'react'\n\nimport type { TextAreaInputProps } from './types.js'\n\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { fieldBaseClass } from '../shared/index.js'\nimport './index.scss'\n\nexport const TextareaInput: React.FC<TextAreaInputProps> = (props) => {\n const {\n AfterInput,\n BeforeInput,\n CustomDescription,\n CustomError,\n CustomLabel,\n className,\n descriptionProps,\n errorProps,\n label,\n labelProps,\n onChange,\n path,\n placeholder,\n readOnly,\n required,\n rows,\n rtl,\n showError,\n style,\n value,\n width,\n } = props\n\n const { i18n } = useTranslation()\n\n return (\n <div\n className={[\n fieldBaseClass,\n 'textarea',\n className,\n showError && 'error',\n readOnly && 'read-only',\n ]\n .filter(Boolean)\n .join(' ')}\n style={{\n ...style,\n width,\n }}\n >\n <FieldError CustomError={CustomError} path={path} {...(errorProps || {})} />\n <FieldLabel\n CustomLabel={CustomLabel}\n label={label}\n required={required}\n {...(labelProps || {})}\n />\n {BeforeInput}\n <label className=\"textarea-outer\" htmlFor={`field-${path.replace(/\\./g, '__')}`}>\n <div className=\"textarea-inner\">\n <div className=\"textarea-clone\" data-value={value || placeholder || ''} />\n <textarea\n className=\"textarea-element\"\n data-rtl={rtl}\n disabled={readOnly}\n id={`field-${path.replace(/\\./g, '__')}`}\n name={path}\n onChange={onChange}\n placeholder={getTranslation(placeholder, i18n)}\n rows={rows}\n value={value || ''}\n />\n </div>\n </label>\n {AfterInput}\n {CustomDescription !== undefined ? (\n CustomDescription\n ) : (\n <FieldDescription {...(descriptionProps || {})} />\n )}\n </div>\n )\n}\n"],"names":["getTranslation","FieldDescription","FieldError","FieldLabel","React","useTranslation","fieldBaseClass","TextareaInput","props","AfterInput","BeforeInput","CustomDescription","CustomError","CustomLabel","className","descriptionProps","errorProps","label","labelProps","onChange","path","placeholder","readOnly","required","rows","rtl","showError","style","value","width","i18n","div","filter","Boolean","join","htmlFor","replace","data-value","textarea","data-rtl","disabled","id","name","undefined"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AACA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,SAASC,gBAAgB,QAAQ,wCAAuC;AACxE,SAASC,UAAU,QAAQ,kCAAiC;AAC5D,SAASC,UAAU,QAAQ,kCAAiC;AAC5D,OAAOC,WAAW,QAAO;AAIzB,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,cAAc,QAAQ,qBAAoB;AAGnD,OAAO,MAAMC,gBAA8C,CAACC;IAC1D,MAAM,EACJC,UAAU,EACVC,WAAW,EACXC,iBAAiB,EACjBC,WAAW,EACXC,WAAW,EACXC,SAAS,EACTC,gBAAgB,EAChBC,UAAU,EACVC,KAAK,EACLC,UAAU,EACVC,QAAQ,EACRC,IAAI,EACJC,WAAW,EACXC,QAAQ,EACRC,QAAQ,EACRC,IAAI,EACJC,GAAG,EACHC,SAAS,EACTC,KAAK,EACLC,KAAK,EACLC,KAAK,EACN,GAAGrB;IAEJ,MAAM,EAAEsB,IAAI,EAAE,GAAGzB;IAEjB,qBACE,oBAAC0B;QACCjB,WAAW;YACTR;YACA;YACAQ;YACAY,aAAa;YACbJ,YAAY;SACb,CACEU,MAAM,CAACC,SACPC,IAAI,CAAC;QACRP,OAAO;YACL,GAAGA,KAAK;YACRE;QACF;qBAEA,oBAAC3B;QAAWU,aAAaA;QAAaQ,MAAMA;QAAO,GAAIJ,cAAc,CAAC,CAAC;sBACvE,oBAACb;QACCU,aAAaA;QACbI,OAAOA;QACPM,UAAUA;QACT,GAAIL,cAAc,CAAC,CAAC;QAEtBR,2BACD,oBAACO;QAAMH,WAAU;QAAiBqB,SAAS,CAAC,MAAM,EAAEf,KAAKgB,OAAO,CAAC,OAAO,MAAM,CAAC;qBAC7E,oBAACL;QAAIjB,WAAU;qBACb,oBAACiB;QAAIjB,WAAU;QAAiBuB,cAAYT,SAASP,eAAe;sBACpE,oBAACiB;QACCxB,WAAU;QACVyB,YAAUd;QACVe,UAAUlB;QACVmB,IAAI,CAAC,MAAM,EAAErB,KAAKgB,OAAO,CAAC,OAAO,MAAM,CAAC;QACxCM,MAAMtB;QACND,UAAUA;QACVE,aAAarB,eAAeqB,aAAaS;QACzCN,MAAMA;QACNI,OAAOA,SAAS;UAIrBnB,YACAE,sBAAsBgC,YACrBhC,kCAEA,oBAACV,kBAAsBc,oBAAoB,CAAC;AAIpD,EAAC"}
1
+ {"version":3,"sources":["../../../src/fields/Textarea/Input.tsx"],"sourcesContent":["'use client'\nimport { getTranslation } from '@payloadcms/translations'\nimport React from 'react'\n\nimport type { TextAreaInputProps } from './types.js'\n\nimport { FieldDescription } from '../../forms/FieldDescription/index.js'\nimport { FieldError } from '../../forms/FieldError/index.js'\nimport { FieldLabel } from '../../forms/FieldLabel/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { fieldBaseClass } from '../shared/index.js'\nimport './index.scss'\n\nexport const TextareaInput: React.FC<TextAreaInputProps> = (props) => {\n const {\n AfterInput,\n BeforeInput,\n CustomDescription,\n CustomError,\n CustomLabel,\n className,\n descriptionProps,\n errorProps,\n label,\n labelProps,\n onChange,\n path,\n placeholder,\n readOnly,\n required,\n rows,\n rtl,\n showError,\n style,\n value,\n width,\n } = props\n\n const { i18n } = useTranslation()\n\n return (\n <div\n className={[\n fieldBaseClass,\n 'textarea',\n className,\n showError && 'error',\n readOnly && 'read-only',\n ]\n .filter(Boolean)\n .join(' ')}\n style={{\n ...style,\n width,\n }}\n >\n <FieldError CustomError={CustomError} path={path} {...(errorProps || {})} />\n <FieldLabel\n CustomLabel={CustomLabel}\n label={label}\n required={required}\n {...(labelProps || {})}\n />\n {BeforeInput}\n <label className=\"textarea-outer\" htmlFor={`field-${path.replace(/\\./g, '__')}`}>\n <div className=\"textarea-inner\">\n <div className=\"textarea-clone\" data-value={value || placeholder || ''} />\n <textarea\n className=\"textarea-element\"\n data-rtl={rtl}\n disabled={readOnly}\n id={`field-${path.replace(/\\./g, '__')}`}\n name={path}\n onChange={onChange}\n placeholder={getTranslation(placeholder, i18n)}\n rows={rows}\n value={value || ''}\n />\n </div>\n </label>\n {AfterInput}\n {CustomDescription !== undefined ? (\n CustomDescription\n ) : (\n <FieldDescription {...(descriptionProps || {})} />\n )}\n </div>\n )\n}\n"],"names":["getTranslation","React","FieldDescription","FieldError","FieldLabel","useTranslation","fieldBaseClass","TextareaInput","props","AfterInput","BeforeInput","CustomDescription","CustomError","CustomLabel","className","descriptionProps","errorProps","label","labelProps","onChange","path","placeholder","readOnly","required","rows","rtl","showError","style","value","width","i18n","div","filter","Boolean","join","htmlFor","replace","data-value","textarea","data-rtl","disabled","id","name","undefined"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AACA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,OAAOC,WAAW,QAAO;AAIzB,SAASC,gBAAgB,QAAQ,wCAAuC;AACxE,SAASC,UAAU,QAAQ,kCAAiC;AAC5D,SAASC,UAAU,QAAQ,kCAAiC;AAC5D,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,cAAc,QAAQ,qBAAoB;AAGnD,OAAO,MAAMC,gBAA8C,CAACC;IAC1D,MAAM,EACJC,UAAU,EACVC,WAAW,EACXC,iBAAiB,EACjBC,WAAW,EACXC,WAAW,EACXC,SAAS,EACTC,gBAAgB,EAChBC,UAAU,EACVC,KAAK,EACLC,UAAU,EACVC,QAAQ,EACRC,IAAI,EACJC,WAAW,EACXC,QAAQ,EACRC,QAAQ,EACRC,IAAI,EACJC,GAAG,EACHC,SAAS,EACTC,KAAK,EACLC,KAAK,EACLC,KAAK,EACN,GAAGrB;IAEJ,MAAM,EAAEsB,IAAI,EAAE,GAAGzB;IAEjB,qBACE,oBAAC0B;QACCjB,WAAW;YACTR;YACA;YACAQ;YACAY,aAAa;YACbJ,YAAY;SACb,CACEU,MAAM,CAACC,SACPC,IAAI,CAAC;QACRP,OAAO;YACL,GAAGA,KAAK;YACRE;QACF;qBAEA,oBAAC1B;QAAWS,aAAaA;QAAaQ,MAAMA;QAAO,GAAIJ,cAAc,CAAC,CAAC;sBACvE,oBAACZ;QACCS,aAAaA;QACbI,OAAOA;QACPM,UAAUA;QACT,GAAIL,cAAc,CAAC,CAAC;QAEtBR,2BACD,oBAACO;QAAMH,WAAU;QAAiBqB,SAAS,CAAC,MAAM,EAAEf,KAAKgB,OAAO,CAAC,OAAO,MAAM,CAAC;qBAC7E,oBAACL;QAAIjB,WAAU;qBACb,oBAACiB;QAAIjB,WAAU;QAAiBuB,cAAYT,SAASP,eAAe;sBACpE,oBAACiB;QACCxB,WAAU;QACVyB,YAAUd;QACVe,UAAUlB;QACVmB,IAAI,CAAC,MAAM,EAAErB,KAAKgB,OAAO,CAAC,OAAO,MAAM,CAAC;QACxCM,MAAMtB;QACND,UAAUA;QACVE,aAAarB,eAAeqB,aAAaS;QACzCN,MAAMA;QACNI,OAAOA,SAAS;UAIrBnB,YACAE,sBAAsBgC,YACrBhC,kCAEA,oBAACT,kBAAsBa,oBAAoB,CAAC;AAIpD,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/Textarea/index.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAsB,MAAM,OAAO,CAAA;AAE1C,OAAO,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAOxE,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAC1C,OAAO,cAAc,CAAA;AAErB,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,aAAa,EAAE,CAAA;AAsFhE,eAAO,MAAM,QAAQ,8BAA+B,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/Textarea/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAsB,MAAM,OAAO,CAAA;AAE1C,OAAO,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAQxE,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAC1C,OAAO,cAAc,CAAA;AAErB,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,aAAa,EAAE,CAAA;AAsFhE,eAAO,MAAM,QAAQ,8BAA+B,CAAA"}
@@ -1,7 +1,7 @@
1
1
  /* eslint-disable react/destructuring-assignment */ 'use client';
2
2
  import { getTranslation } from '@payloadcms/translations';
3
- import { useFieldProps } from '@payloadcms/ui/forms/FieldPropsProvider';
4
3
  import React, { useCallback } from 'react';
4
+ import { useFieldProps } from '../../forms/FieldPropsProvider/index.js';
5
5
  import { useField } from '../../forms/useField/index.js';
6
6
  import { withCondition } from '../../forms/withCondition/index.js';
7
7
  import { useConfig } from '../../providers/Config/index.js';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/fields/Textarea/index.tsx"],"sourcesContent":["/* eslint-disable react/destructuring-assignment */\n'use client'\nimport type { ClientValidate } from 'payload/types'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { useFieldProps } from '@payloadcms/ui/forms/FieldPropsProvider'\nimport React, { useCallback } from 'react'\n\nimport type { TextAreaInputProps, TextareaFieldProps } from './types.js'\n\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { useConfig } from '../../providers/Config/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { isFieldRTL } from '../shared/index.js'\nimport { TextareaInput } from './Input.js'\nimport './index.scss'\n\nexport { TextAreaInputProps, TextareaFieldProps, TextareaInput }\n\nconst TextareaField: React.FC<TextareaFieldProps> = (props) => {\n const {\n name,\n AfterInput,\n BeforeInput,\n CustomDescription,\n CustomError,\n CustomLabel,\n className,\n descriptionProps,\n errorProps,\n label,\n labelProps,\n locale,\n localized,\n maxLength,\n minLength,\n path: pathFromProps,\n placeholder,\n readOnly: readOnlyFromProps,\n required,\n rows,\n rtl,\n style,\n validate,\n width,\n } = props\n\n const { i18n } = useTranslation()\n\n const { localization } = useConfig()\n\n const isRTL = isFieldRTL({\n fieldLocalized: localized,\n fieldRTL: rtl,\n locale,\n localizationConfig: localization || undefined,\n })\n\n const memoizedValidate: ClientValidate = useCallback(\n (value, options) => {\n if (typeof validate === 'function')\n return validate(value, { ...options, maxLength, minLength, required })\n },\n [validate, required, maxLength, minLength],\n )\n\n const { path: pathFromContext, readOnly: readOnlyFromContext } = useFieldProps()\n const readOnly = readOnlyFromProps || readOnlyFromContext\n\n const { path, setValue, showError, value } = useField<string>({\n path: pathFromContext || pathFromProps || name,\n validate: memoizedValidate,\n })\n\n return (\n <TextareaInput\n AfterInput={AfterInput}\n BeforeInput={BeforeInput}\n CustomDescription={CustomDescription}\n CustomError={CustomError}\n CustomLabel={CustomLabel}\n className={className}\n descriptionProps={descriptionProps}\n errorProps={errorProps}\n label={label}\n labelProps={labelProps}\n onChange={(e) => {\n setValue(e.target.value)\n }}\n path={path}\n placeholder={getTranslation(placeholder, i18n)}\n readOnly={readOnly}\n required={required}\n rows={rows}\n rtl={isRTL}\n showError={showError}\n style={style}\n value={value}\n width={width}\n />\n )\n}\n\nexport const Textarea = withCondition(TextareaField)\n"],"names":["getTranslation","useFieldProps","React","useCallback","useField","withCondition","useConfig","useTranslation","isFieldRTL","TextareaInput","TextareaField","props","name","AfterInput","BeforeInput","CustomDescription","CustomError","CustomLabel","className","descriptionProps","errorProps","label","labelProps","locale","localized","maxLength","minLength","path","pathFromProps","placeholder","readOnly","readOnlyFromProps","required","rows","rtl","style","validate","width","i18n","localization","isRTL","fieldLocalized","fieldRTL","localizationConfig","undefined","memoizedValidate","value","options","pathFromContext","readOnlyFromContext","setValue","showError","onChange","e","target","Textarea"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,iDAAiD,GACjD;AAGA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,SAASC,aAAa,QAAQ,0CAAyC;AACvE,OAAOC,SAASC,WAAW,QAAQ,QAAO;AAI1C,SAASC,QAAQ,QAAQ,gCAA+B;AACxD,SAASC,aAAa,QAAQ,qCAAoC;AAClE,SAASC,SAAS,QAAQ,kCAAiC;AAC3D,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,UAAU,QAAQ,qBAAoB;AAC/C,SAASC,aAAa,QAAQ,aAAY;AAG1C,SAAiDA,aAAa,GAAE;AAEhE,MAAMC,gBAA8C,CAACC;IACnD,MAAM,EACJC,IAAI,EACJC,UAAU,EACVC,WAAW,EACXC,iBAAiB,EACjBC,WAAW,EACXC,WAAW,EACXC,SAAS,EACTC,gBAAgB,EAChBC,UAAU,EACVC,KAAK,EACLC,UAAU,EACVC,MAAM,EACNC,SAAS,EACTC,SAAS,EACTC,SAAS,EACTC,MAAMC,aAAa,EACnBC,WAAW,EACXC,UAAUC,iBAAiB,EAC3BC,QAAQ,EACRC,IAAI,EACJC,GAAG,EACHC,KAAK,EACLC,QAAQ,EACRC,KAAK,EACN,GAAG1B;IAEJ,MAAM,EAAE2B,IAAI,EAAE,GAAG/B;IAEjB,MAAM,EAAEgC,YAAY,EAAE,GAAGjC;IAEzB,MAAMkC,QAAQhC,WAAW;QACvBiC,gBAAgBjB;QAChBkB,UAAUR;QACVX;QACAoB,oBAAoBJ,gBAAgBK;IACtC;IAEA,MAAMC,mBAAmC1C,YACvC,CAAC2C,OAAOC;QACN,IAAI,OAAOX,aAAa,YACtB,OAAOA,SAASU,OAAO;YAAE,GAAGC,OAAO;YAAEtB;YAAWC;YAAWM;QAAS;IACxE,GACA;QAACI;QAAUJ;QAAUP;QAAWC;KAAU;IAG5C,MAAM,EAAEC,MAAMqB,eAAe,EAAElB,UAAUmB,mBAAmB,EAAE,GAAGhD;IACjE,MAAM6B,WAAWC,qBAAqBkB;IAEtC,MAAM,EAAEtB,IAAI,EAAEuB,QAAQ,EAAEC,SAAS,EAAEL,KAAK,EAAE,GAAG1C,SAAiB;QAC5DuB,MAAMqB,mBAAmBpB,iBAAiBhB;QAC1CwB,UAAUS;IACZ;IAEA,qBACE,oBAACpC;QACCI,YAAYA;QACZC,aAAaA;QACbC,mBAAmBA;QACnBC,aAAaA;QACbC,aAAaA;QACbC,WAAWA;QACXC,kBAAkBA;QAClBC,YAAYA;QACZC,OAAOA;QACPC,YAAYA;QACZ8B,UAAU,CAACC;YACTH,SAASG,EAAEC,MAAM,CAACR,KAAK;QACzB;QACAnB,MAAMA;QACNE,aAAa7B,eAAe6B,aAAaS;QACzCR,UAAUA;QACVE,UAAUA;QACVC,MAAMA;QACNC,KAAKM;QACLW,WAAWA;QACXhB,OAAOA;QACPW,OAAOA;QACPT,OAAOA;;AAGb;AAEA,OAAO,MAAMkB,WAAWlD,cAAcK,eAAc"}
1
+ {"version":3,"sources":["../../../src/fields/Textarea/index.tsx"],"sourcesContent":["/* eslint-disable react/destructuring-assignment */\n'use client'\nimport type { ClientValidate } from 'payload/types'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport React, { useCallback } from 'react'\n\nimport type { TextAreaInputProps, TextareaFieldProps } from './types.js'\n\nimport { useFieldProps } from '../../forms/FieldPropsProvider/index.js'\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { useConfig } from '../../providers/Config/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { isFieldRTL } from '../shared/index.js'\nimport { TextareaInput } from './Input.js'\nimport './index.scss'\n\nexport { TextAreaInputProps, TextareaFieldProps, TextareaInput }\n\nconst TextareaField: React.FC<TextareaFieldProps> = (props) => {\n const {\n name,\n AfterInput,\n BeforeInput,\n CustomDescription,\n CustomError,\n CustomLabel,\n className,\n descriptionProps,\n errorProps,\n label,\n labelProps,\n locale,\n localized,\n maxLength,\n minLength,\n path: pathFromProps,\n placeholder,\n readOnly: readOnlyFromProps,\n required,\n rows,\n rtl,\n style,\n validate,\n width,\n } = props\n\n const { i18n } = useTranslation()\n\n const { localization } = useConfig()\n\n const isRTL = isFieldRTL({\n fieldLocalized: localized,\n fieldRTL: rtl,\n locale,\n localizationConfig: localization || undefined,\n })\n\n const memoizedValidate: ClientValidate = useCallback(\n (value, options) => {\n if (typeof validate === 'function')\n return validate(value, { ...options, maxLength, minLength, required })\n },\n [validate, required, maxLength, minLength],\n )\n\n const { path: pathFromContext, readOnly: readOnlyFromContext } = useFieldProps()\n const readOnly = readOnlyFromProps || readOnlyFromContext\n\n const { path, setValue, showError, value } = useField<string>({\n path: pathFromContext || pathFromProps || name,\n validate: memoizedValidate,\n })\n\n return (\n <TextareaInput\n AfterInput={AfterInput}\n BeforeInput={BeforeInput}\n CustomDescription={CustomDescription}\n CustomError={CustomError}\n CustomLabel={CustomLabel}\n className={className}\n descriptionProps={descriptionProps}\n errorProps={errorProps}\n label={label}\n labelProps={labelProps}\n onChange={(e) => {\n setValue(e.target.value)\n }}\n path={path}\n placeholder={getTranslation(placeholder, i18n)}\n readOnly={readOnly}\n required={required}\n rows={rows}\n rtl={isRTL}\n showError={showError}\n style={style}\n value={value}\n width={width}\n />\n )\n}\n\nexport const Textarea = withCondition(TextareaField)\n"],"names":["getTranslation","React","useCallback","useFieldProps","useField","withCondition","useConfig","useTranslation","isFieldRTL","TextareaInput","TextareaField","props","name","AfterInput","BeforeInput","CustomDescription","CustomError","CustomLabel","className","descriptionProps","errorProps","label","labelProps","locale","localized","maxLength","minLength","path","pathFromProps","placeholder","readOnly","readOnlyFromProps","required","rows","rtl","style","validate","width","i18n","localization","isRTL","fieldLocalized","fieldRTL","localizationConfig","undefined","memoizedValidate","value","options","pathFromContext","readOnlyFromContext","setValue","showError","onChange","e","target","Textarea"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,iDAAiD,GACjD;AAGA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,OAAOC,SAASC,WAAW,QAAQ,QAAO;AAI1C,SAASC,aAAa,QAAQ,0CAAyC;AACvE,SAASC,QAAQ,QAAQ,gCAA+B;AACxD,SAASC,aAAa,QAAQ,qCAAoC;AAClE,SAASC,SAAS,QAAQ,kCAAiC;AAC3D,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,UAAU,QAAQ,qBAAoB;AAC/C,SAASC,aAAa,QAAQ,aAAY;AAG1C,SAAiDA,aAAa,GAAE;AAEhE,MAAMC,gBAA8C,CAACC;IACnD,MAAM,EACJC,IAAI,EACJC,UAAU,EACVC,WAAW,EACXC,iBAAiB,EACjBC,WAAW,EACXC,WAAW,EACXC,SAAS,EACTC,gBAAgB,EAChBC,UAAU,EACVC,KAAK,EACLC,UAAU,EACVC,MAAM,EACNC,SAAS,EACTC,SAAS,EACTC,SAAS,EACTC,MAAMC,aAAa,EACnBC,WAAW,EACXC,UAAUC,iBAAiB,EAC3BC,QAAQ,EACRC,IAAI,EACJC,GAAG,EACHC,KAAK,EACLC,QAAQ,EACRC,KAAK,EACN,GAAG1B;IAEJ,MAAM,EAAE2B,IAAI,EAAE,GAAG/B;IAEjB,MAAM,EAAEgC,YAAY,EAAE,GAAGjC;IAEzB,MAAMkC,QAAQhC,WAAW;QACvBiC,gBAAgBjB;QAChBkB,UAAUR;QACVX;QACAoB,oBAAoBJ,gBAAgBK;IACtC;IAEA,MAAMC,mBAAmC3C,YACvC,CAAC4C,OAAOC;QACN,IAAI,OAAOX,aAAa,YACtB,O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AE,sBAAsB,CAAA;IACnC,aAAa,CAAC,EAAE,mBAAmB,CAAA;IACnC,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAA,KAAK,IAAI,CAAA;IACtB,UAAU,CAAC,EAAE,WAAW,CAAC,YAAY,CAAC,CAAA;IACtC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CA2JlD,CAAA"}
1
+ {"version":3,"file":"Input.d.ts","sourceRoot":"","sources":["../../../src/fields/Upload/Input.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAG7F,OAAO,KAA2C,MAAM,OAAO,CAAA;AAI/D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAWlD,OAAO,cAAc,CAAA;AAIrB,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,gBAAgB,EAAE,eAAe,CAAC,GAAG;IACvE,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,UAAU,CAAC,EAAE,sBAAsB,CAAA;IACnC,aAAa,CAAC,EAAE,mBAAmB,CAAA;IACnC,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAA,KAAK,IAAI,CAAA;IACtB,UAAU,CAAC,EAAE,WAAW,CAAC,YAAY,CAAC,CAAA;IACtC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CA2JlD,CAAA"}
@@ -1,13 +1,13 @@
1
1
  'use client';
2
2
  import { getTranslation } from '@payloadcms/translations';
3
- import { FieldDescription } from '@payloadcms/ui/forms/FieldDescription';
4
- import { FieldError } from '@payloadcms/ui/forms/FieldError';
5
- import { FieldLabel } from '@payloadcms/ui/forms/FieldLabel';
6
3
  import React, { useCallback, useEffect, useState } from 'react';
7
4
  import { Button } from '../../elements/Button/index.js';
8
5
  import { useDocumentDrawer } from '../../elements/DocumentDrawer/index.js';
9
6
  import { FileDetails } from '../../elements/FileDetails/index.js';
10
7
  import { useListDrawer } from '../../elements/ListDrawer/index.js';
8
+ import { FieldDescription } from '../../forms/FieldDescription/index.js';
9
+ import { FieldError } from '../../forms/FieldError/index.js';
10
+ import { FieldLabel } from '../../forms/FieldLabel/index.js';
11
11
  import { useTranslation } from '../../providers/Translation/index.js';
12
12
  import { fieldBaseClass } from '../shared/index.js';
13
13
  const baseClass = 'upload';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/fields/Upload/Input.tsx"],"sourcesContent":["'use client'\n\nimport type { ClientCollectionConfig, FilterOptionsResult, UploadField } from 'payload/types'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { FieldDescription } from '@payloadcms/ui/forms/FieldDescription'\nimport { FieldError } from '@payloadcms/ui/forms/FieldError'\nimport { FieldLabel } from '@payloadcms/ui/forms/FieldLabel'\nimport React, { useCallback, useEffect, useState } from 'react'\n\nimport type { DocumentDrawerProps } from '../../elements/DocumentDrawer/types.js'\nimport type { ListDrawerProps } from '../../elements/ListDrawer/types.js'\nimport type { UploadFieldProps } from './types.js'\n\nimport { Button } from '../../elements/Button/index.js'\nimport { useDocumentDrawer } from '../../elements/DocumentDrawer/index.js'\nimport { FileDetails } from '../../elements/FileDetails/index.js'\nimport { useListDrawer } from '../../elements/ListDrawer/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { fieldBaseClass } from '../shared/index.js'\nimport './index.scss'\n\nconst baseClass = 'upload'\n\nexport type UploadInputProps = Omit<UploadFieldProps, 'filterOptions'> & {\n api?: string\n collection?: ClientCollectionConfig\n filterOptions?: FilterOptionsResult\n onChange?: (e) => void\n relationTo?: UploadField['relationTo']\n serverURL?: string\n showError?: boolean\n value?: string\n}\n\nexport const UploadInput: React.FC<UploadInputProps> = (props) => {\n const {\n CustomDescription,\n CustomError,\n CustomLabel,\n api = '/api',\n className,\n collection,\n descriptionProps,\n errorProps,\n filterOptions,\n label,\n labelProps,\n onChange,\n readOnly,\n relationTo,\n required,\n serverURL,\n showError,\n style,\n value,\n width,\n } = props\n\n const { i18n, t } = useTranslation()\n\n const [fileDoc, setFileDoc] = useState(undefined)\n const [missingFile, setMissingFile] = useState(false)\n const [collectionSlugs] = useState([collection?.slug])\n\n const [DocumentDrawer, DocumentDrawerToggler, { closeDrawer }] = useDocumentDrawer({\n collectionSlug: collectionSlugs[0],\n })\n\n const [ListDrawer, ListDrawerToggler, { closeDrawer: closeListDrawer }] = useListDrawer({\n collectionSlugs,\n filterOptions,\n })\n\n useEffect(() => {\n if (value !== null && typeof value !== 'undefined' && value !== '') {\n const fetchFile = async () => {\n const response = await fetch(`${serverURL}${api}/${relationTo}/${value}`, {\n credentials: 'include',\n headers: {\n 'Accept-Language': i18n.language,\n },\n })\n if (response.ok) {\n const json = await response.json()\n setFileDoc(json)\n } else {\n setMissingFile(true)\n setFileDoc(undefined)\n }\n }\n\n void fetchFile()\n } else {\n setFileDoc(undefined)\n }\n }, [value, relationTo, api, serverURL, i18n])\n\n const onSave = useCallback<DocumentDrawerProps['onSave']>(\n (args) => {\n setMissingFile(false)\n onChange(args.doc)\n closeDrawer()\n },\n [onChange, closeDrawer],\n )\n\n const onSelect = useCallback<ListDrawerProps['onSelect']>(\n (args) => {\n setMissingFile(false)\n onChange({\n id: args.docID,\n })\n closeListDrawer()\n },\n [onChange, closeListDrawer],\n )\n\n if (collection.upload) {\n return (\n <div\n className={[\n fieldBaseClass,\n baseClass,\n className,\n showError && 'error',\n readOnly && 'read-only',\n ]\n .filter(Boolean)\n .join(' ')}\n style={{\n ...style,\n width,\n }}\n >\n <FieldError CustomError={CustomError} {...(errorProps || {})} />\n <FieldLabel\n CustomLabel={CustomLabel}\n label={label}\n required={required}\n {...(labelProps || {})}\n />\n {collection?.upload && (\n <React.Fragment>\n {fileDoc && !missingFile && (\n <FileDetails\n collectionSlug={relationTo}\n doc={fileDoc}\n handleRemove={\n readOnly\n ? undefined\n : () => {\n onChange(null)\n }\n }\n uploadConfig={collection.upload}\n />\n )}\n {(!fileDoc || missingFile) && (\n <div className={`${baseClass}__wrap`}>\n <div className={`${baseClass}__buttons`}>\n <DocumentDrawerToggler className={`${baseClass}__toggler`} disabled={readOnly}>\n <Button buttonStyle=\"secondary\" disabled={readOnly} el=\"div\">\n {t('fields:uploadNewLabel', {\n label: getTranslation(collection.labels.singular, i18n),\n })}\n </Button>\n </DocumentDrawerToggler>\n <ListDrawerToggler className={`${baseClass}__toggler`} disabled={readOnly}>\n <Button buttonStyle=\"secondary\" disabled={readOnly} el=\"div\">\n {t('fields:chooseFromExisting')}\n </Button>\n </ListDrawerToggler>\n </div>\n </div>\n )}\n {CustomDescription !== undefined ? (\n CustomDescription\n ) : (\n <FieldDescription {...(descriptionProps || {})} />\n )}\n </React.Fragment>\n )}\n {!readOnly && <DocumentDrawer onSave={onSave} />}\n {!readOnly && <ListDrawer onSelect={onSelect} />}\n </div>\n )\n }\n\n return null\n}\n"],"names":["getTranslation","FieldDescription","FieldError","FieldLabel","React","useCallback","useEffect","useState","Button","useDocumentDrawer","FileDetails","useListDrawer","useTranslation","fieldBaseClass","baseClass","UploadInput","props","CustomDescription","CustomError","CustomLabel","api","className","collection","descriptionProps","errorProps","filterOptions","label","labelProps","onChange","readOnly","relationTo","required","serverURL","showError","style","value","width","i18n","t","fileDoc","setFileDoc","undefined","missingFile","setMissingFile","collectionSlugs","slug","DocumentDrawer","DocumentDrawerToggler","closeDrawer","collectionSlug","ListDrawer","ListDrawerToggler","closeListDrawer","fetchFile","response","fetch","credentials","headers","language","ok","json","onSave","args","doc","onSelect","id","docID","upload","div","filter","Boolean","join","Fragment","handleRemove","u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OAAOA;YACPK,UAAUA;YACT,GAAIJ,cAAc,CAAC,CAAC;YAEtBL,YAAY6C,wBACX,oBAAC/D,MAAMoE,QAAQ,QACZjC,WAAW,CAACG,6BACX,oBAAChC;YACCuC,gBAAgBnB;YAChBiC,KAAKxB;YACLkC,cACE5C,WACIY,YACA;gBACEb,SAAS;YACX;YAEN8C,cAAcpD,WAAW6C,MAAM;YAGlC,AAAC,CAAA,CAAC5B,WAAWG,WAAU,mBACtB,oBAAC0B;YAAI/C,WAAW,CAAC,EAAEP,UAAU,MAAM,CAAC;yBAClC,oBAACsD;YAAI/C,WAAW,CAAC,EAAEP,UAAU,SAAS,CAAC;yBACrC,oBAACiC;YAAsB1B,WAAW,CAAC,EAAEP,UAAU,SAAS,CAAC;YAAE6D,UAAU9C;yBACnE,oBAACrB;YAAOoE,aAAY;YAAYD,UAAU9C;YAAUgD,IAAG;WACpDvC,EAAE,yBAAyB;YAC1BZ,OAAO1B,eAAesB,WAAWwD,MAAM,CAACC,QAAQ,EAAE1C;QACpD,oBAGJ,oBAACc;YAAkB9B,WAAW,CAAC,EAAEP,UAAU,SAAS,CAAC;YAAE6D,UAAU9C;yBAC/D,oBAACrB;YAAOoE,aAAY;YAAYD,UAAU9C;YAAUgD,IAAG;WACpDvC,EAAE,kCAMZrB,sBAAsBwB,YACrBxB,kCAEA,oBAAChB,kBAAsBsB,oBAAoB,CAAC,KAIjD,CAACM,0BAAY,oBAACiB;YAAee,QAAQA;YACrC,CAAChC,0BAAY,oBAACqB;YAAWc,UAAUA;;IAG1C;IAEA,OAAO;AACT,EAAC"}
1
+ {"version":3,"sources":["../../../src/fields/Upload/Input.tsx"],"sourcesContent":["'use client'\n\nimport type { ClientCollectionConfig, FilterOptionsResult, UploadField } from 'payload/types'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport React, { useCallback, useEffect, useState } from 'react'\n\nimport type { DocumentDrawerProps } from '../../elements/DocumentDrawer/types.js'\nimport type { ListDrawerProps } from '../../elements/ListDrawer/types.js'\nimport type { UploadFieldProps } from './types.js'\n\nimport { Button } from '../../elements/Button/index.js'\nimport { useDocumentDrawer } from '../../elements/DocumentDrawer/index.js'\nimport { FileDetails } from '../../elements/FileDetails/index.js'\nimport { useListDrawer } from '../../elements/ListDrawer/index.js'\nimport { FieldDescription } from '../../forms/FieldDescription/index.js'\nimport { FieldError } from '../../forms/FieldError/index.js'\nimport { FieldLabel } from '../../forms/FieldLabel/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { fieldBaseClass } from '../shared/index.js'\nimport './index.scss'\n\nconst baseClass = 'upload'\n\nexport type UploadInputProps = Omit<UploadFieldProps, 'filterOptions'> & {\n api?: string\n collection?: ClientCollectionConfig\n filterOptions?: FilterOptionsResult\n onChange?: (e) => void\n relationTo?: UploadField['relationTo']\n serverURL?: string\n showError?: boolean\n value?: string\n}\n\nexport const UploadInput: React.FC<UploadInputProps> = (props) => {\n const {\n CustomDescription,\n CustomError,\n CustomLabel,\n api = '/api',\n className,\n collection,\n descriptionProps,\n errorProps,\n filterOptions,\n label,\n labelProps,\n onChange,\n readOnly,\n relationTo,\n required,\n serverURL,\n showError,\n style,\n value,\n width,\n } = props\n\n const { i18n, t } = useTranslation()\n\n const [fileDoc, setFileDoc] = useState(undefined)\n const [missingFile, setMissingFile] = useState(false)\n const [collectionSlugs] = useState([collection?.slug])\n\n const [DocumentDrawer, DocumentDrawerToggler, { closeDrawer }] = useDocumentDrawer({\n collectionSlug: collectionSlugs[0],\n })\n\n const [ListDrawer, ListDrawerToggler, { closeDrawer: closeListDrawer }] = useListDrawer({\n collectionSlugs,\n filterOptions,\n })\n\n useEffect(() => {\n if (value !== null && typeof value !== 'undefined' && value !== '') {\n const fetchFile = async () => {\n const response = await fetch(`${serverURL}${api}/${relationTo}/${value}`, {\n credentials: 'include',\n headers: {\n 'Accept-Language': i18n.language,\n },\n })\n if (response.ok) {\n const json = await response.json()\n setFileDoc(json)\n } else {\n setMissingFile(true)\n setFileDoc(undefined)\n }\n }\n\n void fetchFile()\n } else {\n setFileDoc(undefined)\n }\n }, [value, relationTo, api, serverURL, i18n])\n\n const onSave = useCallback<DocumentDrawerProps['onSave']>(\n (args) => {\n setMissingFile(false)\n onChange(args.doc)\n closeDrawer()\n },\n [onChange, closeDrawer],\n )\n\n const onSelect = useCallback<ListDrawerProps['onSelect']>(\n (args) => {\n setMissingFile(false)\n onChange({\n id: args.docID,\n })\n closeListDrawer()\n },\n [onChange, closeListDrawer],\n )\n\n if (collection.upload) {\n return (\n <div\n className={[\n fieldBaseClass,\n baseClass,\n className,\n showError && 'error',\n readOnly && 'read-only',\n ]\n .filter(Boolean)\n .join(' ')}\n style={{\n ...style,\n width,\n }}\n >\n <FieldError CustomError={CustomError} {...(errorProps || {})} />\n <FieldLabel\n CustomLabel={CustomLabel}\n label={label}\n required={required}\n {...(labelProps || {})}\n />\n {collection?.upload && (\n <React.Fragment>\n {fileDoc && !missingFile && (\n <FileDetails\n collectionSlug={relationTo}\n doc={fileDoc}\n handleRemove={\n readOnly\n ? undefined\n : () => {\n onChange(null)\n }\n }\n uploadConfig={collection.upload}\n />\n )}\n {(!fileDoc || missingFile) && (\n <div className={`${baseClass}__wrap`}>\n <div className={`${baseClass}__buttons`}>\n <DocumentDrawerToggler className={`${baseClass}__toggler`} disabled={readOnly}>\n <Button buttonStyle=\"secondary\" disabled={readOnly} el=\"div\">\n {t('fields:uploadNewLabel', {\n label: getTranslation(collection.labels.singular, i18n),\n })}\n </Button>\n </DocumentDrawerToggler>\n <ListDrawerToggler className={`${baseClass}__toggler`} disabled={readOnly}>\n <Button buttonStyle=\"secondary\" disabled={readOnly} el=\"div\">\n {t('fields:chooseFromExisting')}\n </Button>\n </ListDrawerToggler>\n </div>\n </div>\n )}\n {CustomDescription !== undefined ? (\n CustomDescription\n ) : (\n <FieldDescription {...(descriptionProps || {})} />\n )}\n </React.Fragment>\n )}\n {!readOnly && <DocumentDrawer onSave={onSave} />}\n {!readOnly && <ListDrawer onSelect={onSelect} />}\n </div>\n )\n }\n\n return null\n}\n"],"names":["getTranslation","React","useCallback","useEffect","useState","Button","useDocumentDrawer","FileDetails","useListDrawer","FieldDescription","FieldError","FieldLabel","useTranslation","fieldBaseClass","baseClass","UploadInput","props","CustomDescription","CustomError","CustomLabel","api","className","collection","descriptionProps","errorProps","filterOptions","label","labelProps","onChange","readOnly","relationTo","required","serverURL","showError","style","value","width","i18n","t","fileDoc","setFileDoc","undefined","missingFile","setMissingFile","collectionSlugs","slug","DocumentDrawer","DocumentDrawerToggler","closeDrawer","collectionSlug","ListDrawer","ListDrawerToggler","closeListDrawer","fetchFile","response","fetch","credentials","headers","language","ok","json","onSave","args","doc","onSelect","id","docID","upload","div","filter","Boolean","join","Fragment","handleRemove","uploadConfig","disabled","buttonStyle","el","labels","singular"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAIA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,OAAOC,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAM/D,SAASC,MAAM,QAAQ,iCAAgC;AACvD,SAASC,iBAAiB,QAAQ,yCAAwC;AAC1E,SAASC,WAAW,QAAQ,sCAAqC;AACjE,SAASC,aAAa,QAAQ,qCAAoC;AAClE,SAASC,gBAAgB,QAAQ,wCAAuC;AACxE,SAASC,UAAU,QAAQ,kCAAiC;AAC5D,SAASC,UAAU,QAAQ,kCAAiC;AAC5D,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,cAAc,QAAQ,qBAAoB;AAGnD,MAAMC,YAAY;AAalB,OAAO,MAAMC,cAA0C,CAACC;IACtD,MAAM,EACJC,iBAAiB,EACjBC,WAAW,EACXC,WAAW,EACXC,MAAM,MAAM,EACZC,SAAS,EACTC,UAAU,EACV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gD,IAAG;WACpDvC,EAAE,kCAMZrB,sBAAsBwB,YACrBxB,kCAEA,oBAACR,kBAAsBc,oBAAoB,CAAC,KAIjD,CAACM,0BAAY,oBAACiB;YAAee,QAAQA;YACrC,CAAChC,0BAAY,oBAACqB;YAAWc,UAAUA;;IAG1C;IAEA,OAAO;AACT,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/Upload/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAsB,MAAM,OAAO,CAAA;AAE1C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAClD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAIlD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AACxC,OAAO,cAAc,CAAA;AAErB,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,CAAA;AACxC,YAAY,EAAE,gBAAgB,EAAE,CAAA;AAqFhC,eAAO,MAAM,MAAM,4BAAyB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/Upload/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAsB,MAAM,OAAO,CAAA;AAE1C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAClD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAMlD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AACxC,OAAO,cAAc,CAAA;AAErB,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,CAAA;AACxC,YAAY,EAAE,gBAAgB,EAAE,CAAA;AAqFhC,eAAO,MAAM,MAAM,4BAAyB,CAAA"}
@@ -1,8 +1,8 @@
1
1
  'use client';
2
- import { useFieldProps } from '@payloadcms/ui/forms/FieldPropsProvider';
3
- import { withCondition } from '@payloadcms/ui/forms/withCondition';
4
2
  import React, { useCallback } from 'react';
3
+ import { useFieldProps } from '../../forms/FieldPropsProvider/index.js';
5
4
  import { useField } from '../../forms/useField/index.js';
5
+ import { withCondition } from '../../forms/withCondition/index.js';
6
6
  import { useConfig } from '../../providers/Config/index.js';
7
7
  import { UploadInput } from './Input.js';
8
8
  export { UploadInput };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/fields/Upload/index.tsx"],"sourcesContent":["'use client'\nimport { useFieldProps } from '@payloadcms/ui/forms/FieldPropsProvider'\nimport { withCondition } from '@payloadcms/ui/forms/withCondition'\nimport React, { useCallback } from 'react'\n\nimport type { UploadInputProps } from './Input.js'\nimport type { UploadFieldProps } from './types.js'\n\nimport { useField } from '../../forms/useField/index.js'\nimport { useConfig } from '../../providers/Config/index.js'\nimport { UploadInput } from './Input.js'\nimport './index.scss'\n\nexport { UploadFieldProps, UploadInput }\nexport type { UploadInputProps }\n\nconst _Upload: React.FC<UploadFieldProps> = (props) => {\n const {\n CustomDescription,\n CustomError,\n CustomLabel,\n className,\n descriptionProps,\n errorProps,\n label,\n labelProps,\n path: pathFromProps,\n readOnly: readOnlyFromProps,\n relationTo,\n required,\n style,\n validate,\n width,\n } = props\n\n const {\n collections,\n routes: { api },\n serverURL,\n } = useConfig()\n\n const collection = collections.find((coll) => coll.slug === relationTo)\n\n const memoizedValidate = useCallback(\n (value, options) => {\n if (typeof validate === 'function') {\n return validate(value, { ...options, required })\n }\n },\n [validate, required],\n )\n\n const { path: pathFromContext, readOnly: readOnlyFromContext } = useFieldProps()\n const readOnly = readOnlyFromProps || readOnlyFromContext\n\n const { filterOptions, path, setValue, showError, value } = useField<string>({\n path: pathFromContext || pathFromProps,\n validate: memoizedValidate,\n })\n\n const onChange = useCallback(\n (incomingValue) => {\n const incomingID = incomingValue?.id || incomingValue\n setValue(incomingID)\n },\n [setValue],\n )\n\n if (collection.upload) {\n return (\n <UploadInput\n CustomDescription={CustomDescription}\n CustomError={CustomError}\n CustomLabel={CustomLabel}\n api={api}\n className={className}\n collection={collection}\n descriptionProps={descriptionProps}\n errorProps={errorProps}\n filterOptions={filterOptions}\n label={label}\n labelProps={labelProps}\n onChange={onChange}\n path={path}\n readOnly={readOnly}\n relationTo={relationTo}\n required={required}\n serverURL={serverURL}\n showError={showError}\n style={style}\n value={value}\n width={width}\n />\n )\n }\n\n return null\n}\n\nexport const Upload = withCondition(_Upload)\n"],"names":["useFieldProps","withCondition","React","useCallback","useField","useConfig","UploadInput","_Upload","props","CustomDescription","CustomError","CustomLabel","className","descriptionProps","errorProps","label","labelProps","path","pathFromProps","readOnly","readOnlyFromProps","relationTo","required","style","validate","width","collections","routes","api","serverURL","collection","find","coll","slug","memoizedValidate","value","options","pathFromContext","readOnlyFromContext","filterOptions","setValue","showError","onChange","incomingValue","incomingID","id","upload","Upload"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AACA,SAASA,aAAa,QAAQ,0CAAyC;AACvE,SAASC,aAAa,QAAQ,qCAAoC;AAClE,OAAOC,SAASC,WAAW,QAAQ,QAAO;AAK1C,SAASC,QAAQ,QAAQ,gCAA+B;AACxD,SAASC,SAAS,QAAQ,kCAAiC;AAC3D,SAASC,WAAW,QAAQ,aAAY;AAGxC,SAA2BA,WAAW,GAAE;AAGxC,MAAMC,UAAsC,CAACC;IAC3C,MAAM,EACJC,iBAAiB,EACjBC,WAAW,EACXC,WAAW,EACXC,SAAS,EACTC,gBAAgB,EAChBC,UAAU,EACVC,KAAK,EACLC,UAAU,EACVC,MAAMC,aAAa,EACnBC,UAAUC,iBAAiB,EAC3BC,UAAU,EACVC,QAAQ,EACRC,KAAK,EACLC,QAAQ,EACRC,KAAK,EACN,GAAGjB;IAEJ,MAAM,EACJkB,WAAW,EACXC,QAAQ,EAAEC,GAAG,EAAE,EACfC,SAAS,EACV,GAAGxB;IAEJ,MAAMyB,aAAaJ,YAAYK,IAAI,CAAC,CAACC,OAASA,KAAKC,IAAI,KAAKZ;IAE5D,MAAMa,mBAAmB/B,YACvB,CAACgC,OAAOC;QACN,IAAI,OAAOZ,aAAa,YAAY;YAClC,OAAOA,SAASW,OAAO;gBAAE,GAAGC,OAAO;gBAAEd;YAAS;QAChD;IACF,GACA;QAACE;QAAUF;KAAS;IAGtB,MAAM,EAAEL,MAAMoB,eAAe,EAAElB,UAAUmB,mBAAmB,EAAE,GAAGtC;IACjE,MAAMmB,WAAWC,qBAAqBkB;IAEtC,MAAM,EAAEC,aAAa,EAAEtB,IAAI,EAAEuB,QAAQ,EAAEC,SAAS,EAAEN,KAAK,EAAE,GAAG/B,SAAiB;QAC3Ea,MAAMoB,mBAAmBnB;QACzBM,UAAUU;IACZ;IAEA,MAAMQ,WAAWvC,YACf,CAACwC;QACC,MAAMC,aAAaD,eAAeE,MAAMF;QACxCH,SAASI;IACX,GACA;QAACJ;KAAS;IAGZ,IAAIV,WAAWgB,MAAM,EAAE;QACrB,qBACE,oBAACxC;YACCG,mBAAmBA;YACnBC,aAAaA;YACbC,aAAaA;YACbiB,KAAKA;YACLhB,WAAWA;YACXkB,YAAYA;YACZjB,kBAAkBA;YAClBC,YAAYA;YACZyB,eAAeA;YACfxB,OAAOA;YACPC,YAAYA;YACZ0B,UAAUA;YACVzB,MAAMA;YACNE,UAAUA;YACVE,YAAYA;YACZC,UAAUA;YACVO,WAAWA;YACXY,WAAWA;YACXlB,OAAOA;YACPY,OAAOA;YACPV,OAAOA;;IAGb;IAEA,OAAO;AACT;AAEA,OAAO,MAAMsB,SAAS9C,cAAcM,SAAQ"}
1
+ {"version":3,"sources":["../../../src/fields/Upload/index.tsx"],"sourcesContent":["'use client'\n\nimport React, { useCallback } from 'react'\n\nimport type { UploadInputProps } from './Input.js'\nimport type { UploadFieldProps } from './types.js'\n\nimport { useFieldProps } from '../../forms/FieldPropsProvider/index.js'\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { useConfig } from '../../providers/Config/index.js'\nimport { UploadInput } from './Input.js'\nimport './index.scss'\n\nexport { UploadFieldProps, UploadInput }\nexport type { UploadInputProps }\n\nconst _Upload: React.FC<UploadFieldProps> = (props) => {\n const {\n CustomDescription,\n CustomError,\n CustomLabel,\n className,\n descriptionProps,\n errorProps,\n label,\n labelProps,\n path: pathFromProps,\n readOnly: readOnlyFromProps,\n relationTo,\n required,\n style,\n validate,\n width,\n } = props\n\n const {\n collections,\n routes: { api },\n serverURL,\n } = useConfig()\n\n const collection = collections.find((coll) => coll.slug === relationTo)\n\n const memoizedValidate = useCallback(\n (value, options) => {\n if (typeof validate === 'function') {\n return validate(value, { ...options, required })\n }\n },\n [validate, required],\n )\n\n const { path: pathFromContext, readOnly: readOnlyFromContext } = useFieldProps()\n const readOnly = readOnlyFromProps || readOnlyFromContext\n\n const { filterOptions, path, setValue, showError, value } = useField<string>({\n path: pathFromContext || pathFromProps,\n validate: memoizedValidate,\n })\n\n const onChange = useCallback(\n (incomingValue) => {\n const incomingID = incomingValue?.id || incomingValue\n setValue(incomingID)\n },\n [setValue],\n )\n\n if (collection.upload) {\n return (\n <UploadInput\n CustomDescription={CustomDescription}\n CustomError={CustomError}\n CustomLabel={CustomLabel}\n api={api}\n className={className}\n collection={collection}\n descriptionProps={descriptionProps}\n errorProps={errorProps}\n filterOptions={filterOptions}\n label={label}\n labelProps={labelProps}\n onChange={onChange}\n path={path}\n readOnly={readOnly}\n relationTo={relationTo}\n required={required}\n serverURL={serverURL}\n showError={showError}\n style={style}\n value={value}\n width={width}\n />\n )\n }\n\n return null\n}\n\nexport const Upload = withCondition(_Upload)\n"],"names":["React","useCallback","useFieldProps","useField","withCondition","useConfig","UploadInput","_Upload","props","CustomDescription","CustomError","CustomLabel","className","descriptionProps","errorProps","label","labelProps","path","pathFromProps","readOnly","readOnlyFromProps","relationTo","required","style","validate","width","collections","routes","api","serverURL","collection","find","coll","slug","memoizedValidate","value","options","pathFromContext","readOnlyFromContext","filterOptions","setValue","showError","onChange","incomingValue","incomingID","id","up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0C;QACC,MAAMC,aAAaD,eAAeE,MAAMF;QACxCH,SAASI;IACX,GACA;QAACJ;KAAS;IAGZ,IAAIV,WAAWgB,MAAM,EAAE;QACrB,qBACE,oBAACxC;YACCG,mBAAmBA;YACnBC,aAAaA;YACbC,aAAaA;YACbiB,KAAKA;YACLhB,WAAWA;YACXkB,YAAYA;YACZjB,kBAAkBA;YAClBC,YAAYA;YACZyB,eAAeA;YACfxB,OAAOA;YACPC,YAAYA;YACZ0B,UAAUA;YACVzB,MAAMA;YACNE,UAAUA;YACVE,YAAYA;YACZC,UAAUA;YACVO,WAAWA;YACXY,WAAWA;YACXlB,OAAOA;YACPY,OAAOA;YACPV,OAAOA;;IAGb;IAEA,OAAO;AACT;AAEA,OAAO,MAAMsB,SAAS3C,cAAcG,SAAQ"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/forms/FieldLabel/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAI/C,OAAO,KAAK,MAAM,OAAO,CAAA;AAMzB,OAAO,cAAc,CAAA;AA8BrB,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,UAAU,CAQ3C,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/forms/FieldLabel/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAG/C,OAAO,KAAK,MAAM,OAAO,CAAA;AAOzB,OAAO,cAAc,CAAA;AA8BrB,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,UAAU,CAQ3C,CAAA"}
@@ -1,7 +1,7 @@
1
1
  'use client';
2
2
  import { getTranslation } from '@payloadcms/translations';
3
- import { useEditDepth } from '@payloadcms/ui/providers/EditDepth';
4
3
  import React from 'react';
4
+ import { useEditDepth } from '../../providers/EditDepth/index.js';
5
5
  import { useTranslation } from '../../providers/Translation/index.js';
6
6
  import { generateFieldID } from '../../utilities/generateFieldID.js';
7
7
  import { useFieldProps } from '../FieldPropsProvider/index.js';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/forms/FieldLabel/index.tsx"],"sourcesContent":["'use client'\n\nimport type { LabelProps } from 'payload/types'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { useEditDepth } from '@payloadcms/ui/providers/EditDepth'\nimport React from 'react'\n\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { generateFieldID } from '../../utilities/generateFieldID.js'\nimport { useFieldProps } from '../FieldPropsProvider/index.js'\nimport { useForm } from '../Form/context.js'\nimport './index.scss'\n\nconst DefaultFieldLabel: React.FC<LabelProps> = (props) => {\n const {\n as: Element = 'label',\n htmlFor: htmlForFromProps,\n label: labelFromProps,\n required = false,\n unstyled = false,\n } = props\n\n const { uuid } = useForm()\n const { path } = useFieldProps()\n const editDepth = useEditDepth()\n const htmlFor = htmlForFromProps || generateFieldID(path, editDepth, uuid)\n\n const { i18n } = useTranslation()\n\n if (labelFromProps) {\n return (\n <Element className={`field-label ${unstyled ? 'unstyled' : ''}`} htmlFor={htmlFor}>\n {getTranslation(labelFromProps, i18n)}\n {required && !unstyled && <span className=\"required\">*</span>}\n </Element>\n )\n }\n\n return null\n}\n\nexport const FieldLabel: React.FC<LabelProps> = (props) => {\n const { CustomLabel } = props\n\n if (CustomLabel !== undefined) {\n return CustomLabel\n }\n\n return <DefaultFieldLabel {...props} />\n}\n"],"names":["getTranslation","useEditDepth","React","useTranslation","generateFieldID","useFieldProps","useForm","DefaultFieldLabel","props","as","Element","htmlFor","htmlForFromProps","label","labelFromProps","required","unstyled","uuid","path","editDepth","i18n","className","span","FieldLabel","CustomLabel","undefined"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAIA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,SAASC,YAAY,QAAQ,qCAAoC;AACjE,OAAOC,WAAW,QAAO;AAEzB,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,aAAa,QAAQ,iCAAgC;AAC9D,SAASC,OAAO,QAAQ,qBAAoB;AAG5C,MAAMC,oBAA0C,CAACC;IAC/C,MAAM,EACJC,IAAIC,UAAU,OAAO,EACrBC,SAASC,gBAAgB,EACzBC,OAAOC,cAAc,EACrBC,WAAW,KAAK,EAChBC,WAAW,KAAK,EACjB,GAAGR;IAEJ,MAAM,EAAES,IAAI,EAAE,GAAGX;IACjB,MAAM,EAAEY,IAAI,EAAE,GAAGb;IACjB,MAAMc,YAAYlB;IAClB,MAAMU,UAAUC,oBAAoBR,gBAAgBc,MAAMC,WAAWF;IAErE,MAAM,EAAEG,IAAI,EAAE,GAAGjB;IAEjB,IAAIW,gBAAgB;QAClB,qBACE,oBAACJ;YAAQW,WAAW,CAAC,YAAY,EAAEL,WAAW,aAAa,GAAG,CAAC;YAAEL,SAASA;WACvEX,eAAec,gBAAgBM,OAC/BL,YAAY,CAACC,0BAAY,oBAACM;YAAKD,WAAU;WAAW;IAG3D;IAEA,OAAO;AACT;AAEA,OAAO,MAAME,aAAmC,CAACf;IAC/C,MAAM,EAAEgB,WAAW,EAAE,GAAGhB;IAExB,IAAIgB,gBAAgBC,WAAW;QAC7B,OAAOD;IACT;IAEA,qBAAO,oBAACjB,mBAAsBC;AAChC,EAAC"}
1
+ {"version":3,"sources":["../../../src/forms/FieldLabel/index.tsx"],"sourcesContent":["'use client'\n\nimport type { LabelProps } from 'payload/types'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport React from 'react'\n\nimport { useEditDepth } from '../../providers/EditDepth/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { generateFieldID } from '../../utilities/generateFieldID.js'\nimport { useFieldProps } from '../FieldPropsProvider/index.js'\nimport { useForm } from '../Form/context.js'\nimport './index.scss'\n\nconst DefaultFieldLabel: React.FC<LabelProps> = (props) => {\n const {\n as: Element = 'label',\n htmlFor: htmlForFromProps,\n label: labelFromProps,\n required = false,\n unstyled = false,\n } = props\n\n const { uuid } = useForm()\n const { path } = useFieldProps()\n const editDepth = useEditDepth()\n const htmlFor = htmlForFromProps || generateFieldID(path, editDepth, uuid)\n\n const { i18n } = useTranslation()\n\n if (labelFromProps) {\n return (\n <Element className={`field-label ${unstyled ? 'unstyled' : ''}`} htmlFor={htmlFor}>\n {getTranslation(labelFromProps, i18n)}\n {required && !unstyled && <span className=\"required\">*</span>}\n </Element>\n )\n }\n\n return null\n}\n\nexport const FieldLabel: React.FC<LabelProps> = (props) => {\n const { CustomLabel } = props\n\n if (CustomLabel !== undefined) {\n return CustomLabel\n }\n\n return <DefaultFieldLabel {...props} />\n}\n"],"names":["getTranslation","React","useEditDepth","useTranslation","generateFieldID","useFieldProps","useForm","DefaultFieldLabel","props","as","Element","htmlFor","htmlForFromProps","label","labelFromProps","required","unstyled","uuid","path","editDepth","i18n","className","span","FieldLabel","CustomLabel","undefined"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAIA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,OAAOC,WAAW,QAAO;AAEzB,SAASC,YAAY,QAAQ,qCAAoC;AACjE,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,aAAa,QAAQ,iCAAgC;AAC9D,SAASC,OAAO,QAAQ,qBAAoB;AAG5C,MAAMC,oBAA0C,CAACC;IAC/C,MAAM,EACJC,IAAIC,UAAU,OAAO,EACrBC,SAASC,gBAAgB,EACzBC,OAAOC,cAAc,EACrBC,WAAW,KAAK,EAChBC,WAAW,KAAK,EACjB,GAAGR;IAEJ,MAAM,EAAES,IAAI,EAAE,GAAGX;IACjB,MAAM,EAAEY,IAAI,EAAE,GAAGb;IACjB,MAAMc,YAAYjB;IAClB,MAAMS,UAAUC,oBAAoBR,gBAAgBc,MAAMC,WAAWF;IAErE,MAAM,EAAEG,IAAI,EAAE,GAAGjB;IAEjB,IAAIW,gBAAgB;QAClB,qBACE,oBAACJ;YAAQW,WAAW,CAAC,YAAY,EAAEL,WAAW,aAAa,GAAG,CAAC;YAAEL,SAASA;WACvEX,eAAec,gBAAgBM,OAC/BL,YAAY,CAACC,0BAAY,oBAACM;YAAKD,WAAU;WAAW;IAG3D;IAEA,OAAO;AACT;AAEA,OAAO,MAAME,aAAmC,CAACf;IAC/C,MAAM,EAAEgB,WAAW,EAAE,GAAGhB;IAExB,IAAIgB,gBAAgBC,WAAW;QAC7B,OAAOD;IACT;IAEA,qBAAO,oBAACjB,mBAAsBC;AAChC,EAAC"}