@sanity/dashboard 2.30.2-shopify.2 → 3.0.0-studio-v3.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.
Files changed (49) hide show
  1. package/README.md +123 -44
  2. package/lib/cjs/index.js +1005 -0
  3. package/lib/cjs/index.js.map +1 -0
  4. package/lib/esm/index.js +980 -0
  5. package/lib/esm/index.js.map +1 -0
  6. package/lib/types/index.d.ts +42 -0
  7. package/lib/types/index.d.ts.map +1 -0
  8. package/package.json +63 -16
  9. package/sanity.json +2 -53
  10. package/src/components/DashboardLayout.tsx +10 -0
  11. package/src/components/DashboardWidgetContainer.tsx +69 -0
  12. package/src/components/NotFoundWidget.tsx +30 -0
  13. package/src/components/WidgetGroup.tsx +108 -0
  14. package/src/containers/Dashboard.tsx +19 -0
  15. package/src/containers/DashboardContext.tsx +8 -0
  16. package/src/containers/WidgetContainer.tsx +21 -0
  17. package/src/index.tsx +62 -0
  18. package/src/types.ts +21 -0
  19. package/src/versionedClient.ts +7 -0
  20. package/src/widgets/projectInfo/ProjectInfo.tsx +233 -0
  21. package/src/widgets/projectInfo/index.ts +10 -0
  22. package/src/widgets/projectUsers/ProjectUsers.tsx +170 -0
  23. package/src/widgets/projectUsers/index.ts +10 -0
  24. package/src/widgets/sanityTutorials/SanityTutorials.tsx +77 -0
  25. package/src/widgets/sanityTutorials/Tutorial.tsx +111 -0
  26. package/src/widgets/sanityTutorials/dataAdapter.ts +48 -0
  27. package/src/widgets/sanityTutorials/index.ts +10 -0
  28. package/v2-incompatible.js +11 -0
  29. package/.babelrc +0 -4
  30. package/lib/DashboardTool.js +0 -59
  31. package/lib/components/DashboardLayout.js +0 -35
  32. package/lib/components/NotFoundWidget.js +0 -51
  33. package/lib/components/WidgetGroup.js +0 -67
  34. package/lib/components/dashboardWidget.js +0 -51
  35. package/lib/containers/Dashboard.js +0 -32
  36. package/lib/containers/WidgetContainer.js +0 -56
  37. package/lib/dashboardConfig.js +0 -16
  38. package/lib/legacyParts.js +0 -55
  39. package/lib/versionedClient.js +0 -20
  40. package/lib/widget.css +0 -62
  41. package/lib/widgets/projectInfo/ProjectInfo.js +0 -265
  42. package/lib/widgets/projectInfo/index.js +0 -19
  43. package/lib/widgets/projectUsers/ProjectUsers.js +0 -188
  44. package/lib/widgets/projectUsers/index.js +0 -16
  45. package/lib/widgets/sanityTutorials/SanityTutorials.js +0 -115
  46. package/lib/widgets/sanityTutorials/Tutorial.js +0 -111
  47. package/lib/widgets/sanityTutorials/dataAdapter.js +0 -28
  48. package/lib/widgets/sanityTutorials/index.js +0 -19
  49. package/tsconfig.json +0 -17
