@elementor/editor-panels 0.1.0

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/README.md ADDED
@@ -0,0 +1,76 @@
1
+ # Editor Panels
2
+
3
+ > **Warning**
4
+ >
5
+ > This package is under development and not ready for production use.
6
+
7
+ ## Usage
8
+
9
+ Creating panel contains 3 steps:
10
+
11
+ 1. Creating the panel component
12
+ ```tsx
13
+ // components/my-panel.tsx
14
+ import { Panel, PanelHeader, PanelHeaderTitle, PanelBody } from '@elementor/editor-panels';
15
+
16
+ export default function MyPanel() {
17
+ return (
18
+ <Panel>
19
+ <PanelHeader>
20
+ <PanelHeaderTitle>{/* Panel title */}</PanelHeaderTitle>
21
+ </PanelHeader>
22
+ <PanelBody>
23
+ {/* Here should be all the content of the panel */}
24
+ </PanelBody>
25
+ </Panel>
26
+ );
27
+ }
28
+ ```
29
+
30
+ 2. Creating an instance of the panel
31
+ ```ts
32
+ // panel.ts
33
+ import { createPanel } from '@elementor/editor-panels';
34
+ import MyPanel from './components/my-panel';
35
+
36
+ export const {
37
+ panel,
38
+ usePanelStatus,
39
+ usePanelActions,
40
+ } = createPanel( {
41
+ id: 'my-panel',
42
+ component: MyPanel
43
+ } );
44
+ ```
45
+
46
+ 3. Registering the panel
47
+ ```ts
48
+ // init.ts
49
+ import { registerPanel } from '@elementor/editor-panels';
50
+ import panel from './panel';
51
+
52
+ function init() {
53
+ registerPanel( panel );
54
+ }
55
+ ```
56
+
57
+ ### Using panel actions and state
58
+
59
+ To change the state of a panel (open/close) or read the state of a panel, you can use 2 hooks that are being returned from the `createPanel` function.
60
+ Let's assume that we have a button that should open the panel when clicked, and close it when clicked again.
61
+
62
+ ```tsx
63
+ // components/my-panel-button.tsx
64
+ import { usePanelStatus, usePanelActions } from '../panel';
65
+
66
+ export default function MyPanelButton() {
67
+ const { isOpen, isBlocked } = usePanelStatus();
68
+ const { openPanel, closePanel } = usePanelActions();
69
+
70
+ return (
71
+ <button onClick={ isOpen ? closePanel : openPanel } disabled={ isBlocked }>
72
+ { isOpen ? 'Close panel' : 'Open panel' }
73
+ </button>
74
+ );
75
+ }
76
+ ```
@@ -0,0 +1,33 @@
1
+ import * as React from 'react';
2
+ import { ComponentType } from 'react';
3
+ import { DrawerProps, BoxProps, TypographyProps } from '@elementor/ui';
4
+
5
+ type PanelDeclaration = {
6
+ id: string;
7
+ component: ComponentType;
8
+ };
9
+ declare function createPanel({ id, component }: PanelDeclaration): {
10
+ panel: {
11
+ id: string;
12
+ component: ComponentType;
13
+ };
14
+ usePanelStatus: () => {
15
+ isOpen: boolean;
16
+ isBlocked: boolean;
17
+ };
18
+ usePanelActions: () => {
19
+ open: () => Promise<void>;
20
+ close: () => Promise<void>;
21
+ };
22
+ };
23
+ declare function registerPanel({ id, component }: Pick<PanelDeclaration, 'id' | 'component'>): void;
24
+
25
+ declare function Panel({ children, sx, ...props }: DrawerProps): React.JSX.Element;
26
+
27
+ declare function PanelHeader({ children, ...props }: BoxProps): React.JSX.Element;
28
+
29
+ declare function PanelHeaderTitle({ children, ...props }: TypographyProps): React.JSX.Element;
30
+
31
+ declare function PanelBody({ children, sx, ...props }: BoxProps): React.JSX.Element;
32
+
33
+ export { Panel, PanelBody, PanelHeader, PanelHeaderTitle, createPanel, registerPanel };
package/dist/index.js ADDED
@@ -0,0 +1,351 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var src_exports = {};
32
+ __export(src_exports, {
33
+ Panel: () => Panel,
34
+ PanelBody: () => PanelBody,
35
+ PanelHeader: () => PanelHeader,
36
+ PanelHeaderTitle: () => PanelHeaderTitle,
37
+ createPanel: () => createPanel,
38
+ registerPanel: () => registerPanel
39
+ });
40
+ module.exports = __toCommonJS(src_exports);
41
+
42
+ // src/init.ts
43
+ var import_editor = require("@elementor/editor");
44
+ var import_store6 = require("@elementor/store");
45
+
46
+ // src/components/internal/panels.tsx
47
+ var React2 = __toESM(require("react"));
48
+
49
+ // src/hooks/use-open-panel-injection.ts
50
+ var import_store2 = require("@elementor/store");
51
+
52
+ // src/location.ts
53
+ var import_locations = require("@elementor/locations");
54
+ var {
55
+ inject: injectIntoPanels,
56
+ useInjections: usePanelsInjections
57
+ } = (0, import_locations.createLocation)();
58
+
59
+ // src/store/selectors.ts
60
+ var selectOpenId = (state) => state.panels.openId;
61
+
62
+ // src/store/slice.ts
63
+ var import_store = require("@elementor/store");
64
+ var initialState = {
65
+ openId: null
66
+ };
67
+ var slice_default = (0, import_store.createSlice)({
68
+ name: "panels",
69
+ initialState,
70
+ reducers: {
71
+ open(state, action) {
72
+ state.openId = action.payload;
73
+ },
74
+ close(state, action) {
75
+ if (!action.payload || state.openId === action.payload) {
76
+ state.openId = null;
77
+ }
78
+ }
79
+ }
80
+ });
81
+
82
+ // src/hooks/use-open-panel-injection.ts
83
+ var import_react = require("react");
84
+ function useOpenPanelInjection() {
85
+ const injections = usePanelsInjections();
86
+ const openId = (0, import_store2.useSelector)(selectOpenId);
87
+ return (0, import_react.useMemo)(
88
+ () => injections.find((injection) => openId === injection.id),
89
+ [injections, openId]
90
+ );
91
+ }
92
+
93
+ // src/components/internal/portal.tsx
94
+ var React = __toESM(require("react"));
95
+ var import_ui = require("@elementor/ui");
96
+ var import_react2 = require("react");
97
+
98
+ // src/sync.ts
99
+ var import_editor_v1_adapters = require("@elementor/editor-v1-adapters");
100
+ var import_store4 = require("@elementor/store");
101
+ var V2_PANEL = "panel/v2";
102
+ function getPortalContainer() {
103
+ return document.querySelector("#elementor-panel-inner");
104
+ }
105
+ function useV1PanelStatus() {
106
+ return (0, import_editor_v1_adapters.useRouteStatus)(V2_PANEL, {
107
+ blockOnKitRoutes: true,
108
+ blockOnPreviewMode: true
109
+ });
110
+ }
111
+ function sync() {
112
+ (0, import_editor_v1_adapters.listenTo)(
113
+ (0, import_editor_v1_adapters.windowEvent)("elementor/panel/init"),
114
+ () => (0, import_editor_v1_adapters.registerRoute)(V2_PANEL)
115
+ );
116
+ (0, import_editor_v1_adapters.listenTo)(
117
+ (0, import_editor_v1_adapters.routeOpenEvent)(V2_PANEL),
118
+ () => {
119
+ getV1PanelElements().forEach((el) => {
120
+ el.setAttribute("hidden", "hidden");
121
+ el.setAttribute("aria-hidden", "true");
122
+ });
123
+ }
124
+ );
125
+ (0, import_editor_v1_adapters.listenTo)(
126
+ (0, import_editor_v1_adapters.routeCloseEvent)(V2_PANEL),
127
+ () => selectOpenId((0, import_store4.getState)()) && (0, import_store4.dispatch)(slice_default.actions.close())
128
+ );
129
+ (0, import_editor_v1_adapters.listenTo)(
130
+ (0, import_editor_v1_adapters.routeCloseEvent)(V2_PANEL),
131
+ () => {
132
+ getV1PanelElements().forEach((el) => {
133
+ el.removeAttribute("hidden");
134
+ el.removeAttribute("aria-hidden");
135
+ });
136
+ }
137
+ );
138
+ (0, import_editor_v1_adapters.listenTo)(
139
+ (0, import_editor_v1_adapters.windowEvent)("elementor/panel/init"),
140
+ () => subscribe({
141
+ on: (state) => selectOpenId(state),
142
+ when: ({ prev, current }) => !!(!prev && current),
143
+ // is panel opened
144
+ callback: () => (0, import_editor_v1_adapters.openRoute)(V2_PANEL)
145
+ })
146
+ );
147
+ (0, import_editor_v1_adapters.listenTo)(
148
+ (0, import_editor_v1_adapters.windowEvent)("elementor/panel/init"),
149
+ () => subscribe({
150
+ on: (state) => selectOpenId(state),
151
+ when: ({ prev, current }) => !!(!current && prev),
152
+ // is panel closed
153
+ callback: () => (0, import_editor_v1_adapters.isRouteActive)(V2_PANEL) && (0, import_editor_v1_adapters.openRoute)(getDefaultRoute())
154
+ })
155
+ );
156
+ }
157
+ function getV1PanelElements() {
158
+ const v1ElementsSelector = [
159
+ "#elementor-panel-header-wrapper",
160
+ "#elementor-panel-content-wrapper",
161
+ "#elementor-panel-state-loading",
162
+ "#elementor-panel-footer"
163
+ ].join(", ");
164
+ return document.querySelectorAll(v1ElementsSelector);
165
+ }
166
+ function getDefaultRoute() {
167
+ const defaultRoute = window?.elementor?.documents?.getCurrent?.()?.config?.panel?.default_route;
168
+ return defaultRoute || "panel/elements/categories";
169
+ }
170
+ function subscribe({
171
+ on,
172
+ when,
173
+ callback
174
+ }) {
175
+ let prev;
176
+ (0, import_store4.subscribe)(() => {
177
+ const current = on((0, import_store4.getState)());
178
+ if (when({ prev, current })) {
179
+ callback({ prev, current });
180
+ }
181
+ prev = current;
182
+ });
183
+ }
184
+
185
+ // src/components/internal/portal.tsx
186
+ function Portal(props) {
187
+ const containerRef = (0, import_react2.useRef)(getPortalContainer);
188
+ if (!containerRef.current) {
189
+ return null;
190
+ }
191
+ return /* @__PURE__ */ React.createElement(import_ui.Portal, { container: containerRef.current, ...props });
192
+ }
193
+
194
+ // src/components/internal/panels.tsx
195
+ function Panels() {
196
+ const openPanel = useOpenPanelInjection();
197
+ const Component = openPanel?.filler ?? null;
198
+ if (!Component) {
199
+ return null;
200
+ }
201
+ return /* @__PURE__ */ React2.createElement(Portal, null, /* @__PURE__ */ React2.createElement(Component, null));
202
+ }
203
+
204
+ // src/init.ts
205
+ function init() {
206
+ sync();
207
+ (0, import_store6.registerSlice)(slice_default);
208
+ (0, import_editor.injectIntoTop)({ id: "panels", filler: Panels });
209
+ }
210
+
211
+ // src/api.ts
212
+ var import_store9 = require("@elementor/store");
213
+ function createPanel({ id, component }) {
214
+ const usePanelStatus = createUseStatus(id);
215
+ const usePanelActions = createUseActions(id, usePanelStatus);
216
+ return {
217
+ panel: {
218
+ id,
219
+ component
220
+ },
221
+ usePanelStatus,
222
+ usePanelActions
223
+ };
224
+ }
225
+ function registerPanel({ id, component }) {
226
+ injectIntoPanels({
227
+ id,
228
+ filler: component
229
+ });
230
+ }
231
+ function createUseStatus(id) {
232
+ return () => {
233
+ const openPanelId = (0, import_store9.useSelector)(selectOpenId);
234
+ const v1PanelStatus = useV1PanelStatus();
235
+ return {
236
+ isOpen: openPanelId === id && v1PanelStatus.isActive,
237
+ isBlocked: v1PanelStatus.isBlocked
238
+ };
239
+ };
240
+ }
241
+ function createUseActions(id, useStatus) {
242
+ return () => {
243
+ const dispatch2 = (0, import_store9.useDispatch)();
244
+ const { isBlocked } = useStatus();
245
+ return {
246
+ open: async () => {
247
+ if (isBlocked) {
248
+ return;
249
+ }
250
+ dispatch2(slice_default.actions.open(id));
251
+ },
252
+ close: async () => {
253
+ if (isBlocked) {
254
+ return;
255
+ }
256
+ dispatch2(slice_default.actions.close(id));
257
+ }
258
+ };
259
+ };
260
+ }
261
+
262
+ // src/components/external/panel.tsx
263
+ var React3 = __toESM(require("react"));
264
+ var import_ui2 = require("@elementor/ui");
265
+ function Panel({ children, sx, ...props }) {
266
+ return /* @__PURE__ */ React3.createElement(
267
+ import_ui2.Drawer,
268
+ {
269
+ open: true,
270
+ variant: "persistent",
271
+ anchor: "left",
272
+ PaperProps: {
273
+ sx: {
274
+ position: "relative",
275
+ width: "100%",
276
+ bgcolor: "background.default",
277
+ border: "none"
278
+ }
279
+ },
280
+ sx: { height: "100%", ...sx },
281
+ ...props
282
+ },
283
+ children
284
+ );
285
+ }
286
+
287
+ // src/components/external/panel-header.tsx
288
+ var React4 = __toESM(require("react"));
289
+ var import_ui3 = require("@elementor/ui");
290
+ var Header = (0, import_ui3.styled)(import_ui3.Box)(({ theme }) => ({
291
+ height: theme?.sizing?.["600"] || "48px",
292
+ display: "flex",
293
+ alignItems: "center",
294
+ justifyContent: "center"
295
+ }));
296
+ function PanelHeader({ children, ...props }) {
297
+ return /* @__PURE__ */ React4.createElement(React4.Fragment, null, /* @__PURE__ */ React4.createElement(Header, { component: "header", ...props }, children), /* @__PURE__ */ React4.createElement(import_ui3.Divider, null));
298
+ }
299
+
300
+ // src/components/external/panel-header-title.tsx
301
+ var React5 = __toESM(require("react"));
302
+ var import_ui4 = require("@elementor/ui");
303
+ var Title = (0, import_ui4.styled)(import_ui4.Typography)(({ theme }) => ({
304
+ "&.MuiTypography-root": {
305
+ fontWeight: "bold",
306
+ fontSize: theme.typography.body1.fontSize
307
+ }
308
+ }));
309
+ function PanelHeaderTitle({ children, ...props }) {
310
+ return /* @__PURE__ */ React5.createElement(
311
+ Title,
312
+ {
313
+ component: "h2",
314
+ variant: "body1",
315
+ ...props
316
+ },
317
+ children
318
+ );
319
+ }
320
+
321
+ // src/components/external/panel-body.tsx
322
+ var React6 = __toESM(require("react"));
323
+ var import_ui5 = require("@elementor/ui");
324
+ function PanelBody({ children, sx, ...props }) {
325
+ return /* @__PURE__ */ React6.createElement(
326
+ import_ui5.Box,
327
+ {
328
+ component: "main",
329
+ sx: {
330
+ overflowY: "auto",
331
+ height: "100%",
332
+ ...sx
333
+ },
334
+ ...props
335
+ },
336
+ children
337
+ );
338
+ }
339
+
340
+ // src/index.ts
341
+ init();
342
+ // Annotate the CommonJS export names for ESM import in node:
343
+ 0 && (module.exports = {
344
+ Panel,
345
+ PanelBody,
346
+ PanelHeader,
347
+ PanelHeaderTitle,
348
+ createPanel,
349
+ registerPanel
350
+ });
351
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/init.ts","../src/components/internal/panels.tsx","../src/hooks/use-open-panel-injection.ts","../src/location.ts","../src/store/selectors.ts","../src/store/slice.ts","../src/components/internal/portal.tsx","../src/sync.ts","../src/api.ts","../src/components/external/panel.tsx","../src/components/external/panel-header.tsx","../src/components/external/panel-header-title.tsx","../src/components/external/panel-body.tsx"],"sourcesContent":["import init from './init';\n\nexport { createPanel, registerPanel } from './api';\nexport * from './components/external';\n\ninit();\n","import { injectIntoTop } from '@elementor/editor';\nimport { registerSlice } from '@elementor/store';\nimport Panels from './components/internal/panels';\nimport { sync } from './sync';\nimport { slice } from './store';\n\nexport default function init() {\n\tsync();\n\n\tregisterSlice( slice );\n\n\tinjectIntoTop( { id: 'panels', filler: Panels } );\n}\n","import * as React from 'react';\nimport useOpenPanelInjection from '../../hooks/use-open-panel-injection';\nimport Portal from './portal';\n\nexport default function Panels() {\n\tconst openPanel = useOpenPanelInjection();\n\tconst Component = openPanel?.filler ?? null;\n\n\tif ( ! Component ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Portal>\n\t\t\t<Component />\n\t\t</Portal>\n\t);\n}\n","import { useSelector } from '@elementor/store';\nimport { usePanelsInjections } from '../location';\nimport { selectOpenId } from '../store';\nimport { useMemo } from 'react';\n\nexport default function useOpenPanelInjection() {\n\tconst injections = usePanelsInjections();\n\tconst openId = useSelector( selectOpenId );\n\n\treturn useMemo(\n\t\t() => injections.find( ( injection ) => openId === injection.id ),\n\t\t[ injections, openId ]\n\t);\n}\n","import { createLocation } from '@elementor/locations';\n\nexport const {\n\tinject: injectIntoPanels,\n\tuseInjections: usePanelsInjections,\n} = createLocation();\n","import { SliceState } from '@elementor/store';\nimport slice from './slice';\n\ntype State = SliceState<typeof slice>;\n\nexport const selectOpenId = ( state: State ) => state.panels.openId;\n","import { createSlice, PayloadAction } from '@elementor/store';\n\nconst initialState: {\n\topenId: string | null;\n} = {\n\topenId: null,\n};\n\nexport default createSlice( {\n\tname: 'panels',\n\tinitialState,\n\treducers: {\n\t\topen( state, action: PayloadAction<string> ) {\n\t\t\tstate.openId = action.payload;\n\t\t},\n\t\tclose( state, action: PayloadAction<string | undefined> ) {\n\t\t\tif ( ! action.payload || state.openId === action.payload ) {\n\t\t\t\tstate.openId = null;\n\t\t\t}\n\t\t},\n\t},\n} );\n","import * as React from 'react';\nimport { Portal as BasePortal, PortalProps } from '@elementor/ui';\nimport { useRef } from 'react';\nimport { getPortalContainer } from '../../sync';\n\ntype Props = Omit<PortalProps, 'container'>;\n\nexport default function Portal( props: Props ) {\n\tconst containerRef = useRef( getPortalContainer );\n\n\tif ( ! containerRef.current ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<BasePortal container={ containerRef.current } { ...props } />\n\t);\n}\n","import {\n\topenRoute,\n\tlistenTo,\n\trouteCloseEvent,\n\tuseRouteStatus,\n\trouteOpenEvent,\n\twindowEvent,\n\tregisterRoute,\n\tisRouteActive,\n} from '@elementor/editor-v1-adapters';\nimport { dispatch, getState, subscribe as originalSubscribe } from '@elementor/store';\nimport { selectOpenId, slice } from './store';\n\nconst V2_PANEL = 'panel/v2';\n\nexport function getPortalContainer() {\n\treturn document.querySelector( '#elementor-panel-inner' );\n}\n\nexport function useV1PanelStatus() {\n\t// For now supporting only panels that are not part of the kit and not in preview mode.\n\treturn useRouteStatus( V2_PANEL, {\n\t\tblockOnKitRoutes: true,\n\t\tblockOnPreviewMode: true,\n\t} );\n}\n\nexport function sync() {\n\t// Register the V2 panel route on panel init.\n\tlistenTo(\n\t\twindowEvent( 'elementor/panel/init' ),\n\t\t() => registerRoute( V2_PANEL )\n\t);\n\n\t// On empty route open, hide V1 panel elements.\n\tlistenTo(\n\t\trouteOpenEvent( V2_PANEL ),\n\t\t() => {\n\t\t\tgetV1PanelElements().forEach( ( el ) => {\n\t\t\t\tel.setAttribute( 'hidden', 'hidden' );\n\t\t\t\tel.setAttribute( 'aria-hidden', 'true' );\n\t\t\t} );\n\t\t},\n\t);\n\n\t// On empty route close, close the V2 panel.\n\tlistenTo(\n\t\trouteCloseEvent( V2_PANEL ),\n\t\t() => selectOpenId( getState() ) && dispatch( slice.actions.close() )\n\t);\n\n\t// On empty route close, show V1 panel elements.\n\tlistenTo(\n\t\trouteCloseEvent( V2_PANEL ),\n\t\t() => {\n\t\t\tgetV1PanelElements().forEach( ( el ) => {\n\t\t\t\tel.removeAttribute( 'hidden' );\n\t\t\t\tel.removeAttribute( 'aria-hidden' );\n\t\t\t} );\n\t\t},\n\t);\n\n\t// On V2 panel open, open the V2 panel route.\n\tlistenTo(\n\t\twindowEvent( 'elementor/panel/init' ),\n\t\t() => subscribe( {\n\t\t\ton: ( state ) => selectOpenId( state ),\n\t\t\twhen: ( { prev, current } ) => !! ( ! prev && current ), // is panel opened\n\t\t\tcallback: () => openRoute( V2_PANEL ),\n\t\t} )\n\t);\n\n\t// On V2 panel close, close the V2 panel route.\n\tlistenTo(\n\t\twindowEvent( 'elementor/panel/init' ),\n\t\t() => subscribe( {\n\t\t\ton: ( state ) => selectOpenId( state ),\n\t\t\twhen: ( { prev, current } ) => !! ( ! current && prev ), // is panel closed\n\t\t\tcallback: () => isRouteActive( V2_PANEL ) && openRoute( getDefaultRoute() ),\n\t\t} )\n\t);\n}\n\nfunction getV1PanelElements() {\n\tconst v1ElementsSelector = [\n\t\t'#elementor-panel-header-wrapper',\n\t\t'#elementor-panel-content-wrapper',\n\t\t'#elementor-panel-state-loading',\n\t\t'#elementor-panel-footer',\n\t].join( ', ' );\n\n\treturn document.querySelectorAll( v1ElementsSelector );\n}\n\nfunction getDefaultRoute() {\n\ttype ExtendedWindow = Window & {\n\t\telementor?: {\n\t\t\tdocuments?: {\n\t\t\t\tgetCurrent?: () => {\n\t\t\t\t\tconfig?: {\n\t\t\t\t\t\tpanel?: {\n\t\t\t\t\t\t\tdefault_route?: string,\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t}\n\t\t}\n\t}\n\n\tconst defaultRoute = ( window as unknown as ExtendedWindow )\n\t\t?.elementor\n\t\t?.documents\n\t\t?.getCurrent?.()\n\t\t?.config\n\t\t?.panel\n\t\t?.default_route;\n\n\treturn defaultRoute || 'panel/elements/categories';\n}\n\nfunction subscribe<TVal>( {\n\ton,\n\twhen,\n\tcallback,\n}: {\n\ton: ( state: ReturnType<typeof getState> ) => TVal,\n\twhen: ( { prev, current }: { prev: TVal, current: TVal } ) => boolean,\n\tcallback: ( { prev, current }: { prev: TVal, current: TVal } ) => void,\n} ) {\n\tlet prev: TVal;\n\n\toriginalSubscribe( () => {\n\t\tconst current = on( getState() );\n\n\t\tif ( when( { prev, current } ) ) {\n\t\t\tcallback( { prev, current } );\n\t\t}\n\n\t\tprev = current;\n\t} );\n}\n","import { ComponentType } from 'react';\nimport { injectIntoPanels } from './location';\nimport { selectOpenId, slice } from './store';\nimport { useSelector, useDispatch } from '@elementor/store';\nimport { useV1PanelStatus } from './sync';\n\nexport type PanelDeclaration = {\n\tid: string;\n\tcomponent: ComponentType;\n}\n\nexport function createPanel( { id, component }: PanelDeclaration ) {\n\tconst usePanelStatus = createUseStatus( id );\n\tconst usePanelActions = createUseActions( id, usePanelStatus );\n\n\treturn {\n\t\tpanel: {\n\t\t\tid,\n\t\t\tcomponent,\n\t\t},\n\t\tusePanelStatus,\n\t\tusePanelActions,\n\t};\n}\n\nexport function registerPanel( { id, component }: Pick<PanelDeclaration, 'id' | 'component'> ) {\n\tinjectIntoPanels( {\n\t\tid,\n\t\tfiller: component,\n\t} );\n}\n\nfunction createUseStatus( id: PanelDeclaration['id'] ) {\n\treturn () => {\n\t\tconst openPanelId = useSelector( selectOpenId );\n\t\tconst v1PanelStatus = useV1PanelStatus();\n\n\t\treturn {\n\t\t\tisOpen: openPanelId === id && v1PanelStatus.isActive,\n\t\t\tisBlocked: v1PanelStatus.isBlocked,\n\t\t};\n\t};\n}\n\nfunction createUseActions( id: PanelDeclaration['id'], useStatus: ReturnType<typeof createUseStatus> ) {\n\treturn () => {\n\t\tconst dispatch = useDispatch();\n\t\tconst { isBlocked } = useStatus();\n\n\t\treturn {\n\t\t\topen: async () => {\n\t\t\t\tif ( isBlocked ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tdispatch( slice.actions.open( id ) );\n\t\t\t},\n\t\t\tclose: async () => {\n\t\t\t\tif ( isBlocked ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tdispatch( slice.actions.close( id ) );\n\t\t\t},\n\t\t};\n\t};\n}\n","import * as React from 'react';\nimport { Drawer, DrawerProps } from '@elementor/ui';\n\nexport default function Panel( { children, sx, ...props }: DrawerProps ) {\n\treturn (\n\t\t<Drawer\n\t\t\topen={ true }\n\t\t\tvariant=\"persistent\"\n\t\t\tanchor=\"left\"\n\t\t\tPaperProps={ {\n\t\t\t\tsx: {\n\t\t\t\t\tposition: 'relative',\n\t\t\t\t\twidth: '100%',\n\t\t\t\t\tbgcolor: 'background.default',\n\t\t\t\t\tborder: 'none',\n\t\t\t\t},\n\t\t\t} }\n\t\t\tsx={ { height: '100%', ...sx } }\n\t\t\t{ ...props }\n\t\t>\n\t\t\t{ children }\n\t\t</Drawer>\n\t);\n}\n","import * as React from 'react';\nimport { Box, BoxProps, Divider, styled } from '@elementor/ui';\n\nconst Header = styled( Box )( ( { theme } ) => ( {\n\theight: theme?.sizing?.[ '600' ] || '48px',\n\tdisplay: 'flex',\n\talignItems: 'center',\n\tjustifyContent: 'center',\n} ) );\n\nexport default function PanelHeader( { children, ...props }: BoxProps ) {\n\treturn (\n\t\t<>\n\t\t\t<Header component=\"header\" { ...props }>\n\t\t\t\t{ children }\n\t\t\t</Header>\n\t\t\t<Divider />\n\t\t</>\n\t);\n}\n","import * as React from 'react';\nimport { Typography, TypographyProps, styled } from '@elementor/ui';\n\nconst Title = styled( Typography )( ( { theme } ) => ( {\n\t'&.MuiTypography-root': {\n\t\tfontWeight: 'bold',\n\t\tfontSize: theme.typography.body1.fontSize,\n\t},\n} ) );\n\nexport default function PanelHeaderTitle( { children, ...props }: TypographyProps ) {\n\treturn (\n\t\t<Title\n\t\t\tcomponent=\"h2\"\n\t\t\tvariant=\"body1\"\n\t\t\t{ ...props }\n\t\t>\n\t\t\t{ children }\n\t\t</Title>\n\t);\n}\n","import * as React from 'react';\nimport { Box, BoxProps } from '@elementor/ui';\n\nexport default function PanelBody( { children, sx, ...props }: BoxProps ) {\n\treturn (\n\t\t<Box\n\t\t\tcomponent=\"main\"\n\t\t\tsx={ {\n\t\t\t\toverflowY: 'auto',\n\t\t\t\theight: '100%',\n\t\t\t\t...sx,\n\t\t\t} }\n\t\t\t{ ...props }\n\t\t>{ children }</Box>\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,oBAA8B;AAC9B,IAAAA,gBAA8B;;;ACD9B,IAAAC,SAAuB;;;ACAvB,IAAAC,gBAA4B;;;ACA5B,uBAA+B;AAExB,IAAM;AAAA,EACZ,QAAQ;AAAA,EACR,eAAe;AAChB,QAAI,iCAAe;;;ACAZ,IAAM,eAAe,CAAE,UAAkB,MAAM,OAAO;;;ACL7D,mBAA2C;AAE3C,IAAM,eAEF;AAAA,EACH,QAAQ;AACT;AAEA,IAAO,oBAAQ,0BAAa;AAAA,EAC3B,MAAM;AAAA,EACN;AAAA,EACA,UAAU;AAAA,IACT,KAAM,OAAO,QAAgC;AAC5C,YAAM,SAAS,OAAO;AAAA,IACvB;AAAA,IACA,MAAO,OAAO,QAA4C;AACzD,UAAK,CAAE,OAAO,WAAW,MAAM,WAAW,OAAO,SAAU;A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AAA,MACA,WAAU;AAAA,MACV,IAAK;AAAA,QACJ,WAAW;AAAA,QACX,QAAQ;AAAA,QACR,GAAG;AAAA,MACJ;AAAA,MACE,GAAG;AAAA;AAAA,IACH;AAAA,EAAU;AAEf;;;AbVA,KAAK;","names":["import_store","React","import_store","import_react","import_store","originalSubscribe","BasePortal","import_store","dispatch","React","import_ui","React","import_ui","React","import_ui","React","import_ui"]}