@payloadcms/ui 3.31.0-canary.0 → 3.31.0

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/JSON/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAoD,MAAM,OAAO,CAAA;AAWxE,OAAO,cAAc,CAAA;AA8JrB,eAAO,MAAM,SAAS;;;;;+EAAoC,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/JSON/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAoD,MAAM,OAAO,CAAA;AAYxE,OAAO,cAAc,CAAA;AA8JrB,eAAO,MAAM,SAAS;;;;;+EAAoC,CAAA"}
@@ -2,6 +2,7 @@
2
2
 
3
3
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
4
4
  import React, { useCallback, useEffect, useMemo, useState } from 'react';
5
+ import { v4 as uuidv4 } from 'uuid';
5
6
  import { CodeEditor } from '../../elements/CodeEditor/index.js';
6
7
  import { RenderCustomComponent } from '../../elements/RenderCustomComponent/index.js';
7
8
  import { useField } from '../../forms/useField/index.js';
@@ -72,7 +73,7 @@ const JSONFieldComponent = props => {
72
73
  validate: true
73
74
  });
74
75
  const uri = jsonSchema.uri;
75
- const newUri = uri.includes('?') ? `${uri}&${crypto.randomUUID()}` : `${uri}?${crypto.randomUUID()}`;
76
+ const newUri = uri.includes('?') ? `${uri}&${crypto.randomUUID ? crypto.randomUUID() : uuidv4()}` : `${uri}?${crypto.randomUUID ? crypto.randomUUID() : uuidv4()}`;
76
77
  editor.setModel(monaco.editor.createModel(JSON.stringify(value_0, null, 2), 'json', monaco.Uri.parse(newUri)));
77
78
  }, [jsonSchema, value_0]);
