@elementor/editor-editing-panel 1.34.0 → 1.35.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 +17 -0
- package/dist/index.js +91 -57
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +39 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
- package/src/components/editing-panel-tabs.tsx +37 -20
- package/src/components/section.tsx +4 -3
- package/src/hooks/use-state-by-element.ts +18 -0
package/dist/index.mjs
CHANGED
|
@@ -1004,6 +1004,21 @@ function useScrollDirection() {
|
|
|
1004
1004
|
return useContext4(ScrollContext)?.direction ?? DEFAULT_SCROLL_DIRECTION;
|
|
1005
1005
|
}
|
|
1006
1006
|
|
|
1007
|
+
// src/hooks/use-state-by-element.ts
|
|
1008
|
+
import { useState as useState5 } from "react";
|
|
1009
|
+
import { getSessionStorageItem, setSessionStorageItem } from "@elementor/session";
|
|
1010
|
+
var useStateByElement = (key, initialValue) => {
|
|
1011
|
+
const { element } = useElement();
|
|
1012
|
+
const lookup = `elementor/editor-state/${element.id}/${key}`;
|
|
1013
|
+
const storedValue = getSessionStorageItem(lookup);
|
|
1014
|
+
const [value, setValue] = useState5(storedValue ?? initialValue);
|
|
1015
|
+
const doUpdate = (newValue) => {
|
|
1016
|
+
setSessionStorageItem(lookup, newValue);
|
|
1017
|
+
setValue(newValue);
|
|
1018
|
+
};
|
|
1019
|
+
return [value, doUpdate];
|
|
1020
|
+
};
|
|
1021
|
+
|
|
1007
1022
|
// src/components/settings-tab.tsx
|
|
1008
1023
|
import * as React16 from "react";
|
|
1009
1024
|
import { ControlFormLabel } from "@elementor/editor-controls";
|
|
@@ -1105,7 +1120,7 @@ var SettingsField = ({ bind, children }) => {
|
|
|
1105
1120
|
|
|
1106
1121
|
// src/components/section.tsx
|
|
1107
1122
|
import * as React14 from "react";
|
|
1108
|
-
import { useId as useId3
|
|
1123
|
+
import { useId as useId3 } from "react";
|
|
1109
1124
|
import { Collapse, Divider as Divider2, ListItemButton, ListItemText, Stack as Stack5 } from "@elementor/ui";
|
|
1110
1125
|
|
|
1111
1126
|
// src/components/collapse-icon.tsx
|
|
@@ -1122,7 +1137,7 @@ var CollapseIcon = styled5(ChevronDownIcon, {
|
|
|
1122
1137
|
|
|
1123
1138
|
// src/components/section.tsx
|
|
1124
1139
|
function Section({ title, children, defaultExpanded = false }) {
|
|
1125
|
-
const [isOpen, setIsOpen] =
|
|
1140
|
+
const [isOpen, setIsOpen] = useStateByElement(title, !!defaultExpanded);
|
|
1126
1141
|
const id = useId3();
|
|
1127
1142
|
const labelId = `label-${id}`;
|
|
1128
1143
|
const contentId = `content-${id}`;
|
|
@@ -1131,7 +1146,7 @@ function Section({ title, children, defaultExpanded = false }) {
|
|
|
1131
1146
|
{
|
|
1132
1147
|
id: labelId,
|
|
1133
1148
|
"aria-controls": contentId,
|
|
1134
|
-
onClick: () => setIsOpen(
|
|
1149
|
+
onClick: () => setIsOpen(!isOpen),
|
|
1135
1150
|
sx: { "&:hover": { backgroundColor: "transparent" } }
|
|
1136
1151
|
},
|
|
1137
1152
|
/* @__PURE__ */ React14.createElement(
|
|
@@ -3219,13 +3234,32 @@ function useCurrentClassesProp() {
|
|
|
3219
3234
|
// src/components/editing-panel-tabs.tsx
|
|
3220
3235
|
var EditingPanelTabs = () => {
|
|
3221
3236
|
const { element } = useElement();
|
|
3222
|
-
const { getTabProps, getTabPanelProps, getTabsProps } = useTabs("settings");
|
|
3223
3237
|
return (
|
|
3224
3238
|
// When switching between elements, the local states should be reset. We are using key to rerender the tabs.
|
|
3225
3239
|
// Reference: https://react.dev/learn/preserving-and-resetting-state#resetting-a-form-with-a-key
|
|
3226
|
-
/* @__PURE__ */ React69.createElement(Fragment8, { key: element.id }, /* @__PURE__ */ React69.createElement(
|
|
3240
|
+
/* @__PURE__ */ React69.createElement(Fragment8, { key: element.id }, /* @__PURE__ */ React69.createElement(PanelTabContent, null))
|
|
3227
3241
|
);
|
|
3228
3242
|
};
|
|
3243
|
+
var PanelTabContent = () => {
|
|
3244
|
+
const defaultComponentTab = "settings";
|
|
3245
|
+
const [currentTab, setCurrentTab] = useStateByElement("tab", defaultComponentTab);
|
|
3246
|
+
const { getTabProps, getTabPanelProps, getTabsProps } = useTabs(currentTab);
|
|
3247
|
+
return /* @__PURE__ */ React69.createElement(ScrollProvider, null, /* @__PURE__ */ React69.createElement(Stack17, { direction: "column", sx: { width: "100%" } }, /* @__PURE__ */ React69.createElement(Stack17, { sx: { ...stickyHeaderStyles, top: 0 } }, /* @__PURE__ */ React69.createElement(
|
|
3248
|
+
Tabs,
|
|
3249
|
+
{
|
|
3250
|
+
variant: "fullWidth",
|
|
3251
|
+
size: "small",
|
|
3252
|
+
sx: { mt: 0.5 },
|
|
3253
|
+
...getTabsProps(),
|
|
3254
|
+
onChange: (_, newValue) => {
|
|
3255
|
+
getTabsProps().onChange(_, newValue);
|
|
3256
|
+
setCurrentTab(newValue);
|
|
3257
|
+
}
|
|
3258
|
+
},
|
|
3259
|
+
/* @__PURE__ */ React69.createElement(Tab, { label: __45("General", "elementor"), ...getTabProps("settings") }),
|
|
3260
|
+
/* @__PURE__ */ React69.createElement(Tab, { label: __45("Style", "elementor"), ...getTabProps("style") })
|
|
3261
|
+
), /* @__PURE__ */ React69.createElement(Divider6, null)), /* @__PURE__ */ React69.createElement(TabPanel, { ...getTabPanelProps("settings"), disablePadding: true }, /* @__PURE__ */ React69.createElement(SettingsTab, null)), /* @__PURE__ */ React69.createElement(TabPanel, { ...getTabPanelProps("style"), disablePadding: true }, /* @__PURE__ */ React69.createElement(StyleTab, null))));
|
|
3262
|
+
};
|
|
3229
3263
|
|
|
3230
3264
|
// src/components/editing-panel.tsx
|
|
3231
3265
|
var { useMenuItems } = controlActionsMenu;
|