@powerhousedao/connect 2.5.0-dev.20 → 2.5.0-dev.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{app-DA0JMREv.js → app-BcXkGQiq.js} +7 -7
- package/dist/assets/{app-DA0JMREv.js.map → app-BcXkGQiq.js.map} +1 -1
- package/dist/assets/{ccip-DetCMEhN.js → ccip-CuEI6ate.js} +2 -2
- package/dist/assets/{ccip-DetCMEhN.js.map → ccip-CuEI6ate.js.map} +1 -1
- package/dist/assets/{content-YVQofdmK.js → content-d2haQv36.js} +2 -2
- package/dist/assets/{content-YVQofdmK.js.map → content-d2haQv36.js.map} +1 -1
- package/dist/assets/{cookie-banner-D8YsZPCa.js → cookie-banner-DR0V1IJG.js} +2 -2
- package/dist/assets/{cookie-banner-D8YsZPCa.js.map → cookie-banner-DR0V1IJG.js.map} +1 -1
- package/dist/assets/{index-aBSTHzHo.js → index-3nfLp-u3.js} +2 -2
- package/dist/assets/{index-aBSTHzHo.js.map → index-3nfLp-u3.js.map} +1 -1
- package/dist/assets/{index-gSzx5Vm4.js → index-C-s-fxTL.js} +2 -2
- package/dist/assets/{index-gSzx5Vm4.js.map → index-C-s-fxTL.js.map} +1 -1
- package/dist/assets/{index-BaVUqXqC.js → index-CRQWfxlS.js} +2 -2
- package/dist/assets/{index-BaVUqXqC.js.map → index-CRQWfxlS.js.map} +1 -1
- package/dist/assets/{index-BMorSdw9.js → index-CYlcJ2ja.js} +5 -5
- package/dist/assets/{index-BMorSdw9.js.map → index-CYlcJ2ja.js.map} +1 -1
- package/dist/assets/{index-D8qNWlx1.js → index-CwT7v3QF.js} +2 -2
- package/dist/assets/{index-D8qNWlx1.js.map → index-CwT7v3QF.js.map} +1 -1
- package/dist/assets/{isAddressEqual-CP3UX6_a.js → isAddressEqual-DREghARX.js} +2 -2
- package/dist/assets/{isAddressEqual-CP3UX6_a.js.map → isAddressEqual-DREghARX.js.map} +1 -1
- package/dist/assets/{main.CYpCwhXq.js → main.B6BOUKAI.js} +3 -3
- package/dist/assets/{main.CYpCwhXq.js.map → main.B6BOUKAI.js.map} +1 -1
- package/dist/assets/{nodefs-DwIIa0lK.js → nodefs-CeZROlM7.js} +2 -2
- package/dist/assets/{nodefs-DwIIa0lK.js.map → nodefs-CeZROlM7.js.map} +1 -1
- package/dist/assets/{opfs-ahp-C4fR-rLJ.js → opfs-ahp-DsHAic0w.js} +2 -2
- package/dist/assets/{opfs-ahp-C4fR-rLJ.js.map → opfs-ahp-DsHAic0w.js.map} +1 -1
- package/dist/assets/{reactor-analytics-CPu6wNgL.js → reactor-analytics-CrgBcpoI.js} +3 -3
- package/dist/assets/{reactor-analytics-CPu6wNgL.js.map → reactor-analytics-CrgBcpoI.js.map} +1 -1
- package/dist/assets/{router-CRSqzmeU.js → router-DkUmzbHQ.js} +4 -4
- package/dist/assets/{router-CRSqzmeU.js.map → router-DkUmzbHQ.js.map} +1 -1
- package/dist/index.html +1 -1
- package/dist/vite-envs.sh +1 -1
- package/package.json +9 -9
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsxs as l,jsx as e}from"react/jsx-runtime";import{m as y,u as N,a as v,b as C,c as B,T as j}from"./app-
|
|
2
|
-
//# sourceMappingURL=cookie-banner-
|
|
1
|
+
import{jsxs as l,jsx as e}from"react/jsx-runtime";import{m as y,u as N,a as v,b as C,c as B,T as j}from"./app-BcXkGQiq.js";import{useState as w}from"react";import{B as b}from"./index-CYlcJ2ja.js";import"./main.B6BOUKAI.js";import"./isAddressEqual-DREghARX.js";import"react-dom";import"react-dom/client";const S=s=>{const{children:t,cookies:o,submitLabel:n,rejectLabel:c,onSubmit:r=()=>{},onReject:m=()=>{},...d}=s,[i,u]=w(o),f=a=>{const{id:k,checked:x}=a.target;u(g=>g.map(p=>p.id===k?{...p,value:x}:p))},h="min-w-64 h-8 text-base";return l("div",{...y(d,"flex flex-col items-center"),children:[e("div",{className:"text-center",children:t}),e("div",{className:"my-8 flex gap-x-16 text-sm font-medium",children:i.map(a=>l("div",{className:"cursor-pointer",children:[e("input",{checked:a.value,className:"mr-1 size-3 cursor-pointer rounded-sm border-2 border-gray-900 accent-gray-900 focus:outline-none",id:a.id,onChange:f,type:"checkbox"}),e("label",{className:"cursor-pointer select-none",htmlFor:a.id,children:a.label})]},a.id))}),l("div",{className:"flex gap-x-8",children:[e(b,{className:h,color:"light",onClick:()=>m(),size:"small",children:c}),e(b,{className:h,onClick:()=>r(i),size:"small",children:n})]})]})},z=(s,t)=>s.some(o=>o.id===t&&o.value),I=()=>{const{t:s}=N(),{showModal:t}=v(),[o,n]=C(),[,c]=B(),r=[{id:"analytics-cookie",label:s("cookieBanner.cookies.analytics"),value:!0}],m=i=>{n(!1),z(i,"analytics-cookie")&&c(u=>({...u,analytics:!0}))},d=()=>{n(!1),c(()=>({analytics:!1,functional:!1,marketing:!1}))};return o?l("div",{className:"absolute inset-0 z-[10000] backdrop-blur-sm",children:[e("div",{className:"absolute inset-0 bg-black opacity-15"}),e("div",{className:"absolute inset-x-0 bottom-0 flex justify-center bg-white px-10 pb-16 pt-10 shadow-lg",children:e(S,{className:"max-w-[1024px] ",cookies:r,onSubmit:m,onReject:d,submitLabel:s("cookieBanner.accept"),rejectLabel:s("cookieBanner.reject"),children:e("p",{className:"font-semibold text-gray-500",children:e(j,{i18nKey:"cookieBanner.message",components:{a:e("a",{onClick:()=>t("cookiesPolicy",{}),className:"cursor-pointer text-gray-900 hover:underline"})}})})})})]}):null};export{I as CookieBanner};
|
|
2
|
+
//# sourceMappingURL=cookie-banner-DR0V1IJG.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cookie-banner-
|
|
1
|
+
{"version":3,"file":"cookie-banner-DR0V1IJG.js","sources":["../../../../packages/design-system/dist/src/connect/components/cookie-banner/cookie-banner.js","../../src/components/cookie-banner.tsx"],"sourcesContent":["import { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nimport { Button, mergeClassNameProps } from \"#powerhouse\";\nimport { useState } from \"react\";\nexport const CookieBanner = (props) => {\n const { children, cookies, submitLabel, rejectLabel, onSubmit = () => { }, onReject = () => { }, ...divProps } = props;\n const [cookiesValue, setCookiesValue] = useState(cookies);\n const handleOnChange = (event) => {\n const { id, checked } = event.target;\n setCookiesValue((prevState) => prevState.map((cookie) => cookie.id === id ? { ...cookie, value: checked } : cookie));\n };\n const buttonStyles = \"min-w-64 h-8 text-base\";\n return (_jsxs(\"div\", { ...mergeClassNameProps(divProps, \"flex flex-col items-center\"), children: [_jsx(\"div\", { className: \"text-center\", children: children }), _jsx(\"div\", { className: \"my-8 flex gap-x-16 text-sm font-medium\", children: cookiesValue.map((cookie) => (_jsxs(\"div\", { className: \"cursor-pointer\", children: [_jsx(\"input\", { checked: cookie.value, className: \"mr-1 size-3 cursor-pointer rounded-sm border-2 border-gray-900 accent-gray-900 focus:outline-none\", id: cookie.id, onChange: handleOnChange, type: \"checkbox\" }), _jsx(\"label\", { className: \"cursor-pointer select-none\", htmlFor: cookie.id, children: cookie.label })] }, cookie.id))) }), _jsxs(\"div\", { className: \"flex gap-x-8\", children: [_jsx(Button, { className: buttonStyles, color: \"light\", onClick: () => onReject(), size: \"small\", children: rejectLabel }), _jsx(Button, { className: buttonStyles, onClick: () => onSubmit(cookiesValue), size: \"small\", children: submitLabel })] })] }));\n};\n//# sourceMappingURL=cookie-banner.js.map","import {\n type CookieInput,\n CookieBanner as PHCookieBanner,\n} from '@powerhousedao/design-system';\nimport { Trans, useTranslation } from 'react-i18next';\nimport { useAcceptedCookies } from '../hooks/useAcceptedCookies.js';\nimport { useCookieBanner } from '../hooks/useCookiebanner.js';\nimport { useModal } from './modal/index.js';\n\nconst isCookieAccepted = (cookies: CookieInput[], id: string) => {\n return cookies.some(cookie => cookie.id === id && cookie.value);\n};\n\nexport const CookieBanner = () => {\n const { t } = useTranslation();\n const { showModal } = useModal();\n const [showBanner, setShowBanner] = useCookieBanner();\n const [, setAcceptedCookies] = useAcceptedCookies();\n\n const cookiesInput: CookieInput[] = [\n {\n id: 'analytics-cookie',\n label: t('cookieBanner.cookies.analytics'),\n value: true,\n },\n ];\n\n const handleAccept = (cookies: CookieInput[]) => {\n setShowBanner(false);\n\n if (isCookieAccepted(cookies, 'analytics-cookie')) {\n setAcceptedCookies(acceptedCookies => ({\n ...acceptedCookies,\n analytics: true,\n }));\n }\n };\n\n const handleReject = () => {\n setShowBanner(false);\n setAcceptedCookies(() => ({\n analytics: false,\n functional: false,\n marketing: false,\n }));\n };\n\n if (!showBanner) {\n return null;\n }\n\n return (\n <div className=\"absolute inset-0 z-[10000] backdrop-blur-sm\">\n <div className=\"absolute inset-0 bg-black opacity-15\" />\n <div className=\"absolute inset-x-0 bottom-0 flex justify-center bg-white px-10 pb-16 pt-10 shadow-lg\">\n <PHCookieBanner\n className=\"max-w-[1024px] \"\n cookies={cookiesInput}\n onSubmit={handleAccept}\n onReject={handleReject}\n submitLabel={t('cookieBanner.accept')}\n rejectLabel={t('cookieBanner.reject')}\n >\n <p className=\"font-semibold text-gray-500\">\n <Trans\n i18nKey=\"cookieBanner.message\"\n components={{\n a: (\n <a\n onClick={() =>\n showModal('cookiesPolicy', {})\n }\n className=\"cursor-pointer text-gray-900 hover:underline\"\n />\n ),\n }}\n />\n </p>\n </PHCookieBanner>\n </div>\n </div>\n );\n};\n"],"names":["CookieBanner","props","children","cookies","submitLabel","rejectLabel","onSubmit","onReject","divProps","cookiesValue","setCookiesValue","useState","handleOnChange","event","id","checked","prevState","cookie","buttonStyles","_jsxs","mergeClassNameProps","_jsx","Button","isCookieAccepted","t","useTranslation","showModal","useModal","showBanner","setShowBanner","useCookieBanner","setAcceptedCookies","useAcceptedCookies","cookiesInput","handleAccept","acceptedCookies","handleReject","jsxs","jsx","PHCookieBanner","Trans"],"mappings":"+SAGO,MAAMA,EAAgBC,GAAU,CACnC,KAAM,CAAE,SAAAC,EAAU,QAAAC,EAAS,YAAAC,EAAa,YAAAC,EAAa,SAAAC,EAAW,IAAM,CAAG,EAAE,SAAAC,EAAW,IAAM,CAAA,EAAK,GAAGC,CAAU,EAAGP,EAC3G,CAACQ,EAAcC,CAAe,EAAIC,EAASR,CAAO,EAClDS,EAAkBC,GAAU,CAC9B,KAAM,CAAE,GAAAC,EAAI,QAAAC,CAAS,EAAGF,EAAM,OAC9BH,EAAiBM,GAAcA,EAAU,IAAKC,GAAWA,EAAO,KAAOH,EAAK,CAAE,GAAGG,EAAQ,MAAOF,CAAO,EAAKE,CAAM,CAAC,CACtH,EACKC,EAAe,yBACrB,OAAQC,EAAM,MAAO,CAAE,GAAGC,EAAoBZ,EAAU,4BAA4B,EAAG,SAAU,CAACa,EAAK,MAAO,CAAE,UAAW,cAAe,SAAUnB,EAAU,EAAGmB,EAAK,MAAO,CAAE,UAAW,yCAA0C,SAAUZ,EAAa,IAAKQ,GAAYE,EAAM,MAAO,CAAE,UAAW,iBAAkB,SAAU,CAACE,EAAK,QAAS,CAAE,QAASJ,EAAO,MAAO,UAAW,oGAAqG,GAAIA,EAAO,GAAI,SAAUL,EAAgB,KAAM,UAAY,CAAA,EAAGS,EAAK,QAAS,CAAE,UAAW,6BAA8B,QAASJ,EAAO,GAAI,SAAUA,EAAO,KAAK,CAAE,CAAC,CAAC,EAAIA,EAAO,EAAE,CAAE,EAAG,EAAGE,EAAM,MAAO,CAAE,UAAW,eAAgB,SAAU,CAACE,EAAKC,EAAQ,CAAE,UAAWJ,EAAc,MAAO,QAAS,QAAS,IAAMX,IAAY,KAAM,QAAS,SAAUF,EAAa,EAAGgB,EAAKC,EAAQ,CAAE,UAAWJ,EAAc,QAAS,IAAMZ,EAASG,CAAY,EAAG,KAAM,QAAS,SAAUL,CAAa,CAAA,CAAC,CAAG,CAAA,CAAC,CAAC,CAAE,CACt8B,ECHMmB,EAAmB,CAACpB,EAAwBW,IACvCX,EAAQ,KAAKc,GAAUA,EAAO,KAAOH,GAAMG,EAAO,KAAK,EAGrDjB,EAAe,IAAM,CACxB,KAAA,CAAE,EAAAwB,CAAE,EAAIC,EAAe,EACvB,CAAE,UAAAC,CAAU,EAAIC,EAAS,EACzB,CAACC,EAAYC,CAAa,EAAIC,EAAgB,EAC9C,CAAG,CAAAC,CAAkB,EAAIC,EAAmB,EAE5CC,EAA8B,CAChC,CACI,GAAI,mBACJ,MAAOT,EAAE,gCAAgC,EACzC,MAAO,EAAA,CAEf,EAEMU,EAAgB/B,GAA2B,CAC7C0B,EAAc,EAAK,EAEfN,EAAiBpB,EAAS,kBAAkB,GAC5C4B,EAAuCI,IAAA,CACnC,GAAGA,EACH,UAAW,EAAA,EACb,CAEV,EAEMC,EAAe,IAAM,CACvBP,EAAc,EAAK,EACnBE,EAAmB,KAAO,CACtB,UAAW,GACX,WAAY,GACZ,UAAW,EAAA,EACb,CACN,EAEA,OAAKH,EAKDS,EAAC,MAAI,CAAA,UAAU,8CACX,SAAA,CAACC,EAAA,MAAA,CAAI,UAAU,sCAAuC,CAAA,EACtDA,EAAC,MAAI,CAAA,UAAU,uFACX,SAAAA,EAACC,EAAA,CACG,UAAU,kBACV,QAASN,EACT,SAAUC,EACV,SAAUE,EACV,YAAaZ,EAAE,qBAAqB,EACpC,YAAaA,EAAE,qBAAqB,EAEpC,SAAAc,EAAC,IAAE,CAAA,UAAU,8BACT,SAAAA,EAACE,EAAA,CACG,QAAQ,uBACR,WAAY,CACR,EACIF,EAAC,IAAA,CACG,QAAS,IACLZ,EAAU,gBAAiB,EAAE,EAEjC,UAAU,8CAAA,CAAA,CACd,CAER,CAAA,CAER,CAAA,CAAA,CAAA,CAER,CAAA,CAAA,EACJ,EAhCO,IAkCf"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{jsx as Z,jsxs as Pe}from"react/jsx-runtime";import{a7 as Vb,a8 as oe,a9 as On,aa as bu,ab as An,ac as vc,ad as Ht,ae as en,af as yc,ag as Fi,ah as Fs,ai as fk,aj as K,ak as dk,al as hk,am as qb,an as Ub,ao as pk,ap as Fr,aq as ht,ar as Tn,as as xe,at as mk,au as jb,av as Gb,aw as gk,ax as vk,ay as yk,az as Hb,aA as $p,aB as Ar,aC as Qp,aD as Bp,aE as Vp,aF as bk,aG as ar,aH as Pn,aI as Ok,aJ as $i,aK as $s,aL as Qs,aM as Nh,aN as Wb,aO as Zb,aP as Yb,aQ as Kb,aR as td,aS as Sk,aT as Du,aU as Tk,aV as kh,aW as wh,aX as $n,aY as zb,aZ as nd,a_ as of,a$ as Ek,b0 as Ak,b1 as Nk,b2 as kk,b3 as wk,b4 as _k,b5 as xk,b6 as Ik,b7 as Rk,b8 as Dk,b9 as Xb,ba as Ck,bb as rd,bc as id,bd as sd,be as ys,bf as Mk,bg as Jb,bh as Pk,bi as Lk,bj as it,bk as Fk,bl as $k,bm as Qk,bn as Bk,bo as Vk,bp as qk,bq as eO,br as tO,bs as nO,bt as qp,bu as Uk,bv as jk,bw as Gk,bx as Hk,by as Wk,bz as Up,bA as Zk,bB as af,bC as Yk,bD as Kk,bE as zk,bF as Xk,bG as Jk,bH as ew,bI as tw,bJ as nw,bK as rw,bL as iw,bM as sw}from"./app-
|
|
1
|
+
import{jsx as Z,jsxs as Pe}from"react/jsx-runtime";import{a7 as Vb,a8 as oe,a9 as On,aa as bu,ab as An,ac as vc,ad as Ht,ae as en,af as yc,ag as Fi,ah as Fs,ai as fk,aj as K,ak as dk,al as hk,am as qb,an as Ub,ao as pk,ap as Fr,aq as ht,ar as Tn,as as xe,at as mk,au as jb,av as Gb,aw as gk,ax as vk,ay as yk,az as Hb,aA as $p,aB as Ar,aC as Qp,aD as Bp,aE as Vp,aF as bk,aG as ar,aH as Pn,aI as Ok,aJ as $i,aK as $s,aL as Qs,aM as Nh,aN as Wb,aO as Zb,aP as Yb,aQ as Kb,aR as td,aS as Sk,aT as Du,aU as Tk,aV as kh,aW as wh,aX as $n,aY as zb,aZ as nd,a_ as of,a$ as Ek,b0 as Ak,b1 as Nk,b2 as kk,b3 as wk,b4 as _k,b5 as xk,b6 as Ik,b7 as Rk,b8 as Dk,b9 as Xb,ba as Ck,bb as rd,bc as id,bd as sd,be as ys,bf as Mk,bg as Jb,bh as Pk,bi as Lk,bj as it,bk as Fk,bl as $k,bm as Qk,bn as Bk,bo as Vk,bp as qk,bq as eO,br as tO,bs as nO,bt as qp,bu as Uk,bv as jk,bw as Gk,bx as Hk,by as Wk,bz as Up,bA as Zk,bB as af,bC as Yk,bD as Kk,bE as zk,bF as Xk,bG as Jk,bH as ew,bI as tw,bJ as nw,bK as rw,bL as iw,bM as sw}from"./app-BcXkGQiq.js";import*as Wt from"react";import Cu,{useState as Bs,useEffect as tn,createContext as ow,useContext as aw,forwardRef as _h,useRef as kt,useCallback as ge,useImperativeHandle as rO,useId as xh,memo as iO,useMemo as to}from"react";import{t as lw,co as uw,P as cw,cp as fw}from"./index-CYlcJ2ja.js";import"./main.B6BOUKAI.js";import"./isAddressEqual-DREghARX.js";import"react-dom";import"react-dom/client";const dw=Object.freeze({major:16,minor:11,patch:0,preReleaseTag:null});function hw(n){return n instanceof Error?n:new pw(n)}class pw extends Error{constructor(e){super("Unexpected error value: "+Vb(e)),this.name="NonErrorThrown",this.thrownValue=e}}function mw(n,e,t){var r;const i=hw(n);return gw(i)?i:new oe(i.message,{nodes:(r=i.nodes)!==null&&r!==void 0?r:e,source:i.source,positions:i.positions,path:t,originalError:i})}function gw(n){return Array.isArray(n.path)}function vw(n){return{Field(e){const t=n.getFieldDef(),r=t==null?void 0:t.deprecationReason;if(t&&r!=null){const i=n.getParentType();i!=null||bu(!1),n.reportError(new oe(`The field ${i.name}.${t.name} is deprecated. ${r}`,{nodes:e}))}},Argument(e){const t=n.getArgument(),r=t==null?void 0:t.deprecationReason;if(t&&r!=null){const i=n.getDirective();if(i!=null)n.reportError(new oe(`Directive "@${i.name}" argument "${t.name}" is deprecated. ${r}`,{nodes:e}));else{const s=n.getParentType(),o=n.getFieldDef();s!=null&&o!=null||bu(!1),n.reportError(new oe(`Field "${s.name}.${o.name}" argument "${t.name}" is deprecated. ${r}`,{nodes:e}))}}},ObjectField(e){const t=On(n.getParentInputType());if(An(t)){const r=t.getFields()[e.name.value],i=r==null?void 0:r.deprecationReason;i!=null&&n.reportError(new oe(`The input field ${t.name}.${r.name} is deprecated. ${i}`,{nodes:e}))}},EnumValue(e){const t=n.getEnumValue(),r=t==null?void 0:t.deprecationReason;if(t&&r!=null){const i=On(n.getInputType());i!=null||bu(!1),n.reportError(new oe(`The enum value "${i.name}.${t.name}" is deprecated. ${r}`,{nodes:e}))}}}}function Ih(n){return bw(n,e=>!qb(e),yw)}function yw(n){return!Ub(n)&&!pk(n)}function bw(n,e,t){const r=n.getDirectives().filter(e),i=Object.values(n.getTypeMap()).filter(t);return[Ow(n),...r.map(s=>xw(s)),...i.map(s=>Tw(s))].filter(Boolean).join(`
|
|
2
2
|
|
|
3
3
|
`)}function Ow(n){if(n.description==null&&Sw(n))return;const e=[],t=n.getQueryType();t&&e.push(` query: ${t.name}`);const r=n.getMutationType();r&&e.push(` mutation: ${r.name}`);const i=n.getSubscriptionType();return i&&e.push(` subscription: ${i.name}`),Zt(n)+`schema {
|
|
4
4
|
${e.join(`
|
|
@@ -111,4 +111,4 @@ In some cases, you need to provide options to alter GraphQL's execution behavior
|
|
|
111
111
|
"errors editor"
|
|
112
112
|
`,gridTemplateRows:"auto 1fr"},children:[Pe("div",{className:"flex flex-col gap-2",style:{gridArea:"left"},children:[Z(dT,{operation:e,onAddOperationAndInitialSchema:s,updateOperationName:o,deleteOperation:a,module:t,allOperationNames:r}),Z(o$,{operation:e,focusOnMount:e.id===i,setOperationDescription:u})]}),Z("div",{className:"relative top-8",style:{gridArea:"editor"},children:Z(Sh,{doc:e.schema??"",updateDocumentInModel:h,customLinter:p})}),Pe("div",{style:{gridArea:"errors"},children:[Z("h3",{className:"my-2 text-sm font-medium text-gray-700",children:"Reducer Exceptions"}),Z(a$,{operation:e,addOperationError:f,deleteOperationError:c,setOperationErrorName:d})]})]})}function f$({module:n,allOperations:e,shouldFocusNewOperation:t,updateOperationName:r,deleteOperation:i,addOperationAndInitialSchema:s,addOperationError:o,deleteOperationError:a,setOperationErrorName:l,updateOperationSchema:u,setOperationDescription:f}){const[c,d]=Bs(null),h=xh(),p=e.map(g=>g.name).filter(g=>g!==null),m=ge(async(g,v)=>{const b=await s(g,v);return b&&d(b),b},[s,d]);return Pe("div",{children:[n.operations.map(g=>Z("div",{children:Z(c$,{operation:g,module:n,lastCreatedOperationId:c,allOperationNames:p,addOperationError:o,deleteOperationError:a,setOperationErrorName:l,onAddOperationAndInitialSchema:m,updateOperationName:r,deleteOperation:i,updateOperationSchema:u,setOperationDescription:f})},g.id)),Z("div",{className:"mt-6 w-1/2 pr-6",children:Z(dT,{onAddOperationAndInitialSchema:m,updateOperationName:r,deleteOperation:i,module:n,allOperationNames:p,focusOnMount:t},h)})]})}function Fb(n){const{module:e,modules:t,allOperations:r,lastCreatedModuleId:i,onAddModule:s,updateModuleName:o,deleteModule:a,updateOperationName:l,deleteOperation:u,addOperationAndInitialSchema:f,updateOperationSchema:c,setOperationDescription:d,addOperationError:h,deleteOperationError:p,setOperationErrorName:m}=n;return Pe("div",{className:"relative rounded-3xl bg-gray-100 p-6",children:[Pe("div",{className:"mb-2 w-1/2 pr-6",children:[Z(nR,{modules:t,module:e,onAddModule:s,updateModuleName:o}),!!e&&Z("button",{"aria-label":"Delete module",tabIndex:-1,className:"absolute right-1 top-1 p-2 text-gray-800 transition-colors hover:text-gray-500",onClick:()=>{a(e.id)},children:Z("svg",{className:"size-6",viewBox:"0 0 24 24",fill:"currentcolor",children:Z("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M16.9993 8.51506L15.4844 7L11.9994 10.4852L8.51497 7.00057L7 8.51562L10.4844 12.0003L7.00056 15.4843L8.51552 16.9994L11.9994 13.5153L15.4838 17L16.9988 15.4849L13.5144 12.0003L16.9993 8.51506Z"})})})]}),!!e&&Z(f$,{module:e,allOperations:r,shouldFocusNewOperation:e.id===i,updateOperationName:l,deleteOperation:u,addOperationAndInitialSchema:f,updateOperationSchema:c,setOperationDescription:d,addOperationError:h,deleteOperationError:p,setOperationErrorName:m})]})}function d$({modules:n,allOperations:e,addModule:t,updateModuleName:r,deleteModule:i,updateOperationName:s,deleteOperation:o,addOperationAndInitialSchema:a,updateOperationSchema:l,setOperationDescription:u,addOperationError:f,deleteOperationError:c,setOperationErrorName:d}){const[h,p]=Bs(null),m=kt(null),g=ge(async v=>{var S;const b=await t(v);return b&&(p(b),(S=m.current)==null||S.focus()),b},[t,p]);return Pe("div",{className:"flex flex-col gap-2",children:[n.map(v=>Z(Fb,{module:v,modules:n,allOperations:e,lastCreatedModuleId:h,onAddModule:g,updateModuleName:r,deleteModule:i,updateOperationName:s,deleteOperation:o,addOperationAndInitialSchema:a,updateOperationSchema:l,setOperationDescription:u,addOperationError:f,deleteOperationError:c,setOperationErrorName:d},v.id)),Z(Fb,{modules:n,allOperations:e,lastCreatedModuleId:h,onAddModule:g,updateModuleName:r,deleteModule:i,updateOperationName:s,deleteOperation:o,addOperationAndInitialSchema:a,updateOperationSchema:l,setOperationDescription:u,addOperationError:f,deleteOperationError:c,setOperationErrorName:d},"add-module"),Z("div",{ref:m,tabIndex:0,className:"size-0 overflow-hidden","aria-hidden":"true"})]})}const Th=_h((n,e)=>{const{className:t,...r}=n;return Z("button",{ref:e,...r,className:Kt("h-10 whitespace-nowrap rounded-md border border-gray-200 bg-gray-50 px-4 py-2 text-sm font-medium text-gray-800 transition-colors hover:bg-gray-100 hover:text-gray-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",t)})}),h$=up({String:y.string,Number:y.number,"True False":y.bool,PropertyName:y.propertyName,Null:y.null,", :":y.separator,"[ ]":y.squareBracket,"{ }":y.brace}),p$=Rs.deserialize({version:14,states:"$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#ClOOQO'#Cr'#CrQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CtOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59W,59WO!iQPO,59WOVQPO,59QOqQPO'#CmO!nQPO,59`OOQO1G.k1G.kOVQPO'#CnO!vQPO,59aOOQO1G.r1G.rOOQO1G.l1G.lOOQO,59X,59XOOQO-E6k-E6kOOQO,59Y,59YOOQO-E6l-E6l",stateData:"#O~OeOS~OQSORSOSSOTSOWQO_ROgPO~OVXOgUO~O^[O~PVO[^O~O]_OVhX~OVaO~O]bO^iX~O^dO~O]_OVha~O]bO^ia~O",goto:"!kjPPPPPPkPPkqwPPPPk{!RPPP!XP!e!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",nodeNames:"⚠ JsonText True False Null Number String } { Object Property PropertyName : , ] [ Array",maxTerm:25,nodeProps:[["isolate",-2,6,11,""],["openedBy",7,"{",14,"["],["closedBy",8,"}",15,"]"]],propSources:[h$],skippedNodes:[0],repeatNodeCount:2,tokenData:"(|~RaXY!WYZ!W]^!Wpq!Wrs!]|}$u}!O$z!Q!R%T!R![&c![!]&t!}#O&y#P#Q'O#Y#Z'T#b#c'r#h#i(Z#o#p(r#q#r(w~!]Oe~~!`Wpq!]qr!]rs!xs#O!]#O#P!}#P;'S!];'S;=`$o<%lO!]~!}Og~~#QXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#m~#pR!Q![#y!c!i#y#T#Z#y~#|R!Q![$V!c!i$V#T#Z$V~$YR!Q![$c!c!i$c#T#Z$c~$fR!Q![!]!c!i!]#T#Z!]~$rP;=`<%l!]~$zO]~~$}Q!Q!R%T!R![&c~%YRT~!O!P%c!g!h%w#X#Y%w~%fP!Q![%i~%nRT~!Q![%i!g!h%w#X#Y%w~%zR{|&T}!O&T!Q![&Z~&WP!Q![&Z~&`PT~!Q![&Z~&hST~!O!P%c!Q![&c!g!h%w#X#Y%w~&yO[~~'OO_~~'TO^~~'WP#T#U'Z~'^P#`#a'a~'dP#g#h'g~'jP#X#Y'm~'rOR~~'uP#i#j'x~'{P#`#a(O~(RP#`#a(U~(ZOS~~(^P#f#g(a~(dP#i#j(g~(jP#X#Y(m~(rOQ~~(wOW~~(|OV~",tokenizers:[0],topRules:{JsonText:[0,1]},tokenPrec:0}),m$=()=>n=>{try{JSON.parse(n.state.doc.toString())}catch(e){if(!(e instanceof SyntaxError))throw e;const t=g$(e,n.state.doc);return[{from:t,message:e.message,severity:"error",to:t}]}return[]};function g$(n,e){let t;return(t=n.message.match(/at position (\d+)/))?Math.min(+t[1],e.length):(t=n.message.match(/at line (\d+) column (\d+)/))?Math.min(e.line(+t[1]).from+ +t[2]-1,e.length):0}const BN=Ds.define({name:"json",parser:p$.configure({props:[dp.add({Object:xy({except:/^\s*\}/}),Array:xy({except:/^\s*\]/})}),pp.add({"Object Array":fA})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function v$(){return new lA(BN)}const y$=iO(function(e){const{doc:t,readonly:r=!1,updateDocumentInModel:i}=e,{editorRef:s,viewRef:o,updateListenerCompartment:a,focusHandlerCompartment:l,pasteHandlerCompartment:u,timeoutRef:f}=DN();return tn(()=>{o.current||(o.current=new ne({state:Te.create({doc:t,extensions:[...LN,Vc.of(FN),kA,BN,v$(),np(m$()),a.current.of(Cp(r,f,i)),l.current.of(Mp(r,f,i)),u.current.of(Pp(r,f,i)),Te.readOnly.of(r)]}),parent:s.current}),Ii(o.current))},[]),CN(o),MN(o.current,r,f,i,{updateListener:a.current,focusHandler:l.current,pasteHandler:u.current}),PN(o.current,t),Z("div",{ref:s})}),b$=qk,VN=Wt.forwardRef(({className:n,...e},t)=>Z(eO,{ref:t,className:Kt("flex items-center justify-center rounded-xl bg-slate-50 p-1 shadow-[inset_0px_0px_2px_rgba(255,255,255,0.50)]",n),...e}));VN.displayName=eO.displayName;const Eh=Wt.forwardRef(({className:n,...e},t)=>Z(tO,{ref:t,className:Kt("flex w-full items-center justify-center whitespace-nowrap rounded-lg p-1 text-sm text-gray-500 transition-all disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-gray-50 data-[state=active]:text-gray-800 data-[state=active]:shadow-[0px_16px_16px_-4px_rgba(0,0,0,0.10)]",n),...e}));Eh.displayName=tO.displayName;const Ah=Wt.forwardRef(({className:n,...e},t)=>Z(nO,{ref:t,className:Kt("",n),...e}));Ah.displayName=nO.displayName;function $b({modelName:n,stateSchema:e,initialValue:t,setStateSchema:r,setInitialState:i,scope:s}){const o=_S(),[a,l]=Bs(!1),u=ge(p=>l$(p,n,s),[n,s]),f=ge(()=>{l(p=>!p)},[]),c=ge(p=>r(p,s),[r,s]),d=ge(p=>i(p,s),[i,s]),h=ge(()=>{const p=t||"{}",m=nn(o);if(!m)return;const g=nn(e);if(!g)return;const v=xS(n,s);if(!v)return;const b=g.definitions.find(T=>T.kind===K.OBJECT_TYPE_DEFINITION&&T.name.value===v);if(!b||b.kind!==K.OBJECT_TYPE_DEFINITION)return;const S=V_({sharedSchemaDocumentNode:m,stateTypeDefinitionNode:b,existingValue:p});i(S,s)},[o,t,i,s]);return Pe("div",{className:"grid grid-cols-2 gap-4",children:[Pe("div",{children:[Pe("h3",{className:"mb-2 text-lg capitalize",children:[s," state schema"]}),Pe(Th,{onClick:f,className:"mb-2 flex w-fit items-center gap-2",children:[a?"Hide":"Show"," standard library",Z("svg",{className:Kt("inline-block transition-transform",a?"rotate-180":"rotate-0"),xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",children:Z("path",{d:"M11.9883 6.01172C11.4363 6.01172 10.9883 6.45972 10.9883 7.01172V13.0117H6.98828L11.9883 18.0117L16.9883 13.0117H12.9883V7.01172C12.9883 6.45972 12.5403 6.01172 11.9883 6.01172Z",fill:"black"})})]}),a&&Z(Sh,{doc:Ch,readonly:!0}),Z(Sh,{doc:e,updateDocumentInModel:c,customLinter:u})]}),Pe("div",{children:[Pe("div",{className:"flex flex-col items-end",children:[Pe("h3",{className:"mb-2 text-right text-lg capitalize",children:[s," state initial value"]}),Pe(Th,{onClick:h,className:"mb-2 flex w-fit items-center gap-2",children:["Sync with schema"," ",Z("svg",{className:"inline-block",xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:Z("path",{d:"M8.00521 1.99219C6.63588 1.99219 5.32788 2.45152 4.27588 3.28419C3.98721 3.51219 3.94321 3.93285 4.17188 4.22151C4.40054 4.51018 4.82055 4.55418 5.10921 4.32552C5.92721 3.67819 6.93921 3.32552 8.00521 3.32552C10.5825 3.32552 12.6719 5.41485 12.6719 7.99218H11.3385L13.3385 10.6588L15.3385 7.99218H14.0052C14.0052 4.67818 11.3192 1.99219 8.00521 1.99219ZM2.67188 5.32552L0.671875 7.99218H2.00521C2.00521 11.3062 4.69121 13.9922 8.00521 13.9922C9.37521 13.9922 10.6825 13.5335 11.7345 12.7002C12.0232 12.4722 12.0672 12.0515 11.8385 11.7628C11.6099 11.4742 11.1899 11.4302 10.9012 11.6588C10.0825 12.3068 9.07188 12.6588 8.00521 12.6588C5.42788 12.6588 3.33854 10.5695 3.33854 7.99218H4.67188L2.67188 5.32552Z",fill:"#343839"})})]})]}),Z(y$,{doc:t,updateDocumentInModel:d})]})]})}function O$({modelName:n,globalStateSchema:e,localStateSchema:t,globalStateInitialValue:r,localStateInitialValue:i,setStateSchema:s,setInitialState:o}){const a=ge(()=>{const l=Mh(n,"local");s(l,"local"),o("","local")},[n,s,o]);return Pe(b$,{className:"pb-8",activationMode:"manual",defaultValue:"global",children:[Z("div",{className:"my-6",children:Pe(VN,{className:"mx-auto flex max-w-sm",children:[Z(Eh,{value:"global",children:"Global"}),Z(Eh,{value:"local",children:"Local"})]})}),Z(Ah,{value:"global",tabIndex:-1,children:Z($b,{modelName:n,stateSchema:e,initialValue:r,setStateSchema:s,setInitialState:o,scope:"global"})}),Z(Ah,{value:"local",tabIndex:-1,children:t?Z($b,{modelName:n,stateSchema:t,initialValue:i,setStateSchema:s,setInitialState:o,scope:"local"}):Pe("div",{className:"",children:[Z("h3",{className:"mb-2 text-lg capitalize",children:"local state schema"}),Z(Th,{onClick:a,children:"Add local state"})]})})]})}function S$(n){const{document:e,documentNodeName:t,dispatch:r}=n,{name:i,id:s,extension:o,description:a,author:{name:l,website:u}}=to(()=>e.state.global,[e.state.global]),{state:{global:{schema:f,initialValue:c},local:{schema:d,initialValue:h}},modules:p}=to(()=>e.state.global.specifications[0],[e.state.global.specifications[0]]),m=to(()=>p.flatMap(V=>V.operations),[p]),g=kt(!i&&!!t&&m.length===0);tn(()=>{!g.current||!t||(r(qp({name:t})),MS({modelName:t,setStateSchema:(V,ee)=>{r(Up({schema:V,scope:ee}))}}),g.current=!1)},[t]);const v=to(()=>m.flatMap(V=>V.schema??[]).join(`
|
|
113
113
|
`),[m]),b=ge(V=>{ut(V,s)||r(Uk({id:V}))},[s]),S=ge(V=>{ut(V,a)||r(jk({description:V}))},[a]),T=ge(V=>{ut(V,o)||r(Gk({extension:V}))},[o]),O=ge(V=>{ut(V,i)||r(qp({name:V}))},[i]),E=ge(V=>{ut(V,l)||r(Hk({authorName:V}))},[l]),_=ge(V=>{ut(V,u??"")||r(Wk({authorWebsite:V}))},[u]),M=ge((V,ee)=>{ut(V,ee==="global"?f:d)||r(Up({schema:V,scope:ee}))},[f,d]),D=ge((V,ee)=>{ut(V,ee==="global"?c:h)||r(Zk({initialValue:V,scope:ee}))},[c,h]),C=ge(V=>new Promise(ee=>{try{if(p.some(pe=>ut(pe.name,V))){ee(void 0);return}const re=af();r(Yk({id:re,name:V})),ee(re)}catch(re){console.error("Failed to add module:",re),ee(void 0)}}),[p]),$=ge((V,ee)=>{p.some(re=>ut(re.name,ee))||r(Kk({id:V,name:ee}))},[p]),N=ge(V=>r(zk({id:V})),[]),w=ge((V,ee)=>new Promise(re=>{var pe;try{if((((pe=p.find(je=>je.id===V))==null?void 0:pe.operations.map(je=>je.name).filter(Boolean))??[]).some(je=>ut(je,ee))){re(void 0);return}const Le=af();r(Xk({id:Le,moduleId:V,name:ee})),re(Le)}catch(we){console.error("Failed to add operation:",we),re(void 0)}}),[p]),I=ge((V,ee)=>{const re=p.find(we=>we.operations.some(Le=>Le.id===V));((re==null?void 0:re.operations.map(we=>we.name).filter(Boolean))??[]).some(we=>ut(we,ee))||r(Jk({id:V,name:ee}))},[p]),R=ge((V,ee)=>{const re=m.find(pe=>pe.id===V);re!=null&&re.schema&&ut(ee,re.schema)||r(ew({id:V,schema:ee}))},[m]),Q=ge((V,ee)=>{var pe;const re=((pe=m.find(we=>we.id===V))==null?void 0:pe.description)??"";ut(re,ee)||r(tw({id:V,description:ee}))},[m]),U=ge(V=>r(nw({id:V})),[]),X=ge((V,ee)=>new Promise(re=>{try{const pe=m.find(je=>je.id===V);if(((pe==null?void 0:pe.errors.map(je=>je.name).filter(Boolean))??[]).some(je=>ut(je,ee))){re(void 0);return}const Le=af();r(rw({id:Le,operationId:V,errorName:ee})),re(Le)}catch(pe){console.error("Failed to add operation error:",pe),re(void 0)}}),[m]),te=ge(V=>r(iw({id:V})),[]),ue=ge((V,ee,re)=>{const pe=m.find(Le=>Le.id===V);((pe==null?void 0:pe.errors.map(Le=>Le.name).filter(Boolean))??[]).some(Le=>ut(Le,re))||r(sw({id:ee,errorName:re}))},[m]),ce=ge(async(V,ee)=>{try{const re=await w(V,ee);if(!re)return;try{return R(re,Q_(ee)),re}catch(pe){console.error("Failed to update operation schema:",pe);return}}catch(re){console.error("Failed to add operation and schema:",re);return}},[w,R]);return Z("main",{className:"min-h-dvh bg-gray-50",children:Z($_,{globalStateSchemaSdl:f,localStateSchemaSdl:d,operationSchemasSdl:v,children:Pe("div",{className:"mx-auto max-w-6xl px-4 pt-8",children:[Z(YI,{name:i,documentType:s,extension:o,description:a,authorName:l,authorWebsite:u??"",globalStateSchema:f,localStateSchema:d,setModelId:b,setModelDescription:S,setModelExtension:T,setModelName:O,setAuthorName:E,setAuthorWebsite:_,setStateSchema:M}),Z(Gp,{}),Pe("div",{children:[Z(O$,{modelName:i,globalStateSchema:f,globalStateInitialValue:c,localStateSchema:d,localStateInitialValue:h,setStateSchema:M,setInitialState:D}),Z(Gp,{}),Z("h3",{className:"mb-6 text-lg",children:"Global Operations"}),Z(d$,{modules:p,allOperations:m,addModule:C,updateModuleName:$,deleteModule:N,updateOperationName:I,updateOperationSchema:R,setOperationDescription:Q,deleteOperation:U,addOperationError:X,deleteOperationError:te,setOperationErrorName:ue,addOperationAndInitialSchema:ce})]})]})})})}const F$={Component:S$,documentTypes:["powerhouse/document-model"],config:{id:"document-model-editor-v2",disableExternalControls:!0,documentToolbarEnabled:!0,timelineEnabled:!0}};export{S$ as DocumentModelEditor,F$ as documentModelEditorModule};
|
|
114
|
-
//# sourceMappingURL=index-
|
|
114
|
+
//# sourceMappingURL=index-3nfLp-u3.js.map
|