@payloadcms/ui 3.0.0-beta.129 → 3.0.0-beta.130
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/EmailAndUsername/index.d.ts.map +1 -1
- package/dist/elements/EmailAndUsername/index.js +3 -8
- package/dist/elements/EmailAndUsername/index.js.map +1 -1
- package/dist/elements/Nav/NavToggler/index.d.ts.map +1 -1
- package/dist/elements/Nav/NavToggler/index.js +1 -1
- package/dist/elements/Nav/NavToggler/index.js.map +1 -1
- package/dist/elements/NavGroup/index.d.ts +1 -0
- package/dist/elements/NavGroup/index.d.ts.map +1 -1
- package/dist/elements/NavGroup/index.js +69 -90
- package/dist/elements/NavGroup/index.js.map +1 -1
- package/dist/exports/client/index.d.ts +1 -2
- package/dist/exports/client/index.d.ts.map +1 -1
- package/dist/exports/client/index.js +22 -22
- package/dist/exports/client/index.js.map +4 -4
- package/dist/exports/shared/index.d.ts +1 -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 +2 -2
- package/dist/fields/Array/index.d.ts +1 -2
- package/dist/fields/Array/index.d.ts.map +1 -1
- package/dist/fields/Array/index.js +1 -2
- package/dist/fields/Array/index.js.map +1 -1
- package/dist/fields/Blocks/index.d.ts +1 -2
- package/dist/fields/Blocks/index.d.ts.map +1 -1
- package/dist/fields/Blocks/index.js +1 -2
- package/dist/fields/Blocks/index.js.map +1 -1
- package/dist/fields/Checkbox/index.d.ts +1 -1
- package/dist/fields/Checkbox/index.d.ts.map +1 -1
- package/dist/fields/Checkbox/index.js +1 -3
- package/dist/fields/Checkbox/index.js.map +1 -1
- package/dist/fields/Code/index.d.ts +1 -1
- package/dist/fields/Code/index.d.ts.map +1 -1
- package/dist/fields/Code/index.js +1 -3
- package/dist/fields/Code/index.js.map +1 -1
- package/dist/fields/Collapsible/index.d.ts +1 -3
- package/dist/fields/Collapsible/index.d.ts.map +1 -1
- package/dist/fields/Collapsible/index.js +65 -69
- package/dist/fields/Collapsible/index.js.map +1 -1
- package/dist/fields/DateTime/index.d.ts +1 -1
- package/dist/fields/DateTime/index.d.ts.map +1 -1
- package/dist/fields/DateTime/index.js +1 -3
- package/dist/fields/DateTime/index.js.map +1 -1
- package/dist/fields/Email/index.d.ts +1 -1
- package/dist/fields/Email/index.d.ts.map +1 -1
- package/dist/fields/Email/index.js +1 -3
- package/dist/fields/Email/index.js.map +1 -1
- package/dist/fields/Group/index.d.ts +1 -3
- package/dist/fields/Group/index.d.ts.map +1 -1
- package/dist/fields/Group/index.js +1 -2
- package/dist/fields/Group/index.js.map +1 -1
- package/dist/fields/JSON/index.d.ts +1 -1
- package/dist/fields/JSON/index.d.ts.map +1 -1
- package/dist/fields/JSON/index.js +1 -2
- package/dist/fields/JSON/index.js.map +1 -1
- package/dist/fields/Join/index.d.ts +3 -1
- package/dist/fields/Join/index.d.ts.map +1 -1
- package/dist/fields/Join/index.js +1 -2
- package/dist/fields/Join/index.js.map +1 -1
- package/dist/fields/Number/index.d.ts +1 -1
- package/dist/fields/Number/index.d.ts.map +1 -1
- package/dist/fields/Number/index.js +1 -3
- package/dist/fields/Number/index.js.map +1 -1
- package/dist/fields/Password/index.d.ts.map +1 -1
- package/dist/fields/Password/index.js +1 -3
- package/dist/fields/Password/index.js.map +1 -1
- package/dist/fields/Password/types.d.ts +1 -1
- package/dist/fields/Password/types.d.ts.map +1 -1
- package/dist/fields/Password/types.js.map +1 -1
- package/dist/fields/Point/index.d.ts +1 -1
- package/dist/fields/Point/index.d.ts.map +1 -1
- package/dist/fields/Point/index.js +1 -3
- package/dist/fields/Point/index.js.map +1 -1
- package/dist/fields/RadioGroup/index.d.ts +1 -1
- package/dist/fields/RadioGroup/index.d.ts.map +1 -1
- package/dist/fields/RadioGroup/index.js +1 -3
- package/dist/fields/RadioGroup/index.js.map +1 -1
- package/dist/fields/Relationship/index.d.ts +1 -1
- package/dist/fields/Relationship/index.d.ts.map +1 -1
- package/dist/fields/Relationship/index.js +1 -2
- package/dist/fields/Relationship/index.js.map +1 -1
- package/dist/fields/Row/index.d.ts +1 -1
- package/dist/fields/Select/index.d.ts +1 -1
- package/dist/fields/Select/index.d.ts.map +1 -1
- package/dist/fields/Select/index.js +1 -2
- package/dist/fields/Select/index.js.map +1 -1
- package/dist/fields/Tabs/index.d.ts +1 -1
- package/dist/fields/Text/index.d.ts +2 -2
- package/dist/fields/Text/index.d.ts.map +1 -1
- package/dist/fields/Text/index.js +2 -4
- package/dist/fields/Text/index.js.map +1 -1
- package/dist/fields/Textarea/index.d.ts +1 -1
- package/dist/fields/Textarea/index.d.ts.map +1 -1
- package/dist/fields/Textarea/index.js +1 -3
- package/dist/fields/Textarea/index.js.map +1 -1
- package/dist/fields/Upload/index.d.ts.map +1 -1
- package/dist/fields/Upload/index.js +1 -3
- package/dist/fields/Upload/index.js.map +1 -1
- package/dist/fields/index.d.ts +4 -1
- package/dist/fields/index.d.ts.map +1 -1
- package/dist/fields/index.js.map +1 -1
- package/dist/forms/NullifyField/index.d.ts.map +1 -1
- package/dist/forms/NullifyField/index.js +0 -3
- package/dist/forms/NullifyField/index.js.map +1 -1
- package/dist/forms/RenderFields/RenderField.d.ts +2 -2
- package/dist/forms/RenderFields/RenderField.d.ts.map +1 -1
- package/dist/forms/RenderFields/RenderField.js +189 -35
- package/dist/forms/RenderFields/RenderField.js.map +1 -1
- package/dist/forms/fieldSchemasToFormState/renderField.d.ts.map +1 -1
- package/dist/forms/fieldSchemasToFormState/renderField.js +6 -3
- package/dist/forms/fieldSchemasToFormState/renderField.js.map +1 -1
- package/dist/forms/withCondition/index.d.ts +2 -2
- package/dist/forms/withCondition/index.d.ts.map +1 -1
- package/dist/forms/withCondition/index.js.map +1 -1
- package/dist/providers/Preferences/index.d.ts.map +1 -1
- package/dist/providers/Preferences/index.js +2 -4
- package/dist/providers/Preferences/index.js.map +1 -1
- package/dist/providers/Root/index.d.ts.map +1 -1
- package/dist/providers/Root/index.js +37 -42
- package/dist/providers/Root/index.js.map +1 -1
- package/dist/providers/ServerFunctions/index.js +12 -3
- package/dist/providers/ServerFunctions/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/utilities/groupNavItems.d.ts +2 -2
- package/dist/utilities/groupNavItems.d.ts.map +1 -1
- package/dist/utilities/groupNavItems.js.map +1 -1
- package/dist/views/Edit/Auth/index.d.ts.map +1 -1
- package/dist/views/Edit/Auth/index.js +0 -6
- package/dist/views/Edit/Auth/index.js.map +1 -1
- package/dist/views/List/types.d.ts +18 -1
- package/dist/views/List/types.d.ts.map +1 -1
- package/dist/views/List/types.js.map +1 -1
- package/package.json +4 -4
- package/dist/providers/FieldComponents/index.d.ts +0 -9
- package/dist/providers/FieldComponents/index.d.ts.map +0 -1
- package/dist/providers/FieldComponents/index.js +0 -18
- package/dist/providers/FieldComponents/index.js.map +0 -1
package/dist/fields/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["RowLabel","ArrayField","BlocksField","CheckboxField","CodeField","CollapsibleField","ConfirmPasswordField","DateTimeField","EmailField","FieldDescription","FieldError","FieldLabel","GroupField","HiddenField","JoinField","JSONField","NumberField","PasswordField","PointField","RadioGroupField","RelationshipField","RichTextField","RowField","SelectField","TabsField","TextField","TextareaField","UIField","UploadField","fieldComponents","array","blocks","checkbox","code","collapsible","confirmPassword","date","email","group","hidden","join","json","number","password","point","radio","relationship","richText","row","select","tabs","text","textarea","ui","upload","allFieldComponents","Description","Error","Label"],"sources":["../../src/fields/index.tsx"],"sourcesContent":["'use client'\nimport type {\n ClientFieldBase,\n FieldTypes,\n GenericDescriptionProps,\n GenericErrorProps,\n GenericLabelProps,\n} from 'payload'\nimport type React from 'react'\n\nimport { RowLabel } from '../forms/RowLabel/index.js'\nimport { ArrayField } from './Array/index.js'\nimport { BlocksField } from './Blocks/index.js'\nimport { CheckboxField } from './Checkbox/index.js'\nimport { CodeField } from './Code/index.js'\nimport { CollapsibleField } from './Collapsible/index.js'\nimport { ConfirmPasswordField } from './ConfirmPassword/index.js'\nimport { DateTimeField } from './DateTime/index.js'\nimport { EmailField } from './Email/index.js'\nimport { FieldDescription } from './FieldDescription/index.js'\nimport { FieldError } from './FieldError/index.js'\nimport { FieldLabel } from './FieldLabel/index.js'\nimport { GroupField } from './Group/index.js'\nimport { HiddenField } from './Hidden/index.js'\nimport { JoinField } from './Join/index.js'\nimport { JSONField } from './JSON/index.js'\nimport { NumberField } from './Number/index.js'\nimport { PasswordField } from './Password/index.js'\nimport { PointField } from './Point/index.js'\nimport { RadioGroupField } from './RadioGroup/index.js'\nimport { RelationshipField } from './Relationship/index.js'\nimport { RichTextField } from './RichText/index.js'\nimport { RowField } from './Row/index.js'\nimport { SelectField } from './Select/index.js'\nimport { TabsField } from './Tabs/index.js'\nimport { TextField } from './Text/index.js'\nimport { TextareaField } from './Textarea/index.js'\nimport { UIField } from './UI/index.js'\nimport { UploadField } from './Upload/index.js'\n\nexport * from './shared/index.js'\n\nexport type FieldTypesComponents = {\n [K in '
|
|
1
|
+
{"version":3,"file":"index.js","names":["RowLabel","ArrayField","BlocksField","CheckboxField","CodeField","CollapsibleField","ConfirmPasswordField","DateTimeField","EmailField","FieldDescription","FieldError","FieldLabel","GroupField","HiddenField","JoinField","JSONField","NumberField","PasswordField","PointField","RadioGroupField","RelationshipField","RichTextField","RowField","SelectField","TabsField","TextField","TextareaField","UIField","UploadField","fieldComponents","array","blocks","checkbox","code","collapsible","confirmPassword","date","email","group","hidden","join","json","number","password","point","radio","relationship","richText","row","select","tabs","text","textarea","ui","upload","allFieldComponents","Description","Error","Label"],"sources":["../../src/fields/index.tsx"],"sourcesContent":["'use client'\nimport type {\n ClientFieldBase,\n FieldTypes,\n GenericDescriptionProps,\n GenericErrorProps,\n GenericLabelProps,\n} from 'payload'\nimport type React from 'react'\n\nimport type { ConfirmPasswordFieldProps } from './ConfirmPassword/index.js'\n\nimport { RowLabel } from '../forms/RowLabel/index.js'\nimport { ArrayField } from './Array/index.js'\nimport { BlocksField } from './Blocks/index.js'\nimport { CheckboxField } from './Checkbox/index.js'\nimport { CodeField } from './Code/index.js'\nimport { CollapsibleField } from './Collapsible/index.js'\nimport { ConfirmPasswordField } from './ConfirmPassword/index.js'\nimport { DateTimeField } from './DateTime/index.js'\nimport { EmailField } from './Email/index.js'\nimport { FieldDescription } from './FieldDescription/index.js'\nimport { FieldError } from './FieldError/index.js'\nimport { FieldLabel } from './FieldLabel/index.js'\nimport { GroupField } from './Group/index.js'\nimport { HiddenField } from './Hidden/index.js'\nimport { JoinField } from './Join/index.js'\nimport { JSONField } from './JSON/index.js'\nimport { NumberField } from './Number/index.js'\nimport { PasswordField } from './Password/index.js'\nimport { PointField } from './Point/index.js'\nimport { RadioGroupField } from './RadioGroup/index.js'\nimport { RelationshipField } from './Relationship/index.js'\nimport { RichTextField } from './RichText/index.js'\nimport { RowField } from './Row/index.js'\nimport { SelectField } from './Select/index.js'\nimport { TabsField } from './Tabs/index.js'\nimport { TextField } from './Text/index.js'\nimport { TextareaField } from './Textarea/index.js'\nimport { UIField } from './UI/index.js'\nimport { UploadField } from './Upload/index.js'\n\nexport * from './shared/index.js'\n\nexport type FieldTypesComponents = {\n [K in 'hidden' | 'password' | FieldTypes]: React.FC<ClientFieldBase>\n} & {\n confirmPassword: React.FC<ConfirmPasswordFieldProps>\n}\n\nexport const fieldComponents: FieldTypesComponents = {\n array: ArrayField,\n blocks: BlocksField,\n checkbox: CheckboxField,\n code: CodeField,\n collapsible: CollapsibleField,\n confirmPassword: ConfirmPasswordField,\n date: DateTimeField,\n email: EmailField,\n group: GroupField,\n hidden: HiddenField,\n join: JoinField,\n json: JSONField,\n number: NumberField,\n password: PasswordField,\n point: PointField,\n radio: RadioGroupField,\n relationship: RelationshipField,\n richText: RichTextField,\n row: RowField,\n select: SelectField,\n tabs: TabsField,\n text: TextField,\n textarea: TextareaField,\n ui: UIField,\n upload: UploadField,\n}\n\nexport type FieldComponentsWithSlots = {\n Description: React.FC<GenericDescriptionProps>\n Error: React.FC<GenericErrorProps>\n Label: React.FC<GenericLabelProps>\n RowLabel: React.FC\n} & FieldTypesComponents\n\nexport const allFieldComponents: FieldComponentsWithSlots = {\n ...fieldComponents,\n Description: FieldDescription,\n Error: FieldError,\n Label: FieldLabel,\n RowLabel,\n}\n"],"mappings":"AAAA;;AAYA,SAASA,QAAQ,QAAQ;AACzB,SAASC,UAAU,QAAQ;AAC3B,SAASC,WAAW,QAAQ;AAC5B,SAASC,aAAa,QAAQ;AAC9B,SAASC,SAAS,QAAQ;AAC1B,SAASC,gBAAgB,QAAQ;AACjC,SAASC,oBAAoB,QAAQ;AACrC,SAASC,aAAa,QAAQ;AAC9B,SAASC,UAAU,QAAQ;AAC3B,SAASC,gBAAgB,QAAQ;AACjC,SAASC,UAAU,QAAQ;AAC3B,SAASC,UAAU,QAAQ;AAC3B,SAASC,UAAU,QAAQ;AAC3B,SAASC,WAAW,QAAQ;AAC5B,SAASC,SAAS,QAAQ;AAC1B,SAASC,SAAS,QAAQ;AAC1B,SAASC,WAAW,QAAQ;AAC5B,SAASC,aAAa,QAAQ;AAC9B,SAASC,UAAU,QAAQ;AAC3B,SAASC,eAAe,QAAQ;AAChC,SAASC,iBAAiB,QAAQ;AAClC,SAASC,aAAa,QAAQ;AAC9B,SAASC,QAAQ,QAAQ;AACzB,SAASC,WAAW,QAAQ;AAC5B,SAASC,SAAS,QAAQ;AAC1B,SAASC,SAAS,QAAQ;AAC1B,SAASC,aAAa,QAAQ;AAC9B,SAASC,OAAO,QAAQ;AACxB,SAASC,WAAW,QAAQ;AAE5B,cAAc;AAQd,OAAO,MAAMC,eAAA,GAAwC;EACnDC,KAAA,EAAO7B,UAAA;EACP8B,MAAA,EAAQ7B,WAAA;EACR8B,QAAA,EAAU7B,aAAA;EACV8B,IAAA,EAAM7B,SAAA;EACN8B,WAAA,EAAa7B,gBAAA;EACb8B,eAAA,EAAiB7B,oBAAA;EACjB8B,IAAA,EAAM7B,aAAA;EACN8B,KAAA,EAAO7B,UAAA;EACP8B,KAAA,EAAO1B,UAAA;EACP2B,MAAA,EAAQ1B,WAAA;EACR2B,IAAA,EAAM1B,SAAA;EACN2B,IAAA,EAAM1B,SAAA;EACN2B,MAAA,EAAQ1B,WAAA;EACR2B,QAAA,EAAU1B,aAAA;EACV2B,KAAA,EAAO1B,UAAA;EACP2B,KAAA,EAAO1B,eAAA;EACP2B,YAAA,EAAc1B,iBAAA;EACd2B,QAAA,EAAU1B,aAAA;EACV2B,GAAA,EAAK1B,QAAA;EACL2B,MAAA,EAAQ1B,WAAA;EACR2B,IAAA,EAAM1B,SAAA;EACN2B,IAAA,EAAM1B,SAAA;EACN2B,QAAA,EAAU1B,aAAA;EACV2B,EAAA,EAAI1B,OAAA;EACJ2B,MAAA,EAAQ1B;AACV;AASA,OAAO,MAAM2B,kBAAA,GAA+C;EAC1D,GAAG1B,eAAe;EAClB2B,WAAA,EAAa/C,gBAAA;EACbgD,KAAA,EAAO/C,UAAA;EACPgD,KAAA,EAAO/C,UAAA;EACPX;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/forms/NullifyField/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAQ9B,KAAK,uBAAuB,GAAG;IAC7B,QAAQ,CAAC,UAAU,CAAC,EAAE,EAAE,GAAG,IAAI,GAAG,MAAM,CAAA;IACxC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAA;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CACtB,CAAA;AAED,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,uBAAuB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/forms/NullifyField/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAQ9B,KAAK,uBAAuB,GAAG;IAC7B,QAAQ,CAAC,UAAU,CAAC,EAAE,EAAE,GAAG,IAAI,GAAG,MAAM,CAAA;IACxC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAA;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CACtB,CAAA;AAED,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,uBAAuB,CAmDhE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","React","Banner","CheckboxField","useConfig","useLocale","useTranslation","NullifyLocaleField","t0","$","fieldValue","localized","path","code","currentLocale","config","t1","localization","checked","setChecked","useState","defaultLocale","t","fallback","hideCheckbox","Array","isArray","length","t2","_jsx","children","field","name","label","id","replace","
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","React","Banner","CheckboxField","useConfig","useLocale","useTranslation","NullifyLocaleField","t0","$","fieldValue","localized","path","code","currentLocale","config","t1","localization","checked","setChecked","useState","defaultLocale","t","fallback","hideCheckbox","Array","isArray","length","t2","_jsx","children","field","name","label","id","replace","schemaPath"],"sources":["../../../src/forms/NullifyField/index.tsx"],"sourcesContent":["'use client'\n\nimport * as React from 'react'\n\nimport { Banner } from '../../elements/Banner/index.js'\nimport { CheckboxField } from '../../fields/Checkbox/index.js'\nimport { useConfig } from '../../providers/Config/index.js'\nimport { useLocale } from '../../providers/Locale/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\n\ntype NullifyLocaleFieldProps = {\n readonly fieldValue?: [] | null | number\n readonly localized: boolean\n readonly path: string\n}\n\nexport const NullifyLocaleField: React.FC<NullifyLocaleFieldProps> = ({\n fieldValue,\n localized,\n path,\n}) => {\n const { code: currentLocale } = useLocale()\n const {\n config: { localization },\n } = useConfig()\n const [checked, setChecked] = React.useState<boolean>(typeof fieldValue !== 'number')\n const defaultLocale =\n localization && localization.defaultLocale ? localization.defaultLocale : 'en'\n const { t } = useTranslation()\n\n if (!localized || currentLocale === defaultLocale || (localization && !localization.fallback)) {\n // hide when field is not localized or editing default locale or when fallback is disabled\n return null\n }\n\n if (fieldValue) {\n let hideCheckbox = false\n if (typeof fieldValue === 'number' && fieldValue > 0) {\n hideCheckbox = true\n }\n if (Array.isArray(fieldValue) && fieldValue.length > 0) {\n hideCheckbox = true\n }\n\n if (hideCheckbox) {\n if (checked) {\n setChecked(false)\n } // uncheck when field has value\n return null\n }\n }\n\n return (\n <Banner>\n <CheckboxField\n checked={checked}\n field={{\n name: '',\n label: t('general:fallbackToDefaultLocale'),\n }}\n id={`field-${path.replace(/\\./g, '__')}`}\n path={path}\n schemaPath=\"\"\n // onToggle={onChange}\n />\n </Banner>\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAEA,YAAYC,KAAA,MAAW;AAEvB,SAASC,MAAM,QAAQ;AACvB,SAASC,aAAa,QAAQ;AAC9B,SAASC,SAAS,QAAQ;AAC1B,SAASC,SAAS,QAAQ;AAC1B,SAASC,cAAc,QAAQ;AAQ/B,OAAO,MAAMC,kBAAA,GAAwDC,EAAA;EAAA,MAAAC,CAAA,GAAAT,EAAA;EAAC;IAAAU,UAAA;IAAAC,SAAA;IAAAC;EAAA,IAAAJ,EAIrE;EACC;IAAAK,IAAA,EAAAC;EAAA,IAAgCT,SAAA;EAChC;IAAAU,MAAA,EAAAC;EAAA,IAEIZ,SAAA;EADM;IAAAa;EAAA,IAAAD,EAAgB;EAE1B,OAAAE,OAAA,EAAAC,UAAA,IAA8BlB,KAAA,CAAAmB,QAAA,CAAwB,OAAOV,UAAA,KAAe;EAC5E,MAAAW,aAAA,GACEJ,YAAA,IAAgBA,YAAA,CAAAI,aAA0B,GAAGJ,YAAA,CAAAI,aAAA,GAA6B;EAC5E;IAAAC;EAAA,IAAchB,cAAA;EAAA,IAEV,CAACK,SAAA,IAAaG,aAAA,KAAkBO,aAAA,IAAkBJ,YAAA,KAAiBA,YAAA,CAAAM,QAAqB;IAAA;EAAA;EAAA,IAKxFb,UAAA;IACF,IAAAc,YAAA;IAAmB,IACf,OAAOd,UAAA,KAAe,YAAYA,UAAA,IAAa;MACjDc,YAAA,CAAAA,CAAA,CAAAA,IAAA;IAAA;IAAA,IAEEC,KAAA,CAAAC,OAAA,CAAchB,UAAA,KAAeA,UAAA,CAAAiB,MAAA,IAAoB;MACnDH,YAAA,CAAAA,CAAA,CAAAA,IAAA;IAAA;IAAA,IAGEA,YAAA;MAAA,IACEN,OAAA;QACFC,UAAA,MAAW;MAAA;MAAA;IAAA;EAAA;EAAA,IAAAS,EAAA;EAAA,IAAAnB,CAAA,QAAAa,CAAA,IAAAb,CAAA,QAAAG,IAAA,IAAAH,CAAA,QAAAS,OAAA;IAOfU,EAAA,GAAAC,IAAA,CAAA3B,MAAA;MAAA4B,QAAA,EACED,IAAA,CAAA1B,aAAA;QAAAe,OAAA;QAAAa,KAAA;UAAAC,IAAA,EAGU;UAAAC,KAAA,EACCX,CAAA,CAAE;QAAA;QAAAY,EAAA,EAEP,SAAStB,IAAA,CAAAuB,OAAA,QAAoB,OAAO;QAAAvB,IAAA;QAAAwB,UAAA,EAE7B;MAAA,C;;;;;;;;;SATfR,E;CAcJ","ignoreList":[]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { ClientComponentProps, ClientField, FieldPermissions } from 'payload';
|
|
1
|
+
import type { ClientComponentProps, ClientField, FieldPaths, FieldPermissions } from 'payload';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
type RenderFieldProps = {
|
|
4
4
|
clientFieldConfig: ClientField;
|
|
5
5
|
permissions: FieldPermissions;
|
|
6
|
-
} & Pick<ClientComponentProps, 'forceRender' | '
|
|
6
|
+
} & FieldPaths & Pick<ClientComponentProps, 'forceRender' | 'readOnly' | 'schemaPath'>;
|
|
7
7
|
export declare function RenderField({ clientFieldConfig, forceRender, indexPath, parentPath, parentSchemaPath, path, permissions, readOnly, schemaPath, }: RenderFieldProps): string | number | bigint | true | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode>> | React.JSX.Element;
|
|
8
8
|
export {};
|
|
9
9
|
//# sourceMappingURL=RenderField.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RenderField.d.ts","sourceRoot":"","sources":["../../../src/forms/RenderFields/RenderField.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"RenderField.d.ts","sourceRoot":"","sources":["../../../src/forms/RenderFields/RenderField.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,WAAW,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAE9F,OAAO,KAAK,MAAM,OAAO,CAAA;AA2BzB,KAAK,gBAAgB,GAAG;IACtB,iBAAiB,EAAE,WAAW,CAAA;IAC9B,WAAW,EAAE,gBAAgB,CAAA;CAC9B,GAAG,UAAU,GACZ,IAAI,CAAC,oBAAoB,EAAE,aAAa,GAAG,UAAU,GAAG,YAAY,CAAC,CAAA;AAEvE,wBAAgB,WAAW,CAAC,EAC1B,iBAAiB,EACjB,WAAW,EACX,SAAS,EACT,UAAU,EACV,gBAAgB,EAChB,IAAI,EACJ,WAAW,EACX,QAAQ,EACR,UAAU,GACX,EAAE,gBAAgB,0PA4FlB"}
|
|
@@ -5,13 +5,28 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import { ArrayField } from '../../fields/Array/index.js';
|
|
7
7
|
import { BlocksField } from '../../fields/Blocks/index.js';
|
|
8
|
+
import { CheckboxField } from '../../fields/Checkbox/index.js';
|
|
9
|
+
import { CodeField } from '../../fields/Code/index.js';
|
|
8
10
|
import { CollapsibleField } from '../../fields/Collapsible/index.js';
|
|
11
|
+
import { DateTimeField } from '../../fields/DateTime/index.js';
|
|
12
|
+
import { EmailField } from '../../fields/Email/index.js';
|
|
9
13
|
import { GroupField } from '../../fields/Group/index.js';
|
|
10
14
|
import { HiddenField } from '../../fields/Hidden/index.js';
|
|
15
|
+
import { JoinField } from '../../fields/Join/index.js';
|
|
16
|
+
import { JSONField } from '../../fields/JSON/index.js';
|
|
17
|
+
import { NumberField } from '../../fields/Number/index.js';
|
|
18
|
+
import { PointField } from '../../fields/Point/index.js';
|
|
19
|
+
import { RadioGroupField } from '../../fields/RadioGroup/index.js';
|
|
20
|
+
import { RelationshipField } from '../../fields/Relationship/index.js';
|
|
21
|
+
import { RichTextField } from '../../fields/RichText/index.js';
|
|
11
22
|
import { RowField } from '../../fields/Row/index.js';
|
|
23
|
+
import { SelectField } from '../../fields/Select/index.js';
|
|
12
24
|
import { TabsField } from '../../fields/Tabs/index.js';
|
|
25
|
+
import { TextField } from '../../fields/Text/index.js';
|
|
26
|
+
import { TextareaField } from '../../fields/Textarea/index.js';
|
|
27
|
+
import { UIField } from '../../fields/UI/index.js';
|
|
28
|
+
import { UploadField } from '../../fields/Upload/index.js';
|
|
13
29
|
import { useFormFields } from '../../forms/Form/index.js';
|
|
14
|
-
import { useFieldComponents } from '../../providers/FieldComponents/index.js';
|
|
15
30
|
export function RenderField(t0) {
|
|
16
31
|
const $ = _c(13);
|
|
17
32
|
const {
|
|
@@ -25,7 +40,6 @@ export function RenderField(t0) {
|
|
|
25
40
|
readOnly,
|
|
26
41
|
schemaPath
|
|
27
42
|
} = t0;
|
|
28
|
-
const fieldComponents = useFieldComponents();
|
|
29
43
|
let t1;
|
|
30
44
|
if ($[0] !== path) {
|
|
31
45
|
t1 = t2 => {
|
|
@@ -42,104 +56,244 @@ export function RenderField(t0) {
|
|
|
42
56
|
return Field || null;
|
|
43
57
|
}
|
|
44
58
|
let t2;
|
|
45
|
-
if ($[2] !== forceRender || $[3] !==
|
|
59
|
+
if ($[2] !== forceRender || $[3] !== readOnly || $[4] !== schemaPath || $[5] !== indexPath || $[6] !== parentPath || $[7] !== parentSchemaPath || $[8] !== permissions || $[9] !== clientFieldConfig || $[10] !== path) {
|
|
46
60
|
t2 = Symbol.for("react.early_return_sentinel");
|
|
47
61
|
bb0: {
|
|
48
|
-
const
|
|
62
|
+
const baseFieldProps = {
|
|
49
63
|
forceRender,
|
|
64
|
+
readOnly,
|
|
65
|
+
schemaPath
|
|
66
|
+
};
|
|
67
|
+
const iterableFieldProps = {
|
|
68
|
+
...baseFieldProps,
|
|
50
69
|
indexPath,
|
|
51
70
|
parentPath,
|
|
52
71
|
parentSchemaPath,
|
|
53
|
-
|
|
54
|
-
readOnly,
|
|
55
|
-
schemaPath
|
|
72
|
+
permissions
|
|
56
73
|
};
|
|
57
74
|
if (clientFieldConfig.admin?.hidden) {
|
|
58
75
|
t2 = _jsx(HiddenField, {
|
|
76
|
+
...baseFieldProps,
|
|
59
77
|
field: clientFieldConfig,
|
|
60
|
-
|
|
78
|
+
path
|
|
61
79
|
});
|
|
62
80
|
break bb0;
|
|
63
81
|
}
|
|
64
|
-
const DefaultField = fieldComponents?.[clientFieldConfig?.type];
|
|
65
82
|
switch (clientFieldConfig.type) {
|
|
66
83
|
case "array":
|
|
67
84
|
{
|
|
68
85
|
t2 = _jsx(ArrayField, {
|
|
69
|
-
...
|
|
86
|
+
...iterableFieldProps,
|
|
70
87
|
field: clientFieldConfig,
|
|
71
|
-
|
|
88
|
+
path
|
|
72
89
|
});
|
|
73
90
|
break bb0;
|
|
74
91
|
}
|
|
75
92
|
case "blocks":
|
|
76
93
|
{
|
|
77
94
|
t2 = _jsx(BlocksField, {
|
|
78
|
-
...
|
|
95
|
+
...iterableFieldProps,
|
|
96
|
+
field: clientFieldConfig,
|
|
97
|
+
path
|
|
98
|
+
});
|
|
99
|
+
break bb0;
|
|
100
|
+
}
|
|
101
|
+
case "checkbox":
|
|
102
|
+
{
|
|
103
|
+
t2 = _jsx(CheckboxField, {
|
|
104
|
+
...baseFieldProps,
|
|
79
105
|
field: clientFieldConfig,
|
|
80
|
-
|
|
106
|
+
path
|
|
107
|
+
});
|
|
108
|
+
break bb0;
|
|
109
|
+
}
|
|
110
|
+
case "code":
|
|
111
|
+
{
|
|
112
|
+
t2 = _jsx(CodeField, {
|
|
113
|
+
...baseFieldProps,
|
|
114
|
+
field: clientFieldConfig,
|
|
115
|
+
path
|
|
81
116
|
});
|
|
82
117
|
break bb0;
|
|
83
118
|
}
|
|
84
119
|
case "collapsible":
|
|
85
120
|
{
|
|
86
121
|
t2 = _jsx(CollapsibleField, {
|
|
87
|
-
...
|
|
122
|
+
...iterableFieldProps,
|
|
123
|
+
field: clientFieldConfig,
|
|
124
|
+
path
|
|
125
|
+
});
|
|
126
|
+
break bb0;
|
|
127
|
+
}
|
|
128
|
+
case "date":
|
|
129
|
+
{
|
|
130
|
+
t2 = _jsx(DateTimeField, {
|
|
131
|
+
...baseFieldProps,
|
|
88
132
|
field: clientFieldConfig,
|
|
89
|
-
|
|
133
|
+
path
|
|
134
|
+
});
|
|
135
|
+
break bb0;
|
|
136
|
+
}
|
|
137
|
+
case "email":
|
|
138
|
+
{
|
|
139
|
+
t2 = _jsx(EmailField, {
|
|
140
|
+
...baseFieldProps,
|
|
141
|
+
field: clientFieldConfig,
|
|
142
|
+
path
|
|
90
143
|
});
|
|
91
144
|
break bb0;
|
|
92
145
|
}
|
|
93
146
|
case "group":
|
|
94
147
|
{
|
|
95
148
|
t2 = _jsx(GroupField, {
|
|
96
|
-
...
|
|
149
|
+
...iterableFieldProps,
|
|
150
|
+
field: clientFieldConfig,
|
|
151
|
+
path
|
|
152
|
+
});
|
|
153
|
+
break bb0;
|
|
154
|
+
}
|
|
155
|
+
case "join":
|
|
156
|
+
{
|
|
157
|
+
t2 = _jsx(JoinField, {
|
|
158
|
+
...baseFieldProps,
|
|
159
|
+
field: clientFieldConfig,
|
|
160
|
+
path
|
|
161
|
+
});
|
|
162
|
+
break bb0;
|
|
163
|
+
}
|
|
164
|
+
case "json":
|
|
165
|
+
{
|
|
166
|
+
t2 = _jsx(JSONField, {
|
|
167
|
+
...baseFieldProps,
|
|
168
|
+
field: clientFieldConfig,
|
|
169
|
+
path
|
|
170
|
+
});
|
|
171
|
+
break bb0;
|
|
172
|
+
}
|
|
173
|
+
case "number":
|
|
174
|
+
{
|
|
175
|
+
t2 = _jsx(NumberField, {
|
|
176
|
+
...baseFieldProps,
|
|
177
|
+
field: clientFieldConfig,
|
|
178
|
+
path
|
|
179
|
+
});
|
|
180
|
+
break bb0;
|
|
181
|
+
}
|
|
182
|
+
case "point":
|
|
183
|
+
{
|
|
184
|
+
t2 = _jsx(PointField, {
|
|
185
|
+
...baseFieldProps,
|
|
186
|
+
field: clientFieldConfig,
|
|
187
|
+
path
|
|
188
|
+
});
|
|
189
|
+
break bb0;
|
|
190
|
+
}
|
|
191
|
+
case "radio":
|
|
192
|
+
{
|
|
193
|
+
t2 = _jsx(RadioGroupField, {
|
|
194
|
+
...baseFieldProps,
|
|
195
|
+
field: clientFieldConfig,
|
|
196
|
+
path
|
|
197
|
+
});
|
|
198
|
+
break bb0;
|
|
199
|
+
}
|
|
200
|
+
case "relationship":
|
|
201
|
+
{
|
|
202
|
+
t2 = _jsx(RelationshipField, {
|
|
203
|
+
...baseFieldProps,
|
|
97
204
|
field: clientFieldConfig,
|
|
98
|
-
|
|
205
|
+
path
|
|
206
|
+
});
|
|
207
|
+
break bb0;
|
|
208
|
+
}
|
|
209
|
+
case "richText":
|
|
210
|
+
{
|
|
211
|
+
t2 = _jsx(RichTextField, {
|
|
212
|
+
...baseFieldProps,
|
|
213
|
+
field: clientFieldConfig,
|
|
214
|
+
path
|
|
99
215
|
});
|
|
100
216
|
break bb0;
|
|
101
217
|
}
|
|
102
218
|
case "row":
|
|
103
219
|
{
|
|
104
220
|
t2 = _jsx(RowField, {
|
|
105
|
-
...
|
|
221
|
+
...iterableFieldProps,
|
|
222
|
+
field: clientFieldConfig
|
|
223
|
+
});
|
|
224
|
+
break bb0;
|
|
225
|
+
}
|
|
226
|
+
case "select":
|
|
227
|
+
{
|
|
228
|
+
t2 = _jsx(SelectField, {
|
|
229
|
+
...baseFieldProps,
|
|
106
230
|
field: clientFieldConfig,
|
|
107
|
-
|
|
231
|
+
path
|
|
108
232
|
});
|
|
109
233
|
break bb0;
|
|
110
234
|
}
|
|
111
235
|
case "tabs":
|
|
112
236
|
{
|
|
113
237
|
t2 = _jsx(TabsField, {
|
|
114
|
-
...
|
|
238
|
+
...iterableFieldProps,
|
|
239
|
+
field: clientFieldConfig,
|
|
240
|
+
path
|
|
241
|
+
});
|
|
242
|
+
break bb0;
|
|
243
|
+
}
|
|
244
|
+
case "text":
|
|
245
|
+
{
|
|
246
|
+
t2 = _jsx(TextField, {
|
|
247
|
+
...baseFieldProps,
|
|
115
248
|
field: clientFieldConfig,
|
|
116
|
-
|
|
249
|
+
path
|
|
117
250
|
});
|
|
118
251
|
break bb0;
|
|
119
252
|
}
|
|
120
|
-
|
|
253
|
+
case "textarea":
|
|
121
254
|
{
|
|
122
|
-
t2 =
|
|
255
|
+
t2 = _jsx(TextareaField, {
|
|
256
|
+
...baseFieldProps,
|
|
123
257
|
field: clientFieldConfig,
|
|
124
|
-
|
|
125
|
-
})
|
|
258
|
+
path
|
|
259
|
+
});
|
|
260
|
+
break bb0;
|
|
261
|
+
}
|
|
262
|
+
case "ui":
|
|
263
|
+
{
|
|
264
|
+
let t3;
|
|
265
|
+
if ($[12] === Symbol.for("react.memo_cache_sentinel")) {
|
|
266
|
+
t3 = _jsx(UIField, {});
|
|
267
|
+
$[12] = t3;
|
|
268
|
+
} else {
|
|
269
|
+
t3 = $[12];
|
|
270
|
+
}
|
|
271
|
+
t2 = t3;
|
|
272
|
+
break bb0;
|
|
273
|
+
}
|
|
274
|
+
case "upload":
|
|
275
|
+
{
|
|
276
|
+
t2 = _jsx(UploadField, {
|
|
277
|
+
...baseFieldProps,
|
|
278
|
+
field: clientFieldConfig,
|
|
279
|
+
path
|
|
280
|
+
});
|
|
126
281
|
break bb0;
|
|
127
282
|
}
|
|
128
283
|
}
|
|
129
284
|
}
|
|
130
285
|
$[2] = forceRender;
|
|
131
|
-
$[3] =
|
|
132
|
-
$[4] =
|
|
133
|
-
$[5] =
|
|
134
|
-
$[6] =
|
|
135
|
-
$[7] =
|
|
136
|
-
$[8] =
|
|
286
|
+
$[3] = readOnly;
|
|
287
|
+
$[4] = schemaPath;
|
|
288
|
+
$[5] = indexPath;
|
|
289
|
+
$[6] = parentPath;
|
|
290
|
+
$[7] = parentSchemaPath;
|
|
291
|
+
$[8] = permissions;
|
|
137
292
|
$[9] = clientFieldConfig;
|
|
138
|
-
$[10] =
|
|
139
|
-
$[11] =
|
|
140
|
-
$[12] = t2;
|
|
293
|
+
$[10] = path;
|
|
294
|
+
$[11] = t2;
|
|
141
295
|
} else {
|
|
142
|
-
t2 = $[
|
|
296
|
+
t2 = $[11];
|
|
143
297
|
}
|
|
144
298
|
if (t2 !== Symbol.for("react.early_return_sentinel")) {
|
|
145
299
|
return t2;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RenderField.js","names":["c","_c","React","ArrayField","BlocksField","CollapsibleField","GroupField","HiddenField","RowField","TabsField","
|
|
1
|
+
{"version":3,"file":"RenderField.js","names":["c","_c","React","ArrayField","BlocksField","CheckboxField","CodeField","CollapsibleField","DateTimeField","EmailField","GroupField","HiddenField","JoinField","JSONField","NumberField","PointField","RadioGroupField","RelationshipField","RichTextField","RowField","SelectField","TabsField","TextField","TextareaField","UIField","UploadField","useFormFields","RenderField","t0","$","clientFieldConfig","forceRender","indexPath","parentPath","parentSchemaPath","path","permissions","readOnly","schemaPath","t1","t2","fields","customComponents","Field","undefined","Symbol","for","baseFieldProps","iterableFieldProps","admin","hidden","_jsx","field","type","t3","bb0"],"sources":["../../../src/forms/RenderFields/RenderField.tsx"],"sourcesContent":["'use client'\n\nimport type { ClientComponentProps, ClientField, FieldPaths, FieldPermissions } from 'payload'\n\nimport React from 'react'\n\nimport { ArrayField } from '../../fields/Array/index.js'\nimport { BlocksField } from '../../fields/Blocks/index.js'\nimport { CheckboxField } from '../../fields/Checkbox/index.js'\nimport { CodeField } from '../../fields/Code/index.js'\nimport { CollapsibleField } from '../../fields/Collapsible/index.js'\nimport { DateTimeField } from '../../fields/DateTime/index.js'\nimport { EmailField } from '../../fields/Email/index.js'\nimport { GroupField } from '../../fields/Group/index.js'\nimport { HiddenField } from '../../fields/Hidden/index.js'\nimport { JoinField } from '../../fields/Join/index.js'\nimport { JSONField } from '../../fields/JSON/index.js'\nimport { NumberField } from '../../fields/Number/index.js'\nimport { PointField } from '../../fields/Point/index.js'\nimport { RadioGroupField } from '../../fields/RadioGroup/index.js'\nimport { RelationshipField } from '../../fields/Relationship/index.js'\nimport { RichTextField } from '../../fields/RichText/index.js'\nimport { RowField } from '../../fields/Row/index.js'\nimport { SelectField } from '../../fields/Select/index.js'\nimport { TabsField } from '../../fields/Tabs/index.js'\nimport { TextField } from '../../fields/Text/index.js'\nimport { TextareaField } from '../../fields/Textarea/index.js'\nimport { UIField } from '../../fields/UI/index.js'\nimport { UploadField } from '../../fields/Upload/index.js'\nimport { useFormFields } from '../../forms/Form/index.js'\n\ntype RenderFieldProps = {\n clientFieldConfig: ClientField\n permissions: FieldPermissions\n} & FieldPaths &\n Pick<ClientComponentProps, 'forceRender' | 'readOnly' | 'schemaPath'>\n\nexport function RenderField({\n clientFieldConfig,\n forceRender,\n indexPath,\n parentPath,\n parentSchemaPath,\n path,\n permissions,\n readOnly,\n schemaPath,\n}: RenderFieldProps) {\n const Field = useFormFields(([fields]) => fields && fields?.[path]?.customComponents?.Field)\n\n if (Field !== undefined) {\n return Field || null\n }\n\n const baseFieldProps: Pick<ClientComponentProps, 'forceRender' | 'readOnly' | 'schemaPath'> = {\n forceRender,\n readOnly,\n schemaPath,\n }\n\n const iterableFieldProps = {\n ...baseFieldProps,\n indexPath,\n parentPath,\n parentSchemaPath,\n permissions,\n }\n\n if (clientFieldConfig.admin?.hidden) {\n return <HiddenField {...baseFieldProps} field={clientFieldConfig} path={path} />\n }\n\n switch (clientFieldConfig.type) {\n case 'array':\n return <ArrayField {...iterableFieldProps} field={clientFieldConfig} path={path} />\n\n case 'blocks':\n return <BlocksField {...iterableFieldProps} field={clientFieldConfig} path={path} />\n\n case 'checkbox':\n return <CheckboxField {...baseFieldProps} field={clientFieldConfig} path={path} />\n\n case 'code':\n return <CodeField {...baseFieldProps} field={clientFieldConfig} path={path} />\n\n case 'collapsible':\n return <CollapsibleField {...iterableFieldProps} field={clientFieldConfig} path={path} />\n\n case 'date':\n return <DateTimeField {...baseFieldProps} field={clientFieldConfig} path={path} />\n\n case 'email':\n return <EmailField {...baseFieldProps} field={clientFieldConfig} path={path} />\n\n case 'group':\n return <GroupField {...iterableFieldProps} field={clientFieldConfig} path={path} />\n\n case 'join':\n return <JoinField {...baseFieldProps} field={clientFieldConfig} path={path} />\n\n case 'json':\n return <JSONField {...baseFieldProps} field={clientFieldConfig} path={path} />\n\n case 'number':\n return <NumberField {...baseFieldProps} field={clientFieldConfig} path={path} />\n\n case 'point':\n return <PointField {...baseFieldProps} field={clientFieldConfig} path={path} />\n\n case 'radio':\n return <RadioGroupField {...baseFieldProps} field={clientFieldConfig} path={path} />\n\n case 'relationship':\n return <RelationshipField {...baseFieldProps} field={clientFieldConfig} path={path} />\n\n case 'richText':\n return <RichTextField {...baseFieldProps} field={clientFieldConfig} path={path} />\n\n case 'row':\n return <RowField {...iterableFieldProps} field={clientFieldConfig} />\n\n case 'select':\n return <SelectField {...baseFieldProps} field={clientFieldConfig} path={path} />\n\n case 'tabs':\n return <TabsField {...iterableFieldProps} field={clientFieldConfig} path={path} />\n\n case 'text':\n return <TextField {...baseFieldProps} field={clientFieldConfig} path={path} />\n\n case 'textarea':\n return <TextareaField {...baseFieldProps} field={clientFieldConfig} path={path} />\n\n case 'ui':\n return <UIField />\n\n case 'upload':\n return <UploadField {...baseFieldProps} field={clientFieldConfig} path={path} />\n }\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A,CAAAjC,aAAA;cAAA,GAAmB6B,cAAc;cAAAK,KAAA,EAAStB,iBAAA;cAAAK;YAAA,C;;;aAE9C;UAAA;YACIK,EAAA,GAAAW,IAAA,CAAAhC,QAAA;cAAA,GAAc6B,kBAAkB;cAAAI,KAAA,EAAStB;YAAA,C;;;aAE7C;UAAA;YACIU,EAAA,GAAAW,IAAA,CAAA/B,WAAA;cAAA,GAAiB2B,cAAc;cAAAK,KAAA,EAAStB,iBAAA;cAAAK;YAAA,C;;;aAE5C;UAAA;YACIK,EAAA,GAAAW,IAAA,CAAA9B,SAAA;cAAA,GAAe2B,kBAAkB;cAAAI,KAAA,EAAStB,iBAAA;cAAAK;YAAA,C;;;aAE9C;UAAA;YACIK,EAAA,GAAAW,IAAA,CAAA7B,SAAA;cAAA,GAAeyB,cAAc;cAAAK,KAAA,EAAStB,iBAAA;cAAAK;YAAA,C;;;aAE1C;UAAA;YACIK,EAAA,GAAAW,IAAA,CAAA5B,aAAA;cAAA,GAAmBwB,cAAc;cAAAK,KAAA,EAAStB,iBAAA;cAAAK;YAAA,C;;;aAE9C;UAAA;YAAA,IAAAmB,EAAA;YAAA,IAAAzB,CAAA,SAAAgB,MAAA,CAAAC,GAAA;cACIQ,EAAA,GAAAH,IAAA,CAAA3B,OAAA,IAAC;cAAAK,CAAA,OAAAyB,EAAA;YAAA;cAAAA,EAAA,GAAAzB,CAAA;YAAA;YAADW,EAAA,GAAAc,EAAC;YAAA,MAAAC,GAAA;UAAA;QAAA,KAEL;UAAA;YACIf,EAAA,GAAAW,IAAA,CAAA1B,WAAA;cAAA,GAAiBsB,cAAc;cAAAK,KAAA,EAAStB,iBAAA;cAAAK;YAAA,C","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderField.d.ts","sourceRoot":"","sources":["../../../src/forms/fieldSchemasToFormState/renderField.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"renderField.d.ts","sourceRoot":"","sources":["../../../src/forms/fieldSchemasToFormState/renderField.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAKnD,eAAO,MAAM,WAAW,EAAE,iBA2OzB,CAAA"}
|
|
@@ -33,13 +33,16 @@ export const renderField = ({
|
|
|
33
33
|
const clientProps = {
|
|
34
34
|
customComponents: fieldState?.customComponents || {},
|
|
35
35
|
field: clientField,
|
|
36
|
-
indexPath,
|
|
37
|
-
parentPath,
|
|
38
|
-
parentSchemaPath,
|
|
39
36
|
path,
|
|
40
37
|
readOnly: permissions?.[operation]?.permission === false,
|
|
41
38
|
schemaPath
|
|
42
39
|
};
|
|
40
|
+
// fields with subfields
|
|
41
|
+
if (['array', 'blocks', 'collapsible', 'group', 'row', 'tabs'].includes(fieldConfig.type)) {
|
|
42
|
+
clientProps.indexPath = indexPath;
|
|
43
|
+
clientProps.parentPath = parentPath;
|
|
44
|
+
clientProps.parentSchemaPath = parentSchemaPath;
|
|
45
|
+
}
|
|
43
46
|
const serverProps = {
|
|
44
47
|
clientField,
|
|
45
48
|
data,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderField.js","names":["getTranslation","createClientField","deepCopyObjectSimple","MissingEditorProp","fieldAffectsData","RenderServerComponent","FieldDescription","renderField","data","fieldConfig","fieldSchemaMap","fieldState","formState","indexPath","operation","parentPath","parentSchemaPath","path","permissions","incomingPermissions","req","schemaPath","siblingData","clientField","defaultIDType","payload","config","db","field","i18n","name","clientProps","customComponents","readOnly","permission","serverProps","user","type","rows","forEach","row","rowIndex","admin","components","RowLabels","_jsx","Component","RowLabel","importMap","rowLabel","labels","singular","String","padStart","rowNumber","editor","Error","FieldComponent","Field","Fallback","undefined","Description","description","t","AfterInput","afterInput","BeforeInput","beforeInput","Label"],"sources":["../../../src/forms/fieldSchemasToFormState/renderField.tsx"],"sourcesContent":["import type {\n ClientComponentProps,\n ClientField,\n FieldPermissions,\n PayloadComponent,\n ServerComponentProps,\n} from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { createClientField, deepCopyObjectSimple, MissingEditorProp } from 'payload'\nimport { fieldAffectsData } from 'payload/shared'\n\nimport type { RenderFieldMethod } from './types.js'\n\nimport { RenderServerComponent } from '../../elements/RenderServerComponent/index.js'\nimport { FieldDescription } from '../../fields/FieldDescription/index.js'\n\nexport const renderField: RenderFieldMethod = ({\n data,\n fieldConfig,\n fieldSchemaMap,\n fieldState,\n formState,\n indexPath,\n operation,\n parentPath,\n parentSchemaPath,\n path,\n permissions: incomingPermissions,\n req,\n schemaPath,\n siblingData,\n}) => {\n // TODO (ALESSIO): why are we passing the fieldConfig twice?\n // and especially, why are we deepCopyObject -here- instead of inside the createClientField func,\n // so no one screws this up in the future?\n const clientField = createClientField({\n clientField: deepCopyObjectSimple(fieldConfig) as ClientField,\n defaultIDType: req.payload.config.db.defaultIDType,\n field: fieldConfig,\n i18n: req.i18n,\n })\n\n const permissions = fieldAffectsData(fieldConfig)\n ? incomingPermissions?.[fieldConfig.name]\n : ({} as FieldPermissions)\n\n const clientProps: ClientComponentProps = {\n customComponents: fieldState?.customComponents || {},\n field: clientField,\n indexPath,\n parentPath,\n parentSchemaPath,\n path,\n readOnly: permissions?.[operation]?.permission === false,\n schemaPath,\n }\n\n const serverProps: ServerComponentProps = {\n clientField,\n data,\n field: fieldConfig,\n fieldSchemaMap,\n permissions,\n // TODO: Should we pass explicit values? initialValue, value, valid\n // value and initialValue should be typed\n formState,\n i18n: req.i18n,\n payload: req.payload,\n siblingData,\n user: req.user,\n }\n\n if (!fieldState?.customComponents) {\n fieldState.customComponents = {}\n }\n\n switch (fieldConfig.type) {\n // TODO: handle block row labels as well in a similar fashion\n case 'array': {\n fieldState?.rows?.forEach((row, rowIndex) => {\n if (fieldConfig.admin?.components && 'RowLabel' in fieldConfig.admin.components) {\n if (!fieldState.customComponents.RowLabels) {\n fieldState.customComponents.RowLabels = []\n }\n\n fieldState.customComponents.RowLabels[rowIndex] = (\n <RenderServerComponent\n clientProps={clientProps}\n Component={fieldConfig.admin.components.RowLabel}\n importMap={req.payload.importMap}\n serverProps={{\n ...serverProps,\n rowLabel: `${getTranslation(fieldConfig.labels.singular, req.i18n)} ${String(\n rowIndex + 1,\n ).padStart(2, '0')}`,\n rowNumber: rowIndex + 1,\n }}\n />\n )\n }\n })\n\n break\n }\n\n case 'richText': {\n if (!fieldConfig?.editor) {\n throw new MissingEditorProp(fieldConfig) // while we allow disabling editor functionality, you should not have any richText fields defined if you do not have an editor\n }\n\n if (typeof fieldConfig?.editor === 'function') {\n throw new Error('Attempted to access unsanitized rich text editor.')\n }\n\n if (!fieldConfig.admin) {\n fieldConfig.admin = {}\n }\n\n if (!fieldConfig.admin.components) {\n fieldConfig.admin.components = {}\n }\n\n /**\n * We have to deep copy all the props we send to the client (= FieldComponent.clientProps).\n * That way, every editor's field / cell props we send to the client have their own object references.\n *\n * If we send the same object reference to the client twice (e.g. through some configurations where 2 or more fields\n * reference the same editor object, like the root editor), the admin panel may hang indefinitely. This has been happening since\n * a newer Next.js update that made it break when sending the same object reference to the client twice.\n *\n * We can use deepCopyObjectSimple as client props should be JSON-serializable.\n */\n const FieldComponent: PayloadComponent = fieldConfig.editor.FieldComponent\n if (typeof FieldComponent === 'object' && FieldComponent.clientProps) {\n FieldComponent.clientProps = deepCopyObjectSimple(FieldComponent.clientProps)\n }\n\n fieldState.customComponents.Field = (\n <RenderServerComponent\n clientProps={clientProps}\n Component={FieldComponent}\n Fallback={undefined}\n importMap={req.payload.importMap}\n serverProps={serverProps}\n />\n )\n\n break\n }\n\n default: {\n break\n }\n }\n\n if (fieldConfig.admin) {\n if ('description' in fieldConfig.admin) {\n // @TODO move this to client, only render if it is a function\n fieldState.customComponents.Description = (\n <FieldDescription\n description={\n typeof fieldConfig.admin?.description === 'string' ||\n typeof fieldConfig.admin?.description === 'object'\n ? fieldConfig.admin.description\n : typeof fieldConfig.admin?.description === 'function'\n ? fieldConfig.admin?.description({ t: req.i18n.t })\n : ''\n }\n path={path}\n />\n )\n }\n\n if (fieldConfig.admin?.components) {\n if ('afterInput' in fieldConfig.admin.components) {\n fieldState.customComponents.AfterInput = (\n <RenderServerComponent\n clientProps={clientProps}\n Component={fieldConfig.admin.components.afterInput}\n importMap={req.payload.importMap}\n key=\"field.admin.components.afterInput\"\n serverProps={serverProps}\n />\n )\n }\n\n if ('beforeInput' in fieldConfig.admin.components) {\n fieldState.customComponents.BeforeInput = (\n <RenderServerComponent\n clientProps={clientProps}\n Component={fieldConfig.admin.components.beforeInput}\n importMap={req.payload.importMap}\n key=\"field.admin.components.beforeInput\"\n serverProps={serverProps}\n />\n )\n }\n\n if ('Description' in fieldConfig.admin.components) {\n fieldState.customComponents.Description = (\n <RenderServerComponent\n clientProps={clientProps}\n Component={fieldConfig.admin.components.Description}\n importMap={req.payload.importMap}\n key=\"field.admin.components.Description\"\n serverProps={serverProps}\n />\n )\n }\n\n if ('Error' in fieldConfig.admin.components) {\n fieldState.customComponents.Error = (\n <RenderServerComponent\n clientProps={clientProps}\n Component={fieldConfig.admin.components.Error}\n importMap={req.payload.importMap}\n key=\"field.admin.components.Error\"\n serverProps={serverProps}\n />\n )\n }\n\n if ('Label' in fieldConfig.admin.components) {\n fieldState.customComponents.Label = (\n <RenderServerComponent\n clientProps={clientProps}\n Component={fieldConfig.admin.components.Label}\n importMap={req.payload.importMap}\n key=\"field.admin.components.Label\"\n serverProps={serverProps}\n />\n )\n }\n\n if ('Field' in fieldConfig.admin.components) {\n fieldState.customComponents.Field = (\n <RenderServerComponent\n clientProps={clientProps}\n Component={fieldConfig.admin.components.Field}\n importMap={req.payload.importMap}\n key=\"field.admin.components.Field\"\n serverProps={serverProps}\n />\n )\n }\n }\n }\n}\n"],"mappings":";AAQA,SAASA,cAAc,QAAQ;AAC/B,SAASC,iBAAiB,EAAEC,oBAAoB,EAAEC,iBAAiB,QAAQ;AAC3E,SAASC,gBAAgB,QAAQ;AAIjC,SAASC,qBAAqB,QAAQ;AACtC,SA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gB,CAACoC,KAAK,gBAC/BvB,IAAA,CAACxC,qBAAA;UACC0B,WAAA,EAAaA,WAAA;UACbe,SAAA,EAAWrC,WAAA,CAAYiC,KAAK,CAACC,UAAU,CAACyB,KAAK;UAC7CpB,SAAA,EAAW5B,GAAA,CAAIK,OAAO,CAACuB,SAAS;UAEhCb,WAAA,EAAaA;WADT;MAIV;MAEA,IAAI,WAAW1B,WAAA,CAAYiC,KAAK,CAACC,UAAU,EAAE;QAC3ChC,UAAA,CAAWqB,gBAAgB,CAAC0B,KAAK,gBAC/Bb,IAAA,CAACxC,qBAAA;UACC0B,WAAA,EAAaA,WAAA;UACbe,SAAA,EAAWrC,WAAA,CAAYiC,KAAK,CAACC,UAAU,CAACe,KAAK;UAC7CV,SAAA,EAAW5B,GAAA,CAAIK,OAAO,CAACuB,SAAS;UAEhCb,WAAA,EAAaA;WADT;MAIV;IACF;EACF;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"renderField.js","names":["getTranslation","createClientField","deepCopyObjectSimple","MissingEditorProp","fieldAffectsData","RenderServerComponent","FieldDescription","renderField","data","fieldConfig","fieldSchemaMap","fieldState","formState","indexPath","operation","parentPath","parentSchemaPath","path","permissions","incomingPermissions","req","schemaPath","siblingData","clientField","defaultIDType","payload","config","db","field","i18n","name","clientProps","customComponents","readOnly","permission","includes","type","serverProps","user","rows","forEach","row","rowIndex","admin","components","RowLabels","_jsx","Component","RowLabel","importMap","rowLabel","labels","singular","String","padStart","rowNumber","editor","Error","FieldComponent","Field","Fallback","undefined","Description","description","t","AfterInput","afterInput","BeforeInput","beforeInput","Label"],"sources":["../../../src/forms/fieldSchemasToFormState/renderField.tsx"],"sourcesContent":["import type {\n ClientComponentProps,\n ClientField,\n FieldPaths,\n FieldPermissions,\n PayloadComponent,\n ServerComponentProps,\n} from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { createClientField, deepCopyObjectSimple, MissingEditorProp } from 'payload'\nimport { fieldAffectsData } from 'payload/shared'\n\nimport type { RenderFieldMethod } from './types.js'\n\nimport { RenderServerComponent } from '../../elements/RenderServerComponent/index.js'\nimport { FieldDescription } from '../../fields/FieldDescription/index.js'\n\nexport const renderField: RenderFieldMethod = ({\n data,\n fieldConfig,\n fieldSchemaMap,\n fieldState,\n formState,\n indexPath,\n operation,\n parentPath,\n parentSchemaPath,\n path,\n permissions: incomingPermissions,\n req,\n schemaPath,\n siblingData,\n}) => {\n // TODO (ALESSIO): why are we passing the fieldConfig twice?\n // and especially, why are we deepCopyObject -here- instead of inside the createClientField func,\n // so no one screws this up in the future?\n const clientField = createClientField({\n clientField: deepCopyObjectSimple(fieldConfig) as ClientField,\n defaultIDType: req.payload.config.db.defaultIDType,\n field: fieldConfig,\n i18n: req.i18n,\n })\n\n const permissions = fieldAffectsData(fieldConfig)\n ? incomingPermissions?.[fieldConfig.name]\n : ({} as FieldPermissions)\n\n const clientProps: ClientComponentProps & Partial<FieldPaths> = {\n customComponents: fieldState?.customComponents || {},\n field: clientField,\n path,\n readOnly: permissions?.[operation]?.permission === false,\n schemaPath,\n }\n\n // fields with subfields\n if (['array', 'blocks', 'collapsible', 'group', 'row', 'tabs'].includes(fieldConfig.type)) {\n clientProps.indexPath = indexPath\n clientProps.parentPath = parentPath\n clientProps.parentSchemaPath = parentSchemaPath\n }\n\n const serverProps: ServerComponentProps = {\n clientField,\n data,\n field: fieldConfig,\n fieldSchemaMap,\n permissions,\n // TODO: Should we pass explicit values? initialValue, value, valid\n // value and initialValue should be typed\n formState,\n i18n: req.i18n,\n payload: req.payload,\n siblingData,\n user: req.user,\n }\n\n if (!fieldState?.customComponents) {\n fieldState.customComponents = {}\n }\n\n switch (fieldConfig.type) {\n // TODO: handle block row labels as well in a similar fashion\n case 'array': {\n fieldState?.rows?.forEach((row, rowIndex) => {\n if (fieldConfig.admin?.components && 'RowLabel' in fieldConfig.admin.components) {\n if (!fieldState.customComponents.RowLabels) {\n fieldState.customComponents.RowLabels = []\n }\n\n fieldState.customComponents.RowLabels[rowIndex] = (\n <RenderServerComponent\n clientProps={clientProps}\n Component={fieldConfig.admin.components.RowLabel}\n importMap={req.payload.importMap}\n serverProps={{\n ...serverProps,\n rowLabel: `${getTranslation(fieldConfig.labels.singular, req.i18n)} ${String(\n rowIndex + 1,\n ).padStart(2, '0')}`,\n rowNumber: rowIndex + 1,\n }}\n />\n )\n }\n })\n\n break\n }\n\n case 'richText': {\n if (!fieldConfig?.editor) {\n throw new MissingEditorProp(fieldConfig) // while we allow disabling editor functionality, you should not have any richText fields defined if you do not have an editor\n }\n\n if (typeof fieldConfig?.editor === 'function') {\n throw new Error('Attempted to access unsanitized rich text editor.')\n }\n\n if (!fieldConfig.admin) {\n fieldConfig.admin = {}\n }\n\n if (!fieldConfig.admin.components) {\n fieldConfig.admin.components = {}\n }\n\n /**\n * We have to deep copy all the props we send to the client (= FieldComponent.clientProps).\n * That way, every editor's field / cell props we send to the client have their own object references.\n *\n * If we send the same object reference to the client twice (e.g. through some configurations where 2 or more fields\n * reference the same editor object, like the root editor), the admin panel may hang indefinitely. This has been happening since\n * a newer Next.js update that made it break when sending the same object reference to the client twice.\n *\n * We can use deepCopyObjectSimple as client props should be JSON-serializable.\n */\n const FieldComponent: PayloadComponent = fieldConfig.editor.FieldComponent\n if (typeof FieldComponent === 'object' && FieldComponent.clientProps) {\n FieldComponent.clientProps = deepCopyObjectSimple(FieldComponent.clientProps)\n }\n\n fieldState.customComponents.Field = (\n <RenderServerComponent\n clientProps={clientProps}\n Component={FieldComponent}\n Fallback={undefined}\n importMap={req.payload.importMap}\n serverProps={serverProps}\n />\n )\n\n break\n }\n\n default: {\n break\n }\n }\n\n if (fieldConfig.admin) {\n if ('description' in fieldConfig.admin) {\n // @TODO move this to client, only render if it is a function\n fieldState.customComponents.Description = (\n <FieldDescription\n description={\n typeof fieldConfig.admin?.description === 'string' ||\n typeof fieldConfig.admin?.description === 'object'\n ? fieldConfig.admin.description\n : typeof fieldConfig.admin?.description === 'function'\n ? fieldConfig.admin?.description({ t: req.i18n.t })\n : ''\n }\n path={path}\n />\n )\n }\n\n if (fieldConfig.admin?.components) {\n if ('afterInput' in fieldConfig.admin.components) {\n fieldState.customComponents.AfterInput = (\n <RenderServerComponent\n clientProps={clientProps}\n Component={fieldConfig.admin.components.afterInput}\n importMap={req.payload.importMap}\n key=\"field.admin.components.afterInput\"\n serverProps={serverProps}\n />\n )\n }\n\n if ('beforeInput' in fieldConfig.admin.components) {\n fieldState.customComponents.BeforeInput = (\n <RenderServerComponent\n clientProps={clientProps}\n Component={fieldConfig.admin.components.beforeInput}\n importMap={req.payload.importMap}\n key=\"field.admin.components.beforeInput\"\n serverProps={serverProps}\n />\n )\n }\n\n if ('Description' in fieldConfig.admin.components) {\n fieldState.customComponents.Description = (\n <RenderServerComponent\n clientProps={clientProps}\n Component={fieldConfig.admin.components.Description}\n importMap={req.payload.importMap}\n key=\"field.admin.components.Description\"\n serverProps={serverProps}\n />\n )\n }\n\n if ('Error' in fieldConfig.admin.components) {\n fieldState.customComponents.Error = (\n <RenderServerComponent\n clientProps={clientProps}\n Component={fieldConfig.admin.components.Error}\n importMap={req.payload.importMap}\n key=\"field.admin.components.Error\"\n serverProps={serverProps}\n />\n )\n }\n\n if ('Label' in fieldConfig.admin.components) {\n fieldState.customComponents.Label = (\n <RenderServerComponent\n clientProps={clientProps}\n Component={fieldConfig.admin.components.Label}\n importMap={req.payload.importMap}\n key=\"field.admin.components.Label\"\n serverProps={serverProps}\n />\n )\n }\n\n if ('Field' in fieldConfig.admin.components) {\n fieldState.customComponents.Field = (\n <RenderServerComponent\n clientProps={clientProps}\n Component={fieldConfig.admin.components.Field}\n importMap={req.payload.importMap}\n key=\"field.admin.components.Field\"\n serverProps={serverProps}\n />\n )\n }\n }\n }\n}\n"],"mappings":";AASA,SAASA,cAAc,QAAQ;AAC/B,SAASC,iBAAiB,EAAEC,oBAAoB,EAAEC,iBAAiB,QAAQ;AAC3E,SAASC,gBAAgB,QAAQ;AAIjC,SAASC,qBAAqB,Q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SAAA,EAAWtC,WAAA,CAAYkC,KAAK,CAACC,UAAU,CAACa,KAAK;UAC7CR,SAAA,EAAW7B,GAAA,CAAIK,OAAO,CAACwB,SAAS;UAEhCZ,WAAA,EAAaA;WADT;MAIV;MAEA,IAAI,WAAW5B,WAAA,CAAYkC,KAAK,CAACC,UAAU,EAAE;QAC3CjC,UAAA,CAAWqB,gBAAgB,CAACqC,KAAK,gBAC/BvB,IAAA,CAACzC,qBAAA;UACC0B,WAAA,EAAaA,WAAA;UACbgB,SAAA,EAAWtC,WAAA,CAAYkC,KAAK,CAACC,UAAU,CAACyB,KAAK;UAC7CpB,SAAA,EAAW7B,GAAA,CAAIK,OAAO,CAACwB,SAAS;UAEhCZ,WAAA,EAAaA;WADT;MAIV;MAEA,IAAI,WAAW5B,WAAA,CAAYkC,KAAK,CAACC,UAAU,EAAE;QAC3CjC,UAAA,CAAWqB,gBAAgB,CAAC2B,KAAK,gBAC/Bb,IAAA,CAACzC,qBAAA;UACC0B,WAAA,EAAaA,WAAA;UACbgB,SAAA,EAAWtC,WAAA,CAAYkC,KAAK,CAACC,UAAU,CAACe,KAAK;UAC7CV,SAAA,EAAW7B,GAAA,CAAIK,OAAO,CAACwB,SAAS;UAEhCZ,WAAA,EAAaA;WADT;MAIV;IACF;EACF;AACF","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ClientFieldProps } from 'payload';
|
|
1
|
+
import type { ClientFieldProps, FieldPaths } from 'payload';
|
|
2
2
|
import type { MarkOptional } from 'ts-essentials';
|
|
3
3
|
import React from 'react';
|
|
4
|
-
export declare const withCondition: <P extends MarkOptional<Pick<ClientFieldProps, "field"
|
|
4
|
+
export declare const withCondition: <P extends MarkOptional<FieldPaths & Pick<ClientFieldProps, "field">, "indexPath" | "path">>(Field: React.ComponentType<P>) => React.FC<P>;
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/forms/withCondition/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/forms/withCondition/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAEjD,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,eAAO,MAAM,aAAa,GACxB,CAAC,SAAS,YAAY,CAAC,UAAU,GAAG,IAAI,CAAC,gBAAgB,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,MAAM,CAAC,SAEnF,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,KAC5B,KAAK,CAAC,EAAE,CAAC,CAAC,CAoBZ,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","WatchCondition","withCondition","Field","CheckForCondition","props","field","type","indexPath","path","pathFromProps","name","undefined","_jsx"],"sources":["../../../src/forms/withCondition/index.tsx"],"sourcesContent":["'use client'\nimport type { ClientFieldProps } from 'payload'\nimport type { MarkOptional } from 'ts-essentials'\n\nimport React from 'react'\n\nimport { WatchCondition } from './WatchCondition.js'\n\nexport const withCondition = <\n P extends MarkOptional
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","WatchCondition","withCondition","Field","CheckForCondition","props","field","type","indexPath","path","pathFromProps","name","undefined","_jsx"],"sources":["../../../src/forms/withCondition/index.tsx"],"sourcesContent":["'use client'\nimport type { ClientFieldProps, FieldPaths } from 'payload'\nimport type { MarkOptional } from 'ts-essentials'\n\nimport React from 'react'\n\nimport { WatchCondition } from './WatchCondition.js'\n\nexport const withCondition = <\n P extends MarkOptional<FieldPaths & Pick<ClientFieldProps, 'field'>, 'indexPath' | 'path'>,\n>(\n Field: React.ComponentType<P>,\n): React.FC<P> => {\n const CheckForCondition: React.FC<P> = (props) => {\n const {\n field: { type },\n indexPath,\n path: pathFromProps,\n } = props\n\n const name = 'name' in props.field ? props.field.name : undefined\n\n const path = pathFromProps ?? name\n\n return (\n <WatchCondition indexPath={indexPath} name={name} path={path} type={type}>\n <Field {...props} />\n </WatchCondition>\n )\n }\n\n return CheckForCondition\n}\n"],"mappings":"AAAA;;;AAIA,OAAOA,KAAA,MAAW;AAElB,SAASC,cAAc,QAAQ;AAE/B,OAAO,MAAMC,aAAA,GAGXC,KAAA;EAEA,MAAMC,iBAAA,GAAkCC,KAAA;IACtC,MAAM;MACJC,KAAA,EAAO;QAAEC;MAAI,CAAE;MACfC,SAAS;MACTC,IAAA,EAAMC;IAAa,CACpB,GAAGL,KAAA;IAEJ,MAAMM,IAAA,GAAO,UAAUN,KAAA,CAAMC,KAAK,GAAGD,KAAA,CAAMC,KAAK,CAACK,IAAI,GAAGC,SAAA;IAExD,MAAMH,IAAA,GAAOC,aAAA,IAAiBC,IAAA;IAE9B,oBACEE,IAAA,CAACZ,cAAA;MAAeO,SAAA,EAAWA,SAAA;MAAWG,IAAA,EAAMA,IAAA;MAAMF,IAAA,EAAMA,IAAA;MAAMF,IAAA,EAAMA,IAAA;gBAClE,aAAAM,IAAA,CAACV,KAAA;QAAO,GAAGE;;;EAGjB;EAEA,OAAOD,iBAAA;AACT","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/Preferences/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAoE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/Preferences/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAoE,MAAM,OAAO,CAAA;AAQxF,KAAK,kBAAkB,GAAG;IACxB,aAAa,EAAE,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,CAAA;IACnD;;;;OAIG;IACH,aAAa,EAAE,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;CAClF,CAAA;AAYD,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC;IAAE,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,CAuHxE,CAAA;AAED,eAAO,MAAM,cAAc,QAAO,kBAAyC,CAAA"}
|
|
@@ -5,6 +5,7 @@ import { dequal } from 'dequal/lite'; // lite: no need for Map and Set support
|
|
|
5
5
|
import React, { createContext, useCallback, useContext, useEffect, useRef } from 'react';
|
|
6
6
|
import { useTranslation } from '../../providers/Translation/index.js';
|
|
7
7
|
import { requests } from '../../utilities/api.js';
|
|
8
|
+
import { deepMergeSimple } from '../../utilities/deepMerge.js';
|
|
8
9
|
import { useAuth } from '../Auth/index.js';
|
|
9
10
|
import { useConfig } from '../Config/index.js';
|
|
10
11
|
const Context = /*#__PURE__*/createContext({});
|
|
@@ -79,10 +80,7 @@ export const PreferencesProvider = ({
|
|
|
79
80
|
// handle value objects where multiple values can be set under one key
|
|
80
81
|
if (typeof value_0 === 'object' && typeof currentPreference === 'object' && typeof newValue === 'object') {
|
|
81
82
|
// merge the value with any existing preference for the key
|
|
82
|
-
newValue =
|
|
83
|
-
...(currentPreference || {}),
|
|
84
|
-
...value_0
|
|
85
|
-
};
|
|
83
|
+
newValue = deepMergeSimple(currentPreference, newValue);
|
|
86
84
|
if (dequal(newValue, currentPreference)) {
|
|
87
85
|
return;
|
|
88
86
|
}
|