sanity-plugin-media 6.5.0 → 6.6.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/README.md CHANGED
@@ -226,6 +226,9 @@ When `locales` are provided, all localized fields (title, altText, description,
226
226
 
227
227
  This will return the Italian value if present, otherwise English, otherwise French, etc. Adjust the order as needed for your project.
228
228
 
229
+ **Sorting by title:**
230
+ When `locales` are configured, "Title: A to Z" / "Title: Z to A" in the sort dropdown sort by the first available translation, checked in the order your `locales` array is declared — the same fallback pattern shown above. Assets missing a title in every configured locale sort as empty.
231
+
229
232
  #### Migrating existing assets to localized format
230
233
 
231
234
  If you enable `locales` on a project that already has assets with plain string fields (e.g. `title: "My photo"`), you should run the provided migration script to convert those fields to the localized object format (e.g. `title: {en: "My photo"}`).
package/dist/index.d.ts CHANGED
@@ -29,88 +29,32 @@ type DetailsProps = {
29
29
  declare const tagOptionSchema: z.ZodObject<{
30
30
  label: z.ZodString;
31
31
  value: z.ZodString;
32
- }, "strip", z.ZodTypeAny, {
33
- label: string;
34
- value: string;
35
- }, {
36
- label: string;
37
- value: string;
38
- }>;
32
+ }, z.core.$strip>;
39
33
  declare function getAssetFormSchema(locales?: {
40
34
  id: string;
41
35
  }[]): z.ZodObject<{
42
- altText: z.ZodObject<Record<string, z.ZodTypeAny>, "passthrough", z.ZodTypeAny, z.objectOutputType<Record<string, z.ZodTypeAny>, z.ZodTypeAny, "passthrough">, z.objectInputType<Record<string, z.ZodTypeAny>, z.ZodTypeAny, "passthrough">> | z.ZodOptional<z.ZodString>;
43
- creditLine: z.ZodObject<Record<string, z.ZodTypeAny>, "passthrough", z.ZodTypeAny, z.objectOutputType<Record<string, z.ZodTypeAny>, z.ZodTypeAny, "passthrough">, z.objectInputType<Record<string, z.ZodTypeAny>, z.ZodTypeAny, "passthrough">> | z.ZodOptional<z.ZodString>;
44
- description: z.ZodObject<Record<string, z.ZodTypeAny>, "passthrough", z.ZodTypeAny, z.objectOutputType<Record<string, z.ZodTypeAny>, z.ZodTypeAny, "passthrough">, z.objectInputType<Record<string, z.ZodTypeAny>, z.ZodTypeAny, "passthrough">> | z.ZodOptional<z.ZodString>;
36
+ altText: z.ZodObject<{
37
+ [x: string]: z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
38
+ }, z.core.$loose> | z.ZodOptional<z.ZodString>;
39
+ creditLine: z.ZodObject<{
40
+ [x: string]: z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
41
+ }, z.core.$loose> | z.ZodOptional<z.ZodString>;
42
+ description: z.ZodObject<{
43
+ [x: string]: z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
44
+ }, z.core.$loose> | z.ZodOptional<z.ZodString>;
45
45
  opt: z.ZodObject<{
46
46
  media: z.ZodObject<{
47
47
  tags: z.ZodNullable<z.ZodArray<z.ZodObject<{
48
48
  label: z.ZodString;
49
49
  value: z.ZodString;
50
- }, "strip", z.ZodTypeAny, {
51
- label: string;
52
- value: string;
53
- }, {
54
- label: string;
55
- value: string;
56
- }>, "many">>;
57
- }, "strip", z.ZodTypeAny, {
58
- tags: {
59
- label: string;
60
- value: string;
61
- }[] | null;
62
- }, {
63
- tags: {
64
- label: string;
65
- value: string;
66
- }[] | null;
67
- }>;
68
- }, "strip", z.ZodTypeAny, {
69
- media: {
70
- tags: {
71
- label: string;
72
- value: string;
73
- }[] | null;
74
- };
75
- }, {
76
- media: {
77
- tags: {
78
- label: string;
79
- value: string;
80
- }[] | null;
81
- };
82
- }>;
50
+ }, z.core.$strip>>>;
51
+ }, z.core.$strip>;
52
+ }, z.core.$strip>;
83
53
  originalFilename: z.ZodString;
