@buerli.io/react-cad 0.0.22-beta.0 → 0.0.23-beta.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.
Files changed (31) hide show
  1. package/build/components/UI/CAD/Messages/Message.d.ts +5 -0
  2. package/build/components/UI/CAD/Messages/Messages.d.ts +9 -0
  3. package/build/components/UI/CAD/Messages/index.d.ts +1 -0
  4. package/build/components/UI/CAD/Messages/msgStore.d.ts +17 -0
  5. package/build/components/UI/CAD/SideBar/FeatureList/Feature.d.ts +1 -1
  6. package/build/components/UI/CAD/SideBar/FeatureList/utils.d.ts +1 -0
  7. package/build/components/UI/CAD/common/BlankDiv.d.ts +4 -0
  8. package/build/components/UI/CAD/common/primitives.d.ts +4 -1
  9. package/build/components/UI/CAD/store/CADActions.d.ts +4 -0
  10. package/build/components/UI/CAD/store/CADStore.d.ts +4 -0
  11. package/build/index.cjs.js +1857 -1008
  12. package/build/index.js +1862 -1013
  13. package/build/plugins/Dimensions/index.d.ts +1 -1
  14. package/build/plugins/Sketch/Root/Details.d.ts +2 -0
  15. package/build/plugins/Sketch/Root/useMenuItems.d.ts +5 -0
  16. package/build/plugins/Sketch/View/graphics/Merged/Arc.d.ts +9 -0
  17. package/build/plugins/Sketch/View/graphics/Merged/Line.d.ts +10 -0
  18. package/build/plugins/Sketch/View/graphics/Merged/MergedWrapper.d.ts +11 -0
  19. package/build/plugins/Sketch/View/graphics/Merged/Point.d.ts +8 -0
  20. package/build/plugins/Sketch/View/graphics/graphics.d.ts +1 -2
  21. package/build/plugins/Sketch/View/graphics/hooks.d.ts +3 -1
  22. package/build/plugins/Sketch/View/graphics/primitives.d.ts +3 -3
  23. package/build/plugins/Sketch/View/graphics/scale.d.ts +4 -0
  24. package/build/plugins/Sketch/View/handlers/Handlers.d.ts +2 -0
  25. package/build/plugins/Sketch/View/handlers/UseRef.d.ts +3 -0
  26. package/build/plugins/Sketch/types.d.ts +1 -0
  27. package/build/plugins/Sketch/utils/Interaction.d.ts +4 -0
  28. package/build/utils/FileUtils.d.ts +1 -1
  29. package/build/utils/helpers.d.ts +2 -0
  30. package/package.json +9 -8
  31. package/build/plugins/Sketch/Root/UseRef.d.ts +0 -2
@@ -10,23 +10,24 @@ var THREE = require('three');
10
10
  var _defineProperty = require('@babel/runtime/helpers/defineProperty');
11
11
  var fiber = require('@react-three/fiber');
12
12
  var drei = require('@react-three/drei');
13
+ var create = require('zustand');
14
+ var vanilla = require('zustand/vanilla');
15
+ require('antd/dist/antd.css');
13
16
  var icons = require('@ant-design/icons');
14
17
  var _extends = require('@babel/runtime/helpers/extends');
15
18
  var Switch = require('antd/lib/switch');
19
+ var AntdButton = require('antd/lib/button');
16
20
  var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
17
21
  var styled = require('styled-components');
18
22
  var Tooltip = require('antd/lib/tooltip');
19
23
  var RadioGroupImpl = require('antd/lib/radio/group');
20
24
  var RadioButtonImpl = require('antd/lib/radio/radioButton');
25
+ var antd = require('antd');
21
26
  var guid = require('uuid');
22
27
  var shallow = require('zustand/shallow');
23
28
  var threeStdlib = require('three-stdlib');
24
29
  var SelectImpl = require('antd/lib/select');
25
30
  var path = require('path');
26
- var antd = require('antd');
27
- require('antd/dist/antd.css');
28
- var create = require('zustand');
29
- var vanilla = require('zustand/vanilla');
30
31
  var reactUid = require('react-uid');
31
32
  var deepmerge = require('deepmerge');
32
33
  var reactSortableHoc = require('react-sortable-hoc');
@@ -55,9 +56,9 @@ var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
55
56
  var THREE__namespace = /*#__PURE__*/_interopNamespaceDefault(THREE);
56
57
  var deepmerge__namespace = /*#__PURE__*/_interopNamespaceDefault(deepmerge);
57
58
 
