@payloadcms/ui 3.0.0-beta.79 → 3.0.0-beta.81
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/elements/Autosave/index.js +1 -1
- package/dist/elements/Autosave/index.js.map +1 -1
- package/dist/elements/Nav/context.d.ts +3 -0
- package/dist/elements/Nav/context.d.ts.map +1 -1
- package/dist/elements/Nav/context.js +16 -7
- package/dist/elements/Nav/context.js.map +1 -1
- package/dist/exports/client/index.js +7 -7
- package/dist/exports/client/index.js.map +3 -3
- package/dist/exports/shared/index.d.ts +0 -1
- package/dist/exports/shared/index.d.ts.map +1 -1
- package/dist/exports/shared/index.js +2 -2
- package/dist/exports/shared/index.js.map +4 -4
- package/dist/fields/Array/index.js +1 -1
- package/dist/fields/Array/index.js.map +1 -1
- package/dist/fields/Blocks/index.js +1 -1
- package/dist/fields/Blocks/index.js.map +1 -1
- package/dist/fields/Code/index.js +1 -1
- package/dist/fields/Code/index.js.map +1 -1
- package/dist/fields/Collapsible/index.js +1 -1
- package/dist/fields/Collapsible/index.js.map +1 -1
- package/dist/fields/DateTime/index.js +1 -1
- package/dist/fields/DateTime/index.js.map +1 -1
- package/dist/fields/Group/index.js +1 -1
- package/dist/fields/Group/index.js.map +1 -1
- package/dist/fields/JSON/index.d.ts.map +1 -1
- package/dist/fields/JSON/index.js +1 -1
- package/dist/fields/JSON/index.js.map +1 -1
- package/dist/fields/Point/index.js +1 -1
- package/dist/fields/Point/index.js.map +1 -1
- package/dist/fields/Relationship/index.js +1 -1
- package/dist/fields/Relationship/index.js.map +1 -1
- package/dist/fields/Row/index.d.ts.map +1 -1
- package/dist/fields/Row/index.js +1 -1
- package/dist/fields/Row/index.js.map +1 -1
- package/dist/fields/Tabs/index.js +1 -1
- package/dist/fields/Tabs/index.js.map +1 -1
- package/dist/fields/Text/index.js +1 -1
- package/dist/fields/Text/index.js.map +1 -1
- package/dist/fields/Textarea/index.js +1 -1
- package/dist/fields/Textarea/index.js.map +1 -1
- package/dist/fields/Upload/index.js +1 -1
- package/dist/fields/Upload/index.js.map +1 -1
- package/dist/providers/Config/RenderComponent.d.ts.map +1 -1
- package/dist/providers/Config/RenderComponent.js +3 -0
- package/dist/providers/Config/RenderComponent.js.map +1 -1
- package/dist/providers/Config/createClientConfig/collections.d.ts.map +1 -1
- package/dist/providers/Config/createClientConfig/collections.js +2 -2
- package/dist/providers/Config/createClientConfig/collections.js.map +1 -1
- package/dist/providers/Config/createClientConfig/getComponent.d.ts +1 -1
- package/dist/providers/Config/createClientConfig/getComponent.d.ts.map +1 -1
- package/dist/providers/Config/createClientConfig/getComponent.js +3 -2
- package/dist/providers/Config/createClientConfig/getComponent.js.map +1 -1
- package/dist/providers/Config/createClientConfig/getCreateMappedComponent.d.ts.map +1 -1
- package/dist/providers/Config/createClientConfig/getCreateMappedComponent.js +7 -2
- package/dist/providers/Config/createClientConfig/getCreateMappedComponent.js.map +1 -1
- package/dist/providers/Config/createClientConfig/globals.d.ts.map +1 -1
- package/dist/providers/Config/createClientConfig/globals.js +1 -1
- package/dist/providers/Config/createClientConfig/globals.js.map +1 -1
- package/dist/providers/Root/index.d.ts +1 -0
- package/dist/providers/Root/index.d.ts.map +1 -1
- package/dist/providers/Root/index.js +2 -1
- package/dist/providers/Root/index.js.map +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/fields/Tabs/index.tsx"],"sourcesContent":["'use client'\nimport type { DocumentPreferences, TabsFieldProps } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { tabHasName, toKebabCase } from 'payload/shared'\nimport React, { useCallback, useEffect, useState } from 'react'\n\nimport { useCollapsible } from '../../elements/Collapsible/provider.js'\nimport { useFieldProps } from '../../forms/FieldPropsProvider/index.js'\nimport { RenderFields } from '../../forms/RenderFields/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { useDocumentInfo } from '../../providers/DocumentInfo/index.js'\nimport { usePreferences } from '../../providers/Preferences/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { FieldDescription } from '../FieldDescription/index.js'\nimport { fieldBaseClass } from '../shared/index.js'\nimport { TabComponent } from './Tab/index.js'\nimport './index.scss'\nimport { TabsProvider } from './provider.js'\n\nconst baseClass = 'tabs-field'\n\nexport { TabsProvider }\n\nconst TabsFieldComponent: React.FC<TabsFieldProps> = (props) => {\n const {\n field,\n field: {\n _path: pathFromProps,\n admin: { className, readOnly: readOnlyFromAdmin },\n tabs = [],\n },\n forceRender = false,\n readOnly: readOnlyFromTopLevelProps,\n } = props\n\n const {\n indexPath,\n path: pathFromContext,\n readOnly: readOnlyFromContext,\n schemaPath,\n siblingPermissions,\n } = useFieldProps()\n const readOnlyFromProps = readOnlyFromTopLevelProps || readOnlyFromAdmin\n\n const readOnly = readOnlyFromProps || readOnlyFromContext\n const path = pathFromContext ?? pathFromProps\n const { getPreference, setPreference } = usePreferences()\n const { preferencesKey } = useDocumentInfo()\n const { i18n } = useTranslation()\n const { isWithinCollapsible } = useCollapsible()\n const [activeTabIndex, setActiveTabIndex] = useState<number>(0)\n const tabsPrefKey = `tabs-${indexPath}`\n\n useEffect(() => {\n if (preferencesKey) {\n const getInitialPref = async () => {\n const existingPreferences: DocumentPreferences = await getPreference(preferencesKey)\n const initialIndex = path\n ? existingPreferences?.fields?.[path]?.tabIndex\n : existingPreferences?.fields?.[tabsPrefKey]?.tabIndex\n setActiveTabIndex(initialIndex || 0)\n }\n void getInitialPref()\n }\n }, [path, getPreference, preferencesKey, tabsPrefKey])\n\n const handleTabChange = useCallback(\n async (incomingTabIndex: number): Promise<void> => {\n setActiveTabIndex(incomingTabIndex)\n\n const existingPreferences: DocumentPreferences = await getPreference(preferencesKey)\n\n if (preferencesKey) {\n void setPreference(preferencesKey, {\n ...existingPreferences,\n ...(path\n ? {\n fields: {\n ...(existingPreferences?.fields || {}),\n [path]: {\n ...existingPreferences?.fields?.[path],\n tabIndex: incomingTabIndex,\n },\n },\n }\n : {\n fields: {\n ...existingPreferences?.fields,\n [tabsPrefKey]: {\n ...existingPreferences?.fields?.[tabsPrefKey],\n tabIndex: incomingTabIndex,\n },\n },\n }),\n })\n }\n },\n [preferencesKey, getPreference, setPreference, path, tabsPrefKey],\n )\n\n const activeTabConfig = tabs[activeTabIndex]\n\n function generateTabPath() {\n let tabPath = path\n if (path && tabHasName(activeTabConfig) && activeTabConfig.name) {\n tabPath = `${path}.${activeTabConfig.name}`\n } else if (!path && tabHasName(activeTabConfig) && activeTabConfig.name) {\n tabPath = activeTabConfig.name\n }\n\n return tabPath\n }\n\n return (\n <div\n className={[\n fieldBaseClass,\n className,\n baseClass,\n isWithinCollapsible && `${baseClass}--within-collapsible`,\n ]\n .filter(Boolean)\n .join(' ')}\n >\n <TabsProvider>\n <div className={`${baseClass}__tabs-wrap`}>\n <div className={`${baseClass}__tabs`}>\n {tabs.map((tab, tabIndex) => {\n return (\n <TabComponent\n isActive={activeTabIndex === tabIndex}\n key={tabIndex}\n parentPath={path}\n setIsActive={() => {\n void handleTabChange(tabIndex)\n }}\n tab={tab}\n />\n )\n })}\n </div>\n </div>\n <div className={`${baseClass}__content-wrap`}>\n {activeTabConfig && (\n <div\n className={[\n `${baseClass}__tab`,\n activeTabConfig.label &&\n `${baseClass}__tabConfigLabel-${toKebabCase(\n getTranslation(activeTabConfig.label, i18n),\n )}`,\n ]\n .filter(Boolean)\n .join(' ')}\n >\n <FieldDescription Description={field?.admin?.components?.Description} />\n <RenderFields\n fields={activeTabConfig.fields}\n forceRender={forceRender}\n key={\n activeTabConfig.label\n ? getTranslation(activeTabConfig.label, i18n)\n : activeTabConfig['name']\n }\n margins=\"small\"\n path={generateTabPath()}\n permissions={\n 'name' in activeTabConfig && siblingPermissions?.[activeTabConfig.name]?.fields\n ? siblingPermissions[activeTabConfig.name]?.fields\n : siblingPermissions\n }\n readOnly={readOnly}\n schemaPath={`${schemaPath ? `${schemaPath}` : ''}${tabHasName(activeTabConfig) && activeTabConfig.name ? `.${activeTabConfig.name}` : ''}`}\n />\n </div>\n )}\n </div>\n </TabsProvider>\n </div>\n )\n}\n\nexport const TabsField = withCondition(TabsFieldComponent)\n"],"names":["getTranslation","tabHasName","toKebabCase","React","useCallback","useEffect","useState","useCollapsible","useFieldProps","RenderFields","withCondition","useDocumentInfo","usePreferences","useTranslation","FieldDescription","fieldBaseClass","TabComponent","TabsProvider","baseClass","TabsFieldComponent","props","field","_path","pathFromProps","admin","className","readOnly","readOnlyFromAdmin","tabs","forceRender","readOnlyFromTopLevelProps","indexPath","path","pathFromContext","readOnlyFromContext","schemaPath","siblingPermissions","readOnlyFromProps","getPreference","setPreference","preferencesKey","i18n","isWithinCollapsible","activeTabIndex","setActiveTabIndex","tabsPrefKey","getInitialPref","existingPreferences","initialIndex","fields","tabIndex","handleTabChange","incomingTabIndex","activeTabConfig","generateTabPath","tabPath","name","div","filter","Boolean","join","map","tab","isActive","parentPath","setIsActive","label","Description","components","margins","permissions","TabsField"],"mappings":"AAAA;;AAGA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,SAASC,UAAU,EAAEC,WAAW,QAAQ,iBAAgB;AACxD,OAAOC,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAE/D,SAASC,cAAc,QAAQ,yCAAwC;AACvE,SAASC,aAAa,QAAQ,0CAAyC;AACvE,SAASC,YAAY,QAAQ,oCAAmC;AAChE,SAASC,aAAa,QAAQ,qCAAoC;AAClE,SAASC,eAAe,QAAQ,wCAAuC;AACvE,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,gBAAgB,QAAQ,+BAA8B;AAC/D,SAASC,cAAc,QAAQ,qBAAoB;AACnD,SAASC,YAAY,QAAQ,iBAAgB;AAC7C,OAAO,eAAc;AACrB,SAASC,YAAY,QAAQ,gBAAe;AAE5C,MAAMC,YAAY;AAElB,SAASD,YAAY,GAAE;AAEvB,MAAME,qBA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AACI;wBACChC,WAAW;4BACT,CAAC,EAAEP,UAAU,KAAK,CAAC;4BACnBmC,gBAAgBa,KAAK,IACnB,CAAC,EAAEhD,UAAU,iBAAiB,EAAEhB,YAC9BF,eAAeqD,gBAAgBa,KAAK,EAAEzB,OACtC,CAAC;yBACN,CACEiB,MAAM,CAACC,SACPC,IAAI,CAAC;;0CAER,KAAC9C;gCAAiBqD,aAAa9C,OAAOG,OAAO4C,YAAYD;;0CACzD,KAAC1D;gCACCwC,QAAQI,gBAAgBJ,MAAM;gCAC9BpB,aAAaA;gCAMbwC,SAAQ;gCACRrC,MAAMsB;gCACNgB,aACE,UAAUjB,mBAAmBjB,oBAAoB,CAACiB,gBAAgBG,IAAI,CAAC,EAAEP,SACrEb,kBAAkB,CAACiB,gBAAgBG,IAAI,CAAC,EAAEP,SAC1Cb;gCAENV,UAAUA;gCACVS,YAAY,CAAC,EAAEA,aAAa,CAAC,EAAEA,WAAW,CAAC,GAAG,GAAG,EAAElC,WAAWoD,oBAAoBA,gBAAgBG,IAAI,GAAG,CAAC,CAAC,EAAEH,gBAAgBG,IAAI,CAAC,CAAC,GAAG,GAAG,CAAC;+BAZxIH,gBAAgBa,KAAK,GACjBlE,eAAeqD,gBAAgBa,KAAK,EAAEzB,QACtCY,eAAe,CAAC,OAAO;;;;;;;AAkB7C;AAEA,OAAO,MAAMkB,YAAY7D,cAAcS,oBAAmB"}
|
|
1
|
+
{"version":3,"sources":["../../../src/fields/Tabs/index.tsx"],"sourcesContent":["'use client'\nimport type { DocumentPreferences, TabsFieldProps } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { tabHasName, toKebabCase } from 'payload/shared'\nimport React, { useCallback, useEffect, useState } from 'react'\n\nimport { useCollapsible } from '../../elements/Collapsible/provider.js'\nimport { useFieldProps } from '../../forms/FieldPropsProvider/index.js'\nimport { RenderFields } from '../../forms/RenderFields/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { useDocumentInfo } from '../../providers/DocumentInfo/index.js'\nimport { usePreferences } from '../../providers/Preferences/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { FieldDescription } from '../FieldDescription/index.js'\nimport { fieldBaseClass } from '../shared/index.js'\nimport { TabComponent } from './Tab/index.js'\nimport './index.scss'\nimport { TabsProvider } from './provider.js'\n\nconst baseClass = 'tabs-field'\n\nexport { TabsProvider }\n\nconst TabsFieldComponent: React.FC<TabsFieldProps> = (props) => {\n const {\n field,\n field: {\n _path: pathFromProps,\n admin: { className, readOnly: readOnlyFromAdmin } = {},\n tabs = [],\n },\n forceRender = false,\n readOnly: readOnlyFromTopLevelProps,\n } = props\n\n const {\n indexPath,\n path: pathFromContext,\n readOnly: readOnlyFromContext,\n schemaPath,\n siblingPermissions,\n } = useFieldProps()\n const readOnlyFromProps = readOnlyFromTopLevelProps || readOnlyFromAdmin\n\n const readOnly = readOnlyFromProps || readOnlyFromContext\n const path = pathFromContext ?? pathFromProps\n const { getPreference, setPreference } = usePreferences()\n const { preferencesKey } = useDocumentInfo()\n const { i18n } = useTranslation()\n const { isWithinCollapsible } = useCollapsible()\n const [activeTabIndex, setActiveTabIndex] = useState<number>(0)\n const tabsPrefKey = `tabs-${indexPath}`\n\n useEffect(() => {\n if (preferencesKey) {\n const getInitialPref = async () => {\n const existingPreferences: DocumentPreferences = await getPreference(preferencesKey)\n const initialIndex = path\n ? existingPreferences?.fields?.[path]?.tabIndex\n : existingPreferences?.fields?.[tabsPrefKey]?.tabIndex\n setActiveTabIndex(initialIndex || 0)\n }\n void getInitialPref()\n }\n }, [path, getPreference, preferencesKey, tabsPrefKey])\n\n const handleTabChange = useCallback(\n async (incomingTabIndex: number): Promise<void> => {\n setActiveTabIndex(incomingTabIndex)\n\n const existingPreferences: DocumentPreferences = await getPreference(preferencesKey)\n\n if (preferencesKey) {\n void setPreference(preferencesKey, {\n ...existingPreferences,\n ...(path\n ? {\n fields: {\n ...(existingPreferences?.fields || {}),\n [path]: {\n ...existingPreferences?.fields?.[path],\n tabIndex: incomingTabIndex,\n },\n },\n }\n : {\n fields: {\n ...existingPreferences?.fields,\n [tabsPrefKey]: {\n ...existingPreferences?.fields?.[tabsPrefKey],\n tabIndex: incomingTabIndex,\n },\n },\n }),\n })\n }\n },\n [preferencesKey, getPreference, setPreference, path, tabsPrefKey],\n )\n\n const activeTabConfig = tabs[activeTabIndex]\n\n function generateTabPath() {\n let tabPath = path\n if (path && tabHasName(activeTabConfig) && activeTabConfig.name) {\n tabPath = `${path}.${activeTabConfig.name}`\n } else if (!path && tabHasName(activeTabConfig) && activeTabConfig.name) {\n tabPath = activeTabConfig.name\n }\n\n return tabPath\n }\n\n return (\n <div\n className={[\n fieldBaseClass,\n className,\n baseClass,\n isWithinCollapsible && `${baseClass}--within-collapsible`,\n ]\n .filter(Boolean)\n .join(' ')}\n >\n <TabsProvider>\n <div className={`${baseClass}__tabs-wrap`}>\n <div className={`${baseClass}__tabs`}>\n {tabs.map((tab, tabIndex) => {\n return (\n <TabComponent\n isActive={activeTabIndex === tabIndex}\n key={tabIndex}\n parentPath={path}\n setIsActive={() => {\n void handleTabChange(tabIndex)\n }}\n tab={tab}\n />\n )\n })}\n </div>\n </div>\n <div className={`${baseClass}__content-wrap`}>\n {activeTabConfig && (\n <div\n className={[\n `${baseClass}__tab`,\n activeTabConfig.label &&\n `${baseClass}__tabConfigLabel-${toKebabCase(\n getTranslation(activeTabConfig.label, i18n),\n )}`,\n ]\n .filter(Boolean)\n .join(' ')}\n >\n <FieldDescription Description={field?.admin?.components?.Description} />\n <RenderFields\n fields={activeTabConfig.fields}\n forceRender={forceRender}\n key={\n activeTabConfig.label\n ? getTranslation(activeTabConfig.label, i18n)\n : activeTabConfig['name']\n }\n margins=\"small\"\n path={generateTabPath()}\n permissions={\n 'name' in activeTabConfig && siblingPermissions?.[activeTabConfig.name]?.fields\n ? siblingPermissions[activeTabConfig.name]?.fields\n : siblingPermissions\n }\n readOnly={readOnly}\n schemaPath={`${schemaPath ? `${schemaPath}` : ''}${tabHasName(activeTabConfig) && activeTabConfig.name ? `.${activeTabConfig.name}` : ''}`}\n />\n </div>\n )}\n </div>\n </TabsProvider>\n </div>\n )\n}\n\nexport const TabsField = withCondition(TabsFieldComponent)\n"],"names":["getTranslation","tabHasName","toKebabCase","React","useCallback","useEffect","useState","useCollapsible","useFieldProps","RenderFields","withCondition","useDocumentInfo","usePreferences","useTranslation","FieldDescription","fieldBaseClass","TabComponent","TabsProvider","baseClass","TabsFieldComponent","props","field","_path","pathFromProps","admin","className","readOnly","readOnlyFromAdmin","tabs","forceRender","readOnlyFromTopLevelProps","indexPath","path","pathFromContext","readOnlyFromContext","schemaPath","siblingPermissions","readOnlyFromProps","getPreference","setPreference","preferencesKey","i18n","isWithinCollapsible","activeTabIndex","setActiveTabIndex","tabsPrefKey","getInitialPref","existingPreferences","initialIndex","fields","tabIndex","handleTabChange","incomingTabIndex","activeTabConfig","generateTabPath","tabPath","name","div","filter","Boolean","join","map","tab","isActive","parentPath","setIsActive","label","Description","components","margins","permissions","TabsField"],"mappings":"AAAA;;AAGA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,SAASC,UAAU,EAAEC,WAAW,QAAQ,iBAAgB;AACxD,OAAOC,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAE/D,SAASC,cAAc,QAAQ,yCAAwC;AACvE,SAASC,aAAa,QAAQ,0CAAyC;AACvE,SAASC,YAAY,QAAQ,oCAAmC;AAChE,SAASC,aAAa,QAAQ,qCAAoC;AAClE,SAASC,eAAe,QAAQ,wCAAuC;AACvE,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,gBAAgB,QAAQ,+BAA8B;AAC/D,SAASC,cAAc,QAAQ,qBAAoB;AACnD,SAASC,YAAY,QAAQ,iBAAgB;AAC7C,OAAO,eAAc;AACrB,SAASC,YAAY,QAAQ,gBAAe;AAE5C,MAAMC,YAAY;AAElB,SAASD,YAAY,GA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EP,UAAU,cAAc,CAAC;8BACzCmC,iCACC,MAACI;wBACChC,WAAW;4BACT,CAAC,EAAEP,UAAU,KAAK,CAAC;4BACnBmC,gBAAgBa,KAAK,IACnB,CAAC,EAAEhD,UAAU,iBAAiB,EAAEhB,YAC9BF,eAAeqD,gBAAgBa,KAAK,EAAEzB,OACtC,CAAC;yBACN,CACEiB,MAAM,CAACC,SACPC,IAAI,CAAC;;0CAER,KAAC9C;gCAAiBqD,aAAa9C,OAAOG,OAAO4C,YAAYD;;0CACzD,KAAC1D;gCACCwC,QAAQI,gBAAgBJ,MAAM;gCAC9BpB,aAAaA;gCAMbwC,SAAQ;gCACRrC,MAAMsB;gCACNgB,aACE,UAAUjB,mBAAmBjB,oBAAoB,CAACiB,gBAAgBG,IAAI,CAAC,EAAEP,SACrEb,kBAAkB,CAACiB,gBAAgBG,IAAI,CAAC,EAAEP,SAC1Cb;gCAENV,UAAUA;gCACVS,YAAY,CAAC,EAAEA,aAAa,CAAC,EAAEA,WAAW,CAAC,GAAG,GAAG,EAAElC,WAAWoD,oBAAoBA,gBAAgBG,IAAI,GAAG,CAAC,CAAC,EAAEH,gBAAgBG,IAAI,CAAC,CAAC,GAAG,GAAG,CAAC;+BAZxIH,gBAAgBa,KAAK,GACjBlE,eAAeqD,gBAAgBa,KAAK,EAAEzB,QACtCY,eAAe,CAAC,OAAO;;;;;;;AAkB7C;AAEA,OAAO,MAAMkB,YAAY7D,cAAcS,oBAAmB"}
|
|
@@ -11,7 +11,7 @@ import { TextInput } from './Input.js';
|
|
|
11
11
|
import './index.scss';
|
|
12
12
|
export { TextInput };
|
|
13
13
|
const TextFieldComponent = (props)=>{
|
|
14
|
-
const { field, field: { name, _path: pathFromProps, admin: { className, description, placeholder, readOnly: readOnlyFromAdmin, rtl, style, width }, hasMany, label, localized, maxLength, maxRows, minLength, minRows, required }, inputRef, readOnly: readOnlyFromTopLevelProps, validate } = props;
|
|
14
|
+
const { field, field: { name, _path: pathFromProps, admin: { className, description, placeholder, readOnly: readOnlyFromAdmin, rtl, style, width } = {}, hasMany, label, localized, maxLength, maxRows, minLength, minRows, required }, inputRef, readOnly: readOnlyFromTopLevelProps, validate } = props;
|
|
15
15
|
const readOnlyFromProps = readOnlyFromTopLevelProps || readOnlyFromAdmin;
|
|
16
16
|
const locale = useLocale();
|
|
17
17
|
const { config: { localization: localizationConfig } } = useConfig();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/fields/Text/index.tsx"],"sourcesContent":["'use client'\nimport type { TextFieldProps } from 'payload'\n\nimport React, { useCallback, useEffect, useState } from 'react'\n\nimport type { Option } from '../../elements/ReactSelect/types.js'\nimport type { TextInputProps } from './types.js'\n\nimport { useFieldProps } from '../../forms/FieldPropsProvider/index.js'\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { useConfig } from '../../providers/Config/index.js'\nimport { useLocale } from '../../providers/Locale/index.js'\nimport { isFieldRTL } from '../shared/index.js'\nimport { TextInput } from './Input.js'\nimport './index.scss'\n\nexport { TextInput, TextInputProps }\n\nconst TextFieldComponent: React.FC<TextFieldProps> = (props) => {\n const {\n field,\n field: {\n name,\n _path: pathFromProps,\n admin: {\n className,\n description,\n placeholder,\n readOnly: readOnlyFromAdmin,\n rtl,\n style,\n width,\n },\n hasMany,\n label,\n localized,\n maxLength,\n maxRows,\n minLength,\n minRows,\n required,\n },\n inputRef,\n readOnly: readOnlyFromTopLevelProps,\n validate,\n } = props\n const readOnlyFromProps = readOnlyFromTopLevelProps || readOnlyFromAdmin\n\n const locale = useLocale()\n\n const {\n config: { localization: localizationConfig },\n } = useConfig()\n\n const memoizedValidate = useCallback(\n (value, options) => {\n if (typeof validate === 'function')\n return validate(value, { ...options, maxLength, minLength, required })\n },\n [validate, minLength, maxLength, required],\n )\n\n const { path: pathFromContext, readOnly: readOnlyFromContext } = useFieldProps()\n\n const { formInitializing, formProcessing, path, setValue, showError, value } = useField({\n path: pathFromContext ?? pathFromProps ?? name,\n validate: memoizedValidate,\n })\n\n const disabled = readOnlyFromProps || readOnlyFromContext || formProcessing || formInitializing\n\n const renderRTL = isFieldRTL({\n fieldLocalized: localized,\n fieldRTL: rtl,\n locale,\n localizationConfig: localizationConfig || undefined,\n })\n\n const [valueToRender, setValueToRender] = useState<\n { id: string; label: string; value: { value: number } }[]\n >([]) // Only for hasMany\n\n const handleHasManyChange = useCallback(\n (selectedOption) => {\n if (!disabled) {\n let newValue\n if (!selectedOption) {\n newValue = []\n } else if (Array.isArray(selectedOption)) {\n newValue = selectedOption.map((option) => option.value?.value || option.value)\n } else {\n newValue = [selectedOption.value?.value || selectedOption.value]\n }\n\n setValue(newValue)\n }\n },\n [disabled, setValue],\n )\n\n // useEffect update valueToRender:\n useEffect(() => {\n if (hasMany && Array.isArray(value)) {\n setValueToRender(\n value.map((val, index) => {\n return {\n id: `${val}${index}`, // append index to avoid duplicate keys but allow duplicate numbers\n label: `${val}`,\n value: {\n // React-select automatically uses \"label-value\" as a key, so we will get that react duplicate key warning if we just pass in the value as multiple values can be the same. So we need to append the index to the toString() of the value to avoid that warning, as it uses that as the key.\n toString: () => `${val}${index}`,\n value: val?.value || val,\n },\n }\n }),\n )\n }\n }, [value, hasMany])\n\n return (\n <TextInput\n Description={field?.admin?.components?.Description}\n Error={field?.admin?.components?.Error}\n Label={field?.admin?.components?.Label}\n afterInput={field?.admin?.components?.afterInput}\n beforeInput={field?.admin?.components?.beforeInput}\n className={className}\n description={description}\n hasMany={hasMany}\n inputRef={inputRef}\n label={label}\n maxRows={maxRows}\n minRows={minRows}\n onChange={\n hasMany\n ? handleHasManyChange\n : (e) => {\n setValue(e.target.value)\n }\n }\n path={path}\n placeholder={placeholder}\n readOnly={disabled}\n required={required}\n rtl={renderRTL}\n showError={showError}\n style={style}\n value={(value as string) || ''}\n valueToRender={valueToRender as Option[]}\n width={width}\n />\n )\n}\n\nexport const TextField = withCondition(TextFieldComponent)\n"],"names":["React","useCallback","useEffect","useState","useFieldProps","useField","withCondition","useConfig","useLocale","isFieldRTL","TextInput","TextFieldComponent","props","field","name","_path","pathFromProps","admin","className","description","placeholder","readOnly","readOnlyFromAdmin","rtl","style","width","hasMany","label","localized","maxLength","maxRows","minLength","minRows","required","inputRef","readOnlyFromTopLevelProps","validate","readOnlyFromProps","locale","config","localization","localizationConfig","memoizedValidate","value","options","path","pathFromContext","readOnlyFromContext","formInitializing","formProcessing","setValue","showError","disabled","renderRTL","fieldLocalized","fieldRTL","undefined","valueToRender","setValueToRender","handleHasManyChange","selectedOption","newValue","Array","isArray","map","option","val","index","id","toString","Description","components","Error","Label","afterInput","beforeInput","onChange","e","target","TextField"],"mappings":"AAAA;;AAGA,OAAOA,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAK/D,SAASC,aAAa,QAAQ,0CAAyC;AACvE,SAASC,QAAQ,QAAQ,gCAA+B;AACxD,SAASC,aAAa,QAAQ,qCAAoC;AAClE,SAASC,SAAS,QAAQ,kCAAiC;AAC3D,SAASC,SAAS,QAAQ,kCAAiC;AAC3D,SAASC,UAAU,QAAQ,qBAAoB;AAC/C,SAASC,SAAS,QAAQ,aAAY;AACtC,OAAO,eAAc;AAErB,SAASA,SAAS,GAAkB;AAEpC,MAAMC,qBAA+C,CAACC;IACpD,MAAM,EACJC,KAAK,EACLA,OAAO,EACLC,IAAI,EACJC,OAAOC,aAAa,EACpBC,OAAO,EACLC,SAAS,EACTC,WAAW,EACXC,WAAW,EACXC,UAAUC,iBAAiB,EAC3BC,GAAG,EACHC,KAAK,EACLC,KAAK,EACN,
|
|
1
|
+
{"version":3,"sources":["../../../src/fields/Text/index.tsx"],"sourcesContent":["'use client'\nimport type { TextFieldProps } from 'payload'\n\nimport React, { useCallback, useEffect, useState } from 'react'\n\nimport type { Option } from '../../elements/ReactSelect/types.js'\nimport type { TextInputProps } from './types.js'\n\nimport { useFieldProps } from '../../forms/FieldPropsProvider/index.js'\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { useConfig } from '../../providers/Config/index.js'\nimport { useLocale } from '../../providers/Locale/index.js'\nimport { isFieldRTL } from '../shared/index.js'\nimport { TextInput } from './Input.js'\nimport './index.scss'\n\nexport { TextInput, TextInputProps }\n\nconst TextFieldComponent: React.FC<TextFieldProps> = (props) => {\n const {\n field,\n field: {\n name,\n _path: pathFromProps,\n admin: {\n className,\n description,\n placeholder,\n readOnly: readOnlyFromAdmin,\n rtl,\n style,\n width,\n } = {},\n hasMany,\n label,\n localized,\n maxLength,\n maxRows,\n minLength,\n minRows,\n required,\n },\n inputRef,\n readOnly: readOnlyFromTopLevelProps,\n validate,\n } = props\n const readOnlyFromProps = readOnlyFromTopLevelProps || readOnlyFromAdmin\n\n const locale = useLocale()\n\n const {\n config: { localization: localizationConfig },\n } = useConfig()\n\n const memoizedValidate = useCallback(\n (value, options) => {\n if (typeof validate === 'function')\n return validate(value, { ...options, maxLength, minLength, required })\n },\n [validate, minLength, maxLength, required],\n )\n\n const { path: pathFromContext, readOnly: readOnlyFromContext } = useFieldProps()\n\n const { formInitializing, formProcessing, path, setValue, showError, value } = useField({\n path: pathFromContext ?? pathFromProps ?? name,\n validate: memoizedValidate,\n })\n\n const disabled = readOnlyFromProps || readOnlyFromContext || formProcessing || formInitializing\n\n const renderRTL = isFieldRTL({\n fieldLocalized: localized,\n fieldRTL: rtl,\n locale,\n localizationConfig: localizationConfig || undefined,\n })\n\n const [valueToRender, setValueToRender] = useState<\n { id: string; label: string; value: { value: number } }[]\n >([]) // Only for hasMany\n\n const handleHasManyChange = useCallback(\n (selectedOption) => {\n if (!disabled) {\n let newValue\n if (!selectedOption) {\n newValue = []\n } else if (Array.isArray(selectedOption)) {\n newValue = selectedOption.map((option) => option.value?.value || option.value)\n } else {\n newValue = [selectedOption.value?.value || selectedOption.value]\n }\n\n setValue(newValue)\n }\n },\n [disabled, setValue],\n )\n\n // useEffect update valueToRender:\n useEffect(() => {\n if (hasMany && Array.isArray(value)) {\n setValueToRender(\n value.map((val, index) => {\n return {\n id: `${val}${index}`, // append index to avoid duplicate keys but allow duplicate numbers\n label: `${val}`,\n value: {\n // React-select automatically uses \"label-value\" as a key, so we will get that react duplicate key warning if we just pass in the value as multiple values can be the same. So we need to append the index to the toString() of the value to avoid that warning, as it uses that as the key.\n toString: () => `${val}${index}`,\n value: val?.value || val,\n },\n }\n }),\n )\n }\n }, [value, hasMany])\n\n return (\n <TextInput\n Description={field?.admin?.components?.Description}\n Error={field?.admin?.components?.Error}\n Label={field?.admin?.components?.Label}\n afterInput={field?.admin?.components?.afterInput}\n beforeInput={field?.admin?.components?.beforeInput}\n className={className}\n description={description}\n hasMany={hasMany}\n inputRef={inputRef}\n label={label}\n maxRows={maxRows}\n minRows={minRows}\n onChange={\n hasMany\n ? handleHasManyChange\n : (e) => {\n setValue(e.target.value)\n }\n }\n path={path}\n placeholder={placeholder}\n readOnly={disabled}\n required={required}\n rtl={renderRTL}\n showError={showError}\n style={style}\n value={(value as string) || ''}\n valueToRender={valueToRender as Option[]}\n width={width}\n />\n )\n}\n\nexport const TextField = withCondition(TextFieldComponent)\n"],"names":["React","useCallback","useEffect","useState","useFieldProps","useField","withCondition","useConfig","useLocale","isFieldRTL","TextInput","TextFieldComponent","props","field","name","_path","pathFromProps","admin","className","description","placeholder","readOnly","readOnlyFromAdmin","rtl","style","width","hasMany","label","localized","maxLength","maxRows","minLength","minRows","required","inputRef","readOnlyFromTopLevelProps","validate","readOnlyFromProps","locale","config","localization","localizationConfig","memoizedValidate","value","options","path","pathFromContext","readOnlyFromContext","formInitializing","formProcessing","setValue","showError","disabled","renderRTL","fieldLocalized","fieldRTL","undefined","valueToRender","setValueToRender","handleHasManyChange","selectedOption","newValue","Array","isArray","map","option","val","index","id","toString","Description","components","Error","Label","afterInput","beforeInput","onChange","e","target","TextField"],"mappings":"AAAA;;AAGA,OAAOA,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAK/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D,OAAOI,OAAOsD,YAAYI;QACvCzD,WAAWA;QACXC,aAAaA;QACbO,SAASA;QACTQ,UAAUA;QACVP,OAAOA;QACPG,SAASA;QACTE,SAASA;QACT4C,UACElD,UACIiC,sBACA,CAACkB;YACC3B,SAAS2B,EAAEC,MAAM,CAACnC,KAAK;QACzB;QAENE,MAAMA;QACNzB,aAAaA;QACbC,UAAU+B;QACVnB,UAAUA;QACVV,KAAK8B;QACLF,WAAWA;QACX3B,OAAOA;QACPmB,OAAO,AAACA,SAAoB;QAC5Bc,eAAeA;QACfhC,OAAOA;;AAGb;AAEA,OAAO,MAAMsD,YAAYzE,cAAcK,oBAAmB"}
|
|
@@ -12,7 +12,7 @@ import { TextareaInput } from './Input.js';
|
|
|
12
12
|
import './index.scss';
|
|
13
13
|
export { TextareaInput };
|
|
14
14
|
const TextareaFieldComponent = (props)=>{
|
|
15
|
-
const { field, field: { name, _path: pathFromProps, admin: { className, description, placeholder, readOnly: readOnlyFromAdmin, rows, rtl, style, width }, label, localized, maxLength, minLength, required }, locale, readOnly: readOnlyFromTopLevelProps, validate } = props;
|
|
15
|
+
const { field, field: { name, _path: pathFromProps, admin: { className, description, placeholder, readOnly: readOnlyFromAdmin, rows, rtl, style, width } = {}, label, localized, maxLength, minLength, required }, locale, readOnly: readOnlyFromTopLevelProps, validate } = props;
|
|
16
16
|
const readOnlyFromProps = readOnlyFromTopLevelProps || readOnlyFromAdmin;
|
|
17
17
|
const { i18n } = useTranslation();
|
|
18
18
|
const { config: { localization } } = useConfig();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/fields/Textarea/index.tsx"],"sourcesContent":["'use client'\nimport type { TextareaFieldProps, TextareaFieldValidation } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport React, { useCallback } from 'react'\n\nimport type { TextAreaInputProps } from './types.js'\n\nimport { useFieldProps } from '../../forms/FieldPropsProvider/index.js'\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { useConfig } from '../../providers/Config/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { isFieldRTL } from '../shared/index.js'\nimport { TextareaInput } from './Input.js'\nimport './index.scss'\n\nexport { TextAreaInputProps, TextareaInput }\n\nconst TextareaFieldComponent: React.FC<TextareaFieldProps> = (props) => {\n const {\n field,\n field: {\n name,\n _path: pathFromProps,\n admin: {\n className,\n description,\n placeholder,\n readOnly: readOnlyFromAdmin,\n rows,\n rtl,\n style,\n width,\n },\n label,\n localized,\n maxLength,\n minLength,\n required,\n },\n locale,\n readOnly: readOnlyFromTopLevelProps,\n validate,\n } = props\n const readOnlyFromProps = readOnlyFromTopLevelProps || readOnlyFromAdmin\n\n const { i18n } = useTranslation()\n\n const {\n config: { localization },\n } = useConfig()\n\n const isRTL = isFieldRTL({\n fieldLocalized: localized,\n fieldRTL: rtl,\n locale,\n localizationConfig: localization || undefined,\n })\n\n const memoizedValidate: TextareaFieldValidation = useCallback(\n (value, options) => {\n if (typeof validate === 'function')\n return validate(value, { ...options, maxLength, minLength, required })\n },\n [validate, required, maxLength, minLength],\n )\n\n const { path: pathFromContext, readOnly: readOnlyFromContext } = useFieldProps()\n\n const { formInitializing, formProcessing, path, setValue, showError, value } = useField<string>({\n path: pathFromContext ?? pathFromProps ?? name,\n validate: memoizedValidate,\n })\n\n const disabled = readOnlyFromProps || readOnlyFromContext || formProcessing || formInitializing\n\n return (\n <TextareaInput\n Description={field?.admin?.components?.Description}\n Error={field?.admin?.components?.Error}\n Label={field?.admin?.components?.Label}\n afterInput={field?.admin?.components?.afterInput}\n beforeInput={field?.admin?.components?.beforeInput}\n className={className}\n description={description}\n label={label}\n onChange={(e) => {\n setValue(e.target.value)\n }}\n path={path}\n placeholder={getTranslation(placeholder, i18n)}\n readOnly={disabled}\n required={required}\n rows={rows}\n rtl={isRTL}\n showError={showError}\n style={style}\n value={value}\n width={width}\n />\n )\n}\n\nexport const TextareaField = withCondition(TextareaFieldComponent)\n"],"names":["getTranslation","React","useCallback","useFieldProps","useField","withCondition","useConfig","useTranslation","isFieldRTL","TextareaInput","TextareaFieldComponent","props","field","name","_path","pathFromProps","admin","className","description","placeholder","readOnly","readOnlyFromAdmin","rows","rtl","style","width","label","localized","maxLength","minLength","required","locale","readOnlyFromTopLevelProps","validate","readOnlyFromProps","i18n","config","localization","isRTL","fieldLocalized","fieldRTL","localizationConfig","undefined","memoizedValidate","value","options","path","pathFromContext","readOnlyFromContext","formInitializing","formProcessing","setValue","showError","disabled","Description","components","Error","Label","afterInput","beforeInput","onChange","e","target","TextareaField"],"mappings":"AAAA;;AAGA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,OAAOC,SAASC,WAAW,QAAQ,QAAO;AAI1C,SAASC,aAAa,QAAQ,0CAAyC;AACvE,SAASC,QAAQ,QAAQ,gCAA+B;AACxD,SAASC,aAAa,QAAQ,qCAAoC;AAClE,SAASC,SAAS,QAAQ,kCAAiC;AAC3D,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,UAAU,QAAQ,qBAAoB;AAC/C,SAASC,aAAa,QAAQ,aAAY;AAC1C,OAAO,eAAc;AAErB,SAA6BA,aAAa,GAAE;AAE5C,MAAMC,yBAAuD,CAACC;IAC5D,MAAM,EACJC,KAAK,EACLA,OAAO,EACLC,IAAI,EACJC,OAAOC,aAAa,EACpBC,OAAO,EACLC,SAAS,EACTC,WAAW,EACXC,WAAW,EACXC,UAAUC,iBAAiB,EAC3BC,IAAI,EACJC,GAAG,EACHC,KAAK,EACLC,KAAK,EACN,
|
|
1
|
+
{"version":3,"sources":["../../../src/fields/Textarea/index.tsx"],"sourcesContent":["'use client'\nimport type { TextareaFieldProps, TextareaFieldValidation } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport React, { useCallback } from 'react'\n\nimport type { TextAreaInputProps } from './types.js'\n\nimport { useFieldProps } from '../../forms/FieldPropsProvider/index.js'\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { useConfig } from '../../providers/Config/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { isFieldRTL } from '../shared/index.js'\nimport { TextareaInput } from './Input.js'\nimport './index.scss'\n\nexport { TextAreaInputProps, TextareaInput }\n\nconst TextareaFieldComponent: React.FC<TextareaFieldProps> = (props) => {\n const {\n field,\n field: {\n name,\n _path: pathFromProps,\n admin: {\n className,\n description,\n placeholder,\n readOnly: readOnlyFromAdmin,\n rows,\n rtl,\n style,\n width,\n } = {},\n label,\n localized,\n maxLength,\n minLength,\n required,\n },\n locale,\n readOnly: readOnlyFromTopLevelProps,\n validate,\n } = props\n const readOnlyFromProps = readOnlyFromTopLevelProps || readOnlyFromAdmin\n\n const { i18n } = useTranslation()\n\n const {\n config: { localization },\n } = useConfig()\n\n const isRTL = isFieldRTL({\n fieldLocalized: localized,\n fieldRTL: rtl,\n locale,\n localizationConfig: localization || undefined,\n })\n\n const memoizedValidate: TextareaFieldValidation = useCallback(\n (value, options) => {\n if (typeof validate === 'function')\n return validate(value, { ...options, maxLength, minLength, required })\n },\n [validate, required, maxLength, minLength],\n )\n\n const { path: pathFromContext, readOnly: readOnlyFromContext } = useFieldProps()\n\n const { formInitializing, formProcessing, path, setValue, showError, value } = useField<string>({\n path: pathFromContext ?? pathFromProps ?? name,\n validate: memoizedValidate,\n })\n\n const disabled = readOnlyFromProps || readOnlyFromContext || formProcessing || formInitializing\n\n return (\n <TextareaInput\n Description={field?.admin?.components?.Description}\n Error={field?.admin?.components?.Error}\n Label={field?.admin?.components?.Label}\n afterInput={field?.admin?.components?.afterInput}\n beforeInput={field?.admin?.components?.beforeInput}\n className={className}\n description={description}\n label={label}\n onChange={(e) => {\n setValue(e.target.value)\n }}\n path={path}\n placeholder={getTranslation(placeholder, i18n)}\n readOnly={disabled}\n required={required}\n rows={rows}\n rtl={isRTL}\n showError={showError}\n style={style}\n value={value}\n width={width}\n />\n )\n}\n\nexport const TextareaField = withCondition(TextareaFieldComponent)\n"],"names":["getTranslation","React","useCallback","useFieldProps","useField","withCondition","useConfig","useTranslation","isFieldRTL","TextareaInput","TextareaFieldComponent","props","field","name","_path","pathFromProps","admin","className","description","placeholder","readOnly","readOnlyFromAdmin","rows","rtl","style","width","label","localized","maxLength","minLength","required","locale","readOnlyFromTopLevelProps","validate","readOnlyFromProps","i18n","config","localization","isRTL","fieldLocalized","fieldRTL","localizationConfig","undefined","memoizedValidate","value","options","path","pathFromContext","readOnlyFromContext","formInitializing","formProcessing","setValue","showError","disabled","Description","components","Error","Label","afterInput","beforeInput","onChange","e","target","TextareaField"],"mappings":"AAAA;;AAGA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,OAAOC,SAASC,WAAW,QAAQ,QAAO;AAI1C,SAASC,aAAa,QAAQ,0CAAyC;AACvE,SAASC,QAAQ,QAAQ,gCAA+B;AACxD,SAASC,aAAa,QAAQ,qCAAoC;AAClE,SAASC,SAAS,QAAQ,kCAAiC;AAC3D,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,UAAU,QAAQ,qBAAoB;AAC/C,SAASC,aAAa,QAAQ,aAAY;AAC1C,OAAO,eAAc;AAErB,SAA6BA,aAAa,GAAE;AAE5C,MAAMC,yBAAuD,CAACC;IAC5D,MAAM,EACJC,KAAK,EACLA,OAAO,EACLC,IAAI,EACJC,OAAOC,aAAa,EACpBC,OAAO,EACLC,SAAS,EACTC,WAAW,EACXC,WAAW,EACXC,UAAUC,iBAAiB,EAC3BC,IAAI,EACJC,GAAG,EACHC,KAAK,EACLC,KAAK,EACN,GAAG,CAAC,CAAC,EACNC,KAAK,EACLC,SAAS,EACTC,SAAS,EACTC,SAAS,EACTC,QAAQ,EACT,EACDC,MAAM,EACNX,UAAUY,yBAAyB,EACnCC,QAAQ,EACT,GAAGtB;IACJ,MAAMuB,oBAAoBF,6BAA6BX;IAEvD,MAAM,EAAEc,IAAI,EAAE,GAAG5B;IAEjB,MAAM,EACJ6B,QAAQ,EAAEC,YAAY,E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UploadInput };
|
|
12
12
|
const UploadComponent = (props)=>{
|
|
13
|
-
const { field, field: { _path: pathFromProps, admin: { className, readOnly: readOnlyFromAdmin, style, width }, label, relationTo, required }, readOnly: readOnlyFromTopLevelProps, validate } = props;
|
|
13
|
+
const { field, field: { _path: pathFromProps, admin: { className, readOnly: readOnlyFromAdmin, style, width } = {}, label, relationTo, required }, readOnly: readOnlyFromTopLevelProps, validate } = props;
|
|
14
14
|
const readOnlyFromProps = readOnlyFromTopLevelProps || readOnlyFromAdmin;
|
|
15
15
|
const { config: { collections, routes: { api: apiRoute }, serverURL } } = useConfig();
|
|
16
16
|
const { permissions } = useAuth();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/fields/Upload/index.tsx"],"sourcesContent":["'use client'\n\nimport type { UploadFieldProps } from 'payload'\n\nimport React, { useCallback, useMemo } from 'react'\n\nimport type { UploadInputProps } from './Input.js'\n\nimport { useFieldProps } from '../../forms/FieldPropsProvider/index.js'\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { useAuth } from '../../providers/Auth/index.js'\nimport { useConfig } from '../../providers/Config/index.js'\nimport { UploadInput } from './Input.js'\nimport './index.scss'\n\nexport { UploadFieldProps, UploadInput }\nexport type { UploadInputProps }\n\nconst UploadComponent: React.FC<UploadFieldProps> = (props) => {\n const {\n field,\n field: {\n _path: pathFromProps,\n admin: { className, readOnly: readOnlyFromAdmin, style, width },\n label,\n relationTo,\n required,\n },\n readOnly: readOnlyFromTopLevelProps,\n validate,\n } = props\n const readOnlyFromProps = readOnlyFromTopLevelProps || readOnlyFromAdmin\n\n const {\n config: {\n collections,\n routes: { api: apiRoute },\n serverURL,\n },\n } = useConfig()\n\n const { permissions } = useAuth()\n\n const collection = collections.find((coll) => coll.slug === relationTo)\n\n const memoizedValidate = useCallback(\n (value, options) => {\n if (typeof validate === 'function') {\n return validate(value, { ...options, required })\n }\n },\n [validate, required],\n )\n\n const { path: pathFromContext, readOnly: readOnlyFromContext } = useFieldProps()\n\n // Checks if the user has permissions to create a new document in the related collection\n const canCreate = useMemo(() => {\n if (permissions?.collections && permissions.collections?.[relationTo]?.create) {\n if (permissions.collections[relationTo].create?.permission === true) {\n return true\n }\n }\n\n return false\n }, [relationTo, permissions])\n\n const { filterOptions, formInitializing, formProcessing, setValue, showError, value } =\n useField<string>({\n path: pathFromContext ?? pathFromProps,\n validate: memoizedValidate,\n })\n\n const disabled = readOnlyFromProps || readOnlyFromContext || formProcessing || formInitializing\n\n const onChange = useCallback(\n (incomingValue) => {\n const incomingID = incomingValue?.id || incomingValue\n setValue(incomingID)\n },\n [setValue],\n )\n\n if (collection.upload) {\n return (\n <UploadInput\n Description={field?.admin?.components?.Description}\n Error={field?.admin?.components?.Error}\n Label={field?.admin?.components?.Label}\n allowNewUpload={canCreate}\n api={apiRoute}\n className={className}\n collection={collection}\n filterOptions={filterOptions}\n label={label}\n onChange={onChange}\n readOnly={disabled}\n relationTo={relationTo}\n required={required}\n serverURL={serverURL}\n showError={showError}\n style={style}\n value={value}\n width={width}\n />\n )\n }\n\n return null\n}\n\nexport const UploadField = withCondition(UploadComponent)\n"],"names":["React","useCallback","useMemo","useFieldProps","useField","withCondition","useAuth","useConfig","UploadInput","UploadComponent","props","field","_path","pathFromProps","admin","className","readOnly","readOnlyFromAdmin","style","width","label","relationTo","required","readOnlyFromTopLevelProps","validate","readOnlyFromProps","config","collections","routes","api","apiRoute","serverURL","permissions","collection","find","coll","slug","memoizedValidate","value","options","path","pathFromContext","readOnlyFromContext","canCreate","create","permission","filterOptions","formInitializing","formProcessing","setValue","showError","disabled","onChange","incomingValue","incomingID","id","upload","Description","components","Error","Label","allowNewUpload","UploadField"],"mappings":"AAAA;;AAIA,OAAOA,SAASC,WAAW,EAAEC,OAAO,QAAQ,QAAO;AAInD,SAASC,aAAa,QAAQ,0CAAyC;AACvE,SAASC,QAAQ,QAAQ,gCAA+B;AACxD,SAASC,aAAa,QAAQ,qCAAoC;AAClE,SAASC,OAAO,QAAQ,gCAA+B;AACvD,SAASC,SAAS,QAAQ,kCAAiC;AAC3D,SAASC,WAAW,QAAQ,aAAY;AACxC,OAAO,eAAc;AAErB,SAA2BA,WAAW,GAAE;AAGxC,MAAMC,kBAA8C,CAACC;IACnD,MAAM,EACJC,KAAK,EACLA,OAAO,EACLC,OAAOC,aAAa,EACpBC,OAAO,EAAEC,SAAS,EAAEC,UAAUC,iBAAiB,EAAEC,KAAK,EAAEC,KAAK,EAAE,
|
|
1
|
+
{"version":3,"sources":["../../../src/fields/Upload/index.tsx"],"sourcesContent":["'use client'\n\nimport type { UploadFieldProps } from 'payload'\n\nimport React, { useCallback, useMemo } from 'react'\n\nimport type { UploadInputProps } from './Input.js'\n\nimport { useFieldProps } from '../../forms/FieldPropsProvider/index.js'\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { useAuth } from '../../providers/Auth/index.js'\nimport { useConfig } from '../../providers/Config/index.js'\nimport { UploadInput } from './Input.js'\nimport './index.scss'\n\nexport { UploadFieldProps, UploadInput }\nexport type { UploadInputProps }\n\nconst UploadComponent: React.FC<UploadFieldProps> = (props) => {\n const {\n field,\n field: {\n _path: pathFromProps,\n admin: { className, readOnly: readOnlyFromAdmin, style, width } = {},\n label,\n relationTo,\n required,\n },\n readOnly: readOnlyFromTopLevelProps,\n validate,\n } = props\n const readOnlyFromProps = readOnlyFromTopLevelProps || readOnlyFromAdmin\n\n const {\n config: {\n collections,\n routes: { api: apiRoute },\n serverURL,\n },\n } = useConfig()\n\n const { permissions } = useAuth()\n\n const collection = collections.find((coll) => coll.slug === relationTo)\n\n const memoizedValidate = useCallback(\n (value, options) => {\n if (typeof validate === 'function') {\n return validate(value, { ...options, required })\n }\n },\n [validate, required],\n )\n\n const { path: pathFromContext, readOnly: readOnlyFromContext } = useFieldProps()\n\n // Checks if the user has permissions to create a new document in the related collection\n const canCreate = useMemo(() => {\n if (permissions?.collections && permissions.collections?.[relationTo]?.create) {\n if (permissions.collections[relationTo].create?.permission === true) {\n return true\n }\n }\n\n return false\n }, [relationTo, permissions])\n\n const { filterOptions, formInitializing, formProcessing, setValue, showError, value } =\n useField<string>({\n path: pathFromContext ?? pathFromProps,\n validate: memoizedValidate,\n })\n\n const disabled = readOnlyFromProps || readOnlyFromContext || formProcessing || formInitializing\n\n const onChange = useCallback(\n (incomingValue) => {\n const incomingID = incomingValue?.id || incomingValue\n setValue(incomingID)\n },\n [setValue],\n )\n\n if (collection.upload) {\n return (\n <UploadInput\n Description={field?.admin?.components?.Description}\n Error={field?.admin?.components?.Error}\n Label={field?.admin?.components?.Label}\n allowNewUpload={canCreate}\n api={apiRoute}\n className={className}\n collection={collection}\n filterOptions={filterOptions}\n label={label}\n onChange={onChange}\n readOnly={disabled}\n relationTo={relationTo}\n required={required}\n serverURL={serverURL}\n showError={showError}\n style={style}\n value={value}\n width={width}\n />\n )\n }\n\n return null\n}\n\nexport const UploadField = withCondition(UploadComponent)\n"],"names":["React","useCallback","useMemo","useFieldProps","useField","withCondition","useAuth","useConfig","UploadInput","UploadComponent","props","field","_path","pathFromProps","admin","className","readOnly","readOnlyFromAdmin","style","width","label","relationTo","required","readOnlyFromTopLevelProps","validate","readOnlyFromProps","config","collections","routes","api","apiRoute","serverURL","permissions","collection","find","coll","slug","memoizedValidate","value","options","path","pathFromContext","readOnlyFromContext","canCreate","create","permission","filterOptions","formInitializing","formProcessing","setValue","showError","disabled","onChange","incomingValue","incomingID","id","upload","Description","components","Error","Label","allowNewUpload","UploadField"],"mappings":"AAAA;;AAIA,OAAOA,SAASC,WAAW,EAAEC,OAAO,QAAQ,QAAO;AAInD,SAASC,aAAa,QAAQ,0CAAyC;AACvE,SAASC,QAAQ,QAAQ,gCAA+B;AACxD,SAASC,aAAa,QAAQ,qCAAoC;AAClE,SAASC,OAAO,QAAQ,gCAA+B;AACvD,SAASC,SAAS,QAAQ,kCAAiC;AAC3D,SAASC,WAAW,QAAQ,aAAY;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QACzBW,UAAUa;IACZ;IAEF,MAAMc,WAAW1B,qBAAqBiB,uBAAuBM,kBAAkBD;IAE/E,MAAMK,WAAWnD,YACf,CAACoD;QACC,MAAMC,aAAaD,eAAeE,MAAMF;QACxCJ,SAASK;IACX,GACA;QAACL;KAAS;IAGZ,IAAIhB,WAAWuB,MAAM,EAAE;QACrB,qBACE,KAAChD;YACCiD,aAAa9C,OAAOG,OAAO4C,YAAYD;YACvCE,OAAOhD,OAAOG,OAAO4C,YAAYC;YACjCC,OAAOjD,OAAOG,OAAO4C,YAAYE;YACjCC,gBAAgBlB;YAChBd,KAAKC;YACLf,WAAWA;YACXkB,YAAYA;YACZa,eAAeA;YACf1B,OAAOA;YACPgC,UAAUA;YACVpC,UAAUmC;YACV9B,YAAYA;YACZC,UAAUA;YACVS,WAAWA;YACXmB,WAAWA;YACXhC,OAAOA;YACPoB,OAAOA;YACPnB,OAAOA;;IAGb;IAEA,OAAO;AACT;AAEA,OAAO,MAAM2C,cAAczD,cAAcI,iBAAgB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RenderComponent.d.ts","sourceRoot":"","sources":["../../../src/providers/Config/RenderComponent.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAG9C,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC;IACrC,QAAQ,CAAC,SAAS,CAAC,EAAE,KAAK,CAAC,aAAa,GAAG,KAAK,CAAC,aAAa,EAAE,CAAA;IAChE,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,eAAe,CAAC,EAAE,eAAe,GAAG,eAAe,EAAE,CAAA;IAC9D,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAC9B,
|
|
1
|
+
{"version":3,"file":"RenderComponent.d.ts","sourceRoot":"","sources":["../../../src/providers/Config/RenderComponent.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAG9C,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC;IACrC,QAAQ,CAAC,SAAS,CAAC,EAAE,KAAK,CAAC,aAAa,GAAG,KAAK,CAAC,aAAa,EAAE,CAAA;IAChE,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,eAAe,CAAC,EAAE,eAAe,GAAG,eAAe,EAAE,CAAA;IAC9D,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAC9B,CA0EA,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/providers/Config/RenderComponent.tsx"],"sourcesContent":["import type { MappedComponent } from 'payload'\n\nimport { isReactServerComponentOrFunction } from 'payload/shared'\nimport React from 'react'\n\n/**\n * Can be used to render both MappedComponents and React Components.\n */\nexport const RenderComponent: React.FC<{\n readonly Component?: React.ComponentType | React.ComponentType[]\n readonly clientProps?: object\n readonly mappedComponent?: MappedComponent | MappedComponent[]\n readonly serverProps?: object\n}> = ({ Component, clientProps = {}, mappedComponent, serverProps }) => {\n if (!mappedComponent && Component) {\n if (Array.isArray(Component)) {\n return Component.map((c, index) => (\n <RenderComponent\n Component={c}\n clientProps={clientProps}\n key={index}\n serverProps={serverProps}\n />\n ))\n }\n\n const mappedComponent: MappedComponent = isReactServerComponentOrFunction(Component)\n ? {\n type: 'server',\n Component,\n RenderedComponent: null,\n }\n : {\n type: 'client',\n Component,\n }\n\n return (\n <RenderComponent\n clientProps={clientProps}\n mappedComponent={mappedComponent}\n serverProps={serverProps}\n />\n )\n }\n if (!mappedComponent) {\n return null\n }\n\n if (Array.isArray(mappedComponent)) {\n return mappedComponent.map((c, index) => (\n <RenderComponent\n clientProps={clientProps}\n key={index}\n mappedComponent={c}\n serverProps={serverProps}\n />\n ))\n }\n\n if (mappedComponent.RenderedComponent) {\n return mappedComponent.RenderedComponent\n }\n\n if (!mappedComponent.Component) {\n return null\n }\n\n if (mappedComponent.type === 'server') {\n if (mappedComponent.props) {\n return (\n <mappedComponent.Component {...mappedComponent.props} {...serverProps} {...clientProps} />\n )\n }\n\n return <mappedComponent.Component {...serverProps} {...clientProps} />\n }\n\n if (mappedComponent.props) {\n return <mappedComponent.Component {...mappedComponent.props} {...clientProps} />\n }\n\n return <mappedComponent.Component {...clientProps} />\n}\n"],"names":["isReactServerComponentOrFunction","React","RenderComponent","Component","clientProps","mappedComponent","serverProps","Array","isArray","map","c","index","type","RenderedComponent","props"],"mappings":";AAEA,SAASA,gCAAgC,QAAQ,iBAAgB;AACjE,OAAOC,WAAW,QAAO;AAEzB;;CAEC,GACD,OAAO,MAAMC,kBAKR,CAAC,EAAEC,SAAS,EAAEC,cAAc,CAAC,CAAC,EAAEC,eAAe,EAAEC,WAAW,EAAE;IACjE,IAAI,CAACD,mBAAmBF,WAAW;QACjC,IAAII,MAAMC,OAAO,CAACL,YAAY;YAC5B,OAAOA,UAAUM,GAAG,CAAC,CAACC,GAAGC,sBACvB,KAACT;oBACCC,WAAWO;oBACXN,aAAaA;oBAEbE,aAAaA;mBADRK;QAIX;QAEA,MAAMN,kBAAmCL,iCAAiCG,aACtE;YACES,MAAM;YACNT;YACAU,mBAAmB;QACrB,IACA;YACED,MAAM;YACNT;QACF;QAEJ,qBACE,KAACD;YACCE,aAAaA;YACbC,iBAAiBA;YACjBC,aAAaA;;IAGnB;IACA,IAAI,CAACD,iBAAiB;QACpB,OAAO;IACT;IAEA,IAAIE,MAAMC,OAAO,CAACH,kBAAkB;QAClC,OAAOA,gBAAgBI,GAAG,CAAC,CAACC,GAAGC,sBAC7B,KAACT;gBACCE,aAAaA;gBAEbC,iBAAiBK;gBACjBJ,aAAaA;eAFRK;IAKX;IAEA,IAAIN,gBAAgBQ,iBAAiB,EAAE;QACrC,OAAOR,gBAAgBQ,iBAAiB;IAC1C;IAEA,IAAI,CAACR,gBAAgBF,SAAS,EAAE;QAC9B,OAAO;IACT;IAEA,IAAIE,gBAAgBO,IAAI,KAAK,UAAU;QACrC,IAAIP,gBAAgBS,KAAK,EAAE;YACzB,qBACE,KAACT,gBAAgBF,SAAS;gBAAE,GAAGE,gBAAgBS,KAAK;gBAAG,GAAGR,WAAW;gBAAG,GAAGF,WAAW;;QAE1F;QAEA,qBAAO,KAACC,gBAAgBF,SAAS;YAAE,GAAGG,WAAW;YAAG,GAAGF,WAAW;;IACpE;IAEA,IAAIC,gBAAgBS,KAAK,EAAE;QACzB,qBAAO,KAACT,gBAAgBF,SAAS;YAAE,GAAGE,gBAAgBS,KAAK;YAAG,GAAGV,WAAW;;IAC9E;IAEA,qBAAO,KAACC,gBAAgBF,SAAS;QAAE,GAAGC,WAAW;;AACnD,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/providers/Config/RenderComponent.tsx"],"sourcesContent":["import type { MappedComponent } from 'payload'\n\nimport { isReactServerComponentOrFunction } from 'payload/shared'\nimport React from 'react'\n\n/**\n * Can be used to render both MappedComponents and React Components.\n */\nexport const RenderComponent: React.FC<{\n readonly Component?: React.ComponentType | React.ComponentType[]\n readonly clientProps?: object\n readonly mappedComponent?: MappedComponent | MappedComponent[]\n readonly serverProps?: object\n}> = ({ Component, clientProps = {}, mappedComponent, serverProps }) => {\n if (!mappedComponent && Component) {\n if (Array.isArray(Component)) {\n return Component.map((c, index) => (\n <RenderComponent\n Component={c}\n clientProps={clientProps}\n key={index}\n serverProps={serverProps}\n />\n ))\n }\n\n const mappedComponent: MappedComponent = isReactServerComponentOrFunction(Component)\n ? {\n type: 'server',\n Component,\n RenderedComponent: null,\n }\n : {\n type: 'client',\n Component,\n }\n\n return (\n <RenderComponent\n clientProps={clientProps}\n mappedComponent={mappedComponent}\n serverProps={serverProps}\n />\n )\n }\n if (!mappedComponent) {\n return null\n }\n\n if (Array.isArray(mappedComponent)) {\n return mappedComponent.map((c, index) => (\n <RenderComponent\n clientProps={clientProps}\n key={index}\n mappedComponent={c}\n serverProps={serverProps}\n />\n ))\n }\n\n if (mappedComponent.type === 'empty') {\n return null\n }\n\n if (mappedComponent.RenderedComponent) {\n return mappedComponent.RenderedComponent\n }\n\n if (!mappedComponent.Component) {\n return null\n }\n\n if (mappedComponent.type === 'server') {\n if (mappedComponent.props) {\n return (\n <mappedComponent.Component {...mappedComponent.props} {...serverProps} {...clientProps} />\n )\n }\n\n return <mappedComponent.Component {...serverProps} {...clientProps} />\n }\n\n if (mappedComponent.props) {\n return <mappedComponent.Component {...mappedComponent.props} {...clientProps} />\n }\n\n return <mappedComponent.Component {...clientProps} />\n}\n"],"names":["isReactServerComponentOrFunction","React","RenderComponent","Component","clientProps","mappedComponent","serverProps","Array","isArray","map","c","index","type","RenderedComponent","props"],"mappings":";AAEA,SAASA,gCAAgC,QAAQ,iBAAgB;AACjE,OAAOC,WAAW,QAAO;AAEzB;;CAEC,GACD,OAAO,MAAMC,kBAKR,CAAC,EAAEC,SAAS,EAAEC,cAAc,CAAC,CAAC,EAAEC,eAAe,EAAEC,WAAW,EAAE;IACjE,IAAI,CAACD,mBAAmBF,WAAW;QACjC,IAAII,MAAMC,OAAO,CAACL,YAAY;YAC5B,OAAOA,UAAUM,GAAG,CAAC,CAACC,GAAGC,sBACvB,KAACT;oBACCC,WAAWO;oBACXN,aAAaA;oBAEbE,aAAaA;mBADRK;QAIX;QAEA,MAAMN,kBAAmCL,iCAAiCG,aACtE;YACES,MAAM;YACNT;YACAU,mBAAmB;QACrB,IACA;YACED,MAAM;YACNT;QACF;QAEJ,qBACE,KAACD;YACCE,aAAaA;YACbC,iBAAiBA;YACjBC,aAAaA;;IAGnB;IACA,IAAI,CAACD,iBAAiB;QACpB,OAAO;IACT;IAEA,IAAIE,MAAMC,OAAO,CAACH,kBAAkB;QAClC,OAAOA,gBAAgBI,GAAG,CAAC,CAACC,GAAGC,sBAC7B,KAACT;gBACCE,aAAaA;gBAEbC,iBAAiBK;gBACjBJ,aAAaA;eAFRK;IAKX;IAEA,IAAIN,gBAAgBO,IAAI,KAAK,SAAS;QACpC,OAAO;IACT;IAEA,IAAIP,gBAAgBQ,iBAAiB,EAAE;QACrC,OAAOR,gBAAgBQ,iBAAiB;IAC1C;IAEA,IAAI,CAACR,gBAAgBF,SAAS,EAAE;QAC9B,OAAO;IACT;IAEA,IAAIE,gBAAgBO,IAAI,KAAK,UAAU;QACrC,IAAIP,gBAAgBS,KAAK,EAAE;YACzB,qBACE,KAACT,gBAAgBF,SAAS;gBAAE,GAAGE,gBAAgBS,KAAK;gBAAG,GAAGR,WAAW;gBAAG,GAAGF,WAAW;;QAE1F;QAEA,qBAAO,KAACC,gBAAgBF,SAAS;YAAE,GAAGG,WAAW;YAAG,GAAGF,WAAW;;IACpE;IAEA,IAAIC,gBAAgBS,KAAK,EAAE;QACzB,qBAAO,KAACT,gBAAgBF,SAAS;YAAE,GAAGE,gBAAgBS,KAAK;YAAG,GAAGV,WAAW;;IAC9E;IAEA,qBAAO,KAACC,gBAAgBF,SAAS;QAAE,GAAGC,WAAW;;AACnD,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collections.d.ts","sourceRoot":"","sources":["../../../../src/providers/Config/createClientConfig/collections.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,KAAK,EACV,cAAc,EACd,sBAAsB,EACtB,qBAAqB,EAErB,aAAa,EACb,SAAS,EAET,OAAO,EACP,yBAAyB,EAG1B,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAM9B,eAAO,MAAM,4BAA4B,yHAStC;IACD,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CAAC,CAAA;IACxC,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAAC,CAAA;IACzC,gBAAgB,EAAE,sBAAsB,CAAA;IACxC,UAAU,EAAE,yBAAyB,CAAA;IACrC,qBAAqB,EAAE,qBAAqB,CAAA;IAC5C,IAAI,EAAE,UAAU,CAAA;IAChB,SAAS,EAAE,SAAS,CAAA;IACpB,OAAO,EAAE,OAAO,CAAA;CACjB,KAAG,
|
|
1
|
+
{"version":3,"file":"collections.d.ts","sourceRoot":"","sources":["../../../../src/providers/Config/createClientConfig/collections.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,KAAK,EACV,cAAc,EACd,sBAAsB,EACtB,qBAAqB,EAErB,aAAa,EACb,SAAS,EAET,OAAO,EACP,yBAAyB,EAG1B,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAM9B,eAAO,MAAM,4BAA4B,yHAStC;IACD,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CAAC,CAAA;IACxC,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAAC,CAAA;IACzC,gBAAgB,EAAE,sBAAsB,CAAA;IACxC,UAAU,EAAE,yBAAyB,CAAA;IACrC,qBAAqB,EAAE,qBAAqB,CAAA;IAC5C,IAAI,EAAE,UAAU,CAAA;IAChB,SAAS,EAAE,SAAS,CAAA;IACpB,OAAO,EAAE,OAAO,CAAA;CACjB,KAAG,sBAyTH,CAAA;AAED,eAAO,MAAM,6BAA6B,2HASvC;IACD,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CAAC,CAAA;IACxC,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAAC,CAAA;IACzC,iBAAiB,EAAE,sBAAsB,EAAE,CAAA;IAC3C,WAAW,EAAE,yBAAyB,EAAE,CAAA;IACxC,qBAAqB,EAAE,qBAAqB,CAAA;IAC5C,IAAI,EAAE,UAAU,CAAA;IAChB,SAAS,EAAE,SAAS,CAAA;IACpB,OAAO,EAAE,OAAO,CAAA;CACjB,KAAG,sBAAsB,EAiBzB,CAAA"}
|
|
@@ -117,7 +117,7 @@ export const createClientCollectionConfig = ({ DefaultEditView, DefaultListView,
|
|
|
117
117
|
clientCollection.admin.components.views.edit = {};
|
|
118
118
|
}
|
|
119
119
|
clientCollection.admin.components.views.edit.default = {
|
|
120
|
-
Component: createMappedComponent(hasEditView && 'Component' in collection.admin.components.views.edit.default && collection.admin.components.views.edit.default.Component, {
|
|
120
|
+
Component: createMappedComponent(hasEditView && 'Component' in collection.admin.components.views.edit.default && collection.admin.components.views.edit.default.Component ? collection.admin.components.views.edit.default.Component : null, {
|
|
121
121
|
collectionSlug: collection.slug
|
|
122
122
|
}, DefaultEditView, 'collection.admin.components.views.edit.default')
|
|
123
123
|
};
|
|
@@ -141,7 +141,7 @@ export const createClientCollectionConfig = ({ DefaultEditView, DefaultListView,
|
|
|
141
141
|
if (!clientCollection.admin.components.views.list) {
|
|
142
142
|
clientCollection.admin.components.views.list = {};
|
|
143
143
|
}
|
|
144
|
-
clientCollection.admin.components.views.list.Component = createMappedComponent(hasListView && 'Component' in collection.admin.components.views.list && collection.admin.components.views.list.Component, {
|
|
144
|
+
clientCollection.admin.components.views.list.Component = createMappedComponent(hasListView && 'Component' in collection.admin.components.views.list && collection.admin.components.views.list.Component ? collection.admin.components.views.list.Component : null, {
|
|
145
145
|
collectionSlug: collection.slug
|
|
146
146
|
}, DefaultListView, 'collection.admin.components.views.list');
|
|
147
147
|
if (hasListView && 'actions' in collection.admin.components.views.list && collection.admin.components.views.list.actions) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/providers/Config/createClientConfig/collections.tsx"],"sourcesContent":["import type { I18nClient } from '@payloadcms/translations'\nimport type {\n AdminViewProps,\n ClientCollectionConfig,\n CreateMappedComponent,\n EditViewConfig,\n EditViewProps,\n ImportMap,\n MappedView,\n Payload,\n SanitizedCollectionConfig,\n ServerOnlyCollectionAdminProperties,\n ServerOnlyCollectionProperties,\n} from 'payload'\nimport type React from 'react'\n\nimport { deepCopyObjectSimple } from 'payload'\n\nimport { createClientFields } from './fields.js'\n\nexport const createClientCollectionConfig = ({\n DefaultEditView,\n DefaultListView,\n clientCollection,\n collection,\n createMappedComponent,\n i18n,\n importMap,\n payload,\n}: {\n DefaultEditView: React.FC<EditViewProps>\n DefaultListView: React.FC<AdminViewProps>\n clientCollection: ClientCollectionConfig\n collection: SanitizedCollectionConfig\n createMappedComponent: CreateMappedComponent\n i18n: I18nClient\n importMap: ImportMap\n payload: Payload\n}): ClientCollectionConfig => {\n clientCollection.fields = createClientFields({\n clientFields: clientCollection.fields,\n createMappedComponent,\n fields: collection.fields,\n i18n,\n importMap,\n payload,\n })\n\n const serverOnlyCollectionProperties: Partial<ServerOnlyCollectionProperties>[] = [\n 'hooks',\n 'access',\n 'endpoints',\n 'custom',\n // `upload`\n // `admin`\n // are all handled separately\n ]\n\n serverOnlyCollectionProperties.forEach((key) => {\n if (key in clientCollection) {\n delete clientCollection[key]\n }\n })\n\n if ('upload' in clientCollection && typeof clientCollection.upload === 'object') {\n delete clientCollection.upload.handlers\n delete clientCollection.upload.adminThumbnail\n delete clientCollection.upload.externalFileHeaderFilter\n delete clientCollection.upload.withMetadata\n\n if ('imageSizes' in clientCollection.upload && clientCollection.upload.imageSizes.length) {\n clientCollection.upload.imageSizes = clientCollection.upload.imageSizes.map((size) => {\n const sanitizedSize = { ...size }\n if ('generateImageName' in sanitizedSize) delete sanitizedSize.generateImageName\n return sanitizedSize\n })\n }\n }\n\n if ('auth' in clientCollection && typeof clientCollection.auth === 'object') {\n delete clientCollection.auth.strategies\n delete clientCollection.auth.forgotPassword\n delete clientCollection.auth.verify\n }\n\n if (collection.labels) {\n Object.entries(collection.labels).forEach(([labelType, collectionLabel]) => {\n if (typeof collectionLabel === 'function') {\n clientCollection.labels[labelType] = collectionLabel({ t: i18n.t })\n }\n })\n }\n\n const serverOnlyCollectionAdminProperties: Partial<ServerOnlyCollectionAdminProperties>[] = [\n 'hidden',\n 'preview',\n // `livePreview` is handled separately\n ]\n\n serverOnlyCollectionAdminProperties.forEach((key) => {\n if (key in clientCollection.admin) {\n delete clientCollection.admin[key]\n }\n })\n\n if (collection.admin.preview) {\n clientCollection._isPreviewEnabled = true\n }\n\n clientCollection.admin.components = {} as ClientCollectionConfig['admin']['components']\n\n if (collection?.admin?.components) {\n if (collection.admin.components?.edit) {\n clientCollection.admin.components.edit =\n {} as ClientCollectionConfig['admin']['components']['edit']\n\n if (collection.admin.components.edit?.PreviewButton) {\n clientCollection.admin.components.edit.PreviewButton = createMappedComponent(\n collection.admin.components.edit.PreviewButton,\n undefined,\n undefined,\n 'collection.admin.components.edit.PreviewButton',\n )\n }\n\n if (collection.admin.components.edit?.PublishButton) {\n clientCollection.admin.components.edit.PublishButton = createMappedComponent(\n collection.admin.components.edit.PublishButton,\n undefined,\n undefined,\n 'collection.admin.components.edit.PublishButton',\n )\n }\n\n if (collection.admin.components.edit?.SaveButton) {\n clientCollection.admin.components.edit.SaveButton = createMappedComponent(\n collection.admin.components.edit.SaveButton,\n undefined,\n undefined,\n 'collection.admin.components.edit.SaveButton',\n )\n }\n\n if (collection.admin.components.edit?.SaveDraftButton) {\n clientCollection.admin.components.edit.SaveDraftButton = createMappedComponent(\n collection.admin.components.edit.SaveDraftButton,\n undefined,\n undefined,\n 'collection.admin.components.edit.SaveDraftButton',\n )\n }\n\n if (collection.admin.components.edit?.Upload) {\n clientCollection.admin.components.edit.Upload = createMappedComponent(\n collection.admin.components.edit.Upload,\n undefined,\n undefined,\n 'collection.admin.components.edit.Upload',\n )\n }\n }\n\n if (collection.admin.components?.beforeList) {\n clientCollection.admin.components.beforeList = collection.admin.components.beforeList.map(\n (Component) =>\n createMappedComponent(\n Component,\n undefined,\n undefined,\n 'collection.admin.components.beforeList',\n ),\n )\n }\n\n if (collection.admin.components?.beforeListTable) {\n clientCollection.admin.components.beforeListTable =\n collection.admin.components.beforeListTable.map((Component) =>\n createMappedComponent(\n Component,\n undefined,\n undefined,\n 'collection.admin.components.beforeListTable',\n ),\n )\n }\n\n if (collection.admin.components?.afterList) {\n clientCollection.admin.components.afterList = collection.admin.components.afterList.map(\n (Component) =>\n createMappedComponent(\n Component,\n undefined,\n undefined,\n 'collection.admin.components.afterList',\n ),\n )\n }\n\n if (collection.admin.components?.afterListTable) {\n clientCollection.admin.components.afterListTable =\n collection.admin.components.afterListTable.map((Component) =>\n createMappedComponent(\n Component,\n undefined,\n undefined,\n 'collection.admin.components.afterListTable',\n ),\n )\n }\n }\n\n let description = undefined\n if (collection.admin?.description) {\n if (\n typeof collection.admin?.description === 'string' ||\n typeof collection.admin?.description === 'object'\n ) {\n description = collection.admin.description\n } else if (typeof collection.admin?.description === 'function') {\n description = collection.admin?.description({ t: i18n.t })\n }\n }\n clientCollection.admin.description = description\n\n if (collection.admin.components.edit?.Description) {\n clientCollection.admin.components.edit.Description = createMappedComponent(\n collection.admin.components.edit.Description,\n {\n description,\n },\n undefined,\n 'collection.admin.components.edit.Description',\n )\n }\n\n clientCollection.admin.description = description\n\n clientCollection.admin.components.views = (\n collection?.admin?.components?.views\n ? deepCopyObjectSimple(collection?.admin?.components?.views)\n : {}\n ) as ClientCollectionConfig['admin']['components']['views']\n\n const hasEditView =\n 'admin' in collection &&\n 'components' in collection.admin &&\n 'views' in collection.admin.components &&\n 'edit' in collection.admin.components.views &&\n 'default' in collection.admin.components.views.edit\n\n if (!clientCollection.admin.components.views.edit) {\n clientCollection.admin.components.views.edit =\n {} as ClientCollectionConfig['admin']['components']['views']['edit']\n }\n\n clientCollection.admin.components.views.edit.default = {\n Component: createMappedComponent(\n hasEditView &&\n 'Component' in collection.admin.components.views.edit.default &&\n collection.admin.components.views.edit.default.Component,\n {\n collectionSlug: collection.slug,\n },\n DefaultEditView,\n 'collection.admin.components.views.edit.default',\n ),\n }\n\n if (collection?.admin?.components?.views?.edit) {\n for (const key in collection.admin.components.views.edit) {\n const view: EditViewConfig = collection.admin.components.views.edit[key]\n\n if (!clientCollection.admin.components.views.edit[key]) {\n clientCollection.admin.components.views.edit[key] = {} as MappedView\n }\n\n if ('Component' in view && key !== 'default') {\n clientCollection.admin.components.views.edit[key].Component = createMappedComponent(\n view.Component,\n {\n collectionSlug: collection.slug,\n },\n undefined,\n 'collection.admin.components.views.edit.key.Component',\n )\n }\n\n if ('actions' in view && view.actions?.length) {\n clientCollection.admin.components.views.edit[key].actions = view.actions.map((Component) =>\n createMappedComponent(\n Component,\n undefined,\n undefined,\n 'collection.admin.components.views.key.admin',\n ),\n )\n }\n }\n }\n\n const hasListView =\n 'admin' in collection &&\n 'components' in collection.admin &&\n 'views' in collection.admin.components &&\n 'list' in collection.admin.components.views\n\n if (!clientCollection.admin.components.views.list) {\n clientCollection.admin.components.views.list =\n {} as ClientCollectionConfig['admin']['components']['views']['list']\n }\n\n clientCollection.admin.components.views.list.Component = createMappedComponent(\n hasListView &&\n 'Component' in collection.admin.components.views.list &&\n collection.admin.components.views.list.Component,\n {\n collectionSlug: collection.slug,\n },\n DefaultListView,\n 'collection.admin.components.views.list',\n )\n\n if (\n hasListView &&\n 'actions' in collection.admin.components.views.list &&\n collection.admin.components.views.list.actions\n ) {\n clientCollection.admin.components.views.list.actions =\n collection.admin.components.views.list.actions.map((Component) =>\n createMappedComponent(\n Component,\n undefined,\n undefined,\n 'collection.admin.components.views.list',\n ),\n )\n }\n\n if (\n 'livePreview' in clientCollection.admin &&\n clientCollection.admin.livePreview &&\n 'url' in clientCollection.admin.livePreview\n ) {\n delete clientCollection.admin.livePreview.url\n }\n\n return clientCollection\n}\n\nexport const createClientCollectionConfigs = ({\n DefaultEditView,\n DefaultListView,\n clientCollections,\n collections,\n createMappedComponent,\n i18n,\n importMap,\n payload,\n}: {\n DefaultEditView: React.FC<EditViewProps>\n DefaultListView: React.FC<AdminViewProps>\n clientCollections: ClientCollectionConfig[]\n collections: SanitizedCollectionConfig[]\n createMappedComponent: CreateMappedComponent\n i18n: I18nClient\n importMap: ImportMap\n payload: Payload\n}): ClientCollectionConfig[] => {\n for (let i = 0; i < collections.length; i++) {\n const collection = collections[i]\n const clientCollection = clientCollections[i]\n clientCollections[i] = createClientCollectionConfig({\n DefaultEditView,\n DefaultListView,\n clientCollection,\n collection,\n createMappedComponent,\n i18n,\n importMap,\n payload,\n })\n }\n\n return clientCollections\n}\n"],"names":["deepCopyObjectSimple","createClientFields","createClientCollectionConfig","DefaultEditView","DefaultListView","clientCollection","collection","createMappedComponent","i18n","importMap","payload","fields","clientFields","serverOnlyCollectionProperties","forEach","key","upload","handlers","adminThumbnail","externalFileHeaderFilter","withMetadata","imageSizes","length","map","size","sanitizedSize","generateImageName","auth","strategies","forgotPassword","verify","labels","Object","entries","labelType","collectionLabel","t","serverOnlyCollectionAdminProperties","admin","preview","_isPreviewEnabled","components","edit","PreviewButton","undefined","PublishButton","SaveButton","SaveDraftButton","Upload","beforeList","Component","beforeListTable","afterList","afterListTable","description","Description","views","hasEditView","default","collectionSlug","slug","view","actions","hasListView","list","livePreview","url","createClientCollectionConfigs","clientCollections","collections","i"],"mappings":"AAgBA,SAASA,oBAAoB,QAAQ,UAAS;AAE9C,SAASC,kBAAkB,QAAQ,cAAa;AAEhD,OAAO,MAAMC,+BAA+B,CAAC,EAC3CC,eAAe,EACfC,eAAe,EACfC,gBAAgB,EAChBC,UAAU,EACVC,qBAAqB,EACrBC,IAAI,EACJC,SAAS,EACTC,OAAO,EAUR;IACCL,iBAAiBM,MAAM,GAAGV,mBAAmB;QAC3CW,cAAcP,iBAAiBM,MAAM;QACrCJ;QACAI,QAAQL,WAAWK,MAAM;QACzBH;QACAC;QACAC;IACF;IAEA,MAAMG,iCAA4E;QAChF;QACA;QACA;QACA;KAID;IAEDA,+BAA+BC,OAAO,CAAC,CAACC;QACtC,IAAIA,OAAOV,kBAAkB;YAC3B,OAAOA,gBAAgB,CAACU,IAAI;QAC9B;IACF;IAEA,IAAI,YAAYV,oBAAoB,OAAOA,iBAAiBW,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ClDC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;QACF;IACF;IAEA,OAAO0D;AACT,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/providers/Config/createClientConfig/collections.tsx"],"sourcesContent":["import type { I18nClient } from '@payloadcms/translations'\nimport type {\n AdminViewProps,\n ClientCollectionConfig,\n CreateMappedComponent,\n EditViewConfig,\n EditViewProps,\n ImportMap,\n MappedView,\n Payload,\n SanitizedCollectionConfig,\n ServerOnlyCollectionAdminProperties,\n ServerOnlyCollectionProperties,\n} from 'payload'\nimport type React from 'react'\n\nimport { deepCopyObjectSimple } from 'payload'\n\nimport { createClientFields } from './fields.js'\n\nexport const createClientCollectionConfig = ({\n DefaultEditView,\n DefaultListView,\n clientCollection,\n collection,\n createMappedComponent,\n i18n,\n importMap,\n payload,\n}: {\n DefaultEditView: React.FC<EditViewProps>\n DefaultListView: React.FC<AdminViewProps>\n clientCollection: ClientCollectionConfig\n collection: SanitizedCollectionConfig\n createMappedComponent: CreateMappedComponent\n i18n: I18nClient\n importMap: ImportMap\n payload: Payload\n}): ClientCollectionConfig => {\n clientCollection.fields = createClientFields({\n clientFields: clientCollection.fields,\n createMappedComponent,\n fields: collection.fields,\n i18n,\n importMap,\n payload,\n })\n\n const serverOnlyCollectionProperties: Partial<ServerOnlyCollectionProperties>[] = [\n 'hooks',\n 'access',\n 'endpoints',\n 'custom',\n // `upload`\n // `admin`\n // are all handled separately\n ]\n\n serverOnlyCollectionProperties.forEach((key) => {\n if (key in clientCollection) {\n delete clientCollection[key]\n }\n })\n\n if ('upload' in clientCollection && typeof clientCollection.upload === 'object') {\n delete clientCollection.upload.handlers\n delete clientCollection.upload.adminThumbnail\n delete clientCollection.upload.externalFileHeaderFilter\n delete clientCollection.upload.withMetadata\n\n if ('imageSizes' in clientCollection.upload && clientCollection.upload.imageSizes.length) {\n clientCollection.upload.imageSizes = clientCollection.upload.imageSizes.map((size) => {\n const sanitizedSize = { ...size }\n if ('generateImageName' in sanitizedSize) delete sanitizedSize.generateImageName\n return sanitizedSize\n })\n }\n }\n\n if ('auth' in clientCollection && typeof clientCollection.auth === 'object') {\n delete clientCollection.auth.strategies\n delete clientCollection.auth.forgotPassword\n delete clientCollection.auth.verify\n }\n\n if (collection.labels) {\n Object.entries(collection.labels).forEach(([labelType, collectionLabel]) => {\n if (typeof collectionLabel === 'function') {\n clientCollection.labels[labelType] = collectionLabel({ t: i18n.t })\n }\n })\n }\n\n const serverOnlyCollectionAdminProperties: Partial<ServerOnlyCollectionAdminProperties>[] = [\n 'hidden',\n 'preview',\n // `livePreview` is handled separately\n ]\n\n serverOnlyCollectionAdminProperties.forEach((key) => {\n if (key in clientCollection.admin) {\n delete clientCollection.admin[key]\n }\n })\n\n if (collection.admin.preview) {\n clientCollection._isPreviewEnabled = true\n }\n\n clientCollection.admin.components = {} as ClientCollectionConfig['admin']['components']\n\n if (collection?.admin?.components) {\n if (collection.admin.components?.edit) {\n clientCollection.admin.components.edit =\n {} as ClientCollectionConfig['admin']['components']['edit']\n\n if (collection.admin.components.edit?.PreviewButton) {\n clientCollection.admin.components.edit.PreviewButton = createMappedComponent(\n collection.admin.components.edit.PreviewButton,\n undefined,\n undefined,\n 'collection.admin.components.edit.PreviewButton',\n )\n }\n\n if (collection.admin.components.edit?.PublishButton) {\n clientCollection.admin.components.edit.PublishButton = createMappedComponent(\n collection.admin.components.edit.PublishButton,\n undefined,\n undefined,\n 'collection.admin.components.edit.PublishButton',\n )\n }\n\n if (collection.admin.components.edit?.SaveButton) {\n clientCollection.admin.components.edit.SaveButton = createMappedComponent(\n collection.admin.components.edit.SaveButton,\n undefined,\n undefined,\n 'collection.admin.components.edit.SaveButton',\n )\n }\n\n if (collection.admin.components.edit?.SaveDraftButton) {\n clientCollection.admin.components.edit.SaveDraftButton = createMappedComponent(\n collection.admin.components.edit.SaveDraftButton,\n undefined,\n undefined,\n 'collection.admin.components.edit.SaveDraftButton',\n )\n }\n\n if (collection.admin.components.edit?.Upload) {\n clientCollection.admin.components.edit.Upload = createMappedComponent(\n collection.admin.components.edit.Upload,\n undefined,\n undefined,\n 'collection.admin.components.edit.Upload',\n )\n }\n }\n\n if (collection.admin.components?.beforeList) {\n clientCollection.admin.components.beforeList = collection.admin.components.beforeList.map(\n (Component) =>\n createMappedComponent(\n Component,\n undefined,\n undefined,\n 'collection.admin.components.beforeList',\n ),\n )\n }\n\n if (collection.admin.components?.beforeListTable) {\n clientCollection.admin.components.beforeListTable =\n collection.admin.components.beforeListTable.map((Component) =>\n createMappedComponent(\n Component,\n undefined,\n undefined,\n 'collection.admin.components.beforeListTable',\n ),\n )\n }\n\n if (collection.admin.components?.afterList) {\n clientCollection.admin.components.afterList = collection.admin.components.afterList.map(\n (Component) =>\n createMappedComponent(\n Component,\n undefined,\n undefined,\n 'collection.admin.components.afterList',\n ),\n )\n }\n\n if (collection.admin.components?.afterListTable) {\n clientCollection.admin.components.afterListTable =\n collection.admin.components.afterListTable.map((Component) =>\n createMappedComponent(\n Component,\n undefined,\n undefined,\n 'collection.admin.components.afterListTable',\n ),\n )\n }\n }\n\n let description = undefined\n if (collection.admin?.description) {\n if (\n typeof collection.admin?.description === 'string' ||\n typeof collection.admin?.description === 'object'\n ) {\n description = collection.admin.description\n } else if (typeof collection.admin?.description === 'function') {\n description = collection.admin?.description({ t: i18n.t })\n }\n }\n clientCollection.admin.description = description\n\n if (collection.admin.components.edit?.Description) {\n clientCollection.admin.components.edit.Description = createMappedComponent(\n collection.admin.components.edit.Description,\n {\n description,\n },\n undefined,\n 'collection.admin.components.edit.Description',\n )\n }\n\n clientCollection.admin.description = description\n\n clientCollection.admin.components.views = (\n collection?.admin?.components?.views\n ? deepCopyObjectSimple(collection?.admin?.components?.views)\n : {}\n ) as ClientCollectionConfig['admin']['components']['views']\n\n const hasEditView =\n 'admin' in collection &&\n 'components' in collection.admin &&\n 'views' in collection.admin.components &&\n 'edit' in collection.admin.components.views &&\n 'default' in collection.admin.components.views.edit\n\n if (!clientCollection.admin.components.views.edit) {\n clientCollection.admin.components.views.edit =\n {} as ClientCollectionConfig['admin']['components']['views']['edit']\n }\n\n clientCollection.admin.components.views.edit.default = {\n Component: createMappedComponent(\n hasEditView &&\n 'Component' in collection.admin.components.views.edit.default &&\n collection.admin.components.views.edit.default.Component\n ? collection.admin.components.views.edit.default.Component\n : null,\n {\n collectionSlug: collection.slug,\n },\n DefaultEditView,\n 'collection.admin.components.views.edit.default',\n ),\n }\n\n if (collection?.admin?.components?.views?.edit) {\n for (const key in collection.admin.components.views.edit) {\n const view: EditViewConfig = collection.admin.components.views.edit[key]\n\n if (!clientCollection.admin.components.views.edit[key]) {\n clientCollection.admin.components.views.edit[key] = {} as MappedView\n }\n\n if ('Component' in view && key !== 'default') {\n clientCollection.admin.components.views.edit[key].Component = createMappedComponent(\n view.Component,\n {\n collectionSlug: collection.slug,\n },\n undefined,\n 'collection.admin.components.views.edit.key.Component',\n )\n }\n\n if ('actions' in view && view.actions?.length) {\n clientCollection.admin.components.views.edit[key].actions = view.actions.map((Component) =>\n createMappedComponent(\n Component,\n undefined,\n undefined,\n 'collection.admin.components.views.key.admin',\n ),\n )\n }\n }\n }\n\n const hasListView =\n 'admin' in collection &&\n 'components' in collection.admin &&\n 'views' in collection.admin.components &&\n 'list' in collection.admin.components.views\n\n if (!clientCollection.admin.components.views.list) {\n clientCollection.admin.components.views.list =\n {} as ClientCollectionConfig['admin']['components']['views']['list']\n }\n\n clientCollection.admin.components.views.list.Component = createMappedComponent(\n hasListView &&\n 'Component' in collection.admin.components.views.list &&\n collection.admin.components.views.list.Component\n ? collection.admin.components.views.list.Component\n : null,\n {\n collectionSlug: collection.slug,\n },\n DefaultListView,\n 'collection.admin.components.views.list',\n )\n\n if (\n hasListView &&\n 'actions' in collection.admin.components.views.list &&\n collection.admin.components.views.list.actions\n ) {\n clientCollection.admin.components.views.list.actions =\n collection.admin.components.views.list.actions.map((Component) =>\n createMappedComponent(\n Component,\n undefined,\n undefined,\n 'collection.admin.components.views.list',\n ),\n )\n }\n\n if (\n 'livePreview' in clientCollection.admin &&\n clientCollection.admin.livePreview &&\n 'url' in clientCollection.admin.livePreview\n ) {\n delete clientCollection.admin.livePreview.url\n }\n\n return clientCollection\n}\n\nexport const createClientCollectionConfigs = ({\n DefaultEditView,\n DefaultListView,\n clientCollections,\n collections,\n createMappedComponent,\n i18n,\n importMap,\n payload,\n}: {\n DefaultEditView: React.FC<EditViewProps>\n DefaultListView: React.FC<AdminViewProps>\n clientCollections: ClientCollectionConfig[]\n collections: SanitizedCollectionConfig[]\n createMappedComponent: CreateMappedComponent\n i18n: I18nClient\n importMap: ImportMap\n payload: Payload\n}): ClientCollectionConfig[] => {\n for (let i = 0; i < collections.length; i++) {\n const collection = collections[i]\n const clientCollection = clientCollections[i]\n clientCollections[i] = createClientCollectionConfig({\n DefaultEditView,\n DefaultListView,\n clientCollection,\n collection,\n createMappedComponent,\n i18n,\n importMap,\n payload,\n })\n }\n\n return clientCollections\n}\n"],"names":["deepCopyObjectSimple","createClientFields","createClientCollectionConfig","DefaultEditView","DefaultListView","clientCollection","collection","createMappedComponent","i18n","importMap","payload","fields","clientFields","serverOnlyCollectionProperties","forEach","key","upload","handlers","adminThumbnail","externalFileHeaderFilter","withMetadata","imageSizes","length","map","size","sanitizedSize","generateImageName","auth","strategies","forgotPassword","verify","labels","Object","entries","labelType","collectionLabel","t","serverOnlyCollectionAdminProperties","admin","preview","_isPreviewEnabled","components","edit","PreviewButton","undefined","PublishButton","SaveButton","SaveDraftButton","Upload","beforeList","Component","beforeListTable","afterList","afterListTable","description","Description","views","hasEditView","default","collectionSlug","slug","view","actions","hasListView","list","livePreview","url","createClientCollectionConfigs","clientCollections","collections","i"],"mappings":"AAgBA,SAASA,oBAAoB,QAAQ,UAAS;AAE9C,SAASC,kBAAkB,QAAQ,cAAa;AAEhD,OAAO,MAAMC,+BAA+B,CAAC,EAC3CC,eAAe,EACfC,eAAe,EACfC,gBAAgB,EAChBC,UAAU,EACVC,qBAAqB,EACrBC,IA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vCjC,iBAAiBiC,KAAK,CAAC2B,WAAW,IAClC,SAAS5D,iBAAiBiC,KAAK,CAAC2B,WAAW,EAC3C;QACA,OAAO5D,iBAAiBiC,KAAK,CAAC2B,WAAW,CAACC,GAAG;IAC/C;IAEA,OAAO7D;AACT,EAAC;AAED,OAAO,MAAM8D,gCAAgC,CAAC,EAC5ChE,eAAe,EACfC,eAAe,EACfgE,iBAAiB,EACjBC,WAAW,EACX9D,qBAAqB,EACrBC,IAAI,EACJC,SAAS,EACTC,OAAO,EAUR;IACC,IAAK,IAAI4D,IAAI,GAAGA,IAAID,YAAY/C,MAAM,EAAEgD,IAAK;QAC3C,MAAMhE,aAAa+D,WAAW,CAACC,EAAE;QACjC,MAAMjE,mBAAmB+D,iBAAiB,CAACE,EAAE;QAC7CF,iBAAiB,CAACE,EAAE,GAAGpE,6BAA6B;YAClDC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;QACF;IACF;IAEA,OAAO0D;AACT,EAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ImportMap, PayloadComponent, ResolvedComponent } from 'payload';
|
|
2
2
|
/**
|
|
3
|
-
* Gets
|
|
3
|
+
* Gets the resolved React component from `PayloadComponent` from the importMap
|
|
4
4
|
*/
|
|
5
5
|
export declare const getComponent: <TComponentServerProps extends object, TComponentClientProps extends object>({ identifier, importMap, payloadComponent, silent, }: {
|
|
6
6
|
identifier?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getComponent.d.ts","sourceRoot":"","sources":["../../../../src/providers/Config/createClientConfig/getComponent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAI7E;;GAEG;AACH,eAAO,MAAM,YAAY,GACvB,qBAAqB,SAAS,MAAM,EACpC,qBAAqB,SAAS,MAAM,wDAMnC;IACD,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,SAAS,EAAE,SAAS,CAAA;IACpB,gBAAgB,EACZ,gBAAgB,CAAC,qBAAqB,EAAE,qBAAqB,CAAC,GAC9D,IAAI,GACJ,SAAS,CAAA;IACb,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB,KAAG,iBAAiB,CAAC,qBAAqB,EAAE,qBAAqB,
|
|
1
|
+
{"version":3,"file":"getComponent.d.ts","sourceRoot":"","sources":["../../../../src/providers/Config/createClientConfig/getComponent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAI7E;;GAEG;AACH,eAAO,MAAM,YAAY,GACvB,qBAAqB,SAAS,MAAM,EACpC,qBAAqB,SAAS,MAAM,wDAMnC;IACD,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,SAAS,EAAE,SAAS,CAAA;IACpB,gBAAgB,EACZ,gBAAgB,CAAC,qBAAqB,EAAE,qBAAqB,CAAC,GAC9D,IAAI,GACJ,SAAS,CAAA;IACb,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB,KAAG,iBAAiB,CAAC,qBAAqB,EAAE,qBAAqB,CAuCjE,CAAA"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { parsePayloadComponent } from 'payload/shared';
|
|
2
2
|
/**
|
|
3
|
-
* Gets
|
|
3
|
+
* Gets the resolved React component from `PayloadComponent` from the importMap
|
|
4
4
|
*/ export const getComponent = ({ identifier, importMap, payloadComponent, silent })=>{
|
|
5
5
|
if (!payloadComponent) {
|
|
6
|
+
// undefined, null or false
|
|
6
7
|
return {
|
|
7
8
|
Component: undefined,
|
|
8
9
|
clientProps: undefined,
|
|
@@ -17,7 +18,7 @@ import { parsePayloadComponent } from 'payload/shared';
|
|
|
17
18
|
identifier,
|
|
18
19
|
key,
|
|
19
20
|
payloadComponent
|
|
20
|
-
});
|
|
21
|
+
}, 'You may need to run the `payload generate:importmap` command to generate the importMap ahead of runtime.');
|
|
21
22
|
}
|
|
22
23
|
return {
|
|
23
24
|
Component,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/providers/Config/createClientConfig/getComponent.ts"],"sourcesContent":["import type { ImportMap, PayloadComponent, ResolvedComponent } from 'payload'\n\nimport { parsePayloadComponent } from 'payload/shared'\n\n/**\n * Gets
|
|
1
|
+
{"version":3,"sources":["../../../../src/providers/Config/createClientConfig/getComponent.ts"],"sourcesContent":["import type { ImportMap, PayloadComponent, ResolvedComponent } from 'payload'\n\nimport { parsePayloadComponent } from 'payload/shared'\n\n/**\n * Gets the resolved React component from `PayloadComponent` from the importMap\n */\nexport const getComponent = <\n TComponentServerProps extends object,\n TComponentClientProps extends object,\n>({\n identifier,\n importMap,\n payloadComponent,\n silent,\n}: {\n identifier?: string\n importMap: ImportMap\n payloadComponent:\n | PayloadComponent<TComponentServerProps, TComponentClientProps>\n | null\n | undefined\n silent?: boolean\n}): ResolvedComponent<TComponentServerProps, TComponentClientProps> => {\n if (!payloadComponent) {\n // undefined, null or false\n return {\n Component: undefined,\n clientProps: undefined,\n serverProps: undefined,\n }\n }\n\n const { exportName, path } = parsePayloadComponent(payloadComponent)\n\n const key = path + '#' + exportName\n\n const Component = importMap[key]\n\n if (!Component && !silent) {\n console.error(\n `getComponent: Component not found in importMap`,\n {\n identifier,\n key,\n payloadComponent,\n },\n 'You may need to run the `payload generate:importmap` command to generate the importMap ahead of runtime.',\n )\n }\n\n return {\n Component,\n clientProps:\n typeof payloadComponent === 'object'\n ? (payloadComponent.clientProps as TComponentClientProps)\n : undefined,\n serverProps:\n typeof payloadComponent === 'object'\n ? (payloadComponent.serverProps as TComponentServerProps)\n : undefined,\n }\n}\n"],"names":["parsePayloadComponent","getComponent","identifier","importMap","payloadComponent","silent","Component","undefined","clientProps","serverProps","exportName","path","key","console","error"],"mappings":"AAEA,SAASA,qBAAqB,QAAQ,iBAAgB;AAEtD;;CAEC,GACD,OAAO,MAAMC,eAAe,CAG1B,EACAC,UAAU,EACVC,SAAS,EACTC,gBAAgB,EAChBC,MAAM,EASP;IACC,IAAI,CAACD,kBAAkB;QACrB,2BAA2B;QAC3B,OAAO;YACLE,WAAWC;YACXC,aAAaD;YACbE,aAAaF;QACf;IACF;IAEA,MAAM,EAAEG,UAAU,EAAEC,IAAI,EAAE,GAAGX,sBAAsBI;IAEnD,MAAMQ,MAAMD,OAAO,MAAMD;IAEzB,MAAMJ,YAAYH,SAAS,CAACS,IAAI;IAEhC,IAAI,CAACN,aAAa,CAACD,QAAQ;QACzBQ,QAAQC,KAAK,CACX,CAAC,8CAA8C,CAAC,EAChD;YACEZ;YACAU;YACAR;QACF,GACA;IAEJ;IAEA,OAAO;QACLE;QACAE,aACE,OAAOJ,qBAAqB,WACvBA,iBAAiBI,WAAW,GAC7BD;QACNE,aACE,OAAOL,qBAAqB,WACvBA,iBAAiBK,WAAW,GAC7BF;IACR;AACF,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getCreateMappedComponent.d.ts","sourceRoot":"","sources":["../../../../src/providers/Config/createClientConfig/getCreateMappedComponent.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,KAAK,EACV,qBAAqB,EACrB,SAAS,EAGT,OAAO,EAER,MAAM,SAAS,CAAA;AAOhB,wBAAgB,wBAAwB,CAAC,EACvC,SAAS,EACT,WAAW,GACZ,EAAE;IACD,SAAS,EAAE,SAAS,CAAA;IACpB,WAAW,EAAE;QACX,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;QAClB,IAAI,CAAC,EAAE,UAAU,CAAA;QACjB,OAAO,CAAC,EAAE,OAAO,CAAA;KAClB,CAAA;CACF,GAAG,qBAAqB,
|
|
1
|
+
{"version":3,"file":"getCreateMappedComponent.d.ts","sourceRoot":"","sources":["../../../../src/providers/Config/createClientConfig/getCreateMappedComponent.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,KAAK,EACV,qBAAqB,EACrB,SAAS,EAGT,OAAO,EAER,MAAM,SAAS,CAAA;AAOhB,wBAAgB,wBAAwB,CAAC,EACvC,SAAS,EACT,WAAW,GACZ,EAAE;IACD,SAAS,EAAE,SAAS,CAAA;IACpB,WAAW,EAAE;QACX,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;QAClB,IAAI,CAAC,EAAE,UAAU,CAAA;QACjB,OAAO,CAAC,EAAE,OAAO,CAAA;KAClB,CAAA;CACF,GAAG,qBAAqB,CAuHxB"}
|
|
@@ -4,7 +4,7 @@ import React from 'react';
|
|
|
4
4
|
import { getComponent } from './getComponent.js';
|
|
5
5
|
export function getCreateMappedComponent({ importMap, serverProps }) {
|
|
6
6
|
const createSingleMappedComponent = (payloadComponent, key, props, Fallback, identifier)=>{
|
|
7
|
-
if (
|
|
7
|
+
if (payloadComponent === undefined || payloadComponent === null) {
|
|
8
8
|
if (!Fallback) {
|
|
9
9
|
return undefined;
|
|
10
10
|
}
|
|
@@ -27,6 +27,11 @@ export function getCreateMappedComponent({ importMap, serverProps }) {
|
|
|
27
27
|
return toReturn;
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
|
+
if (payloadComponent === false) {
|
|
31
|
+
return {
|
|
32
|
+
type: 'empty'
|
|
33
|
+
};
|
|
34
|
+
}
|
|
30
35
|
const resolvedComponent = payloadComponent && typeof payloadComponent === 'object' && 'ReactComponent' in payloadComponent ? {
|
|
31
36
|
Component: payloadComponent.ReactComponent
|
|
32
37
|
} : getComponent({
|
|
@@ -66,7 +71,7 @@ export function getCreateMappedComponent({ importMap, serverProps }) {
|
|
|
66
71
|
}
|
|
67
72
|
};
|
|
68
73
|
const createMappedComponent = (payloadComponent, props, fallback, identifier)=>{
|
|
69
|
-
if (
|
|
74
|
+
if ((payloadComponent === undefined || payloadComponent === null) && !fallback) {
|
|
70
75
|
return undefined;
|
|
71
76
|
}
|
|
72
77
|
if (payloadComponent && Array.isArray(payloadComponent)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/providers/Config/createClientConfig/getCreateMappedComponent.tsx"],"sourcesContent":["import type { I18nClient } from '@payloadcms/translations'\nimport type {\n CreateMappedComponent,\n ImportMap,\n JsonObject,\n MappedComponent,\n Payload,\n PayloadComponent,\n} from 'payload'\n\nimport { isReactServerComponentOrFunction } from 'payload/shared'\nimport React from 'react'\n\nimport { getComponent } from './getComponent.js'\n\nexport function getCreateMappedComponent({\n importMap,\n serverProps,\n}: {\n importMap: ImportMap\n serverProps: {\n [key: string]: any\n i18n?: I18nClient\n payload?: Payload\n }\n}): CreateMappedComponent {\n const createSingleMappedComponent = (\n payloadComponent: { ReactComponent: React.FC<any> } | PayloadComponent,\n key: number | string,\n props: JsonObject,\n Fallback: React.FC<any>,\n identifier: string,\n ): MappedComponent => {\n if (
|
|
1
|
+
{"version":3,"sources":["../../../../src/providers/Config/createClientConfig/getCreateMappedComponent.tsx"],"sourcesContent":["import type { I18nClient } from '@payloadcms/translations'\nimport type {\n CreateMappedComponent,\n ImportMap,\n JsonObject,\n MappedComponent,\n Payload,\n PayloadComponent,\n} from 'payload'\n\nimport { isReactServerComponentOrFunction } from 'payload/shared'\nimport React from 'react'\n\nimport { getComponent } from './getComponent.js'\n\nexport function getCreateMappedComponent({\n importMap,\n serverProps,\n}: {\n importMap: ImportMap\n serverProps: {\n [key: string]: any\n i18n?: I18nClient\n payload?: Payload\n }\n}): CreateMappedComponent {\n const createSingleMappedComponent = (\n payloadComponent: { ReactComponent: React.FC<any> } | PayloadComponent,\n key: number | string,\n props: JsonObject,\n Fallback: React.FC<any>,\n identifier: string,\n ): MappedComponent => {\n if (payloadComponent === undefined || payloadComponent === null) {\n if (!Fallback) {\n return undefined\n }\n\n if (isReactServerComponentOrFunction(Fallback)) {\n return {\n type: 'server',\n Component: null,\n RenderedComponent: <Fallback key={key} {...serverProps} {...props} />,\n }\n } else {\n const toReturn: MappedComponent = {\n type: 'client',\n Component: Fallback,\n }\n\n // conditionally set props here to avoid bloating the HTML with `$undefined` props\n if (props) toReturn.props = props\n\n return toReturn\n }\n }\n\n if (payloadComponent === false) {\n return {\n type: 'empty',\n }\n }\n\n const resolvedComponent =\n payloadComponent &&\n typeof payloadComponent === 'object' &&\n 'ReactComponent' in payloadComponent\n ? {\n Component: payloadComponent.ReactComponent,\n }\n : getComponent({\n identifier,\n importMap,\n payloadComponent: payloadComponent as any,\n })\n\n if (!resolvedComponent.Component) {\n console.error(`getCreateMappedComponent: Component not found in importMap`, {\n identifier,\n key,\n })\n }\n\n if (isReactServerComponentOrFunction(resolvedComponent.Component)) {\n const Component: React.FC<any> = resolvedComponent.Component\n\n return {\n type: 'server',\n Component: null,\n RenderedComponent: (\n <Component key={key} {...serverProps} {...resolvedComponent.serverProps} {...props} />\n ),\n }\n } else {\n if (!resolvedComponent.Component) {\n return undefined\n }\n\n return {\n type: 'client',\n Component: resolvedComponent.Component,\n props: {\n ...(resolvedComponent.clientProps || {}),\n ...props,\n },\n }\n }\n }\n\n const createMappedComponent: CreateMappedComponent = (\n payloadComponent,\n props,\n fallback,\n identifier,\n ) => {\n if ((payloadComponent === undefined || payloadComponent === null) && !fallback) {\n return undefined as any\n }\n\n if (payloadComponent && Array.isArray(payloadComponent)) {\n const mappedComponents: MappedComponent[] = []\n for (let i = 0; i < payloadComponent.length; i++) {\n const component = createSingleMappedComponent(\n payloadComponent[i],\n i,\n props,\n fallback,\n identifier,\n )\n mappedComponents.push(component)\n }\n return mappedComponents as any\n } else {\n return createSingleMappedComponent(\n payloadComponent,\n undefined,\n props,\n fallback,\n identifier,\n ) as any\n }\n }\n\n return createMappedComponent\n}\n"],"names":["isReactServerComponentOrFunction","React","getComponent","getCreateMappedComponent","importMap","serverProps","createSingleMappedComponent","payloadComponent","key","props","Fallback","identifier","undefined","type","Component","RenderedComponent","toReturn","resolvedComponent","ReactComponent","console","error","clientProps","createMappedComponent","fallback","Array","isArray","mappedComponents","i","length","component","push"],"mappings":";AAUA,SAASA,gCAAgC,QAAQ,iBAAgB;AACjE,OAAOC,WAAW,QAAO;AAEzB,SAASC,YAAY,QAAQ,oBAAmB;AAEhD,OAAO,SAASC,yBAAyB,EACvCC,SAAS,EACTC,WAAW,EAQZ;IACC,MAAMC,8BAA8B,CAClCC,kBACAC,KACAC,OACAC,UACAC;QAEA,IAAIJ,qBAAqBK,aAAaL,qBAAqB,MAAM;YAC/D,IAAI,CAACG,UAAU;gBACb,OAAOE;YACT;YAEA,IAAIZ,iCAAiCU,WAAW;gBAC9C,OAAO;oBACLG,MAAM;oBACNC,WAAW;oBACXC,iCAAmB,KAACL;wBAAoB,GAAGL,WAAW;wBAAG,GAAGI,KAAK;uBAA/BD;gBACpC;YACF,OAAO;gBACL,MAAMQ,WAA4B;oBAChCH,MAAM;oBACNC,WAAWJ;gBACb;gBAEA,kFAAkF;gBAClF,IAAID,OAAOO,SAASP,KAAK,GAAGA;gBAE5B,OAAOO;YACT;QACF;QAEA,IAAIT,qBAAqB,OAAO;YAC9B,OAAO;gBACLM,MAAM;YACR;QACF;QAEA,MAAMI,oBACJV,oBACA,OAAOA,qBAAqB,YAC5B,oBAAoBA,mBAChB;YACEO,WAAWP,iBAAiBW,cAAc;QAC5C,IACAhB,aAAa;YACXS;YACAP;YACAG,kBAAkBA;QACpB;QAEN,IAAI,CAACU,kBAAkBH,SAAS,EAAE;YAChCK,QAAQC,KAAK,CAAC,CAAC,0DAA0D,CAAC,EAAE;gBAC1ET;gBACAH;YACF;QACF;QAEA,IAAIR,iCAAiCiB,kBAAkBH,SAAS,GAAG;YACjE,MAAMA,YAA2BG,kBAAkBH,SAAS;YAE5D,OAAO;gBACLD,MAAM;gBACNC,WAAW;gBACXC,iCACE,KAACD;oBAAqB,GAAGT,WAAW;oBAAG,GAAGY,kBAAkBZ,WAAW;oBAAG,GAAGI,KAAK;mBAAlED;YAEpB;QACF,OAAO;YACL,IAAI,CAACS,kBAAkBH,SAAS,EAAE;gBAChC,OAAOF;YACT;YAEA,OAAO;gBACLC,MAAM;gBACNC,WAAWG,kBAAkBH,SAAS;gBACtCL,OAAO;oBACL,GAAIQ,kBAAkBI,WAAW,IAAI,CAAC,CAAC;oBACvC,GAAGZ,KAAK;gBACV;YACF;QACF;IACF;IAEA,MAAMa,wBAA+C,CACnDf,kBACAE,OACAc,UACAZ;QAEA,IAAI,AAACJ,CAAAA,qBAAqBK,aAAaL,qBAAqB,IAAG,KAAM,CAACgB,UAAU;YAC9E,OAAOX;QACT;QAEA,IAAIL,oBAAoBiB,MAAMC,OAAO,CAAClB,mBAAmB;YACvD,MAAMmB,mBAAsC,EAAE;YAC9C,IAAK,IAAIC,IAAI,GAAGA,IAAIpB,iBAAiBqB,MAAM,EAAED,IAAK;gBAChD,MAAME,YAAYvB,4BAChBC,gBAAgB,CAACoB,EAAE,EACnBA,GACAlB,OACAc,UACAZ;gBAEFe,iBAAiBI,IAAI,CAACD;YACxB;YACA,OAAOH;QACT,OAAO;YACL,OAAOpB,4BACLC,kBACAK,WACAH,OACAc,UACAZ;QAEJ;IACF;IAEA,OAAOW;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"globals.d.ts","sourceRoot":"","sources":["../../../../src/providers/Config/createClientConfig/globals.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,KAAK,EACV,kBAAkB,EAClB,qBAAqB,EAErB,aAAa,EACb,SAAS,EAET,OAAO,EACP,eAAe,EAGhB,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAM9B,eAAO,MAAM,wBAAwB,gGAQlC;IACD,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CAAC,CAAA;IACxC,YAAY,EAAE,kBAAkB,CAAA;IAChC,qBAAqB,EAAE,qBAAqB,CAAA;IAC5C,MAAM,EAAE,eAAe,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAA;IACrC,IAAI,EAAE,UAAU,CAAA;IAChB,SAAS,EAAE,SAAS,CAAA;IACpB,OAAO,EAAE,OAAO,CAAA;CACjB,KAAG,
|
|
1
|
+
{"version":3,"file":"globals.d.ts","sourceRoot":"","sources":["../../../../src/providers/Config/createClientConfig/globals.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,KAAK,EACV,kBAAkB,EAClB,qBAAqB,EAErB,aAAa,EACb,SAAS,EAET,OAAO,EACP,eAAe,EAGhB,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAM9B,eAAO,MAAM,wBAAwB,gGAQlC;IACD,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CAAC,CAAA;IACxC,YAAY,EAAE,kBAAkB,CAAA;IAChC,qBAAqB,EAAE,qBAAqB,CAAA;IAC5C,MAAM,EAAE,eAAe,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAA;IACrC,IAAI,EAAE,UAAU,CAAA;IAChB,SAAS,EAAE,SAAS,CAAA;IACpB,OAAO,EAAE,OAAO,CAAA;CACjB,KAAG,kBA6JH,CAAA;AAED,eAAO,MAAM,yBAAyB,kGAQnC;IACD,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CAAC,CAAA;IACxC,aAAa,EAAE,kBAAkB,EAAE,CAAA;IACnC,qBAAqB,EAAE,qBAAqB,CAAA;IAC5C,OAAO,EAAE,eAAe,CAAC,SAAS,CAAC,CAAA;IACnC,IAAI,EAAE,UAAU,CAAA;IAChB,SAAS,EAAE,SAAS,CAAA;IACpB,OAAO,EAAE,OAAO,CAAA;CACjB,KAAG,kBAAkB,EAerB,CAAA"}
|
|
@@ -57,7 +57,7 @@ export const createClientGlobalConfig = ({ DefaultEditView, clientGlobal, create
|
|
|
57
57
|
clientGlobal.admin.components.views.edit = {};
|
|
58
58
|
}
|
|
59
59
|
clientGlobal.admin.components.views.edit.default = {
|
|
60
|
-
Component: createMappedComponent(hasEditView && 'Component' in global.admin.components.views.edit.default && global.admin.components.views.edit.default.Component, {
|
|
60
|
+
Component: createMappedComponent(hasEditView && 'Component' in global.admin.components.views.edit.default && global.admin.components.views.edit.default.Component ? global.admin.components.views.edit.default.Component : null, {
|
|
61
61
|
globalSlug: global.slug
|
|
62
62
|
}, DefaultEditView, 'global.admin.components.views.edit.default')
|
|
63
63
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/providers/Config/createClientConfig/globals.tsx"],"sourcesContent":["import type { I18nClient } from '@payloadcms/translations'\nimport type {\n ClientGlobalConfig,\n CreateMappedComponent,\n EditViewConfig,\n EditViewProps,\n ImportMap,\n MappedView,\n Payload,\n SanitizedConfig,\n ServerOnlyGlobalAdminProperties,\n ServerOnlyGlobalProperties,\n} from 'payload'\nimport type React from 'react'\n\nimport { deepCopyObjectSimple } from 'payload'\n\nimport { createClientFields } from './fields.js'\n\nexport const createClientGlobalConfig = ({\n DefaultEditView,\n clientGlobal,\n createMappedComponent,\n global,\n i18n,\n importMap,\n payload,\n}: {\n DefaultEditView: React.FC<EditViewProps>\n clientGlobal: ClientGlobalConfig\n createMappedComponent: CreateMappedComponent\n global: SanitizedConfig['globals'][0]\n i18n: I18nClient\n importMap: ImportMap\n payload: Payload\n}): ClientGlobalConfig => {\n clientGlobal.fields = createClientFields({\n clientFields: clientGlobal.fields,\n createMappedComponent,\n fields: global.fields,\n i18n,\n importMap,\n payload,\n })\n\n const serverOnlyProperties: Partial<ServerOnlyGlobalProperties>[] = [\n 'hooks',\n 'access',\n 'endpoints',\n 'custom',\n // `admin` is handled separately\n ]\n\n serverOnlyProperties.forEach((key) => {\n if (key in clientGlobal) {\n delete clientGlobal[key]\n }\n })\n\n if ('admin' in clientGlobal) {\n const serverOnlyGlobalAdminProperties: Partial<ServerOnlyGlobalAdminProperties>[] = [\n 'hidden',\n 'preview',\n ]\n\n serverOnlyGlobalAdminProperties.forEach((key) => {\n if (key in clientGlobal.admin) {\n delete clientGlobal.admin[key]\n }\n })\n\n if (global.admin.preview) {\n clientGlobal._isPreviewEnabled = true\n }\n\n clientGlobal.admin.components = {} as ClientGlobalConfig['admin']['components']\n\n if (global?.admin?.components) {\n if (global.admin.components.elements) {\n clientGlobal.admin.components.elements =\n {} as ClientGlobalConfig['admin']['components']['elements']\n\n if (global.admin.components.elements?.PreviewButton) {\n clientGlobal.admin.components.elements.PreviewButton = createMappedComponent(\n global.admin.components.elements.PreviewButton,\n undefined,\n undefined,\n 'global.admin.components.elements.PreviewButton',\n )\n }\n\n if (global.admin.components.elements?.PublishButton) {\n clientGlobal.admin.components.elements.PublishButton = createMappedComponent(\n global.admin.components.elements.PublishButton,\n undefined,\n undefined,\n 'global.admin.components.elements.PublishButton',\n )\n }\n\n if (global.admin.components.elements?.SaveButton) {\n clientGlobal.admin.components.elements.SaveButton = createMappedComponent(\n global.admin.components.elements.SaveButton,\n undefined,\n undefined,\n 'global.admin.components.elements.SaveButton',\n )\n }\n\n if (global.admin.components.elements?.SaveDraftButton) {\n clientGlobal.admin.components.elements.SaveDraftButton = createMappedComponent(\n global.admin.components.elements.SaveDraftButton,\n undefined,\n undefined,\n 'global.admin.components.elements.SaveDraftButton',\n )\n }\n }\n }\n\n clientGlobal.admin.components.views = (\n global?.admin?.components?.views ? deepCopyObjectSimple(global?.admin?.components?.views) : {}\n ) as ClientGlobalConfig['admin']['components']['views']\n\n const hasEditView =\n 'admin' in global &&\n 'components' in global.admin &&\n 'views' in global.admin.components &&\n 'edit' in global.admin.components.views &&\n 'default' in global.admin.components.views.edit\n\n if (!clientGlobal.admin.components.views.edit) {\n clientGlobal.admin.components.views.edit =\n {} as ClientGlobalConfig['admin']['components']['views']['edit']\n }\n\n clientGlobal.admin.components.views.edit.default = {\n Component: createMappedComponent(\n hasEditView &&\n 'Component' in global.admin.components.views.edit.default &&\n global.admin.components.views.edit.default.Component,\n {\n globalSlug: global.slug,\n },\n DefaultEditView,\n 'global.admin.components.views.edit.default',\n ),\n }\n\n if (global?.admin?.components?.views?.edit) {\n for (const key in global.admin.components.views.edit) {\n const view: EditViewConfig = global.admin.components.views.edit[key]\n if (!clientGlobal.admin.components.views.edit[key]) {\n clientGlobal.admin.components.views.edit[key] = {} as MappedView\n }\n\n if ('Component' in view && key !== 'default') {\n clientGlobal.admin.components.views.edit[key].Component = createMappedComponent(\n view.Component,\n {\n globalSlug: global.slug,\n },\n undefined,\n 'global.admin.components.views.edit.key.Component',\n )\n }\n\n if ('actions' in view && view.actions?.length) {\n clientGlobal.admin.components.views.edit[key].actions = view.actions.map((Component) =>\n createMappedComponent(\n Component,\n undefined,\n undefined,\n 'global.admin.components.views.key.actions',\n ),\n )\n }\n }\n }\n\n if (\n 'livePreview' in clientGlobal.admin &&\n clientGlobal.admin.livePreview &&\n 'url' in clientGlobal.admin.livePreview\n ) {\n delete clientGlobal.admin.livePreview.url\n }\n }\n\n return clientGlobal\n}\n\nexport const createClientGlobalConfigs = ({\n DefaultEditView,\n clientGlobals,\n createMappedComponent,\n globals,\n i18n,\n importMap,\n payload,\n}: {\n DefaultEditView: React.FC<EditViewProps>\n clientGlobals: ClientGlobalConfig[]\n createMappedComponent: CreateMappedComponent\n globals: SanitizedConfig['globals']\n i18n: I18nClient\n importMap: ImportMap\n payload: Payload\n}): ClientGlobalConfig[] => {\n for (let i = 0; i < globals.length; i++) {\n const global = globals[i]\n const clientGlobal = clientGlobals[i]\n clientGlobals[i] = createClientGlobalConfig({\n DefaultEditView,\n clientGlobal,\n createMappedComponent,\n global,\n i18n,\n importMap,\n payload,\n })\n }\n return clientGlobals\n}\n"],"names":["deepCopyObjectSimple","createClientFields","createClientGlobalConfig","DefaultEditView","clientGlobal","createMappedComponent","global","i18n","importMap","payload","fields","clientFields","serverOnlyProperties","forEach","key","serverOnlyGlobalAdminProperties","admin","preview","_isPreviewEnabled","components","elements","PreviewButton","undefined","PublishButton","SaveButton","SaveDraftButton","views","hasEditView","edit","default","Component","globalSlug","slug","view","actions","length","map","livePreview","url","createClientGlobalConfigs","clientGlobals","globals","i"],"mappings":"AAeA,SAASA,oBAAoB,QAAQ,UAAS;AAE9C,SAASC,kBAAkB,QAAQ,cAAa;AAEhD,OAAO,MAAMC,2BAA2B,CAAC,EACvCC,eAAe,EACfC,YAAY,EACZC,qBAAqB,EACrBC,MAAM,EACNC,IAAI,EACJC,SAAS,EACTC,OAAO,EASR;IACCL,aAAaM,MAAM,GAAGT,mBAAmB;QACvCU,cAAcP,aAAaM,MAAM;QACjCL;QACAK,QAAQJ,OAAOI,MAAM;QACrBH;QACAC;QACAC;IACF;IAEA,MAAMG,uBAA8D;QAClE;QACA;QACA;QACA;KAED;IAEDA,qBAAqBC,OAAO,CAAC,CAACC;QAC5B,IAAIA,OAAOV,cAAc;YACvB,OAAOA,YAAY,CAACU,IAAI;QAC1B;IACF;IAEA,IAAI,WAAWV,cAAc;QAC3B,MAAMW,kCAA8E;YAClF;YACA;SACD;QAEDA,gCAAgCF,OAAO,CAAC,CAACC;YACvC,IAAIA,OAAOV,aAAaY,KAAK,EAAE;gBAC7B,OAAOZ,aAAaY,KAAK,CAACF,IAAI;YAChC;QACF;QAEA,IAAIR,OAAOU,KAAK,CAACC,OAAO,EAAE;YACxBb,aAAac,iBAAiB,GAAG;QACnC;QAEAd,aAAaY,KAAK,CAACG,UAAU,GAAG,CAAC;QAEjC,IAAIb,QAAQU,OAAOG,YAAY;YAC7B,IAAIb,OAAOU,KAAK,CAACG,UAAU,CAACC,QAAQ,EAAE;gBACpChB,aAAaY,KAAK,CAACG,UAAU,CAACC,QAAQ,GACpC,CAAC;gBAEH,IAAId,OAAOU,KAAK,CAACG,UAAU,CAACC,QAAQ,EAAEC,eAAe;oBACnDjB,aAAaY,KAAK,CAACG,UAAU,CAACC,QAAQ,CAACC,aAAa,GAAGhB,sBACr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,KAAK,CAACqB,WAAW,IAC9B,SAASjC,aAAaY,KAAK,CAACqB,WAAW,EACvC;YACA,OAAOjC,aAAaY,KAAK,CAACqB,WAAW,CAACC,GAAG;QAC3C;IACF;IAEA,OAAOlC;AACT,EAAC;AAED,OAAO,MAAMmC,4BAA4B,CAAC,EACxCpC,eAAe,EACfqC,aAAa,EACbnC,qBAAqB,EACrBoC,OAAO,EACPlC,IAAI,EACJC,SAAS,EACTC,OAAO,EASR;IACC,IAAK,IAAIiC,IAAI,GAAGA,IAAID,QAAQN,MAAM,EAAEO,IAAK;QACvC,MAAMpC,SAASmC,OAAO,CAACC,EAAE;QACzB,MAAMtC,eAAeoC,aAAa,CAACE,EAAE;QACrCF,aAAa,CAACE,EAAE,GAAGxC,yBAAyB;YAC1CC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;QACF;IACF;IACA,OAAO+B;AACT,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/providers/Config/createClientConfig/globals.tsx"],"sourcesContent":["import type { I18nClient } from '@payloadcms/translations'\nimport type {\n ClientGlobalConfig,\n CreateMappedComponent,\n EditViewConfig,\n EditViewProps,\n ImportMap,\n MappedView,\n Payload,\n SanitizedConfig,\n ServerOnlyGlobalAdminProperties,\n ServerOnlyGlobalProperties,\n} from 'payload'\nimport type React from 'react'\n\nimport { deepCopyObjectSimple } from 'payload'\n\nimport { createClientFields } from './fields.js'\n\nexport const createClientGlobalConfig = ({\n DefaultEditView,\n clientGlobal,\n createMappedComponent,\n global,\n i18n,\n importMap,\n payload,\n}: {\n DefaultEditView: React.FC<EditViewProps>\n clientGlobal: ClientGlobalConfig\n createMappedComponent: CreateMappedComponent\n global: SanitizedConfig['globals'][0]\n i18n: I18nClient\n importMap: ImportMap\n payload: Payload\n}): ClientGlobalConfig => {\n clientGlobal.fields = createClientFields({\n clientFields: clientGlobal.fields,\n createMappedComponent,\n fields: global.fields,\n i18n,\n importMap,\n payload,\n })\n\n const serverOnlyProperties: Partial<ServerOnlyGlobalProperties>[] = [\n 'hooks',\n 'access',\n 'endpoints',\n 'custom',\n // `admin` is handled separately\n ]\n\n serverOnlyProperties.forEach((key) => {\n if (key in clientGlobal) {\n delete clientGlobal[key]\n }\n })\n\n if ('admin' in clientGlobal) {\n const serverOnlyGlobalAdminProperties: Partial<ServerOnlyGlobalAdminProperties>[] = [\n 'hidden',\n 'preview',\n ]\n\n serverOnlyGlobalAdminProperties.forEach((key) => {\n if (key in clientGlobal.admin) {\n delete clientGlobal.admin[key]\n }\n })\n\n if (global.admin.preview) {\n clientGlobal._isPreviewEnabled = true\n }\n\n clientGlobal.admin.components = {} as ClientGlobalConfig['admin']['components']\n\n if (global?.admin?.components) {\n if (global.admin.components.elements) {\n clientGlobal.admin.components.elements =\n {} as ClientGlobalConfig['admin']['components']['elements']\n\n if (global.admin.components.elements?.PreviewButton) {\n clientGlobal.admin.components.elements.PreviewButton = createMappedComponent(\n global.admin.components.elements.PreviewButton,\n undefined,\n undefined,\n 'global.admin.components.elements.PreviewButton',\n )\n }\n\n if (global.admin.components.elements?.PublishButton) {\n clientGlobal.admin.components.elements.PublishButton = createMappedComponent(\n global.admin.components.elements.PublishButton,\n undefined,\n undefined,\n 'global.admin.components.elements.PublishButton',\n )\n }\n\n if (global.admin.components.elements?.SaveButton) {\n clientGlobal.admin.components.elements.SaveButton = createMappedComponent(\n global.admin.components.elements.SaveButton,\n undefined,\n undefined,\n 'global.admin.components.elements.SaveButton',\n )\n }\n\n if (global.admin.components.elements?.SaveDraftButton) {\n clientGlobal.admin.components.elements.SaveDraftButton = createMappedComponent(\n global.admin.components.elements.SaveDraftButton,\n undefined,\n undefined,\n 'global.admin.components.elements.SaveDraftButton',\n )\n }\n }\n }\n\n clientGlobal.admin.components.views = (\n global?.admin?.components?.views ? deepCopyObjectSimple(global?.admin?.components?.views) : {}\n ) as ClientGlobalConfig['admin']['components']['views']\n\n const hasEditView =\n 'admin' in global &&\n 'components' in global.admin &&\n 'views' in global.admin.components &&\n 'edit' in global.admin.components.views &&\n 'default' in global.admin.components.views.edit\n\n if (!clientGlobal.admin.components.views.edit) {\n clientGlobal.admin.components.views.edit =\n {} as ClientGlobalConfig['admin']['components']['views']['edit']\n }\n\n clientGlobal.admin.components.views.edit.default = {\n Component: createMappedComponent(\n hasEditView &&\n 'Component' in global.admin.components.views.edit.default &&\n global.admin.components.views.edit.default.Component\n ? global.admin.components.views.edit.default.Component\n : null,\n {\n globalSlug: global.slug,\n },\n DefaultEditView,\n 'global.admin.components.views.edit.default',\n ),\n }\n\n if (global?.admin?.components?.views?.edit) {\n for (const key in global.admin.components.views.edit) {\n const view: EditViewConfig = global.admin.components.views.edit[key]\n if (!clientGlobal.admin.components.views.edit[key]) {\n clientGlobal.admin.components.views.edit[key] = {} as MappedView\n }\n\n if ('Component' in view && key !== 'default') {\n clientGlobal.admin.components.views.edit[key].Component = createMappedComponent(\n view.Component,\n {\n globalSlug: global.slug,\n },\n undefined,\n 'global.admin.components.views.edit.key.Component',\n )\n }\n\n if ('actions' in view && view.actions?.length) {\n clientGlobal.admin.components.views.edit[key].actions = view.actions.map((Component) =>\n createMappedComponent(\n Component,\n undefined,\n undefined,\n 'global.admin.components.views.key.actions',\n ),\n )\n }\n }\n }\n\n if (\n 'livePreview' in clientGlobal.admin &&\n clientGlobal.admin.livePreview &&\n 'url' in clientGlobal.admin.livePreview\n ) {\n delete clientGlobal.admin.livePreview.url\n }\n }\n\n return clientGlobal\n}\n\nexport const createClientGlobalConfigs = ({\n DefaultEditView,\n clientGlobals,\n createMappedComponent,\n globals,\n i18n,\n importMap,\n payload,\n}: {\n DefaultEditView: React.FC<EditViewProps>\n clientGlobals: ClientGlobalConfig[]\n createMappedComponent: CreateMappedComponent\n globals: SanitizedConfig['globals']\n i18n: I18nClient\n importMap: ImportMap\n payload: Payload\n}): ClientGlobalConfig[] => {\n for (let i = 0; i < globals.length; i++) {\n const global = globals[i]\n const clientGlobal = clientGlobals[i]\n clientGlobals[i] = createClientGlobalConfig({\n DefaultEditView,\n clientGlobal,\n createMappedComponent,\n global,\n i18n,\n importMap,\n payload,\n })\n }\n return clientGlobals\n}\n"],"names":["deepCopyObjectSimple","createClientFields","createClientGlobalConfig","DefaultEditView","clientGlobal","createMappedComponent","global","i18n","importMap","payload","fields","clientFields","serverOnlyProperties","forEach","key","serverOnlyGlobalAdminProperties","admin","preview","_isPreviewEnabled","components","elements","PreviewButton","undefined","PublishButton","SaveButton","SaveDraftButton","views","hasEditView","edit","default","Component","globalSlug","slug","view","actions","length","map","livePreview","url","createClientGlobalConfigs","clientGlobals","globals","i"],"mappings":"AAeA,SAASA,oBAAoB,QAAQ,UAAS;AAE9C,SAASC,kBAAkB,QAAQ,cAAa;AAEhD,OAAO,MAAMC,2BAA2B,CAAC,EACvCC,eAAe,EACfC,YAAY,EACZC,qBAAqB,EACrBC,MAAM,EACNC,IAAI,EACJC,SAAS,EACTC,OAAO,EASR;IACCL,aAAaM,MAAM,GAAGT,mBAAmB;QACvCU,cAAcP,aAAaM,MAAM;QACjCL;QACAK,QAAQJ,OAAOI,MAAM;QACrBH;QACAC;QACAC;IACF;IAEA,MAAMG,uBAA8D;QAClE;QACA;QACA;QACA;KAED;IAEDA,qBAAqBC,OAAO,CAAC,CAACC;QAC5B,IAAIA,OAAOV,cAAc;YACvB,OAAOA,YAAY,CAACU,IAAI;QAC1B;IACF;IAEA,IAAI,WAAWV,cAAc;QAC3B,MAAMW,kCAA8E;YAClF;YACA;SACD;QAEDA,gCAAgCF,OAAO,CAAC,CAACC;YACvC,IAAIA,OAAOV,aAAaY,KAAK,EAAE;gBAC7B,OAAOZ,aAAaY,KAAK,CAACF,IAAI;YAChC;QACF;QAEA,IAAIR,OAAOU,KAAK,CAACC,OAAO,EAAE;YACxBb,aAAac,iBAAiB,GAAG;QACnC;QAEAd,aAAaY,KAAK,CAACG,UAAU,GAAG,CAAC;QAEjC,IAAIb,QAAQU,OAAOG,YAAY;YAC7B,IAAIb,OAAOU,KAAK,CAACG,UAAU,CAACC,Q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