@buerli.io/react-cad 0.5.0-beta.4 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/index.js
CHANGED
|
@@ -11,7 +11,7 @@ import create from 'zustand';
|
|
|
11
11
|
import vanilla from 'zustand/vanilla';
|
|
12
12
|
import 'antd/dist/antd.css';
|
|
13
13
|
import styled, { css, keyframes } from 'styled-components';
|
|
14
|
-
import { ArrowUpOutlined, CheckOutlined, QuestionCircleFilled, DownOutlined, RightOutlined, EyeFilled, EyeOutlined, EditOutlined, DeleteOutlined, CaretRightOutlined, CaretDownOutlined, PlusOutlined, SelectOutlined, PlusSquareOutlined, ExportOutlined, CloseOutlined, CheckCircleTwoTone, CloseCircleTwoTone, ExclamationCircleTwoTone, InfoCircleTwoTone,
|
|
14
|
+
import { ArrowUpOutlined, CheckOutlined, QuestionCircleFilled, DownOutlined, RightOutlined, EyeFilled, EyeOutlined, EditOutlined, DeleteOutlined, CaretRightOutlined, CaretDownOutlined, PlusOutlined, SelectOutlined, PlusSquareOutlined, ExportOutlined, CloseOutlined, CheckCircleTwoTone, CloseCircleTwoTone, ExclamationCircleTwoTone, InfoCircleTwoTone, MessageOutlined, EditFilled, AppstoreOutlined, FileOutlined, LeftOutlined, AppstoreAddOutlined, FontSizeOutlined, ExpandAltOutlined, CodeSandboxOutlined } from '@ant-design/icons';
|
|
15
15
|
import _extends from '@babel/runtime/helpers/esm/extends';
|
|
16
16
|
import TabsImpl from 'antd/lib/tabs';
|
|
17
17
|
import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
|
|
@@ -32,8 +32,8 @@ import { SortableContainer, SortableElement } from 'react-sortable-hoc';
|
|
|
32
32
|
import { RgbaColorPicker } from 'react-colorful';
|
|
33
33
|
import * as deepmerge from 'deepmerge';
|
|
34
34
|
|
|
35
|
-
function ownKeys$
|
|
36
|
-
function _objectSpread$
|
|
35
|
+
function ownKeys$q(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
36
|
+
function _objectSpread$q(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$q(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$q(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
37
37
|
function getGraphicId(tree, refOrObjId) {
|
|
38
38
|
const res = {
|
|
39
39
|
graphicId: refOrObjId,
|
|
@@ -96,7 +96,7 @@ function useSelectedItems(drawingId, refOrObjIds) {
|
|
|
96
96
|
window.console.error('Product is not a CC_Part. Assembly is not supported now');
|
|
97
97
|
}
|
|
98
98
|
const createSelItem = React__default.useCallback(element => {
|
|
99
|
-
return createGraphicItem(prodId, _objectSpread$
|
|
99
|
+
return createGraphicItem(prodId, _objectSpread$q(_objectSpread$q({}, element), {}, {
|
|
100
100
|
productId: prodId
|
|
101
101
|
}));
|
|
102
102
|
}, [prodId]);
|
|
@@ -121,7 +121,7 @@ function useSelectedItems(drawingId, refOrObjIds) {
|
|
|
121
121
|
if (grIds && grIds.length > 0) {
|
|
122
122
|
const elem = cont.map[Number(grIds[0])];
|
|
123
123
|
if (elem) {
|
|
124
|
-
elems.push(_objectSpread$
|
|
124
|
+
elems.push(_objectSpread$q(_objectSpread$q({}, elem), {}, {
|
|
125
125
|
graphicId: contId,
|
|
126
126
|
type: cont.type
|
|
127
127
|
}));
|
|
@@ -157,8 +157,8 @@ function useSelectedItems(drawingId, refOrObjIds) {
|
|
|
157
157
|
return selectedItems;
|
|
158
158
|
}
|
|
159
159
|
|
|
160
|
-
function ownKeys$
|
|
161
|
-
function _objectSpread$
|
|
160
|
+
function ownKeys$p(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
161
|
+
function _objectSpread$p(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$p(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$p(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
162
162
|
function addMembers(drawingId, ccObjId) {
|
|
163
163
|
const drawingState = getDrawing(drawingId);
|
|
164
164
|
const objInTree = drawingState.structure.tree[ccObjId];
|
|
@@ -169,7 +169,7 @@ function addMembers(drawingId, ccObjId) {
|
|
|
169
169
|
const members = {};
|
|
170
170
|
Object.keys(curMembers).forEach(memberName => {
|
|
171
171
|
const curMember = curMembers[memberName];
|
|
172
|
-
members[memberName] = _objectSpread$
|
|
172
|
+
members[memberName] = _objectSpread$p(_objectSpread$p({}, curMember), {}, {
|
|
173
173
|
name: memberName
|
|
174
174
|
});
|
|
175
175
|
if (curMember.type === MemberType.POINT && Array.isArray(curMember.value)) {
|
|
@@ -370,11 +370,6 @@ function findObject(drawingId, id, unrollRefs = false) {
|
|
|
370
370
|
}
|
|
371
371
|
return undefined;
|
|
372
372
|
}
|
|
373
|
-
function round(value, digits) {
|
|
374
|
-
if (isNaN(value)) return NaN;
|
|
375
|
-
const factor = Math.pow(10, digits);
|
|
376
|
-
return Math.round(value * factor) / factor;
|
|
377
|
-
}
|
|
378
373
|
function componentToHex(x) {
|
|
379
374
|
const hex = x.toString(16);
|
|
380
375
|
return hex.length == 1 ? '0' + hex : hex;
|
|
@@ -507,8 +502,11 @@ const Wrapper = ({
|
|
|
507
502
|
}, children));
|
|
508
503
|
};
|
|
509
504
|
|
|
505
|
+
function isDegValue(expr) {
|
|
506
|
+
return expr.length > 0 && expr[expr.length - 1] === 'g' && !isNaN(Number(expr.slice(0, expr.length - 1)));
|
|
507
|
+
}
|
|
510
508
|
function getDefNumValue(numOrExpr) {
|
|
511
|
-
return typeof numOrExpr === 'number' ? numOrExpr : 0;
|
|
509
|
+
return typeof numOrExpr === 'number' ? numOrExpr : isDegValue(numOrExpr) ? numOrExpr : 0;
|
|
512
510
|
}
|
|
513
511
|
function getDefExprValue(numOrExpr) {
|
|
514
512
|
return typeof numOrExpr === 'string' ? numOrExpr : String(numOrExpr);
|
|
@@ -522,7 +520,7 @@ const NumOrExpr = ({
|
|
|
522
520
|
prefix
|
|
523
521
|
}) => {
|
|
524
522
|
const [state, setState] = React__default.useState({
|
|
525
|
-
isExpr: Boolean(typeof valOrExpr === 'string' && allowExpr),
|
|
523
|
+
isExpr: Boolean(typeof valOrExpr === 'string' && !isDegValue(valOrExpr) && allowExpr),
|
|
526
524
|
defaultVal: getDefNumValue(defaults),
|
|
527
525
|
defaultExpr: getDefExprValue(defaults)
|
|
528
526
|
});
|
|
@@ -531,12 +529,6 @@ const NumOrExpr = ({
|
|
|
531
529
|
defaultVal,
|
|
532
530
|
defaultExpr
|
|
533
531
|
} = state;
|
|
534
|
-
|
|
535
|
-
// TODO: This effect is probably not needed anymore? Remove if no issues are found
|
|
536
|
-
/* React.useEffect(() => {
|
|
537
|
-
setIsExpr(typeof valOrExpr === 'string')
|
|
538
|
-
}, [valOrExpr]) */
|
|
539
|
-
|
|
540
532
|
const prefixed = prefix !== undefined;
|
|
541
533
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
542
534
|
style: {
|
|
@@ -592,9 +584,11 @@ const NumInput$1 = ({
|
|
|
592
584
|
} = useBuerli(buerli => buerli.options.elements);
|
|
593
585
|
const [sValue, setSValue] = React__default.useState(String(value));
|
|
594
586
|
React__default.useEffect(() => {
|
|
595
|
-
const float =
|
|
587
|
+
const float = Number(sValue);
|
|
596
588
|
if (!isNaN(float)) {
|
|
597
589
|
onChange(float); // Call onChange of parent component
|
|
590
|
+
} else if (isDegValue(sValue)) {
|
|
591
|
+
onChange(sValue);
|
|
598
592
|
} else {
|
|
599
593
|
onChange(value);
|
|
600
594
|
}
|
|
@@ -606,14 +600,14 @@ const NumInput$1 = ({
|
|
|
606
600
|
target
|
|
607
601
|
}) => {
|
|
608
602
|
const val = target.value;
|
|
609
|
-
const reg = /^-?(\d*(\.\d*)?)?$/; // Regexpr for float number
|
|
603
|
+
const reg = /^-?(\d*(\.\d*)?)?g?$/; // Regexpr for float number
|
|
610
604
|
if (reg.test(val) || val === '') {
|
|
611
605
|
setSValue(val); // Remove extra zeros from the begin
|
|
612
606
|
}
|
|
613
607
|
}, []);
|
|
614
608
|
const onBlur = React__default.useCallback(() => {
|
|
615
|
-
const float =
|
|
616
|
-
if (isNaN(float)) {
|
|
609
|
+
const float = Number(sValue);
|
|
610
|
+
if (isNaN(float) && !isDegValue(sValue)) {
|
|
617
611
|
setSValue(String(value));
|
|
618
612
|
}
|
|
619
613
|
}, [value, sValue]);
|
|
@@ -770,11 +764,13 @@ const Suffix = ({
|
|
|
770
764
|
}) => {
|
|
771
765
|
const onClick = React__default.useCallback(() => {
|
|
772
766
|
if (state.isExpr && state.defaultVal !== undefined) {
|
|
767
|
+
const isDeg = typeof valOrExpr === 'string' && isDegValue(valOrExpr);
|
|
773
768
|
const float = Number(valOrExpr);
|
|
774
|
-
|
|
769
|
+
const newDefaultVal = isDeg ? valOrExpr : !isNaN(float) ? float : undefined;
|
|
770
|
+
if (newDefaultVal !== undefined) {
|
|
775
771
|
setState({
|
|
776
772
|
isExpr: false,
|
|
777
|
-
defaultVal:
|
|
773
|
+
defaultVal: newDefaultVal,
|
|
778
774
|
defaultExpr: state.defaultExpr
|
|
779
775
|
});
|
|
780
776
|
return;
|
|
@@ -977,19 +973,13 @@ function useParam(param, getServValue, validation) {
|
|
|
977
973
|
}, [userValue, setUserValue, defaults, isChanged, defValidator, setDefValidator, getServValue, validator, setValidator]);
|
|
978
974
|
}
|
|
979
975
|
|
|
980
|
-
function createRealParam(member
|
|
976
|
+
function createRealParam(member) {
|
|
981
977
|
// In the old models if member doesn't contain experssion, the value is stored in the member.expression as string
|
|
982
978
|
// For example 'limit2' member for an extrusion looks like this: {expression: "50", type: "real", value: 50, visible: 1}
|
|
983
979
|
// These expressions should be ignored.
|
|
984
980
|
const expr = member.expression;
|
|
985
981
|
const isExpr = expr.length > 0 && isNaN(Number(expr));
|
|
986
|
-
|
|
987
|
-
if (isExpr) {
|
|
988
|
-
value = angle ? member.expression.replace(/(a_r\()(.+)(\))/, '$2') // a_r(ExpressionSet.foo) --> ExpressionSet.foo
|
|
989
|
-
: expr;
|
|
990
|
-
} else {
|
|
991
|
-
value = angle ? round(radiansToDegrees(member.value), 2) : member.value;
|
|
992
|
-
}
|
|
982
|
+
const value = isExpr ? expr : member.value;
|
|
993
983
|
return {
|
|
994
984
|
value,
|
|
995
985
|
isExpr
|
|
@@ -998,20 +988,17 @@ function createRealParam(member, angle) {
|
|
|
998
988
|
function useNumParam(drawingId, objId, memberName, options = {
|
|
999
989
|
angle: false
|
|
1000
990
|
}) {
|
|
1001
|
-
const {
|
|
1002
|
-
angle
|
|
1003
|
-
} = options;
|
|
1004
991
|
const member = useDrawing(drawingId, d => {
|
|
1005
992
|
var _d$structure$tree$obj, _d$structure$tree$obj2;
|
|
1006
993
|
return (_d$structure$tree$obj = d.structure.tree[objId]) == null ? void 0 : (_d$structure$tree$obj2 = _d$structure$tree$obj.members) == null ? void 0 : _d$structure$tree$obj2[memberName];
|
|
1007
994
|
});
|
|
1008
|
-
const [userValue, setUserValue] = React__default.useState(createRealParam(member
|
|
995
|
+
const [userValue, setUserValue] = React__default.useState(createRealParam(member));
|
|
1009
996
|
|
|
1010
997
|
// Update userValue if member is changed in tree
|
|
1011
998
|
React__default.useEffect(() => {
|
|
1012
|
-
setUserValue(createRealParam(member
|
|
1013
|
-
}, [member
|
|
1014
|
-
const defaults = React__default.useMemo(() => createRealParam(member
|
|
999
|
+
setUserValue(createRealParam(member));
|
|
1000
|
+
}, [member]);
|
|
1001
|
+
const defaults = React__default.useMemo(() => createRealParam(member), [member]);
|
|
1015
1002
|
const isChanged = React__default.useCallback(() => {
|
|
1016
1003
|
return userValue.isExpr !== defaults.isExpr || userValue.value !== defaults.value;
|
|
1017
1004
|
}, [defaults, userValue]);
|
|
@@ -1020,18 +1007,6 @@ function useNumParam(drawingId, objId, memberName, options = {
|
|
|
1020
1007
|
setUserValue,
|
|
1021
1008
|
defaults,
|
|
1022
1009
|
isChanged
|
|
1023
|
-
}, function (userValue_) {
|
|
1024
|
-
if (userValue_.isExpr) {
|
|
1025
|
-
return {
|
|
1026
|
-
value: angle ? 'a_r(' + userValue_.value + ')' : userValue_.value,
|
|
1027
|
-
isExpr: true
|
|
1028
|
-
};
|
|
1029
|
-
} else {
|
|
1030
|
-
return {
|
|
1031
|
-
value: angle ? degreesToRadians(userValue_.value) : userValue_.value,
|
|
1032
|
-
isExpr: false
|
|
1033
|
-
};
|
|
1034
|
-
}
|
|
1035
1010
|
});
|
|
1036
1011
|
}
|
|
1037
1012
|
|
|
@@ -1059,8 +1034,8 @@ const isAngular = dim => {
|
|
|
1059
1034
|
return dim.class === CCClasses.CCAngularDimension || dim.class === CCClasses.CCAngularFeatureDimension || dim.class === CCClasses.CCAngularRefDimension;
|
|
1060
1035
|
};
|
|
1061
1036
|
|
|
1062
|
-
function ownKeys$
|
|
1063
|
-
function _objectSpread$
|
|
1037
|
+
function ownKeys$o(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
1038
|
+
function _objectSpread$o(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$o(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$o(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
1064
1039
|
const appApi = (set, get) => ({
|
|
1065
1040
|
assemblyTree: {
|
|
1066
1041
|
startProdEditing: (drawingId, objId) => {
|
|
@@ -1069,7 +1044,7 @@ const appApi = (set, get) => ({
|
|
|
1069
1044
|
const curNode = api.getState().drawing.refs[drawingId].structure.currentNode;
|
|
1070
1045
|
res = state.assemblyTree.prodStack;
|
|
1071
1046
|
curNode && res.push(curNode);
|
|
1072
|
-
return _objectSpread$
|
|
1047
|
+
return _objectSpread$o(_objectSpread$o({}, state), {}, {
|
|
1073
1048
|
assemblyTree: {
|
|
1074
1049
|
prodStack: [...res]
|
|
1075
1050
|
}
|
|
@@ -1084,7 +1059,7 @@ const appApi = (set, get) => ({
|
|
|
1084
1059
|
set(state => {
|
|
1085
1060
|
const res = state.assemblyTree.prodStack;
|
|
1086
1061
|
res.pop();
|
|
1087
|
-
return _objectSpread$
|
|
1062
|
+
return _objectSpread$o(_objectSpread$o({}, state), {}, {
|
|
1088
1063
|
assemblyTree: {
|
|
1089
1064
|
prodStack: [...res]
|
|
1090
1065
|
}
|
|
@@ -1093,7 +1068,7 @@ const appApi = (set, get) => ({
|
|
|
1093
1068
|
ccAPI.assemblyBuilder.setCurrentNode(drawingId, prevProd).catch(console.warn);
|
|
1094
1069
|
},
|
|
1095
1070
|
clearProdStack: () => {
|
|
1096
|
-
set(state => _objectSpread$
|
|
1071
|
+
set(state => _objectSpread$o(_objectSpread$o({}, state), {}, {
|
|
1097
1072
|
assemblyTree: {
|
|
1098
1073
|
prodStack: []
|
|
1099
1074
|
}
|
|
@@ -1102,7 +1077,7 @@ const appApi = (set, get) => ({
|
|
|
1102
1077
|
},
|
|
1103
1078
|
blankDiv: {
|
|
1104
1079
|
show: callback => {
|
|
1105
|
-
set(state => _objectSpread$
|
|
1080
|
+
set(state => _objectSpread$o(_objectSpread$o({}, state), {}, {
|
|
1106
1081
|
blankDiv: {
|
|
1107
1082
|
isActive: true,
|
|
1108
1083
|
onClose: callback
|
|
@@ -1110,7 +1085,7 @@ const appApi = (set, get) => ({
|
|
|
1110
1085
|
}));
|
|
1111
1086
|
},
|
|
1112
1087
|
hide: () => {
|
|
1113
|
-
set(state => _objectSpread$
|
|
1088
|
+
set(state => _objectSpread$o(_objectSpread$o({}, state), {}, {
|
|
1114
1089
|
blankDiv: {
|
|
1115
1090
|
isActive: false,
|
|
1116
1091
|
onClose: undefined
|
|
@@ -1207,15 +1182,13 @@ const DimValue = ({
|
|
|
1207
1182
|
const caption = React__default.useMemo(() => {
|
|
1208
1183
|
var _master$members2, _master$members3;
|
|
1209
1184
|
// const paramName = dimension.members.paramName.value
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
return expr ? expr + ' (' + value.toFixed(2) + ')' : value.toFixed(2);
|
|
1218
|
-
}, [master, dimension, memberName]);
|
|
1185
|
+
const expr = (_master$members2 = master.members) == null ? void 0 : _master$members2[memberName].expression.replace(/ /g, '').replace(/ExpressionSet./g, '@');
|
|
1186
|
+
const degValue = expr.length > 0 && expr[expr.length - 1] === 'g' ? Number(expr.slice(0, expr.length - 1)) : NaN;
|
|
1187
|
+
const isDeg = !isNaN(degValue);
|
|
1188
|
+
const value = isDeg ? degValue : (_master$members3 = master.members) == null ? void 0 : _master$members3[memberName].value;
|
|
1189
|
+
const valueStr = isDeg ? value.toFixed(2) + 'g' : value.toFixed(2);
|
|
1190
|
+
return expr && !isDeg ? expr + ' (' + valueStr + ')' : valueStr;
|
|
1191
|
+
}, [master, memberName]);
|
|
1219
1192
|
const [editMode, setEditMode] = React__default.useState(false);
|
|
1220
1193
|
React__default.useEffect(() => {
|
|
1221
1194
|
if (editMode) {
|
|
@@ -2322,8 +2295,8 @@ function useRefsParam(drawingId, objId, memberName) {
|
|
|
2322
2295
|
});
|
|
2323
2296
|
}
|
|
2324
2297
|
|
|
2325
|
-
function ownKeys$
|
|
2326
|
-
function _objectSpread$
|
|
2298
|
+
function ownKeys$n(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2299
|
+
function _objectSpread$n(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$n(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$n(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
2327
2300
|
|
|
2328
2301
|
/**
|
|
2329
2302
|
* Implies the following data structure:
|
|
@@ -2451,7 +2424,7 @@ function useTreeObjSelection(drawingId, objId) {
|
|
|
2451
2424
|
const isSelected = useIsSelected$1(drawingId, objId);
|
|
2452
2425
|
const handlers = React__default.useMemo(() => {
|
|
2453
2426
|
if (isSelectable) {
|
|
2454
|
-
return _objectSpread$
|
|
2427
|
+
return _objectSpread$n(_objectSpread$n({}, hHandlers), sHandlers);
|
|
2455
2428
|
}
|
|
2456
2429
|
return {};
|
|
2457
2430
|
}, [isSelectable, hHandlers, sHandlers]);
|
|
@@ -2925,8 +2898,8 @@ const SelectionRestorer = ({
|
|
|
2925
2898
|
return null;
|
|
2926
2899
|
};
|
|
2927
2900
|
|
|
2928
|
-
function ownKeys$
|
|
2929
|
-
function _objectSpread$
|
|
2901
|
+
function ownKeys$m(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2902
|
+
function _objectSpread$m(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$m(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$m(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
2930
2903
|
|
|
2931
2904
|
/**
|
|
2932
2905
|
* Implies the following data structure:
|
|
@@ -3020,7 +2993,7 @@ function useMateSelection(drawingId, matePath, csysId) {
|
|
|
3020
2993
|
}));
|
|
3021
2994
|
const handlers = React__default.useMemo(() => {
|
|
3022
2995
|
if (isSelectable) {
|
|
3023
|
-
return _objectSpread$
|
|
2996
|
+
return _objectSpread$m(_objectSpread$m({}, hHandlers), sHandlers);
|
|
3024
2997
|
}
|
|
3025
2998
|
return {};
|
|
3026
2999
|
}, [isSelectable, hHandlers, sHandlers]);
|
|
@@ -3680,8 +3653,8 @@ var index$x = /*#__PURE__*/Object.freeze({
|
|
|
3680
3653
|
description: description$x
|
|
3681
3654
|
});
|
|
3682
3655
|
|
|
3683
|
-
function ownKeys$
|
|
3684
|
-
function _objectSpread$
|
|
3656
|
+
function ownKeys$l(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
3657
|
+
function _objectSpread$l(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$l(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$l(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
3685
3658
|
function parseVal(val) {
|
|
3686
3659
|
const float = Number(val);
|
|
3687
3660
|
if (!isNaN(float)) {
|
|
@@ -3689,26 +3662,35 @@ function parseVal(val) {
|
|
|
3689
3662
|
}
|
|
3690
3663
|
return val;
|
|
3691
3664
|
}
|
|
3692
|
-
function
|
|
3693
|
-
|
|
3694
|
-
|
|
3665
|
+
function parsePoint(param) {
|
|
3666
|
+
if (!param.isExpr) {
|
|
3667
|
+
const value = param.value;
|
|
3668
|
+
return [value.x, value.y, value.z];
|
|
3669
|
+
}
|
|
3670
|
+
let str = param.value.replace(/ /g, ''); // remove all spaces...
|
|
3695
3671
|
str = str.substr(1, str.length - 2); // ... and brackets from the beginning and end of the string.
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3672
|
+
|
|
3673
|
+
// Respect braces and ignore commas as component separators if they are nested within braces (i.e. as function parameter separators)
|
|
3674
|
+
// Should break the expression string into exactly 3 components
|
|
3675
|
+
let depth = 0;
|
|
3676
|
+
let subStart = 0;
|
|
3677
|
+
let comps = [];
|
|
3678
|
+
for (let i = 0; i < str.length; i++) {
|
|
3679
|
+
if (str[i] === '(') depth++;
|
|
3680
|
+
if (str[i] === ')') depth--;
|
|
3681
|
+
if (str[i] === ',' && depth === 0) {
|
|
3682
|
+
comps.push(parseVal(str.slice(subStart, i)));
|
|
3683
|
+
subStart = i + 1;
|
|
3684
|
+
}
|
|
3704
3685
|
}
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
if (defaults.isExpr) {
|
|
3708
|
-
return getCompFromExpr(defaults.value, comp);
|
|
3686
|
+
if (depth === 0 && comps.length === 2) {
|
|
3687
|
+
comps.push(parseVal(str.slice(subStart, str.length)));
|
|
3709
3688
|
} else {
|
|
3710
|
-
return
|
|
3689
|
+
// Expression is somehow incorrect, return an array of 0-values
|
|
3690
|
+
window.console.log('Error when parsing point expression!');
|
|
3691
|
+
comps = [0, 0, 0];
|
|
3711
3692
|
}
|
|
3693
|
+
return comps;
|
|
3712
3694
|
}
|
|
3713
3695
|
function getDisplayValue(valOrExpr) {
|
|
3714
3696
|
return typeof valOrExpr === 'string' ? valOrExpr.replace(/ /g, '').replace(/ExpressionSet./g, '@') : valOrExpr.toString();
|
|
@@ -3851,9 +3833,10 @@ const PointEditor = ({
|
|
|
3851
3833
|
setUserValue,
|
|
3852
3834
|
defaults
|
|
3853
3835
|
} = param;
|
|
3854
|
-
const
|
|
3855
|
-
const [
|
|
3856
|
-
const [
|
|
3836
|
+
const parsedDefaults = React__default.useMemo(() => parsePoint(defaults), [defaults]);
|
|
3837
|
+
const [x, setX] = React__default.useState(parsedDefaults[0]);
|
|
3838
|
+
const [y, setY] = React__default.useState(parsedDefaults[1]);
|
|
3839
|
+
const [z, setZ] = React__default.useState(parsedDefaults[2]);
|
|
3857
3840
|
React__default.useEffect(() => {
|
|
3858
3841
|
if (typeof x === 'string' || typeof y === 'string' || typeof z === 'string') {
|
|
3859
3842
|
setUserValue({
|
|
@@ -3893,23 +3876,30 @@ const PointEditor = ({
|
|
|
3893
3876
|
}, [validatorWrapper, setValidator]);
|
|
3894
3877
|
const [displayState, setDisplayState] = React__default.useState({
|
|
3895
3878
|
editMode: false,
|
|
3896
|
-
displayVals:
|
|
3897
|
-
x: 0,
|
|
3898
|
-
y: 0,
|
|
3899
|
-
z: 0
|
|
3900
|
-
}
|
|
3879
|
+
displayVals: [0, 0, 0]
|
|
3901
3880
|
});
|
|
3902
3881
|
React__default.useEffect(() => {
|
|
3903
|
-
if (userValue.isExpr) {
|
|
3882
|
+
if (userValue.isExpr && !isDegValue(userValue.value)) {
|
|
3904
3883
|
const curProdId = getDrawing(drawingId).structure.currentProduct;
|
|
3905
3884
|
const tree = getDrawing(drawingId).structure.tree;
|
|
3906
3885
|
const exprSetId = tree[curProdId].expressionSet;
|
|
3907
|
-
ccAPI.common.evaluateExpression(drawingId, exprSetId, userValue.value).then(res => setDisplayState(state =>
|
|
3908
|
-
|
|
3909
|
-
|
|
3886
|
+
ccAPI.common.evaluateExpression(drawingId, exprSetId, userValue.value).then(res => setDisplayState(state => {
|
|
3887
|
+
const res_ = res;
|
|
3888
|
+
const newVals = res_ !== null ? [res_.x, res_.y, res_.z] : [...state.displayVals];
|
|
3889
|
+
const parsedPoint = parsePoint(userValue);
|
|
3890
|
+
parsedPoint.forEach((val, i) => {
|
|
3891
|
+
if (typeof val === 'string' && isDegValue(val)) {
|
|
3892
|
+
newVals[i] = val;
|
|
3893
|
+
}
|
|
3894
|
+
});
|
|
3895
|
+
return _objectSpread$l(_objectSpread$l({}, state), {}, {
|
|
3896
|
+
displayVals: newVals
|
|
3897
|
+
});
|
|
3898
|
+
})).catch();
|
|
3910
3899
|
} else {
|
|
3911
|
-
|
|
3912
|
-
|
|
3900
|
+
const value = userValue.value;
|
|
3901
|
+
setDisplayState(state => _objectSpread$l(_objectSpread$l({}, state), {}, {
|
|
3902
|
+
displayVals: [value.x, value.y, value.z]
|
|
3913
3903
|
}));
|
|
3914
3904
|
}
|
|
3915
3905
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -3919,16 +3909,20 @@ const PointEditor = ({
|
|
|
3919
3909
|
const curProdId = getDrawing(drawingId).structure.currentProduct;
|
|
3920
3910
|
const tree = getDrawing(drawingId).structure.tree;
|
|
3921
3911
|
const exprSetId = tree[curProdId].expressionSet;
|
|
3922
|
-
ccAPI.common.evaluateExpression(drawingId, exprSetId, userValue.value).then(res =>
|
|
3923
|
-
|
|
3924
|
-
|
|
3925
|
-
|
|
3912
|
+
ccAPI.common.evaluateExpression(drawingId, exprSetId, userValue.value).then(res => {
|
|
3913
|
+
const res_ = res;
|
|
3914
|
+
setDisplayState(state => ({
|
|
3915
|
+
editMode: false,
|
|
3916
|
+
displayVals: res_ !== null ? [res_.x, res_.y, res_.z] : [...state.displayVals]
|
|
3917
|
+
}));
|
|
3918
|
+
}).catch(() => setDisplayState(state => _objectSpread$l(_objectSpread$l({}, state), {}, {
|
|
3926
3919
|
editMode: false
|
|
3927
3920
|
})));
|
|
3928
3921
|
} else {
|
|
3922
|
+
const value = userValue.value;
|
|
3929
3923
|
setDisplayState({
|
|
3930
3924
|
editMode: false,
|
|
3931
|
-
displayVals:
|
|
3925
|
+
displayVals: [value.x, value.y, value.z]
|
|
3932
3926
|
});
|
|
3933
3927
|
}
|
|
3934
3928
|
}, [drawingId, userValue]);
|
|
@@ -3940,7 +3934,7 @@ const PointEditor = ({
|
|
|
3940
3934
|
caption: caption,
|
|
3941
3935
|
highlighted: param.isChanged()
|
|
3942
3936
|
}, !editMode && /*#__PURE__*/React__default.createElement(DisplayBase, {
|
|
3943
|
-
onClick: () => setDisplayState(state => _objectSpread$
|
|
3937
|
+
onClick: () => setDisplayState(state => _objectSpread$l(_objectSpread$l({}, state), {}, {
|
|
3944
3938
|
editMode: true
|
|
3945
3939
|
}))
|
|
3946
3940
|
}, /*#__PURE__*/React__default.createElement(Tooltip, {
|
|
@@ -3956,7 +3950,7 @@ const PointEditor = ({
|
|
|
3956
3950
|
gridColumnEnd: '3',
|
|
3957
3951
|
width: '100%'
|
|
3958
3952
|
}
|
|
3959
|
-
}, displayVals.
|
|
3953
|
+
}, displayVals[0].toString()), typeof x === 'string' && !isDegValue(x) && /*#__PURE__*/React__default.createElement(ExprMark, {
|
|
3960
3954
|
style: {
|
|
3961
3955
|
right: '-3px'
|
|
3962
3956
|
}
|
|
@@ -3969,7 +3963,7 @@ const PointEditor = ({
|
|
|
3969
3963
|
gridColumnEnd: '3',
|
|
3970
3964
|
width: '100%'
|
|
3971
3965
|
}
|
|
3972
|
-
}, displayVals.
|
|
3966
|
+
}, displayVals[1].toString()), typeof y === 'string' && !isDegValue(y) && /*#__PURE__*/React__default.createElement(ExprMark, {
|
|
3973
3967
|
style: {
|
|
3974
3968
|
right: '-5px'
|
|
3975
3969
|
}
|
|
@@ -3986,7 +3980,7 @@ const PointEditor = ({
|
|
|
3986
3980
|
gridColumnEnd: '3',
|
|
3987
3981
|
width: '100%'
|
|
3988
3982
|
}
|
|
3989
|
-
}, displayVals.
|
|
3983
|
+
}, displayVals[2].toString()), typeof z === 'string' && !isDegValue(z) && /*#__PURE__*/React__default.createElement(ExprMark, {
|
|
3990
3984
|
style: {
|
|
3991
3985
|
right: '-9px'
|
|
3992
3986
|
}
|
|
@@ -3998,21 +3992,21 @@ const PointEditor = ({
|
|
|
3998
3992
|
drawingId: drawingId,
|
|
3999
3993
|
valOrExpr: x,
|
|
4000
3994
|
onChange: setX,
|
|
4001
|
-
defaults:
|
|
3995
|
+
defaults: parsedDefaults[0],
|
|
4002
3996
|
allowExpr: true,
|
|
4003
3997
|
prefix: "x:"
|
|
4004
3998
|
})), /*#__PURE__*/React__default.createElement(EditY, null, /*#__PURE__*/React__default.createElement(NumOrExpr, {
|
|
4005
3999
|
drawingId: drawingId,
|
|
4006
4000
|
valOrExpr: y,
|
|
4007
4001
|
onChange: setY,
|
|
4008
|
-
defaults:
|
|
4002
|
+
defaults: parsedDefaults[1],
|
|
4009
4003
|
allowExpr: true,
|
|
4010
4004
|
prefix: "y:"
|
|
4011
4005
|
})), /*#__PURE__*/React__default.createElement(EditZ, null, /*#__PURE__*/React__default.createElement(NumOrExpr, {
|
|
4012
4006
|
drawingId: drawingId,
|
|
4013
4007
|
valOrExpr: z,
|
|
4014
4008
|
onChange: setZ,
|
|
4015
|
-
defaults:
|
|
4009
|
+
defaults: parsedDefaults[2],
|
|
4016
4010
|
allowExpr: true,
|
|
4017
4011
|
prefix: "z:"
|
|
4018
4012
|
})), /*#__PURE__*/React__default.createElement(Collapse, {
|
|
@@ -4020,29 +4014,11 @@ const PointEditor = ({
|
|
|
4020
4014
|
}, "\u2014")));
|
|
4021
4015
|
};
|
|
4022
4016
|
|
|
4023
|
-
|
|
4024
|
-
function
|
|
4017
|
+
function ownKeys$k(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4018
|
+
function _objectSpread$k(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$k(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$k(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4019
|
+
function createPointParam(member) {
|
|
4025
4020
|
const isExpr = member.expression.length > 0;
|
|
4026
|
-
|
|
4027
|
-
if (isExpr) {
|
|
4028
|
-
value = angle ? member.expression.replace(/{a_r\((.+)\), *a_r\((.+)\), *a_r\((.+)\)}/, '{$1, $2, $3}') // {a_r(ExpressionSet.foo), a_r(42), a_r(0.5)} --> {ExpressionSet.foo, 42, 0.5}
|
|
4029
|
-
: member.expression;
|
|
4030
|
-
} else {
|
|
4031
|
-
const {
|
|
4032
|
-
x,
|
|
4033
|
-
y,
|
|
4034
|
-
z
|
|
4035
|
-
} = member.value;
|
|
4036
|
-
value = angle ? {
|
|
4037
|
-
x: toDeg(x),
|
|
4038
|
-
y: toDeg(y),
|
|
4039
|
-
z: toDeg(z)
|
|
4040
|
-
} : {
|
|
4041
|
-
x,
|
|
4042
|
-
y,
|
|
4043
|
-
z
|
|
4044
|
-
};
|
|
4045
|
-
}
|
|
4021
|
+
const value = isExpr ? member.expression : _objectSpread$k({}, member.value);
|
|
4046
4022
|
return {
|
|
4047
4023
|
value,
|
|
4048
4024
|
isExpr
|
|
@@ -4051,18 +4027,15 @@ function createPointParam(member, angle) {
|
|
|
4051
4027
|
function usePointParam(drawingId, objId, memberName, options = {
|
|
4052
4028
|
angle: false
|
|
4053
4029
|
}) {
|
|
4054
|
-
const {
|
|
4055
|
-
angle
|
|
4056
|
-
} = options;
|
|
4057
4030
|
const member = useDrawing(drawingId, d => {
|
|
4058
4031
|
var _d$structure$tree$obj, _d$structure$tree$obj2;
|
|
4059
4032
|
return (_d$structure$tree$obj = d.structure.tree[objId]) == null ? void 0 : (_d$structure$tree$obj2 = _d$structure$tree$obj.members) == null ? void 0 : _d$structure$tree$obj2[memberName];
|
|
4060
4033
|
});
|
|
4061
|
-
const defaults = React__default.useMemo(() => createPointParam(member
|
|
4034
|
+
const defaults = React__default.useMemo(() => createPointParam(member), [member]);
|
|
4062
4035
|
const [userValue, setUserValue] = React__default.useState(defaults);
|
|
4063
4036
|
React__default.useEffect(() => {
|
|
4064
|
-
setUserValue(createPointParam(member
|
|
4065
|
-
}, [member
|
|
4037
|
+
setUserValue(createPointParam(member));
|
|
4038
|
+
}, [member]);
|
|
4066
4039
|
const isChanged = React__default.useCallback(() => {
|
|
4067
4040
|
if (userValue.isExpr !== defaults.isExpr) {
|
|
4068
4041
|
return true;
|
|
@@ -4075,35 +4048,12 @@ function usePointParam(drawingId, objId, memberName, options = {
|
|
|
4075
4048
|
return value.x !== defValue.x || value.y !== defValue.y || value.z !== defValue.z;
|
|
4076
4049
|
}
|
|
4077
4050
|
}, [defaults, userValue]);
|
|
4078
|
-
const getServValue = React__default.useCallback(userValue_ => {
|
|
4079
|
-
if (userValue_.isExpr) {
|
|
4080
|
-
return {
|
|
4081
|
-
value: angle ? userValue_.value.replace(/{(.+), *(.+), *(.+)}/, '{a_r($1), a_r($2), a_r($3)}') // {ExpressionSet.foo, 42, 0.5} --> {a_r(ExpressionSet.foo), a_r(42), a_r(0.5)}
|
|
4082
|
-
: userValue_.value,
|
|
4083
|
-
isExpr: true
|
|
4084
|
-
};
|
|
4085
|
-
} else {
|
|
4086
|
-
const {
|
|
4087
|
-
x,
|
|
4088
|
-
y,
|
|
4089
|
-
z
|
|
4090
|
-
} = userValue_.value;
|
|
4091
|
-
return {
|
|
4092
|
-
value: angle ? {
|
|
4093
|
-
x: degreesToRadians(x),
|
|
4094
|
-
y: degreesToRadians(y),
|
|
4095
|
-
z: degreesToRadians(z)
|
|
4096
|
-
} : userValue_.value,
|
|
4097
|
-
isExpr: false
|
|
4098
|
-
};
|
|
4099
|
-
}
|
|
4100
|
-
}, [angle]);
|
|
4101
4051
|
return useParam({
|
|
4102
4052
|
userValue,
|
|
4103
4053
|
setUserValue,
|
|
4104
4054
|
defaults,
|
|
4105
4055
|
isChanged
|
|
4106
|
-
}
|
|
4056
|
+
});
|
|
4107
4057
|
}
|
|
4108
4058
|
|
|
4109
4059
|
var img$10 = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAADcSURBVEhL3ZTbDcMgDEVJlsgonabfnanfmaajdIlSS0aU+lWEsaLmCCkhMfheB2fJOadI1nIN49wJlv0Jo0xGURPUrZ05wkskH1OuOl+3ctfQE3bERxaLbnyJ+2WFUSYMy4G9shO63lBqvDJQBVbtThNfi39qHDAhqyOqPSY+fcDV4b63xwunFTjsbTAPa7thXFonQidXdURaq4vEIBhJmnnQAf8l8Eoi3hJp+1bGE3ATAH/odQCACcOHKwHRK3qa4AARdwemJdCw+oCgabQJd3BEieby/yUKTpDSG4InWqXAb1/sAAAAAElFTkSuQmCC";
|
|
@@ -18478,7 +18428,7 @@ const ImportModel = ({
|
|
|
18478
18428
|
content
|
|
18479
18429
|
}) => {
|
|
18480
18430
|
const type = extname(file.name).replace('.', '');
|
|
18481
|
-
if (['ofb', 'stp', 'step', 'stl'].includes(type)) {
|
|
18431
|
+
if (['ofb', 'stp', 'step', 'stl'].includes(type == null ? void 0 : type.toLowerCase())) {
|
|
18482
18432
|
ccAPI.assemblyBuilder.loadProduct(drawingId, content, type, file.name).catch(console.warn);
|
|
18483
18433
|
} else {
|
|
18484
18434
|
throw new Error('This type of file is not supported to import.');
|
|
@@ -18685,7 +18635,7 @@ const load = (file, singleDrawingApp) => {
|
|
|
18685
18635
|
try {
|
|
18686
18636
|
api.getState().api.setActiveDrawing(drawingId);
|
|
18687
18637
|
const type = extname(file.name).replace('.', '');
|
|
18688
|
-
if (['ofb', 'stp', 'step', 'stl'].includes(type)) {
|
|
18638
|
+
if (['ofb', 'stp', 'step', 'stl'].includes(type == null ? void 0 : type.toLowerCase())) {
|
|
18689
18639
|
await ccAPI.baseModeler.load(drawingId, result, type, file.name).catch(console.warn);
|
|
18690
18640
|
} else {
|
|
18691
18641
|
throw new Error('This type of file is not supported to load.');
|
|
@@ -19536,7 +19486,7 @@ const Divider = props => {
|
|
|
19536
19486
|
}));
|
|
19537
19487
|
};
|
|
19538
19488
|
|
|
19539
|
-
const animation = keyframes`
|
|
19489
|
+
const animation$1 = keyframes`
|
|
19540
19490
|
0%,
|
|
19541
19491
|
100% {
|
|
19542
19492
|
box-shadow: 0em -2.6em 0em 0em #ffffff, 1.8em -1.8em 0 0em rgba(255, 255, 255, 0.2),
|
|
@@ -19595,7 +19545,7 @@ const Spinner = styled.div`
|
|
|
19595
19545
|
border-radius: 50%;
|
|
19596
19546
|
position: relative;
|
|
19597
19547
|
text-indent: -9999em;
|
|
19598
|
-
animation: ${animation} 1.1s infinite ease;
|
|
19548
|
+
animation: ${animation$1} 1.1s infinite ease;
|
|
19599
19549
|
transform: translateZ(0);
|
|
19600
19550
|
`;
|
|
19601
19551
|
|
|
@@ -19643,6 +19593,9 @@ function createApi(set) {
|
|
|
19643
19593
|
msgs: newMsgs
|
|
19644
19594
|
});
|
|
19645
19595
|
}),
|
|
19596
|
+
deleteAllMsgs: () => set(prev => _objectSpread$4(_objectSpread$4({}, prev), {}, {
|
|
19597
|
+
msgs: {}
|
|
19598
|
+
})),
|
|
19646
19599
|
setShown: () => {
|
|
19647
19600
|
set(prev => {
|
|
19648
19601
|
const msgs = _objectSpread$4({}, prev.msgs);
|
|
@@ -19674,27 +19627,49 @@ function getBorderColor(msg) {
|
|
|
19674
19627
|
return '#91d5ff';
|
|
19675
19628
|
}
|
|
19676
19629
|
function getBackGrColor(msg) {
|
|
19677
|
-
if (msg.isShown) return '#
|
|
19630
|
+
if (msg.isShown) return '#fafafa';
|
|
19678
19631
|
if (msg.type === 'success') return '#f6ffed';
|
|
19679
19632
|
if (msg.type === 'error') return '#fff2f0';
|
|
19680
19633
|
if (msg.type === 'warning') return '#fffbe6';
|
|
19681
19634
|
if (msg.type === 'busy' || msg.type === 'info') return '#e6f7ff';
|
|
19682
19635
|
return '#e6f7ff';
|
|
19683
19636
|
}
|
|
19637
|
+
function isAccentuated(msg) {
|
|
19638
|
+
return msg.type === 'error' && !msg.isShown;
|
|
19639
|
+
}
|
|
19640
|
+
const animation = keyframes`
|
|
19641
|
+
0% {
|
|
19642
|
+
background-color: #fff2f0;
|
|
19643
|
+
border-color: #ffccc7;
|
|
19644
|
+
}
|
|
19645
|
+
50% {
|
|
19646
|
+
background-color: #ffe8e0;
|
|
19647
|
+
border-color: #ffaca7;
|
|
19648
|
+
}
|
|
19649
|
+
100% {
|
|
19650
|
+
background-color: #fff2f0;
|
|
19651
|
+
border-color: #ffccc7;
|
|
19652
|
+
}
|
|
19653
|
+
`;
|
|
19684
19654
|
const MessageWrapper = styled.div`
|
|
19655
|
+
width: ${props => isAccentuated(props.msg) ? '100%' : '80%'};
|
|
19656
|
+
min-width: 0px;
|
|
19685
19657
|
border: 1px solid ${props => getBorderColor(props.msg)};
|
|
19686
19658
|
background-color: ${props => getBackGrColor(props.msg)};
|
|
19687
19659
|
padding: 8px 15px;
|
|
19688
|
-
margin
|
|
19660
|
+
margin: 0px 0px 4px auto;
|
|
19661
|
+
${props => isAccentuated(props.msg) && css`
|
|
19662
|
+
-webkit-animation: ${animation} 0.5s infinite ease-in;
|
|
19663
|
+
`}
|
|
19689
19664
|
`;
|
|
19690
19665
|
const FlexContainer = styled.div`
|
|
19691
19666
|
display: flex;
|
|
19692
|
-
align-items:
|
|
19667
|
+
align-items: top;
|
|
19693
19668
|
`;
|
|
19694
19669
|
const MessageText = styled.div`
|
|
19695
|
-
flex-grow: 1;
|
|
19696
19670
|
overflow: auto;
|
|
19697
19671
|
overflow-wrap: break-word;
|
|
19672
|
+
min-width: 0px;
|
|
19698
19673
|
max-height: 300px;
|
|
19699
19674
|
&::-webkit-scrollbar {
|
|
19700
19675
|
width: 12px;
|
|
@@ -19707,14 +19682,19 @@ const MessageText = styled.div`
|
|
|
19707
19682
|
}
|
|
19708
19683
|
`;
|
|
19709
19684
|
const iconStyle = {
|
|
19710
|
-
marginRight: '8px'
|
|
19685
|
+
marginRight: '8px',
|
|
19686
|
+
marginTop: '1px',
|
|
19687
|
+
fontSize: '20px'
|
|
19711
19688
|
};
|
|
19712
19689
|
const CloseButton = styled.button`
|
|
19713
|
-
margin-left: 8px;
|
|
19714
19690
|
padding: 0;
|
|
19715
19691
|
overflow: hidden;
|
|
19692
|
+
width: 12px;
|
|
19693
|
+
height: 12px;
|
|
19716
19694
|
font-size: 12px;
|
|
19717
19695
|
line-height: 12px;
|
|
19696
|
+
margin-left: 8px;
|
|
19697
|
+
margin-top: 5px;
|
|
19718
19698
|
background-color: transparent;
|
|
19719
19699
|
border: none;
|
|
19720
19700
|
outline: none;
|
|
@@ -19723,7 +19703,7 @@ const CloseButton = styled.button`
|
|
|
19723
19703
|
const Time = styled.div`
|
|
19724
19704
|
font-size: 0.7rem;
|
|
19725
19705
|
color: #adadad;
|
|
19726
|
-
margin-left:
|
|
19706
|
+
margin-left: 28px;
|
|
19727
19707
|
`;
|
|
19728
19708
|
function getTime(timestamp) {
|
|
19729
19709
|
const date = new Date(timestamp);
|
|
@@ -19764,7 +19744,11 @@ const Message = ({
|
|
|
19764
19744
|
msg: msg
|
|
19765
19745
|
}, /*#__PURE__*/React__default.createElement(FlexContainer, null, /*#__PURE__*/React__default.createElement(Icon$1, {
|
|
19766
19746
|
type: type
|
|
19767
|
-
}), /*#__PURE__*/React__default.createElement(MessageText,
|
|
19747
|
+
}), /*#__PURE__*/React__default.createElement(MessageText, {
|
|
19748
|
+
style: {
|
|
19749
|
+
flex: 1
|
|
19750
|
+
}
|
|
19751
|
+
}, `${msg.title ? msg.title : ''} ${msg.text}`), /*#__PURE__*/React__default.createElement(CloseButton, {
|
|
19768
19752
|
onClick: () => msgApi.deleteMsg(msgId)
|
|
19769
19753
|
}, /*#__PURE__*/React__default.createElement(CloseOutlined, null))), /*#__PURE__*/React__default.createElement(Time, null, getTime(msg.timestamp)));
|
|
19770
19754
|
};
|
|
@@ -19772,9 +19756,8 @@ const Message = ({
|
|
|
19772
19756
|
function ownKeys$3(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
19773
19757
|
function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$3(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$3(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
19774
19758
|
const MsgListWrapper = styled.div`
|
|
19759
|
+
width: 500px;
|
|
19775
19760
|
max-height: 500px;
|
|
19776
|
-
max-width: 400px;
|
|
19777
|
-
min-width: 300px;
|
|
19778
19761
|
overflow-y: auto;
|
|
19779
19762
|
&::-webkit-scrollbar {
|
|
19780
19763
|
width: 12px;
|
|
@@ -19788,19 +19771,22 @@ const MsgListWrapper = styled.div`
|
|
|
19788
19771
|
z-index: ${blankZIndex + 1};
|
|
19789
19772
|
`;
|
|
19790
19773
|
const MessageList = ({
|
|
19791
|
-
|
|
19774
|
+
isOpen
|
|
19792
19775
|
}) => {
|
|
19793
|
-
const
|
|
19776
|
+
const msgApi = useMsgStore(s => s.api);
|
|
19777
|
+
const msgIds = useMsgStore(s => {
|
|
19794
19778
|
// Return array of messages with fresh messages in the beginning
|
|
19795
|
-
|
|
19779
|
+
const allMsgIds = Object.keys(s.msgs).sort((id1, id2) => s.msgs[id2].timestamp - s.msgs[id1].timestamp);
|
|
19780
|
+
return isOpen ? allMsgIds : allMsgIds.filter(id => s.msgs[id].type === 'error' && !s.msgs[id].isShown);
|
|
19796
19781
|
});
|
|
19797
|
-
const msgsApi = useMsgStore(s => s.api);
|
|
19798
19782
|
|
|
19799
|
-
// Set
|
|
19783
|
+
// Set isShown = true for all messages in store on unhover / unpin
|
|
19800
19784
|
React__default.useEffect(() => {
|
|
19801
|
-
|
|
19802
|
-
|
|
19803
|
-
|
|
19785
|
+
if (!isOpen) {
|
|
19786
|
+
msgApi.setShown();
|
|
19787
|
+
}
|
|
19788
|
+
}, [isOpen, msgApi]);
|
|
19789
|
+
return /*#__PURE__*/React__default.createElement(MsgListWrapper, null, msgIds.map(msgId => /*#__PURE__*/React__default.createElement(Message, {
|
|
19804
19790
|
msgId: msgId,
|
|
19805
19791
|
key: msgId
|
|
19806
19792
|
})));
|
|
@@ -19808,15 +19794,30 @@ const MessageList = ({
|
|
|
19808
19794
|
const Messages = ({
|
|
19809
19795
|
drawingId
|
|
19810
19796
|
}) => {
|
|
19811
|
-
const [
|
|
19797
|
+
const [isHovered, setIsHovered] = React__default.useState(false);
|
|
19798
|
+
const [isPinned, setIsPinned] = React__default.useState(true);
|
|
19812
19799
|
const [showBadge, setShowBadge] = React__default.useState(false);
|
|
19800
|
+
const isOpen = isHovered || isPinned;
|
|
19813
19801
|
const timestamp = useBuerli(state => state.message.timestamp);
|
|
19814
19802
|
const msg = useBuerli(state => state.message.data);
|
|
19815
19803
|
const msgsApi = useMsgStore(s => s.api);
|
|
19816
|
-
const msgsLen = useMsgStore(s => Object.keys(s.msgs).length);
|
|
19817
|
-
React__default.useEffect(() => setShowBadge(true), [timestamp]);
|
|
19818
19804
|
|
|
19819
|
-
//
|
|
19805
|
+
// If there are some new messages, and the message list is not shown, then display the badge
|
|
19806
|
+
React__default.useEffect(() => {
|
|
19807
|
+
if (!isOpen) {
|
|
19808
|
+
setShowBadge(true);
|
|
19809
|
+
}
|
|
19810
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
19811
|
+
}, [timestamp]);
|
|
19812
|
+
|
|
19813
|
+
// Whenever the message list is opened, stop showing the badge
|
|
19814
|
+
React__default.useEffect(() => {
|
|
19815
|
+
if (isOpen) {
|
|
19816
|
+
setShowBadge(false);
|
|
19817
|
+
}
|
|
19818
|
+
}, [isOpen]);
|
|
19819
|
+
|
|
19820
|
+
// Add recent message to the store
|
|
19820
19821
|
React__default.useEffect(() => {
|
|
19821
19822
|
if (timestamp && msg && (msg.text || msg.title)) {
|
|
19822
19823
|
msgsApi.setMsg(msg.id, _objectSpread$3(_objectSpread$3({}, msg), {}, {
|
|
@@ -19826,36 +19827,49 @@ const Messages = ({
|
|
|
19826
19827
|
}
|
|
19827
19828
|
}, [timestamp, msg, msgsApi]);
|
|
19828
19829
|
|
|
19829
|
-
//
|
|
19830
|
+
// Clean up messages on drawingId change
|
|
19830
19831
|
React__default.useEffect(() => {
|
|
19831
|
-
|
|
19832
|
-
}, [
|
|
19833
|
-
const
|
|
19834
|
-
|
|
19835
|
-
|
|
19836
|
-
|
|
19837
|
-
|
|
19838
|
-
|
|
19839
|
-
setShowList(s => !s);
|
|
19840
|
-
setShowBadge(false);
|
|
19841
|
-
}, [showList]);
|
|
19832
|
+
msgsApi.deleteAllMsgs();
|
|
19833
|
+
}, [drawingId, msgsApi]);
|
|
19834
|
+
const onClearClick = React__default.useCallback(() => {
|
|
19835
|
+
msgsApi.deleteAllMsgs();
|
|
19836
|
+
}, [msgsApi]);
|
|
19837
|
+
const onMessagesClick = React__default.useCallback(() => {
|
|
19838
|
+
setIsPinned(s => !s);
|
|
19839
|
+
}, []);
|
|
19842
19840
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
19843
19841
|
style: {
|
|
19844
19842
|
display: 'flex',
|
|
19845
19843
|
flexDirection: 'column',
|
|
19846
19844
|
alignItems: 'flex-end'
|
|
19847
|
-
}
|
|
19848
|
-
|
|
19849
|
-
|
|
19850
|
-
|
|
19851
|
-
|
|
19845
|
+
},
|
|
19846
|
+
onMouseLeave: () => setIsHovered(false)
|
|
19847
|
+
}, /*#__PURE__*/React__default.createElement(MessageList, {
|
|
19848
|
+
isOpen: isOpen
|
|
19849
|
+
}), /*#__PURE__*/React__default.createElement(Space, {
|
|
19850
|
+
style: {
|
|
19851
|
+
marginTop: '5px'
|
|
19852
|
+
},
|
|
19853
|
+
onMouseEnter: () => setIsHovered(true)
|
|
19854
|
+
}, /*#__PURE__*/React__default.createElement(Tooltip, {
|
|
19855
|
+
title: "Clear messages"
|
|
19856
|
+
}, /*#__PURE__*/React__default.createElement(Button, {
|
|
19857
|
+
style: {
|
|
19858
|
+
display: isOpen ? 'inline' : 'none'
|
|
19859
|
+
},
|
|
19860
|
+
size: "small",
|
|
19861
|
+
icon: /*#__PURE__*/React__default.createElement(DeleteOutlined, null),
|
|
19862
|
+
onClick: onClearClick
|
|
19863
|
+
})), /*#__PURE__*/React__default.createElement(Tooltip, {
|
|
19864
|
+
title: "Messages (Pin / Unpin)"
|
|
19852
19865
|
}, /*#__PURE__*/React__default.createElement(Badge, {
|
|
19853
19866
|
dot: showBadge
|
|
19854
19867
|
}, /*#__PURE__*/React__default.createElement(Button, {
|
|
19855
19868
|
size: "small",
|
|
19856
|
-
|
|
19857
|
-
|
|
19858
|
-
|
|
19869
|
+
type: isPinned ? 'primary' : 'default',
|
|
19870
|
+
icon: /*#__PURE__*/React__default.createElement(MessageOutlined, null),
|
|
19871
|
+
onClick: onMessagesClick
|
|
19872
|
+
})))));
|
|
19859
19873
|
};
|
|
19860
19874
|
|
|
19861
19875
|
const DraggableModalContext = /*#__PURE__*/React.createContext(null);
|
|
@@ -22332,8 +22346,8 @@ const Drawing = ({
|
|
|
22332
22346
|
}, children), /*#__PURE__*/React__default.createElement("div", {
|
|
22333
22347
|
style: {
|
|
22334
22348
|
position: 'absolute',
|
|
22335
|
-
bottom: '
|
|
22336
|
-
right: '
|
|
22349
|
+
bottom: '5px',
|
|
22350
|
+
right: '5px'
|
|
22337
22351
|
}
|
|
22338
22352
|
}, /*#__PURE__*/React__default.createElement(Messages, {
|
|
22339
22353
|
drawingId: drawingId
|