@payloadcms/ui 3.65.0-internal.098b771 → 3.65.0-internal.19683e7
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/AppHeader/index.scss +2 -2
- package/dist/elements/PublishButton/index.d.ts.map +1 -1
- package/dist/elements/PublishButton/index.js +13 -16
- package/dist/elements/PublishButton/index.js.map +1 -1
- package/dist/elements/ReactSelect/MultiValueLabel/index.d.ts.map +1 -1
- package/dist/elements/ReactSelect/MultiValueLabel/index.js +18 -9
- package/dist/elements/ReactSelect/MultiValueLabel/index.js.map +1 -1
- package/dist/elements/ReactSelect/ValueContainer/index.d.ts.map +1 -1
- package/dist/elements/ReactSelect/ValueContainer/index.js +19 -7
- package/dist/elements/ReactSelect/ValueContainer/index.js.map +1 -1
- package/dist/elements/WhereBuilder/Condition/index.js +1 -1
- package/dist/elements/WhereBuilder/Condition/index.js.map +1 -1
- package/dist/elements/withMergedProps/index.d.ts +1 -1
- package/dist/elements/withMergedProps/index.js +1 -1
- package/dist/elements/withMergedProps/index.js.map +1 -1
- package/dist/exports/client/{CodeEditor-IVFMKS4Z.js → CodeEditor-ORMD3ID3.js} +2 -2
- package/dist/exports/client/{chunk-XUCNM5EK.js → chunk-PXD7OIXB.js} +1 -1
- package/dist/exports/client/{chunk-XUCNM5EK.js.map → chunk-PXD7OIXB.js.map} +2 -2
- package/dist/exports/client/index.d.ts +3 -0
- package/dist/exports/client/index.d.ts.map +1 -1
- package/dist/exports/client/index.js +12 -12
- package/dist/exports/client/index.js.map +4 -4
- package/dist/exports/shared/index.js.map +1 -1
- package/dist/fields/Array/index.js +1 -1
- package/dist/fields/Array/index.js.map +1 -1
- package/dist/fields/Blocks/BlockSelector/BlockSearch/index.d.ts.map +1 -0
- package/dist/fields/Blocks/BlockSelector/BlockSearch/index.js.map +1 -0
- package/dist/fields/Blocks/BlockSelector/index.d.ts +13 -0
- package/dist/fields/Blocks/BlockSelector/index.d.ts.map +1 -0
- package/dist/fields/Blocks/BlockSelector/index.js +116 -0
- package/dist/fields/Blocks/BlockSelector/index.js.map +1 -0
- package/dist/fields/Blocks/BlocksDrawer/index.d.ts +0 -1
- package/dist/fields/Blocks/BlocksDrawer/index.d.ts.map +1 -1
- package/dist/fields/Blocks/BlocksDrawer/index.js +62 -105
- package/dist/fields/Blocks/BlocksDrawer/index.js.map +1 -1
- package/dist/fields/Relationship/select-components/MultiValueLabel/index.js +1 -0
- package/dist/fields/Relationship/select-components/MultiValueLabel/index.js.map +1 -1
- package/dist/fields/Relationship/select-components/SingleValue/index.js +11 -8
- package/dist/fields/Relationship/select-components/SingleValue/index.js.map +1 -1
- package/dist/hooks/useControllableState.d.ts.map +1 -1
- package/dist/hooks/useControllableState.js.map +1 -1
- package/dist/providers/Auth/index.d.ts.map +1 -1
- package/dist/providers/Auth/index.js +10 -8
- package/dist/providers/Auth/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/utilities/handleLivePreview.d.ts.map +1 -1
- package/package.json +5 -5
- package/dist/fields/Blocks/BlocksDrawer/BlockSearch/index.d.ts.map +0 -1
- package/dist/fields/Blocks/BlocksDrawer/BlockSearch/index.js.map +0 -1
- /package/dist/exports/client/{CodeEditor-IVFMKS4Z.js.map → CodeEditor-ORMD3ID3.js.map} +0 -0
- /package/dist/fields/Blocks/{BlocksDrawer → BlockSelector}/BlockSearch/index.d.ts +0 -0
- /package/dist/fields/Blocks/{BlocksDrawer → BlockSelector}/BlockSearch/index.js +0 -0
- /package/dist/fields/Blocks/{BlocksDrawer → BlockSelector}/BlockSearch/index.scss +0 -0
- /package/dist/fields/Blocks/{BlocksDrawer → BlockSelector}/index.scss +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/elements/PublishButton/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAA;AAIvD,OAAO,KAA2C,MAAM,OAAO,CAAA;AAe/D,wBAAgB,aAAa,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,wBAAwB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/elements/PublishButton/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAA;AAIvD,OAAO,KAA2C,MAAM,OAAO,CAAA;AAe/D,wBAAgB,aAAa,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,wBAAwB,qBA2P3E"}
|
|
@@ -84,7 +84,7 @@ export function PublishButton({
|
|
|
84
84
|
const hasLocalizedField = traverseForLocalizedFields(entityConfig?.fields);
|
|
85
85
|
setHasLocalizedFields(hasLocalizedField);
|
|
86
86
|
}, [entityConfig?.fields]);
|
|
87
|
-
const
|
|
87
|
+
const isSpecificLocalePublishEnabled = localization && hasLocalizedFields && hasPublishPermission;
|
|
88
88
|
const operation = useOperation();
|
|
89
89
|
const disabled = operation === 'update' && !modified;
|
|
90
90
|
const saveDraft = useCallback(async () => {
|
|
@@ -157,17 +157,10 @@ export function PublishButton({
|
|
|
157
157
|
setHasPublishedDoc(true);
|
|
158
158
|
}
|
|
159
159
|
}, [api, collectionSlug, globalSlug, id, serverURL, setHasPublishedDoc, submit, uploadStatus]);
|
|
160
|
-
|
|
160
|
+
// Publish to all locales unless there are localized fields AND defaultLocalePublishOption is 'active'
|
|
161
|
+
const isDefaultPublishAll = !isSpecificLocalePublishEnabled || localization && localization?.defaultLocalePublishOption !== 'active';
|
|
161
162
|
const activeLocale = localization && localization?.locales.find(locale_0 => typeof locale_0 === 'string' ? locale_0 === localeCode : locale_0.code === localeCode);
|
|
162
163
|
const activeLocaleLabel = activeLocale && (typeof activeLocale.label === 'string' ? activeLocale.label : activeLocale.label?.[localeCode] ?? undefined);
|
|
163
|
-
const defaultPublish = publishAll ? publish : () => publishSpecificLocale(activeLocale.code);
|
|
164
|
-
const defaultLabel = publishAll ? label : t('version:publishIn', {
|
|
165
|
-
locale: activeLocaleLabel
|
|
166
|
-
});
|
|
167
|
-
const secondaryPublish = publishAll ? () => publishSpecificLocale(activeLocale.code) : publish;
|
|
168
|
-
const secondaryLabel = publishAll ? t('version:publishIn', {
|
|
169
|
-
locale: activeLocaleLabel
|
|
170
|
-
}) : t('version:publishAllLocales');
|
|
171
164
|
if (!hasPublishPermission) {
|
|
172
165
|
return null;
|
|
173
166
|
}
|
|
@@ -176,9 +169,9 @@ export function PublishButton({
|
|
|
176
169
|
buttonId: "action-save",
|
|
177
170
|
disabled: !canPublish,
|
|
178
171
|
enableSubMenu: canSchedulePublish,
|
|
179
|
-
onClick:
|
|
172
|
+
onClick: isDefaultPublishAll ? publish : () => publishSpecificLocale(activeLocale.code),
|
|
180
173
|
size: "medium",
|
|
181
|
-
SubMenuPopupContent:
|
|
174
|
+
SubMenuPopupContent: isSpecificLocalePublishEnabled || canSchedulePublish ? ({
|
|
182
175
|
close
|
|
183
176
|
}) => {
|
|
184
177
|
return /*#__PURE__*/_jsxs(React.Fragment, {
|
|
@@ -188,17 +181,21 @@ export function PublishButton({
|
|
|
188
181
|
onClick: () => [toggleModal(drawerSlug), close()],
|
|
189
182
|
children: t('version:schedulePublish')
|
|
190
183
|
})
|
|
191
|
-
}, "schedule-publish"),
|
|
184
|
+
}, "schedule-publish"), isSpecificLocalePublishEnabled && /*#__PURE__*/_jsx(PopupList.ButtonGroup, {
|
|
192
185
|
children: /*#__PURE__*/_jsx(PopupList.Button, {
|
|
193
186
|
id: "publish-locale",
|
|
194
|
-
onClick:
|
|
195
|
-
children:
|
|
187
|
+
onClick: isDefaultPublishAll ? () => publishSpecificLocale(activeLocale.code) : publish,
|
|
188
|
+
children: isDefaultPublishAll ? t('version:publishIn', {
|
|
189
|
+
locale: activeLocaleLabel
|
|
190
|
+
}) : t('version:publishAllLocales')
|
|
196
191
|
})
|
|
197
192
|
})]
|
|
198
193
|
});
|
|
199
194
|
} : undefined,
|
|
200
195
|
type: "button",
|
|
201
|
-
children:
|
|
196
|
+
children: !isDefaultPublishAll ? t('version:publishIn', {
|
|
197
|
+
locale: activeLocaleLabel
|
|
198
|
+
}) : label
|
|
202
199
|
}), canSchedulePublish && isModalOpen(drawerSlug) && /*#__PURE__*/_jsx(ScheduleDrawer, {
|
|
203
200
|
defaultType: !hasNewerVersions ? 'unpublish' : 'publish',
|
|
204
201
|
schedulePublishConfig: typeof schedulePublish === 'object' && schedulePublish,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["useModal","qs","React","useCallback","useEffect","useState","useForm","useFormModified","FormSubmit","useHotkey","useConfig","useDocumentInfo","useEditDepth","useLocale","useOperation","useTranslation","traverseForLocalizedFields","PopupList","ScheduleDrawer","PublishButton","label","labelProp","id","collectionSlug","docConfig","globalSlug","hasPublishedDoc","hasPublishPermission","setHasPublishedDoc","setMostRecentVersionIsAutosaved","setUnpublishedVersionCount","unpublishedVersionCount","uploadStatus","config","getEntityConfig","submit","modified","editDepth","code","localeCode","isModalOpen","toggleModal","drawerSlug","localization","routes","api","serverURL","t","entityConfig","useMemo","hasNewerVersions","schedulePublish","versions","drafts","canPublish","scheduledPublishEnabled","Boolean","hasAutosave","autosave","canSchedulePublish","hasLocalizedFields","setHasLocalizedFields","hasLocalizedField","fields","canPublishSpecificLocale","operation","disabled","saveDraft","search","action","method","overrides","_status","skipValidation","cmdCtrlKey","keyCodes","e","preventDefault","stopPropagation","publish","result","publishSpecificLocale","locale","params","stringify","depth","publishAll","defaultLocalePublishOption","activeLocale","locales","find","activeLocaleLabel","undefined","defaultPublish","defaultLabel","secondaryPublish","secondaryLabel","_jsxs","Fragment","_jsx","buttonId","enableSubMenu","onClick","size","SubMenuPopupContent","close","ButtonGroup","Button","type","defaultType","schedulePublishConfig","slug"],"sources":["../../../src/elements/PublishButton/index.tsx"],"sourcesContent":["'use client'\n\nimport type { PublishButtonClientProps } from 'payload'\n\nimport { useModal } from '@faceless-ui/modal'\nimport * as qs from 'qs-esm'\nimport React, { useCallback, useEffect, useState } from 'react'\n\nimport { useForm, useFormModified } from '../../forms/Form/context.js'\nimport { FormSubmit } from '../../forms/Submit/index.js'\nimport { useHotkey } from '../../hooks/useHotkey.js'\nimport { useConfig } from '../../providers/Config/index.js'\nimport { useDocumentInfo } from '../../providers/DocumentInfo/index.js'\nimport { useEditDepth } from '../../providers/EditDepth/index.js'\nimport { useLocale } from '../../providers/Locale/index.js'\nimport { useOperation } from '../../providers/Operation/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { traverseForLocalizedFields } from '../../utilities/traverseForLocalizedFields.js'\nimport { PopupList } from '../Popup/index.js'\nimport { ScheduleDrawer } from './ScheduleDrawer/index.js'\n\nexport function PublishButton({ label: labelProp }: PublishButtonClientProps) {\n const {\n id,\n collectionSlug,\n docConfig,\n globalSlug,\n hasPublishedDoc,\n hasPublishPermission,\n setHasPublishedDoc,\n setMostRecentVersionIsAutosaved,\n setUnpublishedVersionCount,\n unpublishedVersionCount,\n uploadStatus,\n } = useDocumentInfo()\n\n const { config, getEntityConfig } = useConfig()\n const { submit } = useForm()\n const modified = useFormModified()\n const editDepth = useEditDepth()\n const { code: localeCode } = useLocale()\n const { isModalOpen, toggleModal } = useModal()\n\n const drawerSlug = `schedule-publish-${id}`\n\n const {\n localization,\n routes: { api },\n serverURL,\n } = config\n\n const { t } = useTranslation()\n const label = labelProp || t('version:publishChanges')\n\n const entityConfig = React.useMemo(() => {\n if (collectionSlug) {\n return getEntityConfig({ collectionSlug })\n }\n\n if (globalSlug) {\n return getEntityConfig({ globalSlug })\n }\n }, [collectionSlug, globalSlug, getEntityConfig])\n\n const hasNewerVersions = unpublishedVersionCount > 0\n\n const schedulePublish =\n typeof entityConfig?.versions?.drafts === 'object' &&\n entityConfig?.versions?.drafts.schedulePublish\n\n const canPublish =\n hasPublishPermission &&\n (modified || hasNewerVersions || !hasPublishedDoc) &&\n uploadStatus !== 'uploading'\n\n const scheduledPublishEnabled = Boolean(schedulePublish)\n\n // If autosave is enabled the modified will always be true so only conditionally check on modified state\n const hasAutosave = Boolean(\n typeof entityConfig?.versions?.drafts === 'object' && entityConfig?.versions?.drafts.autosave,\n )\n\n const canSchedulePublish = Boolean(\n scheduledPublishEnabled &&\n hasPublishPermission &&\n (globalSlug || (collectionSlug && id)) &&\n (hasAutosave || !modified),\n )\n\n const [hasLocalizedFields, setHasLocalizedFields] = useState(false)\n\n useEffect(() => {\n const hasLocalizedField = traverseForLocalizedFields(entityConfig?.fields)\n setHasLocalizedFields(hasLocalizedField)\n }, [entityConfig?.fields])\n\n const canPublishSpecificLocale = localization && hasLocalizedFields && hasPublishPermission\n\n const operation = useOperation()\n\n const disabled = operation === 'update' && !modified\n\n const saveDraft = useCallback(async () => {\n if (disabled) {\n return\n }\n\n const search = `?locale=${localeCode}&depth=0&fallback-locale=null&draft=true`\n let action\n let method = 'POST'\n\n if (collectionSlug) {\n action = `${serverURL}${api}/${collectionSlug}${id ? `/${id}` : ''}${search}`\n if (id) {\n method = 'PATCH'\n }\n }\n\n if (globalSlug) {\n action = `${serverURL}${api}/globals/${globalSlug}${search}`\n }\n\n await submit({\n action,\n method,\n overrides: {\n _status: 'draft',\n },\n skipValidation: true,\n })\n }, [submit, collectionSlug, globalSlug, serverURL, api, localeCode, id, disabled])\n\n useHotkey({ cmdCtrlKey: true, editDepth, keyCodes: ['s'] }, (e) => {\n e.preventDefault()\n e.stopPropagation()\n\n if (saveDraft && docConfig.versions?.drafts && docConfig.versions?.drafts?.autosave) {\n void saveDraft()\n }\n })\n\n const publish = useCallback(async () => {\n if (uploadStatus === 'uploading') {\n return\n }\n\n const result = await submit({\n overrides: {\n _status: 'published',\n },\n })\n\n if (result) {\n setUnpublishedVersionCount(0)\n setMostRecentVersionIsAutosaved(false)\n setHasPublishedDoc(true)\n }\n }, [\n setHasPublishedDoc,\n submit,\n setUnpublishedVersionCount,\n uploadStatus,\n setMostRecentVersionIsAutosaved,\n ])\n\n const publishSpecificLocale = useCallback(\n async (locale) => {\n if (uploadStatus === 'uploading') {\n return\n }\n\n const params = qs.stringify({\n depth: 0,\n publishSpecificLocale: locale,\n })\n\n const action = `${serverURL}${api}${\n globalSlug ? `/globals/${globalSlug}` : `/${collectionSlug}${id ? `/${id}` : ''}`\n }${params ? '?' + params : ''}`\n\n const result = await submit({\n action,\n overrides: {\n _status: 'published',\n },\n })\n\n if (result) {\n setHasPublishedDoc(true)\n }\n },\n [api, collectionSlug, globalSlug, id, serverURL, setHasPublishedDoc, submit, uploadStatus],\n )\n\n const publishAll =\n !localization || (localization && localization.defaultLocalePublishOption !== 'active')\n\n const activeLocale =\n localization &&\n localization?.locales.find((locale) =>\n typeof locale === 'string' ? locale === localeCode : locale.code === localeCode,\n )\n\n const activeLocaleLabel =\n activeLocale &&\n (typeof activeLocale.label === 'string'\n ? activeLocale.label\n : (activeLocale.label?.[localeCode] ?? undefined))\n\n const defaultPublish = publishAll ? publish : () => publishSpecificLocale(activeLocale.code)\n const defaultLabel = publishAll ? label : t('version:publishIn', { locale: activeLocaleLabel })\n\n const secondaryPublish = publishAll ? () => publishSpecificLocale(activeLocale.code) : publish\n const secondaryLabel = publishAll\n ? t('version:publishIn', { locale: activeLocaleLabel })\n : t('version:publishAllLocales')\n\n if (!hasPublishPermission) {\n return null\n }\n\n return (\n <React.Fragment>\n <FormSubmit\n buttonId=\"action-save\"\n disabled={!canPublish}\n enableSubMenu={canSchedulePublish}\n onClick={defaultPublish}\n size=\"medium\"\n SubMenuPopupContent={\n canPublishSpecificLocale || canSchedulePublish\n ? ({ close }) => {\n return (\n <React.Fragment>\n {canSchedulePublish && (\n <PopupList.ButtonGroup key=\"schedule-publish\">\n <PopupList.Button\n id=\"schedule-publish\"\n onClick={() => [toggleModal(drawerSlug), close()]}\n >\n {t('version:schedulePublish')}\n </PopupList.Button>\n </PopupList.ButtonGroup>\n )}\n {canPublishSpecificLocale && (\n <PopupList.ButtonGroup>\n <PopupList.Button id=\"publish-locale\" onClick={secondaryPublish}>\n {secondaryLabel}\n </PopupList.Button>\n </PopupList.ButtonGroup>\n )}\n </React.Fragment>\n )\n }\n : undefined\n }\n type=\"button\"\n >\n {localization ? defaultLabel : label}\n </FormSubmit>\n {canSchedulePublish && isModalOpen(drawerSlug) && (\n <ScheduleDrawer\n defaultType={!hasNewerVersions ? 'unpublish' : 'publish'}\n schedulePublishConfig={typeof schedulePublish === 'object' && schedulePublish}\n slug={drawerSlug}\n />\n )}\n </React.Fragment>\n )\n}\n"],"mappings":"AAAA;;;AAIA,SAASA,QAAQ,QAAQ;AACzB,YAAYC,EAAA,MAAQ;AACpB,OAAOC,KAAA,IAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ;AAExD,SAASC,OAAO,EAAEC,eAAe,QAAQ;AACzC,SAASC,UAAU,QAAQ;AAC3B,SAASC,SAAS,QAAQ;AAC1B,SAASC,SAAS,QAAQ;AAC1B,SAASC,eAAe,QAAQ;AAChC,SAASC,YAAY,QAAQ;AAC7B,SAASC,SAAS,QAAQ;AAC1B,SAASC,YAAY,QAAQ;AAC7B,SAASC,cAAc,QAAQ;AAC/B,SAASC,0BAA0B,QAAQ;AAC3C,SAASC,SAAS,QAAQ;AAC1B,SAASC,cAAc,QAAQ;AAE/B,OAAO,SAASC,cAAc;EAAEC,KAAA,EAAOC;AAAS,CAA4B;EAC1E,MAAM;IACJC,EAAE;IACFC,cAAc;IACdC,SAAS;IACTC,UAAU;IACVC,eAAe;IACfC,oBAAoB;IACpBC,kBAAkB;IAClBC,+BAA+B;IAC/BC,0BAA0B;IAC1BC,uBAAuB;IACvBC;EAAY,CACb,GAAGrB,eAAA;EAEJ,MAAM;IAAEsB,MAAM;IAAEC;EAAe,CAAE,GAAGxB,SAAA;EACpC,MAAM;IAAEyB;EAAM,CAAE,GAAG7B,OAAA;EACnB,MAAM8B,QAAA,GAAW7B,eAAA;EACjB,MAAM8B,SAAA,GAAYzB,YAAA;EAClB,MAAM;IAAE0B,IAAA,EAAMC;EAA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A,CAAC/F,KAAA,CAAMgG,QAAQ;qBACZvC,kBAAA,iBACCwC,IAAA,CAAClF,SAAA,CAAUyF,WAAW;sBACpB,aAAAP,IAAA,CAAClF,SAAA,CAAU0F,MAAM;cACfrF,EAAA,EAAG;cACHgF,OAAA,EAASA,CAAA,KAAM,CAAC7D,WAAA,CAAYC,UAAA,GAAa+D,KAAA,GAAQ;wBAEhD1D,CAAA,CAAE;;aALoB,qBAS5BiB,wBAAA,iBACCmC,IAAA,CAAClF,SAAA,CAAUyF,WAAW;sBACpB,aAAAP,IAAA,CAAClF,SAAA,CAAU0F,MAAM;cAACrF,EAAA,EAAG;cAAiBgF,OAAA,EAASP,gBAAA;wBAC5CC;;;;MAMb,IACAJ,SAAA;MAENgB,IAAA,EAAK;gBAEJjE,YAAA,GAAemD,YAAA,GAAe1E;QAEhCuC,kBAAA,IAAsBnB,WAAA,CAAYE,UAAA,kBACjCyD,IAAA,CAACjF,cAAA;MACC2F,WAAA,EAAa,CAAC3D,gBAAA,GAAmB,cAAc;MAC/C4D,qBAAA,EAAuB,OAAO3D,eAAA,KAAoB,YAAYA,eAAA;MAC9D4D,IAAA,EAAMrE;;;AAKhB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["useModal","qs","React","useCallback","useEffect","useState","useForm","useFormModified","FormSubmit","useHotkey","useConfig","useDocumentInfo","useEditDepth","useLocale","useOperation","useTranslation","traverseForLocalizedFields","PopupList","ScheduleDrawer","PublishButton","label","labelProp","id","collectionSlug","docConfig","globalSlug","hasPublishedDoc","hasPublishPermission","setHasPublishedDoc","setMostRecentVersionIsAutosaved","setUnpublishedVersionCount","unpublishedVersionCount","uploadStatus","config","getEntityConfig","submit","modified","editDepth","code","localeCode","isModalOpen","toggleModal","drawerSlug","localization","routes","api","serverURL","t","entityConfig","useMemo","hasNewerVersions","schedulePublish","versions","drafts","canPublish","scheduledPublishEnabled","Boolean","hasAutosave","autosave","canSchedulePublish","hasLocalizedFields","setHasLocalizedFields","hasLocalizedField","fields","isSpecificLocalePublishEnabled","operation","disabled","saveDraft","search","action","method","overrides","_status","skipValidation","cmdCtrlKey","keyCodes","e","preventDefault","stopPropagation","publish","result","publishSpecificLocale","locale","params","stringify","depth","isDefaultPublishAll","defaultLocalePublishOption","activeLocale","locales","find","activeLocaleLabel","undefined","_jsxs","Fragment","_jsx","buttonId","enableSubMenu","onClick","size","SubMenuPopupContent","close","ButtonGroup","Button","type","defaultType","schedulePublishConfig","slug"],"sources":["../../../src/elements/PublishButton/index.tsx"],"sourcesContent":["'use client'\n\nimport type { PublishButtonClientProps } from 'payload'\n\nimport { useModal } from '@faceless-ui/modal'\nimport * as qs from 'qs-esm'\nimport React, { useCallback, useEffect, useState } from 'react'\n\nimport { useForm, useFormModified } from '../../forms/Form/context.js'\nimport { FormSubmit } from '../../forms/Submit/index.js'\nimport { useHotkey } from '../../hooks/useHotkey.js'\nimport { useConfig } from '../../providers/Config/index.js'\nimport { useDocumentInfo } from '../../providers/DocumentInfo/index.js'\nimport { useEditDepth } from '../../providers/EditDepth/index.js'\nimport { useLocale } from '../../providers/Locale/index.js'\nimport { useOperation } from '../../providers/Operation/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { traverseForLocalizedFields } from '../../utilities/traverseForLocalizedFields.js'\nimport { PopupList } from '../Popup/index.js'\nimport { ScheduleDrawer } from './ScheduleDrawer/index.js'\n\nexport function PublishButton({ label: labelProp }: PublishButtonClientProps) {\n const {\n id,\n collectionSlug,\n docConfig,\n globalSlug,\n hasPublishedDoc,\n hasPublishPermission,\n setHasPublishedDoc,\n setMostRecentVersionIsAutosaved,\n setUnpublishedVersionCount,\n unpublishedVersionCount,\n uploadStatus,\n } = useDocumentInfo()\n\n const { config, getEntityConfig } = useConfig()\n const { submit } = useForm()\n const modified = useFormModified()\n const editDepth = useEditDepth()\n const { code: localeCode } = useLocale()\n const { isModalOpen, toggleModal } = useModal()\n\n const drawerSlug = `schedule-publish-${id}`\n\n const {\n localization,\n routes: { api },\n serverURL,\n } = config\n\n const { t } = useTranslation()\n const label = labelProp || t('version:publishChanges')\n\n const entityConfig = React.useMemo(() => {\n if (collectionSlug) {\n return getEntityConfig({ collectionSlug })\n }\n\n if (globalSlug) {\n return getEntityConfig({ globalSlug })\n }\n }, [collectionSlug, globalSlug, getEntityConfig])\n\n const hasNewerVersions = unpublishedVersionCount > 0\n\n const schedulePublish =\n typeof entityConfig?.versions?.drafts === 'object' &&\n entityConfig?.versions?.drafts.schedulePublish\n\n const canPublish =\n hasPublishPermission &&\n (modified || hasNewerVersions || !hasPublishedDoc) &&\n uploadStatus !== 'uploading'\n\n const scheduledPublishEnabled = Boolean(schedulePublish)\n\n // If autosave is enabled the modified will always be true so only conditionally check on modified state\n const hasAutosave = Boolean(\n typeof entityConfig?.versions?.drafts === 'object' && entityConfig?.versions?.drafts.autosave,\n )\n\n const canSchedulePublish = Boolean(\n scheduledPublishEnabled &&\n hasPublishPermission &&\n (globalSlug || (collectionSlug && id)) &&\n (hasAutosave || !modified),\n )\n\n const [hasLocalizedFields, setHasLocalizedFields] = useState(false)\n\n useEffect(() => {\n const hasLocalizedField = traverseForLocalizedFields(entityConfig?.fields)\n setHasLocalizedFields(hasLocalizedField)\n }, [entityConfig?.fields])\n\n const isSpecificLocalePublishEnabled = localization && hasLocalizedFields && hasPublishPermission\n\n const operation = useOperation()\n\n const disabled = operation === 'update' && !modified\n\n const saveDraft = useCallback(async () => {\n if (disabled) {\n return\n }\n\n const search = `?locale=${localeCode}&depth=0&fallback-locale=null&draft=true`\n let action\n let method = 'POST'\n\n if (collectionSlug) {\n action = `${serverURL}${api}/${collectionSlug}${id ? `/${id}` : ''}${search}`\n if (id) {\n method = 'PATCH'\n }\n }\n\n if (globalSlug) {\n action = `${serverURL}${api}/globals/${globalSlug}${search}`\n }\n\n await submit({\n action,\n method,\n overrides: {\n _status: 'draft',\n },\n skipValidation: true,\n })\n }, [submit, collectionSlug, globalSlug, serverURL, api, localeCode, id, disabled])\n\n useHotkey({ cmdCtrlKey: true, editDepth, keyCodes: ['s'] }, (e) => {\n e.preventDefault()\n e.stopPropagation()\n\n if (saveDraft && docConfig.versions?.drafts && docConfig.versions?.drafts?.autosave) {\n void saveDraft()\n }\n })\n\n const publish = useCallback(async () => {\n if (uploadStatus === 'uploading') {\n return\n }\n\n const result = await submit({\n overrides: {\n _status: 'published',\n },\n })\n\n if (result) {\n setUnpublishedVersionCount(0)\n setMostRecentVersionIsAutosaved(false)\n setHasPublishedDoc(true)\n }\n }, [\n setHasPublishedDoc,\n submit,\n setUnpublishedVersionCount,\n uploadStatus,\n setMostRecentVersionIsAutosaved,\n ])\n\n const publishSpecificLocale = useCallback(\n async (locale) => {\n if (uploadStatus === 'uploading') {\n return\n }\n\n const params = qs.stringify({\n depth: 0,\n publishSpecificLocale: locale,\n })\n\n const action = `${serverURL}${api}${\n globalSlug ? `/globals/${globalSlug}` : `/${collectionSlug}${id ? `/${id}` : ''}`\n }${params ? '?' + params : ''}`\n\n const result = await submit({\n action,\n overrides: {\n _status: 'published',\n },\n })\n\n if (result) {\n setHasPublishedDoc(true)\n }\n },\n [api, collectionSlug, globalSlug, id, serverURL, setHasPublishedDoc, submit, uploadStatus],\n )\n\n // Publish to all locales unless there are localized fields AND defaultLocalePublishOption is 'active'\n const isDefaultPublishAll =\n !isSpecificLocalePublishEnabled ||\n (localization && localization?.defaultLocalePublishOption !== 'active')\n\n const activeLocale =\n localization &&\n localization?.locales.find((locale) =>\n typeof locale === 'string' ? locale === localeCode : locale.code === localeCode,\n )\n\n const activeLocaleLabel =\n activeLocale &&\n (typeof activeLocale.label === 'string'\n ? activeLocale.label\n : (activeLocale.label?.[localeCode] ?? undefined))\n\n if (!hasPublishPermission) {\n return null\n }\n\n return (\n <React.Fragment>\n <FormSubmit\n buttonId=\"action-save\"\n disabled={!canPublish}\n enableSubMenu={canSchedulePublish}\n onClick={isDefaultPublishAll ? publish : () => publishSpecificLocale(activeLocale.code)}\n size=\"medium\"\n SubMenuPopupContent={\n isSpecificLocalePublishEnabled || canSchedulePublish\n ? ({ close }) => {\n return (\n <React.Fragment>\n {canSchedulePublish && (\n <PopupList.ButtonGroup key=\"schedule-publish\">\n <PopupList.Button\n id=\"schedule-publish\"\n onClick={() => [toggleModal(drawerSlug), close()]}\n >\n {t('version:schedulePublish')}\n </PopupList.Button>\n </PopupList.ButtonGroup>\n )}\n {isSpecificLocalePublishEnabled && (\n <PopupList.ButtonGroup>\n <PopupList.Button\n id=\"publish-locale\"\n onClick={\n isDefaultPublishAll\n ? () => publishSpecificLocale(activeLocale.code)\n : publish\n }\n >\n {isDefaultPublishAll\n ? t('version:publishIn', { locale: activeLocaleLabel })\n : t('version:publishAllLocales')}\n </PopupList.Button>\n </PopupList.ButtonGroup>\n )}\n </React.Fragment>\n )\n }\n : undefined\n }\n type=\"button\"\n >\n {!isDefaultPublishAll ? t('version:publishIn', { locale: activeLocaleLabel }) : label}\n </FormSubmit>\n {canSchedulePublish && isModalOpen(drawerSlug) && (\n <ScheduleDrawer\n defaultType={!hasNewerVersions ? 'unpublish' : 'publish'}\n schedulePublishConfig={typeof schedulePublish === 'object' && schedulePublish}\n slug={drawerSlug}\n />\n )}\n </React.Fragment>\n )\n}\n"],"mappings":"AAAA;;;AAIA,SAASA,QAAQ,QAAQ;AACzB,YAAYC,EAAA,MAAQ;AACpB,OAAOC,KAAA,IAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ;AAExD,SAASC,OAAO,EAAEC,eAAe,QAAQ;AACzC,SAASC,UAAU,QAAQ;AAC3B,SAASC,SAAS,QAAQ;AAC1B,SAASC,SAAS,QAAQ;AAC1B,SAASC,eAAe,QAAQ;AAChC,SAASC,YAAY,QAAQ;AAC7B,SAASC,SAAS,QAAQ;AAC1B,SAASC,YAAY,QAAQ;AAC7B,SAASC,cAAc,QAAQ;AAC/B,SAASC,0BAA0B,QAAQ;AAC3C,SAASC,SAAS,QAAQ;AAC1B,SAASC,cAAc,QAAQ;AAE/B,OAAO,SA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AAA,EAAK;MACLC,mBAAA,EACEpC,8BAAA,IAAkCL,kBAAA,GAC9B,CAAC;QAAE0C;MAAK,CAAE;QACR,oBACER,KAAA,CAAC3F,KAAA,CAAM4F,QAAQ;qBACZnC,kBAAA,iBACCoC,IAAA,CAAC9E,SAAA,CAAUqF,WAAW;sBACpB,aAAAP,IAAA,CAAC9E,SAAA,CAAUsF,MAAM;cACfjF,EAAA,EAAG;cACH4E,OAAA,EAASA,CAAA,KAAM,CAACzD,WAAA,CAAYC,UAAA,GAAa2D,KAAA,GAAQ;wBAEhDtD,CAAA,CAAE;;aALoB,qBAS5BiB,8BAAA,iBACC+B,IAAA,CAAC9E,SAAA,CAAUqF,WAAW;sBACpB,aAAAP,IAAA,CAAC9E,SAAA,CAAUsF,MAAM;cACfjF,EAAA,EAAG;cACH4E,OAAA,EACEZ,mBAAA,GACI,MAAML,qBAAA,CAAsBO,YAAA,CAAalD,IAAI,IAC7CyC,OAAA;wBAGLO,mBAAA,GACGvC,CAAA,CAAE,qBAAqB;gBAAEmC,MAAA,EAAQS;cAAkB,KACnD5C,CAAA,CAAE;;;;MAMlB,IACA6C,SAAA;MAENY,IAAA,EAAK;gBAEJ,CAAClB,mBAAA,GAAsBvC,CAAA,CAAE,qBAAqB;QAAEmC,MAAA,EAAQS;MAAkB,KAAKvE;QAEjFuC,kBAAA,IAAsBnB,WAAA,CAAYE,UAAA,kBACjCqD,IAAA,CAAC7E,cAAA;MACCuF,WAAA,EAAa,CAACvD,gBAAA,GAAmB,cAAc;MAC/CwD,qBAAA,EAAuB,OAAOvD,eAAA,KAAoB,YAAYA,eAAA;MAC9DwD,IAAA,EAAMjE;;;AAKhB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/elements/ReactSelect/MultiValueLabel/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/elements/ReactSelect/MultiValueLabel/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAGnD,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAGzC,OAAO,cAAc,CAAA;AAIrB,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAAC,MAAM,CAAC,CAqB7D,CAAA"}
|
|
@@ -1,25 +1,34 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
+
import { getTranslation } from '@payloadcms/translations';
|
|
4
5
|
import React from 'react';
|
|
5
6
|
import { components as SelectComponents } from 'react-select';
|
|
7
|
+
import { useTranslation } from '../../../providers/Translation/index.js';
|
|
6
8
|
import './index.scss';
|
|
7
9
|
const baseClass = 'multi-value-label';
|
|
8
10
|
export const MultiValueLabel = props => {
|
|
9
|
-
// @ts-expect-error-next-line// TODO Fix this - moduleResolution 16 breaks our declare module
|
|
10
11
|
const {
|
|
11
12
|
data,
|
|
12
|
-
selectProps:
|
|
13
|
-
customProps: {
|
|
14
|
-
draggableProps,
|
|
15
|
-
editableProps
|
|
16
|
-
} = {}
|
|
17
|
-
} = {}
|
|
13
|
+
selectProps: t0
|
|
18
14
|
} = props;
|
|
15
|
+
const {
|
|
16
|
+
customProps: t1
|
|
17
|
+
} = t0 === undefined ? {} : t0;
|
|
18
|
+
const {
|
|
19
|
+
draggableProps,
|
|
20
|
+
editableProps
|
|
21
|
+
} = t1 === undefined ? {} : t1;
|
|
22
|
+
const {
|
|
23
|
+
i18n
|
|
24
|
+
} = useTranslation();
|
|
19
25
|
const className = `${baseClass}__text`;
|
|
20
|
-
|
|
26
|
+
const labelText = data.label ? getTranslation(data.label, i18n) : "";
|
|
27
|
+
const titleText = typeof labelText === "string" ? labelText : "";
|
|
28
|
+
return _jsx("div", {
|
|
21
29
|
className: baseClass,
|
|
22
|
-
|
|
30
|
+
title: titleText,
|
|
31
|
+
children: _jsx(SelectComponents.MultiValueLabel, {
|
|
23
32
|
...props,
|
|
24
33
|
innerProps: {
|
|
25
34
|
className,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","components","SelectComponents","baseClass","MultiValueLabel","props","data","selectProps","customProps","draggableProps","editableProps","className","_jsx","innerProps"],"sources":["../../../../src/elements/ReactSelect/MultiValueLabel/index.tsx"],"sourcesContent":["'use client'\nimport type { MultiValueProps } from 'react-select'\n\nimport React from 'react'\nimport { components as SelectComponents } from 'react-select'\n\nimport type { Option } from '../types.js'\n\nimport './index.scss'\n\nconst baseClass = 'multi-value-label'\n\nexport const MultiValueLabel: React.FC<MultiValueProps<Option>> = (props) => {\n // @ts-expect-error-next-line// TODO Fix this - moduleResolution 16 breaks our declare module\n const { data, selectProps: { customProps: { draggableProps, editableProps } = {} } = {} } = props\n\n const className = `${baseClass}__text`\n\n return (\n <div className={baseClass}>\n <SelectComponents.MultiValueLabel\n {...props}\n innerProps={{\n className,\n ...((editableProps && editableProps(data, className, props.selectProps)) || {}),\n ...(draggableProps || {}),\n }}\n />\n </div>\n )\n}\n"],"mappings":"AAAA;;;
|
|
1
|
+
{"version":3,"file":"index.js","names":["getTranslation","React","components","SelectComponents","useTranslation","baseClass","MultiValueLabel","props","data","selectProps","t0","customProps","t1","undefined","draggableProps","editableProps","i18n","className","labelText","label","titleText","_jsx","title","children","innerProps"],"sources":["../../../../src/elements/ReactSelect/MultiValueLabel/index.tsx"],"sourcesContent":["'use client'\nimport type { OptionLabel } from 'payload'\nimport type { MultiValueProps } from 'react-select'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport React from 'react'\nimport { components as SelectComponents } from 'react-select'\n\nimport type { Option } from '../types.js'\n\nimport { useTranslation } from '../../../providers/Translation/index.js'\nimport './index.scss'\n\nconst baseClass = 'multi-value-label'\n\nexport const MultiValueLabel: React.FC<MultiValueProps<Option>> = (props) => {\n // @ts-expect-error-next-line// TODO Fix this - moduleResolution 16 breaks our declare module\n const { data, selectProps: { customProps: { draggableProps, editableProps } = {} } = {} } = props\n const { i18n } = useTranslation()\n\n const className = `${baseClass}__text`\n const labelText = data.label ? getTranslation(data.label as OptionLabel, i18n) : ''\n const titleText = typeof labelText === 'string' ? labelText : ''\n\n return (\n <div className={baseClass} title={titleText}>\n <SelectComponents.MultiValueLabel\n {...props}\n innerProps={{\n className,\n ...((editableProps && editableProps(data, className, props.selectProps)) || {}),\n ...(draggableProps || {}),\n }}\n />\n </div>\n )\n}\n"],"mappings":"AAAA;;;AAIA,SAASA,cAAc,QAAQ;AAC/B,OAAOC,KAAA,MAAW;AAClB,SAASC,UAAA,IAAcC,gBAAgB,QAAQ;AAI/C,SAASC,cAAc,QAAQ;AAC/B,OAAO;AAEP,MAAMC,SAAA,GAAY;AAElB,OAAO,MAAMC,eAAA,GAAqDC,KAAA;EAEhE;IAAAC,IAAA;IAAAC,WAAA,EAAAC;EAAA,IAA4FH,KAAA;EAAjE;IAAAI,WAAA,EAAAC;EAAA,IAAAF,EAA4D,KAAAG,SAAA,QAA5DH,EAA4D;EAA7C;IAAAI,cAAA;IAAAC;EAAA,IAAAH,EAAsC,KAAAC,SAAA,QAAtCD,EAAsC;EAChF;IAAAI;EAAA,IAAiBZ,cAAA;EAEjB,MAAAa,SAAA,GAAkB,GAAAZ,SAAA,QAAoB;EACtC,MAAAa,SAAA,GAAkBV,IAAA,CAAAW,KAAA,GAAanB,cAAA,CAAeQ,IAAA,CAAAW,KAAA,EAA2BH,IAAA,IAAQ;EACjF,MAAAI,SAAA,GAAkB,OAAOF,SAAA,KAAc,WAAWA,SAAA,GAAY;EAAA,OAG5DG,IAAA,CAAC;IAAAJ,SAAA,EAAAZ,SAAA;IAAAiB,KAAA,EAAiCF,SAAA;IAAAG,QAAA,EAChCF,IAAA,CAAAlB,gBAAA,CAAAG,eAAA;MAAA,GACMC,KAAK;MAAAiB,UAAA;QAAAP,SAAA;QAAA,IAGHF,aAAC,IAAiBA,aAAA,CAAcP,IAAA,EAAMS,SAAA,EAAWV,KAAA,CAAAE,WAAiB,OAAQ;QAAA,IAC1EK,cAAA,MAAoB;MAAA;IAAA,C;;CAKlC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/elements/ReactSelect/ValueContainer/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/elements/ReactSelect/ValueContainer/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAGvD,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAGzC,OAAO,cAAc,CAAA;AAIrB,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAAC,MAAM,EAAE,GAAG,CAAC,CAoBrE,CAAA"}
|
|
@@ -1,24 +1,36 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
|
+
import { getTranslation } from '@payloadcms/translations';
|
|
4
5
|
import React from 'react';
|
|
5
6
|
import { components as SelectComponents } from 'react-select';
|
|
7
|
+
import { useTranslation } from '../../../providers/Translation/index.js';
|
|
6
8
|
import './index.scss';
|
|
7
9
|
const baseClass = 'value-container';
|
|
8
10
|
export const ValueContainer = props => {
|
|
9
|
-
// @ts-expect-error-next-line // TODO Fix this - moduleResolution 16 breaks our declare module
|
|
10
11
|
const {
|
|
11
|
-
selectProps:
|
|
12
|
-
customProps
|
|
13
|
-
} = {}
|
|
12
|
+
selectProps: t0
|
|
14
13
|
} = props;
|
|
15
|
-
|
|
14
|
+
const {
|
|
15
|
+
customProps,
|
|
16
|
+
value
|
|
17
|
+
} = t0 === undefined ? {} : t0;
|
|
18
|
+
const {
|
|
19
|
+
i18n
|
|
20
|
+
} = useTranslation();
|
|
21
|
+
let titleText = "";
|
|
22
|
+
if (value && !Array.isArray(value) && typeof value === "object" && "label" in value) {
|
|
23
|
+
const labelText = value.label ? getTranslation(value.label, i18n) : "";
|
|
24
|
+
titleText = typeof labelText === "string" ? labelText : "";
|
|
25
|
+
}
|
|
26
|
+
return _jsxs("div", {
|
|
16
27
|
className: baseClass,
|
|
17
28
|
ref: customProps?.droppableRef,
|
|
18
|
-
|
|
29
|
+
title: titleText,
|
|
30
|
+
children: [customProps?.valueContainerLabel && _jsx("span", {
|
|
19
31
|
className: `${baseClass}__label`,
|
|
20
32
|
children: customProps?.valueContainerLabel
|
|
21
|
-
}),
|
|
33
|
+
}), _jsx(SelectComponents.ValueContainer, {
|
|
22
34
|
...props
|
|
23
35
|
})]
|
|
24
36
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","components","SelectComponents","baseClass","ValueContainer","props","selectProps","customProps","_jsxs","className","ref","droppableRef","valueContainerLabel","_jsx"],"sources":["../../../../src/elements/ReactSelect/ValueContainer/index.tsx"],"sourcesContent":["'use client'\nimport type { ValueContainerProps } from 'react-select'\n\nimport React from 'react'\nimport { components as SelectComponents } from 'react-select'\n\nimport type { Option } from '../types.js'\n\nimport './index.scss'\n\nconst baseClass = 'value-container'\n\nexport const ValueContainer: React.FC<ValueContainerProps<Option, any>> = (props) => {\n // @ts-expect-error-next-line // TODO Fix this - moduleResolution 16 breaks our declare module\n const { selectProps: { customProps } = {} } = props\n\n return (\n <div className={baseClass} ref={customProps?.droppableRef}>\n {customProps?.valueContainerLabel && (\n <span className={`${baseClass}__label`}>{customProps?.valueContainerLabel}</span>\n )}\n <SelectComponents.ValueContainer {...props} />\n </div>\n )\n}\n"],"mappings":"AAAA;;;
|
|
1
|
+
{"version":3,"file":"index.js","names":["getTranslation","React","components","SelectComponents","useTranslation","baseClass","ValueContainer","props","selectProps","t0","customProps","value","undefined","i18n","titleText","Array","isArray","labelText","label","_jsxs","className","ref","droppableRef","title","children","valueContainerLabel","_jsx"],"sources":["../../../../src/elements/ReactSelect/ValueContainer/index.tsx"],"sourcesContent":["'use client'\nimport type { OptionLabel } from 'payload'\nimport type { ValueContainerProps } from 'react-select'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport React from 'react'\nimport { components as SelectComponents } from 'react-select'\n\nimport type { Option } from '../types.js'\n\nimport { useTranslation } from '../../../providers/Translation/index.js'\nimport './index.scss'\n\nconst baseClass = 'value-container'\n\nexport const ValueContainer: React.FC<ValueContainerProps<Option, any>> = (props) => {\n // @ts-expect-error-next-line // TODO Fix this - moduleResolution 16 breaks our declare module\n const { selectProps: { customProps, value } = {} } = props\n const { i18n } = useTranslation()\n\n // Get the title for single-value selects\n let titleText = ''\n if (value && !Array.isArray(value) && typeof value === 'object' && 'label' in value) {\n const labelText = value.label ? getTranslation(value.label as OptionLabel, i18n) : ''\n titleText = typeof labelText === 'string' ? labelText : ''\n }\n\n return (\n <div className={baseClass} ref={customProps?.droppableRef} title={titleText}>\n {customProps?.valueContainerLabel && (\n <span className={`${baseClass}__label`}>{customProps?.valueContainerLabel}</span>\n )}\n <SelectComponents.ValueContainer {...props} />\n </div>\n )\n}\n"],"mappings":"AAAA;;;AAIA,SAASA,cAAc,QAAQ;AAC/B,OAAOC,KAAA,MAAW;AAClB,SAASC,UAAA,IAAcC,gBAAgB,QAAQ;AAI/C,SAASC,cAAc,QAAQ;AAC/B,OAAO;AAEP,MAAMC,SAAA,GAAY;AAElB,OAAO,MAAMC,cAAA,GAA6DC,KAAA;EAExE;IAAAC,WAAA,EAAAC;EAAA,IAAqDF,KAAA;EAAhC;IAAAG,WAAA;IAAAC;EAAA,IAAAF,EAA2B,KAAAG,SAAA,QAA3BH,EAA2B;EAChD;IAAAI;EAAA,IAAiBT,cAAA;EAGjB,IAAAU,SAAA,GAAgB;EAAA,IACZH,KAAA,KAAUI,KAAA,CAAAC,OAAA,CAAcL,KAAA,KAAU,OAAOA,KAAA,KAAU,YAAY,WAAWA,KAAA;IAC5E,MAAAM,SAAA,GAAkBN,KAAA,CAAAO,KAAA,GAAclB,cAAA,CAAeW,KAAA,CAAAO,KAAA,EAA4BL,IAAA,IAAQ;IACnFC,SAAA,CAAAA,CAAA,CAAYA,MAAA,CAAOG,SAAA,KAAc,WAAWA,SAAA,GAAY;EAAxD;EAAA,OAIAE,KAAA,CAAC;IAAAC,SAAA,EAAAf,SAAA;IAAAgB,GAAA,EAA+BX,WAAA,EAAAY,YAAA;IAAAC,KAAA,EAAkCT,SAAA;IAAAU,QAAA,GAC/Dd,WAAA,EAAAe,mBAAA,IACCC,IAAA,CAAC;MAAAN,SAAA,EAAgB,GAAAf,SAAA,SAAqB;MAAAmB,QAAA,EAAGd,WAAA,EAAAe;IAAA,C,GAE3CC,IAAA,CAAAvB,gBAAA,CAAAG,cAAA;MAAA,GAAqCC;IAAK,C;;CAGhD","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","useCallback","useEffect","useState","useDebounce","useEffectEvent","useTranslation","Button","ReactSelect","DefaultFilter","getOperatorValueTypes","baseClass","Condition","props","addCondition","andIndex","fieldPath","filterOptions","operator","orIndex","reducedFields","removeCondition","RenderedFilter","updateCondition","value","t","reducedField","find","field","internalValue","setInternalValue","debouncedValue","booleanSelect","includes","type","valueOptions","label","options","updateValue","disabled","admin","disableListFilter","handleFieldChange","undefined","option","handleOperatorChange","operatorValueTypes","validOperatorValue","isValidValue","_jsx","className","_jsxs","filterOption","inputValue","data","plainTextLabel","toLowerCase","isClearable","onChange","filter","operators","o","internalField","buttonStyle","icon","iconStyle","onClick","round","relation"],"sources":["../../../../src/elements/WhereBuilder/Condition/index.tsx"],"sourcesContent":["'use client'\nimport React, { useCallback, useEffect, useState } from 'react'\n\nimport type {\n AddCondition,\n ReducedField,\n RemoveCondition,\n UpdateCondition,\n Value,\n} from '../types.js'\n\nexport type Props = {\n readonly addCondition: AddCondition\n readonly andIndex: number\n readonly fieldPath: string\n readonly filterOptions: ResolvedFilterOptions\n readonly operator: Operator\n readonly orIndex: number\n readonly reducedFields: ReducedField[]\n readonly removeCondition: RemoveCondition\n readonly RenderedFilter: React.ReactNode\n readonly updateCondition: UpdateCondition\n readonly value: Value\n}\n\nimport type { Operator, Option as PayloadOption, ResolvedFilterOptions } from 'payload'\n\nimport type { Option } from '../../ReactSelect/index.js'\n\nimport { useDebounce } from '../../../hooks/useDebounce.js'\nimport { useEffectEvent } from '../../../hooks/useEffectEvent.js'\nimport { useTranslation } from '../../../providers/Translation/index.js'\nimport { Button } from '../../Button/index.js'\nimport { ReactSelect } from '../../ReactSelect/index.js'\nimport { DefaultFilter } from './DefaultFilter/index.js'\nimport { getOperatorValueTypes } from './validOperators.js'\nimport './index.scss'\n\nconst baseClass = 'condition'\n\nexport const Condition: React.FC<Props> = (props) => {\n const {\n addCondition,\n andIndex,\n fieldPath,\n filterOptions,\n operator,\n orIndex,\n reducedFields,\n removeCondition,\n RenderedFilter,\n updateCondition,\n value,\n } = props\n\n const { t } = useTranslation()\n\n const reducedField = reducedFields.find((field) => field.value === fieldPath)\n\n const [internalValue, setInternalValue] = useState<Value>(value)\n\n const debouncedValue = useDebounce(internalValue, 300)\n\n const booleanSelect = ['exists'].includes(operator) || reducedField?.field?.type === 'checkbox'\n\n let valueOptions: PayloadOption[] = []\n\n if (booleanSelect) {\n valueOptions = [\n { label: t('general:true'), value: 'true' },\n { label: t('general:false'), value: 'false' },\n ]\n } else if (reducedField?.field && 'options' in reducedField.field) {\n valueOptions = reducedField.field.options\n }\n\n const updateValue = useEffectEvent(async (debouncedValue) => {\n if (operator) {\n await updateCondition({\n type: 'value',\n andIndex,\n field: reducedField,\n operator,\n orIndex,\n value: debouncedValue === null ? '' : debouncedValue,\n })\n }\n })\n\n useEffect(() => {\n void updateValue(debouncedValue)\n }, [debouncedValue])\n\n const disabled =\n (!reducedField?.value && typeof reducedField?.value !== 'number') ||\n reducedField?.field?.admin?.disableListFilter\n\n const handleFieldChange = useCallback(\n async (field: Option<string>) => {\n setInternalValue(undefined)\n await updateCondition({\n type: 'field',\n andIndex,\n field: reducedFields.find((option) => option.value === field.value),\n operator,\n orIndex,\n value: undefined,\n })\n },\n [andIndex, operator, orIndex, reducedFields, updateCondition],\n )\n\n const handleOperatorChange = useCallback(\n async (operator: Option<Operator>) => {\n const operatorValueTypes = getOperatorValueTypes(reducedField.field.type)\n const validOperatorValue = operatorValueTypes[operator.value] || 'any'\n const isValidValue =\n validOperatorValue === 'any' ||\n typeof value === validOperatorValue ||\n (validOperatorValue === 'boolean' && (value === 'true' || value === 'false'))\n\n if (!isValidValue) {\n // if the current value is not valid for the new operator\n // reset the value before passing it to updateCondition\n setInternalValue(undefined)\n }\n\n await updateCondition({\n type: 'operator',\n andIndex,\n field: reducedField,\n operator: operator.value,\n orIndex,\n value: isValidValue ? value : undefined,\n })\n },\n [andIndex, reducedField, orIndex, updateCondition, value],\n )\n\n return (\n <div className={baseClass}>\n <div className={`${baseClass}__wrap`}>\n <div className={`${baseClass}__inputs`}>\n <div className={`${baseClass}__field`}>\n <ReactSelect\n disabled={disabled}\n filterOption={(option, inputValue) =>\n ((option?.data?.plainTextLabel as string) || option.label)\n .toLowerCase()\n .includes(inputValue.toLowerCase())\n }\n isClearable={false}\n onChange={handleFieldChange}\n options={reducedFields.filter((field) => !field.field.admin.disableListFilter)}\n value={\n reducedField || {\n value: reducedField?.value,\n }\n }\n />\n </div>\n <div className={`${baseClass}__operator`}>\n <ReactSelect\n disabled={disabled}\n isClearable={false}\n onChange={handleOperatorChange}\n options={reducedField?.operators}\n value={reducedField?.operators.find((o) => operator === o.value) || null}\n />\n </div>\n <div className={`${baseClass}__value`}>\n {RenderedFilter || (\n <DefaultFilter\n booleanSelect={booleanSelect}\n disabled={\n !operator || !reducedField || reducedField?.field?.admin?.disableListFilter\n }\n filterOptions={filterOptions}\n internalField={reducedField}\n onChange={setInternalValue}\n operator={operator}\n options={valueOptions}\n value={internalValue ?? ''}\n />\n )}\n </div>\n </div>\n <div className={`${baseClass}__actions`}>\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__actions-remove`}\n icon=\"x\"\n iconStyle=\"with-border\"\n onClick={() =>\n removeCondition({\n andIndex,\n orIndex,\n })\n }\n round\n />\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__actions-add`}\n icon=\"plus\"\n iconStyle=\"with-border\"\n onClick={() =>\n addCondition({\n andIndex: andIndex + 1,\n field: reducedFields.find((field) => !field.field.admin?.disableListFilter),\n orIndex,\n relation: 'and',\n })\n }\n round\n />\n </div>\n </div>\n </div>\n )\n}\n"],"mappings":"AAAA;;;AACA,OAAOA,KAAA,IAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ;AA4BxD,SAASC,WAAW,QAAQ;AAC5B,SAASC,cAAc,QAAQ;AAC/B,SAASC,cAAc,QAAQ;AAC/B,SAASC,MAAM,QAAQ;AACvB,SAASC,WAAW,QAAQ;AAC5B,SAASC,aAAa,QAAQ;AAC9B,SAASC,qBAAqB,QAAQ;AACtC,OAAO;AAEP,MAAMC,SAAA,GAAY;AAElB,OAAO,MAAMC,SAAA,GAA8BC,KAAA;EACzC,MAAM;IACJC,YAAY;IACZC,QAAQ;IACRC,SAAS;IACTC,aAAa;IACbC,QAAQ;IACRC,OAAO;IACPC,aAAa;IACbC,eAAe;IACfC,cAAc;IACdC,eAAe;IACfC;EAAK,CACN,GAAGX,KAAA;EAEJ,MAAM;IAAEY;EAAC,CAAE,GAAGnB,cAAA;EAEd,MAAMoB,YAAA,GAAeN,aAAA,CAAcO,IAAI,CAAEC,KAAA,IAAUA,KAAA,CAAMJ,KAAK,KAAKR,SAAA;EAEnE,MAAM,CAACa,aAAA,EAAeC,gBAAA,CAAiB,GAAG3B,QAAA,CAAgBqB,KAAA;EAE1D,MAAMO,cAAA,GAAiB3B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A,EAAU;UACVC,OAAA,EAASA,CAAA,KACP7C,eAAA,CAAgB;YACdN,QAAA;YACAI;UACF;UAEFgD,KAAK;yBAEPlB,IAAA,CAAC1C,MAAA;UACCwD,WAAA,EAAY;UACZb,SAAA,EAAW,GAAGvC,SAAA,eAAwB;UACtCqD,IAAA,EAAK;UACLC,SAAA,EAAU;UACVC,OAAA,EAASA,CAAA,KACPpD,YAAA,CAAa;YACXC,QAAA,EAAUA,QAAA,GAAW;YACrBa,KAAA,EAAOR,aAAA,CAAcO,IAAI,CAAEC,OAAA,IAAU,CAACA,OAAA,CAAMA,KAAK,CAACY,KAAK,EAAEC,iBAAA;YACzDtB,OAAA;YACAiD,QAAA,EAAU;UACZ;UAEFD,KAAK;;;;;AAMjB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","useCallback","useEffect","useState","useDebounce","useEffectEvent","useTranslation","Button","ReactSelect","DefaultFilter","getOperatorValueTypes","baseClass","Condition","props","addCondition","andIndex","fieldPath","filterOptions","operator","orIndex","reducedFields","removeCondition","RenderedFilter","updateCondition","value","t","reducedField","find","field","internalValue","setInternalValue","debouncedValue","booleanSelect","includes","type","valueOptions","label","options","updateValue","undefined","disabled","admin","disableListFilter","handleFieldChange","option","handleOperatorChange","operatorValueTypes","validOperatorValue","isValidValue","_jsx","className","_jsxs","filterOption","inputValue","data","plainTextLabel","toLowerCase","isClearable","onChange","filter","operators","o","internalField","buttonStyle","icon","iconStyle","onClick","round","relation"],"sources":["../../../../src/elements/WhereBuilder/Condition/index.tsx"],"sourcesContent":["'use client'\nimport React, { useCallback, useEffect, useState } from 'react'\n\nimport type {\n AddCondition,\n ReducedField,\n RemoveCondition,\n UpdateCondition,\n Value,\n} from '../types.js'\n\nexport type Props = {\n readonly addCondition: AddCondition\n readonly andIndex: number\n readonly fieldPath: string\n readonly filterOptions: ResolvedFilterOptions\n readonly operator: Operator\n readonly orIndex: number\n readonly reducedFields: ReducedField[]\n readonly removeCondition: RemoveCondition\n readonly RenderedFilter: React.ReactNode\n readonly updateCondition: UpdateCondition\n readonly value: Value\n}\n\nimport type { Operator, Option as PayloadOption, ResolvedFilterOptions } from 'payload'\n\nimport type { Option } from '../../ReactSelect/index.js'\n\nimport { useDebounce } from '../../../hooks/useDebounce.js'\nimport { useEffectEvent } from '../../../hooks/useEffectEvent.js'\nimport { useTranslation } from '../../../providers/Translation/index.js'\nimport { Button } from '../../Button/index.js'\nimport { ReactSelect } from '../../ReactSelect/index.js'\nimport { DefaultFilter } from './DefaultFilter/index.js'\nimport { getOperatorValueTypes } from './validOperators.js'\nimport './index.scss'\n\nconst baseClass = 'condition'\n\nexport const Condition: React.FC<Props> = (props) => {\n const {\n addCondition,\n andIndex,\n fieldPath,\n filterOptions,\n operator,\n orIndex,\n reducedFields,\n removeCondition,\n RenderedFilter,\n updateCondition,\n value,\n } = props\n\n const { t } = useTranslation()\n\n const reducedField = reducedFields.find((field) => field.value === fieldPath)\n\n const [internalValue, setInternalValue] = useState<Value>(value)\n\n const debouncedValue = useDebounce(internalValue, 300)\n\n const booleanSelect = ['exists'].includes(operator) || reducedField?.field?.type === 'checkbox'\n\n let valueOptions: PayloadOption[] = []\n\n if (booleanSelect) {\n valueOptions = [\n { label: t('general:true'), value: 'true' },\n { label: t('general:false'), value: 'false' },\n ]\n } else if (reducedField?.field && 'options' in reducedField.field) {\n valueOptions = reducedField.field.options\n }\n\n const updateValue = useEffectEvent(async (debouncedValue: Value) => {\n if (operator) {\n await updateCondition({\n type: 'value',\n andIndex,\n field: reducedField,\n operator,\n orIndex,\n value: debouncedValue === null || debouncedValue === '' ? undefined : debouncedValue,\n })\n }\n })\n\n useEffect(() => {\n void updateValue(debouncedValue)\n }, [debouncedValue])\n\n const disabled =\n (!reducedField?.value && typeof reducedField?.value !== 'number') ||\n reducedField?.field?.admin?.disableListFilter\n\n const handleFieldChange = useCallback(\n async (field: Option<string>) => {\n setInternalValue(undefined)\n await updateCondition({\n type: 'field',\n andIndex,\n field: reducedFields.find((option) => option.value === field.value),\n operator,\n orIndex,\n value: undefined,\n })\n },\n [andIndex, operator, orIndex, reducedFields, updateCondition],\n )\n\n const handleOperatorChange = useCallback(\n async (operator: Option<Operator>) => {\n const operatorValueTypes = getOperatorValueTypes(reducedField.field.type)\n const validOperatorValue = operatorValueTypes[operator.value] || 'any'\n const isValidValue =\n validOperatorValue === 'any' ||\n typeof value === validOperatorValue ||\n (validOperatorValue === 'boolean' && (value === 'true' || value === 'false'))\n\n if (!isValidValue) {\n // if the current value is not valid for the new operator\n // reset the value before passing it to updateCondition\n setInternalValue(undefined)\n }\n\n await updateCondition({\n type: 'operator',\n andIndex,\n field: reducedField,\n operator: operator.value,\n orIndex,\n value: isValidValue ? value : undefined,\n })\n },\n [andIndex, reducedField, orIndex, updateCondition, value],\n )\n\n return (\n <div className={baseClass}>\n <div className={`${baseClass}__wrap`}>\n <div className={`${baseClass}__inputs`}>\n <div className={`${baseClass}__field`}>\n <ReactSelect\n disabled={disabled}\n filterOption={(option, inputValue) =>\n ((option?.data?.plainTextLabel as string) || option.label)\n .toLowerCase()\n .includes(inputValue.toLowerCase())\n }\n isClearable={false}\n onChange={handleFieldChange}\n options={reducedFields.filter((field) => !field.field.admin.disableListFilter)}\n value={\n reducedField || {\n value: reducedField?.value,\n }\n }\n />\n </div>\n <div className={`${baseClass}__operator`}>\n <ReactSelect\n disabled={disabled}\n isClearable={false}\n onChange={handleOperatorChange}\n options={reducedField?.operators}\n value={reducedField?.operators.find((o) => operator === o.value) || null}\n />\n </div>\n <div className={`${baseClass}__value`}>\n {RenderedFilter || (\n <DefaultFilter\n booleanSelect={booleanSelect}\n disabled={\n !operator || !reducedField || reducedField?.field?.admin?.disableListFilter\n }\n filterOptions={filterOptions}\n internalField={reducedField}\n onChange={setInternalValue}\n operator={operator}\n options={valueOptions}\n value={internalValue ?? ''}\n />\n )}\n </div>\n </div>\n <div className={`${baseClass}__actions`}>\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__actions-remove`}\n icon=\"x\"\n iconStyle=\"with-border\"\n onClick={() =>\n removeCondition({\n andIndex,\n orIndex,\n })\n }\n round\n />\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__actions-add`}\n icon=\"plus\"\n iconStyle=\"with-border\"\n onClick={() =>\n addCondition({\n andIndex: andIndex + 1,\n field: reducedFields.find((field) => !field.field.admin?.disableListFilter),\n orIndex,\n relation: 'and',\n })\n }\n round\n />\n </div>\n </div>\n </div>\n )\n}\n"],"mappings":"AAAA;;;AACA,OAAOA,KAAA,IAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ;AA4BxD,SAASC,WAAW,QAAQ;AAC5B,SAASC,cAAc,QAAQ;AAC/B,SAASC,cAAc,QAAQ;AAC/B,SAASC,MAAM,QAAQ;AACvB,SAASC,WAAW,QAAQ;AAC5B,SAASC,aAAa,QAAQ;AAC9B,SAASC,qBAAqB,QAAQ;AACtC,OAAO;AAEP,MAAMC,SAAA,GAAY;AAElB,OAAO,MAAMC,SAAA,GAA8BC,KAAA;EACzC,MAAM;IACJC,YAAY;IACZC,QAAQ;IACRC,SAAS;IACTC,aAAa;IACbC,QAAQ;IACRC,OAAO;IACPC,aAAa;IACbC,eAAe;IACfC,cAAc;IACdC,eAAe;IACfC;EAAK,CACN,GAAGX,KAAA;EAEJ,MAAM;IAAEY;EAAC,CAAE,GAAGnB,cAAA;EAEd,MAAMoB,YAAA,GAAeN,aAAA,CAAcO,IAAI,CAAEC,KAAA,IAAUA,KAAA,CAAMJ,KAAK,KAAKR,SAAA;EAEnE,MAAM,CAACa,aAAA,EAAeC,gBAAA,CAAiB,GAAG3B,QAAA,CAAgBqB,KAAA;EAE1D,MAAMO,cAAA,GAAiB3B,WAAA,CAAYyB,aAAA,EAAe;EAElD,MAAMG,aAAA,GAAgB,CAAC,SAAS,CAACC,QAAQ,CAACf,QAAA,KAAaQ,YAAA,EAAcE,KAAA,EAAOM,IAAA,KAAS;EAErF,IAAIC,YAAA,GAAgC,EAA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SAAA,EAAW,GAAGvC,SAAA,eAAwB;UACtCqD,IAAA,EAAK;UACLC,SAAA,EAAU;UACVC,OAAA,EAASA,CAAA,KACPpD,YAAA,CAAa;YACXC,QAAA,EAAUA,QAAA,GAAW;YACrBa,KAAA,EAAOR,aAAA,CAAcO,IAAI,CAAEC,OAAA,IAAU,CAACA,OAAA,CAAMA,KAAK,CAACa,KAAK,EAAEC,iBAAA;YACzDvB,OAAA;YACAiD,QAAA,EAAU;UACZ;UAEFD,KAAK;;;;;AAMjB","ignoreList":[]}
|
|
@@ -8,7 +8,7 @@ import React from 'react';
|
|
|
8
8
|
* rendering the original component.
|
|
9
9
|
*
|
|
10
10
|
* @example
|
|
11
|
-
* const PredefinedComponent =
|
|
11
|
+
* const PredefinedComponent = withMergedProps({
|
|
12
12
|
* Component: OriginalComponent,
|
|
13
13
|
* toMergeIntoProps: { someExtraValue: 5 }
|
|
14
14
|
* });
|
|
@@ -10,7 +10,7 @@ import React from 'react';
|
|
|
10
10
|
* rendering the original component.
|
|
11
11
|
*
|
|
12
12
|
* @example
|
|
13
|
-
* const PredefinedComponent =
|
|
13
|
+
* const PredefinedComponent = withMergedProps({
|
|
14
14
|
* Component: OriginalComponent,
|
|
15
15
|
* toMergeIntoProps: { someExtraValue: 5 }
|
|
16
16
|
* });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["isReactServerComponentOrFunction","serverProps","React","withMergedProps","Component","sanitizeServerOnlyProps","toMergeIntoProps","undefined","MergedPropsComponent","passedProps","mergedProps","simpleMergeProps","forEach","prop","_jsx","props","toMerge"],"sources":["../../../src/elements/withMergedProps/index.tsx"],"sourcesContent":["import { isReactServerComponentOrFunction, serverProps } from 'payload/shared'\nimport React from 'react'\n\n/**\n * Creates a higher-order component (HOC) that merges predefined properties (`toMergeIntoProps`)\n * with any properties passed to the resulting component.\n *\n * Use this when you want to pre-specify some props for a component, while also allowing users to\n * pass in their own props. The HOC ensures the passed props and predefined props are combined before\n * rendering the original component.\n *\n * @example\n * const PredefinedComponent =
|
|
1
|
+
{"version":3,"file":"index.js","names":["isReactServerComponentOrFunction","serverProps","React","withMergedProps","Component","sanitizeServerOnlyProps","toMergeIntoProps","undefined","MergedPropsComponent","passedProps","mergedProps","simpleMergeProps","forEach","prop","_jsx","props","toMerge"],"sources":["../../../src/elements/withMergedProps/index.tsx"],"sourcesContent":["import { isReactServerComponentOrFunction, serverProps } from 'payload/shared'\nimport React from 'react'\n\n/**\n * Creates a higher-order component (HOC) that merges predefined properties (`toMergeIntoProps`)\n * with any properties passed to the resulting component.\n *\n * Use this when you want to pre-specify some props for a component, while also allowing users to\n * pass in their own props. The HOC ensures the passed props and predefined props are combined before\n * rendering the original component.\n *\n * @example\n * const PredefinedComponent = withMergedProps({\n * Component: OriginalComponent,\n * toMergeIntoProps: { someExtraValue: 5 }\n * });\n * // Using <PredefinedComponent customProp=\"value\" /> will result in\n * // <OriginalComponent customProp=\"value\" someExtraValue={5} />\n *\n * @returns A higher-order component with combined properties.\n *\n * @param Component - The original component to wrap.\n * @param sanitizeServerOnlyProps - If true, server-only props will be removed from the merged props. @default true if the component is not a server component, false otherwise.\n * @param toMergeIntoProps - The properties to merge into the passed props.\n */\nexport function withMergedProps<ToMergeIntoProps, CompleteReturnProps>({\n Component,\n sanitizeServerOnlyProps,\n toMergeIntoProps,\n}: {\n Component: React.FC<CompleteReturnProps>\n sanitizeServerOnlyProps?: boolean\n toMergeIntoProps: ToMergeIntoProps\n}): React.FC<CompleteReturnProps> {\n if (sanitizeServerOnlyProps === undefined) {\n sanitizeServerOnlyProps = !isReactServerComponentOrFunction(Component)\n }\n // A wrapper around the args.Component to inject the args.toMergeArgs as props, which are merged with the passed props\n const MergedPropsComponent: React.FC<CompleteReturnProps> = (passedProps) => {\n const mergedProps = simpleMergeProps(passedProps, toMergeIntoProps) as CompleteReturnProps\n\n if (sanitizeServerOnlyProps) {\n serverProps.forEach((prop) => {\n delete mergedProps[prop]\n })\n }\n\n return <Component {...mergedProps} />\n }\n\n return MergedPropsComponent\n}\n\nfunction simpleMergeProps(props, toMerge) {\n return { ...props, ...toMerge }\n}\n"],"mappings":";AAAA,SAASA,gCAAgC,EAAEC,WAAW,QAAQ;AAC9D,OAAOC,KAAA,MAAW;AAElB;;;;;;;;;;;;;;;;;;;;;;AAsBA,OAAO,SAASC,gBAAuD;EACrEC,SAAS;EACTC,uBAAuB;EACvBC;AAAgB,CAKjB;EACC,IAAID,uBAAA,KAA4BE,SAAA,EAAW;IACzCF,uBAAA,GAA0B,CAACL,gCAAA,CAAiCI,SAAA;EAC9D;EACA;EACA,MAAMI,oBAAA,GAAuDC,WAAA;IAC3D,MAAMC,WAAA,GAAcC,gBAAA,CAAiBF,WAAA,EAAaH,gBAAA;IAElD,IAAID,uBAAA,EAAyB;MAC3BJ,WAAA,CAAYW,OAAO,CAAEC,IAAA;QACnB,OAAOH,WAAW,CAACG,IAAA,CAAK;MAC1B;IACF;IAEA,oBAAOC,IAAA,CAACV,SAAA;MAAW,GAAGM;;EACxB;EAEA,OAAOF,oBAAA;AACT;AAEA,SAASG,iBAAiBI,KAAK,EAAEC,OAAO;EACtC,OAAO;IAAE,GAAGD,KAAK;IAAE,GAAGC;EAAQ;AAChC","ignoreList":[]}
|
|
@@ -10,5 +10,5 @@ function require(m) {
|
|
|
10
10
|
}
|
|
11
11
|
// Workaround end
|
|
12
12
|
|
|
13
|
-
import{l as a}from"./chunk-
|
|
14
|
-
//# sourceMappingURL=CodeEditor-
|
|
13
|
+
import{l as a}from"./chunk-PXD7OIXB.js";import"./chunk-5LKBKI4T.js";export{a as default};
|
|
14
|
+
//# sourceMappingURL=CodeEditor-ORMD3ID3.js.map
|
|
@@ -24,4 +24,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
24
24
|
`).length*18+2+p):l),d.current=u)},b=[c,l,p,u],e[4]=l,e[5]=p,e[6]=u,e[7]=c,e[8]=P,e[9]=b):(P=e[8],b=e[9]),Ke.useEffect(P,b),Ge(_r,{className:v,height:n?Math.min(C,n):C,loading:Ge(se,{height:C}),options:{...qe,...E,readOnly:!!a,detectIndentation:!1,insertSpaces:void 0,tabSize:void 0,trimAutoWhitespace:void 0},theme:L==="dark"?"vs-dark":"vs",value:c,...s,onChange:(f,T)=>{s.onChange?.(f,T),y(f?Math.max(l,f.split(`
|
|
25
25
|
`).length*18+2+p):l)},onMount:(f,T)=>{s.onMount?.(f,T);let _=f.getModel();_&&_.updateOptions({insertSpaces:x??ee.insertSpaces,tabSize:w??ee.tabSize,trimAutoWhitespace:M??ee.trimAutoWhitespace}),y(Math.max(l,f.getValue().split(`
|
|
26
26
|
`).length*18+2+p))}})},co=kr;export{ke as a,jr as b,ue as c,_n as d,Ue as e,se as f,Qn as g,Ar as h,Vn as i,Fe as j,ee as k,co as l};
|
|
27
|
-
//# sourceMappingURL=chunk-
|
|
27
|
+
//# sourceMappingURL=chunk-PXD7OIXB.js.map
|