@bison-lab/payload-core 3.32.0 → 3.33.1
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/admin.d.mts +16 -2
- package/dist/admin.d.mts.map +1 -1
- package/dist/admin.mjs +1107 -22
- package/dist/admin.mjs.map +1 -1
- package/dist/index.d.mts +47 -5
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +249 -17
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/admin.mjs
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { a as colorDocFromState, i as SYSTEM_COLOR_KEYS, n as pageEditorLooks, r as pageEditorTokens, s as stateFromColorDoc } from "./looks-BbL309kO.mjs";
|
|
3
|
-
import { ArrayField, Button, CheckboxInput, DefaultCell, FieldDescription, FieldError, FieldLabel, Link, Logout, NavGroup, NavToggler, SelectField, fieldBaseClass, useAuth, useConfig, useField, useForm, useFormFields, useNav, useRowLabel, useStepNav } from "@payloadcms/ui";
|
|
3
|
+
import { ArrayField, Button, CheckboxInput, DefaultCell, FieldDescription, FieldError, FieldLabel, Link, Logout, NavGroup, NavToggler, SelectField, fieldBaseClass, useAuth, useBulkUpload, useConfig, useField, useForm, useFormFields, useListQuery, useModal, useNav, useRowLabel, useStepNav } from "@payloadcms/ui";
|
|
4
4
|
import { GREY_SCALES, SHADE_STEPS, contrastForeground, contrastRatio, createColorScale, deriveDarkPalette, deriveLightPalette, hexToHSL, hslToString, includedShadeSteps, isThemeHex, presetHints, setColorScaleInclude } from "@bison-lab/tokens";
|
|
5
5
|
import { useCallback, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
6
6
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
-
import { Badge, Button as Button$1, Checkbox, DeleteGlyph, Dialog, EditGlyph, Field, Input, KitProvider, Label, MainHead, Page, Pagination, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, Switch, Table, TableActions, TableCell, TableHead, TableRow, Textarea } from "@bison-lab/admin-ui";
|
|
7
|
+
import { Badge, Button as Button$1, Checkbox, Chip, ConfirmDialog, DeleteGlyph, Dialog, EditGlyph, Field, Input, KitProvider, Label, MainHead, Page, Pagination, Popover, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, Switch, Table, TableActions, TableCell, TableHead, TableRow, Textarea, Thumbnail } from "@bison-lab/admin-ui";
|
|
8
8
|
import { HexColorPicker } from "react-colorful";
|
|
9
9
|
import { createPortal } from "react-dom";
|
|
10
10
|
import { findFont, fontFaceCss, isFontId } from "@bison-lab/fonts";
|
|
11
11
|
import "payload";
|
|
12
|
+
import { formatAdminURL, formatFilesize } from "payload/shared";
|
|
12
13
|
//#region src/admin/color-field.tsx
|
|
13
14
|
const HEX_ERROR = "Enter a six-digit hex colour like #1e3a5f";
|
|
14
15
|
/**
|
|
@@ -3504,7 +3505,7 @@ const RolesField = ({ field, path: pathFromProps, readOnly, validate }) => {
|
|
|
3504
3505
|
};
|
|
3505
3506
|
//#endregion
|
|
3506
3507
|
//#region src/admin/roles-grants-field.tsx
|
|
3507
|
-
const LIST_CSS$
|
|
3508
|
+
const LIST_CSS$2 = `.bl-role-grants{margin-block:.2rem 0;font-size:16px}.bl-role-grants__group{margin-block:.75rem 0}.bl-role-grants__group-title{font-size:13px;letter-spacing:.02em;color:var(--theme-elevation-400,#94a3b8);font-weight:650;margin-block-end:.25rem}.bl-role-grants__row{display:flex;align-items:center;gap:.65rem;padding:.35rem 0}.bl-role-grants__row.is-implicit{opacity:.85}.bl-role-grants input{inline-size:1.15rem;block-size:1.15rem}.bl-role-grants input:disabled{cursor:default}.bl-role-grants__note{margin-block:.35rem 0;font-size:13px;color:var(--theme-elevation-500,#64748b)}`;
|
|
3508
3509
|
function asGrants(value) {
|
|
3509
3510
|
if (!Array.isArray(value)) return [];
|
|
3510
3511
|
return value.filter((entry) => typeof entry === "string");
|
|
@@ -3552,7 +3553,7 @@ const RolesGrantsField = (props) => {
|
|
|
3552
3553
|
/* @__PURE__ */ jsx("style", {
|
|
3553
3554
|
href: "bl-role-grants",
|
|
3554
3555
|
precedence: "default",
|
|
3555
|
-
children: LIST_CSS$
|
|
3556
|
+
children: LIST_CSS$2
|
|
3556
3557
|
}),
|
|
3557
3558
|
implicitAll ? /* @__PURE__ */ jsx("p", {
|
|
3558
3559
|
className: "bl-role-grants__note",
|
|
@@ -3583,7 +3584,7 @@ const RolesGrantsField = (props) => {
|
|
|
3583
3584
|
};
|
|
3584
3585
|
//#endregion
|
|
3585
3586
|
//#region src/admin/features-matrix-field.tsx
|
|
3586
|
-
const LIST_CSS = `.bl-features{margin-block:.35rem 0;font-size:16px}.bl-features__group{margin-block:1rem 0}.bl-features__group-title{font-size:14px;letter-spacing:.02em;color:var(--theme-elevation-400,#94a3b8);font-weight:650;margin-block-end:.35rem}.bl-features__row{display:flex;align-items:center;justify-content:space-between;gap:1rem;padding:.55rem 0;border-bottom:1px solid var(--theme-elevation-150,#e2e8f0)}.bl-features__row:last-child{border-bottom:0}.bl-features input{inline-size:1.15rem;block-size:1.15rem}`;
|
|
3587
|
+
const LIST_CSS$1 = `.bl-features{margin-block:.35rem 0;font-size:16px}.bl-features__group{margin-block:1rem 0}.bl-features__group-title{font-size:14px;letter-spacing:.02em;color:var(--theme-elevation-400,#94a3b8);font-weight:650;margin-block-end:.35rem}.bl-features__row{display:flex;align-items:center;justify-content:space-between;gap:1rem;padding:.55rem 0;border-bottom:1px solid var(--theme-elevation-150,#e2e8f0)}.bl-features__row:last-child{border-bottom:0}.bl-features input{inline-size:1.15rem;block-size:1.15rem}`;
|
|
3587
3588
|
function asRows(value) {
|
|
3588
3589
|
return Array.isArray(value) ? value : [];
|
|
3589
3590
|
}
|
|
@@ -3642,7 +3643,7 @@ const FeaturesMatrixField = (props) => {
|
|
|
3642
3643
|
children: [/* @__PURE__ */ jsx("style", {
|
|
3643
3644
|
href: "bl-features",
|
|
3644
3645
|
precedence: "default",
|
|
3645
|
-
children: LIST_CSS
|
|
3646
|
+
children: LIST_CSS$1
|
|
3646
3647
|
}), FEATURE_GROUPS.map((group) => {
|
|
3647
3648
|
const members = rows.map((row, index) => ({
|
|
3648
3649
|
row,
|
|
@@ -4086,10 +4087,10 @@ const QUESTIONS_LIST_CSS = `
|
|
|
4086
4087
|
.bl-faq-library__answer{margin:0;color:var(--bl-kit-ink-muted);max-width:640px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
4087
4088
|
.bl-faq-library__chips{display:flex;flex-wrap:wrap;gap:5px}
|
|
4088
4089
|
.bl-faq-library__chip{font-size:12px;font-weight:650;padding:3px 7px}
|
|
4089
|
-
.bl-faq-library__chip--
|
|
4090
|
+
.bl-faq-library__chip--linked{background:var(--bl-kit-accent-soft);color:var(--bl-kit-accent,#2563eb)}
|
|
4090
4091
|
.bl-faq-library__chip--look{background:hsl(var(--look-tint));color:hsl(var(--look-ink))}
|
|
4091
4092
|
[data-theme="dark"] .bl-faq-library__chip--look{background:hsl(var(--look-tint-dark));color:hsl(var(--look-ink-dark))}
|
|
4092
|
-
.bl-faq-library__chip--
|
|
4093
|
+
.bl-faq-library__chip--managed{background:color-mix(in srgb,var(--theme-info-500,#1769aa) 12%,var(--bl-kit-surface));color:var(--theme-info-500,#1769aa)}
|
|
4093
4094
|
.bl-faq-library__used{font-size:12px;color:var(--bl-kit-ink-muted)}
|
|
4094
4095
|
.bl-faq-library__used strong{color:var(--bl-kit-ink);font-weight:700}
|
|
4095
4096
|
.bl-faq-library__empty{display:none;padding:55px;text-align:center;color:var(--bl-kit-ink-muted);border:1px solid var(--bl-kit-border);border-radius:var(--bl-kit-radius);background:var(--bl-kit-surface)}
|
|
@@ -4172,7 +4173,7 @@ function familyFromDoc(value) {
|
|
|
4172
4173
|
if (typeof raw === "string" && raw.trim()) return raw.trim();
|
|
4173
4174
|
}
|
|
4174
4175
|
}
|
|
4175
|
-
function chipsFrom(value) {
|
|
4176
|
+
function chipsFrom$1(value) {
|
|
4176
4177
|
if (!Array.isArray(value)) return [];
|
|
4177
4178
|
const chips = [];
|
|
4178
4179
|
for (const item of value) {
|
|
@@ -4206,6 +4207,33 @@ function lookMapsFromGlobal(doc, look) {
|
|
|
4206
4207
|
function resolveFamily(field, name, family, looks) {
|
|
4207
4208
|
return family || looks[field]?.[name.toLowerCase()] || void 0;
|
|
4208
4209
|
}
|
|
4210
|
+
function termSingular(label) {
|
|
4211
|
+
const lower = label.trim().toLowerCase();
|
|
4212
|
+
if (lower.endsWith("ies")) return `${lower.slice(0, -3)}y`;
|
|
4213
|
+
if (lower.endsWith("s") && !lower.endsWith("ss")) return lower.slice(0, -1);
|
|
4214
|
+
return lower;
|
|
4215
|
+
}
|
|
4216
|
+
function facetChipClass(entry) {
|
|
4217
|
+
return entry.manage ? "managed" : "linked";
|
|
4218
|
+
}
|
|
4219
|
+
function manageIntro(entries) {
|
|
4220
|
+
const linked = entries.filter((entry) => !entry.manage);
|
|
4221
|
+
const managed = entries.filter((entry) => entry.manage);
|
|
4222
|
+
const parts = [];
|
|
4223
|
+
if (linked.length > 0) {
|
|
4224
|
+
const labels = linked.map((entry) => entry.label).join(" and ");
|
|
4225
|
+
parts.push(`${labels}: read-only terms from linked collections.`);
|
|
4226
|
+
}
|
|
4227
|
+
if (managed.length > 0) {
|
|
4228
|
+
const labels = managed.map((entry) => entry.label).join(" and ");
|
|
4229
|
+
parts.push(`Create and delete ${labels} below.`);
|
|
4230
|
+
}
|
|
4231
|
+
return parts.join(" ");
|
|
4232
|
+
}
|
|
4233
|
+
function facetHint(entry) {
|
|
4234
|
+
if (entry.manage) return `Use ${entry.label.toLowerCase()} to group related FAQs.`;
|
|
4235
|
+
return `Select every ${termSingular(entry.label)} this FAQ applies to.`;
|
|
4236
|
+
}
|
|
4209
4237
|
function useApi() {
|
|
4210
4238
|
const { config } = useConfig();
|
|
4211
4239
|
const base = `${config.serverURL}${config.routes.api}`;
|
|
@@ -4557,8 +4585,8 @@ function QuestionsListPage({ collectionSlug, organizeBy: organizeByProp }) {
|
|
|
4557
4585
|
children: doc.answer
|
|
4558
4586
|
})] }),
|
|
4559
4587
|
organizeBy.map((entry) => {
|
|
4560
|
-
const chips = chipsFrom(doc[entry.name]);
|
|
4561
|
-
const kind = entry
|
|
4588
|
+
const chips = chipsFrom$1(doc[entry.name]);
|
|
4589
|
+
const kind = facetChipClass(entry);
|
|
4562
4590
|
return /* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx("div", {
|
|
4563
4591
|
className: "bl-faq-library__chips",
|
|
4564
4592
|
children: chips.length === 0 && !entry.manage ? /* @__PURE__ */ jsx("span", {
|
|
@@ -4613,7 +4641,7 @@ function QuestionsListPage({ collectionSlug, organizeBy: organizeByProp }) {
|
|
|
4613
4641
|
className: "bl-faq-library__manage-head",
|
|
4614
4642
|
children: [/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h3", { children: "Manage organization" }), /* @__PURE__ */ jsx("div", {
|
|
4615
4643
|
className: "bl-faq-library__taxmeta",
|
|
4616
|
-
children:
|
|
4644
|
+
children: manageIntro(organizeBy)
|
|
4617
4645
|
})] }), /* @__PURE__ */ jsx(Button$1, {
|
|
4618
4646
|
variant: "outline",
|
|
4619
4647
|
onClick: () => setManageOpen(false),
|
|
@@ -4661,7 +4689,7 @@ function QuestionsListPage({ collectionSlug, organizeBy: organizeByProp }) {
|
|
|
4661
4689
|
...current,
|
|
4662
4690
|
[entry.name]: event.target.value
|
|
4663
4691
|
})),
|
|
4664
|
-
placeholder: `New ${entry.label
|
|
4692
|
+
placeholder: `New ${termSingular(entry.label)} name`,
|
|
4665
4693
|
onKeyDown: (event) => {
|
|
4666
4694
|
if (event.key === "Enter") {
|
|
4667
4695
|
event.preventDefault();
|
|
@@ -4751,7 +4779,7 @@ function QuestionsListPage({ collectionSlug, organizeBy: organizeByProp }) {
|
|
|
4751
4779
|
field: entry.name,
|
|
4752
4780
|
name: event.target.value
|
|
4753
4781
|
}),
|
|
4754
|
-
placeholder:
|
|
4782
|
+
placeholder: `New ${termSingular(entry.label)} name`
|
|
4755
4783
|
}), /* @__PURE__ */ jsx(Button$1, {
|
|
4756
4784
|
type: "submit",
|
|
4757
4785
|
variant: "outline",
|
|
@@ -4765,11 +4793,11 @@ function QuestionsListPage({ collectionSlug, organizeBy: organizeByProp }) {
|
|
|
4765
4793
|
field: entry.name,
|
|
4766
4794
|
name: ""
|
|
4767
4795
|
}),
|
|
4768
|
-
children:
|
|
4796
|
+
children: `+ Create new ${termSingular(entry.label)}`
|
|
4769
4797
|
}) : null,
|
|
4770
4798
|
/* @__PURE__ */ jsx("small", {
|
|
4771
4799
|
className: "bl-faq-library__hint",
|
|
4772
|
-
children: entry
|
|
4800
|
+
children: facetHint(entry)
|
|
4773
4801
|
})
|
|
4774
4802
|
]
|
|
4775
4803
|
}, entry.name))
|
|
@@ -4837,12 +4865,16 @@ function QuestionsListPage({ collectionSlug, organizeBy: organizeByProp }) {
|
|
|
4837
4865
|
children: [
|
|
4838
4866
|
"Delete “",
|
|
4839
4867
|
deleteTerm.term.name,
|
|
4840
|
-
"”
|
|
4868
|
+
"” ",
|
|
4869
|
+
termSingular(deleteTerm.entry.label),
|
|
4870
|
+
"?"
|
|
4841
4871
|
]
|
|
4842
4872
|
})]
|
|
4843
4873
|
}),
|
|
4844
4874
|
deleteTerm.count > 0 ? /* @__PURE__ */ jsxs("p", { children: [
|
|
4845
|
-
"This
|
|
4875
|
+
"This ",
|
|
4876
|
+
termSingular(deleteTerm.entry.label),
|
|
4877
|
+
" is currently assigned to",
|
|
4846
4878
|
" ",
|
|
4847
4879
|
/* @__PURE__ */ jsx("button", {
|
|
4848
4880
|
type: "button",
|
|
@@ -4861,8 +4893,14 @@ function QuestionsListPage({ collectionSlug, organizeBy: organizeByProp }) {
|
|
|
4861
4893
|
deleteTerm.count === 1 ? "" : "s"
|
|
4862
4894
|
] })
|
|
4863
4895
|
}),
|
|
4864
|
-
". Deleting it removes the
|
|
4865
|
-
|
|
4896
|
+
". Deleting it removes the ",
|
|
4897
|
+
termSingular(deleteTerm.entry.label),
|
|
4898
|
+
" assignment only."
|
|
4899
|
+
] }) : /* @__PURE__ */ jsxs("p", { children: [
|
|
4900
|
+
"This ",
|
|
4901
|
+
termSingular(deleteTerm.entry.label),
|
|
4902
|
+
" is not assigned to any FAQs."
|
|
4903
|
+
] }),
|
|
4866
4904
|
/* @__PURE__ */ jsxs("div", {
|
|
4867
4905
|
className: "bl-faq-library__impact",
|
|
4868
4906
|
children: [
|
|
@@ -4884,7 +4922,7 @@ function QuestionsListPage({ collectionSlug, organizeBy: organizeByProp }) {
|
|
|
4884
4922
|
variant: "danger",
|
|
4885
4923
|
disabled: busy,
|
|
4886
4924
|
onClick: () => void confirmDeleteTerm(),
|
|
4887
|
-
children:
|
|
4925
|
+
children: `Delete ${termSingular(deleteTerm.entry.label)}`
|
|
4888
4926
|
})]
|
|
4889
4927
|
})]
|
|
4890
4928
|
})]
|
|
@@ -4893,6 +4931,1053 @@ function QuestionsListPage({ collectionSlug, organizeBy: organizeByProp }) {
|
|
|
4893
4931
|
] });
|
|
4894
4932
|
}
|
|
4895
4933
|
//#endregion
|
|
4896
|
-
|
|
4934
|
+
//#region src/collections/media-alt.ts
|
|
4935
|
+
/** The name the editor just chose, or the stored filename on an existing row. */
|
|
4936
|
+
function filenameFromUpload(file, filename) {
|
|
4937
|
+
if (typeof File !== "undefined" && file instanceof File) return file.name;
|
|
4938
|
+
if (typeof filename === "string") return filename;
|
|
4939
|
+
return "";
|
|
4940
|
+
}
|
|
4941
|
+
/** Alt text from an upload filename: drop the extension, hyphenate the rest. */
|
|
4942
|
+
function altFromFilename(filename) {
|
|
4943
|
+
if (typeof filename !== "string") return "";
|
|
4944
|
+
return filename.trim().replace(/\.[a-z0-9]{1,5}$/i, "").replace(/[_\s]+/g, "-");
|
|
4945
|
+
}
|
|
4946
|
+
/**
|
|
4947
|
+
* Fill while Alt is empty or still the last auto value. Stop once the editor
|
|
4948
|
+
* types something else.
|
|
4949
|
+
*/
|
|
4950
|
+
function shouldFillMediaAlt(existing, generated, lastAuto) {
|
|
4951
|
+
if (!generated) return false;
|
|
4952
|
+
const current = typeof existing === "string" ? existing.trim() : "";
|
|
4953
|
+
if (current === generated) return false;
|
|
4954
|
+
if (!current) return true;
|
|
4955
|
+
return current === lastAuto;
|
|
4956
|
+
}
|
|
4957
|
+
//#endregion
|
|
4958
|
+
//#region src/admin/media-alt-autofill.tsx
|
|
4959
|
+
/**
|
|
4960
|
+
* Writes a hyphenated filename into Alt as the file is chosen. Renders
|
|
4961
|
+
* nothing: the stock text field stays the one the editor types into.
|
|
4962
|
+
*/
|
|
4963
|
+
function MediaAltAutofill({ path }) {
|
|
4964
|
+
const { value, setValue } = useField({
|
|
4965
|
+
path,
|
|
4966
|
+
potentiallyStalePath: path
|
|
4967
|
+
});
|
|
4968
|
+
const filename = useFormFields(([fields]) => filenameFromUpload(fields.file?.value, fields.filename?.value));
|
|
4969
|
+
const lastAuto = useRef("");
|
|
4970
|
+
useEffect(() => {
|
|
4971
|
+
const generated = altFromFilename(filename);
|
|
4972
|
+
if (!generated) return;
|
|
4973
|
+
if ((typeof value === "string" ? value.trim() : "") === generated) {
|
|
4974
|
+
lastAuto.current = generated;
|
|
4975
|
+
return;
|
|
4976
|
+
}
|
|
4977
|
+
if (!shouldFillMediaAlt(value, generated, lastAuto.current)) return;
|
|
4978
|
+
lastAuto.current = generated;
|
|
4979
|
+
setValue(generated);
|
|
4980
|
+
}, [
|
|
4981
|
+
filename,
|
|
4982
|
+
setValue,
|
|
4983
|
+
value
|
|
4984
|
+
]);
|
|
4985
|
+
return null;
|
|
4986
|
+
}
|
|
4987
|
+
//#endregion
|
|
4988
|
+
//#region src/collections/media-list-query.ts
|
|
4989
|
+
const MEDIA_COLUMN_KEYS = [
|
|
4990
|
+
"filename",
|
|
4991
|
+
"alt",
|
|
4992
|
+
"inUse",
|
|
4993
|
+
"updatedAt",
|
|
4994
|
+
"createdAt",
|
|
4995
|
+
"filesize",
|
|
4996
|
+
"dimensions"
|
|
4997
|
+
];
|
|
4998
|
+
const EMPTY_MEDIA_FILTERS = {
|
|
4999
|
+
alt: "any",
|
|
5000
|
+
date: "any",
|
|
5001
|
+
advField: "filename",
|
|
5002
|
+
advOp: "contains",
|
|
5003
|
+
advValue: ""
|
|
5004
|
+
};
|
|
5005
|
+
function mediaInUseEnabled(config) {
|
|
5006
|
+
return (config?.admin?.custom)?.mediaInUse !== false;
|
|
5007
|
+
}
|
|
5008
|
+
function defaultMediaColumns(inUseEnabled) {
|
|
5009
|
+
return inUseEnabled ? [
|
|
5010
|
+
"filename",
|
|
5011
|
+
"alt",
|
|
5012
|
+
"inUse",
|
|
5013
|
+
"updatedAt",
|
|
5014
|
+
"createdAt"
|
|
5015
|
+
] : [
|
|
5016
|
+
"filename",
|
|
5017
|
+
"alt",
|
|
5018
|
+
"updatedAt",
|
|
5019
|
+
"createdAt"
|
|
5020
|
+
];
|
|
5021
|
+
}
|
|
5022
|
+
function normalizeColumns(columns) {
|
|
5023
|
+
if (Array.isArray(columns)) return columns.filter((entry) => typeof entry === "string");
|
|
5024
|
+
if (typeof columns !== "string" || !columns.trim()) return null;
|
|
5025
|
+
try {
|
|
5026
|
+
const parsed = JSON.parse(columns);
|
|
5027
|
+
if (!Array.isArray(parsed)) return null;
|
|
5028
|
+
return parsed.filter((entry) => typeof entry === "string");
|
|
5029
|
+
} catch {
|
|
5030
|
+
return null;
|
|
5031
|
+
}
|
|
5032
|
+
}
|
|
5033
|
+
function columnsFromQuery(columns, inUseEnabled) {
|
|
5034
|
+
const defaultOn = defaultMediaColumns(inUseEnabled);
|
|
5035
|
+
const visible = Object.fromEntries(MEDIA_COLUMN_KEYS.map((key) => [key, defaultOn.includes(key)]));
|
|
5036
|
+
const entries = normalizeColumns(columns);
|
|
5037
|
+
if (!entries) return visible;
|
|
5038
|
+
const named = /* @__PURE__ */ new Set();
|
|
5039
|
+
for (const entry of entries) {
|
|
5040
|
+
if (typeof entry !== "string") continue;
|
|
5041
|
+
const active = entry[0] !== "-";
|
|
5042
|
+
const key = active ? entry : entry.slice(1);
|
|
5043
|
+
if (!MEDIA_COLUMN_KEYS.includes(key)) continue;
|
|
5044
|
+
if (key === "inUse" && !inUseEnabled) continue;
|
|
5045
|
+
visible[key] = active;
|
|
5046
|
+
named.add(key);
|
|
5047
|
+
}
|
|
5048
|
+
if (inUseEnabled && !named.has("inUse")) visible.inUse = true;
|
|
5049
|
+
visible.filename = true;
|
|
5050
|
+
if (!inUseEnabled) visible.inUse = false;
|
|
5051
|
+
return visible;
|
|
5052
|
+
}
|
|
5053
|
+
function columnsToQuery(visible) {
|
|
5054
|
+
return MEDIA_COLUMN_KEYS.map((key) => visible[key] ? key : `-${key}`);
|
|
5055
|
+
}
|
|
5056
|
+
function draftFromWhere(where) {
|
|
5057
|
+
const draft = { ...EMPTY_MEDIA_FILTERS };
|
|
5058
|
+
const clauses = flattenWhere(where);
|
|
5059
|
+
for (const clause of clauses) {
|
|
5060
|
+
if (clause.alt && typeof clause.alt === "object") {
|
|
5061
|
+
const alt = clause.alt;
|
|
5062
|
+
if (alt.equals === "" || alt.exists === false) draft.alt = "missing";
|
|
5063
|
+
else if (alt.exists === true || alt.not_equals === "") draft.alt = "has";
|
|
5064
|
+
else if (typeof alt.equals === "string" && alt.equals !== "") {
|
|
5065
|
+
draft.advField = "alt";
|
|
5066
|
+
draft.advOp = "equals";
|
|
5067
|
+
draft.advValue = alt.equals;
|
|
5068
|
+
}
|
|
5069
|
+
}
|
|
5070
|
+
if (clause.createdAt && typeof clause.createdAt === "object") {
|
|
5071
|
+
const stamp = clause.createdAt.greater_than_equal;
|
|
5072
|
+
if (stamp) {
|
|
5073
|
+
const days = (Date.now() - new Date(stamp).getTime()) / 864e5;
|
|
5074
|
+
draft.date = days <= 1.1 ? "today" : days <= 8 ? "week" : "month";
|
|
5075
|
+
}
|
|
5076
|
+
}
|
|
5077
|
+
for (const field of ["filename", "alt"]) {
|
|
5078
|
+
const value = clause[field];
|
|
5079
|
+
if (!value || typeof value !== "object") continue;
|
|
5080
|
+
const op = value;
|
|
5081
|
+
if (typeof op.contains === "string") {
|
|
5082
|
+
draft.advField = field;
|
|
5083
|
+
draft.advOp = "contains";
|
|
5084
|
+
draft.advValue = op.contains;
|
|
5085
|
+
} else if (typeof op.equals === "string") {
|
|
5086
|
+
draft.advField = field;
|
|
5087
|
+
draft.advOp = "equals";
|
|
5088
|
+
draft.advValue = op.equals;
|
|
5089
|
+
} else if (typeof op.not_like === "string") {
|
|
5090
|
+
draft.advField = field;
|
|
5091
|
+
draft.advOp = "not_contains";
|
|
5092
|
+
draft.advValue = op.not_like;
|
|
5093
|
+
}
|
|
5094
|
+
}
|
|
5095
|
+
}
|
|
5096
|
+
return draft;
|
|
5097
|
+
}
|
|
5098
|
+
function whereFromDraft(draft) {
|
|
5099
|
+
const and = [];
|
|
5100
|
+
if (draft.alt === "has") and.push({ and: [{ alt: { exists: true } }, { alt: { not_equals: "" } }] });
|
|
5101
|
+
if (draft.alt === "missing") and.push({ or: [{ alt: { exists: false } }, { alt: { equals: "" } }] });
|
|
5102
|
+
if (draft.date !== "any") {
|
|
5103
|
+
const start = /* @__PURE__ */ new Date();
|
|
5104
|
+
start.setHours(0, 0, 0, 0);
|
|
5105
|
+
if (draft.date === "week") start.setDate(start.getDate() - 6);
|
|
5106
|
+
if (draft.date === "month") start.setDate(start.getDate() - 29);
|
|
5107
|
+
and.push({ createdAt: { greater_than_equal: start.toISOString() } });
|
|
5108
|
+
}
|
|
5109
|
+
const value = draft.advValue.trim();
|
|
5110
|
+
if (value) if (draft.advOp === "contains") and.push({ [draft.advField]: { contains: value } });
|
|
5111
|
+
else if (draft.advOp === "equals") and.push({ [draft.advField]: { equals: value } });
|
|
5112
|
+
else and.push({ [draft.advField]: { not_like: value } });
|
|
5113
|
+
if (and.length === 0) return {};
|
|
5114
|
+
if (and.length === 1) return and[0];
|
|
5115
|
+
return { and };
|
|
5116
|
+
}
|
|
5117
|
+
function flattenWhere(where) {
|
|
5118
|
+
if (!where || typeof where !== "object") return [];
|
|
5119
|
+
const and = where.and;
|
|
5120
|
+
if (Array.isArray(and)) return and.flatMap((entry) => flattenWhere(entry));
|
|
5121
|
+
const or = where.or;
|
|
5122
|
+
if (Array.isArray(or)) return or.flatMap((entry) => flattenWhere(entry));
|
|
5123
|
+
return [where];
|
|
5124
|
+
}
|
|
5125
|
+
//#endregion
|
|
5126
|
+
//#region src/admin/media-list-view.tsx
|
|
5127
|
+
const COLUMN_KEYS = MEDIA_COLUMN_KEYS;
|
|
5128
|
+
const LOCKED = "filename";
|
|
5129
|
+
const CHECK_COL = "56px";
|
|
5130
|
+
const FILE_COL = "18rem";
|
|
5131
|
+
const ACTIONS_COL = "var(--bl-media-actions-col,max-content)";
|
|
5132
|
+
const FILE_PIN_LEFT = { left: CHECK_COL };
|
|
5133
|
+
const LIST_CSS = `
|
|
5134
|
+
.bl-media-list{font:14px/1.4 Inter,ui-sans-serif,system-ui,sans-serif;color:var(--bl-kit-ink)}
|
|
5135
|
+
.bl-media-list .bl-workspace__main-head{padding:0;margin:0 0 22px;align-items:flex-start}
|
|
5136
|
+
.bl-media-list .bl-workspace__main-head h1{display:flex;align-items:baseline;gap:.45em;font-size:27px;margin:0;font-weight:700;letter-spacing:-.02em}
|
|
5137
|
+
.bl-media-list__count{color:var(--bl-kit-ink-muted);white-space:nowrap;font-size:13px;font-weight:500;letter-spacing:0}
|
|
5138
|
+
.bl-media-list__actions{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
|
|
5139
|
+
.bl-media-list__toolbar{display:flex;align-items:center;gap:8px;margin-bottom:18px}
|
|
5140
|
+
.bl-media-list__search{position:relative;flex:1;min-width:0}
|
|
5141
|
+
.bl-media-list__search .bl-nav-kit__input{padding-left:44px}
|
|
5142
|
+
.bl-media-list__search-icon{position:absolute;left:12px;top:50%;transform:translateY(-50%);color:var(--bl-kit-ink-muted);pointer-events:none;display:grid;place-items:center}
|
|
5143
|
+
.bl-media-list__search-icon svg{display:block;width:20px;height:20px}
|
|
5144
|
+
.bl-media-list__file{display:flex;align-items:center;gap:12px;width:100%;min-width:0;max-width:100%}
|
|
5145
|
+
.bl-media-list .bl-nav-kit__thumb--sm .bl-nav-kit__thumb-frame{width:38px;height:38px;border-radius:5px;flex:none}
|
|
5146
|
+
.bl-media-list__when{white-space:nowrap}
|
|
5147
|
+
.bl-media-list__filename{text-decoration:underline;font-weight:500;color:inherit;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0;flex:1}
|
|
5148
|
+
.bl-media-list__filename:hover{color:var(--bl-kit-accent,#2563eb)}
|
|
5149
|
+
.bl-media-list__sort{display:inline-flex;align-items:center;gap:2px;border:0;background:transparent;padding:0;color:inherit;font:inherit;font-weight:inherit;letter-spacing:inherit;text-transform:inherit;cursor:pointer;min-width:0;max-width:100%}
|
|
5150
|
+
.bl-media-list__sort-mark{display:inline-flex;flex-direction:column;width:12px;height:16px;margin-left:4px;flex:none}
|
|
5151
|
+
.bl-media-list__sort-mark svg{display:block;width:12px;height:9px;stroke:currentColor;fill:none;stroke-width:2.4;stroke-linecap:round;stroke-linejoin:round;opacity:.32}
|
|
5152
|
+
.bl-media-list__sort-mark[data-dir="asc"] svg:first-child,.bl-media-list__sort-mark[data-dir="desc"] svg:last-child{opacity:1;color:var(--bl-kit-accent,#2563eb)}
|
|
5153
|
+
.bl-media-list .bl-nav-kit__table-row:not(.bl-nav-kit__table-head):nth-child(even){--bl-table-row-bg:var(--bl-kit-surface-well);background-color:var(--bl-table-row-bg)}
|
|
5154
|
+
.bl-media-list .bl-nav-kit__table-cell--shade.bl-nav-kit__table-cell--pin-start{min-width:0;overflow:hidden}
|
|
5155
|
+
.bl-media-list .bl-nav-kit__table-cell--pin-end{justify-content:center}
|
|
5156
|
+
.bl-media-list .bl-nav-kit__table-cell--pin-end .bl-nav-kit__table-actions{justify-content:center;width:max-content}
|
|
5157
|
+
.bl-media-list__empty{padding:48px 16px;text-align:center;color:var(--bl-kit-ink-muted)}
|
|
5158
|
+
.bl-media-list__checks{display:flex;flex-direction:column;gap:2px}
|
|
5159
|
+
.bl-media-list__checks label{display:flex;align-items:center;gap:8px;margin:9px 0;font-weight:400;cursor:pointer}
|
|
5160
|
+
.bl-media-list__checks label small{margin-left:auto;color:var(--bl-kit-ink-muted)}
|
|
5161
|
+
.bl-media-list__radios{display:flex;gap:14px;flex-wrap:wrap;margin:8px 0 4px}
|
|
5162
|
+
.bl-media-list__radios label{display:flex;align-items:center;gap:8px;margin:0;font-weight:400;cursor:pointer}
|
|
5163
|
+
.bl-media-list__field{display:block;margin:12px 0}
|
|
5164
|
+
.bl-media-list__field-label{display:block;margin-bottom:6px;font-weight:500}
|
|
5165
|
+
.bl-media-list__advanced{display:none;border-top:1px solid var(--bl-kit-border);padding-top:12px;margin-top:12px}
|
|
5166
|
+
.bl-media-list__advanced.is-open{display:block}
|
|
5167
|
+
.bl-media-list__link{border:0;background:none;color:var(--bl-kit-accent,#2563eb);padding:4px 0;cursor:pointer;font:inherit}
|
|
5168
|
+
.bl-media-list__inuse{display:grid;place-items:center;color:var(--theme-success-500,#3cbf7a)}
|
|
5169
|
+
.bl-media-list__inuse svg{display:block}
|
|
5170
|
+
.bl-media-list .bl-nav-kit__chips{margin:0 0 18px}
|
|
5171
|
+
@media(max-width:700px){
|
|
5172
|
+
.bl-media-list .bl-workspace__main-head{flex-direction:column}
|
|
5173
|
+
.bl-media-list__toolbar{flex-wrap:wrap}
|
|
5174
|
+
.bl-media-list__search{flex-basis:100%}
|
|
5175
|
+
}
|
|
5176
|
+
`;
|
|
5177
|
+
function MediaListView(props) {
|
|
5178
|
+
return /* @__PURE__ */ jsx(ThemeKitAccent, { children: /* @__PURE__ */ jsx(MediaListPage, { ...props }) });
|
|
5179
|
+
}
|
|
5180
|
+
function MediaListPage({ collectionSlug, hasCreatePermission, hasDeletePermission, newDocumentURL }) {
|
|
5181
|
+
const { setStepNav } = useStepNav();
|
|
5182
|
+
const { openModal } = useModal();
|
|
5183
|
+
const { drawerSlug, setCollectionSlug, setOnSuccess } = useBulkUpload();
|
|
5184
|
+
const { config: { routes: { admin: adminRoute, api }, serverURL }, getEntityConfig } = useConfig();
|
|
5185
|
+
const { data, query, handleSearchChange, handlePageChange, handlePerPageChange, handleSortChange, handleWhereChange, refineListData } = useListQuery();
|
|
5186
|
+
const collectionConfig = getEntityConfig({ collectionSlug });
|
|
5187
|
+
const inUseEnabled = mediaInUseEnabled(collectionConfig);
|
|
5188
|
+
const canDelete = hasDeletePermission !== false;
|
|
5189
|
+
const [search, setSearch] = useState(typeof query.search === "string" ? query.search : "");
|
|
5190
|
+
const [visible, setVisible] = useState(() => columnsFromQuery(query.columns, inUseEnabled));
|
|
5191
|
+
const [openPop, setOpenPop] = useState(null);
|
|
5192
|
+
const [draft, setDraft] = useState(() => draftFromWhere(query.where));
|
|
5193
|
+
const [applied, setApplied] = useState(() => draftFromWhere(query.where));
|
|
5194
|
+
const [advancedOpen, setAdvancedOpen] = useState(Boolean(draftFromWhere(query.where).advValue));
|
|
5195
|
+
const [selected, setSelected] = useState(/* @__PURE__ */ new Set());
|
|
5196
|
+
const [selectedLabels, setSelectedLabels] = useState(/* @__PURE__ */ new Map());
|
|
5197
|
+
const [inUse, setInUse] = useState(/* @__PURE__ */ new Set());
|
|
5198
|
+
const [inUseScanFailed, setInUseScanFailed] = useState(false);
|
|
5199
|
+
const [confirm, setConfirm] = useState(null);
|
|
5200
|
+
const rootRef = useRef(null);
|
|
5201
|
+
const docs = data?.docs ?? [];
|
|
5202
|
+
const totalDocs = data?.totalDocs ?? docs.length;
|
|
5203
|
+
const page = data?.page ?? 1;
|
|
5204
|
+
const pageCount = Math.max(1, data?.totalPages ?? 1);
|
|
5205
|
+
const pageSize = data?.limit ?? 10;
|
|
5206
|
+
const sort = typeof query.sort === "string" ? query.sort : void 0;
|
|
5207
|
+
const searchQuery = typeof query.search === "string" ? query.search : "";
|
|
5208
|
+
const pendingSearches = useRef(/* @__PURE__ */ new Set());
|
|
5209
|
+
useEffect(() => {
|
|
5210
|
+
setStepNav([{ label: "Media" }]);
|
|
5211
|
+
}, [setStepNav]);
|
|
5212
|
+
useEffect(() => {
|
|
5213
|
+
const next = typeof query.search === "string" ? query.search : "";
|
|
5214
|
+
if (pendingSearches.current.has(next)) {
|
|
5215
|
+
pendingSearches.current.delete(next);
|
|
5216
|
+
return;
|
|
5217
|
+
}
|
|
5218
|
+
setSearch(next);
|
|
5219
|
+
}, [query.search]);
|
|
5220
|
+
useEffect(() => {
|
|
5221
|
+
setVisible(columnsFromQuery(query.columns, inUseEnabled));
|
|
5222
|
+
}, [query.columns, inUseEnabled]);
|
|
5223
|
+
useEffect(() => {
|
|
5224
|
+
const nextDraft = draftFromWhere(query.where);
|
|
5225
|
+
setApplied(nextDraft);
|
|
5226
|
+
setDraft(nextDraft);
|
|
5227
|
+
setAdvancedOpen(Boolean(nextDraft.advValue));
|
|
5228
|
+
}, [query.where]);
|
|
5229
|
+
useEffect(() => {
|
|
5230
|
+
if (search === searchQuery) return;
|
|
5231
|
+
const handle = window.setTimeout(() => {
|
|
5232
|
+
pendingSearches.current.add(search);
|
|
5233
|
+
if (handleSearchChange) handleSearchChange(search);
|
|
5234
|
+
}, 250);
|
|
5235
|
+
return () => window.clearTimeout(handle);
|
|
5236
|
+
}, [
|
|
5237
|
+
search,
|
|
5238
|
+
searchQuery,
|
|
5239
|
+
handleSearchChange
|
|
5240
|
+
]);
|
|
5241
|
+
const refreshInUse = useCallback(() => {
|
|
5242
|
+
if (!inUseEnabled) {
|
|
5243
|
+
setInUse(/* @__PURE__ */ new Set());
|
|
5244
|
+
setInUseScanFailed(false);
|
|
5245
|
+
return;
|
|
5246
|
+
}
|
|
5247
|
+
fetch(`${serverURL}${api}/media/in-use`, { credentials: "include" }).then((response) => {
|
|
5248
|
+
if (!response.ok) {
|
|
5249
|
+
setInUseScanFailed(true);
|
|
5250
|
+
setInUse(/* @__PURE__ */ new Set());
|
|
5251
|
+
return;
|
|
5252
|
+
}
|
|
5253
|
+
return response.json();
|
|
5254
|
+
}).then((body) => {
|
|
5255
|
+
if (!body) return;
|
|
5256
|
+
setInUseScanFailed(false);
|
|
5257
|
+
const ids = Array.isArray(body.ids) ? body.ids.map(String) : [];
|
|
5258
|
+
setInUse(new Set(ids));
|
|
5259
|
+
}).catch(() => {
|
|
5260
|
+
setInUseScanFailed(true);
|
|
5261
|
+
setInUse(/* @__PURE__ */ new Set());
|
|
5262
|
+
});
|
|
5263
|
+
}, [
|
|
5264
|
+
api,
|
|
5265
|
+
inUseEnabled,
|
|
5266
|
+
serverURL
|
|
5267
|
+
]);
|
|
5268
|
+
useEffect(() => {
|
|
5269
|
+
refreshInUse();
|
|
5270
|
+
}, [refreshInUse]);
|
|
5271
|
+
const openBulkUpload = useCallback(() => {
|
|
5272
|
+
setCollectionSlug(collectionSlug);
|
|
5273
|
+
setOnSuccess(() => {
|
|
5274
|
+
refineListData({});
|
|
5275
|
+
});
|
|
5276
|
+
openModal(drawerSlug);
|
|
5277
|
+
}, [
|
|
5278
|
+
collectionSlug,
|
|
5279
|
+
drawerSlug,
|
|
5280
|
+
openModal,
|
|
5281
|
+
refineListData,
|
|
5282
|
+
setCollectionSlug,
|
|
5283
|
+
setOnSuccess
|
|
5284
|
+
]);
|
|
5285
|
+
const editUrl = (id) => formatAdminURL({
|
|
5286
|
+
adminRoute,
|
|
5287
|
+
path: `/collections/${collectionSlug}/${id}`
|
|
5288
|
+
});
|
|
5289
|
+
const toggleColumn = (key, on) => {
|
|
5290
|
+
if (key === LOCKED) return;
|
|
5291
|
+
const next = {
|
|
5292
|
+
...visible,
|
|
5293
|
+
[key]: on
|
|
5294
|
+
};
|
|
5295
|
+
setVisible(next);
|
|
5296
|
+
if (refineListData) refineListData({ columns: columnsToQuery(next) });
|
|
5297
|
+
};
|
|
5298
|
+
const applyFilters = () => {
|
|
5299
|
+
setApplied(draft);
|
|
5300
|
+
setOpenPop(null);
|
|
5301
|
+
if (handleWhereChange) handleWhereChange(whereFromDraft(draft));
|
|
5302
|
+
};
|
|
5303
|
+
const clearDraft = () => setDraft(EMPTY_MEDIA_FILTERS);
|
|
5304
|
+
const dismissChip = (key) => {
|
|
5305
|
+
const next = {
|
|
5306
|
+
...applied,
|
|
5307
|
+
...key === "alt" ? { alt: "any" } : {},
|
|
5308
|
+
...key === "date" ? { date: "any" } : {},
|
|
5309
|
+
...key === "adv" ? { advValue: "" } : {}
|
|
5310
|
+
};
|
|
5311
|
+
setApplied(next);
|
|
5312
|
+
setDraft(next);
|
|
5313
|
+
if (handleWhereChange) handleWhereChange(whereFromDraft(next));
|
|
5314
|
+
};
|
|
5315
|
+
const clearAllFilters = () => {
|
|
5316
|
+
setApplied(EMPTY_MEDIA_FILTERS);
|
|
5317
|
+
setDraft(EMPTY_MEDIA_FILTERS);
|
|
5318
|
+
if (handleWhereChange) handleWhereChange({});
|
|
5319
|
+
};
|
|
5320
|
+
const chips = useMemo(() => chipsFrom(applied), [applied]);
|
|
5321
|
+
const shown = COLUMN_KEYS.filter((key) => visible[key]);
|
|
5322
|
+
const columns = gridColumns(shown);
|
|
5323
|
+
useLayoutEffect(() => {
|
|
5324
|
+
const root = rootRef.current;
|
|
5325
|
+
const table = root?.querySelector(".bl-nav-kit__table");
|
|
5326
|
+
if (!root || !table) return;
|
|
5327
|
+
const measurePins = () => {
|
|
5328
|
+
const actionCells = [...root.querySelectorAll(".bl-nav-kit__table-cell--pin-end")];
|
|
5329
|
+
const actionsCol = Math.ceil(Math.max(0, ...actionCells.map((cell) => pinTrackWidth(cell, ".bl-nav-kit__table-actions"))));
|
|
5330
|
+
if (actionsCol) table.style.setProperty("--bl-media-actions-col", `${actionsCol}px`);
|
|
5331
|
+
};
|
|
5332
|
+
measurePins();
|
|
5333
|
+
const observer = new ResizeObserver(measurePins);
|
|
5334
|
+
observer.observe(table);
|
|
5335
|
+
window.addEventListener("resize", measurePins);
|
|
5336
|
+
return () => {
|
|
5337
|
+
observer.disconnect();
|
|
5338
|
+
window.removeEventListener("resize", measurePins);
|
|
5339
|
+
};
|
|
5340
|
+
}, [
|
|
5341
|
+
columns,
|
|
5342
|
+
docs.length,
|
|
5343
|
+
shown.length
|
|
5344
|
+
]);
|
|
5345
|
+
const pageIds = docs.map((doc) => String(doc.id));
|
|
5346
|
+
const allPageSelected = pageIds.length > 0 && pageIds.every((id) => selected.has(id));
|
|
5347
|
+
const toggleAll = (on) => {
|
|
5348
|
+
setSelected((current) => {
|
|
5349
|
+
const next = new Set(current);
|
|
5350
|
+
for (const id of pageIds) if (on) next.add(id);
|
|
5351
|
+
else next.delete(id);
|
|
5352
|
+
return next;
|
|
5353
|
+
});
|
|
5354
|
+
setSelectedLabels((current) => {
|
|
5355
|
+
const next = new Map(current);
|
|
5356
|
+
for (const doc of docs) {
|
|
5357
|
+
const id = String(doc.id);
|
|
5358
|
+
if (!pageIds.includes(id)) continue;
|
|
5359
|
+
if (on) next.set(id, doc.filename || id);
|
|
5360
|
+
else next.delete(id);
|
|
5361
|
+
}
|
|
5362
|
+
return next;
|
|
5363
|
+
});
|
|
5364
|
+
};
|
|
5365
|
+
const askDelete = (targets) => {
|
|
5366
|
+
setConfirm({
|
|
5367
|
+
ids: targets.map((doc) => doc.id),
|
|
5368
|
+
names: targets.map((doc) => doc.filename || String(doc.id))
|
|
5369
|
+
});
|
|
5370
|
+
};
|
|
5371
|
+
const runDelete = async () => {
|
|
5372
|
+
if (!confirm) return;
|
|
5373
|
+
const failed = [];
|
|
5374
|
+
for (const id of confirm.ids) if (!(await fetch(`${serverURL}${api}/media/${id}`, {
|
|
5375
|
+
method: "DELETE",
|
|
5376
|
+
credentials: "include"
|
|
5377
|
+
})).ok) failed.push(String(id));
|
|
5378
|
+
if (refineListData) refineListData({});
|
|
5379
|
+
if (failed.length > 0) {
|
|
5380
|
+
setSelected(new Set(failed));
|
|
5381
|
+
setSelectedLabels((current) => new Map([...current].filter(([id]) => failed.includes(id))));
|
|
5382
|
+
setConfirm({
|
|
5383
|
+
ids: failed,
|
|
5384
|
+
names: failed.map((id) => selectedLabels.get(id) ?? id),
|
|
5385
|
+
error: "Some files could not be deleted."
|
|
5386
|
+
});
|
|
5387
|
+
return;
|
|
5388
|
+
}
|
|
5389
|
+
setSelected(/* @__PURE__ */ new Set());
|
|
5390
|
+
setSelectedLabels(/* @__PURE__ */ new Map());
|
|
5391
|
+
setConfirm(null);
|
|
5392
|
+
refreshInUse();
|
|
5393
|
+
};
|
|
5394
|
+
const askDeleteSelected = () => {
|
|
5395
|
+
const ids = [...selected];
|
|
5396
|
+
if (ids.length === 0) return;
|
|
5397
|
+
setConfirm({
|
|
5398
|
+
ids,
|
|
5399
|
+
names: ids.map((id) => selectedLabels.get(id) ?? id)
|
|
5400
|
+
});
|
|
5401
|
+
};
|
|
5402
|
+
const confirmInUse = confirm?.ids.some((id) => inUse.has(String(id))) ?? false;
|
|
5403
|
+
const confirmInUseUnavailable = inUseEnabled && inUseScanFailed;
|
|
5404
|
+
const title = typeof collectionConfig?.labels?.plural === "string" ? collectionConfig.labels.plural : "Media";
|
|
5405
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("style", {
|
|
5406
|
+
href: "bl-media-list",
|
|
5407
|
+
precedence: "default",
|
|
5408
|
+
children: LIST_CSS
|
|
5409
|
+
}), /* @__PURE__ */ jsx(Page, {
|
|
5410
|
+
className: "bl-media-list",
|
|
5411
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
5412
|
+
ref: rootRef,
|
|
5413
|
+
children: [
|
|
5414
|
+
/* @__PURE__ */ jsx(MainHead, {
|
|
5415
|
+
title: /* @__PURE__ */ jsxs(Fragment, { children: [title, /* @__PURE__ */ jsxs("span", {
|
|
5416
|
+
className: "bl-media-list__count",
|
|
5417
|
+
children: [
|
|
5418
|
+
totalDocs,
|
|
5419
|
+
" ",
|
|
5420
|
+
totalDocs === 1 ? "file" : "files"
|
|
5421
|
+
]
|
|
5422
|
+
})] }),
|
|
5423
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
5424
|
+
className: "bl-media-list__actions",
|
|
5425
|
+
children: [
|
|
5426
|
+
/* @__PURE__ */ jsx(Button$1, {
|
|
5427
|
+
variant: "primary",
|
|
5428
|
+
disabled: !hasCreatePermission,
|
|
5429
|
+
onClick: () => window.location.assign(newDocumentURL),
|
|
5430
|
+
children: "Create New"
|
|
5431
|
+
}),
|
|
5432
|
+
/* @__PURE__ */ jsx(Button$1, {
|
|
5433
|
+
variant: "outline",
|
|
5434
|
+
onClick: openBulkUpload,
|
|
5435
|
+
children: "Bulk Upload"
|
|
5436
|
+
}),
|
|
5437
|
+
/* @__PURE__ */ jsx(Button$1, {
|
|
5438
|
+
variant: "outline",
|
|
5439
|
+
disabled: !canDelete || selected.size === 0,
|
|
5440
|
+
onClick: askDeleteSelected,
|
|
5441
|
+
children: "Delete"
|
|
5442
|
+
})
|
|
5443
|
+
]
|
|
5444
|
+
})
|
|
5445
|
+
}),
|
|
5446
|
+
/* @__PURE__ */ jsxs("div", {
|
|
5447
|
+
className: "bl-media-list__toolbar",
|
|
5448
|
+
children: [
|
|
5449
|
+
/* @__PURE__ */ jsxs("label", {
|
|
5450
|
+
className: "bl-media-list__search",
|
|
5451
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
5452
|
+
className: "bl-media-list__search-icon",
|
|
5453
|
+
"aria-hidden": true,
|
|
5454
|
+
children: /* @__PURE__ */ jsx(SearchMark, {})
|
|
5455
|
+
}), /* @__PURE__ */ jsx(Input, {
|
|
5456
|
+
value: search,
|
|
5457
|
+
onChange: (event) => setSearch(event.target.value),
|
|
5458
|
+
placeholder: "Search by file name",
|
|
5459
|
+
"aria-label": "Search by file name"
|
|
5460
|
+
})]
|
|
5461
|
+
}),
|
|
5462
|
+
/* @__PURE__ */ jsx(Popover, {
|
|
5463
|
+
open: openPop === "columns",
|
|
5464
|
+
onOpenChange: (open) => setOpenPop(open ? "columns" : null),
|
|
5465
|
+
title: "Show columns",
|
|
5466
|
+
size: "sm",
|
|
5467
|
+
trigger: /* @__PURE__ */ jsxs(Button$1, {
|
|
5468
|
+
variant: "outline",
|
|
5469
|
+
onClick: () => setOpenPop(openPop === "columns" ? null : "columns"),
|
|
5470
|
+
children: [
|
|
5471
|
+
/* @__PURE__ */ jsx(ColumnsMark, {}),
|
|
5472
|
+
"Columns",
|
|
5473
|
+
/* @__PURE__ */ jsx(ChevronMark, {})
|
|
5474
|
+
]
|
|
5475
|
+
}),
|
|
5476
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
5477
|
+
className: "bl-media-list__checks",
|
|
5478
|
+
children: [COLUMN_KEYS.map((key) => /* @__PURE__ */ jsxs("label", { children: [
|
|
5479
|
+
/* @__PURE__ */ jsx(Checkbox, {
|
|
5480
|
+
checked: visible[key],
|
|
5481
|
+
disabled: key === LOCKED,
|
|
5482
|
+
onCheckedChange: (value) => toggleColumn(key, value === true)
|
|
5483
|
+
}),
|
|
5484
|
+
/* @__PURE__ */ jsx("span", { children: columnLabel(key) }),
|
|
5485
|
+
key === LOCKED ? /* @__PURE__ */ jsx("small", { children: "Required" }) : null
|
|
5486
|
+
] }, key)), /* @__PURE__ */ jsxs("label", { children: [
|
|
5487
|
+
/* @__PURE__ */ jsx(Checkbox, {
|
|
5488
|
+
checked: true,
|
|
5489
|
+
disabled: true
|
|
5490
|
+
}),
|
|
5491
|
+
/* @__PURE__ */ jsx("span", { children: "Actions" }),
|
|
5492
|
+
/* @__PURE__ */ jsx("small", { children: "Required" })
|
|
5493
|
+
] })]
|
|
5494
|
+
})
|
|
5495
|
+
}),
|
|
5496
|
+
/* @__PURE__ */ jsxs(Popover, {
|
|
5497
|
+
open: openPop === "filters",
|
|
5498
|
+
onOpenChange: (open) => setOpenPop(open ? "filters" : null),
|
|
5499
|
+
title: "Filters",
|
|
5500
|
+
trigger: /* @__PURE__ */ jsxs(Button$1, {
|
|
5501
|
+
variant: "outline",
|
|
5502
|
+
onClick: () => setOpenPop(openPop === "filters" ? null : "filters"),
|
|
5503
|
+
children: [
|
|
5504
|
+
/* @__PURE__ */ jsx(FiltersMark, {}),
|
|
5505
|
+
chips.length ? `Filters (${chips.length})` : "Filters",
|
|
5506
|
+
/* @__PURE__ */ jsx(ChevronMark, {})
|
|
5507
|
+
]
|
|
5508
|
+
}),
|
|
5509
|
+
footer: /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Button$1, {
|
|
5510
|
+
variant: "ghost",
|
|
5511
|
+
onClick: clearDraft,
|
|
5512
|
+
children: "Clear"
|
|
5513
|
+
}), /* @__PURE__ */ jsx(Button$1, {
|
|
5514
|
+
variant: "primary",
|
|
5515
|
+
onClick: applyFilters,
|
|
5516
|
+
children: "Apply filters"
|
|
5517
|
+
})] }),
|
|
5518
|
+
children: [
|
|
5519
|
+
/* @__PURE__ */ jsxs("div", {
|
|
5520
|
+
className: "bl-media-list__field",
|
|
5521
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
5522
|
+
className: "bl-media-list__field-label",
|
|
5523
|
+
children: "Alt text"
|
|
5524
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
5525
|
+
className: "bl-media-list__radios",
|
|
5526
|
+
children: [
|
|
5527
|
+
["any", "Any"],
|
|
5528
|
+
["has", "Has alt text"],
|
|
5529
|
+
["missing", "Missing alt text"]
|
|
5530
|
+
].map(([value, label]) => /* @__PURE__ */ jsxs("label", { children: [/* @__PURE__ */ jsx("input", {
|
|
5531
|
+
type: "radio",
|
|
5532
|
+
name: "media-alt",
|
|
5533
|
+
value,
|
|
5534
|
+
checked: draft.alt === value,
|
|
5535
|
+
onChange: () => setDraft((current) => ({
|
|
5536
|
+
...current,
|
|
5537
|
+
alt: value
|
|
5538
|
+
}))
|
|
5539
|
+
}), label] }, value))
|
|
5540
|
+
})]
|
|
5541
|
+
}),
|
|
5542
|
+
/* @__PURE__ */ jsxs("label", {
|
|
5543
|
+
className: "bl-media-list__field",
|
|
5544
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
5545
|
+
className: "bl-media-list__field-label",
|
|
5546
|
+
children: "Uploaded"
|
|
5547
|
+
}), /* @__PURE__ */ jsxs(Select, {
|
|
5548
|
+
value: draft.date,
|
|
5549
|
+
onValueChange: (value) => setDraft((current) => ({
|
|
5550
|
+
...current,
|
|
5551
|
+
date: value
|
|
5552
|
+
})),
|
|
5553
|
+
children: [/* @__PURE__ */ jsx(SelectTrigger, {
|
|
5554
|
+
"aria-label": "Uploaded",
|
|
5555
|
+
children: /* @__PURE__ */ jsx(SelectValue, {})
|
|
5556
|
+
}), /* @__PURE__ */ jsxs(SelectContent, { children: [
|
|
5557
|
+
/* @__PURE__ */ jsx(SelectItem, {
|
|
5558
|
+
value: "any",
|
|
5559
|
+
children: "Any time"
|
|
5560
|
+
}),
|
|
5561
|
+
/* @__PURE__ */ jsx(SelectItem, {
|
|
5562
|
+
value: "today",
|
|
5563
|
+
children: "Today"
|
|
5564
|
+
}),
|
|
5565
|
+
/* @__PURE__ */ jsx(SelectItem, {
|
|
5566
|
+
value: "week",
|
|
5567
|
+
children: "Past 7 days"
|
|
5568
|
+
}),
|
|
5569
|
+
/* @__PURE__ */ jsx(SelectItem, {
|
|
5570
|
+
value: "month",
|
|
5571
|
+
children: "Past 30 days"
|
|
5572
|
+
})
|
|
5573
|
+
] })]
|
|
5574
|
+
})]
|
|
5575
|
+
}),
|
|
5576
|
+
/* @__PURE__ */ jsxs("button", {
|
|
5577
|
+
type: "button",
|
|
5578
|
+
className: "bl-media-list__link",
|
|
5579
|
+
onClick: () => setAdvancedOpen((open) => !open),
|
|
5580
|
+
children: ["Advanced filters ", advancedOpen ? "▴" : "▾"]
|
|
5581
|
+
}),
|
|
5582
|
+
/* @__PURE__ */ jsxs("div", {
|
|
5583
|
+
className: ["bl-media-list__advanced", advancedOpen ? "is-open" : void 0].filter(Boolean).join(" "),
|
|
5584
|
+
children: [
|
|
5585
|
+
/* @__PURE__ */ jsxs("label", {
|
|
5586
|
+
className: "bl-media-list__field",
|
|
5587
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
5588
|
+
className: "bl-media-list__field-label",
|
|
5589
|
+
children: "Field"
|
|
5590
|
+
}), /* @__PURE__ */ jsxs(Select, {
|
|
5591
|
+
value: draft.advField,
|
|
5592
|
+
onValueChange: (value) => setDraft((current) => ({
|
|
5593
|
+
...current,
|
|
5594
|
+
advField: value
|
|
5595
|
+
})),
|
|
5596
|
+
children: [/* @__PURE__ */ jsx(SelectTrigger, {
|
|
5597
|
+
"aria-label": "Field",
|
|
5598
|
+
children: /* @__PURE__ */ jsx(SelectValue, {})
|
|
5599
|
+
}), /* @__PURE__ */ jsxs(SelectContent, { children: [/* @__PURE__ */ jsx(SelectItem, {
|
|
5600
|
+
value: "filename",
|
|
5601
|
+
children: "File name"
|
|
5602
|
+
}), /* @__PURE__ */ jsx(SelectItem, {
|
|
5603
|
+
value: "alt",
|
|
5604
|
+
children: "Alt text"
|
|
5605
|
+
})] })]
|
|
5606
|
+
})]
|
|
5607
|
+
}),
|
|
5608
|
+
/* @__PURE__ */ jsxs("label", {
|
|
5609
|
+
className: "bl-media-list__field",
|
|
5610
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
5611
|
+
className: "bl-media-list__field-label",
|
|
5612
|
+
children: "Operator"
|
|
5613
|
+
}), /* @__PURE__ */ jsxs(Select, {
|
|
5614
|
+
value: draft.advOp,
|
|
5615
|
+
onValueChange: (value) => setDraft((current) => ({
|
|
5616
|
+
...current,
|
|
5617
|
+
advOp: value
|
|
5618
|
+
})),
|
|
5619
|
+
children: [/* @__PURE__ */ jsx(SelectTrigger, {
|
|
5620
|
+
"aria-label": "Operator",
|
|
5621
|
+
children: /* @__PURE__ */ jsx(SelectValue, {})
|
|
5622
|
+
}), /* @__PURE__ */ jsxs(SelectContent, { children: [
|
|
5623
|
+
/* @__PURE__ */ jsx(SelectItem, {
|
|
5624
|
+
value: "contains",
|
|
5625
|
+
children: "contains"
|
|
5626
|
+
}),
|
|
5627
|
+
/* @__PURE__ */ jsx(SelectItem, {
|
|
5628
|
+
value: "equals",
|
|
5629
|
+
children: "equals"
|
|
5630
|
+
}),
|
|
5631
|
+
/* @__PURE__ */ jsx(SelectItem, {
|
|
5632
|
+
value: "not_contains",
|
|
5633
|
+
children: "does not contain"
|
|
5634
|
+
})
|
|
5635
|
+
] })]
|
|
5636
|
+
})]
|
|
5637
|
+
}),
|
|
5638
|
+
/* @__PURE__ */ jsxs("label", {
|
|
5639
|
+
className: "bl-media-list__field",
|
|
5640
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
5641
|
+
className: "bl-media-list__field-label",
|
|
5642
|
+
children: "Value"
|
|
5643
|
+
}), /* @__PURE__ */ jsx(Input, {
|
|
5644
|
+
value: draft.advValue,
|
|
5645
|
+
onChange: (event) => setDraft((current) => ({
|
|
5646
|
+
...current,
|
|
5647
|
+
advValue: event.target.value
|
|
5648
|
+
}))
|
|
5649
|
+
})]
|
|
5650
|
+
})
|
|
5651
|
+
]
|
|
5652
|
+
})
|
|
5653
|
+
]
|
|
5654
|
+
})
|
|
5655
|
+
]
|
|
5656
|
+
}),
|
|
5657
|
+
chips.length > 0 ? /* @__PURE__ */ jsxs("div", {
|
|
5658
|
+
className: "bl-nav-kit__chips",
|
|
5659
|
+
children: [chips.map((chip) => /* @__PURE__ */ jsx(Chip, {
|
|
5660
|
+
onDismiss: () => dismissChip(chip.key),
|
|
5661
|
+
children: chip.label
|
|
5662
|
+
}, chip.key)), /* @__PURE__ */ jsx(Button$1, {
|
|
5663
|
+
variant: "ghost",
|
|
5664
|
+
onClick: clearAllFilters,
|
|
5665
|
+
children: "Clear all"
|
|
5666
|
+
})]
|
|
5667
|
+
}) : null,
|
|
5668
|
+
/* @__PURE__ */ jsxs(Table, {
|
|
5669
|
+
columns,
|
|
5670
|
+
children: [/* @__PURE__ */ jsxs(TableHead, { children: [
|
|
5671
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
5672
|
+
pin: "start",
|
|
5673
|
+
children: /* @__PURE__ */ jsx(Checkbox, {
|
|
5674
|
+
checked: allPageSelected,
|
|
5675
|
+
onCheckedChange: (value) => toggleAll(value === true),
|
|
5676
|
+
"aria-label": "Select all on this page"
|
|
5677
|
+
})
|
|
5678
|
+
}),
|
|
5679
|
+
shown.map((key) => /* @__PURE__ */ jsx(TableCell, {
|
|
5680
|
+
pin: key === "filename" ? "start" : void 0,
|
|
5681
|
+
shade: key === "filename",
|
|
5682
|
+
style: key === "filename" ? FILE_PIN_LEFT : void 0,
|
|
5683
|
+
children: sortable(key) ? /* @__PURE__ */ jsxs("button", {
|
|
5684
|
+
type: "button",
|
|
5685
|
+
className: "bl-media-list__sort",
|
|
5686
|
+
onClick: () => handleSortChange && void handleSortChange(nextSort(sort, key)),
|
|
5687
|
+
children: [columnLabel(key), /* @__PURE__ */ jsx(SortChevrons, { dir: sortDir(sort, key) })]
|
|
5688
|
+
}) : columnLabel(key)
|
|
5689
|
+
}, key)),
|
|
5690
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
5691
|
+
pin: "end",
|
|
5692
|
+
shade: true,
|
|
5693
|
+
children: "Actions"
|
|
5694
|
+
})
|
|
5695
|
+
] }), docs.map((doc) => {
|
|
5696
|
+
const id = String(doc.id);
|
|
5697
|
+
const name = doc.filename || id;
|
|
5698
|
+
return /* @__PURE__ */ jsxs(TableRow, { children: [
|
|
5699
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
5700
|
+
pin: "start",
|
|
5701
|
+
children: /* @__PURE__ */ jsx(Checkbox, {
|
|
5702
|
+
checked: selected.has(id),
|
|
5703
|
+
onCheckedChange: (value) => {
|
|
5704
|
+
setSelected((current) => {
|
|
5705
|
+
const next = new Set(current);
|
|
5706
|
+
if (value === true) next.add(id);
|
|
5707
|
+
else next.delete(id);
|
|
5708
|
+
return next;
|
|
5709
|
+
});
|
|
5710
|
+
setSelectedLabels((current) => {
|
|
5711
|
+
const next = new Map(current);
|
|
5712
|
+
if (value === true) next.set(id, name);
|
|
5713
|
+
else next.delete(id);
|
|
5714
|
+
return next;
|
|
5715
|
+
});
|
|
5716
|
+
},
|
|
5717
|
+
"aria-label": `Select ${name}`
|
|
5718
|
+
})
|
|
5719
|
+
}),
|
|
5720
|
+
shown.map((key) => /* @__PURE__ */ jsx(TableCell, {
|
|
5721
|
+
pin: key === "filename" ? "start" : void 0,
|
|
5722
|
+
shade: key === "filename",
|
|
5723
|
+
style: key === "filename" ? FILE_PIN_LEFT : void 0,
|
|
5724
|
+
children: key === "filename" ? /* @__PURE__ */ jsxs("div", {
|
|
5725
|
+
className: "bl-media-list__file",
|
|
5726
|
+
children: [/* @__PURE__ */ jsx(Thumbnail, {
|
|
5727
|
+
size: "sm",
|
|
5728
|
+
src: doc.thumbnailURL || doc.url,
|
|
5729
|
+
alt: doc.alt || name
|
|
5730
|
+
}), /* @__PURE__ */ jsx("a", {
|
|
5731
|
+
className: "bl-media-list__filename",
|
|
5732
|
+
href: editUrl(doc.id),
|
|
5733
|
+
children: name
|
|
5734
|
+
})]
|
|
5735
|
+
}) : key === "alt" ? doc.alt || "—" : key === "inUse" ? inUse.has(id) ? /* @__PURE__ */ jsx("span", {
|
|
5736
|
+
className: "bl-media-list__inuse",
|
|
5737
|
+
"aria-label": "In use",
|
|
5738
|
+
children: /* @__PURE__ */ jsx(InUseMark, {})
|
|
5739
|
+
}) : null : key === "updatedAt" ? /* @__PURE__ */ jsx("span", {
|
|
5740
|
+
className: "bl-media-list__when",
|
|
5741
|
+
children: formatWhen(doc.updatedAt)
|
|
5742
|
+
}) : key === "createdAt" ? /* @__PURE__ */ jsx("span", {
|
|
5743
|
+
className: "bl-media-list__when",
|
|
5744
|
+
children: formatWhen(doc.createdAt)
|
|
5745
|
+
}) : key === "filesize" ? doc.filesize != null ? formatFilesize(doc.filesize) : "—" : doc.width && doc.height ? `${doc.width} × ${doc.height}` : "—"
|
|
5746
|
+
}, key)),
|
|
5747
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
5748
|
+
pin: "end",
|
|
5749
|
+
shade: true,
|
|
5750
|
+
children: /* @__PURE__ */ jsxs(TableActions, { children: [/* @__PURE__ */ jsx(Button$1, {
|
|
5751
|
+
size: "icon",
|
|
5752
|
+
variant: "ghost",
|
|
5753
|
+
"aria-label": `Edit ${name}`,
|
|
5754
|
+
onClick: () => window.location.assign(editUrl(doc.id)),
|
|
5755
|
+
children: /* @__PURE__ */ jsx(EditGlyph, {})
|
|
5756
|
+
}), /* @__PURE__ */ jsx(Button$1, {
|
|
5757
|
+
size: "icon",
|
|
5758
|
+
variant: "danger",
|
|
5759
|
+
"aria-label": `Delete ${name}`,
|
|
5760
|
+
disabled: !canDelete,
|
|
5761
|
+
onClick: () => askDelete([doc]),
|
|
5762
|
+
children: /* @__PURE__ */ jsx(DeleteGlyph, {})
|
|
5763
|
+
})] })
|
|
5764
|
+
})
|
|
5765
|
+
] }, id);
|
|
5766
|
+
})]
|
|
5767
|
+
}),
|
|
5768
|
+
docs.length === 0 ? /* @__PURE__ */ jsx("div", {
|
|
5769
|
+
className: "bl-media-list__empty",
|
|
5770
|
+
children: "No files match these filters."
|
|
5771
|
+
}) : null,
|
|
5772
|
+
docs.length > 0 ? /* @__PURE__ */ jsx("div", {
|
|
5773
|
+
style: { marginTop: 16 },
|
|
5774
|
+
children: /* @__PURE__ */ jsx(Pagination, {
|
|
5775
|
+
page,
|
|
5776
|
+
pageCount,
|
|
5777
|
+
onPageChange: (next) => handlePageChange && void handlePageChange(next),
|
|
5778
|
+
pageSize,
|
|
5779
|
+
pageSizeOptions: [
|
|
5780
|
+
10,
|
|
5781
|
+
25,
|
|
5782
|
+
50
|
|
5783
|
+
],
|
|
5784
|
+
onPageSizeChange: (next) => handlePerPageChange && void handlePerPageChange(next)
|
|
5785
|
+
})
|
|
5786
|
+
}) : null,
|
|
5787
|
+
/* @__PURE__ */ jsxs(ConfirmDialog, {
|
|
5788
|
+
open: Boolean(confirm),
|
|
5789
|
+
title: confirm && confirm.names.length === 1 ? `Delete ${confirm.names[0]}?` : `Delete ${confirm?.names.length ?? 0} files?`,
|
|
5790
|
+
cancelLabel: "Cancel",
|
|
5791
|
+
confirmLabel: "Delete",
|
|
5792
|
+
confirmVariant: "danger",
|
|
5793
|
+
onCancel: () => setConfirm(null),
|
|
5794
|
+
onConfirm: () => void runDelete(),
|
|
5795
|
+
children: [confirm?.error ? /* @__PURE__ */ jsx("p", { children: confirm.error }) : null, confirmInUseUnavailable ? "The in-use check is unavailable right now. Deleting may leave a broken picture on a live page." : confirmInUse ? "This cannot be undone. At least one selected file appears on a published document or live global. Deleting it leaves a broken picture." : "This cannot be undone."]
|
|
5796
|
+
})
|
|
5797
|
+
]
|
|
5798
|
+
})
|
|
5799
|
+
})] });
|
|
5800
|
+
}
|
|
5801
|
+
function columnLabel(key) {
|
|
5802
|
+
switch (key) {
|
|
5803
|
+
case "filename": return "File name";
|
|
5804
|
+
case "alt": return "Alt text";
|
|
5805
|
+
case "inUse": return "In Use";
|
|
5806
|
+
case "updatedAt": return "Updated at";
|
|
5807
|
+
case "createdAt": return "Created at";
|
|
5808
|
+
case "filesize": return "File size";
|
|
5809
|
+
case "dimensions": return "Dimensions";
|
|
5810
|
+
}
|
|
5811
|
+
}
|
|
5812
|
+
function sortable(key) {
|
|
5813
|
+
return key === "filename" || key === "alt" || key === "updatedAt" || key === "createdAt";
|
|
5814
|
+
}
|
|
5815
|
+
function nextSort(current, key) {
|
|
5816
|
+
if (current === key) return `-${key}`;
|
|
5817
|
+
return key;
|
|
5818
|
+
}
|
|
5819
|
+
function sortDir(current, key) {
|
|
5820
|
+
if (current === key) return "asc";
|
|
5821
|
+
if (current === `-${key}`) return "desc";
|
|
5822
|
+
return null;
|
|
5823
|
+
}
|
|
5824
|
+
function pinTrackWidth(cell, innerSelector) {
|
|
5825
|
+
const inner = cell.querySelector(innerSelector);
|
|
5826
|
+
const styles = getComputedStyle(cell);
|
|
5827
|
+
const pad = (Number.parseFloat(styles.paddingLeft) || 0) + (Number.parseFloat(styles.paddingRight) || 0);
|
|
5828
|
+
return (inner ? inner.scrollWidth : Math.max(0, cell.scrollWidth - pad)) + pad;
|
|
5829
|
+
}
|
|
5830
|
+
function gridColumns(shown) {
|
|
5831
|
+
return [
|
|
5832
|
+
CHECK_COL,
|
|
5833
|
+
...shown.map((key) => key === "filename" ? FILE_COL : key === "inUse" ? "72px" : key === "updatedAt" || key === "createdAt" ? "148px" : "minmax(120px,1fr)"),
|
|
5834
|
+
ACTIONS_COL
|
|
5835
|
+
].join(" ");
|
|
5836
|
+
}
|
|
5837
|
+
function chipsFrom(applied) {
|
|
5838
|
+
const chips = [];
|
|
5839
|
+
if (applied.alt === "has") chips.push({
|
|
5840
|
+
key: "alt",
|
|
5841
|
+
label: "Has alt text"
|
|
5842
|
+
});
|
|
5843
|
+
if (applied.alt === "missing") chips.push({
|
|
5844
|
+
key: "alt",
|
|
5845
|
+
label: "Missing alt text"
|
|
5846
|
+
});
|
|
5847
|
+
if (applied.date === "today") chips.push({
|
|
5848
|
+
key: "date",
|
|
5849
|
+
label: "Today"
|
|
5850
|
+
});
|
|
5851
|
+
if (applied.date === "week") chips.push({
|
|
5852
|
+
key: "date",
|
|
5853
|
+
label: "Past 7 days"
|
|
5854
|
+
});
|
|
5855
|
+
if (applied.date === "month") chips.push({
|
|
5856
|
+
key: "date",
|
|
5857
|
+
label: "Past 30 days"
|
|
5858
|
+
});
|
|
5859
|
+
if (applied.advValue.trim()) chips.push({
|
|
5860
|
+
key: "adv",
|
|
5861
|
+
label: `Advanced: ${applied.advValue.trim()}`
|
|
5862
|
+
});
|
|
5863
|
+
return chips;
|
|
5864
|
+
}
|
|
5865
|
+
function formatWhen(value) {
|
|
5866
|
+
if (!value) return "—";
|
|
5867
|
+
const date = new Date(value);
|
|
5868
|
+
if (Number.isNaN(date.getTime())) return value;
|
|
5869
|
+
const month = String(date.getMonth() + 1).padStart(2, "0");
|
|
5870
|
+
const day = String(date.getDate()).padStart(2, "0");
|
|
5871
|
+
const year = String(date.getFullYear()).slice(-2);
|
|
5872
|
+
const minute = String(date.getMinutes()).padStart(2, "0");
|
|
5873
|
+
let hour = date.getHours();
|
|
5874
|
+
const meridiem = hour >= 12 ? "PM" : "AM";
|
|
5875
|
+
hour = hour % 12 || 12;
|
|
5876
|
+
return `${month}/${day}/${year} ${String(hour).padStart(2, "0")}:${minute} ${meridiem}`;
|
|
5877
|
+
}
|
|
5878
|
+
function InUseMark() {
|
|
5879
|
+
return /* @__PURE__ */ jsx("svg", {
|
|
5880
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
5881
|
+
width: "16",
|
|
5882
|
+
height: "16",
|
|
5883
|
+
viewBox: "0 0 24 24",
|
|
5884
|
+
fill: "none",
|
|
5885
|
+
stroke: "currentColor",
|
|
5886
|
+
strokeWidth: "2.2",
|
|
5887
|
+
strokeLinecap: "round",
|
|
5888
|
+
strokeLinejoin: "round",
|
|
5889
|
+
"aria-hidden": true,
|
|
5890
|
+
children: /* @__PURE__ */ jsx("path", { d: "M20 6 9 17l-5-5" })
|
|
5891
|
+
});
|
|
5892
|
+
}
|
|
5893
|
+
function SearchMark() {
|
|
5894
|
+
return /* @__PURE__ */ jsxs("svg", {
|
|
5895
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
5896
|
+
width: "20",
|
|
5897
|
+
height: "20",
|
|
5898
|
+
viewBox: "0 0 24 24",
|
|
5899
|
+
fill: "none",
|
|
5900
|
+
stroke: "currentColor",
|
|
5901
|
+
strokeWidth: "2",
|
|
5902
|
+
strokeLinecap: "round",
|
|
5903
|
+
strokeLinejoin: "round",
|
|
5904
|
+
"aria-hidden": true,
|
|
5905
|
+
children: [/* @__PURE__ */ jsx("circle", {
|
|
5906
|
+
cx: "11",
|
|
5907
|
+
cy: "11",
|
|
5908
|
+
r: "7"
|
|
5909
|
+
}), /* @__PURE__ */ jsx("path", { d: "m20 20-3.5-3.5" })]
|
|
5910
|
+
});
|
|
5911
|
+
}
|
|
5912
|
+
function SortChevrons({ dir }) {
|
|
5913
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
5914
|
+
className: "bl-media-list__sort-mark",
|
|
5915
|
+
"data-dir": dir ?? "none",
|
|
5916
|
+
children: [/* @__PURE__ */ jsx("svg", {
|
|
5917
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
5918
|
+
viewBox: "0 0 24 24",
|
|
5919
|
+
"aria-hidden": true,
|
|
5920
|
+
children: /* @__PURE__ */ jsx("path", { d: "m6 15 6-6 6 6" })
|
|
5921
|
+
}), /* @__PURE__ */ jsx("svg", {
|
|
5922
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
5923
|
+
viewBox: "0 0 24 24",
|
|
5924
|
+
"aria-hidden": true,
|
|
5925
|
+
children: /* @__PURE__ */ jsx("path", { d: "m6 9 6 6 6-6" })
|
|
5926
|
+
})]
|
|
5927
|
+
});
|
|
5928
|
+
}
|
|
5929
|
+
function ColumnsMark() {
|
|
5930
|
+
return /* @__PURE__ */ jsxs("svg", {
|
|
5931
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
5932
|
+
width: "16",
|
|
5933
|
+
height: "16",
|
|
5934
|
+
viewBox: "0 0 24 24",
|
|
5935
|
+
fill: "none",
|
|
5936
|
+
stroke: "currentColor",
|
|
5937
|
+
strokeWidth: "1.8",
|
|
5938
|
+
strokeLinecap: "round",
|
|
5939
|
+
strokeLinejoin: "round",
|
|
5940
|
+
"aria-hidden": true,
|
|
5941
|
+
children: [/* @__PURE__ */ jsx("rect", {
|
|
5942
|
+
x: "3",
|
|
5943
|
+
y: "4",
|
|
5944
|
+
width: "18",
|
|
5945
|
+
height: "16",
|
|
5946
|
+
rx: "2"
|
|
5947
|
+
}), /* @__PURE__ */ jsx("path", { d: "M9 4v16M15 4v16" })]
|
|
5948
|
+
});
|
|
5949
|
+
}
|
|
5950
|
+
function FiltersMark() {
|
|
5951
|
+
return /* @__PURE__ */ jsx("svg", {
|
|
5952
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
5953
|
+
width: "16",
|
|
5954
|
+
height: "16",
|
|
5955
|
+
viewBox: "0 0 24 24",
|
|
5956
|
+
fill: "none",
|
|
5957
|
+
stroke: "currentColor",
|
|
5958
|
+
strokeWidth: "1.8",
|
|
5959
|
+
strokeLinecap: "round",
|
|
5960
|
+
strokeLinejoin: "round",
|
|
5961
|
+
"aria-hidden": true,
|
|
5962
|
+
children: /* @__PURE__ */ jsx("path", { d: "M4 6h16M7 12h10M10 18h4" })
|
|
5963
|
+
});
|
|
5964
|
+
}
|
|
5965
|
+
function ChevronMark() {
|
|
5966
|
+
return /* @__PURE__ */ jsx("svg", {
|
|
5967
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
5968
|
+
width: "12",
|
|
5969
|
+
height: "12",
|
|
5970
|
+
viewBox: "0 0 24 24",
|
|
5971
|
+
fill: "none",
|
|
5972
|
+
stroke: "currentColor",
|
|
5973
|
+
strokeWidth: "2",
|
|
5974
|
+
strokeLinecap: "round",
|
|
5975
|
+
strokeLinejoin: "round",
|
|
5976
|
+
"aria-hidden": true,
|
|
5977
|
+
children: /* @__PURE__ */ jsx("path", { d: "m6 9 6 6 6-6" })
|
|
5978
|
+
});
|
|
5979
|
+
}
|
|
5980
|
+
//#endregion
|
|
5981
|
+
export { AdminNav, AdminNavEntityField, AdminNavItemRowLabel, AdminNavRowLabel, AppearanceField, ColorField, ColorScaleField, ContrastReport, DocumentCreateNew, DocumentTitleActions, FeaturesMatrixField, FontField, GreyScaleField, HiddenSaveButton, IdentityFallback, LibraryField, LookField, MediaAltAutofill, MediaListView, PageTitleCell, PairingField, PublishChild, QuestionsList, RoleNameField, RoleSlugField, RolesField, RolesGrantsField, RolesMatrixField, RolesRowLabel, SectionHeading, SlugField, ThemeDocumentControls, ThemeSaveButton, setThemePreviewMode };
|
|
4897
5982
|
|
|
4898
5983
|
//# sourceMappingURL=admin.mjs.map
|