@payloadcms/ui 3.0.0-alpha.53 → 3.0.0-alpha.55

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 (62) hide show
  1. package/dist/elements/DocumentControls/index.d.ts.map +1 -1
  2. package/dist/elements/DocumentControls/index.js +2 -3
  3. package/dist/elements/DocumentControls/index.js.map +1 -1
  4. package/dist/elements/FileDetails/index.js +1 -1
  5. package/dist/elements/FileDetails/index.js.map +1 -1
  6. package/dist/elements/Table/DefaultCell/fields/File/index.js +1 -1
  7. package/dist/elements/Table/DefaultCell/fields/File/index.js.map +1 -1
  8. package/dist/fields/Array/index.d.ts.map +1 -1
  9. package/dist/fields/Array/index.js +3 -2
  10. package/dist/fields/Array/index.js.map +1 -1
  11. package/dist/fields/Blocks/index.d.ts.map +1 -1
  12. package/dist/fields/Blocks/index.js +3 -2
  13. package/dist/fields/Blocks/index.js.map +1 -1
  14. package/dist/fields/Checkbox/index.d.ts.map +1 -1
  15. package/dist/fields/Checkbox/index.js +3 -2
  16. package/dist/fields/Checkbox/index.js.map +1 -1
  17. package/dist/fields/Code/index.d.ts.map +1 -1
  18. package/dist/fields/Code/index.js +3 -2
  19. package/dist/fields/Code/index.js.map +1 -1
  20. package/dist/fields/Collapsible/index.d.ts.map +1 -1
  21. package/dist/fields/Collapsible/index.js +3 -2
  22. package/dist/fields/Collapsible/index.js.map +1 -1
  23. package/dist/fields/DateTime/index.d.ts.map +1 -1
  24. package/dist/fields/DateTime/index.js +3 -2
  25. package/dist/fields/DateTime/index.js.map +1 -1
  26. package/dist/fields/Email/index.d.ts.map +1 -1
  27. package/dist/fields/Email/index.js +4 -3
  28. package/dist/fields/Email/index.js.map +1 -1
  29. package/dist/fields/Group/index.d.ts.map +1 -1
  30. package/dist/fields/Group/index.js +3 -2
  31. package/dist/fields/Group/index.js.map +1 -1
  32. package/dist/fields/JSON/index.d.ts.map +1 -1
  33. package/dist/fields/JSON/index.js +3 -2
  34. package/dist/fields/JSON/index.js.map +1 -1
  35. package/dist/fields/Number/index.d.ts.map +1 -1
  36. package/dist/fields/Number/index.js +3 -2
  37. package/dist/fields/Number/index.js.map +1 -1
  38. package/dist/fields/Point/index.d.ts.map +1 -1
  39. package/dist/fields/Point/index.js +4 -3
  40. package/dist/fields/Point/index.js.map +1 -1
  41. package/dist/fields/RadioGroup/index.d.ts.map +1 -1
  42. package/dist/fields/RadioGroup/index.js +3 -2
  43. package/dist/fields/RadioGroup/index.js.map +1 -1
  44. package/dist/fields/Relationship/index.d.ts.map +1 -1
  45. package/dist/fields/Relationship/index.js +3 -2
  46. package/dist/fields/Relationship/index.js.map +1 -1
  47. package/dist/fields/Select/index.d.ts.map +1 -1
  48. package/dist/fields/Select/index.js +3 -2
  49. package/dist/fields/Select/index.js.map +1 -1
  50. package/dist/fields/Tabs/index.d.ts.map +1 -1
  51. package/dist/fields/Tabs/index.js +3 -2
  52. package/dist/fields/Tabs/index.js.map +1 -1
  53. package/dist/fields/Text/index.d.ts.map +1 -1
  54. package/dist/fields/Text/index.js +5 -4
  55. package/dist/fields/Text/index.js.map +1 -1
  56. package/dist/fields/Textarea/index.d.ts.map +1 -1
  57. package/dist/fields/Textarea/index.js +4 -3
  58. package/dist/fields/Textarea/index.js.map +1 -1
  59. package/dist/fields/Upload/index.d.ts.map +1 -1
  60. package/dist/fields/Upload/index.js +4 -2
  61. package/dist/fields/Upload/index.js.map +1 -1
  62. package/package.json +4 -4
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/fields/Collapsible/index.tsx"],"sourcesContent":["'use client'\nimport type { DocumentPreferences, FieldBase } from 'payload/types'\n\nimport React, { Fragment, useCallback, useEffect, useState } from 'react'\n\nimport { Collapsible as CollapsibleElement } from '../../elements/Collapsible/index.js'\nimport { ErrorPill } from '../../elements/ErrorPill/index.js'\nimport { useFieldProps } from '../../forms/FieldPropsProvider/index.js'\nimport { RenderFields } from '../../forms/RenderFields/index.js'\nimport { RowLabel } from '../../forms/RowLabel/index.js'\nimport { WatchChildErrors } from '../../forms/WatchChildErrors/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 './index.scss'\n\nconst baseClass = 'collapsible-field'\n\nimport type { FieldPermissions } from 'payload/auth'\n\nimport { FieldDescription } from '@payloadcms/ui/forms/FieldDescription'\n\nimport type { FieldMap } from '../../providers/ComponentMap/buildComponentMap/types.js'\nimport type { FormFieldBase } from '../shared/index.js'\n\nexport type CollapsibleFieldProps = FormFieldBase & {\n fieldMap: FieldMap\n initCollapsed?: boolean\n label?: FieldBase['label']\n permissions: FieldPermissions\n width?: string\n}\n\nconst CollapsibleField: React.FC<CollapsibleFieldProps> = (props) => {\n const {\n CustomDescription,\n CustomLabel,\n className,\n descriptionProps,\n fieldMap,\n initCollapsed = false,\n labelProps,\n path: pathFromProps,\n } = props\n\n const {\n indexPath,\n path: pathFromContext,\n readOnly,\n schemaPath,\n siblingPermissions,\n } = useFieldProps()\n const path = pathFromContext || pathFromProps\n\n const { i18n } = useTranslation()\n const { getPreference, setPreference } = usePreferences()\n const { preferencesKey } = useDocumentInfo()\n const [collapsedOnMount, setCollapsedOnMount] = useState<boolean>()\n const fieldPreferencesKey = `collapsible-${indexPath.replace(/\\./g, '__')}`\n const [errorCount, setErrorCount] = useState(0)\n const fieldHasErrors = errorCount > 0\n\n const onToggle = useCallback(\n async (newCollapsedState: boolean) => {\n const existingPreferences: DocumentPreferences = await getPreference(preferencesKey)\n\n void setPreference(preferencesKey, {\n ...existingPreferences,\n ...(path\n ? {\n fields: {\n ...(existingPreferences?.fields || {}),\n [path]: {\n ...existingPreferences?.fields?.[path],\n collapsed: newCollapsedState,\n },\n },\n }\n : {\n fields: {\n ...(existingPreferences?.fields || {}),\n [fieldPreferencesKey]: {\n ...existingPreferences?.fields?.[fieldPreferencesKey],\n collapsed: newCollapsedState,\n },\n },\n }),\n })\n },\n [preferencesKey, fieldPreferencesKey, getPreference, setPreference, path],\n )\n\n useEffect(() => {\n const fetchInitialState = async () => {\n const preferences = await getPreference(preferencesKey)\n if (preferences) {\n const initCollapsedFromPref = path\n ? preferences?.fields?.[path]?.collapsed\n : preferences?.fields?.[fieldPreferencesKey]?.collapsed\n setCollapsedOnMount(Boolean(initCollapsedFromPref))\n } else {\n setCollapsedOnMount(typeof initCollapsed === 'boolean' ? initCollapsed : false)\n }\n }\n\n void fetchInitialState()\n }, [getPreference, preferencesKey, fieldPreferencesKey, initCollapsed, path])\n\n if (typeof collapsedOnMount !== 'boolean') return null\n\n return (\n <Fragment>\n <WatchChildErrors fieldMap={fieldMap} path={path} setErrorCount={setErrorCount} />\n <div\n className={[\n fieldBaseClass,\n baseClass,\n className,\n fieldHasErrors ? `${baseClass}--has-error` : `${baseClass}--has-no-error`,\n ]\n .filter(Boolean)\n .join(' ')}\n id={`field-${fieldPreferencesKey}${path ? `-${path.replace(/\\./g, '__')}` : ''}`}\n >\n <CollapsibleElement\n className={`${baseClass}__collapsible`}\n collapsibleStyle={fieldHasErrors ? 'error' : 'default'}\n header={\n <div className={`${baseClass}__row-label-wrap`}>\n <RowLabel\n RowLabelComponent={CustomLabel}\n i18n={i18n}\n path={path}\n rowLabel={labelProps.label}\n />\n {fieldHasErrors && <ErrorPill count={errorCount} i18n={i18n} withMessage />}\n </div>\n }\n initCollapsed={collapsedOnMount}\n onToggle={onToggle}\n >\n <RenderFields\n fieldMap={fieldMap}\n forceRender\n indexPath={indexPath}\n margins=\"small\"\n path={path}\n permissions={siblingPermissions}\n readOnly={readOnly}\n schemaPath={schemaPath}\n />\n </CollapsibleElement>\n <FieldDescription CustomDescription={CustomDescription} {...(descriptionProps || {})} />\n </div>\n </Fragment>\n )\n}\n\nexport const Collapsible = withCondition(CollapsibleField)\n"],"names":["React","Fragment","useCallback","useEffect","useState","Collapsible","CollapsibleElement","ErrorPill","useFieldProps","RenderFields","RowLabel","WatchChildErrors","withCondition","useDocumentInfo","usePreferences","useTranslation","fieldBaseClass","baseClass","FieldDescription","CollapsibleField","props","CustomDescription","CustomLabel","className","descriptionProps","fieldMap","initCollapsed","labelProps","path","pathFromProps","indexPath","pathFromContext","readOnly","schemaPath","siblingPermissions","i18n","getPreference","setPreference","preferencesKey","collapsedOnMount","setCollapsedOnMount","fieldPreferencesKey","replace","errorCount","setErrorCount","fieldHasErrors","onToggle","newCollapsedState","existingPreferences","fields","collapsed","fetchInitialState","preferences","initCollapsedFromPref","Boolean","div","filter","join","id","collapsibleStyle","header","RowLabelComponent","rowLabel","label","count","withMessage","forceRender","margins","permissions"],"mappings":"AAAA;AAGA,OAAOA,SAASC,QAAQ,EAAEC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAEzE,SAASC,eAAeC,kBAAkB,QAAQ,sCAAqC;AACvF,SAASC,SAAS,QAAQ,oCAAmC;AAC7D,SAASC,aAAa,QAAQ,0CAAyC;AACvE,SAASC,YAAY,QAAQ,oCAAmC;AAChE,SAASC,QAAQ,QAAQ,gCAA+B;AACxD,SAASC,gBAAgB,QAAQ,wCAAuC;AACxE,SAASC,aAAa,QAAQ,qCAAoC;AAClE,SAASC,eAAe,QAAQ,wCAAuC;AACvE,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,cAAc,QAAQ,qBAAoB;AAGnD,MAAMC,YAAY;AAIlB,SAASC,gBAAgB,QAAQ,wCAAuC;AAaxE,MAAMC,mBAAoD,CAACC;IACzD,MAAM,EACJC,iBAAiB,EACjBC,WAAW,EACXC,SAAS,EACTC,gBAAgB,EAChBC,QAAQ,EACRC,gBAAgB,KAAK,EACrBC,UAAU,EACVC,MAAMC,aAAa,EACpB,GAAGT;IAEJ,MAAM,EACJU,SAAS,EACTF,MAAMG,eAAe,EACrBC,QAAQ,EACRC,UAAU,EACV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AEA,KAAKyB;IACP,GAAG;QAACf;QAAeE;QAAgBG;QAAqBf;QAAeE;KAAK;IAE5E,IAAI,OAAOW,qBAAqB,WAAW,OAAO;IAElD,qBACE,oBAACtC,8BACC,oBAACU;QAAiBc,UAAUA;QAAUG,MAAMA;QAAMgB,eAAeA;sBACjE,oBAACW;QACChC,WAAW;YACTP;YACAC;YACAM;YACAsB,iBAAiB,CAAC,EAAE5B,UAAU,WAAW,CAAC,GAAG,CAAC,EAAEA,UAAU,cAAc,CAAC;SAC1E,CACEuC,MAAM,CAACF,SACPG,IAAI,CAAC;QACRC,IAAI,CAAC,MAAM,EAAEjB,oBAAoB,EAAEb,OAAO,CAAC,CAAC,EAAEA,KAAKc,OAAO,CAAC,OAAO,MAAM,CAAC,GAAG,GAAG,CAAC;qBAEhF,oBAACpC;QACCiB,WAAW,CAAC,EAAEN,UAAU,aAAa,CAAC;QACtC0C,kBAAkBd,iBAAiB,UAAU;QAC7Ce,sBACE,oBAACL;YAAIhC,WAAW,CAAC,EAAEN,UAAU,gBAAgB,CAAC;yBAC5C,oBAACP;YACCmD,mBAAmBvC;YACnBa,MAAMA;YACNP,MAAMA;YACNkC,UAAUnC,WAAWoC,KAAK;YAE3BlB,gCAAkB,oBAACtC;YAAUyD,OAAOrB;YAAYR,MAAMA;YAAM8B,aAAAA;;QAGjEvC,eAAea;QACfO,UAAUA;qBAEV,oBAACrC;QACCgB,UAAUA;QACVyC,aAAAA;QACApC,WAAWA;QACXqC,SAAQ;QACRvC,MAAMA;QACNwC,aAAalC;QACbF,UAAUA;QACVC,YAAYA;uBAGhB,oBAACf;QAAiBG,mBAAmBA;QAAoB,GAAIG,oBAAoB,CAAC,CAAC;;AAI3F;AAEA,OAAO,MAAMnB,cAAcO,cAAcO,kBAAiB"}
1
+ {"version":3,"sources":["../../../src/fields/Collapsible/index.tsx"],"sourcesContent":["'use client'\nimport type { DocumentPreferences, FieldBase } from 'payload/types'\n\nimport React, { Fragment, useCallback, useEffect, useState } from 'react'\n\nimport { Collapsible as CollapsibleElement } from '../../elements/Collapsible/index.js'\nimport { ErrorPill } from '../../elements/ErrorPill/index.js'\nimport { useFieldProps } from '../../forms/FieldPropsProvider/index.js'\nimport { RenderFields } from '../../forms/RenderFields/index.js'\nimport { RowLabel } from '../../forms/RowLabel/index.js'\nimport { WatchChildErrors } from '../../forms/WatchChildErrors/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 './index.scss'\n\nconst baseClass = 'collapsible-field'\n\nimport type { FieldPermissions } from 'payload/auth'\n\nimport { FieldDescription } from '@payloadcms/ui/forms/FieldDescription'\n\nimport type { FieldMap } from '../../providers/ComponentMap/buildComponentMap/types.js'\nimport type { FormFieldBase } from '../shared/index.js'\n\nexport type CollapsibleFieldProps = FormFieldBase & {\n fieldMap: FieldMap\n initCollapsed?: boolean\n label?: FieldBase['label']\n permissions: FieldPermissions\n width?: string\n}\n\nconst CollapsibleField: React.FC<CollapsibleFieldProps> = (props) => {\n const {\n CustomDescription,\n CustomLabel,\n className,\n descriptionProps,\n fieldMap,\n initCollapsed = false,\n labelProps,\n path: pathFromProps,\n readOnly: readOnlyFromProps,\n } = props\n\n const {\n indexPath,\n path: pathFromContext,\n readOnly: readOnlyFromContext,\n schemaPath,\n siblingPermissions,\n } = useFieldProps()\n const path = pathFromContext || pathFromProps\n\n const { i18n } = useTranslation()\n const { getPreference, setPreference } = usePreferences()\n const { preferencesKey } = useDocumentInfo()\n const [collapsedOnMount, setCollapsedOnMount] = useState<boolean>()\n const fieldPreferencesKey = `collapsible-${indexPath.replace(/\\./g, '__')}`\n const [errorCount, setErrorCount] = useState(0)\n const fieldHasErrors = errorCount > 0\n\n const onToggle = useCallback(\n async (newCollapsedState: boolean) => {\n const existingPreferences: DocumentPreferences = await getPreference(preferencesKey)\n\n void setPreference(preferencesKey, {\n ...existingPreferences,\n ...(path\n ? {\n fields: {\n ...(existingPreferences?.fields || {}),\n [path]: {\n ...existingPreferences?.fields?.[path],\n collapsed: newCollapsedState,\n },\n },\n }\n : {\n fields: {\n ...(existingPreferences?.fields || {}),\n [fieldPreferencesKey]: {\n ...existingPreferences?.fields?.[fieldPreferencesKey],\n collapsed: newCollapsedState,\n },\n },\n }),\n })\n },\n [preferencesKey, fieldPreferencesKey, getPreference, setPreference, path],\n )\n\n useEffect(() => {\n const fetchInitialState = async () => {\n const preferences = await getPreference(preferencesKey)\n if (preferences) {\n const initCollapsedFromPref = path\n ? preferences?.fields?.[path]?.collapsed\n : preferences?.fields?.[fieldPreferencesKey]?.collapsed\n setCollapsedOnMount(Boolean(initCollapsedFromPref))\n } else {\n setCollapsedOnMount(typeof initCollapsed === 'boolean' ? initCollapsed : false)\n }\n }\n\n void fetchInitialState()\n }, [getPreference, preferencesKey, fieldPreferencesKey, initCollapsed, path])\n\n if (typeof collapsedOnMount !== 'boolean') return null\n\n const readOnly = readOnlyFromProps || readOnlyFromContext\n\n return (\n <Fragment>\n <WatchChildErrors fieldMap={fieldMap} path={path} setErrorCount={setErrorCount} />\n <div\n className={[\n fieldBaseClass,\n baseClass,\n className,\n fieldHasErrors ? `${baseClass}--has-error` : `${baseClass}--has-no-error`,\n ]\n .filter(Boolean)\n .join(' ')}\n id={`field-${fieldPreferencesKey}${path ? `-${path.replace(/\\./g, '__')}` : ''}`}\n >\n <CollapsibleElement\n className={`${baseClass}__collapsible`}\n collapsibleStyle={fieldHasErrors ? 'error' : 'default'}\n header={\n <div className={`${baseClass}__row-label-wrap`}>\n <RowLabel\n RowLabelComponent={CustomLabel}\n i18n={i18n}\n path={path}\n rowLabel={labelProps.label}\n />\n {fieldHasErrors && <ErrorPill count={errorCount} i18n={i18n} withMessage />}\n </div>\n }\n initCollapsed={collapsedOnMount}\n onToggle={onToggle}\n >\n <RenderFields\n fieldMap={fieldMap}\n forceRender\n indexPath={indexPath}\n margins=\"small\"\n path={path}\n permissions={siblingPermissions}\n readOnly={readOnly}\n schemaPath={schemaPath}\n />\n </CollapsibleElement>\n <FieldDescription CustomDescription={CustomDescription} {...(descriptionProps || {})} />\n </div>\n </Fragment>\n )\n}\n\nexport const Collapsible = withCondition(CollapsibleField)\n"],"names":["React","Fragment","useCallback","useEffect","useState","Collapsible","CollapsibleElement","ErrorPill","useFieldProps","RenderFields","RowLabel","WatchChildErrors","withCondition","useDocumentInfo","usePreferences","useTranslation","fieldBaseClass","baseClass","FieldDescription","CollapsibleField","props","CustomDescription","CustomLabel","className","descriptionProps","fieldMap","initCollapsed","labelProps","path","pathFromProps","readOnly","readOnlyFromProps","indexPath","pathFromContext","readOnlyFromContext","schemaPath","siblingPermissions","i18n","getPreference","setPreference","preferencesKey","collapsedOnMount","setCollapsedOnMount","fieldPreferencesKey","replace","errorCount","setErrorCount","fieldHasErrors","onToggle","newCollapsedState","existingPreferences","fields","collapsed","fetchInitialState","preferences","initCollapsedFromPref","Boolean","div","filter","join","id","collapsibleStyle","header","RowLabelComponent","rowLabel","label","count","withMessage","forceRender","margins","permissions"],"mappings":"AAAA;AAGA,OAAOA,SAASC,QAAQ,EAAEC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAEzE,SAASC,eAAeC,kBAAkB,QAAQ,sCAAqC;AACvF,SAASC,SAAS,QAAQ,oCAAmC;AAC7D,SAASC,aAAa,QAAQ,0CAAyC;AACvE,SAASC,YAAY,QAAQ,oCAAmC;AAChE,SAASC,QAAQ,QAAQ,gCAA+B;AACxD,SAASC,gBAAgB,QAAQ,wCAAuC;AACxE,SAASC,aAAa,QAAQ,qCAAoC;AAClE,SAASC,eAAe,QAAQ,wCAAuC;AACvE,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,cAAc,QAAQ,qBAAoB;AAGnD,MAAMC,YAAY;AAIlB,SAASC,gB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aAAAA;QACApC,WAAWA;QACXqC,SAAQ;QACRzC,MAAMA;QACN0C,aAAalC;QACbN,UAAUA;QACVK,YAAYA;uBAGhB,oBAACjB;QAAiBG,mBAAmBA;QAAoB,GAAIG,oBAAoB,CAAC,CAAC;;AAI3F;AAEA,OAAO,MAAMnB,cAAcO,cAAcO,kBAAiB"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/DateTime/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAsB,MAAM,OAAO,CAAA;AAO1C,OAAO,cAAc,CAAA;AAIrB,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAMzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAIvD,MAAM,MAAM,cAAc,GAAG,aAAa,GAAG;IAC3C,IAAI,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAA;IACjC,KAAK,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,CAAA;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC,aAAa,CAAC,GAAG,MAAM,CAAA;IACxD,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AA0FD,eAAO,MAAM,QAAQ,0BAA+B,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/DateTime/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAsB,MAAM,OAAO,CAAA;AAO1C,OAAO,cAAc,CAAA;AAIrB,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAMzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAIvD,MAAM,MAAM,cAAc,GAAG,aAAa,GAAG;IAC3C,IAAI,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAA;IACjC,KAAK,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,CAAA;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC,aAAa,CAAC,GAAG,MAAM,CAAA;IACxD,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AA4FD,eAAO,MAAM,QAAQ,0BAA+B,CAAA"}
@@ -12,7 +12,7 @@ import { FieldError } from '@payloadcms/ui/forms/FieldError';
12
12
  import { useFieldProps } from '@payloadcms/ui/forms/FieldPropsProvider';
13
13
  import { withCondition } from '../../forms/withCondition/index.js';
14
14
  const DateTimeField = (props)=>{
15
- const { name, AfterInput, BeforeInput, CustomDescription, CustomError, CustomLabel, className, date: datePickerProps, descriptionProps, errorProps, label, labelProps, path: pathFromProps, placeholder, readOnly, required, style, validate, width } = props;
15
+ const { name, AfterInput, BeforeInput, CustomDescription, CustomError, CustomLabel, className, date: datePickerProps, descriptionProps, errorProps, label, labelProps, path: pathFromProps, placeholder, readOnly: readOnlyFromProps, required, style, validate, width } = props;
16
16
  const { i18n } = useTranslation();
17
17
  const memoizedValidate = useCallback((value, options)=>{
18
18
  if (typeof validate === 'function') {
@@ -25,11 +25,12 @@ const DateTimeField = (props)=>{
25
25
  validate,
26
26
  required
27
27
  ]);
28
- const { path: pathFromContext } = useFieldProps();
28
+ const { path: pathFromContext, readOnly: readOnlyFromContext } = useFieldProps();
29
29
  const { path, setValue, showError, value } = useField({
30
30
  path: pathFromContext || pathFromProps || name,
31
31
  validate: memoizedValidate
32
32
  });
33
+ const readOnly = readOnlyFromProps || readOnlyFromContext;
33
34
  return /*#__PURE__*/ React.createElement("div", {
34
35
  className: [
35
36
  fieldBaseClass,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/fields/DateTime/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 { DatePickerField } from '../../elements/DatePicker/index.js'\nimport { FieldLabel } from '../../forms/FieldLabel/index.js'\nimport { useField } from '../../forms/useField/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { fieldBaseClass } from '../shared/index.js'\nimport './index.scss'\n\nconst baseClass = 'date-time-field'\n\nimport type { DateField, FieldBase } from 'payload/types'\n\nimport { FieldDescription } from '@payloadcms/ui/forms/FieldDescription'\nimport { FieldError } from '@payloadcms/ui/forms/FieldError'\nimport { useFieldProps } from '@payloadcms/ui/forms/FieldPropsProvider'\n\nimport type { FormFieldBase } from '../shared/index.js'\n\nimport { withCondition } from '../../forms/withCondition/index.js'\n\nexport type DateFieldProps = FormFieldBase & {\n date?: DateField['admin']['date']\n label?: FieldBase['label']\n name?: string\n path?: string\n placeholder?: DateField['admin']['placeholder'] | string\n width?: string\n}\n\nconst DateTimeField: React.FC<DateFieldProps> = (props) => {\n const {\n name,\n AfterInput,\n BeforeInput,\n CustomDescription,\n CustomError,\n CustomLabel,\n className,\n date: datePickerProps,\n descriptionProps,\n errorProps,\n label,\n labelProps,\n path: pathFromProps,\n placeholder,\n readOnly,\n required,\n style,\n validate,\n width,\n } = props\n\n const { i18n } = useTranslation()\n\n const memoizedValidate: ClientValidate = 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 } = useFieldProps()\n\n const { path, setValue, showError, value } = useField<Date>({\n path: pathFromContext || pathFromProps || name,\n validate: memoizedValidate,\n })\n\n return (\n <div\n className={[\n fieldBaseClass,\n baseClass,\n className,\n showError && `${baseClass}--has-error`,\n readOnly && 'read-only',\n ]\n .filter(Boolean)\n .join(' ')}\n style={{\n ...style,\n width,\n }}\n >\n <div className={`${baseClass}__error-wrap`}>\n <FieldError CustomError={CustomError} path={path} {...(errorProps || {})} />\n </div>\n <FieldLabel\n CustomLabel={CustomLabel}\n label={label}\n required={required}\n {...(labelProps || {})}\n />\n <div className={`${baseClass}__input-wrapper`} id={`field-${path.replace(/\\./g, '__')}`}>\n {BeforeInput}\n <DatePickerField\n {...datePickerProps}\n onChange={(incomingDate) => {\n if (!readOnly) setValue(incomingDate?.toISOString() || null)\n }}\n placeholder={getTranslation(placeholder, i18n)}\n readOnly={readOnly}\n value={value}\n />\n {AfterInput}\n </div>\n {CustomDescription !== undefined ? (\n CustomDescription\n ) : (\n <FieldDescription {...(descriptionProps || {})} />\n )}\n </div>\n )\n}\n\nexport const DateTime = withCondition(DateTimeField)\n"],"names":["getTranslation","React","useCallback","DatePickerField","FieldLabel","useField","useTranslation","fieldBaseClass","baseClass","FieldDescription","FieldError","useFieldProps","withCondition","DateTimeField","props","name","AfterInput","BeforeInput","CustomDescription","CustomError","CustomLabel","className","date","datePickerProps","descriptionProps","errorProps","label","labelProps","path","pathFromProps","placeholder","readOnly","required","style","validate","width","i18n","memoizedValidate","value","options","pathFromContext","setValue","showError","div","filter","Boolean","join","id","replace","onChange","incomingDate","toISOString","undefined","DateTime"],"mappings":"AAAA,iDAAiD,GACjD;AAGA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,OAAOC,SAASC,WAAW,QAAQ,QAAO;AAE1C,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,UAAU,QAAQ,kCAAiC;AAC5D,SAASC,QAAQ,QAAQ,gCAA+B;AACxD,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,cAAc,QAAQ,qBAAoB;AAGnD,MAAMC,YAAY;AAIlB,SAASC,gBAAgB,QAAQ,wCAAuC;AACxE,SAASC,UAAU,QAAQ,kCAAiC;AAC5D,SAASC,aAAa,QAAQ,0CAAyC;AAIvE,SAASC,aAAa,QAAQ,qCAAoC;AAWlE,MAAMC,gBAA0C,CAACC;IAC/C,MAAM,EAC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/B,2BACD,oBAACd;QACE,GAAGoB,eAAe;QACnB0B,UAAU,CAACC;YACT,IAAI,CAACnB,UAAUU,SAASS,cAAcC,iBAAiB;QACzD;QACArB,aAAa9B,eAAe8B,aAAaM;QACzCL,UAAUA;QACVO,OAAOA;QAERtB,aAEFE,sBAAsBkC,YACrBlC,kCAEA,oBAACT,kBAAsBe,oBAAoB,CAAC;AAIpD;AAEA,OAAO,MAAM6B,WAAWzC,cAAcC,eAAc"}
1
+ {"version":3,"sources":["../../../src/fields/DateTime/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 { DatePickerField } from '../../elements/DatePicker/index.js'\nimport { FieldLabel } from '../../forms/FieldLabel/index.js'\nimport { useField } from '../../forms/useField/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { fieldBaseClass } from '../shared/index.js'\nimport './index.scss'\n\nconst baseClass = 'date-time-field'\n\nimport type { DateField, FieldBase } from 'payload/types'\n\nimport { FieldDescription } from '@payloadcms/ui/forms/FieldDescription'\nimport { FieldError } from '@payloadcms/ui/forms/FieldError'\nimport { useFieldProps } from '@payloadcms/ui/forms/FieldPropsProvider'\n\nimport type { FormFieldBase } from '../shared/index.js'\n\nimport { withCondition } from '../../forms/withCondition/index.js'\n\nexport type DateFieldProps = FormFieldBase & {\n date?: DateField['admin']['date']\n label?: FieldBase['label']\n name?: string\n path?: string\n placeholder?: DateField['admin']['placeholder'] | string\n width?: string\n}\n\nconst DateTimeField: React.FC<DateFieldProps> = (props) => {\n const {\n name,\n AfterInput,\n BeforeInput,\n CustomDescription,\n CustomError,\n CustomLabel,\n className,\n date: datePickerProps,\n descriptionProps,\n errorProps,\n label,\n labelProps,\n path: pathFromProps,\n placeholder,\n readOnly: readOnlyFromProps,\n required,\n style,\n validate,\n width,\n } = props\n\n const { i18n } = useTranslation()\n\n const memoizedValidate: ClientValidate = 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\n const { path, setValue, showError, value } = useField<Date>({\n path: pathFromContext || pathFromProps || name,\n validate: memoizedValidate,\n })\n\n const readOnly = readOnlyFromProps || readOnlyFromContext\n\n return (\n <div\n className={[\n fieldBaseClass,\n baseClass,\n className,\n showError && `${baseClass}--has-error`,\n readOnly && 'read-only',\n ]\n .filter(Boolean)\n .join(' ')}\n style={{\n ...style,\n width,\n }}\n >\n <div className={`${baseClass}__error-wrap`}>\n <FieldError CustomError={CustomError} path={path} {...(errorProps || {})} />\n </div>\n <FieldLabel\n CustomLabel={CustomLabel}\n label={label}\n required={required}\n {...(labelProps || {})}\n />\n <div className={`${baseClass}__input-wrapper`} id={`field-${path.replace(/\\./g, '__')}`}>\n {BeforeInput}\n <DatePickerField\n {...datePickerProps}\n onChange={(incomingDate) => {\n if (!readOnly) setValue(incomingDate?.toISOString() || null)\n }}\n placeholder={getTranslation(placeholder, i18n)}\n readOnly={readOnly}\n value={value}\n />\n {AfterInput}\n </div>\n {CustomDescription !== undefined ? (\n CustomDescription\n ) : (\n <FieldDescription {...(descriptionProps || {})} />\n )}\n </div>\n )\n}\n\nexport const DateTime = withCondition(DateTimeField)\n"],"names":["getTranslation","React","useCallback","DatePickerField","FieldLabel","useField","useTranslation","fieldBaseClass","baseClass","FieldDescription","FieldError","useFieldProps","withCondition","DateTimeField","props","name","AfterInput","BeforeInput","CustomDescription","CustomError","CustomLabel","className","date","datePickerProps","descriptionProps","errorProps","label","labelProps","path","pathFromProps","placeholder","readOnly","readOnlyFromProps","required","style","validate","width","i18n","memoizedValidate","value","options","pathFromContext","readOnlyFromContext","setValue","showError","div","filter","Boolean","join","id","replace","onChange","incomingDate","toISOString","undefined","DateTime"],"mappings":"AAAA,iDAAiD,GACjD;AAGA,SAASA,cAAc,QAAQ,2BAA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,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,cAAc,CAAC,OAAO,CAAC,CAAC,aAAa,CAAC,CAAA;IACpD,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAmFD,eAAO,MAAM,KAAK,2BAA4B,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/Email/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,IAAI,cAAc,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAO5E,OAAO,KAAsB,MAAM,OAAO,CAAA;AAE1C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAMvD,OAAO,cAAc,CAAA;AAErB,MAAM,MAAM,eAAe,GAAG,aAAa,GAAG;IAC5C,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,KAAK,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,CAAA;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,cAAc,CAAC,OAAO,CAAC,CAAC,aAAa,CAAC,CAAA;IACpD,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAoFD,eAAO,MAAM,KAAK,2BAA4B,CAAA"}
@@ -10,7 +10,7 @@ import { withCondition } from '../../forms/withCondition/index.js';
10
10
  import { useTranslation } from '../../providers/Translation/index.js';
11
11
  import { fieldBaseClass } from '../shared/index.js';
12
12
  const EmailField = (props)=>{
13
- const { name, AfterInput, BeforeInput, CustomDescription, CustomError, CustomLabel, autoComplete, className, descriptionProps, errorProps, label, labelProps, path: pathFromProps, placeholder, readOnly, required, style, validate, width } = props;
13
+ const { name, AfterInput, BeforeInput, CustomDescription, CustomError, CustomLabel, autoComplete, className, descriptionProps, errorProps, label, labelProps, path: pathFromProps, placeholder, readOnly: readOnlyFromProps, required, style, validate, width } = props;
14
14
  const { i18n } = useTranslation();
15
15
  const memoizedValidate = useCallback((value, options)=>{
16
16
  if (typeof validate === 'function') {
@@ -23,7 +23,8 @@ const EmailField = (props)=>{
23
23
  validate,
24
24
  required
25
25
  ]);
26
- const { path: pathFromContext } = useFieldProps();
26
+ const { path: pathFromContext, readOnly: readOnlyFromContext } = useFieldProps();
27
+ const readOnly = readOnlyFromProps || readOnlyFromContext;
27
28
  const { path, setValue, showError, value } = useField({
28
29
  path: pathFromContext || pathFromProps || name,
29
30
  validate: memoizedValidate
@@ -51,7 +52,7 @@ const EmailField = (props)=>{
51
52
  ...labelProps || {}
52
53
  }), /*#__PURE__*/ React.createElement("div", null, BeforeInput, /*#__PURE__*/ React.createElement("input", {
53
54
  autoComplete: autoComplete,
54
- disabled: Boolean(readOnly),
55
+ disabled: readOnly,
55
56
  id: `field-${path.replace(/\./g, '__')}`,
56
57
  name: path,
57
58
  onChange: setValue,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/fields/Email/index.tsx"],"sourcesContent":["'use client'\nimport type { ClientValidate } from 'payload/types'\nimport type { EmailField as EmailFieldType, FieldBase } 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 { useFieldProps } from '@payloadcms/ui/forms/FieldPropsProvider'\nimport React, { useCallback } from 'react'\n\nimport type { FormFieldBase } from '../shared/index.js'\n\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { fieldBaseClass } from '../shared/index.js'\nimport './index.scss'\n\nexport type EmailFieldProps = FormFieldBase & {\n autoComplete?: string\n label?: FieldBase['label']\n name?: string\n path?: string\n placeholder?: EmailFieldType['admin']['placeholder']\n width?: string\n}\n\nconst EmailField: React.FC<EmailFieldProps> = (props) => {\n const {\n name,\n AfterInput,\n BeforeInput,\n CustomDescription,\n CustomError,\n CustomLabel,\n autoComplete,\n className,\n descriptionProps,\n errorProps,\n label,\n labelProps,\n path: pathFromProps,\n placeholder,\n readOnly,\n required,\n style,\n validate,\n width,\n } = props\n\n const { i18n } = useTranslation()\n\n const memoizedValidate: ClientValidate = 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 } = useFieldProps()\n\n const { path, setValue, showError, value } = useField({\n path: pathFromContext || pathFromProps || name,\n validate: memoizedValidate,\n })\n\n return (\n <div\n className={[fieldBaseClass, 'email', className, showError && 'error', readOnly && 'read-only']\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 <div>\n {BeforeInput}\n <input\n autoComplete={autoComplete}\n disabled={Boolean(readOnly)}\n id={`field-${path.replace(/\\./g, '__')}`}\n name={path}\n onChange={setValue}\n placeholder={getTranslation(placeholder, i18n)}\n type=\"email\"\n value={(value as string) || ''}\n />\n {AfterInput}\n </div>\n {CustomDescription !== undefined ? (\n CustomDescription\n ) : (\n <FieldDescription {...(descriptionProps || {})} />\n )}\n </div>\n )\n}\n\nexport const Email = withCondition(EmailField)\n"],"names":["getTranslation","FieldDescription","FieldError","FieldLabel","useFieldProps","React","useCallback","useField","withCondition","useTranslation","fieldBaseClass","EmailField","props","name","AfterInput","BeforeInput","CustomDescription","CustomError","CustomLabel","autoComplete","className","descriptionProps","errorProps","label","labelProps","path","pathFromProps","placeholder","readOnly","required","style","validate","width","i18n","memoizedValidate","value","options","pathFromContext","setValue","showError","div","filter","Boolean","join","input","disabled","id","replace","onChange","type","undefined","Email"],"mappings":"AAAA;AAIA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,SAASC,gBAAgB,QAA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Ac,CAAC,CAAC;sBACvE,oBAACnB;QACCe,aAAaA;QACbK,OAAOA;QACPM,UAAUA;QACT,GAAIL,cAAc,CAAC,CAAC;sBAEvB,oBAACgB,aACEzB,2BACD,oBAAC6B;QACCzB,cAAcA;QACd0B,UAAUH,QAAQd;QAClBkB,IAAI,CAAC,MAAM,EAAErB,KAAKsB,OAAO,CAAC,OAAO,MAAM,CAAC;QACxClC,MAAMY;QACNuB,UAAUV;QACVX,aAAa3B,eAAe2B,aAAaM;QACzCgB,MAAK;QACLd,OAAO,AAACA,SAAoB;QAE7BrB,aAEFE,sBAAsBkC,YACrBlC,kCAEA,oBAACf,kBAAsBoB,oBAAoB,CAAC;AAIpD;AAEA,OAAO,MAAM8B,QAAQ3C,cAAcG,YAAW"}
1
+ {"version":3,"sources":["../../../src/fields/Email/index.tsx"],"sourcesContent":["'use client'\nimport type { ClientValidate } from 'payload/types'\nimport type { EmailField as EmailFieldType, FieldBase } 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 { useFieldProps } from '@payloadcms/ui/forms/FieldPropsProvider'\nimport React, { useCallback } from 'react'\n\nimport type { FormFieldBase } from '../shared/index.js'\n\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { fieldBaseClass } from '../shared/index.js'\nimport './index.scss'\n\nexport type EmailFieldProps = FormFieldBase & {\n autoComplete?: string\n label?: FieldBase['label']\n name?: string\n path?: string\n placeholder?: EmailFieldType['admin']['placeholder']\n width?: string\n}\n\nconst EmailField: React.FC<EmailFieldProps> = (props) => {\n const {\n name,\n AfterInput,\n BeforeInput,\n CustomDescription,\n CustomError,\n CustomLabel,\n autoComplete,\n className,\n descriptionProps,\n errorProps,\n label,\n labelProps,\n path: pathFromProps,\n placeholder,\n readOnly: readOnlyFromProps,\n required,\n style,\n validate,\n width,\n } = props\n\n const { i18n } = useTranslation()\n\n const memoizedValidate: ClientValidate = 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 { path, setValue, showError, value } = useField({\n path: pathFromContext || pathFromProps || name,\n validate: memoizedValidate,\n })\n\n return (\n <div\n className={[fieldBaseClass, 'email', className, showError && 'error', readOnly && 'read-only']\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 <div>\n {BeforeInput}\n <input\n autoComplete={autoComplete}\n disabled={readOnly}\n id={`field-${path.replace(/\\./g, '__')}`}\n name={path}\n onChange={setValue}\n placeholder={getTranslation(placeholder, i18n)}\n type=\"email\"\n value={(value as string) || ''}\n />\n {AfterInput}\n </div>\n {CustomDescription !== undefined ? (\n CustomDescription\n ) : (\n <FieldDescription {...(descriptionProps || {})} />\n )}\n </div>\n )\n}\n\nexport const Email = withCondition(EmailField)\n"],"names":["getTranslation","FieldDescription","FieldError","FieldLabel","useFieldProps","React","useCallback","useField","withCondition","useTranslation","fieldBaseClass","EmailField","props","name","AfterInput","BeforeInput","CustomDescription","CustomError","CustomLabel","autoComplete","className","descriptionProps","errorProps","label","labelProps","path","pathFromProps","placeholder","readOnly","readOnlyFromProps","required","style","validate","width","i18n","memoizedValidate","value","options","pathFromContext","readOnlyFromContext","setValue","showError","div","filter","Boolean","join","input","disabled","id","replace","onChange","type","undefined","Email"],"mappings":"AAAA;AAIA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,SAASC,gBAAgB,QAAQ,wCAAuC;AACxE,SAASC,UAAU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AC,EAAE,MAAM,CAAA;CACf,CAAA;AAuFD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAA;AAElC,eAAO,MAAM,KAAK,2BAA4B,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/Group/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAI9C,OAAO,KAAmB,MAAM,OAAO,CAAA;AAEvC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yDAAyD,CAAA;AACvF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAavD,OAAO,cAAc,CAAA;AACrB,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAIvD,MAAM,MAAM,eAAe,GAAG,aAAa,GAAG;IAC5C,QAAQ,EAAE,QAAQ,CAAA;IAClB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,KAAK,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,CAAA;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,gBAAgB,CAAA;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAyFD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAA;AAElC,eAAO,MAAM,KAAK,2BAA4B,CAAA"}
@@ -16,8 +16,8 @@ import { fieldBaseClass } from '../shared/index.js';
16
16
  import { GroupProvider, useGroup } from './provider.js';
17
17
  const baseClass = 'group-field';
18
18
  const GroupField = (props)=>{
19
- const { CustomDescription, CustomLabel, className, descriptionProps, fieldMap, hideGutter, labelProps, style, width } = props;
20
- const { path, permissions, readOnly, schemaPath } = useFieldProps();
19
+ const { CustomDescription, CustomLabel, className, descriptionProps, fieldMap, hideGutter, labelProps, readOnly: readOnlyFromProps, style, width } = props;
20
+ const { path, permissions, readOnly: readOnlyFromContext, schemaPath } = useFieldProps();
21
21
  const { i18n } = useTranslation();
22
22
  const isWithinCollapsible = useCollapsible();
23
23
  const isWithinGroup = useGroup();
@@ -29,6 +29,7 @@ const GroupField = (props)=>{
29
29
  const submitted = useFormSubmitted();
30
30
  const errorCount = errorPaths.length;
31
31
  const fieldHasErrors = submitted && errorCount > 0;
32
+ const readOnly = readOnlyFromProps || readOnlyFromContext;
32
33
  const isTopLevel = !(isWithinCollapsible || isWithinGroup || isWithinRow);
33
34
  return /*#__PURE__*/ React.createElement(Fragment, null, /*#__PURE__*/ React.createElement("div", {
34
35
  className: [
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/fields/Group/index.tsx"],"sourcesContent":["'use client'\nimport type { FieldPermissions } from 'payload/auth'\nimport type { FieldBase } from 'payload/types'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { FieldDescription } from '@payloadcms/ui/forms/FieldDescription'\nimport React, { Fragment } from 'react'\n\nimport type { FieldMap } from '../../providers/ComponentMap/buildComponentMap/types.js'\nimport type { FormFieldBase } from '../shared/index.js'\n\nimport { useCollapsible } from '../../elements/Collapsible/provider.js'\nimport { ErrorPill } from '../../elements/ErrorPill/index.js'\nimport { useFieldProps } from '../../forms/FieldPropsProvider/index.js'\nimport { useFormSubmitted } from '../../forms/Form/context.js'\nimport { RenderFields } from '../../forms/RenderFields/index.js'\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { useRow } from '../Row/provider.js'\nimport { useTabs } from '../Tabs/provider.js'\nimport { fieldBaseClass } from '../shared/index.js'\nimport './index.scss'\nimport { GroupProvider, useGroup } from './provider.js'\n\nconst baseClass = 'group-field'\n\nexport type GroupFieldProps = FormFieldBase & {\n fieldMap: FieldMap\n forceRender?: boolean\n hideGutter?: boolean\n label?: FieldBase['label']\n name?: string\n permissions: FieldPermissions\n width?: string\n}\n\nconst GroupField: React.FC<GroupFieldProps> = (props) => {\n const {\n CustomDescription,\n CustomLabel,\n className,\n descriptionProps,\n fieldMap,\n hideGutter,\n labelProps,\n style,\n width,\n } = props\n\n const { path, permissions, readOnly, schemaPath } = useFieldProps()\n const { i18n } = useTranslation()\n const isWithinCollapsible = useCollapsible()\n const isWithinGroup = useGroup()\n const isWithinRow = useRow()\n const isWithinTab = useTabs()\n const { errorPaths } = useField({ path })\n const submitted = useFormSubmitted()\n const errorCount = errorPaths.length\n const fieldHasErrors = submitted && errorCount > 0\n\n const isTopLevel = !(isWithinCollapsible || isWithinGroup || isWithinRow)\n\n return (\n <Fragment>\n <div\n className={[\n fieldBaseClass,\n baseClass,\n isTopLevel && `${baseClass}--top-level`,\n isWithinCollapsible && `${baseClass}--within-collapsible`,\n isWithinGroup && `${baseClass}--within-group`,\n isWithinRow && `${baseClass}--within-row`,\n isWithinTab && `${baseClass}--within-tab`,\n !hideGutter && isWithinGroup && `${baseClass}--gutter`,\n fieldHasErrors && `${baseClass}--has-error`,\n className,\n ]\n .filter(Boolean)\n .join(' ')}\n id={`field-${path?.replace(/\\./g, '__')}`}\n style={{\n ...style,\n width,\n }}\n >\n <GroupProvider>\n <div className={`${baseClass}__wrap`}>\n <div className={`${baseClass}__header`}>\n {(CustomLabel || CustomDescription || labelProps?.label) && (\n <header>\n {CustomLabel !== undefined ? (\n CustomLabel\n ) : labelProps?.label ? (\n <h3 className={`${baseClass}__title`}>\n {getTranslation(labelProps.label, i18n)}\n </h3>\n ) : null}\n {CustomDescription !== undefined ? (\n CustomDescription\n ) : (\n <FieldDescription {...(descriptionProps || {})} />\n )}\n </header>\n )}\n {fieldHasErrors && <ErrorPill count={errorCount} i18n={i18n} withMessage />}\n </div>\n <RenderFields\n fieldMap={fieldMap}\n margins=\"small\"\n path={path}\n permissions={permissions?.fields}\n readOnly={readOnly}\n schemaPath={schemaPath}\n />\n </div>\n </GroupProvider>\n </div>\n </Fragment>\n )\n}\n\nexport { GroupProvider, useGroup }\n\nexport const Group = withCondition(GroupField)\n"],"names":["getTranslation","FieldDescription","React","Fragment","useCollapsible","ErrorPill","useFieldProps","useFormSubmitted","RenderFields","useField","withCondition","useTranslation","useRow","useTabs","fieldBaseClass","GroupProvider","useGroup","baseClass","GroupField","props","CustomDescription","CustomLabel","className","descriptionProps","fieldMap","hideGutter","labelProps","style","width","path","permissions","readOnly","schemaPath","i18n","isWithinCollapsible","isWithinGroup","isWithinRow","isWithinTab","errorPaths","submitted","errorCount","length","fieldHasErrors","isTopLevel","div","filter","Boolean","join","id","replace","label","header","undefined","h3","count","withMessage","margins","fields","Group"],"mappings":"AAAA;AAIA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,SAASC,gBAAgB,QAAQ,wCAAuC;AACxE,OAAOC,SAASC,QAAQ,QAAQ,QAAO;AAKvC,SAASC,cAAc,QAAQ,yCAAwC;AACvE,SAASC,SAAS,QAAQ,oCAAmC;AAC7D,SAASC,aAAa,QAAQ,0CAAyC;AACvE,SAASC,gBAAgB,QAAQ,8BAA6B;AAC9D,SAASC,YAAY,QAAQ,oCAAmC;AAChE,SAASC,QAAQ,QAAQ,gCAA+B;AACxD,SAASC,aAAa,QAAQ,qCAAoC;AAClE,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,MAAM,QAAQ,qBAAoB;AAC3C,SAASC,OAAO,QAAQ,sBAAqB;AAC7C,SAASC,cAAc,QAAQ,qBAAoB;AAEnD,SAASC,aAAa,EAAEC,QAAQ,QAAQ,gBAAe;AAEvD,MAAMC,YAAY;AAYlB,MAAMC,aAAwC,CAACC;IAC7C,MAAM,EACJC,iBAAiB,EACjBC,WAAW,EACXC,SAAS,EACTC,gBAAgB,EAChBC,QAAQ,EACRC,UAAU,EACVC,UAAU,EACVC,KAAK,EACLC,KAAK,EACN,GAAGT;IAEJ,MAAM,EAAEU,IAAI,EAAEC,WAAW,EAAEC,QAAQ,EAAEC,UAAU,EAAE,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C;OACjCjB,eAAe0B,WAAWwB,KAAK,EAAEjB,SAElC,MACHb,sBAAsBgC,YACrBhC,kCAEA,oBAACnB,kBAAsBsB,oBAAoB,CAAC,KAIjDmB,gCAAkB,oBAACrC;QAAUiD,OAAOd;QAAYP,MAAMA;QAAMsB,aAAAA;uBAE/D,oBAAC/C;QACCgB,UAAUA;QACVgC,SAAQ;QACR3B,MAAMA;QACNC,aAAaA,aAAa2B;QAC1B1B,UAAUA;QACVC,YAAYA;;AAO1B;AAEA,SAASjB,aAAa,EAAEC,QAAQ,GAAE;AAElC,OAAO,MAAM0C,QAAQhD,cAAcQ,YAAW"}
1
+ {"version":3,"sources":["../../../src/fields/Group/index.tsx"],"sourcesContent":["'use client'\nimport type { FieldPermissions } from 'payload/auth'\nimport type { FieldBase } from 'payload/types'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { FieldDescription } from '@payloadcms/ui/forms/FieldDescription'\nimport React, { Fragment } from 'react'\n\nimport type { FieldMap } from '../../providers/ComponentMap/buildComponentMap/types.js'\nimport type { FormFieldBase } from '../shared/index.js'\n\nimport { useCollapsible } from '../../elements/Collapsible/provider.js'\nimport { ErrorPill } from '../../elements/ErrorPill/index.js'\nimport { useFieldProps } from '../../forms/FieldPropsProvider/index.js'\nimport { useFormSubmitted } from '../../forms/Form/context.js'\nimport { RenderFields } from '../../forms/RenderFields/index.js'\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { useRow } from '../Row/provider.js'\nimport { useTabs } from '../Tabs/provider.js'\nimport { fieldBaseClass } from '../shared/index.js'\nimport './index.scss'\nimport { GroupProvider, useGroup } from './provider.js'\n\nconst baseClass = 'group-field'\n\nexport type GroupFieldProps = FormFieldBase & {\n fieldMap: FieldMap\n forceRender?: boolean\n hideGutter?: boolean\n label?: FieldBase['label']\n name?: string\n permissions: FieldPermissions\n width?: string\n}\n\nconst GroupField: React.FC<GroupFieldProps> = (props) => {\n const {\n CustomDescription,\n CustomLabel,\n className,\n descriptionProps,\n fieldMap,\n hideGutter,\n labelProps,\n readOnly: readOnlyFromProps,\n style,\n width,\n } = props\n\n const { path, permissions, readOnly: readOnlyFromContext, schemaPath } = useFieldProps()\n const { i18n } = useTranslation()\n const isWithinCollapsible = useCollapsible()\n const isWithinGroup = useGroup()\n const isWithinRow = useRow()\n const isWithinTab = useTabs()\n const { errorPaths } = useField({ path })\n const submitted = useFormSubmitted()\n const errorCount = errorPaths.length\n const fieldHasErrors = submitted && errorCount > 0\n const readOnly = readOnlyFromProps || readOnlyFromContext\n\n const isTopLevel = !(isWithinCollapsible || isWithinGroup || isWithinRow)\n\n return (\n <Fragment>\n <div\n className={[\n fieldBaseClass,\n baseClass,\n isTopLevel && `${baseClass}--top-level`,\n isWithinCollapsible && `${baseClass}--within-collapsible`,\n isWithinGroup && `${baseClass}--within-group`,\n isWithinRow && `${baseClass}--within-row`,\n isWithinTab && `${baseClass}--within-tab`,\n !hideGutter && isWithinGroup && `${baseClass}--gutter`,\n fieldHasErrors && `${baseClass}--has-error`,\n className,\n ]\n .filter(Boolean)\n .join(' ')}\n id={`field-${path?.replace(/\\./g, '__')}`}\n style={{\n ...style,\n width,\n }}\n >\n <GroupProvider>\n <div className={`${baseClass}__wrap`}>\n <div className={`${baseClass}__header`}>\n {(CustomLabel || CustomDescription || labelProps?.label) && (\n <header>\n {CustomLabel !== undefined ? (\n CustomLabel\n ) : labelProps?.label ? (\n <h3 className={`${baseClass}__title`}>\n {getTranslation(labelProps.label, i18n)}\n </h3>\n ) : null}\n {CustomDescription !== undefined ? (\n CustomDescription\n ) : (\n <FieldDescription {...(descriptionProps || {})} />\n )}\n </header>\n )}\n {fieldHasErrors && <ErrorPill count={errorCount} i18n={i18n} withMessage />}\n </div>\n <RenderFields\n fieldMap={fieldMap}\n margins=\"small\"\n path={path}\n permissions={permissions?.fields}\n readOnly={readOnly}\n schemaPath={schemaPath}\n />\n </div>\n </GroupProvider>\n </div>\n </Fragment>\n )\n}\n\nexport { GroupProvider, useGroup }\n\nexport const Group = withCondition(GroupField)\n"],"names":["getTranslation","FieldDescription","React","Fragment","useCollapsible","ErrorPill","useFieldProps","useFormSubmitted","RenderFields","useField","withCondition","useTranslation","useRow","useTabs","fieldBaseClass","GroupProvider","useGroup","baseClass","GroupField","props","CustomDescription","CustomLabel","className","descriptionProps","fieldMap","hideGutter","labelProps","readOnly","readOnlyFromProps","style","width","path","permissions","readOnlyFromContext","schemaPath","i18n","isWithinCollapsible","isWithinGroup","isWithinRow","isWithinTab","errorPaths","submitted","errorCount","length","fieldHasErrors","isTopLevel","div","filter","Boolean","join","id","replace","label","header","undefined","h3","count","withMessage","margins","fields","Group"],"mappings":"AAAA;AAIA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,SAASC,gBAAgB,QAAQ,wCAAuC;AACxE,OAAOC,SAASC,QAAQ,QAAQ,QAAO;AAKvC,SAASC,cAAc,QAAQ,yCAAwC;AACvE,SAASC,SAAS,QAAQ,oCAAmC;AAC7D,SAASC,aAAa,QAAQ,0CAAyC;AACvE,SAASC,gBAAgB,QAAQ,8BAA6B;AAC9D,SAASC,YAAY,QAAQ,oCAAmC;AAChE,SAASC,QAAQ,QAAQ,gCAA+B;AACxD,SAASC,aAAa,QAAQ,qCAAoC;AAClE,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,MAAM,QAAQ,qBAAoB;AAC3C,SAASC,OAAO,QAAQ,sBAAqB;AAC7C,SAASC,cAAc,QAAQ,qBAAoB;AAEnD,SAASC,aAAa,EAAEC,QAAQ,QAAQ,gBAAe;AAEvD,MAAMC,YAAY;AAYlB,MAAMC,aAAwC,CAACC;IAC7C,MAAM,EACJC,iBAAiB,EACjBC,WAAW,EACXC,SAAS,EACTC,gBAAgB,EAChBC,QAAQ,EACRC,UAAU,EACVC,UAAU,EACVC,UAAUC,iBAAiB,EAC3BC,KAAK,EACLC,KAAK,EACN,GAAGX;IAEJ,MAAM,EA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ACC,gBACEhC,gBAAgBiC,YACfjC,cACEK,YAAY0B,sBACd,oBAACG;QAAGjC,WAAW,CAAC,EAAEL,UAAU,OAAO,CAAC;OACjCjB,eAAe0B,WAAW0B,KAAK,EAAEjB,SAElC,MACHf,sBAAsBkC,YACrBlC,kCAEA,oBAACnB,kBAAsBsB,oBAAoB,CAAC,KAIjDqB,gCAAkB,oBAACvC;QAAUmD,OAAOd;QAAYP,MAAMA;QAAMsB,aAAAA;uBAE/D,oBAACjD;QACCgB,UAAUA;QACVkC,SAAQ;QACR3B,MAAMA;QACNC,aAAaA,aAAa2B;QAC1BhC,UAAUA;QACVO,YAAYA;;AAO1B;AAEA,SAASnB,aAAa,EAAEC,QAAQ,GAAE;AAElC,OAAO,MAAM4C,QAAQlD,cAAcQ,YAAW"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/JSON/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAA2C,MAAM,OAAO,CAAA;AAO/D,OAAO,cAAc,CAAA;AAIrB,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,eAAe,CAAA;AAM1E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAEvD,MAAM,MAAM,cAAc,GAAG,aAAa,GAAG;IAC3C,aAAa,CAAC,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC,eAAe,CAAC,CAAA;IACvD,KAAK,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,CAAA;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AA8GD,eAAO,MAAM,SAAS,0BAAoC,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/JSON/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAA2C,MAAM,OAAO,CAAA;AAO/D,OAAO,cAAc,CAAA;AAIrB,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,eAAe,CAAA;AAM1E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAEvD,MAAM,MAAM,cAAc,GAAG,aAAa,GAAG;IAC3C,aAAa,CAAC,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC,eAAe,CAAC,CAAA;IACvD,KAAK,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,CAAA;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AA+GD,eAAO,MAAM,SAAS,0BAAoC,CAAA"}
@@ -10,7 +10,7 @@ import { FieldDescription } from '@payloadcms/ui/forms/FieldDescription';
10
10
  import { FieldError } from '@payloadcms/ui/forms/FieldError';
11
11
  import { useFieldProps } from '@payloadcms/ui/forms/FieldPropsProvider';
12
12
  const JSONFieldComponent = (props)=>{
13
- const { name, AfterInput, BeforeInput, CustomDescription, CustomError, CustomLabel, className, descriptionProps, editorOptions, errorProps, label, labelProps, path: pathFromProps, readOnly, required, style, validate, width } = props;
13
+ const { name, AfterInput, BeforeInput, CustomDescription, CustomError, CustomLabel, className, descriptionProps, editorOptions, errorProps, label, labelProps, path: pathFromProps, readOnly: readOnlyFromProps, required, style, validate, width } = props;
14
14
  const [stringValue, setStringValue] = useState();
15
15
  const [jsonError, setJsonError] = useState();
16
16
  const [hasLoadedValue, setHasLoadedValue] = useState(false);
@@ -25,7 +25,8 @@ const JSONFieldComponent = (props)=>{
25
25
  required,
26
26
  jsonError
27
27
  ]);
28
- const { path: pathFromContext } = useFieldProps();
28
+ const { path: pathFromContext, readOnly: readOnlyFromContext } = useFieldProps();
29
+ const readOnly = readOnlyFromProps || readOnlyFromContext;
29
30
  const { initialValue, path, setValue, showError, value } = useField({
30
31
  path: pathFromContext || pathFromProps || name,
31
32
  validate: memoizedValidate
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/fields/JSON/index.tsx"],"sourcesContent":["'use client'\nimport type { ClientValidate } from 'payload/types'\n\nimport React, { useCallback, useEffect, useState } from 'react'\n\nimport { CodeEditor } from '../../elements/CodeEditor/index.js'\nimport { FieldLabel } from '../../forms/FieldLabel/index.js'\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { fieldBaseClass } from '../shared/index.js'\nimport './index.scss'\n\nconst baseClass = 'json-field'\n\nimport type { FieldBase, JSONField as JSONFieldType } from 'payload/types'\n\nimport { FieldDescription } from '@payloadcms/ui/forms/FieldDescription'\nimport { FieldError } from '@payloadcms/ui/forms/FieldError'\nimport { useFieldProps } from '@payloadcms/ui/forms/FieldPropsProvider'\n\nimport type { FormFieldBase } from '../shared/index.js'\n\nexport type JSONFieldProps = FormFieldBase & {\n editorOptions?: JSONFieldType['admin']['editorOptions']\n label?: FieldBase['label']\n name?: string\n path?: string\n width?: string\n}\n\nconst JSONFieldComponent: React.FC<JSONFieldProps> = (props) => {\n const {\n name,\n AfterInput,\n BeforeInput,\n CustomDescription,\n CustomError,\n CustomLabel,\n className,\n descriptionProps,\n editorOptions,\n errorProps,\n label,\n labelProps,\n path: pathFromProps,\n readOnly,\n required,\n style,\n validate,\n width,\n } = props\n\n const [stringValue, setStringValue] = useState<string>()\n const [jsonError, setJsonError] = useState<string>()\n const [hasLoadedValue, setHasLoadedValue] = useState(false)\n\n const memoizedValidate: ClientValidate = useCallback(\n (value, options) => {\n if (typeof validate === 'function')\n return validate(value, { ...options, jsonError, required })\n },\n [validate, required, jsonError],\n )\n\n const { path: pathFromContext } = useFieldProps()\n\n const { initialValue, path, setValue, showError, value } = useField<string>({\n path: pathFromContext || pathFromProps || name,\n validate: memoizedValidate,\n })\n\n const handleChange = useCallback(\n (val) => {\n if (readOnly) return\n setStringValue(val)\n\n try {\n setValue(val ? JSON.parse(val) : null)\n setJsonError(undefined)\n } catch (e) {\n setValue(val ? val : null)\n setJsonError(e)\n }\n },\n [readOnly, setValue, setStringValue],\n )\n\n useEffect(() => {\n if (hasLoadedValue) return\n setStringValue(\n value || initialValue ? JSON.stringify(value ? value : initialValue, null, 2) : '',\n )\n setHasLoadedValue(true)\n }, [initialValue, value, hasLoadedValue])\n\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} path={path} {...(errorProps || {})} />\n <FieldLabel\n CustomLabel={CustomLabel}\n label={label}\n required={required}\n {...(labelProps || {})}\n />\n <div>\n {BeforeInput}\n <CodeEditor\n defaultLanguage=\"json\"\n onChange={handleChange}\n options={editorOptions}\n readOnly={readOnly}\n value={stringValue}\n />\n {AfterInput}\n </div>\n {CustomDescription !== undefined ? (\n CustomDescription\n ) : (\n <FieldDescription {...(descriptionProps || {})} />\n )}\n </div>\n )\n}\n\nexport const JSONField = withCondition(JSONFieldComponent)\n"],"names":["React","useCallback","useEffect","useState","CodeEditor","FieldLabel","useField","withCondition","fieldBaseClass","baseClass","FieldDescription","FieldError","useFieldProps","JSONFieldComponent","props","name","AfterInput","BeforeInput","CustomDescription","CustomError","CustomLabel","className","descriptionProps","editorOptions","errorProps","label","labelProps","path","pathFromProps","readOnly","required","style","validate","width","stringValue","setStringValue","jsonError","setJsonError","hasLoadedValue","setHasLoadedValue","memoizedValidate","value","options","pathFromContext","initialValue","setValue","showError","handleChange","val","JSON","parse","undefined","e","stringify","div","filter","Boolean","join","defaultLanguage","onChange","JSONField"],"mappings":"AAAA;AAGA,OAAOA,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAE/D,SAASC,UAAU,QAAQ,qCAAoC;AAC/D,SAASC,UAAU,QAAQ,kCAAiC;AAC5D,SAASC,QAAQ,QAAQ,gCAA+B;AACxD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AUV;KAAe;IAGtCjC,UAAU;QACR,IAAIoC,gBAAgB;QACpBH,eACEM,SAASG,eAAeK,KAAKI,SAAS,CAACZ,QAAQA,QAAQG,cAAc,MAAM,KAAK;QAElFL,kBAAkB;IACpB,GAAG;QAACK;QAAcH;QAAOH;KAAe;IAExC,qBACE,oBAACgB;QACCjC,WAAW;YACTb;YACAC;YACAY;YACAyB,aAAa;YACbjB,YAAY;SACb,CACE0B,MAAM,CAACC,SACPC,IAAI,CAAC;QACR1B,OAAO;YACL,GAAGA,KAAK;YACRE;QACF;qBAEA,oBAACtB;QAAWQ,aAAaA;QAAaQ,MAAMA;QAAO,GAAIH,cAAc,CAAC,CAAC;sBACvE,oBAACnB;QACCe,aAAaA;QACbK,OAAOA;QACPK,UAAUA;QACT,GAAIJ,cAAc,CAAC,CAAC;sBAEvB,oBAAC4B,aACErC,2BACD,oBAACb;QACCsD,iBAAgB;QAChBC,UAAUZ;QACVL,SAASnB;QACTM,UAAUA;QACVY,OAAOP;QAERlB,aAEFE,sBAAsBiC,YACrBjC,kCAEA,oBAACR,kBAAsBY,oBAAoB,CAAC;AAIpD;AAEA,OAAO,MAAMsC,YAAYrD,cAAcM,oBAAmB"}
1
+ {"version":3,"sources":["../../../src/fields/JSON/index.tsx"],"sourcesContent":["'use client'\nimport type { ClientValidate } from 'payload/types'\n\nimport React, { useCallback, useEffect, useState } from 'react'\n\nimport { CodeEditor } from '../../elements/CodeEditor/index.js'\nimport { FieldLabel } from '../../forms/FieldLabel/index.js'\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { fieldBaseClass } from '../shared/index.js'\nimport './index.scss'\n\nconst baseClass = 'json-field'\n\nimport type { FieldBase, JSONField as JSONFieldType } from 'payload/types'\n\nimport { FieldDescription } from '@payloadcms/ui/forms/FieldDescription'\nimport { FieldError } from '@payloadcms/ui/forms/FieldError'\nimport { useFieldProps } from '@payloadcms/ui/forms/FieldPropsProvider'\n\nimport type { FormFieldBase } from '../shared/index.js'\n\nexport type JSONFieldProps = FormFieldBase & {\n editorOptions?: JSONFieldType['admin']['editorOptions']\n label?: FieldBase['label']\n name?: string\n path?: string\n width?: string\n}\n\nconst JSONFieldComponent: React.FC<JSONFieldProps> = (props) => {\n const {\n name,\n AfterInput,\n BeforeInput,\n CustomDescription,\n CustomError,\n CustomLabel,\n className,\n descriptionProps,\n editorOptions,\n errorProps,\n label,\n labelProps,\n path: pathFromProps,\n readOnly: readOnlyFromProps,\n required,\n style,\n validate,\n width,\n } = props\n\n const [stringValue, setStringValue] = useState<string>()\n const [jsonError, setJsonError] = useState<string>()\n const [hasLoadedValue, setHasLoadedValue] = useState(false)\n\n const memoizedValidate: ClientValidate = useCallback(\n (value, options) => {\n if (typeof validate === 'function')\n return validate(value, { ...options, jsonError, required })\n },\n [validate, required, jsonError],\n )\n\n const { path: pathFromContext, readOnly: readOnlyFromContext } = useFieldProps()\n const readOnly = readOnlyFromProps || readOnlyFromContext\n\n const { initialValue, path, setValue, showError, value } = useField<string>({\n path: pathFromContext || pathFromProps || name,\n validate: memoizedValidate,\n })\n\n const handleChange = useCallback(\n (val) => {\n if (readOnly) return\n setStringValue(val)\n\n try {\n setValue(val ? JSON.parse(val) : null)\n setJsonError(undefined)\n } catch (e) {\n setValue(val ? val : null)\n setJsonError(e)\n }\n },\n [readOnly, setValue, setStringValue],\n )\n\n useEffect(() => {\n if (hasLoadedValue) return\n setStringValue(\n value || initialValue ? JSON.stringify(value ? value : initialValue, null, 2) : '',\n )\n setHasLoadedValue(true)\n }, [initialValue, value, hasLoadedValue])\n\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} path={path} {...(errorProps || {})} />\n <FieldLabel\n CustomLabel={CustomLabel}\n label={label}\n required={required}\n {...(labelProps || {})}\n />\n <div>\n {BeforeInput}\n <CodeEditor\n defaultLanguage=\"json\"\n onChange={handleChange}\n options={editorOptions}\n readOnly={readOnly}\n value={stringValue}\n />\n {AfterInput}\n </div>\n {CustomDescription !== undefined ? (\n CustomDescription\n ) : (\n <FieldDescription {...(descriptionProps || {})} />\n )}\n </div>\n )\n}\n\nexport const JSONField = withCondition(JSONFieldComponent)\n"],"names":["React","useCallback","useEffect","useState","CodeEditor","FieldLabel","useField","withCondition","fieldBaseClass","baseClass","FieldDescription","FieldError","useFieldProps","JSONFieldComponent","props","name","AfterInput","BeforeInput","CustomDescription","CustomError","CustomLabel","className","descriptionProps","editorOptions","errorProps","label","labelProps","path","pathFromProps","readOnly","readOnlyFromProps","required","style","validate","width","stringValue","setStringValue","jsonError","setJsonError","hasLoadedValue","setHasLoadedValue","memoizedValidate","value","options","pathFromContext","readOnlyFromContext","initialValue","setValue","showError","handleChange","val","JSON","parse","undefined","e","stringify","div","filter","Boolean","join","defaultLanguage","onChange","JSONField"],"mappings":"AAAA;AAGA,OAAOA,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAE/D,SAASC,UAAU,QAAQ,qCAAoC;AAC/D,SAASC,UAAU,QAAQ,kCAAiC;AAC5D,SAASC,QAAQ,QAAQ,gCAA+B;AACxD,SAASC,aAAa,QAAQ,qCAAoC;AAClE,SAASC,cAAc,QAAQ,qBAAoB;AAGnD,MAAMC,YAAY;AAIlB,SAASC,gBAAgB,QAAQ,wCAAuC;AACxE,SAASC,UAAU,QAAQ,kCAAiC;AAC5D,SAASC,aAAa,QAAQ,0CAAyC;AAYvE,MAAMC,qBAA+C,CAACC;IACpD,MAAM,EACJC,IAAI,EACJC,UAAU,EACVC,WAAW,EACXC,iBAAiB,EACjBC,WAAW,EACXC,WAAW,EACXC,SAAS,EACTC,gBAAgB,EAChBC,aAAa,EACbC,UAAU,EACVC,KAAK,EACLC,UAAU,EACVC,MAAMC,aAAa,EACnBC,UAAUC,iBAAiB,EAC3BC,QAAQ,EACRC,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AAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/Number/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,IAAI,eAAe,EAAE,MAAM,eAAe,CAAA;AAQ9E,OAAO,KAA2C,MAAM,OAAO,CAAA;AAG/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAOvD,OAAO,cAAc,CAAA;AAErB,MAAM,MAAM,gBAAgB,GAAG,aAAa,GAAG;IAC7C,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,KAAK,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,CAAA;IAC1B,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,eAAe,CAAC,OAAO,CAAC,CAAC,aAAa,CAAC,CAAA;IACrD,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AA8LD,eAAO,MAAM,WAAW,4BAAsC,CAAA"}
@@ -12,7 +12,7 @@ import { withCondition } from '../../forms/withCondition/index.js';
12
12
  import { useTranslation } from '../../providers/Translation/index.js';
13
13
  import { fieldBaseClass } from '../shared/index.js';
14
14
  const NumberFieldComponent = (props)=>{
15
- const { name, AfterInput, BeforeInput, CustomDescription, CustomError, CustomLabel, className, descriptionProps, errorProps, hasMany = false, label, labelProps, max = Infinity, maxRows = Infinity, min = -Infinity, onChange: onChangeFromProps, path: pathFromProps, placeholder, readOnly, required, step = 1, style, validate, width } = props;
15
+ const { name, AfterInput, BeforeInput, CustomDescription, CustomError, CustomLabel, className, descriptionProps, errorProps, hasMany = false, label, labelProps, max = Infinity, maxRows = Infinity, min = -Infinity, onChange: onChangeFromProps, path: pathFromProps, placeholder, readOnly: readOnlyFromProps, required, step = 1, style, validate, width } = props;
16
16
  const { i18n, t } = useTranslation();
17
17
  const memoizedValidate = useCallback((value, options)=>{
18
18
  if (typeof validate === 'function') {
@@ -29,7 +29,8 @@ const NumberFieldComponent = (props)=>{
29
29
  max,
30
30
  required
31
31
  ]);
32
- const { path: pathFromContext } = useFieldProps();
32
+ const { path: pathFromContext, readOnly: readOnlyFromContext } = useFieldProps();
33
+ const readOnly = readOnlyFromProps || readOnlyFromContext;
33
34
  const { path, setValue, showError, value } = useField({
34
35
  path: pathFromContext || pathFromProps || name,
35
36
  validate: memoizedValidate
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/fields/Number/index.tsx"],"sourcesContent":["/* eslint-disable react/destructuring-assignment */\n'use client'\nimport type { FieldBase, NumberField as NumberFieldType } 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 { useFieldProps } from '@payloadcms/ui/forms/FieldPropsProvider'\nimport { isNumber } from 'payload/utilities'\nimport React, { useCallback, useEffect, useState } from 'react'\n\nimport type { Option } from '../../elements/ReactSelect/types.js'\nimport type { FormFieldBase } from '../shared/index.js'\n\nimport { ReactSelect } from '../../elements/ReactSelect/index.js'\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { fieldBaseClass } from '../shared/index.js'\nimport './index.scss'\n\nexport type NumberFieldProps = FormFieldBase & {\n hasMany?: boolean\n label?: FieldBase['label']\n max?: number\n maxRows?: number\n min?: number\n name?: string\n onChange?: (e: number) => void\n path?: string\n placeholder?: NumberFieldType['admin']['placeholder']\n step?: number\n width?: string\n}\n\nconst NumberFieldComponent: React.FC<NumberFieldProps> = (props) => {\n const {\n name,\n AfterInput,\n BeforeInput,\n CustomDescription,\n CustomError,\n CustomLabel,\n className,\n descriptionProps,\n errorProps,\n hasMany = false,\n label,\n labelProps,\n max = Infinity,\n maxRows = Infinity,\n min = -Infinity,\n onChange: onChangeFromProps,\n path: pathFromProps,\n placeholder,\n readOnly,\n required,\n step = 1,\n style,\n validate,\n width,\n } = props\n\n const { i18n, t } = useTranslation()\n\n const memoizedValidate = useCallback(\n (value, options) => {\n if (typeof validate === 'function') {\n return validate(value, { ...options, max, min, required })\n }\n },\n [validate, min, max, required],\n )\n\n const { path: pathFromContext } = useFieldProps()\n\n const { path, setValue, showError, value } = useField<number | number[]>({\n path: pathFromContext || pathFromProps || name,\n validate: memoizedValidate,\n })\n\n const handleChange = useCallback(\n (e) => {\n const val = parseFloat(e.target.value)\n let newVal = val\n\n if (Number.isNaN(val)) {\n newVal = undefined\n }\n\n if (typeof onChangeFromProps === 'function') {\n onChangeFromProps(newVal)\n }\n\n setValue(newVal)\n },\n [onChangeFromProps, setValue],\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) => Number(option.value?.value || option.value))\n } else {\n newValue = [Number(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 toString: () => `${val}${index}`,\n value: (val as unknown as Record<string, number>)?.value || val,\n }, // You're probably wondering, why the hell is this done that way? Well, 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 }\n }),\n )\n }\n }, [value, hasMany])\n\n return (\n <div\n className={[\n fieldBaseClass,\n 'number',\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 <FieldLabel\n CustomLabel={CustomLabel}\n label={label}\n required={required}\n {...(labelProps || {})}\n />\n <FieldError CustomError={CustomError} path={path} {...(errorProps || {})} />\n {hasMany ? (\n <ReactSelect\n className={`field-${path.replace(/\\./g, '__')}`}\n disabled={readOnly}\n filterOption={(_, rawInput) => {\n // eslint-disable-next-line no-restricted-globals\n const isOverHasMany = Array.isArray(value) && value.length >= maxRows\n return isNumber(rawInput) && !isOverHasMany\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 // numberOnly\n onChange={handleHasManyChange}\n options={[]}\n placeholder={t('general:enterAValue')}\n showError={showError}\n value={valueToRender as Option[]}\n />\n ) : (\n <div>\n {BeforeInput}\n <input\n disabled={readOnly}\n id={`field-${path.replace(/\\./g, '__')}`}\n max={max}\n min={min}\n name={path}\n onChange={handleChange}\n onWheel={(e) => {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n e.target.blur()\n }}\n placeholder={getTranslation(placeholder, i18n)}\n step={step}\n type=\"number\"\n value={typeof value === 'number' ? value : ''}\n />\n {AfterInput}\n </div>\n )}\n {CustomDescription !== undefined ? (\n CustomDescription\n ) : (\n <FieldDescription {...(descriptionProps || {})} />\n )}\n </div>\n )\n}\n\nexport const NumberField = withCondition(NumberFieldComponent)\n"],"names":["getTranslation","FieldDescription","FieldError","FieldLabel","useFieldProps","isNumber","React","useCallback","useEffect","useState","ReactSelect","useField","withCondition","useTranslation","fieldBaseClass","NumberFieldComponent","props","name","AfterInput","BeforeInput","CustomDescription","CustomError","CustomLabel","className","descriptionProps","errorProps","hasMany","label","labelProps","max","Infinity","maxRows","min","onChange","onChangeFromProps","path","pathFromProps","placeholder","readOnly","required","step","style","validate","width","i18n","t","memoizedValidate","value","options","pathFromContext","setValue","showError","handleChange","e","val","parseFloat","target","newVal","Number","isNaN","undefined","valueToRender","setValueToRender","handleHasManyChange","selectedOption","newValue","Array","isArray","map","option","index","id","toString","div","filter","Boolean","join","replace","disabled","filterOption","_","rawInput","isOverHasMany","length","isClearable","isCreatable","isMulti","isSortable","noOptionsMessage","input","onWheel","blur","type","NumberField"],"mappings":"AAAA,iDAAiD,GACjD;AAGA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,SAASC,gBAAgB,QAAQ,wCAAuC;AACxE,SAASC,UAAU,QAAQ,kCAAiC;AAC5D,SAASC,UAAU,QAAQ,kCAAiC;AAC5D,SAASC,aAAa,QAAQ,0CAAyC;AACvE,SAASC,QAAQ,QAAQ,oBAAmB;AAC5C,OAAOC,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAK/D,SAASC,WAAW,QAAQ,sCAAqC;AACjE,SAASC,QAAQ,QAAQ,gCAA+B;AACxD,SAASC,aAAa,QAAQ,qCAAoC;AAClE,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,cAAc,QAAQ,qBAAoB;AAiBnD,MAAMC,uBAAmD,CAACC;IACxD,MAAM,EACJC,IAAI,EACJC,UAAU,EACVC,WAAW,EACXC,iBAAiB,EACjBC,WAAW,EACXC,WAAW,EACXC,SAAS,EACTC,gBAAgB,EAChBC,UAAU,EACVC,UAAU,KAAK,EACfC,KAAK,EACLC,UAAU,EACVC,MAAMC,QAAQ,EACdC,UAAUD,QAAQ,EAClBE,MAAM,CAACF,QAAQ,EACfG,UAAUC,iBAAiB,EAC3BC,MAAMC,aA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,MAAM,IAAIpD;YAC9D,IAAImD,eAAe;gBACjB,OAAOrC,EAAE,2BAA2B;oBAAEhB,KAAKE;oBAASgB,OAAOA,MAAMoC,MAAM,GAAG;gBAAE;YAC9E;YACA,OAAO;QACT;QACA,aAAa;QACblD,UAAU8B;QACVf,SAAS,EAAE;QACXX,aAAaQ,EAAE;QACfM,WAAWA;QACXJ,OAAOc;uBAGT,oBAACY,aACEtD,2BACD,oBAACsE;QACCX,UAAUxC;QACViC,IAAI,CAAC,MAAM,EAAEpC,KAAK0C,OAAO,CAAC,OAAO,MAAM,CAAC;QACxChD,KAAKA;QACLG,KAAKA;QACLf,MAAMkB;QACNF,UAAUmB;QACVsC,SAAS,CAACrC;YACR,6DAA6D;YAC7D,mBAAmB;YACnBA,EAAEG,MAAM,CAACmC,IAAI;QACf;QACAtD,aAAarC,eAAeqC,aAAaO;QACzCJ,MAAMA;QACNoD,MAAK;QACL7C,OAAO,OAAOA,UAAU,WAAWA,QAAQ;QAE5C7B,aAGJE,sBAAsBwC,YACrBxC,kCAEA,oBAACnB,kBAAsBuB,oBAAoB,CAAC;AAIpD;AAEA,OAAO,MAAMqE,cAAcjF,cAAcG,sBAAqB"}
1
+ {"version":3,"sources":["../../../src/fields/Number/index.tsx"],"sourcesContent":["/* eslint-disable react/destructuring-assignment */\n'use client'\nimport type { FieldBase, NumberField as NumberFieldType } 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 { useFieldProps } from '@payloadcms/ui/forms/FieldPropsProvider'\nimport { isNumber } from 'payload/utilities'\nimport React, { useCallback, useEffect, useState } from 'react'\n\nimport type { Option } from '../../elements/ReactSelect/types.js'\nimport type { FormFieldBase } from '../shared/index.js'\n\nimport { ReactSelect } from '../../elements/ReactSelect/index.js'\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { fieldBaseClass } from '../shared/index.js'\nimport './index.scss'\n\nexport type NumberFieldProps = FormFieldBase & {\n hasMany?: boolean\n label?: FieldBase['label']\n max?: number\n maxRows?: number\n min?: number\n name?: string\n onChange?: (e: number) => void\n path?: string\n placeholder?: NumberFieldType['admin']['placeholder']\n step?: number\n width?: string\n}\n\nconst NumberFieldComponent: React.FC<NumberFieldProps> = (props) => {\n const {\n name,\n AfterInput,\n BeforeInput,\n CustomDescription,\n CustomError,\n CustomLabel,\n className,\n descriptionProps,\n errorProps,\n hasMany = false,\n label,\n labelProps,\n max = Infinity,\n maxRows = Infinity,\n min = -Infinity,\n onChange: onChangeFromProps,\n path: pathFromProps,\n placeholder,\n readOnly: readOnlyFromProps,\n required,\n step = 1,\n style,\n validate,\n width,\n } = props\n\n const { i18n, t } = useTranslation()\n\n const memoizedValidate = useCallback(\n (value, options) => {\n if (typeof validate === 'function') {\n return validate(value, { ...options, max, min, required })\n }\n },\n [validate, min, max, required],\n )\n\n const { path: pathFromContext, readOnly: readOnlyFromContext } = useFieldProps()\n const readOnly = readOnlyFromProps || readOnlyFromContext\n\n const { path, setValue, showError, value } = useField<number | number[]>({\n path: pathFromContext || pathFromProps || name,\n validate: memoizedValidate,\n })\n\n const handleChange = useCallback(\n (e) => {\n const val = parseFloat(e.target.value)\n let newVal = val\n\n if (Number.isNaN(val)) {\n newVal = undefined\n }\n\n if (typeof onChangeFromProps === 'function') {\n onChangeFromProps(newVal)\n }\n\n setValue(newVal)\n },\n [onChangeFromProps, setValue],\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) => Number(option.value?.value || option.value))\n } else {\n newValue = [Number(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 toString: () => `${val}${index}`,\n value: (val as unknown as Record<string, number>)?.value || val,\n }, // You're probably wondering, why the hell is this done that way? Well, 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 }\n }),\n )\n }\n }, [value, hasMany])\n\n return (\n <div\n className={[\n fieldBaseClass,\n 'number',\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 <FieldLabel\n CustomLabel={CustomLabel}\n label={label}\n required={required}\n {...(labelProps || {})}\n />\n <FieldError CustomError={CustomError} path={path} {...(errorProps || {})} />\n {hasMany ? (\n <ReactSelect\n className={`field-${path.replace(/\\./g, '__')}`}\n disabled={readOnly}\n filterOption={(_, rawInput) => {\n // eslint-disable-next-line no-restricted-globals\n const isOverHasMany = Array.isArray(value) && value.length >= maxRows\n return isNumber(rawInput) && !isOverHasMany\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 // numberOnly\n onChange={handleHasManyChange}\n options={[]}\n placeholder={t('general:enterAValue')}\n showError={showError}\n value={valueToRender as Option[]}\n />\n ) : (\n <div>\n {BeforeInput}\n <input\n disabled={readOnly}\n id={`field-${path.replace(/\\./g, '__')}`}\n max={max}\n min={min}\n name={path}\n onChange={handleChange}\n onWheel={(e) => {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n e.target.blur()\n }}\n placeholder={getTranslation(placeholder, i18n)}\n step={step}\n type=\"number\"\n value={typeof value === 'number' ? value : ''}\n />\n {AfterInput}\n </div>\n )}\n {CustomDescription !== undefined ? (\n CustomDescription\n ) : (\n <FieldDescription {...(descriptionProps || {})} />\n )}\n </div>\n )\n}\n\nexport const NumberField = withCondition(NumberFieldComponent)\n"],"names":["getTranslation","FieldDescription","FieldError","FieldLabel","useFieldProps","isNumber","React","useCallback","useEffect","useState","ReactSelect","useField","withCondition","useTranslation","fieldBaseClass","NumberFieldComponent","props","name","AfterInput","BeforeInput","CustomDescription","CustomError","CustomLabel","className","descriptionProps","errorProps","hasMany","label","labelProps","max","Infinity","maxRows","min","onChange","onChangeFromProps","path","pathFromProps","placeholder","readOnly","readOnlyFromProps","required","step","style","validate","width","i18n","t","memoizedValidate","value","options","pathFromContext","readOnlyFromContext","setValue","showError","handleChange","e","val","parseFloat","target","newVal","Number","isNaN","undefined","valueToRender","setValueToRender","handleHasManyChange","selectedOption","newValue","Array","isArray","map","option","index","id","toString","div","filter","Boolean","join","replace","disabled","filterOption","_","rawInput","isOverHasMany","length","isClearable","isCreatable","isMulti","isSortable","noOptionsMessage","input","onWheel","blur","type","NumberField"],"mappings":"AAAA,iDAAiD,GACjD;AAGA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,SAASC,gBAAgB,QAAQ,wCAAuC;AACxE,SAASC,UAAU,QAAQ,kCAAiC;AAC5D,SAASC,UAAU,QAAQ,kCAAiC;AAC5D,SAASC,aAAa,QAAQ,0CAAyC;AACvE,SAASC,QAAQ,QAAQ,oBAAmB;AAC5C,OAAOC,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAK/D,SAASC,WAAW,QAAQ,sCAAqC;AACjE,SAASC,QAAQ,QAAQ,gCAA+B;AACxD,SAASC,aAAa,QAAQ,qCAAoC;AAClE,SAASC,cAAc,QAAQ,uCAAs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AIV,cAAc,CAAC,CAAC;QACtEC,wBACC,oBAAChB;QACCa,WAAW,CAAC,MAAM,EAAEY,KAAK4C,OAAO,CAAC,OAAO,MAAM,CAAC;QAC/CC,UAAU1C;QACV2C,cAAc,CAACC,GAAGC;YAChB,iDAAiD;YACjD,MAAMC,gBAAgBhB,MAAMC,OAAO,CAACrB,UAAUA,MAAMqC,MAAM,IAAItD;YAC9D,OAAO1B,SAAS8E,aAAa,CAACC;QAChC;QACAE,aAAAA;QACAC,aAAAA;QACAC,SAAAA;QACAC,YAAAA;QACAC,kBAAkB;YAChB,MAAMN,gBAAgBhB,MAAMC,OAAO,CAACrB,UAAUA,MAAMqC,MAAM,IAAItD;YAC9D,IAAIqD,eAAe;gBACjB,OAAOtC,EAAE,2BAA2B;oBAAEjB,KAAKE;oBAASiB,OAAOA,MAAMqC,MAAM,GAAG;gBAAE;YAC9E;YACA,OAAO;QACT;QACA,aAAa;QACbpD,UAAUgC;QACVhB,SAAS,EAAE;QACXZ,aAAaS,EAAE;QACfO,WAAWA;QACXL,OAAOe;uBAGT,oBAACY,aACExD,2BACD,oBAACwE;QACCX,UAAU1C;QACVmC,IAAI,CAAC,MAAM,EAAEtC,KAAK4C,OAAO,CAAC,OAAO,MAAM,CAAC;QACxClD,KAAKA;QACLG,KAAKA;QACLf,MAAMkB;QACNF,UAAUqB;QACVsC,SAAS,CAACrC;YACR,6DAA6D;YAC7D,mBAAmB;YACnBA,EAAEG,MAAM,CAACmC,IAAI;QACf;QACAxD,aAAarC,eAAeqC,aAAaQ;QACzCJ,MAAMA;QACNqD,MAAK;QACL9C,OAAO,OAAOA,UAAU,WAAWA,QAAQ;QAE5C9B,aAGJE,sBAAsB0C,YACrB1C,kCAEA,oBAACnB,kBAAsBuB,oBAAoB,CAAC;AAIpD;AAEA,OAAO,MAAMuE,cAAcnF,cAAcG,sBAAqB"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/Point/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAkB,SAAS,EAAE,MAAM,eAAe,CAAA;AAG9D,OAAO,KAAsB,MAAM,OAAO,CAAA;AAM1C,OAAO,cAAc,CAAA;AASrB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAEvD,MAAM,MAAM,eAAe,GAAG,aAAa,GAAG;IAC5C,KAAK,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,CAAA;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AA2ID,eAAO,MAAM,KAAK,2BAA4B,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/Point/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAkB,SAAS,EAAE,MAAM,eAAe,CAAA;AAG9D,OAAO,KAAsB,MAAM,OAAO,CAAA;AAM1C,OAAO,cAAc,CAAA;AASrB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAEvD,MAAM,MAAM,eAAe,GAAG,aAAa,GAAG;IAC5C,KAAK,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,CAAA;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AA6ID,eAAO,MAAM,KAAK,2BAA4B,CAAA"}
@@ -11,7 +11,7 @@ import { FieldError } from '@payloadcms/ui/forms/FieldError';
11
11
  import { FieldLabel } from '@payloadcms/ui/forms/FieldLabel';
12
12
  import { useFieldProps } from '@payloadcms/ui/forms/FieldPropsProvider';
13
13
  const PointField = (props)=>{
14
- const { name, AfterInput, BeforeInput, CustomDescription, CustomError, CustomLabel, className, descriptionProps, errorProps, labelProps, path: pathFromProps, placeholder, readOnly, required, step, style, validate, width } = props;
14
+ const { name, AfterInput, BeforeInput, CustomDescription, CustomError, CustomLabel, className, descriptionProps, errorProps, labelProps, path: pathFromProps, placeholder, readOnly: readOnlyFromProps, required, step, style, validate, width } = props;
15
15
  const { i18n, t } = useTranslation();
16
16
  const memoizedValidate = useCallback((value, options)=>{
17
17
  if (typeof validate === 'function') {
@@ -24,7 +24,8 @@ const PointField = (props)=>{
24
24
  validate,
25
25
  required
26
26
  ]);
27
- const { path: pathFromContext } = useFieldProps();
27
+ const { path: pathFromContext, readOnly: readOnlyFromContext } = useFieldProps();
28
+ const readOnly = readOnlyFromProps || readOnlyFromContext;
28
29
  const { path, setValue, showError, value = [
29
30
  null,
30
31
  null
@@ -48,7 +49,7 @@ const PointField = (props)=>{
48
49
  ]);
49
50
  const getCoordinateFieldLabel = (type)=>{
50
51
  const suffix = type === 'longitude' ? t('fields:longitude') : t('fields:latitude');
51
- const fieldLabel = labelProps && labelProps.label ? labelProps.label : '';
52
+ const fieldLabel = labelProps && labelProps.label ? getTranslation(labelProps.label, i18n) : '';
52
53
  return {
53
54
  ...labelProps,
54
55
  label: `${fieldLabel}${fieldLabel ? ' - ' : ''}${suffix}`
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/fields/Point/index.tsx"],"sourcesContent":["/* eslint-disable react/destructuring-assignment */\n'use client'\nimport type { ClientValidate, FieldBase } from 'payload/types'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport React, { useCallback } from 'react'\n\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { fieldBaseClass } from '../shared/index.js'\nimport './index.scss'\n\nconst baseClass = 'point'\n\nimport { FieldDescription } from '@payloadcms/ui/forms/FieldDescription'\nimport { FieldError } from '@payloadcms/ui/forms/FieldError'\nimport { FieldLabel } from '@payloadcms/ui/forms/FieldLabel'\nimport { useFieldProps } from '@payloadcms/ui/forms/FieldPropsProvider'\n\nimport type { FormFieldBase } from '../shared/index.js'\n\nexport type PointFieldProps = FormFieldBase & {\n label?: FieldBase['label']\n name?: string\n path?: string\n placeholder?: string\n step?: number\n width?: string\n}\n\nconst PointField: React.FC<PointFieldProps> = (props) => {\n const {\n name,\n AfterInput,\n BeforeInput,\n CustomDescription,\n CustomError,\n CustomLabel,\n className,\n descriptionProps,\n errorProps,\n labelProps,\n path: pathFromProps,\n placeholder,\n readOnly,\n required,\n step,\n style,\n validate,\n width,\n } = props\n\n const { i18n, t } = useTranslation()\n\n const memoizedValidate: ClientValidate = 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 } = useFieldProps()\n\n const {\n path,\n setValue,\n showError,\n value = [null, null],\n } = useField<[number, number]>({\n path: pathFromContext || pathFromProps || name,\n validate: memoizedValidate,\n })\n\n const handleChange = useCallback(\n (e, index: 0 | 1) => {\n let val = parseFloat(e.target.value)\n if (Number.isNaN(val)) {\n val = e.target.value\n }\n const coordinates = [...value]\n coordinates[index] = val\n setValue(coordinates)\n },\n [setValue, value],\n )\n\n const getCoordinateFieldLabel = (type: 'latitude' | 'longitude') => {\n const suffix = type === 'longitude' ? t('fields:longitude') : t('fields:latitude')\n const fieldLabel = labelProps && labelProps.label ? labelProps.label : ''\n return {\n ...labelProps,\n label: `${fieldLabel}${fieldLabel ? ' - ' : ''}${suffix}`,\n }\n }\n\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} path={path} {...(errorProps || {})} />\n <ul className={`${baseClass}__wrap`}>\n <li>\n {CustomLabel !== undefined ? (\n CustomLabel\n ) : (\n <FieldLabel {...getCoordinateFieldLabel('longitude')} />\n )}\n <div className=\"input-wrapper\">\n {BeforeInput}\n <input\n disabled={readOnly}\n id={`field-longitude-${path.replace(/\\./g, '__')}`}\n name={`${path}.longitude`}\n onChange={(e) => handleChange(e, 0)}\n placeholder={getTranslation(placeholder, i18n)}\n step={step}\n type=\"number\"\n value={value && typeof value[0] === 'number' ? value[0] : ''}\n />\n {AfterInput}\n </div>\n </li>\n <li>\n {CustomLabel !== undefined ? (\n CustomLabel\n ) : (\n <FieldLabel {...getCoordinateFieldLabel('latitude')} />\n )}\n <div className=\"input-wrapper\">\n {BeforeInput}\n <input\n disabled={readOnly}\n id={`field-latitude-${path.replace(/\\./g, '__')}`}\n name={`${path}.latitude`}\n onChange={(e) => handleChange(e, 1)}\n placeholder={getTranslation(placeholder, i18n)}\n step={step}\n type=\"number\"\n value={value && typeof value[1] === 'number' ? value[1] : ''}\n />\n {AfterInput}\n </div>\n </li>\n </ul>\n {CustomDescription !== undefined ? (\n CustomDescription\n ) : (\n <FieldDescription {...(descriptionProps || {})} />\n )}\n </div>\n )\n}\n\nexport const Point = withCondition(PointField)\n"],"names":["getTranslation","React","useCallback","useField","withCondition","useTranslation","fieldBaseClass","baseClass","FieldDescription","FieldError","FieldLabel","useFieldProps","PointField","props","name","AfterInput","BeforeInput","CustomDescription","CustomError","CustomLabel","className","descriptionProps","errorProps","labelProps","path","pathFromProps","placeholder","readOnly","required","step","style","validate","width","i18n","t","memoizedValidate","value","options","pathFromContext","setValue","showError","handleChange","e","index","val","parseFloat","target","Number","isNaN","coordinates","getCoordinateFieldLabel","type","suffix","fieldLabel","label","div","filter","Boolean","join","ul","li","undefined","input","disabled","id","replace","onChange","Point"],"mappings":"AAAA,iDAAiD,GACjD;AAGA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,OAAOC,SAASC,WAAW,QAAQ,QAAO;AAE1C,SAASC,QAAQ,QAAQ,gCAA+B;AACxD,SAASC,aAAa,Q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CAAC,OAAO,MAAM,CAAC;QACjDnD,MAAM,CAAC,EAAEU,KAAK,SAAS,CAAC;QACxB0C,UAAU,CAACxB,IAAMD,aAAaC,GAAG;QACjChB,aAAa1B,eAAe0B,aAAaO;QACzCJ,MAAMA;QACNsB,MAAK;QACLf,OAAOA,SAAS,OAAOA,KAAK,CAAC,EAAE,KAAK,WAAWA,KAAK,CAAC,EAAE,GAAG;QAE3DrB,eAINE,sBAAsB4C,YACrB5C,kCAEA,oBAACT,kBAAsBa,oBAAoB,CAAC;AAIpD;AAEA,OAAO,MAAM8C,QAAQ/D,cAAcQ,YAAW"}
1
+ {"version":3,"sources":["../../../src/fields/Point/index.tsx"],"sourcesContent":["/* eslint-disable react/destructuring-assignment */\n'use client'\nimport type { ClientValidate, FieldBase } from 'payload/types'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport React, { useCallback } from 'react'\n\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { fieldBaseClass } from '../shared/index.js'\nimport './index.scss'\n\nconst baseClass = 'point'\n\nimport { FieldDescription } from '@payloadcms/ui/forms/FieldDescription'\nimport { FieldError } from '@payloadcms/ui/forms/FieldError'\nimport { FieldLabel } from '@payloadcms/ui/forms/FieldLabel'\nimport { useFieldProps } from '@payloadcms/ui/forms/FieldPropsProvider'\n\nimport type { FormFieldBase } from '../shared/index.js'\n\nexport type PointFieldProps = FormFieldBase & {\n label?: FieldBase['label']\n name?: string\n path?: string\n placeholder?: string\n step?: number\n width?: string\n}\n\nconst PointField: React.FC<PointFieldProps> = (props) => {\n const {\n name,\n AfterInput,\n BeforeInput,\n CustomDescription,\n CustomError,\n CustomLabel,\n className,\n descriptionProps,\n errorProps,\n labelProps,\n path: pathFromProps,\n placeholder,\n readOnly: readOnlyFromProps,\n required,\n step,\n style,\n validate,\n width,\n } = props\n\n const { i18n, t } = useTranslation()\n\n const memoizedValidate: ClientValidate = 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 {\n path,\n setValue,\n showError,\n value = [null, null],\n } = useField<[number, number]>({\n path: pathFromContext || pathFromProps || name,\n validate: memoizedValidate,\n })\n\n const handleChange = useCallback(\n (e, index: 0 | 1) => {\n let val = parseFloat(e.target.value)\n if (Number.isNaN(val)) {\n val = e.target.value\n }\n const coordinates = [...value]\n coordinates[index] = val\n setValue(coordinates)\n },\n [setValue, value],\n )\n\n const getCoordinateFieldLabel = (type: 'latitude' | 'longitude') => {\n const suffix = type === 'longitude' ? t('fields:longitude') : t('fields:latitude')\n const fieldLabel = labelProps && labelProps.label ? getTranslation(labelProps.label, i18n) : ''\n\n return {\n ...labelProps,\n label: `${fieldLabel}${fieldLabel ? ' - ' : ''}${suffix}`,\n }\n }\n\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} path={path} {...(errorProps || {})} />\n <ul className={`${baseClass}__wrap`}>\n <li>\n {CustomLabel !== undefined ? (\n CustomLabel\n ) : (\n <FieldLabel {...getCoordinateFieldLabel('longitude')} />\n )}\n <div className=\"input-wrapper\">\n {BeforeInput}\n <input\n disabled={readOnly}\n id={`field-longitude-${path.replace(/\\./g, '__')}`}\n name={`${path}.longitude`}\n onChange={(e) => handleChange(e, 0)}\n placeholder={getTranslation(placeholder, i18n)}\n step={step}\n type=\"number\"\n value={value && typeof value[0] === 'number' ? value[0] : ''}\n />\n {AfterInput}\n </div>\n </li>\n <li>\n {CustomLabel !== undefined ? (\n CustomLabel\n ) : (\n <FieldLabel {...getCoordinateFieldLabel('latitude')} />\n )}\n <div className=\"input-wrapper\">\n {BeforeInput}\n <input\n disabled={readOnly}\n id={`field-latitude-${path.replace(/\\./g, '__')}`}\n name={`${path}.latitude`}\n onChange={(e) => handleChange(e, 1)}\n placeholder={getTranslation(placeholder, i18n)}\n step={step}\n type=\"number\"\n value={value && typeof value[1] === 'number' ? value[1] : ''}\n />\n {AfterInput}\n </div>\n </li>\n </ul>\n {CustomDescription !== undefined ? (\n CustomDescription\n ) : (\n <FieldDescription {...(descriptionProps || {})} />\n )}\n </div>\n )\n}\n\nexport const Point = withCondition(PointField)\n"],"names":["getTranslation","React","useCallback","useField","withCondition","useTranslation","fieldBaseClass","baseClass","FieldDescription","FieldError","FieldLabel","useFieldProps","PointField","props","name","AfterInput","BeforeInput","CustomDescription","CustomError","CustomLabel","className","descriptionProps","errorProps","labelProps","path","pathFromProps","placeholder","readOnly","readOnlyFromProps","required","step","style","validate","width","i18n","t","memoizedValidate","value","options","pathFromContext","readOnlyFromContext","setValue","showError","handleChange","e","index","val","parseFloat","target","Number","isNaN","coordinates","getCoordinateFieldLabel","type","suffix","fieldLabel","label","div","filter","Boolean","join","ul","li","undefined","input","disabled","id","replace","onChange","Point"],"mappings":"AAAA,iDAAiD,GACjD;AAGA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,OAAOC,SAASC,WAAW,QAAQ,QAAO;AAE1C,SAASC,QAAQ,QAAQ,gCAA+B;AACxD,SAASC,aAAa,QAAQ,qCAAoC;AAClE,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,cAAc,QAAQ,qBAAoB;AAGnD,MAAMC,YAAY;AAElB,SAASC,gBAAgB,QAAQ,wCAAuC;AACxE,SAASC,UAAU,QAAQ,kCAAiC;AAC5D,SAASC,UAAU,QAAQ,kCAAiC;AAC5D,SAASC,aAAa,QAAQ,0CAAyC;AAavE,MAAMC,aAAwC,CAACC;IAC7C,MAAM,EACJC,IAAI,EACJC,UAAU,EACVC,WAAW,EACXC,iBAAiB,EACjBC,WAAW,EACXC,WAAW,EACXC,SAAS,EACTC,gBAAgB,EAChB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oBAACT,kBAAsBa,oBAAoB,CAAC;AAIpD;AAEA,OAAO,MAAMgD,QAAQjE,cAAcQ,YAAW"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/RadioGroup/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAGtD,OAAO,KAAsB,MAAM,OAAO,CAAA;AAQ1C,OAAO,cAAc,CAAA;AAQrB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAEvD,MAAM,MAAM,eAAe,GAAG,aAAa,GAAG;IAC5C,KAAK,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,CAAA;IAC1B,MAAM,CAAC,EAAE,YAAY,GAAG,UAAU,CAAA;IAClC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;IAClB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED,MAAM,MAAM,QAAQ,CAAC,CAAC,GAAG,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAA;AAwHrD,eAAO,MAAM,UAAU,2BAAiC,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/RadioGroup/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAGtD,OAAO,KAAsB,MAAM,OAAO,CAAA;AAQ1C,OAAO,cAAc,CAAA;AAQrB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAEvD,MAAM,MAAM,eAAe,GAAG,aAAa,GAAG;IAC5C,KAAK,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,CAAA;IAC1B,MAAM,CAAC,EAAE,YAAY,GAAG,UAAU,CAAA;IAClC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;IAClB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED,MAAM,MAAM,QAAQ,CAAC,CAAC,GAAG,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAA;AAyHrD,eAAO,MAAM,UAAU,2BAAiC,CAAA"}
@@ -12,7 +12,7 @@ import { FieldDescription } from '@payloadcms/ui/forms/FieldDescription';
12
12
  import { FieldError } from '@payloadcms/ui/forms/FieldError';
13
13
  import { useFieldProps } from '@payloadcms/ui/forms/FieldPropsProvider';
14
14
  const RadioGroupField = (props)=>{
15
- const { name, CustomDescription, CustomError, CustomLabel, className, descriptionProps, errorProps, label, labelProps, layout = 'horizontal', onChange: onChangeFromProps, options = [], path: pathFromProps, readOnly, required, style, validate, value: valueFromProps, width } = props;
15
+ const { name, CustomDescription, CustomError, CustomLabel, className, descriptionProps, errorProps, label, labelProps, layout = 'horizontal', onChange: onChangeFromProps, options = [], path: pathFromProps, readOnly: readOnlyFromProps, required, style, validate, value: valueFromProps, width } = props;
16
16
  const { uuid } = useForm();
17
17
  const memoizedValidate = useCallback((value, validationOptions)=>{
18
18
  if (typeof validate === 'function') return validate(value, {
@@ -25,7 +25,8 @@ const RadioGroupField = (props)=>{
25
25
  options,
26
26
  required
27
27
  ]);
28
- const { path: pathFromContext } = useFieldProps();
28
+ const { path: pathFromContext, readOnly: readOnlyFromContext } = useFieldProps();
29
+ const readOnly = readOnlyFromProps || readOnlyFromContext;
29
30
  const { path, setValue, showError, value: valueFromContext } = useField({
30
31
  path: pathFromContext || pathFromProps || name,
31
32
  validate: memoizedValidate