@chaibuilder/sdk 4.0.0-beta.50 → 4.0.0-beta.51

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 (156) hide show
  1. package/README.md +35 -47
  2. package/dist/{2SSKDMRQ-DRvGNTLs.cjs → 2SSKDMRQ-BSYe_xPq.cjs} +1 -1
  3. package/dist/{2SSKDMRQ-DqIyZppU.js → 2SSKDMRQ-Dv-C_YAA.js} +3 -3
  4. package/dist/{AP7HFJJL-BWwvxG86.cjs → AP7HFJJL-BJolKJBt.cjs} +1 -1
  5. package/dist/{AP7HFJJL-DlUIW-7z.js → AP7HFJJL-DhdVstVC.js} +1 -1
  6. package/dist/{IconPicker-Bf163F7t.js → IconPicker-BBkl0T8b.js} +13 -13
  7. package/dist/{IconPicker-JWhYq2Gp.cjs → IconPicker-C0WWlb8t.cjs} +1 -1
  8. package/dist/{WDYDFRGG-SsaVMSIa.js → WDYDFRGG-CJs2MxSq.js} +4 -4
  9. package/dist/{WDYDFRGG-N7kNyI7H.cjs → WDYDFRGG-DRt6Zg7Q.cjs} +1 -1
  10. package/dist/{actions-registery-BHbZHkE3.cjs → actions-registery-CLL3KrNv.cjs} +2 -2
  11. package/dist/{actions-registery-gJb_wq2F.js → actions-registery-CrGIlqUX.js} +88 -88
  12. package/dist/actions.cjs +1 -1
  13. package/dist/actions.js +2 -2
  14. package/dist/{add-new-language-page-QIaeQ_fJ.cjs → add-new-language-page-ByMSfRcN.cjs} +1 -1
  15. package/dist/{add-new-language-page-BnPnQ-3A.js → add-new-language-page-DtVoDNfI.js} +35 -35
  16. package/dist/{add-new-page-Ddoy3kTu.cjs → add-new-page-CnuChfJz.cjs} +1 -1
  17. package/dist/add-new-page-DanzzvYo.js +31 -0
  18. package/dist/{ai-panel-default-lang-BOCTOIH_.js → ai-panel-default-lang-BaPz2d_6.js} +35 -35
  19. package/dist/{ai-panel-default-lang-FNeOfRkj.cjs → ai-panel-default-lang-CoIQSz_Y.cjs} +2 -2
  20. package/dist/{ai-panel-other-lang-C2j7qGZx.js → ai-panel-other-lang--i-5z4e2.js} +22 -22
  21. package/dist/{ai-panel-other-lang-DgRzCQGx.cjs → ai-panel-other-lang-ChlMVodg.cjs} +1 -1
  22. package/dist/{ai-prompt-input-p5KHwgCW.js → ai-prompt-input-BQi0VDJC.js} +77 -77
  23. package/dist/{ai-prompt-input-SJnya_UU.cjs → ai-prompt-input-BT5426AB.cjs} +1 -1
  24. package/dist/{ai-translation-prompt-BTEXWPQq.js → ai-translation-prompt-BN78s33t.js} +8 -8
  25. package/dist/{ai-translation-prompt-Dhh-bNJr.cjs → ai-translation-prompt-BQPaekp3.cjs} +1 -1
  26. package/dist/{apply-binding-CBSjMYSk.cjs → apply-binding-Cjh1kqMO.cjs} +1 -1
  27. package/dist/{apply-binding-vAuN-TGV.js → apply-binding-v_W4uR3U.js} +28 -28
  28. package/dist/{plugin-BSjgGgwo.js → chai-theme-helpers-BEf2rwE4.js} +83 -83
  29. package/dist/chai-theme-helpers-q3nwoNht.cjs +22 -0
  30. package/dist/{change-password-modal-BwBRdCeD.cjs → change-password-modal-DHUrrKw7.cjs} +1 -1
  31. package/dist/{change-password-modal-BkBFwrxi.js → change-password-modal-pEp-nMNb.js} +30 -30
  32. package/dist/{code-display-DdWcOQ_i.js → code-display-BaLKScgW.js} +5 -5
  33. package/dist/{code-display-BR-gij5j.cjs → code-display-i7jb2kmw.cjs} +1 -1
  34. package/dist/{code-editor-CyLjDiEp.js → code-editor-CRoniyP0.js} +12 -12
  35. package/dist/{code-editor-SWbfFj1E.cjs → code-editor-gwFRjQ2_.cjs} +1 -1
  36. package/dist/core.cjs +1 -1
  37. package/dist/core.d.ts +0 -5
  38. package/dist/core.js +49 -49
  39. package/dist/{css-import-modal-Be47CBJn.js → css-import-modal-B3qxX9Iv.js} +14 -14
  40. package/dist/{css-import-modal-Bdwgd05S.cjs → css-import-modal-nAB5FSwn.cjs} +2 -2
  41. package/dist/{delete-page-BYh290jY.js → delete-page-DbawNFf7.js} +13 -13
  42. package/dist/{delete-page-BNZclrjF.cjs → delete-page-YP1HEAoD.cjs} +1 -1
  43. package/dist/{digital-asset-manager-BINMP8H4.js → digital-asset-manager-DTD5mf24.js} +388 -357
  44. package/dist/digital-asset-manager-kJnuMqpw.cjs +1 -0
  45. package/dist/{duplicate-page-DgxKd840.cjs → duplicate-page-CxqW_EO7.cjs} +1 -1
  46. package/dist/{duplicate-page-B_j9rgxU.js → duplicate-page-DnRb1y6K.js} +19 -19
  47. package/dist/{dynamic-page-selector-CDuWB_Yw.cjs → dynamic-page-selector-2EqJhUrB.cjs} +1 -1
  48. package/dist/{dynamic-page-selector-B2HE4wRM.js → dynamic-page-selector-D6VLDIN9.js} +17 -17
  49. package/dist/{get-chai-builder-tailwind-config-7CxFxEYL.cjs → get-chai-builder-tailwind-config-DNp8Vhme.cjs} +1 -1
  50. package/dist/{get-chai-builder-tailwind-config-DC4sDOYK.js → get-chai-builder-tailwind-config-k8l5sdcw.js} +3 -3
  51. package/dist/{get-chai-builder-theme-BpuwSLeS.js → get-chai-builder-theme-DLpviqPJ.js} +1 -1
  52. package/dist/get-chai-builder-theme-Du4ARJlw.cjs +1 -0
  53. package/dist/{image-editor-DwhTYkVR.cjs → image-editor-BQcOGsli.cjs} +1 -1
  54. package/dist/{image-editor-BBvvi9Vm.js → image-editor-CMf731xL.js} +15 -15
  55. package/dist/index-BYrRPW_c.cjs +5 -0
  56. package/dist/index-D-r_K4yA.cjs +160 -0
  57. package/dist/{index-OuHV9Ann.js → index-DPV6NiJ-.js} +5894 -6049
  58. package/dist/index-DqzFD1CG.js +4861 -0
  59. package/dist/{mark-as-template-BP6ltrws.js → mark-as-template-D7jqSCXw.js} +28 -28
  60. package/dist/{mark-as-template-6kAFYYpY.cjs → mark-as-template-DyB56HzI.cjs} +1 -1
  61. package/dist/{nested-path-selector-content-DmtCI3q9.js → nested-path-selector-content-dwSikrsV.js} +2 -2
  62. package/dist/{nested-path-selector-content-aTdu-o0e.cjs → nested-path-selector-content-g9_Tq_sR.cjs} +1 -1
  63. package/dist/no-language-page-content-BRITuyfN.js +43 -0
  64. package/dist/{no-language-page-content-HjxRSjI0.cjs → no-language-page-content-ZvMNVY-Y.cjs} +1 -1
  65. package/dist/{no-language-page-dialog-CoRH5H9v.cjs → no-language-page-dialog-Cndq8xRP.cjs} +1 -1
  66. package/dist/no-language-page-dialog-D7L9nVb9.js +10 -0
  67. package/dist/page-creator-BAIbU14q.js +652 -0
  68. package/dist/page-creator-qL3-M8g3.cjs +1 -0
  69. package/dist/{page-manager-new-KUeOWmce.cjs → page-manager-new-By3eGO3i.cjs} +1 -1
  70. package/dist/{page-manager-new-CwYu8Am_.js → page-manager-new-YRG89y4f.js} +63 -63
  71. package/dist/page-manager-search-and-filter-BbdgOU9V.cjs +1 -0
  72. package/dist/page-manager-search-and-filter-Cllju4CV.js +184 -0
  73. package/dist/pages.cjs +1 -1
  74. package/dist/pages.d.ts +0 -15
  75. package/dist/pages.js +20 -21
  76. package/dist/{publish-pages-content-BmaVd0qz.js → publish-pages-content-CG5LBUnY.js} +48 -48
  77. package/dist/{publish-pages-content-gMEMzV-_.cjs → publish-pages-content-DxMiBxNU.cjs} +1 -1
  78. package/dist/{register-chai-top-bar-DyW9GPzV.cjs → register-chai-top-bar-CCssW5dL.cjs} +1 -1
  79. package/dist/{register-chai-top-bar-D6GjnauV.js → register-chai-top-bar-DWmJ2efT.js} +11 -11
  80. package/dist/render.cjs +1 -1
  81. package/dist/render.js +54 -54
  82. package/dist/{rte-widget-modal-CiTwsXTr.cjs → rte-widget-modal-CsTqFJc_.cjs} +1 -1
  83. package/dist/{rte-widget-modal-IU8JzPuZ.js → rte-widget-modal-DoeTMRtX.js} +2 -2
  84. package/dist/runtime-client.cjs +1 -1
  85. package/dist/runtime-client.js +1 -1
  86. package/dist/runtime.cjs +1 -1
  87. package/dist/runtime.js +1 -1
  88. package/dist/sdk.css +1 -1
  89. package/dist/{selected-block-display-C7iOI7Wd.js → selected-block-display-Ck1kkNEi.js} +17 -28
  90. package/dist/{selected-block-display-CSYAaqzP.cjs → selected-block-display-DSow6N4b.cjs} +1 -1
  91. package/dist/seo-panel---mYZmLD.js +559 -0
  92. package/dist/seo-panel-mfX63fua.cjs +1 -0
  93. package/dist/{shared-json-ld-nS_mdAYR.js → shared-json-ld-B3I_RLE2.js} +46 -46
  94. package/dist/{shared-json-ld-Clk0cKIp.cjs → shared-json-ld-CGgwUOlW.cjs} +1 -1
  95. package/dist/{slug-input-DLWTMTsO.js → slug-input-DQ4t3-Tt.js} +5 -5
  96. package/dist/{slug-input-CiHC5l3r.cjs → slug-input-DaNbl597.cjs} +1 -1
  97. package/dist/supabase-actions.cjs +1 -1
  98. package/dist/supabase-actions.js +2 -2
  99. package/dist/types.d.ts +0 -96
  100. package/dist/{unmark-as-template-D_-Bbbl_.cjs → unmark-as-template-CZ65AE4v.cjs} +1 -1
  101. package/dist/{unmark-as-template-BStQtwjr.js → unmark-as-template-DvmoTbVu.js} +11 -11
  102. package/dist/unpublish-page-3--vO5b0.js +28 -0
  103. package/dist/{unpublish-page-CGZWa57H.cjs → unpublish-page-B46TiWlU.cjs} +1 -1
  104. package/dist/{unpublished-partials-modal-BhNAub_z.js → unpublished-partials-modal-DVMz3q83.js} +18 -15
  105. package/dist/{unpublished-partials-modal-Cv5R9-hi.cjs → unpublished-partials-modal-U5lKBOSR.cjs} +1 -1
  106. package/dist/utils.cjs +1 -1
  107. package/dist/utils.js +2 -2
  108. package/dist/web-blocks.cjs +1 -1
  109. package/dist/web-blocks.js +2 -2
  110. package/dist/{web-preview-_TrLPhaZ.js → web-preview-D5o5XQo0.js} +2 -2
  111. package/dist/{web-preview-e2NMKzzH.cjs → web-preview-Da3RhcjQ.cjs} +1 -1
  112. package/package.json +1 -1
  113. package/dist/active-in-another-tab-3S4Tzg0v.js +0 -35
  114. package/dist/active-in-another-tab-C83x4jHw.cjs +0 -1
  115. package/dist/add-new-page-aLHfIIHC.js +0 -31
  116. package/dist/continue-editing-in-this-client-DTmWmAee.js +0 -25
  117. package/dist/continue-editing-in-this-client-DgtsPYZ4.cjs +0 -1
  118. package/dist/design-token-usage-D1lWCJ3L.js +0 -114
  119. package/dist/design-token-usage-eY2wQ0l3.cjs +0 -1
  120. package/dist/digital-asset-manager-DnNRvKt8.cjs +0 -1
  121. package/dist/get-chai-builder-theme-B5RkBTsB.cjs +0 -1
  122. package/dist/image-compression-DPFITwOL.js +0 -37
  123. package/dist/image-compression-UaU7Bwqe.cjs +0 -1
  124. package/dist/index-CzBSRTj0.cjs +0 -5
  125. package/dist/index-DCJDQs1a.cjs +0 -160
  126. package/dist/index-nzqILA37.js +0 -5199
  127. package/dist/json-diff-viewer-3C7leKFH.cjs +0 -8
  128. package/dist/json-diff-viewer-CMw5W_Li.js +0 -261
  129. package/dist/lang-panel-DIdkbjDj.cjs +0 -1
  130. package/dist/lang-panel-S3dD5t_t.js +0 -216
  131. package/dist/manage-design-tokens-6YGIctip.js +0 -446
  132. package/dist/manage-design-tokens-modal-BSSCXH8Y.cjs +0 -1
  133. package/dist/manage-design-tokens-modal-CzsnN49F.js +0 -161
  134. package/dist/manage-design-tokens-udLBvkHA.cjs +0 -1
  135. package/dist/no-language-page-content-MPJjIXir.js +0 -43
  136. package/dist/no-language-page-dialog-D06JM3cU.js +0 -10
  137. package/dist/page-creator-Cu6i7LZ1.js +0 -796
  138. package/dist/page-creator-QCmVlpyE.cjs +0 -1
  139. package/dist/page-lock-D5BkmYCP.cjs +0 -1
  140. package/dist/page-lock-csXU_vk5.js +0 -30
  141. package/dist/page-locked-dialog-BfmE52P5.cjs +0 -1
  142. package/dist/page-locked-dialog-o9eCXo2g.js +0 -136
  143. package/dist/page-manager-search-and-filter-BE7w_2hv.cjs +0 -1
  144. package/dist/page-manager-search-and-filter-BwxrJZgv.js +0 -210
  145. package/dist/page-revisions-content-DmXFnqRE.js +0 -459
  146. package/dist/page-revisions-content-qIljNtcN.cjs +0 -1
  147. package/dist/plugin-DHpuZZXz.cjs +0 -22
  148. package/dist/save-to-lib-CPqQG37K.js +0 -429
  149. package/dist/save-to-lib-DMPQDhKe.cjs +0 -1
  150. package/dist/seo-panel-CgDo_uDs.cjs +0 -2
  151. package/dist/seo-panel-DUVBUbG3.js +0 -789
  152. package/dist/take-over-request-Bjyi22us.js +0 -64
  153. package/dist/take-over-request-GdscXVYh.cjs +0 -1
  154. package/dist/translation-warning-modal-CLZ9tC1F.cjs +0 -1
  155. package/dist/translation-warning-modal-CzNt6LDO.js +0 -27
  156. package/dist/unpublish-page-Dsqk_IA1.js +0 -28
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),v=require("./register-chai-top-bar-DyW9GPzV.cjs"),a=require("./index-DCJDQs1a.cjs"),o=require("react"),_=require("./slug-input-CiHC5l3r.cjs"),w=require("lodash-es"),N=require("lucide-react"),k=require("./index-CzBSRTj0.cjs"),je=require("@tanstack/react-query"),J=require("sonner"),fe=require("./get-seo-defaults-Cw7vFt-B.cjs");function Ue({value:t,onChange:c,placeholder:j="Enter custom slug part",dynamicPattern:p,onValidationChange:i}){const[f,m]=o.useState(null),h=o.useRef(null),[g,T]=o.useState(p+t);o.useEffect(()=>{T(p+t)},[t,p]);const O=S=>{const C=S.target.value;if(!C.startsWith(p)){const W=C.replace(p,""),G=p+W;T(G),c(W);return}const l=C.substring(p.length).replace(/\//g,"").replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-_.]/g,"-").replace(/-+/g,"-").replace(/^-+/,"").toLowerCase(),n=(l.match(/\./g)||[]).length,x=n<=1;n>1?m("Invalid slug. Only one dot (.) is allowed in the slug"):m(null),i&&i(x);const y=p+l;T(y),c(l)},b=()=>{if(h.current){const S=h.current;setTimeout(()=>{const C=p.length;S.setSelectionRange(C,C)},0)}},R=S=>{const C=S.currentTarget;(C.selectionStart||0)<=p.length&&setTimeout(()=>{const l=p.length;C.setSelectionRange(l,l)},0)};return e.jsx("div",{children:e.jsxs("div",{className:"relative",children:[e.jsxs("p",{className:"mb-2 text-xs text-gray-500",children:[`${p}`," is a dynamic segment of slug"]}),e.jsx(v.Input,{ref:h,value:g,onChange:O,onFocus:b,onClick:R,placeholder:j,className:f?"border-red-500":""}),f&&e.jsx("div",{className:"mt-1 text-xs text-red-500",children:f})]})})}const X=({children:t,onWheel:c,...j})=>{const p=i=>{try{i.preventDefault();const f=i.currentTarget;f.scrollTop+=i.deltaY}catch{i.preventDefault()}c&&c(i)};return e.jsx(a.CommandList,{...j,onWheel:p,children:t})},te=(...t)=>t.filter(Boolean).join(" ");function ze({pages:t,selectedParentId:c,onChange:j,className:p,id:i="parentPage",currentPage:f}){const[m,h]=o.useState(!1),[g,T]=o.useState(""),O=v.useChaiFeatureFlag("enable-add-page-dropdown");O||(p="w-full rounded-md border border-gray-300 px-3 py-2");const b=o.useMemo(()=>!t||t.length===0?[]:t.filter(x=>!w.isEmpty(x.slug)).filter(x=>x.slug!=="/").sort((x,y)=>x.slug.localeCompare(y.slug)),[t]),R=o.useMemo(()=>{if(!g.trim())return b;const n=g.toLowerCase();return b.filter(x=>x.name.toLowerCase().includes(n)||x.slug.toLowerCase().includes(n))},[b,g]),S=n=>Math.max(0,(n.match(/\//g)||[]).length-1),C=n=>"    ".repeat(n),d=n=>{if(n==="/")return"/";const x=n.split("/").filter(Boolean);if(x.length<=1){const y=x[0]||"";return`/${_.removeSlugExtension(y)}`}return`/${_.removeSlugExtension(x[x.length-1])}`},l=()=>{if(!c||c==="none")return"None";const n=b.find(x=>x.id===c);return n?`${n.name} (${d(n.slug)})`:"None"};return e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(a.Label,{htmlFor:i,className:"text-sm",children:"Parent"}),O?e.jsxs(a.Popover,{open:m,onOpenChange:h,children:[e.jsx(a.PopoverTrigger,{asChild:!0,children:e.jsxs(v.Button,{id:i,variant:"outline",role:"combobox",className:te("w-full justify-between",p),"data-testid":"parent-page-selector",children:[l(),e.jsx(N.ChevronDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(a.PopoverContent,{className:"w-[var(--radix-popover-trigger-width)] p-0",align:"start",children:e.jsxs(a.Command,{shouldFilter:!1,children:[e.jsx("div",{className:"relative border-none py-2",children:e.jsx("div",{className:"sticky top-0 z-10 bg-white px-3 py-2",children:e.jsxs("div",{className:"relative",children:[e.jsx(N.Search,{strokeWidth:2,className:"absolute left-2 top-2 h-4 w-4 text-gray-400"}),e.jsx(v.Input,{placeholder:"Search pages...",className:"h-8 pl-8 text-xs",value:g,onChange:n=>T(n.target.value)})]})})}),e.jsxs(X,{className:"max-h-[300px] overflow-y-auto",children:[e.jsx(a.CommandEmpty,{children:"No pages found."}),e.jsxs(a.CommandGroup,{children:[e.jsxs(a.CommandItem,{value:"none",onSelect:()=>{j(""),h(!1),T("")},className:"flex cursor-pointer items-center justify-between",children:[e.jsx("span",{children:"None"}),e.jsx(N.Check,{className:te("mr-2 h-4 w-4",c?"opacity-0":"opacity-100")})]}),R.map(n=>{const x=C(S(n.slug)),y=d(n.slug),W=e.jsxs("span",{className:"flex items-center text-sm",children:[x,n.name,e.jsxs("span",{className:"text-xs text-gray-500",children:[" (",y,")"]})]});return e.jsxs(a.CommandItem,{value:n.id,onSelect:()=>{j(n.id),h(!1),T("")},className:"flex cursor-pointer items-center justify-between whitespace-pre-wrap",children:[e.jsx("span",{children:W}),e.jsx(N.Check,{className:te("mr-2 h-4 w-4 shrink-0",c===n.id?"opacity-100":"opacity-0")})]},n.id)})]})]})]})})]}):e.jsxs("select",{id:i,value:c||"none",onChange:n=>j(n.target.value),className:p,"data-testid":"parent-page-selector",children:[e.jsx("option",{value:"none",children:"None"}),b.map(n=>{const x=S(n.slug),y=x>0?C(x):"",W=d(n.slug);return(f==null?void 0:f.id)&&(f.id===n.id||n.slug.startsWith(f.slug+"/"))?null:e.jsxs("option",{value:n.id,children:[y,n.name," (",W,")"]},n.id)})]})]})}const _e=(...t)=>t.filter(Boolean).join(" "),Ve=({templates:t,selectedTemplateId:c,onSelectTemplate:j,isLoading:p=!1})=>{const[i,f]=o.useState(""),[m,h]=o.useState(!1),[g,T]=o.useState(""),O=v.useChaiFeatureFlag("enable-add-page-dropdown");if(o.useEffect(()=>{if(c){const d=t.find(l=>l.id===c);o.startTransition(()=>f((d==null?void 0:d.preview)||""))}else o.startTransition(()=>f(""))},[c,t]),p)return e.jsx("div",{className:"flex h-fit items-center justify-center text-sm text-gray-500",children:"Loading templates..."});if(t.length===0)return null;const b={};t.forEach(d=>{const l=d.libraryName;b[l]||(b[l]=[]),b[l].push(d)});const R=Object.entries(b).reduce((d,[l,n])=>{const x=n.filter(y=>y.name.toLowerCase().includes(g.toLowerCase())||l.toLowerCase().includes(g.toLowerCase()));return x.length>0&&(d[l]=x),d},{}),S=t.find(d=>d.id===c),C=S?w.startCase(S.name):"No Template";return e.jsxs("div",{className:"space-y-4",children:[O?e.jsxs(a.Popover,{open:m,onOpenChange:h,children:[e.jsx(a.PopoverTrigger,{asChild:!0,children:e.jsxs(v.Button,{variant:"outline",role:"combobox",className:"w-full justify-between",children:[C,e.jsx(N.ChevronDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(a.PopoverContent,{className:"w-[var(--radix-popover-trigger-width)] p-0",align:"start",children:e.jsxs(a.Command,{shouldFilter:!1,children:[e.jsx("div",{className:"sticky top-0 z-10 bg-white px-3 py-2",children:e.jsxs("div",{className:"relative",children:[e.jsx(N.Search,{strokeWidth:2,className:"absolute left-2 top-2 h-4 w-4 text-gray-400"}),e.jsx(v.Input,{placeholder:"Search templates...",className:"h-8 pl-8 text-xs",value:g,onChange:d=>T(d.target.value)})]})}),e.jsxs(X,{className:"max-h-[300px] overflow-y-auto",children:[e.jsx(a.CommandEmpty,{children:"No templates found."}),Object.entries(R).map(([d,l])=>e.jsx(a.CommandGroup,{heading:d,children:l.map(n=>e.jsxs(a.CommandItem,{value:n.id,onSelect:()=>{j(n.id),h(!1),T("")},className:"flex cursor-pointer items-center justify-between",children:[w.startCase(n.name),e.jsx(N.Check,{className:_e("mr-2 h-4 w-4",c===n.id?"opacity-100":"opacity-0")})]},n.id))},d))]})]})})]}):e.jsxs("select",{className:"w-full rounded-md border border-gray-300 px-3 py-2",value:c,onChange:d=>j(d.target.value),children:[e.jsx("option",{value:"",children:"No Template"}),Object.entries(b).map(([d,l])=>e.jsx("optgroup",{label:d,children:l.map(n=>e.jsx("option",{value:n.id,children:w.startCase(n.name)},n.id))},d))]}),i&&e.jsxs("div",{className:"mt-3 overflow-hidden rounded border",children:[e.jsx("div",{className:"max-h-[200px] overflow-auto",children:e.jsx("img",{src:i,alt:"Template Preview",className:"w-full object-contain"})}),e.jsx("div",{className:"border-t bg-gray-50 p-2 text-xs text-gray-500",children:"Template preview"})]})]})},$e=()=>{const t=k.useApiUrl(),c=k.useFetch();return je.useQuery({queryKey:[k.ACTIONS.GET_LIBRARIES],staleTime:"static",queryFn:async()=>await c(t,{action:k.ACTIONS.GET_LIBRARIES})||[]})},Qe=t=>{const c=k.useApiUrl(),j=k.useFetch();return je.useQuery({queryKey:[k.ACTIONS.GET_TEMPLATES_BY_TYPE,t],staleTime:"static",enabled:!!t,queryFn:async()=>{const p=await j(c,{action:k.ACTIONS.GET_TEMPLATES_BY_TYPE,data:{pageType:t}});return(t?w.filter(p,{pageType:t}):p)||[]}})},Ye=t=>{const{data:c=[],isLoading:j}=Qe(t),{data:p=[],isLoading:i}=$e(),f=o.useMemo(()=>j||i?[]:c.map(h=>{const g=w.find(p,{id:h.library});return{...h,libraryName:(g==null?void 0:g.type)!=="shared"?"Site Library":(g==null?void 0:g.name)+" Library",libraryType:g==null?void 0:g.type}}),[c,p,j,i]),m=o.useMemo(()=>w.groupBy(f,"libraryName"),[f]);return{data:f,groupedData:m,isLoading:j||i}},z=(...t)=>t.filter(Boolean).join(" ");function He({addEditPage:t,close:c,closePanel:j}){var xe,ge;const{data:p}=k.usePageTypes(),i=o.useMemo(()=>p??[],[p]),f=k.useChangePage(),m=!!(t!=null&&t.id),{data:h}=k.useWebsitePrimaryPages(),{mutate:g,isPending:T}=k.useCreatePage(),{mutate:O,isPending:b}=k.useUpdatePage(),[R,S]=o.useState(null),[C,d]=o.useState(!0),[l,n]=o.useState((t==null?void 0:t.pageType)??"page"),{hasPermission:x}=a.usePermissions(),y=x(k.PAGES_PERMISSIONS.CHANGE_PAGE_TYPE),[W,G]=o.useState(!1),[ye,ve]=o.useState(""),{selectedLang:Se,fallbackLang:Ce}=a.useLanguages(),ne=Se||Ce,[V,H]=o.useState(""),[ae,Q]=o.useState(!1),le=o.useMemo(()=>{const s=i.find(u=>u.key===l);return(s==null?void 0:s.hasSlug)===!1},[l,i]),[D,Ne]=o.useState((t==null?void 0:t.parent)??""),[M,re]=o.useState((t==null?void 0:t.name)??""),[F,oe]=o.useState((t==null?void 0:t.dynamic)??!1),[B,Y]=o.useState(F?"":((t==null?void 0:t.slug)??"").split("/").pop()||""),[ie,ce]=o.useState((t==null?void 0:t.dynamicSlugCustom)??""),[ue,be]=o.useState(!0),[we,P]=o.useState(!1),[E,ke]=o.useState(""),{data:me,isLoading:Le}=Ye(l),$=T||b,he=v.useChaiFeatureFlag("enable-add-page-dropdown"),ee=o.useMemo(()=>!m||!(t!=null&&t.id)||!h?null:h.find(s=>s.id===t.id),[m,t==null?void 0:t.id,h]),Te=(ee==null?void 0:ee.online)||!1,De=o.useMemo(()=>!m||!(t!=null&&t.id)||!h?!1:h.some(s=>s.parent===t.id),[m,t==null?void 0:t.id,h]),r=i.find(s=>s.key===l),U=s=>{if(m&&l!==s){ve(s),G(!0),H(""),Q(!1);return}n(s),H(""),Q(!1)},pe=()=>{n(ye),G(!1),oe(!1)},Ie=s=>{oe(s),s?Y(""):ce("")},Fe=s=>{if(Ne(s),s&&s!=="none"){const u=h==null?void 0:h.find(L=>L.id===s),q=(u==null?void 0:u.slug)||"";if(B.startsWith(q)){const L=B.slice(q.length).replace(/^\/+/,"");Y(L)}else Y(B.replace(/^\/+/,""))}else Y(B?`${B}`:"")},Be=s=>{ke(s)},qe=()=>M.trim()?F&&!w.isEmpty(B)?(S("Slug must be empty when using dynamic slug"),!1):F&&!ue?(S("Dynamic slug is invalid"),!1):!0:(J.toast.error("Name is required"),!1),Ae=()=>{const s={pageType:r==null?void 0:r.key,name:M,slug:"",hasSlug:!1};m?O({id:t==null?void 0:t.id,name:M},{onSuccess:()=>{J.toast.success((r==null?void 0:r.name)+" updated successfully"),c()}}):g(s,{onSuccess:u=>{c(),f(u.page.id,j)}})},Oe=(s,u)=>{if(!s.trim()&&!F)return S("Child page slug is required"),!1;const q=_.removeSlugExtension(u),L=_.combineParentChildSlugs(q,s);return Object.keys(k.LANGUAGES).some(Z=>L===`/${Z}`||(L==null?void 0:L.startsWith(`/${Z}/`)))?(S("Slugs cannot start with a language code for primary page"),!1):!0},We=(s,u)=>{const q=_.removeSlugExtension(u),L=_.combineParentChildSlugs(q,s),I={pageType:l,name:M,slug:L.replace(/\/$/,""),parent:D,dynamic:F,hasSlug:!0,template:E||void 0,tracking:{},seo:{},jsonLD:{}};if(F&&(I.dynamicSlugCustom=ie),m){const A=w.pick(I,["pageType","parent","name","slug","dynamic","dynamicSlugCustom"]);O({id:t==null?void 0:t.id,...A},{onSuccess:()=>{J.toast.success("Page updated successfully"),c()}})}else{const A=w.find(i,{key:l});A!=null&&A.trackingDefault&&(I.tracking=A.trackingDefault);const{seo:Z,jsonLD:Ge}=fe.getSeoDefaults(A,ne);w.set(I,"seo",Z),w.set(I,"jsonLD",Ge),g(I,{onSuccess:Me=>{c(),f(Me.page.id,j)}})}},Re=()=>{const s={pageType:l,name:M,slug:B===""?"/":`/${B.replace(/\/$/,"")}`,template:E||void 0,parent:null,tracking:{}};if(m)O({id:t==null?void 0:t.id,...s},{onSuccess:()=>{J.toast.success("Page updated successfully"),c()}});else{const u=w.find(i,{key:l});u!=null&&u.trackingDefault&&(s.tracking=u.trackingDefault);const{seo:q,jsonLD:L}=fe.getSeoDefaults(u,ne);w.set(s,"seo",q),w.set(s,"jsonLD",L),g(s,{onSuccess:I=>{var A;(A=I==null?void 0:I.page)!=null&&A.id&&f(I.page.id,j),c()}})}},de=s=>{if(s.preventDefault(),S(null),!!qe()){if(!(r!=null&&r.hasSlug)){Ae();return}if(D&&D!=="none"){const u=h==null?void 0:h.find(L=>L.id===D),q=(u==null?void 0:u.slug)||"";if(!Oe(B,q))return;We(B,q)}else Re()}},{pagesType:se,partialsType:K}=o.useMemo(()=>{const s=u=>V?u.name.toLowerCase().includes(V.toLowerCase())||u.key.toLowerCase().includes(V.toLowerCase()):!0;return{pagesType:i.filter(u=>u.hasSlug!==!1&&s(u)),partialsType:i.filter(u=>u.hasSlug===!1&&s(u))}},[i,V]);return r!=null&&r.hasSlug?e.jsxs("form",{onSubmit:de,className:"mx-auto w-full max-w-md space-y-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(a.Label,{htmlFor:"pageType",className:"text-sm",children:"Type"}),he?e.jsxs(a.Popover,{open:ae,onOpenChange:Q,children:[e.jsx(a.PopoverTrigger,{asChild:!0,children:e.jsxs(v.Button,{variant:"outline",role:"combobox",disabled:m&&!y,className:z("w-full justify-between",m&&!y?"cursor-not-allowed text-gray-500":""),children:[(r==null?void 0:r.name)||"Select page type",e.jsx(N.ChevronDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(a.PopoverContent,{className:"w-[var(--radix-popover-trigger-width)] p-0",align:"start",children:e.jsxs(a.Command,{shouldFilter:!1,children:[e.jsx("div",{className:"sticky top-0 z-10 bg-white px-3 py-2",children:e.jsxs("div",{className:"relative",children:[e.jsx(N.Search,{strokeWidth:2,className:"absolute left-2 top-2 h-4 w-4 text-gray-400"}),e.jsx(v.Input,{placeholder:"Search page types...",className:"h-8 pl-8 text-xs",value:V,onChange:s=>H(s.target.value)})]})}),e.jsxs(X,{className:"overflow-y-auto",children:[e.jsx(a.CommandEmpty,{children:"No page type found."}),m?le?e.jsx(a.CommandGroup,{heading:"Partials",children:K.map(s=>e.jsxs(a.CommandItem,{value:s.key,onSelect:()=>U(s.key),className:"flex cursor-pointer items-center justify-between",children:[s.name,e.jsx(N.Check,{className:z("mr-2 h-4 w-4",l===s.key?"opacity-100":"opacity-0")})]},s.key))}):e.jsx(a.CommandGroup,{heading:"Pages",children:se.map(s=>e.jsxs(a.CommandItem,{value:s.key,onSelect:()=>U(s.key),className:"flex cursor-pointer items-center justify-between",children:[s.name,e.jsx(N.Check,{className:z("mr-2 h-4 w-4",l===s.key?"opacity-100":"opacity-0")})]},s.key))}):e.jsxs(e.Fragment,{children:[se.length>0&&e.jsx(a.CommandGroup,{heading:"Pages",children:se.map(s=>e.jsxs(a.CommandItem,{value:s.key,onSelect:()=>U(s.key),className:"flex cursor-pointer items-center justify-between",children:[s.name,e.jsx(N.Check,{className:z("mr-2 h-4 w-4",l===s.key?"opacity-100":"opacity-0")})]},s.key))}),K.length>0&&e.jsx(a.CommandGroup,{heading:"Partials",children:K.map(s=>e.jsxs(a.CommandItem,{value:s.key,onSelect:()=>U(s.key),className:"flex cursor-pointer items-center justify-between",children:[s.name,e.jsx(N.Check,{className:z("mr-2 h-4 w-4",l===s.key?"opacity-100":"opacity-0")})]},s.key))})]})]})]})})]}):e.jsx("select",{id:"pageType",value:l,disabled:m&&!y,onChange:s=>U(s.target.value),className:`w-full rounded-md border border-gray-300 px-3 py-2 ${m&&!y?"cursor-not-allowed text-gray-500":""}`,children:m?le?e.jsx("optgroup",{label:"Partials",children:i.filter(s=>s.hasSlug===!1).map(s=>e.jsx("option",{value:s.key,children:s.name},s.key))}):e.jsx("optgroup",{label:"Pages",children:i.filter(s=>s.hasSlug!==!1).map(s=>e.jsx("option",{value:s.key,children:s.name},s.key))}):e.jsxs(e.Fragment,{children:[e.jsx("optgroup",{label:"Pages",children:i.filter(s=>s.hasSlug!==!1).map(s=>e.jsx("option",{value:s.key,children:s.name},s.key))}),e.jsx("optgroup",{label:"Partials",children:i.filter(s=>s.hasSlug===!1).map(s=>e.jsx("option",{value:s.key,children:s.name},s.key))})]})}),W&&e.jsxs("div",{className:"mt-2 rounded-md border border-yellow-200 bg-yellow-50 p-3",children:[e.jsx("p",{className:"text-sm text-yellow-800",children:"Changing the page type may impact the page data. Are you sure you want to proceed?"}),e.jsxs("div",{className:"mt-2 flex gap-2",children:[e.jsx(v.Button,{variant:"outline",size:"sm",onClick:()=>G(!1),children:"Cancel"}),e.jsx(v.Button,{variant:"default",size:"sm",onClick:pe,children:"Confirm"})]})]})]}),!m&&(r==null?void 0:r.hasSlug)&&me.length>0&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(a.Label,{className:"mb-1 block text-sm",children:"Template"}),e.jsx(Ve,{templates:me,selectedTemplateId:E,onSelectTemplate:Be,isLoading:Le})]}),e.jsx(ze,{pages:h,selectedParentId:D,onChange:Fe,currentPage:t}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(a.Label,{htmlFor:"name",className:"text-sm",children:"Name"}),e.jsx(v.Input,{id:"name",value:M,onChange:s=>re(s.target.value),required:!0,"aria-required":"true",placeholder:"Enter page name"})]}),(r==null?void 0:r.dynamicSegments)&&D&&D!=="none"&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"checkbox",id:"useDynamicSlug",checked:F,onChange:s=>Ie(s.target.checked),className:"rounded border-gray-300"}),e.jsx(a.Label,{htmlFor:"useDynamicSlug",className:"text-sm",children:"Use Dynamic Slug"})]}),F&&e.jsx("div",{className:"space-y-2",children:e.jsx("div",{className:"space-y-0.5",children:e.jsx(Ue,{value:ie,onChange:ce,dynamicPattern:(r==null?void 0:r.dynamicSlug)||"{{id}}",placeholder:"Enter custom slug part (optional)",onValidationChange:be})})})]}),(!(r!=null&&r.dynamicSegments)||!F)&&e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(a.Label,{htmlFor:"slug",className:"text-sm",children:"Slug"}),e.jsx(_.SlugInput,{value:B,onChange:s=>{var u;Y(s),m&&s!==(((u=t==null?void 0:t.slug)==null?void 0:u.split("/").pop())||"")?P(!!(Te||De)):P(!1)},placeholder:D&&D!=="none"?"Enter page slug":l==="page"?"Leave empty for home page":"Required - e.g. your-slug",parentSlug:D&&D!=="none"?(ge=h==null?void 0:h.find(s=>s.id===D))==null?void 0:ge.slug:void 0,onValidationChange:d}),R&&e.jsx("p",{className:"text-xs text-red-500",children:R}),we&&e.jsx("div",{className:"mt-4 rounded-md border border-amber-200 bg-amber-50 p-3",children:e.jsxs("div",{className:"flex items-start space-x-2",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx("svg",{className:"h-5 w-5 text-amber-400",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z",clipRule:"evenodd"})})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"text-sm font-medium text-amber-800",children:"Slug Change Warning"}),e.jsx("div",{className:"mt-1 text-sm text-amber-700",children:e.jsx("p",{children:"The previous URL and any child pages will become inaccessible. You may want to set up a redirect to avoid broken links."})})]})]})})]}),e.jsx(v.Button,{disabled:$||!C&&(!(r!=null&&r.dynamicSegments)||!F)||F&&!ue,type:"submit",className:"w-full",children:m?$?"Updating...":"Update page":$?"Creating...":"Create Page"})]}):e.jsxs("form",{onSubmit:de,className:"mx-auto w-full max-w-md space-y-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(a.Label,{htmlFor:"pageType",className:"text-sm",children:"Type"}),he?e.jsxs(a.Popover,{open:ae,onOpenChange:Q,children:[e.jsx(a.PopoverTrigger,{asChild:!0,children:e.jsxs(v.Button,{variant:"outline",role:"combobox",disabled:m&&!y,className:z("w-full justify-between",m&&!y?"cursor-not-allowed text-gray-500":""),children:[(r==null?void 0:r.name)||"Select page type",e.jsx(N.ChevronDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(a.PopoverContent,{className:"w-[var(--radix-popover-trigger-width)] p-0",align:"start",children:e.jsxs(a.Command,{shouldFilter:!1,children:[e.jsx("div",{className:"sticky top-0 z-10 bg-white px-3 py-2",children:e.jsxs("div",{className:"relative",children:[e.jsx(N.Search,{strokeWidth:2,className:"absolute left-2 top-2 h-4 w-4 text-gray-400"}),e.jsx(v.Input,{placeholder:"Search page types...",className:"h-8 pl-8 text-xs",value:V,onChange:s=>H(s.target.value)})]})}),e.jsxs(X,{className:"max-h-[200px] overflow-y-auto",children:[e.jsx(a.CommandEmpty,{children:"No page type found."}),e.jsx(a.CommandGroup,{heading:"Partials",children:K.map(s=>e.jsxs(a.CommandItem,{value:s.key,onSelect:()=>{U(s.key),Q(!1)},className:"flex cursor-pointer items-center justify-between",children:[s.name,e.jsx(N.Check,{className:z("mr-2 h-4 w-4",l===s.key?"opacity-100":"opacity-0")})]},s.key))})]})]})})]}):e.jsx("select",{id:"pageType",value:l,disabled:m&&!y,onChange:s=>U(s.target.value),className:`w-full rounded-md border border-gray-300 px-3 py-2 ${m&&!y?"cursor-not-allowed text-gray-500":""}`,children:e.jsx("optgroup",{label:"Partials",children:i.filter(s=>s.hasSlug===!1).map(s=>e.jsx("option",{value:s.key,children:s.name},s.key))})}),W&&e.jsxs("div",{className:"mt-2 rounded-md border border-yellow-200 bg-yellow-50 p-3",children:[e.jsx("p",{className:"text-sm text-yellow-800",children:"Changing the page type may impact the page data. Are you sure you want to proceed?"}),e.jsxs("div",{className:"mt-2 flex gap-2",children:[e.jsx(v.Button,{variant:"outline",size:"sm",onClick:()=>G(!1),children:"Cancel"}),e.jsx(v.Button,{variant:"default",size:"sm",onClick:pe,children:"Confirm"})]})]}),e.jsx("p",{className:"text-xs text-gray-500",children:(xe=i.find(s=>s.key===l))==null?void 0:xe.helpText})]}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(a.Label,{htmlFor:"name",className:"text-sm",children:"Name"}),e.jsx(v.Input,{id:"name",value:M,onChange:s=>re(s.target.value),required:!0,"aria-required":"true"})]}),e.jsx(v.Button,{disabled:$,type:"submit",className:"w-full",children:m?$?"Updating...":"Update "+(r==null?void 0:r.name):$?"Creating...":"Create "+(r==null?void 0:r.name)})]})}exports.default=He;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react/jsx-runtime"),e=require("./index-CzBSRTj0.cjs"),E=require("@tanstack/react-query"),r=require("react"),c=r.lazy(()=>Promise.resolve().then(()=>require("./take-over-request-GdscXVYh.cjs"))),o=r.lazy(()=>Promise.resolve().then(()=>require("./page-locked-dialog-BfmE52P5.cjs"))),l=r.lazy(()=>Promise.resolve().then(()=>require("./active-in-another-tab-C83x4jHw.cjs"))),S=r.lazy(()=>Promise.resolve().then(()=>require("./continue-editing-in-this-client-DgtsPYZ4.cjs"))),s=n=>u.jsx(r.Suspense,{children:u.jsx(n,{})}),A=({isFetchingPageData:n})=>{e.useChaibuilderRealtime();const{pageStatus:t}=e.usePageLockStatus(),{pageLockMeta:a}=e.usePageLockMeta(),T=E.useQueryClient(),i=r.useRef(t);if(r.useEffect(()=>{t===e.PAGE_STATUS.EDITING&&i.current!==e.PAGE_STATUS.TAKE_OVER_REQUESTED&&T.invalidateQueries({queryKey:[e.ACTIONS.GET_DRAFT_PAGE]}),i.current=t},[t,T]),n)return null;switch(t){case e.PAGE_STATUS.EDITING:case e.PAGE_STATUS.CHECKING:case e.PAGE_STATUS.FORCE_TAKE_OVER:return a.type===e.EVENT.CONTINUE_EDITING_IN_THIS_CLIENT?s(S):null;case e.PAGE_STATUS.LOCKED:return s(o);case e.PAGE_STATUS.TAKE_OVER_REQUESTED:return s(c);case e.PAGE_STATUS.ACTIVE_IN_ANOTHER_TAB:return s(l);case e.PAGE_STATUS.CONNECTION_LOST:return u.jsx(e.BlurContainer,{children:null});default:return null}};exports.default=A;
@@ -1,30 +0,0 @@
1
- import { jsx as n } from "react/jsx-runtime";
2
- import { u as E, a as c, b as T, P as e, A as l, B as I, E as _ } from "./index-nzqILA37.js";
3
- import { useQueryClient as C } from "@tanstack/react-query";
4
- import { useRef as p, useEffect as N, Suspense as A, lazy as s } from "react";
5
- const m = s(() => import("./take-over-request-Bjyi22us.js")), f = s(() => import("./page-locked-dialog-o9eCXo2g.js")), O = s(() => import("./active-in-another-tab-3S4Tzg0v.js")), S = s(() => import("./continue-editing-in-this-client-DTmWmAee.js")), r = (a) => /* @__PURE__ */ n(A, { children: /* @__PURE__ */ n(a, {}) }), L = ({ isFetchingPageData: a }) => {
6
- E();
7
- const { pageStatus: t } = c(), { pageLockMeta: o } = T(), u = C(), i = p(t);
8
- if (N(() => {
9
- t === e.EDITING && i.current !== e.TAKE_OVER_REQUESTED && u.invalidateQueries({ queryKey: [l.GET_DRAFT_PAGE] }), i.current = t;
10
- }, [t, u]), a) return null;
11
- switch (t) {
12
- case e.EDITING:
13
- case e.CHECKING:
14
- case e.FORCE_TAKE_OVER:
15
- return o.type === _.CONTINUE_EDITING_IN_THIS_CLIENT ? r(S) : null;
16
- case e.LOCKED:
17
- return r(f);
18
- case e.TAKE_OVER_REQUESTED:
19
- return r(m);
20
- case e.ACTIVE_IN_ANOTHER_TAB:
21
- return r(O);
22
- case e.CONNECTION_LOST:
23
- return /* @__PURE__ */ n(I, { children: null });
24
- default:
25
- return null;
26
- }
27
- };
28
- export {
29
- L as default
30
- };
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("./index-DCJDQs1a.cjs"),p=require("./register-chai-top-bar-DyW9GPzV.cjs"),t=require("./index-CzBSRTj0.cjs"),c=require("lucide-react"),d=require("react"),O=require("react-i18next"),_=()=>{const m=t.useCurrentPageOwner(),f=t.useSendRealtimeEvent(),{setPageStatus:j}=t.usePageLockStatus(),{data:s,isFetching:v}=t.useChaiUserInfo((m==null?void 0:m.userId)||""),{pageLockMeta:o,setPageLockMeta:g}=t.usePageLockMeta(),{t:r}=O.useTranslation(),[u,i]=d.useState(""),[a,N]=d.useState({}),[T,k]=d.useState(!1),l=d.useRef(null);d.useEffect(()=>{o!=null&&o.type&&(l.current&&clearTimeout(l.current),d.startTransition(()=>{N(o),g({}),i("")}))},[o,g]);const b=()=>{u!==t.EVENT.TAKE_OVER_REQUEST&&(i(t.EVENT.TAKE_OVER_REQUEST),f(t.EVENT.TAKE_OVER_REQUEST),l.current=setTimeout(()=>i(""),2e4))},R=()=>{u!==t.EVENT.FORCE_TAKE_OVER_REQUEST&&(i(t.EVENT.FORCE_TAKE_OVER_REQUEST),f(t.EVENT.FORCE_TAKE_OVER_REQUEST),j(t.PAGE_STATUS.CHECKING),l.current=setTimeout(()=>i(""),2e4))},y=()=>{N({}),l.current&&clearTimeout(l.current),i("")},x=v?"Loading...":(s==null?void 0:s.name)||"Current editor",h=u===t.EVENT.TAKE_OVER_REQUEST,E=u===t.EVENT.FORCE_TAKE_OVER_REQUEST;return e.jsx(t.BlurContainer,{children:e.jsxs(n.Card,{className:"mx-auto w-full max-w-md",children:[e.jsx(n.CardHeader,{className:"space-y-1 border-b pb-3",children:e.jsxs(n.CardTitle,{className:"flex items-center gap-2 text-xl",children:[e.jsx(c.LockKeyhole,{className:"h-8 w-8 rounded-md bg-sky-500/20 p-1.5 text-sky-500"}),e.jsx("span",{children:r("Page Locked for Editing")})]})}),e.jsxs(n.CardContent,{className:"space-y-4 p-4",children:[e.jsxs("div",{className:"relative rounded-md border border-green-500 px-2 pb-2 pt-4",children:[e.jsx("div",{className:"absolute -top-2.5 left-3 w-max rounded-full bg-green-500 px-3 py-1 text-xs font-medium leading-3 text-white",children:"Current Editor"}),e.jsxs("div",{className:"flex items-center space-x-4 p-1",children:[s!=null&&s.avatar?e.jsx("img",{src:s.avatar,alt:s.name,className:"h-12 w-12 flex-shrink-0 rounded-full bg-black text-white"}):e.jsx(c.UserIcon,{className:"h-12 w-12 flex-shrink-0 rounded-full bg-black p-3 text-white"}),e.jsxs("div",{className:"flex-1 space-y-0",children:[e.jsx("div",{className:"truncate font-medium leading-tight text-black",children:x}),(s==null?void 0:s.email)&&e.jsx("p",{className:"truncate text-sm leading-tight text-muted-foreground",children:s.email})]})]})]}),((a==null?void 0:a.type)===t.EVENT.TAKE_OVER_REJECTED||(a==null?void 0:a.type)===t.EVENT.FORCE_TAKE_OVER_REQUEST)&&e.jsx("section",{className:"space-y-2",children:e.jsxs("div",{className:"flex items-center justify-between gap-x-2 rounded border border-red-500 bg-red-500/10 py-2 pl-3 pr-2 text-sm font-medium text-red-500",children:[e.jsxs("div",{className:"flex items-start gap-x-2",children:[e.jsx(c.AlertCircleIcon,{className:"mt-px flex h-4 w-4 shrink-0"}),e.jsxs("div",{className:"font-light leading-tight",children:[e.jsx("span",{className:"font-medium",children:(s==null?void 0:s.name)||"The current editor"}),(a==null?void 0:a.type)===t.EVENT.TAKE_OVER_REJECTED?" rejected your take over request.":" forcefully took over this page."]})]}),e.jsx(p.Button,{size:"icon",variant:"ghost",onClick:y,className:"flex-shrink-0",children:e.jsx(c.X,{className:"h-4 w-4"})})]})})]}),e.jsx(n.CardFooter,{className:"flex flex-col gap-3 border-t pt-3",children:e.jsxs("section",{className:"space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:r("Take Over Options")}),e.jsxs("div",{className:"rounded-md border bg-muted/40 p-3",children:[e.jsxs("div",{className:"mb-2",children:[e.jsx("p",{className:"text-sm font-medium",children:r("Take Over Request:")}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:r("Send a request to {{currentEditorName}} asking them to release the page. They can accept or decline your request.",{currentEditorName:x})})]}),e.jsxs(p.Button,{disabled:h,variant:"default",onClick:b,className:"mt-3 w-full gap-2",children:[e.jsx(c.Edit,{className:"h-4 w-4"}),h?"Take over request sent":"Send Take Over Request"]}),h&&e.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:r("Request sent. If no response, try again or use force take over.")})]}),e.jsx(n.Accordion,{type:"single",collapsible:!0,className:"w-full",children:e.jsxs(n.AccordionItem,{value:"force-takeover",className:"rounded-md border border-destructive/40 bg-destructive/5",children:[e.jsx(n.AccordionTrigger,{className:"px-3 py-2 hover:no-underline",children:e.jsx("div",{className:"flex items-center gap-2 text-left",children:e.jsxs("div",{children:[e.jsxs("p",{className:"flex items-center gap-x-2 text-sm font-medium text-destructive",children:[e.jsx(c.ShieldAlert,{className:"h-4 w-4 text-destructive"}),r("Force Take Over")]}),e.jsx("p",{className:"pl-6 text-xs font-normal leading-tight text-muted-foreground",children:r("Immediately take control (use with caution)")})]})})}),e.jsx(n.AccordionContent,{className:"px-3 pb-3",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-destructive/40 bg-background p-2",children:[e.jsx("input",{type:"checkbox",id:"force-takeover",checked:T,onChange:C=>k(C.target.checked),className:"mt-0.5 h-4 w-4 rounded border-gray-300"}),e.jsx("label",{htmlFor:"force-takeover",className:"flex-1 text-xs text-muted-foreground",children:r("I understand this will immediately close the editor for {{currentEditorName}}. I am using this option with caution.",{currentEditorName:x})})]}),e.jsxs(p.Button,{disabled:!T||E,variant:"destructive",onClick:R,className:"w-full gap-2",children:[e.jsx(c.ShieldAlert,{className:"h-4 w-4"}),r(E?"Take over page...":"Force Take Over")]}),E&&e.jsx("p",{className:"text-xs text-muted-foreground",children:r("Attempting to forcefully take over this page. Please wait while we update the editing session.")})]})})]})})]})})]})})};exports.default=_;
@@ -1,136 +0,0 @@
1
- import { jsx as e, jsxs as t } from "react/jsx-runtime";
2
- import { J as _, K as w, M as A, O as S, Q as K, R as F, U, V, W as I } from "./index-OuHV9Ann.js";
3
- import { B as p } from "./register-chai-top-bar-D6GjnauV.js";
4
- import { ap as Q, an as q, a as P, ao as j, b as B, B as D, E as a, P as J } from "./index-nzqILA37.js";
5
- import { LockKeyhole as L, UserIcon as G, AlertCircleIcon as H, X as z, Edit as W, ShieldAlert as v } from "lucide-react";
6
- import { useState as f, useRef as X, useEffect as Y, startTransition as Z } from "react";
7
- import { useTranslation as $ } from "react-i18next";
8
- const ie = () => {
9
- const d = Q(), x = q(), { setPageStatus: T } = P(), { data: r, isFetching: k } = j((d == null ? void 0 : d.userId) || ""), { pageLockMeta: l, setPageLockMeta: E } = B(), { t: s } = $(), [o, i] = f(""), [n, g] = f({}), [N, b] = f(!1), c = X(null);
10
- Y(() => {
11
- l != null && l.type && (c.current && clearTimeout(c.current), Z(() => {
12
- g(l), E({}), i("");
13
- }));
14
- }, [l, E]);
15
- const R = () => {
16
- o !== a.TAKE_OVER_REQUEST && (i(a.TAKE_OVER_REQUEST), x(a.TAKE_OVER_REQUEST), c.current = setTimeout(() => i(""), 2e4));
17
- }, C = () => {
18
- o !== a.FORCE_TAKE_OVER_REQUEST && (i(a.FORCE_TAKE_OVER_REQUEST), x(a.FORCE_TAKE_OVER_REQUEST), T(J.CHECKING), c.current = setTimeout(() => i(""), 2e4));
19
- }, O = () => {
20
- g({}), c.current && clearTimeout(c.current), i("");
21
- }, m = k ? "Loading..." : (r == null ? void 0 : r.name) || "Current editor", u = o === a.TAKE_OVER_REQUEST, h = o === a.FORCE_TAKE_OVER_REQUEST;
22
- return /* @__PURE__ */ e(D, { children: /* @__PURE__ */ t(_, { className: "mx-auto w-full max-w-md", children: [
23
- /* @__PURE__ */ e(w, { className: "space-y-1 border-b pb-3", children: /* @__PURE__ */ t(A, { className: "flex items-center gap-2 text-xl", children: [
24
- /* @__PURE__ */ e(L, { className: "h-8 w-8 rounded-md bg-sky-500/20 p-1.5 text-sky-500" }),
25
- /* @__PURE__ */ e("span", { children: s("Page Locked for Editing") })
26
- ] }) }),
27
- /* @__PURE__ */ t(S, { className: "space-y-4 p-4", children: [
28
- /* @__PURE__ */ t("div", { className: "relative rounded-md border border-green-500 px-2 pb-2 pt-4", children: [
29
- /* @__PURE__ */ e("div", { className: "absolute -top-2.5 left-3 w-max rounded-full bg-green-500 px-3 py-1 text-xs font-medium leading-3 text-white", children: "Current Editor" }),
30
- /* @__PURE__ */ t("div", { className: "flex items-center space-x-4 p-1", children: [
31
- r != null && r.avatar ? /* @__PURE__ */ e(
32
- "img",
33
- {
34
- src: r.avatar,
35
- alt: r.name,
36
- className: "h-12 w-12 flex-shrink-0 rounded-full bg-black text-white"
37
- }
38
- ) : /* @__PURE__ */ e(G, { className: "h-12 w-12 flex-shrink-0 rounded-full bg-black p-3 text-white" }),
39
- /* @__PURE__ */ t("div", { className: "flex-1 space-y-0", children: [
40
- /* @__PURE__ */ e("div", { className: "truncate font-medium leading-tight text-black", children: m }),
41
- (r == null ? void 0 : r.email) && /* @__PURE__ */ e("p", { className: "truncate text-sm leading-tight text-muted-foreground", children: r.email })
42
- ] })
43
- ] })
44
- ] }),
45
- ((n == null ? void 0 : n.type) === a.TAKE_OVER_REJECTED || (n == null ? void 0 : n.type) === a.FORCE_TAKE_OVER_REQUEST) && /* @__PURE__ */ e("section", { className: "space-y-2", children: /* @__PURE__ */ t("div", { className: "flex items-center justify-between gap-x-2 rounded border border-red-500 bg-red-500/10 py-2 pl-3 pr-2 text-sm font-medium text-red-500", children: [
46
- /* @__PURE__ */ t("div", { className: "flex items-start gap-x-2", children: [
47
- /* @__PURE__ */ e(H, { className: "mt-px flex h-4 w-4 shrink-0" }),
48
- /* @__PURE__ */ t("div", { className: "font-light leading-tight", children: [
49
- /* @__PURE__ */ e("span", { className: "font-medium", children: (r == null ? void 0 : r.name) || "The current editor" }),
50
- (n == null ? void 0 : n.type) === a.TAKE_OVER_REJECTED ? " rejected your take over request." : " forcefully took over this page."
51
- ] })
52
- ] }),
53
- /* @__PURE__ */ e(p, { size: "icon", variant: "ghost", onClick: O, className: "flex-shrink-0", children: /* @__PURE__ */ e(z, { className: "h-4 w-4" }) })
54
- ] }) })
55
- ] }),
56
- /* @__PURE__ */ e(K, { className: "flex flex-col gap-3 border-t pt-3", children: /* @__PURE__ */ t("section", { className: "space-y-2", children: [
57
- /* @__PURE__ */ e("h3", { className: "text-xs font-semibold uppercase tracking-wide text-muted-foreground", children: s("Take Over Options") }),
58
- /* @__PURE__ */ t("div", { className: "rounded-md border bg-muted/40 p-3", children: [
59
- /* @__PURE__ */ t("div", { className: "mb-2", children: [
60
- /* @__PURE__ */ e("p", { className: "text-sm font-medium", children: s("Take Over Request:") }),
61
- /* @__PURE__ */ e("p", { className: "mt-1 text-xs text-muted-foreground", children: s(
62
- "Send a request to {{currentEditorName}} asking them to release the page. They can accept or decline your request.",
63
- { currentEditorName: m }
64
- ) })
65
- ] }),
66
- /* @__PURE__ */ t(
67
- p,
68
- {
69
- disabled: u,
70
- variant: "default",
71
- onClick: R,
72
- className: "mt-3 w-full gap-2",
73
- children: [
74
- /* @__PURE__ */ e(W, { className: "h-4 w-4" }),
75
- u ? "Take over request sent" : "Send Take Over Request"
76
- ]
77
- }
78
- ),
79
- u && /* @__PURE__ */ e("p", { className: "mt-2 text-xs text-muted-foreground", children: s("Request sent. If no response, try again or use force take over.") })
80
- ] }),
81
- /* @__PURE__ */ e(F, { type: "single", collapsible: !0, className: "w-full", children: /* @__PURE__ */ t(
82
- U,
83
- {
84
- value: "force-takeover",
85
- className: "rounded-md border border-destructive/40 bg-destructive/5",
86
- children: [
87
- /* @__PURE__ */ e(V, { className: "px-3 py-2 hover:no-underline", children: /* @__PURE__ */ e("div", { className: "flex items-center gap-2 text-left", children: /* @__PURE__ */ t("div", { children: [
88
- /* @__PURE__ */ t("p", { className: "flex items-center gap-x-2 text-sm font-medium text-destructive", children: [
89
- /* @__PURE__ */ e(v, { className: "h-4 w-4 text-destructive" }),
90
- s("Force Take Over")
91
- ] }),
92
- /* @__PURE__ */ e("p", { className: "pl-6 text-xs font-normal leading-tight text-muted-foreground", children: s("Immediately take control (use with caution)") })
93
- ] }) }) }),
94
- /* @__PURE__ */ e(I, { className: "px-3 pb-3", children: /* @__PURE__ */ t("div", { className: "space-y-3", children: [
95
- /* @__PURE__ */ t("div", { className: "flex items-start gap-2 rounded-md border border-destructive/40 bg-background p-2", children: [
96
- /* @__PURE__ */ e(
97
- "input",
98
- {
99
- type: "checkbox",
100
- id: "force-takeover",
101
- checked: N,
102
- onChange: (y) => b(y.target.checked),
103
- className: "mt-0.5 h-4 w-4 rounded border-gray-300"
104
- }
105
- ),
106
- /* @__PURE__ */ e("label", { htmlFor: "force-takeover", className: "flex-1 text-xs text-muted-foreground", children: s(
107
- "I understand this will immediately close the editor for {{currentEditorName}}. I am using this option with caution.",
108
- { currentEditorName: m }
109
- ) })
110
- ] }),
111
- /* @__PURE__ */ t(
112
- p,
113
- {
114
- disabled: !N || h,
115
- variant: "destructive",
116
- onClick: C,
117
- className: "w-full gap-2",
118
- children: [
119
- /* @__PURE__ */ e(v, { className: "h-4 w-4" }),
120
- s(h ? "Take over page..." : "Force Take Over")
121
- ]
122
- }
123
- ),
124
- h && /* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground", children: s(
125
- "Attempting to forcefully take over this page. Please wait while we update the editing session."
126
- ) })
127
- ] }) })
128
- ]
129
- }
130
- ) })
131
- ] }) })
132
- ] }) });
133
- };
134
- export {
135
- ie as default
136
- };
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),h=require("./register-chai-top-bar-DyW9GPzV.cjs"),n=require("./index-DCJDQs1a.cjs"),v=require("./index-CzBSRTj0.cjs"),w=require("./use-page-expand-manager-B6XTvk0E.cjs"),S=require("@tanstack/react-query"),s=require("lodash-es"),x=require("lucide-react"),b=require("react"),j=require("react-i18next"),k=({selectedPageType:l,setSelectedPageType:a})=>{const{t:o}=j.useTranslation(),[r,i]=b.useState(""),{data:c}=v.usePageTypes(),m=b.useMemo(()=>c.some(t=>!["page","global"].includes(s.get(t,"key",""))),[c]);if(b.useEffect(()=>{!m&&l!=="all"&&a("all")},[m,l,a]),!m)return null;const u=t=>{if(!r)return!0;const d=r.toLowerCase(),g=f=>String(s.get(t,f,"")).toLowerCase().includes(d);return g("name")||g("key")},p=c.find(t=>t.key===l);return e.jsxs(n.Select,{onValueChange:a,value:l,children:[e.jsx(n.SelectTrigger,{className:`${l==="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:(p==null?void 0:p.name)||o("All")}),e.jsx(x.ListFilter,{className:`${l!=="all"?"fill-sky-50 text-sky-500":""} pointer-events-none h-4 w-4 text-muted-foreground hover:bg-blue-300`})]})}),e.jsxs(n.SelectContent,{children:[e.jsx("div",{className:"sticky top-0 z-10 bg-white pb-2",children:e.jsxs("div",{className:"relative",children:[e.jsx(x.Search,{strokeWidth:2,className:"absolute left-2 top-2.5 h-3.5 w-3.5 text-gray-400"}),e.jsx(h.Input,{placeholder:o("Search page types..."),className:"h-8 w-full rounded border pl-8 text-xs shadow-none",value:r,onChange:t=>i(t.target.value),onKeyDown:t=>t.stopPropagation()})]})}),e.jsx(n.SelectItem,{value:"all",children:o("All")}),!s.isEmpty(s.filter(c,t=>t.hasSlug&&u(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:o("Pages")}),s.map([...s.filter(c,t=>t.hasSlug&&u(t))].sort((t,d)=>s.get(t,"name","").localeCompare(s.get(d,"name",""))),t=>e.jsx(n.SelectItem,{value:s.get(t,"key"),children:s.get(t,"name")},s.get(t,"key")))]}),!s.isEmpty(s.filter(c,t=>!t.hasSlug&&u(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:o("Partials")}),s.map([...s.filter(c,t=>!t.hasSlug&&u(t))].sort((t,d)=>s.get(t,"name","").localeCompare(s.get(d,"name",""))),t=>e.jsx(n.SelectItem,{value:s.get(t,"key"),children:s.get(t,"name")},s.get(t,"key")))]}),s.isEmpty(s.filter(c,u))&&e.jsx("div",{className:"px-3 py-2 text-center text-sm text-gray-500",children:o("No matching page types found")})]})]})},T=({search:l,setSearch:a})=>{const{t:o}=j.useTranslation();return 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:o("Search Pages")}),e.jsx(x.Search,{className:`${l?"fill-sky-50 text-sky-500":""} pointer-events-none h-4 w-4 text-muted-foreground`,"aria-hidden":"true"}),e.jsx(h.Input,{id:"page-search-input",placeholder:o("Search pages"),value:l,onChange:r=>a(r.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",autoFocus:!0})]})},E=({pages:l})=>{const{t:a}=j.useTranslation(),{expandAll:o,collapseAll:r,expandedPages:i}=w.usePageExpandManager(null);return e.jsxs("div",{className:"flex gap-1",children:[e.jsxs(n.Tooltip,{children:[e.jsx(n.TooltipTrigger,{asChild:!0,children:e.jsx(h.Button,{variant:"outline",size:"icon",onClick:()=>o(l),className:"rounded p-1 text-gray-500",children:e.jsx(x.ChevronsUpDown,{})})}),e.jsx(n.TooltipContent,{children:a("Expand All")})]}),e.jsxs(n.Tooltip,{children:[e.jsx(n.TooltipTrigger,{asChild:!0,children:e.jsx(h.Button,{disabled:i.length===0,variant:"outline",size:"icon",onClick:()=>r(),className:"rounded p-1 text-gray-500",children:e.jsx(x.ChevronsDownUp,{})})}),e.jsx(n.TooltipContent,{children:a("Collapse All")})]})]})},C=({languages:l,selectedLanguage:a,setSelectedLanguage:o})=>{const r=v.useFallbackLang();return e.jsx("div",{className:"scrollbar-hide flex gap-1 overflow-x-auto pb-1",children:l.map(i=>e.jsxs(h.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===r&&e.jsx(x.Star,{size:4,className:`p-0.5 ${a===r?"fill-white":"fill-black"}`}),v.LANGUAGES[i]||""]},i))})},y=()=>{const{t:l}=j.useTranslation(),a=S.useQueryClient();return e.jsxs(n.Tooltip,{children:[e.jsx(n.TooltipTrigger,{asChild:!0,children:e.jsx(h.Button,{size:"sm",variant:"ghost",onClick:()=>a.invalidateQueries({queryKey:[v.ACTIONS.GET_WEBSITE_PAGES]}),className:"mt-1 h-6 w-6",children:e.jsx(x.RefreshCw,{})})}),e.jsx(n.TooltipContent,{side:"bottom",children:l("Refresh pages list")})]})},q=({pages:l,search:a,setSearch:o,languages:r,onAddPage:i,selectedLanguage:c,setSelectedLanguage:m,selectedPageType:u,setSelectedPageType:p,showUntranslatedPages:t,setShowUntranslatedPages:d})=>{const{t:g}=j.useTranslation(),f=r.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(k,{selectedPageType:u,setSelectedPageType:p}),e.jsx(T,{search:a,setSearch:o}),e.jsx(E,{pages:l}),e.jsxs(h.Button,{variant:"default",onClick:i,className:"rounded px-3 font-normal",children:[e.jsx(x.Plus,{strokeWidth:2,className:"stroke-white stroke-[3]"}),e.jsx("span",{className:"font-normal text-white",children:g("Add Page")})]}),!f&&e.jsx(y,{})]}),f?e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx(C,{languages:r,selectedLanguage:c,setSelectedLanguage:N=>{m(N),d(t&&(r==null?void 0:r[0])!==c)}}),e.jsxs("div",{className:"flex items-center gap-x-2",children:[(r==null?void 0:r[0])!==c&&e.jsxs(n.Tooltip,{children:[e.jsx(n.TooltipTrigger,{asChild:!0,children:e.jsx(h.Button,{variant:"ghost",onClick:()=>d(!t),className:"h-6 rounded px-3 py-1 text-xs font-normal",children:t?e.jsx(x.FilterXIcon,{}):e.jsx(x.Filter,{})})}),e.jsx(n.TooltipContent,{side:"bottom",children:g("Toggle Untranslated Pages")})]}),e.jsx(y,{})]})]}):e.jsx("div",{className:"flex items-center justify-between gap-2"})]})};exports.LanguageSelector=C;exports.default=q;
@@ -1,210 +0,0 @@
1
- import { jsx as e, jsxs as a, Fragment as k } from "react/jsx-runtime";
2
- import { B as m, z as E } from "./register-chai-top-bar-D6GjnauV.js";
3
- import { z as b, A as y, E as N, S as L, F as I, G as P, H as w } from "./index-OuHV9Ann.js";
4
- import { i as j, L as G, k as $, A as M } from "./index-nzqILA37.js";
5
- import { u as B } from "./use-page-expand-manager-Cf4MUEJw.js";
6
- import { useQueryClient as D } from "@tanstack/react-query";
7
- import { get as c, isEmpty as C, filter as f, map as S } from "lodash-es";
8
- import { Star as R, Plus as W, FilterXIcon as q, Filter as K, ListFilter as Q, Search as F, ChevronsUpDown as T, ChevronsDownUp as _, RefreshCw as H } from "lucide-react";
9
- import { useState as O, useMemo as U, useEffect as V } from "react";
10
- import { useTranslation as v } from "react-i18next";
11
- const X = ({ selectedPageType: n, setSelectedPageType: l }) => {
12
- const { t: s } = v(), [r, o] = O(""), { data: i } = $(), p = U(
13
- () => i.some((t) => !["page", "global"].includes(c(t, "key", ""))),
14
- [i]
15
- );
16
- if (V(() => {
17
- !p && n !== "all" && l("all");
18
- }, [p, n, l]), !p) return null;
19
- const h = (t) => {
20
- if (!r) return !0;
21
- const d = r.toLowerCase(), x = (g) => String(c(t, g, "")).toLowerCase().includes(d);
22
- return x("name") || x("key");
23
- }, u = i.find((t) => t.key === n);
24
- return /* @__PURE__ */ a(L, { onValueChange: l, value: n, children: [
25
- /* @__PURE__ */ e(
26
- I,
27
- {
28
- 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`,
29
- children: /* @__PURE__ */ a("div", { className: "flex w-full items-center justify-between gap-x-1.5", children: [
30
- /* @__PURE__ */ e("span", { className: "max-w-[150px] overflow-hidden truncate whitespace-nowrap font-medium leading-tight", children: (u == null ? void 0 : u.name) || s("All") }),
31
- /* @__PURE__ */ e(
32
- Q,
33
- {
34
- className: `${n !== "all" ? "fill-sky-50 text-sky-500" : ""} pointer-events-none h-4 w-4 text-muted-foreground hover:bg-blue-300`
35
- }
36
- )
37
- ] })
38
- }
39
- ),
40
- /* @__PURE__ */ a(P, { children: [
41
- /* @__PURE__ */ e("div", { className: "sticky top-0 z-10 bg-white pb-2", children: /* @__PURE__ */ a("div", { className: "relative", children: [
42
- /* @__PURE__ */ e(F, { strokeWidth: 2, className: "absolute left-2 top-2.5 h-3.5 w-3.5 text-gray-400" }),
43
- /* @__PURE__ */ e(
44
- E,
45
- {
46
- placeholder: s("Search page types..."),
47
- className: "h-8 w-full rounded border pl-8 text-xs shadow-none",
48
- value: r,
49
- onChange: (t) => o(t.target.value),
50
- onKeyDown: (t) => t.stopPropagation()
51
- }
52
- )
53
- ] }) }),
54
- /* @__PURE__ */ e(w, { value: "all", children: s("All") }),
55
- !C(f(i, (t) => t.hasSlug && h(t))) && /* @__PURE__ */ a(k, { 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: s("Pages") }),
57
- S(
58
- [...f(i, (t) => t.hasSlug && h(t))].sort(
59
- (t, d) => c(t, "name", "").localeCompare(c(d, "name", ""))
60
- ),
61
- (t) => /* @__PURE__ */ e(w, { value: c(t, "key"), children: c(t, "name") }, c(t, "key"))
62
- )
63
- ] }),
64
- !C(f(i, (t) => !t.hasSlug && h(t))) && /* @__PURE__ */ a(k, { children: [
65
- /* @__PURE__ */ e("div", { className: "mt-2 border-t px-2 py-1.5 pt-2 text-xs font-semibold text-gray-500", children: s("Partials") }),
66
- S(
67
- [...f(i, (t) => !t.hasSlug && h(t))].sort(
68
- (t, d) => c(t, "name", "").localeCompare(c(d, "name", ""))
69
- ),
70
- (t) => /* @__PURE__ */ e(w, { value: c(t, "key"), children: c(t, "name") }, c(t, "key"))
71
- )
72
- ] }),
73
- C(f(i, h)) && /* @__PURE__ */ e("div", { className: "px-3 py-2 text-center text-sm text-gray-500", children: s("No matching page types found") })
74
- ] })
75
- ] });
76
- }, J = ({ search: n, setSearch: l }) => {
77
- const { t: s } = v();
78
- return /* @__PURE__ */ a("div", { className: "relative flex h-9 flex-1 items-center gap-2 rounded-md border px-2.5", children: [
79
- /* @__PURE__ */ e("label", { htmlFor: "page-search-input", className: "sr-only", children: s("Search Pages") }),
80
- /* @__PURE__ */ e(
81
- F,
82
- {
83
- className: `${n ? "fill-sky-50 text-sky-500" : ""} pointer-events-none h-4 w-4 text-muted-foreground`,
84
- "aria-hidden": "true"
85
- }
86
- ),
87
- /* @__PURE__ */ e(
88
- E,
89
- {
90
- id: "page-search-input",
91
- placeholder: s("Search pages"),
92
- value: n,
93
- onChange: (r) => l(r.target.value),
94
- className: "border-none px-1.5 shadow-none outline-none ring-0 transition-none focus:outline-none focus:ring-0 focus-visible:ring-0",
95
- autoComplete: "off",
96
- autoFocus: !0
97
- }
98
- )
99
- ] });
100
- }, Y = ({ pages: n }) => {
101
- const { t: l } = v(), { expandAll: s, collapseAll: r, expandedPages: o } = B(null);
102
- return /* @__PURE__ */ a("div", { className: "flex gap-1", children: [
103
- /* @__PURE__ */ a(b, { children: [
104
- /* @__PURE__ */ e(y, { asChild: !0, children: /* @__PURE__ */ e(m, { variant: "outline", size: "icon", onClick: () => s(n), className: "rounded p-1 text-gray-500", children: /* @__PURE__ */ e(T, {}) }) }),
105
- /* @__PURE__ */ e(N, { children: l("Expand All") })
106
- ] }),
107
- /* @__PURE__ */ a(b, { children: [
108
- /* @__PURE__ */ e(y, { asChild: !0, children: /* @__PURE__ */ e(
109
- m,
110
- {
111
- disabled: o.length === 0,
112
- variant: "outline",
113
- size: "icon",
114
- onClick: () => r(),
115
- className: "rounded p-1 text-gray-500",
116
- children: /* @__PURE__ */ e(_, {})
117
- }
118
- ) }),
119
- /* @__PURE__ */ e(N, { children: l("Collapse All") })
120
- ] })
121
- ] });
122
- }, Z = ({ languages: n, selectedLanguage: l, setSelectedLanguage: s }) => {
123
- const r = j();
124
- return /* @__PURE__ */ e("div", { className: "scrollbar-hide flex gap-1 overflow-x-auto pb-1", children: n.map((o) => /* @__PURE__ */ a(
125
- m,
126
- {
127
- variant: l === o ? "default" : "outline",
128
- size: "sm",
129
- className: `h-6 flex-shrink-0 whitespace-nowrap rounded px-3 text-xs font-normal ${l === o ? "bg-black text-white hover:bg-black" : "text-gray-500"}`,
130
- onClick: () => s(o.toLowerCase()),
131
- children: [
132
- o === r && /* @__PURE__ */ e(R, { size: 4, className: `p-0.5 ${l === r ? "fill-white" : "fill-black"}` }),
133
- G[o] || ""
134
- ]
135
- },
136
- o
137
- )) });
138
- }, A = () => {
139
- const { t: n } = v(), l = D();
140
- return /* @__PURE__ */ a(b, { children: [
141
- /* @__PURE__ */ e(y, { asChild: !0, children: /* @__PURE__ */ e(
142
- m,
143
- {
144
- size: "sm",
145
- variant: "ghost",
146
- onClick: () => l.invalidateQueries({ queryKey: [M.GET_WEBSITE_PAGES] }),
147
- className: "mt-1 h-6 w-6",
148
- children: /* @__PURE__ */ e(H, {})
149
- }
150
- ) }),
151
- /* @__PURE__ */ e(N, { side: "bottom", children: n("Refresh pages list") })
152
- ] });
153
- }, de = ({
154
- pages: n,
155
- search: l,
156
- setSearch: s,
157
- languages: r,
158
- onAddPage: o,
159
- selectedLanguage: i,
160
- setSelectedLanguage: p,
161
- selectedPageType: h,
162
- setSelectedPageType: u,
163
- showUntranslatedPages: t,
164
- setShowUntranslatedPages: d
165
- }) => {
166
- const { t: x } = v(), g = r.length > 1;
167
- return /* @__PURE__ */ a("div", { className: "space-y-3 border-b border-b-gray-200 px-4 pb-1", children: [
168
- /* @__PURE__ */ a("div", { className: "flex items-center gap-x-2", children: [
169
- /* @__PURE__ */ e(X, { selectedPageType: h, setSelectedPageType: u }),
170
- /* @__PURE__ */ e(J, { search: l, setSearch: s }),
171
- /* @__PURE__ */ e(Y, { pages: n }),
172
- /* @__PURE__ */ a(m, { variant: "default", onClick: o, className: "rounded px-3 font-normal", children: [
173
- /* @__PURE__ */ e(W, { strokeWidth: 2, className: "stroke-white stroke-[3]" }),
174
- /* @__PURE__ */ e("span", { className: "font-normal text-white", children: x("Add Page") })
175
- ] }),
176
- !g && /* @__PURE__ */ e(A, {})
177
- ] }),
178
- g ? /* @__PURE__ */ a("div", { className: "flex items-center justify-between gap-2", children: [
179
- /* @__PURE__ */ e(
180
- Z,
181
- {
182
- languages: r,
183
- selectedLanguage: i,
184
- setSelectedLanguage: (z) => {
185
- p(z), d(t && (r == null ? void 0 : r[0]) !== i);
186
- }
187
- }
188
- ),
189
- /* @__PURE__ */ a("div", { className: "flex items-center gap-x-2", children: [
190
- (r == null ? void 0 : r[0]) !== i && /* @__PURE__ */ a(b, { children: [
191
- /* @__PURE__ */ e(y, { asChild: !0, children: /* @__PURE__ */ e(
192
- m,
193
- {
194
- variant: "ghost",
195
- onClick: () => d(!t),
196
- className: "h-6 rounded px-3 py-1 text-xs font-normal",
197
- children: t ? /* @__PURE__ */ e(q, {}) : /* @__PURE__ */ e(K, {})
198
- }
199
- ) }),
200
- /* @__PURE__ */ e(N, { side: "bottom", children: x("Toggle Untranslated Pages") })
201
- ] }),
202
- /* @__PURE__ */ e(A, {})
203
- ] })
204
- ] }) : /* @__PURE__ */ e("div", { className: "flex items-center justify-between gap-2" })
205
- ] });
206
- };
207
- export {
208
- Z as LanguageSelector,
209
- de as default
210
- };