@payloadcms/ui 3.0.0-alpha.61 → 3.0.0-alpha.63
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/DocumentControls/index.js +1 -1
- package/dist/elements/DocumentControls/index.js.map +1 -1
- package/dist/elements/EditMany/index.js +2 -2
- package/dist/elements/EditMany/index.js.map +1 -1
- package/dist/elements/HydrateClientUser/index.d.ts +3 -2
- package/dist/elements/HydrateClientUser/index.d.ts.map +1 -1
- package/dist/elements/HydrateClientUser/index.js.map +1 -1
- package/dist/elements/ListControls/index.js +1 -1
- package/dist/elements/ListControls/index.js.map +1 -1
- package/dist/elements/Publish/index.js +1 -1
- package/dist/elements/Publish/index.js.map +1 -1
- package/dist/elements/Table/DefaultCell/fields/JSON/index.js +1 -1
- package/dist/elements/Table/DefaultCell/fields/JSON/index.js.map +1 -1
- package/dist/elements/TableColumns/buildColumnState.d.ts.map +1 -1
- package/dist/elements/TableColumns/buildColumnState.js +1 -0
- package/dist/elements/TableColumns/buildColumnState.js.map +1 -1
- package/dist/elements/withMergedProps/index.d.ts +2 -1
- package/dist/elements/withMergedProps/index.d.ts.map +1 -1
- package/dist/elements/withMergedProps/index.js +7 -1
- package/dist/elements/withMergedProps/index.js.map +1 -1
- package/dist/exports/elements.d.ts +3 -2
- package/dist/exports/elements.d.ts.map +1 -1
- package/dist/exports/elements.js +5 -2
- package/dist/exports/elements.js.map +1 -1
- package/dist/exports/fields.d.ts +2 -0
- package/dist/exports/fields.d.ts.map +1 -0
- package/dist/exports/fields.js +3 -0
- package/dist/exports/fields.js.map +1 -0
- package/dist/exports/providers.d.ts +2 -0
- package/dist/exports/providers.d.ts.map +1 -0
- package/dist/exports/providers.js +3 -0
- package/dist/exports/providers.js.map +1 -0
- package/dist/fields/Array/index.d.ts.map +1 -1
- package/dist/fields/Array/index.js +3 -2
- package/dist/fields/Array/index.js.map +1 -1
- package/dist/fields/Blocks/index.d.ts.map +1 -1
- package/dist/fields/Blocks/index.js +3 -2
- package/dist/fields/Blocks/index.js.map +1 -1
- package/dist/fields/Collapsible/index.d.ts.map +1 -1
- package/dist/fields/Collapsible/index.js +27 -21
- package/dist/fields/Collapsible/index.js.map +1 -1
- package/dist/fields/HiddenInput/index.d.ts +1 -1
- package/dist/fields/HiddenInput/index.d.ts.map +1 -1
- package/dist/fields/HiddenInput/index.js.map +1 -1
- package/dist/fields/JSON/index.d.ts +1 -0
- package/dist/fields/JSON/index.d.ts.map +1 -1
- package/dist/fields/JSON/index.js +20 -1
- package/dist/fields/JSON/index.js.map +1 -1
- package/dist/fields/Tabs/index.d.ts.map +1 -1
- package/dist/fields/Tabs/index.js +27 -23
- package/dist/fields/Tabs/index.js.map +1 -1
- package/dist/fields/shared/index.d.ts +1 -0
- package/dist/fields/shared/index.d.ts.map +1 -1
- package/dist/fields/shared/index.js.map +1 -1
- package/dist/forms/FieldPropsProvider/index.d.ts +2 -0
- package/dist/forms/FieldPropsProvider/index.d.ts.map +1 -1
- package/dist/forms/FieldPropsProvider/index.js +5 -3
- package/dist/forms/FieldPropsProvider/index.js.map +1 -1
- package/dist/forms/RenderFields/RenderField.d.ts +1 -0
- package/dist/forms/RenderFields/RenderField.d.ts.map +1 -1
- package/dist/forms/RenderFields/RenderField.js +2 -1
- package/dist/forms/RenderFields/RenderField.js.map +1 -1
- package/dist/forms/RenderFields/index.d.ts.map +1 -1
- package/dist/forms/RenderFields/index.js +2 -1
- package/dist/forms/RenderFields/index.js.map +1 -1
- package/dist/providers/ComponentMap/buildComponentMap/WithServerSideProps.d.ts +3 -0
- package/dist/providers/ComponentMap/buildComponentMap/WithServerSideProps.d.ts.map +1 -0
- package/dist/providers/ComponentMap/buildComponentMap/WithServerSideProps.js +19 -0
- package/dist/providers/ComponentMap/buildComponentMap/WithServerSideProps.js.map +1 -0
- package/dist/providers/ComponentMap/buildComponentMap/actions.d.ts +2 -1
- package/dist/providers/ComponentMap/buildComponentMap/actions.d.ts.map +1 -1
- package/dist/providers/ComponentMap/buildComponentMap/actions.js +7 -3
- package/dist/providers/ComponentMap/buildComponentMap/actions.js.map +1 -1
- package/dist/providers/ComponentMap/buildComponentMap/collections.d.ts +3 -2
- package/dist/providers/ComponentMap/buildComponentMap/collections.d.ts.map +1 -1
- package/dist/providers/ComponentMap/buildComponentMap/collections.js +35 -14
- package/dist/providers/ComponentMap/buildComponentMap/collections.js.map +1 -1
- package/dist/providers/ComponentMap/buildComponentMap/fields.d.ts +2 -1
- package/dist/providers/ComponentMap/buildComponentMap/fields.d.ts.map +1 -1
- package/dist/providers/ComponentMap/buildComponentMap/fields.js +46 -12
- package/dist/providers/ComponentMap/buildComponentMap/fields.js.map +1 -1
- package/dist/providers/ComponentMap/buildComponentMap/globals.d.ts +3 -2
- package/dist/providers/ComponentMap/buildComponentMap/globals.d.ts.map +1 -1
- package/dist/providers/ComponentMap/buildComponentMap/globals.js +19 -6
- package/dist/providers/ComponentMap/buildComponentMap/globals.js.map +1 -1
- package/dist/providers/ComponentMap/buildComponentMap/index.d.ts +2 -1
- package/dist/providers/ComponentMap/buildComponentMap/index.d.ts.map +1 -1
- package/dist/providers/ComponentMap/buildComponentMap/index.js +20 -4
- package/dist/providers/ComponentMap/buildComponentMap/index.js.map +1 -1
- package/dist/providers/ComponentMap/buildComponentMap/types.d.ts +2 -0
- package/dist/providers/ComponentMap/buildComponentMap/types.d.ts.map +1 -1
- package/dist/providers/ComponentMap/buildComponentMap/types.js.map +1 -1
- package/dist/providers/ComponentMap/index.d.ts +1 -0
- package/dist/providers/ComponentMap/index.d.ts.map +1 -1
- package/dist/providers/ComponentMap/index.js +1 -0
- package/dist/providers/ComponentMap/index.js.map +1 -1
- package/dist/providers/Locale/index.js +1 -1
- package/dist/providers/Locale/index.js.map +1 -1
- package/dist/scss/app.scss +2 -3
- package/dist/scss/vars.scss +0 -7
- package/package.json +9 -9
- package/dist/assets/fonts/SuisseIntl-Bold.woff +0 -0
- package/dist/assets/fonts/SuisseIntl-Bold.woff2 +0 -0
- package/dist/assets/fonts/SuisseIntl-Medium.woff +0 -0
- package/dist/assets/fonts/SuisseIntl-Medium.woff2 +0 -0
- package/dist/assets/fonts/SuisseIntl-SemiBold.woff +0 -0
- package/dist/assets/fonts/SuisseIntl-SemiBold.woff2 +0 -0
- package/dist/assets/fonts/SuisseIntl.woff +0 -0
- package/dist/assets/fonts/SuisseIntl.woff2 +0 -0
- package/dist/assets/fonts/merriweather-v30-latin-900.woff +0 -0
- package/dist/assets/fonts/merriweather-v30-latin-900.woff2 +0 -0
- package/dist/assets/fonts/merriweather-v30-latin-900italic.woff +0 -0
- package/dist/assets/fonts/merriweather-v30-latin-900italic.woff2 +0 -0
- package/dist/assets/fonts/merriweather-v30-latin-italic.woff +0 -0
- package/dist/assets/fonts/merriweather-v30-latin-italic.woff2 +0 -0
- package/dist/assets/fonts/merriweather-v30-latin-regular.woff +0 -0
- package/dist/assets/fonts/merriweather-v30-latin-regular.woff2 +0 -0
- package/dist/scss/fonts.scss +0 -75
|
@@ -27,12 +27,14 @@ const TabsField = (props)=>{
|
|
|
27
27
|
const [activeTabIndex, setActiveTabIndex] = useState(0);
|
|
28
28
|
const tabsPrefKey = `tabs-${indexPath}`;
|
|
29
29
|
useEffect(()=>{
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
30
|
+
if (preferencesKey) {
|
|
31
|
+
const getInitialPref = async ()=>{
|
|
32
|
+
const existingPreferences = await getPreference(preferencesKey);
|
|
33
|
+
const initialIndex = path ? existingPreferences?.fields?.[path]?.tabIndex : existingPreferences?.fields?.[tabsPrefKey]?.tabIndex;
|
|
34
|
+
setActiveTabIndex(initialIndex || 0);
|
|
35
|
+
};
|
|
36
|
+
void getInitialPref();
|
|
37
|
+
}
|
|
36
38
|
}, [
|
|
37
39
|
path,
|
|
38
40
|
getPreference,
|
|
@@ -42,26 +44,28 @@ const TabsField = (props)=>{
|
|
|
42
44
|
const handleTabChange = useCallback(async (incomingTabIndex)=>{
|
|
43
45
|
setActiveTabIndex(incomingTabIndex);
|
|
44
46
|
const existingPreferences = await getPreference(preferencesKey);
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
47
|
+
if (preferencesKey) {
|
|
48
|
+
void setPreference(preferencesKey, {
|
|
49
|
+
...existingPreferences,
|
|
50
|
+
...path ? {
|
|
51
|
+
fields: {
|
|
52
|
+
...existingPreferences?.fields || {},
|
|
53
|
+
[path]: {
|
|
54
|
+
...existingPreferences?.fields?.[path],
|
|
55
|
+
tabIndex: incomingTabIndex
|
|
56
|
+
}
|
|
53
57
|
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
} : {
|
|
59
|
+
fields: {
|
|
60
|
+
...existingPreferences?.fields,
|
|
61
|
+
[tabsPrefKey]: {
|
|
62
|
+
...existingPreferences?.fields?.[tabsPrefKey],
|
|
63
|
+
tabIndex: incomingTabIndex
|
|
64
|
+
}
|
|
61
65
|
}
|
|
62
66
|
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
65
69
|
}, [
|
|
66
70
|
preferencesKey,
|
|
67
71
|
getPreference,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/fields/Tabs/index.tsx"],"sourcesContent":["'use client'\nimport type { FieldPermissions } from 'payload/auth'\nimport type { DocumentPreferences } from 'payload/types'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { FieldDescription } from '@payloadcms/ui/forms/FieldDescription'\nimport { toKebabCase } from 'payload/utilities'\nimport React, { useCallback, useEffect, useState } from 'react'\n\nimport type { MappedTab } from '../../providers/ComponentMap/buildComponentMap/types.js'\nimport type { FormFieldBase } from '../shared/index.js'\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 { 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\nexport type TabsFieldProps = FormFieldBase & {\n forceRender?: boolean\n name?: string\n path?: string\n permissions: FieldPermissions\n tabs?: MappedTab[]\n width?: string\n}\n\nconst TabsField: React.FC<TabsFieldProps> = (props) => {\n const {\n name,\n CustomDescription,\n className,\n descriptionProps,\n forceRender = false,\n path: pathFromProps,\n readOnly: readOnlyFromProps,\n tabs = [],\n } = props\n\n const {\n indexPath,\n path: pathFromContext,\n permissions,\n readOnly: readOnlyFromContext,\n schemaPath,\n } = useFieldProps()\n const readOnly = readOnlyFromProps || readOnlyFromContext\n const path = pathFromContext || pathFromProps || name\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 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 }, [path, getPreference, preferencesKey, tabsPrefKey])\n\n const handleTabChange = useCallback(\n async (incomingTabIndex: number) => {\n setActiveTabIndex(incomingTabIndex)\n\n const existingPreferences: DocumentPreferences = await getPreference(preferencesKey)\n\n void setPreference(preferencesKey, {\n ...existingPreferences,\n ...(path\n ? {\n fields: {\n ...(existingPreferences?.fields || {}),\n [path]: {\n ...existingPreferences?.fields?.[path],\n 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 [preferencesKey, getPreference, setPreference, path, tabsPrefKey],\n )\n\n const activeTabConfig = tabs[activeTabIndex]\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={() => handleTabChange(tabIndex)}\n tab={tab}\n />\n )\n })}\n </div>\n </div>\n <div className={`${baseClass}__content-wrap`}>\n {activeTabConfig && (\n <React.Fragment>\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 {CustomDescription ? (\n CustomDescription\n ) : (\n <FieldDescription {...(descriptionProps || {})} />\n )}\n <RenderFields\n fieldMap={activeTabConfig.fieldMap}\n forceRender={forceRender}\n key={\n activeTabConfig.label\n ? getTranslation(activeTabConfig.label, i18n)\n : activeTabConfig['name']\n }\n margins=\"small\"\n path={`${path ? `${path}.` : ''}${activeTabConfig.name ? `${activeTabConfig.name}` : ''}`}\n permissions={\n 'name' in activeTabConfig && permissions?.fields?.[activeTabConfig.name]?.fields\n ? permissions?.fields?.[activeTabConfig.name]?.fields\n : permissions?.fields\n }\n readOnly={readOnly}\n schemaPath={`${schemaPath ? `${schemaPath}` : ''}${activeTabConfig.name ? `.${activeTabConfig.name}` : ''}`}\n />\n </div>\n </React.Fragment>\n )}\n </div>\n </TabsProvider>\n </div>\n )\n}\n\nexport const Tabs = withCondition(TabsField)\n"],"names":["getTranslation","FieldDescription","toKebabCase","React","useCallback","useEffect","useState","useCollapsible","useFieldProps","RenderFields","withCondition","useDocumentInfo","usePreferences","useTranslation","fieldBaseClass","TabComponent","TabsProvider","baseClass","TabsField","props","name","CustomDescription","className","descriptionProps","forceRender","path","pathFromProps","readOnly","readOnlyFromProps","tabs","indexPath","pathFromContext","permissions","readOnlyFromContext","schemaPath","getPreference","setPreference","preferencesKey","i18n","isWithinCollapsible","activeTabIndex","setActiveTabIndex","tabsPrefKey","getInitialPref","existingPreferences","initialIndex","fields","tabIndex","handleTabChange","incomingTabIndex","activeTabConfig","div","filter","Boolean","join","map","tab","isActive","key","parentPath","setIsActive","Fragment","label","fieldMap","margins","Tabs"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAIA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,SAASC,gBAAgB,QAAQ,wCAAuC;AACxE,SAASC,WAAW,QAAQ,oBAAmB;AAC/C,OAAOC,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAK/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,cAAc,QAAQ,qBAAoB;AACnD,SAASC,YAAY,QAAQ,iBAAgB;AAE7C,SAASC,YAAY,QAAQ,g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,KACER,gBAAgBY,KAAK,GACjB9D,eAAekD,gBAAgBY,KAAK,EAAExB,QACtCY,eAAe,CAAC,OAAO;QAE7Bc,SAAQ;QACRvC,MAAM,CAAC,EAAEA,OAAO,CAAC,EAAEA,KAAK,CAAC,CAAC,GAAG,GAAG,EAAEyB,gBAAgB9B,IAAI,GAAG,CAAC,EAAE8B,gBAAgB9B,IAAI,CAAC,CAAC,GAAG,GAAG,CAAC;QACzFY,aACE,UAAUkB,mBAAmBlB,aAAac,QAAQ,CAACI,gBAAgB9B,IAAI,CAAC,EAAE0B,SACtEd,aAAac,QAAQ,CAACI,gBAAgB9B,IAAI,CAAC,EAAE0B,SAC7Cd,aAAac;QAEnBnB,UAAUA;QACVO,YAAY,CAAC,EAAEA,aAAa,CAAC,EAAEA,WAAW,CAAC,GAAG,GAAG,EAAEgB,gBAAgB9B,IAAI,GAAG,CAAC,CAAC,EAAE8B,gBAAgB9B,IAAI,CAAC,CAAC,GAAG,GAAG,CAAC;;AAS7H;AAEA,OAAO,MAAM6C,OAAOvD,cAAcQ,WAAU"}
|
|
1
|
+
{"version":3,"sources":["../../../src/fields/Tabs/index.tsx"],"sourcesContent":["'use client'\nimport type { FieldPermissions } from 'payload/auth'\nimport type { DocumentPreferences } from 'payload/types'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { FieldDescription } from '@payloadcms/ui/forms/FieldDescription'\nimport { toKebabCase } from 'payload/utilities'\nimport React, { useCallback, useEffect, useState } from 'react'\n\nimport type { MappedTab } from '../../providers/ComponentMap/buildComponentMap/types.js'\nimport type { FormFieldBase } from '../shared/index.js'\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 { 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\nexport type TabsFieldProps = FormFieldBase & {\n forceRender?: boolean\n name?: string\n path?: string\n permissions: FieldPermissions\n tabs?: MappedTab[]\n width?: string\n}\n\nconst TabsField: React.FC<TabsFieldProps> = (props) => {\n const {\n name,\n CustomDescription,\n className,\n descriptionProps,\n forceRender = false,\n path: pathFromProps,\n readOnly: readOnlyFromProps,\n tabs = [],\n } = props\n\n const {\n indexPath,\n path: pathFromContext,\n permissions,\n readOnly: readOnlyFromContext,\n schemaPath,\n } = useFieldProps()\n const readOnly = readOnlyFromProps || readOnlyFromContext\n const path = pathFromContext || pathFromProps || name\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) => {\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 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={() => handleTabChange(tabIndex)}\n tab={tab}\n />\n )\n })}\n </div>\n </div>\n <div className={`${baseClass}__content-wrap`}>\n {activeTabConfig && (\n <React.Fragment>\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 {CustomDescription ? (\n CustomDescription\n ) : (\n <FieldDescription {...(descriptionProps || {})} />\n )}\n <RenderFields\n fieldMap={activeTabConfig.fieldMap}\n forceRender={forceRender}\n key={\n activeTabConfig.label\n ? getTranslation(activeTabConfig.label, i18n)\n : activeTabConfig['name']\n }\n margins=\"small\"\n path={`${path ? `${path}.` : ''}${activeTabConfig.name ? `${activeTabConfig.name}` : ''}`}\n permissions={\n 'name' in activeTabConfig && permissions?.fields?.[activeTabConfig.name]?.fields\n ? permissions?.fields?.[activeTabConfig.name]?.fields\n : permissions?.fields\n }\n readOnly={readOnly}\n schemaPath={`${schemaPath ? `${schemaPath}` : ''}${activeTabConfig.name ? `.${activeTabConfig.name}` : ''}`}\n />\n </div>\n </React.Fragment>\n )}\n </div>\n </TabsProvider>\n </div>\n )\n}\n\nexport const Tabs = withCondition(TabsField)\n"],"names":["getTranslation","FieldDescription","toKebabCase","React","useCallback","useEffect","useState","useCollapsible","useFieldProps","RenderFields","withCondition","useDocumentInfo","usePreferences","useTranslation","fieldBaseClass","TabComponent","TabsProvider","baseClass","TabsField","props","name","CustomDescription","className","descriptionProps","forceRender","path","pathFromProps","readOnly","readOnlyFromProps","tabs","indexPath","pathFromContext","permissions","readOnlyFromContext","schemaPath","getPreference","setPreference","preferencesKey","i18n","isWithinCollapsible","activeTabIndex","setActiveTabIndex","tabsPrefKey","getInitialPref","existingPreferences","initialIndex","fields","tabIndex","handleTabChange","incomingTabIndex","activeTabConfig","div","filter","Boolean","join","map","tab","isActive","key","parentPath","setIsActive","Fragment","label","fieldMap","margins","Tabs"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAIA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,SAASC,gBAAgB,QAAQ,wCAAuC;AACxE,SAASC,WAAW,QAAQ,oBAAmB;AAC/C,OAAOC,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAK/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,cAAc,QAAQ,qBAAoB;AACnD,SAASC,YAAY,QAAQ,iBAAgB;AAE7C,SAASC,YAAY,QAAQ,gBAAe;AAE5C,MAAMC,YAAY;AAElB,SAASD,YAAY,GAAE;AAWvB,MAAME,YAAsC,CAACC;IAC3C,MAAM,EACJC,IAAI,EACJC,iBAAiB,EACjBC,SAAS,EACTC,gBAAgB,EAChBC,cAAc,KAAK,EACnBC,MAA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M,CAAC,EAAEA,OAAO,CAAC,EAAEA,KAAK,CAAC,CAAC,GAAG,GAAG,EAAEyB,gBAAgB9B,IAAI,GAAG,CAAC,EAAE8B,gBAAgB9B,IAAI,CAAC,CAAC,GAAG,GAAG,CAAC;QACzFY,aACE,UAAUkB,mBAAmBlB,aAAac,QAAQ,CAACI,gBAAgB9B,IAAI,CAAC,EAAE0B,SACtEd,aAAac,QAAQ,CAACI,gBAAgB9B,IAAI,CAAC,EAAE0B,SAC7Cd,aAAac;QAEnBnB,UAAUA;QACVO,YAAY,CAAC,EAAEA,aAAa,CAAC,EAAEA,WAAW,CAAC,GAAG,GAAG,EAAEgB,gBAAgB9B,IAAI,GAAG,CAAC,CAAC,EAAE8B,gBAAgB9B,IAAI,CAAC,CAAC,GAAG,GAAG,CAAC;;AAS7H;AAEA,OAAO,MAAM6C,OAAOvD,cAAcQ,WAAU"}
|
|
@@ -10,6 +10,7 @@ export type FormFieldBase = {
|
|
|
10
10
|
CustomError?: React.ReactNode;
|
|
11
11
|
CustomLabel?: React.ReactNode;
|
|
12
12
|
className?: string;
|
|
13
|
+
custom?: Record<string, any>;
|
|
13
14
|
descriptionProps?: FieldDescriptionProps;
|
|
14
15
|
disabled?: boolean;
|
|
15
16
|
docPreferences?: DocumentPreferences;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/shared/index.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,KAAK,EAAE,MAAM,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAA;AACzE,OAAO,KAAK,EACV,mBAAmB,EACnB,UAAU,EACV,qBAAqB,EACrB,UAAU,EACV,QAAQ,EACT,MAAM,eAAe,CAAA;AAEtB,eAAO,MAAM,cAAc,eAAe,CAAA;AAE1C,MAAM,MAAM,aAAa,GAAG;IAC1B,UAAU,CAAC,EAAE,KAAK,CAAC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;IACjB,MAAM,EAAE,MAAM,CAAA;IACd,kBAAkB,CAAC,EAAE,2BAA2B,CAAA;CACjD,WAiBA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/fields/shared/index.tsx"],"sourcesContent":["import type { User } from 'payload/auth'\nimport type { Locale, SanitizedLocalizationConfig } from 'payload/config'\nimport type {\n DocumentPreferences,\n ErrorProps,\n FieldDescriptionProps,\n LabelProps,\n Validate,\n} from 'payload/types'\n\nexport const fieldBaseClass = 'field-type'\n\nexport type FormFieldBase = {\n AfterInput?: React.ReactNode\n BeforeInput?: React.ReactNode\n CustomDescription?: React.ReactNode\n CustomError?: React.ReactNode\n CustomLabel?: React.ReactNode\n className?: string\n descriptionProps?: FieldDescriptionProps\n disabled?: boolean\n docPreferences?: DocumentPreferences\n errorProps?: ErrorProps\n labelProps?: LabelProps\n locale?: Locale\n localized?: boolean\n path?: string\n readOnly?: boolean\n required?: boolean\n rtl?: boolean\n style?: React.CSSProperties\n user?: User\n validate?: Validate\n}\n\n/**\n * Determines whether a field should be displayed as right-to-left (RTL) based on its configuration, payload's localization configuration and the adming user's currently enabled locale.\n\n * @returns Whether the field should be displayed as RTL.\n */\nexport function isFieldRTL({\n fieldLocalized,\n fieldRTL,\n locale,\n localizationConfig,\n}: {\n fieldLocalized: boolean\n fieldRTL: boolean\n locale: Locale\n localizationConfig?: SanitizedLocalizationConfig\n}) {\n const hasMultipleLocales =\n locale &&\n localizationConfig &&\n localizationConfig.locales &&\n localizationConfig.locales.length > 1\n\n const isCurrentLocaleDefaultLocale = locale?.code === localizationConfig?.defaultLocale\n\n return (\n (fieldRTL !== false &&\n locale?.rtl === true &&\n (fieldLocalized ||\n (!fieldLocalized && !hasMultipleLocales) || // If there is only one locale which is also rtl, that field is rtl too\n (!fieldLocalized && isCurrentLocaleDefaultLocale))) || // If the current locale is the default locale, but the field is not localized, that field is rtl too\n fieldRTL === true\n ) // If fieldRTL is true. This should be useful for when no localization is set at all in the payload config, but you still want fields to be rtl.\n}\n"],"names":["fieldBaseClass","isFieldRTL","fieldLocalized","fieldRTL","locale","localizationConfig","hasMultipleLocales","locales","length","isCurrentLocaleDefaultLocale","code","defaultLocale","rtl"],"rangeMappings":";;;;;;;;;;;;","mappings":"AAUA,OAAO,MAAMA,iBAAiB,aAAY;
|
|
1
|
+
{"version":3,"sources":["../../../src/fields/shared/index.tsx"],"sourcesContent":["import type { User } from 'payload/auth'\nimport type { Locale, SanitizedLocalizationConfig } from 'payload/config'\nimport type {\n DocumentPreferences,\n ErrorProps,\n FieldDescriptionProps,\n LabelProps,\n Validate,\n} from 'payload/types'\n\nexport const fieldBaseClass = 'field-type'\n\nexport type FormFieldBase = {\n AfterInput?: React.ReactNode\n BeforeInput?: React.ReactNode\n CustomDescription?: React.ReactNode\n CustomError?: React.ReactNode\n CustomLabel?: React.ReactNode\n className?: string\n custom?: Record<string, any>\n descriptionProps?: FieldDescriptionProps\n disabled?: boolean\n docPreferences?: DocumentPreferences\n errorProps?: ErrorProps\n labelProps?: LabelProps\n locale?: Locale\n localized?: boolean\n path?: string\n readOnly?: boolean\n required?: boolean\n rtl?: boolean\n style?: React.CSSProperties\n user?: User\n validate?: Validate\n}\n\n/**\n * Determines whether a field should be displayed as right-to-left (RTL) based on its configuration, payload's localization configuration and the adming user's currently enabled locale.\n\n * @returns Whether the field should be displayed as RTL.\n */\nexport function isFieldRTL({\n fieldLocalized,\n fieldRTL,\n locale,\n localizationConfig,\n}: {\n fieldLocalized: boolean\n fieldRTL: boolean\n locale: Locale\n localizationConfig?: SanitizedLocalizationConfig\n}) {\n const hasMultipleLocales =\n locale &&\n localizationConfig &&\n localizationConfig.locales &&\n localizationConfig.locales.length > 1\n\n const isCurrentLocaleDefaultLocale = locale?.code === localizationConfig?.defaultLocale\n\n return (\n (fieldRTL !== false &&\n locale?.rtl === true &&\n (fieldLocalized ||\n (!fieldLocalized && !hasMultipleLocales) || // If there is only one locale which is also rtl, that field is rtl too\n (!fieldLocalized && isCurrentLocaleDefaultLocale))) || // If the current locale is the default locale, but the field is not localized, that field is rtl too\n fieldRTL === true\n ) // If fieldRTL is true. This should be useful for when no localization is set at all in the payload config, but you still want fields to be rtl.\n}\n"],"names":["fieldBaseClass","isFieldRTL","fieldLocalized","fieldRTL","locale","localizationConfig","hasMultipleLocales","locales","length","isCurrentLocaleDefaultLocale","code","defaultLocale","rtl"],"rangeMappings":";;;;;;;;;;;;","mappings":"AAUA,OAAO,MAAMA,iBAAiB,aAAY;AA0B1C;;;;CAIC,GACD,OAAO,SAASC,WAAW,EACzBC,cAAc,EACdC,QAAQ,EACRC,MAAM,EACNC,kBAAkB,EAMnB;IACC,MAAMC,qBACJF,UACAC,sBACAA,mBAAmBE,OAAO,IAC1BF,mBAAmBE,OAAO,CAACC,MAAM,GAAG;IAEtC,MAAMC,+BAA+BL,QAAQM,SAASL,oBAAoBM;IAE1E,OACE,AAACR,aAAa,SACZC,QAAQQ,QAAQ,QACfV,CAAAA,kBACE,CAACA,kBAAkB,CAACI,sBAAuB,uEAAuE;IAClH,CAACJ,kBAAkBO,4BAA4B,KAAO,qGAAqG;IAChKN,aAAa,KACb,gJAAgJ;;AACpJ"}
|
|
@@ -2,6 +2,7 @@ import type { FieldTypes } from 'payload/config';
|
|
|
2
2
|
import type { FieldPermissions } from 'payload/types';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
export type FieldPropsContextType = {
|
|
5
|
+
custom?: Record<any, string>;
|
|
5
6
|
indexPath?: string;
|
|
6
7
|
path: string;
|
|
7
8
|
permissions?: FieldPermissions;
|
|
@@ -14,6 +15,7 @@ export type FieldPropsContextType = {
|
|
|
14
15
|
};
|
|
15
16
|
export type Props = {
|
|
16
17
|
children: React.ReactNode;
|
|
18
|
+
custom?: Record<any, string>;
|
|
17
19
|
indexPath?: string;
|
|
18
20
|
path: string;
|
|
19
21
|
permissions?: FieldPermissions;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/forms/FieldPropsProvider/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAErD,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,MAAM,MAAM,qBAAqB,GAAG;IAClC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,CAAC,EAAE,gBAAgB,CAAA;IAC9B,QAAQ,EAAE,OAAO,CAAA;IACjB,UAAU,EAAE,MAAM,CAAA;IAClB,kBAAkB,EAAE;QAClB,CAAC,SAAS,EAAE,MAAM,GAAG,gBAAgB,CAAA;KACtC,CAAA;IACD,IAAI,EAAE,MAAM,UAAU,CAAA;CACvB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/forms/FieldPropsProvider/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAErD,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,MAAM,MAAM,qBAAqB,GAAG;IAClC,MAAM,CAAC,EAAE,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,CAAC,EAAE,gBAAgB,CAAA;IAC9B,QAAQ,EAAE,OAAO,CAAA;IACjB,UAAU,EAAE,MAAM,CAAA;IAClB,kBAAkB,EAAE;QAClB,CAAC,SAAS,EAAE,MAAM,GAAG,gBAAgB,CAAA;KACtC,CAAA;IACD,IAAI,EAAE,MAAM,UAAU,CAAA;CACvB,CAAA;AAaD,MAAM,MAAM,KAAK,GAAG;IAClB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,CAAC,EAAE,gBAAgB,CAAA;IAC9B,QAAQ,EAAE,OAAO,CAAA;IACjB,UAAU,EAAE,MAAM,CAAA;IAClB,kBAAkB,EAAE;QAClB,CAAC,SAAS,EAAE,MAAM,GAAG,gBAAgB,CAAA;KACtC,CAAA;IACD,IAAI,EAAE,MAAM,UAAU,CAAA;CACvB,CAAA;AAED,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CA2B9C,CAAA;AAED,eAAO,MAAM,aAAa,6BAGzB,CAAA"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
const FieldPropsContext = /*#__PURE__*/ React.createContext({
|
|
4
4
|
type: '',
|
|
5
|
+
custom: {},
|
|
5
6
|
indexPath: '',
|
|
6
7
|
path: '',
|
|
7
8
|
permissions: {},
|
|
@@ -9,10 +10,11 @@ const FieldPropsContext = /*#__PURE__*/ React.createContext({
|
|
|
9
10
|
schemaPath: '',
|
|
10
11
|
siblingPermissions: {}
|
|
11
12
|
});
|
|
12
|
-
export const FieldPropsProvider = ({ type, children, indexPath, path, permissions, readOnly, schemaPath, siblingPermissions })=>{
|
|
13
|
+
export const FieldPropsProvider = ({ type, children, custom, indexPath, path, permissions, readOnly, schemaPath, siblingPermissions })=>{
|
|
13
14
|
return /*#__PURE__*/ React.createElement(FieldPropsContext.Provider, {
|
|
14
15
|
value: {
|
|
15
16
|
type,
|
|
17
|
+
custom,
|
|
16
18
|
indexPath,
|
|
17
19
|
path,
|
|
18
20
|
permissions,
|
|
@@ -23,8 +25,8 @@ export const FieldPropsProvider = ({ type, children, indexPath, path, permission
|
|
|
23
25
|
}, children);
|
|
24
26
|
};
|
|
25
27
|
export const useFieldProps = ()=>{
|
|
26
|
-
const
|
|
27
|
-
return
|
|
28
|
+
const props = React.useContext(FieldPropsContext);
|
|
29
|
+
return props;
|
|
28
30
|
};
|
|
29
31
|
|
|
30
32
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/forms/FieldPropsProvider/index.tsx"],"sourcesContent":["'use client'\nimport type { FieldTypes } from 'payload/config'\nimport type { FieldPermissions } from 'payload/types'\n\nimport React from 'react'\n\nexport type FieldPropsContextType = {\n indexPath?: string\n path: string\n permissions?: FieldPermissions\n readOnly: boolean\n schemaPath: string\n siblingPermissions: {\n [fieldName: string]: FieldPermissions\n }\n type: keyof FieldTypes\n}\n\nconst FieldPropsContext = React.createContext<FieldPropsContextType>({\n type: '' as keyof FieldTypes,\n indexPath: '',\n path: '',\n permissions: {} as FieldPermissions,\n readOnly: false,\n schemaPath: '',\n siblingPermissions: {},\n})\n\nexport type Props = {\n children: React.ReactNode\n indexPath?: string\n path: string\n permissions?: FieldPermissions\n readOnly: boolean\n schemaPath: string\n siblingPermissions: {\n [fieldName: string]: FieldPermissions\n }\n type: keyof FieldTypes\n}\n\nexport const FieldPropsProvider: React.FC<Props> = ({\n type,\n children,\n indexPath,\n path,\n permissions,\n readOnly,\n schemaPath,\n siblingPermissions,\n}) => {\n return (\n <FieldPropsContext.Provider\n value={{\n type,\n indexPath,\n path,\n permissions,\n readOnly,\n schemaPath,\n siblingPermissions,\n }}\n >\n {children}\n </FieldPropsContext.Provider>\n )\n}\n\nexport const useFieldProps = () => {\n const
|
|
1
|
+
{"version":3,"sources":["../../../src/forms/FieldPropsProvider/index.tsx"],"sourcesContent":["'use client'\nimport type { FieldTypes } from 'payload/config'\nimport type { FieldPermissions } from 'payload/types'\n\nimport React from 'react'\n\nexport type FieldPropsContextType = {\n custom?: Record<any, string>\n indexPath?: string\n path: string\n permissions?: FieldPermissions\n readOnly: boolean\n schemaPath: string\n siblingPermissions: {\n [fieldName: string]: FieldPermissions\n }\n type: keyof FieldTypes\n}\n\nconst FieldPropsContext = React.createContext<FieldPropsContextType>({\n type: '' as keyof FieldTypes,\n custom: {},\n indexPath: '',\n path: '',\n permissions: {} as FieldPermissions,\n readOnly: false,\n schemaPath: '',\n siblingPermissions: {},\n})\n\nexport type Props = {\n children: React.ReactNode\n custom?: Record<any, string>\n indexPath?: string\n path: string\n permissions?: FieldPermissions\n readOnly: boolean\n schemaPath: string\n siblingPermissions: {\n [fieldName: string]: FieldPermissions\n }\n type: keyof FieldTypes\n}\n\nexport const FieldPropsProvider: React.FC<Props> = ({\n type,\n children,\n custom,\n indexPath,\n path,\n permissions,\n readOnly,\n schemaPath,\n siblingPermissions,\n}) => {\n return (\n <FieldPropsContext.Provider\n value={{\n type,\n custom,\n indexPath,\n path,\n permissions,\n readOnly,\n schemaPath,\n siblingPermissions,\n }}\n >\n {children}\n </FieldPropsContext.Provider>\n )\n}\n\nexport const useFieldProps = () => {\n const props = React.useContext(FieldPropsContext)\n return props\n}\n"],"names":["React","FieldPropsContext","createContext","type","custom","indexPath","path","permissions","readOnly","schemaPath","siblingPermissions","FieldPropsProvider","children","Provider","value","useFieldProps","props","useContext"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAIA,OAAOA,WAAW,QAAO;AAezB,MAAMC,kCAAoBD,MAAME,aAAa,CAAwB;IACnEC,MAAM;IACNC,QAAQ,CAAC;IACTC,WAAW;IACXC,MAAM;IACNC,aAAa,CAAC;IACdC,UAAU;IACVC,YAAY;IACZC,oBAAoB,CAAC;AACvB;AAgBA,OAAO,MAAMC,qBAAsC,CAAC,EAClDR,IAAI,EACJS,QAAQ,EACRR,MAAM,EACNC,SAAS,EACTC,IAAI,EACJC,WAAW,EACXC,QAAQ,EACRC,UAAU,EACVC,kBAAkB,EACnB;IACC,qBACE,oBAACT,kBAAkBY,QAAQ;QACzBC,OAAO;YACLX;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;QACF;OAECE;AAGP,EAAC;AAED,OAAO,MAAMG,gBAAgB;IAC3B,MAAMC,QAAQhB,MAAMiB,UAAU,CAAChB;IAC/B,OAAOe;AACT,EAAC"}
|
|
@@ -4,6 +4,7 @@ import React from 'react';
|
|
|
4
4
|
import type { FieldComponentProps, MappedField } from '../../providers/ComponentMap/buildComponentMap/types.js';
|
|
5
5
|
type Props = {
|
|
6
6
|
CustomField: MappedField['CustomField'];
|
|
7
|
+
custom?: Record<any, string>;
|
|
7
8
|
disabled: boolean;
|
|
8
9
|
fieldComponentProps?: FieldComponentProps;
|
|
9
10
|
indexPath?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RenderField.d.ts","sourceRoot":"","sources":["../../../src/forms/RenderFields/RenderField.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAErD,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EACV,mBAAmB,EACnB,WAAW,EACZ,MAAM,yDAAyD,CAAA;AAOhE,KAAK,KAAK,GAAG;IACX,WAAW,EAAE,WAAW,CAAC,aAAa,CAAC,CAAA;IACvC,QAAQ,EAAE,OAAO,CAAA;IACjB,mBAAmB,CAAC,EAAE,mBAAmB,CAAA;IACzC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,CAAC,EAAE,gBAAgB,CAAA;IAC9B,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,kBAAkB,EAAE;QAClB,CAAC,SAAS,EAAE,MAAM,GAAG,gBAAgB,CAAA;KACtC,CAAA;IACD,IAAI,EAAE,MAAM,UAAU,CAAA;CACvB,CAAA;AAED,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,
|
|
1
|
+
{"version":3,"file":"RenderField.d.ts","sourceRoot":"","sources":["../../../src/forms/RenderFields/RenderField.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAErD,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EACV,mBAAmB,EACnB,WAAW,EACZ,MAAM,yDAAyD,CAAA;AAOhE,KAAK,KAAK,GAAG;IACX,WAAW,EAAE,WAAW,CAAC,aAAa,CAAC,CAAA;IACvC,MAAM,CAAC,EAAE,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;IAC5B,QAAQ,EAAE,OAAO,CAAA;IACjB,mBAAmB,CAAC,EAAE,mBAAmB,CAAA;IACzC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,CAAC,EAAE,gBAAgB,CAAA;IAC9B,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,kBAAkB,EAAE;QAClB,CAAC,SAAS,EAAE,MAAM,GAAG,gBAAgB,CAAA;KACtC,CAAA;IACD,IAAI,EAAE,MAAM,UAAU,CAAA;CACvB,CAAA;AAED,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CA2DvC,CAAA"}
|
|
@@ -4,7 +4,7 @@ import { HiddenInput } from '../../fields/HiddenInput/index.js';
|
|
|
4
4
|
import { useFieldComponents } from '../../providers/FieldComponents/index.js';
|
|
5
5
|
import { useOperation } from '../../providers/Operation/index.js';
|
|
6
6
|
import { FieldPropsProvider, useFieldProps } from '../FieldPropsProvider/index.js';
|
|
7
|
-
export const RenderField = ({ name, type, CustomField, disabled, fieldComponentProps, indexPath, isHidden, path: pathFromProps, permissions, readOnly: readOnlyFromProps, schemaPath: schemaPathFromProps, siblingPermissions })=>{
|
|
7
|
+
export const RenderField = ({ name, type, CustomField, custom, disabled, fieldComponentProps, indexPath, isHidden, path: pathFromProps, permissions, readOnly: readOnlyFromProps, schemaPath: schemaPathFromProps, siblingPermissions })=>{
|
|
8
8
|
const operation = useOperation();
|
|
9
9
|
const { readOnly: readOnlyFromContext } = useFieldProps();
|
|
10
10
|
const fieldComponents = useFieldComponents();
|
|
@@ -34,6 +34,7 @@ export const RenderField = ({ name, type, CustomField, disabled, fieldComponentP
|
|
|
34
34
|
return null;
|
|
35
35
|
}
|
|
36
36
|
return /*#__PURE__*/ React.createElement(FieldPropsProvider, {
|
|
37
|
+
custom: custom,
|
|
37
38
|
indexPath: indexPath,
|
|
38
39
|
path: path,
|
|
39
40
|
permissions: permissions,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/forms/RenderFields/RenderField.tsx"],"sourcesContent":["'use client'\n\nimport type { FieldTypes } from 'payload/config'\nimport type { FieldPermissions } from 'payload/types'\n\nimport React from 'react'\n\nimport type {\n FieldComponentProps,\n MappedField,\n} from '../../providers/ComponentMap/buildComponentMap/types.js'\n\nimport { HiddenInput } from '../../fields/HiddenInput/index.js'\nimport { useFieldComponents } from '../../providers/FieldComponents/index.js'\nimport { useOperation } from '../../providers/Operation/index.js'\nimport { FieldPropsProvider, useFieldProps } from '../FieldPropsProvider/index.js'\n\ntype Props = {\n CustomField: MappedField['CustomField']\n disabled: boolean\n fieldComponentProps?: FieldComponentProps\n indexPath?: string\n isHidden?: boolean\n name?: string\n path: string\n permissions?: FieldPermissions\n readOnly?: boolean\n schemaPath: string\n siblingPermissions: {\n [fieldName: string]: FieldPermissions\n }\n type: keyof FieldTypes\n}\n\nexport const RenderField: React.FC<Props> = ({\n name,\n type,\n CustomField,\n disabled,\n fieldComponentProps,\n indexPath,\n isHidden,\n path: pathFromProps,\n permissions,\n readOnly: readOnlyFromProps,\n schemaPath: schemaPathFromProps,\n siblingPermissions,\n}) => {\n const operation = useOperation()\n const { readOnly: readOnlyFromContext } = useFieldProps()\n const fieldComponents = useFieldComponents()\n\n const path = [pathFromProps, name].filter(Boolean).join('.')\n const schemaPath = [schemaPathFromProps, name].filter(Boolean).join('.')\n\n // if the user cannot read the field, then filter it out\n // this is different from `admin.readOnly` which is executed based on `operation`\n if (permissions?.read?.permission === false || disabled) {\n return null\n }\n\n // `admin.readOnly` displays the value but prevents the field from being edited\n let readOnly = readOnlyFromProps\n\n // if parent field is `readOnly: true`, but this field is `readOnly: false`, the field should still be editable\n if (readOnlyFromContext && readOnly !== false) readOnly = true\n\n // if the user does not have access control to begin with, force it to be read-only\n if (permissions?.[operation]?.permission === false) {\n readOnly = true\n }\n\n const DefaultField = isHidden ? HiddenInput : fieldComponents[type]\n\n if (CustomField === undefined && !DefaultField) {\n return null\n }\n\n return (\n <FieldPropsProvider\n indexPath={indexPath}\n path={path}\n permissions={permissions}\n readOnly={readOnly}\n schemaPath={schemaPath}\n siblingPermissions={siblingPermissions}\n type={type}\n >\n {CustomField !== undefined ? CustomField : <DefaultField {...fieldComponentProps} />}\n </FieldPropsProvider>\n )\n}\n"],"names":["React","HiddenInput","useFieldComponents","useOperation","FieldPropsProvider","useFieldProps","RenderField","name","type","CustomField","disabled","fieldComponentProps","indexPath","isHidden","path","pathFromProps","permissions","readOnly","readOnlyFromProps","schemaPath","schemaPathFromProps","siblingPermissions","operation","readOnlyFromContext","fieldComponents","filter","Boolean","join","read","permission","DefaultField","undefined"],"rangeMappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/forms/RenderFields/RenderField.tsx"],"sourcesContent":["'use client'\n\nimport type { FieldTypes } from 'payload/config'\nimport type { FieldPermissions } from 'payload/types'\n\nimport React from 'react'\n\nimport type {\n FieldComponentProps,\n MappedField,\n} from '../../providers/ComponentMap/buildComponentMap/types.js'\n\nimport { HiddenInput } from '../../fields/HiddenInput/index.js'\nimport { useFieldComponents } from '../../providers/FieldComponents/index.js'\nimport { useOperation } from '../../providers/Operation/index.js'\nimport { FieldPropsProvider, useFieldProps } from '../FieldPropsProvider/index.js'\n\ntype Props = {\n CustomField: MappedField['CustomField']\n custom?: Record<any, string>\n disabled: boolean\n fieldComponentProps?: FieldComponentProps\n indexPath?: string\n isHidden?: boolean\n name?: string\n path: string\n permissions?: FieldPermissions\n readOnly?: boolean\n schemaPath: string\n siblingPermissions: {\n [fieldName: string]: FieldPermissions\n }\n type: keyof FieldTypes\n}\n\nexport const RenderField: React.FC<Props> = ({\n name,\n type,\n CustomField,\n custom,\n disabled,\n fieldComponentProps,\n indexPath,\n isHidden,\n path: pathFromProps,\n permissions,\n readOnly: readOnlyFromProps,\n schemaPath: schemaPathFromProps,\n siblingPermissions,\n}) => {\n const operation = useOperation()\n const { readOnly: readOnlyFromContext } = useFieldProps()\n const fieldComponents = useFieldComponents()\n\n const path = [pathFromProps, name].filter(Boolean).join('.')\n const schemaPath = [schemaPathFromProps, name].filter(Boolean).join('.')\n\n // if the user cannot read the field, then filter it out\n // this is different from `admin.readOnly` which is executed based on `operation`\n if (permissions?.read?.permission === false || disabled) {\n return null\n }\n\n // `admin.readOnly` displays the value but prevents the field from being edited\n let readOnly = readOnlyFromProps\n\n // if parent field is `readOnly: true`, but this field is `readOnly: false`, the field should still be editable\n if (readOnlyFromContext && readOnly !== false) readOnly = true\n\n // if the user does not have access control to begin with, force it to be read-only\n if (permissions?.[operation]?.permission === false) {\n readOnly = true\n }\n\n const DefaultField = isHidden ? HiddenInput : fieldComponents[type]\n\n if (CustomField === undefined && !DefaultField) {\n return null\n }\n\n return (\n <FieldPropsProvider\n custom={custom}\n indexPath={indexPath}\n path={path}\n permissions={permissions}\n readOnly={readOnly}\n schemaPath={schemaPath}\n siblingPermissions={siblingPermissions}\n type={type}\n >\n {CustomField !== undefined ? CustomField : <DefaultField {...fieldComponentProps} />}\n </FieldPropsProvider>\n )\n}\n"],"names":["React","HiddenInput","useFieldComponents","useOperation","FieldPropsProvider","useFieldProps","RenderField","name","type","CustomField","custom","disabled","fieldComponentProps","indexPath","isHidden","path","pathFromProps","permissions","readOnly","readOnlyFromProps","schemaPath","schemaPathFromProps","siblingPermissions","operation","readOnlyFromContext","fieldComponents","filter","Boolean","join","read","permission","DefaultField","undefined"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAKA,OAAOA,WAAW,QAAO;AAOzB,SAASC,WAAW,QAAQ,oCAAmC;AAC/D,SAASC,kBAAkB,QAAQ,2CAA0C;AAC7E,SAASC,YAAY,QAAQ,qCAAoC;AACjE,SAASC,kBAAkB,EAAEC,aAAa,QAAQ,iCAAgC;AAoBlF,OAAO,MAAMC,cAA+B,CAAC,EAC3CC,IAAI,EACJC,IAAI,EACJC,WAAW,EACXC,MAAM,EACNC,QAAQ,EACRC,mBAAmB,EACnBC,SAAS,EACTC,QAAQ,EACRC,MAAMC,aAAa,EACnBC,WAAW,EACXC,UAAUC,iBAAiB,EAC3BC,YAAYC,mBAAmB,EAC/BC,kBAAkB,EACnB;IACC,MAAMC,YAAYpB;IAClB,MAAM,EAAEe,UAAUM,mBAAmB,EAAE,GAAGnB;IAC1C,MAAMoB,kBAAkBvB;IAExB,MAAMa,OAAO;QAACC;QAAeT;KAAK,CAACmB,MAAM,CAACC,SAASC,IAAI,CAAC;IACxD,MAAMR,aAAa;QAACC;QAAqBd;KAAK,CAACmB,MAAM,CAACC,SAASC,IAAI,CAAC;IAEpE,wDAAwD;IACxD,iFAAiF;IACjF,IAAIX,aAAaY,MAAMC,eAAe,SAASnB,UAAU;QACvD,OAAO;IACT;IAEA,+EAA+E;IAC/E,IAAIO,WAAWC;IAEf,+GAA+G;IAC/G,IAAIK,uBAAuBN,aAAa,OAAOA,WAAW;IAE1D,mFAAmF;IACnF,IAAID,aAAa,CAACM,UAAU,EAAEO,eAAe,OAAO;QAClDZ,WAAW;IACb;IAEA,MAAMa,eAAejB,WAAWb,cAAcwB,eAAe,CAACjB,KAAK;IAEnE,IAAIC,gBAAgBuB,aAAa,CAACD,cAAc;QAC9C,OAAO;IACT;IAEA,qBACE,oBAAC3B;QACCM,QAAQA;QACRG,WAAWA;QACXE,MAAMA;QACNE,aAAaA;QACbC,UAAUA;QACVE,YAAYA;QACZE,oBAAoBA;QACpBd,MAAMA;OAELC,gBAAgBuB,YAAYvB,4BAAc,oBAACsB,cAAiBnB;AAGnE,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/forms/RenderFields/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAKvC,OAAO,cAAc,CAAA;AAIrB,OAAO,EAAE,KAAK,EAAE,CAAA;AAEhB,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/forms/RenderFields/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAKvC,OAAO,cAAc,CAAA;AAIrB,OAAO,EAAE,KAAK,EAAE,CAAA;AAEhB,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAiFxC,CAAA"}
|
|
@@ -39,10 +39,11 @@ export const RenderFields = (props)=>{
|
|
|
39
39
|
].filter(Boolean).join(' '),
|
|
40
40
|
ref: intersectionRef
|
|
41
41
|
}, hasRendered && fieldMap?.map((f, fieldIndex)=>{
|
|
42
|
-
const { type, CustomField, disabled, fieldComponentProps, fieldComponentProps: { readOnly }, isHidden } = f;
|
|
42
|
+
const { type, CustomField, custom, disabled, fieldComponentProps, fieldComponentProps: { readOnly }, isHidden } = f;
|
|
43
43
|
const name = 'name' in f ? f.name : undefined;
|
|
44
44
|
return /*#__PURE__*/ React.createElement(RenderField, {
|
|
45
45
|
CustomField: CustomField,
|
|
46
|
+
custom: custom,
|
|
46
47
|
disabled: disabled,
|
|
47
48
|
fieldComponentProps: fieldComponentProps,
|
|
48
49
|
indexPath: indexPath !== undefined ? `${indexPath}.${fieldIndex}` : `${fieldIndex}`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/forms/RenderFields/index.tsx"],"sourcesContent":["'use client'\nimport React from 'react'\n\nimport type { Props } from './types.js'\n\nimport { useIntersect } from '../../hooks/useIntersect.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { RenderField } from './RenderField.js'\nimport './index.scss'\n\nconst baseClass = 'render-fields'\n\nexport { Props }\n\nexport const RenderFields: React.FC<Props> = (props) => {\n const { className, fieldMap, forceRender, indexPath, margins, path, permissions, schemaPath } =\n props\n\n const { i18n } = useTranslation()\n const [hasRendered, setHasRendered] = React.useState(Boolean(forceRender))\n const [intersectionRef, entry] = useIntersect(\n {\n rootMargin: '1000px',\n },\n forceRender,\n )\n const isIntersecting = Boolean(entry?.isIntersecting)\n const isAboveViewport = entry?.boundingClientRect?.top < 0\n const shouldRender = forceRender || isIntersecting || isAboveViewport\n\n React.useEffect(() => {\n if (shouldRender && !hasRendered) {\n setHasRendered(true)\n }\n }, [shouldRender, hasRendered])\n\n if (!fieldMap || (Array.isArray(fieldMap) && fieldMap.length === 0)) {\n return null\n }\n\n if (!i18n) {\n console.error('Need to implement i18n when calling RenderFields') // eslint-disable-line no-console\n }\n\n if (fieldMap) {\n return (\n <div\n className={[\n baseClass,\n className,\n margins && `${baseClass}--margins-${margins}`,\n margins === false && `${baseClass}--margins-none`,\n ]\n .filter(Boolean)\n .join(' ')}\n ref={intersectionRef}\n >\n {hasRendered &&\n fieldMap?.map((f, fieldIndex) => {\n const {\n type,\n CustomField,\n disabled,\n fieldComponentProps,\n fieldComponentProps: { readOnly },\n isHidden,\n } = f\n\n const name = 'name' in f ? f.name : undefined\n\n return (\n <RenderField\n CustomField={CustomField}\n disabled={disabled}\n fieldComponentProps={fieldComponentProps}\n indexPath={indexPath !== undefined ? `${indexPath}.${fieldIndex}` : `${fieldIndex}`}\n isHidden={isHidden}\n key={fieldIndex}\n name={name}\n path={path}\n permissions={permissions?.[name]}\n readOnly={readOnly}\n schemaPath={schemaPath}\n siblingPermissions={permissions}\n type={type}\n />\n )\n })}\n </div>\n )\n }\n\n return null\n}\n"],"names":["React","useIntersect","useTranslation","RenderField","baseClass","RenderFields","props","className","fieldMap","forceRender","indexPath","margins","path","permissions","schemaPath","i18n","hasRendered","setHasRendered","useState","Boolean","intersectionRef","entry","rootMargin","isIntersecting","isAboveViewport","boundingClientRect","top","shouldRender","useEffect","Array","isArray","length","console","error","div","filter","join","ref","map","f","fieldIndex","type","CustomField","disabled","fieldComponentProps","readOnly","isHidden","name","undefined","key","siblingPermissions"],"rangeMappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/forms/RenderFields/index.tsx"],"sourcesContent":["'use client'\nimport React from 'react'\n\nimport type { Props } from './types.js'\n\nimport { useIntersect } from '../../hooks/useIntersect.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { RenderField } from './RenderField.js'\nimport './index.scss'\n\nconst baseClass = 'render-fields'\n\nexport { Props }\n\nexport const RenderFields: React.FC<Props> = (props) => {\n const { className, fieldMap, forceRender, indexPath, margins, path, permissions, schemaPath } =\n props\n\n const { i18n } = useTranslation()\n const [hasRendered, setHasRendered] = React.useState(Boolean(forceRender))\n const [intersectionRef, entry] = useIntersect(\n {\n rootMargin: '1000px',\n },\n forceRender,\n )\n const isIntersecting = Boolean(entry?.isIntersecting)\n const isAboveViewport = entry?.boundingClientRect?.top < 0\n const shouldRender = forceRender || isIntersecting || isAboveViewport\n\n React.useEffect(() => {\n if (shouldRender && !hasRendered) {\n setHasRendered(true)\n }\n }, [shouldRender, hasRendered])\n\n if (!fieldMap || (Array.isArray(fieldMap) && fieldMap.length === 0)) {\n return null\n }\n\n if (!i18n) {\n console.error('Need to implement i18n when calling RenderFields') // eslint-disable-line no-console\n }\n\n if (fieldMap) {\n return (\n <div\n className={[\n baseClass,\n className,\n margins && `${baseClass}--margins-${margins}`,\n margins === false && `${baseClass}--margins-none`,\n ]\n .filter(Boolean)\n .join(' ')}\n ref={intersectionRef}\n >\n {hasRendered &&\n fieldMap?.map((f, fieldIndex) => {\n const {\n type,\n CustomField,\n custom,\n disabled,\n fieldComponentProps,\n fieldComponentProps: { readOnly },\n isHidden,\n } = f\n\n const name = 'name' in f ? f.name : undefined\n\n return (\n <RenderField\n CustomField={CustomField}\n custom={custom}\n disabled={disabled}\n fieldComponentProps={fieldComponentProps}\n indexPath={indexPath !== undefined ? `${indexPath}.${fieldIndex}` : `${fieldIndex}`}\n isHidden={isHidden}\n key={fieldIndex}\n name={name}\n path={path}\n permissions={permissions?.[name]}\n readOnly={readOnly}\n schemaPath={schemaPath}\n siblingPermissions={permissions}\n type={type}\n />\n )\n })}\n </div>\n )\n }\n\n return null\n}\n"],"names":["React","useIntersect","useTranslation","RenderField","baseClass","RenderFields","props","className","fieldMap","forceRender","indexPath","margins","path","permissions","schemaPath","i18n","hasRendered","setHasRendered","useState","Boolean","intersectionRef","entry","rootMargin","isIntersecting","isAboveViewport","boundingClientRect","top","shouldRender","useEffect","Array","isArray","length","console","error","div","filter","join","ref","map","f","fieldIndex","type","CustomField","custom","disabled","fieldComponentProps","readOnly","isHidden","name","undefined","key","siblingPermissions"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AACA,OAAOA,WAAW,QAAO;AAIzB,SAASC,YAAY,QAAQ,8BAA6B;AAC1D,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,W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AAO,UAAUT,IAAIA,EAAES,IAAI,GAAGC;YAEpC,qBACE,oBAAC9C;gBACCuC,aAAaA;gBACbC,QAAQA;gBACRC,UAAUA;gBACVC,qBAAqBA;gBACrBnC,WAAWA,cAAcuC,YAAY,CAAC,EAAEvC,UAAU,CAAC,EAAE8B,WAAW,CAAC,GAAG,CAAC,EAAEA,WAAW,CAAC;gBACnFO,UAAUA;gBACVG,KAAKV;gBACLQ,MAAMA;gBACNpC,MAAMA;gBACNC,aAAaA,aAAa,CAACmC,KAAK;gBAChCF,UAAUA;gBACVhC,YAAYA;gBACZqC,oBAAoBtC;gBACpB4B,MAAMA;;QAGZ;IAGR;IAEA,OAAO;AACT,EAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WithServerSideProps.d.ts","sourceRoot":"","sources":["../../../../src/providers/ComponentMap/buildComponentMap/WithServerSideProps.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,IAAI,uBAAuB,EAAE,MAAM,eAAe,CAAA;AAKnF,eAAO,MAAM,mBAAmB,EAAE,uBAejC,CAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { isReactServerComponent } from 'payload/utilities';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export const WithServerSideProps = ({ Component, payload, ...rest })=>{
|
|
4
|
+
if (Component) {
|
|
5
|
+
const WithServerSideProps = (passedProps)=>{
|
|
6
|
+
const propsWithPayload = {
|
|
7
|
+
...passedProps,
|
|
8
|
+
...isReactServerComponent(Component) ? {
|
|
9
|
+
payload
|
|
10
|
+
} : {}
|
|
11
|
+
};
|
|
12
|
+
return /*#__PURE__*/ React.createElement(Component, propsWithPayload);
|
|
13
|
+
};
|
|
14
|
+
return /*#__PURE__*/ React.createElement(WithServerSideProps, rest);
|
|
15
|
+
}
|
|
16
|
+
return null;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=WithServerSideProps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/providers/ComponentMap/buildComponentMap/WithServerSideProps.tsx"],"sourcesContent":["import type { WithServerSideProps as WithServerSidePropsType } from 'payload/types'\n\nimport { isReactServerComponent } from 'payload/utilities'\nimport React from 'react'\n\nexport const WithServerSideProps: WithServerSidePropsType = ({ Component, payload, ...rest }) => {\n if (Component) {\n const WithServerSideProps: React.FC<any> = (passedProps) => {\n const propsWithPayload = {\n ...passedProps,\n ...(isReactServerComponent(Component) ? { payload } : {}),\n }\n\n return <Component {...propsWithPayload} />\n }\n\n return <WithServerSideProps {...rest} />\n }\n\n return null\n}\n"],"names":["isReactServerComponent","React","WithServerSideProps","Component","payload","rest","passedProps","propsWithPayload"],"rangeMappings":";;;;;;;;;;;;;;;;","mappings":"AAEA,SAASA,sBAAsB,QAAQ,oBAAmB;AAC1D,OAAOC,WAAW,QAAO;AAEzB,OAAO,MAAMC,sBAA+C,CAAC,EAAEC,SAAS,EAAEC,OAAO,EAAE,GAAGC,MAAM;IAC1F,IAAIF,WAAW;QACb,MAAMD,sBAAqC,CAACI;YAC1C,MAAMC,mBAAmB;gBACvB,GAAGD,WAAW;gBACd,GAAIN,uBAAuBG,aAAa;oBAAEC;gBAAQ,IAAI,CAAC,CAAC;YAC1D;YAEA,qBAAO,oBAACD,WAAcI;QACxB;QAEA,qBAAO,oBAACL,qBAAwBG;IAClC;IAEA,OAAO;AACT,EAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { SanitizedCollectionConfig, SanitizedGlobalConfig } from 'payload/types';
|
|
1
|
+
import type { SanitizedCollectionConfig, SanitizedGlobalConfig, WithServerSideProps as WithServerSidePropsType } from 'payload/types';
|
|
2
2
|
import type { ActionMap } from './types.js';
|
|
3
3
|
export declare const mapActions: (args: {
|
|
4
|
+
WithServerSideProps: WithServerSidePropsType;
|
|
4
5
|
collectionConfig?: SanitizedCollectionConfig;
|
|
5
6
|
globalConfig?: SanitizedGlobalConfig;
|
|
6
7
|
}) => ActionMap;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../../../src/providers/ComponentMap/buildComponentMap/actions.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../../../src/providers/ComponentMap/buildComponentMap/actions.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,yBAAyB,EACzB,qBAAqB,EACrB,mBAAmB,IAAI,uBAAuB,EAC/C,MAAM,eAAe,CAAA;AAItB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAE3C,eAAO,MAAM,UAAU,SAAU;IAC/B,mBAAmB,EAAE,uBAAuB,CAAA;IAC5C,gBAAgB,CAAC,EAAE,yBAAyB,CAAA;IAC5C,YAAY,CAAC,EAAE,qBAAqB,CAAA;CACrC,KAAG,SAuCH,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
export const mapActions = (args)=>{
|
|
3
|
-
const { collectionConfig, globalConfig } = args;
|
|
3
|
+
const { WithServerSideProps, collectionConfig, globalConfig } = args;
|
|
4
4
|
const editViews = (collectionConfig || globalConfig)?.admin?.components?.views?.Edit;
|
|
5
5
|
const listActions = typeof collectionConfig?.admin?.components?.views?.List === 'object' ? collectionConfig?.admin?.components?.views?.List?.actions : undefined;
|
|
6
6
|
const result = {
|
|
@@ -15,7 +15,9 @@ export const mapActions = (args)=>{
|
|
|
15
15
|
if (typeof Action === 'function') {
|
|
16
16
|
result.Edit[key] = [
|
|
17
17
|
...result[key] || [],
|
|
18
|
-
/*#__PURE__*/ React.createElement(
|
|
18
|
+
/*#__PURE__*/ React.createElement(WithServerSideProps, {
|
|
19
|
+
Component: Action
|
|
20
|
+
})
|
|
19
21
|
];
|
|
20
22
|
}
|
|
21
23
|
});
|
|
@@ -29,7 +31,9 @@ export const mapActions = (args)=>{
|
|
|
29
31
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
30
32
|
result.List = [
|
|
31
33
|
...result.List,
|
|
32
|
-
/*#__PURE__*/ React.createElement(
|
|
34
|
+
/*#__PURE__*/ React.createElement(WithServerSideProps, {
|
|
35
|
+
Component: Action
|
|
36
|
+
})
|
|
33
37
|
];
|
|
34
38
|
}
|
|
35
39
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/providers/ComponentMap/buildComponentMap/actions.tsx"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"sources":["../../../../src/providers/ComponentMap/buildComponentMap/actions.tsx"],"sourcesContent":["import type {\n SanitizedCollectionConfig,\n SanitizedGlobalConfig,\n WithServerSideProps as WithServerSidePropsType,\n} from 'payload/types'\n\nimport React from 'react'\n\nimport type { ActionMap } from './types.js'\n\nexport const mapActions = (args: {\n WithServerSideProps: WithServerSidePropsType\n collectionConfig?: SanitizedCollectionConfig\n globalConfig?: SanitizedGlobalConfig\n}): ActionMap => {\n const { WithServerSideProps, collectionConfig, globalConfig } = args\n\n const editViews = (collectionConfig || globalConfig)?.admin?.components?.views?.Edit\n\n const listActions =\n typeof collectionConfig?.admin?.components?.views?.List === 'object'\n ? collectionConfig?.admin?.components?.views?.List?.actions\n : undefined\n\n const result: ActionMap = {\n Edit: {},\n List: [],\n }\n\n if (editViews) {\n Object.entries(editViews).forEach(([key, view]) => {\n if (typeof view === 'object' && 'actions' in view) {\n view.actions.forEach((action) => {\n const Action = action\n if (typeof Action === 'function') {\n result.Edit[key] = [...(result[key] || []), <WithServerSideProps Component={Action} />]\n }\n })\n }\n })\n }\n\n if (listActions) {\n listActions.forEach((action) => {\n const Action = action\n if (typeof Action === 'function') {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n result.List = [...result.List, <WithServerSideProps Component={Action} />]\n }\n })\n }\n\n return result\n}\n"],"names":["React","mapActions","args","WithServerSideProps","collectionConfig","globalConfig","editViews","admin","components","views","Edit","listActions","List","actions","undefined","result","Object","entries","forEach","key","view","action","Action","Component"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAMA,OAAOA,WAAW,QAAO;AAIzB,OAAO,MAAMC,aAAa,CAACC;IAKzB,MAAM,EAAEC,mBAAmB,EAAEC,gBAAgB,EAAEC,YAAY,EAAE,GAAGH;IAEhE,MAAMI,YAAaF,CAAAA,oBAAoBC,YAAW,GAAIE,OAAOC,YAAYC,OAAOC;IAEhF,MAAMC,cACJ,OAAOP,kBAAkBG,OAAOC,YAAYC,OAAOG,SAAS,WACxDR,kBAAkBG,OAAOC,YAAYC,OAAOG,MAAMC,UAClDC;IAEN,MAAMC,SAAoB;QACxBL,MAAM,CAAC;QACPE,MAAM,EAAE;IACV;IAEA,IAAIN,WAAW;QACbU,OAAOC,OAAO,CAACX,WAAWY,OAAO,CAAC,CAAC,CAACC,KAAKC,KAAK;YAC5C,IAAI,OAAOA,SAAS,YAAY,aAAaA,MAAM;gBACjDA,KAAKP,OAAO,CAACK,OAAO,CAAC,CAACG;oBACpB,MAAMC,SAASD;oBACf,IAAI,OAAOC,WAAW,YAAY;wBAChCP,OAAOL,IAAI,CAACS,IAAI,GAAG;+BAAKJ,MAAM,CAACI,IAAI,IAAI,EAAE;0CAAG,oBAAChB;gCAAoBoB,WAAWD;;yBAAW;oBACzF;gBACF;YACF;QACF;IACF;IAEA,IAAIX,aAAa;QACfA,YAAYO,OAAO,CAAC,CAACG;YACnB,MAAMC,SAASD;YACf,IAAI,OAAOC,WAAW,YAAY;gBAChC,mEAAmE;gBACnEP,OAAOH,IAAI,GAAG;uBAAIG,OAAOH,IAAI;kCAAE,oBAACT;wBAAoBoB,WAAWD;;iBAAW;YAC5E;QACF;IACF;IAEA,OAAOP;AACT,EAAC"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { I18n } from '@payloadcms/translations';
|
|
2
|
-
import type { AdminViewProps, EditViewProps, SanitizedCollectionConfig, SanitizedConfig } from 'payload/types';
|
|
2
|
+
import type { AdminViewProps, EditViewProps, SanitizedCollectionConfig, SanitizedConfig, WithServerSideProps as WithServerSidePropsType } from 'payload/types';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import type { CollectionComponentMap } from './types.js';
|
|
5
|
-
export declare const mapCollections: ({ DefaultEditView, DefaultListView, collections, config, i18n, readOnly: readOnlyOverride, }: {
|
|
5
|
+
export declare const mapCollections: ({ DefaultEditView, DefaultListView, WithServerSideProps, collections, config, i18n, readOnly: readOnlyOverride, }: {
|
|
6
6
|
DefaultEditView: React.FC<EditViewProps>;
|
|
7
7
|
DefaultListView: React.FC<AdminViewProps>;
|
|
8
|
+
WithServerSideProps: WithServerSidePropsType;
|
|
8
9
|
collections: SanitizedCollectionConfig[];
|
|
9
10
|
config: SanitizedConfig;
|
|
10
11
|
i18n: I18n;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collections.d.ts","sourceRoot":"","sources":["../../../../src/providers/ComponentMap/buildComponentMap/collections.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAA;AAEpD,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EAGb,yBAAyB,EACzB,eAAe,
|
|
1
|
+
{"version":3,"file":"collections.d.ts","sourceRoot":"","sources":["../../../../src/providers/ComponentMap/buildComponentMap/collections.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAA;AAEpD,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EAGb,yBAAyB,EACzB,eAAe,EACf,mBAAmB,IAAI,uBAAuB,EAC/C,MAAM,eAAe,CAAA;AAItB,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAA;AAKxD,eAAO,MAAM,cAAc,sHAQxB;IACD,eAAe,EAAE,MAAM,EAAE,CAAC,aAAa,CAAC,CAAA;IACxC,eAAe,EAAE,MAAM,EAAE,CAAC,cAAc,CAAC,CAAA;IACzC,mBAAmB,EAAE,uBAAuB,CAAA;IAC5C,WAAW,EAAE,yBAAyB,EAAE,CAAA;IACxC,MAAM,EAAE,eAAe,CAAA;IACvB,IAAI,EAAE,IAAI,CAAA;IACV,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,KAAG;IACF,CAAC,GAAG,EAAE,yBAAyB,CAAC,MAAM,CAAC,GAAG,sBAAsB,CAAA;CAsJ1D,CAAA"}
|
|
@@ -3,7 +3,7 @@ import { isPlainFunction, isReactComponent } from 'payload/utilities';
|
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { mapActions } from './actions.js';
|
|
5
5
|
import { mapFields } from './fields.js';
|
|
6
|
-
export const mapCollections = ({ DefaultEditView, DefaultListView, collections, config, i18n, readOnly: readOnlyOverride })=>collections.reduce((acc, collectionConfig)=>{
|
|
6
|
+
export const mapCollections = ({ DefaultEditView, DefaultListView, WithServerSideProps, collections, config, i18n, readOnly: readOnlyOverride })=>collections.reduce((acc, collectionConfig)=>{
|
|
7
7
|
const { slug, fields } = collectionConfig;
|
|
8
8
|
const internalCollections = [
|
|
9
9
|
'payload-preferences',
|
|
@@ -18,27 +18,46 @@ export const mapCollections = ({ DefaultEditView, DefaultListView, collections,
|
|
|
18
18
|
const CustomListView = typeof listViewFromConfig === 'function' ? listViewFromConfig : typeof listViewFromConfig === 'object' && typeof listViewFromConfig.Component === 'function' ? listViewFromConfig.Component : undefined;
|
|
19
19
|
const Edit = CustomEditView || DefaultEditView;
|
|
20
20
|
const List = CustomListView || DefaultListView;
|
|
21
|
-
const beforeList = collectionConfig?.admin?.components?.BeforeList;
|
|
22
|
-
const beforeListTable = collectionConfig?.admin?.components?.BeforeListTable;
|
|
23
|
-
const afterList = collectionConfig?.admin?.components?.AfterList;
|
|
24
|
-
const afterListTable = collectionConfig?.admin?.components?.AfterListTable;
|
|
25
21
|
const SaveButtonComponent = collectionConfig?.admin?.components?.edit?.SaveButton;
|
|
26
|
-
const SaveButton = SaveButtonComponent ? /*#__PURE__*/ React.createElement(
|
|
22
|
+
const SaveButton = SaveButtonComponent ? /*#__PURE__*/ React.createElement(WithServerSideProps, {
|
|
23
|
+
Component: SaveButtonComponent
|
|
24
|
+
}) : undefined;
|
|
27
25
|
const SaveDraftButtonComponent = collectionConfig?.admin?.components?.edit?.SaveDraftButton;
|
|
28
|
-
const SaveDraftButton = SaveDraftButtonComponent ? /*#__PURE__*/ React.createElement(
|
|
26
|
+
const SaveDraftButton = SaveDraftButtonComponent ? /*#__PURE__*/ React.createElement(WithServerSideProps, {
|
|
27
|
+
Component: SaveDraftButtonComponent
|
|
28
|
+
}) : undefined;
|
|
29
29
|
const PreviewButtonComponent = collectionConfig?.admin?.components?.edit?.PreviewButton;
|
|
30
|
-
const PreviewButton = PreviewButtonComponent ? /*#__PURE__*/ React.createElement(
|
|
30
|
+
const PreviewButton = PreviewButtonComponent ? /*#__PURE__*/ React.createElement(WithServerSideProps, {
|
|
31
|
+
Component: PreviewButtonComponent
|
|
32
|
+
}) : undefined;
|
|
31
33
|
const PublishButtonComponent = collectionConfig?.admin?.components?.edit?.PublishButton;
|
|
32
|
-
const PublishButton = PublishButtonComponent ? /*#__PURE__*/ React.createElement(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
const
|
|
34
|
+
const PublishButton = PublishButtonComponent ? /*#__PURE__*/ React.createElement(WithServerSideProps, {
|
|
35
|
+
Component: PublishButtonComponent
|
|
36
|
+
}) : undefined;
|
|
37
|
+
const beforeList = collectionConfig?.admin?.components?.BeforeList;
|
|
38
|
+
const BeforeList = beforeList && Array.isArray(beforeList) && beforeList?.map((Component)=>/*#__PURE__*/ React.createElement(WithServerSideProps, {
|
|
39
|
+
Component: Component
|
|
40
|
+
})) || null;
|
|
41
|
+
const beforeListTable = collectionConfig?.admin?.components?.BeforeListTable;
|
|
42
|
+
const BeforeListTable = beforeListTable && Array.isArray(beforeListTable) && beforeListTable?.map((Component)=>/*#__PURE__*/ React.createElement(WithServerSideProps, {
|
|
43
|
+
Component: Component
|
|
44
|
+
})) || null;
|
|
45
|
+
const afterList = collectionConfig?.admin?.components?.AfterList;
|
|
46
|
+
const AfterList = afterList && Array.isArray(afterList) && afterList?.map((Component)=>/*#__PURE__*/ React.createElement(WithServerSideProps, {
|
|
47
|
+
Component: Component
|
|
48
|
+
})) || null;
|
|
49
|
+
const afterListTable = collectionConfig?.admin?.components?.AfterListTable;
|
|
50
|
+
const AfterListTable = afterListTable && Array.isArray(afterListTable) && afterListTable?.map((Component)=>/*#__PURE__*/ React.createElement(WithServerSideProps, {
|
|
51
|
+
Component: Component
|
|
52
|
+
})) || null;
|
|
37
53
|
const descriptionProps = {
|
|
38
54
|
description: collectionConfig.admin && 'description' in collectionConfig.admin && ((typeof collectionConfig.admin?.description === 'string' || typeof collectionConfig.admin?.description === 'object') && collectionConfig.admin.description || typeof collectionConfig.admin?.description === 'function' && isPlainFunction(collectionConfig.admin?.description) && collectionConfig.admin?.description()) || undefined
|
|
39
55
|
};
|
|
40
56
|
const DescriptionComponent = collectionConfig.admin && 'description' in collectionConfig.admin && (isReactComponent(collectionConfig.admin.description) && collectionConfig.admin.description || collectionConfig.admin.description && ViewDescription) || undefined;
|
|
41
|
-
const Description = DescriptionComponent !== undefined ? /*#__PURE__*/ React.createElement(
|
|
57
|
+
const Description = DescriptionComponent !== undefined ? /*#__PURE__*/ React.createElement(WithServerSideProps, {
|
|
58
|
+
Component: DescriptionComponent,
|
|
59
|
+
...descriptionProps || {}
|
|
60
|
+
}) : undefined;
|
|
42
61
|
const componentMap = {
|
|
43
62
|
AfterList,
|
|
44
63
|
AfterListTable,
|
|
@@ -56,9 +75,11 @@ export const mapCollections = ({ DefaultEditView, DefaultListView, collections,
|
|
|
56
75
|
SaveButton,
|
|
57
76
|
SaveDraftButton,
|
|
58
77
|
actionsMap: mapActions({
|
|
78
|
+
WithServerSideProps,
|
|
59
79
|
collectionConfig
|
|
60
80
|
}),
|
|
61
81
|
fieldMap: mapFields({
|
|
82
|
+
WithServerSideProps,
|
|
62
83
|
config,
|
|
63
84
|
fieldSchema: fields,
|
|
64
85
|
i18n,
|