← All changes
|
assets/js/packages/editor-design-system/editor-design-system.min.js
+1
-1
4.1.2
→
trunk
View file →
| @@ -1 +1 @@ | ||
| 1 | -!function(){"use strict";var e={d:function(t,n){for(var o in n)e.o(n,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:n[o]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{getInitialDesignSystemTab:function(){return E},init:function(){return ge},panel:function(){return ee},persistDesignSystemTab:function(){return _},usePanelActions:function(){return ne},usePanelStatus:function(){return te}});var n=window.elementorV2.editorV1Adapters,o=window.elementorV2.editor,i=window.elementorV2.editorAppBar,r=window.elementorV2.editorPanels,s=window.React,a=window.elementorV2.editorDocuments,l=window.elementorV2.editorGlobalClasses,c=window.elementorV2.editorUi,m=window.elementorV2.editorVariables,d=window.elementorV2.icons,u=window.elementorV2.ui,p=window.wp.i18n;const g="elementor_editor_design_system_active_tab";function f(){if("undefined"==typeof window)return"variables";try{const e=window.localStorage.getItem(g);if("classes"===e||"variables"===e)return e}catch{}return"variables"}let y=null,w=f();function v(e){y=e}function E(){if(y){const e=y;return y=null,w=e,_(e),e}const e=f();return w=e,e}function b(e){w=e}function _(e){if("undefined"!=typeof window)try{window.localStorage.setItem(g,e)}catch{}}var h=window.elementorV2.editorCurrentUser,C=window.elementorV2.query,S=window.elementorV2.editorNotifications;const x="design-system-export-started",P="design-system-export-failed";var k=window.elementorV2.httpClient;const I="design-system-export",D={include:["settings"],kitInfo:{title:"design-system",description:"",source:"local"},customization:{settings:{theme:!1,classes:!0,variables:!0}}};class T extends Error{constructor(e){super("Design system export failed"),this.name="DesignSystemExportError",this.cause=e}}const z=e=>{const t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return new Blob([n],{type:"application/zip"})};var O=window.elementorV2.editorCanvas;const V="elementor/v1/import-export-customization",L=12e4,R=["global-classes","global-variables"],M="design-system-import";class A extends Error{constructor(e){super("Design system upload validation failed"),this.name="DesignSystemUploadValidationError",this.cause=e}}const F=({value:e,onChange:t})=>{const n=[{value:"replace",title:(0,p.__)("Replace existing values","elementor"),description:(0,p.__)("Imported design system values will overwrite existing variables and classes.","elementor")},{value:"keep",title:(0,p.__)("Keep existing values","elementor"),description:(0,p.__)("Existing variables and classes will not change.","elementor")}];return s.createElement(u.Stack,{spacing:1},s.createElement(u.Typography,{variant:"body1"},(0,p.__)("How to handle conflicts with existing variables or classes?","elementor")),s.createElement(u.RadioGroup,{value:e??"",onChange:(e,n)=>t(n)},s.createElement(u.Stack,{spacing:1},n.map(n=>s.createElement(u.Card,{key:n.value,variant:"outlined"},s.createElement(u.CardActionArea,{onClick:()=>t(n.value)},s.createElement(u.Stack,{direction:"row",alignItems:"center",spacing:2,padding:2},s.createElement(u.Radio,{value:n.value,checked:e===n.value,inputProps:{"aria-label":n.title}}),s.createElement(u.Stack,{direction:"column",spacing:.5},s.createElement(u.Typography,{variant:"subtitle2"},n.title),s.createElement(u.Typography,{variant:"caption",color:"text.secondary"},n.description)))))))))},U={file:null,conflictStrategy:null},j="design-system-import-started",B="design-system-import-failed";var N=window.elementorV2.events;const H="design_system",q=e=>{const{dispatchEvent:t,config:n}=(0,N.getMixpanel)(),o=n?.names?.design_system?.[e.event];if(!o)return;const{event:i,...r}=e;try{t?.(o,{event:i,...r})}catch{}},K=["application/zip"],Y=()=>{q({event:"importOpened"}),(0,c.openDialog)({component:s.createElement(G,{onClose:c.closeDialog})})},G=({onClose:e})=>{const{file:t,conflictStrategy:o,setFile:i,setConflictStrategy:r}=(()=>{const[e,t]=(0,s.useState)(U);return{...e,setFile:e=>t(t=>({...t,file:e})),setConflictStrategy:e=>t(t=>({...t,conflictStrategy:e}))}})(),a=(0,C.useMutation)({mutationKey:[M],mutationFn:async({file:e,conflictStrategy:t})=>{await(0,n.__privateRunCommand)("document/save/auto",{force:!0});const o=await(async e=>{const t=new FormData;t.append("e_import_file",e);try{const{data:e}=await(0,k.httpService)().post(`${V}/upload`,t,{headers:{"Content-Type":"multipart/form-data"},timeout:L});return e.data.session}catch(e){throw new A(e)}})(e),i=await(async(e,t)=>{const n={"design-system":{conflict_resolution:"keep"===t?"skip":"replace"}},{data:o}=await(0,k.httpService)().post(`${V}/import`,{session:e,include:["design-system"],customization:n},{timeout:L});return(o.data.runners??[]).filter(e=>R.includes(e))})(o,t);await(async(e,t)=>{for(const n of t)await(0,k.httpService)().post(`${V}/import-runner`,{session:e,runner:n},{timeout:L})})(o,i),window.dispatchEvent(new CustomEvent(O.GLOBAL_STYLES_IMPORTED_EVENT))}}),l=Boolean(t&&o);return s.createElement(s.Fragment,null,s.createElement(u.DialogHeader,{logo:!1},s.createElement(u.DialogTitle,null,(0,p.__)("Import Design System","elementor"))),s.createElement(u.DialogContent,null,s.createElement(u.Stack,{spacing:3},t?s.createElement(c.FileUploadRow,{file:t,onRemove:()=>i(null)}):s.createElement(c.FileUploadDropzone,{onFileSelected:e=>{i(e),q({event:"fileSelected",file_type:H})},allowedFileTypes:K,accept:"application/zip,.zip",regionLabel:(0,p.__)("Design system file dropzone","elementor"),helperText:(0,p.sprintf)((0,p.__)("zip (max. %dMB)","elementor"),3)}),s.createElement(F,{value:o,onChange:e=>{r(e),q({event:"conflictChoice",choice:e})}}),s.createElement(u.Stack,{direction:"row",spacing:.5,alignItems:"center",justifyContent:"flex-start"},s.createElement(d.HelpIcon,{sx:{fontSize:16,color:"text.tertiary"}}),s.createElement(u.Link,{href:"https://go.elementor.com/wp-dash-import-export-design-system/",target:"_blank",rel:"noopener noreferrer",underline:"always",variant:"caption",color:"text.tertiary"},(0,p.__)("Learn how design system imports work","elementor"))))),s.createElement(u.DialogActions,null,s.createElement(u.Button,{size:"medium",color:"secondary",onClick:e},(0,p.__)("Cancel","elementor")),s.createElement(u.Button,{size:"medium",variant:"contained",color:"primary",disabled:!l,onClick:async()=>{if(t&&o){q({event:"confirmed",conflict_choice:o}),(0,S.notify)({id:j,type:"info",message:(0,p.__)("Import in Progress. You will be notified when the import is complete.","elementor")}),e();try{await a.mutateAsync({file:t,conflictStrategy:o}),q({event:"imported"}),(0,S.dismissNotification)(j),(0,S.notify)({id:"design-system-import-succeeded",type:"success",message:(0,p.__)("Design system imported","elementor")})}catch(e){q(e instanceof A?{event:"validationFailed",file_type:H}:{event:"importFailed"}),n=Y,(0,S.dismissNotification)(j),(0,S.notify)({id:B,type:"error",message:(0,p.__)("Your design system import failed","elementor"),additionalActionProps:[{size:"small",variant:"outlined",color:"error",children:(0,p.__)("Try again","elementor"),onClick:()=>{(0,S.dismissNotification)(B),(0,C.getQueryClient)().isMutating({mutationKey:[M]})>0||n()}}]})}var n}}},(0,p.__)("Import","elementor"))))};function $(){return $=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)({}).hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},$.apply(null,arguments)}const W=()=>{const{isAdmin:e}=(0,h.useCurrentUserCapabilities)(),t=(0,u.usePopupState)({variant:"popover",popupId:"design-system-header-menu"}),n=(0,C.useMutation)({mutationKey:[I],mutationFn:async()=>{try{const{data:e}=await(0,k.httpService)().post("elementor/v1/import-export-customization/export",D,{timeout:12e4});return{fileName:"design-system-export.zip",blob:z(e.data.file)}}catch(e){throw new T(e)}}}),o=(0,C.useIsMutating)({mutationKey:[M]})>0,i=(0,C.useIsMutating)({mutationKey:[I]})>0,r=o||i,a=(0,u.bindTrigger)(t),l=async()=>{(0,S.notify)({id:x,type:"info",message:(0,p.__)("Export in progress. Your file will download when it’s ready.","elementor")});try{const{blob:e,fileName:t}=await n.mutateAsync();((e,t)=>{const n=URL.createObjectURL(e),o=document.createElement("a");o.href=n,o.download=t,o.rel="noopener",document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(n)})(e,t),(0,S.dismissNotification)(x),(0,S.notify)({id:"design-system-export-succeeded",type:"success",message:(0,p.__)("Design system exported","elementor")})}catch{e=l,(0,S.dismissNotification)(x),(0,S.notify)({id:P,type:"error",message:(0,p.__)("Your design system export failed","elementor"),additionalActionProps:[{size:"small",variant:"outlined",color:"error",children:(0,p.__)("Try again","elementor"),onClick:()=>{(0,S.dismissNotification)(P),e()}}]})}var e},m=(0,p.__)("Design system actions","elementor"),g=(0,p.__)("Export is in progress. The file will be downloaded when it's complete.","elementor"),f=(0,p.__)("Import is in progress. You will receive a notification when it's complete.","elementor");let y=m;return r&&(y=i?g:f),s.createElement(s.Fragment,null,e&&s.createElement(u.Tooltip,{title:y,placement:"top"},s.createElement("span",null,s.createElement(u.IconButton,$({},a,{size:"small","aria-label":m,disabled:r}),s.createElement(d.DotsVerticalIcon,{fontSize:"small"})))),s.createElement(u.Menu,$({},(0,u.bindMenu)(t),{MenuListProps:{dense:!0},PaperProps:{elevation:6},anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"}}),s.createElement(u.MenuItem,{onClick:()=>{t.close(),q({event:"importOpened"}),(0,c.openDialog)({component:s.createElement(G,{onClose:c.closeDialog})})},disabled:o},s.createElement(u.ListItemIcon,null,s.createElement(d.UploadIcon,{fontSize:"tiny"})),s.createElement(u.ListItemText,null,(0,p.__)("Import","elementor"))),s.createElement(u.MenuItem,{onClick:()=>{t.close(),l()},disabled:i},s.createElement(u.ListItemIcon,null,s.createElement(d.DownloadIcon,{fontSize:"tiny"})),s.createElement(u.ListItemText,null,(0,p.__)("Export","elementor")))))};function Q(){return Q=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)({}).hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},Q.apply(null,arguments)}const J={position:"sticky",zIndex:1100,opacity:1,backgroundColor:"background.default",transition:"top 300ms ease"};function X({onRequestClose:e}){const[t,n]=(0,s.useState)(()=>E()),o=(0,s.useRef)(null),i=(0,s.useRef)(null),{getTabProps:a,getTabPanelProps:g,getTabsProps:f}=(0,u.useTabs)(t);return(0,s.useEffect)(()=>{b(t)},[t]),(0,s.useEffect)(()=>{const e=e=>{const t=e.detail?.tab;t&&(n(t),_(t),b(t))};return window.addEventListener("elementor/design-system/set-tab",e),()=>{window.removeEventListener("elementor/design-system/set-tab",e)}},[]),s.createElement(c.ThemeProvider,null,s.createElement(r.Panel,null,s.createElement(r.PanelHeader,null,s.createElement(u.Stack,{p:1,pl:2,width:"100%",direction:"row",alignItems:"center",spacing:.5},s.createElement(r.PanelHeaderTitle,{sx:{flex:1,minWidth:0}},(0,p.__)("Design system","elementor")),s.createElement(W,null),s.createElement(u.CloseButton,{"aria-label":(0,p.__)("Close","elementor"),sx:{flexShrink:0},onClick:()=>{"variables"===t&&o.current?o.current():"classes"===t&&i.current?i.current():e()}}))),s.createElement(r.PanelBody,{sx:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden",minHeight:0}},s.createElement(u.Stack,{direction:"column",sx:{width:"100%",flex:1,minHeight:0,overflow:"hidden"}},s.createElement(u.Stack,{sx:{...J,top:0,flexShrink:0}},s.createElement(u.Tabs,Q({variant:"fullWidth",size:"small",sx:{mt:.5}},f(),{onChange:(e,t)=>{f().onChange(e,t),n(t),_(t),b(t)}}),s.createElement(u.Tab,Q({label:(0,p.__)("Variables","elementor"),icon:s.createElement(d.ColorFilterIcon,{fontSize:"small"}),iconPosition:"start"},a("variables"))),s.createElement(u.Tab,Q({label:(0,p.__)("Classes","elementor"),icon:s.createElement(d.ColorSwatchIcon,{fontSize:"small"}),iconPosition:"start"},a("classes")))),s.createElement(u.Divider,null)),s.createElement(u.Box,Q({role:"tabpanel"},g(t),{sx:{flex:1,minHeight:0,display:"flex",flexDirection:"column",overflow:"hidden",pt:1}}),"variables"===t&&s.createElement(m.VariablesManagerPanelEmbedded,{onRequestClose:e,onExposeCloseAttempt:e=>{o.current=e}}),"classes"===t&&s.createElement(l.ClassManagerPanelEmbedded,{onRequestClose:e,onExposeCloseAttempt:e=>{i.current=e}}))))))}const Z="design-system",{panel:ee,usePanelStatus:te,usePanelActions:ne}=(0,r.__createPanel)({id:Z,component:function(){const{close:e}=ne();return s.createElement(X,{onRequestClose:e})},allowedEditModes:["edit",Z],onOpen:()=>{(0,n.changeEditMode)(Z)},onClose:async()=>{(0,n.changeEditMode)("edit"),await(0,a.reloadCurrentDocument)()},isOpenPreviousElement:!0}),oe="panel/elements/categories",ie="elementor/open-variables-manager",re="elementor/open-global-classes-manager",se="elementor/toggle-design-system",ae="elementor/design-system/set-tab",le="active-panel",ce="design-system",me="global-classes-manager",de="variables-manager";function ue(){const{open:e,close:t}=ne(),{isOpen:o}=te(),i=(0,s.useRef)(o);i.current=o,(0,s.useEffect)(()=>{const e=e=>{const n=e.detail?.tab;"variables"!==n&&"classes"!==n||(i.current&&w===n?t():i.current?window.dispatchEvent(new CustomEvent(ae,{detail:{tab:n}})):window.dispatchEvent(new CustomEvent("variables"===n?ie:re)))};return window.addEventListener(se,e),()=>{window.removeEventListener(se,e)}},[t]);const r=(0,s.useRef)(null),[a,l]=(0,s.useState)(!1);(0,s.useEffect)(()=>{a&&(l(!1),e())},[a,e]),(0,s.useEffect)(()=>(0,n.__privateListenTo)((0,n.routeOpenEvent)(oe),()=>{const e=r.current;e&&(r.current=null,v(e),l(!0))}),[]),(0,s.useEffect)(()=>{const e=(e,t)=>{const o=()=>{r.current=t,(0,n.__privateOpenRoute)(oe)};return window.addEventListener(e,o),()=>window.removeEventListener(e,o)},t=e(ie,"variables"),o=e(re,"classes");return()=>{t(),o()}},[]);const c=(0,s.useRef)(!1);return(0,s.useEffect)(()=>{const t=new URLSearchParams(window.location.search),o=t.get(le);if(!o)return;let i=null;if(o===ce){const e=t.get("design-system-tab");i="classes"===e?"classes":"variables"}else if(o===me)i="classes";else{if(o!==de)return;i="variables"}return(0,n.__privateListenTo)((0,n.routeOpenEvent)(oe),()=>{c.current||(c.current=!0,requestAnimationFrame(()=>{i&&v(i),e()}))})},[e]),null}function pe(){const{isOpen:e}=te(),{open:t,close:n}=ne(),o=(0,s.useCallback)(()=>{e?n():t()},[e,t,n]);return{title:(0,p.__)("Design System","elementor"),icon:d.DropletHalfFilledIcon,onClick:o,selected:e}}function ge(){(0,n.isExperimentActive)("e_editor_design_system_panel")&&((0,r.__registerPanel)(ee),(0,o.injectIntoLogic)({id:"design-system-entrypoints",component:ue}),i.toolsMenu.registerToggleAction({id:"open-design-system-toolbar",priority:21,useProps:pe}))}(window.elementorV2=window.elementorV2||{}).editorDesignSystem=t}(),window.elementorV2.editorDesignSystem?.init?.(); | |
| 1 | +(function(){var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,__commonJSMin=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),__copyProps=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},__toESM=(n,r,a)=>(a=n==null?{}:e(i(n)),__copyProps(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n)),o=__toESM(__commonJSMin(((e,t)=>{var n=Object.create,r=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.getPrototypeOf,s=Object.prototype.hasOwnProperty,__export=(e,t)=>{for(var n in t)r(e,n,{get:t[n],enumerable:!0})},__copyProps=(e,t,n,o)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of a(t))!s.call(e,c)&&c!==n&&r(e,c,{get:()=>t[c],enumerable:!(o=i(t,c))||o.enumerable});return e},__toESM=(e,t,i)=>(i=e==null?{}:n(o(e)),__copyProps(t||!e||!e.__esModule?r(i,`default`,{value:e,enumerable:!0}):i,e)),__toCommonJS=e=>__copyProps(r({},`__esModule`,{value:!0}),e),c={};__export(c,{getInitialDesignSystemTab:()=>getInitialDesignSystemTab,init:()=>init,panel:()=>X,persistDesignSystemTab:()=>persistDesignSystemTab,usePanelActions:()=>Q,usePanelStatus:()=>Z}),t.exports=__toCommonJS(c);var l=globalThis.elementorV2.editor,u=globalThis.elementorV2.editorAppBar,d=globalThis.elementorV2.editorPanels,f=__toESM(globalThis.React),p=globalThis.React,ee=globalThis.elementorV2.editorDocuments,m=globalThis.elementorV2.editorUi,h=globalThis.elementorV2.editorV1Adapters,g=globalThis.wp.i18n,te=__toESM(globalThis.React),_=globalThis.elementorV2.editorDocuments,v=globalThis.elementorV2.editorPanels,y=globalThis.elementorV2.editorV1Adapters,b=__toESM(globalThis.React),x=globalThis.React,ne=globalThis.elementorV2.editorDefaultStyles,re=globalThis.elementorV2.editorGlobalClasses,S=globalThis.elementorV2.editorPanels,ie=globalThis.elementorV2.editorUi,ae=globalThis.elementorV2.editorVariables,C=globalThis.elementorV2.icons,w=globalThis.elementorV2.ui,T=globalThis.wp.i18n,oe=`elementor_editor_design_system_active_tab`;function readStoredTab(){if(typeof window>`u`)return`defaults`;try{let e=window.localStorage.getItem(oe);if(e===`defaults`||e===`classes`||e===`variables`)return e}catch{}return`defaults`}var E=null,D=readStoredTab();function normalizeDesignSystemTab(e){return e}function setPendingDesignSystemTab(e){E=e}function getInitialDesignSystemTab(){if(E){let e=E;return E=null,D=e,persistDesignSystemTab(e),e}let e=readStoredTab();return D=e,e}function notifyDesignSystemTabChange(e){D=e}function getActiveDesignSystemTab(){return D}function persistDesignSystemTab(e){if(!(typeof window>`u`))try{window.localStorage.setItem(oe,e)}catch{}}var O=__toESM(globalThis.React),se=globalThis.elementorV2.editorCurrentUser,ce=globalThis.elementorV2.editorUi,k=globalThis.elementorV2.icons,le=globalThis.elementorV2.query,A=globalThis.elementorV2.ui,j=globalThis.wp.i18n,downloadBlob=(e,t)=>{let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,r.rel=`noopener`,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(n)},M=globalThis.elementorV2.editorNotifications,N=globalThis.wp.i18n,P=`design-system-export-started`,ue=`design-system-export-succeeded`,de=`design-system-export-failed`,notifyExportInProgress=()=>{(0,M.notify)({id:P,type:`info`,message:(0,N.__)(`Export in progress. Your file will download when it’s ready.`,`elementor`)})},notifyExportSuccess=()=>{(0,M.dismissNotification)(P),(0,M.notify)({id:ue,type:`success`,message:(0,N.__)(`Design system exported`,`elementor`)})},notifyExportFailure=e=>{(0,M.dismissNotification)(P),(0,M.notify)({id:de,type:`error`,message:(0,N.__)(`Your design system export failed`,`elementor`),additionalActionProps:[{size:`small`,variant:`outlined`,color:`error`,children:(0,N.__)(`Try again`,`elementor`),onClick:()=>{(0,M.dismissNotification)(de),e()}}]})},fe=globalThis.elementorV2.httpClient,pe=globalThis.elementorV2.query,me=`elementor/v1/import-export-customization`,he=`design-system-export`,ge=`design-system-export.zip`,_e=12e4,ve={include:[`settings`],kitInfo:{title:`design-system`,description:``,source:`local`},customization:{settings:{theme:!1,classes:!0,variables:!0}}},DesignSystemExportError=class extends Error{constructor(e){super(`Design system export failed`),this.name=`DesignSystemExportError`,this.cause=e}},useExportRequest=()=>(0,pe.useMutation)({mutationKey:[he],mutationFn:async()=>{try{let{data:e}=await(0,fe.httpService)().post(`${me}/export`,ve,{timeout:_e});return{fileName:ge,blob:base64ToZipBlob(e.data.file)}}catch(e){throw new DesignSystemExportError(e)}}}),base64ToZipBlob=e=>{let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return new Blob([n],{type:`application/zip`})},ye=globalThis.elementorV2.editorCanvas,be=globalThis.elementorV2.editorV1Adapters,F=globalThis.elementorV2.httpClient,xe=globalThis.elementorV2.query,I=`elementor/v1/import-export-customization`,L=12e4,Se=[`global-classes`,`global-variables`],R=`design-system-import`,useImportRequest=()=>(0,xe.useMutation)({mutationKey:[R],mutationFn:async({file:e,conflictStrategy:t})=>{await(0,be.__privateRunCommand)(`document/save/auto`,{force:!0});let n=await uploadKit(e);await runRunners(n,await startImport(n,t)),window.dispatchEvent(new CustomEvent(ye.GLOBAL_STYLES_IMPORTED_EVENT))}}),DesignSystemUploadValidationError=class extends Error{constructor(e){super(`Design system upload validation failed`),this.name=`DesignSystemUploadValidationError`,this.cause=e}},uploadKit=async e=>{let t=new FormData;t.append(`e_import_file`,e);try{let{data:e}=await(0,F.httpService)().post(`${I}/upload`,t,{headers:{"Content-Type":`multipart/form-data`},timeout:L});return e.data.session}catch(e){throw new DesignSystemUploadValidationError(e)}},startImport=async(e,t)=>{let n={"design-system":{conflict_resolution:t===`keep`?`skip`:`replace`}},{data:r}=await(0,F.httpService)().post(`${I}/import`,{session:e,include:[`design-system`],customization:n},{timeout:L});return(r.data.runners??[]).filter(e=>Se.includes(e))},runRunners=async(e,t)=>{for(let n of t)await(0,F.httpService)().post(`${I}/import-runner`,{session:e,runner:n},{timeout:L})},z=__toESM(globalThis.React),B=globalThis.elementorV2.editorUi,Ce=globalThis.elementorV2.icons,V=globalThis.elementorV2.ui,H=globalThis.wp.i18n,U=__toESM(globalThis.React),W=globalThis.elementorV2.ui,G=globalThis.wp.i18n,getOptions=()=>[{value:`replace`,title:(0,G.__)(`Replace existing values`,`elementor`),description:(0,G.__)(`Imported design system values will overwrite existing variables and classes.`,`elementor`)},{value:`keep`,title:(0,G.__)(`Keep existing values`,`elementor`),description:(0,G.__)(`Existing variables and classes will not change.`,`elementor`)}],ConflictOptions=({value:e,onChange:t})=>{let n=getOptions();return U.createElement(W.Stack,{spacing:1},U.createElement(W.Typography,{variant:`body1`},(0,G.__)(`How to handle conflicts with existing variables or classes?`,`elementor`)),U.createElement(W.RadioGroup,{value:e??``,onChange:(e,n)=>t(n)},U.createElement(W.Stack,{spacing:1},n.map(n=>U.createElement(W.Card,{key:n.value,variant:`outlined`},U.createElement(W.CardActionArea,{onClick:()=>t(n.value)},U.createElement(W.Stack,{direction:`row`,alignItems:`center`,spacing:2,padding:2},U.createElement(W.Radio,{value:n.value,checked:e===n.value,inputProps:{"aria-label":n.title}}),U.createElement(W.Stack,{direction:`column`,spacing:.5},U.createElement(W.Typography,{variant:`subtitle2`},n.title),U.createElement(W.Typography,{variant:`caption`,color:`text.secondary`},n.description)))))))))},we=globalThis.React,Te={file:null,conflictStrategy:null},useDialogState=()=>{let[e,t]=(0,we.useState)(Te),setFile=e=>t(t=>({...t,file:e})),setConflictStrategy=e=>t(t=>({...t,conflictStrategy:e}));return{...e,setFile,setConflictStrategy}},K=globalThis.elementorV2.editorNotifications,Ee=globalThis.elementorV2.query,q=globalThis.wp.i18n,J=`design-system-import-started`,De=`design-system-import-succeeded`,Oe=`design-system-import-failed`,notifyImportInProgress=()=>{(0,K.notify)({id:J,type:`info`,message:(0,q.__)(`Import in Progress. You will be notified when the import is complete.`,`elementor`)})},notifyImportSuccess=()=>{(0,K.dismissNotification)(J),(0,K.notify)({id:De,type:`success`,message:(0,q.__)(`Design system imported`,`elementor`)})},notifyImportFailure=e=>{(0,K.dismissNotification)(J),(0,K.notify)({id:Oe,type:`error`,message:(0,q.__)(`Your design system import failed`,`elementor`),additionalActionProps:[{size:`small`,variant:`outlined`,color:`error`,children:(0,q.__)(`Try again`,`elementor`),onClick:()=>{(0,K.dismissNotification)(Oe),!((0,Ee.getQueryClient)().isMutating({mutationKey:[R]})>0)&&e()}}]})},ke=globalThis.elementorV2.events,Ae=`design_system`,trackDesignSystem=e=>{let{dispatchEvent:t,config:n}=(0,ke.getMixpanel)(),r=n?.names?.design_system?.[e.event];if(!r)return;let{event:i,...a}=e;try{t?.(r,{event:i,...a})}catch{}},je=[`application/zip`],Me=`application/zip,.zip`,Ne=3,Pe=`https://go.elementor.com/wp-dash-import-export-design-system/`,reopenSelf=()=>{trackDesignSystem({event:`importOpened`}),(0,B.openDialog)({component:z.createElement(ImportDesignSystemDialog,{onClose:B.closeDialog})})},ImportDesignSystemDialog=({onClose:e})=>{let{file:t,conflictStrategy:n,setFile:r,setConflictStrategy:i}=useDialogState(),a=useImportRequest(),o=!!(t&&n),handleFileSelected=e=>{r(e),trackDesignSystem({event:`fileSelected`,file_type:Ae})},handleConflictChange=e=>{i(e),trackDesignSystem({event:`conflictChoice`,choice:e})},handleImport=async()=>{if(!(!t||!n)){trackDesignSystem({event:`confirmed`,conflict_choice:n}),notifyImportInProgress(),e();try{await a.mutateAsync({file:t,conflictStrategy:n}),trackDesignSystem({event:`imported`}),notifyImportSuccess()}catch(e){e instanceof DesignSystemUploadValidationError?trackDesignSystem({event:`validationFailed`,file_type:Ae}):trackDesignSystem({event:`importFailed`}),notifyImportFailure(reopenSelf)}}};return z.createElement(z.Fragment,null,z.createElement(V.DialogHeader,{logo:!1},z.createElement(V.DialogTitle,null,(0,H.__)(`Import Design System`,`elementor`))),z.createElement(V.DialogContent,null,z.createElement(V.Stack,{spacing:3},t?z.createElement(B.FileUploadRow,{file:t,onRemove:()=>r(null)}):z.createElement(B.FileUploadDropzone,{onFileSelected:handleFileSelected,allowedFileTypes:je,accept:Me,regionLabel:(0,H.__)(`Design system file dropzone`,`elementor`),helperText:(0,H.sprintf)((0,H.__)(`zip (max. %dMB)`,`elementor`),Ne)}),z.createElement(ConflictOptions,{value:n,onChange:handleConflictChange}),z.createElement(V.Stack,{direction:`row`,spacing:.5,alignItems:`center`,justifyContent:`flex-start`},z.createElement(Ce.HelpIcon,{sx:{fontSize:16,color:`text.tertiary`}}),z.createElement(V.Link,{href:Pe,target:`_blank`,rel:`noopener noreferrer`,underline:`always`,variant:`caption`,color:`text.tertiary`},(0,H.__)(`Learn how design system imports work`,`elementor`))))),z.createElement(V.DialogActions,null,z.createElement(V.Button,{size:`medium`,color:`secondary`,onClick:e},(0,H.__)(`Cancel`,`elementor`)),z.createElement(V.Button,{size:`medium`,variant:`contained`,color:`primary`,disabled:!o,onClick:handleImport},(0,H.__)(`Import`,`elementor`))))},Fe=`design-system-header-menu`,DesignSystemHeaderMenu=()=>{let{isAdmin:e}=(0,se.useCurrentUserCapabilities)(),t=(0,A.usePopupState)({variant:`popover`,popupId:Fe}),n=useExportRequest(),r=(0,le.useIsMutating)({mutationKey:[R]})>0,i=(0,le.useIsMutating)({mutationKey:[he]})>0,a=r||i,o=(0,A.bindTrigger)(t),handleImport=()=>{t.close(),trackDesignSystem({event:`importOpened`}),(0,ce.openDialog)({component:O.createElement(ImportDesignSystemDialog,{onClose:ce.closeDialog})})},runExport=async()=>{notifyExportInProgress();try{let{blob:e,fileName:t}=await n.mutateAsync();downloadBlob(e,t),notifyExportSuccess()}catch{notifyExportFailure(runExport)}},handleExport=()=>{t.close(),trackDesignSystem({event:`export`}),runExport()},s=(0,j.__)(`Design system actions`,`elementor`),c=(0,j.__)(`Export is in progress. The file will be downloaded when it's complete.`,`elementor`),l=(0,j.__)(`Import is in progress. You will receive a notification when it's complete.`,`elementor`),u=s;return a&&(u=i?c:l),O.createElement(O.Fragment,null,e&&O.createElement(A.Tooltip,{title:u,placement:`top`},O.createElement(`span`,null,O.createElement(A.IconButton,{...o,size:`small`,"aria-label":s,disabled:a},O.createElement(k.DotsVerticalIcon,{fontSize:`small`})))),O.createElement(A.Menu,{...(0,A.bindMenu)(t),MenuListProps:{dense:!0},PaperProps:{elevation:6},anchorOrigin:{vertical:`bottom`,horizontal:`right`},transformOrigin:{vertical:`top`,horizontal:`right`}},O.createElement(A.MenuItem,{onClick:handleImport,disabled:r},O.createElement(A.ListItemIcon,null,O.createElement(k.DownloadIcon,{fontSize:`tiny`})),O.createElement(A.ListItemText,null,(0,j.__)(`Import`,`elementor`))),O.createElement(A.MenuItem,{onClick:handleExport,disabled:i},O.createElement(A.ListItemIcon,null,O.createElement(k.UploadIcon,{fontSize:`tiny`})),O.createElement(A.ListItemText,null,(0,j.__)(`Export`,`elementor`)))))},Ie={position:`sticky`,zIndex:1100,opacity:1,backgroundColor:`background.default`,transition:`top 300ms ease`},Le=`elementor/design-system/set-tab`,trackDesignSystemTabOpened=e=>{switch(e){case`classes`:(0,re.trackGlobalClasses)({event:`classManagerOpened`,source:`system-panel`});break;case`variables`:(0,ae.trackVariablesManagerEvent)({action:`openManager`,source:`system-panel`});break}};function DesignSystemPanelContent({onRequestClose:e}){let[t,n]=(0,x.useState)(()=>getInitialDesignSystemTab()),r=(0,x.useRef)(null),i=(0,x.useRef)(null),a=(0,x.useRef)(null),o=(0,x.useRef)(!1),{getTabProps:s,getTabPanelProps:c,getTabsProps:l}=(0,w.useTabs)(t),u=(0,x.useCallback)(()=>{if(!o.current&&a.current){o.current=!0,a.current(),o.current=!1;return}e()},[e]),d=(0,x.useCallback)(()=>{if(!o.current&&i.current){o.current=!0,i.current(),o.current=!1;return}e()},[e]),f=(0,x.useCallback)(()=>{if(!o.current&&r.current){o.current=!0,r.current(),o.current=!1;return}e()},[e]);(0,x.useEffect)(()=>{notifyDesignSystemTabChange(t)},[t]),(0,x.useEffect)(()=>{let handler=e=>{let t=e.detail?.tab;if(!t)return;let r=normalizeDesignSystemTab(t);n(r),persistDesignSystemTab(r),notifyDesignSystemTabChange(r),trackDesignSystemTabOpened(r)};return window.addEventListener(Le,handler),()=>{window.removeEventListener(Le,handler)}},[]);let handleHeaderClose=()=>{if(t===`defaults`&&r.current){r.current();return}if(t===`variables`&&i.current){i.current();return}if(t===`classes`&&a.current){a.current();return}e()};return b.createElement(ie.ThemeProvider,null,b.createElement(S.Panel,null,b.createElement(S.PanelHeader,null,b.createElement(w.Stack,{p:1,pl:2,width:`100%`,direction:`row`,alignItems:`center`,spacing:.5},b.createElement(S.PanelHeaderTitle,{sx:{flex:1,minWidth:0}},(0,T.__)(`Design system`,`elementor`)),b.createElement(DesignSystemHeaderMenu,null),b.createElement(w.CloseButton,{"aria-label":(0,T.__)(`Close`,`elementor`),sx:{flexShrink:0},onClick:()=>void handleHeaderClose()}))),b.createElement(S.PanelBody,{sx:{display:`flex`,flexDirection:`column`,height:`100%`,overflow:`hidden`,minHeight:0}},b.createElement(w.Stack,{direction:`column`,sx:{width:`100%`,flex:1,minHeight:0,overflow:`hidden`}},b.createElement(w.Stack,{sx:{...Ie,top:0,flexShrink:0}},b.createElement(w.Tabs,{variant:`fullWidth`,size:`small`,sx:{mt:.5},...l(),onChange:(e,t)=>{l().onChange(e,t),n(t),persistDesignSystemTab(t),notifyDesignSystemTabChange(t),trackDesignSystemTabOpened(t)}},b.createElement(w.Tab,{label:(0,T.__)(`Defaults`,`elementor`),icon:b.createElement(C.TextIcon,{fontSize:`small`}),iconPosition:`start`,...s(`defaults`)}),b.createElement(w.Tab,{label:(0,T.__)(`Variables`,`elementor`),icon:b.createElement(C.ColorFilterIcon,{fontSize:`small`}),iconPosition:`start`,...s(`variables`)}),b.createElement(w.Tab,{label:(0,T.__)(`Classes`,`elementor`),icon:b.createElement(C.ColorSwatchIcon,{fontSize:`small`}),iconPosition:`start`,...s(`classes`)})),b.createElement(w.Divider,null)),b.createElement(w.Box,{role:`tabpanel`,...c(`defaults`),sx:{flex:1,minHeight:0,display:t===`defaults`?`flex`:`none`,flexDirection:`column`,overflow:`hidden`,pt:1}},b.createElement(ne.DefaultStylesTabEmbedded,{onRequestClose:d,onExposeCloseAttempt:e=>{r.current=e}})),b.createElement(w.Box,{role:`tabpanel`,...c(`variables`),sx:{flex:1,minHeight:0,display:t===`variables`?`flex`:`none`,flexDirection:`column`,overflow:`hidden`,pt:1}},b.createElement(ae.VariablesManagerPanelEmbedded,{onRequestClose:u,onExposeCloseAttempt:e=>{i.current=e}})),b.createElement(w.Box,{role:`tabpanel`,...c(`classes`),sx:{flex:1,minHeight:0,display:t===`classes`?`flex`:`none`,flexDirection:`column`,overflow:`hidden`,pt:1}},b.createElement(re.ClassManagerPanelEmbedded,{onRequestClose:f,onExposeCloseAttempt:e=>{a.current=e},isActive:t===`classes`}))))))}var Y=`design-system`,{panel:X,usePanelStatus:Z,usePanelActions:Q}=(0,v.createPanel)({id:Y,component:DesignSystemPanelRoot,allowedEditModes:[`edit`,Y],onOpen:()=>{(0,y.changeEditMode)(Y)},onClose:async()=>{(0,y.changeEditMode)(`edit`),await(0,_.reloadCurrentDocument)()},isOpenPreviousElement:!0});function DesignSystemPanelRoot(){let{close:e}=Q();return te.createElement(DesignSystemPanelContent,{onRequestClose:e})}var $=`panel/elements/categories`,Re=`elementor/open-default-styles`,ze=`elementor/open-variables-manager`,Be=`elementor/open-global-classes-manager`,Ve=`elementor/toggle-design-system`,He=`elementor/design-system/set-tab`,Ue=`active-panel`,We=`design-system`,Ge=`default-styles`,Ke=`global-classes-manager`,qe=`variables-manager`,Je={defaults:Re,variables:ze,classes:Be};function DesignSystemEntrypoints(){let{open:e,close:t}=Q(),{isOpen:n}=Z(),r=(0,ee.__useActiveDocument)(),{save:i}=(0,ee.__useActiveDocumentActions)(),{open:a,close:o,isOpen:s}=(0,m.useDialog)(),c=(0,p.useRef)(r);c.current=r;let l=(0,p.useRef)(null),u=(0,p.useCallback)(e=>{if(c.current?.isDirty){l.current=e,a();return}e()},[a]),d=(0,p.useCallback)(async()=>{try{await i(),o(),l.current?.(),l.current=null}catch{}},[i,o]),te=(0,p.useCallback)(()=>{o(),l.current=null},[o]),_=(0,p.useRef)(n);_.current=n,(0,p.useEffect)(()=>{let handler=e=>{let n=e.detail?.tab;if(n===`defaults`||n===`variables`||n===`classes`){if(_.current&&getActiveDesignSystemTab()===n){t();return}if(_.current){window.dispatchEvent(new CustomEvent(He,{detail:{tab:n}}));return}u(()=>{window.dispatchEvent(new CustomEvent(Je[n]))})}};return window.addEventListener(Ve,handler),()=>{window.removeEventListener(Ve,handler)}},[t,u]);let v=(0,p.useRef)(null),[y,b]=(0,p.useState)(!1);(0,p.useEffect)(()=>{y&&(b(!1),e())},[y,e]),(0,p.useEffect)(()=>(0,h.__privateListenTo)((0,h.routeOpenEvent)($),()=>{let e=v.current;e&&(v.current=null,setPendingDesignSystemTab(e),b(!0))}),[]),(0,p.useEffect)(()=>{let bind=(e,t)=>{let handler=()=>{v.current=t,(0,h.__privateOpenRoute)($)};return window.addEventListener(e,handler),()=>window.removeEventListener(e,handler)},e=bind(Re,`defaults`),t=bind(ze,`variables`),n=bind(Be,`classes`);return()=>{e(),t(),n()}},[]);let x=(0,p.useRef)(!1);return(0,p.useEffect)(()=>{let t=new URLSearchParams(window.location.search),n=t.get(Ue);if(!n)return;let r=null;if(n===We){let e=t.get(`design-system-tab`);r=e===`classes`?`classes`:e===`variables`?`variables`:`defaults`}else if(n===Ge)r=`defaults`;else if(n===Ke)r=`classes`;else if(n===qe)r=`variables`;else return;return(0,h.__privateListenTo)((0,h.routeOpenEvent)($),()=>{x.current||(x.current=!0,requestAnimationFrame(()=>{r&&setPendingDesignSystemTab(r),u(()=>void e())}))})},[e,u]),s?f.createElement(m.ThemeProvider,null,f.createElement(m.SaveChangesDialog,null,f.createElement(m.SaveChangesDialog.Title,null,(0,g.__)(`You have unsaved changes`,`elementor`)),f.createElement(m.SaveChangesDialog.Content,null,f.createElement(m.SaveChangesDialog.ContentText,{sx:{mb:2}},(0,g.__)(`To open the Design System, save your page first. You can't continue without saving.`,`elementor`))),f.createElement(m.SaveChangesDialog.Actions,{actions:{cancel:{label:(0,g.__)(`Stay here`,`elementor`),action:te},confirm:{label:(0,g.__)(`Save & Continue`,`elementor`),action:d}}}))):null}var Ye=globalThis.elementorV2.icons,Xe=globalThis.wp.i18n,Ze=`elementor/toggle-design-system`;function useOpenDesignSystemToolbar(){let{isOpen:e}=Z();return{title:(0,Xe.__)(`Design System`,`elementor`),icon:Ye.DropletHalfFilledIcon,onClick:()=>{e||trackDesignSystem({event:`opened`});let t=getActiveDesignSystemTab();window.dispatchEvent(new CustomEvent(Ze,{detail:{tab:t}}))},selected:e}}function init(){(0,d.registerPanel)(X),(0,l.injectIntoLogic)({id:`design-system-entrypoints`,component:DesignSystemEntrypoints}),u.toolsMenu.registerToggleAction({id:`open-design-system-toolbar`,priority:4,useProps:useOpenDesignSystemToolbar})}0&&(t.exports={getInitialDesignSystemTab,init,panel:X,persistDesignSystemTab,usePanelActions:Q,usePanelStatus:Z})}))());(window.elementorV2=window.elementorV2||{}).editorDesignSystem=o})(),window.elementorV2.editorDesignSystem?.init?.(); | |