@bison-lab/payload-core 5.9.2 → 5.9.3
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/README.md +10 -0
- package/dist/admin.d.mts +19 -1
- package/dist/admin.d.mts.map +1 -1
- package/dist/admin.mjs +189 -4
- package/dist/admin.mjs.map +1 -1
- package/dist/index.d.mts +8 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +48 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -677,6 +677,16 @@ a document drawer (Create New from an upload or relationship field)
|
|
|
677
677
|
keeps its own Save in the drawer, and the page behind keeps its own.
|
|
678
678
|
One-list Globals pass `documentCreateNew("roles")` (or a site field
|
|
679
679
|
path) so Create New uses those same words, with no icon.
|
|
680
|
+
It also keeps a refused publish refused on screen (#357): the provider
|
|
681
|
+
wraps Payload's `getFormState`, and the plugin adds `REFUSED_SUBMIT_GUARD`
|
|
682
|
+
(renders nothing) to every collection's and global's
|
|
683
|
+
`beforeDocumentControls`. After the server refuses a save or publish, the
|
|
684
|
+
form stays modified (Publish stays enabled) and the refusal's field errors
|
|
685
|
+
stand until the data changes, even when Payload's form-state answer for an
|
|
686
|
+
earlier edit lands after the refusal. Payload 3.94.2 on its own clears the
|
|
687
|
+
modified flag on any refused publish and lets that late answer mark every
|
|
688
|
+
field valid (payloadcms/payload#17517 and #18425, fixed in Payload
|
|
689
|
+
4.0.0-beta.12). Remove the workaround when the library moves to Payload 4.
|
|
680
690
|
`listAlign()` keeps a list column's header and cells together: a field
|
|
681
691
|
declares `admin: { custom: { listAlign: "center" | "end" } }` and the
|
|
682
692
|
plugin writes one stylesheet (`listAlignCss`) from every collection's
|
package/dist/admin.d.mts
CHANGED
|
@@ -229,6 +229,24 @@ declare function DocumentTitleActions({
|
|
|
229
229
|
children?: ReactNode;
|
|
230
230
|
}): react_jsx_runtime0.JSX.Element;
|
|
231
231
|
//#endregion
|
|
232
|
+
//#region src/admin/refused-submit.d.ts
|
|
233
|
+
/**
|
|
234
|
+
* Re-provides Payload's server functions with `getFormState` wrapped, so
|
|
235
|
+
* no form-state answer undoes a refused submit. Mounted once for the
|
|
236
|
+
* admin, inside `DocumentTitleActions`.
|
|
237
|
+
*/
|
|
238
|
+
declare function RefusedSubmitProvider({
|
|
239
|
+
children
|
|
240
|
+
}: {
|
|
241
|
+
children?: ReactNode;
|
|
242
|
+
}): react_jsx_runtime0.JSX.Element;
|
|
243
|
+
/**
|
|
244
|
+
* Renders nothing. Inside a document form, it tells `RefusedSubmitProvider`
|
|
245
|
+
* when a submit is in flight and what a refused one refused, and keeps
|
|
246
|
+
* the form modified after a refusal so Publish (or Save) stays enabled.
|
|
247
|
+
*/
|
|
248
|
+
declare function RefusedSubmitGuard(): null;
|
|
249
|
+
//#endregion
|
|
232
250
|
//#region src/admin/list-align-styles.d.ts
|
|
233
251
|
/**
|
|
234
252
|
* The stylesheet `listAlign()` built from each field's
|
|
@@ -434,5 +452,5 @@ declare function TranslationActivityPanel(): react_jsx_runtime0.JSX.Element;
|
|
|
434
452
|
*/
|
|
435
453
|
declare function TranslationStatusBar(): react_jsx_runtime0.JSX.Element | null;
|
|
436
454
|
//#endregion
|
|
437
|
-
export { AdminNav, AdminNavEntityField, AdminNavItemRowLabel, AdminNavRowLabel, AppearanceField, BlockDrawerStyles, BlockLibraryField, ColorField, ColorScaleField, ContrastReport, DocumentCreateNew, DocumentTitleActions, FeaturesMatrixField, FontField, GreyScaleField, HiddenSaveButton, IdentityFallback, LibraryField, ListAlignStyles, LookField, MediaAltAutofill, MediaListView, PageSlugCell, PageTitleCell, PairingField, PublishChild, QuestionsList, RequiredPageCell, RequiredPageField, RichTextEditorFontStyles, RoleNameField, RoleSlugField, RolesCell, RolesField, RolesGrantsField, RolesMatrixField, RolesRowLabel, SectionHeading, SlugField, ThemeDocumentControls, ThemeSaveButton, TranslateNowMenuItem, TranslationActivityPanel, TranslationKeyPanel, TranslationStatusBar, setThemePreviewMode };
|
|
455
|
+
export { AdminNav, AdminNavEntityField, AdminNavItemRowLabel, AdminNavRowLabel, AppearanceField, BlockDrawerStyles, BlockLibraryField, ColorField, ColorScaleField, ContrastReport, DocumentCreateNew, DocumentTitleActions, FeaturesMatrixField, FontField, GreyScaleField, HiddenSaveButton, IdentityFallback, LibraryField, ListAlignStyles, LookField, MediaAltAutofill, MediaListView, PageSlugCell, PageTitleCell, PairingField, PublishChild, QuestionsList, RefusedSubmitGuard, RefusedSubmitProvider, RequiredPageCell, RequiredPageField, RichTextEditorFontStyles, RoleNameField, RoleSlugField, RolesCell, RolesField, RolesGrantsField, RolesMatrixField, RolesRowLabel, SectionHeading, SlugField, ThemeDocumentControls, ThemeSaveButton, TranslateNowMenuItem, TranslationActivityPanel, TranslationKeyPanel, TranslationStatusBar, setThemePreviewMode };
|
|
438
456
|
//# sourceMappingURL=admin.d.mts.map
|
package/dist/admin.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin.d.mts","names":[],"sources":["../src/admin/color-field.tsx","../src/admin/color-scale-field.tsx","../src/admin/library-field.tsx","../src/admin/font-field.tsx","../src/admin/pairing-field.tsx","../src/admin/appearance-field.tsx","../src/admin/grey-scale-field.tsx","../src/admin/contrast-report.tsx","../src/admin/section-heading.tsx","../src/admin/publish-child.tsx","../src/admin/save-button.tsx","../src/admin/preview-mode.tsx","../src/admin/identity-fallback.tsx","../src/admin/look-field.tsx","../src/admin/roles-cell.tsx","../src/admin/roles-matrix-field.tsx","../src/admin/roles-row-label.tsx","../src/admin/role-slug-field.tsx","../src/admin/slug-field.tsx","../src/admin/page-title-cell.tsx","../src/admin/page-slug-cell.tsx","../src/admin/required-page-cell.tsx","../src/admin/role-name-field.tsx","../src/admin/roles-field.tsx","../src/admin/roles-grants-field.tsx","../src/admin/features-matrix-field.tsx","../src/admin/block-library-field.tsx","../src/admin/document-title-actions.tsx","../src/admin/list-align-styles.tsx","../src/admin/block-drawer-styles.tsx","../src/admin/rich-text-editor-font-styles.tsx","../src/admin/document-create-new.tsx","../src/admin-nav/types.ts","../src/admin/admin-nav.tsx","../src/admin/admin-nav-row-label.tsx","../src/admin/admin-nav-item-row-label.tsx","../src/admin/admin-nav-entity-field.tsx","../src/taxonomy/facet-field.ts","../src/questions/types.ts","../src/admin/questions-list.tsx","../src/admin/media-alt-autofill.tsx","../src/admin/media-list-view.tsx","../src/admin/translate-now.tsx","../src/admin/translation-key-panel.tsx","../src/admin/translation-activity-panel.tsx","../src/admin/translation-status-bar.tsx"],"mappings":";;;;;;;;;;;cAWa,UAAA,EAAY,wBAAA;;;;;;;;cCuBZ,eAAA,EAAiB,yBAAA;;;;;;;;;cCMjB,YAAA,EAAc,yBAAA;;;;;;;;;cCtBd,SAAA,EAAW,0BAAA;;;;;;;cCNX,YAAA,EAAc,sBAAA;;;;;;;cCCd,eAAA,EAAiB,yBAAA;;;ALF9B;;;;AAAA,cM4Da,cAAA,EAAgB,0BAAA;;;;;;;cCnDhB,cAAA,EAAgB,sBAAA;;;;;;cCbhB,cAAA,EAAgB,sBAAA;;;cC0IhB,YAAA,EAAc,sBAAA;;;;;;;;iBCtIX,qBAAA,CAAA;;AVAhB;;;iBUQgB,eAAA,CAAA,GAAe,kBAAA,CAAA,GAAA,CAAA,OAAA;;iBA0Bf,gBAAA,CAAA,GAAgB,kBAAA,CAAA,GAAA,CAAA,OAAA;;;KCpCpB,gBAAA;AAAA,iBAgDI,mBAAA,CAAoB,IAAA,EAAM,gBAAA;;;;;;;cCjD7B,gBAAA,EAAkB,sBAAA;;;;;;;cCIlB,SAAA,EAAW,wBAAA;;;;;;;;;iBCOR,SAAA,CAAA;EAAY,QAAA;EAAU;AAAA,GAAS,yBAAA,GAAyB,kBAAA,CAAA,GAAA,CAAA,OAAA;;;;;;;;cCc3D,gBAAA,EAAkB,yBAAA;;;;;;iBC1Bf,aAAA,CAAA,GAAa,kBAAA,CAAA,GAAA,CAAA,OAAA;;;;;;cCChB,aAAA,EAAe,wBAAA;;;;;;;;;cC8Bf,SAAA,EAAW,wBAAA;;;;;;;;;AlB3BxB;iBmBCgB,aAAA,CAAc,KAAA,EAAO,yBAAA,GAAyB,kBAAA,CAAA,GAAA,CAAA,OAAA;;;;iBCP9C,YAAA,CAAA;EAAe,QAAA;EAAU;AAAA,GAAW,yBAAA,GAAyB,kBAAA,CAAA,GAAA,CAAA,OAAA;;;;cCEhE,iBAAA,EAAmB,wBAAA;AAAA,iBAEhB,gBAAA,CAAA;EAAmB;AAAA,GAAW,yBAAA,GAAyB,kBAAA,CAAA,GAAA,CAAA,OAAA;;;;;;;cCA1D,aAAA,EAAe,wBAAA;;;;;;;;cCqBf,UAAA,EAAY,0BAAA;;;;;;;;cCiBZ,gBAAA,EAAkB,wBAAA;;;;;;;;;AxBpC/B;;cyB2Ca,mBAAA,EAAqB,yBAAA;;;;;;;;;AzB3ClC;;;;;;;c0B8Ua,iBAAA,EAAmB,yBAAA;;;
|
|
1
|
+
{"version":3,"file":"admin.d.mts","names":[],"sources":["../src/admin/color-field.tsx","../src/admin/color-scale-field.tsx","../src/admin/library-field.tsx","../src/admin/font-field.tsx","../src/admin/pairing-field.tsx","../src/admin/appearance-field.tsx","../src/admin/grey-scale-field.tsx","../src/admin/contrast-report.tsx","../src/admin/section-heading.tsx","../src/admin/publish-child.tsx","../src/admin/save-button.tsx","../src/admin/preview-mode.tsx","../src/admin/identity-fallback.tsx","../src/admin/look-field.tsx","../src/admin/roles-cell.tsx","../src/admin/roles-matrix-field.tsx","../src/admin/roles-row-label.tsx","../src/admin/role-slug-field.tsx","../src/admin/slug-field.tsx","../src/admin/page-title-cell.tsx","../src/admin/page-slug-cell.tsx","../src/admin/required-page-cell.tsx","../src/admin/role-name-field.tsx","../src/admin/roles-field.tsx","../src/admin/roles-grants-field.tsx","../src/admin/features-matrix-field.tsx","../src/admin/block-library-field.tsx","../src/admin/document-title-actions.tsx","../src/admin/refused-submit.tsx","../src/admin/list-align-styles.tsx","../src/admin/block-drawer-styles.tsx","../src/admin/rich-text-editor-font-styles.tsx","../src/admin/document-create-new.tsx","../src/admin-nav/types.ts","../src/admin/admin-nav.tsx","../src/admin/admin-nav-row-label.tsx","../src/admin/admin-nav-item-row-label.tsx","../src/admin/admin-nav-entity-field.tsx","../src/taxonomy/facet-field.ts","../src/questions/types.ts","../src/admin/questions-list.tsx","../src/admin/media-alt-autofill.tsx","../src/admin/media-list-view.tsx","../src/admin/translate-now.tsx","../src/admin/translation-key-panel.tsx","../src/admin/translation-activity-panel.tsx","../src/admin/translation-status-bar.tsx"],"mappings":";;;;;;;;;;;cAWa,UAAA,EAAY,wBAAA;;;;;;;;cCuBZ,eAAA,EAAiB,yBAAA;;;;;;;;;cCMjB,YAAA,EAAc,yBAAA;;;;;;;;;cCtBd,SAAA,EAAW,0BAAA;;;;;;;cCNX,YAAA,EAAc,sBAAA;;;;;;;cCCd,eAAA,EAAiB,yBAAA;;;ALF9B;;;;AAAA,cM4Da,cAAA,EAAgB,0BAAA;;;;;;;cCnDhB,cAAA,EAAgB,sBAAA;;;;;;cCbhB,cAAA,EAAgB,sBAAA;;;cC0IhB,YAAA,EAAc,sBAAA;;;;;;;;iBCtIX,qBAAA,CAAA;;AVAhB;;;iBUQgB,eAAA,CAAA,GAAe,kBAAA,CAAA,GAAA,CAAA,OAAA;;iBA0Bf,gBAAA,CAAA,GAAgB,kBAAA,CAAA,GAAA,CAAA,OAAA;;;KCpCpB,gBAAA;AAAA,iBAgDI,mBAAA,CAAoB,IAAA,EAAM,gBAAA;;;;;;;cCjD7B,gBAAA,EAAkB,sBAAA;;;;;;;cCIlB,SAAA,EAAW,wBAAA;;;;;;;;;iBCOR,SAAA,CAAA;EAAY,QAAA;EAAU;AAAA,GAAS,yBAAA,GAAyB,kBAAA,CAAA,GAAA,CAAA,OAAA;;;;;;;;cCc3D,gBAAA,EAAkB,yBAAA;;;;;;iBC1Bf,aAAA,CAAA,GAAa,kBAAA,CAAA,GAAA,CAAA,OAAA;;;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kBAAA,CAAA,GAAA,CAAA,OAAA;;;;;;;;;iBCWnB,wBAAA,CAAA,GAAwB,kBAAA,CAAA,GAAA,CAAA,OAAA;;;;;;A7C/BxC;;;;;iB8CuBgB,oBAAA,CAAA,GAAoB,kBAAA,CAAA,GAAA,CAAA,OAAA"}
|
package/dist/admin.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { a as pageEditorLooks, c as colorDocFromState, n as clampIslandHeight, o as pageEditorTokens, r as islandHeightOf, s as SYSTEM_COLOR_KEYS, u as stateFromColorDoc } from "./island-97l5VY8l.mjs";
|
|
3
|
-
import { ArrayField, Button, CheckboxInput, DefaultCell, FieldDescription, FieldError, FieldLabel, Link, Logout, NavGroup, NavToggler, PopupList, SelectField, fieldBaseClass, toast, useAllFormFields, useAuth, useBulkUpload, useConfig, useDocumentInfo, useEntityVisibility, useField, useForm, useFormFields, useListDrawerContext, useListQuery, useLocale, useModal, useNav, useRowLabel, useStepNav } from "@payloadcms/ui";
|
|
3
|
+
import { ArrayField, Button, CheckboxInput, DefaultCell, FieldDescription, FieldError, FieldLabel, Link, Logout, NavGroup, NavToggler, PopupList, SelectField, ServerFunctionsContext, fieldBaseClass, toast, useAllFormFields, useAuth, useBulkUpload, useConfig, useDocumentInfo, useEntityVisibility, useField, useForm, useFormFields, useFormModified, useFormProcessing, useFormSubmitted, useListDrawerContext, useListQuery, useLocale, useModal, useNav, useRowLabel, useStepNav } from "@payloadcms/ui";
|
|
4
4
|
import { GREY_SCALES, SHADE_STEPS, contrastForeground, contrastRatio, createColorScale, deriveDarkPalette, deriveLightPalette, hexToHSL, hslToString, includedShadeSteps, isThemeHex, presetHints, regenerateColorScale, setColorScaleInclude, updateColorScale } from "@bison-lab/tokens";
|
|
5
|
-
import { useCallback, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
5
|
+
import { createContext, use, useCallback, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
6
6
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
import { Badge, Button as Button$1, CancelGlyph, CategoryRail, Checkbox, Chip, ConfirmDialog, DeleteGlyph, Dialog, EditGlyph, Field, Fold, Input, KitProvider, Label, LockGlyph, MainHead, Page, Pagination, Popover, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, Stack, Switch, Table, TableActions, TableCell, TableHead, TableRow, Thumbnail, filterCategories } from "@bison-lab/admin-ui";
|
|
8
8
|
import { HexColorPicker } from "react-colorful";
|
|
@@ -4578,6 +4578,188 @@ function slugFromHash(hash) {
|
|
|
4578
4578
|
}
|
|
4579
4579
|
}
|
|
4580
4580
|
//#endregion
|
|
4581
|
+
//#region src/admin/refused-submit.tsx
|
|
4582
|
+
/** The longest an edit's form-state answer waits for a submit in flight. */
|
|
4583
|
+
const PENDING_LIMIT_MS = 15e3;
|
|
4584
|
+
const FormsContext = createContext(null);
|
|
4585
|
+
function docKey(doc) {
|
|
4586
|
+
return [
|
|
4587
|
+
doc.collectionSlug ?? "",
|
|
4588
|
+
doc.globalSlug ?? "",
|
|
4589
|
+
doc.id ?? ""
|
|
4590
|
+
].join("|");
|
|
4591
|
+
}
|
|
4592
|
+
/** Field values by path, as a form submits them (no `disableFormData`, no files: a form-state request drops those). */
|
|
4593
|
+
function valuesOf(state) {
|
|
4594
|
+
const values = {};
|
|
4595
|
+
for (const [path, field] of Object.entries(state)) {
|
|
4596
|
+
if (!field || field.disableFormData || field.value === void 0) continue;
|
|
4597
|
+
if (typeof File !== "undefined" && field.value instanceof File) continue;
|
|
4598
|
+
values[path] = field.value;
|
|
4599
|
+
}
|
|
4600
|
+
return values;
|
|
4601
|
+
}
|
|
4602
|
+
function deepEqual(a, b) {
|
|
4603
|
+
if (a === b) return true;
|
|
4604
|
+
if (typeof a !== "object" || typeof b !== "object" || a === null || b === null) return false;
|
|
4605
|
+
if (Array.isArray(a) !== Array.isArray(b)) return false;
|
|
4606
|
+
const left = a;
|
|
4607
|
+
const right = b;
|
|
4608
|
+
const keys = Object.keys(left);
|
|
4609
|
+
if (keys.length !== Object.keys(right).length) return false;
|
|
4610
|
+
return keys.every((key) => key in right && deepEqual(left[key], right[key]));
|
|
4611
|
+
}
|
|
4612
|
+
/** What a refusal put on the form: invalid fields and the parents counting their errors. */
|
|
4613
|
+
function errorsOf(state) {
|
|
4614
|
+
const errors = {};
|
|
4615
|
+
for (const [path, field] of Object.entries(state)) {
|
|
4616
|
+
if (!field) continue;
|
|
4617
|
+
if (field.valid === false) errors[path] = {
|
|
4618
|
+
valid: false,
|
|
4619
|
+
errorMessage: field.errorMessage
|
|
4620
|
+
};
|
|
4621
|
+
if (Array.isArray(field.errorPaths) && field.errorPaths.length > 0) errors[path] = {
|
|
4622
|
+
...errors[path],
|
|
4623
|
+
errorPaths: field.errorPaths
|
|
4624
|
+
};
|
|
4625
|
+
}
|
|
4626
|
+
return errors;
|
|
4627
|
+
}
|
|
4628
|
+
function withErrors(state, errors) {
|
|
4629
|
+
const next = { ...state };
|
|
4630
|
+
for (const [path, error] of Object.entries(errors)) {
|
|
4631
|
+
const field = next[path];
|
|
4632
|
+
if (field) next[path] = {
|
|
4633
|
+
...field,
|
|
4634
|
+
...error
|
|
4635
|
+
};
|
|
4636
|
+
}
|
|
4637
|
+
return next;
|
|
4638
|
+
}
|
|
4639
|
+
/**
|
|
4640
|
+
* An edit's form-state request: the Edit view's `onChange` sends the
|
|
4641
|
+
* client `formState` and no `data`. A save's (`onSave`) sends `data`, and
|
|
4642
|
+
* runs while the submit is still in flight, so it must never wait.
|
|
4643
|
+
*/
|
|
4644
|
+
function isEditRequest(args) {
|
|
4645
|
+
return Boolean(args?.formState) && !("data" in args);
|
|
4646
|
+
}
|
|
4647
|
+
/**
|
|
4648
|
+
* Re-provides Payload's server functions with `getFormState` wrapped, so
|
|
4649
|
+
* no form-state answer undoes a refused submit. Mounted once for the
|
|
4650
|
+
* admin, inside `DocumentTitleActions`.
|
|
4651
|
+
*/
|
|
4652
|
+
function RefusedSubmitProvider({ children }) {
|
|
4653
|
+
const outer = use(ServerFunctionsContext);
|
|
4654
|
+
const forms = useRef(/* @__PURE__ */ new Set()).current;
|
|
4655
|
+
const value = useMemo(() => {
|
|
4656
|
+
if (!outer) return void 0;
|
|
4657
|
+
const getFormState = async (args) => {
|
|
4658
|
+
const result = await outer.getFormState(args);
|
|
4659
|
+
if (!isEditRequest(args)) return result;
|
|
4660
|
+
const doc = docKey(args);
|
|
4661
|
+
const mine = [...forms].filter((form) => form.doc === doc);
|
|
4662
|
+
const pending = mine.flatMap((form) => form.pending ? [form.pending] : []);
|
|
4663
|
+
if (pending.length) {
|
|
4664
|
+
let timer;
|
|
4665
|
+
await Promise.race([Promise.all(pending), new Promise((resolve) => {
|
|
4666
|
+
timer = setTimeout(resolve, PENDING_LIMIT_MS);
|
|
4667
|
+
})]);
|
|
4668
|
+
clearTimeout(timer);
|
|
4669
|
+
}
|
|
4670
|
+
if (!result?.state) return result;
|
|
4671
|
+
const values = valuesOf(args.formState);
|
|
4672
|
+
let state = result.state;
|
|
4673
|
+
for (const form of mine) if (form.refusal && deepEqual(form.refusal.values, values)) state = withErrors(state, form.refusal.errors);
|
|
4674
|
+
return state === result.state ? result : {
|
|
4675
|
+
...result,
|
|
4676
|
+
state
|
|
4677
|
+
};
|
|
4678
|
+
};
|
|
4679
|
+
return {
|
|
4680
|
+
...outer,
|
|
4681
|
+
getFormState
|
|
4682
|
+
};
|
|
4683
|
+
}, [outer, forms]);
|
|
4684
|
+
return /* @__PURE__ */ jsx(FormsContext, {
|
|
4685
|
+
value: forms,
|
|
4686
|
+
children: value ? /* @__PURE__ */ jsx(ServerFunctionsContext, {
|
|
4687
|
+
value,
|
|
4688
|
+
children
|
|
4689
|
+
}) : children
|
|
4690
|
+
});
|
|
4691
|
+
}
|
|
4692
|
+
/**
|
|
4693
|
+
* Renders nothing. Inside a document form, it tells `RefusedSubmitProvider`
|
|
4694
|
+
* when a submit is in flight and what a refused one refused, and keeps
|
|
4695
|
+
* the form modified after a refusal so Publish (or Save) stays enabled.
|
|
4696
|
+
*/
|
|
4697
|
+
function RefusedSubmitGuard() {
|
|
4698
|
+
const forms = use(FormsContext);
|
|
4699
|
+
const docInfo = useDocumentInfo();
|
|
4700
|
+
const form = useForm();
|
|
4701
|
+
const processing = useFormProcessing();
|
|
4702
|
+
const modified = useFormModified();
|
|
4703
|
+
const submitted = useFormSubmitted();
|
|
4704
|
+
const doc = docKey(docInfo);
|
|
4705
|
+
const entry = useRef({
|
|
4706
|
+
doc,
|
|
4707
|
+
pending: null,
|
|
4708
|
+
refusal: null
|
|
4709
|
+
}).current;
|
|
4710
|
+
entry.doc = doc;
|
|
4711
|
+
const submit = useRef({
|
|
4712
|
+
active: false,
|
|
4713
|
+
modified: false,
|
|
4714
|
+
values: {},
|
|
4715
|
+
release: () => {}
|
|
4716
|
+
}).current;
|
|
4717
|
+
useLayoutEffect(() => {
|
|
4718
|
+
forms?.add(entry);
|
|
4719
|
+
return () => {
|
|
4720
|
+
forms?.delete(entry);
|
|
4721
|
+
submit.release();
|
|
4722
|
+
};
|
|
4723
|
+
}, [
|
|
4724
|
+
forms,
|
|
4725
|
+
entry,
|
|
4726
|
+
submit
|
|
4727
|
+
]);
|
|
4728
|
+
useLayoutEffect(() => {
|
|
4729
|
+
if (processing && !submit.active) {
|
|
4730
|
+
submit.active = true;
|
|
4731
|
+
submit.modified = modified;
|
|
4732
|
+
submit.values = valuesOf(form.getFields());
|
|
4733
|
+
entry.refusal = null;
|
|
4734
|
+
entry.pending = new Promise((resolve) => {
|
|
4735
|
+
submit.release = resolve;
|
|
4736
|
+
});
|
|
4737
|
+
return;
|
|
4738
|
+
}
|
|
4739
|
+
if (!processing && submit.active) {
|
|
4740
|
+
submit.active = false;
|
|
4741
|
+
const errors = errorsOf(form.getFields());
|
|
4742
|
+
if (submitted || Object.keys(errors).length > 0) {
|
|
4743
|
+
entry.refusal = {
|
|
4744
|
+
values: submit.values,
|
|
4745
|
+
errors
|
|
4746
|
+
};
|
|
4747
|
+
if (submit.modified && !modified) form.setModified(true);
|
|
4748
|
+
}
|
|
4749
|
+
entry.pending = null;
|
|
4750
|
+
submit.release();
|
|
4751
|
+
}
|
|
4752
|
+
}, [
|
|
4753
|
+
processing,
|
|
4754
|
+
modified,
|
|
4755
|
+
submitted,
|
|
4756
|
+
form,
|
|
4757
|
+
entry,
|
|
4758
|
+
submit
|
|
4759
|
+
]);
|
|
4760
|
+
return null;
|
|
4761
|
+
}
|
|
4762
|
+
//#endregion
|
|
4581
4763
|
//#region src/admin/theme-kit-accent.tsx
|
|
4582
4764
|
function primaryHex(doc) {
|
|
4583
4765
|
const hex = doc?.colors?.brand?.primary?.hex;
|
|
@@ -4633,6 +4815,9 @@ function ThemeKitAccent({ children }) {
|
|
|
4633
4815
|
* Mounted as `admin.components.providers` so Account and every
|
|
4634
4816
|
* collection / global share one lift. A MutationObserver re-applies
|
|
4635
4817
|
* after Payload redraws the controls.
|
|
4818
|
+
*
|
|
4819
|
+
* It also carries `RefusedSubmitProvider`, so a refused publish keeps its
|
|
4820
|
+
* field errors and stays publishable (#357).
|
|
4636
4821
|
*/
|
|
4637
4822
|
const TITLE_ACTIONS_CSS = `
|
|
4638
4823
|
.doc-header__header{display:flex;align-items:center;justify-content:flex-start;width:100%;gap:10px}
|
|
@@ -4717,7 +4902,7 @@ function DocumentTitleActions({ children }) {
|
|
|
4717
4902
|
href: "bl-doc-title-actions",
|
|
4718
4903
|
precedence: "default",
|
|
4719
4904
|
children: TITLE_ACTIONS_CSS
|
|
4720
|
-
}), children] });
|
|
4905
|
+
}), /* @__PURE__ */ jsx(RefusedSubmitProvider, { children })] });
|
|
4721
4906
|
}
|
|
4722
4907
|
//#endregion
|
|
4723
4908
|
//#region src/admin/list-align-styles.tsx
|
|
@@ -7578,6 +7763,6 @@ function TranslationActivityPanel() {
|
|
|
7578
7763
|
] });
|
|
7579
7764
|
}
|
|
7580
7765
|
//#endregion
|
|
7581
|
-
export { AdminNav, AdminNavEntityField, AdminNavItemRowLabel, AdminNavRowLabel, AppearanceField, BlockDrawerStyles, BlockLibraryField, ColorField, ColorScaleField, ContrastReport, DocumentCreateNew, DocumentTitleActions, FeaturesMatrixField, FontField, GreyScaleField, HiddenSaveButton, IdentityFallback, LibraryField, ListAlignStyles, LookField, MediaAltAutofill, MediaListView, PageSlugCell, PageTitleCell, PairingField, PublishChild, QuestionsList, RequiredPageCell, RequiredPageField, RichTextEditorFontStyles, RoleNameField, RoleSlugField, RolesCell, RolesField, RolesGrantsField, RolesMatrixField, RolesRowLabel, SectionHeading, SlugField, ThemeDocumentControls, ThemeSaveButton, TranslateNowMenuItem, TranslationActivityPanel, TranslationKeyPanel, TranslationStatusBar, setThemePreviewMode };
|
|
7766
|
+
export { AdminNav, AdminNavEntityField, AdminNavItemRowLabel, AdminNavRowLabel, AppearanceField, BlockDrawerStyles, BlockLibraryField, ColorField, ColorScaleField, ContrastReport, DocumentCreateNew, DocumentTitleActions, FeaturesMatrixField, FontField, GreyScaleField, HiddenSaveButton, IdentityFallback, LibraryField, ListAlignStyles, LookField, MediaAltAutofill, MediaListView, PageSlugCell, PageTitleCell, PairingField, PublishChild, QuestionsList, RefusedSubmitGuard, RefusedSubmitProvider, RequiredPageCell, RequiredPageField, RichTextEditorFontStyles, RoleNameField, RoleSlugField, RolesCell, RolesField, RolesGrantsField, RolesMatrixField, RolesRowLabel, SectionHeading, SlugField, ThemeDocumentControls, ThemeSaveButton, TranslateNowMenuItem, TranslationActivityPanel, TranslationKeyPanel, TranslationStatusBar, setThemePreviewMode };
|
|
7582
7767
|
|
|
7583
7768
|
//# sourceMappingURL=admin.mjs.map
|