@elementor/editor-editing-panel 0.5.1 → 0.6.1
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 +20 -0
- package/dist/index.js +173 -71
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +167 -65
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -7
- package/src/components/controls/collapsible-section.tsx +25 -0
- package/src/components/controls/control-types/text-area-control.tsx +5 -3
- package/src/components/controls/control-types/text-control.tsx +11 -0
- package/src/components/controls/get-control-by-type.ts +13 -0
- package/src/components/controls/settings-control.tsx +38 -13
- package/src/components/controls/style-control.tsx +35 -0
- package/src/components/{editing-panel-hooks.tsx → editing-panel/editing-panel-hooks.tsx} +1 -1
- package/src/components/editing-panel/editing-panel-tabs.tsx +26 -0
- package/src/components/editing-panel/editing-panel.tsx +35 -0
- package/src/components/editing-panel/settings-tab.tsx +64 -0
- package/src/components/editing-panel/style-tab.tsx +17 -0
- package/src/contexts/control-context.tsx +0 -25
- package/src/contexts/style-context.tsx +34 -0
- package/src/hooks/use-element-style-prop.ts +44 -0
- package/src/hooks/use-element-styles.ts +13 -0
- package/src/init.ts +1 -1
- package/src/panel.ts +1 -1
- package/src/sync/get-element-styles.ts +8 -0
- package/src/sync/types.ts +3 -2
- package/src/sync/update-style.ts +23 -0
- package/src/types.ts +49 -3
- package/src/__tests__/utils.ts +0 -28
- package/src/components/__tests__/editing-panel.test.tsx +0 -92
- package/src/components/controls/__tests__/settings-control.test.tsx +0 -71
- package/src/components/controls/control-types/__tests__/select-control.test.tsx +0 -67
- package/src/components/controls/control-types/__tests__/text-area-control.test.tsx +0 -29
- package/src/components/editing-panel.tsx +0 -66
- package/src/contexts/__tests__/control-context.test.tsx +0 -14
- package/src/hooks/__tests__/use-widget-settings.test.ts +0 -128
- package/src/sync/__tests__/get-container.test.ts +0 -40
- package/src/sync/__tests__/should-use-v2-panel.test.ts +0 -95
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// src/panel.ts
|
|
2
2
|
import { __createPanel as createPanel } from "@elementor/editor-panels";
|
|
3
3
|
|
|
4
|
-
// src/components/editing-panel.tsx
|
|
5
|
-
import * as
|
|
6
|
-
import { __ } from "@wordpress/i18n";
|
|
4
|
+
// src/components/editing-panel/editing-panel.tsx
|
|
5
|
+
import * as React11 from "react";
|
|
6
|
+
import { __ as __2 } from "@wordpress/i18n";
|
|
7
7
|
|
|
8
8
|
// src/hooks/use-selected-elements.ts
|
|
9
9
|
import { __privateUseListenTo as useListenTo, commandEndEvent } from "@elementor/editor-v1-adapters";
|
|
@@ -64,17 +64,9 @@ function useElementType(type) {
|
|
|
64
64
|
);
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
// src/components/editing-panel.tsx
|
|
67
|
+
// src/components/editing-panel/editing-panel.tsx
|
|
68
68
|
import { Panel, PanelBody, PanelHeader, PanelHeaderTitle } from "@elementor/editor-panels";
|
|
69
69
|
|
|
70
|
-
// src/components/controls/control-types/select-control.tsx
|
|
71
|
-
import * as React3 from "react";
|
|
72
|
-
import { MenuItem, Select } from "@elementor/ui";
|
|
73
|
-
|
|
74
|
-
// src/contexts/control-context.tsx
|
|
75
|
-
import * as React2 from "react";
|
|
76
|
-
import { createContext as createContext2, useContext as useContext2 } from "react";
|
|
77
|
-
|
|
78
70
|
// src/contexts/element-context.tsx
|
|
79
71
|
import * as React from "react";
|
|
80
72
|
import { createContext, useContext } from "react";
|
|
@@ -90,6 +82,32 @@ function useElementContext() {
|
|
|
90
82
|
return context;
|
|
91
83
|
}
|
|
92
84
|
|
|
85
|
+
// src/components/editing-panel/editing-panel-tabs.tsx
|
|
86
|
+
import { Stack as Stack4, Tabs, Tab, TabPanel, useTabs } from "@elementor/ui";
|
|
87
|
+
import * as React10 from "react";
|
|
88
|
+
import { __ } from "@wordpress/i18n";
|
|
89
|
+
|
|
90
|
+
// src/components/editing-panel/settings-tab.tsx
|
|
91
|
+
import * as React7 from "react";
|
|
92
|
+
import { Stack as Stack3 } from "@elementor/ui";
|
|
93
|
+
|
|
94
|
+
// src/components/controls/settings-control.tsx
|
|
95
|
+
import * as React2 from "react";
|
|
96
|
+
|
|
97
|
+
// src/contexts/control-context.tsx
|
|
98
|
+
import { createContext as createContext2, useContext as useContext2 } from "react";
|
|
99
|
+
var ControlContext = createContext2(null);
|
|
100
|
+
function useControl(defaultValue) {
|
|
101
|
+
const controlContext = useContext2(ControlContext);
|
|
102
|
+
if (!controlContext) {
|
|
103
|
+
throw new Error("useControl must be used within a ControlContext");
|
|
104
|
+
}
|
|
105
|
+
return { ...controlContext, value: controlContext.value ?? defaultValue };
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// src/components/controls/settings-control.tsx
|
|
109
|
+
import { Stack, styled, Typography } from "@elementor/ui";
|
|
110
|
+
|
|
93
111
|
// src/hooks/use-widget-settings.ts
|
|
94
112
|
import { commandEndEvent as commandEndEvent3, __privateUseListenTo as useListenTo3 } from "@elementor/editor-v1-adapters";
|
|
95
113
|
|
|
@@ -125,16 +143,8 @@ var updateSettings = ({ id, props }) => {
|
|
|
125
143
|
});
|
|
126
144
|
};
|
|
127
145
|
|
|
128
|
-
// src/
|
|
129
|
-
var
|
|
130
|
-
function useControl(defaultValue) {
|
|
131
|
-
const controlContext = useContext2(ControlContext);
|
|
132
|
-
if (!controlContext) {
|
|
133
|
-
throw new Error("useControl must be used within a ControlContext");
|
|
134
|
-
}
|
|
135
|
-
return { ...controlContext, value: controlContext.value ?? defaultValue };
|
|
136
|
-
}
|
|
137
|
-
var ControlContextProvider = ({ bind, children }) => {
|
|
146
|
+
// src/components/controls/settings-control.tsx
|
|
147
|
+
var SettingsControlProvider = ({ bind, children }) => {
|
|
138
148
|
const { element } = useElementContext();
|
|
139
149
|
const value = useWidgetSettings({ id: element.id, bind });
|
|
140
150
|
const setValue = (newValue) => {
|
|
@@ -147,29 +157,58 @@ var ControlContextProvider = ({ bind, children }) => {
|
|
|
147
157
|
};
|
|
148
158
|
return /* @__PURE__ */ React2.createElement(ControlContext.Provider, { value: { setValue, value, bind } }, children);
|
|
149
159
|
};
|
|
160
|
+
var SettingsControl = ({ children, bind }) => /* @__PURE__ */ React2.createElement(SettingsControlProvider, { bind }, /* @__PURE__ */ React2.createElement(StyledStack, { gap: 1, direction: "row", alignItems: "center", justifyContent: "space-between", flexWrap: "wrap" }, children));
|
|
161
|
+
var StyledStack = styled(Stack)`
|
|
162
|
+
& > * {
|
|
163
|
+
flex-grow: 1;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
& > label {
|
|
167
|
+
min-width: 50%;
|
|
168
|
+
}
|
|
169
|
+
`;
|
|
170
|
+
var Label = ({ children }) => {
|
|
171
|
+
return /* @__PURE__ */ React2.createElement(Typography, { component: "label", variant: "caption" }, children);
|
|
172
|
+
};
|
|
173
|
+
SettingsControl.Label = Label;
|
|
174
|
+
|
|
175
|
+
// src/components/controls/collapsible-section.tsx
|
|
176
|
+
import * as React3 from "react";
|
|
177
|
+
import { useId } from "react";
|
|
178
|
+
import { Accordion, AccordionSummary, AccordionDetails, AccordionSummaryText, Stack as Stack2 } from "@elementor/ui";
|
|
179
|
+
var CollapsibleSection = ({ title, children }) => {
|
|
180
|
+
const uid = useId();
|
|
181
|
+
const labelId = `label-${uid}`;
|
|
182
|
+
const contentId = `content-${uid}`;
|
|
183
|
+
return /* @__PURE__ */ React3.createElement(Accordion, { disableGutters: true, defaultExpanded: true }, /* @__PURE__ */ React3.createElement(AccordionSummary, { "aria-controls": contentId, id: labelId }, /* @__PURE__ */ React3.createElement(AccordionSummaryText, { primaryTypographyProps: { variant: "caption" } }, title)), /* @__PURE__ */ React3.createElement(AccordionDetails, { id: contentId, "aria-labelledby": labelId }, /* @__PURE__ */ React3.createElement(Stack2, { gap: 2.5 }, children)));
|
|
184
|
+
};
|
|
150
185
|
|
|
151
186
|
// src/components/controls/control-types/select-control.tsx
|
|
187
|
+
import * as React4 from "react";
|
|
188
|
+
import { MenuItem, Select } from "@elementor/ui";
|
|
152
189
|
var SelectControl = ({ options }) => {
|
|
153
190
|
const { value, setValue } = useControl();
|
|
154
191
|
const handleChange = (event) => {
|
|
155
192
|
setValue(event.target.value);
|
|
156
193
|
};
|
|
157
|
-
return /* @__PURE__ */
|
|
194
|
+
return /* @__PURE__ */ React4.createElement(Select, { size: "tiny", value: value ?? "", onChange: handleChange }, options.map(({ label, ...props }) => /* @__PURE__ */ React4.createElement(MenuItem, { key: props.value, ...props }, label)));
|
|
158
195
|
};
|
|
159
196
|
|
|
160
197
|
// src/components/controls/control-types/text-area-control.tsx
|
|
161
|
-
import * as
|
|
162
|
-
import {
|
|
198
|
+
import * as React5 from "react";
|
|
199
|
+
import { TextField } from "@elementor/ui";
|
|
163
200
|
var TextAreaControl = ({ placeholder }) => {
|
|
164
201
|
const { value, setValue } = useControl("");
|
|
165
202
|
const handleChange = (event) => {
|
|
166
203
|
setValue(event.target.value);
|
|
167
204
|
};
|
|
168
|
-
return /* @__PURE__ */
|
|
169
|
-
|
|
205
|
+
return /* @__PURE__ */ React5.createElement(
|
|
206
|
+
TextField,
|
|
170
207
|
{
|
|
171
208
|
size: "tiny",
|
|
172
|
-
|
|
209
|
+
multiline: true,
|
|
210
|
+
fullWidth: true,
|
|
211
|
+
rows: 5,
|
|
173
212
|
value,
|
|
174
213
|
onChange: handleChange,
|
|
175
214
|
placeholder
|
|
@@ -177,32 +216,109 @@ var TextAreaControl = ({ placeholder }) => {
|
|
|
177
216
|
);
|
|
178
217
|
};
|
|
179
218
|
|
|
180
|
-
// src/components/controls/
|
|
181
|
-
import * as
|
|
182
|
-
import {
|
|
183
|
-
var
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
flexDirection: "row",
|
|
188
|
-
alignItems: "center",
|
|
189
|
-
justifyContent: "space-between",
|
|
190
|
-
flexWrap: "wrap",
|
|
191
|
-
sx: { px: 2 }
|
|
192
|
-
},
|
|
193
|
-
/* @__PURE__ */ React5.createElement(ControlContextProvider, { bind }, children)
|
|
194
|
-
);
|
|
195
|
-
var Label = ({ children }) => {
|
|
196
|
-
return /* @__PURE__ */ React5.createElement(Typography, { component: "label", variant: "caption" }, children);
|
|
219
|
+
// src/components/controls/control-types/text-control.tsx
|
|
220
|
+
import * as React6 from "react";
|
|
221
|
+
import { TextField as TextField2 } from "@elementor/ui";
|
|
222
|
+
var TextControl = ({ placeholder }) => {
|
|
223
|
+
const { value, setValue } = useControl("");
|
|
224
|
+
const handleChange = (event) => setValue(event.target.value);
|
|
225
|
+
return /* @__PURE__ */ React6.createElement(TextField2, { type: "text", size: "tiny", value, onChange: handleChange, placeholder });
|
|
197
226
|
};
|
|
198
|
-
SettingsControl.Label = Label;
|
|
199
227
|
|
|
200
|
-
// src/components/
|
|
201
|
-
import { Stack as Stack2 } from "@elementor/ui";
|
|
228
|
+
// src/components/controls/get-control-by-type.ts
|
|
202
229
|
var controlTypes = {
|
|
203
230
|
select: SelectControl,
|
|
231
|
+
text: TextControl,
|
|
204
232
|
textarea: TextAreaControl
|
|
205
233
|
};
|
|
234
|
+
var getControlByType = (type) => {
|
|
235
|
+
return controlTypes[type] ?? null;
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
// src/components/editing-panel/settings-tab.tsx
|
|
239
|
+
var SettingsTab = () => {
|
|
240
|
+
const { element } = useElementContext();
|
|
241
|
+
const elementType = useElementType(element?.type);
|
|
242
|
+
if (!elementType) {
|
|
243
|
+
return null;
|
|
244
|
+
}
|
|
245
|
+
return /* @__PURE__ */ React7.createElement(Stack3, null, elementType.controls.map(({ type, value }, index) => {
|
|
246
|
+
if (type === "control") {
|
|
247
|
+
return /* @__PURE__ */ React7.createElement(Control, { key: value.bind, control: value });
|
|
248
|
+
}
|
|
249
|
+
if (type === "section") {
|
|
250
|
+
return /* @__PURE__ */ React7.createElement(CollapsibleSection, { key: type + "." + index, title: value.label }, value.items?.map((item) => {
|
|
251
|
+
if (item.type === "control") {
|
|
252
|
+
return /* @__PURE__ */ React7.createElement(Control, { key: item.value.bind, control: item.value });
|
|
253
|
+
}
|
|
254
|
+
return null;
|
|
255
|
+
}));
|
|
256
|
+
}
|
|
257
|
+
return null;
|
|
258
|
+
}));
|
|
259
|
+
};
|
|
260
|
+
var Control = ({ control }) => {
|
|
261
|
+
const ControlComponent = getControlByType(control.type);
|
|
262
|
+
if (!ControlComponent) {
|
|
263
|
+
return null;
|
|
264
|
+
}
|
|
265
|
+
return /* @__PURE__ */ React7.createElement(SettingsControl, { key: control.bind, bind: control.bind }, /* @__PURE__ */ React7.createElement(SettingsControl.Label, null, control.label), /* @__PURE__ */ React7.createElement(
|
|
266
|
+
ControlComponent,
|
|
267
|
+
{
|
|
268
|
+
...control.props
|
|
269
|
+
}
|
|
270
|
+
));
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
// src/components/editing-panel/style-tab.tsx
|
|
274
|
+
import * as React9 from "react";
|
|
275
|
+
|
|
276
|
+
// src/contexts/style-context.tsx
|
|
277
|
+
import * as React8 from "react";
|
|
278
|
+
import { createContext as createContext3, useContext as useContext3 } from "react";
|
|
279
|
+
import { useActiveBreakpoint } from "@elementor/editor-responsive";
|
|
280
|
+
var Context2 = createContext3(null);
|
|
281
|
+
function StyleContext({ children, selectedStyleDef }) {
|
|
282
|
+
const breakpoint = useActiveBreakpoint();
|
|
283
|
+
const selectedMeta = { breakpoint, state: null };
|
|
284
|
+
return /* @__PURE__ */ React8.createElement(Context2.Provider, { value: { selectedStyleDef, selectedMeta } }, children);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// src/hooks/use-element-styles.ts
|
|
288
|
+
import { __privateUseListenTo as useListenTo4, commandEndEvent as commandEndEvent4 } from "@elementor/editor-v1-adapters";
|
|
289
|
+
|
|
290
|
+
// src/sync/get-element-styles.ts
|
|
291
|
+
var getElementStyles = (elementID) => {
|
|
292
|
+
const container = getContainer(elementID);
|
|
293
|
+
return container?.model.get("styles") || null;
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
// src/hooks/use-element-styles.ts
|
|
297
|
+
var useElementStyles = (elementID) => {
|
|
298
|
+
return useListenTo4(
|
|
299
|
+
commandEndEvent4("document/atomic-widgets/styles"),
|
|
300
|
+
() => {
|
|
301
|
+
return getElementStyles(elementID);
|
|
302
|
+
},
|
|
303
|
+
[elementID]
|
|
304
|
+
);
|
|
305
|
+
};
|
|
306
|
+
|
|
307
|
+
// src/components/editing-panel/style-tab.tsx
|
|
308
|
+
var StyleTab = () => {
|
|
309
|
+
const selectedElementID = useElementContext().element.id;
|
|
310
|
+
const elementStyles = useElementStyles(selectedElementID);
|
|
311
|
+
const selectedStyleDef = elementStyles ? Object.values(elementStyles)[0] : null;
|
|
312
|
+
return /* @__PURE__ */ React9.createElement(StyleContext, { selectedStyleDef }, /* @__PURE__ */ React9.createElement("div", null, "Style Tab"));
|
|
313
|
+
};
|
|
314
|
+
|
|
315
|
+
// src/components/editing-panel/editing-panel-tabs.tsx
|
|
316
|
+
var EditingPanelTabs = () => {
|
|
317
|
+
const { getTabProps, getTabPanelProps, getTabsProps } = useTabs("settings");
|
|
318
|
+
return /* @__PURE__ */ React10.createElement(Stack4, { direction: "column", sx: { width: "100%" } }, /* @__PURE__ */ React10.createElement(Tabs, { variant: "fullWidth", indicatorColor: "secondary", textColor: "inherit", ...getTabsProps() }, /* @__PURE__ */ React10.createElement(Tab, { label: __("General", "elementor"), ...getTabProps("settings") }), /* @__PURE__ */ React10.createElement(Tab, { label: __("Style", "elementor"), ...getTabProps("style") })), /* @__PURE__ */ React10.createElement(TabPanel, { ...getTabPanelProps("settings"), disablePadding: true }, /* @__PURE__ */ React10.createElement(SettingsTab, null)), /* @__PURE__ */ React10.createElement(TabPanel, { ...getTabPanelProps("style"), disablePadding: true }, /* @__PURE__ */ React10.createElement(StyleTab, null)));
|
|
319
|
+
};
|
|
320
|
+
|
|
321
|
+
// src/components/editing-panel/editing-panel.tsx
|
|
206
322
|
var EditingPanel = () => {
|
|
207
323
|
const elements = useSelectedElements();
|
|
208
324
|
const [selectedElement] = elements;
|
|
@@ -210,22 +326,8 @@ var EditingPanel = () => {
|
|
|
210
326
|
if (elements.length !== 1 || !elementType) {
|
|
211
327
|
return null;
|
|
212
328
|
}
|
|
213
|
-
const panelTitle =
|
|
214
|
-
return /* @__PURE__ */
|
|
215
|
-
if (control.type === "control") {
|
|
216
|
-
const ControlComponent = controlTypes[control.value.type];
|
|
217
|
-
if (!ControlComponent) {
|
|
218
|
-
return null;
|
|
219
|
-
}
|
|
220
|
-
return /* @__PURE__ */ React6.createElement(SettingsControl, { key: control.value.bind, bind: control.value.bind }, /* @__PURE__ */ React6.createElement(SettingsControl.Label, null, control.value.label), /* @__PURE__ */ React6.createElement(
|
|
221
|
-
ControlComponent,
|
|
222
|
-
{
|
|
223
|
-
...control.value.props
|
|
224
|
-
}
|
|
225
|
-
));
|
|
226
|
-
}
|
|
227
|
-
return null;
|
|
228
|
-
})))));
|
|
329
|
+
const panelTitle = __2("Edit %s", "elementor").replace("%s", elementType.title);
|
|
330
|
+
return /* @__PURE__ */ React11.createElement(Panel, null, /* @__PURE__ */ React11.createElement(PanelHeader, null, /* @__PURE__ */ React11.createElement(PanelHeaderTitle, null, panelTitle)), /* @__PURE__ */ React11.createElement(PanelBody, null, /* @__PURE__ */ React11.createElement(ElementContext, { element: selectedElement }, /* @__PURE__ */ React11.createElement(EditingPanelTabs, null))));
|
|
229
331
|
};
|
|
230
332
|
|
|
231
333
|
// src/panel.ts
|
|
@@ -261,7 +363,7 @@ var useOpenEditorPanel = () => {
|
|
|
261
363
|
}, []);
|
|
262
364
|
};
|
|
263
365
|
|
|
264
|
-
// src/components/editing-panel-hooks.tsx
|
|
366
|
+
// src/components/editing-panel/editing-panel-hooks.tsx
|
|
265
367
|
var EditingPanelHooks = () => {
|
|
266
368
|
useOpenEditorPanel();
|
|
267
369
|
return null;
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/panel.ts","../src/components/editing-panel.tsx","../src/hooks/use-selected-elements.ts","../src/sync/get-selected-elements.ts","../src/hooks/use-element-type.ts","../src/sync/get-widgets-cache.ts","../src/components/controls/control-types/select-control.tsx","../src/contexts/control-context.tsx","../src/contexts/element-context.tsx","../src/hooks/use-widget-settings.ts","../src/sync/get-container.ts","../src/sync/update-settings.ts","../src/components/controls/control-types/text-area-control.tsx","../src/components/controls/settings-control.tsx","../src/init.ts","../src/sync/should-use-v2-panel.ts","../src/hooks/use-open-editor-panel.ts","../src/components/editing-panel-hooks.tsx","../src/index.ts"],"sourcesContent":["import { __createPanel as createPanel } from '@elementor/editor-panels';\nimport { EditingPanel } from './components/editing-panel';\n\nexport const { panel, usePanelActions, usePanelStatus } = createPanel( {\n\tid: 'editing-panel',\n\tcomponent: EditingPanel,\n} );\n","import * as React from 'react';\nimport { __ } from '@wordpress/i18n';\nimport useSelectedElements from '../hooks/use-selected-elements';\nimport useElementType from '../hooks/use-element-type';\nimport { Panel, PanelBody, PanelHeader, PanelHeaderTitle } from '@elementor/editor-panels';\nimport { SelectControl } from './controls/control-types/select-control';\nimport { TextAreaControl } from './controls/control-types/text-area-control';\nimport { SettingsControl } from '../components/controls/settings-control';\nimport { Stack } from '@elementor/ui';\nimport { ElementContext } from '../contexts/element-context';\n\nconst controlTypes = {\n\tselect: SelectControl,\n\ttextarea: TextAreaControl,\n};\n\nexport const EditingPanel = () => {\n\tconst elements = useSelectedElements();\n\n\tconst [ selectedElement ] = elements;\n\n\tconst elementType = useElementType( selectedElement?.type );\n\n\tif ( elements.length !== 1 || ! elementType ) {\n\t\treturn null;\n\t}\n\n\t/* translators: %s: Element type title. */\n\tconst panelTitle = __( 'Edit %s', 'elementor' ).replace( '%s', elementType.title );\n\n\treturn (\n\t\t<Panel>\n\t\t\t<PanelHeader>\n\t\t\t\t<PanelHeaderTitle>{ panelTitle }</PanelHeaderTitle>\n\t\t\t</PanelHeader>\n\t\t\t<PanelBody>\n\t\t\t\t<ElementContext element={ selectedElement }>\n\t\t\t\t\t<Stack spacing={ 2 }>\n\t\t\t\t\t\t{ elementType.controls.map( ( control ) => {\n\t\t\t\t\t\t\tif ( control.type === 'control' ) {\n\t\t\t\t\t\t\t\tconst ControlComponent =\n\t\t\t\t\t\t\t\t\tcontrolTypes[ control.value.type as keyof typeof controlTypes ];\n\n\t\t\t\t\t\t\t\tif ( ! ControlComponent ) {\n\t\t\t\t\t\t\t\t\treturn null;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t<SettingsControl key={ control.value.bind } bind={ control.value.bind }>\n\t\t\t\t\t\t\t\t\t\t<SettingsControl.Label>{ control.value.label }</SettingsControl.Label>\n\t\t\t\t\t\t\t\t\t\t<ControlComponent\n\t\t\t\t\t\t\t\t\t\t\t/* eslint-disable-next-line @typescript-eslint/no-explicit-any */\n\t\t\t\t\t\t\t\t\t\t\t{ ...( control.value.props as any ) }\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t</SettingsControl>\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\treturn null;\n\t\t\t\t\t\t} ) }\n\t\t\t\t\t</Stack>\n\t\t\t\t</ElementContext>\n\t\t\t</PanelBody>\n\t\t</Panel>\n\t);\n};\n","import { __privateUseListenTo as useListenTo, commandEndEvent } from '@elementor/editor-v1-adapters';\nimport getSelectedElements from '../sync/get-selected-elements';\n\nexport default function useSelectedElements() {\n\treturn useListenTo(\n\t\t[ commandEndEvent( 'document/elements/select' ), commandEndEvent( 'document/elements/deselect' ) ],\n\t\t() => getSelectedElements()\n\t);\n}\n","import { ExtendedWindow } from './types';\nimport { Element } from '../types';\n\nexport default function getSelectedElements(): Element[] {\n\tconst extendedWindow = window as unknown as ExtendedWindow;\n\n\tconst selectedElements = extendedWindow.elementor?.selection?.getElements?.() ?? [];\n\n\treturn selectedElements.reduce< Element[] >( ( acc, el ) => {\n\t\tconst type = el.model.get( 'widgetType' ) || el.model.get( 'elType' );\n\n\t\tif ( type ) {\n\t\t\tacc.push( {\n\t\t\t\tid: el.model.get( 'id' ),\n\t\t\t\ttype,\n\t\t\t} );\n\t\t}\n\n\t\treturn acc;\n\t}, [] );\n}\n","import { __privateUseListenTo as useListenTo, commandEndEvent } from '@elementor/editor-v1-adapters';\nimport getWidgetsCache from '../sync/get-widgets-cache';\nimport { ElementType } from '../types';\n\nexport default function useElementType( type?: string ) {\n\treturn useListenTo(\n\t\tcommandEndEvent( 'editor/documents/load' ),\n\t\t(): ElementType | null => {\n\t\t\tif ( ! type ) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tconst widgetsCache = getWidgetsCache();\n\t\t\tconst elementType = widgetsCache?.[ type ];\n\n\t\t\tif ( ! elementType?.atomic_controls ) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tkey: type,\n\t\t\t\tcontrols: elementType.atomic_controls,\n\t\t\t\ttitle: elementType.title,\n\t\t\t};\n\t\t},\n\t\t[ type ]\n\t);\n}\n","import { ExtendedWindow } from './types';\n\nexport default function getWidgetsCache() {\n\tconst extendedWindow = window as unknown as ExtendedWindow;\n\n\treturn extendedWindow?.elementor?.widgetsCache || null;\n}\n","import * as React from 'react';\nimport { MenuItem, Select, SelectChangeEvent } from '@elementor/ui';\nimport { useControl } from '../../../contexts/control-context';\nimport { PropValue } from '../../../types';\n\ntype Props< T > = {\n\toptions: Array< { label: string; value: T; disabled?: boolean } >;\n};\n\nexport const SelectControl = < T extends PropValue >( { options }: Props< T > ) => {\n\tconst { value, setValue } = useControl< T >();\n\n\tconst handleChange = ( event: SelectChangeEvent< T > ) => {\n\t\tsetValue( event.target.value as T );\n\t};\n\n\treturn (\n\t\t<Select size=\"tiny\" value={ value ?? '' } onChange={ handleChange }>\n\t\t\t{ options.map( ( { label, ...props } ) => (\n\t\t\t\t<MenuItem key={ props.value } { ...props }>\n\t\t\t\t\t{ label }\n\t\t\t\t</MenuItem>\n\t\t\t) ) }\n\t\t</Select>\n\t);\n};\n","import * as React from 'react';\nimport { createContext, useContext } from 'react';\nimport { PropKey, PropValue } from '../types';\nimport { useElementContext } from './element-context';\nimport { useWidgetSettings } from '../hooks/use-widget-settings';\nimport { updateSettings } from '../sync/update-settings';\n\nexport type ControlContext< T extends PropValue > = null | {\n\tbind: PropKey;\n\tsetValue: ( value: T ) => void;\n\tvalue: T;\n};\n\nexport const ControlContext = createContext< ControlContext< PropValue > >( null );\n\nexport function useControl< T extends PropValue >( defaultValue?: T ) {\n\tconst controlContext = useContext< ControlContext< T > >( ControlContext as never );\n\n\tif ( ! controlContext ) {\n\t\tthrow new Error( 'useControl must be used within a ControlContext' );\n\t}\n\n\treturn { ...controlContext, value: controlContext.value ?? defaultValue };\n}\n\ntype Props = {\n\tbind: PropKey;\n\tchildren: React.ReactNode;\n};\n\nexport const ControlContextProvider = ( { bind, children }: Props ) => {\n\tconst { element } = useElementContext();\n\tconst value = useWidgetSettings( { id: element.id, bind } );\n\n\tconst setValue = ( newValue: PropValue ) => {\n\t\tupdateSettings( {\n\t\t\tid: element.id,\n\t\t\tprops: {\n\t\t\t\t[ bind ]: newValue,\n\t\t\t},\n\t\t} );\n\t};\n\n\treturn <ControlContext.Provider value={ { setValue, value, bind } }>{ children }</ControlContext.Provider>;\n};\n","import * as React from 'react';\nimport { createContext, ReactNode, useContext } from 'react';\nimport { Element } from '../types';\n\ntype ContextValue = {\n\telement: Element;\n};\n\nconst Context = createContext< ContextValue | null >( null );\n\ntype Props = {\n\telement: Element;\n\tchildren?: ReactNode;\n};\n\nexport function ElementContext( { children, element }: Props ) {\n\treturn <Context.Provider value={ { element } }>{ children }</Context.Provider>;\n}\n\nexport function useElementContext() {\n\tconst context = useContext( Context );\n\n\tif ( ! context ) {\n\t\tthrow new Error( 'useElementContext must be used within a ElementContextProvider' );\n\t}\n\n\treturn context;\n}\n","import { commandEndEvent, __privateUseListenTo as useListenTo } from '@elementor/editor-v1-adapters';\nimport { PropValue } from '../types';\nimport getContainer from '../sync/get-container';\n\nexport const useWidgetSettings = ( { id, bind }: { id: string; bind: string } ): PropValue => {\n\treturn useListenTo(\n\t\tcommandEndEvent( 'document/elements/settings' ),\n\t\t() => {\n\t\t\tconst container = getContainer( id );\n\t\t\tconst value = container?.settings?.get( bind ) ?? null;\n\n\t\t\treturn value;\n\t\t},\n\t\t[ id, bind ]\n\t);\n};\n","import { ExtendedWindow } from './types';\n\nexport default function getContainer( id: string ) {\n\tconst extendedWindow = window as unknown as ExtendedWindow;\n\tconst container = extendedWindow.elementor?.getContainer?.( id );\n\n\treturn container ?? null;\n}\n","import { __privateRunCommand as runCommand } from '@elementor/editor-v1-adapters';\nimport { Props } from '../types';\nimport getContainer from './get-container';\n\nexport const updateSettings = ( { id, props }: { id: string; props: Props } ) => {\n\tconst container = getContainer( id );\n\n\trunCommand( 'document/elements/settings', {\n\t\tcontainer,\n\t\tsettings: {\n\t\t\t...props,\n\t\t},\n\t} );\n};\n","import * as React from 'react';\nimport { TextareaAutosize } from '@elementor/ui';\nimport { useControl } from '../../../contexts/control-context';\n\ntype Props = {\n\tplaceholder?: string;\n};\n\nexport const TextAreaControl = ( { placeholder }: Props ) => {\n\tconst { value, setValue } = useControl< string >( '' );\n\n\tconst handleChange = ( event: React.ChangeEvent< HTMLInputElement > ) => {\n\t\tsetValue( event.target.value );\n\t};\n\n\treturn (\n\t\t<TextareaAutosize\n\t\t\tsize=\"tiny\"\n\t\t\tminRows={ 3 }\n\t\t\tvalue={ value }\n\t\t\tonChange={ handleChange }\n\t\t\tplaceholder={ placeholder }\n\t\t/>\n\t);\n};\n","import * as React from 'react';\nimport { ControlContextProvider } from '../../contexts/control-context';\nimport { Stack, Typography } from '@elementor/ui';\nimport { PropKey } from '../../types';\n\ntype Props = {\n\tbind: PropKey;\n\tchildren: React.ReactNode;\n};\n\nconst SettingsControl = ( { children, bind }: Props ) => (\n\t<Stack\n\t\tspacing={ 1 }\n\t\tflexDirection=\"row\"\n\t\talignItems=\"center\"\n\t\tjustifyContent=\"space-between\"\n\t\tflexWrap=\"wrap\"\n\t\tsx={ { px: 2 } }\n\t>\n\t\t<ControlContextProvider bind={ bind }>{ children }</ControlContextProvider>\n\t</Stack>\n);\n\nconst Label = ( { children }: { children: React.ReactNode } ) => {\n\treturn (\n\t\t<Typography component=\"label\" variant=\"caption\">\n\t\t\t{ children }\n\t\t</Typography>\n\t);\n};\n\nSettingsControl.Label = Label;\nexport { SettingsControl };\n","import { panel } from './panel';\nimport { injectIntoLogic } from '@elementor/editor';\nimport { shouldUseV2Panel } from './sync/should-use-v2-panel';\nimport { EditingPanelHooks } from './components/editing-panel-hooks';\nimport { __registerPanel as registerPanel } from '@elementor/editor-panels';\nimport { __privateBlockDataCommand as blockDataCommand } from '@elementor/editor-v1-adapters';\n\nexport default function init() {\n\tregisterPanel( panel );\n\tblockV1Panel();\n\n\tinjectIntoLogic( {\n\t\tid: 'editing-panel-hooks',\n\t\tcomponent: EditingPanelHooks,\n\t} );\n}\n\nconst blockV1Panel = () => {\n\tblockDataCommand( {\n\t\tcommand: 'panel/editor/open',\n\t\tcondition: shouldUseV2Panel,\n\t} );\n};\n","import getSelectedElements from './get-selected-elements';\nimport getWidgetsCache from './get-widgets-cache';\n\nexport const shouldUseV2Panel = () => {\n\tconst selectedElements = getSelectedElements();\n\tconst widgetCache = getWidgetsCache();\n\n\tif ( selectedElements.length !== 1 ) {\n\t\treturn false;\n\t}\n\n\t// Check if the selected element has atomic controls, meaning it's a V2 element.\n\treturn !! widgetCache?.[ selectedElements[ 0 ].type ]?.atomic_controls;\n};\n","import { useEffect } from 'react';\nimport { commandStartEvent, __privateListenTo as listenTo } from '@elementor/editor-v1-adapters';\nimport { usePanelActions } from '../panel';\nimport { shouldUseV2Panel } from '../sync/should-use-v2-panel';\n\nexport const useOpenEditorPanel = () => {\n\tconst { open } = usePanelActions();\n\n\tuseEffect( () => {\n\t\treturn listenTo( commandStartEvent( 'panel/editor/open' ), () => {\n\t\t\tif ( shouldUseV2Panel() ) {\n\t\t\t\topen();\n\t\t\t}\n\t\t} );\n\t}, [] ); // eslint-disable-line react-hooks/exhaustive-deps\n};\n","import { useOpenEditorPanel } from '../hooks/use-open-editor-panel';\n\nexport const EditingPanelHooks = () => {\n\tuseOpenEditorPanel();\n\n\treturn null;\n};\n","import init from './init';\n\ninit();\n"],"mappings":";AAAA,SAAS,iBAAiB,mBAAmB;;;ACA7C,YAAYA,YAAW;AACvB,SAAS,UAAU;;;ACDnB,SAAS,wBAAwB,aAAa,uBAAuB;;;ACGtD,SAAR,sBAAkD;AACxD,QAAM,iBAAiB;AAEvB,QAAM,mBAAmB,eAAe,WAAW,WAAW,cAAc,KAAK,CAAC;AAElF,SAAO,iBAAiB,OAAqB,CAAE,KAAK,OAAQ;AAC3D,UAAM,OAAO,GAAG,MAAM,IAAK,YAAa,KAAK,GAAG,MAAM,IAAK,QAAS;AAEpE,QAAK,MAAO;AACX,UAAI,KAAM;AAAA,QACT,IAAI,GAAG,MAAM,IAAK,IAAK;AAAA,QACvB;AAAA,MACD,CAAE;AAAA,IACH;AAEA,WAAO;AAAA,EACR,GAAG,CAAC,CAAE;AACP;;;ADjBe,SAAR,sBAAuC;AAC7C,SAAO;AAAA,IACN,CAAE,gBAAiB,0BAA2B,GAAG,gBAAiB,4BAA6B,CAAE;AAAA,IACjG,MAAM,oBAAoB;AAAA,EAC3B;AACD;;;AERA,SAAS,wBAAwBC,cAAa,mBAAAC,wBAAuB;;;ACEtD,SAAR,kBAAmC;AACzC,QAAM,iBAAiB;AAEvB,SAAO,gBAAgB,WAAW,gBAAgB;AACnD;;;ADFe,SAAR,eAAiC,MAAgB;AACvD,SAAOC;AAAA,IACNC,iBAAiB,uBAAwB;AAAA,IACzC,MAA0B;AACzB,UAAK,CAAE,MAAO;AACb,eAAO;AAAA,MACR;AAEA,YAAM,eAAe,gBAAgB;AACrC,YAAM,cAAc,eAAgB,IAAK;AAEzC,UAAK,CAAE,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A,IACT,WAAW;AAAA,EACZ,CAAE;AACH;;;AIpBA,KAAK;","names":["React","useListenTo","commandEndEvent","useListenTo","commandEndEvent","React","React","createContext","useContext","commandEndEvent","useListenTo","useListenTo","commandEndEvent","createContext","useContext","React","React","Stack","Stack"]}
|
|
1
|
+
{"version":3,"sources":["../src/panel.ts","../src/components/editing-panel/editing-panel.tsx","../src/hooks/use-selected-elements.ts","../src/sync/get-selected-elements.ts","../src/hooks/use-element-type.ts","../src/sync/get-widgets-cache.ts","../src/contexts/element-context.tsx","../src/components/editing-panel/editing-panel-tabs.tsx","../src/components/editing-panel/settings-tab.tsx","../src/components/controls/settings-control.tsx","../src/contexts/control-context.tsx","../src/hooks/use-widget-settings.ts","../src/sync/get-container.ts","../src/sync/update-settings.ts","../src/components/controls/collapsible-section.tsx","../src/components/controls/control-types/select-control.tsx","../src/components/controls/control-types/text-area-control.tsx","../src/components/controls/control-types/text-control.tsx","../src/components/controls/get-control-by-type.ts","../src/components/editing-panel/style-tab.tsx","../src/contexts/style-context.tsx","../src/hooks/use-element-styles.ts","../src/sync/get-element-styles.ts","../src/init.ts","../src/sync/should-use-v2-panel.ts","../src/hooks/use-open-editor-panel.ts","../src/components/editing-panel/editing-panel-hooks.tsx","../src/index.ts"],"sourcesContent":["import { __createPanel as createPanel } from '@elementor/editor-panels';\nimport { EditingPanel } from './components/editing-panel/editing-panel';\n\nexport const { panel, usePanelActions, usePanelStatus } = createPanel( {\n\tid: 'editing-panel',\n\tcomponent: EditingPanel,\n} );\n","import * as React from 'react';\nimport { __ } from '@wordpress/i18n';\nimport useSelectedElements from '../../hooks/use-selected-elements';\nimport useElementType from '../../hooks/use-element-type';\nimport { Panel, PanelBody, PanelHeader, PanelHeaderTitle } from '@elementor/editor-panels';\nimport { ElementContext } from '../../contexts/element-context';\nimport { EditingPanelTabs } from './editing-panel-tabs';\n\nexport const EditingPanel = () => {\n\tconst elements = useSelectedElements();\n\n\tconst [ selectedElement ] = elements;\n\n\tconst elementType = useElementType( selectedElement?.type );\n\n\tif ( elements.length !== 1 || ! elementType ) {\n\t\treturn null;\n\t}\n\n\t/* translators: %s: Element type title. */\n\tconst panelTitle = __( 'Edit %s', 'elementor' ).replace( '%s', elementType.title );\n\n\treturn (\n\t\t<Panel>\n\t\t\t<PanelHeader>\n\t\t\t\t<PanelHeaderTitle>{ panelTitle }</PanelHeaderTitle>\n\t\t\t</PanelHeader>\n\t\t\t<PanelBody>\n\t\t\t\t<ElementContext element={ selectedElement }>\n\t\t\t\t\t<EditingPanelTabs />\n\t\t\t\t</ElementContext>\n\t\t\t</PanelBody>\n\t\t</Panel>\n\t);\n};\n","import { __privateUseListenTo as useListenTo, commandEndEvent } from '@elementor/editor-v1-adapters';\nimport getSelectedElements from '../sync/get-selected-elements';\n\nexport default function useSelectedElements() {\n\treturn useListenTo(\n\t\t[ commandEndEvent( 'document/elements/select' ), commandEndEvent( 'document/elements/deselect' ) ],\n\t\t() => getSelectedElements()\n\t);\n}\n","import { ExtendedWindow } from './types';\nimport { Element } from '../types';\n\nexport default function getSelectedElements(): Element[] {\n\tconst extendedWindow = window as unknown as ExtendedWindow;\n\n\tconst selectedElements = extendedWindow.elementor?.selection?.getElements?.() ?? [];\n\n\treturn selectedElements.reduce< Element[] >( ( acc, el ) => {\n\t\tconst type = el.model.get( 'widgetType' ) || el.model.get( 'elType' );\n\n\t\tif ( type ) {\n\t\t\tacc.push( {\n\t\t\t\tid: el.model.get( 'id' ),\n\t\t\t\ttype,\n\t\t\t} );\n\t\t}\n\n\t\treturn acc;\n\t}, [] );\n}\n","import { __privateUseListenTo as useListenTo, commandEndEvent } from '@elementor/editor-v1-adapters';\nimport getWidgetsCache from '../sync/get-widgets-cache';\nimport { ElementType } from '../types';\n\nexport default function useElementType( type?: string ) {\n\treturn useListenTo(\n\t\tcommandEndEvent( 'editor/documents/load' ),\n\t\t(): ElementType | null => {\n\t\t\tif ( ! type ) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tconst widgetsCache = getWidgetsCache();\n\t\t\tconst elementType = widgetsCache?.[ type ];\n\n\t\t\tif ( ! elementType?.atomic_controls ) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tkey: type,\n\t\t\t\tcontrols: elementType.atomic_controls,\n\t\t\t\ttitle: elementType.title,\n\t\t\t};\n\t\t},\n\t\t[ type ]\n\t);\n}\n","import { ExtendedWindow } from './types';\n\nexport default function getWidgetsCache() {\n\tconst extendedWindow = window as unknown as ExtendedWindow;\n\n\treturn extendedWindow?.elementor?.widgetsCache || null;\n}\n","import * as React from 'react';\nimport { createContext, ReactNode, useContext } from 'react';\nimport { Element } from '../types';\n\ntype ContextValue = {\n\telement: Element;\n};\n\nconst Context = createContext< ContextValue | null >( null );\n\ntype Props = {\n\telement: Element;\n\tchildren?: ReactNode;\n};\n\nexport function ElementContext( { children, element }: Props ) {\n\treturn <Context.Provider value={ { element } }>{ children }</Context.Provider>;\n}\n\nexport function useElementContext() {\n\tconst context = useContext( Context );\n\n\tif ( ! context ) {\n\t\tthrow new Error( 'useElementContext must be used within a ElementContextProvider' );\n\t}\n\n\treturn context;\n}\n","import { Stack, Tabs, Tab, TabPanel, useTabs } from '@elementor/ui';\nimport * as React from 'react';\nimport { __ } from '@wordpress/i18n';\nimport { SettingsTab } from './settings-tab';\nimport { StyleTab } from './style-tab';\n\ntype TabValue = 'settings' | 'style';\n\nexport const EditingPanelTabs = () => {\n\tconst { getTabProps, getTabPanelProps, getTabsProps } = useTabs< TabValue >( 'settings' );\n\n\treturn (\n\t\t<Stack direction=\"column\" sx={ { width: '100%' } }>\n\t\t\t<Tabs variant=\"fullWidth\" indicatorColor=\"secondary\" textColor=\"inherit\" { ...getTabsProps() }>\n\t\t\t\t<Tab label={ __( 'General', 'elementor' ) } { ...getTabProps( 'settings' ) } />\n\t\t\t\t<Tab label={ __( 'Style', 'elementor' ) } { ...getTabProps( 'style' ) } />\n\t\t\t</Tabs>\n\t\t\t<TabPanel { ...getTabPanelProps( 'settings' ) } disablePadding>\n\t\t\t\t<SettingsTab />\n\t\t\t</TabPanel>\n\t\t\t<TabPanel { ...getTabPanelProps( 'style' ) } disablePadding>\n\t\t\t\t<StyleTab />\n\t\t\t</TabPanel>\n\t\t</Stack>\n\t);\n};\n","import * as React from 'react';\nimport { Stack } from '@elementor/ui';\nimport { SettingsControl } from '../controls/settings-control';\nimport { useElementContext } from '../../contexts/element-context';\nimport useElementType from '../../hooks/use-element-type';\nimport type { Control } from '../../types';\nimport { CollapsibleSection } from '../controls/collapsible-section';\nimport { getControlByType } from '../controls/get-control-by-type';\n\nexport const SettingsTab = () => {\n\tconst { element } = useElementContext();\n\n\tconst elementType = useElementType( element?.type );\n\n\tif ( ! elementType ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Stack>\n\t\t\t{ elementType.controls.map( ( { type, value }, index ) => {\n\t\t\t\tif ( type === 'control' ) {\n\t\t\t\t\treturn <Control key={ value.bind } control={ value } />;\n\t\t\t\t}\n\n\t\t\t\tif ( type === 'section' ) {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<CollapsibleSection key={ type + '.' + index } title={ value.label }>\n\t\t\t\t\t\t\t{ value.items?.map( ( item ) => {\n\t\t\t\t\t\t\t\tif ( item.type === 'control' ) {\n\t\t\t\t\t\t\t\t\treturn <Control key={ item.value.bind } control={ item.value } />;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t// TODO: Handle 2nd level sections\n\t\t\t\t\t\t\t\treturn null;\n\t\t\t\t\t\t\t} ) }\n\t\t\t\t\t\t</CollapsibleSection>\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn null;\n\t\t\t} ) }\n\t\t</Stack>\n\t);\n};\n\n// TODO: Create control wrapper by type for different layouts.\nconst Control = ( { control }: { control: Control[ 'value' ] } ) => {\n\tconst ControlComponent = getControlByType( control.type );\n\n\tif ( ! ControlComponent ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<SettingsControl key={ control.bind } bind={ control.bind }>\n\t\t\t<SettingsControl.Label>{ control.label }</SettingsControl.Label>\n\t\t\t<ControlComponent\n\t\t\t\t/* eslint-disable-next-line @typescript-eslint/no-explicit-any */\n\t\t\t\t{ ...( control.props as any ) }\n\t\t\t/>\n\t\t</SettingsControl>\n\t);\n};\n","import * as React from 'react';\nimport { ControlContext } from '../../contexts/control-context';\nimport { Stack, styled, Typography } from '@elementor/ui';\nimport { PropKey, PropValue } from '../../types';\nimport { useElementContext } from '../../contexts/element-context';\nimport { useWidgetSettings } from '../../hooks/use-widget-settings';\nimport { updateSettings } from '../../sync/update-settings';\n\ntype Props = {\n\tbind: PropKey;\n\tchildren: React.ReactNode;\n};\n\nexport const SettingsControlProvider = ( { bind, children }: Props ) => {\n\tconst { element } = useElementContext();\n\tconst value = useWidgetSettings( { id: element.id, bind } );\n\n\tconst setValue = ( newValue: PropValue ) => {\n\t\tupdateSettings( {\n\t\t\tid: element.id,\n\t\t\tprops: {\n\t\t\t\t[ bind ]: newValue,\n\t\t\t},\n\t\t} );\n\t};\n\n\treturn <ControlContext.Provider value={ { setValue, value, bind } }>{ children }</ControlContext.Provider>;\n};\n\nconst SettingsControl = ( { children, bind }: Props ) => (\n\t<SettingsControlProvider bind={ bind }>\n\t\t<StyledStack gap={ 1 } direction=\"row\" alignItems=\"center\" justifyContent=\"space-between\" flexWrap=\"wrap\">\n\t\t\t{ children }\n\t\t</StyledStack>\n\t</SettingsControlProvider>\n);\n\nconst StyledStack = styled( Stack )`\n\t& > * {\n\t\tflex-grow: 1;\n\t}\n\n\t& > label {\n\t\tmin-width: 50%;\n\t}\n`;\n\nconst Label = ( { children }: { children: React.ReactNode } ) => {\n\treturn (\n\t\t<Typography component=\"label\" variant=\"caption\">\n\t\t\t{ children }\n\t\t</Typography>\n\t);\n};\n\nSettingsControl.Label = Label;\n\nexport { SettingsControl };\n","import { createContext, useContext } from 'react';\nimport { PropKey, PropValue } from '../types';\n\nexport type ControlContext< T extends PropValue > = null | {\n\tbind: PropKey;\n\tsetValue: ( value: T ) => void;\n\tvalue: T;\n};\n\nexport const ControlContext = createContext< ControlContext< PropValue > >( null );\n\nexport function useControl< T extends PropValue >( defaultValue?: T ) {\n\tconst controlContext = useContext< ControlContext< T > >( ControlContext as never );\n\n\tif ( ! controlContext ) {\n\t\tthrow new Error( 'useControl must be used within a ControlContext' );\n\t}\n\n\treturn { ...controlContext, value: controlContext.value ?? defaultValue };\n}\n","import { commandEndEvent, __privateUseListenTo as useListenTo } from '@elementor/editor-v1-adapters';\nimport { PropValue } from '../types';\nimport getContainer from '../sync/get-container';\n\nexport const useWidgetSettings = ( { id, bind }: { id: string; bind: string } ): PropValue => {\n\treturn useListenTo(\n\t\tcommandEndEvent( 'document/elements/settings' ),\n\t\t() => {\n\t\t\tconst container = getContainer( id );\n\t\t\tconst value = container?.settings?.get( bind ) ?? null;\n\n\t\t\treturn value;\n\t\t},\n\t\t[ id, bind ]\n\t);\n};\n","import { ExtendedWindow } from './types';\n\nexport default function getContainer( id: string ) {\n\tconst extendedWindow = window as unknown as ExtendedWindow;\n\tconst container = extendedWindow.elementor?.getContainer?.( id );\n\n\treturn container ?? null;\n}\n","import { __privateRunCommand as runCommand } from '@elementor/editor-v1-adapters';\nimport { Props } from '../types';\nimport getContainer from './get-container';\n\nexport const updateSettings = ( { id, props }: { id: string; props: Props } ) => {\n\tconst container = getContainer( id );\n\n\trunCommand( 'document/elements/settings', {\n\t\tcontainer,\n\t\tsettings: {\n\t\t\t...props,\n\t\t},\n\t} );\n};\n","import * as React from 'react';\nimport { useId } from 'react';\nimport { Accordion, AccordionSummary, AccordionDetails, AccordionSummaryText, Stack } from '@elementor/ui';\n\nexport type CollapsibleSectionProps = React.PropsWithChildren< {\n\ttitle: string;\n} >;\n\nexport const CollapsibleSection = ( { title, children }: CollapsibleSectionProps ) => {\n\tconst uid = useId();\n\tconst labelId = `label-${ uid }`;\n\tconst contentId = `content-${ uid }`;\n\n\t// TODO: Change to collapsible list item\n\treturn (\n\t\t<Accordion disableGutters defaultExpanded>\n\t\t\t<AccordionSummary aria-controls={ contentId } id={ labelId }>\n\t\t\t\t<AccordionSummaryText primaryTypographyProps={ { variant: 'caption' } }>{ title }</AccordionSummaryText>\n\t\t\t</AccordionSummary>\n\t\t\t<AccordionDetails id={ contentId } aria-labelledby={ labelId }>\n\t\t\t\t<Stack gap={ 2.5 }>{ children }</Stack>\n\t\t\t</AccordionDetails>\n\t\t</Accordion>\n\t);\n};\n","import * as React from 'react';\nimport { MenuItem, Select, SelectChangeEvent } from '@elementor/ui';\nimport { useControl } from '../../../contexts/control-context';\nimport { PropValue } from '../../../types';\n\ntype Props< T > = {\n\toptions: Array< { label: string; value: T; disabled?: boolean } >;\n};\n\nexport const SelectControl = < T extends PropValue >( { options }: Props< T > ) => {\n\tconst { value, setValue } = useControl< T >();\n\n\tconst handleChange = ( event: SelectChangeEvent< T > ) => {\n\t\tsetValue( event.target.value as T );\n\t};\n\n\treturn (\n\t\t<Select size=\"tiny\" value={ value ?? '' } onChange={ handleChange }>\n\t\t\t{ options.map( ( { label, ...props } ) => (\n\t\t\t\t<MenuItem key={ props.value } { ...props }>\n\t\t\t\t\t{ label }\n\t\t\t\t</MenuItem>\n\t\t\t) ) }\n\t\t</Select>\n\t);\n};\n","import * as React from 'react';\nimport { TextField } from '@elementor/ui';\nimport { useControl } from '../../../contexts/control-context';\n\ntype Props = {\n\tplaceholder?: string;\n};\n\nexport const TextAreaControl = ( { placeholder }: Props ) => {\n\tconst { value, setValue } = useControl< string >( '' );\n\n\tconst handleChange = ( event: React.ChangeEvent< HTMLInputElement > ) => {\n\t\tsetValue( event.target.value );\n\t};\n\n\treturn (\n\t\t<TextField\n\t\t\tsize=\"tiny\"\n\t\t\tmultiline\n\t\t\tfullWidth\n\t\t\trows={ 5 }\n\t\t\tvalue={ value }\n\t\t\tonChange={ handleChange }\n\t\t\tplaceholder={ placeholder }\n\t\t/>\n\t);\n};\n","import * as React from 'react';\nimport { TextField } from '@elementor/ui';\nimport { useControl } from '../../../contexts/control-context';\n\nexport const TextControl = ( { placeholder }: { placeholder?: string } ) => {\n\tconst { value, setValue } = useControl< string >( '' );\n\n\tconst handleChange = ( event: React.ChangeEvent< HTMLInputElement > ) => setValue( event.target.value );\n\n\treturn <TextField type=\"text\" size=\"tiny\" value={ value } onChange={ handleChange } placeholder={ placeholder } />;\n};\n","import { SelectControl } from './control-types/select-control';\nimport { TextAreaControl } from './control-types/text-area-control';\nimport { TextControl } from './control-types/text-control';\n\nconst controlTypes = {\n\tselect: SelectControl,\n\ttext: TextControl,\n\ttextarea: TextAreaControl,\n};\n\nexport const getControlByType = ( type: string ) => {\n\treturn controlTypes[ type as keyof typeof controlTypes ] ?? null;\n};\n","import * as React from 'react';\nimport { StyleContext } from '../../contexts/style-context';\nimport { useElementContext } from '../../contexts/element-context';\nimport { useElementStyles } from '../../hooks/use-element-styles';\n\nexport const StyleTab = () => {\n\tconst selectedElementID = useElementContext().element.id;\n\tconst elementStyles = useElementStyles( selectedElementID );\n\t// TODO: Handle selected style state.\n\tconst selectedStyleDef = elementStyles ? Object.values( elementStyles )[ 0 ] : null;\n\n\treturn (\n\t\t<StyleContext selectedStyleDef={ selectedStyleDef }>\n\t\t\t<div>Style Tab</div>\n\t\t</StyleContext>\n\t);\n};\n","import * as React from 'react';\nimport { createContext, ReactNode, useContext } from 'react';\nimport { StyleDefinition, StyleDefMeta } from '../types';\nimport { useActiveBreakpoint } from '@elementor/editor-responsive';\n\ntype ContextValue = {\n\tselectedStyleDef: StyleDefinition | null;\n\tselectedMeta: StyleDefMeta;\n};\n\nconst Context = createContext< ContextValue | null >( null );\n\ntype Props = {\n\tchildren: ReactNode;\n\tselectedStyleDef: StyleDefinition | null;\n};\n\nexport function StyleContext( { children, selectedStyleDef }: Props ) {\n\tconst breakpoint = useActiveBreakpoint();\n\t// TODO: Handle state when we support it.\n\tconst selectedMeta = { breakpoint, state: null } as const;\n\n\treturn <Context.Provider value={ { selectedStyleDef, selectedMeta } }>{ children }</Context.Provider>;\n}\n\nexport function useStyleContext() {\n\tconst context = useContext( Context );\n\n\tif ( ! context ) {\n\t\tthrow new Error( 'UseStyleContext must be used within a StyleContextProvider' );\n\t}\n\n\treturn context;\n}\n","import { __privateUseListenTo as useListenTo, commandEndEvent } from '@elementor/editor-v1-adapters';\nimport { getElementStyles } from '../sync/get-element-styles';\nimport { ElementID } from '../types';\n\nexport const useElementStyles = ( elementID: ElementID ) => {\n\treturn useListenTo(\n\t\tcommandEndEvent( 'document/atomic-widgets/styles' ),\n\t\t() => {\n\t\t\treturn getElementStyles( elementID );\n\t\t},\n\t\t[ elementID ]\n\t);\n};\n","import getContainer from './get-container';\nimport { ElementID, StyleDefinition } from '../types';\n\nexport const getElementStyles = ( elementID: ElementID ): Record< string, StyleDefinition > | null => {\n\tconst container = getContainer( elementID );\n\n\treturn container?.model.get( 'styles' ) || null;\n};\n","import { panel } from './panel';\nimport { injectIntoLogic } from '@elementor/editor';\nimport { shouldUseV2Panel } from './sync/should-use-v2-panel';\nimport { EditingPanelHooks } from './components/editing-panel/editing-panel-hooks';\nimport { __registerPanel as registerPanel } from '@elementor/editor-panels';\nimport { __privateBlockDataCommand as blockDataCommand } from '@elementor/editor-v1-adapters';\n\nexport default function init() {\n\tregisterPanel( panel );\n\tblockV1Panel();\n\n\tinjectIntoLogic( {\n\t\tid: 'editing-panel-hooks',\n\t\tcomponent: EditingPanelHooks,\n\t} );\n}\n\nconst blockV1Panel = () => {\n\tblockDataCommand( {\n\t\tcommand: 'panel/editor/open',\n\t\tcondition: shouldUseV2Panel,\n\t} );\n};\n","import getSelectedElements from './get-selected-elements';\nimport getWidgetsCache from './get-widgets-cache';\n\nexport const shouldUseV2Panel = () => {\n\tconst selectedElements = getSelectedElements();\n\tconst widgetCache = getWidgetsCache();\n\n\tif ( selectedElements.length !== 1 ) {\n\t\treturn false;\n\t}\n\n\t// Check if the selected element has atomic controls, meaning it's a V2 element.\n\treturn !! widgetCache?.[ selectedElements[ 0 ].type ]?.atomic_controls;\n};\n","import { useEffect } from 'react';\nimport { commandStartEvent, __privateListenTo as listenTo } from '@elementor/editor-v1-adapters';\nimport { usePanelActions } from '../panel';\nimport { shouldUseV2Panel } from '../sync/should-use-v2-panel';\n\nexport const useOpenEditorPanel = () => {\n\tconst { open } = usePanelActions();\n\n\tuseEffect( () => {\n\t\treturn listenTo( commandStartEvent( 'panel/editor/open' ), () => {\n\t\t\tif ( shouldUseV2Panel() ) {\n\t\t\t\topen();\n\t\t\t}\n\t\t} );\n\t}, [] ); // eslint-disable-line react-hooks/exhaustive-deps\n};\n","import { useOpenEditorPanel } from '../../hooks/use-open-editor-panel';\n\nexport const EditingPanelHooks = () => {\n\tuseOpenEditorPanel();\n\n\treturn null;\n};\n","import init from './init';\n\ninit();\n"],"mappings":";AAAA,SAAS,iBAAiB,mBAAmB;;;ACA7C,YAAYA,aAAW;AACvB,SAAS,MAAAC,WAAU;;;ACDnB,SAAS,wBAAwB,aAAa,uBAAuB;;;ACGtD,SAAR,sBAAkD;AACxD,QAAM,iBAAiB;AAEvB,QAAM,mBAAmB,eAAe,WAAW,WAAW,cAAc,KAAK,CAAC;AAElF,SAAO,iBAAiB,OAAqB,CAAE,KAAK,OAAQ;AAC3D,UAAM,OAAO,GAAG,MAAM,IAAK,YAAa,KAAK,GAAG,MAAM,IAAK,QAAS;AAEpE,QAAK,MAAO;AACX,UAAI,KAAM;AAAA,QACT,IAAI,GAAG,MAAM,IAAK,IAAK;AAAA,QACvB;AAAA,MACD,CAAE;AAAA,IACH;AAEA,WAAO;AAAA,EACR,GAAG,CAAC,CAAE;AACP;;;ADjBe,SAAR,sBAAuC;AAC7C,SAAO;AAAA,IACN,CAAE,gBAAiB,0BAA2B,GAAG,gBAAiB,4BAA6B,CAAE;AAAA,IACjG,MAAM,oBAAoB;AAAA,EAC3B;AACD;;;AERA,SAAS,wBAAwBC,cAAa,mBAAAC,wBAAuB;;;ACEtD,SAAR,kBAAmC;AACzC,QAAM,iBAAiB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SAAS,uBAAuB;;;ACEzB,IAAM,mBAAmB,MAAM;AACrC,QAAM,mBAAmB,oBAAoB;AAC7C,QAAM,cAAc,gBAAgB;AAEpC,MAAK,iBAAiB,WAAW,GAAI;AACpC,WAAO;AAAA,EACR;AAGA,SAAO,CAAC,CAAE,cAAe,iBAAkB,CAAE,EAAE,IAAK,GAAG;AACxD;;;ACbA,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB,qBAAqB,gBAAgB;AAI1D,IAAM,qBAAqB,MAAM;AACvC,QAAM,EAAE,KAAK,IAAI,gBAAgB;AAEjC,YAAW,MAAM;AAChB,WAAO,SAAU,kBAAmB,mBAAoB,GAAG,MAAM;AAChE,UAAK,iBAAiB,GAAI;AACzB,aAAK;AAAA,MACN;AAAA,IACD,CAAE;AAAA,EACH,GAAG,CAAC,CAAE;AACP;;;ACbO,IAAM,oBAAoB,MAAM;AACtC,qBAAmB;AAEnB,SAAO;AACR;;;AHFA,SAAS,mBAAmB,qBAAqB;AACjD,SAAS,6BAA6B,wBAAwB;AAE/C,SAAR,OAAwB;AAC9B,gBAAe,KAAM;AACrB,eAAa;AAEb,kBAAiB;AAAA,IAChB,IAAI;AAAA,IACJ,WAAW;AAAA,EACZ,CAAE;AACH;AAEA,IAAM,eAAe,MAAM;AAC1B,mBAAkB;AAAA,IACjB,SAAS;AAAA,IACT,WAAW;AAAA,EACZ,CAAE;AACH;;;AIpBA,KAAK;","names":["React","__","useListenTo","commandEndEvent","useListenTo","commandEndEvent","Stack","React","React","Stack","React","createContext","useContext","commandEndEvent","useListenTo","useListenTo","commandEndEvent","React","Stack","React","React","React","TextField","TextField","Stack","React","React","createContext","useContext","Context","useListenTo","commandEndEvent","useListenTo","commandEndEvent","Stack","__"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elementor/editor-editing-panel",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "Elementor Team",
|
|
6
6
|
"homepage": "https://elementor.com/",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
},
|
|
19
19
|
"repository": {
|
|
20
20
|
"type": "git",
|
|
21
|
-
"url": "https://github.com/elementor/elementor-packages.git",
|
|
21
|
+
"url": "git+https://github.com/elementor/elementor-packages.git",
|
|
22
22
|
"directory": "packages/core/editor-editing-panel"
|
|
23
23
|
},
|
|
24
24
|
"bugs": {
|
|
@@ -27,19 +27,27 @@
|
|
|
27
27
|
"publishConfig": {
|
|
28
28
|
"access": "public"
|
|
29
29
|
},
|
|
30
|
+
"files": [
|
|
31
|
+
"README.md",
|
|
32
|
+
"CHANGELOG.md",
|
|
33
|
+
"/dist",
|
|
34
|
+
"/src",
|
|
35
|
+
"!**/__tests__"
|
|
36
|
+
],
|
|
30
37
|
"scripts": {
|
|
31
38
|
"build": "tsup --config=../../tsup.build.ts",
|
|
32
39
|
"dev": "tsup --config=../../tsup.dev.ts"
|
|
33
40
|
},
|
|
34
41
|
"dependencies": {
|
|
35
|
-
"@elementor/editor": "^0.
|
|
36
|
-
"@elementor/editor-panels": "^0.
|
|
37
|
-
"@elementor/editor-
|
|
38
|
-
"@elementor/
|
|
42
|
+
"@elementor/editor": "^0.12.0",
|
|
43
|
+
"@elementor/editor-panels": "^0.5.0",
|
|
44
|
+
"@elementor/editor-responsive": "^0.11.1",
|
|
45
|
+
"@elementor/editor-v1-adapters": "^0.8.1",
|
|
46
|
+
"@elementor/ui": "^1.14.2",
|
|
39
47
|
"@wordpress/i18n": "^4.45.0"
|
|
40
48
|
},
|
|
41
49
|
"peerDependencies": {
|
|
42
50
|
"react": "^18.3.1"
|
|
43
51
|
},
|
|
44
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "cc46c584717a5a0669f31a40ba7d2d77e50ee5d2"
|
|
45
53
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useId } from 'react';
|
|
3
|
+
import { Accordion, AccordionSummary, AccordionDetails, AccordionSummaryText, Stack } from '@elementor/ui';
|
|
4
|
+
|
|
5
|
+
export type CollapsibleSectionProps = React.PropsWithChildren< {
|
|
6
|
+
title: string;
|
|
7
|
+
} >;
|
|
8
|
+
|
|
9
|
+
export const CollapsibleSection = ( { title, children }: CollapsibleSectionProps ) => {
|
|
10
|
+
const uid = useId();
|
|
11
|
+
const labelId = `label-${ uid }`;
|
|
12
|
+
const contentId = `content-${ uid }`;
|
|
13
|
+
|
|
14
|
+
// TODO: Change to collapsible list item
|
|
15
|
+
return (
|
|
16
|
+
<Accordion disableGutters defaultExpanded>
|
|
17
|
+
<AccordionSummary aria-controls={ contentId } id={ labelId }>
|
|
18
|
+
<AccordionSummaryText primaryTypographyProps={ { variant: 'caption' } }>{ title }</AccordionSummaryText>
|
|
19
|
+
</AccordionSummary>
|
|
20
|
+
<AccordionDetails id={ contentId } aria-labelledby={ labelId }>
|
|
21
|
+
<Stack gap={ 2.5 }>{ children }</Stack>
|
|
22
|
+
</AccordionDetails>
|
|
23
|
+
</Accordion>
|
|
24
|
+
);
|
|
25
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { TextField } from '@elementor/ui';
|
|
3
3
|
import { useControl } from '../../../contexts/control-context';
|
|
4
4
|
|
|
5
5
|
type Props = {
|
|
@@ -14,9 +14,11 @@ export const TextAreaControl = ( { placeholder }: Props ) => {
|
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
return (
|
|
17
|
-
<
|
|
17
|
+
<TextField
|
|
18
18
|
size="tiny"
|
|
19
|
-
|
|
19
|
+
multiline
|
|
20
|
+
fullWidth
|
|
21
|
+
rows={ 5 }
|
|
20
22
|
value={ value }
|
|
21
23
|
onChange={ handleChange }
|
|
22
24
|
placeholder={ placeholder }
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { TextField } from '@elementor/ui';
|
|
3
|
+
import { useControl } from '../../../contexts/control-context';
|
|
4
|
+
|
|
5
|
+
export const TextControl = ( { placeholder }: { placeholder?: string } ) => {
|
|
6
|
+
const { value, setValue } = useControl< string >( '' );
|
|
7
|
+
|
|
8
|
+
const handleChange = ( event: React.ChangeEvent< HTMLInputElement > ) => setValue( event.target.value );
|
|
9
|
+
|
|
10
|
+
return <TextField type="text" size="tiny" value={ value } onChange={ handleChange } placeholder={ placeholder } />;
|
|
11
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { SelectControl } from './control-types/select-control';
|
|
2
|
+
import { TextAreaControl } from './control-types/text-area-control';
|
|
3
|
+
import { TextControl } from './control-types/text-control';
|
|
4
|
+
|
|
5
|
+
const controlTypes = {
|
|
6
|
+
select: SelectControl,
|
|
7
|
+
text: TextControl,
|
|
8
|
+
textarea: TextAreaControl,
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const getControlByType = ( type: string ) => {
|
|
12
|
+
return controlTypes[ type as keyof typeof controlTypes ] ?? null;
|
|
13
|
+
};
|
|
@@ -1,26 +1,50 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import { Stack, Typography } from '@elementor/ui';
|
|
4
|
-
import { PropKey } from '../../types';
|
|
2
|
+
import { ControlContext } from '../../contexts/control-context';
|
|
3
|
+
import { Stack, styled, Typography } from '@elementor/ui';
|
|
4
|
+
import { PropKey, PropValue } from '../../types';
|
|
5
|
+
import { useElementContext } from '../../contexts/element-context';
|
|
6
|
+
import { useWidgetSettings } from '../../hooks/use-widget-settings';
|
|
7
|
+
import { updateSettings } from '../../sync/update-settings';
|
|
5
8
|
|
|
6
9
|
type Props = {
|
|
7
10
|
bind: PropKey;
|
|
8
11
|
children: React.ReactNode;
|
|
9
12
|
};
|
|
10
13
|
|
|
14
|
+
export const SettingsControlProvider = ( { bind, children }: Props ) => {
|
|
15
|
+
const { element } = useElementContext();
|
|
16
|
+
const value = useWidgetSettings( { id: element.id, bind } );
|
|
17
|
+
|
|
18
|
+
const setValue = ( newValue: PropValue ) => {
|
|
19
|
+
updateSettings( {
|
|
20
|
+
id: element.id,
|
|
21
|
+
props: {
|
|
22
|
+
[ bind ]: newValue,
|
|
23
|
+
},
|
|
24
|
+
} );
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
return <ControlContext.Provider value={ { setValue, value, bind } }>{ children }</ControlContext.Provider>;
|
|
28
|
+
};
|
|
29
|
+
|
|
11
30
|
const SettingsControl = ( { children, bind }: Props ) => (
|
|
12
|
-
<
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
flexWrap="wrap"
|
|
18
|
-
sx={ { px: 2 } }
|
|
19
|
-
>
|
|
20
|
-
<ControlContextProvider bind={ bind }>{ children }</ControlContextProvider>
|
|
21
|
-
</Stack>
|
|
31
|
+
<SettingsControlProvider bind={ bind }>
|
|
32
|
+
<StyledStack gap={ 1 } direction="row" alignItems="center" justifyContent="space-between" flexWrap="wrap">
|
|
33
|
+
{ children }
|
|
34
|
+
</StyledStack>
|
|
35
|
+
</SettingsControlProvider>
|
|
22
36
|
);
|
|
23
37
|
|
|
38
|
+
const StyledStack = styled( Stack )`
|
|
39
|
+
& > * {
|
|
40
|
+
flex-grow: 1;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
& > label {
|
|
44
|
+
min-width: 50%;
|
|
45
|
+
}
|
|
46
|
+
`;
|
|
47
|
+
|
|
24
48
|
const Label = ( { children }: { children: React.ReactNode } ) => {
|
|
25
49
|
return (
|
|
26
50
|
<Typography component="label" variant="caption">
|
|
@@ -30,4 +54,5 @@ const Label = ( { children }: { children: React.ReactNode } ) => {
|
|
|
30
54
|
};
|
|
31
55
|
|
|
32
56
|
SettingsControl.Label = Label;
|
|
57
|
+
|
|
33
58
|
export { SettingsControl };
|