@chaibuilder/pages 0.13.4 → 0.14.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 (78) hide show
  1. package/dist/{2AITGKQY-Dx_Cte-P.js → 2AITGKQY-Cti4x7QE.js} +5 -5
  2. package/dist/{2AITGKQY-DpAgk_u8.cjs → 2AITGKQY-PHs1xUsz.cjs} +1 -1
  3. package/dist/{NCMVHL6D-B6lv7Umq.cjs → NCMVHL6D-BChQ0wDN.cjs} +1 -1
  4. package/dist/{NCMVHL6D-CT2qHOTS.js → NCMVHL6D-fAWarBw8.js} +4 -4
  5. package/dist/{ZDWCUMSJ-C1vrgsti.cjs → ZDWCUMSJ-CwWfQqyn.cjs} +1 -1
  6. package/dist/{ZDWCUMSJ-W9xywtZH.js → ZDWCUMSJ-DRWuu_nE.js} +1 -1
  7. package/dist/add-new-language-page-CcBqDtYv.js +390 -0
  8. package/dist/add-new-language-page-Dt9DWunK.cjs +1 -0
  9. package/dist/add-new-page-BN3z9rSq.cjs +1 -0
  10. package/dist/add-new-page-CTUiEKzv.js +30 -0
  11. package/dist/confetti.module-BuUnQuWk.cjs +2 -0
  12. package/dist/confetti.module-DCmCkDyV.js +409 -0
  13. package/dist/delete-page-8MnGZ_mz.js +38 -0
  14. package/dist/delete-page-jELwTpGY.cjs +1 -0
  15. package/dist/digital-asset-manager-BJhwyEdT.js +976 -0
  16. package/dist/digital-asset-manager-ZyQJP6AO.cjs +1 -0
  17. package/dist/duplicate-page-BGYZLkco.js +120 -0
  18. package/dist/duplicate-page-BRjKFpBP.cjs +1 -0
  19. package/dist/dynamic-page-selector-CR-ZpSJ8.cjs +1 -0
  20. package/dist/dynamic-page-selector-CrbujoYg.js +86 -0
  21. package/dist/get-seo-defaults-9zHebckY.js +65 -0
  22. package/dist/get-seo-defaults-Cw7vFt-B.cjs +1 -0
  23. package/dist/image-compression-DZ9WMmyn.cjs +1 -0
  24. package/dist/image-compression-DsZ1oqpb.js +37 -0
  25. package/dist/index-Byi6-4u1.js +5164 -0
  26. package/dist/index-DSUpSpeI.cjs +5 -0
  27. package/dist/index.cjs +1 -1
  28. package/dist/index.d.ts +4 -22
  29. package/dist/index.js +18 -19
  30. package/dist/json-diff-viewer-DKlC7yl6.cjs +8 -0
  31. package/dist/json-diff-viewer-De2bStRw.js +258 -0
  32. package/dist/lang-panel-B3bC1gKq.cjs +1 -0
  33. package/dist/lang-panel-G7RoMOP7.js +218 -0
  34. package/dist/mark-as-template-B1TpGPms.js +146 -0
  35. package/dist/mark-as-template-OgR8I38n.cjs +1 -0
  36. package/dist/nested-path-selector-content-D_iF9Sm3.cjs +1 -0
  37. package/dist/nested-path-selector-content-DvIL_EoN.js +87 -0
  38. package/dist/no-language-page-content-CqH4FMNy.js +35 -0
  39. package/dist/no-language-page-content-iZo2ztXp.cjs +1 -0
  40. package/dist/page-creator-Chnj3W4j.js +796 -0
  41. package/dist/page-creator-DUXzx-zg.cjs +1 -0
  42. package/dist/page-lock-request-D3gmV8Yq.cjs +1 -0
  43. package/dist/page-lock-request-Dc-JkLEZ.js +64 -0
  44. package/dist/page-locked-by-dialog-B9pGi6zb.cjs +1 -0
  45. package/dist/page-locked-by-dialog-DC8UKy9e.js +63 -0
  46. package/dist/page-manager-new-CFtYUNbS.cjs +1 -0
  47. package/dist/page-manager-new-DYYWpxWy.js +354 -0
  48. package/dist/page-manager-search-and-filter-B4xo9IJO.js +197 -0
  49. package/dist/page-manager-search-and-filter-DT9V9AoS.cjs +1 -0
  50. package/dist/page-revisions-content-BjIECUPY.cjs +1 -0
  51. package/dist/page-revisions-content-KJGhm9Pl.js +446 -0
  52. package/dist/publish-pages-content-BWLQZGjd.js +178 -0
  53. package/dist/publish-pages-content-CTduLNtg.cjs +1 -0
  54. package/dist/save-to-lib-B07GbG4I.js +476 -0
  55. package/dist/save-to-lib-CsrSeusU.cjs +1 -0
  56. package/dist/seo-panel-B20DCgo0.js +667 -0
  57. package/dist/seo-panel-QphuqXT2.cjs +1 -0
  58. package/dist/shared-json-ld-C_vIO-Qk.cjs +1 -0
  59. package/dist/shared-json-ld-CkOQRUEw.js +337 -0
  60. package/dist/slug-input-71BuN79c.cjs +1 -0
  61. package/dist/slug-input-rAe3mMkd.js +87 -0
  62. package/dist/theme-panel-footer-DFUfCqKP.js +25 -0
  63. package/dist/theme-panel-footer-DHRs6ag2.cjs +1 -0
  64. package/dist/translation-warning-modal-DalBhNQy.js +26 -0
  65. package/dist/translation-warning-modal-Kctu12rQ.cjs +1 -0
  66. package/dist/unmark-as-template-Cx0CqrpM.cjs +1 -0
  67. package/dist/unmark-as-template-_VyWoVNk.js +38 -0
  68. package/dist/unpublish-page-CuSJRr5c.js +26 -0
  69. package/dist/unpublish-page-D3NM8b3u.cjs +1 -0
  70. package/dist/use-page-expand-manager-MjYZ3CDZ.cjs +1 -0
  71. package/dist/use-page-expand-manager-_msrWd0a.js +85 -0
  72. package/dist/web-preview-BL-vsgoa.js +73 -0
  73. package/dist/web-preview-CI3Vz7Yp.cjs +1 -0
  74. package/package.json +1 -1
  75. package/dist/index-C4j31Yhz.js +0 -11471
  76. package/dist/index-DnjETHks.cjs +0 -6
  77. package/dist/page-revisions-content-Gx-Qf_91.cjs +0 -8
  78. package/dist/page-revisions-content-_-Nd4U11.js +0 -712