84
- title: z.ZodObject<Record<string, z.ZodTypeAny>, "passthrough", z.ZodTypeAny, z.objectOutputType<Record<string, z.ZodTypeAny>, z.ZodTypeAny, "passthrough">, z.objectInputType<Record<string, z.ZodTypeAny>, z.ZodTypeAny, "passthrough">> | z.ZodOptional<z.ZodString>;
85
- }, "strip", z.ZodTypeAny, {
86
- altText?: string | z.objectOutputType<Record<string, z.ZodTypeAny>, z.ZodTypeAny, "passthrough"> | undefined;
87
- creditLine?: string | z.objectOutputType<Record<string, z.ZodTypeAny>, z.ZodTypeAny, "passthrough"> | undefined;
88
- description?: string | z.objectOutputType<Record<string, z.ZodTypeAny>, z.ZodTypeAny, "passthrough"> | undefined;
89
- opt: {
90
- media: {
91
- tags: {
92
- label: string;
93
- value: string;
94
- }[] | null;
95
- };
96
- };
97
- originalFilename: string;
98
- title?: string | z.objectOutputType<Record<string, z.ZodTypeAny>, z.ZodTypeAny, "passthrough"> | undefined;
99
- }, {
100
- altText?: string | z.objectInputType<Record<string, z.ZodTypeAny>, z.ZodTypeAny, "passthrough"> | undefined;
101
- creditLine?: string | z.objectInputType<Record<string, z.ZodTypeAny>, z.ZodTypeAny, "passthrough"> | undefined;
102
- description?: string | z.objectInputType<Record<string, z.ZodTypeAny>, z.ZodTypeAny, "passthrough"> | undefined;
103
- opt: {
104
- media: {
105
- tags: {
106
- label: string;
107
- value: string;
108
- }[] | null;
109
- };
110
- };
111
- originalFilename: string;
112
- title?: string | z.objectInputType<Record<string, z.ZodTypeAny>, z.ZodTypeAny, "passthrough"> | undefined;
113
- }>;
54
+ title: z.ZodObject<{
55
+ [x: string]: z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
56
+ }, z.core.$loose> | z.ZodOptional<z.ZodString>;
57
+ }, z.core.$strip>;
114
58
  type MediaTagsOptions = {
115
59
  mediaTags?: string[];
116
60
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/components/FormBuilderTool/index.tsx","../src/components/DialogAssetEdit/Details.tsx","../src/formSchema/index.ts","../src/types/index.ts","../src/plugin.tsx","../src/components/AutoTagInputWrapper/index.tsx","../src/utils/mediaField.ts"],"mappings":";;;;;;;;cAQM,kBAAe,OAAW,8CAAyB,IAAA;KCsB7C;EACV;EACA,kBAAkB;EAClB,SAAS,QAAQ;EACjB,QAAQ,YAAY;EACpB,UAAU,gBAAgB;EAC1B,eAAe;EACf,iBAAiB;EACjB,cAAc;EACd;EACA;EACA;EACA;EACA;IACE;IACA;;EAEF,UAAU;;cCjCC,iBAAe,EAAA;;;;;;;;;;iBAKZ,mBAAmB;EAAW;MAAa,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KCJ/C;EACV;;KAGU;EACV;EACA;EACA;IACE,UAAU,cACR;MAAgB,uBAAuB,OAAO,iBAAiB,IAAI;;;EAGvE;IACE;IACA;;EAEF;;;;;;;EAOA;;;;;EAKA,UAAU;;;;;;;;;EASV;;KAGU;EACV;EACA;GACC;;KAGE,2BAA2B;KAE3B;EACH,UAAU;EACV,cAAc;EACd;IACE;MACE,SAAS;MACT,OAAO;;;EAGX,QAAQ;;KAYE,QAAQ,YAAY;KAEpB,gBAAgB,EAAE,MAAM,kBAAkB;KAgJ1C,YAAY,sBACtB;EACE;;KAuBQ,aAAa,2BACvB;EACE;EACA,aAAa;;KAqBL;EACV;EACA;EACA;;KA0IU,kBAAkB,EAAE,aAAa;qBClZhC;;;;;;qBAmBA,wBAAK,cAAA;KCrBN,oBAAoB;EAC9B;;;;;;;;;;;;;;;;;;;;;wBAsBc,aAAa,OAAO,oCAAiB,IAAA;KC7BhD,wBAAwB,KAAK,8BAChC;EACE;EACA;EACA,UAAU;;KAGT,uBAAuB,KAAK,6BAC/B;EACE;EACA;EACA,UAAU;;KAGT,wBAAwB,KAAK,8BAChC;EACE,UAAU;IAA8B;;EACxC;IAAa,cAAc;;IACzB,kBACJ;KAEG,uBAAuB,KAAK,6BAC/B;EACE,UAAU;IAA6B;;EACvC;IAAa,cAAc;;IACzB,kBACJ;;;;;;;;;;;;;;;;;;;;;;wBAuBc,WAAW,QAAQ,wBAAwB;wBAC3C,WAAW,QAAQ,uBAAuB"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/components/FormBuilderTool/index.tsx","../src/components/DialogAssetEdit/Details.tsx","../src/formSchema/index.ts","../src/types/index.ts","../src/plugin.tsx","../src/components/AutoTagInputWrapper/index.tsx","../src/utils/mediaField.ts"],"mappings":";;;;;;;;cAQM,kBAAe,OAAW,8CAAyB,IAAA;KCsB7C;EACV;EACA,kBAAkB;EAClB,SAAS,QAAQ;EACjB,QAAQ,YAAY;EACpB,UAAU,gBAAgB;EAC1B,eAAe;EACf,iBAAiB;EACjB,cAAc;EACd;EACA;EACA;EACA;EACA;IACE;IACA;;EAEF,UAAU;;cCjCC,iBAAe,EAAA;;;GAG1B,EAAA,KAAA;iBAEc,mBAAmB;EAAW;MAAa,EAAA;;;;;;;;;;;;;;;;;;;;;;GAa1D,EAAA,KAAA;KCjBW;EACV;;KAGU;EACV;EACA;EACA;IACE,UAAU,cACR;MAAgB,uBAAuB,OAAO,iBAAiB,IAAI;;;EAGvE;IACE;IACA;;EAEF;;;;;;;EAOA;;;;;EAKA,UAAU;;;;;;;;;EASV;;KAGU;EACV;EACA;GACC;;KAGE,2BAA2B;KAE3B;EACH,UAAU;EACV,cAAc;EACd;IACE;MACE,SAAS;MACT,OAAO;;;EAGX,QAAQ;;KAYE,QAAQ,YAAY;KAEpB,gBAAgB,EAAE,MAAM,kBAAkB;KAgJ1C,YAAY,sBACtB;EACE;;KAuBQ,aAAa,2BACvB;EACE;EACA,aAAa;;KAqBL;EACV;EACA;EACA;;KA0IU,kBAAkB,EAAE,aAAa;qBClZhC;;;;;;qBAmBA,wBAAK,cAAA;KCrBN,oBAAoB;EAC9B;;;;;;;;;;;;;;;;;;;;;wBAsBc,aAAa,OAAO,oCAAiB,IAAA;KC7BhD,wBAAwB,KAAK,8BAChC;EACE;EACA;EACA,UAAU;;KAGT,uBAAuB,KAAK,6BAC/B;EACE;EACA;EACA,UAAU;;KAGT,wBAAwB,KAAK,8BAChC;EACE,UAAU;IAA8B;;EACxC;IAAa,cAAc;;IACzB,kBACJ;KAEG,uBAAuB,KAAK,6BAC/B;EACE,UAAU;IAA6B;;EACvC;IAAa,cAAc;;IACzB,kBACJ;;;;;;;;;;;;;;;;;;;;;;wBAuBc,WAAW,QAAQ,wBAAwB;wBAC3C,WAAW,QAAQ,uBAAuB"}
package/dist/index.js CHANGED
@@ -16,9 +16,9 @@ import { bufferTime, catchError, concatMap, debounceTime, delay, filter, first,
16
16
  import { uuid } from "@sanity/uuid";
17
17
  import pluralize from "pluralize";
18
18
  import { createGlobalStyle, css, styled } from "styled-components";
19
+ import { zodResolver } from "@hookform/resolvers/zod";
19
20
  import { Controller, useForm, useFormState } from "react-hook-form";
20
21
  import * as z from "zod";
21
- import { zodResolver } from "@hookform/resolvers/zod";
22
22
  import { DownloadIcon } from "@sanity/icons/Download";
23
23
  import { format } from "date-fns/format";
24
24
  import filesize from "filesize";
@@ -86,7 +86,7 @@ function _temp$38() {
86
86
  const useTypedSelector = useSelector, useVersionedClient = () => {
87
87
  let $ = c(1), t0;
88
88
  return $[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = { apiVersion: "2025-10-02" }, $[0] = t0) : t0 = $[0], useClient(t0);
89
- }, ORDER_DICTIONARY = {
89
+ }, LOCALIZED_ORDER_FIELDS = /* @__PURE__ */ new Set(["title"]), ORDER_DICTIONARY = {
90
90
  _createdAt: {
91
91
  asc: "Last created: Oldest first",
92
92
  desc: "Last created: Newest first"
@@ -103,11 +103,23 @@ const useTypedSelector = useSelector, useVersionedClient = () => {
103
103
  asc: "File name: A to Z",
104
104
  desc: "File name: Z to A"
105
105
  },
106
+ title: {
107
+ asc: "Title: A to Z",
108
+ desc: "Title: Z to A"
109
+ },
106
110
  size: {
107
111
  asc: "File size: Smallest first",
108
112
  desc: "File size: Largest first"
109
113
  }
110
- }, getOrderTitle = (field, direction) => ORDER_DICTIONARY[field][direction], divider = { type: "divider" }, inputs = {
114
+ }, getOrderTitle = (field, direction) => ORDER_DICTIONARY[field][direction], getOrderField = (field, localeIds) => {
115
+ if (localeIds.length === 0 || !LOCALIZED_ORDER_FIELDS.has(field)) return field;
116
+ let localizedFieldAccessors = localeIds.map((localeId) => groq`${field}[${JSON.stringify(localeId)}]`);
117
+ return groq`coalesce(${localizedFieldAccessors.join(", ")})`;
118
+ }, getOrderValue = (value, field, localeIds) => {
119
+ if (localeIds.length === 0 || !LOCALIZED_ORDER_FIELDS.has(field) || typeof value != "object" || !value) return value;
120
+ let localizedValues = value;
121
+ return localeIds.map((localeId) => localizedValues[localeId]).find((v) => v != null);
122
+ }, divider = { type: "divider" }, inputs = {
111
123
  altText: {
112
124
  assetTypes: ["file", "image"],
113
125
  field: "altText",
@@ -472,6 +484,15 @@ const operators = {
472
484
  field: "originalFilename"
473
485
  },
474
486
  null,
487
+ {
488
+ direction: "asc",
489
+ field: "title"
490
+ },
491
+ {
492
+ direction: "desc",
493
+ field: "title"
494
+ },
495
+ null,
475
496
  {
476
497
  direction: "desc",
477
498
  field: "size"
@@ -509,10 +530,38 @@ const operators = {
509
530
  message: "Test error",
510
531
  statusCode: 500
511
532
  })) : of(v))), source);
533
+ }, LOCALIZED_TEXT_FIELDS = /* @__PURE__ */ new Set([
534
+ "altText",
535
+ "creditLine",
536
+ "description",
537
+ "title"
538
+ ]), TEXT_SEARCH_FIELDS = [
539
+ "_id",
540
+ "altText",
541
+ "assetId",
542
+ "creditLine",
543
+ "description",
544
+ "originalFilename",
545
+ "title",
546
+ "url"
547
+ ], groqString = (value) => JSON.stringify(value), localizedFieldPaths = (field, localeIds) => {
548
+ if (!localeIds?.length || !LOCALIZED_TEXT_FIELDS.has(field)) return [];
549
+ let seen = /* @__PURE__ */ new Set(), paths = [];
550
+ for (let localeId of localeIds) localeId && !seen.has(localeId) && (seen.add(localeId), paths.push(`${field}[${groqString(localeId)}]`));
551
+ return paths;
552
+ }, textSearchFieldList = (localeIds) => TEXT_SEARCH_FIELDS.flatMap((field) => [field, ...localizedFieldPaths(field, localeIds)]).join(", "), localizedFieldPresent = (field, paths) => `((string(${field}) == ${field} && defined(${field})) || ${paths.map((path) => `defined(${path})`).join(" || ")})`, stringFacetFragment = (field, operatorType, value, localeIds) => {
553
+ let paths = localizedFieldPaths(field, localeIds);
554
+ if (paths.length === 0) return operators[operatorType].fn(value, field);
555
+ if (operatorType === "includes" || operatorType === "doesNotInclude") return operators[operatorType].fn(value, `[${field}, ${paths.join(", ")}]`);
556
+ if (operatorType === "empty" || operatorType === "notEmpty") {
557
+ let present = localizedFieldPresent(field, paths);
558
+ return operatorType === "empty" ? `!(${present})` : present;
559
+ }
560
+ return operators[operatorType].fn(value, field);
512
561
  }, buildExcludeTagsFragment = (excludeTagSlugs) => {
513
562
  let serializedExcludeTagSlugs = excludeTagSlugs?.length ? JSON.stringify(excludeTagSlugs) : void 0;
514
563
  return serializedExcludeTagSlugs ? groq`!(defined(opt.media.tags) && count(opt.media.tags[@._ref in *[_type == "${TAG_DOCUMENT_NAME}" && name.current in ${serializedExcludeTagSlugs}]._id]) > 0)` : void 0;
515
- }, buildExcludeMediaLibraryFragment = (showMediaLibraryAssets) => showMediaLibraryAssets ? void 0 : groq`(!defined(source.name) || source.name != "${"sanity-media-library"}") && (!defined(media._ref) || !string::startsWith(media._ref, "${"media-library:"}"))`, constructFilter = ({ assetTypes, currentFolderId, excludeTagSlugs, searchFacets, searchQuery, showMediaLibraryAssets = !0 }) => {
564
+ }, buildExcludeMediaLibraryFragment = (showMediaLibraryAssets) => showMediaLibraryAssets ? void 0 : groq`(!defined(source.name) || source.name != "${"sanity-media-library"}") && (!defined(media._ref) || !string::startsWith(media._ref, "${"media-library:"}"))`, constructFilter = ({ assetTypes, currentFolderId, excludeTagSlugs, localeIds, searchFacets, searchQuery, showMediaLibraryAssets = !0 }) => {
516
565
  let documentAssetTypes = assetTypes.map((type) => `sanity.${type}Asset`), baseFilter = groq`
517
566
  _type in ${JSON.stringify(documentAssetTypes)} && !(_id in path("drafts.**"))
518
567
  `, excludeTagsFragment = buildExcludeTagsFragment(excludeTagSlugs), excludeMediaLibraryFragment = buildExcludeMediaLibraryFragment(showMediaLibraryAssets), searchFacetFragments = searchFacets.reduce((acc, facet) => {
@@ -529,7 +578,7 @@ const operators = {
529
578
  fragment && acc.push(fragment);
530
579
  }
531
580
  if (facet.type === "string") {
532
- let { field, operatorType, value } = facet, fragment = operators[operatorType].fn(value, field);
581
+ let { field, operatorType, value } = facet, fragment = stringFacetFragment(field, operatorType, value, localeIds);
533
582
  fragment && acc.push(fragment);
534
583
  }
535
584
  return acc;
@@ -538,7 +587,7 @@ const operators = {
538
587
  baseFilter,
539
588
  ...excludeMediaLibraryFragment ? [excludeMediaLibraryFragment] : [],
540
589
  ...excludeTagsFragment ? [excludeTagsFragment] : [],
541
- ...searchQuery ? [groq`[_id, altText, assetId, creditLine, description, originalFilename, title, url] match ${groqWildcardMatch(searchQuery.trim())}`] : [],
590
+ ...searchQuery ? [groq`[${textSearchFieldList(localeIds)}] match ${groqWildcardMatch(searchQuery.trim())}`] : [],
542
591
  ...folderFilter ? [folderFilter] : [],
543
592
  ...searchFacetFragments
544
593
  ].join(" && ");
@@ -919,6 +968,7 @@ const UPLOADS_ACTIONS = { uploadComplete: createAction("uploads/uploadComplete",
919
968
  fetching: !1,
920
969
  fetchingError: void 0,
921
970
  lastPicked: void 0,
971
+ localeIds: [],
922
972
  order: {
923
973
  direction: defaultOrder.direction,
924
974
  field: defaultOrder.field,
@@ -1137,7 +1187,7 @@ const UPLOADS_ACTIONS = { uploadComplete: createAction("uploads/uploadComplete",
1137
1187
  },
1138
1188
  sort(state) {
1139
1189
  state.allIds.sort((a, b) => {
1140
- let tagA = state.byIds[a].asset[state.order.field], tagB = state.byIds[b].asset[state.order.field];
1190
+ let { field } = state.order, tagA = getOrderValue(state.byIds[a].asset[field], field, state.localeIds), tagB = getOrderValue(state.byIds[b].asset[field], field, state.localeIds);
1141
1191
  return tagA < tagB ? state.order.direction === "asc" ? -1 : 1 : tagA > tagB ? state.order.direction === "asc" ? 1 : -1 : 0;
1142
1192
  });
1143
1193
  },
@@ -1185,6 +1235,7 @@ const UPLOADS_ACTIONS = { uploadComplete: createAction("uploads/uploadComplete",
1185
1235
  assetTypes: state.assets.assetTypes,
1186
1236
  currentFolderId: state.folders.currentFolderId,
1187
1237
  excludeTagSlugs: state.assets.excludeTagSlugs,
1238
+ localeIds: state.assets.localeIds,
1188
1239
  searchFacets: state.search.facets,
1189
1240
  searchQuery: state.search.query,
1190
1241
  showMediaLibraryAssets: state.assets.showMediaLibraryAssets
@@ -1196,7 +1247,7 @@ const UPLOADS_ACTIONS = { uploadComplete: createAction("uploads/uploadComplete",
1196
1247
  params,
1197
1248
  queryFilter: constructedFilter,
1198
1249
  selector: groq`[${start}...${end}]`,
1199
- sort: groq`order(${state.assets?.order?.field} ${state.assets?.order?.direction})`
1250
+ sort: groq`order(${getOrderField(state.assets.order.field, state.assets.localeIds)} ${state.assets.order.direction})`
1200
1251
  }));
1201
1252
  })), assetsFetchNextPageEpic = (action$, state$) => action$.pipe(filter(assetsActions.loadNextPage.match), withLatestFrom(state$), switchMap(([_action, state]) => of(assetsActions.loadPageIndex({ pageIndex: state.assets.pageIndex + 1 })))), assetsFetchAfterDeleteAllEpic = (action$, state$) => action$.pipe(filter(assetsActions.deleteComplete.match), withLatestFrom(state$), switchMap(([_action, state]) => {
1202
1253
  if (state.assets.allIds.length === 0) {
@@ -1834,11 +1885,11 @@ function localizedStringSchema(locales) {
1834
1885
  if (!locales || locales.length === 0) return z.string().trim().optional();
1835
1886
  let shape = {};
1836
1887
  for (let locale of locales) shape[locale.id] = z.string().trim().optional();
1837
- return z.object(shape).passthrough();
1888
+ return z.object(shape).loose();
1838
1889
  }
1839
1890
  const tagOptionSchema = z.object({
1840
- label: z.string().trim().min(1, { message: "Label cannot be empty" }),
1841
- value: z.string().trim().min(1, { message: "Value cannot be empty" })
1891
+ label: z.string().trim().min(1, { error: "Label cannot be empty" }),
1892
+ value: z.string().trim().min(1, { error: "Value cannot be empty" })
1842
1893
  });
1843
1894
  function getAssetFormSchema(locales) {
1844
1895
  return z.object({
@@ -1846,12 +1897,12 @@ function getAssetFormSchema(locales) {
1846
1897
  creditLine: localizedStringSchema(locales),
1847
1898
  description: localizedStringSchema(locales),
1848
1899
  opt: z.object({ media: z.object({ tags: z.array(tagOptionSchema).nullable() }) }),
1849
- originalFilename: z.string().trim().min(1, { message: "Filename cannot be empty" }),
1900
+ originalFilename: z.string().trim().min(1, { error: "Filename cannot be empty" }),
1850
1901
  title: localizedStringSchema(locales)
1851
1902
  });
1852
1903
  }
1853
1904
  getAssetFormSchema();
1854
- const tagFormSchema = z.object({ name: z.string().min(1, { message: "Name cannot be empty" }) }), folderFormSchema = z.object({ name: z.string().trim().min(1, { message: "Name cannot be empty" }) });
1905
+ const tagFormSchema = z.object({ name: z.string().min(1, { error: "Name cannot be empty" }) }), folderFormSchema = z.object({ name: z.string().trim().min(1, { error: "Name cannot be empty" }) });
1855
1906
  function getUniqueDocuments(documents) {
1856
1907
  let draftIds = documents.reduce((acc, doc) => doc._id.startsWith("drafts.") ? acc.concat(doc._id.slice(7)) : acc, []);
1857
1908
  return documents.filter((doc) => !draftIds.includes(doc._id));
@@ -1862,18 +1913,7 @@ const imageDprUrl = (asset, options) => {
1862
1913
  }, sanitizeFormData = (formData) => Object.keys(formData).reduce((acc, key) => {
1863
1914
  let val = formData[key];
1864
1915
  return acc[key] = typeof val == "object" && val && val.constructor !== Array ? sanitizeFormData(val) : val === "" || val === void 0 || val?.length === 0 ? null : typeof val == "string" && val ? formData[key].trim() : formData[key], acc;
1865
- }, {}), isFileAsset = (asset) => asset._type === "sanity.fileAsset", isImageAsset = (asset) => asset._type === "sanity.imageAsset";
1866
- /**
1867
- * `@hookform/resolvers/zod` resolves its own `zod` typings through dependency
1868
- * hoisting, which in this monorepo lands on zod v4, while this plugin authors its
1869
- * form schemas with zod v3. The resolver accepts v3 schema instances correctly at
1870
- * runtime, so this thin wrapper only bridges the type-only v3/v4 mismatch. The
1871
- * react-hook-form field types stay fully checked at the call sites.
1872
- */
1873
- function zodFormResolver(schema) {
1874
- return zodResolver(schema);
1875
- }
1876
- const getAssetResolution = (asset) => `${asset.metadata.dimensions.width}x${asset.metadata.dimensions.height}px`;
1916
+ }, {}), isFileAsset = (asset) => asset._type === "sanity.fileAsset", isImageAsset = (asset) => asset._type === "sanity.imageAsset", getAssetResolution = (asset) => `${asset.metadata.dimensions.width}x${asset.metadata.dimensions.height}px`;
1877
1917
  function usePortalPopoverProps() {
1878
1918
  let $ = c(2), portal = usePortal(), t0;
1879
1919
  return $[0] === portal.element ? t0 = $[1] : (t0 = {
@@ -2850,7 +2890,7 @@ const DialogAssetEdit = (props) => {
2850
2890
  let generateDefaultValues = t7, t8 = assetItem?.asset, t9;
2851
2891
  $[13] !== generateDefaultValues || $[14] !== t8 ? (t9 = generateDefaultValues(t8), $[13] = generateDefaultValues, $[14] = t8, $[15] = t9) : t9 = $[15];
2852
2892
  let t10;
2853
- $[16] === locales ? t10 = $[17] : (t10 = zodFormResolver(getAssetFormSchema(locales)), $[16] = locales, $[17] = t10);
2893
+ $[16] === locales ? t10 = $[17] : (t10 = zodResolver(getAssetFormSchema(locales)), $[16] = locales, $[17] = t10);
2854
2894
  let t11;
2855
2895
  $[18] !== t10 || $[19] !== t9 ? (t11 = {
2856
2896
  defaultValues: t9,
@@ -3779,6 +3819,7 @@ const createThrottler = (concurrency = 4) => {
3779
3819
  assetTypes: state.assets.assetTypes,
3780
3820
  currentFolderId: state.folders.currentFolderId,
3781
3821
  excludeTagSlugs: state.assets.excludeTagSlugs,
3822
+ localeIds: state.assets.localeIds,
3782
3823
  searchFacets: state.search.facets,
3783
3824
  searchQuery: state.search.query,
3784
3825
  showMediaLibraryAssets: state.assets.showMediaLibraryAssets
@@ -4246,7 +4287,7 @@ const DialogAllAssets = (props) => {
4246
4287
  $[3] === Symbol.for("react.memo_cache_sentinel") ? (t3 = {
4247
4288
  defaultValues: t2,
4248
4289
  mode: "onChange",
4249
- resolver: zodFormResolver(folderFormSchema)
4290
+ resolver: zodResolver(folderFormSchema)
4250
4291
  }, $[3] = t3) : t3 = $[3];
4251
4292
  let { formState: t4, handleSubmit, register, setError } = useForm(t3), { errors, isDirty, isValid } = t4, t5;
4252
4293
  $[4] === dispatch ? t5 = $[5] : (t5 = () => {
@@ -4506,7 +4547,7 @@ const DialogFolderRename = (t0) => {
4506
4547
  let parentPath = t3, t4;
4507
4548
  $[6] === currentName ? t4 = $[7] : (t4 = { name: currentName }, $[6] = currentName, $[7] = t4);
4508
4549
  let t5;
4509
- $[8] === Symbol.for("react.memo_cache_sentinel") ? (t5 = zodFormResolver(folderFormSchema), $[8] = t5) : t5 = $[8];
4550
+ $[8] === Symbol.for("react.memo_cache_sentinel") ? (t5 = zodResolver(folderFormSchema), $[8] = t5) : t5 = $[8];
4510
4551
  let t6;
4511
4552
  $[9] === t4 ? t6 = $[10] : (t6 = {
4512
4553
  defaultValues: t4,
@@ -5624,7 +5665,7 @@ const DialogSearchFacets = (props) => {
5624
5665
  $[1] === Symbol.for("react.memo_cache_sentinel") ? (t2 = {
5625
5666
  defaultValues: t1,
5626
5667
  mode: "onChange",
5627
- resolver: zodFormResolver(tagFormSchema)
5668
+ resolver: zodResolver(tagFormSchema)
5628
5669
  }, $[1] = t2) : t2 = $[1];
5629
5670
  let { formState: t3, handleSubmit, register, setError } = useForm(t2), { errors, isDirty, isValid } = t3, formUpdating = creating, t4;
5630
5671
  $[2] === dispatch ? t4 = $[3] : (t4 = () => {
@@ -5701,7 +5742,7 @@ const DialogTagEdit = (props) => {
5701
5742
  let tagItem = useTypedSelector(t1), [tagSnapshot, setTagSnapshot] = useState(tagItem?.tag), currentTag = tagItem ? tagItem?.tag : tagSnapshot, generateDefaultValues = _temp$24, t2 = tagItem?.tag, t3;
5702
5743
  $[2] === t2 ? t3 = $[3] : (t3 = generateDefaultValues(t2), $[2] = t2, $[3] = t3);
5703
5744
  let t4;
5704
- $[4] === Symbol.for("react.memo_cache_sentinel") ? (t4 = zodFormResolver(tagFormSchema), $[4] = t4) : t4 = $[4];
5745
+ $[4] === Symbol.for("react.memo_cache_sentinel") ? (t4 = zodResolver(tagFormSchema), $[4] = t4) : t4 = $[4];
5705
5746
  let t5;
5706
5747
  $[5] === t3 ? t5 = $[6] : (t5 = {
5707
5748
  defaultValues: t3,
@@ -6443,6 +6484,7 @@ function createReduxStore(props) {
6443
6484
  ...initialState$1,
6444
6485
  assetTypes: isSupportedAssetType(props?.assetType) ? [props.assetType] : ["file", "image"],
6445
6486
  excludeTagSlugs: props.excludeTagSlugs?.length ? [...props.excludeTagSlugs] : [],
6487
+ localeIds: props.locales?.length ? props.locales.map((locale) => locale.id) : [],
6446
6488
  showMediaLibraryAssets: props.showMediaLibraryAssets ?? !0
6447
6489
  },
6448
6490
  debug: {
@@ -8561,7 +8603,7 @@ const BrowserContent = (t0) => {
8561
8603
  children: t9
8562
8604
  }), $[11] = portalElement, $[12] = t9, $[13] = t10) : t10 = $[13], t10;
8563
8605
  }, Browser = (props) => {
8564
- let $ = c(16), client = useVersionedClient(), { excludeTagSlugs, showMediaLibraryAssets } = useToolOptions(), t0 = props?.assetType, t1 = props?.document, t2 = props?.selectedAssets, t3 = props?.isMultiSelect, t4 = props?.onSelect, t5;
8606
+ let $ = c(17), client = useVersionedClient(), { excludeTagSlugs, locales, showMediaLibraryAssets } = useToolOptions(), t0 = props?.assetType, t1 = props?.document, t2 = props?.selectedAssets, t3 = props?.isMultiSelect, t4 = props?.onSelect, t5;
8565
8607
  $[0] === Symbol.for("react.memo_cache_sentinel") ? (t5 = /* @__PURE__ */ jsx(GlobalStyle, {}), $[0] = t5) : t5 = $[0];
8566
8608
  let t6 = props?.onClose, t7 = props?.schemaType, t8;
8567
8609
  $[1] !== t6 || $[2] !== t7 ? (t8 = /* @__PURE__ */ jsx(BrowserContent, {
@@ -8575,15 +8617,16 @@ const BrowserContent = (t0) => {
8575
8617
  children: [t5, t8]
8576
8618
  }), $[4] = t3, $[5] = t4, $[6] = t8, $[7] = t9) : t9 = $[7];
8577
8619
  let t10;
8578
- return $[8] !== client || $[9] !== excludeTagSlugs || $[10] !== showMediaLibraryAssets || $[11] !== t0 || $[12] !== t1 || $[13] !== t2 || $[14] !== t9 ? (t10 = /* @__PURE__ */ jsx(ReduxProvider, {
8620
+ return $[8] !== client || $[9] !== excludeTagSlugs || $[10] !== locales || $[11] !== showMediaLibraryAssets || $[12] !== t0 || $[13] !== t1 || $[14] !== t2 || $[15] !== t9 ? (t10 = /* @__PURE__ */ jsx(ReduxProvider, {
8579
8621
  assetType: t0,
8580
8622
  client,
8581
8623
  document: t1,
8582
8624
  excludeTagSlugs,
8625
+ locales,
8583
8626
  selectedAssets: t2,
8584
8627
  showMediaLibraryAssets,
8585
8628
  children: t9
8586
- }), $[8] = client, $[9] = excludeTagSlugs, $[10] = showMediaLibraryAssets, $[11] = t0, $[12] = t1, $[13] = t2, $[14] = t9, $[15] = t10) : t10 = $[15], t10;
8629
+ }), $[8] = client, $[9] = excludeTagSlugs, $[10] = locales, $[11] = showMediaLibraryAssets, $[12] = t0, $[13] = t1, $[14] = t2, $[15] = t9, $[16] = t10) : t10 = $[16], t10;
8587
8630
  }, FormBuilderTool = (props) => {
8588
8631
  let $ = c(13), { onClose } = props, portalElement = useRootPortalElement(), t0;
8589
8632
  $[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = [], $[0] = t0) : t0 = $[0];