@commercetools-demo/puck-content-manager 0.5.0 → 0.5.2
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/index.js +187 -161
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +133 -107
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -13,7 +13,33 @@ import TextInput from "@commercetools-uikit/text-input";
|
|
|
13
13
|
import Label from "@commercetools-uikit/label";
|
|
14
14
|
import { PlusThinIcon, SearchIcon } from "@commercetools-uikit/icons";
|
|
15
15
|
import Stamp from "@commercetools-uikit/stamp";
|
|
16
|
-
|
|
16
|
+
|
|
17
|
+
// src/EnsureIntlProvider.tsx
|
|
18
|
+
import { useContext } from "react";
|
|
19
|
+
import { IntlContext, IntlProvider, ReactIntlErrorCode } from "react-intl";
|
|
20
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
21
|
+
var EnsureIntlProvider = ({ children }) => {
|
|
22
|
+
const intl = useContext(IntlContext);
|
|
23
|
+
if (intl) {
|
|
24
|
+
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
25
|
+
}
|
|
26
|
+
return /* @__PURE__ */ jsx(
|
|
27
|
+
IntlProvider,
|
|
28
|
+
{
|
|
29
|
+
locale: "en",
|
|
30
|
+
defaultLocale: "en",
|
|
31
|
+
messages: {},
|
|
32
|
+
onError: (err) => {
|
|
33
|
+
if (err.code === ReactIntlErrorCode.MISSING_TRANSLATION) return;
|
|
34
|
+
console.error(err);
|
|
35
|
+
},
|
|
36
|
+
children
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// src/ContentManager.tsx
|
|
42
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
17
43
|
var columns = [
|
|
18
44
|
{ key: "name", label: "Name" },
|
|
19
45
|
{ key: "contentType", label: "Content Type" },
|
|
@@ -68,25 +94,25 @@ var ContentList = ({ defaultContentType, onEdit }) => {
|
|
|
68
94
|
}
|
|
69
95
|
};
|
|
70
96
|
const rows = contents.map((c) => ({ ...c, id: c.key }));
|
|
71
|
-
return /* @__PURE__ */
|
|
97
|
+
return /* @__PURE__ */ jsx2("div", { style: { maxWidth: "1200px", margin: "0 auto", padding: "32px 24px" }, children: /* @__PURE__ */ jsxs(Spacings.Stack, { scale: "l", children: [
|
|
72
98
|
/* @__PURE__ */ jsxs(Spacings.Inline, { justifyContent: "space-between", alignItems: "center", children: [
|
|
73
|
-
/* @__PURE__ */
|
|
74
|
-
/* @__PURE__ */
|
|
99
|
+
/* @__PURE__ */ jsx2(Text.Headline, { as: "h1", children: "Content Items" }),
|
|
100
|
+
/* @__PURE__ */ jsx2(
|
|
75
101
|
PrimaryButton,
|
|
76
102
|
{
|
|
77
103
|
label: "New Content",
|
|
78
|
-
iconLeft: /* @__PURE__ */
|
|
104
|
+
iconLeft: /* @__PURE__ */ jsx2(PlusThinIcon, {}),
|
|
79
105
|
onClick: () => setShowCreate((v) => !v)
|
|
80
106
|
}
|
|
81
107
|
)
|
|
82
108
|
] }),
|
|
83
|
-
showCreate && /* @__PURE__ */
|
|
84
|
-
/* @__PURE__ */
|
|
85
|
-
createError && /* @__PURE__ */
|
|
109
|
+
showCreate && /* @__PURE__ */ jsx2(Card, { insetScale: "l", children: /* @__PURE__ */ jsxs(Spacings.Stack, { scale: "m", children: [
|
|
110
|
+
/* @__PURE__ */ jsx2(Text.Subheadline, { as: "h4", isBold: true, children: "Create Content Item" }),
|
|
111
|
+
createError && /* @__PURE__ */ jsx2(Text.Body, { tone: "negative", children: createError }),
|
|
86
112
|
/* @__PURE__ */ jsxs(Spacings.Inline, { scale: "m", children: [
|
|
87
|
-
/* @__PURE__ */
|
|
88
|
-
/* @__PURE__ */
|
|
89
|
-
/* @__PURE__ */
|
|
113
|
+
/* @__PURE__ */ jsx2("div", { style: { flex: 1 }, children: /* @__PURE__ */ jsxs(Spacings.Stack, { scale: "xs", children: [
|
|
114
|
+
/* @__PURE__ */ jsx2(Label, { htmlFor: "create-name", children: "Name" }),
|
|
115
|
+
/* @__PURE__ */ jsx2(
|
|
90
116
|
TextInput,
|
|
91
117
|
{
|
|
92
118
|
id: "create-name",
|
|
@@ -96,9 +122,9 @@ var ContentList = ({ defaultContentType, onEdit }) => {
|
|
|
96
122
|
}
|
|
97
123
|
)
|
|
98
124
|
] }) }),
|
|
99
|
-
/* @__PURE__ */
|
|
100
|
-
/* @__PURE__ */
|
|
101
|
-
/* @__PURE__ */
|
|
125
|
+
/* @__PURE__ */ jsx2("div", { style: { flex: 1 }, children: /* @__PURE__ */ jsxs(Spacings.Stack, { scale: "xs", children: [
|
|
126
|
+
/* @__PURE__ */ jsx2(Label, { htmlFor: "create-type", children: "Content Type" }),
|
|
127
|
+
/* @__PURE__ */ jsx2(
|
|
102
128
|
TextInput,
|
|
103
129
|
{
|
|
104
130
|
id: "create-type",
|
|
@@ -110,7 +136,7 @@ var ContentList = ({ defaultContentType, onEdit }) => {
|
|
|
110
136
|
] }) })
|
|
111
137
|
] }),
|
|
112
138
|
/* @__PURE__ */ jsxs(Spacings.Inline, { scale: "s", children: [
|
|
113
|
-
/* @__PURE__ */
|
|
139
|
+
/* @__PURE__ */ jsx2(
|
|
114
140
|
PrimaryButton,
|
|
115
141
|
{
|
|
116
142
|
label: creating ? "Creating\u2026" : "Create",
|
|
@@ -118,11 +144,11 @@ var ContentList = ({ defaultContentType, onEdit }) => {
|
|
|
118
144
|
isDisabled: creating
|
|
119
145
|
}
|
|
120
146
|
),
|
|
121
|
-
/* @__PURE__ */
|
|
147
|
+
/* @__PURE__ */ jsx2(SecondaryButton, { label: "Cancel", onClick: () => setShowCreate(false) })
|
|
122
148
|
] })
|
|
123
149
|
] }) }),
|
|
124
150
|
/* @__PURE__ */ jsxs(Spacings.Inline, { scale: "s", alignItems: "center", children: [
|
|
125
|
-
/* @__PURE__ */
|
|
151
|
+
/* @__PURE__ */ jsx2("div", { style: { flex: 1, maxWidth: "280px" }, children: /* @__PURE__ */ jsx2(
|
|
126
152
|
TextInput,
|
|
127
153
|
{
|
|
128
154
|
value: filterType,
|
|
@@ -130,15 +156,15 @@ var ContentList = ({ defaultContentType, onEdit }) => {
|
|
|
130
156
|
placeholder: "Filter by content type\u2026"
|
|
131
157
|
}
|
|
132
158
|
) }),
|
|
133
|
-
/* @__PURE__ */
|
|
159
|
+
/* @__PURE__ */ jsx2(
|
|
134
160
|
SecondaryButton,
|
|
135
161
|
{
|
|
136
162
|
label: "Filter",
|
|
137
|
-
iconLeft: /* @__PURE__ */
|
|
163
|
+
iconLeft: /* @__PURE__ */ jsx2(SearchIcon, {}),
|
|
138
164
|
onClick: handleFilter
|
|
139
165
|
}
|
|
140
166
|
),
|
|
141
|
-
/* @__PURE__ */
|
|
167
|
+
/* @__PURE__ */ jsx2(
|
|
142
168
|
FlatButton,
|
|
143
169
|
{
|
|
144
170
|
label: "Clear",
|
|
@@ -148,10 +174,10 @@ var ContentList = ({ defaultContentType, onEdit }) => {
|
|
|
148
174
|
}
|
|
149
175
|
}
|
|
150
176
|
),
|
|
151
|
-
/* @__PURE__ */
|
|
177
|
+
/* @__PURE__ */ jsx2(FlatButton, { label: "Refresh", onClick: () => void refresh() })
|
|
152
178
|
] }),
|
|
153
|
-
error && /* @__PURE__ */
|
|
154
|
-
loading ? /* @__PURE__ */
|
|
179
|
+
error && /* @__PURE__ */ jsx2(Text.Body, { tone: "negative", children: error }),
|
|
180
|
+
loading ? /* @__PURE__ */ jsx2("div", { style: { display: "flex", justifyContent: "center", padding: "48px" }, children: /* @__PURE__ */ jsx2(LoadingSpinner, {}) }) : contents.length === 0 ? /* @__PURE__ */ jsx2(Spacings.Stack, { scale: "m", alignItems: "center", children: /* @__PURE__ */ jsx2(Text.Body, { tone: "secondary", children: "No content items found." }) }) : /* @__PURE__ */ jsx2(
|
|
155
181
|
DataTable,
|
|
156
182
|
{
|
|
157
183
|
columns,
|
|
@@ -159,9 +185,9 @@ var ContentList = ({ defaultContentType, onEdit }) => {
|
|
|
159
185
|
itemRenderer: (row, column) => {
|
|
160
186
|
switch (column.key) {
|
|
161
187
|
case "name":
|
|
162
|
-
return /* @__PURE__ */
|
|
188
|
+
return /* @__PURE__ */ jsx2(Text.Body, { fontWeight: "bold", children: row.value.name });
|
|
163
189
|
case "contentType":
|
|
164
|
-
return /* @__PURE__ */
|
|
190
|
+
return /* @__PURE__ */ jsx2(
|
|
165
191
|
"code",
|
|
166
192
|
{
|
|
167
193
|
style: {
|
|
@@ -178,17 +204,17 @@ var ContentList = ({ defaultContentType, onEdit }) => {
|
|
|
178
204
|
const hasDraft = !!row.states.draft;
|
|
179
205
|
const hasPublished = !!row.states.published;
|
|
180
206
|
return /* @__PURE__ */ jsxs("span", { style: { display: "inline-flex", gap: "4px", flexWrap: "wrap" }, children: [
|
|
181
|
-
hasDraft && /* @__PURE__ */
|
|
182
|
-
hasPublished && /* @__PURE__ */
|
|
183
|
-
!hasDraft && !hasPublished && /* @__PURE__ */
|
|
207
|
+
hasDraft && /* @__PURE__ */ jsx2(Stamp, { tone: "warning", label: "Draft", isCondensed: true }),
|
|
208
|
+
hasPublished && /* @__PURE__ */ jsx2(Stamp, { tone: "positive", label: "Published", isCondensed: true }),
|
|
209
|
+
!hasDraft && !hasPublished && /* @__PURE__ */ jsx2(Stamp, { tone: "secondary", label: "No state", isCondensed: true })
|
|
184
210
|
] });
|
|
185
211
|
}
|
|
186
212
|
case "updatedAt":
|
|
187
|
-
return /* @__PURE__ */
|
|
213
|
+
return /* @__PURE__ */ jsx2(Text.Body, { tone: "secondary", children: new Date(row.value.updatedAt).toLocaleDateString() });
|
|
188
214
|
case "actions":
|
|
189
215
|
return /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
|
|
190
|
-
/* @__PURE__ */
|
|
191
|
-
/* @__PURE__ */
|
|
216
|
+
/* @__PURE__ */ jsx2(PrimaryButton, { label: "Edit", size: "20", onClick: () => onEdit(row) }),
|
|
217
|
+
/* @__PURE__ */ jsx2(
|
|
192
218
|
FlatButton,
|
|
193
219
|
{
|
|
194
220
|
tone: "critical",
|
|
@@ -213,16 +239,16 @@ var ContentManagerList = ({
|
|
|
213
239
|
jwtToken,
|
|
214
240
|
defaultContentType,
|
|
215
241
|
onEdit
|
|
216
|
-
}) => /* @__PURE__ */
|
|
242
|
+
}) => /* @__PURE__ */ jsx2(EnsureIntlProvider, { children: /* @__PURE__ */ jsx2(
|
|
217
243
|
PuckApiProvider,
|
|
218
244
|
{
|
|
219
245
|
baseURL,
|
|
220
246
|
projectKey,
|
|
221
247
|
businessUnitKey,
|
|
222
248
|
jwtToken,
|
|
223
|
-
children: /* @__PURE__ */
|
|
249
|
+
children: /* @__PURE__ */ jsx2(ContentList, { defaultContentType, onEdit })
|
|
224
250
|
}
|
|
225
|
-
);
|
|
251
|
+
) });
|
|
226
252
|
|
|
227
253
|
// src/ContentEditor.tsx
|
|
228
254
|
import { useCallback, useMemo, useRef, useState as useState2 } from "react";
|
|
@@ -246,7 +272,7 @@ import {
|
|
|
246
272
|
import LoadingSpinner2 from "@commercetools-uikit/loading-spinner";
|
|
247
273
|
import Text2 from "@commercetools-uikit/text";
|
|
248
274
|
import Spacings2 from "@commercetools-uikit/spacings";
|
|
249
|
-
import { jsx as
|
|
275
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
250
276
|
var ContentEditorInner = ({
|
|
251
277
|
contentKey,
|
|
252
278
|
config,
|
|
@@ -358,21 +384,21 @@ var ContentEditorInner = ({
|
|
|
358
384
|
};
|
|
359
385
|
}, [config]);
|
|
360
386
|
if (loading) {
|
|
361
|
-
return /* @__PURE__ */
|
|
362
|
-
/* @__PURE__ */
|
|
363
|
-
/* @__PURE__ */
|
|
387
|
+
return /* @__PURE__ */ jsx3("div", { style: { display: "flex", alignItems: "center", justifyContent: "center", height: "100vh" }, children: /* @__PURE__ */ jsxs2(Spacings2.Stack, { scale: "m", alignItems: "center", children: [
|
|
388
|
+
/* @__PURE__ */ jsx3(LoadingSpinner2, {}),
|
|
389
|
+
/* @__PURE__ */ jsx3(Text2.Body, { tone: "secondary", children: "Loading editor\u2026" })
|
|
364
390
|
] }) });
|
|
365
391
|
}
|
|
366
392
|
if (error) {
|
|
367
|
-
return /* @__PURE__ */
|
|
368
|
-
/* @__PURE__ */
|
|
393
|
+
return /* @__PURE__ */ jsx3("div", { style: { padding: "32px" }, children: /* @__PURE__ */ jsxs2(Text2.Body, { tone: "negative", children: [
|
|
394
|
+
/* @__PURE__ */ jsx3("strong", { children: "Error loading content:" }),
|
|
369
395
|
" ",
|
|
370
396
|
error
|
|
371
397
|
] }) });
|
|
372
398
|
}
|
|
373
399
|
const activeData = versionHistory.previewData ?? currentData;
|
|
374
400
|
const toolbarStates = states;
|
|
375
|
-
return /* @__PURE__ */
|
|
401
|
+
return /* @__PURE__ */ jsx3(
|
|
376
402
|
VersionHistoryProvider,
|
|
377
403
|
{
|
|
378
404
|
diff,
|
|
@@ -385,7 +411,7 @@ var ContentEditorInner = ({
|
|
|
385
411
|
onApply: () => void handleApplyVersion(),
|
|
386
412
|
onDiscard: versionHistory.clearSelection,
|
|
387
413
|
onLoadVersions: versionHistory.openPanel,
|
|
388
|
-
children: /* @__PURE__ */
|
|
414
|
+
children: /* @__PURE__ */ jsx3(ComponentSearchProvider, { children: /* @__PURE__ */ jsx3(
|
|
389
415
|
Puck,
|
|
390
416
|
{
|
|
391
417
|
config: contentConfig,
|
|
@@ -394,7 +420,7 @@ var ContentEditorInner = ({
|
|
|
394
420
|
onPublish: handlePublish,
|
|
395
421
|
overrides: {
|
|
396
422
|
headerActions: () => versionHistory.isPreviewingHistory ? /* @__PURE__ */ jsxs2(Spacings2.Inline, { scale: "s", alignItems: "center", children: [
|
|
397
|
-
/* @__PURE__ */
|
|
423
|
+
/* @__PURE__ */ jsx3(
|
|
398
424
|
VersionPreviewBanner,
|
|
399
425
|
{
|
|
400
426
|
timestamp: versionHistory.selectedVersion.timestamp,
|
|
@@ -403,8 +429,8 @@ var ContentEditorInner = ({
|
|
|
403
429
|
isApplying: isApplyingVersion
|
|
404
430
|
}
|
|
405
431
|
),
|
|
406
|
-
/* @__PURE__ */
|
|
407
|
-
] }) : /* @__PURE__ */
|
|
432
|
+
/* @__PURE__ */ jsx3(VersionHistoryButton, { disabled: isApplyingVersion })
|
|
433
|
+
] }) : /* @__PURE__ */ jsx3(
|
|
408
434
|
EditorToolbar,
|
|
409
435
|
{
|
|
410
436
|
saving,
|
|
@@ -416,9 +442,9 @@ var ContentEditorInner = ({
|
|
|
416
442
|
showPublishButton: true
|
|
417
443
|
}
|
|
418
444
|
),
|
|
419
|
-
components: ({ children }) => /* @__PURE__ */
|
|
420
|
-
componentItem: ({ children, name }) => /* @__PURE__ */
|
|
421
|
-
fields: ({ children, isLoading }) => /* @__PURE__ */
|
|
445
|
+
components: ({ children }) => /* @__PURE__ */ jsx3(ComponentsPanel, { children }),
|
|
446
|
+
componentItem: ({ children, name }) => /* @__PURE__ */ jsx3(ComponentItemFilter, { name, children }),
|
|
447
|
+
fields: ({ children, isLoading }) => /* @__PURE__ */ jsx3(VersionAwareFieldsPanel, { isLoading, children })
|
|
422
448
|
}
|
|
423
449
|
},
|
|
424
450
|
versionHistory.selectedVersionId ?? "current"
|
|
@@ -436,14 +462,14 @@ var ContentEditor = ({
|
|
|
436
462
|
onPublish,
|
|
437
463
|
onSave,
|
|
438
464
|
onError
|
|
439
|
-
}) => /* @__PURE__ */
|
|
465
|
+
}) => /* @__PURE__ */ jsx3(EnsureIntlProvider, { children: /* @__PURE__ */ jsx3(
|
|
440
466
|
PuckApiProvider2,
|
|
441
467
|
{
|
|
442
468
|
baseURL,
|
|
443
469
|
projectKey,
|
|
444
470
|
businessUnitKey,
|
|
445
471
|
jwtToken,
|
|
446
|
-
children: /* @__PURE__ */
|
|
472
|
+
children: /* @__PURE__ */ jsx3(
|
|
447
473
|
ContentEditorInner,
|
|
448
474
|
{
|
|
449
475
|
contentKey,
|
|
@@ -454,7 +480,7 @@ var ContentEditor = ({
|
|
|
454
480
|
}
|
|
455
481
|
)
|
|
456
482
|
}
|
|
457
|
-
);
|
|
483
|
+
) });
|
|
458
484
|
|
|
459
485
|
// src/ContentManagerRouter.tsx
|
|
460
486
|
import { useState as useState3, useCallback as useCallback2, useMemo as useMemo2, useRef as useRef2 } from "react";
|
|
@@ -500,7 +526,7 @@ import TextInput2 from "@commercetools-uikit/text-input";
|
|
|
500
526
|
import Label2 from "@commercetools-uikit/label";
|
|
501
527
|
import Stamp2 from "@commercetools-uikit/stamp";
|
|
502
528
|
import { PlusThinIcon as PlusThinIcon2, SearchIcon as SearchIcon2, AngleLeftIcon } from "@commercetools-uikit/icons";
|
|
503
|
-
import { jsx as
|
|
529
|
+
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
504
530
|
var DEFAULT_CONFIG = {
|
|
505
531
|
...defaultPuckConfig,
|
|
506
532
|
components: { ...defaultPuckConfig.components }
|
|
@@ -573,28 +599,28 @@ var ContentListRoute = ({ defaultContentType, backButton }) => {
|
|
|
573
599
|
}
|
|
574
600
|
};
|
|
575
601
|
const rows = contents.map((c) => ({ ...c, id: c.key }));
|
|
576
|
-
return /* @__PURE__ */
|
|
602
|
+
return /* @__PURE__ */ jsx4("div", { style: { maxWidth: "1200px", margin: "0 auto", padding: "32px 24px" }, children: /* @__PURE__ */ jsxs3(Spacings3.Stack, { scale: "l", children: [
|
|
577
603
|
/* @__PURE__ */ jsxs3(Spacings3.Inline, { justifyContent: "space-between", alignItems: "center", children: [
|
|
578
604
|
/* @__PURE__ */ jsxs3(Spacings3.Inline, { scale: "m", alignItems: "center", children: [
|
|
579
605
|
backButton,
|
|
580
|
-
/* @__PURE__ */
|
|
606
|
+
/* @__PURE__ */ jsx4(Text3.Headline, { as: "h1", children: "Content Items" })
|
|
581
607
|
] }),
|
|
582
|
-
/* @__PURE__ */
|
|
608
|
+
/* @__PURE__ */ jsx4(
|
|
583
609
|
PrimaryButton2,
|
|
584
610
|
{
|
|
585
611
|
label: "New Content",
|
|
586
|
-
iconLeft: /* @__PURE__ */
|
|
612
|
+
iconLeft: /* @__PURE__ */ jsx4(PlusThinIcon2, {}),
|
|
587
613
|
onClick: () => setShowCreate((v) => !v)
|
|
588
614
|
}
|
|
589
615
|
)
|
|
590
616
|
] }),
|
|
591
|
-
showCreate && /* @__PURE__ */
|
|
592
|
-
/* @__PURE__ */
|
|
593
|
-
createError && /* @__PURE__ */
|
|
617
|
+
showCreate && /* @__PURE__ */ jsx4(Card2, { insetScale: "l", children: /* @__PURE__ */ jsxs3(Spacings3.Stack, { scale: "m", children: [
|
|
618
|
+
/* @__PURE__ */ jsx4(Text3.Subheadline, { as: "h4", isBold: true, children: "Create Content Item" }),
|
|
619
|
+
createError && /* @__PURE__ */ jsx4(Text3.Body, { tone: "negative", children: createError }),
|
|
594
620
|
/* @__PURE__ */ jsxs3(Spacings3.Inline, { scale: "m", children: [
|
|
595
|
-
/* @__PURE__ */
|
|
596
|
-
/* @__PURE__ */
|
|
597
|
-
/* @__PURE__ */
|
|
621
|
+
/* @__PURE__ */ jsx4("div", { style: { flex: 1 }, children: /* @__PURE__ */ jsxs3(Spacings3.Stack, { scale: "xs", children: [
|
|
622
|
+
/* @__PURE__ */ jsx4(Label2, { htmlFor: "create-content-name", children: "Name" }),
|
|
623
|
+
/* @__PURE__ */ jsx4(
|
|
598
624
|
TextInput2,
|
|
599
625
|
{
|
|
600
626
|
id: "create-content-name",
|
|
@@ -604,9 +630,9 @@ var ContentListRoute = ({ defaultContentType, backButton }) => {
|
|
|
604
630
|
}
|
|
605
631
|
)
|
|
606
632
|
] }) }),
|
|
607
|
-
/* @__PURE__ */
|
|
608
|
-
/* @__PURE__ */
|
|
609
|
-
/* @__PURE__ */
|
|
633
|
+
/* @__PURE__ */ jsx4("div", { style: { flex: 1 }, children: /* @__PURE__ */ jsxs3(Spacings3.Stack, { scale: "xs", children: [
|
|
634
|
+
/* @__PURE__ */ jsx4(Label2, { htmlFor: "create-content-type", children: "Content Type" }),
|
|
635
|
+
/* @__PURE__ */ jsx4(
|
|
610
636
|
TextInput2,
|
|
611
637
|
{
|
|
612
638
|
id: "create-content-type",
|
|
@@ -618,7 +644,7 @@ var ContentListRoute = ({ defaultContentType, backButton }) => {
|
|
|
618
644
|
] }) })
|
|
619
645
|
] }),
|
|
620
646
|
/* @__PURE__ */ jsxs3(Spacings3.Inline, { scale: "s", children: [
|
|
621
|
-
/* @__PURE__ */
|
|
647
|
+
/* @__PURE__ */ jsx4(
|
|
622
648
|
PrimaryButton2,
|
|
623
649
|
{
|
|
624
650
|
label: creating ? "Creating\u2026" : "Create",
|
|
@@ -626,11 +652,11 @@ var ContentListRoute = ({ defaultContentType, backButton }) => {
|
|
|
626
652
|
isDisabled: creating
|
|
627
653
|
}
|
|
628
654
|
),
|
|
629
|
-
/* @__PURE__ */
|
|
655
|
+
/* @__PURE__ */ jsx4(SecondaryButton2, { label: "Cancel", onClick: () => setShowCreate(false) })
|
|
630
656
|
] })
|
|
631
657
|
] }) }),
|
|
632
658
|
/* @__PURE__ */ jsxs3(Spacings3.Inline, { scale: "s", alignItems: "center", children: [
|
|
633
|
-
/* @__PURE__ */
|
|
659
|
+
/* @__PURE__ */ jsx4("div", { style: { flex: 1, maxWidth: "280px" }, children: /* @__PURE__ */ jsx4(
|
|
634
660
|
TextInput2,
|
|
635
661
|
{
|
|
636
662
|
value: filterType,
|
|
@@ -638,15 +664,15 @@ var ContentListRoute = ({ defaultContentType, backButton }) => {
|
|
|
638
664
|
placeholder: "Filter by content type\u2026"
|
|
639
665
|
}
|
|
640
666
|
) }),
|
|
641
|
-
/* @__PURE__ */
|
|
667
|
+
/* @__PURE__ */ jsx4(
|
|
642
668
|
SecondaryButton2,
|
|
643
669
|
{
|
|
644
670
|
label: "Filter",
|
|
645
|
-
iconLeft: /* @__PURE__ */
|
|
671
|
+
iconLeft: /* @__PURE__ */ jsx4(SearchIcon2, {}),
|
|
646
672
|
onClick: handleFilter
|
|
647
673
|
}
|
|
648
674
|
),
|
|
649
|
-
/* @__PURE__ */
|
|
675
|
+
/* @__PURE__ */ jsx4(
|
|
650
676
|
FlatButton2,
|
|
651
677
|
{
|
|
652
678
|
label: "Clear",
|
|
@@ -656,10 +682,10 @@ var ContentListRoute = ({ defaultContentType, backButton }) => {
|
|
|
656
682
|
}
|
|
657
683
|
}
|
|
658
684
|
),
|
|
659
|
-
/* @__PURE__ */
|
|
685
|
+
/* @__PURE__ */ jsx4(FlatButton2, { label: "Refresh", onClick: () => void refresh() })
|
|
660
686
|
] }),
|
|
661
|
-
error && /* @__PURE__ */
|
|
662
|
-
loading ? /* @__PURE__ */
|
|
687
|
+
error && /* @__PURE__ */ jsx4(Text3.Body, { tone: "negative", children: error }),
|
|
688
|
+
loading ? /* @__PURE__ */ jsx4("div", { style: { display: "flex", justifyContent: "center", padding: "48px" }, children: /* @__PURE__ */ jsx4(LoadingSpinner3, {}) }) : contents.length === 0 ? /* @__PURE__ */ jsx4(Spacings3.Stack, { scale: "m", alignItems: "center", children: /* @__PURE__ */ jsx4(Text3.Body, { tone: "secondary", children: "No content items found." }) }) : /* @__PURE__ */ jsx4(
|
|
663
689
|
DataTable2,
|
|
664
690
|
{
|
|
665
691
|
columns: COLUMNS,
|
|
@@ -667,9 +693,9 @@ var ContentListRoute = ({ defaultContentType, backButton }) => {
|
|
|
667
693
|
itemRenderer: (row, column) => {
|
|
668
694
|
switch (column.key) {
|
|
669
695
|
case "name":
|
|
670
|
-
return /* @__PURE__ */
|
|
696
|
+
return /* @__PURE__ */ jsx4(Text3.Body, { fontWeight: "bold", children: row.value.name });
|
|
671
697
|
case "contentType":
|
|
672
|
-
return /* @__PURE__ */
|
|
698
|
+
return /* @__PURE__ */ jsx4(
|
|
673
699
|
"code",
|
|
674
700
|
{
|
|
675
701
|
style: {
|
|
@@ -686,16 +712,16 @@ var ContentListRoute = ({ defaultContentType, backButton }) => {
|
|
|
686
712
|
const hasDraft = !!row.states.draft;
|
|
687
713
|
const hasPublished = !!row.states.published;
|
|
688
714
|
return /* @__PURE__ */ jsxs3("span", { style: { display: "inline-flex", gap: "4px", flexWrap: "wrap" }, children: [
|
|
689
|
-
hasDraft && /* @__PURE__ */
|
|
690
|
-
hasPublished && /* @__PURE__ */
|
|
691
|
-
!hasDraft && !hasPublished && /* @__PURE__ */
|
|
715
|
+
hasDraft && /* @__PURE__ */ jsx4(Stamp2, { tone: "warning", label: "Draft", isCondensed: true }),
|
|
716
|
+
hasPublished && /* @__PURE__ */ jsx4(Stamp2, { tone: "positive", label: "Published", isCondensed: true }),
|
|
717
|
+
!hasDraft && !hasPublished && /* @__PURE__ */ jsx4(Stamp2, { tone: "secondary", label: "No state", isCondensed: true })
|
|
692
718
|
] });
|
|
693
719
|
}
|
|
694
720
|
case "updatedAt":
|
|
695
|
-
return /* @__PURE__ */
|
|
721
|
+
return /* @__PURE__ */ jsx4(Text3.Body, { tone: "secondary", children: new Date(row.value.updatedAt).toLocaleDateString() });
|
|
696
722
|
case "actions":
|
|
697
723
|
return /* @__PURE__ */ jsxs3(Spacings3.Inline, { scale: "s", alignItems: "center", children: [
|
|
698
|
-
/* @__PURE__ */
|
|
724
|
+
/* @__PURE__ */ jsx4(
|
|
699
725
|
PrimaryButton2,
|
|
700
726
|
{
|
|
701
727
|
label: "Edit",
|
|
@@ -703,7 +729,7 @@ var ContentListRoute = ({ defaultContentType, backButton }) => {
|
|
|
703
729
|
onClick: () => history.push(`/${row.key}`, { contentName: row.value.name })
|
|
704
730
|
}
|
|
705
731
|
),
|
|
706
|
-
/* @__PURE__ */
|
|
732
|
+
/* @__PURE__ */ jsx4(
|
|
707
733
|
FlatButton2,
|
|
708
734
|
{
|
|
709
735
|
tone: "critical",
|
|
@@ -821,21 +847,21 @@ var ContentEditorRoute = ({ config, backButton }) => {
|
|
|
821
847
|
};
|
|
822
848
|
}, [config]);
|
|
823
849
|
if (loading) {
|
|
824
|
-
return /* @__PURE__ */
|
|
825
|
-
/* @__PURE__ */
|
|
826
|
-
/* @__PURE__ */
|
|
850
|
+
return /* @__PURE__ */ jsx4("div", { style: { display: "flex", alignItems: "center", justifyContent: "center", height: "100vh" }, children: /* @__PURE__ */ jsxs3(Spacings3.Stack, { scale: "m", alignItems: "center", children: [
|
|
851
|
+
/* @__PURE__ */ jsx4(LoadingSpinner3, {}),
|
|
852
|
+
/* @__PURE__ */ jsx4(Text3.Body, { tone: "secondary", children: "Loading editor\u2026" })
|
|
827
853
|
] }) });
|
|
828
854
|
}
|
|
829
855
|
if (error) {
|
|
830
|
-
return /* @__PURE__ */
|
|
831
|
-
/* @__PURE__ */
|
|
856
|
+
return /* @__PURE__ */ jsx4("div", { style: { padding: "32px" }, children: /* @__PURE__ */ jsxs3(Text3.Body, { tone: "negative", children: [
|
|
857
|
+
/* @__PURE__ */ jsx4("strong", { children: "Error loading content:" }),
|
|
832
858
|
" ",
|
|
833
859
|
error
|
|
834
860
|
] }) });
|
|
835
861
|
}
|
|
836
862
|
const activeData = versionHistory.previewData ?? currentData;
|
|
837
863
|
const toolbarStates = states;
|
|
838
|
-
return /* @__PURE__ */
|
|
864
|
+
return /* @__PURE__ */ jsx4(
|
|
839
865
|
VersionHistoryProvider2,
|
|
840
866
|
{
|
|
841
867
|
diff,
|
|
@@ -851,20 +877,20 @@ var ContentEditorRoute = ({ config, backButton }) => {
|
|
|
851
877
|
children: /* @__PURE__ */ jsxs3("div", { style: { display: "flex", flexDirection: "column", height: "100%" }, children: [
|
|
852
878
|
/* @__PURE__ */ jsxs3("div", { style: NAV_BAR_STYLE, children: [
|
|
853
879
|
backButton,
|
|
854
|
-
backButton && /* @__PURE__ */
|
|
855
|
-
/* @__PURE__ */
|
|
880
|
+
backButton && /* @__PURE__ */ jsx4(Text3.Body, { tone: "secondary", children: "/" }),
|
|
881
|
+
/* @__PURE__ */ jsx4(
|
|
856
882
|
FlatButton2,
|
|
857
883
|
{
|
|
858
884
|
label: "Content Items",
|
|
859
|
-
icon: /* @__PURE__ */
|
|
885
|
+
icon: /* @__PURE__ */ jsx4(AngleLeftIcon, {}),
|
|
860
886
|
iconPosition: "left",
|
|
861
887
|
onClick: () => history.push("/")
|
|
862
888
|
}
|
|
863
889
|
),
|
|
864
|
-
/* @__PURE__ */
|
|
865
|
-
/* @__PURE__ */
|
|
890
|
+
/* @__PURE__ */ jsx4(Text3.Body, { tone: "secondary", children: "/" }),
|
|
891
|
+
/* @__PURE__ */ jsx4(Text3.Body, { fontWeight: "bold", children: contentName })
|
|
866
892
|
] }),
|
|
867
|
-
/* @__PURE__ */
|
|
893
|
+
/* @__PURE__ */ jsx4("div", { style: { flex: 1, overflow: "hidden" }, children: /* @__PURE__ */ jsx4(ComponentSearchProvider2, { children: /* @__PURE__ */ jsx4(
|
|
868
894
|
Puck2,
|
|
869
895
|
{
|
|
870
896
|
config: contentConfig,
|
|
@@ -873,7 +899,7 @@ var ContentEditorRoute = ({ config, backButton }) => {
|
|
|
873
899
|
onPublish: handlePublish,
|
|
874
900
|
overrides: {
|
|
875
901
|
headerActions: () => versionHistory.isPreviewingHistory ? /* @__PURE__ */ jsxs3(Spacings3.Inline, { scale: "s", alignItems: "center", children: [
|
|
876
|
-
/* @__PURE__ */
|
|
902
|
+
/* @__PURE__ */ jsx4(
|
|
877
903
|
VersionPreviewBanner2,
|
|
878
904
|
{
|
|
879
905
|
timestamp: versionHistory.selectedVersion.timestamp,
|
|
@@ -882,8 +908,8 @@ var ContentEditorRoute = ({ config, backButton }) => {
|
|
|
882
908
|
isApplying: isApplyingVersion
|
|
883
909
|
}
|
|
884
910
|
),
|
|
885
|
-
/* @__PURE__ */
|
|
886
|
-
] }) : /* @__PURE__ */
|
|
911
|
+
/* @__PURE__ */ jsx4(VersionHistoryButton2, { disabled: isApplyingVersion })
|
|
912
|
+
] }) : /* @__PURE__ */ jsx4(
|
|
887
913
|
EditorToolbar2,
|
|
888
914
|
{
|
|
889
915
|
saving,
|
|
@@ -895,9 +921,9 @@ var ContentEditorRoute = ({ config, backButton }) => {
|
|
|
895
921
|
showPublishButton: true
|
|
896
922
|
}
|
|
897
923
|
),
|
|
898
|
-
components: ({ children }) => /* @__PURE__ */
|
|
899
|
-
componentItem: ({ children, name }) => /* @__PURE__ */
|
|
900
|
-
fields: ({ children, isLoading }) => /* @__PURE__ */
|
|
924
|
+
components: ({ children }) => /* @__PURE__ */ jsx4(ComponentsPanel2, { children }),
|
|
925
|
+
componentItem: ({ children, name }) => /* @__PURE__ */ jsx4(ComponentItemFilter2, { name, children }),
|
|
926
|
+
fields: ({ children, isLoading }) => /* @__PURE__ */ jsx4(VersionAwareFieldsPanel2, { isLoading, children })
|
|
901
927
|
}
|
|
902
928
|
},
|
|
903
929
|
versionHistory.selectedVersionId ?? "current"
|
|
@@ -911,19 +937,19 @@ var ContentManagerRouterInner = ({
|
|
|
911
937
|
defaultContentType,
|
|
912
938
|
backButton
|
|
913
939
|
}) => /* @__PURE__ */ jsxs3(Switch, { children: [
|
|
914
|
-
/* @__PURE__ */
|
|
940
|
+
/* @__PURE__ */ jsx4(
|
|
915
941
|
Route,
|
|
916
942
|
{
|
|
917
943
|
exact: true,
|
|
918
944
|
path: "/",
|
|
919
|
-
render: () => /* @__PURE__ */
|
|
945
|
+
render: () => /* @__PURE__ */ jsx4(ContentListRoute, { defaultContentType, backButton })
|
|
920
946
|
}
|
|
921
947
|
),
|
|
922
|
-
/* @__PURE__ */
|
|
948
|
+
/* @__PURE__ */ jsx4(
|
|
923
949
|
Route,
|
|
924
950
|
{
|
|
925
951
|
path: "/:contentKey",
|
|
926
|
-
render: () => /* @__PURE__ */
|
|
952
|
+
render: () => /* @__PURE__ */ jsx4(ContentEditorRoute, { config, backButton })
|
|
927
953
|
}
|
|
928
954
|
)
|
|
929
955
|
] });
|
|
@@ -936,14 +962,14 @@ var ContentManager = ({
|
|
|
936
962
|
config = DEFAULT_CONFIG,
|
|
937
963
|
defaultContentType,
|
|
938
964
|
backButton
|
|
939
|
-
}) => /* @__PURE__ */
|
|
965
|
+
}) => /* @__PURE__ */ jsx4(EnsureIntlProvider, { children: /* @__PURE__ */ jsx4(
|
|
940
966
|
PuckApiProvider3,
|
|
941
967
|
{
|
|
942
968
|
baseURL,
|
|
943
969
|
projectKey,
|
|
944
970
|
businessUnitKey,
|
|
945
971
|
jwtToken,
|
|
946
|
-
children: /* @__PURE__ */
|
|
972
|
+
children: /* @__PURE__ */ jsx4(BrowserRouter, { basename: parentUrl, children: /* @__PURE__ */ jsx4(
|
|
947
973
|
ContentManagerRouterInner,
|
|
948
974
|
{
|
|
949
975
|
config,
|
|
@@ -952,7 +978,7 @@ var ContentManager = ({
|
|
|
952
978
|
}
|
|
953
979
|
) })
|
|
954
980
|
}
|
|
955
|
-
);
|
|
981
|
+
) });
|
|
956
982
|
export {
|
|
957
983
|
ContentEditor,
|
|
958
984
|
ContentManager,
|