@payloadcms/ui 3.0.0-beta.79 → 3.0.0-beta.81
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/elements/Autosave/index.js +1 -1
- package/dist/elements/Autosave/index.js.map +1 -1
- package/dist/elements/Nav/context.d.ts +3 -0
- package/dist/elements/Nav/context.d.ts.map +1 -1
- package/dist/elements/Nav/context.js +16 -7
- package/dist/elements/Nav/context.js.map +1 -1
- package/dist/exports/client/index.js +7 -7
- package/dist/exports/client/index.js.map +3 -3
- package/dist/exports/shared/index.d.ts +0 -1
- package/dist/exports/shared/index.d.ts.map +1 -1
- package/dist/exports/shared/index.js +2 -2
- package/dist/exports/shared/index.js.map +4 -4
- package/dist/fields/Array/index.js +1 -1
- package/dist/fields/Array/index.js.map +1 -1
- package/dist/fields/Blocks/index.js +1 -1
- package/dist/fields/Blocks/index.js.map +1 -1
- package/dist/fields/Code/index.js +1 -1
- package/dist/fields/Code/index.js.map +1 -1
- package/dist/fields/Collapsible/index.js +1 -1
- package/dist/fields/Collapsible/index.js.map +1 -1
- package/dist/fields/DateTime/index.js +1 -1
- package/dist/fields/DateTime/index.js.map +1 -1
- package/dist/fields/Group/index.js +1 -1
- package/dist/fields/Group/index.js.map +1 -1
- package/dist/fields/JSON/index.d.ts.map +1 -1
- package/dist/fields/JSON/index.js +1 -1
- package/dist/fields/JSON/index.js.map +1 -1
- package/dist/fields/Point/index.js +1 -1
- package/dist/fields/Point/index.js.map +1 -1
- package/dist/fields/Relationship/index.js +1 -1
- package/dist/fields/Relationship/index.js.map +1 -1
- package/dist/fields/Row/index.d.ts.map +1 -1
- package/dist/fields/Row/index.js +1 -1
- package/dist/fields/Row/index.js.map +1 -1
- package/dist/fields/Tabs/index.js +1 -1
- package/dist/fields/Tabs/index.js.map +1 -1
- package/dist/fields/Text/index.js +1 -1
- package/dist/fields/Text/index.js.map +1 -1
- package/dist/fields/Textarea/index.js +1 -1
- package/dist/fields/Textarea/index.js.map +1 -1
- package/dist/fields/Upload/index.js +1 -1
- package/dist/fields/Upload/index.js.map +1 -1
- package/dist/providers/Config/RenderComponent.d.ts.map +1 -1
- package/dist/providers/Config/RenderComponent.js +3 -0
- package/dist/providers/Config/RenderComponent.js.map +1 -1
- package/dist/providers/Config/createClientConfig/collections.d.ts.map +1 -1
- package/dist/providers/Config/createClientConfig/collections.js +2 -2
- package/dist/providers/Config/createClientConfig/collections.js.map +1 -1
- package/dist/providers/Config/createClientConfig/getComponent.d.ts +1 -1
- package/dist/providers/Config/createClientConfig/getComponent.d.ts.map +1 -1
- package/dist/providers/Config/createClientConfig/getComponent.js +3 -2
- package/dist/providers/Config/createClientConfig/getComponent.js.map +1 -1
- package/dist/providers/Config/createClientConfig/getCreateMappedComponent.d.ts.map +1 -1
- package/dist/providers/Config/createClientConfig/getCreateMappedComponent.js +7 -2
- package/dist/providers/Config/createClientConfig/getCreateMappedComponent.js.map +1 -1
- package/dist/providers/Config/createClientConfig/globals.d.ts.map +1 -1
- package/dist/providers/Config/createClientConfig/globals.js +1 -1
- package/dist/providers/Config/createClientConfig/globals.js.map +1 -1
- package/dist/providers/Root/index.d.ts +1 -0
- package/dist/providers/Root/index.d.ts.map +1 -1
- package/dist/providers/Root/index.js +2 -1
- package/dist/providers/Root/index.js.map +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/fields/Collapsible/index.tsx"],"sourcesContent":["'use client'\nimport type { CollapsibleFieldProps, DocumentPreferences } from 'payload'\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 { useFormInitializing, useFormProcessing } from '../../forms/Form/context.js'\nimport { FieldDescription } from '../FieldDescription/index.js'\n\nconst CollapsibleFieldComponent: React.FC<CollapsibleFieldProps> = (props) => {\n const {\n descriptionProps,\n field,\n field: {\n _path: pathFromProps,\n admin: { className, description, initCollapsed = false, readOnly: readOnlyFromAdmin },\n fields,\n label,\n },\n readOnly: readOnlyFromTopLevelProps,\n } = props\n\n const readOnlyFromProps = readOnlyFromTopLevelProps || readOnlyFromAdmin\n\n const {\n indexPath,\n path: pathFromContext,\n readOnly: readOnlyFromContext,\n schemaPath,\n siblingPermissions,\n } = useFieldProps()\n\n const formInitializing = useFormInitializing()\n const formProcessing = useFormProcessing()\n\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): Promise<void> => {\n const existingPreferences: DocumentPreferences = await getPreference(preferencesKey)\n\n if (preferencesKey) {\n void setPreference(preferencesKey, {\n ...existingPreferences,\n ...(path\n ? {\n fields: {\n ...(existingPreferences?.fields || {}),\n [path]: {\n ...existingPreferences?.fields?.[path],\n 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 },\n [preferencesKey, fieldPreferencesKey, getPreference, setPreference, path],\n )\n\n useEffect(() => {\n const fetchInitialState = async () => {\n if (preferencesKey) {\n const preferences = await getPreference(preferencesKey)\n const specificPreference = path\n ? preferences?.fields?.[path]?.collapsed\n : preferences?.fields?.[fieldPreferencesKey]?.collapsed\n\n if (specificPreference !== undefined) {\n setCollapsedOnMount(Boolean(specificPreference))\n } else {\n setCollapsedOnMount(typeof initCollapsed === 'boolean' ? initCollapsed : false)\n }\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 disabled = readOnlyFromProps || readOnlyFromContext || formProcessing || formInitializing\n\n return (\n <Fragment>\n <WatchChildErrors fields={fields} 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 RowLabel={\n field?.admin?.components && 'RowLabel' in field.admin.components\n ? field.admin.components.RowLabel\n : undefined\n }\n i18n={i18n}\n path={path}\n rowLabel={label}\n />\n {fieldHasErrors && <ErrorPill count={errorCount} i18n={i18n} withMessage />}\n </div>\n }\n initCollapsed={collapsedOnMount}\n onToggle={onToggle}\n >\n <RenderFields\n fields={fields}\n forceRender\n indexPath={indexPath}\n margins=\"small\"\n path={path}\n permissions={siblingPermissions}\n readOnly={disabled}\n schemaPath={schemaPath}\n />\n </CollapsibleElement>\n <FieldDescription\n Description={field?.admin?.components?.Description}\n description={description}\n {...(descriptionProps || {})}\n />\n </div>\n </Fragment>\n )\n}\n\nexport const CollapsibleField = withCondition(CollapsibleFieldComponent)\n"],"names":["React","Fragment","useCallback","useEffect","useState","Collapsible","CollapsibleElement","ErrorPill","useFieldProps","RenderFields","RowLabel","WatchChildErrors","withCondition","useDocumentInfo","usePreferences","useTranslation","fieldBaseClass","baseClass","useFormInitializing","useFormProcessing","FieldDescription","CollapsibleFieldComponent","props","descriptionProps","field","_path","pathFromProps","admin","className","description","initCollapsed","readOnly","readOnlyFromAdmin","fields","label","readOnlyFromTopLevelProps","readOnlyFromProps","indexPath","path","pathFromContext","readOnlyFromContext","schemaPath","siblingPermissions","formInitializing","formProcessing","i18n","getPreference","setPreference","preferencesKey","collapsedOnMount","setCollapsedOnMount","fieldPreferencesKey","replace","errorCount","setErrorCount","fieldHasErrors","onToggle","newCollapsedState","existingPreferences","collapsed","fetchInitialState","preferences","specificPreference","undefined","Boolean","disabled","div","filter","join","id","collapsibleStyle","header","components","rowLabel","count","withMessage","forceRender","margins","permissions","Description","CollapsibleField"],"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;AACnD,OAAO,eAAc;AAErB,MAAMC,YAAY;AAElB,SAASC,mBAAmB,EAAEC,iBAAiB,QAAQ,8BAA6B;AACpF,SAASC,gBAAgB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kBAAkBf,iBAAiB,UAAU;wBAC7CgB,sBACE,MAACL;4BAAItC,WAAW,CAAC,EAAEX,UAAU,gBAAgB,CAAC;;8CAC5C,KAACP;oCACCA,UACEc,OAAOG,OAAO6C,cAAc,cAAchD,MAAMG,KAAK,CAAC6C,UAAU,GAC5DhD,MAAMG,KAAK,CAAC6C,UAAU,CAAC9D,QAAQ,GAC/BqD;oCAENlB,MAAMA;oCACNP,MAAMA;oCACNmC,UAAUvC;;gCAEXqB,gCAAkB,KAAChD;oCAAUmE,OAAOrB;oCAAYR,MAAMA;oCAAM8B,WAAW;;;;wBAG5E7C,eAAemB;wBACfO,UAAUA;kCAEV,cAAA,KAAC/C;4BACCwB,QAAQA;4BACR2C,WAAW;4BACXvC,WAAWA;4BACXwC,SAAQ;4BACRvC,MAAMA;4BACNwC,aAAapC;4BACbX,UAAUkC;4BACVxB,YAAYA;;;kCAGhB,KAACrB;wBACC2D,aAAavD,OAAOG,OAAO6C,YAAYO;wBACvClD,aAAaA;wBACZ,GAAIN,oBAAoB,CAAC,CAAC;;;;;;AAKrC;AAEA,OAAO,MAAMyD,mBAAmBpE,cAAcS,2BAA0B"}
|
|
1
|
+
{"version":3,"sources":["../../../src/fields/Collapsible/index.tsx"],"sourcesContent":["'use client'\nimport type { CollapsibleFieldProps, DocumentPreferences } from 'payload'\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 { useFormInitializing, useFormProcessing } from '../../forms/Form/context.js'\nimport { FieldDescription } from '../FieldDescription/index.js'\n\nconst CollapsibleFieldComponent: React.FC<CollapsibleFieldProps> = (props) => {\n const {\n descriptionProps,\n field,\n field: {\n _path: pathFromProps,\n admin: { className, description, initCollapsed = false, readOnly: readOnlyFromAdmin } = {},\n fields,\n label,\n },\n readOnly: readOnlyFromTopLevelProps,\n } = props\n\n const readOnlyFromProps = readOnlyFromTopLevelProps || readOnlyFromAdmin\n\n const {\n indexPath,\n path: pathFromContext,\n readOnly: readOnlyFromContext,\n schemaPath,\n siblingPermissions,\n } = useFieldProps()\n\n const formInitializing = useFormInitializing()\n const formProcessing = useFormProcessing()\n\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): Promise<void> => {\n const existingPreferences: DocumentPreferences = await getPreference(preferencesKey)\n\n if (preferencesKey) {\n void setPreference(preferencesKey, {\n ...existingPreferences,\n ...(path\n ? {\n fields: {\n ...(existingPreferences?.fields || {}),\n [path]: {\n ...existingPreferences?.fields?.[path],\n 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 },\n [preferencesKey, fieldPreferencesKey, getPreference, setPreference, path],\n )\n\n useEffect(() => {\n const fetchInitialState = async () => {\n if (preferencesKey) {\n const preferences = await getPreference(preferencesKey)\n const specificPreference = path\n ? preferences?.fields?.[path]?.collapsed\n : preferences?.fields?.[fieldPreferencesKey]?.collapsed\n\n if (specificPreference !== undefined) {\n setCollapsedOnMount(Boolean(specificPreference))\n } else {\n setCollapsedOnMount(typeof initCollapsed === 'boolean' ? initCollapsed : false)\n }\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 disabled = readOnlyFromProps || readOnlyFromContext || formProcessing || formInitializing\n\n return (\n <Fragment>\n <WatchChildErrors fields={fields} 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 RowLabel={\n field?.admin?.components && 'RowLabel' in field.admin.components\n ? field.admin.components.RowLabel\n : undefined\n }\n i18n={i18n}\n path={path}\n rowLabel={label}\n />\n {fieldHasErrors && <ErrorPill count={errorCount} i18n={i18n} withMessage />}\n </div>\n }\n initCollapsed={collapsedOnMount}\n onToggle={onToggle}\n >\n <RenderFields\n fields={fields}\n forceRender\n indexPath={indexPath}\n margins=\"small\"\n path={path}\n permissions={siblingPermissions}\n readOnly={disabled}\n schemaPath={schemaPath}\n />\n </CollapsibleElement>\n <FieldDescription\n Description={field?.admin?.components?.Description}\n description={description}\n {...(descriptionProps || {})}\n />\n </div>\n </Fragment>\n )\n}\n\nexport const CollapsibleField = withCondition(CollapsibleFieldComponent)\n"],"names":["React","Fragment","useCallback","useEffect","useState","Collapsible","CollapsibleElement","ErrorPill","useFieldProps","RenderFields","RowLabel","WatchChildErrors","withCondition","useDocumentInfo","usePreferences","useTranslation","fieldBaseClass","baseClass","useFormInitializing","useFormProcessing","FieldDescription","CollapsibleFieldComponent","props","descriptionProps","field","_path","pathFromProps","admin","className","description","initCollapsed","readOnly","readOnlyFromAdmin","fields","label","readOnlyFromTopLevelProps","readOnlyFromProps","indexPath","path","pathFromContext","readOnlyFromContext","schemaPath","siblingPermissions","formInitializing","formProcessing","i18n","getPreference","setPreference","preferencesKey","collapsedOnMount","setCollapsedOnMount","fieldPreferencesKey","replace","errorCount","setErrorCount","fieldHasErrors","onToggle","newCollapsedState","existingPreferences","collapsed","fetchInitialState","preferences","specificPreference","undefined","Boolean","disabled","div","filter","join","id","collapsibleStyle","header","components","rowLabel","count","withMessage","forceRender","margins","permissions","Description","CollapsibleField"],"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;AACnD,OAAO,eAAc;AAErB,MAAMC,YAAY;AAElB,SAASC,mBAAmB,EAAEC,iBAAiB,QAAQ,8BAA6B;AACpF,SAASC,gBAAgB,QAAQ,+BAA8B;AAE/D,MAAMC,4BAA6D,CAACC;IAClE,MAAM,EACJC,gBAAgB,EAChBC,KAAK,EACLA,OAAO,EACLC,OAAOC,aAAa,EACpBC,OAAO,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oCACCA,UACEc,OAAOG,OAAO6C,cAAc,cAAchD,MAAMG,KAAK,CAAC6C,UAAU,GAC5DhD,MAAMG,KAAK,CAAC6C,UAAU,CAAC9D,QAAQ,GAC/BqD;oCAENlB,MAAMA;oCACNP,MAAMA;oCACNmC,UAAUvC;;gCAEXqB,gCAAkB,KAAChD;oCAAUmE,OAAOrB;oCAAYR,MAAMA;oCAAM8B,WAAW;;;;wBAG5E7C,eAAemB;wBACfO,UAAUA;kCAEV,cAAA,KAAC/C;4BACCwB,QAAQA;4BACR2C,WAAW;4BACXvC,WAAWA;4BACXwC,SAAQ;4BACRvC,MAAMA;4BACNwC,aAAapC;4BACbX,UAAUkC;4BACVxB,YAAYA;;;kCAGhB,KAACrB;wBACC2D,aAAavD,OAAOG,OAAO6C,YAAYO;wBACvClD,aAAaA;wBACZ,GAAIN,oBAAoB,CAAC,CAAC;;;;;;AAKrC;AAEA,OAAO,MAAMyD,mBAAmBpE,cAAcS,2BAA0B"}
|
|
@@ -15,7 +15,7 @@ import { RenderComponent } from '../../providers/Config/RenderComponent.js';
|
|
|
15
15
|
import { FieldDescription } from '../FieldDescription/index.js';
|
|
16
16
|
import { FieldError } from '../FieldError/index.js';
|
|
17
17
|
const DateTimeFieldComponent = (props)=>{
|
|
18
|
-
const { descriptionProps, errorProps, field, field: { name, _path: pathFromProps, admin: { className, date: datePickerProps, description, placeholder, readOnly: readOnlyFromAdmin, style, width }, label, required }, labelProps, readOnly: readOnlyFromTopLevelProps, validate } = props;
|
|
18
|
+
const { descriptionProps, errorProps, field, field: { name, _path: pathFromProps, admin: { className, date: datePickerProps, description, placeholder, readOnly: readOnlyFromAdmin, style, width } = {}, label, required }, labelProps, readOnly: readOnlyFromTopLevelProps, validate } = props;
|
|
19
19
|
const readOnlyFromProps = readOnlyFromTopLevelProps || readOnlyFromAdmin;
|
|
20
20
|
const { i18n } = useTranslation();
|
|
21
21
|
const memoizedValidate = useCallback((value, options)=>{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/fields/DateTime/index.tsx"],"sourcesContent":["'use client'\nimport type { DateFieldProps, DateFieldValidation } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport React, { useCallback } from 'react'\n\nimport { DatePickerField } from '../../elements/DatePicker/index.js'\nimport { useField } from '../../forms/useField/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { FieldLabel } from '../FieldLabel/index.js'\nimport { fieldBaseClass } from '../shared/index.js'\nimport './index.scss'\n\nconst baseClass = 'date-time-field'\n\nimport { useFieldProps } from '../../forms/FieldPropsProvider/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { RenderComponent } from '../../providers/Config/RenderComponent.js'\nimport { FieldDescription } from '../FieldDescription/index.js'\nimport { FieldError } from '../FieldError/index.js'\n\nconst DateTimeFieldComponent: React.FC<DateFieldProps> = (props) => {\n const {\n descriptionProps,\n errorProps,\n field,\n field: {\n name,\n _path: pathFromProps,\n admin: {\n className,\n date: datePickerProps,\n description,\n placeholder,\n readOnly: readOnlyFromAdmin,\n style,\n width,\n },\n label,\n required,\n },\n labelProps,\n readOnly: readOnlyFromTopLevelProps,\n validate,\n } = props\n const readOnlyFromProps = readOnlyFromTopLevelProps || readOnlyFromAdmin\n\n const { i18n } = useTranslation()\n\n const memoizedValidate: DateFieldValidation = 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 { formInitializing, formProcessing, path, setValue, showError, value } = useField<Date>({\n path: pathFromContext ?? pathFromProps ?? name,\n validate: memoizedValidate,\n })\n\n const disabled = readOnlyFromProps || readOnlyFromContext || formProcessing || formInitializing\n\n return (\n <div\n className={[\n fieldBaseClass,\n baseClass,\n className,\n showError && `${baseClass}--has-error`,\n disabled && 'read-only',\n ]\n .filter(Boolean)\n .join(' ')}\n style={{\n ...style,\n width,\n }}\n >\n <FieldLabel\n Label={field?.admin?.components?.Label}\n label={label}\n required={required}\n {...(labelProps || {})}\n />\n <div className={`${fieldBaseClass}__wrap`} id={`field-${path.replace(/\\./g, '__')}`}>\n <FieldError\n CustomError={field?.admin?.components?.Error}\n path={path}\n {...(errorProps || {})}\n />\n <RenderComponent mappedComponent={field?.admin?.components?.beforeInput} />\n <DatePickerField\n {...datePickerProps}\n onChange={(incomingDate) => {\n if (!disabled) setValue(incomingDate?.toISOString() || null)\n }}\n placeholder={getTranslation(placeholder, i18n)}\n readOnly={disabled}\n value={value}\n />\n <RenderComponent mappedComponent={field?.admin?.components?.afterInput} />\n </div>\n <FieldDescription\n Description={field?.admin?.components?.Description}\n description={description}\n {...(descriptionProps || {})}\n />\n </div>\n )\n}\n\nexport const DateTimeField = withCondition(DateTimeFieldComponent)\n"],"names":["getTranslation","React","useCallback","DatePickerField","useField","useTranslation","FieldLabel","fieldBaseClass","baseClass","useFieldProps","withCondition","RenderComponent","FieldDescription","FieldError","DateTimeFieldComponent","props","descriptionProps","errorProps","field","name","_path","pathFromProps","admin","className","date","datePickerProps","description","placeholder","readOnly","readOnlyFromAdmin","style","width","label","required","labelProps","readOnlyFromTopLevelProps","validate","readOnlyFromProps","i18n","memoizedValidate","value","options","path","pathFromContext","readOnlyFromContext","formInitializing","formProcessing","setValue","showError","disabled","div","filter","Boolean","join","Label","components","id","replace","CustomError","Error","mappedComponent","beforeInput","onChange","incomingDate","toISOString","afterInput","Description","DateTimeField"],"mappings":"AAAA;;AAGA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,OAAOC,SAASC,WAAW,QAAQ,QAAO;AAE1C,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,QAAQ,QAAQ,gCAA+B;AACxD,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,UAAU,QAAQ,yBAAwB;AACnD,SAASC,cAAc,QAAQ,qBAAoB;AACnD,OAAO,eAAc;AAErB,MAAMC,YAAY;AAElB,SAASC,aAAa,QAAQ,0CAAyC;AACvE,SAASC,aAAa,QAAQ,qCAAoC;AAClE,SAASC,eAAe,QAAQ,4CAA2C;AAC3E,SAASC,gBAAgB,QAAQ,+BAA8B;AAC/D,SAASC,UAAU,QAAQ,yBAAwB;AAEnD,MAAMC,yBAAmD,CAACC;IACxD,MAAM,EACJC,gBAAgB,EAChBC,UAAU,EACVC,KAAK,EACLA,OAAO,EACLC,IAAI,EACJC,OAAOC,aAAa,EACpBC,OAAO,EACLC,SAAS,EACTC,MAAMC,eAAe,EACrBC,WAAW,EACXC,WAAW,EACXC,UAAUC,iBAAiB,EAC3BC,KAAK,EACLC,KAAK,EACN,
|
|
1
|
+
{"version":3,"sources":["../../../src/fields/DateTime/index.tsx"],"sourcesContent":["'use client'\nimport type { DateFieldProps, DateFieldValidation } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport React, { useCallback } from 'react'\n\nimport { DatePickerField } from '../../elements/DatePicker/index.js'\nimport { useField } from '../../forms/useField/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { FieldLabel } from '../FieldLabel/index.js'\nimport { fieldBaseClass } from '../shared/index.js'\nimport './index.scss'\n\nconst baseClass = 'date-time-field'\n\nimport { useFieldProps } from '../../forms/FieldPropsProvider/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { RenderComponent } from '../../providers/Config/RenderComponent.js'\nimport { FieldDescription } from '../FieldDescription/index.js'\nimport { FieldError } from '../FieldError/index.js'\n\nconst DateTimeFieldComponent: React.FC<DateFieldProps> = (props) => {\n const {\n descriptionProps,\n errorProps,\n field,\n field: {\n name,\n _path: pathFromProps,\n admin: {\n className,\n date: datePickerProps,\n description,\n placeholder,\n readOnly: readOnlyFromAdmin,\n style,\n width,\n } = {},\n label,\n required,\n },\n labelProps,\n readOnly: readOnlyFromTopLevelProps,\n validate,\n } = props\n const readOnlyFromProps = readOnlyFromTopLevelProps || readOnlyFromAdmin\n\n const { i18n } = useTranslation()\n\n const memoizedValidate: DateFieldValidation = 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 { formInitializing, formProcessing, path, setValue, showError, value } = useField<Date>({\n path: pathFromContext ?? pathFromProps ?? name,\n validate: memoizedValidate,\n })\n\n const disabled = readOnlyFromProps || readOnlyFromContext || formProcessing || formInitializing\n\n return (\n <div\n className={[\n fieldBaseClass,\n baseClass,\n className,\n showError && `${baseClass}--has-error`,\n disabled && 'read-only',\n ]\n .filter(Boolean)\n .join(' ')}\n style={{\n ...style,\n width,\n }}\n >\n <FieldLabel\n Label={field?.admin?.components?.Label}\n label={label}\n required={required}\n {...(labelProps || {})}\n />\n <div className={`${fieldBaseClass}__wrap`} id={`field-${path.replace(/\\./g, '__')}`}>\n <FieldError\n CustomError={field?.admin?.components?.Error}\n path={path}\n {...(errorProps || {})}\n />\n <RenderComponent mappedComponent={field?.admin?.components?.beforeInput} />\n <DatePickerField\n {...datePickerProps}\n onChange={(incomingDate) => {\n if (!disabled) setValue(incomingDate?.toISOString() || null)\n }}\n placeholder={getTranslation(placeholder, i18n)}\n readOnly={disabled}\n value={value}\n />\n <RenderComponent mappedComponent={field?.admin?.components?.afterInput} />\n </div>\n <FieldDescription\n Description={field?.admin?.components?.Description}\n description={description}\n {...(descriptionProps || {})}\n />\n </div>\n )\n}\n\nexport const DateTimeField = withCondition(DateTimeFieldComponent)\n"],"names":["getTranslation","React","useCallback","DatePickerField","useField","useTranslation","FieldLabel","fieldBaseClass","baseClass","useFieldProps","withCondition","RenderComponent","FieldDescription","FieldError","DateTimeFieldComponent","props","descriptionProps","errorProps","field","name","_path","pathFromProps","admin","className","date","datePickerProps","description","placeholder","readOnly","readOnlyFromAdmin","style","width","label","required","labelProps","readOnlyFromTopLevelProps","validate","readOnlyFromProps","i18n","memoizedValidate","value","options","path","pathFromContext","readOnlyFromContext","formInitializing","formProcessing","setValue","showError","disabled","div","filter","Boolean","join","Label","components","id","replace","CustomError","Error","mappedComponent","beforeInput","onChange","incomingDate","toISOString","afterInput","Description","DateTimeField"],"mappings":"AAAA;;AAGA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,OAAOC,SAASC,WAAW,QAAQ,QAAO;AAE1C,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,QAAQ,QAAQ,gCAA+B;AACxD,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,UAAU,QAAQ,yBAAwB;AACnD,SAASC,cAAc,QAAQ,qBAAoB;AACnD,OAAO,eAAc;AAErB,MAAMC,YAAY;AAElB,SAASC,aAAa,QAAQ,0CAAyC;AACvE,SAASC,aAAa,QAAQ,qCAAoC;AAClE,SAASC,eAAe,QAAQ,4CAA2C;AAC3E,SAASC,gBAAgB,QAAQ,+BAA8B;AAC/D,SAASC,UAAU,QAAQ,yBAAwB;AAEnD,MAAMC,yBAAmD,CAACC;IACxD,MAAM,EACJC,gBAAgB,EAChBC,UAAU,EACVC,KAAK,EACLA,OAAO,EACLC,IAAI,EACJC,OAAOC,aAAa,EACpBC,OAAO,EACLC,SAAS,EACTC,MAAMC,eAAe,EACrBC,WAAW,EACXC,WAAW,EACXC,UAAUC,iBAAiB,EAC3BC,KAAK,EACLC,KAAK,EACN,GAAG,CAAC,CAAC,EACNC,KAAK,EACLC,QAAQ,EACT,EACDC,UAAU,EACVN,UAAUO,yBAAyB,EACnCC,QAAQ,EACT,GAAGrB;IACJ,MAAMsB,oBAAoBF,6BAA6BN;IAEvD,MAAM,EAAES,IAAI,EAAE,GAAGjC;IAEjB,MAAMkC,mBAAwCrC,YAC5C,CAACsC,OAAOC;QACN,IAAI,OAAOL,aAAa,YAAY;YAClC,OAAOA,SAASI,OAAO;gBAAE,GAAGC,OAAO;gBAAER;YAAS;QAChD;IACF,GACA;QAACG;QAAUH;KAAS;IAGtB,MAAM,EAAES,MAAMC,eAAe,EAAEf,UAAUgB,mBAAmB,EAAE,GAAGnC;IAE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I,wBAAuB"}
|
|
@@ -19,7 +19,7 @@ import './index.scss';
|
|
|
19
19
|
import { GroupProvider, useGroup } from './provider.js';
|
|
20
20
|
const baseClass = 'group-field';
|
|
21
21
|
export const GroupFieldComponent = (props)=>{
|
|
22
|
-
const { descriptionProps, field, field: { admin: { className, description, hideGutter, readOnly: readOnlyFromAdmin, style, width }, fields, label }, readOnly: readOnlyFromTopLevelProps } = props;
|
|
22
|
+
const { descriptionProps, field, field: { admin: { className, description, hideGutter, readOnly: readOnlyFromAdmin, style, width } = {}, fields, label }, readOnly: readOnlyFromTopLevelProps } = props;
|
|
23
23
|
const readOnlyFromProps = readOnlyFromTopLevelProps || readOnlyFromAdmin;
|
|
24
24
|
const { path, permissions, readOnly: readOnlyFromContext, schemaPath } = useFieldProps();
|
|
25
25
|
const { i18n } = useTranslation();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/fields/Group/index.tsx"],"sourcesContent":["'use client'\n\nimport type { GroupFieldProps } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport React from 'react'\n\nimport { useCollapsible } from '../../elements/Collapsible/provider.js'\nimport { ErrorPill } from '../../elements/ErrorPill/index.js'\nimport { useFieldProps } from '../../forms/FieldPropsProvider/index.js'\nimport {\n useFormInitializing,\n useFormProcessing,\n useFormSubmitted,\n} 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 { RenderComponent } from '../../providers/Config/RenderComponent.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { FieldDescription } from '../FieldDescription/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 const GroupFieldComponent: React.FC<GroupFieldProps> = (props) => {\n const {\n descriptionProps,\n field,\n field: {\n admin: { className, description, hideGutter, readOnly: readOnlyFromAdmin, style, width },\n fields,\n label,\n },\n readOnly: readOnlyFromTopLevelProps,\n } = props\n const readOnlyFromProps = readOnlyFromTopLevelProps || readOnlyFromAdmin\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 formInitializing = useFormInitializing()\n const formProcessing = useFormProcessing()\n const submitted = useFormSubmitted()\n const errorCount = errorPaths.length\n const fieldHasErrors = submitted && errorCount > 0\n const disabled = readOnlyFromProps || readOnlyFromContext || formProcessing || formInitializing\n\n const isTopLevel = !(isWithinCollapsible || isWithinGroup || isWithinRow)\n\n return (\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 {(field?.admin?.components?.Label ||\n field?.admin?.components?.Description ||\n label) && (\n <header>\n {field?.admin?.components?.Label !== undefined ? (\n <RenderComponent\n clientProps={{ label }}\n mappedComponent={field?.admin?.components?.Label}\n />\n ) : label ? (\n <h3 className={`${baseClass}__title`}>{getTranslation(label, i18n)}</h3>\n ) : null}\n <FieldDescription\n Description={field?.admin?.components?.Description}\n description={description}\n {...(descriptionProps || {})}\n />\n </header>\n )}\n {fieldHasErrors && <ErrorPill count={errorCount} i18n={i18n} withMessage />}\n </div>\n <RenderFields\n fields={fields}\n margins=\"small\"\n path={path}\n permissions={permissions?.fields}\n readOnly={disabled}\n schemaPath={schemaPath}\n />\n </div>\n </GroupProvider>\n </div>\n )\n}\n\nexport { GroupProvider, useGroup }\n\nexport const GroupField = withCondition(GroupFieldComponent)\n"],"names":["getTranslation","React","useCollapsible","ErrorPill","useFieldProps","useFormInitializing","useFormProcessing","useFormSubmitted","RenderFields","useField","withCondition","RenderComponent","useTranslation","FieldDescription","useRow","useTabs","fieldBaseClass","GroupProvider","useGroup","baseClass","GroupFieldComponent","props","descriptionProps","field","admin","className","description","hideGutter","readOnly","readOnlyFromAdmin","style","width","fields","label","readOnlyFromTopLevelProps","readOnlyFromProps","path","permissions","readOnlyFromContext","schemaPath","i18n","isWithinCollapsible","isWithinGroup","isWithinRow","isWithinTab","errorPaths","formInitializing","formProcessing","submitted","errorCount","length","fieldHasErrors","disabled","isTopLevel","div","filter","Boolean","join","id","replace","components","Label","Description","header","undefined","clientProps","mappedComponent","h3","count","withMessage","margins","GroupField"],"mappings":"AAAA;;AAIA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,OAAOC,WAAW,QAAO;AAEzB,SAASC,cAAc,QAAQ,yCAAwC;AACvE,SAASC,SAAS,QAAQ,oCAAmC;AAC7D,SAASC,aAAa,QAAQ,0CAAyC;AACvE,SACEC,mBAAmB,EACnBC,iBAAiB,EACjBC,gBAAgB,QACX,8BAA6B;AACpC,SAASC,YAAY,QAAQ,oCAAmC;AAChE,SAASC,QAAQ,QAAQ,gCAA+B;AACxD,SAASC,aAAa,QAAQ,qCAAoC;AAClE,SAASC,eAAe,QAAQ,4CAA2C;AAC3E,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,gBAAgB,QAAQ,+BAA8B;AAC/D,SAASC,MAAM,QAAQ,qBAAoB;AAC3C,SAASC,OAAO,QAAQ,sBAAqB;AAC7C,SAASC,cAAc,QAAQ,qBAAoB;AACnD,OAAO,eAAc;AACrB,SAASC,aAAa,EAAEC,QAAQ,QAAQ,gBAAe;AAEvD,MAAMC,YAAY;AAElB,OAAO,MAAMC,sBAAiD,CAACC;IAC7D,MAAM,EACJC,gBAAgB,EAChBC,KAAK,EACLA,OAAO,EACLC,OAAO,EAAEC,SAAS,EAAEC,WAAW,EAAEC,UAAU,EAAEC,UAAUC,iBAAiB,EAAEC,KAAK,EAAEC,KAAK,EAAE,
|
|
1
|
+
{"version":3,"sources":["../../../src/fields/Group/index.tsx"],"sourcesContent":["'use client'\n\nimport type { GroupFieldProps } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport React from 'react'\n\nimport { useCollapsible } from '../../elements/Collapsible/provider.js'\nimport { ErrorPill } from '../../elements/ErrorPill/index.js'\nimport { useFieldProps } from '../../forms/FieldPropsProvider/index.js'\nimport {\n useFormInitializing,\n useFormProcessing,\n useFormSubmitted,\n} 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 { RenderComponent } from '../../providers/Config/RenderComponent.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { FieldDescription } from '../FieldDescription/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 const GroupFieldComponent: React.FC<GroupFieldProps> = (props) => {\n const {\n descriptionProps,\n field,\n field: {\n admin: { className, description, hideGutter, readOnly: readOnlyFromAdmin, style, width } = {},\n fields,\n label,\n },\n readOnly: readOnlyFromTopLevelProps,\n } = props\n const readOnlyFromProps = readOnlyFromTopLevelProps || readOnlyFromAdmin\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 formInitializing = useFormInitializing()\n const formProcessing = useFormProcessing()\n const submitted = useFormSubmitted()\n const errorCount = errorPaths.length\n const fieldHasErrors = submitted && errorCount > 0\n const disabled = readOnlyFromProps || readOnlyFromContext || formProcessing || formInitializing\n\n const isTopLevel = !(isWithinCollapsible || isWithinGroup || isWithinRow)\n\n return (\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 {(field?.admin?.components?.Label ||\n field?.admin?.components?.Description ||\n label) && (\n <header>\n {field?.admin?.components?.Label !== undefined ? (\n <RenderComponent\n clientProps={{ label }}\n mappedComponent={field?.admin?.components?.Label}\n />\n ) : label ? (\n <h3 className={`${baseClass}__title`}>{getTranslation(label, i18n)}</h3>\n ) : null}\n <FieldDescription\n Description={field?.admin?.components?.Description}\n description={description}\n {...(descriptionProps || {})}\n />\n </header>\n )}\n {fieldHasErrors && <ErrorPill count={errorCount} i18n={i18n} withMessage />}\n </div>\n <RenderFields\n fields={fields}\n margins=\"small\"\n path={path}\n permissions={permissions?.fields}\n readOnly={disabled}\n schemaPath={schemaPath}\n />\n </div>\n </GroupProvider>\n </div>\n )\n}\n\nexport { GroupProvider, useGroup }\n\nexport const GroupField = withCondition(GroupFieldComponent)\n"],"names":["getTranslation","React","useCollapsible","ErrorPill","useFieldProps","useFormInitializing","useFormProcessing","useFormSubmitted","RenderFields","useField","withCondition","RenderComponent","useTranslation","FieldDescription","useRow","useTabs","fieldBaseClass","GroupProvider","useGroup","baseClass","GroupFieldComponent","props","descriptionProps","field","admin","className","description","hideGutter","readOnly","readOnlyFromAdmin","style","width","fields","label","readOnlyFromTopLevelProps","readOnlyFromProps","path","permissions","readOnlyFromContext","schemaPath","i18n","isWithinCollapsible","isWithinGroup","isWithinRow","isWithinTab","errorPaths","formInitializing","formProcessing","submitted","errorCount","length","fieldHasErrors","disabled","isTopLevel","div","filter","Boolean","join","id","replace","components","Label","Description","header","undefined","clientProps","mappedComponent","h3","count","withMessage","margins","GroupField"],"mappings":"AAAA;;AAIA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,OAAOC,WAAW,QAAO;AAEzB,SAASC,cAAc,QAAQ,yCAAwC;AACvE,SAASC,SAAS,QAAQ,oCAAmC;AAC7D,SAASC,aAAa,QAAQ,0CAAyC;AACvE,SACEC,mBAAmB,EACnBC,iBAAiB,EACjBC,gBAAgB,QACX,8BAA6B;AACpC,SAASC,YAAY,QAAQ,oCAAmC;AAChE,SAASC,QAAQ,QAAQ,gCAA+B;AACxD,SAASC,aAAa,QAAQ,qCAAoC;AAClE,SAASC,eAAe,QAAQ,4CAA2C;AAC3E,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,gBAAgB,QAAQ,+BAA8B;AAC/D,SAASC,MAAM,QAAQ,qBAAoB;AAC3C,SAASC,OAAO,QAAQ,sBAAqB;AAC7C,SAASC,cAAc,QAAQ,qBAAoB;AACnD,OAAO,eAAc;AACrB,SAASC,aAAa,EAAEC,QAAQ,QAAQ,gBAAe;AAEvD,MAAMC,YAAY;AAElB,OAAO,MAAMC,sBAAiD,CAACC;IAC7D,MAAM,EACJC,gBAAgB,EAChBC,KAAK,EACLA,OAAO,EACLC,OAAO,EAAEC,SAAS,EAAEC,WAAW,EAAEC,UAAU,EAAEC,UAAUC,iBAAiB,EAAEC,KAAK,EAAEC,KAAK,EAAE,GAAG,CAAC,CAAC,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d;sBACC,cAAA,MAACqC;gBAAI7B,WAAW,CAAC,EAAEN,UAAU,MAAM,CAAC;;kCAClC,MAACmC;wBAAI7B,WAAW,CAAC,EAAEN,UAAU,QAAQ,CAAC;;4BAClCI,CAAAA,OAAOC,OAAOoC,YAAYC,SAC1BtC,OAAOC,OAAOoC,YAAYE,eAC1B7B,KAAI,mBACJ,MAAC8B;;oCACExC,OAAOC,OAAOoC,YAAYC,UAAUG,0BACnC,KAACrD;wCACCsD,aAAa;4CAAEhC;wCAAM;wCACrBiC,iBAAiB3C,OAAOC,OAAOoC,YAAYC;yCAE3C5B,sBACF,KAACkC;wCAAG1C,WAAW,CAAC,EAAEN,UAAU,OAAO,CAAC;kDAAGnB,eAAeiC,OAAOO;yCAC3D;kDACJ,KAAC3B;wCACCiD,aAAavC,OAAOC,OAAOoC,YAAYE;wCACvCpC,aAAaA;wCACZ,GAAIJ,oBAAoB,CAAC,CAAC;;;;4BAIhC6B,gCAAkB,KAAChD;gCAAUiE,OAAOnB;gCAAYT,MAAMA;gCAAM6B,WAAW;;;;kCAE1E,KAAC7D;wBACCwB,QAAQA;wBACRsC,SAAQ;wBACRlC,MAAMA;wBACNC,aAAaA,aAAaL;wBAC1BJ,UAAUwB;wBACVb,YAAYA;;;;;;AAMxB,EAAC;AAED,SAAStB,aAAa,EAAEC,QAAQ,GAAE;AAElC,OAAO,MAAMqD,aAAa7D,cAAcU,qBAAoB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/JSON/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C,OAAO,KAA2C,MAAM,OAAO,CAAA;AAO/D,OAAO,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/JSON/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C,OAAO,KAA2C,MAAM,OAAO,CAAA;AAO/D,OAAO,cAAc,CAAA;AAsJrB,eAAO,MAAM,SAAS,0BAAoC,CAAA"}
|
|
@@ -13,7 +13,7 @@ import { RenderComponent } from '../../providers/Config/RenderComponent.js';
|
|
|
13
13
|
import { FieldDescription } from '../FieldDescription/index.js';
|
|
14
14
|
import { FieldError } from '../FieldError/index.js';
|
|
15
15
|
const JSONFieldComponent = (props)=>{
|
|
16
|
-
const { descriptionProps, errorProps, field, field: { name, _path: pathFromProps, admin: { className, description, editorOptions, readOnly: readOnlyFromAdmin, style, width }, jsonSchema, label, required }, labelProps, readOnly: readOnlyFromTopLevelProps, validate } = props;
|
|
16
|
+
const { descriptionProps, errorProps, field, field: { name, _path: pathFromProps, admin: { className, description, editorOptions, readOnly: readOnlyFromAdmin, style, width } = {}, jsonSchema, label, required }, labelProps, readOnly: readOnlyFromTopLevelProps, validate } = props;
|
|
17
17
|
const readOnlyFromProps = readOnlyFromTopLevelProps || readOnlyFromAdmin;
|
|
18
18
|
const [stringValue, setStringValue] = useState();
|
|
19
19
|
const [jsonError, setJsonError] = useState();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/fields/JSON/index.tsx"],"sourcesContent":["'use client'\nimport type { JSONFieldProps } from 'payload'\n\nimport React, { useCallback, useEffect, useState } from 'react'\n\nimport { CodeEditor } from '../../elements/CodeEditor/index.js'\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { FieldLabel } from '../FieldLabel/index.js'\nimport { fieldBaseClass } from '../shared/index.js'\nimport './index.scss'\n\nconst baseClass = 'json-field'\n\nimport { useFieldProps } from '../../forms/FieldPropsProvider/index.js'\nimport { RenderComponent } from '../../providers/Config/RenderComponent.js'\nimport { FieldDescription } from '../FieldDescription/index.js'\nimport { FieldError } from '../FieldError/index.js'\n\nconst JSONFieldComponent: React.FC<JSONFieldProps> = (props) => {\n const {\n descriptionProps,\n errorProps,\n field,\n field: {\n name,\n _path: pathFromProps,\n admin: {
|
|
1
|
+
{"version":3,"sources":["../../../src/fields/JSON/index.tsx"],"sourcesContent":["'use client'\nimport type { JSONFieldProps } from 'payload'\n\nimport React, { useCallback, useEffect, useState } from 'react'\n\nimport { CodeEditor } from '../../elements/CodeEditor/index.js'\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { FieldLabel } from '../FieldLabel/index.js'\nimport { fieldBaseClass } from '../shared/index.js'\nimport './index.scss'\n\nconst baseClass = 'json-field'\n\nimport { useFieldProps } from '../../forms/FieldPropsProvider/index.js'\nimport { RenderComponent } from '../../providers/Config/RenderComponent.js'\nimport { FieldDescription } from '../FieldDescription/index.js'\nimport { FieldError } from '../FieldError/index.js'\n\nconst JSONFieldComponent: React.FC<JSONFieldProps> = (props) => {\n const {\n descriptionProps,\n errorProps,\n field,\n field: {\n name,\n _path: pathFromProps,\n admin: {\n className,\n description,\n editorOptions,\n readOnly: readOnlyFromAdmin,\n style,\n width,\n } = {},\n jsonSchema,\n label,\n required,\n },\n labelProps,\n readOnly: readOnlyFromTopLevelProps,\n validate,\n } = props\n const readOnlyFromProps = readOnlyFromTopLevelProps || readOnlyFromAdmin\n\n const [stringValue, setStringValue] = useState<string>()\n const [jsonError, setJsonError] = useState<string>()\n const [hasLoadedValue, setHasLoadedValue] = useState(false)\n\n const memoizedValidate = 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\n const { formInitializing, formProcessing, initialValue, path, setValue, showError, value } =\n useField<string>({\n path: pathFromContext ?? pathFromProps ?? name,\n validate: memoizedValidate,\n })\n\n const disabled = readOnlyFromProps || readOnlyFromContext || formProcessing || formInitializing\n\n const handleMount = useCallback(\n (editor, monaco) => {\n if (!jsonSchema) return\n\n const existingSchemas = monaco.languages.json.jsonDefaults.diagnosticsOptions.schemas || []\n const modelUri = monaco.Uri.parse(jsonSchema.uri)\n\n const model = monaco.editor.createModel(JSON.stringify(value, null, 2), 'json', modelUri)\n monaco.languages.json.jsonDefaults.setDiagnosticsOptions({\n enableSchemaRequest: true,\n schemas: [...existingSchemas, jsonSchema],\n validate: true,\n })\n\n editor.setModel(model)\n },\n [jsonSchema, value],\n )\n\n const handleChange = useCallback(\n (val) => {\n if (disabled) 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 [disabled, setValue, setStringValue],\n )\n\n useEffect(() => {\n if (hasLoadedValue || value === undefined) return\n\n setStringValue(\n value || initialValue ? JSON.stringify(value ? value : initialValue, null, 2) : '',\n )\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 disabled && 'read-only',\n ]\n .filter(Boolean)\n .join(' ')}\n style={{\n ...style,\n width,\n }}\n >\n <FieldLabel\n Label={field?.admin?.components?.Label}\n label={label}\n required={required}\n {...(labelProps || {})}\n />\n <div className={`${fieldBaseClass}__wrap`}>\n <FieldError\n CustomError={field?.admin?.components?.Error}\n path={path}\n {...(errorProps || {})}\n />\n <RenderComponent mappedComponent={field?.admin?.components?.beforeInput} />\n <CodeEditor\n defaultLanguage=\"json\"\n onChange={handleChange}\n onMount={handleMount}\n options={editorOptions}\n readOnly={disabled}\n value={stringValue}\n />\n <RenderComponent mappedComponent={field?.admin?.components?.afterInput} />\n </div>\n <FieldDescription\n Description={field?.admin?.components?.Description}\n description={description}\n {...(descriptionProps || {})}\n />\n </div>\n )\n}\n\nexport const JSONField = withCondition(JSONFieldComponent)\n"],"names":["React","useCallback","useEffect","useState","CodeEditor","useField","withCondition","FieldLabel","fieldBaseClass","baseClass","useFieldProps","RenderComponent","FieldDescription","FieldError","JSONFieldComponent","props","descriptionProps","errorProps","field","name","_path","pathFromProps","admin","className","description","editorOptions","readOnly","readOnlyFromAdmin","style","width","jsonSchema","label","required","labelProps","readOnlyFromTopLevelProps","validate","readOnlyFromProps","stringValue","setStringValue","jsonError","setJsonError","hasLoadedValue","setHasLoadedValue","memoizedValidate","value","options","path","pathFromContext","readOnlyFromContext","formInitializing","formProcessing","initialValue","setValue","showError","disabled","handleMount","editor","monaco","existingSchemas","languages","json","jsonDefaults","diagnosticsOptions","schemas","modelUri","Uri","parse","uri","model","createModel","JSON","stringify","setDiagnosticsOptions","enableSchemaRequest","setModel","handleChange","val","undefined","e","div","filter","Boolean","join","Label","components","CustomError","Error","mappedComponent","beforeInput","defaultLanguage","onChange","onMount","afterInput","Description","JSONField"],"mappings":"AAAA;;AAGA,OAAOA,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAE/D,SAASC,UAAU,QAAQ,qCAAoC;AAC/D,SAASC,QAAQ,QAAQ,gCAA+B;AACxD,SAASC,aAAa,QAAQ,qCAAoC;AAClE,SAASC,UAAU,QAAQ,yBAAwB;AACnD,SAASC,cAAc,QAAQ,qBAAoB;AACnD,OAAO,eAAc;AAErB,MAAMC,YAAY;AAElB,SAASC,aAAa,QAAQ,0CAAyC;AACvE,SAASC,eAAe,QAAQ,4CAA2C;AAC3E,SAASC,gBAAgB,QAAQ,+BAA8B;AAC/D,SAASC,UAAU,QAAQ,yBAAwB;AAEnD,MAAMC,qBAA+C,CAACC;IACpD,MAAM,EACJC,gBAAgB,EAChBC,UAAU,EACVC,KAAK,EACLA,OAAO,EACLC,IAAI,EACJC,OAAOC,aAAa,EACpBC,OAAO,EACLC,SAAS,EACTC,WAAW,EACXC,aAAa,EACbC,UAAUC,iBAAiB,EAC3BC,KAAK,EACLC,KAAK,EACN,GAAG,CAAC,CAAC,EACNC,UAAU,EACVC,KAAK,EACLC,QAAQ,EACT,EACDC,UAAU,EACVP,UAAUQ,yBAAyB,EACnCC,QAA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O,MAAM8E,YAAYxF,cAAcQ,oBAAmB"}
|
|
@@ -14,7 +14,7 @@ import { FieldDescription } from '../FieldDescription/index.js';
|
|
|
14
14
|
import { FieldError } from '../FieldError/index.js';
|
|
15
15
|
import { FieldLabel } from '../FieldLabel/index.js';
|
|
16
16
|
export const PointFieldComponent = (props)=>{
|
|
17
|
-
const { descriptionProps, errorProps, field, field: { name, _path: pathFromProps, admin: { className, description, placeholder, readOnly: readOnlyFromAdmin, step, style, width }, label, required }, labelProps, readOnly: readOnlyFromTopLevelProps, validate } = props;
|
|
17
|
+
const { descriptionProps, errorProps, field, field: { name, _path: pathFromProps, admin: { className, description, placeholder, readOnly: readOnlyFromAdmin, step, style, width } = {}, label, required }, labelProps, readOnly: readOnlyFromTopLevelProps, validate } = props;
|
|
18
18
|
const readOnlyFromProps = readOnlyFromTopLevelProps || readOnlyFromAdmin;
|
|
19
19
|
const { i18n, t } = useTranslation();
|
|
20
20
|
const memoizedValidate = useCallback((value, options)=>{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/fields/Point/index.tsx"],"sourcesContent":["'use client'\nimport type { PointFieldProps, PointFieldValidation } from 'payload'\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 { useFieldProps } from '../../forms/FieldPropsProvider/index.js'\nimport { RenderComponent } from '../../providers/Config/RenderComponent.js'\nimport { FieldDescription } from '../FieldDescription/index.js'\nimport { FieldError } from '../FieldError/index.js'\nimport { FieldLabel } from '../FieldLabel/index.js'\n\nexport const PointFieldComponent: React.FC<PointFieldProps> = (props) => {\n const {\n descriptionProps,\n errorProps,\n field,\n field: {\n name,\n _path: pathFromProps,\n admin: {\n className,\n description,\n placeholder,\n readOnly: readOnlyFromAdmin,\n step,\n style,\n width,\n },\n label,\n required,\n },\n labelProps,\n readOnly: readOnlyFromTopLevelProps,\n validate,\n } = props\n const readOnlyFromProps = readOnlyFromTopLevelProps || readOnlyFromAdmin\n\n const { i18n, t } = useTranslation()\n\n const memoizedValidate: PointFieldValidation = 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 = label ? getTranslation(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 <ul className={`${baseClass}__wrap`}>\n <li>\n <FieldLabel\n Label={field?.admin?.components?.Label}\n {...getCoordinateFieldLabel('longitude')}\n />\n <div className=\"input-wrapper\">\n <RenderComponent mappedComponent={field?.admin?.components?.beforeInput} />\n {/* disable eslint rule because the label is dynamic */}\n {/* eslint-disable-next-line jsx-a11y/control-has-associated-label */}\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 <RenderComponent mappedComponent={field?.admin?.components?.afterInput} />\n </div>\n </li>\n <li>\n <FieldLabel\n Label={field?.admin?.components?.Label}\n {...getCoordinateFieldLabel('latitude')}\n />\n <div className=\"input-wrapper\">\n <FieldError\n CustomError={field?.admin?.components?.Error}\n path={path}\n {...(errorProps || {})}\n />\n <RenderComponent mappedComponent={field?.admin?.components?.beforeInput} />\n {/* disable eslint rule because the label is dynamic */}\n {/* eslint-disable-next-line jsx-a11y/control-has-associated-label */}\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 <RenderComponent mappedComponent={field?.admin?.components?.afterInput} />\n </div>\n </li>\n </ul>\n <FieldDescription\n Description={field?.admin?.components?.Description}\n description={description}\n {...(descriptionProps || {})}\n />\n </div>\n )\n}\n\nexport const PointField = withCondition(PointFieldComponent)\n"],"names":["getTranslation","React","useCallback","useField","withCondition","useTranslation","fieldBaseClass","baseClass","useFieldProps","RenderComponent","FieldDescription","FieldError","FieldLabel","PointFieldComponent","props","descriptionProps","errorProps","field","name","_path","pathFromProps","admin","className","description","placeholder","readOnly","readOnlyFromAdmin","step","style","width","label","required","labelProps","readOnlyFromTopLevelProps","validate","readOnlyFromProps","i18n","t","memoizedValidate","value","options","path","pathFromContext","readOnlyFromContext","setValue","showError","handleChange","e","index","val","parseFloat","target","Number","isNaN","coordinates","getCoordinateFieldLabel","type","suffix","fieldLabel","div","filter","Boolean","join","ul","li","Label","components","mappedComponent","beforeInput","input","disabled","id","replace","onChange","afterInput","CustomError","Error","Description","PointField"],"mappings":"AAAA;;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;AACnD,OAAO,eAAc;AAErB,MAAMC,YAAY;AAElB,SAASC,aAAa,QAAQ,0CAAyC;AACvE,SAASC,eAAe,QAAQ,4CAA2C;AAC3E,SAASC,gBAAgB,QAAQ,+BAA8B;AAC/D,SAASC,UAAU,QAAQ,yBAAwB;AACnD,SAASC,UAAU,QAAQ,yBAAwB;AAEnD,OAAO,MAAMC,sBAAiD,CAACC;IAC7D,MAAM,EACJC,gBAAgB,EAChBC,UAAU,EACVC,KAAK,EACLA,OAAO,EACLC,IAAI,EACJC,OAAOC,aAAa,EACpBC,OAAO,EACLC,SAAS,EACTC,WAAW,EACXC,WAAW,EACXC,UAAUC,iBAAiB,EAC3BC,IAAI,EACJC,KAAK,EACLC,KAAK,EACN,
|
|
1
|
+
{"version":3,"sources":["../../../src/fields/Point/index.tsx"],"sourcesContent":["'use client'\nimport type { PointFieldProps, PointFieldValidation } from 'payload'\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 { useFieldProps } from '../../forms/FieldPropsProvider/index.js'\nimport { RenderComponent } from '../../providers/Config/RenderComponent.js'\nimport { FieldDescription } from '../FieldDescription/index.js'\nimport { FieldError } from '../FieldError/index.js'\nimport { FieldLabel } from '../FieldLabel/index.js'\n\nexport const PointFieldComponent: React.FC<PointFieldProps> = (props) => {\n const {\n descriptionProps,\n errorProps,\n field,\n field: {\n name,\n _path: pathFromProps,\n admin: {\n className,\n description,\n placeholder,\n readOnly: readOnlyFromAdmin,\n step,\n style,\n width,\n } = {},\n label,\n required,\n },\n labelProps,\n readOnly: readOnlyFromTopLevelProps,\n validate,\n } = props\n const readOnlyFromProps = readOnlyFromTopLevelProps || readOnlyFromAdmin\n\n const { i18n, t } = useTranslation()\n\n const memoizedValidate: PointFieldValidation = 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 = label ? getTranslation(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 <ul className={`${baseClass}__wrap`}>\n <li>\n <FieldLabel\n Label={field?.admin?.components?.Label}\n {...getCoordinateFieldLabel('longitude')}\n />\n <div className=\"input-wrapper\">\n <RenderComponent mappedComponent={field?.admin?.components?.beforeInput} />\n {/* disable eslint rule because the label is dynamic */}\n {/* eslint-disable-next-line jsx-a11y/control-has-associated-label */}\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 <RenderComponent mappedComponent={field?.admin?.components?.afterInput} />\n </div>\n </li>\n <li>\n <FieldLabel\n Label={field?.admin?.components?.Label}\n {...getCoordinateFieldLabel('latitude')}\n />\n <div className=\"input-wrapper\">\n <FieldError\n CustomError={field?.admin?.components?.Error}\n path={path}\n {...(errorProps || {})}\n />\n <RenderComponent mappedComponent={field?.admin?.components?.beforeInput} />\n {/* disable eslint rule because the label is dynamic */}\n {/* eslint-disable-next-line jsx-a11y/control-has-associated-label */}\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 <RenderComponent mappedComponent={field?.admin?.components?.afterInput} />\n </div>\n </li>\n </ul>\n <FieldDescription\n Description={field?.admin?.components?.Description}\n description={description}\n {...(descriptionProps || {})}\n />\n </div>\n )\n}\n\nexport const PointField = withCondition(PointFieldComponent)\n"],"names":["getTranslation","React","useCallback","useField","withCondition","useTranslation","fieldBaseClass","baseClass","useFieldProps","RenderComponent","FieldDescription","FieldError","FieldLabel","PointFieldComponent","props","descriptionProps","errorProps","field","name","_path","pathFromProps","admin","className","description","placeholder","readOnly","readOnlyFromAdmin","step","style","width","label","required","labelProps","readOnlyFromTopLevelProps","validate","readOnlyFromProps","i18n","t","memoizedValidate","value","options","path","pathFromContext","readOnlyFromContext","setValue","showError","handleChange","e","index","val","parseFloat","target","Number","isNaN","coordinates","getCoordinateFieldLabel","type","suffix","fieldLabel","div","filter","Boolean","join","ul","li","Label","components","mappedComponent","beforeInput","input","disabled","id","replace","onChange","afterInput","CustomError","Error","Description","PointField"],"mappings":"AAAA;;AAGA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,OAAOC,SAASC,WAAW,QAAQ,QAAO;AAE1C,SAASC,QA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,OAAOA,KAAK,CAAC,EAAE,KAAK,WAAWA,KAAK,CAAC,EAAE,GAAG;;kDAE5D,KAAC9B;wCAAgB0D,iBAAiBlD,OAAOI,OAAO6C,YAAYQ;;;;;;kCAGhE,MAACV;;0CACC,KAACpD;gCACCqD,OAAOhD,OAAOI,OAAO6C,YAAYD;gCAChC,GAAGV,wBAAwB,WAAW;;0CAEzC,MAACI;gCAAIrC,WAAU;;kDACb,KAACX;wCACCgE,aAAa1D,OAAOI,OAAO6C,YAAYU;wCACvCnC,MAAMA;wCACL,GAAIzB,cAAc,CAAC,CAAC;;kDAEvB,KAACP;wCAAgB0D,iBAAiBlD,OAAOI,OAAO6C,YAAYE;;kDAG5D,KAACC;wCACCC,UAAU7C;wCACV8C,IAAI,CAAC,eAAe,EAAE9B,KAAK+B,OAAO,CAAC,OAAO,MAAM,CAAC;wCACjDtD,MAAM,CAAC,EAAEuB,KAAK,SAAS,CAAC;wCACxBgC,UAAU,CAAC1B,IAAMD,aAAaC,GAAG;wCACjCvB,aAAaxB,eAAewB,aAAaY;wCACzCT,MAAMA;wCACN6B,MAAK;wCACLjB,OAAOA,SAAS,OAAOA,KAAK,CAAC,EAAE,KAAK,WAAWA,KAAK,CAAC,EAAE,GAAG;;kDAE5D,KAAC9B;wCAAgB0D,iBAAiBlD,OAAOI,OAAO6C,YAAYQ;;;;;;;;0BAIlE,KAAChE;gBACCmE,aAAa5D,OAAOI,OAAO6C,YAAYW;gBACvCtD,aAAaA;gBACZ,GAAIR,oBAAoB,CAAC,CAAC;;;;AAInC,EAAC;AAED,OAAO,MAAM+D,aAAa1E,cAAcS,qBAAoB"}
|
|
@@ -26,7 +26,7 @@ import { SingleValue } from './select-components/SingleValue/index.js';
|
|
|
26
26
|
const maxResultsPerRequest = 10;
|
|
27
27
|
const baseClass = 'relationship';
|
|
28
28
|
const RelationshipFieldComponent = (props)=>{
|
|
29
|
-
const { descriptionProps, errorProps, field, field: { name, _path: pathFromProps, admin: { allowCreate = true, className, description, isSortable = true, readOnly: readOnlyFromAdmin, sortOptions, style, width }, hasMany, label, relationTo, required }, labelProps, readOnly: readOnlyFromTopLevelProps, validate } = props;
|
|
29
|
+
const { descriptionProps, errorProps, field, field: { name, _path: pathFromProps, admin: { allowCreate = true, className, description, isSortable = true, readOnly: readOnlyFromAdmin, sortOptions, style, width } = {}, hasMany, label, relationTo, required }, labelProps, readOnly: readOnlyFromTopLevelProps, validate } = props;
|
|
30
30
|
const readOnlyFromProps = readOnlyFromTopLevelProps || readOnlyFromAdmin;
|
|
31
31
|
const { config } = useConfig();
|
|
32
32
|
const { collections, routes: { api }, serverURL } = config;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/fields/Relationship/index.tsx"],"sourcesContent":["'use client'\nimport type { PaginatedDocs, RelationshipFieldProps, Where } from 'payload'\n\nimport { wordBoundariesRegex } from 'payload/shared'\nimport * as qs from 'qs-esm'\nimport React, { useCallback, useEffect, useReducer, useRef, useState } from 'react'\n\nimport type { DocumentDrawerProps } from '../../elements/DocumentDrawer/types.js'\nimport type { GetResults, Option, Value } from './types.js'\n\nimport { ReactSelect } from '../../elements/ReactSelect/index.js'\nimport { useFieldProps } from '../../forms/FieldPropsProvider/index.js'\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { useDebouncedCallback } from '../../hooks/useDebouncedCallback.js'\nimport { useAuth } from '../../providers/Auth/index.js'\nimport { useConfig } from '../../providers/Config/index.js'\nimport { useLocale } from '../../providers/Locale/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { FieldDescription } from '../FieldDescription/index.js'\nimport { FieldError } from '../FieldError/index.js'\nimport { FieldLabel } from '../FieldLabel/index.js'\nimport { fieldBaseClass } from '../shared/index.js'\nimport { AddNewRelation } from './AddNew/index.js'\nimport { createRelationMap } from './createRelationMap.js'\nimport { findOptionsByValue } from './findOptionsByValue.js'\nimport './index.scss'\nimport { optionsReducer } from './optionsReducer.js'\nimport { MultiValueLabel } from './select-components/MultiValueLabel/index.js'\nimport { SingleValue } from './select-components/SingleValue/index.js'\n\nconst maxResultsPerRequest = 10\n\nconst baseClass = 'relationship'\n\nconst RelationshipFieldComponent: React.FC<RelationshipFieldProps> = (props) => {\n const {\n descriptionProps,\n errorProps,\n field,\n field: {\n name,\n _path: pathFromProps,\n admin: {\n allowCreate = true,\n className,\n description,\n isSortable = true,\n readOnly: readOnlyFromAdmin,\n sortOptions,\n style,\n width,\n },\n hasMany,\n label,\n relationTo,\n required,\n },\n labelProps,\n readOnly: readOnlyFromTopLevelProps,\n validate,\n } = props\n const readOnlyFromProps = readOnlyFromTopLevelProps || readOnlyFromAdmin\n\n const { config } = useConfig()\n\n const {\n collections,\n routes: { api },\n serverURL,\n } = config\n\n const { i18n, t } = useTranslation()\n const { permissions } = useAuth()\n const { code: locale } = useLocale()\n const hasMultipleRelations = Array.isArray(relationTo)\n const [options, dispatchOptions] = useReducer(optionsReducer, [])\n const [lastFullyLoadedRelation, setLastFullyLoadedRelation] = useState(-1)\n const [lastLoadedPage, setLastLoadedPage] = useState<Record<string, number>>({})\n const [errorLoading, setErrorLoading] = useState('')\n const [search, setSearch] = useState('')\n const [isLoading, setIsLoading] = useState(false)\n const [enableWordBoundarySearch, setEnableWordBoundarySearch] = useState(false)\n const menuIsOpen = useRef(false)\n const hasLoadedFirstPageRef = useRef(false)\n\n const memoizedValidate = useCallback(\n (value, validationOptions) => {\n if (typeof validate === 'function') {\n return validate(value, { ...validationOptions, required })\n }\n },\n [validate, required],\n )\n const { path: pathFromContext, readOnly: readOnlyFromContext } = useFieldProps()\n\n const {\n filterOptions,\n formInitializing,\n formProcessing,\n initialValue,\n path,\n setValue,\n showError,\n value,\n } = useField<Value | Value[]>({\n path: pathFromContext ?? pathFromProps ?? name,\n validate: memoizedValidate,\n })\n\n const readOnly = readOnlyFromProps || readOnlyFromContext || formInitializing\n\n const valueRef = useRef(value)\n valueRef.current = value\n\n const [drawerIsOpen, setDrawerIsOpen] = useState(false)\n\n const getResults: GetResults = useCallback(\n async ({\n lastFullyLoadedRelation: lastFullyLoadedRelationArg,\n lastLoadedPage: lastLoadedPageArg,\n onSuccess,\n search: searchArg,\n sort,\n value: valueArg,\n }) => {\n if (!permissions) {\n return\n }\n const lastFullyLoadedRelationToUse =\n typeof lastFullyLoadedRelationArg !== 'undefined' ? lastFullyLoadedRelationArg : -1\n\n const relations = Array.isArray(relationTo) ? relationTo : [relationTo]\n const relationsToFetch =\n lastFullyLoadedRelationToUse === -1\n ? relations\n : relations.slice(lastFullyLoadedRelationToUse + 1)\n\n let resultsFetched = 0\n const relationMap = createRelationMap({\n hasMany,\n relationTo,\n value: valueArg,\n })\n\n if (!errorLoading) {\n await relationsToFetch.reduce(async (priorRelation, relation) => {\n const relationFilterOption = filterOptions?.[relation]\n\n let lastLoadedPageToUse\n if (search !== searchArg) {\n lastLoadedPageToUse = 1\n } else {\n lastLoadedPageToUse = lastLoadedPageArg[relation] + 1\n }\n await priorRelation\n\n if (relationFilterOption === false) {\n setLastFullyLoadedRelation(relations.indexOf(relation))\n return Promise.resolve()\n }\n\n if (resultsFetched < 10) {\n const collection = collections.find((coll) => coll.slug === relation)\n const fieldToSearch = collection?.admin?.useAsTitle || 'id'\n let fieldToSort = collection?.defaultSort || 'id'\n if (typeof sortOptions === 'string') {\n fieldToSort = sortOptions\n } else if (sortOptions?.[relation]) {\n fieldToSort = sortOptions[relation]\n }\n\n const query: {\n [key: string]: unknown\n where: Where\n } = {\n depth: 0,\n draft: true,\n limit: maxResultsPerRequest,\n locale,\n page: lastLoadedPageToUse,\n sort: fieldToSort,\n where: {\n and: [\n {\n id: {\n not_in: relationMap[relation],\n },\n },\n ],\n },\n }\n\n if (searchArg) {\n query.where.and.push({\n [fieldToSearch]: {\n like: searchArg,\n },\n })\n }\n\n if (relationFilterOption && typeof relationFilterOption !== 'boolean') {\n query.where.and.push(relationFilterOption)\n }\n\n const response = await fetch(`${serverURL}${api}/${relation}`, {\n body: qs.stringify(query),\n credentials: 'include',\n headers: {\n 'Accept-Language': i18n.language,\n 'Content-Type': 'application/x-www-form-urlencoded',\n 'X-HTTP-Method-Override': 'GET',\n },\n method: 'POST',\n })\n\n if (response.ok) {\n const data: PaginatedDocs<unknown> = await response.json()\n setLastLoadedPage((prevState) => {\n return {\n ...prevState,\n [relation]: lastLoadedPageToUse,\n }\n })\n\n if (!data.nextPage) {\n setLastFullyLoadedRelation(relations.indexOf(relation))\n }\n\n if (data.docs.length > 0) {\n resultsFetched += data.docs.length\n\n dispatchOptions({\n type: 'ADD',\n collection,\n // TODO: fix this\n // @ts-expect-error-next-line\n config,\n docs: data.docs,\n i18n,\n sort,\n })\n }\n } else if (response.status === 403) {\n setLastFullyLoadedRelation(relations.indexOf(relation))\n dispatchOptions({\n type: 'ADD',\n collection,\n // TODO: fix this\n // @ts-expect-error-next-line\n config,\n docs: [],\n i18n,\n ids: relationMap[relation],\n sort,\n })\n } else {\n setErrorLoading(t('error:unspecific'))\n }\n }\n }, Promise.resolve())\n\n if (typeof onSuccess === 'function') onSuccess()\n }\n },\n [\n permissions,\n relationTo,\n hasMany,\n errorLoading,\n search,\n collections,\n locale,\n filterOptions,\n serverURL,\n sortOptions,\n api,\n i18n,\n config,\n t,\n ],\n )\n\n const updateSearch = useDebouncedCallback((searchArg: string, valueArg: Value | Value[]) => {\n void getResults({ lastLoadedPage: {}, search: searchArg, sort: true, value: valueArg })\n setSearch(searchArg)\n }, 300)\n\n const handleInputChange = useCallback(\n (searchArg: string, valueArg: Value | Value[]) => {\n if (search !== searchArg) {\n setLastLoadedPage({})\n updateSearch(searchArg, valueArg, searchArg !== '')\n }\n },\n [search, updateSearch],\n )\n\n // ///////////////////////////////////\n // Ensure we have an option for each value\n // ///////////////////////////////////\n\n useEffect(() => {\n const relationMap = createRelationMap({\n hasMany,\n relationTo,\n value,\n })\n\n void Object.entries(relationMap).reduce(async (priorRelation, [relation, ids]) => {\n await priorRelation\n\n const idsToLoad = ids.filter((id) => {\n return !options.find((optionGroup) =>\n optionGroup?.options?.find(\n (option) => option.value === id && option.relationTo === relation,\n ),\n )\n })\n\n if (idsToLoad.length > 0) {\n const query = {\n depth: 0,\n draft: true,\n limit: idsToLoad.length,\n locale,\n where: {\n id: {\n in: idsToLoad,\n },\n },\n }\n\n if (!errorLoading) {\n const response = await fetch(`${serverURL}${api}/${relation}`, {\n body: qs.stringify(query),\n credentials: 'include',\n headers: {\n 'Accept-Language': i18n.language,\n 'Content-Type': 'application/x-www-form-urlencoded',\n 'X-HTTP-Method-Override': 'GET',\n },\n method: 'POST',\n })\n\n const collection = collections.find((coll) => coll.slug === relation)\n let docs = []\n\n if (response.ok) {\n const data = await response.json()\n docs = data.docs\n }\n\n dispatchOptions({\n type: 'ADD',\n collection,\n // TODO: fix this\n // @ts-expect-error-next-line\n config,\n docs,\n i18n,\n ids: idsToLoad,\n sort: true,\n })\n }\n }\n }, Promise.resolve())\n }, [\n options,\n value,\n hasMany,\n errorLoading,\n collections,\n hasMultipleRelations,\n serverURL,\n api,\n i18n,\n relationTo,\n locale,\n config,\n ])\n\n // Determine if we should switch to word boundary search\n useEffect(() => {\n const relations = Array.isArray(relationTo) ? relationTo : [relationTo]\n const isIdOnly = relations.reduce((idOnly, relation) => {\n const collection = collections.find((coll) => coll.slug === relation)\n const fieldToSearch = collection?.admin?.useAsTitle || 'id'\n return fieldToSearch === 'id' && idOnly\n }, true)\n setEnableWordBoundarySearch(!isIdOnly)\n }, [relationTo, collections])\n\n // When (`relationTo` || `filterOptions` || `locale`) changes, reset component\n // Note - effect should not run on first run\n useEffect(() => {\n // If the menu is open while filterOptions changes\n // due to latency of getFormState and fast clicking into this field,\n // re-fetch options\n\n if (hasLoadedFirstPageRef.current && menuIsOpen.current) {\n setIsLoading(true)\n void getResults({\n lastLoadedPage: {},\n onSuccess: () => {\n hasLoadedFirstPageRef.current = true\n setIsLoading(false)\n },\n value: valueRef.current,\n })\n }\n\n // If the menu is not open, still reset the field state\n // because we need to get new options next time the menu\n // opens by the user\n\n dispatchOptions({ type: 'CLEAR' })\n setLastFullyLoadedRelation(-1)\n setLastLoadedPage({})\n hasLoadedFirstPageRef.current = false\n }, [\n relationTo,\n filterOptions,\n locale,\n menuIsOpen,\n getResults,\n valueRef,\n hasLoadedFirstPageRef,\n path,\n ])\n\n const onSave = useCallback<DocumentDrawerProps['onSave']>(\n (args) => {\n dispatchOptions({\n type: 'UPDATE',\n collection: args.collectionConfig,\n // TODO: fix this\n // @ts-expect-error-next-line\n config,\n doc: args.doc,\n i18n,\n })\n },\n [i18n, config],\n )\n\n const filterOption = useCallback((item: Option, searchFilter: string) => {\n if (!searchFilter) {\n return true\n }\n const r = wordBoundariesRegex(searchFilter || '')\n // breaking the labels to search into smaller parts increases performance\n const breakApartThreshold = 250\n let string = item.label\n // strings less than breakApartThreshold length won't be chunked\n while (string.length > breakApartThreshold) {\n // slicing by the next space after the length of the search input prevents slicing the string up by partial words\n const indexOfSpace = string.indexOf(' ', searchFilter.length)\n if (r.test(string.slice(0, indexOfSpace === -1 ? searchFilter.length : indexOfSpace + 1))) {\n return true\n }\n string = string.slice(indexOfSpace === -1 ? searchFilter.length : indexOfSpace + 1)\n }\n return r.test(string.slice(-breakApartThreshold))\n }, [])\n\n const valueToRender = findOptionsByValue({ options, value })\n\n if (!Array.isArray(valueToRender) && valueToRender?.value === 'null') valueToRender.value = null\n\n return (\n <div\n className={[\n fieldBaseClass,\n baseClass,\n className,\n showError && 'error',\n errorLoading && 'error-loading',\n readOnly && `${baseClass}--read-only`,\n !readOnly && allowCreate && `${baseClass}--allow-create`,\n ]\n .filter(Boolean)\n .join(' ')}\n id={`field-${path.replace(/\\./g, '__')}`}\n style={{\n ...style,\n width,\n }}\n >\n <FieldLabel\n Label={field?.admin?.components?.Label}\n label={label}\n required={required}\n {...(labelProps || {})}\n />\n <div className={`${fieldBaseClass}__wrap`}>\n <FieldError\n CustomError={field?.admin?.components?.Error}\n path={path}\n {...(errorProps || {})}\n />\n {!errorLoading && (\n <div className={`${baseClass}__wrap`}>\n <ReactSelect\n backspaceRemovesValue={!drawerIsOpen}\n components={{\n MultiValueLabel,\n SingleValue,\n }}\n customProps={{\n disableKeyDown: drawerIsOpen,\n disableMouseDown: drawerIsOpen,\n onSave,\n setDrawerIsOpen,\n }}\n disabled={readOnly || formProcessing || drawerIsOpen}\n filterOption={enableWordBoundarySearch ? filterOption : undefined}\n getOptionValue={(option) => {\n if (!option) return undefined\n return hasMany && Array.isArray(relationTo)\n ? `${option.relationTo}_${option.value}`\n : option.value\n }}\n isLoading={isLoading}\n isMulti={hasMany}\n isSortable={isSortable}\n onChange={\n !readOnly\n ? (selected) => {\n if (selected === null) {\n setValue(hasMany ? [] : null)\n } else if (hasMany && Array.isArray(selected)) {\n setValue(\n selected\n ? selected.map((option) => {\n if (hasMultipleRelations) {\n return {\n relationTo: option.relationTo,\n value: option.value,\n }\n }\n\n return option.value\n })\n : null,\n )\n } else if (hasMultipleRelations && !Array.isArray(selected)) {\n setValue({\n relationTo: selected.relationTo,\n value: selected.value,\n })\n } else if (!Array.isArray(selected)) {\n setValue(selected.value)\n }\n }\n : undefined\n }\n onInputChange={(newSearch) => handleInputChange(newSearch, value)}\n onMenuClose={() => {\n menuIsOpen.current = false\n }}\n onMenuOpen={() => {\n menuIsOpen.current = true\n\n if (!hasLoadedFirstPageRef.current) {\n setIsLoading(true)\n void getResults({\n lastLoadedPage: {},\n onSuccess: () => {\n hasLoadedFirstPageRef.current = true\n setIsLoading(false)\n },\n value: initialValue,\n })\n }\n }}\n onMenuScrollToBottom={() => {\n void getResults({\n lastFullyLoadedRelation,\n lastLoadedPage,\n search,\n sort: false,\n value: initialValue,\n })\n }}\n options={options}\n showError={showError}\n value={valueToRender ?? null}\n />\n {!readOnly && allowCreate && (\n <AddNewRelation\n {...{\n dispatchOptions,\n hasMany,\n options,\n path,\n relationTo,\n setValue,\n value,\n }}\n />\n )}\n </div>\n )}\n {errorLoading && <div className={`${baseClass}__error-loading`}>{errorLoading}</div>}\n <FieldDescription\n Description={field?.admin?.components?.Description}\n description={description}\n {...(descriptionProps || {})}\n />\n </div>\n </div>\n )\n}\n\nexport const RelationshipField = withCondition(RelationshipFieldComponent)\n"],"names":["wordBoundariesRegex","qs","React","useCallback","useEffect","useReducer","useRef","useState","ReactSelect","useFieldProps","useField","withCondition","useDebouncedCallback","useAuth","useConfig","useLocale","useTranslation","FieldDescription","FieldError","FieldLabel","fieldBaseClass","AddNewRelation","createRelationMap","findOptionsByValue","optionsReducer","MultiValueLabel","SingleValue","maxResultsPerRequest","baseClass","RelationshipFieldComponent","props","descriptionProps","errorProps","field","name","_path","pathFromProps","admin","allowCreate","className","description","isSortable","readOnly","readOnlyFromAdmin","sortOptions","style","width","hasMany","label","relationTo","required","labelProps","readOnlyFromTopLevelProps","validate","readOnlyFromProps","config","collections","routes","api","serverURL","i18n","t","permissions","code","locale","hasMultipleRelations","Array","isArray","options","dispatchOptions","lastFullyLoadedRelation","setLastFullyLoadedRelation","lastLoadedPage","setLastLoadedPage","errorLoading","setErrorLoading","search","setSearch","isLoading","setIsLoading","enableWordBoundarySearch","setEnableWordBoundarySearch","menuIsOpen","hasLoadedFirstPageRef","memoizedValidate","value","validationOptions","path","pathFromContext","readOnlyFromContext","filterOptions","formInitializing","formProcessing","initialValue","setValue","showError","valueRef","current","drawerIsOpen","setDrawerIsOpen","getResults","lastFullyLoadedRelationArg","lastLoadedPageArg","onSuccess","searchArg","sort","valueArg","lastFullyLoadedRelationToUse","relations","relationsToFetch","slice","resultsFetched","relationMap","reduce","priorRelation","relation","relationFilterOption","lastLoadedPageToUse","indexOf","Promise","resolve","collection","find","coll","slug","fieldToSearch","useAsTitle","fieldToSort","defaultSort","query","depth","draft","limit","page","where","and","id","not_in","push","like","response","fetch","body","stringify","credentials","headers","language","method","ok","data","json","prevState","nextPage","docs","length","type","status","ids","updateSearch","handleInputChange","Object","entries","idsToLoad","filter","optionGroup","option","in","isIdOnly","idOnly","onSave","args","collectionConfig","doc","filterOption","item","searchFilter","r","breakApartThreshold","string","indexOfSpace","test","valueToRender","div","Boolean","join","replace","Label","components","CustomError","Error","backspaceRemovesValue","customProps","disableKeyDown","disableMouseDown","disabled","undefined","getOptionValue","isMulti","onChange","selected","map","onInputChange","newSearch","onMenuClose","onMenuOpen","onMenuScrollToBottom","Description","RelationshipField"],"mappings":"AAAA;;AAGA,SAASA,mBAAmB,QAAQ,iBAAgB;AACpD,YAAYC,QAAQ,SAAQ;AAC5B,OAAOC,SAASC,WAAW,EAAEC,SAAS,EAAEC,UAAU,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAO;AAKnF,SAASC,WAAW,QAAQ,sCAAqC;AACjE,SAASC,aAAa,QAAQ,0CAAyC;AACvE,SAASC,QAAQ,QAAQ,gCAA+B;AACxD,SAASC,aAAa,QAAQ,qCAAoC;AAClE,SAASC,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,OAAO,QAAQ,gCAA+B;AACvD,SAASC,SAAS,QAAQ,kCAAiC;AAC3D,SAASC,SAAS,QAAQ,kCAAiC;AAC3D,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,gBAAgB,QAAQ,+BAA8B;AAC/D,SAASC,UAAU,QAAQ,yBAAwB;AACnD,SAASC,UAAU,QAAQ,yBAAwB;AACnD,SAASC,cAAc,QAAQ,qBAAoB;AACnD,SAASC,cAAc,QAAQ,oBAAmB;AAClD,SAASC,iBAAiB,QAAQ,yBAAwB;AAC1D,SAASC,kBAAkB,QAAQ,0BAAyB;AAC5D,OAAO,eAAc;AACrB,SAASC,cAAc,QAAQ,sBAAqB;AACpD,SAASC,eAAe,QAAQ,+CAA8C;AAC9E,SAASC,WAAW,QAAQ,2CAA0C;AAEtE,MAAMC,uBAAuB;AAE7B,MAAMC,YAAY;AAElB,MAAMC,6BAA+D,CAACC;IACpE,MAAM,EACJC,gBAAgB,EAChBC,UAAU,EACVC,KAAK,EACLA,OAAO,EACLC,IAAI,EACJC,OAAOC,aAAa,EACpBC,OAA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OAAO,IAAI,CAACnB,MAAMC,OAAO,CAACoI,WAAW;wCACnCzG,SAASyG,SAASlH,KAAK;oCACzB;gCACF,IACA8G;gCAENM,eAAe,CAACC,YAAc3C,kBAAkB2C,WAAWrH;gCAC3DsH,aAAa;oCACXzH,WAAWe,OAAO,GAAG;gCACvB;gCACA2G,YAAY;oCACV1H,WAAWe,OAAO,GAAG;oCAErB,IAAI,CAACd,sBAAsBc,OAAO,EAAE;wCAClClB,aAAa;wCACb,KAAKqB,WAAW;4CACd5B,gBAAgB,CAAC;4CACjB+B,WAAW;gDACTpB,sBAAsBc,OAAO,GAAG;gDAChClB,aAAa;4CACf;4CACAM,OAAOQ;wCACT;oCACF;gCACF;gCACAgH,sBAAsB;oCACpB,KAAKzG,WAAW;wCACd9B;wCACAE;wCACAI;wCACA6B,MAAM;wCACNpB,OAAOQ;oCACT;gCACF;gCACAzB,SAASA;gCACT2B,WAAWA;gCACXV,OAAOgG,iBAAiB;;4BAEzB,CAAC3I,YAAYJ,6BACZ,KAACjB;gCAEGgD;gCACAtB;gCACAqB;gCACAmB;gCACAtC;gCACA6C;gCACAT;;;;oBAMTX,8BAAgB,KAAC4G;wBAAI/I,WAAW,CAAC,EAAEX,UAAU,eAAe,CAAC;kCAAG8C;;kCACjE,KAACzD;wBACC6L,aAAa7K,OAAOI,OAAOsJ,YAAYmB;wBACvCtK,aAAaA;wBACZ,GAAIT,oBAAoB,CAAC,CAAC;;;;;;AAKrC;AAEA,OAAO,MAAMgL,oBAAoBpM,cAAckB,4BAA2B"}
|
|
1
|
+
{"version":3,"sources":["../../../src/fields/Relationship/index.tsx"],"sourcesContent":["'use client'\nimport type { PaginatedDocs, RelationshipFieldProps, Where } from 'payload'\n\nimport { wordBoundariesRegex } from 'payload/shared'\nimport * as qs from 'qs-esm'\nimport React, { useCallback, useEffect, useReducer, useRef, useState } from 'react'\n\nimport type { DocumentDrawerProps } from '../../elements/DocumentDrawer/types.js'\nimport type { GetResults, Option, Value } from './types.js'\n\nimport { ReactSelect } from '../../elements/ReactSelect/index.js'\nimport { useFieldProps } from '../../forms/FieldPropsProvider/index.js'\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { useDebouncedCallback } from '../../hooks/useDebouncedCallback.js'\nimport { useAuth } from '../../providers/Auth/index.js'\nimport { useConfig } from '../../providers/Config/index.js'\nimport { useLocale } from '../../providers/Locale/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { FieldDescription } from '../FieldDescription/index.js'\nimport { FieldError } from '../FieldError/index.js'\nimport { FieldLabel } from '../FieldLabel/index.js'\nimport { fieldBaseClass } from '../shared/index.js'\nimport { AddNewRelation } from './AddNew/index.js'\nimport { createRelationMap } from './createRelationMap.js'\nimport { findOptionsByValue } from './findOptionsByValue.js'\nimport './index.scss'\nimport { optionsReducer } from './optionsReducer.js'\nimport { MultiValueLabel } from './select-components/MultiValueLabel/index.js'\nimport { SingleValue } from './select-components/SingleValue/index.js'\n\nconst maxResultsPerRequest = 10\n\nconst baseClass = 'relationship'\n\nconst RelationshipFieldComponent: React.FC<RelationshipFieldProps> = (props) => {\n const {\n descriptionProps,\n errorProps,\n field,\n field: {\n name,\n _path: pathFromProps,\n admin: {\n allowCreate = true,\n className,\n description,\n isSortable = true,\n readOnly: readOnlyFromAdmin,\n sortOptions,\n style,\n width,\n } = {},\n hasMany,\n label,\n relationTo,\n required,\n },\n labelProps,\n readOnly: readOnlyFromTopLevelProps,\n validate,\n } = props\n const readOnlyFromProps = readOnlyFromTopLevelProps || readOnlyFromAdmin\n\n const { config } = useConfig()\n\n const {\n collections,\n routes: { api },\n serverURL,\n } = config\n\n const { i18n, t } = useTranslation()\n const { permissions } = useAuth()\n const { code: locale } = useLocale()\n const hasMultipleRelations = Array.isArray(relationTo)\n const [options, dispatchOptions] = useReducer(optionsReducer, [])\n const [lastFullyLoadedRelation, setLastFullyLoadedRelation] = useState(-1)\n const [lastLoadedPage, setLastLoadedPage] = useState<Record<string, number>>({})\n const [errorLoading, setErrorLoading] = useState('')\n const [search, setSearch] = useState('')\n const [isLoading, setIsLoading] = useState(false)\n const [enableWordBoundarySearch, setEnableWordBoundarySearch] = useState(false)\n const menuIsOpen = useRef(false)\n const hasLoadedFirstPageRef = useRef(false)\n\n const memoizedValidate = useCallback(\n (value, validationOptions) => {\n if (typeof validate === 'function') {\n return validate(value, { ...validationOptions, required })\n }\n },\n [validate, required],\n )\n const { path: pathFromContext, readOnly: readOnlyFromContext } = useFieldProps()\n\n const {\n filterOptions,\n formInitializing,\n formProcessing,\n initialValue,\n path,\n setValue,\n showError,\n value,\n } = useField<Value | Value[]>({\n path: pathFromContext ?? pathFromProps ?? name,\n validate: memoizedValidate,\n })\n\n const readOnly = readOnlyFromProps || readOnlyFromContext || formInitializing\n\n const valueRef = useRef(value)\n valueRef.current = value\n\n const [drawerIsOpen, setDrawerIsOpen] = useState(false)\n\n const getResults: GetResults = useCallback(\n async ({\n lastFullyLoadedRelation: lastFullyLoadedRelationArg,\n lastLoadedPage: lastLoadedPageArg,\n onSuccess,\n search: searchArg,\n sort,\n value: valueArg,\n }) => {\n if (!permissions) {\n return\n }\n const lastFullyLoadedRelationToUse =\n typeof lastFullyLoadedRelationArg !== 'undefined' ? lastFullyLoadedRelationArg : -1\n\n const relations = Array.isArray(relationTo) ? relationTo : [relationTo]\n const relationsToFetch =\n lastFullyLoadedRelationToUse === -1\n ? relations\n : relations.slice(lastFullyLoadedRelationToUse + 1)\n\n let resultsFetched = 0\n const relationMap = createRelationMap({\n hasMany,\n relationTo,\n value: valueArg,\n })\n\n if (!errorLoading) {\n await relationsToFetch.reduce(async (priorRelation, relation) => {\n const relationFilterOption = filterOptions?.[relation]\n\n let lastLoadedPageToUse\n if (search !== searchArg) {\n lastLoadedPageToUse = 1\n } else {\n lastLoadedPageToUse = lastLoadedPageArg[relation] + 1\n }\n await priorRelation\n\n if (relationFilterOption === false) {\n setLastFullyLoadedRelation(relations.indexOf(relation))\n return Promise.resolve()\n }\n\n if (resultsFetched < 10) {\n const collection = collections.find((coll) => coll.slug === relation)\n const fieldToSearch = collection?.admin?.useAsTitle || 'id'\n let fieldToSort = collection?.defaultSort || 'id'\n if (typeof sortOptions === 'string') {\n fieldToSort = sortOptions\n } else if (sortOptions?.[relation]) {\n fieldToSort = sortOptions[relation]\n }\n\n const query: {\n [key: string]: unknown\n where: Where\n } = {\n depth: 0,\n draft: true,\n limit: maxResultsPerRequest,\n locale,\n page: lastLoadedPageToUse,\n sort: fieldToSort,\n where: {\n and: [\n {\n id: {\n not_in: relationMap[relation],\n },\n },\n ],\n },\n }\n\n if (searchArg) {\n query.where.and.push({\n [fieldToSearch]: {\n like: searchArg,\n },\n })\n }\n\n if (relationFilterOption && typeof relationFilterOption !== 'boolean') {\n query.where.and.push(relationFilterOption)\n }\n\n const response = await fetch(`${serverURL}${api}/${relation}`, {\n body: qs.stringify(query),\n credentials: 'include',\n headers: {\n 'Accept-Language': i18n.language,\n 'Content-Type': 'application/x-www-form-urlencoded',\n 'X-HTTP-Method-Override': 'GET',\n },\n method: 'POST',\n })\n\n if (response.ok) {\n const data: PaginatedDocs<unknown> = await response.json()\n setLastLoadedPage((prevState) => {\n return {\n ...prevState,\n [relation]: lastLoadedPageToUse,\n }\n })\n\n if (!data.nextPage) {\n setLastFullyLoadedRelation(relations.indexOf(relation))\n }\n\n if (data.docs.length > 0) {\n resultsFetched += data.docs.length\n\n dispatchOptions({\n type: 'ADD',\n collection,\n // TODO: fix this\n // @ts-expect-error-next-line\n config,\n docs: data.docs,\n i18n,\n sort,\n })\n }\n } else if (response.status === 403) {\n setLastFullyLoadedRelation(relations.indexOf(relation))\n dispatchOptions({\n type: 'ADD',\n collection,\n // TODO: fix this\n // @ts-expect-error-next-line\n config,\n docs: [],\n i18n,\n ids: relationMap[relation],\n sort,\n })\n } else {\n setErrorLoading(t('error:unspecific'))\n }\n }\n }, Promise.resolve())\n\n if (typeof onSuccess === 'function') onSuccess()\n }\n },\n [\n permissions,\n relationTo,\n hasMany,\n errorLoading,\n search,\n collections,\n locale,\n filterOptions,\n serverURL,\n sortOptions,\n api,\n i18n,\n config,\n t,\n ],\n )\n\n const updateSearch = useDebouncedCallback((searchArg: string, valueArg: Value | Value[]) => {\n void getResults({ lastLoadedPage: {}, search: searchArg, sort: true, value: valueArg })\n setSearch(searchArg)\n }, 300)\n\n const handleInputChange = useCallback(\n (searchArg: string, valueArg: Value | Value[]) => {\n if (search !== searchArg) {\n setLastLoadedPage({})\n updateSearch(searchArg, valueArg, searchArg !== '')\n }\n },\n [search, updateSearch],\n )\n\n // ///////////////////////////////////\n // Ensure we have an option for each value\n // ///////////////////////////////////\n\n useEffect(() => {\n const relationMap = createRelationMap({\n hasMany,\n relationTo,\n value,\n })\n\n void Object.entries(relationMap).reduce(async (priorRelation, [relation, ids]) => {\n await priorRelation\n\n const idsToLoad = ids.filter((id) => {\n return !options.find((optionGroup) =>\n optionGroup?.options?.find(\n (option) => option.value === id && option.relationTo === relation,\n ),\n )\n })\n\n if (idsToLoad.length > 0) {\n const query = {\n depth: 0,\n draft: true,\n limit: idsToLoad.length,\n locale,\n where: {\n id: {\n in: idsToLoad,\n },\n },\n }\n\n if (!errorLoading) {\n const response = await fetch(`${serverURL}${api}/${relation}`, {\n body: qs.stringify(query),\n credentials: 'include',\n headers: {\n 'Accept-Language': i18n.language,\n 'Content-Type': 'application/x-www-form-urlencoded',\n 'X-HTTP-Method-Override': 'GET',\n },\n method: 'POST',\n })\n\n const collection = collections.find((coll) => coll.slug === relation)\n let docs = []\n\n if (response.ok) {\n const data = await response.json()\n docs = data.docs\n }\n\n dispatchOptions({\n type: 'ADD',\n collection,\n // TODO: fix this\n // @ts-expect-error-next-line\n config,\n docs,\n i18n,\n ids: idsToLoad,\n sort: true,\n })\n }\n }\n }, Promise.resolve())\n }, [\n options,\n value,\n hasMany,\n errorLoading,\n collections,\n hasMultipleRelations,\n serverURL,\n api,\n i18n,\n relationTo,\n locale,\n config,\n ])\n\n // Determine if we should switch to word boundary search\n useEffect(() => {\n const relations = Array.isArray(relationTo) ? relationTo : [relationTo]\n const isIdOnly = relations.reduce((idOnly, relation) => {\n const collection = collections.find((coll) => coll.slug === relation)\n const fieldToSearch = collection?.admin?.useAsTitle || 'id'\n return fieldToSearch === 'id' && idOnly\n }, true)\n setEnableWordBoundarySearch(!isIdOnly)\n }, [relationTo, collections])\n\n // When (`relationTo` || `filterOptions` || `locale`) changes, reset component\n // Note - effect should not run on first run\n useEffect(() => {\n // If the menu is open while filterOptions changes\n // due to latency of getFormState and fast clicking into this field,\n // re-fetch options\n\n if (hasLoadedFirstPageRef.current && menuIsOpen.current) {\n setIsLoading(true)\n void getResults({\n lastLoadedPage: {},\n onSuccess: () => {\n hasLoadedFirstPageRef.current = true\n setIsLoading(false)\n },\n value: valueRef.current,\n })\n }\n\n // If the menu is not open, still reset the field state\n // because we need to get new options next time the menu\n // opens by the user\n\n dispatchOptions({ type: 'CLEAR' })\n setLastFullyLoadedRelation(-1)\n setLastLoadedPage({})\n hasLoadedFirstPageRef.current = false\n }, [\n relationTo,\n filterOptions,\n locale,\n menuIsOpen,\n getResults,\n valueRef,\n hasLoadedFirstPageRef,\n path,\n ])\n\n const onSave = useCallback<DocumentDrawerProps['onSave']>(\n (args) => {\n dispatchOptions({\n type: 'UPDATE',\n collection: args.collectionConfig,\n // TODO: fix this\n // @ts-expect-error-next-line\n config,\n doc: args.doc,\n i18n,\n })\n },\n [i18n, config],\n )\n\n const filterOption = useCallback((item: Option, searchFilter: string) => {\n if (!searchFilter) {\n return true\n }\n const r = wordBoundariesRegex(searchFilter || '')\n // breaking the labels to search into smaller parts increases performance\n const breakApartThreshold = 250\n let string = item.label\n // strings less than breakApartThreshold length won't be chunked\n while (string.length > breakApartThreshold) {\n // slicing by the next space after the length of the search input prevents slicing the string up by partial words\n const indexOfSpace = string.indexOf(' ', searchFilter.length)\n if (r.test(string.slice(0, indexOfSpace === -1 ? searchFilter.length : indexOfSpace + 1))) {\n return true\n }\n string = string.slice(indexOfSpace === -1 ? searchFilter.length : indexOfSpace + 1)\n }\n return r.test(string.slice(-breakApartThreshold))\n }, [])\n\n const valueToRender = findOptionsByValue({ options, value })\n\n if (!Array.isArray(valueToRender) && valueToRender?.value === 'null') valueToRender.value = null\n\n return (\n <div\n className={[\n fieldBaseClass,\n baseClass,\n className,\n showError && 'error',\n errorLoading && 'error-loading',\n readOnly && `${baseClass}--read-only`,\n !readOnly && allowCreate && `${baseClass}--allow-create`,\n ]\n .filter(Boolean)\n .join(' ')}\n id={`field-${path.replace(/\\./g, '__')}`}\n style={{\n ...style,\n width,\n }}\n >\n <FieldLabel\n Label={field?.admin?.components?.Label}\n label={label}\n required={required}\n {...(labelProps || {})}\n />\n <div className={`${fieldBaseClass}__wrap`}>\n <FieldError\n CustomError={field?.admin?.components?.Error}\n path={path}\n {...(errorProps || {})}\n />\n {!errorLoading && (\n <div className={`${baseClass}__wrap`}>\n <ReactSelect\n backspaceRemovesValue={!drawerIsOpen}\n components={{\n MultiValueLabel,\n SingleValue,\n }}\n customProps={{\n disableKeyDown: drawerIsOpen,\n disableMouseDown: drawerIsOpen,\n onSave,\n setDrawerIsOpen,\n }}\n disabled={readOnly || formProcessing || drawerIsOpen}\n filterOption={enableWordBoundarySearch ? filterOption : undefined}\n getOptionValue={(option) => {\n if (!option) return undefined\n return hasMany && Array.isArray(relationTo)\n ? `${option.relationTo}_${option.value}`\n : option.value\n }}\n isLoading={isLoading}\n isMulti={hasMany}\n isSortable={isSortable}\n onChange={\n !readOnly\n ? (selected) => {\n if (selected === null) {\n setValue(hasMany ? [] : null)\n } else if (hasMany && Array.isArray(selected)) {\n setValue(\n selected\n ? selected.map((option) => {\n if (hasMultipleRelations) {\n return {\n relationTo: option.relationTo,\n value: option.value,\n }\n }\n\n return option.value\n })\n : null,\n )\n } else if (hasMultipleRelations && !Array.isArray(selected)) {\n setValue({\n relationTo: selected.relationTo,\n value: selected.value,\n })\n } else if (!Array.isArray(selected)) {\n setValue(selected.value)\n }\n }\n : undefined\n }\n onInputChange={(newSearch) => handleInputChange(newSearch, value)}\n onMenuClose={() => {\n menuIsOpen.current = false\n }}\n onMenuOpen={() => {\n menuIsOpen.current = true\n\n if (!hasLoadedFirstPageRef.current) {\n setIsLoading(true)\n void getResults({\n lastLoadedPage: {},\n onSuccess: () => {\n hasLoadedFirstPageRef.current = true\n setIsLoading(false)\n },\n value: initialValue,\n })\n }\n }}\n onMenuScrollToBottom={() => {\n void getResults({\n lastFullyLoadedRelation,\n lastLoadedPage,\n search,\n sort: false,\n value: initialValue,\n })\n }}\n options={options}\n showError={showError}\n value={valueToRender ?? null}\n />\n {!readOnly && allowCreate && (\n <AddNewRelation\n {...{\n dispatchOptions,\n hasMany,\n options,\n path,\n relationTo,\n setValue,\n value,\n }}\n />\n )}\n </div>\n )}\n {errorLoading && <div className={`${baseClass}__error-loading`}>{errorLoading}</div>}\n <FieldDescription\n Description={field?.admin?.components?.Description}\n description={description}\n {...(descriptionProps || {})}\n />\n </div>\n </div>\n )\n}\n\nexport const RelationshipField = withCondition(RelationshipFieldComponent)\n"],"names":["wordBoundariesRegex","qs","React","useCallback","useEffect","useReducer","useRef","useState","ReactSelect","useFieldProps","useField","withCondition","useDebouncedCallback","useAuth","useConfig","useLocale","useTranslation","FieldDescription","FieldError","FieldLabel","fieldBaseClass","AddNewRelation","createRelationMap","findOptionsByValue","optionsReducer","MultiValueLabel","SingleValue","maxResultsPerRequest","baseClass","RelationshipFieldComponent","props","descriptionProps","errorProps","field","name","_path","pathFromProps","admin","allowCreate","className","description","isSortable","readOnly","readOnlyFromAdmin","sortOptions","style","width","hasMany","label","relationTo","required","labelProps","readOnlyFromTopLevelProps","validate","readOnlyFromProps","config","collections","routes","api","serverURL","i18n","t","permissions","code","locale","hasMultipleRelations","Array","isArray","options","dispatchOptions","lastFullyLoadedRelation","setLastFullyLoadedRelation","lastLoadedPage","setLastLoadedPage","errorLoading","setErrorLoading","search","setSearch","isLoading","setIsLoading","enableWordBoundarySearch","setEnableWordBoundarySearch","menuIsOpen","hasLoadedFirstPageRef","memoizedValidate","value","validationOptions","path","pathFromContext","readOnlyFromContext","filterOptions","formInitializing","formProcessing","initialValue","setValue","showError","valueRef","current","drawerIsOpen","setDrawerIsOpen","getResults","lastFullyLoadedRelationArg","lastLoadedPageArg","onSuccess","searchArg","sort","valueArg","lastFullyLoadedRelationToUse","relations","relationsToFetch","slice","resultsFetched","relationMap","reduce","priorRelation","relation","relationFilterOption","lastLoadedPageToUse","indexOf","Promise","resolve","collection","find","coll","slug","fieldToSearch","useAsTitle","fieldToSort","defaultSort","query","depth","draft","limit","page","where","and","id","not_in","push","like","response","fetch","body","stringify","credentials","headers","language","method","ok","data","json","prevState","nextPage","docs","length","type","status","ids","updateSearch","handleInputChange","Object","entries","idsToLoad","filter","optionGroup","option","in","isIdOnly","idOnly","onSave","args","collectionConfig","doc","filterOption","item","searchFilter","r","breakApartThreshold","string","indexOfSpace","test","valueToRender","div","Boolean","join","replace","Label","components","CustomError","Error","backspaceRemovesValue","customProps","disableKeyDown","disableMouseDown","disabled","undefined","getOptionValue","isMulti","onChange","selected","map","onInputChange","newSearch","onMenuClose","onMenuOpen","onMenuScrollToBottom","Description","RelationshipField"],"mappings":"AAAA;;AAGA,SAASA,mBAAmB,QAAQ,iBAAgB;AACpD,YAAYC,QAAQ,SAAQ;AAC5B,OAAOC,SAASC,WAAW,EAAEC,SAAS,EAAEC,UAAU,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAO;AAKnF,SAASC,WAAW,QAAQ,sCAAqC;AACjE,SAASC,aAAa,QAAQ,0CAAyC;AACvE,SAASC,QAAQ,QAAQ,gCAA+B;AACxD,SAASC,aAAa,QAAQ,qCAAoC;AAClE,SAASC,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,OAAO,QAAQ,gCAA+B;AACvD,SAASC,SAAS,QAAQ,kCAAiC;AAC3D,SAASC,SAAS,QAAQ,kCAAiC;AAC3D,SAASC,cAAc,QAAQ,uCAAsC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;gCACAtC;gCACA6C;gCACAT;;;;oBAMTX,8BAAgB,KAAC4G;wBAAI/I,WAAW,CAAC,EAAEX,UAAU,eAAe,CAAC;kCAAG8C;;kCACjE,KAACzD;wBACC6L,aAAa7K,OAAOI,OAAOsJ,YAAYmB;wBACvCtK,aAAaA;wBACZ,GAAIT,oBAAoB,CAAC,CAAC;;;;;;AAKrC;AAEA,OAAO,MAAMgL,oBAAoBpM,cAAckB,4BAA2B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/Row/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAE5C,OAAO,KAAK,MAAM,OAAO,CAAA;AAMzB,OAAO,cAAc,CAAA;AACrB,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAEnD,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/Row/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAE5C,OAAO,KAAK,MAAM,OAAO,CAAA;AAMzB,OAAO,cAAc,CAAA;AACrB,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAEnD,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,CAAA;AA+B9B,eAAO,MAAM,QAAQ,yBAAmC,CAAA"}
|
package/dist/fields/Row/index.js
CHANGED
|
@@ -10,7 +10,7 @@ import { RowProvider, useRow } from './provider.js';
|
|
|
10
10
|
export { RowProvider, useRow };
|
|
11
11
|
const baseClass = 'row';
|
|
12
12
|
const RowFieldComponent = (props)=>{
|
|
13
|
-
const { field: { admin: { className }, fields }, forceRender = false } = props;
|
|
13
|
+
const { field: { admin: { className } = {}, fields }, forceRender = false } = props;
|
|
14
14
|
const { indexPath, path, readOnly, schemaPath, siblingPermissions } = useFieldProps();
|
|
15
15
|
return /*#__PURE__*/ _jsx(RowProvider, {
|
|
16
16
|
children: /*#__PURE__*/ _jsx("div", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/fields/Row/index.tsx"],"sourcesContent":["'use client'\nimport type { RowFieldProps } from 'payload'\n\nimport React from 'react'\n\nimport { useFieldProps } from '../../forms/FieldPropsProvider/index.js'\nimport { RenderFields } from '../../forms/RenderFields/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { fieldBaseClass } from '../shared/index.js'\nimport './index.scss'\nimport { RowProvider, useRow } from './provider.js'\n\nexport { RowProvider, useRow }\n\nconst baseClass = 'row'\n\nconst RowFieldComponent: React.FC<RowFieldProps> = (props) => {\n const {\n field: {
|
|
1
|
+
{"version":3,"sources":["../../../src/fields/Row/index.tsx"],"sourcesContent":["'use client'\nimport type { RowFieldProps } from 'payload'\n\nimport React from 'react'\n\nimport { useFieldProps } from '../../forms/FieldPropsProvider/index.js'\nimport { RenderFields } from '../../forms/RenderFields/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { fieldBaseClass } from '../shared/index.js'\nimport './index.scss'\nimport { RowProvider, useRow } from './provider.js'\n\nexport { RowProvider, useRow }\n\nconst baseClass = 'row'\n\nconst RowFieldComponent: React.FC<RowFieldProps> = (props) => {\n const {\n field: { admin: { className } = {}, fields },\n forceRender = false,\n } = props\n\n const { indexPath, path, readOnly, schemaPath, siblingPermissions } = useFieldProps()\n\n return (\n <RowProvider>\n <div className={[fieldBaseClass, baseClass, className].filter(Boolean).join(' ')}>\n <RenderFields\n className={`${baseClass}__fields`}\n fields={fields}\n forceRender={forceRender}\n indexPath={indexPath}\n margins={false}\n path={path}\n permissions={siblingPermissions}\n readOnly={readOnly}\n schemaPath={schemaPath}\n />\n </div>\n </RowProvider>\n )\n}\n\nexport const RowField = withCondition(RowFieldComponent)\n"],"names":["React","useFieldProps","RenderFields","withCondition","fieldBaseClass","RowProvider","useRow","baseClass","RowFieldComponent","props","field","admin","className","fields","forceRender","indexPath","path","readOnly","schemaPath","siblingPermissions","div","filter","Boolean","join","margins","permissions","RowField"],"mappings":"AAAA;;AAGA,OAAOA,WAAW,QAAO;AAEzB,SAASC,aAAa,QAAQ,0CAAyC;AACvE,SAASC,YAAY,QAAQ,oCAAmC;AAChE,SAASC,aAAa,QAAQ,qCAAoC;AAClE,SAASC,cAAc,QAAQ,qBAAoB;AACnD,OAAO,eAAc;AACrB,SAASC,WAAW,EAAEC,MAAM,QAAQ,gBAAe;AAEnD,SAASD,WAAW,EAAEC,MAAM,GAAE;AAE9B,MAAMC,YAAY;AAElB,MAAMC,oBAA6C,CAACC;IAClD,MAAM,EACJC,OAAO,EAAEC,OAAO,EAAEC,SAAS,EAAE,GAAG,CAAC,CAAC,EAAEC,MAAM,EAAE,EAC5CC,cAAc,KAAK,EACpB,GAAGL;IAEJ,MAAM,EAAEM,SAAS,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,UAAU,EAAEC,kBAAkB,EAAE,GAAGlB;IAEtE,qBACE,KAACI;kBACC,cAAA,KAACe;YAAIR,WAAW;gBAACR;gBAAgBG;gBAAWK;aAAU,CAACS,MAAM,CAACC,SAASC,IAAI,CAAC;sBAC1E,cAAA,KAACrB;gBACCU,WAAW,CAAC,EAAEL,UAAU,QAAQ,CAAC;gBACjCM,QAAQA;gBACRC,aAAaA;gBACbC,WAAWA;gBACXS,SAAS;gBACTR,MAAMA;gBACNS,aAAaN;gBACbF,UAAUA;gBACVC,YAAYA;;;;AAKtB;AAEA,OAAO,MAAMQ,WAAWvB,cAAcK,mBAAkB"}
|
|
@@ -18,7 +18,7 @@ import { TabsProvider } from './provider.js';
|
|
|
18
18
|
const baseClass = 'tabs-field';
|
|
19
19
|
export { TabsProvider };
|
|
20
20
|
const TabsFieldComponent = (props)=>{
|
|
21
|
-
const { field, field: { _path: pathFromProps, admin: { className, readOnly: readOnlyFromAdmin }, tabs = [] }, forceRender = false, readOnly: readOnlyFromTopLevelProps } = props;
|
|
21
|
+
const { field, field: { _path: pathFromProps, admin: { className, readOnly: readOnlyFromAdmin } = {}, tabs = [] }, forceRender = false, readOnly: readOnlyFromTopLevelProps } = props;
|
|
22
22
|
const { indexPath, path: pathFromContext, readOnly: readOnlyFromContext, schemaPath, siblingPermissions } = useFieldProps();
|
|
23
23
|
const readOnlyFromProps = readOnlyFromTopLevelProps || readOnlyFromAdmin;
|
|
24
24
|
const readOnly = readOnlyFromProps || readOnlyFromContext;
|