sample-ui-component-library 0.0.56-dev → 0.0.57-dev
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/package.json
CHANGED
|
@@ -12,6 +12,7 @@ import React, {
|
|
|
12
12
|
useReducer,
|
|
13
13
|
useContext,
|
|
14
14
|
useRef,
|
|
15
|
+
useEffect
|
|
15
16
|
} from "react";
|
|
16
17
|
|
|
17
18
|
import { EditorContext } from "./EditorContext";
|
|
@@ -32,11 +33,15 @@ export const Editor = forwardRef(({ onSelectAbstraction, onSelectTab, onUpdateCo
|
|
|
32
33
|
const [state, dispatch] = useReducer(editorReducer, initialState);
|
|
33
34
|
const editorRef = useRef();
|
|
34
35
|
|
|
35
|
-
|
|
36
|
-
dispatch({ type: "SELECT_TAB", payload: id });
|
|
36
|
+
useEffect(() => {
|
|
37
37
|
if (onSelectTab) {
|
|
38
|
-
|
|
38
|
+
console.log(state.activeTab);
|
|
39
|
+
onSelectTab(state.activeTab);
|
|
39
40
|
}
|
|
41
|
+
}, [state.activeTab]);
|
|
42
|
+
|
|
43
|
+
const selectTab = useCallback((id) => {
|
|
44
|
+
dispatch({ type: "SELECT_TAB", payload: id });
|
|
40
45
|
}, [onSelectTab]);
|
|
41
46
|
|
|
42
47
|
const closeTab = useCallback((id) => {
|
|
@@ -163,7 +163,11 @@ const Template = (args) => {
|
|
|
163
163
|
|
|
164
164
|
|
|
165
165
|
const onUpdateContent = useCallback((tab, content) => {
|
|
166
|
-
action("Content Updated")(tab
|
|
166
|
+
action("Content Updated")(tab.name + " was modified.");
|
|
167
|
+
}, []);
|
|
168
|
+
|
|
169
|
+
const onSelectTab = useCallback((tab) => {
|
|
170
|
+
action("Tab Selected")(tab&&tab.name);
|
|
167
171
|
}, []);
|
|
168
172
|
|
|
169
173
|
return (
|
|
@@ -174,7 +178,7 @@ const Template = (args) => {
|
|
|
174
178
|
<ToolBarEditor onSelectTool={onSelectTool} />
|
|
175
179
|
</div>
|
|
176
180
|
<div className="flow">
|
|
177
|
-
<Editor ref={editorRef} onUpdateContent={onUpdateContent} onSelectAbstraction={onSelectAbstraction} {...args} />
|
|
181
|
+
<Editor ref={editorRef} onSelectTab={onSelectTab} onUpdateContent={onUpdateContent} onSelectAbstraction={onSelectAbstraction} {...args} />
|
|
178
182
|
{dragging && (
|
|
179
183
|
<div
|
|
180
184
|
style={{
|