@wix/editor-react-components 1.2173.0 → 1.2174.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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useRef, useEffect } from "react";
|
|
2
|
+
import { useState, useRef, useEffect } from "react";
|
|
3
3
|
import { c as clsx } from "../chunks/clsx.js";
|
|
4
4
|
import { s as selectors } from "../chunks/constants22.js";
|
|
5
5
|
const root = "root__zTlgX";
|
|
@@ -63,13 +63,25 @@ const MultiStateBox = (props) => {
|
|
|
63
63
|
activeStateName
|
|
64
64
|
);
|
|
65
65
|
const stateKeys = getStateKeys(states);
|
|
66
|
+
const activeKey = stateKeys[activeIndex];
|
|
67
|
+
const [visitedKeys, setVisitedKeys] = useState(
|
|
68
|
+
() => activeKey === void 0 ? /* @__PURE__ */ new Set() : /* @__PURE__ */ new Set([activeKey])
|
|
69
|
+
);
|
|
66
70
|
const prevActiveIndexRef = useRef(activeIndex);
|
|
67
71
|
useEffect(() => {
|
|
68
72
|
if (prevActiveIndexRef.current !== activeIndex) {
|
|
69
73
|
prevActiveIndexRef.current = activeIndex;
|
|
70
74
|
onChange == null ? void 0 : onChange();
|
|
75
|
+
setVisitedKeys((prev) => {
|
|
76
|
+
if (activeKey === void 0 || prev.has(activeKey)) {
|
|
77
|
+
return prev;
|
|
78
|
+
}
|
|
79
|
+
const next = new Set(prev);
|
|
80
|
+
next.add(activeKey);
|
|
81
|
+
return next;
|
|
82
|
+
});
|
|
71
83
|
}
|
|
72
|
-
}, [activeIndex, onChange]);
|
|
84
|
+
}, [activeIndex, activeKey, onChange]);
|
|
73
85
|
return /* @__PURE__ */ jsx(
|
|
74
86
|
"div",
|
|
75
87
|
{
|
|
@@ -83,13 +95,16 @@ const MultiStateBox = (props) => {
|
|
|
83
95
|
className: clsx(selectors.root, styles.root, className),
|
|
84
96
|
children: states.map((state2, index) => {
|
|
85
97
|
const isActive = index === activeIndex;
|
|
98
|
+
if (!isActive && !visitedKeys.has(stateKeys[index])) {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
86
101
|
return /* @__PURE__ */ jsx(
|
|
87
102
|
"div",
|
|
88
103
|
{
|
|
104
|
+
"data-state-index": index,
|
|
89
105
|
className: clsx(selectors.stateContainer, styles.state, {
|
|
90
106
|
[styles["is-active"]]: isActive
|
|
91
107
|
}),
|
|
92
|
-
...!isActive && { inert: "" },
|
|
93
108
|
children: state2.content
|
|
94
109
|
},
|
|
95
110
|
stateKeys[index]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wix/editor-react-components",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2174.0",
|
|
4
4
|
"description": "React components for the Wix Editor",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -189,5 +189,5 @@
|
|
|
189
189
|
"registry": "https://registry.npmjs.org/",
|
|
190
190
|
"access": "public"
|
|
191
191
|
},
|
|
192
|
-
"falconPackageHash": "
|
|
192
|
+
"falconPackageHash": "077ac90001681d86c1baea7cf9f284f4d42f7c8782e19c2e4b0f4734"
|
|
193
193
|
}
|