78
79
  const handleChange = useCallback(val => {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["React","useCallback","useEffect","useMemo","useState","CodeEditor","RenderCustomComponent","useField","withCondition","FieldDescription","FieldError","FieldLabel","mergeFieldStyles","fieldBaseClass","baseClass","JSONFieldComponent","props","field","admin","className","description","editorOptions","maxHeight","jsonSchema","label","localized","required","path","readOnly","validate","jsonError","setJsonError","inputChangeFromRef","useRef","editorKey","setEditorKey","memoizedValidate","value","options","customComponents","AfterInput","BeforeInput","Description","Error","Label","disabled","initialValue","setValue","showError","initialStringValue","setInitialStringValue","undefined","JSON","stringify","handleMount","editor","monaco","languages","json","jsonDefaults","setDiagnosticsOptions","enableSchemaRequest","schemas","diagnosticsOptions","uri","newUri","includes","crypto","randomUUID","setModel","createModel","Uri","parse","handleChange","val","current","e","Date","toString","styles","_jsxs","filter","Boolean","join","style","_jsx","CustomComponent","Fallback","message","defaultLanguage","onChange","onMount","wrapperProps","id","replace","JSONField"],"sources":["../../../src/fields/JSON/index.tsx"],"sourcesContent":["'use client'\nimport type { JSONFieldClientComponent } from 'payload'\n\nimport { type OnMount } from '@monaco-editor/react'\nimport React, { useCallback, useEffect, useMemo, useState } from 'react'\n\nimport { CodeEditor } from '../../elements/CodeEditor/index.js'\nimport { RenderCustomComponent } from '../../elements/RenderCustomComponent/index.js'\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { FieldDescription } from '../FieldDescription/index.js'\nimport { FieldError } from '../FieldError/index.js'\nimport { FieldLabel } from '../FieldLabel/index.js'\nimport { mergeFieldStyles } from '../mergeFieldStyles.js'\nimport { fieldBaseClass } from '../shared/index.js'\nimport './index.scss'\n\nconst baseClass = 'json-field'\n\nconst JSONFieldComponent: JSONFieldClientComponent = (props) => {\n const {\n field,\n field: {\n admin: { className, description, editorOptions, maxHeight } = {},\n jsonSchema,\n label,\n localized,\n required,\n },\n path,\n readOnly,\n validate,\n } = props\n\n const [jsonError, setJsonError] = useState<string>()\n const inputChangeFromRef = React.useRef<'system' | 'user'>('system')\n const [editorKey, setEditorKey] = useState<string>('')\n\n const memoizedValidate = useCallback(\n (value, options) => {\n if (typeof validate === 'function') {\n return validate(value, { ...options, jsonError, required })\n }\n },\n [validate, required, jsonError],\n )\n\n const {\n customComponents: { AfterInput, BeforeInput, Description, Error, Label } = {},\n disabled,\n initialValue,\n setValue,\n showError,\n value,\n } = useField<string>({\n path,\n validate: memoizedValidate,\n })\n\n const [initialStringValue, setInitialStringValue] = useState<string | undefined>(() =>\n (value || initialValue) !== undefined\n ? JSON.stringify(value ?? initialValue, null, 2)\n : undefined,\n )\n\n const handleMount = useCallback<OnMount>(\n (editor, monaco) => {\n if (!jsonSchema) {\n return\n }\n\n monaco.languages.json.jsonDefaults.setDiagnosticsOptions({\n enableSchemaRequest: true,\n schemas: [\n ...(monaco.languages.json.jsonDefaults.diagnosticsOptions.schemas || []),\n jsonSchema,\n ],\n validate: true,\n })\n\n const uri = jsonSchema.uri\n const newUri = uri.includes('?')\n ? `${uri}&${crypto.randomUUID()}`\n : `${uri}?${crypto.randomUUID()}`\n\n editor.setModel(\n monaco.editor.createModel(JSON.stringify(value, null, 2), 'json', monaco.Uri.parse(newUri)),\n )\n },\n [jsonSchema, value],\n )\n\n const handleChange = useCallback(\n (val) => {\n if (readOnly || disabled) {\n return\n }\n inputChangeFromRef.current = 'user'\n\n try {\n setValue(val ? JSON.parse(val) : null)\n setJsonError(undefined)\n } catch (e) {\n setValue(val ? val : null)\n setJsonError(e)\n }\n },\n [readOnly, disabled, setValue],\n )\n\n useEffect(() => {\n if (inputChangeFromRef.current === 'system') {\n setInitialStringValue(\n (value || initialValue) !== undefined\n ? JSON.stringify(value ?? initialValue, null, 2)\n : undefined,\n )\n setEditorKey(new Date().toString())\n }\n\n inputChangeFromRef.current = 'system'\n }, [initialValue, value])\n\n const styles = useMemo(() => mergeFieldStyles(field), [field])\n\n return (\n <div\n className={[\n fieldBaseClass,\n baseClass,\n className,\n showError && 'error',\n (readOnly || disabled) && 'read-only',\n ]\n .filter(Boolean)\n .join(' ')}\n style={styles}\n >\n <RenderCustomComponent\n CustomComponent={Label}\n Fallback={\n <FieldLabel label={label} localized={localized} path={path} required={required} />\n }\n />\n <div className={`${fieldBaseClass}__wrap`}>\n <RenderCustomComponent\n CustomComponent={Error}\n Fallback={<FieldError message={jsonError} path={path} showError={showError} />}\n />\n {BeforeInput}\n <CodeEditor\n defaultLanguage=\"json\"\n key={editorKey}\n maxHeight={maxHeight}\n onChange={handleChange}\n onMount={handleMount}\n options={editorOptions}\n readOnly={readOnly || disabled}\n value={initialStringValue}\n wrapperProps={{\n id: `field-${path?.replace(/\\./g, '__')}`,\n }}\n />\n {AfterInput}\n </div>\n <RenderCustomComponent\n CustomComponent={Description}\n Fallback={<FieldDescription description={description} path={path} />}\n />\n </div>\n )\n}\n\nexport const JSONField = withCondition(JSONFieldComponent)\n"],"mappings":"AAAA;;;AAIA,OAAOA,KAAA,IAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ;AAEjE,SAASC,UAAU,QAAQ;AAC3B,SAASC,qBAAqB,QAAQ;AACtC,SAASC,QAAQ,QAAQ;AACzB,SAASC,aAAa,QAAQ;AAC9B,SAASC,gBAAgB,QAAQ;AACjC,SAASC,UAAU,QAAQ;AAC3B,SAASC,UAAU,QAAQ;AAC3B,SAASC,gBAAgB,QAAQ;AACjC,SAASC,cAAc,QAAQ;AAC/B,OAAO;AAEP,MAAMC,SAAA,GAAY;AAElB,MAAMC,kBAAA,GAAgDC,KAAA;EACpD,MAAM;IACJC,KAAK;IACLA,KAAA,EAAO;MACLC,KAAA,EAAO;QAAEC,SAAS;QAAEC,WAAW;QAAEC,aAAa;QAAEC;MAAS,CAAE,GAAG,CAAC,CAAC;MAChEC,UAAU;MACVC,KAAK;MACLC,SAAS;MACTC;IAAQ,CACT;IACDC,IAAI;IACJC,QAAQ;IACRC;EAAQ,CACT,GAAGb,KAAA;EAEJ,MAAM,CAACc,SAAA,EAAWC,YAAA,CAAa,GAAG3B,QAAA;EAClC,MAAM4B,kBAAA,GAAqBhC,KAAA,CA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file":"index.js","names":["React","useCallback","useEffect","useMemo","useState","v4","uuidv4","CodeEditor","RenderCustomComponent","useField","withCondition","FieldDescription","FieldError","FieldLabel","mergeFieldStyles","fieldBaseClass","baseClass","JSONFieldComponent","props","field","admin","className","description","editorOptions","maxHeight","jsonSchema","label","localized","required","path","readOnly","validate","jsonError","setJsonError","inputChangeFromRef","useRef","editorKey","setEditorKey","memoizedValidate","value","options","customComponents","AfterInput","BeforeInput","Description","Error","Label","disabled","initialValue","setValue","showError","initialStringValue","setInitialStringValue","undefined","JSON","stringify","handleMount","editor","monaco","languages","json","jsonDefaults","setDiagnosticsOptions","enableSchemaRequest","schemas","diagnosticsOptions","uri","newUri","includes","crypto","randomUUID","setModel","createModel","Uri","parse","handleChange","val","current","e","Date","toString","styles","_jsxs","filter","Boolean","join","style","_jsx","CustomComponent","Fallback","message","defaultLanguage","onChange","onMount","wrapperProps","id","replace","JSONField"],"sources":["../../../src/fields/JSON/index.tsx"],"sourcesContent":["'use client'\nimport type { JSONFieldClientComponent } from 'payload'\n\nimport { type OnMount } from '@monaco-editor/react'\nimport React, { useCallback, useEffect, useMemo, useState } from 'react'\nimport { v4 as uuidv4 } from 'uuid'\n\nimport { CodeEditor } from '../../elements/CodeEditor/index.js'\nimport { RenderCustomComponent } from '../../elements/RenderCustomComponent/index.js'\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { FieldDescription } from '../FieldDescription/index.js'\nimport { FieldError } from '../FieldError/index.js'\nimport { FieldLabel } from '../FieldLabel/index.js'\nimport { mergeFieldStyles } from '../mergeFieldStyles.js'\nimport { fieldBaseClass } from '../shared/index.js'\nimport './index.scss'\n\nconst baseClass = 'json-field'\n\nconst JSONFieldComponent: JSONFieldClientComponent = (props) => {\n const {\n field,\n field: {\n admin: { className, description, editorOptions, maxHeight } = {},\n jsonSchema,\n label,\n localized,\n required,\n },\n path,\n readOnly,\n validate,\n } = props\n\n const [jsonError, setJsonError] = useState<string>()\n const inputChangeFromRef = React.useRef<'system' | 'user'>('system')\n const [editorKey, setEditorKey] = useState<string>('')\n\n const memoizedValidate = useCallback(\n (value, options) => {\n if (typeof validate === 'function') {\n return validate(value, { ...options, jsonError, required })\n }\n },\n [validate, required, jsonError],\n )\n\n const {\n customComponents: { AfterInput, BeforeInput, Description, Error, Label } = {},\n disabled,\n initialValue,\n setValue,\n showError,\n value,\n } = useField<string>({\n path,\n validate: memoizedValidate,\n })\n\n const [initialStringValue, setInitialStringValue] = useState<string | undefined>(() =>\n (value || initialValue) !== undefined\n ? JSON.stringify(value ?? initialValue, null, 2)\n : undefined,\n )\n\n const handleMount = useCallback<OnMount>(\n (editor, monaco) => {\n if (!jsonSchema) {\n return\n }\n\n monaco.languages.json.jsonDefaults.setDiagnosticsOptions({\n enableSchemaRequest: true,\n schemas: [\n ...(monaco.languages.json.jsonDefaults.diagnosticsOptions.schemas || []),\n jsonSchema,\n ],\n validate: true,\n })\n\n const uri = jsonSchema.uri\n const newUri = uri.includes('?')\n ? `${uri}&${crypto.randomUUID ? crypto.randomUUID() : uuidv4()}`\n : `${uri}?${crypto.randomUUID ? crypto.randomUUID() : uuidv4()}`\n\n editor.setModel(\n monaco.editor.createModel(JSON.stringify(value, null, 2), 'json', monaco.Uri.parse(newUri)),\n )\n },\n [jsonSchema, value],\n )\n\n const handleChange = useCallback(\n (val) => {\n if (readOnly || disabled) {\n return\n }\n inputChangeFromRef.current = 'user'\n\n try {\n setValue(val ? JSON.parse(val) : null)\n setJsonError(undefined)\n } catch (e) {\n setValue(val ? val : null)\n setJsonError(e)\n }\n },\n [readOnly, disabled, setValue],\n )\n\n useEffect(() => {\n if (inputChangeFromRef.current === 'system') {\n setInitialStringValue(\n (value || initialValue) !== undefined\n ? JSON.stringify(value ?? initialValue, null, 2)\n : undefined,\n )\n setEditorKey(new Date().toString())\n }\n\n inputChangeFromRef.current = 'system'\n }, [initialValue, value])\n\n const styles = useMemo(() => mergeFieldStyles(field), [field])\n\n return (\n <div\n className={[\n fieldBaseClass,\n baseClass,\n className,\n showError && 'error',\n (readOnly || disabled) && 'read-only',\n ]\n .filter(Boolean)\n .join(' ')}\n style={styles}\n >\n <RenderCustomComponent\n CustomComponent={Label}\n Fallback={\n <FieldLabel label={label} localized={localized} path={path} required={required} />\n }\n />\n <div className={`${fieldBaseClass}__wrap`}>\n <RenderCustomComponent\n CustomComponent={Error}\n Fallback={<FieldError message={jsonError} path={path} showError={showError} />}\n />\n {BeforeInput}\n <CodeEditor\n defaultLanguage=\"json\"\n key={editorKey}\n maxHeight={maxHeight}\n onChange={handleChange}\n onMount={handleMount}\n options={editorOptions}\n readOnly={readOnly || disabled}\n value={initialStringValue}\n wrapperProps={{\n id: `field-${path?.replace(/\\./g, '__')}`,\n }}\n />\n {AfterInput}\n </div>\n <RenderCustomComponent\n CustomComponent={Description}\n Fallback={<FieldDescription description={description} path={path} />}\n />\n </div>\n )\n}\n\nexport const JSONField = withCondition(JSONFieldComponent)\n"],"mappings":"AAAA;;;AAIA,OAAOA,KAAA,IAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ;AACjE,SAASC,EAAA,IAAMC,MAAM,QAAQ;AAE7B,SAASC,UAAU,QAAQ;AAC3B,SAASC,qBAAqB,QAAQ;AACtC,SAASC,QAAQ,QAAQ;AACzB,SAASC,aAAa,QAAQ;AAC9B,SAASC,gBAAgB,QAAQ;AACjC,SAASC,UAAU,QAAQ;AAC3B,SAASC,UAAU,QAAQ;AAC3B,SAASC,gBAAgB,QAAQ;AACjC,SAASC,cAAc,QAAQ;AAC/B,OAAO;AAEP,MAAMC,SAAA,GAAY;AAElB,MAAMC,kBAAA,GAAgDC,KAAA;EACpD,MAAM;IACJC,KAAK;IACLA,KAAA,EAAO;MACLC,KAAA,EAAO;QAAEC,SAAS;QAAEC,WAAW;QAAEC,aAAa;QAAEC;MAAS,CAAE,GAAG,CAAC,CAAC;MAChEC,UAAU;MACVC,KAAK;MACLC,SAAS;MACTC;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M,UAAA;qBAEH6C,IAAA,CAAC/E,qBAAA;MACCgF,eAAA,EAAiB5C,WAAA;MACjB6C,QAAA,eAAUF,IAAA,CAAC5E,gBAAA;QAAiBW,WAAA,EAAaA,WAAA;QAAaO,IAAA,EAAMA;;;;AAIpE;AAEA,OAAO,MAAMoE,SAAA,GAAYvF,aAAA,CAAcO,kBAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utilities/buildClientFieldSchemaMap/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,KAAK,EACV,YAAY,EAEZ,oBAAoB,EACpB,cAAc,EACd,OAAO,EAER,MAAM,SAAS,CAAA;AAiBhB;;GAEG;AACH,eAAO,MAAM,yBAAyB,SAAU;IAC9C,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,MAAM,EAAE,YAAY,CAAA;IACpB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,IAAI,EAAE,IAAI,CAAA;IACV,OAAO,EAAE,OAAO,CAAA;IAChB,SAAS,EAAE,cAAc,CAAA;CAC1B,KAAG;IAAE,oBAAoB,EAAE,oBAAoB,CAAA;CAwD/C,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utilities/buildClientFieldSchemaMap/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,KAAK,EACV,YAAY,EAEZ,oBAAoB,EACpB,cAAc,EACd,OAAO,EAER,MAAM,SAAS,CAAA;AAiBhB;;GAEG;AACH,eAAO,MAAM,yBAAyB,SAAU;IAC9C,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,MAAM,EAAE,YAAY,CAAA;IACpB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,IAAI,EAAE,IAAI,CAAA;IACV,OAAO,EAAE,OAAO,CAAA;IAChB,SAAS,EAAE,cAAc,CAAA;CAC1B,KAAG;IAAE,oBAAoB,EAAE,oBAAoB,CAAA;CAyD/C,CAAA"}
@@ -29,7 +29,8 @@ export const buildClientFieldSchemaMap = args => {
29
29
  ;
30
30
  baseAuthFields[0].label = i18n.t('general:password');
31
31
  baseAuthFields[1].label = i18n.t('authentication:confirmPassword');
32
- fieldsToSet = baseAuthFields.concat(fieldsToSet);
32
+ // Place these fields _last_ to ensure they do not disrupt field paths in the field schema map
33
+ fieldsToSet = fieldsToSet.concat(baseAuthFields);
33
34
  }
34
35
  clientSchemaMap.set(collectionSlug, {
35
36
  fields: fieldsToSet
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["traverseFields","baseAuthFields","name","type","required","buildClientFieldSchemaMap","args","collectionSlug","config","globalSlug","i18n","payload","schemaMap","clientSchemaMap","Map","matchedCollection","collections","find","collection","slug","fieldsToSet","fields","auth","disableLocalStrategy","label","t","concat","set","parentIndexPath","parentSchemaPath","matchedGlobal","globals","global","clientFieldSchemaMap"],"sources":["../../../src/utilities/buildClientFieldSchemaMap/index.ts"],"sourcesContent":["import type { I18n } from '@payloadcms/translations'\nimport type {\n ClientConfig,\n ClientField,\n ClientFieldSchemaMap,\n FieldSchemaMap,\n Payload,\n TextFieldClient,\n} from 'payload'\n\nimport { traverseFields } from './traverseFields.js'\n\nconst baseAuthFields: ClientField[] = [\n {\n name: 'password',\n type: 'text',\n required: true,\n },\n {\n name: 'confirm-password',\n type: 'text',\n required: true,\n },\n]\n\n/**\n * Flattens the config fields into a map of field schemas\n */\nexport const buildClientFieldSchemaMap = (args: {\n collectionSlug?: string\n config: ClientConfig\n globalSlug?: string\n i18n: I18n\n payload: Payload\n schemaMap: FieldSchemaMap\n}): { clientFieldSchemaMap: ClientFieldSchemaMap } => {\n const { collectionSlug, config, globalSlug, i18n, payload, schemaMap } = args\n\n const clientSchemaMap: ClientFieldSchemaMap = new Map()\n\n if (collectionSlug) {\n const matchedCollection = config.collections.find(\n (collection) => collection.slug === collectionSlug,\n )\n\n if (matchedCollection) {\n let fieldsToSet = matchedCollection?.fields || []\n\n if (matchedCollection.auth && !matchedCollection.auth.disableLocalStrategy) {\n ;(baseAuthFields[0] as TextFieldClient).label = i18n.t('general:password')\n ;(baseAuthFields[1] as TextFieldClient).label = i18n.t('authentication:confirmPassword')\n fieldsToSet = baseAuthFields.concat(fieldsToSet)\n }\n\n clientSchemaMap.set(collectionSlug, {\n fields: fieldsToSet,\n })\n\n traverseFields({\n clientSchemaMap,\n config,\n fields: fieldsToSet,\n i18n,\n parentIndexPath: '',\n parentSchemaPath: collectionSlug,\n payload,\n schemaMap,\n })\n }\n } else if (globalSlug) {\n const matchedGlobal = config.globals.find((global) => global.slug === globalSlug)\n\n if (matchedGlobal) {\n clientSchemaMap.set(globalSlug, {\n fields: matchedGlobal.fields,\n })\n\n traverseFields({\n clientSchemaMap,\n config,\n fields: matchedGlobal.fields,\n i18n,\n parentIndexPath: '',\n parentSchemaPath: globalSlug,\n payload,\n schemaMap,\n })\n }\n }\n\n return { clientFieldSchemaMap: clientSchemaMap }\n}\n"],"mappings":"AAUA,SAASA,cAAc,QAAQ;AAE/B,MAAMC,cAAA,GAAgC,CACpC;EACEC,IAAA,EAAM;EACNC,IAAA,EAAM;EACNC,QAAA,EAAU;AACZ,GACA;EACEF,IAAA,EAAM;EACNC,IAAA,EAAM;EACNC,QAAA,EAAU;AACZ,EACD;AAED;;;AAGA,OAAO,MAAMC,yBAAA,GAA6BC,IAAA;EAQxC,MAAM;IAAEC,cAAc;IAAEC,MAAM;IAAEC,UAAU;IAAEC,IAAI;IAAEC,OAAO;IAAEC;EAAS,CAAE,GAAGN,IAAA;EAEzE,MAAMO,eAAA,GAAwC,IAAIC,GAAA;EAElD,IAAIP,cAAA,EAAgB;IAClB,MAAMQ,iBAAA,GAAoBP,MAAA,CAAOQ,WAAW,CAACC,IAAI,CAC9CC,UAAA,IAAeA,UAAA,CAAWC,IAAI,KAAKZ,cAAA;IAGtC,IAAIQ,iBAAA,EAAmB;MACrB,IAAIK,WAAA,GAAcL,iBAAA,EAAmBM,MAAA,IAAU,EAAE;MAEjD,IAAIN,iBAAA,CAAkBO,IAAI,IAAI,CAACP,iBAAA,CAAkBO,IAAI,CAACC,oBAAoB,EAAE;;QACxEtB,cAAc,CAAC,EAAE,CAAqBuB,KAAK,GAAGd,IAAA,CAAKe,CAAC,CAAC;QACrDxB,cAAc,CAAC,EAAE,CAAqBuB,KAAK,GAAGd,IAAA,CAAKe,CAAC,CAAC;QACvDL,WAAA,GAAcnB,cAAA,CAAeyB,MAAM,CAACN,WAAA;MACtC;MAEAP,eAAA,CAAgBc,GAAG,CAACpB,cAAA,EAAgB;QAClCc,MAAA,EAAQD;MACV;MAEApB,cAAA,CAAe;QACba,eAAA;QACAL,MAAA;QACAa,MAAA,EAAQD,WAAA;QACRV,IAAA;QACAkB,eAAA,EAAiB;QACjBC,gBAAA,EAAkBtB,cAAA;QAClBI,OAAA;QACAC;MACF;IACF;EACF,OAAO,IAAIH,UAAA,EAAY;IACrB,MAAMqB,aAAA,GAAgBtB,MAAA,CAAOuB,OAAO,CAACd,IAAI,CAAEe,MAAA,IAAWA,MAAA,CAAOb,IAAI,KAAKV,UAAA;IAEtE,IAAIqB,aAAA,EAAe;MACjBjB,eAAA,CAAgBc,GAAG,CAAClB,UAAA,EAAY;QAC9BY,MAAA,EAAQS,aAAA,CAAcT;MACxB;MAEArB,cAAA,CAAe;QACba,eAAA;QACAL,MAAA;QACAa,MAAA,EAAQS,aAAA,CAAcT,MAAM;QAC5BX,IAAA;QACAkB,eAAA,EAAiB;QACjBC,gBAAA,EAAkBpB,UAAA;QAClBE,OAAA;QACAC;MACF;IACF;EACF;EAEA,OAAO;IAAEqB,oBAAA,EAAsBpB;EAAgB;AACjD","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["traverseFields","baseAuthFields","name","type","required","buildClientFieldSchemaMap","args","collectionSlug","config","globalSlug","i18n","payload","schemaMap","clientSchemaMap","Map","matchedCollection","collections","find","collection","slug","fieldsToSet","fields","auth","disableLocalStrategy","label","t","concat","set","parentIndexPath","parentSchemaPath","matchedGlobal","globals","global","clientFieldSchemaMap"],"sources":["../../../src/utilities/buildClientFieldSchemaMap/index.ts"],"sourcesContent":["import type { I18n } from '@payloadcms/translations'\nimport type {\n ClientConfig,\n ClientField,\n ClientFieldSchemaMap,\n FieldSchemaMap,\n Payload,\n TextFieldClient,\n} from 'payload'\n\nimport { traverseFields } from './traverseFields.js'\n\nconst baseAuthFields: ClientField[] = [\n {\n name: 'password',\n type: 'text',\n required: true,\n },\n {\n name: 'confirm-password',\n type: 'text',\n required: true,\n },\n]\n\n/**\n * Flattens the config fields into a map of field schemas\n */\nexport const buildClientFieldSchemaMap = (args: {\n collectionSlug?: string\n config: ClientConfig\n globalSlug?: string\n i18n: I18n\n payload: Payload\n schemaMap: FieldSchemaMap\n}): { clientFieldSchemaMap: ClientFieldSchemaMap } => {\n const { collectionSlug, config, globalSlug, i18n, payload, schemaMap } = args\n\n const clientSchemaMap: ClientFieldSchemaMap = new Map()\n\n if (collectionSlug) {\n const matchedCollection = config.collections.find(\n (collection) => collection.slug === collectionSlug,\n )\n\n if (matchedCollection) {\n let fieldsToSet = matchedCollection?.fields || []\n\n if (matchedCollection.auth && !matchedCollection.auth.disableLocalStrategy) {\n ;(baseAuthFields[0] as TextFieldClient).label = i18n.t('general:password')\n ;(baseAuthFields[1] as TextFieldClient).label = i18n.t('authentication:confirmPassword')\n // Place these fields _last_ to ensure they do not disrupt field paths in the field schema map\n fieldsToSet = fieldsToSet.concat(baseAuthFields)\n }\n\n clientSchemaMap.set(collectionSlug, {\n fields: fieldsToSet,\n })\n\n traverseFields({\n clientSchemaMap,\n config,\n fields: fieldsToSet,\n i18n,\n parentIndexPath: '',\n parentSchemaPath: collectionSlug,\n payload,\n schemaMap,\n })\n }\n } else if (globalSlug) {\n const matchedGlobal = config.globals.find((global) => global.slug === globalSlug)\n\n if (matchedGlobal) {\n clientSchemaMap.set(globalSlug, {\n fields: matchedGlobal.fields,\n })\n\n traverseFields({\n clientSchemaMap,\n config,\n fields: matchedGlobal.fields,\n i18n,\n parentIndexPath: '',\n parentSchemaPath: globalSlug,\n payload,\n schemaMap,\n })\n }\n }\n\n return { clientFieldSchemaMap: clientSchemaMap }\n}\n"],"mappings":"AAUA,SAASA,cAAc,QAAQ;AAE/B,MAAMC,cAAA,GAAgC,CACpC;EACEC,IAAA,EAAM;EACNC,IAAA,EAAM;EACNC,QAAA,EAAU;AACZ,GACA;EACEF,IAAA,EAAM;EACNC,IAAA,EAAM;EACNC,QAAA,EAAU;AACZ,EACD;AAED;;;AAGA,OAAO,MAAMC,yBAAA,GAA6BC,IAAA;EAQxC,MAAM;IAAEC,cAAc;IAAEC,MAAM;IAAEC,UAAU;IAAEC,IAAI;IAAEC,OAAO;IAAEC;EAAS,CAAE,GAAGN,IAAA;EAEzE,MAAMO,eAAA,GAAwC,IAAIC,GAAA;EAElD,IAAIP,cAAA,EAAgB;IAClB,MAAMQ,iBAAA,GAAoBP,MAAA,CAAOQ,WAAW,CAACC,IAAI,CAC9CC,UAAA,IAAeA,UAAA,CAAWC,IAAI,KAAKZ,cAAA;IAGtC,IAAIQ,iBAAA,EAAmB;MACrB,IAAIK,WAAA,GAAcL,iBAAA,EAAmBM,MAAA,IAAU,EAAE;MAEjD,IAAIN,iBAAA,CAAkBO,IAAI,IAAI,CAACP,iBAAA,CAAkBO,IAAI,CAACC,oBAAoB,EAAE;;QACxEtB,cAAc,CAAC,EAAE,CAAqBuB,KAAK,GAAGd,IAAA,CAAKe,CAAC,CAAC;QACrDxB,cAAc,CAAC,EAAE,CAAqBuB,KAAK,GAAGd,IAAA,CAAKe,CAAC,CAAC;QACvD;QACAL,WAAA,GAAcA,WAAA,CAAYM,MAAM,CAACzB,cAAA;MACnC;MAEAY,eAAA,CAAgBc,GAAG,CAACpB,cAAA,EAAgB;QAClCc,MAAA,EAAQD;MACV;MAEApB,cAAA,CAAe;QACba,eAAA;QACAL,MAAA;QACAa,MAAA,EAAQD,WAAA;QACRV,IAAA;QACAkB,eAAA,EAAiB;QACjBC,gBAAA,EAAkBtB,cAAA;QAClBI,OAAA;QACAC;MACF;IACF;EACF,OAAO,IAAIH,UAAA,EAAY;IACrB,MAAMqB,aAAA,GAAgBtB,MAAA,CAAOuB,OAAO,CAACd,IAAI,CAAEe,MAAA,IAAWA,MAAA,CAAOb,IAAI,KAAKV,UAAA;IAEtE,IAAIqB,aAAA,EAAe;MACjBjB,eAAA,CAAgBc,GAAG,CAAClB,UAAA,EAAY;QAC9BY,MAAA,EAAQS,aAAA,CAAcT;MACxB;MAEArB,cAAA,CAAe;QACba,eAAA;QACAL,MAAA;QACAa,MAAA,EAAQS,aAAA,CAAcT,MAAM;QAC5BX,IAAA;QACAkB,eAAA,EAAiB;QACjBC,gBAAA,EAAkBpB,UAAA;QAClBE,OAAA;QACAC;MACF;IACF;EACF;EAEA,OAAO;IAAEqB,oBAAA,EAAsBpB;EAAgB;AACjD","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utilities/buildFieldSchemaMap/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,KAAK,EAAS,cAAc,EAAE,eAAe,EAAa,MAAM,SAAS,CAAA;AAqBhF;;GAEG;AACH,eAAO,MAAM,mBAAmB,SAAU;IACxC,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,MAAM,EAAE,eAAe,CAAA;IACvB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,IAAI,EAAE,IAAI,CAAA;CACX,KAAG;IAAE,cAAc,EAAE,cAAc,CAAA;CAoDnC,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utilities/buildFieldSchemaMap/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,KAAK,EAAS,cAAc,EAAE,eAAe,EAAa,MAAM,SAAS,CAAA;AAqBhF;;GAEG;AACH,eAAO,MAAM,mBAAmB,SAAU;IACxC,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,MAAM,EAAE,eAAe,CAAA;IACvB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,IAAI,EAAE,IAAI,CAAA;CACX,KAAG;IAAE,cAAc,EAAE,cAAc,CAAA;CAqDnC,CAAA"}
@@ -30,7 +30,8 @@ export const buildFieldSchemaMap = args => {
30
30
  ;
31
31
  baseAuthFields[0].label = i18n.t('general:password');
32
32
  baseAuthFields[1].label = i18n.t('authentication:confirmPassword');
33
- fieldsToSet = baseAuthFields.concat(fieldsToSet);
33
+ // Place these fields _last_ to ensure they do not disrupt field paths in the field schema map
34
+ fieldsToSet = fieldsToSet.concat(baseAuthFields);
34
35
  }
35
36
  schemaMap.set(collectionSlug, {
36
37
  fields: fieldsToSet
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["confirmPassword","password","traverseFields","baseAuthFields","name","type","required","validate","buildFieldSchemaMap","args","collectionSlug","config","globalSlug","i18n","schemaMap","Map","matchedCollection","collections","find","collection","slug","fieldsToSet","fields","auth","disableLocalStrategy","label","t","concat","set","parentIndexPath","parentSchemaPath","matchedGlobal","globals","global","fieldSchemaMap"],"sources":["../../../src/utilities/buildFieldSchemaMap/index.ts"],"sourcesContent":["import type { I18n } from '@payloadcms/translations'\nimport type { Field, FieldSchemaMap, SanitizedConfig, TextField } from 'payload'\n\nimport { confirmPassword, password } from 'payload/shared'\n\nimport { traverseFields } from './traverseFields.js'\n\nconst baseAuthFields: Field[] = [\n {\n name: 'password',\n type: 'text',\n required: true,\n validate: password,\n },\n {\n name: 'confirm-password',\n type: 'text',\n required: true,\n validate: confirmPassword,\n },\n]\n\n/**\n * Flattens the config fields into a map of field schemas\n */\nexport const buildFieldSchemaMap = (args: {\n collectionSlug?: string\n config: SanitizedConfig\n globalSlug?: string\n i18n: I18n\n}): { fieldSchemaMap: FieldSchemaMap } => {\n const { collectionSlug, config, globalSlug, i18n } = args\n\n const schemaMap: FieldSchemaMap = new Map()\n\n if (collectionSlug) {\n const matchedCollection = config.collections.find(\n (collection) => collection.slug === collectionSlug,\n )\n\n if (matchedCollection) {\n let fieldsToSet = matchedCollection?.fields || []\n\n if (matchedCollection.auth && !matchedCollection.auth.disableLocalStrategy) {\n ;(baseAuthFields[0] as TextField).label = i18n.t('general:password')\n ;(baseAuthFields[1] as TextField).label = i18n.t('authentication:confirmPassword')\n fieldsToSet = baseAuthFields.concat(fieldsToSet)\n }\n\n schemaMap.set(collectionSlug, {\n fields: fieldsToSet,\n })\n\n traverseFields({\n config,\n fields: fieldsToSet,\n i18n,\n parentIndexPath: '',\n parentSchemaPath: collectionSlug,\n schemaMap,\n })\n }\n } else if (globalSlug) {\n const matchedGlobal = config.globals.find((global) => global.slug === globalSlug)\n\n if (matchedGlobal) {\n schemaMap.set(globalSlug, {\n fields: matchedGlobal.fields,\n })\n\n traverseFields({\n config,\n fields: matchedGlobal.fields,\n i18n,\n parentIndexPath: '',\n parentSchemaPath: globalSlug,\n schemaMap,\n })\n }\n }\n\n return { fieldSchemaMap: schemaMap }\n}\n"],"mappings":"AAGA,SAASA,eAAe,EAAEC,QAAQ,QAAQ;AAE1C,SAASC,cAAc,QAAQ;AAE/B,MAAMC,cAAA,GAA0B,CAC9B;EACEC,IAAA,EAAM;EACNC,IAAA,EAAM;EACNC,QAAA,EAAU;EACVC,QAAA,EAAUN;AACZ,GACA;EACEG,IAAA,EAAM;EACNC,IAAA,EAAM;EACNC,QAAA,EAAU;EACVC,QAAA,EAAUP;AACZ,EACD;AAED;;;AAGA,OAAO,MAAMQ,mBAAA,GAAuBC,IAAA;EAMlC,MAAM;IAAEC,cAAc;IAAEC,MAAM;IAAEC,UAAU;IAAEC;EAAI,CAAE,GAAGJ,IAAA;EAErD,MAAMK,SAAA,GAA4B,IA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":3,"file":"index.js","names":["confirmPassword","password","traverseFields","baseAuthFields","name","type","required","validate","buildFieldSchemaMap","args","collectionSlug","config","globalSlug","i18n","schemaMap","Map","matchedCollection","collections","find","collection","slug","fieldsToSet","fields","auth","disableLocalStrategy","label","t","concat","set","parentIndexPath","parentSchemaPath","matchedGlobal","globals","global","fieldSchemaMap"],"sources":["../../../src/utilities/buildFieldSchemaMap/index.ts"],"sourcesContent":["import type { I18n } from '@payloadcms/translations'\nimport type { Field, FieldSchemaMap, SanitizedConfig, TextField } from 'payload'\n\nimport { confirmPassword, password } from 'payload/shared'\n\nimport { traverseFields } from './traverseFields.js'\n\nconst baseAuthFields: Field[] = [\n {\n name: 'password',\n type: 'text',\n required: true,\n validate: password,\n },\n {\n name: 'confirm-password',\n type: 'text',\n required: true,\n validate: confirmPassword,\n },\n]\n\n/**\n * Flattens the config fields into a map of field schemas\n */\nexport const buildFieldSchemaMap = (args: {\n collectionSlug?: string\n config: SanitizedConfig\n globalSlug?: string\n i18n: I18n\n}): { fieldSchemaMap: FieldSchemaMap } => {\n const { collectionSlug, config, globalSlug, i18n } = args\n\n const schemaMap: FieldSchemaMap = new Map()\n\n if (collectionSlug) {\n const matchedCollection = config.collections.find(\n (collection) => collection.slug === collectionSlug,\n )\n\n if (matchedCollection) {\n let fieldsToSet = matchedCollection?.fields || []\n\n if (matchedCollection.auth && !matchedCollection.auth.disableLocalStrategy) {\n ;(baseAuthFields[0] as TextField).label = i18n.t('general:password')\n ;(baseAuthFields[1] as TextField).label = i18n.t('authentication:confirmPassword')\n // Place these fields _last_ to ensure they do not disrupt field paths in the field schema map\n fieldsToSet = fieldsToSet.concat(baseAuthFields)\n }\n\n schemaMap.set(collectionSlug, {\n fields: fieldsToSet,\n })\n\n traverseFields({\n config,\n fields: fieldsToSet,\n i18n,\n parentIndexPath: '',\n parentSchemaPath: collectionSlug,\n schemaMap,\n })\n }\n } else if (globalSlug) {\n const matchedGlobal = config.globals.find((global) => global.slug === globalSlug)\n\n if (matchedGlobal) {\n schemaMap.set(globalSlug, {\n fields: matchedGlobal.fields,\n })\n\n traverseFields({\n config,\n fields: matchedGlobal.fields,\n i18n,\n parentIndexPath: '',\n parentSchemaPath: globalSlug,\n schemaMap,\n })\n }\n }\n\n return { fieldSchemaMap: schemaMap }\n}\n"],"mappings":"AAGA,SAASA,eAAe,EAAEC,QAAQ,QAAQ;AAE1C,SAASC,cAAc,QAAQ;AAE/B,MAAMC,cAAA,GAA0B,CAC9B;EACEC,IAAA,EAAM;EACNC,IAAA,EAAM;EACNC,QAAA,EAAU;EACVC,QAAA,EAAUN;AACZ,GACA;EACEG,IAAA,EAAM;EACNC,IAAA,EAAM;EACNC,QAAA,EAAU;EACVC,QAAA,EAAUP;AACZ,EACD;AAED;;;AAGA,OAAO,MAAMQ,mBAAA,GAAuBC,IAAA;EAMlC,MAAM;IAAEC,cAAc;IAAEC,MAAM;IAAEC,UAAU;IAAEC;EAAI,CAAE,GAAGJ,IAAA;EAErD,MAAMK,SAAA,GAA4B,IAAIC,GAAA;EAEtC,IAAIL,cAAA,EAAgB;IAClB,MAAMM,iBAAA,GAAoBL,MAAA,CAAOM,WAAW,CAACC,IAAI,CAC9CC,UAAA,IAAeA,UAAA,CAAWC,IAAI,KAAKV,cAAA;IAGtC,IAAIM,iBAAA,EAAmB;MACrB,IAAIK,WAAA,GAAcL,iBAAA,EAAmBM,MAAA,IAAU,EAAE;MAEjD,IAAIN,iBAAA,CAAkBO,IAAI,IAAI,CAACP,iBAAA,CAAkBO,IAAI,CAACC,oBAAoB,EAAE;;QACxErB,cAAc,CAAC,EAAE,CAAesB,KAAK,GAAGZ,IAAA,CAAKa,CAAC,CAAC;QAC/CvB,cAAc,CAAC,EAAE,CAAesB,KAAK,GAAGZ,IAAA,CAAKa,CAAC,CAAC;QACjD;QACAL,WAAA,GAAcA,WAAA,CAAYM,MAAM,CAACxB,cAAA;MACnC;MAEAW,SAAA,CAAUc,GAAG,CAAClB,cAAA,EAAgB;QAC5BY,MAAA,EAAQD;MACV;MAEAnB,cAAA,CAAe;QACbS,MAAA;QACAW,MAAA,EAAQD,WAAA;QACRR,IAAA;QACAgB,eAAA,EAAiB;QACjBC,gBAAA,EAAkBpB,cAAA;QAClBI;MACF;IACF;EACF,OAAO,IAAIF,UAAA,EAAY;IACrB,MAAMmB,aAAA,GAAgBpB,MAAA,CAAOqB,OAAO,CAACd,IAAI,CAAEe,MAAA,IAAWA,MAAA,CAAOb,IAAI,KAAKR,UAAA;IAEtE,IAAImB,aAAA,EAAe;MACjBjB,SAAA,CAAUc,GAAG,CAAChB,UAAA,EAAY;QACxBU,MAAA,EAAQS,aAAA,CAAcT;MACxB;MAEApB,cAAA,CAAe;QACbS,MAAA;QACAW,MAAA,EAAQS,aAAA,CAAcT,MAAM;QAC5BT,IAAA;QACAgB,eAAA,EAAiB;QACjBC,gBAAA,EAAkBlB,UAAA;QAClBE;MACF;IACF;EACF;EAEA,OAAO;IAAEoB,cAAA,EAAgBpB;EAAU;AACrC","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/ui",
3
- "version": "3.31.0-canary.0",
3
+ "version": "3.31.0",
4
4
  "homepage": "https://payloadcms.com",
5
5
  "repository": {
6
6
  "type": "git",
@@ -132,7 +132,7 @@
132
132
  "ts-essentials": "10.0.3",
133
133
  "use-context-selector": "2.0.0",
134
134
  "uuid": "10.0.0",
135
- "@payloadcms/translations": "3.31.0-canary.0"
135
+ "@payloadcms/translations": "3.31.0"
136
136
  },
137
137
  "devDependencies": {
138
138
  "@babel/cli": "7.26.4",
@@ -148,14 +148,14 @@
148
148
  "esbuild": "0.24.2",
149
149
  "esbuild-sass-plugin": "3.3.1",
150
150
  "eslint-plugin-react-compiler": "19.0.0-beta-714736e-20250131",
151
- "@payloadcms/eslint-config": "3.28.0",
152
- "payload": "3.31.0-canary.0"
151
+ "payload": "3.31.0",
152
+ "@payloadcms/eslint-config": "3.28.0"
153
153
  },
154
154
  "peerDependencies": {
155
155
  "next": "^15.2.3",
156
156
  "react": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
157
157
  "react-dom": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
158
- "payload": "3.31.0-canary.0"
158
+ "payload": "3.31.0"
159
159
  },
160
160
  "engines": {
161
161
  "node": "^18.20.2 || >=20.9.0"