@chaibuilder/pages 0.15.0 → 0.15.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/dist/{2AITGKQY-CpxlNmec.cjs → 2AITGKQY-C2afI3G9.cjs} +1 -1
  2. package/dist/{2AITGKQY-gEvxLMa5.js → 2AITGKQY-CpTgZa1B.js} +2 -2
  3. package/dist/{NCMVHL6D-sV6MElOb.cjs → NCMVHL6D-BdBKMEGN.cjs} +1 -1
  4. package/dist/{NCMVHL6D-DpycZ17L.js → NCMVHL6D-fVqsZOVq.js} +2 -2
  5. package/dist/{ZDWCUMSJ-BbzwbqTE.js → ZDWCUMSJ-CTb4F48A.js} +1 -1
  6. package/dist/{ZDWCUMSJ-BPT9OZay.cjs → ZDWCUMSJ-DHGlUoWR.cjs} +1 -1
  7. package/dist/{add-new-language-page-B4_z4O8a.cjs → add-new-language-page-CY2hL7A-.cjs} +1 -1
  8. package/dist/{add-new-language-page-C8LIaHl6.js → add-new-language-page-DY0789ha.js} +2 -2
  9. package/dist/{add-new-page-JY6dRnC4.js → add-new-page-C6fGkJF9.js} +1 -1
  10. package/dist/{add-new-page-CQRr6Z8g.cjs → add-new-page-DnVeU4g6.cjs} +1 -1
  11. package/dist/{delete-page-z88W-Ikh.cjs → delete-page-DZi2DCAb.cjs} +1 -1
  12. package/dist/{delete-page-Dfa2vyQB.js → delete-page-hLDHKzbl.js} +1 -1
  13. package/dist/digital-asset-manager-Cj5r9niq.cjs +1 -0
  14. package/dist/digital-asset-manager-CpoNKOFK.js +1001 -0
  15. package/dist/{duplicate-page-Welcro7Y.cjs → duplicate-page-CTH0REkv.cjs} +1 -1
  16. package/dist/{duplicate-page-B0urG1pP.js → duplicate-page-sdO4hRfo.js} +14 -14
  17. package/dist/{dynamic-page-selector-CyhZ0SRO.js → dynamic-page-selector-EfxbLRp-.js} +1 -1
  18. package/dist/{dynamic-page-selector-Dn_j_r-h.cjs → dynamic-page-selector-Ki3lEtRJ.cjs} +1 -1
  19. package/dist/image-editor-CRJ0cNde.cjs +1 -0
  20. package/dist/image-editor-DR1FYokM.js +111 -0
  21. package/dist/{index-BSEA_u0X.js → index-CdUDr4JM.js} +1446 -1368
  22. package/dist/index-vjYir4bk.cjs +5 -0
  23. package/dist/index.cjs +1 -1
  24. package/dist/index.js +10 -10
  25. package/dist/{json-diff-viewer-DVlb4YWD.js → json-diff-viewer-BQSgrzoZ.js} +1 -1
  26. package/dist/{json-diff-viewer-BIJ4iNWb.cjs → json-diff-viewer-DthVeQzc.cjs} +1 -1
  27. package/dist/{lang-panel-D0IN38gF.js → lang-panel-DJGvZmRK.js} +29 -29
  28. package/dist/{lang-panel-l6Teik-4.cjs → lang-panel-DTDqVZGv.cjs} +1 -1
  29. package/dist/{mark-as-template-DBPJ1gIK.cjs → mark-as-template-BNbkAkrD.cjs} +1 -1
  30. package/dist/{mark-as-template-B22EANHN.js → mark-as-template-C3669ENB.js} +1 -1
  31. package/dist/{no-language-page-content-DNNu8wd0.js → no-language-page-content-DMdFjwWT.js} +1 -1
  32. package/dist/{no-language-page-content-BUHXqSKG.cjs → no-language-page-content-DY-A9YbI.cjs} +1 -1
  33. package/dist/{page-creator-BPgx7zdJ.js → page-creator-B_X6PI1J.js} +2 -2
  34. package/dist/{page-creator-DbN3Nvq6.cjs → page-creator-BcoyQ5mT.cjs} +1 -1
  35. package/dist/{page-lock-request-BFkpw5VN.cjs → page-lock-request-Cl0GyiJp.cjs} +1 -1
  36. package/dist/{page-lock-request-Br9S1AsA.js → page-lock-request-DJVlDGsX.js} +10 -10
  37. package/dist/{page-locked-by-dialog-2h8cv1tO.cjs → page-locked-by-dialog-CZvpeWVu.cjs} +1 -1
  38. package/dist/{page-locked-by-dialog-DyLcMu33.js → page-locked-by-dialog-DY_jVajL.js} +1 -1
  39. package/dist/{page-manager-new-B2oBm4pU.js → page-manager-new-BKr1R3Yu.js} +37 -37
  40. package/dist/{page-manager-new-CAj6WV-C.cjs → page-manager-new-v2nHss3Q.cjs} +1 -1
  41. package/dist/{page-manager-search-and-filter-CWMXLTqE.cjs → page-manager-search-and-filter-CibEmd6Z.cjs} +1 -1
  42. package/dist/{page-manager-search-and-filter-WQYVXUAt.js → page-manager-search-and-filter-DLrJ5bRM.js} +1 -1
  43. package/dist/{page-revisions-content-AMH8AxBU.cjs → page-revisions-content-Bv1b1HsS.cjs} +1 -1
  44. package/dist/{page-revisions-content-DM-ngq3R.js → page-revisions-content-C4hAdUVX.js} +17 -17
  45. package/dist/{publish-pages-content-Dast4sG6.js → publish-pages-content-B-8X8FzF.js} +2 -2
  46. package/dist/{publish-pages-content-Dkv0Lok8.cjs → publish-pages-content-Krawy2bg.cjs} +1 -1
  47. package/dist/{save-to-lib-B5k0MVbW.js → save-to-lib-BV_uNHn3.js} +12 -12
  48. package/dist/{save-to-lib-DWtmtrUj.cjs → save-to-lib-CiX1h4Po.cjs} +1 -1
  49. package/dist/{seo-panel-D75jQH_j.js → seo-panel-BHqhAOiz.js} +34 -34
  50. package/dist/{seo-panel-dBvEEfi9.cjs → seo-panel-CpjeH5Yl.cjs} +1 -1
  51. package/dist/shared-json-ld-BfkvfAZY.js +650 -0
  52. package/dist/shared-json-ld-C-fV8erH.cjs +1 -0
  53. package/dist/{slug-input-BEegJ8bv.js → slug-input-Dz9A1ksl.js} +1 -1
  54. package/dist/{slug-input-BITq28nI.cjs → slug-input-ssMiXYTG.cjs} +1 -1
  55. package/dist/{theme-panel-footer-zLXS6SHh.js → theme-panel-footer-DZSU9bNX.js} +1 -1
  56. package/dist/{theme-panel-footer-DcASH9l1.cjs → theme-panel-footer-Rmw520a9.cjs} +1 -1
  57. package/dist/{unmark-as-template-DXFRY_pc.js → unmark-as-template-D8o31xMH.js} +1 -1
  58. package/dist/{unmark-as-template-ChmjL4-w.cjs → unmark-as-template-D_Td5Aeb.cjs} +1 -1
  59. package/dist/{unpublish-page-BxN0deJK.cjs → unpublish-page-Bca-dVic.cjs} +1 -1
  60. package/dist/{unpublish-page-DMteaCpR.js → unpublish-page-D9XisIu8.js} +1 -1
  61. package/dist/{web-preview-DM11qhOe.cjs → web-preview-BddtAY2w.cjs} +1 -1
  62. package/dist/{web-preview-BDTdFQ2h.js → web-preview-Dn1aCs5v.js} +1 -1
  63. package/package.json +1 -1
  64. package/dist/digital-asset-manager-Zh-mlMF5.cjs +0 -1
  65. package/dist/digital-asset-manager-hqMwBWhb.js +0 -976
  66. package/dist/image-editor-BWLJT1mr.cjs +0 -1
  67. package/dist/image-editor-CzFST20j.js +0 -104
  68. package/dist/index-MlpQJHWW.cjs +0 -5
  69. package/dist/shared-json-ld-BvWyXBz_.cjs +0 -1
  70. package/dist/shared-json-ld-ZtwsYt9H.js +0 -337
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),p=require("./index-MlpQJHWW.cjs"),S=require("@tanstack/react-query"),N=require("sonner"),a=require("@chaibuilder/sdk/ui"),v=require("lodash-es"),E=require("lucide-react"),g=require("react"),q=require("./slug-input-BITq28nI.cjs"),C=()=>{const t=p.useApiUrl(),r=S.useQueryClient(),h=p.useFetch();return S.useMutation({mutationFn:async({pageId:c,name:u,slug:o})=>{const s={pageId:c,name:u};return o&&(s.slug=o),await h(t,{action:"DUPLICATE_PAGE",data:s})},onSuccess:()=>{r.invalidateQueries({queryKey:[p.ACTIONS.GET_WEBSITE_PAGES]}),N.toast.success("Page duplicated successfully")},onError:c=>{N.toast.error("Failed to duplicate page",{description:c.message||"An error occurred while duplicating the page"})}})},A=({page:t,onClose:r,closePanel:h=()=>{}})=>{const{mutate:c,isPending:u}=C(),[o,s]=g.useState(null),[d,P]=g.useState(`${t.name} (Copy)`),D=p.useChangePage(),i=v.isEmpty(t.slug),[m,b]=g.useState(i?"":`${t.slug.split("/").pop()}-copy`),j=i?"":v.initial(t.slug.split("/")).join("/"),[f,x]=g.useState(!1),I=n=>{if(n.preventDefault(),!d.trim()){s("Name is required");return}if(!i&&!m.trim()){s("Slug is required");return}s(null),x(!0);const y={pageId:t.id,name:d};i||(y.slug=`${j}/${m}`),c(y,{onSuccess:l=>{x(!1),r(),D(l.id,h)},onError:l=>{x(!1),l.code==="SLUG_EXISTS"?s("A page with this slug already exists. Please choose a different slug."):l.code==="INVALID_SLUG"?s("The slug format is invalid. Please use only lowercase letters, numbers, and hyphens."):l.code==="PERMISSION_DENIED"?s("You don't have permission to duplicate this page."):s(l.message||"Failed to duplicate page. Please try again later.")}})};return e.jsx(a.Dialog,{open:!!t,onOpenChange:r,children:e.jsxs(a.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{children:"Duplicate Page"}),e.jsx(a.DialogDescription,{children:"Create a copy of the page with a new name and slug"})]}),e.jsxs("div",{className:"mb-4 rounded-md bg-gray-50 p-3",children:[e.jsx("h3",{className:"mb-1 text-sm font-medium",children:"Duplicating:"}),e.jsxs("div",{className:"flex flex-col gap-1 text-sm text-gray-700",children:[e.jsxs("div",{children:[e.jsx("span",{className:"font-medium",children:"Name:"})," ",t.name]}),!i&&e.jsxs("div",{children:[e.jsx("span",{className:"font-medium",children:"Slug:"})," ",t.slug]}),e.jsxs("div",{children:[e.jsx("span",{className:"font-medium",children:"Type:"})," ",t.pageType]})]})]}),e.jsxs("form",{onSubmit:I,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(a.Label,{htmlFor:"name",className:"text-sm",children:"Name"}),e.jsx(a.Input,{id:"name",value:d,onChange:n=>P(n.target.value),required:!0})]}),!i&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(a.Label,{htmlFor:"slug",className:"text-sm",children:"Slug"}),e.jsx(q.SlugInput,{value:m,onChange:n=>b(n),parentSlug:j,onValidationChange:n=>{s(n?null:"Invalid slug")}})]}),o&&e.jsxs(a.Alert,{variant:"destructive",className:"py-2",children:[e.jsx(E.AlertCircle,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:o})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(a.Button,{type:"button",variant:"outline",onClick:r,disabled:u,children:"Cancel"}),e.jsx(a.Button,{type:"submit",disabled:!d.trim()||!i&&!m.trim()||u||f,children:u||f?"Duplicating...":"Duplicate"})]})]})]})})};exports.default=A;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),p=require("./index-vjYir4bk.cjs"),S=require("@tanstack/react-query"),N=require("sonner"),a=require("@chaibuilder/sdk/ui"),v=require("lodash-es"),E=require("lucide-react"),g=require("react"),q=require("./slug-input-ssMiXYTG.cjs"),C=()=>{const t=p.useApiUrl(),r=S.useQueryClient(),h=p.useFetch();return S.useMutation({mutationFn:async({pageId:c,name:u,slug:o})=>{const s={pageId:c,name:u};return o&&(s.slug=o),await h(t,{action:"DUPLICATE_PAGE",data:s})},onSuccess:()=>{r.invalidateQueries({queryKey:[p.ACTIONS.GET_WEBSITE_PAGES]}),N.toast.success("Page duplicated successfully")},onError:c=>{N.toast.error("Failed to duplicate page",{description:c.message||"An error occurred while duplicating the page"})}})},A=({page:t,onClose:r,closePanel:h=()=>{}})=>{const{mutate:c,isPending:u}=C(),[o,s]=g.useState(null),[d,P]=g.useState(`${t.name} (Copy)`),D=p.useChangePage(),i=v.isEmpty(t.slug),[m,b]=g.useState(i?"":`${t.slug.split("/").pop()}-copy`),j=i?"":v.initial(t.slug.split("/")).join("/"),[f,x]=g.useState(!1),I=n=>{if(n.preventDefault(),!d.trim()){s("Name is required");return}if(!i&&!m.trim()){s("Slug is required");return}s(null),x(!0);const y={pageId:t.id,name:d};i||(y.slug=`${j}/${m}`),c(y,{onSuccess:l=>{x(!1),r(),D(l.id,h)},onError:l=>{x(!1),l.code==="SLUG_EXISTS"?s("A page with this slug already exists. Please choose a different slug."):l.code==="INVALID_SLUG"?s("The slug format is invalid. Please use only lowercase letters, numbers, and hyphens."):l.code==="PERMISSION_DENIED"?s("You don't have permission to duplicate this page."):s(l.message||"Failed to duplicate page. Please try again later.")}})};return e.jsx(a.Dialog,{open:!!t,onOpenChange:r,children:e.jsxs(a.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{children:"Duplicate Page"}),e.jsx(a.DialogDescription,{children:"Create a copy of the page with a new name and slug"})]}),e.jsxs("div",{className:"mb-4 rounded-md bg-gray-50 p-3",children:[e.jsx("h3",{className:"mb-1 text-sm font-medium",children:"Duplicating:"}),e.jsxs("div",{className:"flex flex-col gap-1 text-sm text-gray-700",children:[e.jsxs("div",{children:[e.jsx("span",{className:"font-medium",children:"Name:"})," ",t.name]}),!i&&e.jsxs("div",{children:[e.jsx("span",{className:"font-medium",children:"Slug:"})," ",t.slug]}),e.jsxs("div",{children:[e.jsx("span",{className:"font-medium",children:"Type:"})," ",t.pageType]})]})]}),e.jsxs("form",{onSubmit:I,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(a.Label,{htmlFor:"name",className:"text-sm",children:"Name"}),e.jsx(a.Input,{id:"name",value:d,onChange:n=>P(n.target.value),required:!0})]}),!i&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(a.Label,{htmlFor:"slug",className:"text-sm",children:"Slug"}),e.jsx(q.SlugInput,{value:m,onChange:n=>b(n),parentSlug:j,onValidationChange:n=>{s(n?null:"Invalid slug")}})]}),o&&e.jsxs(a.Alert,{variant:"destructive",className:"py-2",children:[e.jsx(E.AlertCircle,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:o})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(a.Button,{type:"button",variant:"outline",onClick:r,disabled:u,children:"Cancel"}),e.jsx(a.Button,{type:"submit",disabled:!d.trim()||!i&&!m.trim()||u||f,children:u||f?"Duplicating...":"Duplicate"})]})]})]})})};exports.default=A;
@@ -1,13 +1,13 @@
1
1
  import { jsx as e, jsxs as s } from "react/jsx-runtime";
