@elementor/editor-panels 0.4.16 → 0.5.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/CHANGELOG.md +18 -113
- package/dist/index.js +17 -43
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17 -43
- package/dist/index.mjs.map +1 -1
- package/package.json +50 -43
- package/src/api.ts +4 -4
- package/src/components/external/panel-body.tsx +3 -1
- package/src/components/external/panel-header-title.tsx +2 -6
- package/src/components/internal/portal.tsx +2 -4
- package/src/hooks/use-open-panel-injection.ts +1 -4
- package/src/index.ts +1 -4
- package/src/location.ts +1 -4
- package/src/store/selectors.ts +1 -1
- package/src/store/slice.ts +2 -2
- package/src/sync.ts +31 -50
- package/src/__tests__/api.test.tsx +0 -145
- package/src/__tests__/sync.test.tsx +0 -129
package/CHANGELOG.md
CHANGED
|
@@ -3,235 +3,140 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
**Note:** Version bump only for package @elementor/editor-panels
|
|
6
|
+
# [0.5.0](https://github.com/elementor/elementor-packages/compare/@elementor/editor-panels@0.4.17...@elementor/editor-panels@0.5.0) (2024-08-05)
|
|
9
7
|
|
|
8
|
+
### Bug Fixes
|
|
10
9
|
|
|
10
|
+
- publish only necessary files to npm ([#226](https://github.com/elementor/elementor-packages/issues/226)) ([d808e2f](https://github.com/elementor/elementor-packages/commit/d808e2f60eb7ca2d7b8560d0b79c0e62c2f969a8))
|
|
11
11
|
|
|
12
|
+
### Features
|
|
12
13
|
|
|
14
|
+
- **editor-editing-panel:** change textarea component [EDS-311] ([#221](https://github.com/elementor/elementor-packages/issues/221)) ([a9ab0d5](https://github.com/elementor/elementor-packages/commit/a9ab0d53e87086e323c4f024dca0eae93005e1a1))
|
|
15
|
+
- **editor-editing-panel:** settings and style tabs [EDS-277] ([#217](https://github.com/elementor/elementor-packages/issues/217)) ([c623797](https://github.com/elementor/elementor-packages/commit/c6237974d9940a2b58bdd1df3d835dc828e323f4))
|
|
13
16
|
|
|
14
|
-
## [0.4.
|
|
17
|
+
## [0.4.17](https://github.com/elementor/elementor-packages/compare/@elementor/editor-panels@0.4.16...@elementor/editor-panels@0.4.17) (2024-07-16)
|
|
15
18
|
|
|
16
19
|
**Note:** Version bump only for package @elementor/editor-panels
|
|
17
20
|
|
|
21
|
+
## [0.4.16](https://github.com/elementor/elementor-packages/compare/@elementor/editor-panels@0.4.15...@elementor/editor-panels@0.4.16) (2024-07-16)
|
|
18
22
|
|
|
23
|
+
**Note:** Version bump only for package @elementor/editor-panels
|
|
19
24
|
|
|
25
|
+
## [0.4.15](https://github.com/elementor/elementor-packages/compare/@elementor/editor-panels@0.4.14...@elementor/editor-panels@0.4.15) (2024-07-08)
|
|
20
26
|
|
|
27
|
+
**Note:** Version bump only for package @elementor/editor-panels
|
|
21
28
|
|
|
22
29
|
## [0.4.14](https://github.com/elementor/elementor-packages/compare/@elementor/editor-panels@0.4.13...@elementor/editor-panels@0.4.14) (2024-07-03)
|
|
23
30
|
|
|
24
31
|
**Note:** Version bump only for package @elementor/editor-panels
|
|
25
32
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
33
|
## [0.4.13](https://github.com/elementor/elementor-packages/compare/@elementor/editor-panels@0.4.12...@elementor/editor-panels@0.4.13) (2024-07-02)
|
|
31
34
|
|
|
32
35
|
**Note:** Version bump only for package @elementor/editor-panels
|
|
33
36
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
37
|
## [0.4.12](https://github.com/elementor/elementor-packages/compare/@elementor/editor-panels@0.4.11...@elementor/editor-panels@0.4.12) (2024-05-09)
|
|
39
38
|
|
|
40
39
|
**Note:** Version bump only for package @elementor/editor-panels
|
|
41
40
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
41
|
## [0.4.11](https://github.com/elementor/elementor-packages/compare/@elementor/editor-panels@0.4.10...@elementor/editor-panels@0.4.11) (2024-05-07)
|
|
47
42
|
|
|
48
43
|
**Note:** Version bump only for package @elementor/editor-panels
|
|
49
44
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
45
|
## [0.4.10](https://github.com/elementor/elementor-packages/compare/@elementor/editor-panels@0.4.9...@elementor/editor-panels@0.4.10) (2024-04-16)
|
|
55
46
|
|
|
56
47
|
**Note:** Version bump only for package @elementor/editor-panels
|
|
57
48
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
49
|
## [0.4.9](https://github.com/elementor/elementor-packages/compare/@elementor/editor-panels@0.4.8...@elementor/editor-panels@0.4.9) (2024-02-28)
|
|
63
50
|
|
|
64
51
|
**Note:** Version bump only for package @elementor/editor-panels
|
|
65
52
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
53
|
## [0.4.8](https://github.com/elementor/elementor-packages/compare/@elementor/editor-panels@0.4.7...@elementor/editor-panels@0.4.8) (2024-02-22)
|
|
71
54
|
|
|
72
55
|
**Note:** Version bump only for package @elementor/editor-panels
|
|
73
56
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
57
|
## [0.4.7](https://github.com/elementor/elementor-packages/compare/@elementor/editor-panels@0.4.6...@elementor/editor-panels@0.4.7) (2024-01-29)
|
|
79
58
|
|
|
80
59
|
**Note:** Version bump only for package @elementor/editor-panels
|
|
81
60
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
61
|
## [0.4.6](https://github.com/elementor/elementor-packages/compare/@elementor/editor-panels@0.4.5...@elementor/editor-panels@0.4.6) (2024-01-02)
|
|
87
62
|
|
|
88
|
-
|
|
89
63
|
### Bug Fixes
|
|
90
64
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
65
|
+
- **editor-site-navigation:** add error state and fix UI [ED-13182] ([#150](https://github.com/elementor/elementor-packages/issues/150)) ([177c709](https://github.com/elementor/elementor-packages/commit/177c7090c8198c29077d77b9c4f10b80ee1ca9b9))
|
|
96
66
|
|
|
97
67
|
## [0.4.5](https://github.com/elementor/elementor-packages/compare/@elementor/editor-panels@0.4.4...@elementor/editor-panels@0.4.5) (2023-11-07)
|
|
98
68
|
|
|
99
69
|
**Note:** Version bump only for package @elementor/editor-panels
|
|
100
70
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
71
|
## [0.4.4](https://github.com/elementor/elementor-packages/compare/@elementor/editor-panels@0.4.3...@elementor/editor-panels@0.4.4) (2023-11-02)
|
|
106
72
|
|
|
107
73
|
**Note:** Version bump only for package @elementor/editor-panels
|
|
108
74
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
75
|
## [0.4.3](https://github.com/elementor/elementor-packages/compare/@elementor/editor-panels@0.4.2...@elementor/editor-panels@0.4.3) (2023-10-19)
|
|
114
76
|
|
|
115
77
|
**Note:** Version bump only for package @elementor/editor-panels
|
|
116
78
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
79
|
## [0.4.2](https://github.com/elementor/elementor-packages/compare/@elementor/editor-panels@0.4.1...@elementor/editor-panels@0.4.2) (2023-10-19)
|
|
122
80
|
|
|
123
81
|
**Note:** Version bump only for package @elementor/editor-panels
|
|
124
82
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
83
|
## [0.4.1](https://github.com/elementor/elementor-packages/compare/@elementor/editor-panels@0.4.0...@elementor/editor-panels@0.4.1) (2023-09-26)
|
|
130
84
|
|
|
131
85
|
**Note:** Version bump only for package @elementor/editor-panels
|
|
132
86
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
87
|
# [0.4.0](https://github.com/elementor/elementor-packages/compare/@elementor/editor-panels@0.3.0...@elementor/editor-panels@0.4.0) (2023-09-14)
|
|
138
88
|
|
|
139
|
-
|
|
140
89
|
### Features
|
|
141
90
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
91
|
+
- **v1-adapters:** mark private functions [ED-12029] ([#122](https://github.com/elementor/elementor-packages/issues/122)) ([2e79ccc](https://github.com/elementor/elementor-packages/commit/2e79ccc87add5f0508b5a142f9f6d832b4657062))
|
|
147
92
|
|
|
148
93
|
# [0.3.0](https://github.com/elementor/elementor-packages/compare/@elementor/editor-panels@0.2.1...@elementor/editor-panels@0.3.0) (2023-09-11)
|
|
149
94
|
|
|
150
|
-
|
|
151
95
|
### Bug Fixes
|
|
152
96
|
|
|
153
|
-
|
|
154
|
-
|
|
97
|
+
- ui adaptations [ED-11933] ([#107](https://github.com/elementor/elementor-packages/issues/107)) ([18ef329](https://github.com/elementor/elementor-packages/commit/18ef32928cbe921d7f5340c37c3c965b117d8d63))
|
|
155
98
|
|
|
156
99
|
### Features
|
|
157
100
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
101
|
+
- **editor-panels:** mark experimental functions [ED-12067] ([#113](https://github.com/elementor/elementor-packages/issues/113)) ([152ef9f](https://github.com/elementor/elementor-packages/commit/152ef9f6980cd27571537db1738c69de63e2d4bb))
|
|
102
|
+
- **store:** mark experimental functions [ED-12070] ([#114](https://github.com/elementor/elementor-packages/issues/114)) ([d790829](https://github.com/elementor/elementor-packages/commit/d79082911195c75f6d3a89a5619b234e2f5ce158))
|
|
164
103
|
|
|
165
104
|
## [0.2.1](https://github.com/elementor/elementor-packages/compare/@elementor/editor-panels@0.2.0...@elementor/editor-panels@0.2.1) (2023-08-02)
|
|
166
105
|
|
|
167
106
|
**Note:** Version bump only for package @elementor/editor-panels
|
|
168
107
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
108
|
# [0.2.0](https://github.com/elementor/elementor-packages/compare/@elementor/editor-panels@0.1.6...@elementor/editor-panels@0.2.0) (2023-08-02)
|
|
174
109
|
|
|
175
|
-
|
|
176
110
|
### Features
|
|
177
111
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
112
|
+
- **site-navigation:** pages panel UI changes [ED-11348] ([#98](https://github.com/elementor/elementor-packages/issues/98)) ([d07930c](https://github.com/elementor/elementor-packages/commit/d07930c1c70c90ea59152648bfc5fe405a1f50e3))
|
|
183
113
|
|
|
184
114
|
## [0.1.6](https://github.com/elementor/elementor-packages/compare/@elementor/editor-panels@0.1.5...@elementor/editor-panels@0.1.6) (2023-08-01)
|
|
185
115
|
|
|
186
116
|
**Note:** Version bump only for package @elementor/editor-panels
|
|
187
117
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
118
|
## [0.1.5](https://github.com/elementor/elementor-packages/compare/@elementor/editor-panels@0.1.4...@elementor/editor-panels@0.1.5) (2023-07-17)
|
|
193
119
|
|
|
194
120
|
**Note:** Version bump only for package @elementor/editor-panels
|
|
195
121
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
122
|
## [0.1.4](https://github.com/elementor/elementor-packages/compare/@elementor/editor-panels@0.1.3...@elementor/editor-panels@0.1.4) (2023-07-17)
|
|
201
123
|
|
|
202
124
|
**Note:** Version bump only for package @elementor/editor-panels
|
|
203
125
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
126
|
## [0.1.3](https://github.com/elementor/elementor-packages/compare/@elementor/editor-panels@0.1.2...@elementor/editor-panels@0.1.3) (2023-06-29)
|
|
209
127
|
|
|
210
128
|
**Note:** Version bump only for package @elementor/editor-panels
|
|
211
129
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
130
|
## [0.1.2](https://github.com/elementor/elementor-packages/compare/@elementor/editor-panels@0.1.1...@elementor/editor-panels@0.1.2) (2023-06-28)
|
|
217
131
|
|
|
218
132
|
**Note:** Version bump only for package @elementor/editor-panels
|
|
219
133
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
134
|
## [0.1.1](https://github.com/elementor/elementor-packages/compare/@elementor/editor-panels@0.1.0...@elementor/editor-panels@0.1.1) (2023-06-25)
|
|
225
135
|
|
|
226
136
|
**Note:** Version bump only for package @elementor/editor-panels
|
|
227
137
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
138
|
# 0.1.0 (2023-06-11)
|
|
233
139
|
|
|
234
|
-
|
|
235
140
|
### Features
|
|
236
141
|
|
|
237
|
-
|
|
142
|
+
- **editor-panels:** init [ED-10804] ([#44](https://github.com/elementor/elementor-packages/issues/44)) ([1ed4113](https://github.com/elementor/elementor-packages/commit/1ed41131db8fb9151163175bfa614f784159e04b))
|
package/dist/index.js
CHANGED
|
@@ -51,10 +51,7 @@ var import_store2 = require("@elementor/store");
|
|
|
51
51
|
|
|
52
52
|
// src/location.ts
|
|
53
53
|
var import_locations = require("@elementor/locations");
|
|
54
|
-
var {
|
|
55
|
-
inject: injectIntoPanels,
|
|
56
|
-
useInjections: usePanelsInjections
|
|
57
|
-
} = (0, import_locations.createLocation)();
|
|
54
|
+
var { inject: injectIntoPanels, useInjections: usePanelsInjections } = (0, import_locations.createLocation)();
|
|
58
55
|
|
|
59
56
|
// src/store/selectors.ts
|
|
60
57
|
var selectOpenId = (state) => state.panels.openId;
|
|
@@ -84,10 +81,7 @@ var import_react = require("react");
|
|
|
84
81
|
function useOpenPanelInjection() {
|
|
85
82
|
const injections = usePanelsInjections();
|
|
86
83
|
const openId = (0, import_store2.__useSelector)(selectOpenId);
|
|
87
|
-
return (0, import_react.useMemo)(
|
|
88
|
-
() => injections.find((injection) => openId === injection.id),
|
|
89
|
-
[injections, openId]
|
|
90
|
-
);
|
|
84
|
+
return (0, import_react.useMemo)(() => injections.find((injection) => openId === injection.id), [injections, openId]);
|
|
91
85
|
}
|
|
92
86
|
|
|
93
87
|
// src/components/internal/portal.tsx
|
|
@@ -109,32 +103,20 @@ function useV1PanelStatus() {
|
|
|
109
103
|
});
|
|
110
104
|
}
|
|
111
105
|
function sync() {
|
|
112
|
-
(0, import_editor_v1_adapters.__privateListenTo)(
|
|
113
|
-
|
|
114
|
-
() =>
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
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.__privateListenTo)(
|
|
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
|
-
);
|
|
106
|
+
(0, import_editor_v1_adapters.__privateListenTo)((0, import_editor_v1_adapters.windowEvent)("elementor/panel/init"), () => (0, import_editor_v1_adapters.__privateRegisterRoute)(V2_PANEL));
|
|
107
|
+
(0, import_editor_v1_adapters.__privateListenTo)((0, import_editor_v1_adapters.routeOpenEvent)(V2_PANEL), () => {
|
|
108
|
+
getV1PanelElements().forEach((el) => {
|
|
109
|
+
el.setAttribute("hidden", "hidden");
|
|
110
|
+
el.setAttribute("aria-hidden", "true");
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
(0, import_editor_v1_adapters.__privateListenTo)((0, import_editor_v1_adapters.routeCloseEvent)(V2_PANEL), () => selectOpenId((0, import_store4.__getState)()) && (0, import_store4.__dispatch)(slice_default.actions.close()));
|
|
114
|
+
(0, import_editor_v1_adapters.__privateListenTo)((0, import_editor_v1_adapters.routeCloseEvent)(V2_PANEL), () => {
|
|
115
|
+
getV1PanelElements().forEach((el) => {
|
|
116
|
+
el.removeAttribute("hidden");
|
|
117
|
+
el.removeAttribute("aria-hidden");
|
|
118
|
+
});
|
|
119
|
+
});
|
|
138
120
|
(0, import_editor_v1_adapters.__privateListenTo)(
|
|
139
121
|
(0, import_editor_v1_adapters.windowEvent)("elementor/panel/init"),
|
|
140
122
|
() => subscribe({
|
|
@@ -311,15 +293,7 @@ var Typography = (0, import_ui4.styled)(import_ui4.Typography)(({ theme, variant
|
|
|
311
293
|
};
|
|
312
294
|
});
|
|
313
295
|
function PanelHeaderTitle({ children, ...props }) {
|
|
314
|
-
return /* @__PURE__ */ React5.createElement(
|
|
315
|
-
Typography,
|
|
316
|
-
{
|
|
317
|
-
component: "h2",
|
|
318
|
-
variant: "subtitle1",
|
|
319
|
-
...props
|
|
320
|
-
},
|
|
321
|
-
children
|
|
322
|
-
);
|
|
296
|
+
return /* @__PURE__ */ React5.createElement(Typography, { component: "h2", variant: "subtitle1", ...props }, children);
|
|
323
297
|
}
|
|
324
298
|
|
|
325
299
|
// src/components/external/panel-body.tsx
|
package/dist/index.js.map
CHANGED
|
@@ -1 +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 {\n\tcreatePanel as __createPanel,\n\tregisterPanel as __registerPanel,\n} from './api';\n\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\t__registerSlice( slice );\n\n\tinjectIntoTop( { id: 'panels', component: 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?.component ?? 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 as 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\t__privateOpenRoute as openRoute,\n\t__privateListenTo as listenTo,\n\trouteCloseEvent,\n\t__privateUseRouteStatus as useRouteStatus,\n\trouteOpenEvent,\n\twindowEvent,\n\t__privateRegisterRoute as registerRoute,\n\t__privateIsRouteActive as isRouteActive,\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 as useSelector, __useDispatch as 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\tcomponent,\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?.spacing( 6 ) || '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 as TypographySource, TypographyProps, styled } from '@elementor/ui';\n\n// This is to override Editor reset.scss that overrides eui styles\nconst Typography = styled( TypographySource )<TypographyProps>( ( { theme, variant = 'body1' } ) => {\n\tif ( variant === 'inherit' ) {\n\t\treturn {};\n\t}\n\n\treturn {\n\t\t'&.MuiTypography-root': {\n\t\t\t...theme.typography[ variant ],\n\t\t},\n\t};\n} );\n\nexport default function PanelHeaderTitle( { children, ...props }: TypographyProps ) {\n\treturn (\n\t\t<Typography\n\t\t\tcomponent=\"h2\"\n\t\t\tvariant=\"subtitle1\"\n\t\t\t{ ...props }\n\t\t>\n\t\t\t{ children }\n\t\t</Typography>\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,gBAAgC;;;ACDhC,IAAAC,SAAuB;;;ACAvB,IAAAC,gBAA6C;;;ACA7C,uBAA+B;AAExB,IAAM;AAAA,EACZ,QAAQ;AAAA,EACR,eAAe;AAChB,QAAI,iCAAe;;;ACAZ,IAAM,eAAe,CAAE,UAAkB,MAAM,OAAO;;;ACL7D,mBAA6C;AAE7C,IAAM,eAEF;AAAA,EACH,QAAQ;AACT;AAEA,IAAO,oBAAQ,4BAAe;AAAA,EAC7B,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;AAC1D,cAAM,SAAS;AAAA,MAChB;AAAA,IACD;AAAA,EACD;AACD,CAAE;;;AHlBF,mBAAwB;AAET,SAAR,wBAAyC;AAC/C,QAAM,aAAa,oBAAoB;AACvC,QAAM,aAAS,cAAAC,eAAa,YAAa;AAEzC,aAAO;AAAA,IACN,MAAM,WAAW,KAAM,CAAE,cAAe,WAAW,UAAU,EAAG;AAAA,IAChE,CAAE,YAAY,MAAO;AAAA,E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A,MACE,GAAG;AAAA;AAAA,IACH;AAAA,EAAU;AAEf;;;AbNA,KAAK;","names":["import_store","React","import_store","useSelector","import_react","import_store","useRouteStatus","listenTo","registerRoute","openRoute","isRouteActive","originalSubscribe","BasePortal","import_store","useSelector","useDispatch","React","import_ui","React","import_ui","React","import_ui","TypographySource","React","import_ui"]}
|
|
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 as __createPanel, registerPanel as __registerPanel } from './api';\n\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\t__registerSlice( slice );\n\n\tinjectIntoTop( { id: 'panels', component: 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?.component ?? 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 as 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( () => injections.find( ( injection ) => openId === injection.id ), [ injections, openId ] );\n}\n","import { createLocation } from '@elementor/locations';\n\nexport const { inject: injectIntoPanels, useInjections: usePanelsInjections } = 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 <BasePortal container={ containerRef.current } { ...props } />;\n}\n","import {\n\t__privateOpenRoute as openRoute,\n\t__privateListenTo as listenTo,\n\trouteCloseEvent,\n\t__privateUseRouteStatus as useRouteStatus,\n\trouteOpenEvent,\n\twindowEvent,\n\t__privateRegisterRoute as registerRoute,\n\t__privateIsRouteActive as isRouteActive,\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( windowEvent( 'elementor/panel/init' ), () => registerRoute( V2_PANEL ) );\n\n\t// On empty route open, hide V1 panel elements.\n\tlistenTo( routeOpenEvent( V2_PANEL ), () => {\n\t\tgetV1PanelElements().forEach( ( el ) => {\n\t\t\tel.setAttribute( 'hidden', 'hidden' );\n\t\t\tel.setAttribute( 'aria-hidden', 'true' );\n\t\t} );\n\t} );\n\n\t// On empty route close, close the V2 panel.\n\tlistenTo( routeCloseEvent( V2_PANEL ), () => selectOpenId( __getState() ) && __dispatch( slice.actions.close() ) );\n\n\t// On empty route close, show V1 panel elements.\n\tlistenTo( routeCloseEvent( V2_PANEL ), () => {\n\t\tgetV1PanelElements().forEach( ( el ) => {\n\t\t\tel.removeAttribute( 'hidden' );\n\t\t\tel.removeAttribute( 'aria-hidden' );\n\t\t} );\n\t} );\n\n\t// On V2 panel open, open the V2 panel route.\n\tlistenTo( windowEvent( 'elementor/panel/init' ), () =>\n\t\tsubscribe( {\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( windowEvent( 'elementor/panel/init' ), () =>\n\t\tsubscribe( {\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 )?.elementor?.documents?.getCurrent?.()?.config?.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 as useSelector, __useDispatch as 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\tcomponent,\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?.spacing( 6 ) || '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 as TypographySource, TypographyProps, styled } from '@elementor/ui';\n\n// This is to override Editor reset.scss that overrides eui styles\nconst Typography = styled( TypographySource )< TypographyProps >( ( { theme, variant = 'body1' } ) => {\n\tif ( variant === 'inherit' ) {\n\t\treturn {};\n\t}\n\n\treturn {\n\t\t'&.MuiTypography-root': {\n\t\t\t...theme.typography[ variant ],\n\t\t},\n\t};\n} );\n\nexport default function PanelHeaderTitle( { children, ...props }: TypographyProps ) {\n\treturn (\n\t\t<Typography component=\"h2\" variant=\"subtitle1\" { ...props }>\n\t\t\t{ children }\n\t\t</Typography>\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>\n\t\t\t{ children }\n\t\t</Box>\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,oBAA8B;AAC9B,IAAAA,gBAAgC;;;ACDhC,IAAAC,SAAuB;;;ACAvB,IAAAC,gBAA6C;;;ACA7C,uBAA+B;AAExB,IAAM,EAAE,QAAQ,kBAAkB,eAAe,oBAAoB,QAAI,iCAAe;;;ACGxF,IAAM,eAAe,CAAE,UAAkB,MAAM,OAAO;;;ACL7D,mBAA6C;AAE7C,IAAM,eAEF;AAAA,EACH,QAAQ;AACT;AAEA,IAAO,oBAAQ,4BAAe;AAAA,EAC7B,MAAM;AAAA,EACN;AAAA,EACA,UAAU;AAAA,IACT,KAAM,OAAO,QAAkC;AAC9C,YAAM,SAAS,OAAO;AAAA,IACvB;AAAA,IACA,MAAO,OAAO,QAA8C;AAC3D,UAAK,CAAE,OAAO,WAAW,MA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aAA8B;AAEf,SAAR,UAA4B,EAAE,UAAU,IAAI,GAAG,MAAM,GAAc;AACzE,SACC;AAAA,IAAC;AAAA;AAAA,MACA,WAAU;AAAA,MACV,IAAK;AAAA,QACJ,WAAW;AAAA,QACX,QAAQ;AAAA,QACR,GAAG;AAAA,MACJ;AAAA,MACE,GAAG;AAAA;AAAA,IAEH;AAAA,EACH;AAEF;;;AbXA,KAAK;","names":["import_store","React","import_store","useSelector","import_react","import_store","useRouteStatus","listenTo","registerRoute","openRoute","isRouteActive","originalSubscribe","BasePortal","import_store","useSelector","useDispatch","React","import_ui","React","import_ui","React","import_ui","TypographySource","React","import_ui"]}
|
package/dist/index.mjs
CHANGED
|
@@ -10,10 +10,7 @@ import { __useSelector as useSelector } from "@elementor/store";
|
|
|
10
10
|
|
|
11
11
|
// src/location.ts
|
|
12
12
|
import { createLocation } from "@elementor/locations";
|
|
13
|
-
var {
|
|
14
|
-
inject: injectIntoPanels,
|
|
15
|
-
useInjections: usePanelsInjections
|
|
16
|
-
} = createLocation();
|
|
13
|
+
var { inject: injectIntoPanels, useInjections: usePanelsInjections } = createLocation();
|
|
17
14
|
|
|
18
15
|
// src/store/selectors.ts
|
|
19
16
|
var selectOpenId = (state) => state.panels.openId;
|
|
@@ -43,10 +40,7 @@ import { useMemo } from "react";
|
|
|
43
40
|
function useOpenPanelInjection() {
|
|
44
41
|
const injections = usePanelsInjections();
|
|
45
42
|
const openId = useSelector(selectOpenId);
|
|
46
|
-
return useMemo(
|
|
47
|
-
() => injections.find((injection) => openId === injection.id),
|
|
48
|
-
[injections, openId]
|
|
49
|
-
);
|
|
43
|
+
return useMemo(() => injections.find((injection) => openId === injection.id), [injections, openId]);
|
|
50
44
|
}
|
|
51
45
|
|
|
52
46
|
// src/components/internal/portal.tsx
|
|
@@ -77,32 +71,20 @@ function useV1PanelStatus() {
|
|
|
77
71
|
});
|
|
78
72
|
}
|
|
79
73
|
function sync() {
|
|
80
|
-
listenTo(
|
|
81
|
-
|
|
82
|
-
() =>
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
routeCloseEvent(V2_PANEL),
|
|
95
|
-
() => selectOpenId(__getState()) && __dispatch(slice_default.actions.close())
|
|
96
|
-
);
|
|
97
|
-
listenTo(
|
|
98
|
-
routeCloseEvent(V2_PANEL),
|
|
99
|
-
() => {
|
|
100
|
-
getV1PanelElements().forEach((el) => {
|
|
101
|
-
el.removeAttribute("hidden");
|
|
102
|
-
el.removeAttribute("aria-hidden");
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
);
|
|
74
|
+
listenTo(windowEvent("elementor/panel/init"), () => registerRoute(V2_PANEL));
|
|
75
|
+
listenTo(routeOpenEvent(V2_PANEL), () => {
|
|
76
|
+
getV1PanelElements().forEach((el) => {
|
|
77
|
+
el.setAttribute("hidden", "hidden");
|
|
78
|
+
el.setAttribute("aria-hidden", "true");
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
listenTo(routeCloseEvent(V2_PANEL), () => selectOpenId(__getState()) && __dispatch(slice_default.actions.close()));
|
|
82
|
+
listenTo(routeCloseEvent(V2_PANEL), () => {
|
|
83
|
+
getV1PanelElements().forEach((el) => {
|
|
84
|
+
el.removeAttribute("hidden");
|
|
85
|
+
el.removeAttribute("aria-hidden");
|
|
86
|
+
});
|
|
87
|
+
});
|
|
106
88
|
listenTo(
|
|
107
89
|
windowEvent("elementor/panel/init"),
|
|
108
90
|
() => subscribe({
|
|
@@ -279,15 +261,7 @@ var Typography = styled2(TypographySource)(({ theme, variant = "body1" }) => {
|
|
|
279
261
|
};
|
|
280
262
|
});
|
|
281
263
|
function PanelHeaderTitle({ children, ...props }) {
|
|
282
|
-
return /* @__PURE__ */ React5.createElement(
|
|
283
|
-
Typography,
|
|
284
|
-
{
|
|
285
|
-
component: "h2",
|
|
286
|
-
variant: "subtitle1",
|
|
287
|
-
...props
|
|
288
|
-
},
|
|
289
|
-
children
|
|
290
|
-
);
|
|
264
|
+
return /* @__PURE__ */ React5.createElement(Typography, { component: "h2", variant: "subtitle1", ...props }, children);
|
|
291
265
|
}
|
|
292
266
|
|
|
293
267
|
// src/components/external/panel-body.tsx
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../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","../src/index.ts"],"sourcesContent":["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\t__registerSlice( slice );\n\n\tinjectIntoTop( { id: 'panels', component: 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?.component ?? 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 as 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\t__privateOpenRoute as openRoute,\n\t__privateListenTo as listenTo,\n\trouteCloseEvent,\n\t__privateUseRouteStatus as useRouteStatus,\n\trouteOpenEvent,\n\twindowEvent,\n\t__privateRegisterRoute as registerRoute,\n\t__privateIsRouteActive as isRouteActive,\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 as useSelector, __useDispatch as 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\tcomponent,\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?.spacing( 6 ) || '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 as TypographySource, TypographyProps, styled } from '@elementor/ui';\n\n// This is to override Editor reset.scss that overrides eui styles\nconst Typography = styled( TypographySource )<TypographyProps>( ( { theme, variant = 'body1' } ) => {\n\tif ( variant === 'inherit' ) {\n\t\treturn {};\n\t}\n\n\treturn {\n\t\t'&.MuiTypography-root': {\n\t\t\t...theme.typography[ variant ],\n\t\t},\n\t};\n} );\n\nexport default function PanelHeaderTitle( { children, ...props }: TypographyProps ) {\n\treturn (\n\t\t<Typography\n\t\t\tcomponent=\"h2\"\n\t\t\tvariant=\"subtitle1\"\n\t\t\t{ ...props }\n\t\t>\n\t\t\t{ children }\n\t\t</Typography>\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","import init from './init';\n\nexport {\n\tcreatePanel as __createPanel,\n\tregisterPanel as __registerPanel,\n} from './api';\n\nexport * from './components/external';\n\ninit();\n"],"mappings":";AAAA,SAAS,qBAAqB;AAC9B,SAAS,uBAAuB;;;ACDhC,YAAYA,YAAW;;;ACAvB,SAAS,iBAAiB,mBAAmB;;;ACA7C,SAAS,sBAAsB;AAExB,IAAM;AAAA,EACZ,QAAQ;AAAA,EACR,eAAe;AAChB,IAAI,eAAe;;;ACAZ,IAAM,eAAe,CAAE,UAAkB,MAAM,OAAO;;;ACL7D,SAAS,qBAAoC;AAE7C,IAAM,eAEF;AAAA,EACH,QAAQ;AACT;AAEA,IAAO,gBA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,YAAY,WAAY;AAC5B,WAAO,CAAC;AAAA,EACT;AAEA,SAAO;AAAA,IACN,wBAAwB;AAAA,MACvB,GAAG,MAAM,WAAY,OAAQ;AAAA,IAC9B;AAAA,EACD;AACD,CAAE;AAEa,SAAR,iBAAmC,EAAE,UAAU,GAAG,MAAM,GAAqB;AACnF,SACC;AAAA,IAAC;AAAA;AAAA,MACA,WAAU;AAAA,MACV,SAAQ;AAAA,MACN,GAAG;AAAA;AAAA,IAEH;AAAA,EACH;AAEF;;;AC1BA,YAAYC,YAAW;AACvB,SAAS,OAAAC,YAAqB;AAEf,SAAR,UAA4B,EAAE,UAAU,IAAI,GAAG,MAAM,GAAc;AACzE,SACC;AAAA,IAACA;AAAA,IAAA;AAAA,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;;;ACNA,KAAK;","names":["React","useSelector","useSelector","React","React","React","styled","React","Box"]}
|
|
1
|
+
{"version":3,"sources":["../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","../src/index.ts"],"sourcesContent":["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\t__registerSlice( slice );\n\n\tinjectIntoTop( { id: 'panels', component: 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?.component ?? 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 as 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( () => injections.find( ( injection ) => openId === injection.id ), [ injections, openId ] );\n}\n","import { createLocation } from '@elementor/locations';\n\nexport const { inject: injectIntoPanels, useInjections: usePanelsInjections } = 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 <BasePortal container={ containerRef.current } { ...props } />;\n}\n","import {\n\t__privateOpenRoute as openRoute,\n\t__privateListenTo as listenTo,\n\trouteCloseEvent,\n\t__privateUseRouteStatus as useRouteStatus,\n\trouteOpenEvent,\n\twindowEvent,\n\t__privateRegisterRoute as registerRoute,\n\t__privateIsRouteActive as isRouteActive,\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( windowEvent( 'elementor/panel/init' ), () => registerRoute( V2_PANEL ) );\n\n\t// On empty route open, hide V1 panel elements.\n\tlistenTo( routeOpenEvent( V2_PANEL ), () => {\n\t\tgetV1PanelElements().forEach( ( el ) => {\n\t\t\tel.setAttribute( 'hidden', 'hidden' );\n\t\t\tel.setAttribute( 'aria-hidden', 'true' );\n\t\t} );\n\t} );\n\n\t// On empty route close, close the V2 panel.\n\tlistenTo( routeCloseEvent( V2_PANEL ), () => selectOpenId( __getState() ) && __dispatch( slice.actions.close() ) );\n\n\t// On empty route close, show V1 panel elements.\n\tlistenTo( routeCloseEvent( V2_PANEL ), () => {\n\t\tgetV1PanelElements().forEach( ( el ) => {\n\t\t\tel.removeAttribute( 'hidden' );\n\t\t\tel.removeAttribute( 'aria-hidden' );\n\t\t} );\n\t} );\n\n\t// On V2 panel open, open the V2 panel route.\n\tlistenTo( windowEvent( 'elementor/panel/init' ), () =>\n\t\tsubscribe( {\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( windowEvent( 'elementor/panel/init' ), () =>\n\t\tsubscribe( {\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 )?.elementor?.documents?.getCurrent?.()?.config?.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 as useSelector, __useDispatch as 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\tcomponent,\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?.spacing( 6 ) || '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 as TypographySource, TypographyProps, styled } from '@elementor/ui';\n\n// This is to override Editor reset.scss that overrides eui styles\nconst Typography = styled( TypographySource )< TypographyProps >( ( { theme, variant = 'body1' } ) => {\n\tif ( variant === 'inherit' ) {\n\t\treturn {};\n\t}\n\n\treturn {\n\t\t'&.MuiTypography-root': {\n\t\t\t...theme.typography[ variant ],\n\t\t},\n\t};\n} );\n\nexport default function PanelHeaderTitle( { children, ...props }: TypographyProps ) {\n\treturn (\n\t\t<Typography component=\"h2\" variant=\"subtitle1\" { ...props }>\n\t\t\t{ children }\n\t\t</Typography>\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>\n\t\t\t{ children }\n\t\t</Box>\n\t);\n}\n","import init from './init';\n\nexport { createPanel as __createPanel, registerPanel as __registerPanel } from './api';\n\nexport * from './components/external';\n\ninit();\n"],"mappings":";AAAA,SAAS,qBAAqB;AAC9B,SAAS,uBAAuB;;;ACDhC,YAAYA,YAAW;;;ACAvB,SAAS,iBAAiB,mBAAmB;;;ACA7C,SAAS,sBAAsB;AAExB,IA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c,kBAAmC,UAAAC,eAAc;AAGxE,IAAM,aAAaA,QAAQ,gBAAiB,EAAsB,CAAE,EAAE,OAAO,UAAU,QAAQ,MAAO;AACrG,MAAK,YAAY,WAAY;AAC5B,WAAO,CAAC;AAAA,EACT;AAEA,SAAO;AAAA,IACN,wBAAwB;AAAA,MACvB,GAAG,MAAM,WAAY,OAAQ;AAAA,IAC9B;AAAA,EACD;AACD,CAAE;AAEa,SAAR,iBAAmC,EAAE,UAAU,GAAG,MAAM,GAAqB;AACnF,SACC,qCAAC,cAAW,WAAU,MAAK,SAAQ,aAAc,GAAG,SACjD,QACH;AAEF;;;ACtBA,YAAYC,YAAW;AACvB,SAAS,OAAAC,YAAqB;AAEf,SAAR,UAA4B,EAAE,UAAU,IAAI,GAAG,MAAM,GAAc;AACzE,SACC;AAAA,IAACA;AAAA,IAAA;AAAA,MACA,WAAU;AAAA,MACV,IAAK;AAAA,QACJ,WAAW;AAAA,QACX,QAAQ;AAAA,QACR,GAAG;AAAA,MACJ;AAAA,MACE,GAAG;AAAA;AAAA,IAEH;AAAA,EACH;AAEF;;;ACXA,KAAK;","names":["React","useSelector","useSelector","React","React","React","styled","React","Box"]}
|
package/package.json
CHANGED
|
@@ -1,45 +1,52 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
2
|
+
"name": "@elementor/editor-panels",
|
|
3
|
+
"version": "0.5.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"author": "Elementor Team",
|
|
6
|
+
"homepage": "https://elementor.com/",
|
|
7
|
+
"license": "GPL-3.0-or-later",
|
|
8
|
+
"main": "dist/index.js",
|
|
9
|
+
"module": "dist/index.mjs",
|
|
10
|
+
"types": "dist/index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"import": "./dist/index.mjs",
|
|
14
|
+
"require": "./dist/index.js",
|
|
15
|
+
"types": "./dist/index.d.ts"
|
|
16
|
+
},
|
|
17
|
+
"./package.json": "./package.json"
|
|
18
|
+
},
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/elementor/elementor-packages.git",
|
|
22
|
+
"directory": "packages/core/editor-panels"
|
|
23
|
+
},
|
|
24
|
+
"bugs": {
|
|
25
|
+
"url": "https://github.com/elementor/elementor-packages/issues"
|
|
26
|
+
},
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"access": "public"
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"README.md",
|
|
32
|
+
"CHANGELOG.md",
|
|
33
|
+
"/dist",
|
|
34
|
+
"/src",
|
|
35
|
+
"!**/__tests__"
|
|
36
|
+
],
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "tsup --config=../../tsup.build.ts",
|
|
39
|
+
"dev": "tsup --config=../../tsup.dev.ts"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@elementor/editor": "^0.12.0",
|
|
43
|
+
"@elementor/editor-v1-adapters": "^0.8.1",
|
|
44
|
+
"@elementor/locations": "^0.7.5",
|
|
45
|
+
"@elementor/store": "^0.8.5",
|
|
46
|
+
"@elementor/ui": "^1.14.2"
|
|
47
|
+
},
|
|
48
|
+
"peerDependencies": {
|
|
49
|
+
"react": "^18.3.1"
|
|
50
|
+
},
|
|
51
|
+
"gitHead": "f4ca33da0842a29d83736d0a173633085edddaee"
|
|
45
52
|
}
|
package/src/api.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { useV1PanelStatus } from './sync';
|
|
|
7
7
|
export type PanelDeclaration = {
|
|
8
8
|
id: string;
|
|
9
9
|
component: ComponentType;
|
|
10
|
-
}
|
|
10
|
+
};
|
|
11
11
|
|
|
12
12
|
export function createPanel( { id, component }: PanelDeclaration ) {
|
|
13
13
|
const usePanelStatus = createUseStatus( id );
|
|
@@ -23,14 +23,14 @@ export function createPanel( { id, component }: PanelDeclaration ) {
|
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
export function registerPanel( { id, component }: Pick<PanelDeclaration, 'id' | 'component'> ) {
|
|
26
|
+
export function registerPanel( { id, component }: Pick< PanelDeclaration, 'id' | 'component' > ) {
|
|
27
27
|
injectIntoPanels( {
|
|
28
28
|
id,
|
|
29
29
|
component,
|
|
30
30
|
} );
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
function createUseStatus( id: PanelDeclaration['id'] ) {
|
|
33
|
+
function createUseStatus( id: PanelDeclaration[ 'id' ] ) {
|
|
34
34
|
return () => {
|
|
35
35
|
const openPanelId = useSelector( selectOpenId );
|
|
36
36
|
const v1PanelStatus = useV1PanelStatus();
|
|
@@ -42,7 +42,7 @@ function createUseStatus( id: PanelDeclaration['id'] ) {
|
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
function createUseActions( id: PanelDeclaration['id'], useStatus: ReturnType<typeof createUseStatus> ) {
|
|
45
|
+
function createUseActions( id: PanelDeclaration[ 'id' ], useStatus: ReturnType< typeof createUseStatus > ) {
|
|
46
46
|
return () => {
|
|
47
47
|
const dispatch = useDispatch();
|
|
48
48
|
const { isBlocked } = useStatus();
|
|
@@ -2,7 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import { Typography as TypographySource, TypographyProps, styled } from '@elementor/ui';
|
|
3
3
|
|
|
4
4
|
// This is to override Editor reset.scss that overrides eui styles
|
|
5
|
-
const Typography = styled( TypographySource )<TypographyProps>( ( { theme, variant = 'body1' } ) => {
|
|
5
|
+
const Typography = styled( TypographySource )< TypographyProps >( ( { theme, variant = 'body1' } ) => {
|
|
6
6
|
if ( variant === 'inherit' ) {
|
|
7
7
|
return {};
|
|
8
8
|
}
|
|
@@ -16,11 +16,7 @@ const Typography = styled( TypographySource )<TypographyProps>( ( { theme, varia
|
|
|
16
16
|
|
|
17
17
|
export default function PanelHeaderTitle( { children, ...props }: TypographyProps ) {
|
|
18
18
|
return (
|
|
19
|
-
<Typography
|
|
20
|
-
component="h2"
|
|
21
|
-
variant="subtitle1"
|
|
22
|
-
{ ...props }
|
|
23
|
-
>
|
|
19
|
+
<Typography component="h2" variant="subtitle1" { ...props }>
|
|
24
20
|
{ children }
|
|
25
21
|
</Typography>
|
|
26
22
|
);
|
|
@@ -3,7 +3,7 @@ import { Portal as BasePortal, PortalProps } from '@elementor/ui';
|
|
|
3
3
|
import { useRef } from 'react';
|
|
4
4
|
import { getPortalContainer } from '../../sync';
|
|
5
5
|
|
|
6
|
-
type Props = Omit<PortalProps, 'container'>;
|
|
6
|
+
type Props = Omit< PortalProps, 'container' >;
|
|
7
7
|
|
|
8
8
|
export default function Portal( props: Props ) {
|
|
9
9
|
const containerRef = useRef( getPortalContainer );
|
|
@@ -12,7 +12,5 @@ export default function Portal( props: Props ) {
|
|
|
12
12
|
return null;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
return
|
|
16
|
-
<BasePortal container={ containerRef.current } { ...props } />
|
|
17
|
-
);
|
|
15
|
+
return <BasePortal container={ containerRef.current } { ...props } />;
|
|
18
16
|
}
|
|
@@ -7,8 +7,5 @@ export default function useOpenPanelInjection() {
|
|
|
7
7
|
const injections = usePanelsInjections();
|
|
8
8
|
const openId = useSelector( selectOpenId );
|
|
9
9
|
|
|
10
|
-
return useMemo(
|
|
11
|
-
() => injections.find( ( injection ) => openId === injection.id ),
|
|
12
|
-
[ injections, openId ]
|
|
13
|
-
);
|
|
10
|
+
return useMemo( () => injections.find( ( injection ) => openId === injection.id ), [ injections, openId ] );
|
|
14
11
|
}
|
package/src/index.ts
CHANGED
package/src/location.ts
CHANGED
package/src/store/selectors.ts
CHANGED
package/src/store/slice.ts
CHANGED
|
@@ -10,10 +10,10 @@ export default __createSlice( {
|
|
|
10
10
|
name: 'panels',
|
|
11
11
|
initialState,
|
|
12
12
|
reducers: {
|
|
13
|
-
open( state, action: PayloadAction<string> ) {
|
|
13
|
+
open( state, action: PayloadAction< string > ) {
|
|
14
14
|
state.openId = action.payload;
|
|
15
15
|
},
|
|
16
|
-
close( state, action: PayloadAction<string | undefined> ) {
|
|
16
|
+
close( state, action: PayloadAction< string | undefined > ) {
|
|
17
17
|
if ( ! action.payload || state.openId === action.payload ) {
|
|
18
18
|
state.openId = null;
|
|
19
19
|
}
|
package/src/sync.ts
CHANGED
|
@@ -27,43 +27,30 @@ export function useV1PanelStatus() {
|
|
|
27
27
|
|
|
28
28
|
export function sync() {
|
|
29
29
|
// Register the V2 panel route on panel init.
|
|
30
|
-
listenTo(
|
|
31
|
-
windowEvent( 'elementor/panel/init' ),
|
|
32
|
-
() => registerRoute( V2_PANEL )
|
|
33
|
-
);
|
|
30
|
+
listenTo( windowEvent( 'elementor/panel/init' ), () => registerRoute( V2_PANEL ) );
|
|
34
31
|
|
|
35
32
|
// On empty route open, hide V1 panel elements.
|
|
36
|
-
listenTo(
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
} );
|
|
43
|
-
},
|
|
44
|
-
);
|
|
33
|
+
listenTo( routeOpenEvent( V2_PANEL ), () => {
|
|
34
|
+
getV1PanelElements().forEach( ( el ) => {
|
|
35
|
+
el.setAttribute( 'hidden', 'hidden' );
|
|
36
|
+
el.setAttribute( 'aria-hidden', 'true' );
|
|
37
|
+
} );
|
|
38
|
+
} );
|
|
45
39
|
|
|
46
40
|
// On empty route close, close the V2 panel.
|
|
47
|
-
listenTo(
|
|
48
|
-
routeCloseEvent( V2_PANEL ),
|
|
49
|
-
() => selectOpenId( __getState() ) && __dispatch( slice.actions.close() )
|
|
50
|
-
);
|
|
41
|
+
listenTo( routeCloseEvent( V2_PANEL ), () => selectOpenId( __getState() ) && __dispatch( slice.actions.close() ) );
|
|
51
42
|
|
|
52
43
|
// On empty route close, show V1 panel elements.
|
|
53
|
-
listenTo(
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
} );
|
|
60
|
-
},
|
|
61
|
-
);
|
|
44
|
+
listenTo( routeCloseEvent( V2_PANEL ), () => {
|
|
45
|
+
getV1PanelElements().forEach( ( el ) => {
|
|
46
|
+
el.removeAttribute( 'hidden' );
|
|
47
|
+
el.removeAttribute( 'aria-hidden' );
|
|
48
|
+
} );
|
|
49
|
+
} );
|
|
62
50
|
|
|
63
51
|
// On V2 panel open, open the V2 panel route.
|
|
64
|
-
listenTo(
|
|
65
|
-
|
|
66
|
-
() => subscribe( {
|
|
52
|
+
listenTo( windowEvent( 'elementor/panel/init' ), () =>
|
|
53
|
+
subscribe( {
|
|
67
54
|
on: ( state ) => selectOpenId( state ),
|
|
68
55
|
when: ( { prev, current } ) => !! ( ! prev && current ), // is panel opened
|
|
69
56
|
callback: () => openRoute( V2_PANEL ),
|
|
@@ -71,9 +58,8 @@ export function sync() {
|
|
|
71
58
|
);
|
|
72
59
|
|
|
73
60
|
// On V2 panel close, close the V2 panel route.
|
|
74
|
-
listenTo(
|
|
75
|
-
|
|
76
|
-
() => subscribe( {
|
|
61
|
+
listenTo( windowEvent( 'elementor/panel/init' ), () =>
|
|
62
|
+
subscribe( {
|
|
77
63
|
on: ( state ) => selectOpenId( state ),
|
|
78
64
|
when: ( { prev, current } ) => !! ( ! current && prev ), // is panel closed
|
|
79
65
|
callback: () => isRouteActive( V2_PANEL ) && openRoute( getDefaultRoute() ),
|
|
@@ -99,33 +85,28 @@ function getDefaultRoute() {
|
|
|
99
85
|
getCurrent?: () => {
|
|
100
86
|
config?: {
|
|
101
87
|
panel?: {
|
|
102
|
-
default_route?: string
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
const defaultRoute = ( window as unknown as ExtendedWindow )
|
|
111
|
-
?.elementor
|
|
112
|
-
?.documents
|
|
113
|
-
?.getCurrent?.()
|
|
114
|
-
?.config
|
|
115
|
-
?.panel
|
|
88
|
+
default_route?: string;
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
const defaultRoute = ( window as unknown as ExtendedWindow )?.elementor?.documents?.getCurrent?.()?.config?.panel
|
|
116
97
|
?.default_route;
|
|
117
98
|
|
|
118
99
|
return defaultRoute || 'panel/elements/categories';
|
|
119
100
|
}
|
|
120
101
|
|
|
121
|
-
function subscribe<TVal>( {
|
|
102
|
+
function subscribe< TVal >( {
|
|
122
103
|
on,
|
|
123
104
|
when,
|
|
124
105
|
callback,
|
|
125
106
|
}: {
|
|
126
|
-
on: ( state: ReturnType<typeof __getState> ) => TVal
|
|
127
|
-
when: ( { prev, current }: { prev: TVal
|
|
128
|
-
callback: ( { prev, current }: { prev: TVal
|
|
107
|
+
on: ( state: ReturnType< typeof __getState > ) => TVal;
|
|
108
|
+
when: ( { prev, current }: { prev: TVal; current: TVal } ) => boolean;
|
|
109
|
+
callback: ( { prev, current }: { prev: TVal; current: TVal } ) => void;
|
|
129
110
|
} ) {
|
|
130
111
|
let prev: TVal;
|
|
131
112
|
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { __createStore, __registerSlice, __StoreProvider as StoreProvider } from '@elementor/store';
|
|
3
|
-
import { slice } from '../store';
|
|
4
|
-
import { createPanel, registerPanel } from '../api';
|
|
5
|
-
import { fireEvent, render, screen } from '@testing-library/react';
|
|
6
|
-
import Panels from '../components/internal/panels';
|
|
7
|
-
import { __privateUseRouteStatus as useRouteStatus } from '@elementor/editor-v1-adapters';
|
|
8
|
-
import { Panel, PanelBody, PanelHeader, PanelHeaderTitle } from '../components/external';
|
|
9
|
-
|
|
10
|
-
jest.mock( '@elementor/editor-v1-adapters', () => ( {
|
|
11
|
-
__esModule: true,
|
|
12
|
-
...jest.requireActual( '@elementor/editor-v1-adapters' ),
|
|
13
|
-
__privateUseRouteStatus: jest.fn( () => ( {
|
|
14
|
-
isActive: false,
|
|
15
|
-
isBlocked: false,
|
|
16
|
-
} ) ),
|
|
17
|
-
} ) );
|
|
18
|
-
|
|
19
|
-
describe( '@elementor/editor-panels api', () => {
|
|
20
|
-
const {
|
|
21
|
-
panel,
|
|
22
|
-
usePanelStatus,
|
|
23
|
-
usePanelActions,
|
|
24
|
-
} = createPanel( {
|
|
25
|
-
id: 'test-panel',
|
|
26
|
-
component: () => (
|
|
27
|
-
<Panel>
|
|
28
|
-
<PanelHeader>
|
|
29
|
-
<PanelHeaderTitle>Test Panel Header</PanelHeaderTitle>
|
|
30
|
-
</PanelHeader>
|
|
31
|
-
<PanelBody>
|
|
32
|
-
<p>Test Panel Body</p>
|
|
33
|
-
</PanelBody>
|
|
34
|
-
</Panel>
|
|
35
|
-
),
|
|
36
|
-
} );
|
|
37
|
-
|
|
38
|
-
const renderPanels = () => {
|
|
39
|
-
const Trigger = () => {
|
|
40
|
-
const { isOpen, isBlocked } = usePanelStatus();
|
|
41
|
-
const { open, close } = usePanelActions();
|
|
42
|
-
|
|
43
|
-
return (
|
|
44
|
-
<button onClick={ () => isOpen ? close() : open() } disabled={ isBlocked }>
|
|
45
|
-
{ isOpen ? 'Close Panel' : 'Open Panel' }
|
|
46
|
-
</button>
|
|
47
|
-
);
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
__registerSlice( slice );
|
|
51
|
-
|
|
52
|
-
render(
|
|
53
|
-
<StoreProvider store={ __createStore() }>
|
|
54
|
-
<Panels />
|
|
55
|
-
<Trigger />
|
|
56
|
-
</StoreProvider>
|
|
57
|
-
);
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
beforeEach( () => {
|
|
61
|
-
// Setup for the environment.
|
|
62
|
-
document.body.innerHTML = `
|
|
63
|
-
<div id="elementor-editor-wrapper">
|
|
64
|
-
<div id="elementor-panel-inner"></div>
|
|
65
|
-
</div>
|
|
66
|
-
`;
|
|
67
|
-
} );
|
|
68
|
-
|
|
69
|
-
afterEach( () => {
|
|
70
|
-
// Cleanup for the environment.
|
|
71
|
-
document.body.innerHTML = '';
|
|
72
|
-
} );
|
|
73
|
-
|
|
74
|
-
it( 'should open the panel when triggering `open` action', () => {
|
|
75
|
-
// Arrange.
|
|
76
|
-
registerPanel( panel );
|
|
77
|
-
|
|
78
|
-
// Act.
|
|
79
|
-
renderPanels();
|
|
80
|
-
|
|
81
|
-
// Assert.
|
|
82
|
-
expect( screen.queryByText( 'Test Panel Header' ) ).not.toBeInTheDocument();
|
|
83
|
-
expect( screen.queryByText( 'Test Panel Body' ) ).not.toBeInTheDocument();
|
|
84
|
-
|
|
85
|
-
// Act.
|
|
86
|
-
fireEvent.click( screen.getByText( 'Open Panel' ) );
|
|
87
|
-
|
|
88
|
-
// Assert.
|
|
89
|
-
expect( screen.getByText( 'Test Panel Header' ) ).toBeInTheDocument();
|
|
90
|
-
expect( screen.getByText( 'Test Panel Body' ) ).toBeInTheDocument();
|
|
91
|
-
} );
|
|
92
|
-
|
|
93
|
-
it( 'should close the panel when triggering `close` action', () => {
|
|
94
|
-
// Arrange.
|
|
95
|
-
registerPanel( panel );
|
|
96
|
-
|
|
97
|
-
jest.mocked( useRouteStatus ).mockReturnValue( {
|
|
98
|
-
isActive: true,
|
|
99
|
-
isBlocked: false,
|
|
100
|
-
} );
|
|
101
|
-
|
|
102
|
-
// Act.
|
|
103
|
-
renderPanels();
|
|
104
|
-
|
|
105
|
-
fireEvent.click( screen.getByText( 'Open Panel' ) );
|
|
106
|
-
|
|
107
|
-
// Assert.
|
|
108
|
-
expect( screen.getByText( 'Test Panel Header' ) ).toBeInTheDocument();
|
|
109
|
-
expect( screen.getByText( 'Test Panel Body' ) ).toBeInTheDocument();
|
|
110
|
-
|
|
111
|
-
// Act.
|
|
112
|
-
fireEvent.click( screen.getByText( 'Close Panel' ) );
|
|
113
|
-
|
|
114
|
-
// Assert.
|
|
115
|
-
expect( screen.queryByText( 'Test Panel Header' ) ).not.toBeInTheDocument();
|
|
116
|
-
expect( screen.queryByText( 'Test Panel Body' ) ).not.toBeInTheDocument();
|
|
117
|
-
} );
|
|
118
|
-
|
|
119
|
-
it( 'should not open the panel if the panel was not registered', () => {
|
|
120
|
-
// Act.
|
|
121
|
-
renderPanels();
|
|
122
|
-
|
|
123
|
-
fireEvent.click( screen.getByText( 'Open Panel' ) );
|
|
124
|
-
|
|
125
|
-
// Assert.
|
|
126
|
-
expect( screen.queryByText( 'Test Panel Header' ) ).not.toBeInTheDocument();
|
|
127
|
-
expect( screen.queryByText( 'Test Panel Body' ) ).not.toBeInTheDocument();
|
|
128
|
-
} );
|
|
129
|
-
|
|
130
|
-
it( 'should block open panel when isBlocked state equals `true`', () => {
|
|
131
|
-
// Arrange.
|
|
132
|
-
registerPanel( panel );
|
|
133
|
-
|
|
134
|
-
jest.mocked( useRouteStatus ).mockReturnValue( {
|
|
135
|
-
isActive: false,
|
|
136
|
-
isBlocked: true,
|
|
137
|
-
} );
|
|
138
|
-
|
|
139
|
-
// Act.
|
|
140
|
-
renderPanels();
|
|
141
|
-
|
|
142
|
-
// Assert.
|
|
143
|
-
expect( screen.getByText( 'Open Panel' ) ).toBeDisabled();
|
|
144
|
-
} );
|
|
145
|
-
} );
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import { sync } from '../sync';
|
|
2
|
-
import { __privateIsRouteActive as isRouteActive, __privateOpenRoute as openRoute, __privateRegisterRoute as registerRoute } from '@elementor/editor-v1-adapters';
|
|
3
|
-
import { __createStore, __dispatch, __getState, __registerSlice } from '@elementor/store';
|
|
4
|
-
import { selectOpenId, slice } from '../store';
|
|
5
|
-
|
|
6
|
-
jest.mock( '@elementor/editor-v1-adapters', () => ( {
|
|
7
|
-
...jest.requireActual( '@elementor/editor-v1-adapters' ),
|
|
8
|
-
__privateRegisterRoute: jest.fn(),
|
|
9
|
-
__privateOpenRoute: jest.fn(),
|
|
10
|
-
__privateIsRouteActive: jest.fn(),
|
|
11
|
-
} ) );
|
|
12
|
-
|
|
13
|
-
describe( '@elementor/editor-panels sync', () => {
|
|
14
|
-
const v1PanelElementsIds = [
|
|
15
|
-
'elementor-panel-header-wrapper',
|
|
16
|
-
'elementor-panel-content-wrapper',
|
|
17
|
-
'elementor-panel-state-loading',
|
|
18
|
-
'elementor-panel-footer',
|
|
19
|
-
];
|
|
20
|
-
|
|
21
|
-
beforeEach( () => {
|
|
22
|
-
sync();
|
|
23
|
-
__registerSlice( slice );
|
|
24
|
-
__createStore();
|
|
25
|
-
} );
|
|
26
|
-
|
|
27
|
-
afterEach( () => {
|
|
28
|
-
document.body.innerHTML = '';
|
|
29
|
-
} );
|
|
30
|
-
|
|
31
|
-
it( 'should register the empty route on init', () => {
|
|
32
|
-
// Arrange & Act.
|
|
33
|
-
window.dispatchEvent( new CustomEvent( 'elementor/panel/init' ) );
|
|
34
|
-
|
|
35
|
-
// Assert.
|
|
36
|
-
expect( registerRoute ).toHaveBeenCalledTimes( 1 );
|
|
37
|
-
expect( registerRoute ).toHaveBeenCalledWith( 'panel/v2' );
|
|
38
|
-
} );
|
|
39
|
-
|
|
40
|
-
it( 'should open v1 route `panels/empty` when triggering `open` action', () => {
|
|
41
|
-
// Arrange.
|
|
42
|
-
window.dispatchEvent( new CustomEvent( 'elementor/panel/init' ) );
|
|
43
|
-
|
|
44
|
-
// Act.
|
|
45
|
-
__dispatch( slice.actions.open( 'test' ) );
|
|
46
|
-
|
|
47
|
-
// Arrange.
|
|
48
|
-
expect( openRoute ).toHaveBeenCalledTimes( 1 );
|
|
49
|
-
expect( openRoute ).toHaveBeenCalledWith( 'panel/v2' );
|
|
50
|
-
} );
|
|
51
|
-
|
|
52
|
-
it( 'should close v1 route `panel/v2` when triggering `close` action and set default v1 route', () => {
|
|
53
|
-
// Arrange.
|
|
54
|
-
window.dispatchEvent( new CustomEvent( 'elementor/panel/init' ) );
|
|
55
|
-
|
|
56
|
-
jest.mocked( isRouteActive ).mockImplementation( ( route ) => route === 'panel/v2' );
|
|
57
|
-
|
|
58
|
-
__dispatch( slice.actions.open( 'not-relevant-test' ) );
|
|
59
|
-
__dispatch( slice.actions.open( 'not-relevant-test-2' ) );
|
|
60
|
-
__dispatch( slice.actions.open( 'test' ) );
|
|
61
|
-
|
|
62
|
-
// Act.
|
|
63
|
-
__dispatch( slice.actions.close( 'test' ) );
|
|
64
|
-
|
|
65
|
-
// Arrange.
|
|
66
|
-
expect( openRoute ).toHaveBeenCalledTimes( 2 );
|
|
67
|
-
expect( openRoute ).toHaveBeenNthCalledWith( 1, 'panel/v2' );
|
|
68
|
-
expect( openRoute ).toHaveBeenNthCalledWith( 2, 'panel/elements/categories' );
|
|
69
|
-
} );
|
|
70
|
-
|
|
71
|
-
it( 'should not navigate to v1 default route if the route is not `panel/v2`', () => {
|
|
72
|
-
// Arrange.
|
|
73
|
-
window.dispatchEvent( new CustomEvent( 'elementor/panel/init' ) );
|
|
74
|
-
|
|
75
|
-
jest.mocked( isRouteActive ).mockImplementation( () => false );
|
|
76
|
-
|
|
77
|
-
__dispatch( slice.actions.open( 'test' ) );
|
|
78
|
-
|
|
79
|
-
// Act.
|
|
80
|
-
__dispatch( slice.actions.close( 'test' ) );
|
|
81
|
-
|
|
82
|
-
// Arrange.
|
|
83
|
-
expect( openRoute ).toHaveBeenCalledTimes( 1 );
|
|
84
|
-
expect( openRoute ).toHaveBeenCalledWith( 'panel/v2' );
|
|
85
|
-
} );
|
|
86
|
-
|
|
87
|
-
it( 'should close the panel when navigating to another v1 route', () => {
|
|
88
|
-
// Arrange.
|
|
89
|
-
__dispatch( slice.actions.open( 'test' ) );
|
|
90
|
-
|
|
91
|
-
// Act.
|
|
92
|
-
window.dispatchEvent( new CustomEvent( 'elementor/routes/close', {
|
|
93
|
-
detail: { route: 'panel/v2' },
|
|
94
|
-
} ) );
|
|
95
|
-
|
|
96
|
-
// Act.
|
|
97
|
-
expect( selectOpenId( __getState() ) ).toBe( null );
|
|
98
|
-
} );
|
|
99
|
-
|
|
100
|
-
it( 'should hide old panel elements when navigating to empty route', () => {
|
|
101
|
-
// Arrange.
|
|
102
|
-
document.body.innerHTML = v1PanelElementsIds.map( ( id ) => `<div id="${ id }"></div>` ).join( '' );
|
|
103
|
-
|
|
104
|
-
// Act.
|
|
105
|
-
window.dispatchEvent( new CustomEvent( 'elementor/routes/open', {
|
|
106
|
-
detail: { route: 'panel/v2' },
|
|
107
|
-
} ) );
|
|
108
|
-
|
|
109
|
-
// Assert.
|
|
110
|
-
v1PanelElementsIds.forEach( ( id ) => {
|
|
111
|
-
expect( document.getElementById( id ) ).not.toBeVisible();
|
|
112
|
-
} );
|
|
113
|
-
} );
|
|
114
|
-
|
|
115
|
-
it( 'should show old panel elements when navigating out of the empty route', () => {
|
|
116
|
-
// Arrange.
|
|
117
|
-
document.body.innerHTML = v1PanelElementsIds.map( ( id ) => `<div id="${ id }" aria-hidden="true" hidden="hidden"></div>` ).join( '' );
|
|
118
|
-
|
|
119
|
-
// Act.
|
|
120
|
-
window.dispatchEvent( new CustomEvent( 'elementor/routes/close', {
|
|
121
|
-
detail: { route: 'panel/v2' },
|
|
122
|
-
} ) );
|
|
123
|
-
|
|
124
|
-
// Assert.
|
|
125
|
-
v1PanelElementsIds.forEach( ( id ) => {
|
|
126
|
-
expect( document.getElementById( id ) ).toBeVisible();
|
|
127
|
-
} );
|
|
128
|
-
} );
|
|
129
|
-
} );
|