@@ -0,0 +1,1005 @@
1
+ var $dyHF6$reactjsxruntime = require("react/jsx-runtime");
2
+ var $dyHF6$react = require("react");
3
+ var $dyHF6$sanity = require("sanity");
4
+ var $dyHF6$sanityui = require("@sanity/ui");
5
+ var $dyHF6$styledcomponents = require("styled-components");
6
+ var $dyHF6$rxjs = require("rxjs");
7
+ var $dyHF6$rxjsoperators = require("rxjs/operators");
8
+ var $dyHF6$sanityicons = require("@sanity/icons");
9
+ var $dyHF6$sanity_unstable = require("sanity/_unstable");
10
+ var $dyHF6$sanitylibdtssrcdatastores = require("sanity/lib/dts/src/datastores");
11
+ var $dyHF6$sanityimageurl = require("@sanity/image-url");
12
+
13
+ function $parcel$export(e, n, v, s) {
14
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
15
+ }
16
+ function $parcel$exportWildcard(dest, source) {
17
+ Object.keys(source).forEach(function(key) {
18
+ if (key === 'default' || key === '__esModule' || dest.hasOwnProperty(key)) {
19
+ return;
20
+ }
21
+
22
+ Object.defineProperty(dest, key, {
23
+ enumerable: true,
24
+ get: function get() {
25
+ return source[key];
26
+ }
27
+ });
28
+ });
29
+
30
+ return dest;
31
+ }
32
+ function $parcel$interopDefault(a) {
33
+ return a && a.__esModule ? a.default : a;
34
+ }
35
+
36
+ $parcel$export(module.exports, "dashboardTool", () => $329a1cedcedb1349$export$dd097bc0a3a5adbd);
37
+
38
+
39
+
40
+
41
+
42
+
43
+
44
+ function $93c883afbea98073$export$3469e8c87b54056a(props) {
45
+ return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Container), {
46
+ width: 4,
47
+ padding: 4,
48
+ sizing: "border",
49
+ style: {
50
+ minHeight: "100%"
51
+ },
52
+ children: props.children
53
+ });
54
+ }
55
+
56
+
57
+
58
+
59
+
60
+
61
+
62
+
63
+
64
+ const $57696b1483ff1ea5$export$3d9a716c82234f3d = /*#__PURE__*/ (0, $dyHF6$react.createContext)({
65
+ widgets: []
66
+ });
67
+ function $57696b1483ff1ea5$export$f69a0df1904034e() {
68
+ return (0, $dyHF6$react.useContext)($57696b1483ff1ea5$export$3d9a716c82234f3d);
69
+ }
70
+
71
+
72
+
73
+ function $eac9c79096489071$export$d320a48219c7c153(props) {
74
+ const config = (0, $57696b1483ff1ea5$export$f69a0df1904034e)();
75
+ const layout = (0, $dyHF6$react.useMemo)(()=>({
76
+ ...props.layout || {},
77
+ ...config.layout || {}
78
+ }), [
79
+ props.layout,
80
+ config.layout
81
+ ]);
82
+ return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Card), {
83
+ shadow: 1,
84
+ "data-width": layout.width,
85
+ "data-height": layout.height,
86
+ children: /*#__PURE__*/ (0, $dyHF6$react.createElement)(props.component, {})
87
+ });
88
+ }
89
+
90
+
91
+ const $0c9a17bfc268c430$var$media = {
92
+ small: (...args)=>(0, $dyHF6$styledcomponents.css)`
93
+ @media (min-width: ${({ theme: theme })=>theme.sanity.media[0]}px) {
94
+ ${(0, $dyHF6$styledcomponents.css)(...args)}
95
+ }
96
+ `,
97
+ medium: (...args)=>(0, $dyHF6$styledcomponents.css)`
98
+ @media (min-width: ${({ theme: theme })=>theme.sanity.media[2]}px) {
99
+ ${(0, $dyHF6$styledcomponents.css)(...args)}
100
+ }
101
+ `
102
+ };
103
+ const $0c9a17bfc268c430$var$Root = (0, ($parcel$interopDefault($dyHF6$styledcomponents)))((0, $dyHF6$sanityui.Grid))`
104
+ grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
105
+
106
+ & > div {
107
+ overflow: hidden;
108
+ }
109
+
110
+ & > div[data-width='medium'] {
111
+ ${$0c9a17bfc268c430$var$media.small`
112
+ grid-column: span 2;
113
+ `}
114
+ }
115
+
116
+ & > div[data-width='large'] {
117
+ ${$0c9a17bfc268c430$var$media.small`
118
+ grid-column: span 2;
119
+ `}
120
+
121
+ ${$0c9a17bfc268c430$var$media.medium`
122
+ grid-column: span 3;
123
+ `}
124
+ }
125
+
126
+ & > div[data-width='full'] {
127
+ ${$0c9a17bfc268c430$var$media.small`
128
+ grid-column: 1 / -1;
129
+ `}
130
+ }
131
+
132
+ & > div[data-height='medium'] {
133
+ ${$0c9a17bfc268c430$var$media.small`
134
+ grid-row: span 2;
135
+ `}
136
+ }
137
+
138
+ & > div[data-height='large'] {
139
+ ${$0c9a17bfc268c430$var$media.small`
140
+ grid-row: span 2;
141
+ `}
142
+
143
+ ${$0c9a17bfc268c430$var$media.medium`
144
+ grid-row: span 3;
145
+ `}
146
+ }
147
+
148
+ & > div[data-height='full'] {
149
+ ${$0c9a17bfc268c430$var$media.medium`
150
+ grid-row: 1 / -1;
151
+ `}
152
+ }
153
+ `;
154
+ const $0c9a17bfc268c430$var$NO_WIDGETS = [];
155
+ const $0c9a17bfc268c430$var$NO_LAYOUT = {};
156
+ function $0c9a17bfc268c430$export$606a10b16bce9144(props) {
157
+ const { config: { layout: layout = $0c9a17bfc268c430$var$NO_LAYOUT , widgets: widgets = $0c9a17bfc268c430$var$NO_WIDGETS } , } = props;
158
+ return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)($0c9a17bfc268c430$var$Root, {
159
+ autoFlow: "row dense",
160
+ "data-width": layout.width || "auto",
161
+ "data-height": layout.height || "auto",
162
+ gap: 4,
163
+ children: [
164
+ widgets.length ? null : /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Card), {
165
+ padding: 4,
166
+ shadow: 1,
167
+ tone: "primary",
168
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Text), {
169
+ align: "center",
170
+ children: "Add some widgets to populate this space."
171
+ })
172
+ }),
173
+ widgets.map((widgetConfig, index)=>{
174
+ if (widgetConfig.type === "__experimental_group") return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)($0c9a17bfc268c430$export$606a10b16bce9144, {
175
+ config: widgetConfig
176
+ }, index);
177
+ if (widgetConfig.component) return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $eac9c79096489071$export$d320a48219c7c153), {
178
+ ...widgetConfig
179
+ }, index);
180
+ return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)((0, $dyHF6$sanityui.Box), {
181
+ children: [
182
+ widgetConfig.name,
183
+ " is missing widget component"
184
+ ]
185
+ }, index);
186
+ })
187
+ ]
188
+ });
189
+ }
190
+
191
+
192
+
193
+ function $91e9efa9de14badb$export$fe82a520fc33e5f4({ config: config }) {
194
+ if (!config) return null;
195
+ return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $57696b1483ff1ea5$export$3d9a716c82234f3d).Provider, {
196
+ value: config,
197
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $93c883afbea98073$export$3469e8c87b54056a), {
198
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $0c9a17bfc268c430$export$606a10b16bce9144), {
199
+ config: config
200
+ })
201
+ })
202
+ });
203
+ }
204
+
205
+
206
+
207
+ var $4ba7065cde0cca68$exports = {};
208
+
209
+
210
+ var $b40b76121260b241$exports = {};
211
+
212
+ $parcel$export($b40b76121260b241$exports, "DashboardWidgetContainer", () => $b40b76121260b241$export$67b2e85605d868b2);
213
+
214
+
215
+
216
+
217
+ const $b40b76121260b241$var$Root = (0, ($parcel$interopDefault($dyHF6$styledcomponents)))((0, $dyHF6$sanityui.Card))`
218
+ display: flex;
219
+ flex-direction: column;
220
+ justify-content: stretch;
221
+ height: 100%;
222
+ box-sizing: border-box;
223
+ position: relative;
224
+ `;
225
+ const $b40b76121260b241$var$Header = (0, ($parcel$interopDefault($dyHF6$styledcomponents)))((0, $dyHF6$sanityui.Card))`
226
+ position: sticky;
227
+ top: 0;
228
+ z-index: 2;
229
+ border-top-left-radius: inherit;
230
+ border-top-right-radius: inherit;
231
+ `;
232
+ const $b40b76121260b241$var$Footer = (0, ($parcel$interopDefault($dyHF6$styledcomponents)))((0, $dyHF6$sanityui.Card))`
233
+ position: sticky;
234
+ overflow: hidden;
235
+ bottom: 0;
236
+ z-index: 2;
237
+ border-bottom-right-radius: inherit;
238
+ border-bottom-left-radius: inherit;
239
+ margin-top: auto;
240
+ `;
241
+ const $b40b76121260b241$var$Content = (0, ($parcel$interopDefault($dyHF6$styledcomponents)))((0, $dyHF6$sanityui.Box))`
242
+ position: relative;
243
+ z-index: 1;
244
+ height: stretch;
245
+ min-height: 21.5em;
246
+
247
+ @media (min-width: ${({ theme: theme })=>theme.sanity.media[0]}px) {
248
+ overflow-y: auto;
249
+ outline: none;
250
+ }
251
+ `;
252
+ const $b40b76121260b241$export$67b2e85605d868b2 = /*#__PURE__*/ (0, $dyHF6$react.forwardRef)(function DashboardWidgetContainer(props, ref) {
253
+ const { header: header , children: children , footer: footer } = props;
254
+ return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)($b40b76121260b241$var$Root, {
255
+ radius: 3,
256
+ display: "flex",
257
+ ref: ref,
258
+ children: [
259
+ header && /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)($b40b76121260b241$var$Header, {
260
+ borderBottom: true,
261
+ paddingX: 3,
262
+ paddingY: 4,
263
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Heading), {
264
+ size: 1,
265
+ textOverflow: "ellipsis",
266
+ children: header
267
+ })
268
+ }),
269
+ children && /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)($b40b76121260b241$var$Content, {
270
+ children: children
271
+ }),
272
+ footer && /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)($b40b76121260b241$var$Footer, {
273
+ borderTop: true,
274
+ children: footer
275
+ })
276
+ ]
277
+ });
278
+ });
279
+
280
+
281
+ var $3b85b98919e996ec$exports = {};
282
+
283
+ $parcel$export($3b85b98919e996ec$exports, "projectInfoWidget", () => $3b85b98919e996ec$export$66362ea0e7ee12e);
284
+
285
+
286
+
287
+
288
+
289
+ function $b707d8a93b21430e$export$270fde7c7e72cf26() {
290
+ const client = (0, $dyHF6$sanity.useClient)();
291
+ return (0, $dyHF6$react.useMemo)(()=>client.withConfig({
292
+ apiVersion: "1"
293
+ }), [
294
+ client
295
+ ]);
296
+ }
297
+
298
+
299
+
300
+
301
+ function $7f8f68c82a66a1d7$var$isUrl(url) {
302
+ return url && /^https?:\/\//.test(`${url}`);
303
+ }
304
+ function $7f8f68c82a66a1d7$var$getGraphQlUrl(projectId, dataset) {
305
+ return `https://${projectId}.api.sanity.io/v1/graphql/${dataset}/default`;
306
+ }
307
+ function $7f8f68c82a66a1d7$var$getGroqUrl(projectId, dataset) {
308
+ return `https://${projectId}.api.sanity.io/v1/groq/${dataset}`;
309
+ }
310
+ function $7f8f68c82a66a1d7$var$getManageUrl(projectId) {
311
+ return `https://manage.sanity.io/projects/${projectId}`;
312
+ }
313
+ const $7f8f68c82a66a1d7$var$NO_EXPERIMENTAL = [];
314
+ const $7f8f68c82a66a1d7$var$NO_DATA = [];
315
+ function $7f8f68c82a66a1d7$export$a1c9a67310a2d004(props) {
316
+ const { __experimental_before: __experimental_before = $7f8f68c82a66a1d7$var$NO_EXPERIMENTAL , data: data = $7f8f68c82a66a1d7$var$NO_DATA } = props;
317
+ const [studioHost, setStudioHost] = (0, $dyHF6$react.useState)();
318
+ const [graphqlApi, setGraphQlApi] = (0, $dyHF6$react.useState)();
319
+ const versionedClient = (0, $b707d8a93b21430e$export$270fde7c7e72cf26)();
320
+ const { projectId: projectId = "unknown" , dataset: dataset = "unknown" } = versionedClient.config();
321
+ (0, $dyHF6$react.useEffect)(()=>{
322
+ const subscriptions = [];
323
+ subscriptions.push(versionedClient.observable.request({
324
+ uri: `/projects/${projectId}`
325
+ }).subscribe({
326
+ next: (result)=>{
327
+ const { studioHost: host } = result;
328
+ setStudioHost(host ? `https://${host}.sanity.studio` : undefined);
329
+ },
330
+ error: (error)=>{
331
+ console.error("Error while looking for studioHost", error);
332
+ setStudioHost({
333
+ error: "Something went wrong while looking up studioHost. See console."
334
+ });
335
+ }
336
+ }));
337
+ // ping assumed graphql endpoint
338
+ subscriptions.push(versionedClient.observable.request({
339
+ method: "HEAD",
340
+ uri: `/graphql/${dataset}/default`
341
+ }).subscribe({
342
+ next: ()=>setGraphQlApi($7f8f68c82a66a1d7$var$getGraphQlUrl(projectId, dataset)),
343
+ error: (error)=>{
344
+ if (error.statusCode === 404) setGraphQlApi(undefined);
345
+ else {
346
+ console.error("Error while looking for graphqlApi", error);
347
+ setGraphQlApi({
348
+ error: "Something went wrong while looking up graphqlApi. See console."
349
+ });
350
+ }
351
+ }
352
+ }));
353
+ return ()=>{
354
+ subscriptions.forEach((s)=>s.unsubscribe());
355
+ };
356
+ }, [
357
+ dataset,
358
+ projectId,
359
+ versionedClient,
360
+ setGraphQlApi,
361
+ setStudioHost
362
+ ]);
363
+ const assembleTableRows = (0, $dyHF6$react.useMemo)(()=>{
364
+ let result = [
365
+ {
366
+ title: "Sanity project",
367
+ rows: [
368
+ {
369
+ title: "Project ID",
370
+ value: projectId
371
+ },
372
+ {
373
+ title: "Dataset",
374
+ value: dataset
375
+ },
376
+ ]
377
+ },
378
+ ];
379
+ // Handle any apps
380
+ const apps = [
381
+ studioHost ? {
382
+ title: "Studio",
383
+ value: studioHost
384
+ } : null,
385
+ ...data.filter((item)=>item.category === "apps"),
386
+ ].filter((a)=>!!a);
387
+ if (apps.length > 0) result = result.concat([
388
+ {
389
+ title: "Apps",
390
+ rows: apps
391
+ }
392
+ ]);
393
+ // Handle APIs
394
+ result = result.concat([
395
+ {
396
+ title: "APIs",
397
+ rows: [
398
+ {
399
+ title: "GROQ",
400
+ value: $7f8f68c82a66a1d7$var$getGroqUrl(projectId, dataset)
401
+ },
402
+ {
403
+ title: "GraphQL",
404
+ value: (typeof graphqlApi === "object" ? "Error" : graphqlApi) ?? "Not deployed"
405
+ },
406
+ ]
407
+ },
408
+ ], data.filter((item)=>item.category === "apis"));
409
+ // Handle whatever else there might be
410
+ const otherStuff = {};
411
+ data.forEach((item)=>{
412
+ if (item.category && item.category !== "apps" && item.category !== "apis") {
413
+ if (!otherStuff[item.category]) otherStuff[item.category] = [];
414
+ otherStuff[item.category].push(item);
415
+ }
416
+ });
417
+ Object.keys(otherStuff).forEach((category)=>{
418
+ result.push({
419
+ title: category,
420
+ rows: otherStuff[category]
421
+ });
422
+ });
423
+ return result;
424
+ }, [
425
+ graphqlApi,
426
+ studioHost,
427
+ projectId,
428
+ dataset,
429
+ data
430
+ ]);
431
+ return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)((0, $dyHF6$reactjsxruntime.Fragment), {
432
+ children: [
433
+ __experimental_before.map((widgetConfig, idx)=>/*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $eac9c79096489071$export$d320a48219c7c153), {
434
+ ...widgetConfig
435
+ }, idx)),
436
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Box), {
437
+ height: "fill",
438
+ marginTop: __experimental_before?.length > 0 ? 4 : 0,
439
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $b40b76121260b241$export$67b2e85605d868b2), {
440
+ footer: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Button), {
441
+ style: {
442
+ width: "100%"
443
+ },
444
+ paddingX: 2,
445
+ paddingY: 4,
446
+ mode: "bleed",
447
+ tone: "primary",
448
+ text: "Manage project",
449
+ as: "a",
450
+ href: $7f8f68c82a66a1d7$var$getManageUrl(projectId)
451
+ }),
452
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Card), {
453
+ paddingY: 4,
454
+ radius: 2,
455
+ role: "table",
456
+ "aria-label": "Project info",
457
+ "aria-describedby": "project_info_table",
458
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)((0, $dyHF6$sanityui.Stack), {
459
+ space: 4,
460
+ children: [
461
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Box), {
462
+ paddingX: 3,
463
+ as: "header",
464
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Heading), {
465
+ size: 1,
466
+ as: "h2",
467
+ id: "project_info_table",
468
+ children: "Project info"
469
+ })
470
+ }),
471
+ assembleTableRows.map((item)=>{
472
+ if (!item || !item.rows) return null;
473
+ return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)((0, $dyHF6$sanityui.Stack), {
474
+ space: 3,
475
+ children: [
476
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Card), {
477
+ borderBottom: true,
478
+ padding: 3,
479
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Label), {
480
+ size: 0,
481
+ muted: true,
482
+ role: "columnheader",
483
+ children: item.title
484
+ })
485
+ }),
486
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Stack), {
487
+ space: 4,
488
+ paddingX: 3,
489
+ role: "rowgroup",
490
+ children: item.rows.map((row)=>{
491
+ return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)((0, $dyHF6$sanityui.Grid), {
492
+ columns: 2,
493
+ role: "row",
494
+ children: [
495
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Text), {
496
+ weight: "medium",
497
+ role: "rowheader",
498
+ children: row.title
499
+ }),
500
+ typeof row.value === "object" && /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Text), {
501
+ size: 1,
502
+ children: row.value?.error
503
+ }),
504
+ typeof row.value === "string" && /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$reactjsxruntime.Fragment), {
505
+ children: $7f8f68c82a66a1d7$var$isUrl(row.value) ? /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Text), {
506
+ size: 1,
507
+ role: "cell",
508
+ style: {
509
+ wordBreak: "break-word"
510
+ },
511
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("a", {
512
+ href: row.value,
513
+ children: row.value
514
+ })
515
+ }) : /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Code), {
516
+ size: 1,
517
+ role: "cell",
518
+ style: {
519
+ wordBreak: "break-word"
520
+ },
521
+ children: row.value
522
+ })
523
+ })
524
+ ]
525
+ }, row.title);
526
+ })
527
+ })
528
+ ]
529
+ }, item.title);
530
+ })
531
+ ]
532
+ })
533
+ })
534
+ })
535
+ })
536
+ ]
537
+ });
538
+ }
539
+
540
+
541
+ function $3b85b98919e996ec$export$66362ea0e7ee12e(config) {
542
+ return {
543
+ name: "project-info",
544
+ component: (0, $7f8f68c82a66a1d7$export$a1c9a67310a2d004),
545
+ layout: config?.layout ?? {
546
+ width: "medium"
547
+ }
548
+ };
549
+ }
550
+
551
+
552
+ var $9f0f01baaf74f19a$exports = {};
553
+
554
+ $parcel$export($9f0f01baaf74f19a$exports, "projectUsersWidget", () => $9f0f01baaf74f19a$export$5c0e62d7539f632);
555
+
556
+
557
+
558
+
559
+
560
+
561
+
562
+
563
+
564
+
565
+
566
+ const $0a8433cdd42b1c75$var$AvatarWrapper = (0, ($parcel$interopDefault($dyHF6$styledcomponents)))((0, $dyHF6$sanityui.Card))`
567
+ box-sizing: border-box;
568
+ border-radius: 50%;
569
+ border-color: transparent;
570
+ overflow: hidden;
571
+ width: 100%;
572
+ height: 100%;
573
+
574
+ & > img {
575
+ width: 100%;
576
+ height: auto;
577
+ }
578
+ `;
579
+ function $0a8433cdd42b1c75$var$getInviteUrl(projectId) {
580
+ return `https://manage.sanity.io/projects/${projectId}/team/invite`;
581
+ }
582
+ function $0a8433cdd42b1c75$export$2500e0068175e4b9() {
583
+ const [project, setProject] = (0, $dyHF6$react.useState)();
584
+ const [users, setUsers] = (0, $dyHF6$react.useState)();
585
+ const [error, setError] = (0, $dyHF6$react.useState)();
586
+ const userStore = (0, $dyHF6$sanitylibdtssrcdatastores.useUserStore)();
587
+ const versionedClient = (0, $b707d8a93b21430e$export$270fde7c7e72cf26)();
588
+ const fetchData = (0, $dyHF6$react.useCallback)(()=>{
589
+ const { projectId: projectId } = versionedClient.config();
590
+ const subscription = versionedClient.observable.request({
591
+ uri: `/projects/${projectId}`
592
+ }).pipe((0, $dyHF6$rxjsoperators.switchMap)((_project)=>(0, $dyHF6$rxjs.from)(userStore.getUsers(_project.members.map((mem)=>mem.id))).pipe((0, $dyHF6$rxjsoperators.map)((_users)=>({
593
+ project: _project,
594
+ users: _users
595
+ }))))).subscribe({
596
+ next: ({ users: _users , project: _project })=>{
597
+ setProject(_project);
598
+ setUsers((Array.isArray(_users) ? _users : [
599
+ _users
600
+ ]).sort((userA, userB)=>$0a8433cdd42b1c75$var$sortUsersByRobotStatus(userA, userB, _project)));
601
+ },
602
+ error: (e)=>setError(e)
603
+ });
604
+ return ()=>subscription.unsubscribe();
605
+ }, [
606
+ userStore,
607
+ versionedClient
608
+ ]);
609
+ (0, $dyHF6$react.useEffect)(()=>fetchData(), [
610
+ fetchData
611
+ ]);
612
+ const handleRetryFetch = (0, $dyHF6$react.useCallback)(()=>fetchData(), [
613
+ fetchData
614
+ ]);
615
+ const isLoading = !users || !project;
616
+ if (error) return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $b40b76121260b241$export$67b2e85605d868b2), {
617
+ header: "Project users",
618
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Box), {
619
+ padding: 4,
620
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)((0, $dyHF6$sanityui.Text), {
621
+ children: [
622
+ "Something went wrong while fetching data. You could",
623
+ " ",
624
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("a", {
625
+ onClick: handleRetryFetch,
626
+ title: "Retry users fetch",
627
+ style: {
628
+ cursor: "pointer"
629
+ },
630
+ children: "retry"
631
+ }),
632
+ "..?"
633
+ ]
634
+ })
635
+ })
636
+ });
637
+ return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)((0, $b40b76121260b241$export$67b2e85605d868b2), {
638
+ header: "Project users",
639
+ footer: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Button), {
640
+ style: {
641
+ width: "100%"
642
+ },
643
+ paddingX: 2,
644
+ paddingY: 4,
645
+ mode: "bleed",
646
+ tone: "primary",
647
+ text: "Invite members",
648
+ as: "a",
649
+ loading: isLoading,
650
+ href: isLoading ? undefined : $0a8433cdd42b1c75$var$getInviteUrl(project.id)
651
+ }),
652
+ children: [
653
+ isLoading && /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Box), {
654
+ paddingY: 5,
655
+ paddingX: 2,
656
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)((0, $dyHF6$sanityui.Stack), {
657
+ space: 4,
658
+ children: [
659
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Text), {
660
+ align: "center",
661
+ muted: true,
662
+ size: 1,
663
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Spinner), {})
664
+ }),
665
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Text), {
666
+ align: "center",
667
+ size: 1,
668
+ muted: true,
669
+ children: "Loading items..."
670
+ })
671
+ ]
672
+ })
673
+ }),
674
+ !isLoading && /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Stack), {
675
+ space: 3,
676
+ padding: 3,
677
+ children: users?.map((user)=>{
678
+ const membership = project.members.find((member)=>member.id === user.id);
679
+ const media = membership?.isRobot ? /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Text), {
680
+ size: 3,
681
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityicons.RobotIcon), {})
682
+ }) : /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)($0a8433cdd42b1c75$var$AvatarWrapper, {
683
+ tone: "transparent",
684
+ children: user?.imageUrl && /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("img", {
685
+ src: user.imageUrl,
686
+ alt: user?.displayName
687
+ })
688
+ });
689
+ return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Box), {
690
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanity_unstable.DefaultPreview), {
691
+ title: user.displayName,
692
+ subtitle: membership?.role,
693
+ media: media
694
+ })
695
+ }, user.id);
696
+ })
697
+ })
698
+ ]
699
+ });
700
+ }
701
+ function $0a8433cdd42b1c75$var$sortUsersByRobotStatus(userA, userB, project) {
702
+ const { members: members } = project;
703
+ const membershipA = members.find((member)=>member.id === userA?.id);
704
+ const membershipB = members.find((member)=>member.id === userB?.id);
705
+ if (membershipA?.isRobot) return 1;
706
+ if (membershipB?.isRobot) return -1;
707
+ return 0;
708
+ }
709
+
710
+
711
+ function $9f0f01baaf74f19a$export$5c0e62d7539f632(config) {
712
+ return {
713
+ name: "project-info",
714
+ component: (0, $0a8433cdd42b1c75$export$2500e0068175e4b9),
715
+ layout: config?.layout
716
+ };
717
+ }
718
+
719
+
720
+ var $1000d7b311eba884$exports = {};
721
+
722
+ $parcel$export($1000d7b311eba884$exports, "sanityTutorialsWidget", () => $1000d7b311eba884$export$b3552e87a7c5c47b);
723
+
724
+
725
+
726
+
727
+
728
+
729
+
730
+
731
+ const $f7904e4c8f3104b2$var$PlayIconBox = (0, ($parcel$interopDefault($dyHF6$styledcomponents)))((0, $dyHF6$sanityui.Box))`
732
+ position: absolute;
733
+ top: 50%;
734
+ left: 50%;
735
+ transform: translate(-50%, -50%);
736
+
737
+ &:before {
738
+ content: '';
739
+ position: absolute;
740
+ top: 50%;
741
+ left: 50%;
742
+ transform: translate(-50%, -50%);
743
+ width: 2.75em;
744
+ height: 2.75em;
745
+ border-radius: 50%;
746
+ background: ${({ theme: theme })=>theme.sanity.color.card.enabled.bg};
747
+ opacity: 0.75;
748
+ }
749
+ `;
750
+ const $f7904e4c8f3104b2$var$Root = (0, ($parcel$interopDefault($dyHF6$styledcomponents)))((0, $dyHF6$sanityui.Flex))`
751
+ &:hover {
752
+ ${$f7904e4c8f3104b2$var$PlayIconBox} {
753
+ &:before {
754
+ opacity: 1;
755
+ }
756
+ }
757
+ }
758
+ `;
759
+ const $f7904e4c8f3104b2$var$PosterCard = (0, ($parcel$interopDefault($dyHF6$styledcomponents)))((0, $dyHF6$sanityui.Card))`
760
+ width: 100%;
761
+ padding-bottom: calc(9 / 16 * 100%);
762
+ position: relative;
763
+ `;
764
+ const $f7904e4c8f3104b2$var$Poster = (0, ($parcel$interopDefault($dyHF6$styledcomponents))).img`
765
+ position: absolute;
766
+ top: 0;
767
+ left: 0;
768
+ height: 100%;
769
+ width: 100%;
770
+ object-fit: cover;
771
+ display: block;
772
+
773
+ &:not([src]) {
774
+ display: none;
775
+ }
776
+ `;
777
+ function $f7904e4c8f3104b2$export$825b76de5f2b0345(props) {
778
+ const { title: title , posterURL: posterURL , showPlayIcon: showPlayIcon , href: href , presenterName: presenterName , presenterSubtitle: presenterSubtitle } = props;
779
+ return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)($f7904e4c8f3104b2$var$Root, {
780
+ flex: 1,
781
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Card), {
782
+ sizing: "border",
783
+ flex: 1,
784
+ padding: 2,
785
+ radius: 2,
786
+ as: "a",
787
+ href: href,
788
+ target: "_blank",
789
+ rel: "noopener noreferrer",
790
+ style: {
791
+ position: "relative"
792
+ },
793
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)((0, $dyHF6$sanityui.Flex), {
794
+ direction: "column",
795
+ style: {
796
+ height: "100%"
797
+ },
798
+ children: [
799
+ posterURL && /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)($f7904e4c8f3104b2$var$PosterCard, {
800
+ marginBottom: 1,
801
+ children: [
802
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)($f7904e4c8f3104b2$var$Poster, {
803
+ src: posterURL
804
+ }),
805
+ showPlayIcon && /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)($f7904e4c8f3104b2$var$PlayIconBox, {
806
+ display: "flex",
807
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Text), {
808
+ align: "center",
809
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityicons.PlayIcon), {})
810
+ })
811
+ })
812
+ ]
813
+ }),
814
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)((0, $dyHF6$sanityui.Flex), {
815
+ direction: "column",
816
+ justify: "space-between",
817
+ paddingY: 2,
818
+ flex: 1,
819
+ children: [
820
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Heading), {
821
+ as: "h3",
822
+ size: 1,
823
+ children: title
824
+ }),
825
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Box), {
826
+ marginTop: 4,
827
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)((0, $dyHF6$sanityui.Stack), {
828
+ space: 2,
829
+ flex: 1,
830
+ children: [
831
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Text), {
832
+ size: 1,
833
+ children: presenterName
834
+ }),
835
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Text), {
836
+ size: 0,
837
+ style: {
838
+ opacity: 0.7
839
+ },
840
+ children: presenterSubtitle
841
+ })
842
+ ]
843
+ })
844
+ })
845
+ ]
846
+ })
847
+ ]
848
+ })
849
+ })
850
+ });
851
+ }
852
+
853
+
854
+
855
+
856
+
857
+ const $03a20cc8653e0692$var$tutorialsProjectConfig = {
858
+ projectId: "3do82whm",
859
+ dataset: "next"
860
+ };
861
+ function $03a20cc8653e0692$export$144c6e577729d454() {
862
+ const versionedClient = (0, $b707d8a93b21430e$export$270fde7c7e72cf26)();
863
+ return (0, $dyHF6$react.useMemo)(()=>({
864
+ getFeed: (templateRepoId)=>{
865
+ const uri = templateRepoId ? `/addons/dashboard?templateRepoId=${templateRepoId}` : "/addons/dashboard";
866
+ return versionedClient.observable.request({
867
+ uri: uri,
868
+ withCredentials: false
869
+ });
870
+ },
871
+ urlBuilder: (0, ($parcel$interopDefault($dyHF6$sanityimageurl)))($03a20cc8653e0692$var$tutorialsProjectConfig)
872
+ }), [
873
+ versionedClient
874
+ ]);
875
+ }
876
+
877
+
878
+
879
+ function $9c397f58297d9297$var$createUrl(slug, type) {
880
+ if (type === "tutorial") return `https://www.sanity.io/docs/tutorials/${slug.current}`;
881
+ else if (type === "guide") return `https://www.sanity.io/docs/guides/${slug.current}`;
882
+ return false;
883
+ }
884
+ function $9c397f58297d9297$export$5f156cc357b8467f(props) {
885
+ const { templateRepoId: templateRepoId } = props;
886
+ const [feedItems, setFeedItems] = (0, $dyHF6$react.useState)([]);
887
+ const { getFeed: getFeed , urlBuilder: urlBuilder } = (0, $03a20cc8653e0692$export$144c6e577729d454)();
888
+ (0, $dyHF6$react.useEffect)(()=>{
889
+ const subscription = getFeed(templateRepoId).subscribe((response)=>{
890
+ setFeedItems(response.items);
891
+ });
892
+ return ()=>{
893
+ subscription.unsubscribe();
894
+ };
895
+ }, [
896
+ setFeedItems,
897
+ getFeed,
898
+ templateRepoId
899
+ ]);
900
+ const title = "Learn about Sanity";
901
+ return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $b40b76121260b241$export$67b2e85605d868b2), {
902
+ header: title,
903
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Flex), {
904
+ as: "ul",
905
+ overflow: "auto",
906
+ align: "stretch",
907
+ paddingY: 2,
908
+ children: feedItems?.map((feedItem, index)=>{
909
+ if (!feedItem.title || !feedItem.guideOrTutorial && !feedItem.externalLink) return null;
910
+ const presenter = feedItem.presenter || feedItem.guideOrTutorial?.presenter || {};
911
+ const subtitle = feedItem.category;
912
+ const { guideOrTutorial: guideOrTutorial = {} } = feedItem;
913
+ const href = (guideOrTutorial.slug ? $9c397f58297d9297$var$createUrl(guideOrTutorial.slug, guideOrTutorial._type) : feedItem.externalLink) || feedItem.externalLink;
914
+ return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$sanityui.Flex), {
915
+ as: "li",
916
+ paddingRight: index < feedItems?.length - 1 ? 1 : 3,
917
+ paddingLeft: index === 0 ? 3 : 0,
918
+ align: "stretch",
919
+ style: {
920
+ minWidth: 272,
921
+ width: "30%"
922
+ },
923
+ children: /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $f7904e4c8f3104b2$export$825b76de5f2b0345), {
924
+ title: feedItem.title,
925
+ href: href ?? "",
926
+ presenterName: presenter.name,
927
+ presenterSubtitle: subtitle,
928
+ showPlayIcon: feedItem.hasVideo,
929
+ posterURL: feedItem.poster ? urlBuilder.image(feedItem.poster).height(360).url() : undefined
930
+ })
931
+ }, feedItem._id);
932
+ })
933
+ })
934
+ });
935
+ }
936
+
937
+
938
+ function $1000d7b311eba884$export$b3552e87a7c5c47b(config) {
939
+ return {
940
+ name: "sanity-tutorials",
941
+ component: (0, $9c397f58297d9297$export$5f156cc357b8467f),
942
+ layout: config?.layout ?? {
943
+ width: "full"
944
+ }
945
+ };
946
+ }
947
+
948
+
949
+ const $329a1cedcedb1349$var$strokeStyle = {
950
+ stroke: "currentColor",
951
+ strokeWidth: 1.2
952
+ };
953
+ const $329a1cedcedb1349$var$DashboardIcon = ()=>/*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsxs)("svg", {
954
+ "data-sanity-icon": true,
955
+ viewBox: "0 0 25 25",
956
+ fill: "none",
957
+ xmlns: "http://www.w3.org/2000/svg",
958
+ preserveAspectRatio: "xMidYMid",
959
+ width: "1em",
960
+ height: "1em",
961
+ children: [
962
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("path", {
963
+ d: "M19.5 19.5H5.5V5.5H19.5V19.5Z",
964
+ style: $329a1cedcedb1349$var$strokeStyle
965
+ }),
966
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("path", {
967
+ d: "M5.5 12.5H19.5",
968
+ style: $329a1cedcedb1349$var$strokeStyle
969
+ }),
970
+ /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("path", {
971
+ d: "M14.5 19.5V12.5M10.5 12.5V5.5",
972
+ style: $329a1cedcedb1349$var$strokeStyle
973
+ })
974
+ ]
975
+ });
976
+ const $329a1cedcedb1349$export$dd097bc0a3a5adbd = (0, $dyHF6$sanity.createPlugin)((config = {})=>{
977
+ const pluginConfig = {
978
+ layout: config.defaultLayout ?? {},
979
+ widgets: config.widgets ?? []
980
+ };
981
+ return {
982
+ name: "dashboard",
983
+ tools: (prev, context)=>{
984
+ return [
985
+ ...prev,
986
+ {
987
+ title: "Dashboard",
988
+ name: "dashboard",
989
+ icon: $329a1cedcedb1349$var$DashboardIcon,
990
+ component: ()=>/*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $91e9efa9de14badb$export$fe82a520fc33e5f4), {
991
+ config: pluginConfig
992
+ })
993
+ },
994
+ ];
995
+ }
996
+ };
997
+ });
998
+ $parcel$exportWildcard(module.exports, $4ba7065cde0cca68$exports);
999
+ $parcel$exportWildcard(module.exports, $b40b76121260b241$exports);
1000
+ $parcel$exportWildcard(module.exports, $3b85b98919e996ec$exports);
1001
+ $parcel$exportWildcard(module.exports, $9f0f01baaf74f19a$exports);
1002
+ $parcel$exportWildcard(module.exports, $1000d7b311eba884$exports);
1003
+
1004
+
1005
+ //# sourceMappingURL=index.js.map