2
- import { aj as b, ak as C, A, ar as T } from "./index-BSEA_u0X.js";
2
+ import { al as b, am as C, A, an as T } from "./index-CdUDr4JM.js";
3
3
  import { useQueryClient as w, useMutation as F } from "@tanstack/react-query";
4
4
  import { toast as S } from "sonner";
5
- import { Dialog as _, DialogContent as j, DialogHeader as q, DialogTitle as G, DialogDescription as L, Label as v, Input as U, Alert as $, Button as D } from "@chaibuilder/sdk/ui";
6
- import { isEmpty as O, initial as k } from "lodash-es";
7
- import { AlertCircle as B } from "lucide-react";
5
+ import { Dialog as _, DialogContent as q, DialogHeader as G, DialogTitle as L, DialogDescription as U, Label as v, Input as j, Alert as $, Button as D } from "@chaibuilder/sdk/ui";
6
+ import { isEmpty as O, initial as B } from "lodash-es";
7
+ import { AlertCircle as M } from "lucide-react";
8
8
  import { useState as p } from "react";
9
- import { S as M } from "./slug-input-BEegJ8bv.js";
10
- const Q = () => {
9
+ import { S as Q } from "./slug-input-Dz9A1ksl.js";
10
+ const V = () => {
11
11
  const t = b(), r = w(), g = C();
12
12
  return F({
13
13
  mutationFn: async ({ pageId: c, name: o, slug: u }) => {
@@ -37,7 +37,7 @@ const Q = () => {
37
37
  closePanel: g = () => {
38
38
  }
39
39
  }) => {
40
- const { mutate: c, isPending: o } = Q(), [u, a] = p(null), [m, P] = p(`${t.name} (Copy)`), x = T(), i = O(t.slug), [d, I] = p(i ? "" : `${t.slug.split("/").pop()}-copy`), f = i ? "" : k(t.slug.split("/")).join("/"), [y, h] = p(!1), E = (l) => {
40
+ const { mutate: c, isPending: o } = V(), [u, a] = p(null), [m, P] = p(`${t.name} (Copy)`), x = T(), i = O(t.slug), [d, I] = p(i ? "" : `${t.slug.split("/").pop()}-copy`), f = i ? "" : B(t.slug.split("/")).join("/"), [y, h] = p(!1), E = (l) => {
41
41
  if (l.preventDefault(), !m.trim()) {
42
42
  a("Name is required");
43
43
  return;
@@ -60,10 +60,10 @@ const Q = () => {
60
60
  }
61
61
  });
62
62
  };
63
- return /* @__PURE__ */ e(_, { open: !!t, onOpenChange: r, children: /* @__PURE__ */ s(j, { className: "sm:max-w-[425px]", children: [
64
- /* @__PURE__ */ s(q, { children: [
65
- /* @__PURE__ */ e(G, { children: "Duplicate Page" }),
66
- /* @__PURE__ */ e(L, { children: "Create a copy of the page with a new name and slug" })
63
+ return /* @__PURE__ */ e(_, { open: !!t, onOpenChange: r, children: /* @__PURE__ */ s(q, { className: "sm:max-w-[425px]", children: [
64
+ /* @__PURE__ */ s(G, { children: [
65
+ /* @__PURE__ */ e(L, { children: "Duplicate Page" }),
66
+ /* @__PURE__ */ e(U, { children: "Create a copy of the page with a new name and slug" })
67
67
  ] }),
68
68
  /* @__PURE__ */ s("div", { className: "mb-4 rounded-md bg-gray-50 p-3", children: [
69
69
  /* @__PURE__ */ e("h3", { className: "mb-1 text-sm font-medium", children: "Duplicating:" }),
@@ -88,12 +88,12 @@ const Q = () => {
88
88
  /* @__PURE__ */ s("form", { onSubmit: E, className: "space-y-4", children: [
89
89
  /* @__PURE__ */ s("div", { className: "space-y-2", children: [
90
90
  /* @__PURE__ */ e(v, { htmlFor: "name", className: "text-sm", children: "Name" }),
91
- /* @__PURE__ */ e(U, { id: "name", value: m, onChange: (l) => P(l.target.value), required: !0 })
91
+ /* @__PURE__ */ e(j, { id: "name", value: m, onChange: (l) => P(l.target.value), required: !0 })
92
92
  ] }),
93
93
  !i && /* @__PURE__ */ s("div", { className: "space-y-2", children: [
94
94
  /* @__PURE__ */ e(v, { htmlFor: "slug", className: "text-sm", children: "Slug" }),
95
95
  /* @__PURE__ */ e(
96
- M,
96
+ Q,
97
97
  {
98
98
  value: d,
99
99
  onChange: (l) => I(l),
@@ -105,7 +105,7 @@ const Q = () => {
105
105
  )
106
106
  ] }),
107
107
  u && /* @__PURE__ */ s($, { variant: "destructive", className: "py-2", children: [
108
- /* @__PURE__ */ e(B, { className: "h-4 w-4" }),
108
+ /* @__PURE__ */ e(M, { className: "h-4 w-4" }),
109
109
  /* @__PURE__ */ e("span", { className: "text-sm", children: u })
110
110
  ] }),
111
111
  /* @__PURE__ */ s("div", { className: "flex justify-end gap-2", children: [
@@ -4,7 +4,7 @@ import { DropdownMenu as h, DropdownMenuTrigger as p, Button as m, DropdownMenuC
4
4
  import { get as v } from "lodash-es";
5
5
  import { ChevronDown as w } from "lucide-react";
6
6
  import { useRef as b, useEffect as N } from "react";
7
- import { k as y } from "./index-BSEA_u0X.js";
7
+ import { k as y } from "./index-CdUDr4JM.js";
8
8
  const D = ({
9
9
  isDefaultLang: e,
10
10
  searchQuery: l,
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),x=require("@chaibuilder/sdk"),a=require("@chaibuilder/sdk/ui"),h=require("lodash-es"),p=require("lucide-react"),d=require("react"),g=require("./index-MlpQJHWW.cjs"),f=({isDefaultLang:r,searchQuery:l,setSearchQuery:c})=>e.jsx(a.Input,{type:"text",autoFocus:!0,value:r?l:"",onChange:t=>c(t.target.value),placeholder:r?"Search pages...":"To search select default language",disabled:!r,onKeyDown:t=>t.stopPropagation()}),m=({dynamicPage:r,setDynamicPage:l,searchQuery:c,setSearchQuery:t,dynamicPages:n})=>{const{selectedLang:o,fallbackLang:i}=x.useLanguages(),u=(o==null?void 0:o.length)===0;return e.jsxs(a.DropdownMenu,{children:[e.jsx(a.DropdownMenuTrigger,{asChild:!0,children:e.jsxs(a.Button,{variant:"ghost",className:"w-max focus:outline-none focus:ring-0 border-[0px] rounded-md py-1 text-sm h-max border border-gray-200 hover:bg-gray-100 pl-4",children:[r?h.get(r,"name"):"Select Page",e.jsx(p.ChevronDown,{className:"ml-2 h-4 w-4"})]})}),e.jsxs(a.DropdownMenuContent,{className:"w-96 divide-y shadow-xl p-0 max-h-[75vh]",children:[e.jsx("div",{className:"p-1.5 bg-gray-50/30",children:e.jsx(f,{isDefaultLang:u,searchQuery:c,setSearchQuery:t})}),(n==null?void 0:n.length)===0?e.jsx("div",{className:"h-24 text-xs flex items-center justify-center",children:"No pages found"}):n==null?void 0:n.map(s=>e.jsx(a.DropdownMenuItem,{onClick:()=>l(s),disabled:u?i!==s.lang:o!==s.lang,className:`flex flex-col justify-start cursor-pointer overflow-x-auto whitespace-nowrap no-scrollbar ${s.id===(r==null?void 0:r.id)?"bg-blue-50":"hover:bg-gray-50"}`,children:e.jsx("div",{className:"w-full text-xs whitespace-nowrap px-2 py-[2px]",children:e.jsxs("div",{className:"flex items-center gap-x-2",children:[e.jsx("span",{className:"font-medium",children:s.name}),e.jsx("span",{className:"font-mono font-medium text-gray-500 text-xs rounded-full px-2 py-[1px] border border-gray-300 truncate",children:s.slug})]})})},s.id))]})]})},j=()=>{const{dynamicPage:r,dynamicPages:l,allLangPages:c,selectedLang:t,searchQuery:n,updateDynamicPage:o,updateSearchQuery:i,onChangeLanguage:u}=g.useDynamicPageSelector(),s=d.useRef(void 0);return d.useEffect(()=>{s.current!==t&&r&&(u(),s.current=t)},[t,l]),e.jsx("div",{className:"relative",children:e.jsx(m,{dynamicPage:r,setDynamicPage:o,searchQuery:n,setSearchQuery:i,dynamicPages:c})})};exports.default=j;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),x=require("@chaibuilder/sdk"),a=require("@chaibuilder/sdk/ui"),h=require("lodash-es"),p=require("lucide-react"),d=require("react"),g=require("./index-vjYir4bk.cjs"),f=({isDefaultLang:r,searchQuery:l,setSearchQuery:c})=>e.jsx(a.Input,{type:"text",autoFocus:!0,value:r?l:"",onChange:t=>c(t.target.value),placeholder:r?"Search pages...":"To search select default language",disabled:!r,onKeyDown:t=>t.stopPropagation()}),m=({dynamicPage:r,setDynamicPage:l,searchQuery:c,setSearchQuery:t,dynamicPages:n})=>{const{selectedLang:o,fallbackLang:i}=x.useLanguages(),u=(o==null?void 0:o.length)===0;return e.jsxs(a.DropdownMenu,{children:[e.jsx(a.DropdownMenuTrigger,{asChild:!0,children:e.jsxs(a.Button,{variant:"ghost",className:"w-max focus:outline-none focus:ring-0 border-[0px] rounded-md py-1 text-sm h-max border border-gray-200 hover:bg-gray-100 pl-4",children:[r?h.get(r,"name"):"Select Page",e.jsx(p.ChevronDown,{className:"ml-2 h-4 w-4"})]})}),e.jsxs(a.DropdownMenuContent,{className:"w-96 divide-y shadow-xl p-0 max-h-[75vh]",children:[e.jsx("div",{className:"p-1.5 bg-gray-50/30",children:e.jsx(f,{isDefaultLang:u,searchQuery:c,setSearchQuery:t})}),(n==null?void 0:n.length)===0?e.jsx("div",{className:"h-24 text-xs flex items-center justify-center",children:"No pages found"}):n==null?void 0:n.map(s=>e.jsx(a.DropdownMenuItem,{onClick:()=>l(s),disabled:u?i!==s.lang:o!==s.lang,className:`flex flex-col justify-start cursor-pointer overflow-x-auto whitespace-nowrap no-scrollbar ${s.id===(r==null?void 0:r.id)?"bg-blue-50":"hover:bg-gray-50"}`,children:e.jsx("div",{className:"w-full text-xs whitespace-nowrap px-2 py-[2px]",children:e.jsxs("div",{className:"flex items-center gap-x-2",children:[e.jsx("span",{className:"font-medium",children:s.name}),e.jsx("span",{className:"font-mono font-medium text-gray-500 text-xs rounded-full px-2 py-[1px] border border-gray-300 truncate",children:s.slug})]})})},s.id))]})]})},j=()=>{const{dynamicPage:r,dynamicPages:l,allLangPages:c,selectedLang:t,searchQuery:n,updateDynamicPage:o,updateSearchQuery:i,onChangeLanguage:u}=g.useDynamicPageSelector(),s=d.useRef(void 0);return d.useEffect(()=>{s.current!==t&&r&&(u(),s.current=t)},[t,l]),e.jsx("div",{className:"relative",children:e.jsx(m,{dynamicPage:r,setDynamicPage:o,searchQuery:n,setSearchQuery:i,dynamicPages:c})})};exports.default=j;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),I=require("@chaibuilder/sdk/ui"),C=require("lodash-es"),g=require("lucide-react"),o=require("react"),E=require("react-filerobot-image-editor"),b=o.memo(({imageUrl:n,onSave:d,onClose:i,defaultSavedImageName:h,isEditing:u=!1})=>{const[c,m]=o.useState(!0),[x,y]=o.useState(!1);o.useEffect(()=>{const e=new Image;return e.src=n,e.onload=()=>y(!0),()=>{e.onload=null}},[n]),o.useEffect(()=>{const e=t=>{t.key==="Escape"&&c&&(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation())};return document.addEventListener("keydown",e,!0),()=>{document.removeEventListener("keydown",e,!0)}},[]);const f=o.useMemo(()=>C.debounce(async(e,t=!1)=>{const a=e.imageBase64;await d(a,t),m(!1)},300),[d]),s=o.useCallback((e,t=!1)=>{f(e,t)},[f]),p=o.useCallback(()=>{m(!1),i()},[i]),r=o.useMemo(()=>({tabsIds:["Adjust","Annotate","Watermark","Finetune","Resize","Filters"],toolsIds:["Rotate"],defaultTabId:"Adjust",defaultToolId:"Rotate"}),[]),v=o.useMemo(()=>({colors:{primary:"#000000",secondary:"#000000",tertiary:"#000000"}}),[]),w=o.useMemo(()=>u?[{label:"Update this file",onClick:(e,t)=>t((...a)=>{s(a[0],!1)}),icon:g.Save},{label:"Save as new file",onClick:(e,t)=>t((...a)=>{s(a[0],!0)}),icon:g.Copy}]:[],[u,s]);return l.jsx(I.Dialog,{open:!0,onOpenChange:e=>!e&&p(),children:l.jsx(I.DialogContent,{id:"chai-image-editor-container",className:"max-w-[1232px] max-h-[1232px] w-[80vw] h-[80vh] space-y-4 flex flex-col p-0",children:c&&x&&l.jsx(E,{theme:v,source:n,onSave:s,onClose:p,Text:{text:"Add text here"},Rotate:{angle:90,componentType:"slider"},tabsIds:r.tabsIds,defaultTabId:r.defaultTabId,defaultToolId:r.defaultToolId,savingPixelRatio:2,previewPixelRatio:1,defaultSavedImageName:h,moreSaveOptions:w,useZoomPresetsMenu:!0,closeAfterSave:!0})})})});b.displayName="ImageEditor";exports.default=b;
@@ -0,0 +1,111 @@
1
+ import { jsx as d } from "react/jsx-runtime";
2
+ import { Dialog as C, DialogContent as E } from "@chaibuilder/sdk/ui";
3
+ import { debounce as T } from "lodash-es";
4
+ import { Save as k, Copy as S } from "lucide-react";
5
+ import { memo as R, useState as I, useEffect as g, useMemo as s, useCallback as h } from "react";
6
+ import A from "react-filerobot-image-editor";
7
+ const O = R(
8
+ ({ imageUrl: n, onSave: i, onClose: l, defaultSavedImageName: b, isEditing: m = !1 }) => {
9
+ const [c, u] = I(!0), [x, v] = I(!1);
10
+ g(() => {
11
+ const e = new Image();
12
+ return e.src = n, e.onload = () => v(!0), () => {
13
+ e.onload = null;
14
+ };
15
+ }, [n]), g(() => {
16
+ const e = (t) => {
17
+ t.key === "Escape" && c && (t.preventDefault(), t.stopPropagation(), t.stopImmediatePropagation());
18
+ };
19
+ return document.addEventListener("keydown", e, !0), () => {
20
+ document.removeEventListener("keydown", e, !0);
21
+ };
22
+ }, []);
23
+ const f = s(
24
+ () => T(async (e, t = !1) => {
25
+ const o = e.imageBase64;
26
+ await i(o, t), u(!1);
27
+ }, 300),
28
+ [i]
29
+ ), a = h(
30
+ (e, t = !1) => {
31
+ f(e, t);
32
+ },
33
+ [f]
34
+ ), p = h(() => {
35
+ u(!1), l();
36
+ }, [l]), r = s(
37
+ () => ({
38
+ tabsIds: [
39
+ "Adjust",
40
+ "Annotate",
41
+ "Watermark",
42
+ "Finetune",
43
+ "Resize",
44
+ "Filters"
45
+ ],
46
+ toolsIds: ["Rotate"],
47
+ defaultTabId: "Adjust",
48
+ defaultToolId: "Rotate"
49
+ }),
50
+ []
51
+ ), y = s(
52
+ () => ({
53
+ colors: {
54
+ primary: "#000000",
55
+ secondary: "#000000",
56
+ tertiary: "#000000"
57
+ }
58
+ }),
59
+ []
60
+ ), w = s(
61
+ () => m ? [
62
+ {
63
+ label: "Update this file",
64
+ onClick: (e, t) => t((...o) => {
65
+ a(o[0], !1);
66
+ }),
67
+ icon: k
68
+ },
69
+ {
70
+ label: "Save as new file",
71
+ onClick: (e, t) => t((...o) => {
72
+ a(o[0], !0);
73
+ }),
74
+ icon: S
75
+ }
76
+ ] : [],
77
+ [m, a]
78
+ );
79
+ return /* @__PURE__ */ d(C, { open: !0, onOpenChange: (e) => !e && p(), children: /* @__PURE__ */ d(
80
+ E,
81
+ {
82
+ id: "chai-image-editor-container",
83
+ className: "max-w-[1232px] max-h-[1232px] w-[80vw] h-[80vh] space-y-4 flex flex-col p-0",
84
+ children: c && x && /* @__PURE__ */ d(
85
+ A,
86
+ {
87
+ theme: y,
88
+ source: n,
89
+ onSave: a,
90
+ onClose: p,
91
+ Text: { text: "Add text here" },
92
+ Rotate: { angle: 90, componentType: "slider" },
93
+ tabsIds: r.tabsIds,
94
+ defaultTabId: r.defaultTabId,
95
+ defaultToolId: r.defaultToolId,
96
+ savingPixelRatio: 2,
97
+ previewPixelRatio: 1,
98
+ defaultSavedImageName: b,
99
+ moreSaveOptions: w,
100
+ useZoomPresetsMenu: !0,
101
+ closeAfterSave: !0
102
+ }
103
+ )
104
+ }
105
+ ) });
106
+ }
107
+ );
108
+ O.displayName = "ImageEditor";
109
+ export {
110
+ O as default
111
+ };