kitchen-simulator 10.8.0 → 10.9.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,4 +1,4 @@
1
- import React, { useEffect } from 'react';
1
+ import React, { useEffect, useRef } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import Viewer2D from "./viewer2d/viewer2d";
4
4
  import Viewer3D from "./viewer3d/viewer3d";
@@ -20,11 +20,23 @@ export default function Content(_ref) {
20
20
  var mode = state.get('mode');
21
21
 
22
22
  // Internal Event for unselect_all
23
+ var prevSelectedCountRef = useRef(null);
23
24
  useEffect(function () {
24
- if (state.getIn(['scene', 'layers', 'layer-1', 'selected', 'vertices']).size + state.getIn(['scene', 'layers', 'layer-1', 'selected', 'lines']).size + state.getIn(['scene', 'layers', 'layer-1', 'selected', 'holes']).size + state.getIn(['scene', 'layers', 'layer-1', 'selected', 'areas']).size + state.getIn(['scene', 'layers', 'layer-1', 'selected', 'items']).size < 1) onInternalEvent === null || onInternalEvent === void 0 || onInternalEvent({
25
- type: constants.INTERNAL_EVENT_UNSELECT_ALL,
26
- value: null
27
- });
25
+ var selectedCount = state.getIn(['scene', 'layers', 'layer-1', 'selected', 'vertices']).size + state.getIn(['scene', 'layers', 'layer-1', 'selected', 'lines']).size + state.getIn(['scene', 'layers', 'layer-1', 'selected', 'holes']).size + state.getIn(['scene', 'layers', 'layer-1', 'selected', 'areas']).size + state.getIn(['scene', 'layers', 'layer-1', 'selected', 'items']).size;
26
+
27
+ // Skip the initial mount/hydration; only emit when selection transitions from non-empty -> empty.
28
+ if (prevSelectedCountRef.current === null) {
29
+ prevSelectedCountRef.current = selectedCount;
30
+ return;
31
+ }
32
+ var prevSelectedCount = prevSelectedCountRef.current;
33
+ prevSelectedCountRef.current = selectedCount;
34
+ if (prevSelectedCount > 0 && selectedCount < 1) {
35
+ onInternalEvent === null || onInternalEvent === void 0 || onInternalEvent({
36
+ type: constants.INTERNAL_EVENT_UNSELECT_ALL,
37
+ value: null
38
+ });
39
+ }
28
40
  }, [state.getIn(['scene', 'layers', 'layer-1', 'selected'])]);
29
41
  switch (mode) {
30
42
  // this mode is when view elevation
@@ -30,11 +30,23 @@ function Content(_ref) {
30
30
  var mode = state.get('mode');
31
31
 
32
32
  // Internal Event for unselect_all
33
+ var prevSelectedCountRef = (0, _react.useRef)(null);
33
34
  (0, _react.useEffect)(function () {
34
- if (state.getIn(['scene', 'layers', 'layer-1', 'selected', 'vertices']).size + state.getIn(['scene', 'layers', 'layer-1', 'selected', 'lines']).size + state.getIn(['scene', 'layers', 'layer-1', 'selected', 'holes']).size + state.getIn(['scene', 'layers', 'layer-1', 'selected', 'areas']).size + state.getIn(['scene', 'layers', 'layer-1', 'selected', 'items']).size < 1) onInternalEvent === null || onInternalEvent === void 0 || onInternalEvent({
35
- type: constants.INTERNAL_EVENT_UNSELECT_ALL,
36
- value: null
37
- });
35
+ var selectedCount = state.getIn(['scene', 'layers', 'layer-1', 'selected', 'vertices']).size + state.getIn(['scene', 'layers', 'layer-1', 'selected', 'lines']).size + state.getIn(['scene', 'layers', 'layer-1', 'selected', 'holes']).size + state.getIn(['scene', 'layers', 'layer-1', 'selected', 'areas']).size + state.getIn(['scene', 'layers', 'layer-1', 'selected', 'items']).size;
36
+
37
+ // Skip the initial mount/hydration; only emit when selection transitions from non-empty -> empty.
38
+ if (prevSelectedCountRef.current === null) {
39
+ prevSelectedCountRef.current = selectedCount;
40
+ return;
41
+ }
42
+ var prevSelectedCount = prevSelectedCountRef.current;
43
+ prevSelectedCountRef.current = selectedCount;
44
+ if (prevSelectedCount > 0 && selectedCount < 1) {
45
+ onInternalEvent === null || onInternalEvent === void 0 || onInternalEvent({
46
+ type: constants.INTERNAL_EVENT_UNSELECT_ALL,
47
+ value: null
48
+ });
49
+ }
38
50
  }, [state.getIn(['scene', 'layers', 'layer-1', 'selected'])]);
39
51
  switch (mode) {
40
52
  // this mode is when view elevation
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kitchen-simulator",
3
- "version": "10.8.0",
3
+ "version": "10.9.0",
4
4
  "description": "It is a kitchen simulator (self-contained micro-frontend).",
5
5
  "license": "MIT",
6
6
  "main": "lib/index.js",