@chaibuilder/pages 0.15.3 → 0.15.6
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/{2AITGKQY-o6FgGSqg.cjs → 2AITGKQY-BnzAO102.cjs} +1 -1
- package/dist/{2AITGKQY-DhC0sF1x.js → 2AITGKQY-tXLat8E2.js} +2 -2
- package/dist/{NCMVHL6D-D7HU3akD.js → NCMVHL6D-BwDANa-N.js} +2 -2
- package/dist/{NCMVHL6D-BPM6RHYa.cjs → NCMVHL6D-DooF4Fqf.cjs} +1 -1
- package/dist/{ZDWCUMSJ-Cr1v3giV.js → ZDWCUMSJ-DWeYRRkj.js} +1 -1
- package/dist/{ZDWCUMSJ-NVCxv9uE.cjs → ZDWCUMSJ-DiH9kc7o.cjs} +1 -1
- package/dist/add-new-language-page-BCUrfgTy.cjs +1 -0
- package/dist/add-new-language-page-DZhjVBBf.js +401 -0
- package/dist/add-new-page-DWHANcUx.cjs +1 -0
- package/dist/add-new-page-DYuuentN.js +31 -0
- package/dist/delete-page-1dSWwUBg.js +40 -0
- package/dist/delete-page-m-Cuz7rG.cjs +1 -0
- package/dist/digital-asset-manager-BWZlrwFf.js +913 -0
- package/dist/digital-asset-manager-By_JTIbb.cjs +1 -0
- package/dist/duplicate-page-Dzs8ya8l.cjs +1 -0
- package/dist/duplicate-page-fUuBTAs7.js +133 -0
- package/dist/{dynamic-page-selector-CF9nb6i_.cjs → dynamic-page-selector-CwhL4z6F.cjs} +1 -1
- package/dist/{dynamic-page-selector-DTk4oull.js → dynamic-page-selector-X2qgdiNQ.js} +1 -1
- package/dist/image-editor-CeSSNbFY.js +108 -0
- package/dist/image-editor-CnDnY97s.cjs +1 -0
- package/dist/index-0cMGDekp.cjs +5 -0
- package/dist/{index-BuXZJnGo.js → index-Bk8tPO5R.js} +1605 -1571
- package/dist/index.cjs +1 -1
- package/dist/index.js +8 -8
- package/dist/{json-diff-viewer-zBoPBSd3.cjs → json-diff-viewer-Cfa9BjZ6.cjs} +1 -1
- package/dist/{json-diff-viewer-oyxMD3Hc.js → json-diff-viewer-Cm84g19X.js} +1 -1
- package/dist/lang-panel-CaSKOJ8G.js +225 -0
- package/dist/lang-panel-CkSfJqr8.cjs +1 -0
- package/dist/mark-as-template-Ci82hbOm.cjs +1 -0
- package/dist/mark-as-template-CwsW86Zv.js +153 -0
- package/dist/no-language-page-content-CPt4aPy9.cjs +1 -0
- package/dist/no-language-page-content-DDz81nqg.js +42 -0
- package/dist/{page-creator-BG2hc82u.cjs → page-creator-Cd2LrG4u.cjs} +1 -1
- package/dist/{page-creator-y6kl3nw5.js → page-creator-Dr566_Yf.js} +2 -2
- package/dist/page-lock-request-Bw_Wye1t.cjs +1 -0
- package/dist/page-lock-request-ECxkQMdS.js +75 -0
- package/dist/page-locked-by-dialog-AbutJT_V.cjs +1 -0
- package/dist/page-locked-by-dialog-CnkVUpjt.js +68 -0
- package/dist/page-manager-new-DLMvOata.cjs +1 -0
- package/dist/page-manager-new-DkqNLZ5C.js +354 -0
- package/dist/page-manager-search-and-filter-B98nz9xS.js +201 -0
- package/dist/page-manager-search-and-filter-CfEfWFeo.cjs +1 -0
- package/dist/{page-revisions-content-BaTqBnko.js → page-revisions-content-CBQPYFZI.js} +18 -18
- package/dist/{page-revisions-content-Tb3T6zvU.cjs → page-revisions-content-D12GEp8C.cjs} +1 -1
- package/dist/{publish-pages-content-C9CgEWo0.js → publish-pages-content-BF5yMo_L.js} +6 -6
- package/dist/{publish-pages-content-BGkEZ3GK.cjs → publish-pages-content-LNCr9tKv.cjs} +1 -1
- package/dist/{save-to-lib-DNK4GPNw.cjs → save-to-lib-C1B6tWEF.cjs} +1 -1
- package/dist/{save-to-lib-DGtyTG6H.js → save-to-lib-SpilaoOL.js} +1 -1
- package/dist/{seo-panel-CrK7z4bR.cjs → seo-panel-DkgkJUT6.cjs} +1 -1
- package/dist/{seo-panel-DESVAQM5.js → seo-panel-sbYoo746.js} +1 -1
- package/dist/server.cjs +1 -1
- package/dist/server.js +96 -96
- package/dist/shared-json-ld-CEUgLAev.cjs +1 -0
- package/dist/shared-json-ld-D_YyVPk3.js +565 -0
- package/dist/{slug-input-DMYhARDW.cjs → slug-input-Cqj9EBju.cjs} +1 -1
- package/dist/{slug-input-DfAsMPg8.js → slug-input-Df-BG6xl.js} +1 -1
- package/dist/theme-panel-footer-B6leVWSV.js +25 -0
- package/dist/theme-panel-footer-Ca1UF5DA.cjs +1 -0
- package/dist/unmark-as-template-BOE-nKOb.cjs +1 -0
- package/dist/unmark-as-template-Cho9B4RN.js +39 -0
- package/dist/unpublish-page-BcxxZ8pr.cjs +1 -0
- package/dist/unpublish-page-Dr4qbwUx.js +27 -0
- package/dist/{web-preview-DNgPjdgZ.js → web-preview-Cq82TNaS.js} +1 -1
- package/dist/{web-preview-BcULgiw_.cjs → web-preview-ued-fdxs.cjs} +1 -1
- package/package.json +3 -4
- package/dist/add-new-language-page-8q4Ku3eg.js +0 -390
- package/dist/add-new-language-page-D3PSLiUv.cjs +0 -1
- package/dist/add-new-page-BpvpSM4X.js +0 -30
- package/dist/add-new-page-YpzILOYq.cjs +0 -1
- package/dist/delete-page-CXRJjJ4o.js +0 -38
- package/dist/delete-page-w64MO7db.cjs +0 -1
- package/dist/digital-asset-manager-B2m5T22s.js +0 -1001
- package/dist/digital-asset-manager-BGyKKd_6.cjs +0 -1
- package/dist/duplicate-page-CSQs2MOp.js +0 -120
- package/dist/duplicate-page-DB_c7V2t.cjs +0 -1
- package/dist/image-editor-D9MPdtxC.js +0 -107
- package/dist/image-editor-Da6lrqkL.cjs +0 -1
- package/dist/index-Cds1vIhw.cjs +0 -5
- package/dist/lang-panel-B_HcsPPo.js +0 -218
- package/dist/lang-panel-D2YUMeJZ.cjs +0 -1
- package/dist/mark-as-template-C4wH4UKf.cjs +0 -1
- package/dist/mark-as-template-CPEPYXg7.js +0 -146
- package/dist/no-language-page-content-CVyOpT9h.js +0 -35
- package/dist/no-language-page-content-ECt0SxFX.cjs +0 -1
- package/dist/page-lock-request-DC62b588.js +0 -64
- package/dist/page-lock-request-fGZbOFTp.cjs +0 -1
- package/dist/page-locked-by-dialog-BIC-c0Jl.cjs +0 -1
- package/dist/page-locked-by-dialog-D-vXaoga.js +0 -63
- package/dist/page-manager-new-CUfjlMed.cjs +0 -1
- package/dist/page-manager-new-Cto2r7Va.js +0 -354
- package/dist/page-manager-search-and-filter-sVnGlF46.js +0 -197
- package/dist/page-manager-search-and-filter-z2b4sgvb.cjs +0 -1
- package/dist/shared-json-ld-BMfQzOWc.js +0 -650
- package/dist/shared-json-ld-_ozYsSHn.cjs +0 -1
- package/dist/theme-panel-footer-Bj2yHtxO.cjs +0 -1
- package/dist/theme-panel-footer-RrxiDGoD.js +0 -25
- package/dist/unmark-as-template-BjetSrYF.js +0 -38
- package/dist/unmark-as-template-C8hTjRVk.cjs +0 -1
- package/dist/unpublish-page-BTPEVAkv.js +0 -26
- package/dist/unpublish-page-gtGfNOAq.cjs +0 -1
package/dist/server.js
CHANGED
|
@@ -2,19 +2,19 @@ var b = Object.defineProperty;
|
|
|
2
2
|
var D = (i, a, t) => a in i ? b(i, a, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[a] = t;
|
|
3
3
|
var _ = (i, a, t) => D(i, typeof a != "symbol" ? a + "" : a, t);
|
|
4
4
|
import { has as p, get as C, isEmpty as L, isFunction as k, omit as I, startsWith as O } from "lodash-es";
|
|
5
|
-
import { getRegisteredChaiBlock as
|
|
5
|
+
import { getRegisteredChaiBlock as B } from "@chaibuilder/runtime";
|
|
6
6
|
let U = async (i) => ({
|
|
7
7
|
...i
|
|
8
8
|
});
|
|
9
9
|
const F = (i) => {
|
|
10
10
|
U = i;
|
|
11
|
-
},
|
|
11
|
+
}, y = async (i) => {
|
|
12
12
|
try {
|
|
13
13
|
return await U(i);
|
|
14
14
|
} catch (a) {
|
|
15
15
|
return console.error(a), {};
|
|
16
16
|
}
|
|
17
|
-
}, w = {},
|
|
17
|
+
}, w = {}, v = () => Object.values(w), g = (i) => w[i], M = (i, a) => {
|
|
18
18
|
w[i] = { key: i, ...a, hasSlug: !0 };
|
|
19
19
|
}, N = (i, a) => {
|
|
20
20
|
w[i] = { key: i, ...a, hasSlug: !1 };
|
|
@@ -22,7 +22,7 @@ const F = (i) => {
|
|
|
22
22
|
function J(i, a) {
|
|
23
23
|
p(P, i) && console.warn(`Collection ${i} already registered`), P[i] = { ...a, id: i };
|
|
24
24
|
}
|
|
25
|
-
const R = () => Object.values(P),
|
|
25
|
+
const R = () => Object.values(P), G = (i) => C(P, i);
|
|
26
26
|
class H {
|
|
27
27
|
constructor(a) {
|
|
28
28
|
this.backend = a;
|
|
@@ -30,7 +30,7 @@ class H {
|
|
|
30
30
|
async upload({
|
|
31
31
|
file: a,
|
|
32
32
|
folderId: t,
|
|
33
|
-
name:
|
|
33
|
+
name: n
|
|
34
34
|
}, e) {
|
|
35
35
|
var o, c;
|
|
36
36
|
return await ((c = (o = this.backend).handleAssetsAction) == null ? void 0 : c.call(
|
|
@@ -38,7 +38,7 @@ class H {
|
|
|
38
38
|
{
|
|
39
39
|
action: "UPLOAD_ASSET",
|
|
40
40
|
data: {
|
|
41
|
-
name:
|
|
41
|
+
name: n,
|
|
42
42
|
file: a,
|
|
43
43
|
folderId: t
|
|
44
44
|
}
|
|
@@ -47,17 +47,17 @@ class H {
|
|
|
47
47
|
));
|
|
48
48
|
}
|
|
49
49
|
async getAsset({ id: a }, t) {
|
|
50
|
-
var
|
|
51
|
-
return (e = (
|
|
52
|
-
|
|
50
|
+
var n, e;
|
|
51
|
+
return (e = (n = this.backend).handleAssetsAction) == null ? void 0 : e.call(
|
|
52
|
+
n,
|
|
53
53
|
{ action: "GET_ASSET", data: { id: a } },
|
|
54
54
|
t
|
|
55
55
|
);
|
|
56
56
|
}
|
|
57
57
|
async getAssets(a, t) {
|
|
58
|
-
var
|
|
59
|
-
return (e = (
|
|
60
|
-
|
|
58
|
+
var n, e;
|
|
59
|
+
return (e = (n = this.backend).handleAssetsAction) == null ? void 0 : e.call(
|
|
60
|
+
n,
|
|
61
61
|
{
|
|
62
62
|
action: "GET_ASSETS",
|
|
63
63
|
data: a
|
|
@@ -66,9 +66,9 @@ class H {
|
|
|
66
66
|
);
|
|
67
67
|
}
|
|
68
68
|
async deleteAsset({ id: a }, t) {
|
|
69
|
-
var
|
|
70
|
-
return (e = (
|
|
71
|
-
|
|
69
|
+
var n, e;
|
|
70
|
+
return (e = (n = this.backend).handleAssetsAction) == null ? void 0 : e.call(
|
|
71
|
+
n,
|
|
72
72
|
{
|
|
73
73
|
action: "DELETE_ASSET",
|
|
74
74
|
data: { id: a }
|
|
@@ -79,14 +79,14 @@ class H {
|
|
|
79
79
|
async updateAsset({
|
|
80
80
|
id: a,
|
|
81
81
|
file: t,
|
|
82
|
-
description:
|
|
82
|
+
description: n
|
|
83
83
|
}, e) {
|
|
84
84
|
var r, o;
|
|
85
85
|
return (o = (r = this.backend).handleAssetsAction) == null ? void 0 : o.call(
|
|
86
86
|
r,
|
|
87
87
|
{
|
|
88
88
|
action: "UPDATE_ASSET",
|
|
89
|
-
data: { id: a, file: t, description:
|
|
89
|
+
data: { id: a, file: t, description: n }
|
|
90
90
|
},
|
|
91
91
|
e
|
|
92
92
|
);
|
|
@@ -97,8 +97,8 @@ class K {
|
|
|
97
97
|
this.backend = a;
|
|
98
98
|
}
|
|
99
99
|
async refreshToken(a) {
|
|
100
|
-
var
|
|
101
|
-
const t = await ((e = (
|
|
100
|
+
var n, e;
|
|
101
|
+
const t = await ((e = (n = this.backend).handleUsersAction) == null ? void 0 : e.call(n, {
|
|
102
102
|
action: "REFRESH_TOKEN",
|
|
103
103
|
data: a
|
|
104
104
|
}));
|
|
@@ -109,11 +109,11 @@ class K {
|
|
|
109
109
|
password: t
|
|
110
110
|
}) {
|
|
111
111
|
var e, r;
|
|
112
|
-
const
|
|
112
|
+
const n = await ((r = (e = this.backend).handleUsersAction) == null ? void 0 : r.call(e, {
|
|
113
113
|
action: "LOGIN",
|
|
114
114
|
data: { email: a, password: t }
|
|
115
115
|
}));
|
|
116
|
-
return
|
|
116
|
+
return n.error ? { error: n.error } : n;
|
|
117
117
|
}
|
|
118
118
|
async logout() {
|
|
119
119
|
var a, t;
|
|
@@ -122,9 +122,9 @@ class K {
|
|
|
122
122
|
}));
|
|
123
123
|
}
|
|
124
124
|
async isUserActive(a) {
|
|
125
|
-
var
|
|
126
|
-
return (await ((e = (
|
|
127
|
-
|
|
125
|
+
var n, e;
|
|
126
|
+
return (await ((e = (n = this.backend).handleUsersAction) == null ? void 0 : e.call(
|
|
127
|
+
n,
|
|
128
128
|
{
|
|
129
129
|
action: "CHECK_USER_STATUS"
|
|
130
130
|
},
|
|
@@ -132,9 +132,9 @@ class K {
|
|
|
132
132
|
))).success;
|
|
133
133
|
}
|
|
134
134
|
async getUserRoleAndPermissions(a) {
|
|
135
|
-
var
|
|
136
|
-
return await ((e = (
|
|
137
|
-
|
|
135
|
+
var n, e;
|
|
136
|
+
return await ((e = (n = this.backend).handleUsersAction) == null ? void 0 : e.call(
|
|
137
|
+
n,
|
|
138
138
|
{
|
|
139
139
|
action: "GET_ROLE_AND_PERMISSIONS"
|
|
140
140
|
},
|
|
@@ -154,19 +154,19 @@ class K {
|
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
156
|
class Y {
|
|
157
|
-
constructor(a, t,
|
|
157
|
+
constructor(a, t, n) {
|
|
158
158
|
_(this, "fallbackLang", "");
|
|
159
159
|
_(this, "draftMode", !1);
|
|
160
|
-
this.backend = a, this.chaiUsers = t, this.chaiAssets =
|
|
160
|
+
this.backend = a, this.chaiUsers = t, this.chaiAssets = n, this._registerDefaultPageTypes(), this.chaiUsers = t ?? new K(this.backend), this.chaiAssets = n ?? new H(this.backend);
|
|
161
161
|
}
|
|
162
162
|
_registerDefaultPageTypes() {
|
|
163
|
-
|
|
163
|
+
M("page", {
|
|
164
164
|
name: "Static Page",
|
|
165
165
|
icon: '<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 24 24" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M5 8V20H19V8H5ZM5 6H19V4H5V6ZM20 22H4C3.44772 22 3 21.5523 3 21V3C3 2.44772 3.44772 2 4 2H20C20.5523 2 21 2.44772 21 3V21C21 21.5523 20.5523 22 20 22ZM7 10H11V14H7V10ZM7 16H17V18H7V16ZM13 11H17V13H13V11Z"></path></svg>'
|
|
166
166
|
}), N("global", {
|
|
167
167
|
name: "Global Block",
|
|
168
168
|
helpText: "A global block can be reused in multiple pages.",
|
|
169
|
-
icon: '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-
|
|
169
|
+
icon: '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-hash-icon lucide-hash"><line x1="4" x2="20" y1="9" y2="9"/><line x1="4" x2="20" y1="15" y2="15"/><line x1="10" x2="8" y1="3" y2="21"/><line x1="16" x2="14" y1="3" y2="21"/></svg>'
|
|
170
170
|
});
|
|
171
171
|
}
|
|
172
172
|
setFallbackLang(a) {
|
|
@@ -220,7 +220,7 @@ class Y {
|
|
|
220
220
|
return (l = this.chaiUsers) == null ? void 0 : l.getUserInfo(t, a.data);
|
|
221
221
|
}
|
|
222
222
|
if (a.action === "GET_BUILDER_PAGE_DATA") {
|
|
223
|
-
const
|
|
223
|
+
const s = await y({
|
|
224
224
|
lang: a.data.lang,
|
|
225
225
|
draft: !0,
|
|
226
226
|
inBuilder: !0
|
|
@@ -232,49 +232,49 @@ class Y {
|
|
|
232
232
|
inBuilder: !0,
|
|
233
233
|
pageProps: a.data.pageProps ?? {}
|
|
234
234
|
}) : {},
|
|
235
|
-
global:
|
|
236
|
-
} : { global:
|
|
235
|
+
global: s
|
|
236
|
+
} : { global: s };
|
|
237
237
|
}
|
|
238
238
|
if (a.action === "GET_PAGE_TYPES")
|
|
239
239
|
return Promise.all(
|
|
240
|
-
|
|
241
|
-
key:
|
|
242
|
-
helpText:
|
|
243
|
-
icon:
|
|
244
|
-
dynamicSegments:
|
|
245
|
-
dynamicSlug:
|
|
246
|
-
hasSlug:
|
|
247
|
-
name: typeof
|
|
248
|
-
...k(
|
|
249
|
-
...k(
|
|
250
|
-
...k(
|
|
240
|
+
v().map(async (s) => ({
|
|
241
|
+
key: s.key,
|
|
242
|
+
helpText: s.helpText ?? "",
|
|
243
|
+
icon: s.icon ?? "",
|
|
244
|
+
dynamicSegments: s.dynamicSegments ?? "",
|
|
245
|
+
dynamicSlug: s.dynamicSlug ?? "",
|
|
246
|
+
hasSlug: s.hasSlug ?? !0,
|
|
247
|
+
name: typeof s.name == "function" ? await s.name() : s.name,
|
|
248
|
+
...k(s.defaultTrackingInfo) ? { trackingDefault: s.defaultTrackingInfo() } : {},
|
|
249
|
+
...k(s.defaultSeo) ? { defaultSeo: s.defaultSeo() } : {},
|
|
250
|
+
...k(s.defaultJSONLD) ? { defaultJSONLD: s.defaultJSONLD() } : {}
|
|
251
251
|
}))
|
|
252
252
|
);
|
|
253
253
|
if (a.action === "SEARCH_PAGE_TYPE_ITEMS") {
|
|
254
|
-
const
|
|
255
|
-
return
|
|
254
|
+
const s = g(a.data.pageType);
|
|
255
|
+
return s ? s.search ? await s.search(a.data.query) : this.backend.handleAction(a, t) : { error: "Page type not found" };
|
|
256
256
|
}
|
|
257
257
|
if (a.action === "GET_DYNAMIC_PAGES") {
|
|
258
|
-
const
|
|
259
|
-
return
|
|
258
|
+
const s = g(a.data.pageType);
|
|
259
|
+
return s ? s.getDynamicPages ? await s.getDynamicPages(a.data) : [] : { error: "Page type not found" };
|
|
260
260
|
}
|
|
261
261
|
if (a.action === "GET_COLLECTIONS")
|
|
262
|
-
return R().map((
|
|
262
|
+
return R().map((s) => I(s, "fetch"));
|
|
263
263
|
if (a.action === "GET_BLOCK_ASYNC_PROPS") {
|
|
264
|
-
const
|
|
265
|
-
if (h === "Repeater" && (
|
|
266
|
-
const d =
|
|
264
|
+
const s = a.data.block, h = s._type;
|
|
265
|
+
if (h === "Repeater" && (s != null && s.repeaterItems.includes("{{#"))) {
|
|
266
|
+
const d = s.repeaterItems.replace("{{#", "").replace("}}", ""), E = G(d);
|
|
267
267
|
return E ? await (E == null ? void 0 : E.fetch({
|
|
268
|
-
block:
|
|
268
|
+
block: s,
|
|
269
269
|
pageProps: a.data.pageProps,
|
|
270
270
|
lang: a.data.lang,
|
|
271
271
|
draft: !0,
|
|
272
272
|
inBuilder: !0
|
|
273
273
|
})) ?? [] : [];
|
|
274
274
|
} else {
|
|
275
|
-
const d =
|
|
275
|
+
const d = B(h);
|
|
276
276
|
return !d || !k(d.dataProvider) ? {} : await d.dataProvider({
|
|
277
|
-
block:
|
|
277
|
+
block: s,
|
|
278
278
|
pageProps: a.data.pageProps,
|
|
279
279
|
lang: a.data.lang,
|
|
280
280
|
draft: !0,
|
|
@@ -282,23 +282,23 @@ class Y {
|
|
|
282
282
|
}) ?? {};
|
|
283
283
|
}
|
|
284
284
|
}
|
|
285
|
-
const
|
|
286
|
-
return this.emit(a.action,
|
|
285
|
+
const n = await this.backend.handleAction(a, t);
|
|
286
|
+
return this.emit(a.action, n), n;
|
|
287
287
|
}
|
|
288
288
|
emit(a, t) {
|
|
289
289
|
var r, o, c;
|
|
290
290
|
if (!["CREATE_PAGE", "UPDATE_PAGE", "DELETE_PAGE"].includes(a)) return;
|
|
291
|
-
const
|
|
292
|
-
if (!
|
|
293
|
-
const e = g(
|
|
291
|
+
const n = C(t, "page");
|
|
292
|
+
if (!n) return;
|
|
293
|
+
const e = g(n.pageType);
|
|
294
294
|
if (e)
|
|
295
295
|
switch (a) {
|
|
296
296
|
case "CREATE_PAGE":
|
|
297
|
-
return (r = e.onCreate) == null ? void 0 : r.call(e,
|
|
297
|
+
return (r = e.onCreate) == null ? void 0 : r.call(e, n);
|
|
298
298
|
case "UPDATE_PAGE":
|
|
299
|
-
return (o = e.onUpdate) == null ? void 0 : o.call(e,
|
|
299
|
+
return (o = e.onUpdate) == null ? void 0 : o.call(e, n);
|
|
300
300
|
case "DELETE_PAGE":
|
|
301
|
-
return (c = e.onDelete) == null ? void 0 : c.call(e,
|
|
301
|
+
return (c = e.onDelete) == null ? void 0 : c.call(e, n);
|
|
302
302
|
}
|
|
303
303
|
}
|
|
304
304
|
/**
|
|
@@ -309,31 +309,31 @@ class Y {
|
|
|
309
309
|
async resolvePageLink(a, t) {
|
|
310
310
|
if (!O(a, "pageType:"))
|
|
311
311
|
return a;
|
|
312
|
-
const
|
|
312
|
+
const n = a.split(":")[1], e = a.split(":")[2], r = g(n);
|
|
313
313
|
return r ? await this.resolveLink(r.key, e, t) : a;
|
|
314
314
|
}
|
|
315
|
-
async resolveLink(a, t,
|
|
315
|
+
async resolveLink(a, t, n) {
|
|
316
316
|
const e = g(a);
|
|
317
317
|
if (!e)
|
|
318
318
|
return "/not-found";
|
|
319
319
|
const r = this.isDraftMode();
|
|
320
|
-
return e.resolveLink ? await e.resolveLink(t, r,
|
|
320
|
+
return e.resolveLink ? await e.resolveLink(t, r, n) : await this.backend.handleAction({
|
|
321
321
|
action: "GET_LINK",
|
|
322
322
|
data: {
|
|
323
323
|
pageType: a,
|
|
324
324
|
id: t,
|
|
325
325
|
draft: r,
|
|
326
|
-
lang:
|
|
326
|
+
lang: n === this.getFallbackLang() ? "" : n
|
|
327
327
|
}
|
|
328
328
|
});
|
|
329
329
|
}
|
|
330
330
|
async getPageBySlug(a) {
|
|
331
|
-
const t = this.isDraftMode(),
|
|
332
|
-
return
|
|
333
|
-
p(e, "dynamicSegments") && e.dynamicSegments && (
|
|
331
|
+
const t = this.isDraftMode(), n = {};
|
|
332
|
+
return v().forEach((e) => {
|
|
333
|
+
p(e, "dynamicSegments") && e.dynamicSegments && (n[e.key] = e.dynamicSegments);
|
|
334
334
|
}), await this.backend.handleAction({
|
|
335
335
|
action: "GET_PAGE_META",
|
|
336
|
-
data: { slug: a, draft: t, dynamicSegments:
|
|
336
|
+
data: { slug: a, draft: t, dynamicSegments: n }
|
|
337
337
|
});
|
|
338
338
|
}
|
|
339
339
|
async getFullPage(a) {
|
|
@@ -347,8 +347,8 @@ class Y {
|
|
|
347
347
|
}
|
|
348
348
|
});
|
|
349
349
|
}
|
|
350
|
-
async getRevisionPage({ id: a, type: t, lang:
|
|
351
|
-
const e = this.getFallbackLang() ===
|
|
350
|
+
async getRevisionPage({ id: a, type: t, lang: n }) {
|
|
351
|
+
const e = this.getFallbackLang() === n ? "" : n;
|
|
352
352
|
return await this.backend.handleAction({
|
|
353
353
|
action: "GET_REVISION_PAGE",
|
|
354
354
|
data: {
|
|
@@ -368,7 +368,7 @@ class Y {
|
|
|
368
368
|
async getPageData({
|
|
369
369
|
blocks: a,
|
|
370
370
|
pageType: t,
|
|
371
|
-
pageProps:
|
|
371
|
+
pageProps: n,
|
|
372
372
|
lang: e
|
|
373
373
|
}) {
|
|
374
374
|
var m;
|
|
@@ -379,26 +379,26 @@ class Y {
|
|
|
379
379
|
if (c.length > 0) {
|
|
380
380
|
const u = c.map((l) => ({ collectionId: l.repeaterItems.replace("{{#", "").replace("}}", ""), block: l }));
|
|
381
381
|
A = (await Promise.all(
|
|
382
|
-
u.map(async ({ collectionId: l, block:
|
|
383
|
-
const h =
|
|
382
|
+
u.map(async ({ collectionId: l, block: s }) => {
|
|
383
|
+
const h = G(l);
|
|
384
384
|
try {
|
|
385
385
|
const d = await (h == null ? void 0 : h.fetch({
|
|
386
386
|
lang: e,
|
|
387
387
|
draft: r,
|
|
388
388
|
inBuilder: !1,
|
|
389
|
-
pageProps:
|
|
390
|
-
block:
|
|
389
|
+
pageProps: n,
|
|
390
|
+
block: s
|
|
391
391
|
}));
|
|
392
392
|
return Promise.resolve({
|
|
393
|
-
[`#${l}/${
|
|
393
|
+
[`#${l}/${s._id}`]: C(d, "items", []) ?? []
|
|
394
394
|
});
|
|
395
395
|
} catch {
|
|
396
396
|
return Promise.resolve({
|
|
397
|
-
[`#${l}/${
|
|
397
|
+
[`#${l}/${s._id}`]: []
|
|
398
398
|
});
|
|
399
399
|
}
|
|
400
400
|
})
|
|
401
|
-
)).reduce((l,
|
|
401
|
+
)).reduce((l, s) => ({ ...l, ...s }), {});
|
|
402
402
|
}
|
|
403
403
|
const [f, S] = await Promise.all([
|
|
404
404
|
this.getGlobalData(e),
|
|
@@ -406,7 +406,7 @@ class Y {
|
|
|
406
406
|
lang: e,
|
|
407
407
|
draft: r,
|
|
408
408
|
inBuilder: !1,
|
|
409
|
-
pageProps:
|
|
409
|
+
pageProps: n
|
|
410
410
|
})) || Promise.resolve({})
|
|
411
411
|
]);
|
|
412
412
|
return o ? {
|
|
@@ -416,7 +416,7 @@ class Y {
|
|
|
416
416
|
} : { global: f, ...A };
|
|
417
417
|
}
|
|
418
418
|
async getGlobalData(a) {
|
|
419
|
-
return await
|
|
419
|
+
return await y({
|
|
420
420
|
lang: a,
|
|
421
421
|
draft: this.isDraftMode(),
|
|
422
422
|
inBuilder: !1
|
|
@@ -427,30 +427,30 @@ class Y {
|
|
|
427
427
|
}
|
|
428
428
|
}
|
|
429
429
|
class Z {
|
|
430
|
-
constructor(a = "", t =
|
|
430
|
+
constructor(a = "", t = x) {
|
|
431
431
|
this.apiKey = a, this.apiUrl = t;
|
|
432
432
|
}
|
|
433
433
|
async handleUsersAction(a, t) {
|
|
434
|
-
const
|
|
434
|
+
const n = await fetch(`${this.apiUrl}/v1/api/users`, {
|
|
435
435
|
method: "POST",
|
|
436
436
|
body: JSON.stringify(a),
|
|
437
437
|
headers: {
|
|
438
438
|
"x-chai-api-key": this.apiKey,
|
|
439
439
|
"x-chai-auth-token": t
|
|
440
440
|
}
|
|
441
|
-
}), e = await
|
|
442
|
-
return p(e, "error") ? { ...e, status:
|
|
441
|
+
}), e = await n.json();
|
|
442
|
+
return p(e, "error") ? { ...e, status: n.status } : e;
|
|
443
443
|
}
|
|
444
444
|
async handleAction(a, t) {
|
|
445
|
-
const
|
|
445
|
+
const n = await fetch(`${this.apiUrl}/v1/api/chai`, {
|
|
446
446
|
method: "POST",
|
|
447
447
|
body: JSON.stringify(a),
|
|
448
448
|
headers: {
|
|
449
449
|
"x-chai-api-key": this.apiKey,
|
|
450
450
|
"x-chai-auth-token": t
|
|
451
451
|
}
|
|
452
|
-
}), e = await
|
|
453
|
-
return p(e, "error") ? { ...e, status:
|
|
452
|
+
}), e = await n.json();
|
|
453
|
+
return p(e, "error") ? { ...e, status: n.status } : e;
|
|
454
454
|
}
|
|
455
455
|
async handleAssetsAction(a, t) {
|
|
456
456
|
return await (await fetch(`${this.apiUrl}/v1/api/assets`, {
|
|
@@ -651,19 +651,19 @@ const $ = {
|
|
|
651
651
|
yo: "Yoruba",
|
|
652
652
|
za: "Zhuang, Chuang",
|
|
653
653
|
zu: "Zulu"
|
|
654
|
-
},
|
|
654
|
+
}, x = "https://api.chaibuilder.com";
|
|
655
655
|
export {
|
|
656
|
-
|
|
656
|
+
x as API_URL,
|
|
657
657
|
Y as ChaiBuilderPages,
|
|
658
658
|
Z as ChaiBuilderPagesBackend,
|
|
659
659
|
K as ChaiBuilderPagesUserManagement,
|
|
660
660
|
$ as LANGUAGES,
|
|
661
|
-
|
|
661
|
+
G as getChaiCollection,
|
|
662
662
|
R as getChaiCollections,
|
|
663
663
|
g as getChaiPageType,
|
|
664
|
-
|
|
664
|
+
v as getChaiPageTypes,
|
|
665
665
|
J as registerChaiCollection,
|
|
666
666
|
F as registerChaiGlobalDataProvider,
|
|
667
|
-
|
|
667
|
+
M as registerChaiPageType,
|
|
668
668
|
N as registerChaiPartialType
|
|
669
669
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),M=require("@chaibuilder/sdk"),G=require("@tanstack/react-query"),c=require("./index-0cMGDekp.cjs"),s=require("@chaibuilder/sdk/ui"),B=require("lodash-es"),f=require("lucide-react"),x=require("react"),E=require("sonner"),I=()=>{const t=c.useApiUrl(),d=c.useFetch();return G.useQuery({queryKey:[c.ACTIONS.GET_GLOBAL_JSONLD_ITEMS],queryFn:async()=>d(t,{action:c.ACTIONS.GET_GLOBAL_JSONLD_ITEMS})})},U=({show:t,onClose:d,initialData:n})=>e.jsx(s.Dialog,{open:t,onOpenChange:()=>d(),children:t&&e.jsx(_,{show:t,onClose:d,initialData:n})}),_=({show:t,onClose:d,initialData:n})=>{const[r,p]=x.useState({name:"",content:"",description:"",enabledByDefaultForNewPages:!1}),[N,C]=x.useState(!1),{data:g}=c.useCurrentPage(),{mutateAsync:A,isPending:j}=c.useAddGlobalSchema(),{mutateAsync:u}=c.useTogglePageGlobalSchema(),v=G.useQueryClient();x.useEffect(()=>{p(n?{name:n.name,description:n.description,content:JSON.stringify(n.jsonld,null,2),enabledByDefaultForNewPages:!1}:{name:"",description:"",content:"",enabledByDefaultForNewPages:!1}),C(!1)},[t,n]);const i=async()=>{if(!r.name||!r.content){E.toast.error("Please enter a name and content");return}const l=c.parseJSONWithPlaceholders(r.content);if(!l.isValid){E.toast.error("Invalid JSON-LD content");return}const b={name:r.name,jsonld:l.parsed,addToExistingPages:N,addToNewPages:r.enabledByDefaultForNewPages,description:r.description};n!=null&&n.primaryPageId&&(b.primaryPage=n.primaryPageId);const w=await A(b);g!=null&&g.id&&(w!=null&&w.id)&&!(n!=null&&n.primaryPageId)&&(await u({schemaId:w.id,pageId:g.id,enabled:!0}),v.invalidateQueries({queryKey:[c.ACTIONS.GET_LANGUAGE_PAGES,g.id]})),d()};return e.jsxs(s.DialogContent,{className:"flex max-w-xl flex-col overflow-y-auto",children:[e.jsx(s.DialogHeader,{children:e.jsx(s.DialogTitle,{children:"Add New Shared JSON-LD Schema"})}),e.jsxs("div",{className:"flex max-h-[75vh] flex-col space-y-2 overflow-y-auto",children:[(n==null?void 0:n.languageCode)&&e.jsxs(s.Alert,{className:"border-blue-200 bg-blue-50",children:[e.jsx(f.Info,{className:"h-4 w-4 text-blue-600"}),e.jsxs(s.AlertDescription,{className:"text-sm text-blue-800",children:["You are creating a ",e.jsx("span",{className:"font-semibold",children:n.languageCode})," language version of this schema. This will be linked to the default language schema."]})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"new-name",children:"Schema Name"}),e.jsx(s.Input,{id:"new-name",value:r.name,onChange:l=>p({...r,name:l.target.value}),placeholder:"e.g., Product Schema",className:"text-xs"})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"new-description",children:"Description"}),e.jsx(s.Input,{id:"new-description",value:r.description||"",onChange:l=>p({...r,description:l.target.value}),placeholder:"Brief description of this schema"})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"new-content",children:"JSON-LD Content"}),e.jsx(c.SmartJsonInput,{id:"new-content",value:r.content||"{}",onChange:l=>p({...r,content:l}),placeholder:"Enter JSON-LD markup...",rows:10})]}),!(n!=null&&n.primaryPageId)&&e.jsxs("div",{className:"flex flex-col gap-3 pt-2",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"checkbox",id:"add-to-all-existing",checked:N,onChange:l=>C(l.target.checked),className:"h-5 w-5 cursor-pointer rounded focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-1"}),e.jsxs(s.Label,{htmlFor:"add-to-all-existing",children:[e.jsx("div",{children:"Add to all existing pages"}),e.jsx("div",{className:"text-xs font-light text-muted-foreground",children:"This schema will be added to all existing pages on your site"})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"checkbox",id:"new-enabled",checked:r.enabledByDefaultForNewPages,onChange:l=>p({...r,enabledByDefaultForNewPages:l.target.checked}),className:"h-5 w-5 cursor-pointer rounded focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-1"}),e.jsxs(s.Label,{htmlFor:"new-enabled",children:[e.jsx("div",{children:"Enabled by default for new pages"}),e.jsx("div",{className:"text-xs font-light text-muted-foreground",children:"New pages will automatically include this schema"})]})]})]}),e.jsx("div",{className:"border-t pt-3",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(s.Button,{disabled:j,variant:"outline",type:"button",size:"sm",onClick:()=>d(),children:"Cancel"}),e.jsx(s.Button,{disabled:j,type:"button",size:"sm",onClick:i,children:j?e.jsxs(e.Fragment,{children:[e.jsx(f.Loader,{className:"h-4 w-4 animate-spin"})," Adding"]}):e.jsxs(e.Fragment,{children:["Add Schema",(n==null?void 0:n.languageCode)&&` (${n.languageCode})`]})})]})})]})]})},H=({id:t,onClose:d})=>e.jsx(s.Dialog,{open:!!t,onOpenChange:()=>d(),children:t&&e.jsx(Q,{id:t,onClose:d})}),Q=({id:t,onClose:d})=>{const[n,r]=x.useState({name:"",content:"",description:"",enabledByDefaultForNewPages:!1}),[p,N]=x.useState(!1),[C,g]=x.useState(!1),[A,j]=x.useState(!1),{data:u}=I(),{mutateAsync:v,isPending:i}=c.useUpdateGlobalSchema(),{mutateAsync:l}=c.useApplySchemaToAllPages(),{mutateAsync:b}=c.useRemoveSchemaFromAllPages();x.useEffect(()=>{var m,D;if(t&&u){const y=u.find(P=>P.id===t);y&&(r({name:y.name,description:((m=y.metadata)==null?void 0:m.description)||"",content:JSON.stringify(y.jsonld,null,2),enabledByDefaultForNewPages:((D=y.metadata)==null?void 0:D.addToNewPages)||!1}),j(!!y.primaryPage))}},[t,u]);const w=async()=>{if(!n.name||!n.content){E.toast.error("Please enter a name and content");return}const m=c.parseJSONWithPlaceholders(n.content);if(!m.isValid){E.toast.error("Invalid JSON-LD content");return}const D={id:t,name:n.name,jsonld:m.parsed,addToNewPages:n.enabledByDefaultForNewPages,description:n.description};await v(D),d()},F=async()=>{try{await l(t)}finally{N(!1)}},T=async()=>{try{await b(t)}finally{g(!1)}};return e.jsxs(s.DialogContent,{className:"flex max-w-xl flex-col overflow-y-auto",children:[e.jsx(s.DialogHeader,{children:e.jsx(s.DialogTitle,{children:"Edit Shared JSON-LD Schema"})}),e.jsxs("div",{className:"flex max-h-[75vh] flex-col space-y-2 overflow-y-auto",children:[!A&&e.jsxs("div",{className:"flex items-center justify-between rounded-lg border border-blue-300 bg-blue-500/10 p-2",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-blue-900",children:"Manage Existing Pages"}),e.jsx("div",{className:"text-xs text-blue-700",children:"Add or remove this schema from all existing pages on your site"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(s.Button,{size:"sm",className:"text-xs",variant:"outline",onClick:()=>N(!0),children:"Add to all existing"}),e.jsx(s.Button,{size:"sm",variant:"ghost",className:"text-xs",onClick:()=>g(!0),children:"Remove from all"})]})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"edit-name",children:"Schema Name"}),e.jsx(s.Input,{id:"edit-name",value:n.name,onChange:m=>r({...n,name:m.target.value}),placeholder:"e.g., Product Schema",className:"text-xs"})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"edit-description",children:"Description"}),e.jsx(s.Input,{id:"edit-description",value:n.description||"",onChange:m=>r({...n,description:m.target.value}),placeholder:"Brief description of this schema"})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"edit-content",children:"JSON-LD Content"}),e.jsx(c.SmartJsonInput,{id:"edit-content",value:n.content||"{}",onChange:m=>r({...n,content:m}),placeholder:"Enter JSON-LD markup...",rows:10})]}),!A&&e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"checkbox",id:"edit-enabled",checked:n.enabledByDefaultForNewPages,onChange:m=>r({...n,enabledByDefaultForNewPages:m.target.checked}),className:"h-5 w-5 cursor-pointer rounded focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-1"}),e.jsxs(s.Label,{htmlFor:"edit-enabled",children:[e.jsx("div",{children:"Enabled by default for new pages"}),e.jsx("div",{className:"text-xs font-light text-muted-foreground",children:"New pages will automatically include this schema"})]})]}),e.jsx("div",{className:"border-t pt-3",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(s.Button,{disabled:i,variant:"outline",type:"button",size:"sm",onClick:()=>d(),children:"Cancel"}),e.jsx(s.Button,{disabled:i,type:"button",size:"sm",onClick:w,children:i?e.jsxs(e.Fragment,{children:[e.jsx(f.Loader,{className:"h-4 w-4 animate-spin"})," Updating"]}):"Update Schema"})]})})]}),e.jsx(s.AlertDialog,{open:p,onOpenChange:N,children:e.jsxs(s.AlertDialogContent,{children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:"Add to All Existing Pages?"}),e.jsxs(s.AlertDialogDescription,{children:["This will add the schema ",e.jsx("span",{className:"font-medium",children:n.name})," to all existing pages on your site. This action cannot be undone automatically."]})]}),e.jsxs(s.AlertDialogFooter,{children:[e.jsx(s.AlertDialogCancel,{children:"Cancel"}),e.jsx(s.AlertDialogAction,{onClick:F,children:"Add to All"})]})]})}),e.jsx(s.AlertDialog,{open:C,onOpenChange:g,children:e.jsxs(s.AlertDialogContent,{children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:"Remove from All Pages?"}),e.jsxs(s.AlertDialogDescription,{children:["This will remove the schema ",e.jsx("span",{className:"font-medium",children:n.name})," from all existing pages on your site. This action cannot be undone automatically."]})]}),e.jsxs(s.AlertDialogFooter,{children:[e.jsx(s.AlertDialogCancel,{children:"Cancel"}),e.jsx(s.AlertDialogAction,{onClick:T,className:"bg-red-500 hover:bg-red-600",children:"Remove from All"})]})]})})]})};function V(){const[t,d]=x.useState(!1),[n,r]=x.useState(void 0),[p,N]=x.useState(null),[C,g]=x.useState(null),[A,j]=x.useState(null),{data:u,isLoading:v}=I(),{selectedLang:i}=M.useLanguages(),{data:l}=c.useCurrentPage(),{data:b}=c.useLanguagePages(),{mutateAsync:w}=c.useDeleteGlobalSchema(),{mutateAsync:F}=c.useTogglePageGlobalSchema(),T=x.useMemo(()=>b==null?void 0:b.find(a=>!a.primaryPage&&a.lang===""),[b]),m=x.useMemo(()=>(T==null?void 0:T.globalJsonLds)||[],[T]),D=x.useMemo(()=>u?B.filter(u,o=>o.primaryPage===null&&o.lang==="").map(o=>{const h=i?B.find(u,S=>S.primaryPage===o.id&&S.lang===i):null;return{defaultSchema:o,languageVersion:h,displayItem:h||o,hasLanguageVersion:!!h}}):[],[u,i]),[y,P]=x.useState([]),L=y.length>0?y:(l==null?void 0:l.globalJsonLds)||[];x.useEffect(()=>{l!=null&&l.globalJsonLds&&P(l.globalJsonLds)},[l==null?void 0:l.globalJsonLds]);const q=async a=>{if(!(l!=null&&l.id))return;j(a);const o=L.includes(a),h=o?L.filter(S=>S!==a):[...L,a];P(h);try{await F({schemaId:a,pageId:l.id,enabled:!o})}catch{P(l.globalJsonLds)}finally{j(null)}},z=async a=>{j(a);try{await w(a)}finally{j(null)}};return e.jsxs("div",{className:"rounded border bg-muted p-2",children:[e.jsxs("div",{className:"flex items-center justify-between pb-2",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-medium",children:"Shared JSON-LD Templates"}),e.jsx("div",{className:"w-full text-xs text-gray-500",children:"Manage reusable JSON-LD schemas that can be applied across multiple pages"})]}),!i&&e.jsxs(s.Tooltip,{delayDuration:0,children:[e.jsx(s.TooltipTrigger,{type:"button",disabled:v,className:"rounded-full bg-primary p-1 text-primary-foreground hover:bg-primary/80",onClick:a=>{a.stopPropagation(),d(!0)},children:v?e.jsx(f.Loader,{className:"h-4 w-4 animate-spin"}):e.jsx(f.Plus,{className:"h-4 w-4"})}),e.jsx(s.TooltipContent,{children:"Add new schema"})]})]}),e.jsxs(s.ScrollArea,{className:"max-h-96 overflow-y-auto",children:[e.jsxs("div",{className:"space-y-2",children:[(!u||(u==null?void 0:u.length)===0)&&!v&&e.jsx("div",{className:"flex items-center justify-center px-2 py-4 text-xs",children:"No shared JSON-LD found"}),D.map(({defaultSchema:a,displayItem:o,hasLanguageVersion:h})=>{var J,k;const S=L.includes(o.id),O=m.includes(a.id),R=h&&i?O:S;return e.jsxs(s.Card,{className:`relative border-gray-300 p-0 shadow-none transition-all ${A===o.id?"pointer-events-none":""}`,children:[A===o.id&&e.jsx("div",{className:"absolute bottom-0 left-0 right-0 top-0 z-50 flex items-center justify-center rounded-xl bg-white/80",children:e.jsx(f.Loader,{className:"h-5 w-5 animate-spin text-primary"})}),e.jsx(s.CardHeader,{className:"p-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[(h||!i)&&e.jsxs(s.Tooltip,{delayDuration:0,children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx("input",{type:"checkbox",checked:R,onChange:()=>q(a.id),disabled:!!(h&&i),className:"h-5 w-5 cursor-pointer rounded focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-1"})}),h&&i&&e.jsx(s.TooltipContent,{children:"Using the default language state"})]}),e.jsxs("div",{children:[e.jsxs(s.CardTitle,{className:"flex items-center gap-2 text-sm leading-none",children:[o.name,h&&i&&e.jsxs("span",{className:"text-xs font-normal text-muted-foreground",children:["(",i,")"]})]}),((J=o==null?void 0:o.metadata)==null?void 0:J.description)&&e.jsx("p",{className:"mt-1 text-xs leading-none text-muted-foreground",children:(k=o==null?void 0:o.metadata)==null?void 0:k.description})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"mx-2 h-6 w-px bg-border"}),e.jsxs(s.Tooltip,{delayDuration:0,children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx(s.Button,{type:"button",variant:"ghost",size:"icon",className:"h-5 w-5 p-0",onClick:()=>g(o.id),children:e.jsx(f.Eye,{className:"h-4 w-4"})})}),e.jsx(s.TooltipContent,{children:"View schema"})]}),(h||!i)&&e.jsxs(e.Fragment,{children:[e.jsxs(s.Tooltip,{delayDuration:0,children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx(s.Button,{type:"button",variant:"ghost",size:"icon",className:"h-5 w-5 p-0",onClick:()=>N(o.id),children:e.jsx(f.Edit,{className:"h-4 w-4"})})}),e.jsx(s.TooltipContent,{children:"Edit schema"})]}),e.jsxs(s.AlertDialog,{children:[e.jsxs(s.Tooltip,{delayDuration:0,children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx(s.AlertDialogTrigger,{className:"flex h-5 w-5 items-center justify-center rounded-md text-red-500 hover:bg-red-100 hover:text-red-800",children:e.jsx(f.Trash,{className:"h-4 w-4"})})}),e.jsx(s.TooltipContent,{children:"Delete schema"})]}),e.jsxs(s.AlertDialogContent,{children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:"Delete Schema"}),e.jsxs(s.AlertDialogDescription,{children:["Are you sure you want to delete"," ",e.jsx("span",{className:"font-medium",children:o.name}),"? This action cannot be undone."]})]}),e.jsxs(s.AlertDialogFooter,{children:[e.jsx(s.AlertDialogCancel,{type:"button",children:"Cancel"}),e.jsx(s.AlertDialogAction,{type:"button",onClick:()=>z(o.id),className:"bg-red-500 text-white hover:bg-red-600",children:"Delete"})]})]})]})]})]})]})}),!h&&i&&e.jsx(s.CardContent,{className:"px-2 pb-2",children:e.jsxs("div",{className:"flex w-full flex-col items-center justify-center rounded-lg border bg-gray-100 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"max-w-xl text-center text-xs text-gray-500",children:["Not available in '",i,"' language. Default language JSONLD will be used."]}),O&&e.jsx("span",{className:"rounded-full bg-green-100 px-2 py-0.5 text-xs font-medium text-green-700",children:"Enabled in default"})]}),e.jsx(s.Button,{type:"button",size:"sm",variant:"outline",className:"mt-2",onClick:()=>{r({name:a.name,description:a.description||"",jsonld:a.jsonld,languageCode:i,primaryPageId:a.id}),d(!0)},children:"Copy & Edit from default language"})]})})]},a.id)})]}),v&&e.jsx("div",{className:"flex items-center justify-center p-4",children:e.jsx(f.Loader,{className:"h-5 w-5 animate-spin"})})]}),e.jsx(U,{show:t,onClose:()=>{d(!1),r(void 0)},initialData:n}),e.jsx(H,{id:p,onClose:()=>N(null)}),e.jsx(K,{schema:u==null?void 0:u.find(a=>a.id===C),onClose:()=>g(null)})]})}const K=({schema:t,onClose:d})=>e.jsx(s.Dialog,{open:!!t,onOpenChange:d,children:e.jsxs(s.DialogContent,{className:"max-w-2xl",children:[e.jsx(s.DialogHeader,{children:e.jsxs(s.DialogTitle,{className:"flex items-center gap-2",children:[t==null?void 0:t.name,(t==null?void 0:t.lang)&&e.jsxs("span",{className:"text-sm font-normal text-muted-foreground",children:["(",t.lang,")"]})]})}),e.jsxs("div",{className:"space-y-3",children:[(t==null?void 0:t.description)&&e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Description"}),e.jsx("div",{className:"text-sm",children:t.description})]}),e.jsxs("div",{children:[e.jsx("div",{className:"mb-2 text-xs font-medium text-muted-foreground",children:"JSON-LD Schema"}),e.jsx(s.Textarea,{value:JSON.stringify(t==null?void 0:t.jsonld,null,2),readOnly:!0,className:"font-mono text-xs",rows:15})]})]})]})});exports.default=V;
|