@payloadcms/ui
Advanced tools
Comparing version 3.11.1-canary.54f6c59 to 3.11.1-canary.eb516b3
@@ -9,2 +9,3 @@ import type { JsonObject } from 'payload'; | ||
collectionSlug: string; | ||
currentActivePath: string; | ||
drawerSlug: string; | ||
@@ -16,6 +17,7 @@ initialFiles: FileList; | ||
setCollectionSlug: (slug: string) => void; | ||
setCurrentActivePath: (path: string) => void; | ||
setInitialFiles: (files: FileList) => void; | ||
setMaxFiles: (maxFiles: number) => void; | ||
setOnCancel: (onCancel: BulkUploadContext['onCancel']) => void; | ||
setOnSuccess: (onSuccess: BulkUploadContext['onSuccess']) => void; | ||
setOnSuccess: (path: string, onSuccess: BulkUploadContext['onSuccess']) => void; | ||
}; | ||
@@ -22,0 +24,0 @@ export declare function BulkUploadProvider({ children }: { |
@@ -88,2 +88,3 @@ 'use client'; | ||
collectionSlug: '', | ||
currentActivePath: undefined, | ||
drawerSlug: '', | ||
@@ -95,2 +96,3 @@ initialFiles: undefined, | ||
setCollectionSlug: () => null, | ||
setCurrentActivePath: () => null, | ||
setInitialFiles: () => null, | ||
@@ -102,3 +104,3 @@ setMaxFiles: () => null, | ||
export function BulkUploadProvider(t0) { | ||
const $ = _c(14); | ||
const $ = _c(16); | ||
const { | ||
@@ -108,6 +110,7 @@ children | ||
const [collection, setCollection] = React.useState(); | ||
const [onSuccessFunction, setOnSuccessFunction] = React.useState(); | ||
const [onSuccessFunctionMap, setOnSuccessFunctionMap] = React.useState(); | ||
const [onCancelFunction, setOnCancelFunction] = React.useState(); | ||
const [initialFiles, setInitialFiles] = React.useState(undefined); | ||
const [maxFiles, setMaxFiles] = React.useState(undefined); | ||
const [currentActivePath, setCurrentActivePath] = React.useState(undefined); | ||
const drawerSlug = useBulkUploadDrawerSlug(); | ||
@@ -126,4 +129,7 @@ let t1; | ||
if ($[1] === Symbol.for("react.memo_cache_sentinel")) { | ||
t2 = onSuccess => { | ||
setOnSuccessFunction(() => onSuccess); | ||
t2 = (path, onSuccess) => { | ||
setOnSuccessFunctionMap(prev => ({ | ||
...prev, | ||
[path]: onSuccess | ||
})); | ||
}; | ||
@@ -148,18 +154,21 @@ $[1] = t2; | ||
let t4; | ||
if ($[4] !== onSuccessFunction) { | ||
if ($[4] !== currentActivePath || $[5] !== onSuccessFunctionMap) { | ||
t4 = (docIDs, errorCount) => { | ||
if (typeof onSuccessFunction === "function") { | ||
if (onSuccessFunctionMap && Object.hasOwn(onSuccessFunctionMap, currentActivePath)) { | ||
const onSuccessFunction = onSuccessFunctionMap[currentActivePath]; | ||
onSuccessFunction(docIDs, errorCount); | ||
} | ||
}; | ||
$[4] = onSuccessFunction; | ||
$[5] = t4; | ||
$[4] = currentActivePath; | ||
$[5] = onSuccessFunctionMap; | ||
$[6] = t4; | ||
} else { | ||
t4 = $[5]; | ||
t4 = $[6]; | ||
} | ||
let t5; | ||
if ($[6] !== children || $[7] !== collection || $[8] !== drawerSlug || $[9] !== initialFiles || $[10] !== maxFiles || $[11] !== t3 || $[12] !== t4) { | ||
if ($[7] !== children || $[8] !== collection || $[9] !== currentActivePath || $[10] !== drawerSlug || $[11] !== initialFiles || $[12] !== maxFiles || $[13] !== t3 || $[14] !== t4) { | ||
t5 = _jsx(Context.Provider, { | ||
value: { | ||
collectionSlug: collection, | ||
currentActivePath, | ||
drawerSlug, | ||
@@ -171,2 +180,3 @@ initialFiles, | ||
setCollectionSlug, | ||
setCurrentActivePath, | ||
setInitialFiles, | ||
@@ -181,12 +191,13 @@ setMaxFiles, | ||
}); | ||
$[6] = children; | ||
$[7] = collection; | ||
$[8] = drawerSlug; | ||
$[9] = initialFiles; | ||
$[10] = maxFiles; | ||
$[11] = t3; | ||
$[12] = t4; | ||
$[13] = t5; | ||
$[7] = children; | ||
$[8] = collection; | ||
$[9] = currentActivePath; | ||
$[10] = drawerSlug; | ||
$[11] = initialFiles; | ||
$[12] = maxFiles; | ||
$[13] = t3; | ||
$[14] = t4; | ||
$[15] = t5; | ||
} else { | ||
t5 = $[13]; | ||
t5 = $[15]; | ||
} | ||
@@ -193,0 +204,0 @@ return t5; |
'use client'; | ||
import { c as _c } from "react/compiler-runtime"; | ||
import { jsx as _jsx } from "react/jsx-runtime"; | ||
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; | ||
import { useModal } from '@faceless-ui/modal'; | ||
import * as qs from 'qs-esm'; | ||
@@ -17,8 +17,7 @@ import React, { useCallback } from 'react'; | ||
import { PopupList } from '../Popup/index.js'; | ||
export const PublishButton = t0 => { | ||
const $ = _c(41); | ||
import { ScheduleDrawer } from './ScheduleDrawer/index.js'; | ||
export const PublishButton = ({ | ||
label: labelProp | ||
}) => { | ||
const { | ||
label: labelProp | ||
} = t0; | ||
const { | ||
id, | ||
@@ -46,203 +45,134 @@ collectionSlug, | ||
const { | ||
isModalOpen, | ||
toggleModal | ||
} = useModal(); | ||
const drawerSlug = `schedule-publish-${id}`; | ||
const { | ||
localization, | ||
routes: t1, | ||
routes: { | ||
api | ||
}, | ||
serverURL | ||
} = config; | ||
const { | ||
api | ||
} = t1; | ||
const { | ||
i18n, | ||
t | ||
} = useTranslation(); | ||
let t2; | ||
if ($[0] !== labelProp || $[1] !== t) { | ||
t2 = labelProp || t("version:publishChanges"); | ||
$[0] = labelProp; | ||
$[1] = t; | ||
$[2] = t2; | ||
} else { | ||
t2 = $[2]; | ||
} | ||
const label = t2; | ||
const label = labelProp || t('version:publishChanges'); | ||
const entityConfig = React.useMemo(() => { | ||
if (collectionSlug) { | ||
return config.collections.find(({ | ||
slug | ||
}) => slug === collectionSlug); | ||
} | ||
if (globalSlug) { | ||
return config.globals.find(({ | ||
slug: slug_0 | ||
}) => slug_0 === globalSlug); | ||
} | ||
}, [collectionSlug, globalSlug, config]); | ||
const scheduledPublishEnabled = typeof entityConfig?.versions?.drafts === 'object' && entityConfig?.versions?.drafts.schedulePublish; | ||
const hasNewerVersions = unpublishedVersionCount > 0; | ||
const canPublish = hasPublishPermission && (modified || hasNewerVersions || !hasPublishedDoc); | ||
const operation = useOperation(); | ||
const forceDisable = operation === "update" && !modified; | ||
let t3; | ||
if ($[3] !== api || $[4] !== collectionSlug || $[5] !== forceDisable || $[6] !== globalSlug || $[7] !== id || $[8] !== localeCode || $[9] !== serverURL || $[10] !== submit) { | ||
t3 = async () => { | ||
if (forceDisable) { | ||
return; | ||
const forceDisable = operation === 'update' && !modified; | ||
const saveDraft = useCallback(async () => { | ||
if (forceDisable) { | ||
return; | ||
} | ||
const search = `?locale=${localeCode}&depth=0&fallback-locale=null&draft=true`; | ||
let action; | ||
let method = 'POST'; | ||
if (collectionSlug) { | ||
action = `${serverURL}${api}/${collectionSlug}${id ? `/${id}` : ''}${search}`; | ||
if (id) { | ||
method = 'PATCH'; | ||
} | ||
const search = `?locale=${localeCode}&depth=0&fallback-locale=null&draft=true`; | ||
let action; | ||
let method = "POST"; | ||
if (collectionSlug) { | ||
action = `${serverURL}${api}/${collectionSlug}${id ? `/${id}` : ""}${search}`; | ||
if (id) { | ||
method = "PATCH"; | ||
} | ||
} | ||
if (globalSlug) { | ||
action = `${serverURL}${api}/globals/${globalSlug}${search}`; | ||
} | ||
await submit({ | ||
action, | ||
method, | ||
overrides: { | ||
_status: 'draft' | ||
}, | ||
skipValidation: true | ||
}); | ||
}, [submit, collectionSlug, globalSlug, serverURL, api, localeCode, id, forceDisable]); | ||
useHotkey({ | ||
cmdCtrlKey: true, | ||
editDepth, | ||
keyCodes: ['s'] | ||
}, e => { | ||
e.preventDefault(); | ||
e.stopPropagation(); | ||
if (saveDraft && docConfig.versions?.drafts && docConfig.versions?.drafts?.autosave) { | ||
void saveDraft(); | ||
} | ||
}); | ||
const publish = useCallback(() => { | ||
void submit({ | ||
overrides: { | ||
_status: 'published' | ||
} | ||
if (globalSlug) { | ||
action = `${serverURL}${api}/globals/${globalSlug}${search}`; | ||
}); | ||
setUnpublishedVersionCount(0); | ||
setHasPublishedDoc(true); | ||
}, [setHasPublishedDoc, submit, setUnpublishedVersionCount]); | ||
const publishSpecificLocale = useCallback(locale => { | ||
const params = qs.stringify({ | ||
publishSpecificLocale: locale | ||
}); | ||
const action_0 = `${serverURL}${api}${globalSlug ? `/globals/${globalSlug}` : `/${collectionSlug}/${id ? `${'/' + id}` : ''}`}${params ? '?' + params : ''}`; | ||
void submit({ | ||
action: action_0, | ||
overrides: { | ||
_status: 'published' | ||
} | ||
await submit({ | ||
action, | ||
method, | ||
overrides: { | ||
_status: "draft" | ||
}, | ||
skipValidation: true | ||
}); | ||
}; | ||
$[3] = api; | ||
$[4] = collectionSlug; | ||
$[5] = forceDisable; | ||
$[6] = globalSlug; | ||
$[7] = id; | ||
$[8] = localeCode; | ||
$[9] = serverURL; | ||
$[10] = submit; | ||
$[11] = t3; | ||
} else { | ||
t3 = $[11]; | ||
} | ||
const saveDraft = t3; | ||
let t4; | ||
if ($[12] === Symbol.for("react.memo_cache_sentinel")) { | ||
t4 = ["s"]; | ||
$[12] = t4; | ||
} else { | ||
t4 = $[12]; | ||
} | ||
let t5; | ||
if ($[13] !== editDepth) { | ||
t5 = { | ||
cmdCtrlKey: true, | ||
editDepth, | ||
keyCodes: t4 | ||
}; | ||
$[13] = editDepth; | ||
$[14] = t5; | ||
} else { | ||
t5 = $[14]; | ||
} | ||
let t6; | ||
if ($[15] !== docConfig || $[16] !== saveDraft) { | ||
t6 = e => { | ||
e.preventDefault(); | ||
e.stopPropagation(); | ||
if (saveDraft && docConfig.versions?.drafts && docConfig.versions?.drafts?.autosave) { | ||
saveDraft(); | ||
} | ||
}; | ||
$[15] = docConfig; | ||
$[16] = saveDraft; | ||
$[17] = t6; | ||
} else { | ||
t6 = $[17]; | ||
} | ||
useHotkey(t5, t6); | ||
let t7; | ||
if ($[18] !== setHasPublishedDoc || $[19] !== setUnpublishedVersionCount || $[20] !== submit) { | ||
t7 = () => { | ||
submit({ | ||
overrides: { | ||
_status: "published" | ||
} | ||
}); | ||
setUnpublishedVersionCount(0); | ||
setHasPublishedDoc(true); | ||
}; | ||
$[18] = setHasPublishedDoc; | ||
$[19] = setUnpublishedVersionCount; | ||
$[20] = submit; | ||
$[21] = t7; | ||
} else { | ||
t7 = $[21]; | ||
} | ||
const publish = t7; | ||
let t8; | ||
if ($[22] !== api || $[23] !== collectionSlug || $[24] !== globalSlug || $[25] !== id || $[26] !== serverURL || $[27] !== setHasPublishedDoc || $[28] !== submit) { | ||
t8 = locale => { | ||
const params = qs.stringify({ | ||
publishSpecificLocale: locale | ||
}); | ||
const action_0 = `${serverURL}${api}${globalSlug ? `/globals/${globalSlug}` : `/${collectionSlug}/${id ? `${"/" + id}` : ""}`}${params ? "?" + params : ""}`; | ||
submit({ | ||
action: action_0, | ||
overrides: { | ||
_status: "published" | ||
} | ||
}); | ||
setHasPublishedDoc(true); | ||
}; | ||
$[22] = api; | ||
$[23] = collectionSlug; | ||
$[24] = globalSlug; | ||
$[25] = id; | ||
$[26] = serverURL; | ||
$[27] = setHasPublishedDoc; | ||
$[28] = submit; | ||
$[29] = t8; | ||
} else { | ||
t8 = $[29]; | ||
} | ||
const publishSpecificLocale = t8; | ||
}); | ||
setHasPublishedDoc(true); | ||
}, [api, collectionSlug, globalSlug, id, serverURL, setHasPublishedDoc, submit]); | ||
if (!hasPublishPermission) { | ||
return null; | ||
} | ||
const t9 = !canPublish; | ||
let t10; | ||
if ($[30] !== i18n?.language || $[31] !== localeCode || $[32] !== localization || $[33] !== publishSpecificLocale || $[34] !== t) { | ||
t10 = localization ? t11 => { | ||
const { | ||
close | ||
} = t11; | ||
return localization.locales.map(locale_0 => { | ||
const formattedLabel = typeof locale_0.label === "string" ? locale_0.label : locale_0.label && locale_0.label[i18n?.language]; | ||
const isActive = typeof locale_0 === "string" ? locale_0 === localeCode : locale_0.code === localeCode; | ||
if (isActive) { | ||
return _jsx(PopupList.ButtonGroup, { | ||
children: _jsx(PopupList.Button, { | ||
onClick: () => [publishSpecificLocale(locale_0.code), close()], | ||
children: t("version:publishIn", { | ||
locale: formattedLabel || locale_0.code | ||
}) | ||
}) | ||
}, locale_0.code); | ||
} | ||
}); | ||
} : undefined; | ||
$[30] = i18n?.language; | ||
$[31] = localeCode; | ||
$[32] = localization; | ||
$[33] = publishSpecificLocale; | ||
$[34] = t; | ||
$[35] = t10; | ||
} else { | ||
t10 = $[35]; | ||
} | ||
let t11; | ||
if ($[36] !== label || $[37] !== publish || $[38] !== t10 || $[39] !== t9) { | ||
t11 = _jsx(FormSubmit, { | ||
return /*#__PURE__*/_jsxs(React.Fragment, { | ||
children: [/*#__PURE__*/_jsx(FormSubmit, { | ||
buttonId: "action-save", | ||
disabled: t9, | ||
disabled: !canPublish, | ||
onClick: publish, | ||
size: "medium", | ||
SubMenuPopupContent: t10, | ||
SubMenuPopupContent: localization || scheduledPublishEnabled ? ({ | ||
close | ||
}) => { | ||
return /*#__PURE__*/_jsxs(React.Fragment, { | ||
children: [scheduledPublishEnabled && /*#__PURE__*/_jsx(PopupList.ButtonGroup, { | ||
children: /*#__PURE__*/_jsx(PopupList.Button, { | ||
onClick: () => [toggleModal(drawerSlug), close()], | ||
children: t('version:schedulePublish') | ||
}) | ||
}, "schedule-publish"), localization ? localization.locales.map(locale_0 => { | ||
const formattedLabel = typeof locale_0.label === 'string' ? locale_0.label : locale_0.label && locale_0.label[i18n?.language]; | ||
const isActive = typeof locale_0 === 'string' ? locale_0 === localeCode : locale_0.code === localeCode; | ||
if (isActive) { | ||
return /*#__PURE__*/_jsx(PopupList.ButtonGroup, { | ||
children: /*#__PURE__*/_jsx(PopupList.Button, { | ||
onClick: () => [publishSpecificLocale(locale_0.code), close()], | ||
children: t('version:publishIn', { | ||
locale: formattedLabel || locale_0.code | ||
}) | ||
}) | ||
}, locale_0.code); | ||
} | ||
}) : null] | ||
}); | ||
} : undefined, | ||
type: "button", | ||
children: label | ||
}); | ||
$[36] = label; | ||
$[37] = publish; | ||
$[38] = t10; | ||
$[39] = t9; | ||
$[40] = t11; | ||
} else { | ||
t11 = $[40]; | ||
} | ||
return t11; | ||
}), scheduledPublishEnabled && isModalOpen(drawerSlug) && /*#__PURE__*/_jsx(ScheduleDrawer, { | ||
slug: drawerSlug | ||
})] | ||
}); | ||
}; | ||
//# sourceMappingURL=index.js.map |
@@ -27,3 +27,3 @@ 'use client'; | ||
export function UploadInput(props) { | ||
const $ = _c(126); | ||
const $ = _c(130); | ||
const { | ||
@@ -63,2 +63,3 @@ AfterInput, | ||
setCollectionSlug, | ||
setCurrentActivePath, | ||
setInitialFiles, | ||
@@ -297,3 +298,3 @@ setMaxFiles, | ||
let t17; | ||
if ($[41] !== drawerSlug || $[42] !== hasMany || $[43] !== maxRows || $[44] !== openModal || $[45] !== relationTo || $[46] !== setCollectionSlug || $[47] !== setInitialFiles || $[48] !== setMaxFiles) { | ||
if ($[41] !== drawerSlug || $[42] !== hasMany || $[43] !== maxRows || $[44] !== openModal || $[45] !== path || $[46] !== relationTo || $[47] !== setCollectionSlug || $[48] !== setCurrentActivePath || $[49] !== setInitialFiles || $[50] !== setMaxFiles) { | ||
t17 = fileList => { | ||
@@ -313,2 +314,3 @@ let fileListToUse = fileList; | ||
} | ||
setCurrentActivePath(path); | ||
openModal(drawerSlug); | ||
@@ -320,13 +322,15 @@ }; | ||
$[44] = openModal; | ||
$[45] = relationTo; | ||
$[46] = setCollectionSlug; | ||
$[47] = setInitialFiles; | ||
$[48] = setMaxFiles; | ||
$[49] = t17; | ||
$[45] = path; | ||
$[46] = relationTo; | ||
$[47] = setCollectionSlug; | ||
$[48] = setCurrentActivePath; | ||
$[49] = setInitialFiles; | ||
$[50] = setMaxFiles; | ||
$[51] = t17; | ||
} else { | ||
t17 = $[49]; | ||
t17 = $[51]; | ||
} | ||
const onLocalFileSelection = t17; | ||
let t18; | ||
if ($[50] !== activeRelationTo || $[51] !== closeListDrawer || $[52] !== onChange || $[53] !== populateDocs || $[54] !== value) { | ||
if ($[52] !== activeRelationTo || $[53] !== closeListDrawer || $[54] !== onChange || $[55] !== populateDocs || $[56] !== value) { | ||
t18 = async docs => { | ||
@@ -349,14 +353,14 @@ const selectedDocIDs = []; | ||
}; | ||
$[50] = activeRelationTo; | ||
$[51] = closeListDrawer; | ||
$[52] = onChange; | ||
$[53] = populateDocs; | ||
$[54] = value; | ||
$[55] = t18; | ||
$[52] = activeRelationTo; | ||
$[53] = closeListDrawer; | ||
$[54] = onChange; | ||
$[55] = populateDocs; | ||
$[56] = value; | ||
$[57] = t18; | ||
} else { | ||
t18 = $[55]; | ||
t18 = $[57]; | ||
} | ||
const onListBulkSelect = t18; | ||
let t19; | ||
if ($[56] !== activeRelationTo || $[57] !== closeCreateDocDrawer || $[58] !== onChange) { | ||
if ($[58] !== activeRelationTo || $[59] !== closeCreateDocDrawer || $[60] !== onChange) { | ||
t19 = data => { | ||
@@ -372,12 +376,12 @@ if (data.doc) { | ||
}; | ||
$[56] = activeRelationTo; | ||
$[57] = closeCreateDocDrawer; | ||
$[58] = onChange; | ||
$[59] = t19; | ||
$[58] = activeRelationTo; | ||
$[59] = closeCreateDocDrawer; | ||
$[60] = onChange; | ||
$[61] = t19; | ||
} else { | ||
t19 = $[59]; | ||
t19 = $[61]; | ||
} | ||
const onDocCreate = t19; | ||
let t20; | ||
if ($[60] !== activeRelationTo || $[61] !== closeListDrawer || $[62] !== hasMany || $[63] !== onChange || $[64] !== populateDocs || $[65] !== value) { | ||
if ($[62] !== activeRelationTo || $[63] !== closeListDrawer || $[64] !== hasMany || $[65] !== onChange || $[66] !== populateDocs || $[67] !== value) { | ||
t20 = async t21 => { | ||
@@ -412,15 +416,15 @@ const { | ||
}; | ||
$[60] = activeRelationTo; | ||
$[61] = closeListDrawer; | ||
$[62] = hasMany; | ||
$[63] = onChange; | ||
$[64] = populateDocs; | ||
$[65] = value; | ||
$[66] = t20; | ||
$[62] = activeRelationTo; | ||
$[63] = closeListDrawer; | ||
$[64] = hasMany; | ||
$[65] = onChange; | ||
$[66] = populateDocs; | ||
$[67] = value; | ||
$[68] = t20; | ||
} else { | ||
t20 = $[66]; | ||
t20 = $[68]; | ||
} | ||
const onListSelect = t20; | ||
let t21; | ||
if ($[67] !== populateDocs) { | ||
if ($[69] !== populateDocs) { | ||
t21 = async (docID_0, collectionSlug_0) => { | ||
@@ -444,10 +448,10 @@ const { | ||
}; | ||
$[67] = populateDocs; | ||
$[68] = t21; | ||
$[69] = populateDocs; | ||
$[70] = t21; | ||
} else { | ||
t21 = $[68]; | ||
t21 = $[70]; | ||
} | ||
const reloadDoc = t21; | ||
let t22; | ||
if ($[69] !== onChange) { | ||
if ($[71] !== onChange) { | ||
t22 = newValue_0 => { | ||
@@ -458,10 +462,10 @@ const newValueIDs = newValue_0.map(_temp2); | ||
}; | ||
$[69] = onChange; | ||
$[70] = t22; | ||
$[71] = onChange; | ||
$[72] = t22; | ||
} else { | ||
t22 = $[70]; | ||
t22 = $[72]; | ||
} | ||
const onReorder = t22; | ||
let t23; | ||
if ($[71] !== hasMany || $[72] !== onChange) { | ||
if ($[73] !== hasMany || $[74] !== onChange) { | ||
t23 = newValue_1 => { | ||
@@ -472,7 +476,7 @@ const newValueIDs_0 = newValue_1 ? newValue_1.map(_temp3) : null; | ||
}; | ||
$[71] = hasMany; | ||
$[72] = onChange; | ||
$[73] = t23; | ||
$[73] = hasMany; | ||
$[74] = onChange; | ||
$[75] = t23; | ||
} else { | ||
t23 = $[73]; | ||
t23 = $[75]; | ||
} | ||
@@ -482,3 +486,3 @@ const onRemove = t23; | ||
let t25; | ||
if ($[74] !== activeRelationTo || $[75] !== populateDocs || $[76] !== value) { | ||
if ($[76] !== activeRelationTo || $[77] !== populateDocs || $[78] !== value) { | ||
t24 = () => { | ||
@@ -502,32 +506,34 @@ const loadInitialDocs = async function loadInitialDocs() { | ||
t25 = [populateDocs, activeRelationTo, value]; | ||
$[74] = activeRelationTo; | ||
$[75] = populateDocs; | ||
$[76] = value; | ||
$[77] = t24; | ||
$[78] = t25; | ||
$[76] = activeRelationTo; | ||
$[77] = populateDocs; | ||
$[78] = value; | ||
$[79] = t24; | ||
$[80] = t25; | ||
} else { | ||
t24 = $[77]; | ||
t25 = $[78]; | ||
t24 = $[79]; | ||
t25 = $[80]; | ||
} | ||
useEffect(t24, t25); | ||
let t26; | ||
if ($[79] !== onUploadSuccess || $[80] !== setOnSuccess) { | ||
if ($[81] !== onUploadSuccess || $[82] !== path || $[83] !== setOnSuccess) { | ||
t26 = () => { | ||
setOnSuccess(onUploadSuccess); | ||
setOnSuccess(path, onUploadSuccess); | ||
}; | ||
$[79] = onUploadSuccess; | ||
$[80] = setOnSuccess; | ||
$[81] = t26; | ||
$[81] = onUploadSuccess; | ||
$[82] = path; | ||
$[83] = setOnSuccess; | ||
$[84] = t26; | ||
} else { | ||
t26 = $[81]; | ||
t26 = $[84]; | ||
} | ||
let t27; | ||
if ($[82] !== onUploadSuccess || $[83] !== setOnSuccess || $[84] !== value) { | ||
t27 = [value, onUploadSuccess, setOnSuccess]; | ||
$[82] = onUploadSuccess; | ||
$[83] = setOnSuccess; | ||
$[84] = value; | ||
$[85] = t27; | ||
if ($[85] !== onUploadSuccess || $[86] !== path || $[87] !== setOnSuccess || $[88] !== value) { | ||
t27 = [value, path, onUploadSuccess, setOnSuccess]; | ||
$[85] = onUploadSuccess; | ||
$[86] = path; | ||
$[87] = setOnSuccess; | ||
$[88] = value; | ||
$[89] = t27; | ||
} else { | ||
t27 = $[85]; | ||
t27 = $[89]; | ||
} | ||
@@ -539,10 +545,10 @@ useEffect(t26, t27); | ||
let t30; | ||
if ($[86] !== className || $[87] !== t28 || $[88] !== t29) { | ||
if ($[90] !== className || $[91] !== t28 || $[92] !== t29) { | ||
t30 = [fieldBaseClass, baseClass, className, t28, t29].filter(Boolean); | ||
$[86] = className; | ||
$[87] = t28; | ||
$[88] = t29; | ||
$[89] = t30; | ||
$[90] = className; | ||
$[91] = t28; | ||
$[92] = t29; | ||
$[93] = t30; | ||
} else { | ||
t30 = $[89]; | ||
t30 = $[93]; | ||
} | ||
@@ -552,3 +558,3 @@ const t31 = t30.join(" "); | ||
let t33; | ||
if ($[90] !== AfterInput || $[91] !== BeforeInput || $[92] !== CreateDocDrawer || $[93] !== Description || $[94] !== Error || $[95] !== Label || $[96] !== ListDrawer || $[97] !== canCreate || $[98] !== description || $[99] !== hasMany || $[100] !== isSortable || $[101] !== label || $[102] !== localized || $[103] !== maxRows || $[104] !== onDocCreate || $[105] !== onListBulkSelect || $[106] !== onListSelect || $[107] !== onLocalFileSelection || $[108] !== onRemove || $[109] !== onReorder || $[110] !== openCreateDocDrawer || $[111] !== openListDrawer || $[112] !== path || $[113] !== populatedDocs || $[114] !== readOnly || $[115] !== reloadDoc || $[116] !== required || $[117] !== serverURL || $[118] !== showDropzone || $[119] !== showError || $[120] !== style || $[121] !== t || $[122] !== t31 || $[123] !== t32 || $[124] !== value) { | ||
if ($[94] !== AfterInput || $[95] !== BeforeInput || $[96] !== CreateDocDrawer || $[97] !== Description || $[98] !== Error || $[99] !== Label || $[100] !== ListDrawer || $[101] !== canCreate || $[102] !== description || $[103] !== hasMany || $[104] !== isSortable || $[105] !== label || $[106] !== localized || $[107] !== maxRows || $[108] !== onDocCreate || $[109] !== onListBulkSelect || $[110] !== onListSelect || $[111] !== onLocalFileSelection || $[112] !== onRemove || $[113] !== onReorder || $[114] !== openCreateDocDrawer || $[115] !== openListDrawer || $[116] !== path || $[117] !== populatedDocs || $[118] !== readOnly || $[119] !== reloadDoc || $[120] !== required || $[121] !== serverURL || $[122] !== showDropzone || $[123] !== showError || $[124] !== style || $[125] !== t || $[126] !== t31 || $[127] !== t32 || $[128] !== value) { | ||
t33 = _jsxs("div", { | ||
@@ -663,40 +669,40 @@ className: t31, | ||
}); | ||
$[90] = AfterInput; | ||
$[91] = BeforeInput; | ||
$[92] = CreateDocDrawer; | ||
$[93] = Description; | ||
$[94] = Error; | ||
$[95] = Label; | ||
$[96] = ListDrawer; | ||
$[97] = canCreate; | ||
$[98] = description; | ||
$[99] = hasMany; | ||
$[100] = isSortable; | ||
$[101] = label; | ||
$[102] = localized; | ||
$[103] = maxRows; | ||
$[104] = onDocCreate; | ||
$[105] = onListBulkSelect; | ||
$[106] = onListSelect; | ||
$[107] = onLocalFileSelection; | ||
$[108] = onRemove; | ||
$[109] = onReorder; | ||
$[110] = openCreateDocDrawer; | ||
$[111] = openListDrawer; | ||
$[112] = path; | ||
$[113] = populatedDocs; | ||
$[114] = readOnly; | ||
$[115] = reloadDoc; | ||
$[116] = required; | ||
$[117] = serverURL; | ||
$[118] = showDropzone; | ||
$[119] = showError; | ||
$[120] = style; | ||
$[121] = t; | ||
$[122] = t31; | ||
$[123] = t32; | ||
$[124] = value; | ||
$[125] = t33; | ||
$[94] = AfterInput; | ||
$[95] = BeforeInput; | ||
$[96] = CreateDocDrawer; | ||
$[97] = Description; | ||
$[98] = Error; | ||
$[99] = Label; | ||
$[100] = ListDrawer; | ||
$[101] = canCreate; | ||
$[102] = description; | ||
$[103] = hasMany; | ||
$[104] = isSortable; | ||
$[105] = label; | ||
$[106] = localized; | ||
$[107] = maxRows; | ||
$[108] = onDocCreate; | ||
$[109] = onListBulkSelect; | ||
$[110] = onListSelect; | ||
$[111] = onLocalFileSelection; | ||
$[112] = onRemove; | ||
$[113] = onReorder; | ||
$[114] = openCreateDocDrawer; | ||
$[115] = openListDrawer; | ||
$[116] = path; | ||
$[117] = populatedDocs; | ||
$[118] = readOnly; | ||
$[119] = reloadDoc; | ||
$[120] = required; | ||
$[121] = serverURL; | ||
$[122] = showDropzone; | ||
$[123] = showError; | ||
$[124] = style; | ||
$[125] = t; | ||
$[126] = t31; | ||
$[127] = t32; | ||
$[128] = value; | ||
$[129] = t33; | ||
} else { | ||
t33 = $[125]; | ||
t33 = $[129]; | ||
} | ||
@@ -703,0 +709,0 @@ return t33; |
@@ -370,2 +370,3 @@ import ObjectIdImport from 'bson-objectid'; | ||
relationTo: field.relationTo, | ||
req, | ||
siblingData: data, | ||
@@ -372,0 +373,0 @@ user: req.user |
@@ -43,2 +43,4 @@ 'use client'; | ||
}); | ||
const currentQueryRef = React.useRef(currentQuery); | ||
// If the search params change externally, update the current query | ||
useEffect(() => { | ||
@@ -50,5 +52,5 @@ if (modifySearchParams) { | ||
const refineListData = useCallback(async query => { | ||
let pageQuery = 'page' in query ? query.page : currentQuery?.page; | ||
let page = 'page' in query ? query.page : currentQuery?.page; | ||
if ('where' in query || 'search' in query) { | ||
pageQuery = '1'; | ||
page = '1'; | ||
} | ||
@@ -70,3 +72,3 @@ const updatedPreferences = {}; | ||
limit: 'limit' in query ? query.limit : currentQuery?.limit ?? String(defaultLimit), | ||
page: pageQuery, | ||
page, | ||
search: 'search' in query ? query.search : currentQuery?.search, | ||
@@ -84,2 +86,3 @@ sort: 'sort' in query ? query.sort : currentQuery?.sort ?? defaultSort, | ||
} | ||
setCurrentQuery(newQuery); | ||
}, [currentQuery?.page, currentQuery?.limit, currentQuery?.search, currentQuery?.sort, currentQuery?.where, preferenceKey, defaultLimit, defaultSort, modifySearchParams, onQueryChange, onQueryChangeFromProps, setPreference, router]); | ||
@@ -113,19 +116,25 @@ const handlePageChange = useCallback(async arg => { | ||
}, [refineListData]); | ||
// If `defaultLimit` or `defaultSort` are updated externally, update the query | ||
useEffect(() => { | ||
if (modifySearchParams) { | ||
let shouldUpdateQueryString = false; | ||
if (isNumber(defaultLimit) && !('limit' in currentQuery)) { | ||
currentQuery.limit = String(defaultLimit); | ||
const newQuery_0 = { | ||
...(currentQueryRef.current || {}) | ||
}; | ||
// Allow the URL to override the default limit | ||
if (isNumber(defaultLimit) && !('limit' in currentQueryRef.current)) { | ||
newQuery_0.limit = String(defaultLimit); | ||
shouldUpdateQueryString = true; | ||
} | ||
if (defaultSort && !('sort' in currentQuery)) { | ||
currentQuery.sort = defaultSort; | ||
// Allow the URL to override the default sort | ||
if (defaultSort && !('sort' in currentQueryRef.current)) { | ||
newQuery_0.sort = defaultSort; | ||
shouldUpdateQueryString = true; | ||
} | ||
setCurrentQuery(currentQuery); | ||
if (shouldUpdateQueryString) { | ||
router.replace(`?${qs.stringify(currentQuery)}`); | ||
setCurrentQuery(newQuery_0); | ||
router.replace(`?${qs.stringify(newQuery_0)}`); | ||
} | ||
} | ||
}, [defaultSort, defaultLimit, router, modifySearchParams, currentQuery]); | ||
}, [defaultSort, defaultLimit, router, modifySearchParams]); | ||
return /*#__PURE__*/_jsx(Context.Provider, { | ||
@@ -132,0 +141,0 @@ value: { |
@@ -6,5 +6,9 @@ import type { BuildFormStateArgs, BuildTableStateArgs, Data, DocumentSlots, ServerFunctionClient } from 'payload'; | ||
import type { CopyDataFromLocaleArgs } from '../../utilities/copyDataFromLocale.js'; | ||
import type { schedulePublishHandler, SchedulePublishHandlerArgs } from '../../utilities/schedulePublishHandler.js'; | ||
type GetFormStateClient = (args: { | ||
signal?: AbortSignal; | ||
} & Omit<BuildFormStateArgs, 'clientConfig' | 'req'>) => ReturnType<typeof buildFormStateHandler>; | ||
type SchedulePublishClient = (args: { | ||
signal?: AbortSignal; | ||
} & Omit<SchedulePublishHandlerArgs, 'clientConfig' | 'req'>) => ReturnType<typeof schedulePublishHandler>; | ||
type GetTableStateClient = (args: { | ||
@@ -42,2 +46,3 @@ signal?: AbortSignal; | ||
renderDocument: RenderDocument; | ||
schedulePublish: SchedulePublishClient; | ||
serverFunction: ServerFunctionClient; | ||
@@ -44,0 +49,0 @@ }; |
@@ -22,2 +22,32 @@ import { jsx as _jsx } from "react/jsx-runtime"; | ||
}), [serverFunction]); | ||
const schedulePublish = useCallback(async args => { | ||
const { | ||
signal: remoteSignal, | ||
...rest | ||
} = args; | ||
try { | ||
if (!remoteSignal?.aborted) { | ||
const result = await serverFunction({ | ||
name: 'schedule-publish', | ||
args: { | ||
...rest | ||
} | ||
}); | ||
// TODO: infer this type when `strictNullChecks` is enabled | ||
if (!remoteSignal?.aborted) { | ||
return result; | ||
} | ||
} | ||
} catch (_err) { | ||
console.error(_err) // eslint-disable-line no-console | ||
; | ||
} | ||
let error = `Error scheduling ${rest.type}`; | ||
if (rest.doc) { | ||
error += ` for document with ID ${rest.doc.value} in collection ${rest.doc.relationTo}`; | ||
} | ||
return { | ||
error: '' | ||
}; | ||
}, [serverFunction]); | ||
const getFormState = useCallback(async args => { | ||
@@ -119,2 +149,3 @@ const { | ||
renderDocument, | ||
schedulePublish, | ||
serverFunction | ||
@@ -121,0 +152,0 @@ }, |
@@ -41,3 +41,3 @@ 'use client'; | ||
export const DefaultListView = props => { | ||
const $ = _c(16); | ||
const $ = _c(17); | ||
const { | ||
@@ -104,2 +104,3 @@ AfterList, | ||
setCollectionSlug, | ||
setCurrentActivePath, | ||
setOnSuccess | ||
@@ -150,7 +151,8 @@ } = useBulkUpload(); | ||
let t4; | ||
if ($[5] !== bulkUploadDrawerSlug || $[6] !== collectionSlug || $[7] !== openModal || $[8] !== router || $[9] !== setCollectionSlug || $[10] !== setOnSuccess) { | ||
if ($[5] !== bulkUploadDrawerSlug || $[6] !== collectionSlug || $[7] !== openModal || $[8] !== router || $[9] !== setCollectionSlug || $[10] !== setCurrentActivePath || $[11] !== setOnSuccess) { | ||
t4 = () => { | ||
setCollectionSlug(collectionSlug); | ||
setCurrentActivePath(collectionSlug); | ||
openModal(bulkUploadDrawerSlug); | ||
setOnSuccess(() => router.refresh()); | ||
setOnSuccess(collectionSlug, () => router.refresh()); | ||
}; | ||
@@ -162,6 +164,7 @@ $[5] = bulkUploadDrawerSlug; | ||
$[9] = setCollectionSlug; | ||
$[10] = setOnSuccess; | ||
$[11] = t4; | ||
$[10] = setCurrentActivePath; | ||
$[11] = setOnSuccess; | ||
$[12] = t4; | ||
} else { | ||
t4 = $[11]; | ||
t4 = $[12]; | ||
} | ||
@@ -177,3 +180,3 @@ const openBulkUpload = t4; | ||
let t5; | ||
if ($[12] !== beforeActions || $[13] !== enableRowSelections || $[14] !== onBulkSelect) { | ||
if ($[13] !== beforeActions || $[14] !== enableRowSelections || $[15] !== onBulkSelect) { | ||
t5 = enableRowSelections && typeof onBulkSelect === "function" ? beforeActions ? [...beforeActions, _jsx(SelectMany, { | ||
@@ -184,8 +187,8 @@ onClick: onBulkSelect | ||
}, "select-many")] : beforeActions; | ||
$[12] = beforeActions; | ||
$[13] = enableRowSelections; | ||
$[14] = onBulkSelect; | ||
$[15] = t5; | ||
$[13] = beforeActions; | ||
$[14] = enableRowSelections; | ||
$[15] = onBulkSelect; | ||
$[16] = t5; | ||
} else { | ||
t5 = $[15]; | ||
t5 = $[16]; | ||
} | ||
@@ -192,0 +195,0 @@ return _jsx(Fragment, { |
{ | ||
"name": "@payloadcms/ui", | ||
"version": "3.11.1-canary.54f6c59", | ||
"version": "3.11.1-canary.eb516b3", | ||
"homepage": "https://payloadcms.com", | ||
@@ -135,3 +135,3 @@ "repository": { | ||
"uuid": "10.0.0", | ||
"@payloadcms/translations": "3.11.1-canary.54f6c59" | ||
"@payloadcms/translations": "3.11.1-canary.eb516b3" | ||
}, | ||
@@ -153,4 +153,4 @@ "devDependencies": { | ||
"eslint-plugin-react-compiler": "19.0.0-beta-df7b47d-20241124", | ||
"@payloadcms/eslint-config": "3.9.0", | ||
"payload": "3.11.1-canary.54f6c59" | ||
"payload": "3.11.1-canary.eb516b3", | ||
"@payloadcms/eslint-config": "3.9.0" | ||
}, | ||
@@ -161,3 +161,3 @@ "peerDependencies": { | ||
"react-dom": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020", | ||
"payload": "3.11.1-canary.54f6c59" | ||
"payload": "3.11.1-canary.eb516b3" | ||
}, | ||
@@ -176,3 +176,3 @@ "engines": { | ||
"build:without_reactcompiler": "rm -rf dist && rm -rf tsconfig.tsbuildinfo && pnpm copyfiles && pnpm build:types && pnpm build:swc", | ||
"clean": "rimraf {dist,*.tsbuildinfo}", | ||
"clean": "rimraf -g {dist,*.tsbuildinfo}", | ||
"copyfiles": "copyfiles -u 1 \"src/**/*.{html,css,scss,ttf,woff,woff2,eot,svg,jpg,png,json}\" dist/", | ||
@@ -179,0 +179,0 @@ "lint": "eslint .", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9439650
1895
46014
+ Added@payloadcms/translations@3.11.1-canary.eb516b3(transitive)
+ Addedpayload@3.11.1-canary.eb516b3(transitive)
- Removed@payloadcms/translations@3.11.1-canary.54f6c59(transitive)
- Removedpayload@3.11.1-canary.54f6c59(transitive)