sanity 3.94.1-next.4.3a875e37ff → 3.94.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/BehaviorSubject-CU-WJrzA.mjs +30 -0
- package/dist/BehaviorSubject-CU-WJrzA.mjs.map +1 -0
- package/dist/BroadcastDisplayedDocument-BSV9T3BU.mjs +20 -0
- package/dist/BroadcastDisplayedDocument-BSV9T3BU.mjs.map +1 -0
- package/dist/DisplayedDocumentBroadcaster-DZ65n35Q.mjs +62 -0
- package/dist/DisplayedDocumentBroadcaster-DZ65n35Q.mjs.map +1 -0
- package/dist/LiveQueries-Crz53eU5.mjs +407 -0
- package/dist/LiveQueries-Crz53eU5.mjs.map +1 -0
- package/dist/Observable-CCQtH8Gg.mjs +546 -0
- package/dist/Observable-CCQtH8Gg.mjs.map +1 -0
- package/dist/PostMessageDocuments-BjgsJxz4.mjs +72 -0
- package/dist/PostMessageDocuments-BjgsJxz4.mjs.map +1 -0
- package/dist/PostMessagePerspective-pucY-E6a.mjs +22 -0
- package/dist/PostMessagePerspective-pucY-E6a.mjs.map +1 -0
- package/dist/PostMessagePreviewSnapshots-CRQgRg4_.mjs +71 -0
- package/dist/PostMessagePreviewSnapshots-CRQgRg4_.mjs.map +1 -0
- package/dist/PostMessageRefreshMutations-D944RbO3.mjs +66 -0
- package/dist/PostMessageRefreshMutations-D944RbO3.mjs.map +1 -0
- package/dist/PostMessageSchema-3eOtr1bs.mjs +516 -0
- package/dist/PostMessageSchema-3eOtr1bs.mjs.map +1 -0
- package/dist/PostMessageTelemetry-DMTQDJeN.mjs +20 -0
- package/dist/PostMessageTelemetry-DMTQDJeN.mjs.map +1 -0
- package/dist/PresentationToolGrantsCheck-B0q4AQ3b.mjs +3999 -0
- package/dist/PresentationToolGrantsCheck-B0q4AQ3b.mjs.map +1 -0
- package/dist/QRCodeSVG-hyTW2xeN.mjs +648 -0
- package/dist/QRCodeSVG-hyTW2xeN.mjs.map +1 -0
- package/dist/Refractor-Zss2QEe8.mjs +2568 -0
- package/dist/Refractor-Zss2QEe8.mjs.map +1 -0
- package/dist/SourceContext-QxJD1Wrm.mjs +111 -0
- package/dist/SourceContext-QxJD1Wrm.mjs.map +1 -0
- package/dist/StructureToolProvider-B-7cwz7l.mjs +2287 -0
- package/dist/StructureToolProvider-B-7cwz7l.mjs.map +1 -0
- package/dist/ViteDevServerStopped-CgIEqy9p.mjs +57 -0
- package/dist/ViteDevServerStopped-CgIEqy9p.mjs.map +1 -0
- package/dist/_createContext.mjs +38 -0
- package/dist/_createContext.mjs.map +1 -0
- package/dist/_singletons.mjs +216 -0
- package/dist/_singletons.mjs.map +1 -0
- package/dist/browser-B0Q9qZJS.mjs +478 -0
- package/dist/browser-B0Q9qZJS.mjs.map +1 -0
- package/dist/browser-DmX5VEcE.mjs +324 -0
- package/dist/browser-DmX5VEcE.mjs.map +1 -0
- package/dist/desk.mjs +53 -0
- package/dist/desk.mjs.map +1 -0
- package/dist/first-Cz545eV-.mjs +42 -0
- package/dist/first-Cz545eV-.mjs.map +1 -0
- package/dist/index-B2GCDfau.mjs +96 -0
- package/dist/index-B2GCDfau.mjs.map +1 -0
- package/dist/index-BRIelBPK.mjs +6946 -0
- package/dist/index-BRIelBPK.mjs.map +1 -0
- package/dist/index-BUB137yJ.mjs +144 -0
- package/dist/index-BUB137yJ.mjs.map +1 -0
- package/dist/index-C3PGPrdL.mjs +1192 -0
- package/dist/index-C3PGPrdL.mjs.map +1 -0
- package/dist/index-C9NvTy6s.mjs +319 -0
- package/dist/index-C9NvTy6s.mjs.map +1 -0
- package/dist/index-DCkQlgdi.mjs +4001 -0
- package/dist/index-DCkQlgdi.mjs.map +1 -0
- package/dist/index-DG-3plB0.mjs +71 -0
- package/dist/index-DG-3plB0.mjs.map +1 -0
- package/dist/index-RoxwhtVB.mjs +5600 -0
- package/dist/index-RoxwhtVB.mjs.map +1 -0
- package/dist/index-iMZR29eF.mjs +756 -0
- package/dist/index-iMZR29eF.mjs.map +1 -0
- package/dist/index-wVXq9rWS.mjs +244 -0
- package/dist/index-wVXq9rWS.mjs.map +1 -0
- package/dist/index.mjs +137385 -0
- package/dist/index.mjs.map +1 -0
- package/dist/lodash-Vz5dH_Dm.mjs +3679 -0
- package/dist/lodash-Vz5dH_Dm.mjs.map +1 -0
- package/dist/pane-Bm_57XKB.mjs +5 -0
- package/dist/pane-Bm_57XKB.mjs.map +1 -0
- package/dist/pane-Dopl4BjD.mjs +5 -0
- package/dist/pane-Dopl4BjD.mjs.map +1 -0
- package/dist/presentation-DsIky7Cj.mjs +556 -0
- package/dist/presentation-DsIky7Cj.mjs.map +1 -0
- package/dist/presentation.mjs +10 -0
- package/dist/presentation.mjs.map +1 -0
- package/dist/publishReplay-PuJoYJpp.mjs +92 -0
- package/dist/publishReplay-PuJoYJpp.mjs.map +1 -0
- package/dist/refractor-Bg1S3YDK.mjs +26 -0
- package/dist/refractor-Bg1S3YDK.mjs.map +1 -0
- package/dist/resources-BQsCEzu1.mjs +60 -0
- package/dist/resources-BQsCEzu1.mjs.map +1 -0
- package/dist/resources-BahMtJuO.mjs +177 -0
- package/dist/resources-BahMtJuO.mjs.map +1 -0
- package/dist/resources-CjkBN4z6.mjs +126 -0
- package/dist/resources-CjkBN4z6.mjs.map +1 -0
- package/dist/resources-Dc-6ZcPg.mjs +157 -0
- package/dist/resources-Dc-6ZcPg.mjs.map +1 -0
- package/dist/resources-DqxSuDsr.mjs +37 -0
- package/dist/resources-DqxSuDsr.mjs.map +1 -0
- package/dist/resources-_gTjFWLH.mjs +517 -0
- package/dist/resources-_gTjFWLH.mjs.map +1 -0
- package/dist/resources-kA1bao30.mjs +358 -0
- package/dist/resources-kA1bao30.mjs.map +1 -0
- package/dist/router.mjs +721 -0
- package/dist/router.mjs.map +1 -0
- package/dist/stegaEncodeSourceMap-DCG9Ba1H.mjs +358 -0
- package/dist/stegaEncodeSourceMap-DCG9Ba1H.mjs.map +1 -0
- package/dist/structure.mjs +57 -0
- package/dist/structure.mjs.map +1 -0
- package/dist/structureTool-Bth1vd8r.mjs +13150 -0
- package/dist/structureTool-Bth1vd8r.mjs.map +1 -0
- package/dist/switchMap-DHVUskpL.mjs +54 -0
- package/dist/switchMap-DHVUskpL.mjs.map +1 -0
- package/dist/v4-zH-CAum7.mjs +24798 -0
- package/dist/v4-zH-CAum7.mjs.map +1 -0
- package/dist/version-DoE_JnhG.mjs +5 -0
- package/dist/version-DoE_JnhG.mjs.map +1 -0
- package/lib/_chunks-cjs/version.js +1 -1
- package/lib/_chunks-es/version.mjs +1 -1
- package/package.json +23 -23
@@ -0,0 +1,2287 @@
|
|
1
|
+
var re = Object.defineProperty;
|
2
|
+
var oe = (i, e, t) => e in i ? re(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
|
3
|
+
var d = (i, e, t) => oe(i, typeof e != "symbol" ? e + "" : e, t);
|
4
|
+
import { jsx as ce } from "react/jsx-runtime";
|
5
|
+
import { useState as le, useMemo as U } from "react";
|
6
|
+
import { defineLocaleResourceBundle as ae, DEFAULT_STUDIO_CLIENT_OPTIONS as M, getPublishedId as Q, isRecord as V, getConfigContextFromSource as ue, useSource as pe, useConfigContextFromSource as de, useDocumentStore as he, usePerspective as me } from "sanity";
|
7
|
+
import { StructureToolContext as fe } from "sanity/_singletons";
|
8
|
+
import { z as Ie, G as P, J as ye, K as we, r as Te } from "./v4-zH-CAum7.mjs";
|
9
|
+
import { l as I } from "./lodash-Vz5dH_Dm.mjs";
|
10
|
+
import { A as ge, q as _e } from "./index-RoxwhtVB.mjs";
|
11
|
+
const f = "structure", mt = ae({
|
12
|
+
locale: "en-US",
|
13
|
+
namespace: f,
|
14
|
+
resources: () => import("./resources-_gTjFWLH.mjs")
|
15
|
+
}), Ee = ["_id", "_type", "_createdAt", "_updatedAt", "_rev"];
|
16
|
+
function x(i, e, t = !1) {
|
17
|
+
const [n, ...s] = e;
|
18
|
+
if (!("fields" in i))
|
19
|
+
return "";
|
20
|
+
const o = i.fields.find((l) => l.name === n);
|
21
|
+
if (!o) {
|
22
|
+
if (!Ee.includes(n)) {
|
23
|
+
const l = `The current ordering config targeted the nonexistent field "${n}" on schema type "${i.name}". It should be one of ${i.fields.map((u) => u.name).join(", ")}`;
|
24
|
+
if (t)
|
25
|
+
throw new Error(l);
|
26
|
+
console.warn(l);
|
27
|
+
}
|
28
|
+
return "";
|
29
|
+
}
|
30
|
+
if ("to" in o.type && o.type.name === "reference") {
|
31
|
+
const l = o.type.to;
|
32
|
+
return `${n}->{${l.map((u) => x(u, s)).join(",")}}`;
|
33
|
+
}
|
34
|
+
const r = s.length > 0 && x(o.type, s), c = r ? `{${r}}` : "";
|
35
|
+
return s.length > 0 ? `${n}${c}` : n;
|
36
|
+
}
|
37
|
+
function De(i, e, t = !1) {
|
38
|
+
return e.map((n) => x(i, n.field.split("."), t)).join(", ");
|
39
|
+
}
|
40
|
+
class a extends Error {
|
41
|
+
constructor(t, n, s, o) {
|
42
|
+
super(t);
|
43
|
+
d(this, "path");
|
44
|
+
d(this, "helpId");
|
45
|
+
this.name = "SerializeError";
|
46
|
+
const r = typeof s > "u" ? "<unknown>" : `${s}`;
|
47
|
+
this.path = (n || []).concat(o ? `${r} (${o})` : r);
|
48
|
+
}
|
49
|
+
withHelpUrl(t) {
|
50
|
+
return this.helpId = t, this;
|
51
|
+
}
|
52
|
+
}
|
53
|
+
var p = /* @__PURE__ */ ((i) => (i.ID_REQUIRED = "structure-node-id-required", i.TITLE_REQUIRED = "structure-title-required", i.FILTER_REQUIRED = "structure-filter-required", i.INVALID_LIST_ITEM = "structure-invalid-list-item", i.COMPONENT_REQUIRED = "structure-view-component-required", i.DOCUMENT_ID_REQUIRED = "structure-document-id-required", i.DOCUMENT_TYPE_REQUIRED = "structure-document-type-required", i.SCHEMA_TYPE_REQUIRED = "structure-schema-type-required", i.SCHEMA_TYPE_NOT_FOUND = "structure-schema-type-not-found", i.LIST_ITEMS_MUST_BE_ARRAY = "structure-list-items-must-be-array", i.QUERY_PROVIDED_FOR_FILTER = "structure-query-provided-for-filter", i.ACTION_OR_INTENT_REQUIRED = "structure-action-or-intent-required", i.LIST_ITEM_IDS_MUST_BE_UNIQUE = "structure-list-item-ids-must-be-unique", i.ACTION_AND_INTENT_MUTUALLY_EXCLUSIVE = "structure-action-and-intent-mutually-exclusive", i.API_VERSION_REQUIRED_FOR_CUSTOM_FILTER = "structure-api-version-required-for-custom-filter", i))(p || {});
|
54
|
+
const B = {
|
55
|
+
title: "Last edited",
|
56
|
+
i18n: {
|
57
|
+
title: {
|
58
|
+
key: "menu-items.sort-by.last-edited",
|
59
|
+
ns: f
|
60
|
+
}
|
61
|
+
},
|
62
|
+
name: "lastEditedDesc",
|
63
|
+
by: [{
|
64
|
+
field: "_updatedAt",
|
65
|
+
direction: "desc"
|
66
|
+
}]
|
67
|
+
}, Re = {
|
68
|
+
title: "Created",
|
69
|
+
i18n: {
|
70
|
+
title: {
|
71
|
+
key: "menu-items.sort-by.created",
|
72
|
+
ns: f
|
73
|
+
}
|
74
|
+
},
|
75
|
+
name: "lastCreatedDesc",
|
76
|
+
by: [{
|
77
|
+
field: "_createdAt",
|
78
|
+
direction: "desc"
|
79
|
+
}]
|
80
|
+
}, Se = B, H = [
|
81
|
+
B,
|
82
|
+
// _updatedAt
|
83
|
+
Re
|
84
|
+
// _createdAt
|
85
|
+
];
|
86
|
+
function k(i, e, t) {
|
87
|
+
return i instanceof y ? i.serialize({
|
88
|
+
path: t,
|
89
|
+
index: e
|
90
|
+
}) : i;
|
91
|
+
}
|
92
|
+
class y {
|
93
|
+
constructor(e, t) {
|
94
|
+
/** menu item option object. See {@link PartialMenuItem} */
|
95
|
+
d(this, "spec");
|
96
|
+
this._context = e, this.spec = t || {};
|
97
|
+
}
|
98
|
+
/**
|
99
|
+
* Set menu item action
|
100
|
+
* @param action - menu item action. See {@link MenuItemActionType}
|
101
|
+
* @returns menu item builder based on action provided. See {@link MenuItemBuilder}
|
102
|
+
*/
|
103
|
+
action(e) {
|
104
|
+
return this.clone({
|
105
|
+
action: e
|
106
|
+
});
|
107
|
+
}
|
108
|
+
/**
|
109
|
+
* Get menu item action
|
110
|
+
* @returns menu item builder action. See {@link PartialMenuItem}
|
111
|
+
*/
|
112
|
+
getAction() {
|
113
|
+
return this.spec.action;
|
114
|
+
}
|
115
|
+
/**
|
116
|
+
* Set menu item intent
|
117
|
+
* @param intent - menu item intent. See {@link Intent}
|
118
|
+
* @returns menu item builder based on intent provided. See {@link MenuItemBuilder}
|
119
|
+
*/
|
120
|
+
intent(e) {
|
121
|
+
return this.clone({
|
122
|
+
intent: e
|
123
|
+
});
|
124
|
+
}
|
125
|
+
/**
|
126
|
+
* Get menu item intent
|
127
|
+
* @returns menu item intent. See {@link PartialMenuItem}
|
128
|
+
*/
|
129
|
+
getIntent() {
|
130
|
+
return this.spec.intent;
|
131
|
+
}
|
132
|
+
/**
|
133
|
+
* Set menu item title
|
134
|
+
* @param title - menu item title
|
135
|
+
* @returns menu item builder based on title provided. See {@link MenuItemBuilder}
|
136
|
+
*/
|
137
|
+
title(e) {
|
138
|
+
return this.clone({
|
139
|
+
title: e
|
140
|
+
});
|
141
|
+
}
|
142
|
+
/**
|
143
|
+
* Get menu item title. Note that the `i18n` configuration will take
|
144
|
+
* precedence and this title is left here for compatibility.
|
145
|
+
* @returns menu item title
|
146
|
+
*/
|
147
|
+
getTitle() {
|
148
|
+
return this.spec.title;
|
149
|
+
}
|
150
|
+
/**
|
151
|
+
* Set the i18n key and namespace used to populate the localized title.
|
152
|
+
* @param i18n - object with i18n key and related namespace
|
153
|
+
* @returns menu item builder based on i18n config provided. See {@link MenuItemBuilder}
|
154
|
+
*/
|
155
|
+
i18n(e) {
|
156
|
+
return this.clone({
|
157
|
+
i18n: e
|
158
|
+
});
|
159
|
+
}
|
160
|
+
/**
|
161
|
+
* Get the i18n key and namespace used to populate the localized title.
|
162
|
+
* @returns the i18n key and namespace used to populate the localized title.
|
163
|
+
*/
|
164
|
+
getI18n() {
|
165
|
+
return this.spec.i18n;
|
166
|
+
}
|
167
|
+
/**
|
168
|
+
* Set menu item group
|
169
|
+
* @param group - menu item group
|
170
|
+
* @returns menu item builder based on group provided. See {@link MenuItemBuilder}
|
171
|
+
*/
|
172
|
+
group(e) {
|
173
|
+
return this.clone({
|
174
|
+
group: e
|
175
|
+
});
|
176
|
+
}
|
177
|
+
/**
|
178
|
+
* Get menu item group
|
179
|
+
* @returns menu item group. See {@link PartialMenuItem}
|
180
|
+
*/
|
181
|
+
getGroup() {
|
182
|
+
return this.spec.group;
|
183
|
+
}
|
184
|
+
/**
|
185
|
+
* Set menu item icon
|
186
|
+
* @param icon - menu item icon
|
187
|
+
* @returns menu item builder based on icon provided. See {@link MenuItemBuilder}
|
188
|
+
*/
|
189
|
+
icon(e) {
|
190
|
+
return this.clone({
|
191
|
+
icon: e
|
192
|
+
});
|
193
|
+
}
|
194
|
+
/**
|
195
|
+
* Get menu item icon
|
196
|
+
* @returns menu item icon. See {@link PartialMenuItem}
|
197
|
+
*/
|
198
|
+
getIcon() {
|
199
|
+
return this.spec.icon;
|
200
|
+
}
|
201
|
+
/**
|
202
|
+
* Set menu item parameters
|
203
|
+
* @param params - menu item parameters. See {@link MenuItemParamsType}
|
204
|
+
* @returns menu item builder based on parameters provided. See {@link MenuItemBuilder}
|
205
|
+
*/
|
206
|
+
params(e) {
|
207
|
+
return this.clone({
|
208
|
+
params: e
|
209
|
+
});
|
210
|
+
}
|
211
|
+
/**
|
212
|
+
* Get meny item parameters
|
213
|
+
* @returns menu item parameters. See {@link PartialMenuItem}
|
214
|
+
*/
|
215
|
+
getParams() {
|
216
|
+
return this.spec.params;
|
217
|
+
}
|
218
|
+
/**
|
219
|
+
* Set menu item to show as action
|
220
|
+
* @param showAsAction - determine if menu item should show as action
|
221
|
+
* @returns menu item builder based on if it should show as action. See {@link MenuItemBuilder}
|
222
|
+
*/
|
223
|
+
showAsAction(e = !0) {
|
224
|
+
return this.clone({
|
225
|
+
showAsAction: !!e
|
226
|
+
});
|
227
|
+
}
|
228
|
+
/**
|
229
|
+
* Check if menu item should show as action
|
230
|
+
* @returns true if menu item should show as action, false if not. See {@link PartialMenuItem}
|
231
|
+
*/
|
232
|
+
getShowAsAction() {
|
233
|
+
return this.spec.showAsAction;
|
234
|
+
}
|
235
|
+
/** Serialize menu item builder
|
236
|
+
* @param options - serialization options. See {@link SerializeOptions}
|
237
|
+
* @returns menu item node based on path provided in options. See {@link MenuItem}
|
238
|
+
*/
|
239
|
+
serialize(e = {
|
240
|
+
path: []
|
241
|
+
}) {
|
242
|
+
const {
|
243
|
+
title: t,
|
244
|
+
action: n,
|
245
|
+
intent: s
|
246
|
+
} = this.spec;
|
247
|
+
if (!t) {
|
248
|
+
const o = typeof n == "string" ? `action: "${n}"` : void 0;
|
249
|
+
throw new a("`title` is required for menu item", e.path, e.index, o).withHelpUrl(p.TITLE_REQUIRED);
|
250
|
+
}
|
251
|
+
if (!n && !s)
|
252
|
+
throw new a(`\`action\` or \`intent\` required for menu item with title ${this.spec.title}`, e.path, e.index, `"${t}"`).withHelpUrl(p.ACTION_OR_INTENT_REQUIRED);
|
253
|
+
if (s && n)
|
254
|
+
throw new a("cannot set both `action` AND `intent`", e.path, e.index, `"${t}"`).withHelpUrl(p.ACTION_AND_INTENT_MUTUALLY_EXCLUSIVE);
|
255
|
+
return {
|
256
|
+
...this.spec,
|
257
|
+
title: t
|
258
|
+
};
|
259
|
+
}
|
260
|
+
/** Clone menu item builder
|
261
|
+
* @param withSpec - menu item options. See {@link PartialMenuItem}
|
262
|
+
* @returns menu item builder based on context and spec provided. See {@link MenuItemBuilder}
|
263
|
+
*/
|
264
|
+
clone(e) {
|
265
|
+
const t = new y(this._context);
|
266
|
+
return t.spec = {
|
267
|
+
...this.spec,
|
268
|
+
...e
|
269
|
+
}, t;
|
270
|
+
}
|
271
|
+
}
|
272
|
+
function G(i, {
|
273
|
+
by: e,
|
274
|
+
title: t,
|
275
|
+
i18n: n
|
276
|
+
}, s) {
|
277
|
+
let o = new y(i).group("sorting").title(i.i18n.t("default-menu-item.fallback-title", {
|
278
|
+
// note this lives in the `studio` bundle because that one is loaded by default
|
279
|
+
ns: "studio",
|
280
|
+
replace: {
|
281
|
+
title: t
|
282
|
+
}
|
283
|
+
// replaces the `{{title}}` option
|
284
|
+
})).icon(Ie).action("setSortOrder").params({
|
285
|
+
by: e,
|
286
|
+
extendedProjection: s
|
287
|
+
});
|
288
|
+
return n && (o = o.i18n(n)), o;
|
289
|
+
}
|
290
|
+
function Y(i, e) {
|
291
|
+
const {
|
292
|
+
schema: t
|
293
|
+
} = i, n = typeof e == "string" ? t.get(e) : e;
|
294
|
+
return !n || !("orderings" in n) ? [] : (n.orderings ? n.orderings.concat(H) : H).map((s) => G(i, s, De(n, s.by)));
|
295
|
+
}
|
296
|
+
function j(i, e, t) {
|
297
|
+
return i instanceof T ? i.serialize({
|
298
|
+
path: t,
|
299
|
+
index: e
|
300
|
+
}) : i;
|
301
|
+
}
|
302
|
+
class T {
|
303
|
+
constructor(e, t) {
|
304
|
+
/** Menu item group ID */
|
305
|
+
d(this, "_id");
|
306
|
+
/** Menu item group title */
|
307
|
+
d(this, "_title");
|
308
|
+
d(this, "_i18n");
|
309
|
+
this._context = e, this._id = t ? t.id : "", this._title = t ? t.title : "", this._i18n = t ? t.i18n : void 0;
|
310
|
+
}
|
311
|
+
/**
|
312
|
+
* Set menu item group ID
|
313
|
+
* @param id - menu item group ID
|
314
|
+
* @returns menu item group builder based on ID provided. See {@link MenuItemGroupBuilder}
|
315
|
+
*/
|
316
|
+
id(e) {
|
317
|
+
return new T(this._context, {
|
318
|
+
id: e,
|
319
|
+
title: this._title,
|
320
|
+
i18n: this._i18n
|
321
|
+
});
|
322
|
+
}
|
323
|
+
/**
|
324
|
+
* Get menu item group ID
|
325
|
+
* @returns menu item group ID
|
326
|
+
*/
|
327
|
+
getId() {
|
328
|
+
return this._id;
|
329
|
+
}
|
330
|
+
/**
|
331
|
+
* Set menu item group title
|
332
|
+
* @param title - menu item group title
|
333
|
+
* @returns menu item group builder based on title provided. See {@link MenuItemGroupBuilder}
|
334
|
+
*/
|
335
|
+
title(e) {
|
336
|
+
return new T(this._context, {
|
337
|
+
title: e,
|
338
|
+
id: this._id,
|
339
|
+
i18n: this._i18n
|
340
|
+
});
|
341
|
+
}
|
342
|
+
/**
|
343
|
+
* Get menu item group title
|
344
|
+
* @returns menu item group title
|
345
|
+
*/
|
346
|
+
getTitle() {
|
347
|
+
return this._title;
|
348
|
+
}
|
349
|
+
/**
|
350
|
+
* Set the i18n key and namespace used to populate the localized title.
|
351
|
+
* @param i18n - object with i18n key and related namespace
|
352
|
+
* @returns menu item group builder based on i18n info provided. See {@link MenuItemGroupBuilder}
|
353
|
+
*/
|
354
|
+
i18n(e) {
|
355
|
+
return new T(this._context, {
|
356
|
+
i18n: e,
|
357
|
+
id: this._id,
|
358
|
+
title: this._title
|
359
|
+
});
|
360
|
+
}
|
361
|
+
/**
|
362
|
+
* Get the i18n key and namespace used to populate the localized title.
|
363
|
+
* @returns the i18n key and namespace used to populate the localized title.
|
364
|
+
*/
|
365
|
+
getI18n() {
|
366
|
+
return this._i18n;
|
367
|
+
}
|
368
|
+
/**
|
369
|
+
* Serialize menu item group builder
|
370
|
+
* @param options - serialization options (path). See {@link SerializeOptions}
|
371
|
+
* @returns menu item group based on path provided in options. See {@link MenuItemGroup}
|
372
|
+
*/
|
373
|
+
serialize(e = {
|
374
|
+
path: []
|
375
|
+
}) {
|
376
|
+
const {
|
377
|
+
_id: t,
|
378
|
+
_title: n,
|
379
|
+
_i18n: s
|
380
|
+
} = this;
|
381
|
+
if (!t)
|
382
|
+
throw new a("`id` is required for a menu item group", e.path, e.index, n).withHelpUrl(p.ID_REQUIRED);
|
383
|
+
if (!n)
|
384
|
+
throw new a("`title` is required for a menu item group", e.path, t).withHelpUrl(p.TITLE_REQUIRED);
|
385
|
+
return {
|
386
|
+
id: t,
|
387
|
+
title: n,
|
388
|
+
i18n: s
|
389
|
+
};
|
390
|
+
}
|
391
|
+
}
|
392
|
+
const W = /([^A-Za-z0-9-_.])/;
|
393
|
+
function R(i, e, t) {
|
394
|
+
if (typeof i != "string")
|
395
|
+
throw new a(`Structure node id must be of type string, got ${typeof i}`, e, t);
|
396
|
+
const [n] = i.match(W) || [];
|
397
|
+
if (n)
|
398
|
+
throw new a(`Structure node id cannot contain character "${n}"`, e, t);
|
399
|
+
if (i.startsWith("__edit__"))
|
400
|
+
throw new a("Structure node id cannot start with __edit__", e, t);
|
401
|
+
return i;
|
402
|
+
}
|
403
|
+
function C(i, e) {
|
404
|
+
if (e)
|
405
|
+
return e;
|
406
|
+
const t = I.camelCase(i);
|
407
|
+
return W.test(t) ? I.camelCase(ge(i)) : t;
|
408
|
+
}
|
409
|
+
class D {
|
410
|
+
constructor(e) {
|
411
|
+
/** component builder option object */
|
412
|
+
d(this, "spec");
|
413
|
+
this.spec = {
|
414
|
+
options: {},
|
415
|
+
...e || {}
|
416
|
+
};
|
417
|
+
}
|
418
|
+
/** Set Component ID
|
419
|
+
* @param id - component ID
|
420
|
+
* @returns component builder based on ID provided
|
421
|
+
*/
|
422
|
+
id(e) {
|
423
|
+
return this.clone({
|
424
|
+
id: e
|
425
|
+
});
|
426
|
+
}
|
427
|
+
/** Get ID
|
428
|
+
* @returns ID
|
429
|
+
*/
|
430
|
+
getId() {
|
431
|
+
return this.spec.id;
|
432
|
+
}
|
433
|
+
/** Set Component title
|
434
|
+
* @param title - component title
|
435
|
+
* @returns component builder based on title provided (and ID)
|
436
|
+
*/
|
437
|
+
title(e) {
|
438
|
+
return this.clone({
|
439
|
+
title: e,
|
440
|
+
id: C(e, this.spec.id)
|
441
|
+
});
|
442
|
+
}
|
443
|
+
/** Get Component title
|
444
|
+
* @returns title
|
445
|
+
*/
|
446
|
+
getTitle() {
|
447
|
+
return this.spec.title;
|
448
|
+
}
|
449
|
+
/** Set the i18n key and namespace used to populate the localized title.
|
450
|
+
* @param i18n - the key and namespaced used to populate the localized title.
|
451
|
+
* @returns component builder based on i18n key and ns provided
|
452
|
+
*/
|
453
|
+
i18n(e) {
|
454
|
+
return this.clone({
|
455
|
+
i18n: e
|
456
|
+
});
|
457
|
+
}
|
458
|
+
/** Get i18n key and namespace used to populate the localized title
|
459
|
+
* @returns the i18n key and namespace used to populate the localized title
|
460
|
+
*/
|
461
|
+
getI18n() {
|
462
|
+
return this.spec.i18n;
|
463
|
+
}
|
464
|
+
/** Set Component child
|
465
|
+
* @param child - child component
|
466
|
+
* @returns component builder based on child component provided
|
467
|
+
*/
|
468
|
+
child(e) {
|
469
|
+
return this.clone({
|
470
|
+
child: e
|
471
|
+
});
|
472
|
+
}
|
473
|
+
/** Get Component child
|
474
|
+
* @returns child component
|
475
|
+
*/
|
476
|
+
getChild() {
|
477
|
+
return this.spec.child;
|
478
|
+
}
|
479
|
+
/** Set component
|
480
|
+
* @param component - user built component
|
481
|
+
* @returns component builder based on component provided
|
482
|
+
*/
|
483
|
+
component(e) {
|
484
|
+
return this.clone({
|
485
|
+
component: e
|
486
|
+
});
|
487
|
+
}
|
488
|
+
/** Get Component
|
489
|
+
* @returns component
|
490
|
+
*/
|
491
|
+
getComponent() {
|
492
|
+
return this.spec.component;
|
493
|
+
}
|
494
|
+
/** Set Component options
|
495
|
+
* @param options - component options
|
496
|
+
* @returns component builder based on options provided
|
497
|
+
*/
|
498
|
+
options(e) {
|
499
|
+
return this.clone({
|
500
|
+
options: e
|
501
|
+
});
|
502
|
+
}
|
503
|
+
/** Get Component options
|
504
|
+
* @returns component options
|
505
|
+
*/
|
506
|
+
getOptions() {
|
507
|
+
return this.spec.options || {};
|
508
|
+
}
|
509
|
+
/** Set Component menu items
|
510
|
+
* @param menuItems - component menu items
|
511
|
+
* @returns component builder based on menuItems provided
|
512
|
+
*/
|
513
|
+
menuItems(e) {
|
514
|
+
return this.clone({
|
515
|
+
menuItems: e
|
516
|
+
});
|
517
|
+
}
|
518
|
+
/** Get Component menu items
|
519
|
+
* @returns menu items
|
520
|
+
*/
|
521
|
+
getMenuItems() {
|
522
|
+
return this.spec.menuItems;
|
523
|
+
}
|
524
|
+
/** Set Component menu item groups
|
525
|
+
* @param menuItemGroups - component menu item groups
|
526
|
+
* @returns component builder based on menuItemGroups provided
|
527
|
+
*/
|
528
|
+
menuItemGroups(e) {
|
529
|
+
return this.clone({
|
530
|
+
menuItemGroups: e
|
531
|
+
});
|
532
|
+
}
|
533
|
+
/** Get Component menu item groups
|
534
|
+
* @returns menu item groups
|
535
|
+
*/
|
536
|
+
getMenuItemGroups() {
|
537
|
+
return this.spec.menuItemGroups;
|
538
|
+
}
|
539
|
+
canHandleIntent(e) {
|
540
|
+
return this.clone({
|
541
|
+
canHandleIntent: e
|
542
|
+
});
|
543
|
+
}
|
544
|
+
/** Serialize component
|
545
|
+
* @param options - serialization options
|
546
|
+
* @returns component object based on path provided in options
|
547
|
+
*
|
548
|
+
*/
|
549
|
+
serialize(e = {
|
550
|
+
path: []
|
551
|
+
}) {
|
552
|
+
const {
|
553
|
+
id: t,
|
554
|
+
title: n,
|
555
|
+
child: s,
|
556
|
+
options: o,
|
557
|
+
component: r
|
558
|
+
} = this.spec;
|
559
|
+
if (!t)
|
560
|
+
throw new a("`id` is required for `component` structure item", e.path, e.index).withHelpUrl(p.ID_REQUIRED);
|
561
|
+
if (!r)
|
562
|
+
throw new a("`component` is required for `component` structure item", e.path, e.index).withHelpUrl(p.ID_REQUIRED);
|
563
|
+
return {
|
564
|
+
id: R(t, e.path, e.index),
|
565
|
+
title: n,
|
566
|
+
type: "component",
|
567
|
+
child: s,
|
568
|
+
component: r,
|
569
|
+
canHandleIntent: this.spec.canHandleIntent,
|
570
|
+
options: o || {},
|
571
|
+
menuItems: (this.spec.menuItems || []).map((c, l) => k(c, l, e.path)),
|
572
|
+
menuItemGroups: (this.spec.menuItemGroups || []).map((c, l) => j(c, l, e.path))
|
573
|
+
};
|
574
|
+
}
|
575
|
+
/** Clone component builder (allows for options overriding)
|
576
|
+
* @param withSpec - component builder options
|
577
|
+
* @returns cloned builder
|
578
|
+
*/
|
579
|
+
clone(e) {
|
580
|
+
const t = new D();
|
581
|
+
return t.spec = {
|
582
|
+
...this.spec,
|
583
|
+
...e
|
584
|
+
}, t;
|
585
|
+
}
|
586
|
+
}
|
587
|
+
class O {
|
588
|
+
constructor(e) {
|
589
|
+
d(this, "spec");
|
590
|
+
this.spec = {
|
591
|
+
id: I.uniqueId("__divider__"),
|
592
|
+
type: "divider",
|
593
|
+
...e
|
594
|
+
};
|
595
|
+
}
|
596
|
+
/** Set the title of the divider
|
597
|
+
* @param title - the title of the divider
|
598
|
+
* @returns divider builder based on title provided
|
599
|
+
*/
|
600
|
+
title(e) {
|
601
|
+
return this.clone({
|
602
|
+
title: e
|
603
|
+
});
|
604
|
+
}
|
605
|
+
/** Get the title of the divider
|
606
|
+
* @returns the title of the divider
|
607
|
+
*/
|
608
|
+
getTitle() {
|
609
|
+
return this.spec.title;
|
610
|
+
}
|
611
|
+
/** Set the i18n key and namespace used to populate the localized title.
|
612
|
+
* @param i18n - the key and namespaced used to populate the localized title.
|
613
|
+
* @returns divider builder based on i18n key and ns provided
|
614
|
+
*/
|
615
|
+
i18n(e) {
|
616
|
+
return this.clone({
|
617
|
+
i18n: e
|
618
|
+
});
|
619
|
+
}
|
620
|
+
/** Get i18n key and namespace used to populate the localized title
|
621
|
+
* @returns the i18n key and namespace used to populate the localized title
|
622
|
+
*/
|
623
|
+
getI18n() {
|
624
|
+
return this.spec.i18n;
|
625
|
+
}
|
626
|
+
/** Serialize the divider
|
627
|
+
* @returns the serialized divider
|
628
|
+
*/
|
629
|
+
serialize() {
|
630
|
+
return {
|
631
|
+
...this.spec
|
632
|
+
};
|
633
|
+
}
|
634
|
+
/** Clone divider builder (allows for options overriding)
|
635
|
+
* @param withSpec - divider builder options
|
636
|
+
* @returns cloned builder
|
637
|
+
*/
|
638
|
+
clone(e) {
|
639
|
+
const t = new O();
|
640
|
+
return t.spec = {
|
641
|
+
...this.spec,
|
642
|
+
...e
|
643
|
+
}, t;
|
644
|
+
}
|
645
|
+
}
|
646
|
+
async function X(i, e) {
|
647
|
+
return await i(M).fetch("*[sanity::versionOf($publishedId)][0]._type", {
|
648
|
+
publishedId: Q(e)
|
649
|
+
}, {
|
650
|
+
tag: "structure.resolve-type"
|
651
|
+
});
|
652
|
+
}
|
653
|
+
class z {
|
654
|
+
constructor() {
|
655
|
+
/** Generic view option object */
|
656
|
+
d(this, "spec", {});
|
657
|
+
}
|
658
|
+
/** Set generic view ID
|
659
|
+
* @param id - generic view ID
|
660
|
+
* @returns generic view builder based on ID provided.
|
661
|
+
*/
|
662
|
+
id(e) {
|
663
|
+
return this.clone({
|
664
|
+
id: e
|
665
|
+
});
|
666
|
+
}
|
667
|
+
/** Get generic view ID
|
668
|
+
* @returns generic view ID
|
669
|
+
*/
|
670
|
+
getId() {
|
671
|
+
return this.spec.id;
|
672
|
+
}
|
673
|
+
/** Set generic view title
|
674
|
+
* @param title - generic view title
|
675
|
+
* @returns generic view builder based on title provided and (if provided) its ID.
|
676
|
+
*/
|
677
|
+
title(e) {
|
678
|
+
return this.clone({
|
679
|
+
title: e,
|
680
|
+
id: this.spec.id || I.kebabCase(e)
|
681
|
+
});
|
682
|
+
}
|
683
|
+
/** Get generic view title
|
684
|
+
* @returns generic view title
|
685
|
+
*/
|
686
|
+
getTitle() {
|
687
|
+
return this.spec.title;
|
688
|
+
}
|
689
|
+
/** Set generic view icon
|
690
|
+
* @param icon - generic view icon
|
691
|
+
* @returns generic view builder based on icon provided.
|
692
|
+
*/
|
693
|
+
icon(e) {
|
694
|
+
return this.clone({
|
695
|
+
icon: e
|
696
|
+
});
|
697
|
+
}
|
698
|
+
/** Get generic view icon
|
699
|
+
* @returns generic view icon
|
700
|
+
*/
|
701
|
+
getIcon() {
|
702
|
+
return this.spec.icon;
|
703
|
+
}
|
704
|
+
/** Serialize generic view
|
705
|
+
* @param options - serialization options. See {@link SerializeOptions}
|
706
|
+
* @returns generic view object based on path provided in options. See {@link BaseView}
|
707
|
+
*/
|
708
|
+
serialize(e = {
|
709
|
+
path: []
|
710
|
+
}) {
|
711
|
+
const {
|
712
|
+
id: t,
|
713
|
+
title: n,
|
714
|
+
icon: s
|
715
|
+
} = this.spec;
|
716
|
+
if (!t)
|
717
|
+
throw new a("`id` is required for view item", e.path, e.index).withHelpUrl(p.ID_REQUIRED);
|
718
|
+
if (!n)
|
719
|
+
throw new a("`title` is required for view item", e.path, e.index).withHelpUrl(p.TITLE_REQUIRED);
|
720
|
+
return {
|
721
|
+
id: R(t, e.path, e.index),
|
722
|
+
title: n,
|
723
|
+
icon: s
|
724
|
+
};
|
725
|
+
}
|
726
|
+
}
|
727
|
+
function Ue(i) {
|
728
|
+
return typeof i.serialize == "function";
|
729
|
+
}
|
730
|
+
function J(i, e, t) {
|
731
|
+
return Ue(i) ? i.serialize({
|
732
|
+
path: t,
|
733
|
+
index: e
|
734
|
+
}) : i;
|
735
|
+
}
|
736
|
+
const ve = (i) => V(i) && i.type === "component";
|
737
|
+
class A extends z {
|
738
|
+
constructor(t) {
|
739
|
+
const n = ve(t) ? {
|
740
|
+
...t
|
741
|
+
} : {
|
742
|
+
options: {}
|
743
|
+
};
|
744
|
+
super();
|
745
|
+
/** Partial Component view option object. See {@link ComponentView} */
|
746
|
+
d(this, "spec");
|
747
|
+
this.spec = n;
|
748
|
+
const s = typeof t == "function" ? t : this.spec.component;
|
749
|
+
s && (this.spec = this.component(s).spec);
|
750
|
+
}
|
751
|
+
/** Set view Component
|
752
|
+
* @param component - component view component. See {@link UserViewComponent}
|
753
|
+
* @returns component view builder based on component view provided. See {@link ComponentViewBuilder}
|
754
|
+
*/
|
755
|
+
component(t) {
|
756
|
+
return this.clone({
|
757
|
+
component: t
|
758
|
+
});
|
759
|
+
}
|
760
|
+
/** Get view Component
|
761
|
+
* @returns Partial component view. See {@link ComponentView}
|
762
|
+
*/
|
763
|
+
getComponent() {
|
764
|
+
return this.spec.component;
|
765
|
+
}
|
766
|
+
/** Set view Component options
|
767
|
+
* @param options - component view options
|
768
|
+
* @returns component view builder based on options provided. See {@link ComponentViewBuilder}
|
769
|
+
*/
|
770
|
+
options(t) {
|
771
|
+
return this.clone({
|
772
|
+
options: t
|
773
|
+
});
|
774
|
+
}
|
775
|
+
/** Get view Component options
|
776
|
+
* @returns component view options. See {@link ComponentView}
|
777
|
+
*/
|
778
|
+
getOptions() {
|
779
|
+
return this.spec.options || {};
|
780
|
+
}
|
781
|
+
/** Serialize view Component
|
782
|
+
* @param options - serialization options. See {@link SerializeOptions}
|
783
|
+
* @returns component view based on path provided in options. See {@link ComponentView}
|
784
|
+
*
|
785
|
+
*/
|
786
|
+
serialize(t = {
|
787
|
+
path: []
|
788
|
+
}) {
|
789
|
+
const n = super.serialize(t), s = this.spec.component;
|
790
|
+
if (typeof s != "function")
|
791
|
+
throw new a("`component` is required and must be a function for `component()` view item", t.path, t.index).withHelpUrl(p.COMPONENT_REQUIRED);
|
792
|
+
return {
|
793
|
+
...n,
|
794
|
+
component: s,
|
795
|
+
options: this.spec.options || {},
|
796
|
+
type: "component"
|
797
|
+
};
|
798
|
+
}
|
799
|
+
/** Clone Component view builder (allows for options overriding)
|
800
|
+
* @param withSpec - partial for component view option. See {@link ComponentView}
|
801
|
+
* @returns component view builder. See {@link ComponentViewBuilder}
|
802
|
+
*/
|
803
|
+
clone(t) {
|
804
|
+
const n = new A();
|
805
|
+
return n.spec = {
|
806
|
+
...this.spec,
|
807
|
+
...t
|
808
|
+
}, n;
|
809
|
+
}
|
810
|
+
}
|
811
|
+
class N extends z {
|
812
|
+
constructor(t) {
|
813
|
+
super();
|
814
|
+
/** Document list options. See {@link FormView} */
|
815
|
+
d(this, "spec");
|
816
|
+
this.spec = {
|
817
|
+
id: "editor",
|
818
|
+
title: "Editor",
|
819
|
+
...t || {}
|
820
|
+
};
|
821
|
+
}
|
822
|
+
/**
|
823
|
+
* Serialize Form view builder
|
824
|
+
* @param options - Serialize options. See {@link SerializeOptions}
|
825
|
+
* @returns form view builder based on path provided in options. See {@link FormView}
|
826
|
+
*/
|
827
|
+
serialize(t = {
|
828
|
+
path: []
|
829
|
+
}) {
|
830
|
+
return {
|
831
|
+
...super.serialize(t),
|
832
|
+
type: "form"
|
833
|
+
};
|
834
|
+
}
|
835
|
+
/**
|
836
|
+
* Clone Form view builder (allows for options overriding)
|
837
|
+
* @param withSpec - Partial form view builder options. See {@link FormView}
|
838
|
+
* @returns form view builder. See {@link FormViewBuilder}
|
839
|
+
*/
|
840
|
+
clone(t) {
|
841
|
+
const n = new N();
|
842
|
+
return n.spec = {
|
843
|
+
...this.spec,
|
844
|
+
...t
|
845
|
+
}, n;
|
846
|
+
}
|
847
|
+
}
|
848
|
+
const K = (i) => new N(i), Ce = (i) => new A(i), Oe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
849
|
+
__proto__: null,
|
850
|
+
ComponentViewBuilder: A,
|
851
|
+
FormViewBuilder: N,
|
852
|
+
GenericViewBuilder: z,
|
853
|
+
component: Ce,
|
854
|
+
form: K,
|
855
|
+
maybeSerializeView: J
|
856
|
+
}, Symbol.toStringTag, { value: "Module" })), Ae = ({
|
857
|
+
resolveDocumentNode: i,
|
858
|
+
getClient: e
|
859
|
+
}) => async (t, {
|
860
|
+
params: n,
|
861
|
+
path: s
|
862
|
+
}) => {
|
863
|
+
let o = n.type;
|
864
|
+
const r = s.slice(0, s.length - 1), c = s[s.length - 1];
|
865
|
+
if (o || (o = await X(e, t)), !o)
|
866
|
+
throw new a("Failed to resolve document, and no type provided in parameters.", r, c);
|
867
|
+
return i({
|
868
|
+
documentId: t,
|
869
|
+
schemaType: o
|
870
|
+
});
|
871
|
+
};
|
872
|
+
class w {
|
873
|
+
constructor(e, t) {
|
874
|
+
/** Component builder option object See {@link PartialDocumentNode} */
|
875
|
+
d(this, "spec");
|
876
|
+
this._context = e, this.spec = t || {};
|
877
|
+
}
|
878
|
+
/** Set Document Builder ID
|
879
|
+
* @param id - document builder ID
|
880
|
+
* @returns document builder based on ID provided. See {@link DocumentBuilder}
|
881
|
+
*/
|
882
|
+
id(e) {
|
883
|
+
return this.clone({
|
884
|
+
id: e
|
885
|
+
});
|
886
|
+
}
|
887
|
+
/** Get Document Builder ID
|
888
|
+
* @returns document ID. See {@link PartialDocumentNode}
|
889
|
+
*/
|
890
|
+
getId() {
|
891
|
+
return this.spec.id;
|
892
|
+
}
|
893
|
+
/** Set Document title
|
894
|
+
* @param title - document title
|
895
|
+
* @returns document builder based on title provided (and ID). See {@link DocumentBuilder}
|
896
|
+
*/
|
897
|
+
title(e) {
|
898
|
+
return this.clone({
|
899
|
+
title: e,
|
900
|
+
id: C(e, this.spec.id)
|
901
|
+
});
|
902
|
+
}
|
903
|
+
/** Get Document title
|
904
|
+
* @returns document title. See {@link PartialDocumentNode}
|
905
|
+
*/
|
906
|
+
getTitle() {
|
907
|
+
return this.spec.title;
|
908
|
+
}
|
909
|
+
/** Set the i18n key and namespace used to populate the localized title.
|
910
|
+
* @param i18n - the key and namespaced used to populate the localized title.
|
911
|
+
* @returns component builder based on i18n key and ns provided
|
912
|
+
*/
|
913
|
+
i18n(e) {
|
914
|
+
return this.clone({
|
915
|
+
i18n: e
|
916
|
+
});
|
917
|
+
}
|
918
|
+
/** Get i18n key and namespace used to populate the localized title
|
919
|
+
* @returns the i18n key and namespace used to populate the localized title
|
920
|
+
*/
|
921
|
+
getI18n() {
|
922
|
+
return this.spec.i18n;
|
923
|
+
}
|
924
|
+
/** Set Document child
|
925
|
+
* @param child - document child
|
926
|
+
* @returns document builder based on child provided. See {@link DocumentBuilder}
|
927
|
+
*/
|
928
|
+
child(e) {
|
929
|
+
return this.clone({
|
930
|
+
child: e
|
931
|
+
});
|
932
|
+
}
|
933
|
+
/** Get Document child
|
934
|
+
* @returns document child. See {@link PartialDocumentNode}
|
935
|
+
*/
|
936
|
+
getChild() {
|
937
|
+
return this.spec.child;
|
938
|
+
}
|
939
|
+
/** Set Document ID
|
940
|
+
* @param documentId - document ID
|
941
|
+
* @returns document builder with document based on ID provided. See {@link DocumentBuilder}
|
942
|
+
*/
|
943
|
+
documentId(e) {
|
944
|
+
const t = this.spec.id || e;
|
945
|
+
return this.clone({
|
946
|
+
id: t,
|
947
|
+
options: {
|
948
|
+
...this.spec.options,
|
949
|
+
id: e
|
950
|
+
}
|
951
|
+
});
|
952
|
+
}
|
953
|
+
/** Get Document ID
|
954
|
+
* @returns document ID. See {@link DocumentOptions}
|
955
|
+
*/
|
956
|
+
getDocumentId() {
|
957
|
+
var e;
|
958
|
+
return (e = this.spec.options) == null ? void 0 : e.id;
|
959
|
+
}
|
960
|
+
/** Set Document Type
|
961
|
+
* @param documentType - document type
|
962
|
+
* @returns document builder with document based on type provided. See {@link DocumentBuilder}
|
963
|
+
*/
|
964
|
+
schemaType(e) {
|
965
|
+
return this.clone({
|
966
|
+
options: {
|
967
|
+
...this.spec.options,
|
968
|
+
type: typeof e == "string" ? e : e.name
|
969
|
+
}
|
970
|
+
});
|
971
|
+
}
|
972
|
+
/** Get Document Type
|
973
|
+
* @returns document type. See {@link DocumentOptions}
|
974
|
+
*/
|
975
|
+
getSchemaType() {
|
976
|
+
var e;
|
977
|
+
return (e = this.spec.options) == null ? void 0 : e.type;
|
978
|
+
}
|
979
|
+
/** Set Document Template
|
980
|
+
* @param templateId - document template ID
|
981
|
+
* @param parameters - document template parameters
|
982
|
+
* @returns document builder with document based on template provided. See {@link DocumentBuilder}
|
983
|
+
*/
|
984
|
+
initialValueTemplate(e, t) {
|
985
|
+
return this.clone({
|
986
|
+
options: {
|
987
|
+
...this.spec.options,
|
988
|
+
template: e,
|
989
|
+
templateParameters: t
|
990
|
+
}
|
991
|
+
});
|
992
|
+
}
|
993
|
+
/** Get Document Template
|
994
|
+
* @returns document template. See {@link DocumentOptions}
|
995
|
+
*/
|
996
|
+
getInitialValueTemplate() {
|
997
|
+
var e;
|
998
|
+
return (e = this.spec.options) == null ? void 0 : e.template;
|
999
|
+
}
|
1000
|
+
/** Get Document's initial value Template parameters
|
1001
|
+
* @returns document template parameters. See {@link DocumentOptions}
|
1002
|
+
*/
|
1003
|
+
getInitialValueTemplateParameters() {
|
1004
|
+
var e;
|
1005
|
+
return (e = this.spec.options) == null ? void 0 : e.templateParameters;
|
1006
|
+
}
|
1007
|
+
/** Set Document views
|
1008
|
+
* @param views - document views. See {@link ViewBuilder} and {@link View}
|
1009
|
+
* @returns document builder with document based on views provided. See {@link DocumentBuilder}
|
1010
|
+
*/
|
1011
|
+
views(e) {
|
1012
|
+
return this.clone({
|
1013
|
+
views: e
|
1014
|
+
});
|
1015
|
+
}
|
1016
|
+
/** Get Document views
|
1017
|
+
* @returns document views. See {@link ViewBuilder} and {@link View}
|
1018
|
+
*/
|
1019
|
+
getViews() {
|
1020
|
+
return this.spec.views || [];
|
1021
|
+
}
|
1022
|
+
/** Serialize Document builder
|
1023
|
+
* @param options - serialization options. See {@link SerializeOptions}
|
1024
|
+
* @returns document node based on path, index and hint provided in options. See {@link DocumentNode}
|
1025
|
+
*/
|
1026
|
+
serialize({
|
1027
|
+
path: e = [],
|
1028
|
+
index: t,
|
1029
|
+
hint: n
|
1030
|
+
} = {
|
1031
|
+
path: []
|
1032
|
+
}) {
|
1033
|
+
const s = e[t || e.length - 1], o = this.spec.id || s && `${s}` || "", r = {
|
1034
|
+
id: o,
|
1035
|
+
type: void 0,
|
1036
|
+
template: void 0,
|
1037
|
+
templateParameters: void 0,
|
1038
|
+
...this.spec.options
|
1039
|
+
};
|
1040
|
+
if (typeof o != "string" || !o)
|
1041
|
+
throw new a("`id` is required for document nodes", e, t, n).withHelpUrl(p.ID_REQUIRED);
|
1042
|
+
if (!r || !r.id)
|
1043
|
+
throw new a("document id (`id`) is required for document nodes", e, o, n).withHelpUrl(p.DOCUMENT_ID_REQUIRED);
|
1044
|
+
if (!r || !r.type)
|
1045
|
+
throw new a("document type (`schemaType`) is required for document nodes", e, o, n);
|
1046
|
+
const c = (this.spec.views && this.spec.views.length > 0 ? this.spec.views : [K()]).map((h, m) => J(h, m, e)), l = c.map((h) => h.id), u = I.uniq(l.filter((h, m) => l.includes(h, m + 1)));
|
1047
|
+
if (u.length > 0)
|
1048
|
+
throw new a(`document node has views with duplicate IDs: ${u.join(", ")}`, e, o, n);
|
1049
|
+
return {
|
1050
|
+
...this.spec,
|
1051
|
+
child: this.spec.child || Ae(this._context),
|
1052
|
+
id: R(o, e, t),
|
1053
|
+
type: "document",
|
1054
|
+
options: Ne(r),
|
1055
|
+
views: c
|
1056
|
+
};
|
1057
|
+
}
|
1058
|
+
/** Clone Document builder
|
1059
|
+
* @param withSpec - partial document node specification used to extend the cloned builder. See {@link PartialDocumentNode}
|
1060
|
+
* @returns document builder based on context and spec provided. See {@link DocumentBuilder}
|
1061
|
+
*/
|
1062
|
+
clone(e = {}) {
|
1063
|
+
const t = new w(this._context), n = {
|
1064
|
+
...this.spec.options,
|
1065
|
+
...e.options
|
1066
|
+
};
|
1067
|
+
return t.spec = {
|
1068
|
+
...this.spec,
|
1069
|
+
...e,
|
1070
|
+
options: n
|
1071
|
+
}, t;
|
1072
|
+
}
|
1073
|
+
}
|
1074
|
+
function Ne(i) {
|
1075
|
+
const e = {
|
1076
|
+
id: i.id || "",
|
1077
|
+
type: i.type || "*"
|
1078
|
+
};
|
1079
|
+
return i.template && (e.template = i.template), i.templateParameters && (e.templateParameters = i.templateParameters), e;
|
1080
|
+
}
|
1081
|
+
function be(i, e) {
|
1082
|
+
let t = e != null && e.type ? (
|
1083
|
+
// Use user-defined document fragment as base if possible
|
1084
|
+
i.resolveDocumentNode({
|
1085
|
+
schemaType: e.type
|
1086
|
+
})
|
1087
|
+
) : (
|
1088
|
+
// Fall back to plain old document builder
|
1089
|
+
new w(i)
|
1090
|
+
);
|
1091
|
+
if (!e) return t;
|
1092
|
+
const {
|
1093
|
+
id: n,
|
1094
|
+
type: s,
|
1095
|
+
template: o,
|
1096
|
+
templateParameters: r
|
1097
|
+
} = e.options;
|
1098
|
+
return t = t.id(e.id).documentId(n), s && (t = t.schemaType(s)), o && (t = t.initialValueTemplate(o, r)), e.child && (t = t.child(e.child)), t;
|
1099
|
+
}
|
1100
|
+
function xe({
|
1101
|
+
resolveDocumentNode: i,
|
1102
|
+
templates: e
|
1103
|
+
}, t, n) {
|
1104
|
+
const s = e.find((o) => o.id === t);
|
1105
|
+
if (!s)
|
1106
|
+
throw new Error(`Template with ID "${t}" not defined`);
|
1107
|
+
return i({
|
1108
|
+
schemaType: s.schemaType
|
1109
|
+
}).initialValueTemplate(t, n);
|
1110
|
+
}
|
1111
|
+
class b {
|
1112
|
+
constructor(e, t) {
|
1113
|
+
/** Initial Value template item option object. See {@link InitialValueTemplateItem} */
|
1114
|
+
d(this, "spec");
|
1115
|
+
this._context = e, this.spec = t || {};
|
1116
|
+
}
|
1117
|
+
/** Set initial value template item builder ID
|
1118
|
+
* @param id - initial value template item ID
|
1119
|
+
* @returns initial value template item based on ID provided. See {@link InitialValueTemplateItemBuilder}
|
1120
|
+
*/
|
1121
|
+
id(e) {
|
1122
|
+
return this.clone({
|
1123
|
+
id: e
|
1124
|
+
});
|
1125
|
+
}
|
1126
|
+
/** Get initial value template item builder ID
|
1127
|
+
* @returns initial value template item ID. See {@link InitialValueTemplateItem}
|
1128
|
+
*/
|
1129
|
+
getId() {
|
1130
|
+
return this.spec.id;
|
1131
|
+
}
|
1132
|
+
/** Set initial value template item title
|
1133
|
+
* @param title - initial value template item title
|
1134
|
+
* @returns initial value template item based on title provided. See {@link InitialValueTemplateItemBuilder}
|
1135
|
+
*/
|
1136
|
+
title(e) {
|
1137
|
+
return this.clone({
|
1138
|
+
title: e
|
1139
|
+
});
|
1140
|
+
}
|
1141
|
+
/** Get initial value template item title
|
1142
|
+
* @returns initial value template item title. See {@link InitialValueTemplateItem}
|
1143
|
+
*/
|
1144
|
+
getTitle() {
|
1145
|
+
return this.spec.title;
|
1146
|
+
}
|
1147
|
+
/** Set initial value template item description
|
1148
|
+
* @param description - initial value template item description
|
1149
|
+
* @returns initial value template item builder based on description provided. See {@link InitialValueTemplateItemBuilder}
|
1150
|
+
*/
|
1151
|
+
description(e) {
|
1152
|
+
return this.clone({
|
1153
|
+
description: e
|
1154
|
+
});
|
1155
|
+
}
|
1156
|
+
/** Get initial value template item description
|
1157
|
+
* @returns initial value template item description. See {@link InitialValueTemplateItem}
|
1158
|
+
*/
|
1159
|
+
getDescription() {
|
1160
|
+
return this.spec.description;
|
1161
|
+
}
|
1162
|
+
/** Set initial value template ID
|
1163
|
+
* @param templateId - initial value template item template ID
|
1164
|
+
* @returns initial value template item based builder on template ID provided. See {@link InitialValueTemplateItemBuilder}
|
1165
|
+
*/
|
1166
|
+
templateId(e) {
|
1167
|
+
const t = this.spec.id || e;
|
1168
|
+
return this.clone({
|
1169
|
+
id: t,
|
1170
|
+
templateId: e
|
1171
|
+
});
|
1172
|
+
}
|
1173
|
+
/** Get initial value template item template ID
|
1174
|
+
* @returns initial value template item ID. See {@link InitialValueTemplateItem}
|
1175
|
+
*/
|
1176
|
+
getTemplateId() {
|
1177
|
+
return this.spec.templateId;
|
1178
|
+
}
|
1179
|
+
/** Get initial value template item template parameters
|
1180
|
+
* @param parameters - initial value template item parameters
|
1181
|
+
* @returns initial value template item builder based on parameters provided. See {@link InitialValueTemplateItemBuilder}
|
1182
|
+
*/
|
1183
|
+
parameters(e) {
|
1184
|
+
return this.clone({
|
1185
|
+
parameters: e
|
1186
|
+
});
|
1187
|
+
}
|
1188
|
+
/** Get initial value template item template parameters
|
1189
|
+
* @returns initial value template item parameters. See {@link InitialValueTemplateItem}
|
1190
|
+
*/
|
1191
|
+
getParameters() {
|
1192
|
+
return this.spec.parameters;
|
1193
|
+
}
|
1194
|
+
/** Serialize initial value template item
|
1195
|
+
* @param options - serialization options. See {@link SerializeOptions}
|
1196
|
+
* @returns initial value template item object based on the path, index and hint provided in options. See {@link InitialValueTemplateItem}
|
1197
|
+
*/
|
1198
|
+
serialize({
|
1199
|
+
path: e = [],
|
1200
|
+
index: t,
|
1201
|
+
hint: n
|
1202
|
+
} = {
|
1203
|
+
path: []
|
1204
|
+
}) {
|
1205
|
+
const {
|
1206
|
+
spec: s,
|
1207
|
+
_context: o
|
1208
|
+
} = this, {
|
1209
|
+
templates: r
|
1210
|
+
} = o;
|
1211
|
+
if (typeof s.id != "string" || !s.id)
|
1212
|
+
throw new a("`id` is required for initial value template item nodes", e, t, n).withHelpUrl(p.ID_REQUIRED);
|
1213
|
+
if (!s.templateId)
|
1214
|
+
throw new a("template id (`templateId`) is required for initial value template item nodes", e, s.id, n).withHelpUrl(p.ID_REQUIRED);
|
1215
|
+
const c = r.find((l) => l.id === s.templateId);
|
1216
|
+
if (!c)
|
1217
|
+
throw new a("template id (`templateId`) is required for initial value template item nodes", e, s.id, n).withHelpUrl(p.ID_REQUIRED);
|
1218
|
+
return {
|
1219
|
+
id: s.id,
|
1220
|
+
templateId: s.id,
|
1221
|
+
schemaType: c.schemaType,
|
1222
|
+
type: "initialValueTemplateItem",
|
1223
|
+
description: s.description || c.description,
|
1224
|
+
title: s.title || c.title,
|
1225
|
+
subtitle: s.subtitle,
|
1226
|
+
icon: s.icon || c.icon,
|
1227
|
+
initialDocumentId: s.initialDocumentId,
|
1228
|
+
parameters: s.parameters
|
1229
|
+
};
|
1230
|
+
}
|
1231
|
+
/** Clone generic view builder (allows for options overriding)
|
1232
|
+
* @param withSpec - initial value template item builder options. See {@link InitialValueTemplateItemBuilder}
|
1233
|
+
* @returns initial value template item builder based on the context and options provided. See {@link InitialValueTemplateItemBuilder}
|
1234
|
+
*/
|
1235
|
+
clone(e = {}) {
|
1236
|
+
const t = new b(this._context);
|
1237
|
+
return t.spec = {
|
1238
|
+
...this.spec,
|
1239
|
+
...e
|
1240
|
+
}, t;
|
1241
|
+
}
|
1242
|
+
}
|
1243
|
+
function Ve(i) {
|
1244
|
+
const {
|
1245
|
+
schema: e,
|
1246
|
+
getStructureBuilder: t,
|
1247
|
+
templates: n
|
1248
|
+
} = i, s = e.getTypeNames();
|
1249
|
+
return n.filter((r) => {
|
1250
|
+
var c;
|
1251
|
+
return !((c = r.parameters) != null && c.length);
|
1252
|
+
}).sort((r, c) => s.indexOf(r.schemaType) - s.indexOf(c.schemaType)).map((r) => t().initialValueTemplateItem(r.id));
|
1253
|
+
}
|
1254
|
+
function ze(i, e, t) {
|
1255
|
+
return i instanceof b ? i.serialize({
|
1256
|
+
path: t,
|
1257
|
+
index: e
|
1258
|
+
}) : i;
|
1259
|
+
}
|
1260
|
+
function Fe(i, e) {
|
1261
|
+
const {
|
1262
|
+
schema: t,
|
1263
|
+
templates: n
|
1264
|
+
} = i;
|
1265
|
+
return e.map((s) => {
|
1266
|
+
const o = n.find((E) => E.id === s.templateId), r = s.title || (o == null ? void 0 : o.title) || "Create", c = {};
|
1267
|
+
o && o.schemaType && (c.type = o.schemaType), s.templateId && (c.template = s.templateId);
|
1268
|
+
const l = s.parameters ? [c, s.parameters] : c, u = o && t.get(o.schemaType), h = s.i18n || (o == null ? void 0 : o.i18n);
|
1269
|
+
let m = new y(i).title(r).icon(o && o.icon || (u == null ? void 0 : u.icon) || P).intent({
|
1270
|
+
type: "create",
|
1271
|
+
params: l
|
1272
|
+
});
|
1273
|
+
return h && (m = m.i18n(h)), m.serialize();
|
1274
|
+
});
|
1275
|
+
}
|
1276
|
+
const Z = Symbol("Document type list canHandleIntent"), F = (i, e, {
|
1277
|
+
pane: t
|
1278
|
+
}) => {
|
1279
|
+
var h, m;
|
1280
|
+
const n = i === "edit", s = i === "create", o = t, r = ((h = o.options) == null ? void 0 : h.filter) || "", c = ((m = o.options) == null ? void 0 : m.params) || {}, l = o.schemaTypeName ? [o.schemaTypeName] : $(r, c), u = o.initialValueTemplates || [];
|
1281
|
+
return s && e.template ? u.some((E) => E.templateId === e.template) : n && e.id && l.includes(e.type) || s && l.includes(e.type);
|
1282
|
+
};
|
1283
|
+
F.identity = Z;
|
1284
|
+
const L = ["default", "card", "media", "detail", "block"];
|
1285
|
+
function $e() {
|
1286
|
+
}
|
1287
|
+
const ee = (i, e, {
|
1288
|
+
pane: t,
|
1289
|
+
index: n
|
1290
|
+
}) => n <= 1 && F(i, e, {
|
1291
|
+
pane: t
|
1292
|
+
});
|
1293
|
+
class te {
|
1294
|
+
constructor() {
|
1295
|
+
/** Check if initial value templates are set */
|
1296
|
+
d(this, "initialValueTemplatesSpecified", !1);
|
1297
|
+
/** Generic list option object */
|
1298
|
+
d(this, "spec", {});
|
1299
|
+
}
|
1300
|
+
/** Set generic list ID
|
1301
|
+
* @param id - generic list ID
|
1302
|
+
* @returns generic list builder based on ID provided.
|
1303
|
+
*/
|
1304
|
+
id(e) {
|
1305
|
+
return this.clone({
|
1306
|
+
id: e
|
1307
|
+
});
|
1308
|
+
}
|
1309
|
+
/** Get generic list ID
|
1310
|
+
* @returns generic list ID
|
1311
|
+
*/
|
1312
|
+
getId() {
|
1313
|
+
return this.spec.id;
|
1314
|
+
}
|
1315
|
+
/** Set generic list title
|
1316
|
+
* @param title - generic list title
|
1317
|
+
* @returns generic list builder based on title and ID provided.
|
1318
|
+
*/
|
1319
|
+
title(e) {
|
1320
|
+
return this.clone({
|
1321
|
+
title: e,
|
1322
|
+
id: C(e, this.spec.id)
|
1323
|
+
});
|
1324
|
+
}
|
1325
|
+
/** Get generic list title
|
1326
|
+
* @returns generic list title
|
1327
|
+
*/
|
1328
|
+
getTitle() {
|
1329
|
+
return this.spec.title;
|
1330
|
+
}
|
1331
|
+
/** Set the i18n key and namespace used to populate the localized title.
|
1332
|
+
* @param i18n - the key and namespaced used to populate the localized title.
|
1333
|
+
* @returns component builder based on i18n key and ns provided
|
1334
|
+
*/
|
1335
|
+
i18n(e) {
|
1336
|
+
return this.clone({
|
1337
|
+
i18n: e
|
1338
|
+
});
|
1339
|
+
}
|
1340
|
+
/** Get i18n key and namespace used to populate the localized title
|
1341
|
+
* @returns the i18n key and namespace used to populate the localized title
|
1342
|
+
*/
|
1343
|
+
getI18n() {
|
1344
|
+
return this.spec.i18n;
|
1345
|
+
}
|
1346
|
+
/** Set generic list layout
|
1347
|
+
* @param defaultLayout - generic list layout key.
|
1348
|
+
* @returns generic list builder based on layout provided.
|
1349
|
+
*/
|
1350
|
+
defaultLayout(e) {
|
1351
|
+
return this.clone({
|
1352
|
+
defaultLayout: e
|
1353
|
+
});
|
1354
|
+
}
|
1355
|
+
/** Get generic list layout
|
1356
|
+
* @returns generic list layout
|
1357
|
+
*/
|
1358
|
+
getDefaultLayout() {
|
1359
|
+
return this.spec.defaultLayout;
|
1360
|
+
}
|
1361
|
+
/** Set generic list menu items
|
1362
|
+
* @param menuItems - generic list menu items. See {@link MenuItem} and {@link MenuItemBuilder}
|
1363
|
+
* @returns generic list builder based on menu items provided.
|
1364
|
+
*/
|
1365
|
+
menuItems(e) {
|
1366
|
+
return this.clone({
|
1367
|
+
menuItems: e
|
1368
|
+
});
|
1369
|
+
}
|
1370
|
+
/** Get generic list menu items
|
1371
|
+
* @returns generic list menu items
|
1372
|
+
*/
|
1373
|
+
getMenuItems() {
|
1374
|
+
return this.spec.menuItems;
|
1375
|
+
}
|
1376
|
+
/** Set generic list menu item groups
|
1377
|
+
* @param menuItemGroups - generic list menu item groups. See {@link MenuItemGroup} and {@link MenuItemGroupBuilder}
|
1378
|
+
* @returns generic list builder based on menu item groups provided.
|
1379
|
+
*/
|
1380
|
+
menuItemGroups(e) {
|
1381
|
+
return this.clone({
|
1382
|
+
menuItemGroups: e
|
1383
|
+
});
|
1384
|
+
}
|
1385
|
+
/** Get generic list menu item groups
|
1386
|
+
* @returns generic list menu item groups
|
1387
|
+
*/
|
1388
|
+
getMenuItemGroups() {
|
1389
|
+
return this.spec.menuItemGroups;
|
1390
|
+
}
|
1391
|
+
/** Set generic list child
|
1392
|
+
* @param child - generic list child. See {@link Child}
|
1393
|
+
* @returns generic list builder based on child provided (clone).
|
1394
|
+
*/
|
1395
|
+
child(e) {
|
1396
|
+
return this.clone({
|
1397
|
+
child: e
|
1398
|
+
});
|
1399
|
+
}
|
1400
|
+
/** Get generic list child
|
1401
|
+
* @returns generic list child
|
1402
|
+
*/
|
1403
|
+
getChild() {
|
1404
|
+
return this.spec.child;
|
1405
|
+
}
|
1406
|
+
/** Set generic list can handle intent
|
1407
|
+
* @param canHandleIntent - generic list intent checker. See {@link IntentChecker}
|
1408
|
+
* @returns generic list builder based on can handle intent provided.
|
1409
|
+
*/
|
1410
|
+
canHandleIntent(e) {
|
1411
|
+
return this.clone({
|
1412
|
+
canHandleIntent: e
|
1413
|
+
});
|
1414
|
+
}
|
1415
|
+
/** Get generic list can handle intent
|
1416
|
+
* @returns generic list can handle intent
|
1417
|
+
*/
|
1418
|
+
getCanHandleIntent() {
|
1419
|
+
return this.spec.canHandleIntent;
|
1420
|
+
}
|
1421
|
+
/** Set generic list display options
|
1422
|
+
* @param enabled - allow / disallow for showing icons
|
1423
|
+
* @returns generic list builder based on display options (showIcons) provided.
|
1424
|
+
*/
|
1425
|
+
showIcons(e = !0) {
|
1426
|
+
return this.clone({
|
1427
|
+
displayOptions: {
|
1428
|
+
...this.spec.displayOptions,
|
1429
|
+
showIcons: e
|
1430
|
+
}
|
1431
|
+
});
|
1432
|
+
}
|
1433
|
+
/** Get generic list display options
|
1434
|
+
* @returns generic list display options (specifically showIcons)
|
1435
|
+
*/
|
1436
|
+
getShowIcons() {
|
1437
|
+
return this.spec.displayOptions ? this.spec.displayOptions.showIcons : void 0;
|
1438
|
+
}
|
1439
|
+
/** Set generic list initial value templates
|
1440
|
+
* @param templates - generic list initial value templates. See {@link InitialValueTemplateItemBuilder}
|
1441
|
+
* @returns generic list builder based on templates provided.
|
1442
|
+
*/
|
1443
|
+
initialValueTemplates(e) {
|
1444
|
+
return this.initialValueTemplatesSpecified = !0, this.clone({
|
1445
|
+
initialValueTemplates: Array.isArray(e) ? e : [e]
|
1446
|
+
});
|
1447
|
+
}
|
1448
|
+
/** Get generic list initial value templates
|
1449
|
+
* @returns generic list initial value templates
|
1450
|
+
*/
|
1451
|
+
getInitialValueTemplates() {
|
1452
|
+
return this.spec.initialValueTemplates;
|
1453
|
+
}
|
1454
|
+
/** Serialize generic list
|
1455
|
+
* @param options - serialization options. See {@link SerializeOptions}
|
1456
|
+
* @returns generic list object based on path provided in options. See {@link GenericList}
|
1457
|
+
*/
|
1458
|
+
serialize(e = {
|
1459
|
+
path: []
|
1460
|
+
}) {
|
1461
|
+
const t = this.spec.id || "", n = e.path, s = this.spec.defaultLayout;
|
1462
|
+
if (s && !L.includes(s))
|
1463
|
+
throw new a(`\`layout\` must be one of ${L.map((r) => `"${r}"`).join(", ")}`, n, t || e.index, this.spec.title);
|
1464
|
+
const o = (this.spec.initialValueTemplates || []).map((r, c) => ze(r, c, n));
|
1465
|
+
return {
|
1466
|
+
id: R(t, e.path, t || e.index),
|
1467
|
+
title: this.spec.title,
|
1468
|
+
i18n: this.spec.i18n,
|
1469
|
+
type: "genericList",
|
1470
|
+
defaultLayout: s,
|
1471
|
+
child: this.spec.child || $e,
|
1472
|
+
canHandleIntent: this.spec.canHandleIntent || ee,
|
1473
|
+
displayOptions: this.spec.displayOptions,
|
1474
|
+
initialValueTemplates: o,
|
1475
|
+
menuItems: (this.spec.menuItems || []).map((r, c) => k(r, c, n)),
|
1476
|
+
menuItemGroups: (this.spec.menuItemGroups || []).map((r, c) => j(r, c, n))
|
1477
|
+
};
|
1478
|
+
}
|
1479
|
+
}
|
1480
|
+
const qe = (i, e) => {
|
1481
|
+
var n;
|
1482
|
+
const t = ((n = i.options) == null ? void 0 : n.filter.trim()) || "";
|
1483
|
+
if (["*", "{"].includes(t[0]))
|
1484
|
+
throw new a(`\`filter\` cannot start with \`${t[0]}\` - looks like you are providing a query, not a filter`, e.path, i.id, i.title).withHelpUrl(p.QUERY_PROVIDED_FOR_FILTER);
|
1485
|
+
return t;
|
1486
|
+
}, He = (i) => (e, t) => {
|
1487
|
+
var r;
|
1488
|
+
const n = t.parent, s = (r = t.params) != null && r.template ? i.templates.find((c) => c.id === t.params.template) : void 0, o = s ? s.schemaType : n.schemaTypeName || X(i.getClient, e);
|
1489
|
+
return Promise.resolve(o).then((c) => c ? i.resolveDocumentNode({
|
1490
|
+
schemaType: c,
|
1491
|
+
documentId: e
|
1492
|
+
}) : new w(i).id("editor").documentId(e).schemaType(""));
|
1493
|
+
};
|
1494
|
+
class S extends te {
|
1495
|
+
constructor(t, n) {
|
1496
|
+
super();
|
1497
|
+
/** Document list options. See {@link PartialDocumentList} */
|
1498
|
+
d(this, "spec");
|
1499
|
+
this._context = t, this.spec = n || {}, this.initialValueTemplatesSpecified = !!(n != null && n.initialValueTemplates);
|
1500
|
+
}
|
1501
|
+
/** Set API version
|
1502
|
+
* @param apiVersion - API version
|
1503
|
+
* @returns document list builder based on the options and API version provided. See {@link DocumentListBuilder}
|
1504
|
+
*/
|
1505
|
+
apiVersion(t) {
|
1506
|
+
return this.clone({
|
1507
|
+
options: {
|
1508
|
+
...this.spec.options || {
|
1509
|
+
filter: ""
|
1510
|
+
},
|
1511
|
+
apiVersion: t
|
1512
|
+
}
|
1513
|
+
});
|
1514
|
+
}
|
1515
|
+
/** Get API version
|
1516
|
+
* @returns API version
|
1517
|
+
*/
|
1518
|
+
getApiVersion() {
|
1519
|
+
var t;
|
1520
|
+
return (t = this.spec.options) == null ? void 0 : t.apiVersion;
|
1521
|
+
}
|
1522
|
+
/** Set Document list filter
|
1523
|
+
* @param filter - GROQ-filter used to determine which documents to display. Do not support joins, since they operate on individual documents, and will ignore order-clauses and projections. See {@link https://www.sanity.io/docs/realtime-updates}
|
1524
|
+
* @returns document list builder based on the options and filter provided. See {@link DocumentListBuilder}
|
1525
|
+
*/
|
1526
|
+
filter(t) {
|
1527
|
+
return this.clone({
|
1528
|
+
options: {
|
1529
|
+
...this.spec.options,
|
1530
|
+
filter: t
|
1531
|
+
}
|
1532
|
+
});
|
1533
|
+
}
|
1534
|
+
/** Get Document list filter
|
1535
|
+
* @returns filter
|
1536
|
+
*/
|
1537
|
+
getFilter() {
|
1538
|
+
var t;
|
1539
|
+
return (t = this.spec.options) == null ? void 0 : t.filter;
|
1540
|
+
}
|
1541
|
+
/** Set Document list schema type name
|
1542
|
+
* @param type - schema type name.
|
1543
|
+
* @returns document list builder based on the schema type name provided. See {@link DocumentListBuilder}
|
1544
|
+
*/
|
1545
|
+
schemaType(t) {
|
1546
|
+
const n = typeof t == "string" ? t : t.name;
|
1547
|
+
return this.clone({
|
1548
|
+
schemaTypeName: n
|
1549
|
+
});
|
1550
|
+
}
|
1551
|
+
/** Get Document list schema type name
|
1552
|
+
* @returns schema type name
|
1553
|
+
*/
|
1554
|
+
getSchemaType() {
|
1555
|
+
return this.spec.schemaTypeName;
|
1556
|
+
}
|
1557
|
+
/** Set Document list options' parameters
|
1558
|
+
* @param params - parameters
|
1559
|
+
* @returns document list builder based on the options provided. See {@link DocumentListBuilder}
|
1560
|
+
*/
|
1561
|
+
params(t) {
|
1562
|
+
return this.clone({
|
1563
|
+
options: {
|
1564
|
+
...this.spec.options || {
|
1565
|
+
filter: ""
|
1566
|
+
},
|
1567
|
+
params: t
|
1568
|
+
}
|
1569
|
+
});
|
1570
|
+
}
|
1571
|
+
/** Get Document list options' parameters
|
1572
|
+
* @returns options
|
1573
|
+
*/
|
1574
|
+
getParams() {
|
1575
|
+
var t;
|
1576
|
+
return (t = this.spec.options) == null ? void 0 : t.params;
|
1577
|
+
}
|
1578
|
+
/** Set Document list default ordering
|
1579
|
+
* @param ordering - default sort ordering array. See {@link SortOrderingItem}
|
1580
|
+
* @returns document list builder based on ordering provided. See {@link DocumentListBuilder}
|
1581
|
+
*/
|
1582
|
+
defaultOrdering(t) {
|
1583
|
+
if (!Array.isArray(t))
|
1584
|
+
throw new Error("`defaultOrdering` must be an array of order clauses");
|
1585
|
+
return this.clone({
|
1586
|
+
options: {
|
1587
|
+
...this.spec.options || {
|
1588
|
+
filter: ""
|
1589
|
+
},
|
1590
|
+
defaultOrdering: t
|
1591
|
+
}
|
1592
|
+
});
|
1593
|
+
}
|
1594
|
+
/** Get Document list default ordering
|
1595
|
+
* @returns default ordering. See {@link SortOrderingItem}
|
1596
|
+
*/
|
1597
|
+
getDefaultOrdering() {
|
1598
|
+
var t;
|
1599
|
+
return (t = this.spec.options) == null ? void 0 : t.defaultOrdering;
|
1600
|
+
}
|
1601
|
+
/** Serialize Document list
|
1602
|
+
* @param options - serialization options. See {@link SerializeOptions}
|
1603
|
+
* @returns document list object based on path provided in options. See {@link DocumentList}
|
1604
|
+
*/
|
1605
|
+
serialize(t = {
|
1606
|
+
path: []
|
1607
|
+
}) {
|
1608
|
+
var s;
|
1609
|
+
if (typeof this.spec.id != "string" || !this.spec.id)
|
1610
|
+
throw new a("`id` is required for document lists", t.path, t.index, this.spec.title).withHelpUrl(p.ID_REQUIRED);
|
1611
|
+
if (!this.spec.options || !this.spec.options.filter)
|
1612
|
+
throw new a("`filter` is required for document lists", t.path, this.spec.id, this.spec.title).withHelpUrl(p.FILTER_REQUIRED);
|
1613
|
+
return !(((s = this.spec.options) == null ? void 0 : s.filter) === "_type == $type") && this.spec.options.filter && !this.spec.options.apiVersion && console.warn(`No apiVersion specified for document type list with custom filter: \`${this.spec.options.filter}\`. This will be required in the future. See %s for more info.`, _e(p.API_VERSION_REQUIRED_FOR_CUSTOM_FILTER)), {
|
1614
|
+
...super.serialize(t),
|
1615
|
+
type: "documentList",
|
1616
|
+
schemaTypeName: this.spec.schemaTypeName,
|
1617
|
+
child: this.spec.child || He(this._context),
|
1618
|
+
options: {
|
1619
|
+
...this.spec.options,
|
1620
|
+
// @todo: make specifying .apiVersion required when using custom (non-simple) filters in v4
|
1621
|
+
apiVersion: this.spec.options.apiVersion || M.apiVersion,
|
1622
|
+
filter: qe(this.spec, t)
|
1623
|
+
}
|
1624
|
+
};
|
1625
|
+
}
|
1626
|
+
/** Clone Document list builder (allows for options overriding)
|
1627
|
+
* @param withSpec - override document list spec. See {@link PartialDocumentList}
|
1628
|
+
* @returns document list builder. See {@link DocumentListBuilder}
|
1629
|
+
*/
|
1630
|
+
clone(t) {
|
1631
|
+
const n = new S(this._context);
|
1632
|
+
return n.spec = {
|
1633
|
+
...this.spec,
|
1634
|
+
...t
|
1635
|
+
}, this.initialValueTemplatesSpecified || (n.spec.initialValueTemplates = Le(this._context, n.spec)), n.spec.schemaTypeName || (n.spec.schemaTypeName = Me(n.spec)), n;
|
1636
|
+
}
|
1637
|
+
/** Get Document list spec
|
1638
|
+
* @returns document list spec. See {@link PartialDocumentList}
|
1639
|
+
*/
|
1640
|
+
getSpec() {
|
1641
|
+
return this.spec;
|
1642
|
+
}
|
1643
|
+
}
|
1644
|
+
function Le(i, e) {
|
1645
|
+
const {
|
1646
|
+
document: t
|
1647
|
+
} = i, {
|
1648
|
+
schemaTypeName: n,
|
1649
|
+
options: s
|
1650
|
+
} = e, {
|
1651
|
+
filter: o,
|
1652
|
+
params: r
|
1653
|
+
} = s || {
|
1654
|
+
filter: "",
|
1655
|
+
params: {}
|
1656
|
+
}, c = n ? [n] : Array.from(new Set($(o, r)));
|
1657
|
+
if (c.length !== 0)
|
1658
|
+
return c.flatMap((l) => t.resolveNewDocumentOptions({
|
1659
|
+
type: "structure",
|
1660
|
+
schemaType: l
|
1661
|
+
})).map((l) => ({
|
1662
|
+
...l,
|
1663
|
+
icon: P
|
1664
|
+
}));
|
1665
|
+
}
|
1666
|
+
function Me(i) {
|
1667
|
+
const {
|
1668
|
+
options: e
|
1669
|
+
} = i, {
|
1670
|
+
filter: t,
|
1671
|
+
params: n
|
1672
|
+
} = e || {
|
1673
|
+
filter: "",
|
1674
|
+
params: {}
|
1675
|
+
}, s = $(t, n);
|
1676
|
+
return s.length === 1 ? s[0] : void 0;
|
1677
|
+
}
|
1678
|
+
function $(i, e = {}) {
|
1679
|
+
let t = Qe(i, e);
|
1680
|
+
return t.length === 0 && (t = Pe(i, e)), t;
|
1681
|
+
}
|
1682
|
+
function Qe(i, e = {}) {
|
1683
|
+
const t = /\b_type\s*==\s*(['"].*?['"]|\$.*?(?:\s|$))|\B(['"].*?['"]|\$.*?(?:\s|$))\s*==\s*_type/g, n = [];
|
1684
|
+
let s;
|
1685
|
+
for (; (s = t.exec(i)) !== null; )
|
1686
|
+
n.push(s[1] || s[2]);
|
1687
|
+
return n.map((o) => ((o[0] === "$" ? e[o.slice(1)] : o) || "").trim().replace(/^["']|["']$/g, "")).filter(Boolean);
|
1688
|
+
}
|
1689
|
+
function Pe(i, e = {}) {
|
1690
|
+
const t = /\b_type\s+in\s+\[(.*?)\]/, n = i.match(t);
|
1691
|
+
return n ? n[1].split(/,\s*/).map((s) => s.trim().replace(/^["']+|["']+$/g, "")).map((s) => s[0] === "$" ? e[s.slice(1)] : s).filter(Boolean) : [];
|
1692
|
+
}
|
1693
|
+
const Be = (i) => i instanceof g ? "ListBuilder" : We(i) ? "Promise" : Array.isArray(i) ? "array" : typeof i, ke = (i) => i.type === "listItem", Ge = (i, e, t) => (t.pane.items || []).filter(Je).some((o) => o.schemaType.name === e.type && o._id === e.id) || ee(i, e, t), Ye = (i, e) => {
|
1694
|
+
const s = (e.parent.items.filter(ke).find((o) => o.id === i) || {
|
1695
|
+
child: void 0
|
1696
|
+
}).child;
|
1697
|
+
return !s || typeof s != "function" ? s : typeof s == "function" ? s(i, e) : s;
|
1698
|
+
};
|
1699
|
+
function je(i, e, t) {
|
1700
|
+
if (i instanceof _)
|
1701
|
+
return i.serialize({
|
1702
|
+
path: t,
|
1703
|
+
index: e
|
1704
|
+
});
|
1705
|
+
if (i instanceof O)
|
1706
|
+
return i.serialize();
|
1707
|
+
const n = i;
|
1708
|
+
if (n && n.type === "divider")
|
1709
|
+
return i;
|
1710
|
+
if (!n || n.type !== "listItem") {
|
1711
|
+
const s = n && n.type || Be(n), o = s === "array" ? " - did you forget to spread (...moreItems)?" : "";
|
1712
|
+
throw new a(`List items must be of type "listItem", got "${s}"${o}`, t, e).withHelpUrl(p.INVALID_LIST_ITEM);
|
1713
|
+
}
|
1714
|
+
return i;
|
1715
|
+
}
|
1716
|
+
function We(i) {
|
1717
|
+
return V(i) && typeof i.then == "function";
|
1718
|
+
}
|
1719
|
+
class g extends te {
|
1720
|
+
constructor(t, n) {
|
1721
|
+
super();
|
1722
|
+
/** buildable list option object. See {@link BuildableList} */
|
1723
|
+
d(this, "spec");
|
1724
|
+
this._context = t, this.spec = n || {}, this.initialValueTemplatesSpecified = !!(n && n.initialValueTemplates);
|
1725
|
+
}
|
1726
|
+
/**
|
1727
|
+
* Set list builder based on items provided
|
1728
|
+
* @param items - list items. See {@link ListItemBuilder}, {@link ListItem} and {@link Divider}
|
1729
|
+
* @returns list builder based on items provided. See {@link ListBuilder}
|
1730
|
+
*/
|
1731
|
+
items(t) {
|
1732
|
+
return this.clone({
|
1733
|
+
items: t
|
1734
|
+
});
|
1735
|
+
}
|
1736
|
+
/** Get list builder items
|
1737
|
+
* @returns list items. See {@link BuildableList}
|
1738
|
+
*/
|
1739
|
+
getItems() {
|
1740
|
+
return this.spec.items;
|
1741
|
+
}
|
1742
|
+
/** Serialize list builder
|
1743
|
+
* @param options - serialization options. See {@link SerializeOptions}
|
1744
|
+
* @returns list based on path in options. See {@link List}
|
1745
|
+
*/
|
1746
|
+
serialize(t = {
|
1747
|
+
path: []
|
1748
|
+
}) {
|
1749
|
+
const n = this.spec.id;
|
1750
|
+
if (typeof n != "string" || !n)
|
1751
|
+
throw new a("`id` is required for lists", t.path, t.index).withHelpUrl(p.ID_REQUIRED);
|
1752
|
+
const s = typeof this.spec.items > "u" ? [] : this.spec.items;
|
1753
|
+
if (!Array.isArray(s))
|
1754
|
+
throw new a("`items` must be an array of items", t.path, t.index).withHelpUrl(p.LIST_ITEMS_MUST_BE_ARRAY);
|
1755
|
+
const o = (t.path || []).concat(n), r = s.map((l, u) => je(l, u, o)), c = r.filter((l, u) => I.find(r, {
|
1756
|
+
id: l.id
|
1757
|
+
}, u + 1));
|
1758
|
+
if (c.length > 0) {
|
1759
|
+
const l = c.map((h) => h.id).slice(0, 5), u = c.length > 5 ? `${l.join(", ")}...` : l.join(", ");
|
1760
|
+
throw new a(`List items with same ID found (${u})`, t.path, t.index).withHelpUrl(p.LIST_ITEM_IDS_MUST_BE_UNIQUE);
|
1761
|
+
}
|
1762
|
+
return {
|
1763
|
+
...super.serialize(t),
|
1764
|
+
type: "list",
|
1765
|
+
canHandleIntent: this.spec.canHandleIntent || Ge,
|
1766
|
+
child: this.spec.child || Ye,
|
1767
|
+
items: r
|
1768
|
+
};
|
1769
|
+
}
|
1770
|
+
/**
|
1771
|
+
* Clone list builder and return new list builder based on context and spec provided
|
1772
|
+
* @param withSpec - list options. See {@link BuildableList}
|
1773
|
+
* @returns new list builder based on context and spec provided. See {@link ListBuilder}
|
1774
|
+
*/
|
1775
|
+
clone(t) {
|
1776
|
+
const n = new g(this._context);
|
1777
|
+
return n.spec = {
|
1778
|
+
...this.spec,
|
1779
|
+
...t
|
1780
|
+
}, n;
|
1781
|
+
}
|
1782
|
+
}
|
1783
|
+
class _ {
|
1784
|
+
constructor(e, t) {
|
1785
|
+
/** List item option object. See {@link PartialListItem} */
|
1786
|
+
d(this, "spec");
|
1787
|
+
this._context = e, this.spec = t || {};
|
1788
|
+
}
|
1789
|
+
/**
|
1790
|
+
* Set list item ID
|
1791
|
+
* @returns list item builder based on ID provided. See {@link ListItemBuilder}
|
1792
|
+
*/
|
1793
|
+
id(e) {
|
1794
|
+
return this.clone({
|
1795
|
+
id: e
|
1796
|
+
});
|
1797
|
+
}
|
1798
|
+
/**
|
1799
|
+
* Get list item ID
|
1800
|
+
* @returns list item ID. See {@link PartialListItem}
|
1801
|
+
*/
|
1802
|
+
getId() {
|
1803
|
+
return this.spec.id;
|
1804
|
+
}
|
1805
|
+
/**
|
1806
|
+
* Set list item title
|
1807
|
+
* @returns list item builder based on title provided. See {@link ListItemBuilder}
|
1808
|
+
*/
|
1809
|
+
title(e) {
|
1810
|
+
return this.clone({
|
1811
|
+
title: e,
|
1812
|
+
id: C(e, this.spec.id)
|
1813
|
+
});
|
1814
|
+
}
|
1815
|
+
/**
|
1816
|
+
* Get list item title
|
1817
|
+
* @returns list item title. See {@link PartialListItem}
|
1818
|
+
*/
|
1819
|
+
getTitle() {
|
1820
|
+
return this.spec.title;
|
1821
|
+
}
|
1822
|
+
/** Set the i18n key and namespace used to populate the localized title.
|
1823
|
+
* @param i18n - the key and namespaced used to populate the localized title.
|
1824
|
+
* @returns component builder based on i18n key and ns provided
|
1825
|
+
*/
|
1826
|
+
i18n(e) {
|
1827
|
+
return this.clone({
|
1828
|
+
i18n: e
|
1829
|
+
});
|
1830
|
+
}
|
1831
|
+
/** Get i18n key and namespace used to populate the localized title
|
1832
|
+
* @returns the i18n key and namespace used to populate the localized title
|
1833
|
+
*/
|
1834
|
+
getI18n() {
|
1835
|
+
return this.spec.i18n;
|
1836
|
+
}
|
1837
|
+
/**
|
1838
|
+
* Set list item icon
|
1839
|
+
* @returns list item builder based on icon provided. See {@link ListItemBuilder}
|
1840
|
+
*/
|
1841
|
+
icon(e) {
|
1842
|
+
return this.clone({
|
1843
|
+
icon: e
|
1844
|
+
});
|
1845
|
+
}
|
1846
|
+
/**
|
1847
|
+
* Set if list item should show icon
|
1848
|
+
* @returns list item builder based on showIcon provided. See {@link ListItemBuilder}
|
1849
|
+
*/
|
1850
|
+
showIcon(e = !0) {
|
1851
|
+
return this.clone({
|
1852
|
+
displayOptions: {
|
1853
|
+
...this.spec.displayOptions,
|
1854
|
+
showIcon: e
|
1855
|
+
}
|
1856
|
+
});
|
1857
|
+
}
|
1858
|
+
/**
|
1859
|
+
* Check if list item should show icon
|
1860
|
+
* @returns true if it should show the icon, false if not, undefined if not set
|
1861
|
+
*/
|
1862
|
+
getShowIcon() {
|
1863
|
+
return this.spec.displayOptions ? this.spec.displayOptions.showIcon : void 0;
|
1864
|
+
}
|
1865
|
+
/**
|
1866
|
+
*Get list item icon
|
1867
|
+
* @returns list item icon. See {@link PartialListItem}
|
1868
|
+
*/
|
1869
|
+
getIcon() {
|
1870
|
+
return this.spec.icon;
|
1871
|
+
}
|
1872
|
+
/**
|
1873
|
+
* Set list item child
|
1874
|
+
* @param child - list item child. See {@link UnserializedListItemChild}
|
1875
|
+
* @returns list item builder based on child provided. See {@link ListItemBuilder}
|
1876
|
+
*/
|
1877
|
+
child(e) {
|
1878
|
+
return this.clone({
|
1879
|
+
child: e
|
1880
|
+
});
|
1881
|
+
}
|
1882
|
+
/**
|
1883
|
+
* Get list item child
|
1884
|
+
* @returns list item child. See {@link PartialListItem}
|
1885
|
+
*/
|
1886
|
+
getChild() {
|
1887
|
+
return this.spec.child;
|
1888
|
+
}
|
1889
|
+
/**
|
1890
|
+
* Set list item schema type
|
1891
|
+
* @param schemaType - list item schema type. See {@link SchemaType}
|
1892
|
+
* @returns list item builder based on schema type provided. See {@link ListItemBuilder}
|
1893
|
+
*/
|
1894
|
+
schemaType(e) {
|
1895
|
+
return this.clone({
|
1896
|
+
schemaType: e
|
1897
|
+
});
|
1898
|
+
}
|
1899
|
+
/**
|
1900
|
+
* Get list item schema type
|
1901
|
+
* @returns list item schema type. See {@link PartialListItem}
|
1902
|
+
*/
|
1903
|
+
getSchemaType() {
|
1904
|
+
const e = this.spec.schemaType;
|
1905
|
+
return typeof e == "string" ? this._context.schema.get(e) : this.spec.schemaType;
|
1906
|
+
}
|
1907
|
+
/** Serialize list item builder
|
1908
|
+
* @param options - serialization options. See {@link ListItemSerializeOptions}
|
1909
|
+
* @returns list item node based on path provided in options. See {@link ListItem}
|
1910
|
+
*/
|
1911
|
+
serialize(e = {
|
1912
|
+
path: []
|
1913
|
+
}) {
|
1914
|
+
const {
|
1915
|
+
id: t,
|
1916
|
+
title: n,
|
1917
|
+
child: s
|
1918
|
+
} = this.spec;
|
1919
|
+
if (typeof t != "string" || !t)
|
1920
|
+
throw new a("`id` is required for list items", e.path, e.index).withHelpUrl(p.ID_REQUIRED);
|
1921
|
+
if (!e.titleIsOptional && (typeof n != "string" || !n))
|
1922
|
+
throw new a("`title` is required for list items", e.path, t).withHelpUrl(p.TITLE_REQUIRED);
|
1923
|
+
let o = this.spec.schemaType;
|
1924
|
+
if (typeof o == "string") {
|
1925
|
+
const l = this._context.schema.get(o);
|
1926
|
+
if (!l)
|
1927
|
+
throw new a(`Could not find type "${o}" in schema`, e.path, t).withHelpUrl(p.SCHEMA_TYPE_NOT_FOUND);
|
1928
|
+
o = l;
|
1929
|
+
}
|
1930
|
+
const r = {
|
1931
|
+
path: e.path.concat(t),
|
1932
|
+
hint: "child"
|
1933
|
+
};
|
1934
|
+
let c = s instanceof D || s instanceof S || s instanceof w || s instanceof g ? s.serialize(r) : s;
|
1935
|
+
if (typeof c == "function") {
|
1936
|
+
const l = c;
|
1937
|
+
c = (u, h) => l(u, {
|
1938
|
+
...h,
|
1939
|
+
serializeOptions: r
|
1940
|
+
});
|
1941
|
+
}
|
1942
|
+
return {
|
1943
|
+
...this.spec,
|
1944
|
+
id: R(t, e.path, e.index),
|
1945
|
+
schemaType: o,
|
1946
|
+
child: c,
|
1947
|
+
title: n,
|
1948
|
+
type: "listItem"
|
1949
|
+
};
|
1950
|
+
}
|
1951
|
+
/** Clone list item builder
|
1952
|
+
* @param withSpec - partial list item options. See {@link PartialListItem}
|
1953
|
+
* @returns list item builder based on context and spec provided. See {@link ListItemBuilder}
|
1954
|
+
*/
|
1955
|
+
clone(e) {
|
1956
|
+
const t = new _(this._context);
|
1957
|
+
return t.spec = {
|
1958
|
+
...this.spec,
|
1959
|
+
...e
|
1960
|
+
}, t;
|
1961
|
+
}
|
1962
|
+
}
|
1963
|
+
const Xe = (i, e) => (t) => {
|
1964
|
+
const n = e.schemaType && (typeof e.schemaType == "string" ? e.schemaType : e.schemaType.name);
|
1965
|
+
return n ? i.resolveDocumentNode({
|
1966
|
+
schemaType: n,
|
1967
|
+
documentId: t
|
1968
|
+
}) : new w(i).id("documentEditor").documentId(t);
|
1969
|
+
};
|
1970
|
+
class q extends _ {
|
1971
|
+
constructor(t, n) {
|
1972
|
+
super(t, n);
|
1973
|
+
/** Document list options. See {@link PartialDocumentListItem} */
|
1974
|
+
d(this, "spec");
|
1975
|
+
this._context = t, this.spec = n || {};
|
1976
|
+
}
|
1977
|
+
/**
|
1978
|
+
* Serialize document list item
|
1979
|
+
* @param options - serialization options. See {@link SerializeOptions}
|
1980
|
+
* @returns document list item object based on path provided in options. See {@link DocumentListItem}
|
1981
|
+
*/
|
1982
|
+
serialize(t = {
|
1983
|
+
path: []
|
1984
|
+
}) {
|
1985
|
+
const n = super.serialize({
|
1986
|
+
...t,
|
1987
|
+
titleIsOptional: !0
|
1988
|
+
});
|
1989
|
+
if (!n.schemaType)
|
1990
|
+
throw new a("`schemaType` is required for document list items", t.path, t.index).withHelpUrl(p.SCHEMA_TYPE_REQUIRED);
|
1991
|
+
const s = n.child || Xe(this._context, n);
|
1992
|
+
return {
|
1993
|
+
...n,
|
1994
|
+
child: s,
|
1995
|
+
schemaType: n.schemaType,
|
1996
|
+
_id: n.id
|
1997
|
+
};
|
1998
|
+
}
|
1999
|
+
/** Clone Document list item builder (allows for options overriding)
|
2000
|
+
* @param withSpec - Document list item builder options. See {@link PartialDocumentListItem}
|
2001
|
+
* @returns document list item builder. See {@link DocumentListItemBuilder}
|
2002
|
+
*/
|
2003
|
+
clone(t) {
|
2004
|
+
const n = new q(this._context);
|
2005
|
+
return n.spec = {
|
2006
|
+
...this.spec,
|
2007
|
+
...t
|
2008
|
+
}, n;
|
2009
|
+
}
|
2010
|
+
}
|
2011
|
+
function Je(i) {
|
2012
|
+
return V(i) && typeof i.schemaType < "u" && typeof i._id == "string";
|
2013
|
+
}
|
2014
|
+
class v extends S {
|
2015
|
+
constructor(t, n) {
|
2016
|
+
super(t);
|
2017
|
+
/** Document list options. See {@link PartialDocumentList} */
|
2018
|
+
d(this, "spec");
|
2019
|
+
this._context = t, this.spec = n || {};
|
2020
|
+
}
|
2021
|
+
/**
|
2022
|
+
* Set Document type list child
|
2023
|
+
* @param child - Child component. See {@link Child}
|
2024
|
+
* @returns document type list builder based on child component provided without default intent handler. See {@link DocumentTypeListBuilder}
|
2025
|
+
*/
|
2026
|
+
child(t) {
|
2027
|
+
return this.cloneWithoutDefaultIntentHandler({
|
2028
|
+
child: t
|
2029
|
+
});
|
2030
|
+
}
|
2031
|
+
/** Clone Document type list builder (allows for options overriding)
|
2032
|
+
* @param withSpec - Document type list builder options. See {@link PartialDocumentList}
|
2033
|
+
* @returns document type list builder. See {@link DocumentTypeListBuilder}
|
2034
|
+
*/
|
2035
|
+
clone(t) {
|
2036
|
+
const n = super.clone(t), s = new v(this._context);
|
2037
|
+
return s.spec = {
|
2038
|
+
...this.spec,
|
2039
|
+
...n.getSpec(),
|
2040
|
+
...t
|
2041
|
+
}, s;
|
2042
|
+
}
|
2043
|
+
/** Clone Document type list builder (allows for options overriding) and remove default intent handler
|
2044
|
+
* @param withSpec - Document type list builder options. See {@link PartialDocumentList}
|
2045
|
+
* @returns document type list builder without default intent handler. See {@link DocumentTypeListBuilder}
|
2046
|
+
*/
|
2047
|
+
cloneWithoutDefaultIntentHandler(t) {
|
2048
|
+
const n = super.clone(t), s = new v(this._context), o = this.spec.canHandleIntent, c = o && o.identity === Z ? {
|
2049
|
+
canHandleIntent: void 0
|
2050
|
+
} : {};
|
2051
|
+
return s.spec = {
|
2052
|
+
...n.getSpec(),
|
2053
|
+
...this.spec,
|
2054
|
+
...t,
|
2055
|
+
...c
|
2056
|
+
}, s;
|
2057
|
+
}
|
2058
|
+
}
|
2059
|
+
const Ke = ["sanity.imageAsset", "sanity.fileAsset"];
|
2060
|
+
function Ze(i) {
|
2061
|
+
return Ke.includes(i);
|
2062
|
+
}
|
2063
|
+
function et(i) {
|
2064
|
+
var e;
|
2065
|
+
return ((e = i.type) == null ? void 0 : e.name) === "document";
|
2066
|
+
}
|
2067
|
+
function tt(i) {
|
2068
|
+
return i.type === "list";
|
2069
|
+
}
|
2070
|
+
function it({
|
2071
|
+
schema: i
|
2072
|
+
}) {
|
2073
|
+
return i.getTypeNames().filter((e) => {
|
2074
|
+
const t = i.get(e);
|
2075
|
+
return t && et(t);
|
2076
|
+
}).filter((e) => !Ze(e));
|
2077
|
+
}
|
2078
|
+
function ie(i) {
|
2079
|
+
return it(i).map((t) => ne(i, t));
|
2080
|
+
}
|
2081
|
+
function ne(i, e) {
|
2082
|
+
const {
|
2083
|
+
schema: t
|
2084
|
+
} = i, n = t.get(e);
|
2085
|
+
if (!n)
|
2086
|
+
throw new Error(`Schema type with name "${e}" not found`);
|
2087
|
+
const s = n.title || I.startCase(e);
|
2088
|
+
return new _(i).id(e).title(s).schemaType(n).child((o, r) => {
|
2089
|
+
const c = r.parent, l = tt(c) ? c.items.find((h) => h.id === o) : null;
|
2090
|
+
let u = se(i, e);
|
2091
|
+
return l && l.title && (u = u.title(l.title)), u;
|
2092
|
+
});
|
2093
|
+
}
|
2094
|
+
function se(i, e) {
|
2095
|
+
const {
|
2096
|
+
schema: t,
|
2097
|
+
resolveDocumentNode: n
|
2098
|
+
} = i, s = typeof e == "string" ? e : e.schemaType, o = typeof s == "string" ? s : s.name, r = typeof e == "string" ? {} : e, c = t.get(o);
|
2099
|
+
if (!c)
|
2100
|
+
throw new Error(`Schema type with name "${o}" not found`);
|
2101
|
+
const l = c.title || I.startCase(o);
|
2102
|
+
return new v(i).id(r.id || o).title(r.title || l).filter("_type == $type").params({
|
2103
|
+
type: o
|
2104
|
+
}).schemaType(c).defaultOrdering(Se.by).menuItemGroups(r.menuItemGroups || [{
|
2105
|
+
id: "sorting",
|
2106
|
+
title: "Sort",
|
2107
|
+
i18n: {
|
2108
|
+
title: {
|
2109
|
+
key: "menu-item-groups.actions-group",
|
2110
|
+
ns: f
|
2111
|
+
}
|
2112
|
+
}
|
2113
|
+
}, {
|
2114
|
+
id: "layout",
|
2115
|
+
title: "Layout",
|
2116
|
+
i18n: {
|
2117
|
+
title: {
|
2118
|
+
key: "menu-item-groups.layout-group",
|
2119
|
+
ns: f
|
2120
|
+
}
|
2121
|
+
}
|
2122
|
+
}, {
|
2123
|
+
id: "actions",
|
2124
|
+
title: "Actions",
|
2125
|
+
i18n: {
|
2126
|
+
title: {
|
2127
|
+
key: "menu-item-groups.sorting-group",
|
2128
|
+
ns: f
|
2129
|
+
}
|
2130
|
+
}
|
2131
|
+
}]).child(r.child || ((u) => n({
|
2132
|
+
schemaType: o,
|
2133
|
+
documentId: u
|
2134
|
+
}))).canHandleIntent(r.canHandleIntent || F).menuItems(r.menuItems || [
|
2135
|
+
// Create new (from action button) will be added in serialization step of GenericList
|
2136
|
+
// Sort by <Y>
|
2137
|
+
...Y(i, c),
|
2138
|
+
// Display as <Z>
|
2139
|
+
new y(i).group("layout").i18n({
|
2140
|
+
title: {
|
2141
|
+
key: "menu-items.layout.compact-view",
|
2142
|
+
ns: f
|
2143
|
+
}
|
2144
|
+
}).title("Compact view").icon(ye).action("setLayout").params({
|
2145
|
+
layout: "default"
|
2146
|
+
}),
|
2147
|
+
new y(i).group("layout").i18n({
|
2148
|
+
title: {
|
2149
|
+
key: "menu-items.layout.detailed-view",
|
2150
|
+
ns: f
|
2151
|
+
}
|
2152
|
+
}).title("Detailed view").icon(we).action("setLayout").params({
|
2153
|
+
layout: "detail"
|
2154
|
+
})
|
2155
|
+
// Create new (from menu) will be added in serialization step of GenericList
|
2156
|
+
]);
|
2157
|
+
}
|
2158
|
+
function nt(i) {
|
2159
|
+
return !i || typeof i == "string" ? !1 : !!i.icon;
|
2160
|
+
}
|
2161
|
+
function st(i) {
|
2162
|
+
const e = ie(i);
|
2163
|
+
return new g(i).id("__root__").title("Content").i18n({
|
2164
|
+
title: {
|
2165
|
+
key: "default-definition.content-title",
|
2166
|
+
ns: f
|
2167
|
+
}
|
2168
|
+
}).items(e).showIcons(e.some((t) => nt(t.getSchemaType())));
|
2169
|
+
}
|
2170
|
+
function rt({
|
2171
|
+
defaultDocumentNode: i,
|
2172
|
+
source: e,
|
2173
|
+
perspectiveStack: t
|
2174
|
+
}) {
|
2175
|
+
const n = ue(e), s = {
|
2176
|
+
...e,
|
2177
|
+
getStructureBuilder: () => o,
|
2178
|
+
resolveDocumentNode: (r) => {
|
2179
|
+
let c = (i == null ? void 0 : i(o, {
|
2180
|
+
...r,
|
2181
|
+
...n
|
2182
|
+
})) || new w(s);
|
2183
|
+
return c.getId() || (c = c.id("documentEditor")), r.documentId && (c = c.documentId(Q(r.documentId))), c.schemaType(r.schemaType);
|
2184
|
+
},
|
2185
|
+
perspectiveStack: t
|
2186
|
+
}, o = {
|
2187
|
+
defaults: () => st(s),
|
2188
|
+
documentTypeList: (...r) => se(s, ...r),
|
2189
|
+
documentTypeListItem: (...r) => ne(s, ...r),
|
2190
|
+
documentTypeListItems: (...r) => ie(s, ...r),
|
2191
|
+
document: (...r) => new w(s, ...r),
|
2192
|
+
documentWithInitialValueTemplate: (...r) => xe(s, ...r),
|
2193
|
+
defaultDocument: s.resolveDocumentNode,
|
2194
|
+
list: (...r) => new g(s, ...r),
|
2195
|
+
listItem: (...r) => new _(s, ...r),
|
2196
|
+
menuItem: (...r) => new y(s, ...r),
|
2197
|
+
menuItemGroup: (...r) => new T(s, ...r),
|
2198
|
+
menuItemsFromInitialValueTemplateItems: (...r) => Fe(s, ...r),
|
2199
|
+
documentList: (...r) => new S(s, ...r),
|
2200
|
+
documentListItem: (...r) => new q(s, ...r),
|
2201
|
+
orderingMenuItem: (...r) => G(s, ...r),
|
2202
|
+
orderingMenuItemsForType: (...r) => Y(s, ...r),
|
2203
|
+
editor: (...r) => be(s, ...r),
|
2204
|
+
defaultInitialValueTemplateItems: (...r) => Ve(s, ...r),
|
2205
|
+
initialValueTemplateItem: (r, c) => new b(s, {
|
2206
|
+
id: r,
|
2207
|
+
parameters: c,
|
2208
|
+
templateId: r
|
2209
|
+
}),
|
2210
|
+
component: (r) => Te.isValidElementType(r) ? new D().component(r) : new D(r),
|
2211
|
+
divider: (r) => new O(r),
|
2212
|
+
view: Oe,
|
2213
|
+
context: s
|
2214
|
+
};
|
2215
|
+
return o;
|
2216
|
+
}
|
2217
|
+
function ft({
|
2218
|
+
defaultDocumentNode: i,
|
2219
|
+
structure: e,
|
2220
|
+
children: t
|
2221
|
+
}) {
|
2222
|
+
const [n, s] = le(!1), o = pe(), r = de(o), c = he(), {
|
2223
|
+
perspectiveStack: l
|
2224
|
+
} = me(), u = U(() => rt({
|
2225
|
+
defaultDocumentNode: i,
|
2226
|
+
source: o,
|
2227
|
+
perspectiveStack: l
|
2228
|
+
}), [i, o, l]), h = U(() => e ? e(u, {
|
2229
|
+
...r,
|
2230
|
+
documentStore: c,
|
2231
|
+
perspectiveStack: l
|
2232
|
+
}) : u.defaults(), [e, u, r, c, l]), m = U(() => ({
|
2233
|
+
backButton: n,
|
2234
|
+
resizablePanes: !n,
|
2235
|
+
reviewChanges: !n,
|
2236
|
+
splitPanes: !n,
|
2237
|
+
splitViews: !n
|
2238
|
+
}), [n]), E = U(() => ({
|
2239
|
+
features: m,
|
2240
|
+
layoutCollapsed: n,
|
2241
|
+
setLayoutCollapsed: s,
|
2242
|
+
rootPaneNode: h,
|
2243
|
+
structureContext: u.context
|
2244
|
+
}), [m, n, h, u.context]);
|
2245
|
+
return /* @__PURE__ */ ce(fe.Provider, { value: E, children: t });
|
2246
|
+
}
|
2247
|
+
export {
|
2248
|
+
ft as A,
|
2249
|
+
De as B,
|
2250
|
+
D as C,
|
2251
|
+
w as D,
|
2252
|
+
mt as E,
|
2253
|
+
N as F,
|
2254
|
+
te as G,
|
2255
|
+
p as H,
|
2256
|
+
b as I,
|
2257
|
+
g as L,
|
2258
|
+
y as M,
|
2259
|
+
a as S,
|
2260
|
+
xe as a,
|
2261
|
+
S as b,
|
2262
|
+
rt as c,
|
2263
|
+
be as d,
|
2264
|
+
q as e,
|
2265
|
+
v as f,
|
2266
|
+
$ as g,
|
2267
|
+
ee as h,
|
2268
|
+
Je as i,
|
2269
|
+
Ve as j,
|
2270
|
+
Fe as k,
|
2271
|
+
Z as l,
|
2272
|
+
ze as m,
|
2273
|
+
F as n,
|
2274
|
+
_ as o,
|
2275
|
+
k as p,
|
2276
|
+
G as q,
|
2277
|
+
Y as r,
|
2278
|
+
f as s,
|
2279
|
+
j as t,
|
2280
|
+
T as u,
|
2281
|
+
K as v,
|
2282
|
+
Ce as w,
|
2283
|
+
A as x,
|
2284
|
+
z as y,
|
2285
|
+
J as z
|
2286
|
+
};
|
2287
|
+
//# sourceMappingURL=StructureToolProvider-B-7cwz7l.mjs.map
|