@@ -0,0 +1,197 @@
1
+ import { jsx as e, jsxs as r, Fragment as w } from "react/jsx-runtime";
2
+ import { f as P, L, h as F, A as I } from "./index-Byi6-4u1.js";
3
+ import { u as z } from "./use-page-expand-manager-_msrWd0a.js";
4
+ import { Button as m, Tooltip as f, TooltipTrigger as v, TooltipContent as g, Select as j, SelectTrigger as $, SelectContent as G, Input as S, SelectItem as b } from "@chaibuilder/sdk/ui";
5
+ import { useQueryClient as T } from "@tanstack/react-query";
6
+ import { isEmpty as y, filter as u, map as C, get as o } from "lodash-es";
7
+ import { Star as D, Plus as M, FilterXIcon as R, Filter as W, ListFilter as q, Search as A, ChevronsUpDown as B, ChevronsDownUp as K, RefreshCw as Q } from "lucide-react";
8
+ import { useState as _ } from "react";
9
+ const O = ({ selectedPageType: a, setSelectedPageType: i }) => {
10
+ const [s, l] = _(""), { data: n } = F(), c = (t) => {
11
+ if (!s) return !0;
12
+ const d = s.toLowerCase(), h = (x) => String(o(t, x, "")).toLowerCase().includes(d);
13
+ return h("name") || h("key");
14
+ }, p = n.find((t) => t.key === a);
15
+ return /* @__PURE__ */ r(j, { onValueChange: i, value: a, children: [
16
+ /* @__PURE__ */ e(
17
+ $,
18
+ {
19
+ className: `${a === "all" ? "bg-gray-100/30 hover:bg-gray-100" : "gap-x-1 border bg-gray-100/30 hover:bg-gray-100"} h-9 w-max min-w-[150px] overflow-hidden whitespace-nowrap rounded p-0 px-2 py-1 text-xs text-gray-600 shadow-none ring-0 focus:ring-0 [&>svg]:hidden`,
20
+ children: /* @__PURE__ */ r("div", { className: "flex w-full items-center justify-between gap-x-1.5", children: [
21
+ /* @__PURE__ */ e("span", { className: "max-w-[150px] overflow-hidden truncate whitespace-nowrap font-medium leading-tight", children: (p == null ? void 0 : p.name) || "All" }),
22
+ /* @__PURE__ */ e(
23
+ q,
24
+ {
25
+ className: `${a !== "all" ? "fill-sky-50 text-sky-500" : ""} pointer-events-none h-4 w-4 text-muted-foreground hover:bg-blue-300`
26
+ }
27
+ )
28
+ ] })
29
+ }
30
+ ),
31
+ /* @__PURE__ */ r(G, { children: [
32
+ /* @__PURE__ */ e("div", { className: "sticky top-0 z-10 bg-white pb-2", children: /* @__PURE__ */ r("div", { className: "relative", children: [
33
+ /* @__PURE__ */ e(A, { strokeWidth: 2, className: "absolute left-2 top-2.5 h-3.5 w-3.5 text-gray-400" }),
34
+ /* @__PURE__ */ e(
35
+ S,
36
+ {
37
+ placeholder: "Search page types...",
38
+ className: "h-8 w-full rounded border pl-8 text-xs shadow-none",
39
+ value: s,
40
+ onChange: (t) => l(t.target.value),
41
+ onKeyDown: (t) => t.stopPropagation()
42
+ }
43
+ )
44
+ ] }) }),
45
+ /* @__PURE__ */ e(b, { value: "all", children: "All" }),
46
+ !y(u(n, (t) => t.hasSlug && c(t))) && /* @__PURE__ */ r(w, { children: [
47
+ /* @__PURE__ */ e("div", { className: "mt-2 border-t px-2 py-1.5 pt-2 text-xs font-semibold text-gray-500", children: "Pages" }),
48
+ C(
49
+ [...u(n, (t) => t.hasSlug && c(t))].sort(
50
+ (t, d) => o(t, "name", "").localeCompare(o(d, "name", ""))
51
+ ),
52
+ (t) => /* @__PURE__ */ e(b, { value: o(t, "key"), children: o(t, "name") }, o(t, "key"))
53
+ )
54
+ ] }),
55
+ !y(u(n, (t) => !t.hasSlug && c(t))) && /* @__PURE__ */ r(w, { children: [
56
+ /* @__PURE__ */ e("div", { className: "mt-2 border-t px-2 py-1.5 pt-2 text-xs font-semibold text-gray-500", children: "Partials" }),
57
+ C(
58
+ [...u(n, (t) => !t.hasSlug && c(t))].sort(
59
+ (t, d) => o(t, "name", "").localeCompare(o(d, "name", ""))
60
+ ),
61
+ (t) => /* @__PURE__ */ e(b, { value: o(t, "key"), children: o(t, "name") }, o(t, "key"))
62
+ )
63
+ ] }),
64
+ y(u(n, c)) && /* @__PURE__ */ e("div", { className: "px-3 py-2 text-center text-sm text-gray-500", children: "No matching page types found" })
65
+ ] })
66
+ ] });
67
+ }, U = ({ search: a, setSearch: i }) => /* @__PURE__ */ r("div", { className: "relative flex h-9 flex-1 items-center gap-2 rounded-md border px-2.5", children: [
68
+ /* @__PURE__ */ e("label", { htmlFor: "page-search-input", className: "sr-only", children: "Search Pages" }),
69
+ /* @__PURE__ */ e(
70
+ A,
71
+ {
72
+ className: `${a ? "fill-sky-50 text-sky-500" : ""} pointer-events-none h-4 w-4 text-muted-foreground`,
73
+ "aria-hidden": "true"
74
+ }
75
+ ),
76
+ /* @__PURE__ */ e(
77
+ S,
78
+ {
79
+ id: "page-search-input",
80
+ placeholder: "Search pages",
81
+ value: a,
82
+ onChange: (s) => i(s.target.value),
83
+ className: "border-none px-1.5 shadow-none outline-none ring-0 transition-none focus:outline-none focus:ring-0 focus-visible:ring-0",
84
+ autoComplete: "off"
85
+ }
86
+ )
87
+ ] }), V = ({ pages: a }) => {
88
+ const { expandAll: i, collapseAll: s, expandedPages: l } = z(null);
89
+ return /* @__PURE__ */ r("div", { className: "flex gap-1", children: [
90
+ /* @__PURE__ */ r(f, { children: [
91
+ /* @__PURE__ */ e(v, { asChild: !0, children: /* @__PURE__ */ e(m, { variant: "outline", size: "icon", onClick: () => i(a), className: "rounded p-1 text-gray-500", children: /* @__PURE__ */ e(B, {}) }) }),
92
+ /* @__PURE__ */ e(g, { children: "Expand All" })
93
+ ] }),
94
+ /* @__PURE__ */ r(f, { children: [
95
+ /* @__PURE__ */ e(v, { asChild: !0, children: /* @__PURE__ */ e(
96
+ m,
97
+ {
98
+ disabled: l.length === 0,
99
+ variant: "outline",
100
+ size: "icon",
101
+ onClick: () => s(),
102
+ className: "rounded p-1 text-gray-500",
103
+ children: /* @__PURE__ */ e(K, {})
104
+ }
105
+ ) }),
106
+ /* @__PURE__ */ e(g, { children: "Collapse All" })
107
+ ] })
108
+ ] });
109
+ }, X = ({ languages: a, selectedLanguage: i, setSelectedLanguage: s }) => {
110
+ const l = P();
111
+ return /* @__PURE__ */ e("div", { className: "scrollbar-hide flex gap-1 overflow-x-auto pb-1", children: a.map((n) => /* @__PURE__ */ r(
112
+ m,
113
+ {
114
+ variant: i === n ? "default" : "outline",
115
+ size: "sm",
116
+ className: `h-6 flex-shrink-0 whitespace-nowrap rounded px-3 text-xs font-normal ${i === n ? "bg-black text-white hover:bg-black" : "text-gray-500"}`,
117
+ onClick: () => s(n.toLowerCase()),
118
+ children: [
119
+ n === l && /* @__PURE__ */ e(D, { size: 4, className: `p-0.5 ${i === l ? "fill-white" : "fill-black"}` }),
120
+ L[n] || ""
121
+ ]
122
+ },
123
+ n
124
+ )) });
125
+ }, k = () => {
126
+ const a = T();
127
+ return /* @__PURE__ */ r(f, { children: [
128
+ /* @__PURE__ */ e(v, { asChild: !0, children: /* @__PURE__ */ e(
129
+ m,
130
+ {
131
+ size: "sm",
132
+ variant: "ghost",
133
+ onClick: () => a.invalidateQueries({ queryKey: [I.GET_WEBSITE_PAGES] }),
134
+ className: "mt-1 h-6 w-6",
135
+ children: /* @__PURE__ */ e(Q, {})
136
+ }
137
+ ) }),
138
+ /* @__PURE__ */ e(g, { side: "bottom", children: "Refresh pages list" })
139
+ ] });
140
+ }, le = ({
141
+ pages: a,
142
+ search: i,
143
+ setSearch: s,
144
+ languages: l,
145
+ onAddPage: n,
146
+ selectedLanguage: c,
147
+ setSelectedLanguage: p,
148
+ selectedPageType: t,
149
+ setSelectedPageType: d,
150
+ showUntranslatedPages: h,
151
+ setShowUntranslatedPages: x
152
+ }) => {
153
+ const N = l.length > 1;
154
+ return /* @__PURE__ */ r("div", { className: "space-y-3 border-b border-b-gray-200 px-4 pb-1", children: [
155
+ /* @__PURE__ */ r("div", { className: "flex items-center gap-x-2", children: [
156
+ /* @__PURE__ */ e(O, { selectedPageType: t, setSelectedPageType: d }),
157
+ /* @__PURE__ */ e(U, { search: i, setSearch: s }),
158
+ /* @__PURE__ */ e(V, { pages: a }),
159
+ /* @__PURE__ */ r(m, { variant: "default", onClick: n, className: "rounded px-3 font-normal", children: [
160
+ /* @__PURE__ */ e(M, { strokeWidth: 2, className: "stroke-white stroke-[3]" }),
161
+ /* @__PURE__ */ e("span", { className: "font-normal text-white", children: "Add Page" })
162
+ ] }),
163
+ !N && /* @__PURE__ */ e(k, {})
164
+ ] }),
165
+ N ? /* @__PURE__ */ r("div", { className: "flex items-center justify-between gap-2", children: [
166
+ /* @__PURE__ */ e(
167
+ X,
168
+ {
169
+ languages: l,
170
+ selectedLanguage: c,
171
+ setSelectedLanguage: (E) => {
172
+ p(E), x(h && (l == null ? void 0 : l[0]) !== c);
173
+ }
174
+ }
175
+ ),
176
+ /* @__PURE__ */ r("div", { className: "flex items-center gap-x-2", children: [
177
+ (l == null ? void 0 : l[0]) !== c && /* @__PURE__ */ r(f, { children: [
178
+ /* @__PURE__ */ e(v, { asChild: !0, children: /* @__PURE__ */ e(
179
+ m,
180
+ {
181
+ variant: "ghost",
182
+ onClick: () => x(!h),
183
+ className: "h-6 rounded px-3 py-1 text-xs font-normal",
184
+ children: h ? /* @__PURE__ */ e(R, {}) : /* @__PURE__ */ e(W, {})
185
+ }
186
+ ) }),
187
+ /* @__PURE__ */ e(g, { side: "bottom", children: "Toggle Untranslated Pages" })
188
+ ] }),
189
+ /* @__PURE__ */ e(k, {})
190
+ ] })
191
+ ] }) : /* @__PURE__ */ e("div", { className: "flex items-center justify-between gap-2" })
192
+ ] });
193
+ };
194
+ export {
195
+ X as LanguageSelector,
196
+ le as default
197
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),m=require("./index-DSUpSpeI.cjs"),y=require("./use-page-expand-manager-MjYZ3CDZ.cjs"),s=require("@chaibuilder/sdk/ui"),b=require("@tanstack/react-query"),r=require("lodash-es"),c=require("lucide-react"),N=require("react"),w=({selectedPageType:n,setSelectedPageType:a})=>{const[o,l]=N.useState(""),{data:i}=m.usePageTypes(),d=t=>{if(!o)return!0;const x=o.toLowerCase(),h=p=>String(r.get(t,p,"")).toLowerCase().includes(x);return h("name")||h("key")},u=i.find(t=>t.key===n);return e.jsxs(s.Select,{onValueChange:a,value:n,children:[e.jsx(s.SelectTrigger,{className:`${n==="all"?"bg-gray-100/30 hover:bg-gray-100":"gap-x-1 border bg-gray-100/30 hover:bg-gray-100"} h-9 w-max min-w-[150px] overflow-hidden whitespace-nowrap rounded p-0 px-2 py-1 text-xs text-gray-600 shadow-none ring-0 focus:ring-0 [&>svg]:hidden`,children:e.jsxs("div",{className:"flex w-full items-center justify-between gap-x-1.5",children:[e.jsx("span",{className:"max-w-[150px] overflow-hidden truncate whitespace-nowrap font-medium leading-tight",children:(u==null?void 0:u.name)||"All"}),e.jsx(c.ListFilter,{className:`${n!=="all"?"fill-sky-50 text-sky-500":""} pointer-events-none h-4 w-4 text-muted-foreground hover:bg-blue-300`})]})}),e.jsxs(s.SelectContent,{children:[e.jsx("div",{className:"sticky top-0 z-10 bg-white pb-2",children:e.jsxs("div",{className:"relative",children:[e.jsx(c.Search,{strokeWidth:2,className:"absolute left-2 top-2.5 h-3.5 w-3.5 text-gray-400"}),e.jsx(s.Input,{placeholder:"Search page types...",className:"h-8 w-full rounded border pl-8 text-xs shadow-none",value:o,onChange:t=>l(t.target.value),onKeyDown:t=>t.stopPropagation()})]})}),e.jsx(s.SelectItem,{value:"all",children:"All"}),!r.isEmpty(r.filter(i,t=>t.hasSlug&&d(t)))&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mt-2 border-t px-2 py-1.5 pt-2 text-xs font-semibold text-gray-500",children:"Pages"}),r.map([...r.filter(i,t=>t.hasSlug&&d(t))].sort((t,x)=>r.get(t,"name","").localeCompare(r.get(x,"name",""))),t=>e.jsx(s.SelectItem,{value:r.get(t,"key"),children:r.get(t,"name")},r.get(t,"key")))]}),!r.isEmpty(r.filter(i,t=>!t.hasSlug&&d(t)))&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mt-2 border-t px-2 py-1.5 pt-2 text-xs font-semibold text-gray-500",children:"Partials"}),r.map([...r.filter(i,t=>!t.hasSlug&&d(t))].sort((t,x)=>r.get(t,"name","").localeCompare(r.get(x,"name",""))),t=>e.jsx(s.SelectItem,{value:r.get(t,"key"),children:r.get(t,"name")},r.get(t,"key")))]}),r.isEmpty(r.filter(i,d))&&e.jsx("div",{className:"px-3 py-2 text-center text-sm text-gray-500",children:"No matching page types found"})]})]})},C=({search:n,setSearch:a})=>e.jsxs("div",{className:"relative flex h-9 flex-1 items-center gap-2 rounded-md border px-2.5",children:[e.jsx("label",{htmlFor:"page-search-input",className:"sr-only",children:"Search Pages"}),e.jsx(c.Search,{className:`${n?"fill-sky-50 text-sky-500":""} pointer-events-none h-4 w-4 text-muted-foreground`,"aria-hidden":"true"}),e.jsx(s.Input,{id:"page-search-input",placeholder:"Search pages",value:n,onChange:o=>a(o.target.value),className:"border-none px-1.5 shadow-none outline-none ring-0 transition-none focus:outline-none focus:ring-0 focus-visible:ring-0",autoComplete:"off"})]}),S=({pages:n})=>{const{expandAll:a,collapseAll:o,expandedPages:l}=y.usePageExpandManager(null);return e.jsxs("div",{className:"flex gap-1",children:[e.jsxs(s.Tooltip,{children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx(s.Button,{variant:"outline",size:"icon",onClick:()=>a(n),className:"rounded p-1 text-gray-500",children:e.jsx(c.ChevronsUpDown,{})})}),e.jsx(s.TooltipContent,{children:"Expand All"})]}),e.jsxs(s.Tooltip,{children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx(s.Button,{disabled:l.length===0,variant:"outline",size:"icon",onClick:()=>o(),className:"rounded p-1 text-gray-500",children:e.jsx(c.ChevronsDownUp,{})})}),e.jsx(s.TooltipContent,{children:"Collapse All"})]})]})},f=({languages:n,selectedLanguage:a,setSelectedLanguage:o})=>{const l=m.useFallbackLang();return e.jsx("div",{className:"scrollbar-hide flex gap-1 overflow-x-auto pb-1",children:n.map(i=>e.jsxs(s.Button,{variant:a===i?"default":"outline",size:"sm",className:`h-6 flex-shrink-0 whitespace-nowrap rounded px-3 text-xs font-normal ${a===i?"bg-black text-white hover:bg-black":"text-gray-500"}`,onClick:()=>o(i.toLowerCase()),children:[i===l&&e.jsx(c.Star,{size:4,className:`p-0.5 ${a===l?"fill-white":"fill-black"}`}),m.LANGUAGES[i]||""]},i))})},j=()=>{const n=b.useQueryClient();return e.jsxs(s.Tooltip,{children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx(s.Button,{size:"sm",variant:"ghost",onClick:()=>n.invalidateQueries({queryKey:[m.ACTIONS.GET_WEBSITE_PAGES]}),className:"mt-1 h-6 w-6",children:e.jsx(c.RefreshCw,{})})}),e.jsx(s.TooltipContent,{side:"bottom",children:"Refresh pages list"})]})},k=({pages:n,search:a,setSearch:o,languages:l,onAddPage:i,selectedLanguage:d,setSelectedLanguage:u,selectedPageType:t,setSelectedPageType:x,showUntranslatedPages:h,setShowUntranslatedPages:p})=>{const g=l.length>1;return e.jsxs("div",{className:"space-y-3 border-b border-b-gray-200 px-4 pb-1",children:[e.jsxs("div",{className:"flex items-center gap-x-2",children:[e.jsx(w,{selectedPageType:t,setSelectedPageType:x}),e.jsx(C,{search:a,setSearch:o}),e.jsx(S,{pages:n}),e.jsxs(s.Button,{variant:"default",onClick:i,className:"rounded px-3 font-normal",children:[e.jsx(c.Plus,{strokeWidth:2,className:"stroke-white stroke-[3]"}),e.jsx("span",{className:"font-normal text-white",children:"Add Page"})]}),!g&&e.jsx(j,{})]}),g?e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx(f,{languages:l,selectedLanguage:d,setSelectedLanguage:v=>{u(v),p(h&&(l==null?void 0:l[0])!==d)}}),e.jsxs("div",{className:"flex items-center gap-x-2",children:[(l==null?void 0:l[0])!==d&&e.jsxs(s.Tooltip,{children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx(s.Button,{variant:"ghost",onClick:()=>p(!h),className:"h-6 rounded px-3 py-1 text-xs font-normal",children:h?e.jsx(c.FilterXIcon,{}):e.jsx(c.Filter,{})})}),e.jsx(s.TooltipContent,{side:"bottom",children:"Toggle Untranslated Pages"})]}),e.jsx(j,{})]})]}):e.jsx("div",{className:"flex items-center justify-between gap-2"})]})};exports.LanguageSelector=f;exports.default=k;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),d=require("./index-DSUpSpeI.cjs"),N=require("@tanstack/react-query"),O=require("@chaibuilder/sdk"),a=require("@chaibuilder/sdk/ui"),y=require("date-fns"),L=require("lodash-es"),p=require("lucide-react"),b=require("react");function Q(s){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const t in s)if(t!=="default"){const l=Object.getOwnPropertyDescriptor(s,t);Object.defineProperty(n,t,l.get?l:{enumerable:!0,get:()=>s[t]})}}return n.default=s,Object.freeze(n)}const v=Q(b);function z(s){const n=d.useApiUrl(),t=d.useFetch();return N.useQuery({queryKey:[d.ACTIONS.GET_PAGE_REVISIONS,s],queryFn:async()=>await t(n,{action:d.ACTIONS.GET_PAGE_REVISIONS,data:{pageId:s}}),enabled:!!s,refetchOnMount:!0})}const B=()=>{const s=d.useApiUrl(),n=d.useFetch(),t=N.useQueryClient();return N.useMutation({mutationFn:async l=>await n(s,{action:d.ACTIONS.DELETE_PAGE_REVISION,data:{revisionId:l}}),onSuccess:()=>{t.invalidateQueries({queryKey:["revisions"]})}})},H=()=>{const s=d.useApiUrl(),n=d.useFetch(),t=N.useQueryClient();return N.useMutation({mutationFn:async({revisionId:l,discardCurrent:r})=>await n(s,{action:d.ACTIONS.RESTORE_PAGE_REVISION,data:{revisionId:l,discardCurrent:r}}),onSuccess:()=>{t.invalidateQueries({queryKey:["revisions"]})}})},$=b.lazy(()=>Promise.resolve().then(()=>require("./json-diff-viewer-DKlC7yl6.cjs"))),g=({tag:s})=>s==="draft"?e.jsxs("div",{className:"flex items-center gap-1 rounded-full bg-amber-500/10 px-1.5 py-0.5 text-xs text-amber-600",children:[e.jsxs("span",{className:"relative flex h-2 w-2",children:[e.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-amber-400 opacity-75"}),e.jsx("span",{className:"relative inline-flex h-2 w-2 rounded-full bg-amber-500"})]}),e.jsx("span",{className:"text-[11px] leading-tight",children:"Draft"})]}):s==="live"?e.jsxs("span",{className:"flex items-center gap-1 rounded-full bg-primary/10 px-1.5 py-0.5 text-xs text-primary",children:[e.jsxs("span",{className:"relative flex h-2 w-2",children:[e.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-green-400 opacity-75"}),e.jsx("span",{className:"relative inline-flex h-2 w-2 rounded-full bg-green-500"})]}),e.jsx("span",{className:"text-[11px] leading-tight",children:"Live"})]}):s==="published"?e.jsxs("div",{className:"flex items-center gap-1 rounded-full bg-green-500/10 px-1.5 py-0.5 text-xs text-green-600",children:[e.jsx(p.Rocket,{className:"h-3 w-3"}),e.jsx("span",{className:"text-[11px] leading-tight",children:"Published"})]}):s==="unsaved"?e.jsxs("div",{className:"flex items-center gap-1 rounded-full bg-red-500/10 px-1.5 py-0.5 text-xs text-red-600",children:[e.jsx(p.Save,{className:"h-3 w-3"}),e.jsx("span",{className:"text-[11px] leading-tight",children:"Unsaved changes"})]}):e.jsx("span",{className:"rounded bg-purple-500/10 px-1.5 py-0.5 font-mono text-xs font-bold text-purple-600",children:s});function J({compare:s,setCompare:n}){const{data:t}=d.useCurrentPage(),{saveState:l}=O.useSavePage(),[r]=d.usePageEditInfo();if(!t)return null;const c=!!s.find(u=>{var i;return(i=u==null?void 0:u.uid)==null?void 0:i.startsWith("draft:")}),x=s.length>=2&&!c,m=l==="UNSAVED";return e.jsxs("div",{className:"relative flex items-start gap-3 rounded-md border bg-primary/5 p-2 hover:bg-accent/50",children:[e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-1 text-sm font-medium leading-none",children:[e.jsx(g,{tag:"draft"}),e.jsx("span",{className:"text-xs font-bold",children:"Currently editing"})]})}),e.jsx("div",{className:"flex items-center pl-2 text-[11px] text-muted-foreground",children:!L.isEmpty(r.lastSaved)&&e.jsxs("span",{children:["Last updated"," ",y.formatDistanceToNow(new Date(r.lastSaved),{addSuffix:!0})]})}),e.jsx("div",{className:"flex items-center gap-2 pt-0.5",children:m?e.jsx(g,{tag:"unsaved"}):null})]}),e.jsx(A,{checked:c,disabled:x,onChange:()=>{n(c?s.filter(u=>u.uid!==`draft:${t==null?void 0:t.id}`):[...s,{uid:`draft:${t==null?void 0:t.id}`,label:"draft",item:{createdAt:Date.now()}}])}})]})}function K(){return e.jsx("div",{className:"mt-2 space-y-2",children:Array.from({length:5}).map((s,n)=>e.jsxs("div",{className:"flex items-start gap-3 rounded-md border p-2",children:[e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx(a.Skeleton,{className:"h-4 w-3/4"}),e.jsx(a.Skeleton,{className:"h-3 w-1/2"}),e.jsx(a.Skeleton,{className:"mt-1 h-5 w-20"})]}),e.jsx(a.Skeleton,{className:"h-8 w-8 rounded-full"})]},n))})}function I({revision:s,isLatest:n,onRestore:t,onDelete:l,revisionNumber:r,compare:c,setCompare:x,pageId:m}){const{data:u}=d.useChaiUserInfo(s.currentEditor),i=(u==null?void 0:u.name)||"Unknown",f=!!c.find(h=>{var j;return n?(j=h==null?void 0:h.uid)==null?void 0:j.startsWith("live"):(h==null?void 0:h.uid)===s.uid}),S=c.length>=2&&!f;return e.jsxs("div",{className:"relative flex items-start gap-3 rounded-md border p-2 hover:bg-accent/50",children:[e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("p",{className:"flex items-center gap-1 text-xs leading-none",children:[e.jsx(g,{tag:n?"live":`#${r}`}),s.type==="published"?"Published":"Draft"," by ",e.jsx("span",{className:"text-xs font-bold",children:i})]})}),e.jsxs("div",{className:"flex items-center gap-x-3",children:[e.jsx("div",{className:"flex items-center gap-2",children:s.type==="published"?e.jsx(g,{tag:"published"}):e.jsx(g,{tag:"draft"})}),e.jsx("div",{className:"flex items-center text-[10px] text-muted-foreground",children:e.jsx("span",{className:"leading-tight",children:y.format(s.createdAt,"MMM d, h:mm a")})})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(d.PermissionChecker,{permissions:[d.PAGES_PERMISSIONS.RESTORE_REVISION,d.PAGES_PERMISSIONS.DELETE_REVISION],children:e.jsx(Y,{revision:s,onRestore:t,onDelete:l})})}),e.jsx(A,{checked:f,disabled:S,onChange:()=>{x(f?c.filter(h=>n?h.uid!==`live:${m}`:h.uid!==s.uid):[...c,{uid:n?`live:${m}`:s.uid,label:n?"live":`#${r}`,item:s}].sort((h,j)=>new Date(h.item.createdAt).getTime()-new Date(j.item.createdAt).getTime()))}})]})}function W({compare:s,setCompare:n,pageId:t}){const[l,r]=b.useState(!1),[c,x]=s;if(s.length===0)return null;const m=({tab:u})=>e.jsxs("span",{className:"flex items-center justify-between rounded border border-blue-100 p-1 font-medium",children:[e.jsx(g,{tag:u.label}),e.jsx("button",{className:"z-0 flex h-4 w-4 items-center justify-center rounded-full text-gray-400 hover:text-red-500",style:{lineHeight:1},onClick:()=>n(s.filter(i=>i.uid!==u.uid)),"aria-label":"Remove selection 1",children:e.jsx(p.X,{className:"h-3 w-3"})})]});return e.jsxs("div",{className:"mb-2 flex w-full max-w-md flex-col gap-1 rounded border bg-accent/60 p-2 shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-x-2 text-xs",children:[e.jsx("span",{className:"font-medium leading-tight text-gray-600",children:"Compare"}),c&&e.jsx(m,{tab:c}),e.jsx("span",{className:"font-medium leading-tight text-gray-600",children:"with"}),x?e.jsx(m,{tab:x}):e.jsx("span",{className:"rounded border px-1 text-xs text-muted-foreground",children:"Choose another"})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pb-0.5 pt-2",children:[e.jsx(a.Button,{size:"sm",className:"h-6 gap-1 rounded px-2 text-xs leading-none text-gray-500",variant:"outline",onClick:()=>n([]),children:e.jsx("span",{children:" Clear"})}),e.jsxs(a.Button,{size:"sm",className:"h-6 gap-1 rounded px-2 text-xs leading-none",variant:"default",onClick:()=>r(!0),disabled:s.length<2,children:[e.jsx(p.FileJson,{className:"h-2.5 w-2.5"}),e.jsx("span",{className:"pt-0.5",children:"Show JSON Diff"})]})]}),l&&(s==null?void 0:s.length)>1&&t&&e.jsx(b.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center p-4",children:e.jsx("span",{className:"text-sm",children:"Loading diff viewer..."})}),children:e.jsx($,{open:l,onOpenChange:r,compare:s})})]})}function A({checked:s,disabled:n,onChange:t,label:l="Compare"}){return e.jsx("div",{className:"absolute bottom-2 right-2",children:e.jsxs("label",{className:`flex cursor-pointer items-center gap-x-1 text-[11px] ${n?"opacity-50":""}`,children:[e.jsx("input",{type:"checkbox",className:"h-3 w-3 cursor-pointer rounded focus:ring-0 focus:ring-offset-0",checked:s,disabled:n,onChange:t}),e.jsx("span",{className:"select-none leading-tight",children:l})]})})}function Y({revision:s,onRestore:n,onDelete:t}){return e.jsxs(a.DropdownMenu,{children:[e.jsx(a.DropdownMenuTrigger,{asChild:!0,children:e.jsxs(a.Button,{variant:"ghost",size:"icon",className:"h-5 w-5",children:[e.jsx(p.MoreHorizontal,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"More options"})]})}),e.jsxs(a.DropdownMenuContent,{align:"end",className:"text-xs",children:[e.jsx(d.PermissionChecker,{permission:d.PAGES_PERMISSIONS.RESTORE_REVISION,children:e.jsxs(a.DropdownMenuItem,{onClick:n,className:"cursor-pointer text-sm",children:[e.jsx(p.Undo2,{className:"mr-2 h-4 w-4"}),e.jsx("span",{children:"Restore this version"})]})}),e.jsx(d.PermissionChecker,{permission:d.PAGES_PERMISSIONS.DELETE_REVISION,children:s.uid!=="current"&&e.jsxs(e.Fragment,{children:[e.jsx(a.DropdownMenuSeparator,{}),e.jsxs(a.DropdownMenuItem,{onClick:t,className:"cursor-pointer text-destructive",children:[e.jsx(p.Trash,{className:"mr-2 h-4 w-4"}),e.jsx("span",{children:"Delete this version"})]})]})})]})]})}function X({open:s,onOpenChange:n,revision:t,onRestore:l,isRestoring:r}){const{data:c}=d.useChaiUserInfo((t==null?void 0:t.currentEditor)||""),x=(c==null?void 0:c.name)||"Unknown";return t?e.jsx(a.Dialog,{open:s,onOpenChange:m=>{r||n(m)},children:e.jsxs(a.DialogContent,{className:"sm:max-w-md",children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{children:"Restore Revision"}),e.jsxs(a.DialogDescription,{children:["You are about to restore to revision ",t.uid.substring(0,8)," from"," ",y.format(t.createdAt,"MMM d, yyyy 'at' h:mm a")," by ",x]})]}),e.jsx("div",{className:"py-2",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"How would you like to handle your current edits?"})}),e.jsxs(a.DialogFooter,{className:"flex flex-col gap-2 sm:flex-row",children:[e.jsx(a.Button,{variant:"outline",className:"sm:flex-1",onClick:()=>l(!1),disabled:r,children:r?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mr-2 h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Saving as draft..."]}):e.jsxs(e.Fragment,{children:[e.jsx(p.CloudOff,{className:"mr-2 h-4 w-4"}),"Save as draft"]})}),e.jsx(a.Button,{variant:"default",className:"sm:flex-1",onClick:()=>l(!0),disabled:r,children:r?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mr-2 h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Discarding current..."]}):e.jsxs(e.Fragment,{children:[e.jsx(p.Undo2,{className:"mr-2 h-4 w-4"}),"Discard current"]})})]})]})}):null}function Z({open:s,onOpenChange:n,revision:t,onDelete:l,isDeleting:r}){const{data:c}=d.useChaiUserInfo((t==null?void 0:t.currentEditor)||""),x=(c==null?void 0:c.name)||"Unknown";return t?e.jsx(a.Dialog,{open:s,onOpenChange:m=>{r||n(m)},children:e.jsxs(a.DialogContent,{className:"sm:max-w-md",children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{children:"Delete Revision"}),e.jsxs(a.DialogDescription,{children:["You are about to delete revision ",t.uid.substring(0,8)," from"," ",y.format(t.createdAt,"MMM d, yyyy 'at' h:mm a")," by ",x]})]}),e.jsx("div",{className:"py-2",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"This action cannot be undone. Are you sure you want to proceed?"})}),e.jsxs(a.DialogFooter,{className:"flex flex-col gap-2 sm:flex-row",children:[e.jsx(a.Button,{variant:"outline",className:"sm:flex-1",onClick:()=>n(!1),disabled:r,children:"Cancel"}),e.jsx(a.Button,{variant:"destructive",className:"sm:flex-1",onClick:l,disabled:r,children:r?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mr-2 h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Deleting..."]}):e.jsxs(e.Fragment,{children:[e.jsx(p.Trash,{className:"mr-2 h-4 w-4"}),"Delete Revision"]})})]})]})}):null}function ee({isOpen:s}){var E,R;const[n,t]=v.useState([]),[l,r]=v.useState(null),[c,x]=v.useState(!1),[m,u]=v.useState(!1),{data:i}=d.useCurrentPage(),{data:f,isFetching:S,error:h,refetch:j}=z(i==null?void 0:i.id),{mutate:k,isPending:M}=B(),{mutate:T,isPending:F}=H(),_=N.useQueryClient(),{selectedLang:P,fallbackLang:q}=O.useLanguages(),U=P||q;b.useEffect(()=>t([]),[i==null?void 0:i.id]);const G=o=>{l&&T({revisionId:l.uid,discardCurrent:o},{onSuccess:()=>{x(!1),r(null),_.invalidateQueries({queryKey:[d.ACTIONS.GET_DRAFT_PAGE]})}})},D=o=>{r(o),x(!0)},C=o=>{r(o),u(!0)},V=()=>{l&&k(l.uid,{onSuccess:()=>{u(!1),r(null)}})};return b.useEffect(()=>{s&&j()},[s,j]),e.jsxs(e.Fragment,{children:[e.jsxs(a.SheetHeader,{children:[e.jsx(a.SheetTitle,{children:"Revision History"}),(i==null?void 0:i.createdAt)&&e.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:["Page created on ",y.format(new Date(i.createdAt),"MMM d, yyyy 'at' h:mm a")]})]}),S?e.jsx(K,{}):h?e.jsx("div",{className:"p-4 text-center text-sm text-muted-foreground",children:"Failed to load revisions. Please try again."}):e.jsxs("div",{className:"mt-2 flex h-full min-h-0 flex-1 flex-col space-y-2",children:[e.jsx(W,{lang:U,compare:n,setCompare:t,pageId:i==null?void 0:i.id}),e.jsx(J,{compare:n,setCompare:t}),(E=f==null?void 0:f.filter(o=>o.uid==="current"))==null?void 0:E.map((o,w)=>e.jsx(I,{pageId:i==null?void 0:i.id,revision:o,isLatest:!0,onRestore:()=>D(o),onDelete:()=>C(o),revisionNumber:w,compare:n,setCompare:t},o.uid)),e.jsx(a.ScrollArea,{className:"min-h-0 flex-1",children:e.jsx("div",{className:"space-y-2",children:(R=f==null?void 0:f.filter(o=>o.uid!=="current"))==null?void 0:R.map((o,w)=>e.jsx(I,{pageId:i==null?void 0:i.id,revision:o,isLatest:o.uid==="current",onRestore:()=>D(o),onDelete:()=>C(o),revisionNumber:w+1,compare:n,setCompare:t},o.uid))})})]}),e.jsx(X,{open:c,onOpenChange:x,revision:l,onRestore:G,isRestoring:F}),e.jsx(Z,{open:m,onOpenChange:u,revision:l,onDelete:V,isDeleting:M})]})}exports.default=ee;