58
- function ownKeys$k(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
59
+ function ownKeys$m(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
59
60
 
60
- function _objectSpread$k(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$k(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$k(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
61
+ function _objectSpread$m(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$m(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$m(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
61
62
  function getGraphicId(tree, refOrObjId) {
62
63
  const res = {
63
64
  graphicId: refOrObjId,
@@ -129,7 +130,7 @@ function useSelectedItems(drawingId, refOrObjIds) {
129
130
  }
130
131
 
131
132
  const createSelItem = React.useCallback(element => {
132
- return core.createGraphicItem(prodId, _objectSpread$k(_objectSpread$k({}, element), {}, {
133
+ return core.createGraphicItem(prodId, _objectSpread$m(_objectSpread$m({}, element), {}, {
133
134
  productId: prodId
134
135
  }));
135
136
  }, [prodId]);
@@ -160,7 +161,7 @@ function useSelectedItems(drawingId, refOrObjIds) {
160
161
  const elem = cont.map[Number(grIds[0])];
161
162
 
162
163
  if (elem) {
163
- elems.push(_objectSpread$k(_objectSpread$k({}, elem), {}, {
164
+ elems.push(_objectSpread$m(_objectSpread$m({}, elem), {}, {
164
165
  graphicId: contId,
165
166
  type: core.GraphicType.SOLID
166
167
  }));
@@ -198,9 +199,9 @@ function useSelectedItems(drawingId, refOrObjIds) {
198
199
  return selectedItems;
199
200
  }
200
201
 
201
- function ownKeys$j(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
202
+ function ownKeys$l(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
202
203
 
203
- function _objectSpread$j(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$j(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$j(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
204
+ function _objectSpread$l(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$l(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$l(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
204
205
  function addMembers(drawingId, ccObjId) {
205
206
  const drawingState = core.getDrawing(drawingId);
206
207
  const objInTree = drawingState.structure.tree[ccObjId];
@@ -213,7 +214,7 @@ function addMembers(drawingId, ccObjId) {
213
214
  const members = {};
214
215
  Object.keys(curMembers).forEach(memberName => {
215
216
  const curMember = curMembers[memberName];
216
- members[memberName] = _objectSpread$j(_objectSpread$j({}, curMember), {}, {
217
+ members[memberName] = _objectSpread$l(_objectSpread$l({}, curMember), {}, {
217
218
  name: memberName
218
219
  });
219
220
 
@@ -333,6 +334,10 @@ function getAncestorIdByClass(drawingId, objectId, parentClass) {
333
334
 
334
335
  return object.parent;
335
336
  }
337
+ const isSketchGeometry = arg => {
338
+ const objClass = typeof arg === 'string' ? arg : arg.class;
339
+ return objClass === classcad.CCClasses.CCPoint || objClass === classcad.CCClasses.CCLine || objClass === classcad.CCClasses.CCArc || objClass === classcad.CCClasses.CCCircle;
340
+ };
336
341
  const is2DConstraint = arg => {
337
342
  const objClass = typeof arg === 'string' ? arg : arg.class;
338
343
  return Boolean(objClass.match(/CC_2D.+Constraint/)) || objClass === classcad.CCClasses.CCRigidSet;
@@ -441,6 +446,12 @@ function fmod(num, denom) {
441
446
  k = k < 0 ? k + 1 : k;
442
447
  return num - k * denom;
443
448
  }
449
+ function numberToHexColor(color) {
450
+ const hexLen = 6;
451
+ const hexStr = color.toString(16);
452
+ const zeroNumber = hexLen - hexStr.length;
453
+ return '#' + '0'.repeat(zeroNumber) + hexStr;
454
+ }
444
455
 
445
456
  const DimContext = /*#__PURE__*/React.createContext({
446
457
  globalToLocalM: new THREE__namespace.Matrix4(),
@@ -448,7 +459,7 @@ const DimContext = /*#__PURE__*/React.createContext({
448
459
  drawingId: -1
449
460
  });
450
461
 
451
- function useScale(position, getVector) {
462
+ function useScale$1(position, getVector) {
452
463
  const ref = React.useRef();
453
464
  fiber.useFrame(args => {
454
465
  const sf = react.CameraHelper.calculateScaleFactor(position, 1, args.camera, args.size);
@@ -893,6 +904,133 @@ const isAngular = dim => {
893
904
  return dim.class === classcad.CCClasses.CCAngularDimension || dim.class === classcad.CCClasses.CCAngularFeatureDimension || dim.class === classcad.CCClasses.CCAngularRefDimension;
894
905
  };
895
906
 
907
+ const zoomToFit = drawingId => {
908
+ var _getCamera;
909
+
910
+ const drawing = core.getDrawing(drawingId);
911
+ const camApi = (_getCamera = react.getCamera(drawingId)) == null ? void 0 : _getCamera.api;
912
+
913
+ if (!drawing || !camApi) {
914
+ return;
915
+ }
916
+
917
+ const {
918
+ structure,
919
+ api: drawingApi
920
+ } = drawing;
921
+ const {
922
+ root,
923
+ currentProduct,
924
+ currentNode
925
+ } = structure;
926
+ let currRoot = currentNode || currentProduct || root;
927
+
928
+ if (currentProduct && structure.tree[currentProduct].class === 'CC_Part') {
929
+ currRoot = currentProduct;
930
+ }
931
+
932
+ const bounds = drawingApi.structure.calculateProductBounds(currRoot);
933
+ camApi.setZoom('fit', bounds);
934
+ };
935
+
936
+ function ownKeys$k(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
937
+
938
+ function _objectSpread$k(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$k(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$k(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
939
+ const appApi = (set, get) => ({
940
+ assemblyTree: {
941
+ startProdEditing: (drawingId, objId) => {
942
+ set(state => {
943
+ let res = [];
944
+ const curNode = core.api.getState().drawing.refs[drawingId].structure.currentNode;
945
+ res = state.assemblyTree.prodStack;
946
+ curNode && res.push(curNode);
947
+ return _objectSpread$k(_objectSpread$k({}, state), {}, {
948
+ assemblyTree: {
949
+ prodStack: [...res]
950
+ }
951
+ });
952
+ });
953
+ classcad.ccAPI.assemblyBuilder.setCurrentNode(drawingId, objId).then(() => zoomToFit(drawingId)).catch();
954
+ },
955
+ goBack: drawingId => {
956
+ const prodStack = get().assemblyTree.prodStack;
957
+ const prevProd = prodStack[prodStack.length - 1];
958
+ if (!prevProd) return;
959
+ set(state => {
960
+ const res = state.assemblyTree.prodStack;
961
+ res.pop();
962
+ return _objectSpread$k(_objectSpread$k({}, state), {}, {
963
+ assemblyTree: {
964
+ prodStack: [...res]
965
+ }
966
+ });
967
+ });
968
+ classcad.ccAPI.assemblyBuilder.setCurrentNode(drawingId, prevProd).then(() => zoomToFit(drawingId)).catch();
969
+ },
970
+ clearProdStack: () => {
971
+ set(state => _objectSpread$k(_objectSpread$k({}, state), {}, {
972
+ assemblyTree: {
973
+ prodStack: []
974
+ }
975
+ }));
976
+ }
977
+ },
978
+ blankDiv: {
979
+ show: callback => {
980
+ set(state => _objectSpread$k(_objectSpread$k({}, state), {}, {
981
+ blankDiv: {
982
+ isActive: true,
983
+ onClose: callback
984
+ }
985
+ }));
986
+ },
987
+ hide: () => {
988
+ set(state => _objectSpread$k(_objectSpread$k({}, state), {}, {
989
+ blankDiv: {
990
+ isActive: false,
991
+ onClose: undefined
992
+ }
993
+ }));
994
+ }
995
+ }
996
+ });
997
+
998
+ const createAppState = (set, get) => ({
999
+ assemblyTree: {
1000
+ prodStack: []
1001
+ },
1002
+ blankDiv: {
1003
+ isActive: false,
1004
+ onClose: undefined
1005
+ },
1006
+ api: appApi(set, get)
1007
+ });
1008
+
1009
+ const CADApi = vanilla((set, get) => createAppState(set, get));
1010
+ const useCADStore = create(CADApi);
1011
+ const getCADState = CADApi.getState;
1012
+
1013
+ const blankZIndex = 1000;
1014
+ const BlankDiv = () => {
1015
+ const isActive = useCADStore(s => s.blankDiv.isActive);
1016
+ const onClick = React.useCallback(() => {
1017
+ const cadState = getCADState();
1018
+ cadState.blankDiv.onClose && cadState.blankDiv.onClose();
1019
+ cadState.api.blankDiv.hide();
1020
+ }, []);
1021
+ return isActive ? /*#__PURE__*/React.createElement("div", {
1022
+ onClick: onClick,
1023
+ style: {
1024
+ zIndex: blankZIndex,
1025
+ position: 'fixed',
1026
+ top: 0,
1027
+ left: 0,
1028
+ bottom: 0,
1029
+ right: 0
1030
+ }
1031
+ }) : null;
1032
+ };
1033
+
896
1034
  const mainColor = 0x424242;
897
1035
  const lineWidth$1 = 0.5;
898
1036
  const arrowSize = 5;
@@ -916,7 +1054,7 @@ const TextValue = ({
916
1054
  backgroundColor: backgroundColor ? `#${backgroundColor.toString(16)}` : undefined,
917
1055
  color: `#${mainColor.toString(16)}`,
918
1056
  fontSize: '17px',
919
- cursor: 'pointer'
1057
+ cursor: 'text'
920
1058
  }
921
1059
  }, value)));
922
1060
  };
@@ -953,6 +1091,12 @@ const DimValue = ({
953
1091
  return expr ? expr + ' (' + value.toFixed(2) + ')' : value.toFixed(2);
954
1092
  }, [master, dimension, memberName]);
955
1093
  const [editMode, setEditMode] = React.useState(false);
1094
+ React.useEffect(() => {
1095
+ if (editMode) {
1096
+ getCADState().api.blankDiv.show(() => setEditMode(false));
1097
+ return () => getCADState().api.blankDiv.hide();
1098
+ }
1099
+ }, [editMode, setEditMode]);
956
1100
  const update = React.useCallback(() => {
957
1101
  const master_ = core.getDrawing(drawingId).structure.tree[masterId];
958
1102
 
@@ -995,7 +1139,7 @@ const DimValue = ({
995
1139
  return /*#__PURE__*/React.createElement("group", {
996
1140
  position: position
997
1141
  }, /*#__PURE__*/React.createElement(drei.Html, {
998
- zIndexRange: [0, 0],
1142
+ zIndexRange: [blankZIndex + 1, blankZIndex + 1],
999
1143
  style: {
1000
1144
  marginTop: '22px'
1001
1145
  },
@@ -1010,7 +1154,7 @@ const DimValue = ({
1010
1154
  backgroundColor: backgroundColor ? `#${backgroundColor.toString(16)}` : undefined,
1011
1155
  color: `#${mainColor.toString(16)}`,
1012
1156
  fontSize: '17px',
1013
- cursor: 'pointer'
1157
+ cursor: 'text'
1014
1158
  }
1015
1159
  }, caption) : /*#__PURE__*/React.createElement("div", {
1016
1160
  style: {
@@ -1022,14 +1166,14 @@ const DimValue = ({
1022
1166
  allowExpr: true
1023
1167
  })))));
1024
1168
  };
1025
- const Line$1 = ({
1169
+ const Line$2 = ({
1026
1170
  start,
1027
1171
  end
1028
1172
  }) => {
1029
1173
  const position = React.useMemo(() => new THREE__namespace.Vector3().lerpVectors(start, end, 0.5), [start, end]);
1030
1174
  const quaternion = React.useMemo(() => new THREE__namespace.Quaternion().setFromUnitVectors(new THREE__namespace.Vector3(0, 1, 0), end.clone().sub(start).normalize()), [start, end]);
1031
1175
  const lineLength = start.distanceTo(end);
1032
- const ref = useScale(position, scaleF => [lineWidth$1 * scaleF, lineLength, lineWidth$1 * scaleF]);
1176
+ const ref = useScale$1(position, scaleF => [lineWidth$1 * scaleF, lineLength, lineWidth$1 * scaleF]);
1033
1177
  return lineLength === 0 ? null : /*#__PURE__*/React.createElement("mesh", {
1034
1178
  ref: ref,
1035
1179
  position: position,
@@ -1052,7 +1196,7 @@ const Arrow$1 = ({
1052
1196
  // Move arrow that end of the arrow will be at props.end
1053
1197
  geomRef.current && geomRef.current.translate(0, -0.5, 0);
1054
1198
  }, [geomRef]);
1055
- const ref = useScale(position, sf => [arrowSize * sf, arrowSize * 2 * sf, arrowSize * sf]);
1199
+ const ref = useScale$1(position, sf => [arrowSize * sf, arrowSize * 2 * sf, arrowSize * sf]);
1056
1200
  return /*#__PURE__*/React.createElement("mesh", {
1057
1201
  ref: ref,
1058
1202
  position: position,
@@ -1081,7 +1225,7 @@ const Arc$1 = ({
1081
1225
  lines.push(linePos);
1082
1226
  }
1083
1227
 
1084
- return /*#__PURE__*/React.createElement(React.Fragment, null, lines.map((line, i) => /*#__PURE__*/React.createElement(Line$1, {
1228
+ return /*#__PURE__*/React.createElement(React.Fragment, null, lines.map((line, i) => /*#__PURE__*/React.createElement(Line$2, {
1085
1229
  key: i,
1086
1230
  start: line[0],
1087
1231
  end: line[1]
@@ -1108,7 +1252,9 @@ const PositionHandler = ({
1108
1252
  const {
1109
1253
  camera
1110
1254
  } = fiber.useThree();
1111
- const ref = useScale(position, sf => [hRadius$1 * sf, hRadius$1 * sf, hRadius$1 * sf]);
1255
+ const ref = useScale$1(position, sf => [hRadius$1 * sf, hRadius$1 * sf, hRadius$1 * sf]);
1256
+ const [isHovered, setIsHovered] = React.useState(false);
1257
+ drei.useCursor(isHovered, 'move');
1112
1258
  const onPointerDown = React.useCallback(e => {
1113
1259
  if (e.buttons !== 1) // Continue only if 'primary' mouse button is pressed
1114
1260
  return;
@@ -1148,6 +1294,10 @@ const PositionHandler = ({
1148
1294
  te.target.releasePointerCapture(te.pointerId);
1149
1295
  te.stopPropagation();
1150
1296
  }, [dimId, drawingId, position, setPState]);
1297
+ const onPointerOver = React.useCallback(e => {
1298
+ setIsHovered(true);
1299
+ e.stopPropagation();
1300
+ }, []);
1151
1301
  const onPointerMove = React.useCallback(e => {
1152
1302
  if (isPressed.current) {
1153
1303
  isDragged.current = true;
@@ -1157,12 +1307,18 @@ const PositionHandler = ({
1157
1307
 
1158
1308
  e.stopPropagation();
1159
1309
  }, [setPosition, globalToLocalM, camera]);
1310
+ const onPointerOut = React.useCallback(e => {
1311
+ setIsHovered(false);
1312
+ e.stopPropagation();
1313
+ }, []);
1160
1314
  return /*#__PURE__*/React.createElement("mesh", {
1161
1315
  ref: ref,
1162
1316
  position: position,
1163
1317
  onPointerDown: onPointerDown,
1164
1318
  onPointerMove: onPointerMove,
1165
- onPointerUp: onPointerUp
1319
+ onPointerUp: onPointerUp,
1320
+ onPointerOver: onPointerOver,
1321
+ onPointerOut: onPointerOut
1166
1322
  }, /*#__PURE__*/React.createElement("sphereGeometry", {
1167
1323
  args: [1.5, 16, 16]
1168
1324
  }), /*#__PURE__*/React.createElement("meshBasicMaterial", {
@@ -1213,16 +1369,16 @@ const LinearDim = ({
1213
1369
  endDir: endD
1214
1370
  };
1215
1371
  }, [members, tmpDimP]);
1216
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Line$1, {
1372
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Line$2, {
1217
1373
  start: startFoot,
1218
1374
  end: tmpDimP
1219
- }), /*#__PURE__*/React.createElement(Line$1, {
1375
+ }), /*#__PURE__*/React.createElement(Line$2, {
1220
1376
  start: tmpDimP,
1221
1377
  end: endFoot
1222
- }), /*#__PURE__*/React.createElement(Line$1, {
1378
+ }), /*#__PURE__*/React.createElement(Line$2, {
1223
1379
  start: startP,
1224
1380
  end: startFoot
1225
- }), /*#__PURE__*/React.createElement(Line$1, {
1381
+ }), /*#__PURE__*/React.createElement(Line$2, {
1226
1382
  start: endP,
1227
1383
  end: endFoot
1228
1384
  }), /*#__PURE__*/React.createElement(Arrow$1, {
@@ -1268,10 +1424,10 @@ const RadialDim = ({
1268
1424
  dir: outside ? dir_.multiplyScalar(-1) : dir_
1269
1425
  };
1270
1426
  }, [members, tmpDimP]);
1271
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Line$1, {
1427
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Line$2, {
1272
1428
  start: centerP,
1273
1429
  end: endP
1274
- }), /*#__PURE__*/React.createElement(Line$1, {
1430
+ }), /*#__PURE__*/React.createElement(Line$2, {
1275
1431
  start: endP,
1276
1432
  end: dimP
1277
1433
  }), /*#__PURE__*/React.createElement(Arrow$1, {
@@ -1315,10 +1471,10 @@ const DiametralDim = ({
1315
1471
  dirEnd: outside ? dir.clone().multiplyScalar(-1) : dir
1316
1472
  };
1317
1473
  }, [members, tmpDimP]);
1318
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Line$1, {
1474
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Line$2, {
1319
1475
  start: startP,
1320
1476
  end: tmpDimP
1321
- }), /*#__PURE__*/React.createElement(Line$1, {
1477
+ }), /*#__PURE__*/React.createElement(Line$2, {
1322
1478
  start: tmpDimP,
1323
1479
  end: endP
1324
1480
  }), /*#__PURE__*/React.createElement(Arrow$1, {
@@ -1394,10 +1550,10 @@ const AngularDim = ({
1394
1550
  endL2: extendCrn ? corner : end
1395
1551
  };
1396
1552
  }, [members, tmpDimP]);
1397
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Line$1, {
1553
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Line$2, {
1398
1554
  start: startL1,
1399
1555
  end: startFoot
1400
- }), /*#__PURE__*/React.createElement(Line$1, {
1556
+ }), /*#__PURE__*/React.createElement(Line$2, {
1401
1557
  start: endFoot,
1402
1558
  end: endL2
1403
1559
  }), /*#__PURE__*/React.createElement(Arc$1, {
@@ -1472,13 +1628,14 @@ var DimGraphics$1 = DimGraphics;
1472
1628
  /**
1473
1629
  * @see https://reactjs.org/docs/error-boundaries.html
1474
1630
  */
1475
-
1631
+ const isDev = process.env.NODE_ENV === 'development';
1476
1632
  /**
1477
1633
  * Wrapper for components which are exported from package.
1478
1634
  * It's intended to catch all errors and show friendly fallback to the user instead of error log.
1479
1635
  * By default it returns null in error case. You have to pass showHtml prop to show message to the user.
1480
1636
  * TODO: implement message showing.
1481
1637
  */
1638
+
1482
1639
  class ErrorBoundary extends React.Component {
1483
1640
  constructor(props) {
1484
1641
  super(props);
@@ -1507,7 +1664,7 @@ class ErrorBoundary extends React.Component {
1507
1664
  Object.values(warns).forEach(w => {
1508
1665
  if (w) {
1509
1666
  hasWarning = true;
1510
- console.warn(w.caption);
1667
+ isDev && console.warn(w.caption);
1511
1668
  }
1512
1669
  });
1513
1670
  }
@@ -1955,9 +2112,9 @@ var index$w = /*#__PURE__*/Object.freeze({
1955
2112
  useDimensionSetId: useDimensionSetId
1956
2113
  });
1957
2114
 
1958
- function ownKeys$i(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
2115
+ function ownKeys$j(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
1959
2116
 
1960
- function _objectSpread$i(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$i(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$i(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
2117
+ function _objectSpread$j(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$j(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$j(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
1961
2118
  /**
1962
2119
  * Implies the following data structure:
1963
2120
  * data: {
@@ -2060,7 +2217,7 @@ function useMateSelection(drawingId, matePath, csysId) {
2060
2217
  }));
2061
2218
  const handlers = React.useMemo(() => {
2062
2219
  if (isSelectable) {
2063
- return _objectSpread$i(_objectSpread$i({}, hHandlers), sHandlers);
2220
+ return _objectSpread$j(_objectSpread$j({}, hHandlers), sHandlers);
2064
2221
  }
2065
2222
 
2066
2223
  return {};
@@ -2076,9 +2233,9 @@ function useMateSelection(drawingId, matePath, csysId) {
2076
2233
  }, [isHovered, isSelected, isSelectable, handlers]);
2077
2234
  }
2078
2235
 
2079
- function ownKeys$h(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
2236
+ function ownKeys$i(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
2080
2237
 
2081
- function _objectSpread$h(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$h(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$h(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
2238
+ function _objectSpread$i(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$i(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$i(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
2082
2239
  /**
2083
2240
  * Implies the following data structure:
2084
2241
  * data: {
@@ -2097,7 +2254,8 @@ const createTreeObjSelItem = (productId, object) => {
2097
2254
  data: {
2098
2255
  object
2099
2256
  },
2100
- label
2257
+ label,
2258
+ removeCondition: d => d.structure.tree[object.id] === undefined
2101
2259
  };
2102
2260
  };
2103
2261
 
@@ -2206,7 +2364,7 @@ function useTreeObjSelection(drawingId, objId) {
2206
2364
  const isSelected = useIsSelected(drawingId, objId);
2207
2365
  const handlers = React.useMemo(() => {
2208
2366
  if (isSelectable) {
2209
- return _objectSpread$h(_objectSpread$h({}, hHandlers), sHandlers);
2367
+ return _objectSpread$i(_objectSpread$i({}, hHandlers), sHandlers);
2210
2368
  }
2211
2369
 
2212
2370
  return {};
@@ -5030,7 +5188,7 @@ const Root$g = ({
5030
5188
  }));
5031
5189
  };
5032
5190
 
5033
- const Point$1 = ({
5191
+ const Point$2 = ({
5034
5192
  position,
5035
5193
  radius,
5036
5194
  color,
@@ -5102,7 +5260,7 @@ const OriginPoint = ({
5102
5260
  handlers,
5103
5261
  userData
5104
5262
  }) => {
5105
- return /*#__PURE__*/React.createElement(Point$1, {
5263
+ return /*#__PURE__*/React.createElement(Point$2, {
5106
5264
  position: position ? position.clone() : new THREE__namespace.Vector3(),
5107
5265
  radius: 2,
5108
5266
  color: color,
@@ -5143,7 +5301,7 @@ const Csys = ({
5143
5301
  userData
5144
5302
  }) => {
5145
5303
  const position = new THREE__namespace.Vector3().setFromMatrixPosition(matrix);
5146
- const ref = useScale(position.clone(), sf => [2 * sf, 2 * sf, 2 * sf]);
5304
+ const ref = useScale$1(position.clone(), sf => [2 * sf, 2 * sf, 2 * sf]);
5147
5305
  return /*#__PURE__*/React.createElement("group", _extends({
5148
5306
  matrix: matrix,
5149
5307
  matrixAutoUpdate: false
@@ -5182,7 +5340,7 @@ const SelectedCsys = ({
5182
5340
  userData
5183
5341
  }) => {
5184
5342
  const position = new THREE__namespace.Vector3().setFromMatrixPosition(matrix);
5185
- const ref = useScale(position.clone(), sf => [2 * sf, 2 * sf, 2 * sf]);
5343
+ const ref = useScale$1(position.clone(), sf => [2 * sf, 2 * sf, 2 * sf]);
5186
5344
  return /*#__PURE__*/React.createElement("group", _extends({
5187
5345
  matrix: matrix,
5188
5346
  matrixAutoUpdate: false
@@ -5257,7 +5415,7 @@ const Distance = ({
5257
5415
  setShowValue(true);
5258
5416
  }
5259
5417
  });
5260
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Line$1, {
5418
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Line$2, {
5261
5419
  start: start,
5262
5420
  end: end
5263
5421
  }), /*#__PURE__*/React.createElement(Arrow$1, {
@@ -5344,10 +5502,10 @@ const Angle = ({
5344
5502
  setShowValue(true);
5345
5503
  }
5346
5504
  });
5347
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Line$1, {
5505
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Line$2, {
5348
5506
  start: center,
5349
5507
  end: end1
5350
- }), /*#__PURE__*/React.createElement(Line$1, {
5508
+ }), /*#__PURE__*/React.createElement(Line$2, {
5351
5509
  start: center,
5352
5510
  end: end2
5353
5511
  }), /*#__PURE__*/React.createElement("group", {
@@ -5374,7 +5532,7 @@ const Position = ({
5374
5532
  pos,
5375
5533
  result
5376
5534
  }) => {
5377
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Point$1, {
5535
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Point$2, {
5378
5536
  position: pos,
5379
5537
  radius: 1.5,
5380
5538
  color: 0xaf1111
@@ -5389,7 +5547,7 @@ const Vector = ({
5389
5547
  end
5390
5548
  }) => {
5391
5549
  const dir = end.clone().sub(start);
5392
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Line$1, {
5550
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Line$2, {
5393
5551
  start: start,
5394
5552
  end: end
5395
5553
  }), /*#__PURE__*/React.createElement(Arrow$1, {
@@ -5516,6 +5674,7 @@ let HandlersList;
5516
5674
  HandlersList["FILLET"] = "fillet";
5517
5675
  HandlersList["HOVER"] = "hover";
5518
5676
  HandlersList["TRIM"] = "trim";
5677
+ HandlersList["USEREF"] = "useReference";
5519
5678
  HandlersList["GSELECTION"] = "globalSelection";
5520
5679
  })(HandlersList || (HandlersList = {}));
5521
5680
 
@@ -5552,7 +5711,7 @@ const calcPreviewValue = (dir0, dir1, sector, reflex) => {
5552
5711
 
5553
5712
  const hRadius = 6;
5554
5713
  const TmpPositionHandler = props => {
5555
- const ref = useScale(props.position, sf => [hRadius * sf, hRadius * sf, hRadius * sf]);
5714
+ const ref = useScale$1(props.position, sf => [hRadius * sf, hRadius * sf, hRadius * sf]);
5556
5715
  return /*#__PURE__*/React.createElement("mesh", {
5557
5716
  ref: ref,
5558
5717
  position: props.position
@@ -5664,10 +5823,10 @@ const TmpAngularDim = props => {
5664
5823
  };
5665
5824
  }, [dir0, dir1, center, dimPos, reflex]);
5666
5825
  const text = radiansToDegrees(previewValue).toFixed(2);
5667
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Line$1, {
5826
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Line$2, {
5668
5827
  start: cornerP,
5669
5828
  end: startFoot
5670
- }), /*#__PURE__*/React.createElement(Line$1, {
5829
+ }), /*#__PURE__*/React.createElement(Line$2, {
5671
5830
  start: endFoot,
5672
5831
  end: cornerP
5673
5832
  }), /*#__PURE__*/React.createElement(Arc$1, {
@@ -5728,9 +5887,9 @@ function getSketchState(drawingId, pluginId) {
5728
5887
  return plugin.state;
5729
5888
  }
5730
5889
 
5731
- function ownKeys$g(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
5890
+ function ownKeys$h(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
5732
5891
 
5733
- function _objectSpread$g(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$g(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$g(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
5892
+ function _objectSpread$h(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$h(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$h(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
5734
5893
  function CreateAngle(drawingId, pluginId) {
5735
5894
  const {
5736
5895
  set
@@ -5780,8 +5939,8 @@ function CreateAngle(drawingId, pluginId) {
5780
5939
  set(state_ => {
5781
5940
  const tmpAngularDimension = state_.tmpObjects[tmpDimensionId];
5782
5941
  return {
5783
- tmpObjects: _objectSpread$g(_objectSpread$g({}, state_.tmpObjects), {}, {
5784
- [tmpDimensionId]: _objectSpread$g(_objectSpread$g({}, tmpAngularDimension), params)
5942
+ tmpObjects: _objectSpread$h(_objectSpread$h({}, state_.tmpObjects), {}, {
5943
+ [tmpDimensionId]: _objectSpread$h(_objectSpread$h({}, tmpAngularDimension), params)
5785
5944
  })
5786
5945
  };
5787
5946
  });
@@ -5828,7 +5987,7 @@ function CreateAngle(drawingId, pluginId) {
5828
5987
  const center = linesInfo.center;
5829
5988
  const dimPos = center.clone().addScaledVector(dir0.clone().add(dir1).normalize(), 10);
5830
5989
 
5831
- const tmpAngularDimension = _objectSpread$g(_objectSpread$g({
5990
+ const tmpAngularDimension = _objectSpread$h(_objectSpread$h({
5832
5991
  class: classcad.CCClasses.CCAngularDimension,
5833
5992
  id: tmpDimensionId
5834
5993
  }, linesInfo), {}, {
@@ -5908,12 +6067,105 @@ function CreateAngle(drawingId, pluginId) {
5908
6067
  };
5909
6068
  }
5910
6069
 
5911
- function ownKeys$f(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
6070
+ function ownKeys$g(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
5912
6071
 
5913
- function _objectSpread$f(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$f(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$f(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
5914
- function Hover(drawingId, pluginId) {
5915
- let timerId;
6072
+ function _objectSpread$g(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$g(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$g(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
6073
+ let timerId;
6074
+ const hover = (drawingId, pluginId, hoveredId) => {
6075
+ const {
6076
+ state,
6077
+ set
6078
+ } = core.getPlugin(drawingId, pluginId);
6079
+ const tree = core.getDrawing(drawingId).structure.tree;
6080
+ const hoveredObject = tree[hoveredId];
6081
+
6082
+ if (!hoveredObject || hoveredObject && hoveredObject.class === classcad.CCClasses.CCSketch || state.rubberBandRectangle) {
6083
+ return;
6084
+ }
6085
+
6086
+ if (is2DConstraint(hoveredObject)) {
6087
+ const constraintEntities = hoveredObject.members.entities.members.map(entity => entity.value);
6088
+ set(state_ => {
6089
+ const highlighted = state_.highlighted;
6090
+ const highlightedConstraints = highlighted.filter(id => is2DConstraint(tree[id]) && id !== hoveredId);
6091
+ return {
6092
+ hovered: hoveredId,
6093
+ highlighted: [...highlightedConstraints, hoveredId, ...constraintEntities]
6094
+ };
6095
+ });
6096
+ } else {
6097
+ const linkedConstraints = Object.values(tree).filter(obj => is2DConstraint(obj)).filter(obj => obj.members.entities.members.some(entity => entity.value === hoveredId)).map(obj => obj.id);
6098
+ const constraintsToGeometry = {};
6099
+ linkedConstraints.forEach(id => {
6100
+ constraintsToGeometry[id] = hoveredId;
6101
+ });
6102
+ set(state_ => {
6103
+ return {
6104
+ hovered: hoveredId,
6105
+ highlighted: [hoveredId, ...linkedConstraints],
6106
+ constraintsToGeometry: _objectSpread$g(_objectSpread$g({}, state_.constraintsToGeometry), constraintsToGeometry)
6107
+ };
6108
+ });
6109
+ }
6110
+
6111
+ if (timerId) {
6112
+ window.clearTimeout(timerId);
6113
+ timerId = undefined;
6114
+ }
6115
+ };
6116
+ const unhover = (drawingId, pluginId, hoveredId) => {
6117
+ const {
6118
+ state,
6119
+ set
6120
+ } = core.getPlugin(drawingId, pluginId);
6121
+ const tree = core.getDrawing(drawingId).structure.tree;
6122
+ const hoveredObject = tree[hoveredId];
6123
+
6124
+ if (!hoveredObject || hoveredObject && hoveredObject.class === classcad.CCClasses.CCSketch || state.rubberBandRectangle) {
6125
+ return;
6126
+ }
6127
+
6128
+ set(state_ => {
6129
+ const highlighted = state_.highlighted;
6130
+ const highlightedConstraints = highlighted.filter(id => is2DConstraint(tree[id]));
6131
+ return {
6132
+ hovered: state_.hovered === hoveredId ? UNDEFINEDID : state_.hovered,
6133
+ highlighted: highlightedConstraints
6134
+ };
6135
+ });
6136
+
6137
+ if (timerId) {
6138
+ window.clearTimeout(timerId);
6139
+ }
6140
+
6141
+ timerId = window.setTimeout(() => {
6142
+ set({
6143
+ highlighted: []
6144
+ });
6145
+ }, 1000);
6146
+ };
6147
+ const select = (drawingId, pluginId, selectedId) => {
6148
+ const {
6149
+ set
6150
+ } = core.getPlugin(drawingId, pluginId);
6151
+ set(state => {
6152
+ const curSelected = state.selected;
6153
+
6154
+ if (curSelected.indexOf(selectedId) >= 0) {
6155
+ const newSelected = curSelected.filter(id => id !== selectedId);
6156
+ return {
6157
+ selected: newSelected
6158
+ };
6159
+ } else {
6160
+ curSelected.push(selectedId);
6161
+ return {
6162
+ selected: [...curSelected]
6163
+ };
6164
+ }
6165
+ });
6166
+ };
5916
6167
 
6168
+ function Hover(drawingId, pluginId) {
5917
6169
  const filter = object => true;
5918
6170
 
5919
6171
  const destructor = () => {
@@ -5926,81 +6178,14 @@ function Hover(drawingId, pluginId) {
5926
6178
  };
5927
6179
 
5928
6180
  const onPointerOver = e => {
5929
- const {
5930
- state,
5931
- set
5932
- } = core.getPlugin(drawingId, pluginId);
5933
6181
  const hoveredId = e.object.userData.objId;
5934
- const tree = core.getDrawing(drawingId).structure.tree;
5935
- const hoveredObject = tree[hoveredId];
6182
+ hover(drawingId, pluginId, hoveredId);
5936
6183
  e.stopPropagation();
5937
-
5938
- if (!hoveredObject || hoveredObject && hoveredObject.class === classcad.CCClasses.CCSketch || state.rubberBandRectangle) {
5939
- return;
5940
- }
5941
-
5942
- if (is2DConstraint(hoveredObject)) {
5943
- const constraintEntities = hoveredObject.members.entities.members.map(entity => entity.value);
5944
- set(state_ => {
5945
- const highlighted = state_.highlighted;
5946
- const highlightedConstraints = highlighted.filter(id => is2DConstraint(tree[id]) && id !== hoveredId);
5947
- return {
5948
- hovered: hoveredId,
5949
- highlighted: [...highlightedConstraints, hoveredId, ...constraintEntities]
5950
- };
5951
- });
5952
- } else {
5953
- const linkedConstraints = Object.values(tree).filter(obj => is2DConstraint(obj)).filter(obj => obj.members.entities.members.some(entity => entity.value === hoveredId)).map(obj => obj.id);
5954
- const constraintsToGeometry = {};
5955
- linkedConstraints.forEach(id => {
5956
- constraintsToGeometry[id] = hoveredId;
5957
- });
5958
- set(state_ => {
5959
- return {
5960
- hovered: hoveredId,
5961
- highlighted: [hoveredId, ...linkedConstraints],
5962
- constraintsToGeometry: _objectSpread$f(_objectSpread$f({}, state_.constraintsToGeometry), constraintsToGeometry)
5963
- };
5964
- });
5965
- }
5966
-
5967
- if (timerId) {
5968
- window.clearTimeout(timerId);
5969
- timerId = undefined;
5970
- }
5971
6184
  };
5972
6185
 
5973
6186
  const onPointerOut = e => {
5974
- const {
5975
- state,
5976
- set
5977
- } = core.getPlugin(drawingId, pluginId);
5978
6187
  const hoveredId = e.object.userData.objId;
5979
- const tree = core.getDrawing(drawingId).structure.tree;
5980
- const hoveredObject = tree[hoveredId];
5981
-
5982
- if (!hoveredObject || hoveredObject && hoveredObject.class === classcad.CCClasses.CCSketch || state.rubberBandRectangle) {
5983
- return;
5984
- }
5985
-
5986
- set(state_ => {
5987
- const highlighted = state_.highlighted;
5988
- const highlightedConstraints = highlighted.filter(id => is2DConstraint(tree[id]));
5989
- return {
5990
- hovered: state_.hovered === hoveredId ? UNDEFINEDID : state_.hovered,
5991
- highlighted: highlightedConstraints
5992
- };
5993
- });
5994
-
5995
- if (timerId) {
5996
- window.clearTimeout(timerId);
5997
- }
5998
-
5999
- timerId = window.setTimeout(() => {
6000
- set({
6001
- highlighted: []
6002
- });
6003
- }, 1000);
6188
+ unhover(drawingId, pluginId, hoveredId);
6004
6189
  e.stopPropagation();
6005
6190
  };
6006
6191
 
@@ -6099,9 +6284,9 @@ const snapDraggedPoints = (diff, drawingId) => {
6099
6284
  return snapResult;
6100
6285
  };
6101
6286
 
6102
- function ownKeys$e(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
6287
+ function ownKeys$f(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
6103
6288
 
6104
- function _objectSpread$e(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$e(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$e(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
6289
+ function _objectSpread$f(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$f(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$f(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
6105
6290
 
6106
6291
  const artifDelay = 16;
6107
6292
 
@@ -6288,22 +6473,8 @@ function Drag(drawingId, pluginId) {
6288
6473
  return;
6289
6474
  }
6290
6475
 
6291
- set(state => {
6292
- const curSelected = state.selected;
6293
-
6294
- if (curSelected.indexOf(pressedId) >= 0) {
6295
- const newSelected = curSelected.filter(id => id !== pressedId);
6296
- return {
6297
- selected: newSelected
6298
- };
6299
- } else {
6300
- curSelected.push(pressedId);
6301
- return {
6302
- selected: [...curSelected]
6303
- };
6304
- }
6305
- });
6306
- }
6476
+ select(drawingId, pluginId, pressedId);
6477
+ }
6307
6478
 
6308
6479
  clearIgnoreList();
6309
6480
  clearDraggedPoints();
@@ -6389,7 +6560,7 @@ function Drag(drawingId, pluginId) {
6389
6560
  name: HandlersList.DRAG,
6390
6561
  filter,
6391
6562
  onDestruct: destructor,
6392
- pointerHandlers: _objectSpread$e({
6563
+ pointerHandlers: _objectSpread$f({
6393
6564
  onPointerDown,
6394
6565
  onPointerUp,
6395
6566
  onPointerMove
@@ -6401,9 +6572,9 @@ function Drag(drawingId, pluginId) {
6401
6572
  };
6402
6573
  }
6403
6574
 
6404
- function ownKeys$d(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
6575
+ function ownKeys$e(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
6405
6576
 
6406
- function _objectSpread$d(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$d(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$d(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
6577
+ function _objectSpread$e(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$e(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$e(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
6407
6578
  function DrawPoint(drawingId, pluginId) {
6408
6579
  const {
6409
6580
  set
@@ -6472,8 +6643,8 @@ function DrawPoint(drawingId, pluginId) {
6472
6643
  set(state => {
6473
6644
  const tmpPoint = state.tmpObjects[tmpPointId];
6474
6645
  return {
6475
- tmpObjects: _objectSpread$d(_objectSpread$d({}, state.tmpObjects), {}, {
6476
- [tmpPointId]: _objectSpread$d(_objectSpread$d({}, tmpPoint), {}, {
6646
+ tmpObjects: _objectSpread$e(_objectSpread$e({}, state.tmpObjects), {}, {
6647
+ [tmpPointId]: _objectSpread$e(_objectSpread$e({}, tmpPoint), {}, {
6477
6648
  position: mousePos
6478
6649
  })
6479
6650
  })
@@ -6495,9 +6666,9 @@ function DrawPoint(drawingId, pluginId) {
6495
6666
  };
6496
6667
  }
6497
6668
 
6498
- function ownKeys$c(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
6669
+ function ownKeys$d(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
6499
6670
 
6500
- function _objectSpread$c(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$c(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$c(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
6671
+ function _objectSpread$d(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$d(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$d(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
6501
6672
  function DrawLine(drawingId, pluginId) {
6502
6673
  // Global hooks:
6503
6674
  const {
@@ -6583,7 +6754,7 @@ function DrawLine(drawingId, pluginId) {
6583
6754
  endPId: tmpEndP.id
6584
6755
  };
6585
6756
  return {
6586
- tmpObjects: _objectSpread$c(_objectSpread$c({}, state.tmpObjects), {}, {
6757
+ tmpObjects: _objectSpread$d(_objectSpread$d({}, state.tmpObjects), {}, {
6587
6758
  [tmpStartP.id]: tmpStartP,
6588
6759
  [tmpLine.id]: tmpLine
6589
6760
  })
@@ -6621,8 +6792,8 @@ function DrawLine(drawingId, pluginId) {
6621
6792
  const tmpStartP = state.tmpObjects[tmpStartPId];
6622
6793
  const tmpEndP = state.tmpObjects[tmpEndPId];
6623
6794
  return {
6624
- tmpObjects: _objectSpread$c(_objectSpread$c({}, state.tmpObjects), {}, {
6625
- [tmpStartPId]: _objectSpread$c(_objectSpread$c({}, tmpStartP), {}, {
6795
+ tmpObjects: _objectSpread$d(_objectSpread$d({}, state.tmpObjects), {}, {
6796
+ [tmpStartPId]: _objectSpread$d(_objectSpread$d({}, tmpStartP), {}, {
6626
6797
  position: tmpEndP.position.clone()
6627
6798
  })
6628
6799
  })
@@ -6644,8 +6815,8 @@ function DrawLine(drawingId, pluginId) {
6644
6815
  set(state => {
6645
6816
  const tmpEndP = state.tmpObjects[tmpEndPId];
6646
6817
  return {
6647
- tmpObjects: _objectSpread$c(_objectSpread$c({}, state.tmpObjects), {}, {
6648
- [tmpEndPId]: _objectSpread$c(_objectSpread$c({}, tmpEndP), {}, {
6818
+ tmpObjects: _objectSpread$d(_objectSpread$d({}, state.tmpObjects), {}, {
6819
+ [tmpEndPId]: _objectSpread$d(_objectSpread$d({}, tmpEndP), {}, {
6649
6820
  position: mousePos
6650
6821
  })
6651
6822
  })
@@ -6670,9 +6841,9 @@ function DrawLine(drawingId, pluginId) {
6670
6841
  };
6671
6842
  }
6672
6843
 
6673
- function ownKeys$b(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
6844
+ function ownKeys$c(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
6674
6845
 
6675
- function _objectSpread$b(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$b(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$b(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
6846
+ function _objectSpread$c(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$c(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$c(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
6676
6847
  function DrawRectangle(drawingId, pluginId) {
6677
6848
  // Global hooks:
6678
6849
  const {
@@ -6728,7 +6899,7 @@ function DrawRectangle(drawingId, pluginId) {
6728
6899
  set(state => {
6729
6900
  const tmpPoint11 = state.tmpObjects[tmpPoint11Id];
6730
6901
 
6731
- const tmpPoint00 = _objectSpread$b(_objectSpread$b({}, state.tmpObjects[tmpPoint00Id]), {}, {
6902
+ const tmpPoint00 = _objectSpread$c(_objectSpread$c({}, state.tmpObjects[tmpPoint00Id]), {}, {
6732
6903
  position: tmpPoint11.position.clone()
6733
6904
  });
6734
6905
 
@@ -6796,7 +6967,7 @@ function DrawRectangle(drawingId, pluginId) {
6796
6967
  endPId: tmpPoint11.id
6797
6968
  };
6798
6969
  return {
6799
- tmpObjects: _objectSpread$b(_objectSpread$b({}, state.tmpObjects), {}, {
6970
+ tmpObjects: _objectSpread$c(_objectSpread$c({}, state.tmpObjects), {}, {
6800
6971
  [tmpPoint00.id]: tmpPoint00,
6801
6972
  [tmpPoint01.id]: tmpPoint01,
6802
6973
  [tmpPoint10.id]: tmpPoint10,
@@ -6824,7 +6995,7 @@ function DrawRectangle(drawingId, pluginId) {
6824
6995
  const tmpPoint11 = state.tmpObjects[tmpPoint11Id];
6825
6996
  return {
6826
6997
  tmpObjects: {
6827
- [tmpPoint00Id]: _objectSpread$b(_objectSpread$b({}, tmpPoint00), {}, {
6998
+ [tmpPoint00Id]: _objectSpread$c(_objectSpread$c({}, tmpPoint00), {}, {
6828
6999
  position: tmpPoint11.position.clone()
6829
7000
  })
6830
7001
  }
@@ -6848,8 +7019,8 @@ function DrawRectangle(drawingId, pluginId) {
6848
7019
  if (additionIndex === 0) {
6849
7020
  const tmpPoint00 = state.tmpObjects[tmpPoint00Id];
6850
7021
  return {
6851
- tmpObjects: _objectSpread$b(_objectSpread$b({}, state.tmpObjects), {}, {
6852
- [tmpPoint00Id]: _objectSpread$b(_objectSpread$b({}, tmpPoint00), {}, {
7022
+ tmpObjects: _objectSpread$c(_objectSpread$c({}, state.tmpObjects), {}, {
7023
+ [tmpPoint00Id]: _objectSpread$c(_objectSpread$c({}, tmpPoint00), {}, {
6853
7024
  position: snappedPos
6854
7025
  })
6855
7026
  })
@@ -6860,14 +7031,14 @@ function DrawRectangle(drawingId, pluginId) {
6860
7031
  const tmpPoint10 = state.tmpObjects[tmpPoint10Id];
6861
7032
  const tmpPoint11 = state.tmpObjects[tmpPoint11Id];
6862
7033
  return {
6863
- tmpObjects: _objectSpread$b(_objectSpread$b({}, state.tmpObjects), {}, {
6864
- [tmpPoint01Id]: _objectSpread$b(_objectSpread$b({}, tmpPoint01), {}, {
7034
+ tmpObjects: _objectSpread$c(_objectSpread$c({}, state.tmpObjects), {}, {
7035
+ [tmpPoint01Id]: _objectSpread$c(_objectSpread$c({}, tmpPoint01), {}, {
6865
7036
  position: new THREE__namespace.Vector3(startPos.x, snappedPos.y, startPos.z)
6866
7037
  }),
6867
- [tmpPoint10Id]: _objectSpread$b(_objectSpread$b({}, tmpPoint10), {}, {
7038
+ [tmpPoint10Id]: _objectSpread$c(_objectSpread$c({}, tmpPoint10), {}, {
6868
7039
  position: new THREE__namespace.Vector3(snappedPos.x, startPos.y, startPos.z)
6869
7040
  }),
6870
- [tmpPoint11Id]: _objectSpread$b(_objectSpread$b({}, tmpPoint11), {}, {
7041
+ [tmpPoint11Id]: _objectSpread$c(_objectSpread$c({}, tmpPoint11), {}, {
6871
7042
  position: new THREE__namespace.Vector3(snappedPos.x, snappedPos.y, startPos.z)
6872
7043
  })
6873
7044
  })
@@ -6893,17 +7064,35 @@ function DrawRectangle(drawingId, pluginId) {
6893
7064
  };
6894
7065
  }
6895
7066
 
7067
+ let scale = 1;
7068
+ function setScale(newScale) {
7069
+ scale = newScale;
7070
+ }
7071
+ function getScale() {
7072
+ return scale;
7073
+ } // The hook sets scale vector to a refered object in useFrame
7074
+
7075
+ function useScale(getVector) {
7076
+ const ref = React.useRef();
7077
+ fiber.useFrame(args => {
7078
+ if (ref.current) {
7079
+ const newScale = getVector ? getVector(scale) : [scale, scale, scale];
7080
+ ref.current.scale.set(...newScale);
7081
+ }
7082
+ });
7083
+ return ref;
7084
+ }
7085
+
6896
7086
  const lineWidth = 0.2;
6897
7087
  const pointSize = 0.5;
6898
7088
  const arcWidth = 0.2;
6899
7089
  const radSegments = 32;
6900
- const tubeSegments = 6;
6901
- const cylGeom = new THREE__namespace.CylinderGeometry(1, 1, 1, 6);
6902
- const Line = ({
7090
+ const tubeSegments$1 = 6;
7091
+ const cylGeom$1 = new THREE__namespace.CylinderGeometry(1, 1, 1, 6);
7092
+ const Line$1 = ({
6903
7093
  start,
6904
7094
  end,
6905
7095
  width = lineWidth,
6906
- scale = 1,
6907
7096
  materialProps,
6908
7097
  meshProps
6909
7098
  }) => {
@@ -6917,24 +7106,26 @@ const Line = ({
6917
7106
  quaternion: new THREE__namespace.Quaternion().setFromUnitVectors(new THREE__namespace.Vector3(0, 1, 0), dir)
6918
7107
  };
6919
7108
  }, [start, end]);
7109
+ const ref = useScale(scale => [width * scale, start.distanceTo(end), width * scale]);
6920
7110
  return /*#__PURE__*/React.createElement("mesh", _extends({}, meshProps, {
7111
+ ref: ref,
6921
7112
  position: position,
6922
7113
  quaternion: quaternion,
6923
- geometry: cylGeom,
6924
- scale: [width * scale, start.distanceTo(end), width * scale]
7114
+ geometry: cylGeom$1
6925
7115
  }), /*#__PURE__*/React.createElement("meshBasicMaterial", materialProps));
6926
7116
  };
6927
- const Point = ({
7117
+ const Point$1 = ({
6928
7118
  position,
6929
7119
  size = pointSize,
6930
- scale = 1,
6931
7120
  materialProps,
6932
7121
  meshProps
6933
7122
  }) => {
7123
+ const ref = useScale(scale => [size * scale, size * scale, size * scale]);
6934
7124
  return /*#__PURE__*/React.createElement("mesh", _extends({}, meshProps, {
6935
- position: position
7125
+ position: position,
7126
+ ref: ref
6936
7127
  }), /*#__PURE__*/React.createElement("sphereGeometry", {
6937
- args: [size * scale, tubeSegments, tubeSegments]
7128
+ args: [1, tubeSegments$1, tubeSegments$1]
6938
7129
  }), /*#__PURE__*/React.createElement("meshBasicMaterial", materialProps));
6939
7130
  };
6940
7131
  function getArcAngles(params) {
@@ -6994,7 +7185,7 @@ const Arc = ({
6994
7185
  position: center,
6995
7186
  quaternion: quaternion
6996
7187
  }), /*#__PURE__*/React.createElement("torusGeometry", {
6997
- args: [radius, width * scale, tubeSegments, radSegments, thetaLength]
7188
+ args: [radius, width * scale, tubeSegments$1, radSegments, thetaLength]
6998
7189
  }), /*#__PURE__*/React.createElement("meshBasicMaterial", _extends({}, materialProps, {
6999
7190
  side: clockwise ? THREE__namespace.DoubleSide : THREE__namespace.FrontSide
7000
7191
  })));
@@ -7010,13 +7201,13 @@ const Circle = ({
7010
7201
  return /*#__PURE__*/React.createElement("mesh", _extends({}, meshProps, {
7011
7202
  position: center
7012
7203
  }), /*#__PURE__*/React.createElement("torusGeometry", {
7013
- args: [radius, width * scale, tubeSegments, radSegments]
7204
+ args: [radius, width * scale, tubeSegments$1, radSegments]
7014
7205
  }), /*#__PURE__*/React.createElement("meshBasicMaterial", materialProps));
7015
7206
  };
7016
7207
 
7017
- function ownKeys$a(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
7208
+ function ownKeys$b(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
7018
7209
 
7019
- function _objectSpread$a(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$a(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$a(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
7210
+ function _objectSpread$b(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$b(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$b(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
7020
7211
  function DrawArc(drawingId, pluginId, arcType) {
7021
7212
  // Global hooks:
7022
7213
  const {
@@ -7072,7 +7263,7 @@ function DrawArc(drawingId, pluginId, arcType) {
7072
7263
  additionIndex = 0;
7073
7264
  lastAddedEndPointId = UNDEFINEDID;
7074
7265
  set(state => {
7075
- const tmpStartP = _objectSpread$a(_objectSpread$a({}, state.tmpObjects[tmpStartPId]), {}, {
7266
+ const tmpStartP = _objectSpread$b(_objectSpread$b({}, state.tmpObjects[tmpStartPId]), {}, {
7076
7267
  position: lastMousePos.clone()
7077
7268
  });
7078
7269
 
@@ -7087,24 +7278,24 @@ function DrawArc(drawingId, pluginId, arcType) {
7087
7278
  set(state => {
7088
7279
  const tmpStartP = state.tmpObjects[tmpStartPId];
7089
7280
 
7090
- const tmpEndP = _objectSpread$a(_objectSpread$a({}, state.tmpObjects[tmpEndPId]), {}, {
7281
+ const tmpEndP = _objectSpread$b(_objectSpread$b({}, state.tmpObjects[tmpEndPId]), {}, {
7091
7282
  position: lastMousePos.clone()
7092
7283
  });
7093
7284
 
7094
7285
  const centerPos = calculateCenterPoint(tmpStartP.position, lastMousePos, lastMousePos);
7095
7286
 
7096
- const tmpCenterP = _objectSpread$a(_objectSpread$a({}, state.tmpObjects[tmpCenterPId]), {}, {
7287
+ const tmpCenterP = _objectSpread$b(_objectSpread$b({}, state.tmpObjects[tmpCenterPId]), {}, {
7097
7288
  position: centerPos ? centerPos : lastMousePos.clone()
7098
7289
  });
7099
7290
 
7100
- const tmpArc = _objectSpread$a(_objectSpread$a({}, state.tmpObjects[tmpArcId]), {}, {
7291
+ const tmpArc = _objectSpread$b(_objectSpread$b({}, state.tmpObjects[tmpArcId]), {}, {
7101
7292
  // In case centerPos couldn't be calculated, the arc should be drawn as a line
7102
7293
  drawAsLine: centerPos === undefined,
7103
7294
  clockwise: false
7104
7295
  });
7105
7296
 
7106
7297
  return {
7107
- tmpObjects: _objectSpread$a(_objectSpread$a({}, state.tmpObjects), {}, {
7298
+ tmpObjects: _objectSpread$b(_objectSpread$b({}, state.tmpObjects), {}, {
7108
7299
  [tmpEndP.id]: tmpEndP,
7109
7300
  [tmpCenterP.id]: tmpCenterP,
7110
7301
  [tmpArc.id]: tmpArc
@@ -7225,7 +7416,7 @@ function DrawArc(drawingId, pluginId, arcType) {
7225
7416
  clockwise: false
7226
7417
  };
7227
7418
  return {
7228
- tmpObjects: _objectSpread$a(_objectSpread$a({}, state.tmpObjects), {}, {
7419
+ tmpObjects: _objectSpread$b(_objectSpread$b({}, state.tmpObjects), {}, {
7229
7420
  [tmpEndP.id]: tmpEndP,
7230
7421
  [tmpCenterP.id]: tmpCenterP,
7231
7422
  [tmpArc.id]: tmpArc
@@ -7254,7 +7445,7 @@ function DrawArc(drawingId, pluginId, arcType) {
7254
7445
  clockwise: false
7255
7446
  };
7256
7447
  return {
7257
- tmpObjects: _objectSpread$a(_objectSpread$a({}, state.tmpObjects), {}, {
7448
+ tmpObjects: _objectSpread$b(_objectSpread$b({}, state.tmpObjects), {}, {
7258
7449
  [tmpCenterP.id]: tmpCenterP,
7259
7450
  [tmpArc.id]: tmpArc
7260
7451
  })
@@ -7312,11 +7503,11 @@ function DrawArc(drawingId, pluginId, arcType) {
7312
7503
  const tmpEndP = state.tmpObjects[tmpEndPId];
7313
7504
  const tmpCenterP = state.tmpObjects[tmpCenterPId];
7314
7505
  return {
7315
- tmpObjects: _objectSpread$a(_objectSpread$a({}, state.tmpObjects), {}, {
7316
- [tmpStartPId]: _objectSpread$a(_objectSpread$a({}, tmpStartP), {}, {
7506
+ tmpObjects: _objectSpread$b(_objectSpread$b({}, state.tmpObjects), {}, {
7507
+ [tmpStartPId]: _objectSpread$b(_objectSpread$b({}, tmpStartP), {}, {
7317
7508
  position: tmpEndP.position.clone()
7318
7509
  }),
7319
- [tmpCenterPId]: _objectSpread$a(_objectSpread$a({}, tmpCenterP), {}, {
7510
+ [tmpCenterPId]: _objectSpread$b(_objectSpread$b({}, tmpCenterP), {}, {
7320
7511
  position: tmpEndP.position.clone()
7321
7512
  })
7322
7513
  })
@@ -7340,8 +7531,8 @@ function DrawArc(drawingId, pluginId, arcType) {
7340
7531
  if (additionIndex === 0) {
7341
7532
  const tmpStartP = state.tmpObjects[tmpStartPId];
7342
7533
  return {
7343
- tmpObjects: _objectSpread$a(_objectSpread$a({}, state.tmpObjects), {}, {
7344
- [tmpStartPId]: _objectSpread$a(_objectSpread$a({}, tmpStartP), {}, {
7534
+ tmpObjects: _objectSpread$b(_objectSpread$b({}, state.tmpObjects), {}, {
7535
+ [tmpStartPId]: _objectSpread$b(_objectSpread$b({}, tmpStartP), {}, {
7345
7536
  position: lastMousePos.clone()
7346
7537
  })
7347
7538
  })
@@ -7353,14 +7544,14 @@ function DrawArc(drawingId, pluginId, arcType) {
7353
7544
  const tmpCenterP = state.tmpObjects[tmpCenterPId];
7354
7545
  const centerPos = calculateCenterPoint(tmpStartP.position, lastMousePos, lastMousePos);
7355
7546
  return {
7356
- tmpObjects: _objectSpread$a(_objectSpread$a({}, state.tmpObjects), {}, {
7357
- [tmpEndPId]: _objectSpread$a(_objectSpread$a({}, tmpEndP), {}, {
7547
+ tmpObjects: _objectSpread$b(_objectSpread$b({}, state.tmpObjects), {}, {
7548
+ [tmpEndPId]: _objectSpread$b(_objectSpread$b({}, tmpEndP), {}, {
7358
7549
  position: lastMousePos.clone()
7359
7550
  }),
7360
- [tmpCenterPId]: _objectSpread$a(_objectSpread$a({}, tmpCenterP), {}, {
7551
+ [tmpCenterPId]: _objectSpread$b(_objectSpread$b({}, tmpCenterP), {}, {
7361
7552
  position: centerPos ? centerPos : lastMousePos.clone()
7362
7553
  }),
7363
- [tmpArcId]: _objectSpread$a(_objectSpread$a({}, tmpArc), {}, {
7554
+ [tmpArcId]: _objectSpread$b(_objectSpread$b({}, tmpArc), {}, {
7364
7555
  // In case centerPos couldn't be calculated, the arc should be drawn as a line
7365
7556
  drawAsLine: centerPos === undefined,
7366
7557
  clockwise: false
@@ -7374,14 +7565,14 @@ function DrawArc(drawingId, pluginId, arcType) {
7374
7565
  const tmpCenterP = state.tmpObjects[tmpCenterPId];
7375
7566
  const centerPos = calculateCenterPoint(tmpStartP.position, tmpEndP.position, lastMousePos);
7376
7567
  return {
7377
- tmpObjects: _objectSpread$a(_objectSpread$a({}, state.tmpObjects), {}, {
7378
- [tmpEndPId]: _objectSpread$a(_objectSpread$a({}, tmpEndP), {}, {
7568
+ tmpObjects: _objectSpread$b(_objectSpread$b({}, state.tmpObjects), {}, {
7569
+ [tmpEndPId]: _objectSpread$b(_objectSpread$b({}, tmpEndP), {}, {
7379
7570
  position: arcType === HandlersList.DRAWARCTANGENT ? lastMousePos.clone() : tmpEndP.position
7380
7571
  }),
7381
- [tmpCenterPId]: _objectSpread$a(_objectSpread$a({}, tmpCenterP), {}, {
7572
+ [tmpCenterPId]: _objectSpread$b(_objectSpread$b({}, tmpCenterP), {}, {
7382
7573
  position: centerPos ? centerPos : lastMousePos.clone()
7383
7574
  }),
7384
- [tmpArcId]: _objectSpread$a(_objectSpread$a({}, tmpArc), {}, {
7575
+ [tmpArcId]: _objectSpread$b(_objectSpread$b({}, tmpArc), {}, {
7385
7576
  // In case centerPos couldn't be calculated, the arc should be drawn as a line
7386
7577
  drawAsLine: centerPos === undefined,
7387
7578
  clockwise: evaluateClockwise(tmpStartP.position, tmpEndP.position, lastMousePos)
@@ -7409,9 +7600,9 @@ function DrawArc(drawingId, pluginId, arcType) {
7409
7600
  };
7410
7601
  }
7411
7602
 
7412
- function ownKeys$9(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
7603
+ function ownKeys$a(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
7413
7604
 
7414
- function _objectSpread$9(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$9(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$9(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
7605
+ function _objectSpread$a(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$a(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$a(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
7415
7606
  function DrawCircle(drawingId, pluginId) {
7416
7607
  const {
7417
7608
  set
@@ -7458,7 +7649,7 @@ function DrawCircle(drawingId, pluginId) {
7458
7649
  } else {
7459
7650
  additionIndex = 0;
7460
7651
  set(state => {
7461
- const tmpCenterP = _objectSpread$9(_objectSpread$9({}, state.tmpObjects[tmpCenterPId]), {}, {
7652
+ const tmpCenterP = _objectSpread$a(_objectSpread$a({}, state.tmpObjects[tmpCenterPId]), {}, {
7462
7653
  position: lastMousePos.clone()
7463
7654
  });
7464
7655
 
@@ -7492,7 +7683,7 @@ function DrawCircle(drawingId, pluginId) {
7492
7683
  radius: 0.001
7493
7684
  };
7494
7685
  return {
7495
- tmpObjects: _objectSpread$9(_objectSpread$9({}, state.tmpObjects), {}, {
7686
+ tmpObjects: _objectSpread$a(_objectSpread$a({}, state.tmpObjects), {}, {
7496
7687
  [tmpCenterP.id]: tmpCenterP,
7497
7688
  [tmpCircle.id]: tmpCircle
7498
7689
  })
@@ -7513,7 +7704,7 @@ function DrawCircle(drawingId, pluginId) {
7513
7704
  const tmpCenterP = state.tmpObjects[tmpCenterPId];
7514
7705
  return {
7515
7706
  tmpObjects: {
7516
- [tmpCenterPId]: _objectSpread$9(_objectSpread$9({}, tmpCenterP), {}, {
7707
+ [tmpCenterPId]: _objectSpread$a(_objectSpread$a({}, tmpCenterP), {}, {
7517
7708
  position: e.point.clone().applyMatrix4(getGlobalToLocalMatrix(drawingId, sketchId))
7518
7709
  })
7519
7710
  }
@@ -7537,8 +7728,8 @@ function DrawCircle(drawingId, pluginId) {
7537
7728
  if (additionIndex === 0) {
7538
7729
  const tmpCenterP = state.tmpObjects[tmpCenterPId];
7539
7730
  return {
7540
- tmpObjects: _objectSpread$9(_objectSpread$9({}, state.tmpObjects), {}, {
7541
- [tmpCenterPId]: _objectSpread$9(_objectSpread$9({}, tmpCenterP), {}, {
7731
+ tmpObjects: _objectSpread$a(_objectSpread$a({}, state.tmpObjects), {}, {
7732
+ [tmpCenterPId]: _objectSpread$a(_objectSpread$a({}, tmpCenterP), {}, {
7542
7733
  position: snappedPos || localPos
7543
7734
  })
7544
7735
  })
@@ -7547,8 +7738,8 @@ function DrawCircle(drawingId, pluginId) {
7547
7738
  const tmpCenterP = state.tmpObjects[tmpCenterPId];
7548
7739
  const tmpCircle = state.tmpObjects[tmpCircleId];
7549
7740
  return {
7550
- tmpObjects: _objectSpread$9(_objectSpread$9({}, state.tmpObjects), {}, {
7551
- [tmpCircleId]: _objectSpread$9(_objectSpread$9({}, tmpCircle), {}, {
7741
+ tmpObjects: _objectSpread$a(_objectSpread$a({}, state.tmpObjects), {}, {
7742
+ [tmpCircleId]: _objectSpread$a(_objectSpread$a({}, tmpCircle), {}, {
7552
7743
  radius: Math.max(tmpCenterP.position.distanceTo(localPos), 0.001)
7553
7744
  })
7554
7745
  })
@@ -8046,9 +8237,9 @@ function recognizeFilletByArc(object, tree, sketchId) {
8046
8237
  };
8047
8238
  }
8048
8239
 
8049
- function ownKeys$8(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
8240
+ function ownKeys$9(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
8050
8241
 
8051
- function _objectSpread$8(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$8(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$8(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
8242
+ function _objectSpread$9(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$9(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$9(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
8052
8243
  function Fillet(drawingId, pluginId) {
8053
8244
  const actions = core.getDrawing(drawingId).api;
8054
8245
  const plugin = core.getPlugin(drawingId, pluginId);
@@ -8197,7 +8388,7 @@ function Fillet(drawingId, pluginId) {
8197
8388
  return;
8198
8389
  }
8199
8390
 
8200
- classcad.ccAPI.sketcher.createFillet(drawingId, sketchId, data.info.lines.map(line => line.id), data.info.lineStarts.map(lineStart => lineStart.id), data.info.incidence, data.info.control, data.params.start, getArcAngles(_objectSpread$8(_objectSpread$8({}, data.params), {}, {
8391
+ classcad.ccAPI.sketcher.createFillet(drawingId, sketchId, data.info.lines.map(line => line.id), data.info.lineStarts.map(lineStart => lineStart.id), data.info.incidence, data.info.control, data.params.start, getArcAngles(_objectSpread$9(_objectSpread$9({}, data.params), {}, {
8201
8392
  radius: 1
8202
8393
  })).mid, data.params.end);
8203
8394
  set({
@@ -8293,6 +8484,32 @@ function Trim(drawingId, pluginId) {
8293
8484
  };
8294
8485
  }
8295
8486
 
8487
+ function UseRef(drawingId, pluginId) {
8488
+ // UseRef shouldn't work with any of sketch objects
8489
+ const filter = object => false;
8490
+
8491
+ const filterSel = (scope, data) => lineSegmentsFilter(scope, data) || loopFilter(scope, data) || pointFilter(scope, data);
8492
+
8493
+ let remove = undefined;
8494
+
8495
+ const constructor = () => {
8496
+ const selApi = core.getDrawing(drawingId).api.selection;
8497
+ remove = selApi.createSelector('UseRef', filterSel, true);
8498
+ };
8499
+
8500
+ const destructor = () => {
8501
+ remove && remove();
8502
+ };
8503
+
8504
+ return {
8505
+ name: HandlersList.USEREF,
8506
+ filter,
8507
+ onConstruct: constructor,
8508
+ onDestruct: destructor,
8509
+ pointerHandlers: {}
8510
+ };
8511
+ }
8512
+
8296
8513
  const Handlers$1 = {
8297
8514
  [HandlersList.CREATEANGLE]: CreateAngle,
8298
8515
  [HandlersList.DRAG]: Drag,
@@ -8302,6 +8519,7 @@ const Handlers$1 = {
8302
8519
  [HandlersList.DRAWRECTANGLE]: DrawRectangle,
8303
8520
  [HandlersList.FILLET]: Fillet,
8304
8521
  [HandlersList.TRIM]: Trim,
8522
+ [HandlersList.USEREF]: UseRef,
8305
8523
  [HandlersList.DRAWARCCENTER]: (drawingId, pluginId) => DrawArc(drawingId, pluginId, HandlersList.DRAWARCCENTER),
8306
8524
  [HandlersList.DRAWARCMIDDLE]: (drawingId, pluginId) => DrawArc(drawingId, pluginId, HandlersList.DRAWARCMIDDLE),
8307
8525
  [HandlersList.DRAWARCTANGENT]: (drawingId, pluginId) => DrawArc(drawingId, pluginId, HandlersList.DRAWARCTANGENT)
@@ -8762,10 +8980,10 @@ const resources = {
8762
8980
  [HandlersList.DRAWCIRCLE]: img$y,
8763
8981
  [HandlersList.FILLET]: img$x,
8764
8982
  [HandlersList.TRIM]: img$w,
8983
+ [HandlersList.USEREF]: img$s,
8765
8984
  [Patterns.RECTANGULAR]: img$v,
8766
8985
  [Patterns.CIRCULAR]: img$u,
8767
- [Patterns.MIRROR]: img$t,
8768
- ['useRef']: img$s
8986
+ [Patterns.MIRROR]: img$t
8769
8987
  };
8770
8988
  const textures = {};
8771
8989
  const textureLoader = new THREE__namespace.TextureLoader();
@@ -8853,11 +9071,14 @@ const useGeomParams = objId => {
8853
9071
 
8854
9072
  if (isHovered || isSelected || isHighlighted) {
8855
9073
  renderOrder_ += 1;
8856
- }
9074
+ } // TODO: returning isHovered and isSelected is a workaround for changing scale of the hovered point. (return scale coef instead?)
9075
+
8857
9076
 
8858
9077
  return {
8859
9078
  renderOrder: renderOrder_,
8860
- polygonOffsetUnits: offsetUnits
9079
+ polygonOffsetUnits: offsetUnits,
9080
+ isHovered,
9081
+ isSelected
8861
9082
  };
8862
9083
  };
8863
9084
 
@@ -9012,6 +9233,17 @@ const useUserData = objId => {
9012
9233
  return React.useMemo(() => ({
9013
9234
  objId
9014
9235
  }), [objId]);
9236
+ }; // Fix for interaction until drei support undefined as pointer handlers
9237
+
9238
+ const defaultHandlers = {
9239
+ onPointerOver: () => null,
9240
+ // onPointerEnter: () => null,
9241
+ onPointerDown: () => null,
9242
+ onPointerMove: () => null,
9243
+ onPointerUp: () => null,
9244
+ onPointerCancel: () => null,
9245
+ onPointerOut: () => null // onPointerLeave: () => null,
9246
+
9015
9247
  };
9016
9248
  const useHandlersAndColor = (drawingId, objId) => {
9017
9249
  const activeSelection = react.useDrawing(drawingId, d => d.selection.active);
@@ -9020,7 +9252,7 @@ const useHandlersAndColor = (drawingId, objId) => {
9020
9252
  const handlers = activeSelection ? globalSelection.handlers : sketchHandlers;
9021
9253
  const color = useColor(objId, globalSelection.isHovered);
9022
9254
  return React.useMemo(() => ({
9023
- handlers,
9255
+ handlers: handlers || defaultHandlers,
9024
9256
  color
9025
9257
  }), [handlers, color]);
9026
9258
  };
@@ -9236,9 +9468,190 @@ class InfinityPlane extends THREE__namespace.Object3D {
9236
9468
 
9237
9469
  }
9238
9470
 
9239
- function ownKeys$7(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
9471
+ // InstancedMesh from three.js use the single mesh but applies different transformations to different instances of the mesh
9472
+ // which allows to render multiple objects in the same render call, so we have separate render call for each mesh
9473
+ // (in our case there're 2 render calls: one for Boxes and another for Spheres).
9240
9474
 
9241
- function _objectSpread$7(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$7(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$7(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
9475
+ const material = new THREE__namespace.MeshBasicMaterial();
9476
+ const tubeSegments = 6;
9477
+ const cylGeom = new THREE__namespace.CylinderGeometry(1, 1, 1, tubeSegments);
9478
+ const cylMesh = new THREE__namespace.Mesh(cylGeom, material);
9479
+ const widthSegments = 12;
9480
+ const heightSegments = 12;
9481
+ const sphereGeom = new THREE__namespace.SphereGeometry(1, widthSegments, heightSegments);
9482
+ const sphereMesh = new THREE__namespace.Mesh(sphereGeom, material); // We use context to store "mocked" objects.
9483
+
9484
+ const MeshContext = /*#__PURE__*/React.createContext({
9485
+ Cylinder: null,
9486
+ Sphere: null
9487
+ });
9488
+
9489
+ const ContextWrapper = ({
9490
+ cylinder,
9491
+ sphere,
9492
+ children
9493
+ }) => {
9494
+ const contextVal = React.useMemo(() => {
9495
+ return {
9496
+ Cylinder: cylinder,
9497
+ Sphere: sphere
9498
+ };
9499
+ }, [cylinder, sphere]);
9500
+ return /*#__PURE__*/React.createElement(MeshContext.Provider, {
9501
+ value: contextVal
9502
+ }, children);
9503
+ };
9504
+ /**
9505
+ * Component which implements InstancedMesh from three.js.
9506
+ * Merged component from drei takes globaly created meshes and then passes corresponding "mocked" components via function props (Box and Sphere) to children.
9507
+ * "mocked" components are used for saying drei where to draw instances.
9508
+ */
9509
+
9510
+
9511
+ const MergedWrapper = ({
9512
+ children
9513
+ }) => {
9514
+ return (
9515
+ /*#__PURE__*/
9516
+ // Default raycast of merged should be turned off, because custom raycast is used in primitivesMerged
9517
+ React.createElement(drei.Merged, {
9518
+ meshes: [cylMesh, sphereMesh],
9519
+ limit: 10000,
9520
+ raycast: null
9521
+ }, (Cylinder, Sphere) => /*#__PURE__*/React.createElement(ContextWrapper, {
9522
+ cylinder: Cylinder,
9523
+ sphere: Sphere
9524
+ }, children))
9525
+ );
9526
+ };
9527
+
9528
+ const lineStart = new THREE__namespace.Vector3();
9529
+ const lineEnd = new THREE__namespace.Vector3();
9530
+ const pointOnRay = new THREE__namespace.Vector3();
9531
+ const lineCoef = 1.2;
9532
+
9533
+ function getParentSketch(child) {
9534
+ const parent = child.parent;
9535
+ if (!parent) return null;
9536
+ if (parent.name === 'sketch') return parent;
9537
+ return getParentSketch(parent);
9538
+ }
9539
+
9540
+ const Line = ({
9541
+ start,
9542
+ end,
9543
+ width = lineWidth,
9544
+ materialProps,
9545
+ meshProps,
9546
+ notInteractive,
9547
+ scalePlus
9548
+ }) => {
9549
+ const {
9550
+ position,
9551
+ quaternion
9552
+ } = React.useMemo(() => {
9553
+ const dir = end.clone().sub(start).normalize();
9554
+ return {
9555
+ position: new THREE__namespace.Vector3().lerpVectors(start, end, 0.5),
9556
+ quaternion: new THREE__namespace.Quaternion().setFromUnitVectors(new THREE__namespace.Vector3(0, 1, 0), dir)
9557
+ };
9558
+ }, [start, end]); // TODO: make lineRaycast global function
9559
+
9560
+ const lineRaycast = React.useCallback(function (raycaster, intersects) {
9561
+ const sketchGroup = getParentSketch(this);
9562
+
9563
+ if (sketchGroup === null || (sketchGroup == null ? void 0 : sketchGroup.name) !== 'sketch') {
9564
+ console.warn('Line is not a child of sketch group');
9565
+ return;
9566
+ }
9567
+
9568
+ lineStart.copy(start);
9569
+ lineEnd.copy(end);
9570
+ lineStart.applyMatrix4(sketchGroup.matrixWorld);
9571
+ lineEnd.applyMatrix4(sketchGroup.matrixWorld);
9572
+ const dist = Math.sqrt(raycaster.ray.distanceSqToSegment(lineStart, lineEnd, pointOnRay));
9573
+ const sketchScale = getScale();
9574
+
9575
+ if (dist < lineCoef * sketchScale) {
9576
+ intersects.push({
9577
+ distance: dist,
9578
+ point: pointOnRay,
9579
+ face: null,
9580
+ object: this
9581
+ });
9582
+ }
9583
+ }, [start, end]);
9584
+ const {
9585
+ Cylinder
9586
+ } = React.useContext(MeshContext);
9587
+ const ref = useScale(scale => {
9588
+ const scale_ = scalePlus ? scale + 0.01 : scale;
9589
+ return [width * scale_, start.distanceTo(end), width * scale_];
9590
+ }); // We need initial scale to remove flickering of recently created objects
9591
+
9592
+ const initialScale = React.useMemo(() => {
9593
+ const scale = getScale();
9594
+ return [width * scale, start.distanceTo(end), width * scale]; // eslint-disable-next-line react-hooks/exhaustive-deps
9595
+ }, []);
9596
+ return /*#__PURE__*/React.createElement(Cylinder, _extends({
9597
+ ref: ref,
9598
+ scale: initialScale
9599
+ }, materialProps, meshProps, {
9600
+ position: position,
9601
+ quaternion: quaternion,
9602
+ raycast: notInteractive ? null : lineRaycast
9603
+ }));
9604
+ };
9605
+
9606
+ const pointPos = new THREE__namespace.Vector3();
9607
+ const pointCoef = 1.3; // Coefficient for increased interaction area
9608
+
9609
+ function pointRaycast(raycaster, intersects) {
9610
+ this.getWorldPosition(pointPos);
9611
+ const dist = raycaster.ray.distanceToPoint(pointPos);
9612
+ const sketchScale = getScale();
9613
+
9614
+ if (dist < pointCoef * sketchScale) {
9615
+ intersects.push({
9616
+ distance: dist,
9617
+ point: pointPos.clone(),
9618
+ face: null,
9619
+ object: this
9620
+ });
9621
+ }
9622
+ }
9623
+
9624
+ const Point = ({
9625
+ position,
9626
+ size = pointSize,
9627
+ materialProps,
9628
+ meshProps,
9629
+ scalePlus
9630
+ }) => {
9631
+ const {
9632
+ Sphere
9633
+ } = React.useContext(MeshContext);
9634
+ const ref = useScale(scale => {
9635
+ const scale_ = scalePlus ? scale + 0.01 : scale;
9636
+ return [size * scale_, size * scale_, size * scale_];
9637
+ }); // We need initial scale to remove flickering of recently created objects
9638
+
9639
+ const initialScale = React.useMemo(() => {
9640
+ const scale = getScale();
9641
+ return [size * scale, size * scale, size * scale]; // eslint-disable-next-line react-hooks/exhaustive-deps
9642
+ }, []);
9643
+ return /*#__PURE__*/React.createElement(Sphere, _extends({
9644
+ scale: initialScale
9645
+ }, materialProps, meshProps, {
9646
+ position: position,
9647
+ ref: ref,
9648
+ raycast: pointRaycast
9649
+ }));
9650
+ };
9651
+
9652
+ function ownKeys$8(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
9653
+
9654
+ function _objectSpread$8(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$8(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$8(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
9242
9655
  /*
9243
9656
  * !polygonOffset!
9244
9657
  * For correct drawing of objects that lie in the same plane, polygonOffset is used.
@@ -9246,9 +9659,9 @@ function _objectSpread$7(target) { for (var i = 1; i < arguments.length; i++) {
9246
9659
  * offset = factor * DZ + r * units
9247
9660
  * Where DZ is a measurement of the change in depth relative to the screen area of the polygon,
9248
9661
  * and r is an implementation-specific value to create a constant depth offset.
9249
- .
9250
9662
  * The offset is added before the depth test is performed and before the value is written into the depth buffer.
9251
- * factor parameter is redundant for this purpose, so only units parameter is used.
9663
+ *
9664
+ * Factor parameter is redundant for this purpose, so only units parameter is used.
9252
9665
  */
9253
9666
 
9254
9667
  fiber.extend({
@@ -9258,8 +9671,7 @@ const hoverZone = 0.6;
9258
9671
 
9259
9672
  const CCLine = props => {
9260
9673
  const {
9261
- drawingId,
9262
- pluginId
9674
+ drawingId
9263
9675
  } = React.useContext(ViewContext);
9264
9676
  const {
9265
9677
  objId
@@ -9268,8 +9680,7 @@ const CCLine = props => {
9268
9680
  const {
9269
9681
  handlers,
9270
9682
  color
9271
- } = useHandlersAndColor(drawingId, objId);
9272
- const scale = useSketchState(drawingId, pluginId, state => state.scale); // TODO: put useUserData into useHandlersAndColor ?
9683
+ } = useHandlersAndColor(drawingId, objId); // TODO: put useUserData into useHandlersAndColor ?
9273
9684
 
9274
9685
  const userData = useUserData(objId);
9275
9686
  const point1 = react.useDrawing(drawingId, drawing => drawing.structure.tree[line.children[0]]);
@@ -9278,34 +9689,24 @@ const CCLine = props => {
9278
9689
  const end = convertToVector(point2.members.pos);
9279
9690
  const {
9280
9691
  renderOrder,
9281
- polygonOffsetUnits
9692
+ polygonOffsetUnits,
9693
+ isHovered,
9694
+ isSelected
9282
9695
  } = useGeomParams(objId);
9283
9696
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Line, {
9284
9697
  start: start,
9285
9698
  end: end,
9286
- scale: scale,
9287
- meshProps: {
9288
- renderOrder
9289
- },
9290
- materialProps: {
9291
- side: THREE__namespace.DoubleSide,
9292
- polygonOffset: true,
9293
- polygonOffsetUnits: polygonOffsetUnits,
9294
- color
9295
- }
9296
- }), /*#__PURE__*/React.createElement(Line, {
9297
- start: start,
9298
- end: end,
9299
- scale: scale,
9300
- width: lineWidth + hoverZone,
9301
- meshProps: _objectSpread$7(_objectSpread$7({
9699
+ scalePlus: isHovered || isSelected,
9700
+ meshProps: _objectSpread$8(_objectSpread$8({
9302
9701
  renderOrder
9303
9702
  }, handlers), {}, {
9304
9703
  userData
9305
9704
  }),
9306
9705
  materialProps: {
9307
- transparent: true,
9308
- opacity: 0
9706
+ side: THREE__namespace.DoubleSide,
9707
+ polygonOffset: true,
9708
+ polygonOffsetUnits: polygonOffsetUnits,
9709
+ color: numberToHexColor(color)
9309
9710
  }
9310
9711
  }), /*#__PURE__*/React.createElement(CCPoint, {
9311
9712
  key: point1.id,
@@ -9318,8 +9719,7 @@ const CCLine = props => {
9318
9719
 
9319
9720
  const CCPoint = props => {
9320
9721
  const {
9321
- drawingId,
9322
- pluginId
9722
+ drawingId
9323
9723
  } = React.useContext(ViewContext);
9324
9724
  const {
9325
9725
  objId
@@ -9332,40 +9732,33 @@ const CCPoint = props => {
9332
9732
  const userData = useUserData(objId);
9333
9733
  const {
9334
9734
  renderOrder,
9335
- polygonOffsetUnits
9735
+ polygonOffsetUnits,
9736
+ isHovered,
9737
+ isSelected
9336
9738
  } = useGeomParams(objId);
9337
9739
  const position = convertToVector(point.members.pos);
9338
- const scale = useSketchState(drawingId, pluginId, state => state.scale);
9339
9740
  React.useEffect(() => {
9340
9741
  setSnapToPoint(objId, new THREE__namespace.Vector3(position.x, position.y, position.z));
9341
9742
  return () => deleteSnapToPoint(objId);
9342
9743
  }, [objId, position.x, position.y, position.z]);
9343
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Point, {
9344
- position: position,
9345
- scale: scale,
9346
- meshProps: {
9744
+ return /*#__PURE__*/React.createElement(Point, {
9745
+ position: position // It's not possible to change polygonOffset in drei/Merged component,
9746
+ // so we have to increase size of hovered or selected point to make the point not occluded buy other ones
9747
+ ,
9748
+ scalePlus: isHovered || isSelected,
9749
+ meshProps: _objectSpread$8(_objectSpread$8({
9347
9750
  renderOrder
9348
- },
9751
+ }, handlers), {}, {
9752
+ userData
9753
+ }),
9349
9754
  materialProps: {
9350
9755
  side: THREE__namespace.DoubleSide,
9351
9756
  polygonOffset: true,
9352
9757
  polygonOffsetUnits: polygonOffsetUnits,
9353
9758
  // Put hovered point upper then not hovered (check comment in the beginnig of this file about polygonOffset).
9354
- color: color
9759
+ color: numberToHexColor(color)
9355
9760
  }
9356
- }), /*#__PURE__*/React.createElement(Point, {
9357
- position: position,
9358
- scale: scale,
9359
- size: pointSize + hoverZone,
9360
- meshProps: _objectSpread$7({
9361
- userData,
9362
- renderOrder
9363
- }, handlers),
9364
- materialProps: {
9365
- transparent: true,
9366
- opacity: 0
9367
- }
9368
- }));
9761
+ });
9369
9762
  };
9370
9763
 
9371
9764
  const CCArc = props => {
@@ -9390,7 +9783,6 @@ const CCArc = props => {
9390
9783
  const point = [p1, p2, p3].find(p => p.name === pointName);
9391
9784
  return convertToVector(point.members.pos);
9392
9785
  }, [p1, p2, p3]);
9393
- const scale = useSketchState(drawingId, pluginId, state => state.scale);
9394
9786
  const startPoint = React.useMemo(() => getArcPointPos('startPoint'), [getArcPointPos]);
9395
9787
  const endPoint = React.useMemo(() => getArcPointPos('endPoint'), [getArcPointPos]);
9396
9788
  const centerPoint = React.useMemo(() => getArcPointPos('center'), [getArcPointPos]);
@@ -9399,36 +9791,23 @@ const CCArc = props => {
9399
9791
  renderOrder,
9400
9792
  polygonOffsetUnits
9401
9793
  } = useGeomParams(objId);
9794
+ const scale = useSketchState(drawingId, pluginId, state => state.scale);
9402
9795
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Arc, {
9403
9796
  start: startPoint,
9404
9797
  end: endPoint,
9405
9798
  center: centerPoint,
9406
- scale: scale,
9407
9799
  clockwise: clockwise,
9408
- meshProps: {
9409
- renderOrder
9410
- },
9800
+ meshProps: _objectSpread$8({
9801
+ renderOrder,
9802
+ userData
9803
+ }, handlers),
9411
9804
  materialProps: {
9412
9805
  side: THREE__namespace.DoubleSide,
9413
9806
  polygonOffset: true,
9414
9807
  polygonOffsetUnits: polygonOffsetUnits,
9415
9808
  color: color
9416
- }
9417
- }), /*#__PURE__*/React.createElement(Arc, {
9418
- start: startPoint,
9419
- end: endPoint,
9420
- center: centerPoint,
9421
- scale: scale,
9422
- clockwise: clockwise,
9423
- width: arcWidth + hoverZone,
9424
- meshProps: _objectSpread$7({
9425
- renderOrder,
9426
- userData
9427
- }, handlers),
9428
- materialProps: {
9429
- transparent: true,
9430
- opacity: 0
9431
- }
9809
+ },
9810
+ scale: scale
9432
9811
  }), arc.children.map(childId => /*#__PURE__*/React.createElement(CCPoint, {
9433
9812
  key: childId,
9434
9813
  objId: childId
@@ -9475,7 +9854,7 @@ const CCCircle = props => {
9475
9854
  radius: radius,
9476
9855
  scale: scale,
9477
9856
  width: arcWidth + hoverZone,
9478
- meshProps: _objectSpread$7(_objectSpread$7({}, handlers), {}, {
9857
+ meshProps: _objectSpread$8(_objectSpread$8({}, handlers), {}, {
9479
9858
  renderOrder,
9480
9859
  userData
9481
9860
  }),
@@ -9554,7 +9933,7 @@ const SketchPlane = ({
9554
9933
  objId
9555
9934
  }
9556
9935
  })), /*#__PURE__*/React.createElement("gridHelper", {
9557
- args: [step * linesCount, linesCount, 0x000000, 0x333333],
9936
+ args: [step * linesCount, linesCount, 0x000000, 0x888888],
9558
9937
  quaternion: planeQuaternion,
9559
9938
  onUpdate: update
9560
9939
  }));
@@ -9629,10 +10008,11 @@ const Sketch = ({
9629
10008
  drawnObjectsRef
9630
10009
  });
9631
10010
  }, [set]);
9632
- return /*#__PURE__*/React.createElement("group", null, isActive && /*#__PURE__*/React.createElement(SketchPlane, {
10011
+ return /*#__PURE__*/React.createElement(MergedWrapper, null, isActive && /*#__PURE__*/React.createElement(SketchPlane, {
9633
10012
  objId: objId
9634
10013
  }), drawnObjects && /*#__PURE__*/React.createElement("group", {
9635
- ref: drawnObjectsRef
10014
+ ref: drawnObjectsRef,
10015
+ name: "sketch"
9636
10016
  }, drawnObjects, isActive && containerIds && containerIds.length === 0 && /*#__PURE__*/React.createElement(Constraints$2, {
9637
10017
  sketchId: objId
9638
10018
  })));
@@ -9667,10 +10047,8 @@ const TmpPoint = props => {
9667
10047
  } = React.useContext(ViewContext);
9668
10048
  const point = useSketchState(drawingId, pluginId, state => state.tmpObjects[props.objId]);
9669
10049
  const color = getColor$1(point.class);
9670
- const scale = useSketchState(drawingId, pluginId, state => state.scale);
9671
- return /*#__PURE__*/React.createElement(Point, {
10050
+ return /*#__PURE__*/React.createElement(Point$1, {
9672
10051
  position: point.position,
9673
- scale: scale,
9674
10052
  materialProps: {
9675
10053
  side: THREE__namespace.DoubleSide,
9676
10054
  polygonOffset: true,
@@ -9687,13 +10065,11 @@ const TmpLine = props => {
9687
10065
  } = React.useContext(ViewContext);
9688
10066
  const line = useSketchState(drawingId, pluginId, state => state.tmpObjects[props.objId]);
9689
10067
  const color = getColor$1(line.class);
9690
- const scale = useSketchState(drawingId, pluginId, state => state.scale);
9691
10068
  const start = useSketchState(drawingId, pluginId, state => state.tmpObjects[line.startPId]).position;
9692
10069
  const end = useSketchState(drawingId, pluginId, state => state.tmpObjects[line.endPId]).position;
9693
- return /*#__PURE__*/React.createElement(Line, {
10070
+ return /*#__PURE__*/React.createElement(Line$1, {
9694
10071
  start: start,
9695
10072
  end: end,
9696
- scale: scale,
9697
10073
  materialProps: {
9698
10074
  color
9699
10075
  }
@@ -9714,10 +10090,9 @@ const TmpArc = props => {
9714
10090
  const end = useSketchState(drawingId, pluginId, state => state.tmpObjects[arc.endPId]).position;
9715
10091
 
9716
10092
  if (arc.drawAsLine) {
9717
- return /*#__PURE__*/React.createElement(Line, {
10093
+ return /*#__PURE__*/React.createElement(Line$1, {
9718
10094
  start: start,
9719
10095
  end: end,
9720
- scale: scale,
9721
10096
  materialProps: {
9722
10097
  color: getColor$1(classcad.CCClasses.CCLine)
9723
10098
  }
@@ -9886,6 +10261,7 @@ const RubberBandRectangle = () => {
9886
10261
  function useSetScale(drawingId, pluginId) {
9887
10262
  fiber.useFrame(args => {
9888
10263
  const plugin = core.getPlugin(drawingId, pluginId);
10264
+ if (!plugin) return;
9889
10265
  const state = plugin.state;
9890
10266
  const sketchObj = core.getDrawing(drawingId).structure.tree[plugin.objectId];
9891
10267
  const sketchMatrix = core.MathUtils.convertToMatrix4(sketchObj.coordinateSystem);
@@ -9899,7 +10275,9 @@ function useSetScale(drawingId, pluginId) {
9899
10275
  plugin.set({
9900
10276
  step: newStep,
9901
10277
  scale: newScale
9902
- });
10278
+ }); // Old way to set scale, needed for circles. (Should be remove when circles will be implemented via Merged component)
10279
+
10280
+ setScale(newScale); // More efficient way to set scale, used buy lines and points.
9903
10281
  }
9904
10282
  });
9905
10283
  } // Turn off all handlers and hide sketch selection if global selection is active
@@ -9914,7 +10292,7 @@ function useHandleGSelection(drawingId, pluginId, activeHandler) {
9914
10292
  const prevSelected = React.useRef([]);
9915
10293
  React.useEffect(() => {
9916
10294
  // Disable all handlers if global selection is active
9917
- if (activeSelection && !prevHandler.current) {
10295
+ if (activeSelection && activeSelection !== 'UseRef' && !prevHandler.current) {
9918
10296
  prevHandler.current = activeHandler;
9919
10297
  prevSelected.current = getSketchState(drawingId, pluginId).selected;
9920
10298
  set({
@@ -9929,6 +10307,23 @@ function useHandleGSelection(drawingId, pluginId, activeHandler) {
9929
10307
  prevHandler.current = undefined;
9930
10308
  }
9931
10309
  }, [drawingId, pluginId, activeSelection, activeHandler, set]);
10310
+ } // Creates reference geometry in the sketch for all the graphic objects appearing in the 'UseRef' selection; the selection is reset after each triggering
10311
+
10312
+
10313
+ function useUseRef(drawingId, sketchId) {
10314
+ const itemsUseRef = react.useDrawing(drawingId, d => {
10315
+ var _d$selection$refs$Use;
10316
+
10317
+ return (_d$selection$refs$Use = d.selection.refs['UseRef']) == null ? void 0 : _d$selection$refs$Use.items;
10318
+ });
10319
+ React.useEffect(() => {
10320
+ if (itemsUseRef && itemsUseRef.length > 0) {
10321
+ const selApi = core.getDrawing(drawingId).api.selection;
10322
+ selApi.setItems('UseRef', []);
10323
+ const ids = itemsUseRef.map(item => item.data.graphicId);
10324
+ classcad.ccAPI.sketcher.createReferenceGeometry(drawingId, sketchId, ids);
10325
+ }
10326
+ }, [drawingId, sketchId, itemsUseRef]);
9932
10327
  }
9933
10328
 
9934
10329
  const getSketchBounds = boundsMember => {
@@ -10023,10 +10418,13 @@ const DrawingMode = ({
10023
10418
  set({
10024
10419
  activeHandler: HandlersList.DRAG
10025
10420
  });
10026
- return () => set({
10027
- activeHandler: undefined
10028
- });
10029
- }, [set]);
10421
+ return () => {
10422
+ const plugin = core.getPlugin(drawingId, pluginId);
10423
+ plugin && plugin.set({
10424
+ activeHandler: undefined
10425
+ });
10426
+ };
10427
+ }, [drawingId, pluginId, set]);
10030
10428
  useSetScale(drawingId, pluginId);
10031
10429
  const activeHandler = useSketchState(drawingId, pluginId, state => state.activeHandler);
10032
10430
  const currentHandler = React.useRef();
@@ -10047,6 +10445,7 @@ const DrawingMode = ({
10047
10445
  currentHandler.current = activeHandler;
10048
10446
  }, [drawingId, pluginId, activeHandler]);
10049
10447
  useHandleGSelection(drawingId, pluginId, activeHandler);
10448
+ useUseRef(drawingId, sketchId);
10050
10449
  const dimId = useDimensionSetId(drawingId, sketchId);
10051
10450
  const [, dimView] = react.useEmbeddedPlugin(Plugin, drawingId, pluginId, dimId, setDimId); // SketcherDimensionSet has it's own cSys that will be applied in Plugin.tsx, so apply inverse Sketch cSys.
10052
10451
  // TODO: remove it when parent plugin matrix won't be applied for embedded one.
@@ -10093,7 +10492,11 @@ const ViewImpl$d = ({
10093
10492
  drawingId,
10094
10493
  pluginId,
10095
10494
  isActive
10096
- }), [drawingId, pluginId, isActive]);
10495
+ }), [drawingId, pluginId, isActive]); // Reset scale on unmount
10496
+
10497
+ React.useEffect(() => {
10498
+ return () => setScale(1);
10499
+ }, []);
10097
10500
 
10098
10501
  if (planeSelection) {
10099
10502
  return null;
@@ -10123,40 +10526,6 @@ const View$d = ({
10123
10526
  }));
10124
10527
  };
10125
10528
 
10126
- const UseRef = () => {
10127
- const {
10128
- Group,
10129
- Label,
10130
- Selection,
10131
- Button
10132
- } = react.useBuerli(buerli => buerli.options.elements);
10133
- const {
10134
- drawingId,
10135
- pluginId
10136
- } = React.useContext(RootContext);
10137
- const sketchId = react.usePlugin(drawingId, pluginId, plugin => plugin.objectId);
10138
- const [selId, setSelId] = React.useState();
10139
- const createUseRef = React.useCallback(() => {
10140
- if (!selId) return;
10141
- const items = core.getDrawing(drawingId).selection.refs[selId].items;
10142
- const selApi = core.getDrawing(drawingId).api.selection;
10143
- selApi.setItems(selId, []);
10144
- selApi.activateSelector(null);
10145
- if (items.length === 0) return;
10146
- const ids = items.map(item => item.data.graphicId);
10147
- classcad.ccAPI.sketcher.createReferenceGeometry(drawingId, sketchId, ids);
10148
- }, [selId, drawingId, sketchId]);
10149
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Group, null, /*#__PURE__*/React.createElement(Label, null, "Create UseRef"), /*#__PURE__*/React.createElement(Selection, {
10150
- key: "useRefSelection",
10151
- drawingId: drawingId,
10152
- onCreated: setSelId,
10153
- filter: (scope, data) => lineSegmentsFilter(scope, data) || loopFilter(scope, data) || pointFilter(scope, data),
10154
- caption: "Select geometry..."
10155
- })), /*#__PURE__*/React.createElement(Button, {
10156
- onClick: createUseRef
10157
- }, "Create"));
10158
- };
10159
-
10160
10529
  const constraintClasses = {
10161
10530
  fixation: classcad.CCClasses.CC2DFixationConstraint,
10162
10531
  horizontality: classcad.CCClasses.CC2DHorizontalConstraint,
@@ -10182,8 +10551,7 @@ const constraintClasses = {
10182
10551
  };
10183
10552
  const Constraints$1 = () => {
10184
10553
  const {
10185
- Button,
10186
- ButtonGroup
10554
+ Button
10187
10555
  } = react.useBuerli(buerli => buerli.options.elements);
10188
10556
  const {
10189
10557
  drawingId,
@@ -10220,7 +10588,12 @@ const Constraints$1 = () => {
10220
10588
  }
10221
10589
  }
10222
10590
  }, [drawingId, set, selected, sketchId]);
10223
- return allowedConstraints && allowedConstraints.length > 0 ? /*#__PURE__*/React.createElement(ButtonGroup, null, allowedConstraints.map(constraintName => /*#__PURE__*/React.createElement(Button, {
10591
+ return allowedConstraints && allowedConstraints.length > 0 ? /*#__PURE__*/React.createElement(AntdButton.Group, {
10592
+ style: {
10593
+ flexWrap: 'wrap',
10594
+ height: 'unset !important'
10595
+ }
10596
+ }, allowedConstraints.map(constraintName => /*#__PURE__*/React.createElement(Button, {
10224
10597
  key: constraintName,
10225
10598
  titleText: constraintName,
10226
10599
  size: 'small',
@@ -10257,7 +10630,8 @@ const HButton = _ref => {
10257
10630
  } = React.useContext(RootContext);
10258
10631
  const set = core.getPlugin(drawingId, pluginId).set;
10259
10632
  const activeHandler = useSketchState(drawingId, pluginId, state => state.activeHandler);
10260
- const isSelectorActive = react.useDrawing(drawingId, drawing => drawing.selection.active) !== null;
10633
+ const activeSelector = react.useDrawing(drawingId, drawing => drawing.selection.active);
10634
+ const disabled = Boolean(activeSelector) && activeSelector !== 'UseRef';
10261
10635
  const isActive = activeHandler === handlerName;
10262
10636
  return /*#__PURE__*/React.createElement(Tooltip, {
10263
10637
  style: {
@@ -10270,7 +10644,7 @@ const HButton = _ref => {
10270
10644
  key: handlerName,
10271
10645
  value: handlerName,
10272
10646
  checked: isActive,
10273
- disabled: isSelectorActive,
10647
+ disabled: disabled,
10274
10648
  onClick: () => {
10275
10649
  if (isActive) {
10276
10650
  set({
@@ -10308,6 +10682,7 @@ const SubGroup$1 = ({
10308
10682
  } = react.useBuerli(buerli => buerli.options.elements);
10309
10683
  const [lastHandler, setLastHandler] = React.useState(handlers[0]);
10310
10684
  const menu = /*#__PURE__*/React.createElement(Menu, null, /*#__PURE__*/React.createElement(MenuItem, {
10685
+ key: "menuItem",
10311
10686
  style: {
10312
10687
  backgroundColor: 'initial',
10313
10688
  padding: '0px 5px',
@@ -10347,6 +10722,8 @@ const Handlers = () => {
10347
10722
  handlerName: HandlersList.FILLET
10348
10723
  }), /*#__PURE__*/React.createElement(HButton, {
10349
10724
  handlerName: HandlersList.TRIM
10725
+ }), /*#__PURE__*/React.createElement(HButton, {
10726
+ handlerName: HandlersList.USEREF
10350
10727
  }));
10351
10728
  };
10352
10729
 
@@ -10544,110 +10921,489 @@ const useRollbackBar = (drawingId, partId) => {
10544
10921
  }, [drawingId, opSeqId, opSeqChildren]);
10545
10922
  };
10546
10923
 
10547
- const PlaneSelectionMode = ({
10924
+ const _excluded$3 = ["items", "children"];
10925
+ const Menu = _ref => {
10926
+ let {
10927
+ items,
10928
+ children
10929
+ } = _ref,
10930
+ props = _objectWithoutProperties(_ref, _excluded$3);
10931
+
10932
+ const onItemClick = React.useCallback(e => {
10933
+ e.domEvent.stopPropagation();
10934
+ let item = items[e.keyPath.pop()];
10935
+
10936
+ if (item.children) {
10937
+ item = item.children[e.keyPath.pop()];
10938
+ }
10939
+ item.callback(e.domEvent);
10940
+ }, [items]);
10941
+ const menu = /*#__PURE__*/React.createElement(antd.Menu, {
10942
+ onClick: onItemClick
10943
+ }, Object.keys(items).map(key => {
10944
+ const item = items[key];
10945
+
10946
+ if (item.children) {
10947
+ const smItem = item;
10948
+ return /*#__PURE__*/React.createElement(antd.Menu.SubMenu, {
10949
+ title: smItem.caption,
10950
+ key: key,
10951
+ icon: smItem.icon
10952
+ }, Object.keys(smItem.children).map(chKey => {
10953
+ const chItem = smItem.children[chKey];
10954
+ return /*#__PURE__*/React.createElement(antd.Menu.Item, {
10955
+ key: chKey,
10956
+ icon: chItem.icon
10957
+ }, chItem.caption);
10958
+ }));
10959
+ } else {
10960
+ const item_ = item;
10961
+ return /*#__PURE__*/React.createElement(antd.Menu.Item, {
10962
+ key: key,
10963
+ icon: item_.icon
10964
+ }, item_.caption);
10965
+ }
10966
+ }));
10967
+ return /*#__PURE__*/React.createElement(antd.Dropdown, _extends({
10968
+ overlay: menu,
10969
+ placement: "bottomCenter"
10970
+ }, props), children ? children : /*#__PURE__*/React.createElement("div", {
10971
+ style: {
10972
+ width: '24px',
10973
+ cursor: 'pointer',
10974
+ textAlign: 'center'
10975
+ },
10976
+ onClick: e => e.stopPropagation()
10977
+ }, "..."));
10978
+ };
10979
+
10980
+ const NameEdit = ({
10548
10981
  drawingId,
10549
- pluginId
10982
+ objId,
10983
+ setEditName,
10984
+ name
10550
10985
  }) => {
10551
- const {
10552
- Group,
10553
- Label,
10554
- Selection
10555
- } = react.useBuerli(buerli => buerli.options.elements);
10556
- const sketchId = react.usePlugin(drawingId, pluginId, plugin => plugin.objectId);
10557
- const curProduct = react.useDrawing(drawingId, d => d.structure.currentProduct);
10558
- const opSeqId = useOperationSequence(drawingId, curProduct) || -1;
10559
- const opSeqChildren = react.useDrawing(drawingId, d => d.structure.tree[opSeqId].children || []); // Makes base planes visible when just created, and turns them off after initialization (i.e. selecting a plane)
10986
+ const ref = React.useRef(null);
10987
+ const onEnter = React.useCallback(async e => {
10988
+ if (e.target.value !== '') {
10989
+ await classcad.ccAPI.common.setObjectName(drawingId, objId, e.target.value);
10990
+ }
10560
10991
 
10992
+ setEditName(false);
10993
+ }, [drawingId, objId, setEditName]);
10994
+ const onKeyPress = React.useCallback(e => {
10995
+ if (e.key !== 'Escape') return;
10996
+ setEditName(false);
10997
+ }, [setEditName]);
10561
10998
  React.useEffect(() => {
10562
- if (opSeqChildren.length < 7) {
10563
- // Should probably never happen, but just in case...
10564
- return;
10565
- }
10999
+ var _ref$current;
10566
11000
 
10567
- const drawing = core.getDrawing(drawingId);
10568
- const tree = drawing.structure.tree;
10569
- const pluginApi = drawing.api.plugin; // 4, 5, 6 are ids of XY-, XZ- and YZ-planes in the operation sequence array
11001
+ getCADState().api.blankDiv.show(() => setEditName(false));
11002
+ (_ref$current = ref.current) == null ? void 0 : _ref$current.focus({
11003
+ cursor: 'all'
11004
+ }); // Deactivate BlankDiv on dismount
10570
11005
 
10571
- const wpSeqIds = [4, 5, 6];
10572
- const basePlaneIds = wpSeqIds.map(index => tree[opSeqChildren[index]].members.refObj.value);
10573
- const wereInvisible = [];
10574
- basePlaneIds.forEach(id => {
10575
- if (drawing.plugin.visible.indexOf(id) === -1) {
10576
- wereInvisible.push(id);
10577
- pluginApi.setVisiblePlugin(id, true);
10578
- }
10579
- }); // Make planes invisible again
11006
+ return () => getCADState().api.blankDiv.hide();
11007
+ }, [setEditName]); // When BlankDiv is active, increase zIndex so this element would overlap it
10580
11008
 
10581
- return () => {
10582
- const planeId = core.getDrawing(drawingId).structure.tree[sketchId].members.planeReference.value;
10583
- wereInvisible.forEach(id => {
10584
- if (id !== planeId) {
10585
- pluginApi.setVisiblePlugin(id, false);
10586
- }
10587
- });
10588
- }; // Should always happen just once
10589
- // eslint-disable-next-line react-hooks/exhaustive-deps
10590
- }, []);
10591
- return /*#__PURE__*/React.createElement(Group, null, /*#__PURE__*/React.createElement(Label, null, "Select sketcher plane"), /*#__PURE__*/React.createElement(Selection, {
10592
- drawingId: drawingId,
10593
- filter: (scope, data) => {
10594
- return scope === TreeObjScope && data.object.class === classcad.CCClasses.CCWorkPlane || scope === core.BuerliScope && data === core.GraphicType.PLANE;
10595
- },
10596
- onChange: items => {
10597
- if (items.length !== 0) {
10598
- if (items[0].scope === TreeObjScope) {
10599
- classcad.ccAPI.sketcher.setWorkPlane(drawingId, sketchId, items[0].data.object.id);
10600
- } else {
10601
- classcad.ccAPI.sketcher.createAndSetWorkPlane(drawingId, sketchId, items[0].data.graphicId);
10602
- }
10603
- }
11009
+ const showBlankDiv = useCADStore(s => s.blankDiv.isActive);
11010
+ const zIndex = showBlankDiv ? blankZIndex + 1 : 0;
11011
+ return /*#__PURE__*/React.createElement(antd.Input, {
11012
+ style: {
11013
+ zIndex
10604
11014
  },
10605
- defaultActive: true
10606
- }));
11015
+ ref: ref,
11016
+ onPressEnter: onEnter,
11017
+ defaultValue: name,
11018
+ size: "small",
11019
+ onKeyDown: onKeyPress,
11020
+ onBlur: () => setEditName(false)
11021
+ });
10607
11022
  };
10608
11023
 
10609
- const MousePos = () => {
10610
- const {
10611
- Group,
10612
- Label
10613
- } = react.useBuerli(buerli => buerli.options.elements);
10614
- const {
10615
- drawingId,
10616
- pluginId
10617
- } = React.useContext(RootContext);
10618
- const pos = useSketchState(drawingId, pluginId, state => state.mousePos);
10619
- return pos ? /*#__PURE__*/React.createElement(Group, null, /*#__PURE__*/React.createElement(Label, null, "Mouse:"), /*#__PURE__*/React.createElement(Label, {
10620
- flex: "inherit"
10621
- }, "X:"), /*#__PURE__*/React.createElement(Label, null, pos.x.toFixed(2)), /*#__PURE__*/React.createElement(Label, {
10622
- flex: "inherit"
10623
- }, "Y:"), /*#__PURE__*/React.createElement(Label, null, pos.y.toFixed(2))) : null;
10624
- };
11024
+ const FlexRow = styled.div`
11025
+ display: flex;
11026
+ flex-direction: row;
11027
+ `;
11028
+ const FlexReverseRow = styled.div`
11029
+ display: flex;
11030
+ flex-direction: row-reverse;
11031
+ `;
11032
+ const Link = styled.a`
11033
+ color: #4f4f4f;
11034
+ &:hover {
11035
+ text-decoration: underline;
11036
+ text-decoration-color: #4f4f4f;
11037
+ color: #4f4f4f;
11038
+ }
11039
+ `;
11040
+ const HoveredDiv = styled.div`
11041
+ width: 100%;
11042
+ display: flex;
11043
+ justify-content: space-between;
11044
+ cursor: default;
11045
+ background-color: ${props => props.hovered ? '#f0f0f0' : undefined};
11046
+ border-bottom: ${props => props.bordered ? '1px solid #f0f0f0' : undefined};
11047
+ padding: ${props => props.bordered ? '4px 10px' : undefined};
11048
+ &:hover {
11049
+ background-color: #f0f0f0;
11050
+ }
11051
+ `;
10625
11052
 
10626
- const TabIcon = ({
10627
- url,
10628
- tooltip
11053
+ const {
11054
+ Text: Text$3
11055
+ } = antd.Typography;
11056
+ const EntityName = ({
11057
+ name,
11058
+ disabled,
11059
+ strong,
11060
+ onClick,
11061
+ onMouseEnter,
11062
+ onMouseLeave
10629
11063
  }) => {
10630
- const {
10631
- Tooltip
10632
- } = react.useBuerli(b => b.options.elements);
10633
- return /*#__PURE__*/React.createElement(Tooltip, {
10634
- title: tooltip,
10635
- placement: "top"
10636
- }, /*#__PURE__*/React.createElement("div", {
10637
- style: {
10638
- marginRight: '3px',
10639
- marginLeft: '3px'
10640
- }
10641
- }, /*#__PURE__*/React.createElement("img", {
10642
- style: {
10643
- width: 24,
10644
- height: 24
10645
- },
10646
- src: url
10647
- })));
11064
+ return /*#__PURE__*/React.createElement(Link, {
11065
+ onClick: onClick,
11066
+ onMouseEnter: onMouseEnter,
11067
+ onMouseLeave: onMouseLeave
11068
+ }, /*#__PURE__*/React.createElement(Text$3, {
11069
+ disabled: disabled,
11070
+ strong: strong
11071
+ }, name));
10648
11072
  };
10649
11073
 
10650
- const SketchMode = ({
11074
+ const Indent = () => {
11075
+ return /*#__PURE__*/React.createElement("span", {
11076
+ className: "ant-tree-indent"
11077
+ }, /*#__PURE__*/React.createElement("span", {
11078
+ className: "ant-tree-indent-unit"
11079
+ }));
11080
+ };
11081
+ const Indents = ({
11082
+ level
11083
+ }) => {
11084
+ const arr = Array.from(Array(level).keys());
11085
+ return /*#__PURE__*/React.createElement(React.Fragment, null, arr.map(i => /*#__PURE__*/React.createElement(Indent, {
11086
+ key: i
11087
+ })));
11088
+ };
11089
+ const CollapseButton = ({
11090
+ collapsed,
11091
+ onClick
11092
+ }) => {
11093
+ return /*#__PURE__*/React.createElement("span", {
11094
+ className: "ant-tree-switcher",
11095
+ onClick: onClick
11096
+ }, /*#__PURE__*/React.createElement("span", {
11097
+ role: "img",
11098
+ "aria-label": "caret-down",
11099
+ className: "anticon anticon-caret-down ant-tree-switcher-icon"
11100
+ }, collapsed ? /*#__PURE__*/React.createElement(icons.CaretRightOutlined, null) : /*#__PURE__*/React.createElement(icons.CaretDownOutlined, null)));
11101
+ };
11102
+
11103
+ function useMenuItems$4(drawingId, pluginId, objectId, setRename) {
11104
+ const {
11105
+ set,
11106
+ objectId: sketchId
11107
+ } = core.getPlugin(drawingId, pluginId);
11108
+ return React.useMemo(() => {
11109
+ return {
11110
+ rename: {
11111
+ caption: 'rename',
11112
+ icon: /*#__PURE__*/React.createElement(icons.EditOutlined, null),
11113
+ callback: () => {
11114
+ setRename(true);
11115
+ }
11116
+ },
11117
+ delete: {
11118
+ caption: 'delete',
11119
+ icon: /*#__PURE__*/React.createElement(icons.DeleteOutlined, null),
11120
+ callback: () => {
11121
+ classcad.ccAPI.sketcher.removeObjects(drawingId, sketchId, [objectId]);
11122
+ const tree = core.getDrawing(drawingId).structure.tree;
11123
+ set(state_ => {
11124
+ const selected = state_.selected.filter(id => id !== objectId && tree[id].parent !== objectId);
11125
+ return {
11126
+ selected
11127
+ };
11128
+ });
11129
+ }
11130
+ }
11131
+ };
11132
+ }, [drawingId, sketchId, objectId, set, setRename]);
11133
+ }
11134
+
11135
+ const {
11136
+ Text: Text$2
11137
+ } = antd.Typography;
11138
+
11139
+ const ObjTitle = ({
11140
+ objId,
11141
+ withMenu
11142
+ }) => {
11143
+ const {
11144
+ drawingId,
11145
+ pluginId
11146
+ } = React.useContext(RootContext);
11147
+ const name = react.useDrawing(drawingId, d => d.structure.tree[objId].name) || '';
11148
+ const objClass = react.useDrawing(drawingId, d => d.structure.tree[objId].class);
11149
+ const isHovered = useSketchState(drawingId, pluginId, s => s.hovered === objId);
11150
+ const isSelected = useSketchState(drawingId, pluginId, s => s.selected.indexOf(objId) !== -1);
11151
+ const color = isSelected ? '#ffa500' : isHovered ? '#28d79f' : undefined; // TODO: Rename resources so that they have more generic names, i.e. 'CC_Point' instead of 'drawPoint', etc
11152
+
11153
+ const imgName = React.useMemo(() => {
11154
+ switch (objClass) {
11155
+ case classcad.CCClasses.CCPoint:
11156
+ return HandlersList.DRAWPOINT;
11157
+
11158
+ case classcad.CCClasses.CCLine:
11159
+ return HandlersList.DRAWLINE;
11160
+
11161
+ case classcad.CCClasses.CCArc:
11162
+ return HandlersList.DRAWARCCENTER;
11163
+
11164
+ case classcad.CCClasses.CCCircle:
11165
+ return HandlersList.DRAWCIRCLE;
11166
+
11167
+ default:
11168
+ return objClass;
11169
+ }
11170
+ }, [objClass]);
11171
+ const [rename, setRename] = React.useState(false);
11172
+ const [isMenuHovered, setIsMenuHovered] = React.useState(false);
11173
+ const menuItems = useMenuItems$4(drawingId, pluginId, objId, setRename);
11174
+ const activeHandler = useSketchState(drawingId, pluginId, state => state.activeHandler);
11175
+ const globalSelection = useTreeObjSelection(drawingId, objId);
11176
+ const onClickSel = globalSelection.handlers.onClick; // TODO: Implement global selection in onClick? Not sure if needed...
11177
+
11178
+ const onClick = React.useCallback(() => {
11179
+ if (activeHandler === HandlersList.DRAG) {
11180
+ select(drawingId, pluginId, objId);
11181
+ } else if (!activeHandler) {
11182
+ // if no handler is active, some selector should be active
11183
+ onClickSel && onClickSel();
11184
+ }
11185
+ }, [drawingId, pluginId, objId, activeHandler, onClickSel]);
11186
+ const onMouseEnter = React.useCallback(() => {
11187
+ hover(drawingId, pluginId, objId);
11188
+ }, [drawingId, pluginId, objId]);
11189
+ const onMouseLeave = React.useCallback(() => {
11190
+ unhover(drawingId, pluginId, objId);
11191
+ }, [drawingId, pluginId, objId]);
11192
+ const nameComponent = rename ? /*#__PURE__*/React.createElement(NameEdit, {
11193
+ drawingId: drawingId,
11194
+ objId: objId,
11195
+ setEditName: setRename,
11196
+ name: name
11197
+ }) : /*#__PURE__*/React.createElement(EntityName, {
11198
+ name: name,
11199
+ onClick: onClick,
11200
+ onMouseEnter: onMouseEnter,
11201
+ onMouseLeave: onMouseLeave
11202
+ });
11203
+ return /*#__PURE__*/React.createElement(HoveredDiv, {
11204
+ hovered: isMenuHovered,
11205
+ style: {
11206
+ backgroundColor: color
11207
+ }
11208
+ }, /*#__PURE__*/React.createElement(antd.Space, null, imgName && resources[imgName] && /*#__PURE__*/React.createElement("img", {
11209
+ style: {
11210
+ width: 18,
11211
+ height: 18,
11212
+ verticalAlign: '-4px'
11213
+ },
11214
+ src: resources[imgName]
11215
+ }), nameComponent), withMenu && /*#__PURE__*/React.createElement(Menu, {
11216
+ items: menuItems,
11217
+ onVisibleChange: setIsMenuHovered
11218
+ }));
11219
+ };
11220
+
11221
+ const SketchObj = ({
11222
+ objId,
11223
+ level
11224
+ }) => {
11225
+ const {
11226
+ drawingId
11227
+ } = React.useContext(RootContext);
11228
+ const children = react.useDrawing(drawingId, d => d.structure.tree[objId].children || []);
11229
+ const [collapsed, setCollapsed] = React.useState(true);
11230
+ return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(FlexRow, null, /*#__PURE__*/React.createElement(Indents, {
11231
+ level: level
11232
+ }), children.length > 0 ? /*#__PURE__*/React.createElement(CollapseButton, {
11233
+ collapsed: collapsed,
11234
+ onClick: () => setCollapsed(x => !x)
11235
+ }) : /*#__PURE__*/React.createElement(Indent, null), /*#__PURE__*/React.createElement(ObjTitle, {
11236
+ objId: objId,
11237
+ withMenu: level === 0
11238
+ })), children.map(childId => /*#__PURE__*/React.createElement("div", {
11239
+ key: childId,
11240
+ style: {
11241
+ display: collapsed ? 'none' : 'block'
11242
+ }
11243
+ }, /*#__PURE__*/React.createElement(SketchObj, {
11244
+ objId: childId,
11245
+ level: level + 1
11246
+ }))));
11247
+ };
11248
+
11249
+ const Details = () => {
11250
+ const {
11251
+ Collapse
11252
+ } = react.useBuerli(buerli => buerli.options.elements);
11253
+ const {
11254
+ drawingId,
11255
+ pluginId
11256
+ } = React.useContext(RootContext);
11257
+ const sketchId = react.usePlugin(drawingId, pluginId, plugin => plugin.objectId);
11258
+ const sketchChildren = react.useDrawing(drawingId, drawing => drawing.structure.tree[sketchId].children);
11259
+ const {
11260
+ geometry,
11261
+ constraints,
11262
+ isTrimActive
11263
+ } = React.useMemo(() => {
11264
+ const tree = core.getDrawing(drawingId).structure.tree;
11265
+ const geometry_ = (sketchChildren == null ? void 0 : sketchChildren.filter(id => isSketchGeometry(tree[id].class))) || [];
11266
+ const constraints_ = (sketchChildren == null ? void 0 : sketchChildren.filter(id => is2DConstraint(tree[id].class))) || [];
11267
+ const isTrimActive_ = (sketchChildren == null ? void 0 : sketchChildren.findIndex(id => tree[id].class === classcad.CCClasses.CCContainer)) !== -1;
11268
+ return {
11269
+ geometry: geometry_,
11270
+ constraints: constraints_,
11271
+ isTrimActive: isTrimActive_
11272
+ };
11273
+ }, [drawingId, sketchChildren]);
11274
+ return /*#__PURE__*/React.createElement(Collapse, {
11275
+ header: "Details",
11276
+ isActive: false
11277
+ }, geometry.length === 0 && /*#__PURE__*/React.createElement(Text$2, {
11278
+ strong: true
11279
+ }, "The sketch is empty"), geometry.length > 0 && isTrimActive && /*#__PURE__*/React.createElement(Text$2, {
11280
+ strong: true
11281
+ }, "Trim is active"), geometry.length > 0 && !isTrimActive && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Text$2, {
11282
+ strong: true
11283
+ }, "Geometry"), !isTrimActive && geometry.map(childId => /*#__PURE__*/React.createElement(SketchObj, {
11284
+ objId: childId,
11285
+ key: childId,
11286
+ level: 0
11287
+ }))), constraints.length > 0 && !isTrimActive && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Text$2, {
11288
+ strong: true
11289
+ }, "Constraints"), constraints.map(childId => /*#__PURE__*/React.createElement(SketchObj, {
11290
+ objId: childId,
11291
+ key: childId,
11292
+ level: 0
11293
+ }))));
11294
+ };
11295
+
11296
+ const PlaneSelectionMode = ({
11297
+ drawingId,
11298
+ pluginId
11299
+ }) => {
11300
+ const {
11301
+ Group,
11302
+ Label,
11303
+ Selection
11304
+ } = react.useBuerli(buerli => buerli.options.elements);
11305
+ const sketchId = react.usePlugin(drawingId, pluginId, plugin => plugin.objectId);
11306
+ const curProduct = react.useDrawing(drawingId, d => d.structure.currentProduct);
11307
+ const opSeqId = useOperationSequence(drawingId, curProduct) || -1;
11308
+ const opSeqChildren = react.useDrawing(drawingId, d => d.structure.tree[opSeqId].children || []); // Makes base planes visible when just created, and turns them off after initialization (i.e. selecting a plane)
11309
+
11310
+ React.useEffect(() => {
11311
+ if (opSeqChildren.length < 7) {
11312
+ // Should probably never happen, but just in case...
11313
+ return;
11314
+ }
11315
+
11316
+ const drawing = core.getDrawing(drawingId);
11317
+ const tree = drawing.structure.tree;
11318
+ const pluginApi = drawing.api.plugin; // 4, 5, 6 are ids of XY-, XZ- and YZ-planes in the operation sequence array
11319
+
11320
+ const wpSeqIds = [4, 5, 6];
11321
+ const basePlaneIds = wpSeqIds.map(index => tree[opSeqChildren[index]].members.refObj.value);
11322
+ const wereInvisible = [];
11323
+ basePlaneIds.forEach(id => {
11324
+ if (drawing.plugin.visible.indexOf(id) === -1) {
11325
+ wereInvisible.push(id);
11326
+ pluginApi.setVisiblePlugin(id, true);
11327
+ }
11328
+ }); // Make planes invisible again
11329
+
11330
+ return () => {
11331
+ const drawing_ = core.getDrawing(drawingId);
11332
+
11333
+ if (drawing_) {
11334
+ var _drawing_$structure$t, _drawing_$structure$t2;
11335
+
11336
+ const pluginApi_ = drawing_.api.plugin;
11337
+ const planeId = (_drawing_$structure$t = drawing_.structure.tree[sketchId]) == null ? void 0 : (_drawing_$structure$t2 = _drawing_$structure$t.members) == null ? void 0 : _drawing_$structure$t2.planeReference.value;
11338
+ wereInvisible.forEach(id => {
11339
+ if (id !== planeId) {
11340
+ pluginApi_.setVisiblePlugin(id, false);
11341
+ }
11342
+ });
11343
+ }
11344
+ }; // Should always happen just once
11345
+ // eslint-disable-next-line react-hooks/exhaustive-deps
11346
+ }, []);
11347
+ return /*#__PURE__*/React.createElement(Group, null, /*#__PURE__*/React.createElement(Label, null, "Select sketcher plane"), /*#__PURE__*/React.createElement(Selection, {
11348
+ drawingId: drawingId,
11349
+ filter: (scope, data) => {
11350
+ return scope === TreeObjScope && data.object.class === classcad.CCClasses.CCWorkPlane || scope === core.BuerliScope && data === core.GraphicType.PLANE;
11351
+ },
11352
+ onChange: items => {
11353
+ if (items.length !== 0) {
11354
+ if (items[0].scope === TreeObjScope) {
11355
+ classcad.ccAPI.sketcher.setWorkPlane(drawingId, sketchId, items[0].data.object.id);
11356
+ } else {
11357
+ classcad.ccAPI.sketcher.createAndSetWorkPlane(drawingId, sketchId, items[0].data.graphicId);
11358
+ }
11359
+ }
11360
+ },
11361
+ defaultActive: true
11362
+ }));
11363
+ };
11364
+
11365
+ const MousePos = () => {
11366
+ const {
11367
+ Group,
11368
+ Label
11369
+ } = react.useBuerli(buerli => buerli.options.elements);
11370
+ const {
11371
+ drawingId,
11372
+ pluginId
11373
+ } = React.useContext(RootContext);
11374
+ const pos = useSketchState(drawingId, pluginId, state => state.mousePos);
11375
+ return pos ? /*#__PURE__*/React.createElement(Group, null, /*#__PURE__*/React.createElement(Label, null, "Mouse:"), /*#__PURE__*/React.createElement(Label, {
11376
+ flex: "inherit"
11377
+ }, "X:"), /*#__PURE__*/React.createElement(Label, null, pos.x.toFixed(2)), /*#__PURE__*/React.createElement(Label, {
11378
+ flex: "inherit"
11379
+ }, "Y:"), /*#__PURE__*/React.createElement(Label, null, pos.y.toFixed(2))) : null;
11380
+ };
11381
+
11382
+ const TabIcon = ({
11383
+ url,
11384
+ tooltip
11385
+ }) => {
11386
+ const {
11387
+ Tooltip
11388
+ } = react.useBuerli(b => b.options.elements);
11389
+ return /*#__PURE__*/React.createElement(Tooltip, {
11390
+ title: tooltip,
11391
+ placement: "top"
11392
+ }, /*#__PURE__*/React.createElement("div", {
11393
+ style: {
11394
+ marginRight: '3px',
11395
+ marginLeft: '3px'
11396
+ }
11397
+ }, /*#__PURE__*/React.createElement("img", {
11398
+ style: {
11399
+ width: 24,
11400
+ height: 24
11401
+ },
11402
+ src: url
11403
+ })));
11404
+ };
11405
+
11406
+ const SketchMode = ({
10651
11407
  drawingId,
10652
11408
  pluginId
10653
11409
  }) => {
@@ -10692,7 +11448,7 @@ const SketchMode = ({
10692
11448
  });
10693
11449
  }
10694
11450
  })), /*#__PURE__*/React.createElement(MousePos, null), /*#__PURE__*/React.createElement(Collapse, {
10695
- header: "Patterns and use reference",
11451
+ header: "Patterns",
10696
11452
  isActive: false
10697
11453
  }, /*#__PURE__*/React.createElement(Tabs, {
10698
11454
  tabBarGutter: 0,
@@ -10717,13 +11473,7 @@ const SketchMode = ({
10717
11473
  tooltip: "Mirror copy pattern."
10718
11474
  }),
10719
11475
  key: "Mirror"
10720
- }, /*#__PURE__*/React.createElement(MirrorPattern, null)), /*#__PURE__*/React.createElement(TabPane, {
10721
- tab: /*#__PURE__*/React.createElement(TabIcon, {
10722
- url: resources['useRef'],
10723
- tooltip: "Use reference."
10724
- }),
10725
- key: "UseRef"
10726
- }, /*#__PURE__*/React.createElement(UseRef, null))))));
11476
+ }, /*#__PURE__*/React.createElement(MirrorPattern, null)))), /*#__PURE__*/React.createElement(Details, null)));
10727
11477
  };
10728
11478
 
10729
11479
  const RootImpl$f = ({
@@ -10733,22 +11483,23 @@ const RootImpl$f = ({
10733
11483
  const objectId = react.usePlugin(drawingId, pluginId, plugin => plugin.objectId);
10734
11484
  const sketch = react.useDrawing(drawingId, drawing => drawing.structure.tree[objectId]);
10735
11485
  const planeSelected = sketch.members.planeReference.value !== 0;
10736
- const {
10737
- set
10738
- } = core.getPlugin(drawingId, pluginId);
10739
11486
  React.useEffect(() => {
10740
11487
  // Reset some fields in state and force sketch visibility when sketch is unmounted.
10741
11488
  return () => {
10742
- const pluginApi = core.getDrawing(drawingId).api.plugin;
10743
- pluginApi.setVisiblePlugin(pluginId, true);
10744
- set({
10745
- tmpObjects: {},
10746
- selected: [],
10747
- hovered: UNDEFINEDID,
10748
- highlighted: []
10749
- });
11489
+ const plugin = core.getPlugin(drawingId, pluginId); // Only do stuff if plugin exists in the store when unmounting
11490
+
11491
+ if (plugin) {
11492
+ const pluginApi = core.getDrawing(drawingId).api.plugin;
11493
+ pluginApi.setVisiblePlugin(pluginId, true);
11494
+ plugin.set({
11495
+ tmpObjects: {},
11496
+ selected: [],
11497
+ hovered: UNDEFINEDID,
11498
+ highlighted: []
11499
+ });
11500
+ }
10750
11501
  };
10751
- }, [drawingId, pluginId, set]);
11502
+ }, [drawingId, pluginId]);
10752
11503
  React.useEffect(() => {
10753
11504
  if (!planeSelected) {
10754
11505
  return;
@@ -11006,7 +11757,7 @@ const ViewImpl$c = ({
11006
11757
  handlers
11007
11758
  } = useTreeObjSelection(drawingId, objectId);
11008
11759
  const color = getColor(isHovered, isSelected, direction, workAxisObj.members.Type.value);
11009
- const ref = useScale(position.clone(), sf => [3 * sf, 3 * sf, 3 * sf]);
11760
+ const ref = useScale$1(position.clone(), sf => [3 * sf, 3 * sf, 3 * sf]);
11010
11761
  return /*#__PURE__*/React.createElement(HUD, null, /*#__PURE__*/React.createElement("group", {
11011
11762
  ref: ref,
11012
11763
  position: position
@@ -11527,7 +12278,7 @@ const ViewImpl$a = ({
11527
12278
  handlers
11528
12279
  } = useTreeObjSelection(drawingId, objectId);
11529
12280
  const color = isHovered ? 0x28d79f : isSelected ? 0xa70b0b : 0x111111;
11530
- const ref = useScale(position.clone(), sf => [3 * sf, 3 * sf, 3 * sf]);
12281
+ const ref = useScale$1(position.clone(), sf => [3 * sf, 3 * sf, 3 * sf]);
11531
12282
  return /*#__PURE__*/React.createElement(HUD, null, /*#__PURE__*/React.createElement("group", {
11532
12283
  ref: ref,
11533
12284
  position: position
@@ -11568,9 +12319,9 @@ var index$c = /*#__PURE__*/Object.freeze({
11568
12319
  description: description$c
11569
12320
  });
11570
12321
 
11571
- function ownKeys$6(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
12322
+ function ownKeys$7(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
11572
12323
 
11573
- function _objectSpread$6(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$6(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$6(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
12324
+ function _objectSpread$7(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$7(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$7(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
11574
12325
 
11575
12326
  const NumInput = ({
11576
12327
  onChange,
@@ -11631,7 +12382,7 @@ const CSysEditor = ({
11631
12382
  const [z, setZ] = React.useState(() => userValue[csysRow].z);
11632
12383
  React.useEffect(() => {
11633
12384
  setUserValue(val => {
11634
- const newVal = [_objectSpread$6({}, val[0]), _objectSpread$6({}, val[1]), _objectSpread$6({}, val[2]), _objectSpread$6({}, val[3])];
12385
+ const newVal = [_objectSpread$7({}, val[0]), _objectSpread$7({}, val[1]), _objectSpread$7({}, val[2]), _objectSpread$7({}, val[3])];
11635
12386
  newVal[csysRow] = {
11636
12387
  x,
11637
12388
  y,
@@ -12242,36 +12993,36 @@ function ViewImpl$8({
12242
12993
  length: zAxisLength + scale * 10,
12243
12994
  width: arrowWidth,
12244
12995
  color: 0x11116f
12245
- }), /*#__PURE__*/React.createElement(Point$1, {
12996
+ }), /*#__PURE__*/React.createElement(Point$2, {
12246
12997
  position: origin,
12247
12998
  radius: originPointWidth,
12248
12999
  color: 0x111111
12249
- }), axisPoints.map(point => /*#__PURE__*/React.createElement(Point$1, {
13000
+ }), axisPoints.map(point => /*#__PURE__*/React.createElement(Point$2, {
12250
13001
  key: point.key,
12251
13002
  position: point.position,
12252
13003
  radius: axisPointWidth,
12253
13004
  color: point.color
12254
- })), /*#__PURE__*/React.createElement(Point$1, {
13005
+ })), /*#__PURE__*/React.createElement(Point$2, {
12255
13006
  position: xMin,
12256
13007
  radius: boundaryPointWidth,
12257
13008
  color: 0x6f1111
12258
- }), /*#__PURE__*/React.createElement(Point$1, {
13009
+ }), /*#__PURE__*/React.createElement(Point$2, {
12259
13010
  position: xMax,
12260
13011
  radius: boundaryPointWidth,
12261
13012
  color: 0x6f1111
12262
- }), /*#__PURE__*/React.createElement(Point$1, {
13013
+ }), /*#__PURE__*/React.createElement(Point$2, {
12263
13014
  position: yMin,
12264
13015
  radius: boundaryPointWidth,
12265
13016
  color: 0x116f11
12266
- }), /*#__PURE__*/React.createElement(Point$1, {
13017
+ }), /*#__PURE__*/React.createElement(Point$2, {
12267
13018
  position: yMax,
12268
13019
  radius: boundaryPointWidth,
12269
13020
  color: 0x116f11
12270
- }), /*#__PURE__*/React.createElement(Point$1, {
13021
+ }), /*#__PURE__*/React.createElement(Point$2, {
12271
13022
  position: zMin,
12272
13023
  radius: boundaryPointWidth,
12273
13024
  color: 0x11116f
12274
- }), /*#__PURE__*/React.createElement(Point$1, {
13025
+ }), /*#__PURE__*/React.createElement(Point$2, {
12275
13026
  position: zMax,
12276
13027
  radius: boundaryPointWidth,
12277
13028
  color: 0x11116f
@@ -12969,6 +13720,47 @@ const CSysDisplayValidator = ({
12969
13720
  }, children);
12970
13721
  };
12971
13722
 
13723
+ function useFeaturesIds(drawingId, curNodeId) {
13724
+ const curClass = react.useDrawing(drawingId, d => {
13725
+ var _d$structure$tree$cur;
13726
+
13727
+ return (_d$structure$tree$cur = d.structure.tree[curNodeId]) == null ? void 0 : _d$structure$tree$cur.class;
13728
+ });
13729
+ const prodId = react.useDrawing(drawingId, d => {
13730
+ if (curClass === classcad.CCClasses.CCProductReference || curClass === classcad.CCClasses.CCProductReferenceET) {
13731
+ const node = d.structure.tree[curNodeId];
13732
+ return node.members.productId.value;
13733
+ }
13734
+
13735
+ return curNodeId;
13736
+ });
13737
+ const opSeqId = useOperationSequence(drawingId, prodId);
13738
+ const opSeqChildren = react.useDrawing(drawingId, d => {
13739
+ var _d$structure$tree;
13740
+
13741
+ return (_d$structure$tree = d.structure.tree[opSeqId || -1]) == null ? void 0 : _d$structure$tree.children;
13742
+ });
13743
+ const tree = core.getDrawing(drawingId).structure.tree;
13744
+ const featureIds = (opSeqChildren == null ? void 0 : opSeqChildren.map(refId => tree[refId].members.refObj.value)) || [];
13745
+ return featureIds;
13746
+ }
13747
+ function getFeaturesIds(drawingId, curNodeId) {
13748
+ var _tree$prodId, _tree;
13749
+
13750
+ const tree = core.getDrawing(drawingId).structure.tree;
13751
+ const curClass = tree[curNodeId].class;
13752
+ const prodId = curClass === classcad.CCClasses.CCProductReference || curClass === classcad.CCClasses.CCProductReferenceET ? tree[curNodeId].members.productId.value : curNodeId;
13753
+ const prodChildren = (_tree$prodId = tree[prodId]) == null ? void 0 : _tree$prodId.children;
13754
+ const opSeqId = prodChildren == null ? void 0 : prodChildren.find(id => {
13755
+ var _tree$id;
13756
+
13757
+ return ((_tree$id = tree[id]) == null ? void 0 : _tree$id.class) === classcad.CCClasses.CCOperationSequence;
13758
+ });
13759
+ const opSeqChildren = (_tree = tree[opSeqId || -1]) == null ? void 0 : _tree.children;
13760
+ const featureIds = (opSeqChildren == null ? void 0 : opSeqChildren.map(refId => tree[refId].members.refObj.value)) || [];
13761
+ return featureIds;
13762
+ }
13763
+
12972
13764
  const getFlipMatrix = (flip, xAxis, yAxis) => {
12973
13765
  switch (flip) {
12974
13766
  case classcad.FlipType.FLIP_X:
@@ -13311,9 +14103,8 @@ const CSysDisplayImpl = ({
13311
14103
  const productId = ((_tree$id$members = tree[id].members) == null ? void 0 : (_tree$id$members$prod = _tree$id$members.productId) == null ? void 0 : _tree$id$members$prod.value) || tree[id].id;
13312
14104
 
13313
14105
  if (prToCsysMap[productId] === undefined) {
13314
- var _tree$productId$featu;
13315
-
13316
- const csysIds = ((_tree$productId$featu = tree[productId].features) == null ? void 0 : _tree$productId$featu.filter(featureId => tree[featureId].class === classcad.CCClasses.CCWorkCoordSystem)) || [];
14106
+ const features = getFeaturesIds(drawingId, productId);
14107
+ const csysIds = (features == null ? void 0 : features.filter(featureId => tree[featureId].class === classcad.CCClasses.CCWorkCoordSystem)) || [];
13317
14108
  prToCsysMap[productId] = csysIds;
13318
14109
  }
13319
14110
 
@@ -15013,216 +15804,77 @@ function readFile(file, type) {
15013
15804
  break;
15014
15805
 
15015
15806
  case 'Text':
15016
- reader.readAsText(file);
15017
- break;
15018
-
15019
- case 'ArrayBuffer':
15020
- default:
15021
- reader.readAsArrayBuffer(file);
15022
- break;
15023
- }
15024
- });
15025
- }
15026
- /**
15027
- * Simple helper functions for file interaction.
15028
- */
15029
-
15030
-
15031
- const FileUtils = {
15032
- /**
15033
- * Loads a file from the file system.
15034
- * It uses @see document and is therefore directly dependent on the DOM.
15035
- *
15036
- * @param onLoad The callback.
15037
- * @param type The content type.
15038
- */
15039
- loadFile: (onLoad, type, multiple) => {
15040
- const handler = event => {
15041
- if (event.target && event.target.files) {
15042
- const files = [...event.target.files];
15043
- const promises = files.map(f => readFile(f, type));
15044
- Promise.all(promises).then(res => onLoad(res)).catch();
15045
- event.target.value = '';
15046
- }
15047
- };
15048
-
15049
- const loaderId = '________buerli-react-cad________';
15050
- const loaderSelector = `#${loaderId}`;
15051
- let loader = document.querySelector(loaderSelector);
15052
-
15053
- if (!loader || !loader.onchange) {
15054
- loader = document.createElement('input');
15055
- loader.id = loaderId;
15056
- loader.type = 'file';
15057
- loader.multiple = multiple || false;
15058
- loader.style.display = 'none';
15059
- document.body.appendChild(loader);
15060
- }
15061
-
15062
- if (loader) {
15063
- loader.onchange = handler;
15064
- loader.click();
15065
- }
15066
- },
15067
- exportNode: async (drawingId, objectId, type = 'of1') => {
15068
- var _members$productId;
15069
-
15070
- const structure = core.getDrawing(drawingId).structure;
15071
- const tree = structure.tree;
15072
- const isRoot = objectId === structure.root;
15073
- const productId = ((_members$productId = tree[objectId].members.productId) == null ? void 0 : _members$productId.value) || objectId;
15074
- const name = tree[productId].name;
15075
- const data = isRoot ? await classcad.ccAPI.baseModeler.save(drawingId, type) : await classcad.ccAPI.assemblyBuilder.exportNode(drawingId, objectId, type);
15076
-
15077
- if (data) {
15078
- const link = document.createElement('a');
15079
- link.href = window.URL.createObjectURL(new Blob([data], {
15080
- type: 'application/octet-stream'
15081
- }));
15082
- link.download = `${name}.${type}`;
15083
- link.click();
15084
- }
15085
- }
15086
- };
15087
-
15088
- const _excluded$3 = ["items", "children"];
15089
- const Menu = _ref => {
15090
- let {
15091
- items,
15092
- children
15093
- } = _ref,
15094
- props = _objectWithoutProperties(_ref, _excluded$3);
15095
-
15096
- const onItemClick = React.useCallback(e => {
15097
- e.domEvent.stopPropagation();
15098
- let item = items[e.keyPath.pop()];
15099
-
15100
- if (item.children) {
15101
- item = item.children[e.keyPath.pop()];
15102
- }
15103
- item.callback(e.domEvent);
15104
- }, [items]);
15105
- const menu = /*#__PURE__*/React.createElement(antd.Menu, {
15106
- onClick: onItemClick
15107
- }, Object.keys(items).map(key => {
15108
- const item = items[key];
15109
-
15110
- if (item.children) {
15111
- const smItem = item;
15112
- return /*#__PURE__*/React.createElement(antd.Menu.SubMenu, {
15113
- title: smItem.caption,
15114
- key: key,
15115
- icon: smItem.icon
15116
- }, Object.keys(smItem.children).map(chKey => {
15117
- const chItem = smItem.children[chKey];
15118
- return /*#__PURE__*/React.createElement(antd.Menu.Item, {
15119
- key: chKey,
15120
- icon: chItem.icon
15121
- }, chItem.caption);
15122
- }));
15123
- } else {
15124
- const item_ = item;
15125
- return /*#__PURE__*/React.createElement(antd.Menu.Item, {
15126
- key: key,
15127
- icon: item_.icon
15128
- }, item_.caption);
15129
- }
15130
- }));
15131
- return /*#__PURE__*/React.createElement(antd.Dropdown, _extends({
15132
- overlay: menu,
15133
- placement: "bottomCenter"
15134
- }, props), children ? children : /*#__PURE__*/React.createElement("div", {
15135
- style: {
15136
- width: '24px',
15137
- cursor: 'pointer'
15138
- },
15139
- onClick: e => e.stopPropagation()
15140
- }, "..."));
15141
- };
15807
+ reader.readAsText(file);
15808
+ break;
15142
15809
 
15143
- const zoomToFit = drawingId => {
15144
- var _getCamera;
15810
+ case 'ArrayBuffer':
15811
+ default:
15812
+ reader.readAsArrayBuffer(file);
15813
+ break;
15814
+ }
15815
+ });
15816
+ }
15817
+ /**
15818
+ * Simple helper functions for file interaction.
15819
+ */
15145
15820
 
15146
- const drawing = core.getDrawing(drawingId);
15147
- const camApi = (_getCamera = react.getCamera(drawingId)) == null ? void 0 : _getCamera.api;
15148
15821
 
15149
- if (!drawing || !camApi) {
15150
- return;
15151
- }
15822
+ const FileUtils = {
15823
+ /**
15824
+ * Loads a file from the file system.
15825
+ * It uses @see document and is therefore directly dependent on the DOM.
15826
+ *
15827
+ * @param onLoad The callback.
15828
+ * @param type The content type.
15829
+ */
15830
+ loadFile: (onLoad, type, multiple) => {
15831
+ const handler = event => {
15832
+ if (event.target && event.target.files) {
15833
+ const files = [...event.target.files];
15834
+ const promises = files.map(f => readFile(f, type));
15835
+ Promise.all(promises).then(res => onLoad(res)).catch();
15836
+ event.target.value = '';
15837
+ }
15838
+ };
15152
15839
 
15153
- const {
15154
- structure,
15155
- api: drawingApi
15156
- } = drawing;
15157
- const {
15158
- root,
15159
- currentProduct,
15160
- currentNode
15161
- } = structure;
15162
- let currRoot = currentNode || currentProduct || root;
15840
+ const loaderId = '________buerli-react-cad________';
15841
+ const loaderSelector = `#${loaderId}`;
15842
+ let loader = document.querySelector(loaderSelector);
15163
15843
 
15164
- if (currentProduct && structure.tree[currentProduct].class === 'CC_Part') {
15165
- currRoot = currentProduct;
15166
- }
15844
+ if (!loader || !loader.onchange) {
15845
+ loader = document.createElement('input');
15846
+ loader.id = loaderId;
15847
+ loader.type = 'file';
15848
+ loader.multiple = multiple || false;
15849
+ loader.style.display = 'none';
15850
+ document.body.appendChild(loader);
15851
+ }
15167
15852
 
15168
- const bounds = drawingApi.structure.calculateProductBounds(currRoot);
15169
- camApi.setZoom('fit', bounds);
15170
- };
15853
+ if (loader) {
15854
+ loader.onchange = handler;
15855
+ loader.click();
15856
+ }
15857
+ },
15858
+ exportNode: async (drawingId, objectId, type = 'of1') => {
15859
+ var _members$productId;
15171
15860
 
15172
- function ownKeys$5(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
15861
+ const structure = core.getDrawing(drawingId).structure;
15862
+ const tree = structure.tree;
15863
+ const isRoot = objectId === structure.root;
15864
+ const productId = ((_members$productId = tree[objectId].members.productId) == null ? void 0 : _members$productId.value) || objectId;
15865
+ const name = tree[productId].name;
15866
+ const data = isRoot ? await classcad.ccAPI.baseModeler.save(drawingId, type) : await classcad.ccAPI.assemblyBuilder.exportNode(drawingId, objectId, type);
15173
15867
 
15174
- function _objectSpread$5(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$5(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$5(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
15175
- const appApi = (set, get) => ({
15176
- assemblyTree: {
15177
- startProdEditing: (drawingId, objId) => {
15178
- set(state => {
15179
- let res = [];
15180
- const curNode = core.api.getState().drawing.refs[drawingId].structure.currentNode;
15181
- res = state.assemblyTree.prodStack;
15182
- curNode && res.push(curNode);
15183
- return _objectSpread$5(_objectSpread$5({}, state), {}, {
15184
- assemblyTree: {
15185
- prodStack: [...res]
15186
- }
15187
- });
15188
- });
15189
- classcad.ccAPI.assemblyBuilder.setCurrentNode(drawingId, objId).then(() => zoomToFit(drawingId)).catch();
15190
- },
15191
- goBack: drawingId => {
15192
- const prodStack = get().assemblyTree.prodStack;
15193
- const prevProd = prodStack[prodStack.length - 1];
15194
- if (!prevProd) return;
15195
- set(state => {
15196
- const res = state.assemblyTree.prodStack;
15197
- res.pop();
15198
- return _objectSpread$5(_objectSpread$5({}, state), {}, {
15199
- assemblyTree: {
15200
- prodStack: [...res]
15201
- }
15202
- });
15203
- });
15204
- classcad.ccAPI.assemblyBuilder.setCurrentNode(drawingId, prevProd).then(() => zoomToFit(drawingId)).catch();
15205
- },
15206
- clearProdStack: () => {
15207
- set(state => _objectSpread$5(_objectSpread$5({}, state), {}, {
15208
- assemblyTree: {
15209
- prodStack: []
15210
- }
15868
+ if (data) {
15869
+ const link = document.createElement('a');
15870
+ link.href = window.URL.createObjectURL(new Blob([data], {
15871
+ type: 'application/octet-stream'
15211
15872
  }));
15873
+ link.download = `${name}.${type}`;
15874
+ link.click();
15212
15875
  }
15213
15876
  }
15214
- });
15215
-
15216
- const createAppState = (set, get) => ({
15217
- assemblyTree: {
15218
- prodStack: []
15219
- },
15220
- api: appApi(set, get)
15221
- });
15222
-
15223
- const CADApi = vanilla((set, get) => createAppState(set, get));
15224
- const useCADStore = create(CADApi);
15225
- const getCADState = CADApi.getState;
15877
+ };
15226
15878
 
15227
15879
  function useMenuItems$3(drawingId, prodId, setEditName, pluginId) {
15228
15880
  const isCurrent = react.useDrawing(drawingId, d => d.structure.currentProduct === prodId);
@@ -15300,43 +15952,8 @@ function useMenuItems$3(drawingId, prodId, setEditName, pluginId) {
15300
15952
  return res;
15301
15953
  }
15302
15954
 
15303
- const NameEdit = ({
15304
- drawingId,
15305
- objId,
15306
- setEditName,
15307
- name
15308
- }) => {
15309
- const ref = React.useRef(null);
15310
- const onEnter = React.useCallback(async e => {
15311
- if (e.target.value !== '') {
15312
- await classcad.ccAPI.common.setObjectName(drawingId, objId, e.target.value);
15313
- }
15314
-
15315
- setEditName(false);
15316
- }, [drawingId, objId, setEditName]);
15317
- const onKeyPress = React.useCallback(e => {
15318
- if (e.key !== 'Escape') return;
15319
- setEditName(false);
15320
- }, [setEditName]);
15321
- React.useEffect(() => {
15322
- var _ref$current;
15323
-
15324
- (_ref$current = ref.current) == null ? void 0 : _ref$current.focus({
15325
- cursor: 'all'
15326
- });
15327
- }, []);
15328
- return /*#__PURE__*/React.createElement(antd.Input, {
15329
- ref: ref,
15330
- onPressEnter: onEnter,
15331
- defaultValue: name,
15332
- size: "small",
15333
- onKeyDown: onKeyPress,
15334
- onBlur: () => setEditName(false)
15335
- });
15336
- };
15337
-
15338
15955
  const {
15339
- Text: Text$2
15956
+ Text: Text$1
15340
15957
  } = antd.Typography; // TODO: use Name from Feature.tsx
15341
15958
 
15342
15959
  const Name = ({
@@ -15345,7 +15962,7 @@ const Name = ({
15345
15962
  strong,
15346
15963
  onClick
15347
15964
  }) => {
15348
- return /*#__PURE__*/React.createElement(Text$2, {
15965
+ return /*#__PURE__*/React.createElement(Text$1, {
15349
15966
  disabled: disabled,
15350
15967
  strong: strong,
15351
15968
  style: {
@@ -15433,7 +16050,7 @@ const NewProd = ({
15433
16050
  ref: inputRef,
15434
16051
  suffix: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(antd.Space, null, /*#__PURE__*/React.createElement(InputButton, {
15435
16052
  type: "apply",
15436
- onClick: () => createProd() && setCreateMode(false)
16053
+ onClick: () => setCreateMode(false)
15437
16054
  }), /*#__PURE__*/React.createElement(InputButton, {
15438
16055
  type: "cancel",
15439
16056
  onClick: () => setCreateMode(false)
@@ -15470,13 +16087,16 @@ const ProdTable = ({
15470
16087
  dataIndex: 'prodId',
15471
16088
  render
15472
16089
  }];
15473
- }, [drawingId, pluginId, setCreateMode]); // ResetselectedProduct when plugin is closed
16090
+ }, [drawingId, pluginId, setCreateMode]); // Reset selectedProduct when plugin is closed
15474
16091
 
15475
16092
  React.useEffect(() => {
15476
- return () => set({
15477
- selectedProduct: null
15478
- });
15479
- }, [set]);
16093
+ return () => {
16094
+ const plugin = core.getPlugin(drawingId, pluginId);
16095
+ plugin && plugin.set({
16096
+ selectedProduct: null
16097
+ });
16098
+ };
16099
+ }, [drawingId, pluginId]);
15480
16100
  const keyHandler = React.useCallback(e => {
15481
16101
  if (e.key === 'Escape') {
15482
16102
  set({
@@ -15945,6 +16565,25 @@ const useIsDisabled = (drawingId, featureId) => {
15945
16565
  return featureIndex > rollbackBarIndex || actFeatIdx >= 0 && actFeatIdx < featureIndex;
15946
16566
  };
15947
16567
 
16568
+ /**
16569
+ * Validator for FeatureList component. Checks drawing and currentProduct existance.
16570
+ *
16571
+ * @param drawingId
16572
+ * @returns
16573
+ */
16574
+
16575
+ const FeatureListValidator = ({
16576
+ drawingId,
16577
+ children
16578
+ }) => {
16579
+ const warnings = {};
16580
+ useDrawingVerifier(drawingId, warnings);
16581
+ useRootOrProdVerifier(drawingId, warnings);
16582
+ return /*#__PURE__*/React.createElement(ErrorBoundary, {
16583
+ warnings: warnings
16584
+ }, children);
16585
+ };
16586
+
15948
16587
  /**
15949
16588
  * Goal of this component is to manage visibility of individual features when interacting with RollbackBar
15950
16589
  * TODO: change the component name?
@@ -15981,8 +16620,6 @@ const VisibilityController = ({
15981
16620
  const FtVisibilityControllerImpl = ({
15982
16621
  drawingId
15983
16622
  }) => {
15984
- var _operationSequence$ch;
15985
-
15986
16623
  const activeSelId = react.useDrawing(drawingId, d => d.selection.active);
15987
16624
  const featuresToHide = React.useRef([]);
15988
16625
  React.useEffect(() => {
@@ -16011,15 +16648,7 @@ const FtVisibilityControllerImpl = ({
16011
16648
  };
16012
16649
  }, [drawingId, activeSelId]);
16013
16650
  const curPartId = react.useDrawing(drawingId, d => d.structure.currentProduct || d.structure.root);
16014
- const {
16015
- operationSequence
16016
- } = useRollbackBar(drawingId, curPartId);
16017
- const tree = core.getDrawing(drawingId).structure.tree;
16018
- const features = operationSequence == null ? void 0 : (_operationSequence$ch = operationSequence.children) == null ? void 0 : _operationSequence$ch.map(id => {
16019
- var _tree$id, _tree$id$members, _tree$id$members$refO;
16020
-
16021
- return (_tree$id = tree[id]) == null ? void 0 : (_tree$id$members = _tree$id.members) == null ? void 0 : (_tree$id$members$refO = _tree$id$members.refObj) == null ? void 0 : _tree$id$members$refO.value;
16022
- });
16651
+ const features = useFeaturesIds(drawingId, curPartId);
16023
16652
  return features ? /*#__PURE__*/React.createElement(React.Fragment, null, features.map(id => /*#__PURE__*/React.createElement(VisibilityController, {
16024
16653
  key: id,
16025
16654
  drawingId: drawingId,
@@ -16030,70 +16659,25 @@ const FtVisibilityControllerImpl = ({
16030
16659
  const FtVisibilityController = ({
16031
16660
  drawingId
16032
16661
  }) => {
16033
- return /*#__PURE__*/React.createElement(ErrorBoundary, null, /*#__PURE__*/React.createElement(FtVisibilityControllerImpl, {
16662
+ return /*#__PURE__*/React.createElement(FeatureListValidator, {
16663
+ drawingId: drawingId
16664
+ }, /*#__PURE__*/React.createElement(FtVisibilityControllerImpl, {
16034
16665
  drawingId: drawingId
16035
16666
  }));
16036
16667
  };
16037
16668
 
16038
16669
  var FtVisibilityController$1 = FtVisibilityController;
16039
16670
 
16040
- function ownKeys$4(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
16041
-
16042
- function _objectSpread$4(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$4(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$4(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
16043
-
16044
- const Divider = props => {
16045
- return /*#__PURE__*/React.createElement(antd.Divider, _extends({}, props, {
16046
- style: _objectSpread$4({
16047
- margin: '0'
16048
- }, props.style)
16049
- }));
16050
- };
16671
+ function ownKeys$6(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
16051
16672
 
16052
- const FlexRow = styled.div`
16053
- display: flex;
16054
- flex-direction: row;
16055
- `;
16056
- const FlexReverseRow = styled.div`
16057
- display: flex;
16058
- flex-direction: row-reverse;
16059
- `;
16060
- const Link = styled.a`
16061
- color: #4f4f4f;
16062
- &:hover {
16063
- text-decoration: underline;
16064
- text-decoration-color: #4f4f4f;
16065
- color: #4f4f4f;
16066
- }
16067
- `;
16068
- const HoveredDiv = styled.div`
16069
- width: 100%;
16070
- display: flex;
16071
- justify-content: space-between;
16072
- cursor: default;
16073
- &:hover {
16074
- background-color: #fbfbfb;
16075
- }
16076
- `;
16673
+ function _objectSpread$6(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$6(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$6(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
16077
16674
 
16078
- const {
16079
- Text: Text$1
16080
- } = antd.Typography;
16081
- const EntityName = ({
16082
- name,
16083
- disabled,
16084
- strong,
16085
- onClick,
16086
- onMouseEnter,
16087
- onMouseLeave
16088
- }) => {
16089
- return /*#__PURE__*/React.createElement(Link, {
16090
- onClick: onClick,
16091
- onMouseEnter: onMouseEnter,
16092
- onMouseLeave: onMouseLeave
16093
- }, /*#__PURE__*/React.createElement(Text$1, {
16094
- disabled: disabled,
16095
- strong: strong
16096
- }, name));
16675
+ const Divider = props => {
16676
+ return /*#__PURE__*/React.createElement(antd.Divider, _extends({}, props, {
16677
+ style: _objectSpread$6({
16678
+ margin: '0'
16679
+ }, props.style)
16680
+ }));
16097
16681
  };
16098
16682
 
16099
16683
  function useMenuItems$2(drawingId, featureId, isActive, setEditName) {
@@ -16119,35 +16703,92 @@ function useMenuItems$2(drawingId, featureId, isActive, setEditName) {
16119
16703
  }, [drawingId, featureId, isActive, setEditName]);
16120
16704
  }
16121
16705
 
16122
- function useIsCustom(drawingId, featureId) {
16706
+ function useIsCustom(drawingId, featureRefId) {
16707
+ const curProduct = react.useDrawing(drawingId, d => d.structure.currentProduct);
16708
+ const opSeqId = useOperationSequence(drawingId, curProduct);
16709
+ const opSeqChildren = react.useDrawing(drawingId, d => {
16710
+ var _d$structure$tree;
16711
+
16712
+ return (_d$structure$tree = d.structure.tree[opSeqId || -1]) == null ? void 0 : _d$structure$tree.children;
16713
+ }) || []; // First 7 elements in operationSequence are features created by default (origin, x,y,z axes and planes) => they're not custom
16714
+
16715
+ return opSeqChildren.indexOf(featureRefId) > 6;
16716
+ }
16717
+
16718
+ function usePrecheckErrorId(drawingId, featureId) {
16123
16719
  const curProduct = react.useDrawing(drawingId, d => d.structure.currentProduct);
16124
16720
  const opSeqId = useOperationSequence(drawingId, curProduct) || -1;
16125
- const opSeqChildren = react.useDrawing(drawingId, d => d.structure.tree[opSeqId].children || []);
16126
- const referedObjs = React.useMemo(() => {
16127
- return opSeqChildren.map(refId => {
16128
- const ref = core.getDrawing(drawingId).structure.tree[refId];
16129
- return ref.members.refObj.value;
16130
- });
16131
- }, [opSeqChildren, drawingId]); // First 7 elements in operationSequens are features created by default (origin, x,y,z axes and planes) => they're not custom
16721
+ const opSeqChildren = react.useDrawing(drawingId, d => {
16722
+ var _d$structure$tree$opS;
16723
+
16724
+ return (_d$structure$tree$opS = d.structure.tree[opSeqId]) == null ? void 0 : _d$structure$tree$opS.children;
16725
+ }) || [];
16726
+ const refId = opSeqChildren.find(chId => {
16727
+ var _ref_$members;
16728
+
16729
+ const ref_ = core.getDrawing(drawingId).structure.tree[chId];
16730
+ return featureId === (ref_ == null ? void 0 : (_ref_$members = ref_.members) == null ? void 0 : _ref_$members.refObj.value);
16731
+ });
16732
+ const refChildren = react.useDrawing(drawingId, d => {
16733
+ var _d$structure$tree2;
16734
+
16735
+ return (_d$structure$tree2 = d.structure.tree[refId || -1]) == null ? void 0 : _d$structure$tree2.children;
16736
+ }) || [];
16737
+ const errorId = refChildren.find(chId => {
16738
+ var _getDrawing$structure;
16739
+
16740
+ return ((_getDrawing$structure = core.getDrawing(drawingId).structure.tree[chId]) == null ? void 0 : _getDrawing$structure.class) === classcad.CCClasses.BMError;
16741
+ }) || null;
16742
+ return errorId;
16743
+ }
16744
+
16745
+ const ErrorWrapper = styled.div`
16746
+ cursor: pointer;
16747
+ margin-right: 4px;
16748
+ `;
16749
+
16750
+ const PrecheckError = ({
16751
+ drawingId,
16752
+ errorId
16753
+ }) => {
16754
+ var _error$members;
16755
+
16756
+ const error = react.useDrawing(drawingId, d => d.structure.tree[errorId]);
16757
+ const title = (error == null ? void 0 : (_error$members = error.members) == null ? void 0 : _error$members.errorMessage.value) || '';
16758
+ return /*#__PURE__*/React.createElement(ErrorWrapper, null, /*#__PURE__*/React.createElement(Tooltip, {
16759
+ title: title
16760
+ }, /*#__PURE__*/React.createElement(icons.ExclamationCircleTwoTone, {
16761
+ twoToneColor: "#ff5f5f"
16762
+ })));
16763
+ };
16132
16764
 
16133
- return referedObjs.indexOf(featureId) > 6;
16765
+ function useHasView(drawingId, featureId) {
16766
+ const [hasGraphics, setHasGraphics] = React.useState(false);
16767
+ const ftClass = react.useDrawing(drawingId, d => d.structure.tree[featureId].class);
16768
+ react.useFeaturePluginDef(ftClass, plugin => setHasGraphics(Boolean(plugin == null ? void 0 : plugin.View)));
16769
+ return hasGraphics;
16134
16770
  }
16135
16771
 
16136
16772
  const Feature = ({
16137
16773
  drawingId,
16138
- featureId
16774
+ featureRefId
16139
16775
  }) => {
16140
- const name = react.useDrawing(drawingId, d => d.structure.tree[featureId].name);
16141
- const visible = react.useDrawing(drawingId, d => d.plugin.visible.indexOf(featureId) >= 0);
16142
- const view = react.useDrawing(drawingId, d => {
16143
- var _d$plugin$refs$featur;
16776
+ const featureId = react.useDrawing(drawingId, d => {
16777
+ var _d$structure$tree$fea, _d$structure$tree$fea2;
16778
+
16779
+ return (_d$structure$tree$fea = d.structure.tree[featureRefId]) == null ? void 0 : (_d$structure$tree$fea2 = _d$structure$tree$fea.members) == null ? void 0 : _d$structure$tree$fea2.refObj.value;
16780
+ });
16781
+ const name = react.useDrawing(drawingId, d => {
16782
+ var _d$structure$tree$fea3;
16144
16783
 
16145
- return (_d$plugin$refs$featur = d.plugin.refs[featureId]) == null ? void 0 : _d$plugin$refs$featur.View;
16784
+ return (_d$structure$tree$fea3 = d.structure.tree[featureId]) == null ? void 0 : _d$structure$tree$fea3.name;
16146
16785
  });
16147
- const hasGraphics = Boolean(view);
16786
+ const visible = react.useDrawing(drawingId, d => d.plugin.visible.indexOf(featureId) >= 0);
16787
+ const hasGraphics = useHasView(drawingId, featureId);
16148
16788
  const isActive = react.useDrawing(drawingId, d => d.plugin.active.feature === featureId);
16149
- const isCustom = useIsCustom(drawingId, featureId);
16789
+ const isCustom = useIsCustom(drawingId, featureRefId);
16150
16790
  const disabled = useIsDisabled(drawingId, featureId);
16791
+ const errorId = usePrecheckErrorId(drawingId, featureId);
16151
16792
  const [rename, setRename] = React.useState(false);
16152
16793
  const onNameClick = React.useCallback(() => {
16153
16794
  !disabled && core.getDrawing(drawingId).api.plugin.setActiveFeature(featureId);
@@ -16168,6 +16809,7 @@ const Feature = ({
16168
16809
  const pluginApi = core.getDrawing(drawingId).api.plugin;
16169
16810
  pluginApi.setVisiblePlugin(featureId, !visible);
16170
16811
  }, [drawingId, visible, featureId, disabled, rename]);
16812
+ const [isMenuHovered, setIsMenuHovered] = React.useState(false);
16171
16813
  const menuItems = useMenuItems$2(drawingId, featureId, isActive, setRename);
16172
16814
  const eyeComponent = React.useMemo(() => {
16173
16815
  if (!hasGraphics) return /*#__PURE__*/React.createElement("div", {
@@ -16190,51 +16832,20 @@ const Feature = ({
16190
16832
  });
16191
16833
  }, [hasGraphics, visible, disabled, onEyeClick]);
16192
16834
  return /*#__PURE__*/React.createElement(HoveredDiv, {
16193
- style: {
16194
- borderBottom: '1px solid #f0f0f0',
16195
- padding: '4px 10px'
16196
- },
16835
+ hovered: isMenuHovered,
16836
+ bordered: true,
16197
16837
  title: String(featureId)
16198
- }, /*#__PURE__*/React.createElement(antd.Space, null, eyeComponent, nameComponent), isCustom && /*#__PURE__*/React.createElement(Menu, {
16199
- items: menuItems
16200
- }));
16201
- };
16202
-
16203
- function useFeaturesIds(drawingId, curNodeId) {
16204
- const curClass = react.useDrawing(drawingId, d => d.structure.tree[curNodeId].class);
16205
- const prodId = react.useDrawing(drawingId, d => {
16206
- if (curClass === classcad.CCClasses.CCProductReference || curClass === classcad.CCClasses.CCProductReferenceET) {
16207
- const node = d.structure.tree[curNodeId];
16208
- return node.members.productId.value;
16838
+ }, /*#__PURE__*/React.createElement(antd.Space, {
16839
+ style: {
16840
+ flex: 1
16209
16841
  }
16210
-
16211
- return curNodeId;
16212
- });
16213
- const featuresIds = react.useDrawing(drawingId, d => {
16214
- var _d$structure$tree$pro;
16215
-
16216
- return ((_d$structure$tree$pro = d.structure.tree[prodId]) == null ? void 0 : _d$structure$tree$pro.features) || [];
16217
- });
16218
- return featuresIds;
16219
- }
16220
-
16221
- /**
16222
- * Validator for FeatureList component. Checks drawing and currentProduct existance.
16223
- *
16224
- * @param drawingId
16225
- * @returns
16226
- */
16227
-
16228
- const FeatureListValidator = ({
16229
- drawingId,
16230
- children
16231
- }) => {
16232
- const warnings = {};
16233
- useDrawingVerifier(drawingId, warnings);
16234
- useRootOrProdVerifier(drawingId, warnings);
16235
- return /*#__PURE__*/React.createElement(ErrorBoundary, {
16236
- warnings: warnings
16237
- }, children);
16842
+ }, eyeComponent, nameComponent), errorId && /*#__PURE__*/React.createElement(PrecheckError, {
16843
+ drawingId: drawingId,
16844
+ errorId: errorId
16845
+ }), isCustom && /*#__PURE__*/React.createElement(Menu, {
16846
+ items: menuItems,
16847
+ onVisibleChange: setIsMenuHovered
16848
+ }));
16238
16849
  };
16239
16850
 
16240
16851
  const _excluded$1 = ["children"];
@@ -16248,7 +16859,7 @@ const SortableCont = reactSortableHoc.SortableContainer(_ref => {
16248
16859
  });
16249
16860
  const SortableItem = reactSortableHoc.SortableElement(({
16250
16861
  drawingId,
16251
- featureId,
16862
+ featureRefId,
16252
16863
  isRollbackBar
16253
16864
  }) => {
16254
16865
  if (isRollbackBar) return /*#__PURE__*/React.createElement("div", {
@@ -16274,36 +16885,53 @@ const SortableItem = reactSortableHoc.SortableElement(({
16274
16885
  }
16275
16886
  }));else return /*#__PURE__*/React.createElement(Feature, {
16276
16887
  drawingId: drawingId,
16277
- featureId: featureId
16888
+ featureRefId: featureRefId
16278
16889
  });
16279
16890
  });
16280
16891
 
16281
16892
  const Item$1 = ({
16282
16893
  drawingId,
16283
- featureId
16894
+ featureRefId
16284
16895
  }) => {
16285
16896
  const curPartId = react.useDrawing(drawingId, d => d.structure.currentProduct || d.structure.root);
16286
- const featuresIds = useFeaturesIds(drawingId, curPartId);
16897
+ const opSeqId = useOperationSequence(drawingId, curPartId);
16898
+ const idx = react.useDrawing(drawingId, d => {
16899
+ var _d$structure$tree, _d$structure$tree$chi;
16900
+
16901
+ return (_d$structure$tree = d.structure.tree[opSeqId || -1]) == null ? void 0 : (_d$structure$tree$chi = _d$structure$tree.children) == null ? void 0 : _d$structure$tree$chi.indexOf(featureRefId);
16902
+ }) || -1;
16903
+ const featureId = react.useDrawing(drawingId, d => {
16904
+ var _d$structure$tree$fea, _d$structure$tree$fea2;
16905
+
16906
+ return (_d$structure$tree$fea = d.structure.tree[featureRefId]) == null ? void 0 : (_d$structure$tree$fea2 = _d$structure$tree$fea.members) == null ? void 0 : _d$structure$tree$fea2.refObj.value;
16907
+ });
16287
16908
  const objClass = react.useDrawing(drawingId, d => {
16288
- var _d$structure$tree$fea;
16909
+ var _d$structure$tree$fea3;
16289
16910
 
16290
- return ((_d$structure$tree$fea = d.structure.tree[featureId]) == null ? void 0 : _d$structure$tree$fea.class) || '';
16911
+ return ((_d$structure$tree$fea3 = d.structure.tree[featureId]) == null ? void 0 : _d$structure$tree$fea3.class) || '';
16291
16912
  });
16292
- const idx = featuresIds.findIndex(fId => fId === featureId);
16913
+ const isFeatureActive = react.useDrawing(drawingId, d => d.plugin.active.feature !== null) || false;
16293
16914
  const isRollbackBar = objClass === classcad.CCClasses.CCRollbackBar;
16915
+ const isDisabled = !isRollbackBar || isFeatureActive;
16294
16916
  return /*#__PURE__*/React.createElement(SortableItem, {
16295
16917
  drawingId: drawingId,
16296
- featureId: featureId,
16918
+ featureRefId: featureRefId,
16297
16919
  isRollbackBar: isRollbackBar,
16298
- disabled: !isRollbackBar,
16920
+ disabled: isDisabled,
16299
16921
  index: idx
16300
16922
  });
16301
16923
  };
16302
16924
 
16303
16925
  const List$2 = ({
16304
- featureIds,
16305
16926
  drawingId
16306
16927
  }) => {
16928
+ const curPartId = react.useDrawing(drawingId, d => d.structure.currentProduct || d.structure.root);
16929
+ const opSeqId = useOperationSequence(drawingId, curPartId);
16930
+ const featureRefIds = react.useDrawing(drawingId, d => {
16931
+ var _d$structure$tree2;
16932
+
16933
+ return (_d$structure$tree2 = d.structure.tree[opSeqId || -1]) == null ? void 0 : _d$structure$tree2.children;
16934
+ }) || [];
16307
16935
  return /*#__PURE__*/React.createElement(SortableCont, {
16308
16936
  helperClass: "row-dragging",
16309
16937
  lockAxis: "y",
@@ -16311,11 +16939,8 @@ const List$2 = ({
16311
16939
  oldIndex,
16312
16940
  newIndex
16313
16941
  }) => {
16314
- var _object$features;
16315
-
16316
16942
  const rootId_ = core.getDrawing(drawingId).structure.currentProduct;
16317
- const object = core.getDrawing(drawingId).structure.tree[rootId_];
16318
- const features = (_object$features = object == null ? void 0 : object.features) != null ? _object$features : [];
16943
+ const features = getFeaturesIds(drawingId, rootId_);
16319
16944
  const offset = 4;
16320
16945
  const move = classcad.ccAPI.feature.rollback.calculateMovement(oldIndex, newIndex, features, offset);
16321
16946
 
@@ -16325,30 +16950,19 @@ const List$2 = ({
16325
16950
  classcad.ccAPI.feature.rollback.moveBefore(drawingId, move.featureId).catch();
16326
16951
  }
16327
16952
  }
16328
- }, featureIds.map(fId => /*#__PURE__*/React.createElement(Item$1, {
16329
- key: fId,
16953
+ }, featureRefIds.map(refId => /*#__PURE__*/React.createElement(Item$1, {
16954
+ key: refId,
16330
16955
  drawingId: drawingId,
16331
- featureId: fId
16956
+ featureRefId: refId
16332
16957
  })));
16333
16958
  };
16334
16959
 
16335
- const FeatureListImpl = ({
16336
- drawingId
16337
- }) => {
16338
- const curPartId = react.useDrawing(drawingId, d => d.structure.currentProduct || d.structure.root);
16339
- const featuresIds = useFeaturesIds(drawingId, curPartId);
16340
- return /*#__PURE__*/React.createElement(List$2, {
16341
- drawingId: drawingId,
16342
- featureIds: featuresIds
16343
- });
16344
- };
16345
-
16346
16960
  const FeatureList = ({
16347
16961
  drawingId
16348
16962
  }) => {
16349
16963
  return /*#__PURE__*/React.createElement(FeatureListValidator, {
16350
16964
  drawingId: drawingId
16351
- }, /*#__PURE__*/React.createElement(FeatureListImpl, {
16965
+ }, /*#__PURE__*/React.createElement(List$2, {
16352
16966
  drawingId: drawingId
16353
16967
  }));
16354
16968
  };
@@ -16374,35 +16988,6 @@ function useMenuItems$1(drawingId, objectId, setRename) {
16374
16988
  }, [drawingId, objectId, setRename]);
16375
16989
  }
16376
16990
 
16377
- const Indent = () => {
16378
- return /*#__PURE__*/React.createElement("span", {
16379
- className: "ant-tree-indent"
16380
- }, /*#__PURE__*/React.createElement("span", {
16381
- className: "ant-tree-indent-unit"
16382
- }));
16383
- };
16384
- const Indents = ({
16385
- level
16386
- }) => {
16387
- const arr = Array.from(Array(level).keys());
16388
- return /*#__PURE__*/React.createElement(React.Fragment, null, arr.map(i => /*#__PURE__*/React.createElement(Indent, {
16389
- key: i
16390
- })));
16391
- };
16392
- const CollapseButton = ({
16393
- collapsed,
16394
- onClick
16395
- }) => {
16396
- return /*#__PURE__*/React.createElement("span", {
16397
- className: "ant-tree-switcher",
16398
- onClick: onClick
16399
- }, /*#__PURE__*/React.createElement("span", {
16400
- role: "img",
16401
- "aria-label": "caret-down",
16402
- className: "anticon anticon-caret-down ant-tree-switcher-icon"
16403
- }, collapsed ? /*#__PURE__*/React.createElement(icons.CaretRightOutlined, null) : /*#__PURE__*/React.createElement(icons.CaretDownOutlined, null)));
16404
- };
16405
-
16406
16991
  function setProductsHidden(drawingId, prodId, hidden) {
16407
16992
  var _getDrawing$structure;
16408
16993
 
@@ -16451,6 +17036,7 @@ const NodeTitle = ({
16451
17036
  const referedObj = react.useDrawing(drawingId, d => d.structure.tree[referedId]);
16452
17037
  const name = referedObj.name;
16453
17038
  const [rename, setRename] = React.useState(false);
17039
+ const [isMenuHovered, setIsMenuHovered] = React.useState(false);
16454
17040
  const menuItems = useMenuItems$1(drawingId, refId, setRename);
16455
17041
  const nameComponent = rename ? /*#__PURE__*/React.createElement(NameEdit, {
16456
17042
  drawingId: drawingId,
@@ -16463,11 +17049,14 @@ const NodeTitle = ({
16463
17049
  onClick: onClick,
16464
17050
  name: name
16465
17051
  }));
16466
- return /*#__PURE__*/React.createElement(HoveredDiv, null, /*#__PURE__*/React.createElement(antd.Space, null, /*#__PURE__*/React.createElement(EyeIcon, {
17052
+ return /*#__PURE__*/React.createElement(HoveredDiv, {
17053
+ hovered: isMenuHovered
17054
+ }, /*#__PURE__*/React.createElement(antd.Space, null, /*#__PURE__*/React.createElement(EyeIcon, {
16467
17055
  drawingId: drawingId,
16468
17056
  refId: refId
16469
17057
  }), referedObj.class === classcad.CCClasses.CCAssembly ? /*#__PURE__*/React.createElement(icons.AppstoreOutlined, null) : /*#__PURE__*/React.createElement(icons.FileOutlined, null), nameComponent), /*#__PURE__*/React.createElement(Menu, {
16470
- items: menuItems
17058
+ items: menuItems,
17059
+ onVisibleChange: setIsMenuHovered
16471
17060
  }));
16472
17061
  };
16473
17062
 
@@ -16563,6 +17152,7 @@ const AssemblyTreeHeader = ({
16563
17152
  const currNode = useCurrentNode(drawingId);
16564
17153
  const objDetails = useObjectDetails(drawingId, (currNode == null ? void 0 : currNode.id) || -1);
16565
17154
  const showBackBtn = React.useMemo(() => pStackNotEmpty || !objDetails.isRoot && (objDetails.isAssemblyNode || objDetails.isAssembly), [objDetails.isAssembly, objDetails.isAssemblyNode, objDetails.isRoot, pStackNotEmpty]);
17155
+ const isFeatureActive = react.useDrawing(drawingId, d => d.plugin.active.feature !== null) || false;
16566
17156
  const name = currProd ? currProd.name : currNode ? currNode.name : '';
16567
17157
  const [rename, setRename] = React.useState(false);
16568
17158
  const [showNameChoice, setShowNameChoice] = React.useState(false);
@@ -16593,6 +17183,19 @@ const AssemblyTreeHeader = ({
16593
17183
  title: 'Export node as ' + type,
16594
17184
  placement: "right"
16595
17185
  }, type))));
17186
+ const exportComponent = isFeatureActive ? /*#__PURE__*/React.createElement(antd.Tooltip, {
17187
+ title: "All features should be closed before exporting",
17188
+ placement: "left"
17189
+ }, /*#__PURE__*/React.createElement(antd.Button, {
17190
+ icon: /*#__PURE__*/React.createElement(icons.ExportOutlined, null),
17191
+ size: "small",
17192
+ disabled: true
17193
+ })) : /*#__PURE__*/React.createElement(antd.Dropdown, {
17194
+ overlay: menu
17195
+ }, /*#__PURE__*/React.createElement(antd.Button, {
17196
+ icon: /*#__PURE__*/React.createElement(icons.ExportOutlined, null),
17197
+ size: "small"
17198
+ }));
16596
17199
  const nameComponent = rename ? /*#__PURE__*/React.createElement(NameEdit, {
16597
17200
  drawingId: drawingId,
16598
17201
  objId: (currProd == null ? void 0 : currProd.id) || -1,
@@ -16607,12 +17210,7 @@ const AssemblyTreeHeader = ({
16607
17210
  size: "small",
16608
17211
  icon: /*#__PURE__*/React.createElement(icons.LeftOutlined, null),
16609
17212
  onClick: () => api.assemblyTree.goBack(drawingId)
16610
- }), nameComponent), /*#__PURE__*/React.createElement(antd.Space, null, /*#__PURE__*/React.createElement(antd.Dropdown, {
16611
- overlay: menu
16612
- }, /*#__PURE__*/React.createElement(antd.Button, {
16613
- icon: /*#__PURE__*/React.createElement(icons.ExportOutlined, null),
16614
- size: "small"
16615
- })), mode === EditMode.Assembly && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(antd.Tooltip, {
17213
+ }), nameComponent), /*#__PURE__*/React.createElement(antd.Space, null, exportComponent, mode === EditMode.Assembly && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(antd.Tooltip, {
16616
17214
  title: "Convert to subassembly"
16617
17215
  }, /*#__PURE__*/React.createElement(antd.Button, {
16618
17216
  onClick: () => setShowNameChoice(true),
@@ -16793,6 +17391,7 @@ const Entity = ({
16793
17391
  const isActive = react.useDrawing(drawingId, d => d.plugin.active.feature === constraintId);
16794
17392
  const hover = useComponentInteraction(drawingId, state => state.api);
16795
17393
  const [rename, setRename] = React.useState(false);
17394
+ const [isMenuHovered, setIsMenuHovered] = React.useState(false);
16796
17395
  const menuItems = useMenuItems$2(drawingId, constraintId, isActive, setRename);
16797
17396
  const onNameClick = React.useCallback(() => {
16798
17397
  core.getDrawing(drawingId).api.plugin.setActiveFeature(constraintId);
@@ -16816,12 +17415,11 @@ const Entity = ({
16816
17415
  onMouseLeave: onMouseLeave
16817
17416
  });
16818
17417
  return /*#__PURE__*/React.createElement(HoveredDiv, {
16819
- style: {
16820
- borderBottom: '1px solid #f0f0f0',
16821
- padding: '4px 10px'
16822
- }
17418
+ hovered: isMenuHovered,
17419
+ bordered: true
16823
17420
  }, /*#__PURE__*/React.createElement(antd.Space, null, nameComponent), /*#__PURE__*/React.createElement(Menu, {
16824
- items: menuItems
17421
+ items: menuItems,
17422
+ onVisibleChange: setIsMenuHovered
16825
17423
  }));
16826
17424
  }; // TODO: Create external component
16827
17425
 
@@ -16955,7 +17553,8 @@ const ColorPicker = ({
16955
17553
  const geomApi = core.getDrawing(drawingId).api.geometry;
16956
17554
  geomApi.setConfig(solidId, {
16957
17555
  meshes: {
16958
- color: undefined
17556
+ color: undefined,
17557
+ opacity: undefined
16959
17558
  }
16960
17559
  });
16961
17560
  setShowPicker(false);
@@ -16965,7 +17564,8 @@ const ColorPicker = ({
16965
17564
  const geomApi = core.getDrawing(drawingId).api.geometry;
16966
17565
  geomApi.setConfig(solidId, {
16967
17566
  meshes: {
16968
- color: undefined
17567
+ color: undefined,
17568
+ opacity: undefined
16969
17569
  }
16970
17570
  });
16971
17571
  setUColor({
@@ -17071,12 +17671,11 @@ const Solid = ({
17071
17671
  }) || -1;
17072
17672
  const ccSolid = react.useDrawing(drawingId, d => d.structure.tree[solidOwner]);
17073
17673
  const [rename, setRename] = React.useState(false);
17674
+ const [isMenuHovered, setIsMenuHovered] = React.useState(false);
17074
17675
  const menuItems = useMenuItems(setRename);
17075
17676
  return /*#__PURE__*/React.createElement(HoveredDiv, {
17076
- style: {
17077
- borderBottom: '1px solid #f0f0f0',
17078
- padding: '4px 10px'
17079
- }
17677
+ hovered: isMenuHovered,
17678
+ bordered: true
17080
17679
  }, /*#__PURE__*/React.createElement(antd.Space, null, /*#__PURE__*/React.createElement(EyeComponent, {
17081
17680
  drawingId: drawingId,
17082
17681
  solidId: solidId
@@ -17089,7 +17688,8 @@ const Solid = ({
17089
17688
  drawingId: drawingId,
17090
17689
  solidId: solidId
17091
17690
  }), /*#__PURE__*/React.createElement(Menu, {
17092
- items: menuItems
17691
+ items: menuItems,
17692
+ onVisibleChange: setIsMenuHovered
17093
17693
  })));
17094
17694
  }; // TODO: Create external component
17095
17695
 
@@ -17238,9 +17838,9 @@ const Spinner = styled.div`
17238
17838
  transform: translateZ(0);
17239
17839
  `;
17240
17840
 
17241
- function ownKeys$3(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
17841
+ function ownKeys$5(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
17242
17842
 
17243
- function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$3(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$3(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
17843
+ function _objectSpread$5(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$5(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$5(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
17244
17844
  const LoadingWrapper = styled.div`
17245
17845
  position: absolute;
17246
17846
  display: flex;
@@ -17261,7 +17861,7 @@ const LoadingScreen = ({
17261
17861
  children
17262
17862
  }) => {
17263
17863
  return /*#__PURE__*/React.createElement("div", {
17264
- style: _objectSpread$3(_objectSpread$3({}, style), {}, {
17864
+ style: _objectSpread$5(_objectSpread$5({}, style), {}, {
17265
17865
  position: 'relative'
17266
17866
  })
17267
17867
  }, isLoading && /*#__PURE__*/React.createElement(LoadingWrapper, null, /*#__PURE__*/React.createElement(Spinner, null), /*#__PURE__*/React.createElement("div", null, "Loading...")), children);
@@ -17405,9 +18005,9 @@ const useResize = (x, y, width, height, onResize) => {
17405
18005
 
17406
18006
  const _excluded = ["id", "modalState", "dispatch", "visible", "children", "title", "initialWidth", "initialHeight", "initialX", "initialY", "resizable", "minPosition", "maxPosition"];
17407
18007
 
17408
- function ownKeys$2(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
18008
+ function ownKeys$4(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
17409
18009
 
17410
- function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$2(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$2(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
18010
+ function _objectSpread$4(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$4(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$4(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
17411
18011
  const modalStyle = {
17412
18012
  margin: 0,
17413
18013
  paddingBottom: 0,
@@ -17477,7 +18077,7 @@ function DraggableModalInnerNonMemo(_ref) {
17477
18077
  width,
17478
18078
  height
17479
18079
  } = modalState;
17480
- const style = React.useMemo(() => _objectSpread$2(_objectSpread$2({}, modalStyle), {}, {
18080
+ const style = React.useMemo(() => _objectSpread$4(_objectSpread$4({}, modalStyle), {}, {
17481
18081
  top: y,
17482
18082
  left: x,
17483
18083
  height: resizable ? height : 'auto'
@@ -17487,14 +18087,14 @@ function DraggableModalInnerNonMemo(_ref) {
17487
18087
  type: 'focus',
17488
18088
  id
17489
18089
  }), [id, dispatch]);
17490
- const onDragWithID = React.useCallback(args => dispatch(_objectSpread$2(_objectSpread$2({
18090
+ const onDragWithID = React.useCallback(args => dispatch(_objectSpread$4(_objectSpread$4({
17491
18091
  type: 'drag',
17492
18092
  id
17493
18093
  }, args), {}, {
17494
18094
  minPosition,
17495
18095
  maxPosition
17496
18096
  })), [dispatch, id, minPosition, maxPosition]);
17497
- const onResizeWithID = React.useCallback(args => dispatch(_objectSpread$2({
18097
+ const onResizeWithID = React.useCallback(args => dispatch(_objectSpread$4({
17498
18098
  type: 'resize',
17499
18099
  id
17500
18100
  }, args)), [dispatch, id]);
@@ -17533,9 +18133,9 @@ const getWindowSize = () => ({
17533
18133
 
17534
18134
  const clamp = (min, max, value) => Math.max(min, Math.min(max, value));
17535
18135
 
17536
- function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
18136
+ function ownKeys$3(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
17537
18137
 
17538
- function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$1(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
18138
+ function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$3(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$3(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
17539
18139
 
17540
18140
  const mapObject = (o, f) => Object.assign({}, ...Object.keys(o).map(k => ({
17541
18141
  [k]: f(o[k])
@@ -17635,10 +18235,10 @@ const draggableModalReducer = (state, action) => {
17635
18235
  switch (action.type) {
17636
18236
  case 'resize':
17637
18237
  const size = clampResize(state.windowSize.width, state.windowSize.height, action.x, action.y, action.width, action.height);
17638
- return _objectSpread$1(_objectSpread$1({}, state), {}, {
18238
+ return _objectSpread$3(_objectSpread$3({}, state), {}, {
17639
18239
  maxZIndex: getNextZIndex(state, action.id),
17640
- modals: _objectSpread$1(_objectSpread$1({}, state.modals), {}, {
17641
- [action.id]: _objectSpread$1(_objectSpread$1(_objectSpread$1({}, state.modals[action.id]), size), {}, {
18240
+ modals: _objectSpread$3(_objectSpread$3({}, state.modals), {}, {
18241
+ [action.id]: _objectSpread$3(_objectSpread$3(_objectSpread$3({}, state.modals[action.id]), size), {}, {
17642
18242
  zIndex: getNextZIndex(state, action.id)
17643
18243
  })
17644
18244
  })
@@ -17646,10 +18246,10 @@ const draggableModalReducer = (state, action) => {
17646
18246
 
17647
18247
  case 'drag':
17648
18248
  const modal = state.modals[action.id];
17649
- return _objectSpread$1(_objectSpread$1({}, state), {}, {
18249
+ return _objectSpread$3(_objectSpread$3({}, state), {}, {
17650
18250
  maxZIndex: getNextZIndex(state, action.id),
17651
- modals: _objectSpread$1(_objectSpread$1({}, state.modals), {}, {
17652
- [action.id]: _objectSpread$1(_objectSpread$1(_objectSpread$1({}, state.modals[action.id]), clampDrag(action.x, action.y, state.modals[action.id].width || 0, state.modals[action.id].height || 0, modal.maxPosition.x ? Math.min(modal.maxPosition.x, state.windowSize.width) : state.windowSize.width, modal.maxPosition.y ? Math.min(modal.maxPosition.y, state.windowSize.height) : state.windowSize.height, ((_action$minPosition = action.minPosition) == null ? void 0 : _action$minPosition.x) || 0, ((_action$minPosition2 = action.minPosition) == null ? void 0 : _action$minPosition2.y) || 0)), {}, {
18251
+ modals: _objectSpread$3(_objectSpread$3({}, state.modals), {}, {
18252
+ [action.id]: _objectSpread$3(_objectSpread$3(_objectSpread$3({}, state.modals[action.id]), clampDrag(action.x, action.y, state.modals[action.id].width || 0, state.modals[action.id].height || 0, modal.maxPosition.x ? Math.min(modal.maxPosition.x, state.windowSize.width) : state.windowSize.width, modal.maxPosition.y ? Math.min(modal.maxPosition.y, state.windowSize.height) : state.windowSize.height, ((_action$minPosition = action.minPosition) == null ? void 0 : _action$minPosition.x) || 0, ((_action$minPosition2 = action.minPosition) == null ? void 0 : _action$minPosition2.y) || 0)), {}, {
17653
18253
  zIndex: getNextZIndex(state, action.id)
17654
18254
  })
17655
18255
  })
@@ -17669,10 +18269,10 @@ const draggableModalReducer = (state, action) => {
17669
18269
  // modalState.height || 0,
17670
18270
  // )
17671
18271
 
17672
- return _objectSpread$1(_objectSpread$1({}, state), {}, {
18272
+ return _objectSpread$3(_objectSpread$3({}, state), {}, {
17673
18273
  maxZIndex: state.maxZIndex + 1,
17674
- modals: _objectSpread$1(_objectSpread$1({}, state.modals), {}, {
17675
- [action.id]: _objectSpread$1(_objectSpread$1(_objectSpread$1({}, modalState_), position), {}, {
18274
+ modals: _objectSpread$3(_objectSpread$3({}, state.modals), {}, {
18275
+ [action.id]: _objectSpread$3(_objectSpread$3(_objectSpread$3({}, modalState_), position), {}, {
17676
18276
  // ...size,
17677
18277
  zIndex: state.maxZIndex + 1,
17678
18278
  visible: true
@@ -17683,10 +18283,10 @@ const draggableModalReducer = (state, action) => {
17683
18283
 
17684
18284
  case 'focus':
17685
18285
  const modalState = state.modals[action.id];
17686
- return _objectSpread$1(_objectSpread$1({}, state), {}, {
18286
+ return _objectSpread$3(_objectSpread$3({}, state), {}, {
17687
18287
  maxZIndex: state.maxZIndex + 1,
17688
- modals: _objectSpread$1(_objectSpread$1({}, state.modals), {}, {
17689
- [action.id]: _objectSpread$1(_objectSpread$1({}, modalState), {}, {
18288
+ modals: _objectSpread$3(_objectSpread$3({}, state.modals), {}, {
18289
+ [action.id]: _objectSpread$3(_objectSpread$3({}, modalState), {}, {
17690
18290
  zIndex: state.maxZIndex + 1
17691
18291
  })
17692
18292
  })
@@ -17695,9 +18295,9 @@ const draggableModalReducer = (state, action) => {
17695
18295
  case 'hide':
17696
18296
  {
17697
18297
  const modalState_ = state.modals[action.id];
17698
- return _objectSpread$1(_objectSpread$1({}, state), {}, {
17699
- modals: _objectSpread$1(_objectSpread$1({}, state.modals), {}, {
17700
- [action.id]: _objectSpread$1(_objectSpread$1({}, modalState_), {}, {
18298
+ return _objectSpread$3(_objectSpread$3({}, state), {}, {
18299
+ modals: _objectSpread$3(_objectSpread$3({}, state.modals), {}, {
18300
+ [action.id]: _objectSpread$3(_objectSpread$3({}, modalState_), {}, {
17701
18301
  visible: false
17702
18302
  })
17703
18303
  })
@@ -17705,26 +18305,26 @@ const draggableModalReducer = (state, action) => {
17705
18305
  }
17706
18306
 
17707
18307
  case 'mount':
17708
- const initialState = getInitialModalState(_objectSpread$1({}, action.intialState));
17709
- return _objectSpread$1(_objectSpread$1({}, state), {}, {
18308
+ const initialState = getInitialModalState(_objectSpread$3({}, action.intialState));
18309
+ return _objectSpread$3(_objectSpread$3({}, state), {}, {
17710
18310
  maxZIndex: state.maxZIndex + 1,
17711
- modals: _objectSpread$1(_objectSpread$1({}, state.modals), {}, {
17712
- [action.id]: _objectSpread$1(_objectSpread$1(_objectSpread$1({}, state.modals[action.id]), initialState), {}, {
18311
+ modals: _objectSpread$3(_objectSpread$3({}, state.modals), {}, {
18312
+ [action.id]: _objectSpread$3(_objectSpread$3(_objectSpread$3({}, state.modals[action.id]), initialState), {}, {
17713
18313
  zIndex: state.maxZIndex + 1
17714
18314
  })
17715
18315
  })
17716
18316
  });
17717
18317
 
17718
18318
  case 'unmount':
17719
- const modalsClone = _objectSpread$1({}, state.modals);
18319
+ const modalsClone = _objectSpread$3({}, state.modals);
17720
18320
 
17721
18321
  delete modalsClone[action.id];
17722
- return _objectSpread$1(_objectSpread$1({}, state), {}, {
18322
+ return _objectSpread$3(_objectSpread$3({}, state), {}, {
17723
18323
  modals: modalsClone
17724
18324
  });
17725
18325
 
17726
18326
  case 'windowResize':
17727
- return _objectSpread$1(_objectSpread$1({}, state), {}, {
18327
+ return _objectSpread$3(_objectSpread$3({}, state), {}, {
17728
18328
  windowSize: action.size,
17729
18329
  modals: mapObject(state.modals, modalState_ => {
17730
18330
  if (!modalState_.visible) {
@@ -17740,24 +18340,24 @@ const draggableModalReducer = (state, action) => {
17740
18340
  // modalState.height || 0,
17741
18341
  // )
17742
18342
 
17743
- return _objectSpread$1(_objectSpread$1({}, modalState_), position);
18343
+ return _objectSpread$3(_objectSpread$3({}, modalState_), position);
17744
18344
  })
17745
18345
  });
17746
18346
 
17747
18347
  case 'updateMinPosition':
17748
- return _objectSpread$1(_objectSpread$1({}, state), {}, {
17749
- modals: _objectSpread$1(_objectSpread$1({}, state.modals), {}, {
17750
- [action.id]: _objectSpread$1(_objectSpread$1({}, state.modals[action.id]), {}, {
17751
- minPosition: _objectSpread$1(_objectSpread$1({}, state.modals[action.id].minPosition), action.value)
18348
+ return _objectSpread$3(_objectSpread$3({}, state), {}, {
18349
+ modals: _objectSpread$3(_objectSpread$3({}, state.modals), {}, {
18350
+ [action.id]: _objectSpread$3(_objectSpread$3({}, state.modals[action.id]), {}, {
18351
+ minPosition: _objectSpread$3(_objectSpread$3({}, state.modals[action.id].minPosition), action.value)
17752
18352
  })
17753
18353
  })
17754
18354
  });
17755
18355
 
17756
18356
  case 'updateMaxPosition':
17757
- return _objectSpread$1(_objectSpread$1({}, state), {}, {
17758
- modals: _objectSpread$1(_objectSpread$1({}, state.modals), {}, {
17759
- [action.id]: _objectSpread$1(_objectSpread$1({}, state.modals[action.id]), {}, {
17760
- maxPosition: _objectSpread$1(_objectSpread$1({}, state.modals[action.id].maxPosition), action.value)
18357
+ return _objectSpread$3(_objectSpread$3({}, state), {}, {
18358
+ modals: _objectSpread$3(_objectSpread$3({}, state.modals), {}, {
18359
+ [action.id]: _objectSpread$3(_objectSpread$3({}, state.modals[action.id]), {}, {
18360
+ maxPosition: _objectSpread$3(_objectSpread$3({}, state.modals[action.id].maxPosition), action.value)
17761
18361
  })
17762
18362
  })
17763
18363
  });
@@ -17770,9 +18370,9 @@ const draggableModalReducer = (state, action) => {
17770
18370
  var css_248z = "/**\n * NOTE: This is not compiled.\n */\n\n.ant-design-draggable-modal {\n pointer-events: none;\n overflow: hidden !important;\n}\n\n.ant-design-draggable-modal .ant-modal {\n display: flex;\n max-width: none;\n transform-origin: 50% 50% !important;\n}\n\n.ant-design-draggable-modal .ant-modal-content {\n flex: 1;\n display: flex;\n flex-direction: column;\n}\n\n.ant-design-draggable-modal .ant-modal-header {\n flex: 0;\n padding: 0;\n}\n\n.ant-design-draggable-modal .ant-modal-footer {\n flex: 0;\n padding: 16px;\n}\n\n.ant-design-draggable-modal .ant-design-draggable-modal-title {\n cursor: move;\n padding: 16px;\n}\n\n.ant-design-draggable-modal .ant-design-draggable-modal-title::before {\n content: '\\00a0';\n}\n\n.ant-design-draggable-modal .ant-modal-body {\n flex: 1;\n overflow-y: auto;\n padding: 16px;\n}\n\n.ant-design-draggable-modal-resize-handle-inner {\n width: 12px;\n right: 14px;\n border: 2px solid grey;\n height: 12px;\n bottom: 14px;\n position: absolute;\n border-top: 0;\n border-left: 0;\n}\n\n.ant-design-draggable-modal-resize-handle {\n right: -10px;\n width: 44px;\n bottom: -10px;\n cursor: se-resize;\n height: 44px;\n position: absolute;\n}\n";
17771
18371
  styleInject(css_248z);
17772
18372
 
17773
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
18373
+ function ownKeys$2(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
17774
18374
 
17775
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
18375
+ function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$2(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$2(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
17776
18376
  const DraggableModal = props => {
17777
18377
  // Get the unique ID of this modal.
17778
18378
  const id = reactUid.useUID(); // Get modal provider.
@@ -17807,7 +18407,7 @@ const DraggableModal = props => {
17807
18407
  maxPosition
17808
18408
  } = props;
17809
18409
  React__namespace.useEffect(() => {
17810
- const value = _objectSpread({
18410
+ const value = _objectSpread$2({
17811
18411
  x: null,
17812
18412
  y: null
17813
18413
  }, maxPosition);
@@ -17822,7 +18422,7 @@ const DraggableModal = props => {
17822
18422
  minPosition
17823
18423
  } = props;
17824
18424
  React__namespace.useEffect(() => {
17825
- const value = _objectSpread({
18425
+ const value = _objectSpread$2({
17826
18426
  x: null,
17827
18427
  y: null
17828
18428
  }, minPosition);
@@ -17888,15 +18488,17 @@ const FPluginWindow = ({
17888
18488
  const FeaturePlugin = ({
17889
18489
  drawingId
17890
18490
  }) => {
17891
- const activeFeature = react.useDrawing(drawingId, d => d.plugin.active.feature);
18491
+ const activeFeature = react.useDrawing(drawingId, d => d.plugin.active.feature); // Feature plugins are lazy loaded, so it's possible that recently activated feature plugins hasn't been created yet
18492
+
18493
+ const isCreated = react.usePluginExists(drawingId, activeFeature || -1);
17892
18494
  const name = react.useDrawing(drawingId, d => {
17893
- if (!activeFeature) return '';
18495
+ if (!activeFeature || !isCreated) return '';
17894
18496
  const objId = d.plugin.refs[activeFeature].objectId;
17895
18497
  const plugin = d.structure.tree[objId];
17896
18498
  return (plugin == null ? void 0 : plugin.name) || '';
17897
18499
  });
17898
18500
  const pluginAPI = core.getDrawing(drawingId).api.plugin;
17899
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(DraggableModalProvider, null, activeFeature && /*#__PURE__*/React.createElement(DraggableModal, {
18501
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(DraggableModalProvider, null, activeFeature && isCreated && /*#__PURE__*/React.createElement(DraggableModal, {
17900
18502
  visible: true,
17901
18503
  cancelButtonProps: {
17902
18504
  hidden: true
@@ -18025,7 +18627,7 @@ const ViewPlugButtons = ({
18025
18627
  }));
18026
18628
  };
18027
18629
 
18028
- const Icon = ({
18630
+ const Icon$1 = ({
18029
18631
  url
18030
18632
  }) => {
18031
18633
  return /*#__PURE__*/React.createElement("svg", {
@@ -18074,20 +18676,20 @@ const useOptionCommands = drawingId => {
18074
18676
  const commands = React.useMemo(() => {
18075
18677
  return [{
18076
18678
  label: 'Zoom fit',
18077
- icon: /*#__PURE__*/React.createElement(Icon, {
18679
+ icon: /*#__PURE__*/React.createElement(Icon$1, {
18078
18680
  url: img$q
18079
18681
  }),
18080
18682
  command: () => zoomToFit(drawingId)
18081
18683
  }, {
18082
18684
  label: 'Meshes',
18083
- icon: /*#__PURE__*/React.createElement(Icon, {
18685
+ icon: /*#__PURE__*/React.createElement(Icon$1, {
18084
18686
  url: img$p
18085
18687
  }),
18086
18688
  isChecked: showFaces,
18087
18689
  command: () => setShowFaces(!showFaces)
18088
18690
  }, {
18089
18691
  label: 'Wireframe',
18090
- icon: /*#__PURE__*/React.createElement(Icon, {
18692
+ icon: /*#__PURE__*/React.createElement(Icon$1, {
18091
18693
  url: img$n
18092
18694
  }),
18093
18695
  isChecked: showWireframe,
@@ -18095,14 +18697,14 @@ const useOptionCommands = drawingId => {
18095
18697
  command: () => setShowWireframe(!showWireframe)
18096
18698
  }, {
18097
18699
  label: 'Edges',
18098
- icon: /*#__PURE__*/React.createElement(Icon, {
18700
+ icon: /*#__PURE__*/React.createElement(Icon$1, {
18099
18701
  url: img$o
18100
18702
  }),
18101
18703
  isChecked: showEdges,
18102
18704
  command: () => setShowEdges(!showEdges)
18103
18705
  }, {
18104
18706
  label: 'Vertices',
18105
- icon: /*#__PURE__*/React.createElement(Icon, {
18707
+ icon: /*#__PURE__*/React.createElement(Icon$1, {
18106
18708
  url: img$E
18107
18709
  }),
18108
18710
  isChecked: showVertices,
@@ -18198,136 +18800,136 @@ const PartModeCmds = (drawingId, rootId) => {
18198
18800
  return {
18199
18801
  Sketch: {
18200
18802
  label: 'Sketch',
18201
- icon: /*#__PURE__*/React.createElement(Icon, {
18803
+ icon: /*#__PURE__*/React.createElement(Icon$1, {
18202
18804
  url: img$w
18203
18805
  }),
18204
18806
  callback: wrapper(() => classcad.ccAPI.sketcher.createSketch(drawingId, rootId))
18205
18807
  },
18206
18808
  Work: [{
18207
18809
  label: 'Workpoint',
18208
- icon: /*#__PURE__*/React.createElement(Icon, {
18810
+ icon: /*#__PURE__*/React.createElement(Icon$1, {
18209
18811
  url: img$m
18210
18812
  }),
18211
18813
  callback: wrapper(() => featureApi.createWorkPoint(drawingId, rootId))
18212
18814
  }, {
18213
18815
  label: 'Workaxis',
18214
- icon: /*#__PURE__*/React.createElement(Icon, {
18816
+ icon: /*#__PURE__*/React.createElement(Icon$1, {
18215
18817
  url: img$l
18216
18818
  }),
18217
18819
  callback: wrapper(() => featureApi.createWorkAxis(drawingId, rootId))
18218
18820
  }, {
18219
18821
  label: 'Workplane',
18220
- icon: /*#__PURE__*/React.createElement(Icon, {
18822
+ icon: /*#__PURE__*/React.createElement(Icon$1, {
18221
18823
  url: img$k
18222
18824
  }),
18223
18825
  callback: wrapper(() => featureApi.createWorkPlane(drawingId, rootId))
18224
18826
  }, {
18225
18827
  label: 'WCsys',
18226
- icon: /*#__PURE__*/React.createElement(Icon, {
18828
+ icon: /*#__PURE__*/React.createElement(Icon$1, {
18227
18829
  url: img$j
18228
18830
  }),
18229
18831
  callback: wrapper(() => featureApi.createWorkCoordSystem(drawingId, rootId))
18230
18832
  }],
18231
18833
  Solid: [{
18232
18834
  label: 'Extrusion',
18233
- icon: /*#__PURE__*/React.createElement(Icon, {
18835
+ icon: /*#__PURE__*/React.createElement(Icon$1, {
18234
18836
  url: img$G
18235
18837
  }),
18236
18838
  callback: wrapper(() => featureApi.createExtrusion(drawingId, rootId))
18237
18839
  }, {
18238
18840
  label: 'Revolve',
18239
- icon: /*#__PURE__*/React.createElement(Icon, {
18841
+ icon: /*#__PURE__*/React.createElement(Icon$1, {
18240
18842
  url: img$F
18241
18843
  }),
18242
18844
  callback: wrapper(() => featureApi.createRevolve(drawingId, rootId))
18243
18845
  }],
18244
18846
  Boolean: {
18245
18847
  label: 'Boolean',
18246
- icon: /*#__PURE__*/React.createElement(Icon, {
18848
+ icon: /*#__PURE__*/React.createElement(Icon$1, {
18247
18849
  url: img$i
18248
18850
  }),
18249
18851
  callback: wrapper(() => featureApi.createBooleanOperation(drawingId, rootId))
18250
18852
  },
18251
18853
  Slice: {
18252
18854
  label: 'Slice',
18253
- icon: /*#__PURE__*/React.createElement(Icon, {
18855
+ icon: /*#__PURE__*/React.createElement(Icon$1, {
18254
18856
  url: img$f
18255
18857
  }),
18256
18858
  callback: wrapper(() => featureApi.createFeature(drawingId, rootId, classcad.CCClasses.CCSlice, 'Slice'))
18257
18859
  },
18258
18860
  Edge: [{
18259
18861
  label: 'Fillet',
18260
- icon: /*#__PURE__*/React.createElement(Icon, {
18862
+ icon: /*#__PURE__*/React.createElement(Icon$1, {
18261
18863
  url: img$h
18262
18864
  }),
18263
18865
  callback: wrapper(() => featureApi.createFeature(drawingId, rootId, classcad.CCClasses.CCConstantRadiusFillet, 'Fillet'))
18264
18866
  }, {
18265
18867
  label: 'Chamfer',
18266
- icon: /*#__PURE__*/React.createElement(Icon, {
18868
+ icon: /*#__PURE__*/React.createElement(Icon$1, {
18267
18869
  url: img$g
18268
18870
  }),
18269
18871
  callback: wrapper(() => featureApi.createFeature(drawingId, rootId, classcad.CCClasses.CCChamfer, 'Chamfer'))
18270
18872
  }],
18271
18873
  Patterns: [{
18272
18874
  label: 'Linear pattern',
18273
- icon: /*#__PURE__*/React.createElement(Icon, {
18875
+ icon: /*#__PURE__*/React.createElement(Icon$1, {
18274
18876
  url: img$e
18275
18877
  }),
18276
18878
  callback: wrapper(() => featureApi.createFeature(drawingId, rootId, classcad.CCClasses.CCLinearPattern, 'Linear pattern'))
18277
18879
  }, {
18278
18880
  label: 'Circular pattern',
18279
- icon: /*#__PURE__*/React.createElement(Icon, {
18881
+ icon: /*#__PURE__*/React.createElement(Icon$1, {
18280
18882
  url: img$d
18281
18883
  }),
18282
18884
  callback: wrapper(() => featureApi.createFeature(drawingId, rootId, classcad.CCClasses.CCCircularPattern, 'Circular pattern'))
18283
18885
  }],
18284
18886
  Translation: [{
18285
18887
  label: 'Translation',
18286
- icon: /*#__PURE__*/React.createElement(Icon, {
18888
+ icon: /*#__PURE__*/React.createElement(Icon$1, {
18287
18889
  url: img$c
18288
18890
  }),
18289
18891
  callback: wrapper(() => featureApi.createFeature(drawingId, rootId, classcad.CCClasses.CCTranslation, 'Translate'))
18290
18892
  }, {
18291
18893
  label: 'Rotation',
18292
- icon: /*#__PURE__*/React.createElement(Icon, {
18894
+ icon: /*#__PURE__*/React.createElement(Icon$1, {
18293
18895
  url: img$b
18294
18896
  }),
18295
18897
  callback: wrapper(() => featureApi.createFeature(drawingId, rootId, classcad.CCClasses.CCRotation, 'Rotate'))
18296
18898
  }, {
18297
18899
  label: 'Transformation by Csys',
18298
- icon: /*#__PURE__*/React.createElement(Icon, {
18900
+ icon: /*#__PURE__*/React.createElement(Icon$1, {
18299
18901
  url: img$a
18300
18902
  }),
18301
18903
  callback: wrapper(() => featureApi.createFeature(drawingId, rootId, classcad.CCClasses.CCTransformationByCSys, 'Transform by Csys'))
18302
18904
  }],
18303
18905
  BasicShapes: [{
18304
18906
  label: 'Add Box',
18305
- icon: /*#__PURE__*/React.createElement(Icon, {
18907
+ icon: /*#__PURE__*/React.createElement(Icon$1, {
18306
18908
  url: img$n
18307
18909
  }),
18308
18910
  callback: wrapper(() => featureApi.createFeature(drawingId, rootId, 'CC_Box', 'Box'))
18309
18911
  }, {
18310
18912
  label: 'Add Sphere',
18311
- icon: /*#__PURE__*/React.createElement(Icon, {
18913
+ icon: /*#__PURE__*/React.createElement(Icon$1, {
18312
18914
  url: img$9
18313
18915
  }),
18314
18916
  callback: wrapper(() => featureApi.createFeature(drawingId, rootId, 'CC_Sphere', 'Sphere'))
18315
18917
  }, {
18316
18918
  label: 'Add Cylinder',
18317
- icon: /*#__PURE__*/React.createElement(Icon, {
18919
+ icon: /*#__PURE__*/React.createElement(Icon$1, {
18318
18920
  url: img$8
18319
18921
  }),
18320
18922
  callback: wrapper(() => featureApi.createFeature(drawingId, rootId, 'CC_Cylinder', 'Cylinder'))
18321
18923
  }, {
18322
18924
  label: 'Add Cone',
18323
- icon: /*#__PURE__*/React.createElement(Icon, {
18925
+ icon: /*#__PURE__*/React.createElement(Icon$1, {
18324
18926
  url: img$7
18325
18927
  }),
18326
18928
  callback: wrapper(() => featureApi.createFeature(drawingId, rootId, 'CC_Cone', 'Cone'))
18327
18929
  }],
18328
18930
  Import: {
18329
18931
  label: 'Import',
18330
- icon: /*#__PURE__*/React.createElement(Icon, {
18932
+ icon: /*#__PURE__*/React.createElement(Icon$1, {
18331
18933
  url: img$r
18332
18934
  }),
18333
18935
  callback: wrapper(() => featureApi.createFeature(drawingId, rootId, classcad.CCClasses.CCImport, 'Import'))
@@ -18382,49 +18984,49 @@ const AssemblyModeCmds = (drawingId, rootId) => {
18382
18984
  return {
18383
18985
  FastenedOrigin: {
18384
18986
  label: 'Add Fastened Origin',
18385
- icon: /*#__PURE__*/React.createElement(Icon, {
18987
+ icon: /*#__PURE__*/React.createElement(Icon$1, {
18386
18988
  url: img$6
18387
18989
  }),
18388
18990
  callback: wrapper(addFastenedOrigin)
18389
18991
  },
18390
18992
  Fastened: {
18391
18993
  label: 'Add Fastened',
18392
- icon: /*#__PURE__*/React.createElement(Icon, {
18994
+ icon: /*#__PURE__*/React.createElement(Icon$1, {
18393
18995
  url: img$5
18394
18996
  }),
18395
18997
  callback: wrapper(addFastened)
18396
18998
  },
18397
18999
  Slider: {
18398
19000
  label: 'Add Slider',
18399
- icon: /*#__PURE__*/React.createElement(Icon, {
19001
+ icon: /*#__PURE__*/React.createElement(Icon$1, {
18400
19002
  url: img$4
18401
19003
  }),
18402
19004
  callback: wrapper(addSlider)
18403
19005
  },
18404
19006
  Revolute: {
18405
19007
  label: 'Add Revolute',
18406
- icon: /*#__PURE__*/React.createElement(Icon, {
19008
+ icon: /*#__PURE__*/React.createElement(Icon$1, {
18407
19009
  url: img$3
18408
19010
  }),
18409
19011
  callback: wrapper(addRevolute)
18410
19012
  },
18411
19013
  Cylindrical: {
18412
19014
  label: 'Add Cylindrical',
18413
- icon: /*#__PURE__*/React.createElement(Icon, {
19015
+ icon: /*#__PURE__*/React.createElement(Icon$1, {
18414
19016
  url: img$2
18415
19017
  }),
18416
19018
  callback: wrapper(addCylindrical)
18417
19019
  },
18418
19020
  Planar: {
18419
19021
  label: 'Add Planar',
18420
- icon: /*#__PURE__*/React.createElement(Icon, {
19022
+ icon: /*#__PURE__*/React.createElement(Icon$1, {
18421
19023
  url: img$1
18422
19024
  }),
18423
19025
  callback: wrapper(addPlanar)
18424
19026
  },
18425
19027
  Parallel: {
18426
19028
  label: 'Add Parallel',
18427
- icon: /*#__PURE__*/React.createElement(Icon, {
19029
+ icon: /*#__PURE__*/React.createElement(Icon$1, {
18428
19030
  url: img
18429
19031
  }),
18430
19032
  callback: wrapper(addParallel)
@@ -18672,6 +19274,245 @@ const HoveredConstraintDisplay = ({
18672
19274
  }))));
18673
19275
  };
18674
19276
 
19277
+ function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
19278
+
19279
+ function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$1(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
19280
+
19281
+ function createApi(set) {
19282
+ return {
19283
+ setMsg: (msgId, msg) => set(prev => _objectSpread$1(_objectSpread$1({}, prev), {}, {
19284
+ msgs: _objectSpread$1(_objectSpread$1({}, prev.msgs), {}, {
19285
+ [msgId]: msg
19286
+ })
19287
+ })),
19288
+ deleteMsg: msgId => set(prev => {
19289
+ const newMsgs = _objectSpread$1({}, prev.msgs);
19290
+
19291
+ delete newMsgs[msgId];
19292
+ return _objectSpread$1(_objectSpread$1({}, prev), {}, {
19293
+ msgs: newMsgs
19294
+ });
19295
+ }),
19296
+ setShown: () => {
19297
+ set(prev => {
19298
+ const msgs = _objectSpread$1({}, prev.msgs);
19299
+
19300
+ Object.keys(msgs).forEach(msgId => {
19301
+ msgs[msgId].isShown = true;
19302
+ });
19303
+ return _objectSpread$1(_objectSpread$1({}, prev), {}, {
19304
+ msgs
19305
+ });
19306
+ });
19307
+ }
19308
+ };
19309
+ } // Buerli can store only single message in store.
19310
+ // But it will be convenient for the user to save all messages
19311
+ // and provide possibility to look through all messages came from the server.
19312
+
19313
+
19314
+ const useMsgStore = create((set, get) => ({
19315
+ msgs: {},
19316
+ api: createApi(set)
19317
+ }));
19318
+
19319
+ function getBorderColor(msg) {
19320
+ if (msg.isShown) return '#dddddd';
19321
+ if (msg.type === 'success') return '#b7eb8f';
19322
+ if (msg.type === 'error') return '#ffccc7';
19323
+ if (msg.type === 'warning') return '#ffe58f';
19324
+ if (msg.type === 'busy' || msg.type === 'info') return '#91d5ff';
19325
+ return '#91d5ff';
19326
+ }
19327
+
19328
+ function getBackGrColor(msg) {
19329
+ if (msg.isShown) return '#ffffff';
19330
+ if (msg.type === 'success') return '#f6ffed';
19331
+ if (msg.type === 'error') return '#fff2f0';
19332
+ if (msg.type === 'warning') return '#fffbe6';
19333
+ if (msg.type === 'busy' || msg.type === 'info') return '#e6f7ff';
19334
+ return '#e6f7ff';
19335
+ }
19336
+
19337
+ const MessageWrapper = styled.div`
19338
+ border: 1px solid ${props => getBorderColor(props.msg)};
19339
+ background-color: ${props => getBackGrColor(props.msg)};
19340
+ padding: 8px 15px;
19341
+ margin-bottom: 4px;
19342
+ `;
19343
+ const FlexContainer = styled.div`
19344
+ display: flex;
19345
+ align-items: center;
19346
+ `;
19347
+ const MessageText = styled.div`
19348
+ flex-grow: 1;
19349
+ overflow: auto;
19350
+ overflow-wrap: break-word;
19351
+ max-height: 300px;
19352
+ &::-webkit-scrollbar {
19353
+ width: 12px;
19354
+ }
19355
+ &::-webkit-scrollbar-thumb {
19356
+ border-radius: 10px;
19357
+ background-clip: padding-box;
19358
+ background-color: #d7d7d7;
19359
+ border: 3px solid rgba(0, 0, 0, 0); // Invisible boreder to emulate margin
19360
+ }
19361
+ `;
19362
+ const iconStyle = {
19363
+ marginRight: '8px'
19364
+ };
19365
+ const CloseButton = styled.button`
19366
+ margin-left: 8px;
19367
+ padding: 0;
19368
+ overflow: hidden;
19369
+ font-size: 12px;
19370
+ line-height: 12px;
19371
+ background-color: transparent;
19372
+ border: none;
19373
+ outline: none;
19374
+ cursor: pointer;
19375
+ `;
19376
+ const Time = styled.div`
19377
+ font-size: 0.7rem;
19378
+ color: #adadad;
19379
+ margin-left: 20px;
19380
+ `;
19381
+
19382
+ function getTime(timestamp) {
19383
+ const date = new Date(timestamp);
19384
+ return date.toLocaleTimeString(undefined, {
19385
+ hour: 'numeric',
19386
+ minute: '2-digit',
19387
+ hour12: false
19388
+ });
19389
+ }
19390
+
19391
+ const Icon = ({
19392
+ type
19393
+ }) => {
19394
+ if (type === 'success') return /*#__PURE__*/React.createElement(icons.CheckCircleTwoTone, {
19395
+ twoToneColor: "#52c41a",
19396
+ style: iconStyle
19397
+ });
19398
+ if (type === 'error') return /*#__PURE__*/React.createElement(icons.CloseCircleTwoTone, {
19399
+ twoToneColor: "#ff4d4f",
19400
+ style: iconStyle
19401
+ });
19402
+ if (type === 'warning') return /*#__PURE__*/React.createElement(icons.ExclamationCircleTwoTone, {
19403
+ twoToneColor: "#faad14",
19404
+ style: iconStyle
19405
+ });
19406
+ if (type === 'busy' || type === 'info') return /*#__PURE__*/React.createElement(icons.InfoCircleTwoTone, {
19407
+ twoToneColor: "#1890ff",
19408
+ style: iconStyle
19409
+ });
19410
+ return null;
19411
+ };
19412
+
19413
+ const Message = ({
19414
+ msgId
19415
+ }) => {
19416
+ const msg = useMsgStore(s => s.msgs[msgId]) || {};
19417
+ const msgApi = useMsgStore(s => s.api);
19418
+ const type = msg.type === 'busy' ? 'info' : msg.type;
19419
+ return /*#__PURE__*/React.createElement(MessageWrapper, {
19420
+ msg: msg
19421
+ }, /*#__PURE__*/React.createElement(FlexContainer, null, /*#__PURE__*/React.createElement(Icon, {
19422
+ type: type
19423
+ }), /*#__PURE__*/React.createElement(MessageText, null, `${msg.title} ${msg.text}`), /*#__PURE__*/React.createElement(CloseButton, {
19424
+ onClick: () => msgApi.deleteMsg(msgId)
19425
+ }, /*#__PURE__*/React.createElement(icons.CloseOutlined, null))), /*#__PURE__*/React.createElement(Time, null, getTime(msg.timestamp)));
19426
+ };
19427
+
19428
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
19429
+
19430
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
19431
+ const MsgListWrapper = styled.div`
19432
+ max-height: 500px;
19433
+ max-width: 400px;
19434
+ min-width: 300px;
19435
+ overflow-y: auto;
19436
+ &::-webkit-scrollbar {
19437
+ width: 12px;
19438
+ }
19439
+ &::-webkit-scrollbar-thumb {
19440
+ border-radius: 10px;
19441
+ background-clip: padding-box;
19442
+ background-color: #cfcfcf;
19443
+ border: 3px solid rgba(0, 0, 0, 0); // Invisible boreder to emulate margin
19444
+ }
19445
+ z-index: ${blankZIndex + 1};
19446
+ `;
19447
+ const MessageList = ({
19448
+ drawingId
19449
+ }) => {
19450
+ const msgsIds = useMsgStore(s => {
19451
+ // Return array of messages with fresh messages in the beginning
19452
+ return Object.keys(s.msgs).sort((id1, id2) => s.msgs[id2].timestamp - s.msgs[id1].timestamp);
19453
+ });
19454
+ const msgsApi = useMsgStore(s => s.api); // Set isShow = true for all messages in store on unmount
19455
+
19456
+ React.useEffect(() => {
19457
+ return () => msgsApi.setShown();
19458
+ }, [msgsApi]);
19459
+ return /*#__PURE__*/React.createElement(MsgListWrapper, null, msgsIds.map(msgId => /*#__PURE__*/React.createElement(Message, {
19460
+ msgId: msgId,
19461
+ key: msgId
19462
+ })));
19463
+ };
19464
+ const Messages = ({
19465
+ drawingId
19466
+ }) => {
19467
+ const [showList, setShowList] = React.useState(false);
19468
+ const [showBadge, setShowBadge] = React.useState(false);
19469
+ const timestamp = react.useBuerli(state => state.message.timestamp);
19470
+ const msg = react.useBuerli(state => state.message.data);
19471
+ const msgsApi = useMsgStore(s => s.api);
19472
+ const msgsLen = useMsgStore(s => Object.keys(s.msgs).length);
19473
+ React.useEffect(() => setShowBadge(true), [timestamp]); // Add recent message to msgs store
19474
+
19475
+ React.useEffect(() => {
19476
+ if (timestamp && msg && (msg.text || msg.title)) {
19477
+ msgsApi.setMsg(msg.id, _objectSpread(_objectSpread({}, msg), {}, {
19478
+ timestamp,
19479
+ isShown: false
19480
+ }));
19481
+ }
19482
+ }, [timestamp, msg, msgsApi]); // Hide list when there is no cached messages
19483
+
19484
+ React.useEffect(() => {
19485
+ if (msgsLen === 0) setShowList(false);
19486
+ }, [msgsLen]);
19487
+ const onClick = React.useCallback(() => {
19488
+ if (showList) {
19489
+ getCADState().api.blankDiv.hide();
19490
+ } else {
19491
+ getCADState().api.blankDiv.show(() => setShowList(false));
19492
+ }
19493
+
19494
+ setShowList(s => !s);
19495
+ setShowBadge(false);
19496
+ }, [showList]);
19497
+ return /*#__PURE__*/React.createElement("div", {
19498
+ style: {
19499
+ display: 'flex',
19500
+ flexDirection: 'column',
19501
+ alignItems: 'flex-end'
19502
+ }
19503
+ }, showList && /*#__PURE__*/React.createElement(MessageList, {
19504
+ drawingId: drawingId
19505
+ }), /*#__PURE__*/React.createElement(Tooltip, {
19506
+ title: "Messages"
19507
+ }, /*#__PURE__*/React.createElement(antd.Badge, {
19508
+ dot: showBadge
19509
+ }, /*#__PURE__*/React.createElement(antd.Button, {
19510
+ size: "small",
19511
+ icon: /*#__PURE__*/React.createElement(icons.UnorderedListOutlined, null),
19512
+ onClick: onClick
19513
+ }))));
19514
+ };
19515
+
18675
19516
  const EditDrawing = ({
18676
19517
  drawingId
18677
19518
  }) => {
@@ -18702,7 +19543,7 @@ const EditDrawing = ({
18702
19543
  }
18703
19544
  }), /*#__PURE__*/React.createElement("div", {
18704
19545
  style: {
18705
- flex: '1',
19546
+ flexGrow: 1,
18706
19547
  overflow: 'hidden'
18707
19548
  }
18708
19549
  }, /*#__PURE__*/React.createElement("div", {
@@ -18810,7 +19651,15 @@ const Drawing = ({
18810
19651
  }
18811
19652
  }), /*#__PURE__*/React.createElement(EditDrawing, {
18812
19653
  drawingId: drawingId
18813
- })));
19654
+ }), /*#__PURE__*/React.createElement("div", {
19655
+ style: {
19656
+ position: 'absolute',
19657
+ bottom: '4px',
19658
+ right: '4px'
19659
+ }
19660
+ }, /*#__PURE__*/React.createElement(Messages, {
19661
+ drawingId: drawingId
19662
+ })), /*#__PURE__*/React.createElement(BlankDiv, null)));
18814
19663
  };
18815
19664
 
18816
19665
  const CAD = ({