@buerli.io/react-cad 0.5.0-beta.3 → 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.cjs.js
CHANGED
|
@@ -56,8 +56,8 @@ var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
|
56
56
|
var THREE__namespace = /*#__PURE__*/_interopNamespaceDefault(THREE);
|
|
57
57
|
var deepmerge__namespace = /*#__PURE__*/_interopNamespaceDefault(deepmerge);
|
|
58
58
|
|
|
59
|
-
function ownKeys$
|
|
60
|
-
function _objectSpread$
|
|
59
|
+
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; }
|
|
60
|
+
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; }
|
|
61
61
|
function getGraphicId(tree, refOrObjId) {
|
|
62
62
|
const res = {
|
|
63
63
|
graphicId: refOrObjId,
|
|
@@ -120,7 +120,7 @@ function useSelectedItems(drawingId, refOrObjIds) {
|
|
|
120
120
|
window.console.error('Product is not a CC_Part. Assembly is not supported now');
|
|
121
121
|
}
|
|
122
122
|
const createSelItem = React.useCallback(element => {
|
|
123
|
-
return core.createGraphicItem(prodId, _objectSpread$
|
|
123
|
+
return core.createGraphicItem(prodId, _objectSpread$q(_objectSpread$q({}, element), {}, {
|
|
124
124
|
productId: prodId
|
|
125
125
|
}));
|
|
126
126
|
}, [prodId]);
|
|
@@ -145,7 +145,7 @@ function useSelectedItems(drawingId, refOrObjIds) {
|
|
|
145
145
|
if (grIds && grIds.length > 0) {
|
|
146
146
|
const elem = cont.map[Number(grIds[0])];
|
|
147
147
|
if (elem) {
|
|
148
|
-
elems.push(_objectSpread$
|
|
148
|
+
elems.push(_objectSpread$q(_objectSpread$q({}, elem), {}, {
|
|
149
149
|
graphicId: contId,
|
|
150
150
|
type: cont.type
|
|
151
151
|
}));
|
|
@@ -181,8 +181,8 @@ function useSelectedItems(drawingId, refOrObjIds) {
|
|
|
181
181
|
return selectedItems;
|
|
182
182
|
}
|
|
183
183
|
|
|
184
|
-
function ownKeys$
|
|
185
|
-
function _objectSpread$
|
|
184
|
+
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; }
|
|
185
|
+
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; }
|
|
186
186
|
function addMembers(drawingId, ccObjId) {
|
|
187
187
|
const drawingState = core.getDrawing(drawingId);
|
|
188
188
|
const objInTree = drawingState.structure.tree[ccObjId];
|
|
@@ -193,7 +193,7 @@ function addMembers(drawingId, ccObjId) {
|
|
|
193
193
|
const members = {};
|
|
194
194
|
Object.keys(curMembers).forEach(memberName => {
|
|
195
195
|
const curMember = curMembers[memberName];
|
|
196
|
-
members[memberName] = _objectSpread$
|
|
196
|
+
members[memberName] = _objectSpread$p(_objectSpread$p({}, curMember), {}, {
|
|
197
197
|
name: memberName
|
|
198
198
|
});
|
|
199
199
|
if (curMember.type === core.MemberType.POINT && Array.isArray(curMember.value)) {
|
|
@@ -394,11 +394,6 @@ function findObject(drawingId, id, unrollRefs = false) {
|
|
|
394
394
|
}
|
|
395
395
|
return undefined;
|
|
396
396
|
}
|
|
397
|
-
function round(value, digits) {
|
|
398
|
-
if (isNaN(value)) return NaN;
|
|
399
|
-
const factor = Math.pow(10, digits);
|
|
400
|
-
return Math.round(value * factor) / factor;
|
|
401
|
-
}
|
|
402
397
|
function componentToHex(x) {
|
|
403
398
|
const hex = x.toString(16);
|
|
404
399
|
return hex.length == 1 ? '0' + hex : hex;
|
|
@@ -531,8 +526,11 @@ const Wrapper = ({
|
|
|
531
526
|
}, children));
|
|
532
527
|
};
|
|
533
528
|
|
|
529
|
+
function isDegValue(expr) {
|
|
530
|
+
return expr.length > 0 && expr[expr.length - 1] === 'g' && !isNaN(Number(expr.slice(0, expr.length - 1)));
|
|
531
|
+
}
|
|
534
532
|
function getDefNumValue(numOrExpr) {
|
|
535
|
-
return typeof numOrExpr === 'number' ? numOrExpr : 0;
|
|
533
|
+
return typeof numOrExpr === 'number' ? numOrExpr : isDegValue(numOrExpr) ? numOrExpr : 0;
|
|
536
534
|
}
|
|
537
535
|
function getDefExprValue(numOrExpr) {
|
|
538
536
|
return typeof numOrExpr === 'string' ? numOrExpr : String(numOrExpr);
|
|
@@ -546,7 +544,7 @@ const NumOrExpr = ({
|
|
|
546
544
|
prefix
|
|
547
545
|
}) => {
|
|
548
546
|
const [state, setState] = React.useState({
|
|
549
|
-
isExpr: Boolean(typeof valOrExpr === 'string' && allowExpr),
|
|
547
|
+
isExpr: Boolean(typeof valOrExpr === 'string' && !isDegValue(valOrExpr) && allowExpr),
|
|
550
548
|
defaultVal: getDefNumValue(defaults),
|
|
551
549
|
defaultExpr: getDefExprValue(defaults)
|
|
552
550
|
});
|
|
@@ -555,12 +553,6 @@ const NumOrExpr = ({
|
|
|
555
553
|
defaultVal,
|
|
556
554
|
defaultExpr
|
|
557
555
|
} = state;
|
|
558
|
-
|
|
559
|
-
// TODO: This effect is probably not needed anymore? Remove if no issues are found
|
|
560
|
-
/* React.useEffect(() => {
|
|
561
|
-
setIsExpr(typeof valOrExpr === 'string')
|
|
562
|
-
}, [valOrExpr]) */
|
|
563
|
-
|
|
564
556
|
const prefixed = prefix !== undefined;
|
|
565
557
|
return /*#__PURE__*/React.createElement("div", {
|
|
566
558
|
style: {
|
|
@@ -616,9 +608,11 @@ const NumInput$1 = ({
|
|
|
616
608
|
} = react.useBuerli(buerli => buerli.options.elements);
|
|
617
609
|
const [sValue, setSValue] = React.useState(String(value));
|
|
618
610
|
React.useEffect(() => {
|
|
619
|
-
const float =
|
|
611
|
+
const float = Number(sValue);
|
|
620
612
|
if (!isNaN(float)) {
|
|
621
613
|
onChange(float); // Call onChange of parent component
|
|
614
|
+
} else if (isDegValue(sValue)) {
|
|
615
|
+
onChange(sValue);
|
|
622
616
|
} else {
|
|
623
617
|
onChange(value);
|
|
624
618
|
}
|
|
@@ -630,14 +624,14 @@ const NumInput$1 = ({
|
|
|
630
624
|
target
|
|
631
625
|
}) => {
|
|
632
626
|
const val = target.value;
|
|
633
|
-
const reg = /^-?(\d*(\.\d*)?)?$/; // Regexpr for float number
|
|
627
|
+
const reg = /^-?(\d*(\.\d*)?)?g?$/; // Regexpr for float number
|
|
634
628
|
if (reg.test(val) || val === '') {
|
|
635
629
|
setSValue(val); // Remove extra zeros from the begin
|
|
636
630
|
}
|
|
637
631
|
}, []);
|
|
638
632
|
const onBlur = React.useCallback(() => {
|
|
639
|
-
const float =
|
|
640
|
-
if (isNaN(float)) {
|
|
633
|
+
const float = Number(sValue);
|
|
634
|
+
if (isNaN(float) && !isDegValue(sValue)) {
|
|
641
635
|
setSValue(String(value));
|
|
642
636
|
}
|
|
643
637
|
}, [value, sValue]);
|
|
@@ -794,11 +788,13 @@ const Suffix = ({
|
|
|
794
788
|
}) => {
|
|
795
789
|
const onClick = React.useCallback(() => {
|
|
796
790
|
if (state.isExpr && state.defaultVal !== undefined) {
|
|
791
|
+
const isDeg = typeof valOrExpr === 'string' && isDegValue(valOrExpr);
|
|
797
792
|
const float = Number(valOrExpr);
|
|
798
|
-
|
|
793
|
+
const newDefaultVal = isDeg ? valOrExpr : !isNaN(float) ? float : undefined;
|
|
794
|
+
if (newDefaultVal !== undefined) {
|
|
799
795
|
setState({
|
|
800
796
|
isExpr: false,
|
|
801
|
-
defaultVal:
|
|
797
|
+
defaultVal: newDefaultVal,
|
|
802
798
|
defaultExpr: state.defaultExpr
|
|
803
799
|
});
|
|
804
800
|
return;
|
|
@@ -1001,19 +997,13 @@ function useParam(param, getServValue, validation) {
|
|
|
1001
997
|
}, [userValue, setUserValue, defaults, isChanged, defValidator, setDefValidator, getServValue, validator, setValidator]);
|
|
1002
998
|
}
|
|
1003
999
|
|
|
1004
|
-
function createRealParam(member
|
|
1000
|
+
function createRealParam(member) {
|
|
1005
1001
|
// In the old models if member doesn't contain experssion, the value is stored in the member.expression as string
|
|
1006
1002
|
// For example 'limit2' member for an extrusion looks like this: {expression: "50", type: "real", value: 50, visible: 1}
|
|
1007
1003
|
// These expressions should be ignored.
|
|
1008
1004
|
const expr = member.expression;
|
|
1009
1005
|
const isExpr = expr.length > 0 && isNaN(Number(expr));
|
|
1010
|
-
|
|
1011
|
-
if (isExpr) {
|
|
1012
|
-
value = angle ? member.expression.replace(/(a_r\()(.+)(\))/, '$2') // a_r(ExpressionSet.foo) --> ExpressionSet.foo
|
|
1013
|
-
: expr;
|
|
1014
|
-
} else {
|
|
1015
|
-
value = angle ? round(radiansToDegrees(member.value), 2) : member.value;
|
|
1016
|
-
}
|
|
1006
|
+
const value = isExpr ? expr : member.value;
|
|
1017
1007
|
return {
|
|
1018
1008
|
value,
|
|
1019
1009
|
isExpr
|
|
@@ -1022,20 +1012,17 @@ function createRealParam(member, angle) {
|
|
|
1022
1012
|
function useNumParam(drawingId, objId, memberName, options = {
|
|
1023
1013
|
angle: false
|
|
1024
1014
|
}) {
|
|
1025
|
-
const {
|
|
1026
|
-
angle
|
|
1027
|
-
} = options;
|
|
1028
1015
|
const member = react.useDrawing(drawingId, d => {
|
|
1029
1016
|
var _d$structure$tree$obj, _d$structure$tree$obj2;
|
|
1030
1017
|
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];
|
|
1031
1018
|
});
|
|
1032
|
-
const [userValue, setUserValue] = React.useState(createRealParam(member
|
|
1019
|
+
const [userValue, setUserValue] = React.useState(createRealParam(member));
|
|
1033
1020
|
|
|
1034
1021
|
// Update userValue if member is changed in tree
|
|
1035
1022
|
React.useEffect(() => {
|
|
1036
|
-
setUserValue(createRealParam(member
|
|
1037
|
-
}, [member
|
|
1038
|
-
const defaults = React.useMemo(() => createRealParam(member
|
|
1023
|
+
setUserValue(createRealParam(member));
|
|
1024
|
+
}, [member]);
|
|
1025
|
+
const defaults = React.useMemo(() => createRealParam(member), [member]);
|
|
1039
1026
|
const isChanged = React.useCallback(() => {
|
|
1040
1027
|
return userValue.isExpr !== defaults.isExpr || userValue.value !== defaults.value;
|
|
1041
1028
|
}, [defaults, userValue]);
|
|
@@ -1044,18 +1031,6 @@ function useNumParam(drawingId, objId, memberName, options = {
|
|
|
1044
1031
|
setUserValue,
|
|
1045
1032
|
defaults,
|
|
1046
1033
|
isChanged
|
|
1047
|
-
}, function (userValue_) {
|
|
1048
|
-
if (userValue_.isExpr) {
|
|
1049
|
-
return {
|
|
1050
|
-
value: angle ? 'a_r(' + userValue_.value + ')' : userValue_.value,
|
|
1051
|
-
isExpr: true
|
|
1052
|
-
};
|
|
1053
|
-
} else {
|
|
1054
|
-
return {
|
|
1055
|
-
value: angle ? degreesToRadians(userValue_.value) : userValue_.value,
|
|
1056
|
-
isExpr: false
|
|
1057
|
-
};
|
|
1058
|
-
}
|
|
1059
1034
|
});
|
|
1060
1035
|
}
|
|
1061
1036
|
|
|
@@ -1083,8 +1058,8 @@ const isAngular = dim => {
|
|
|
1083
1058
|
return dim.class === classcad.CCClasses.CCAngularDimension || dim.class === classcad.CCClasses.CCAngularFeatureDimension || dim.class === classcad.CCClasses.CCAngularRefDimension;
|
|
1084
1059
|
};
|
|
1085
1060
|
|
|
1086
|
-
function ownKeys$
|
|
1087
|
-
function _objectSpread$
|
|
1061
|
+
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; }
|
|
1062
|
+
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; }
|
|
1088
1063
|
const appApi = (set, get) => ({
|
|
1089
1064
|
assemblyTree: {
|
|
1090
1065
|
startProdEditing: (drawingId, objId) => {
|
|
@@ -1093,7 +1068,7 @@ const appApi = (set, get) => ({
|
|
|
1093
1068
|
const curNode = core.api.getState().drawing.refs[drawingId].structure.currentNode;
|
|
1094
1069
|
res = state.assemblyTree.prodStack;
|
|
1095
1070
|
curNode && res.push(curNode);
|
|
1096
|
-
return _objectSpread$
|
|
1071
|
+
return _objectSpread$o(_objectSpread$o({}, state), {}, {
|
|
1097
1072
|
assemblyTree: {
|
|
1098
1073
|
prodStack: [...res]
|
|
1099
1074
|
}
|
|
@@ -1108,7 +1083,7 @@ const appApi = (set, get) => ({
|
|
|
1108
1083
|
set(state => {
|
|
1109
1084
|
const res = state.assemblyTree.prodStack;
|
|
1110
1085
|
res.pop();
|
|
1111
|
-
return _objectSpread$
|
|
1086
|
+
return _objectSpread$o(_objectSpread$o({}, state), {}, {
|
|
1112
1087
|
assemblyTree: {
|
|
1113
1088
|
prodStack: [...res]
|
|
1114
1089
|
}
|
|
@@ -1117,7 +1092,7 @@ const appApi = (set, get) => ({
|
|
|
1117
1092
|
classcad.ccAPI.assemblyBuilder.setCurrentNode(drawingId, prevProd).catch(console.warn);
|
|
1118
1093
|
},
|
|
1119
1094
|
clearProdStack: () => {
|
|
1120
|
-
set(state => _objectSpread$
|
|
1095
|
+
set(state => _objectSpread$o(_objectSpread$o({}, state), {}, {
|
|
1121
1096
|
assemblyTree: {
|
|
1122
1097
|
prodStack: []
|
|
1123
1098
|
}
|
|
@@ -1126,7 +1101,7 @@ const appApi = (set, get) => ({
|
|
|
1126
1101
|
},
|
|
1127
1102
|
blankDiv: {
|
|
1128
1103
|
show: callback => {
|
|
1129
|
-
set(state => _objectSpread$
|
|
1104
|
+
set(state => _objectSpread$o(_objectSpread$o({}, state), {}, {
|
|
1130
1105
|
blankDiv: {
|
|
1131
1106
|
isActive: true,
|
|
1132
1107
|
onClose: callback
|
|
@@ -1134,7 +1109,7 @@ const appApi = (set, get) => ({
|
|
|
1134
1109
|
}));
|
|
1135
1110
|
},
|
|
1136
1111
|
hide: () => {
|
|
1137
|
-
set(state => _objectSpread$
|
|
1112
|
+
set(state => _objectSpread$o(_objectSpread$o({}, state), {}, {
|
|
1138
1113
|
blankDiv: {
|
|
1139
1114
|
isActive: false,
|
|
1140
1115
|
onClose: undefined
|
|
@@ -1231,15 +1206,13 @@ const DimValue = ({
|
|
|
1231
1206
|
const caption = React.useMemo(() => {
|
|
1232
1207
|
var _master$members2, _master$members3;
|
|
1233
1208
|
// const paramName = dimension.members.paramName.value
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
return expr ? expr + ' (' + value.toFixed(2) + ')' : value.toFixed(2);
|
|
1242
|
-
}, [master, dimension, memberName]);
|
|
1209
|
+
const expr = (_master$members2 = master.members) == null ? void 0 : _master$members2[memberName].expression.replace(/ /g, '').replace(/ExpressionSet./g, '@');
|
|
1210
|
+
const degValue = expr.length > 0 && expr[expr.length - 1] === 'g' ? Number(expr.slice(0, expr.length - 1)) : NaN;
|
|
1211
|
+
const isDeg = !isNaN(degValue);
|
|
1212
|
+
const value = isDeg ? degValue : (_master$members3 = master.members) == null ? void 0 : _master$members3[memberName].value;
|
|
1213
|
+
const valueStr = isDeg ? value.toFixed(2) + 'g' : value.toFixed(2);
|
|
1214
|
+
return expr && !isDeg ? expr + ' (' + valueStr + ')' : valueStr;
|
|
1215
|
+
}, [master, memberName]);
|
|
1243
1216
|
const [editMode, setEditMode] = React.useState(false);
|
|
1244
1217
|
React.useEffect(() => {
|
|
1245
1218
|
if (editMode) {
|
|
@@ -2346,8 +2319,8 @@ function useRefsParam(drawingId, objId, memberName) {
|
|
|
2346
2319
|
});
|
|
2347
2320
|
}
|
|
2348
2321
|
|
|
2349
|
-
function ownKeys$
|
|
2350
|
-
function _objectSpread$
|
|
2322
|
+
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; }
|
|
2323
|
+
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; }
|
|
2351
2324
|
|
|
2352
2325
|
/**
|
|
2353
2326
|
* Implies the following data structure:
|
|
@@ -2475,7 +2448,7 @@ function useTreeObjSelection(drawingId, objId) {
|
|
|
2475
2448
|
const isSelected = useIsSelected$1(drawingId, objId);
|
|
2476
2449
|
const handlers = React.useMemo(() => {
|
|
2477
2450
|
if (isSelectable) {
|
|
2478
|
-
return _objectSpread$
|
|
2451
|
+
return _objectSpread$n(_objectSpread$n({}, hHandlers), sHandlers);
|
|
2479
2452
|
}
|
|
2480
2453
|
return {};
|
|
2481
2454
|
}, [isSelectable, hHandlers, sHandlers]);
|
|
@@ -2949,8 +2922,8 @@ const SelectionRestorer = ({
|
|
|
2949
2922
|
return null;
|
|
2950
2923
|
};
|
|
2951
2924
|
|
|
2952
|
-
function ownKeys$
|
|
2953
|
-
function _objectSpread$
|
|
2925
|
+
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; }
|
|
2926
|
+
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; }
|
|
2954
2927
|
|
|
2955
2928
|
/**
|
|
2956
2929
|
* Implies the following data structure:
|
|
@@ -3044,7 +3017,7 @@ function useMateSelection(drawingId, matePath, csysId) {
|
|
|
3044
3017
|
}));
|
|
3045
3018
|
const handlers = React.useMemo(() => {
|
|
3046
3019
|
if (isSelectable) {
|
|
3047
|
-
return _objectSpread$
|
|
3020
|
+
return _objectSpread$m(_objectSpread$m({}, hHandlers), sHandlers);
|
|
3048
3021
|
}
|
|
3049
3022
|
return {};
|
|
3050
3023
|
}, [isSelectable, hHandlers, sHandlers]);
|
|
@@ -3704,8 +3677,8 @@ var index$x = /*#__PURE__*/Object.freeze({
|
|
|
3704
3677
|
description: description$x
|
|
3705
3678
|
});
|
|
3706
3679
|
|
|
3707
|
-
function ownKeys$
|
|
3708
|
-
function _objectSpread$
|
|
3680
|
+
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; }
|
|
3681
|
+
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; }
|
|
3709
3682
|
function parseVal(val) {
|
|
3710
3683
|
const float = Number(val);
|
|
3711
3684
|
if (!isNaN(float)) {
|
|
@@ -3713,26 +3686,35 @@ function parseVal(val) {
|
|
|
3713
3686
|
}
|
|
3714
3687
|
return val;
|
|
3715
3688
|
}
|
|
3716
|
-
function
|
|
3717
|
-
|
|
3718
|
-
|
|
3689
|
+
function parsePoint(param) {
|
|
3690
|
+
if (!param.isExpr) {
|
|
3691
|
+
const value = param.value;
|
|
3692
|
+
return [value.x, value.y, value.z];
|
|
3693
|
+
}
|
|
3694
|
+
let str = param.value.replace(/ /g, ''); // remove all spaces...
|
|
3719
3695
|
str = str.substr(1, str.length - 2); // ... and brackets from the beginning and end of the string.
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3696
|
+
|
|
3697
|
+
// Respect braces and ignore commas as component separators if they are nested within braces (i.e. as function parameter separators)
|
|
3698
|
+
// Should break the expression string into exactly 3 components
|
|
3699
|
+
let depth = 0;
|
|
3700
|
+
let subStart = 0;
|
|
3701
|
+
let comps = [];
|
|
3702
|
+
for (let i = 0; i < str.length; i++) {
|
|
3703
|
+
if (str[i] === '(') depth++;
|
|
3704
|
+
if (str[i] === ')') depth--;
|
|
3705
|
+
if (str[i] === ',' && depth === 0) {
|
|
3706
|
+
comps.push(parseVal(str.slice(subStart, i)));
|
|
3707
|
+
subStart = i + 1;
|
|
3708
|
+
}
|
|
3728
3709
|
}
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
if (defaults.isExpr) {
|
|
3732
|
-
return getCompFromExpr(defaults.value, comp);
|
|
3710
|
+
if (depth === 0 && comps.length === 2) {
|
|
3711
|
+
comps.push(parseVal(str.slice(subStart, str.length)));
|
|
3733
3712
|
} else {
|
|
3734
|
-
return
|
|
3713
|
+
// Expression is somehow incorrect, return an array of 0-values
|
|
3714
|
+
window.console.log('Error when parsing point expression!');
|
|
3715
|
+
comps = [0, 0, 0];
|
|
3735
3716
|
}
|
|
3717
|
+
return comps;
|
|
3736
3718
|
}
|
|
3737
3719
|
function getDisplayValue(valOrExpr) {
|
|
3738
3720
|
return typeof valOrExpr === 'string' ? valOrExpr.replace(/ /g, '').replace(/ExpressionSet./g, '@') : valOrExpr.toString();
|
|
@@ -3875,9 +3857,10 @@ const PointEditor = ({
|
|
|
3875
3857
|
setUserValue,
|
|
3876
3858
|
defaults
|
|
3877
3859
|
} = param;
|
|
3878
|
-
const
|
|
3879
|
-
const [
|
|
3880
|
-
const [
|
|
3860
|
+
const parsedDefaults = React.useMemo(() => parsePoint(defaults), [defaults]);
|
|
3861
|
+
const [x, setX] = React.useState(parsedDefaults[0]);
|
|
3862
|
+
const [y, setY] = React.useState(parsedDefaults[1]);
|
|
3863
|
+
const [z, setZ] = React.useState(parsedDefaults[2]);
|
|
3881
3864
|
React.useEffect(() => {
|
|
3882
3865
|
if (typeof x === 'string' || typeof y === 'string' || typeof z === 'string') {
|
|
3883
3866
|
setUserValue({
|
|
@@ -3917,23 +3900,30 @@ const PointEditor = ({
|
|
|
3917
3900
|
}, [validatorWrapper, setValidator]);
|
|
3918
3901
|
const [displayState, setDisplayState] = React.useState({
|
|
3919
3902
|
editMode: false,
|
|
3920
|
-
displayVals:
|
|
3921
|
-
x: 0,
|
|
3922
|
-
y: 0,
|
|
3923
|
-
z: 0
|
|
3924
|
-
}
|
|
3903
|
+
displayVals: [0, 0, 0]
|
|
3925
3904
|
});
|
|
3926
3905
|
React.useEffect(() => {
|
|
3927
|
-
if (userValue.isExpr) {
|
|
3906
|
+
if (userValue.isExpr && !isDegValue(userValue.value)) {
|
|
3928
3907
|
const curProdId = core.getDrawing(drawingId).structure.currentProduct;
|
|
3929
3908
|
const tree = core.getDrawing(drawingId).structure.tree;
|
|
3930
3909
|
const exprSetId = tree[curProdId].expressionSet;
|
|
3931
|
-
classcad.ccAPI.common.evaluateExpression(drawingId, exprSetId, userValue.value).then(res => setDisplayState(state =>
|
|
3932
|
-
|
|
3933
|
-
|
|
3910
|
+
classcad.ccAPI.common.evaluateExpression(drawingId, exprSetId, userValue.value).then(res => setDisplayState(state => {
|
|
3911
|
+
const res_ = res;
|
|
3912
|
+
const newVals = res_ !== null ? [res_.x, res_.y, res_.z] : [...state.displayVals];
|
|
3913
|
+
const parsedPoint = parsePoint(userValue);
|
|
3914
|
+
parsedPoint.forEach((val, i) => {
|
|
3915
|
+
if (typeof val === 'string' && isDegValue(val)) {
|
|
3916
|
+
newVals[i] = val;
|
|
3917
|
+
}
|
|
3918
|
+
});
|
|
3919
|
+
return _objectSpread$l(_objectSpread$l({}, state), {}, {
|
|
3920
|
+
displayVals: newVals
|
|
3921
|
+
});
|
|
3922
|
+
})).catch();
|
|
3934
3923
|
} else {
|
|
3935
|
-
|
|
3936
|
-
|
|
3924
|
+
const value = userValue.value;
|
|
3925
|
+
setDisplayState(state => _objectSpread$l(_objectSpread$l({}, state), {}, {
|
|
3926
|
+
displayVals: [value.x, value.y, value.z]
|
|
3937
3927
|
}));
|
|
3938
3928
|
}
|
|
3939
3929
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -3943,16 +3933,20 @@ const PointEditor = ({
|
|
|
3943
3933
|
const curProdId = core.getDrawing(drawingId).structure.currentProduct;
|
|
3944
3934
|
const tree = core.getDrawing(drawingId).structure.tree;
|
|
3945
3935
|
const exprSetId = tree[curProdId].expressionSet;
|
|
3946
|
-
classcad.ccAPI.common.evaluateExpression(drawingId, exprSetId, userValue.value).then(res =>
|
|
3947
|
-
|
|
3948
|
-
|
|
3949
|
-
|
|
3936
|
+
classcad.ccAPI.common.evaluateExpression(drawingId, exprSetId, userValue.value).then(res => {
|
|
3937
|
+
const res_ = res;
|
|
3938
|
+
setDisplayState(state => ({
|
|
3939
|
+
editMode: false,
|
|
3940
|
+
displayVals: res_ !== null ? [res_.x, res_.y, res_.z] : [...state.displayVals]
|
|
3941
|
+
}));
|
|
3942
|
+
}).catch(() => setDisplayState(state => _objectSpread$l(_objectSpread$l({}, state), {}, {
|
|
3950
3943
|
editMode: false
|
|
3951
3944
|
})));
|
|
3952
3945
|
} else {
|
|
3946
|
+
const value = userValue.value;
|
|
3953
3947
|
setDisplayState({
|
|
3954
3948
|
editMode: false,
|
|
3955
|
-
displayVals:
|
|
3949
|
+
displayVals: [value.x, value.y, value.z]
|
|
3956
3950
|
});
|
|
3957
3951
|
}
|
|
3958
3952
|
}, [drawingId, userValue]);
|
|
@@ -3964,7 +3958,7 @@ const PointEditor = ({
|
|
|
3964
3958
|
caption: caption,
|
|
3965
3959
|
highlighted: param.isChanged()
|
|
3966
3960
|
}, !editMode && /*#__PURE__*/React.createElement(DisplayBase, {
|
|
3967
|
-
onClick: () => setDisplayState(state => _objectSpread$
|
|
3961
|
+
onClick: () => setDisplayState(state => _objectSpread$l(_objectSpread$l({}, state), {}, {
|
|
3968
3962
|
editMode: true
|
|
3969
3963
|
}))
|
|
3970
3964
|
}, /*#__PURE__*/React.createElement(Tooltip, {
|
|
@@ -3980,7 +3974,7 @@ const PointEditor = ({
|
|
|
3980
3974
|
gridColumnEnd: '3',
|
|
3981
3975
|
width: '100%'
|
|
3982
3976
|
}
|
|
3983
|
-
}, displayVals.
|
|
3977
|
+
}, displayVals[0].toString()), typeof x === 'string' && !isDegValue(x) && /*#__PURE__*/React.createElement(ExprMark, {
|
|
3984
3978
|
style: {
|
|
3985
3979
|
right: '-3px'
|
|
3986
3980
|
}
|
|
@@ -3993,7 +3987,7 @@ const PointEditor = ({
|
|
|
3993
3987
|
gridColumnEnd: '3',
|
|
3994
3988
|
width: '100%'
|
|
3995
3989
|
}
|
|
3996
|
-
}, displayVals.
|
|
3990
|
+
}, displayVals[1].toString()), typeof y === 'string' && !isDegValue(y) && /*#__PURE__*/React.createElement(ExprMark, {
|
|
3997
3991
|
style: {
|
|
3998
3992
|
right: '-5px'
|
|
3999
3993
|
}
|
|
@@ -4010,7 +4004,7 @@ const PointEditor = ({
|
|
|
4010
4004
|
gridColumnEnd: '3',
|
|
4011
4005
|
width: '100%'
|
|
4012
4006
|
}
|
|
4013
|
-
}, displayVals.
|
|
4007
|
+
}, displayVals[2].toString()), typeof z === 'string' && !isDegValue(z) && /*#__PURE__*/React.createElement(ExprMark, {
|
|
4014
4008
|
style: {
|
|
4015
4009
|
right: '-9px'
|
|
4016
4010
|
}
|
|
@@ -4022,21 +4016,21 @@ const PointEditor = ({
|
|
|
4022
4016
|
drawingId: drawingId,
|
|
4023
4017
|
valOrExpr: x,
|
|
4024
4018
|
onChange: setX,
|
|
4025
|
-
defaults:
|
|
4019
|
+
defaults: parsedDefaults[0],
|
|
4026
4020
|
allowExpr: true,
|
|
4027
4021
|
prefix: "x:"
|
|
4028
4022
|
})), /*#__PURE__*/React.createElement(EditY, null, /*#__PURE__*/React.createElement(NumOrExpr, {
|
|
4029
4023
|
drawingId: drawingId,
|
|
4030
4024
|
valOrExpr: y,
|
|
4031
4025
|
onChange: setY,
|
|
4032
|
-
defaults:
|
|
4026
|
+
defaults: parsedDefaults[1],
|
|
4033
4027
|
allowExpr: true,
|
|
4034
4028
|
prefix: "y:"
|
|
4035
4029
|
})), /*#__PURE__*/React.createElement(EditZ, null, /*#__PURE__*/React.createElement(NumOrExpr, {
|
|
4036
4030
|
drawingId: drawingId,
|
|
4037
4031
|
valOrExpr: z,
|
|
4038
4032
|
onChange: setZ,
|
|
4039
|
-
defaults:
|
|
4033
|
+
defaults: parsedDefaults[2],
|
|
4040
4034
|
allowExpr: true,
|
|
4041
4035
|
prefix: "z:"
|
|
4042
4036
|
})), /*#__PURE__*/React.createElement(Collapse, {
|
|
@@ -4044,29 +4038,11 @@ const PointEditor = ({
|
|
|
4044
4038
|
}, "\u2014")));
|
|
4045
4039
|
};
|
|
4046
4040
|
|
|
4047
|
-
|
|
4048
|
-
function
|
|
4041
|
+
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; }
|
|
4042
|
+
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; }
|
|
4043
|
+
function createPointParam(member) {
|
|
4049
4044
|
const isExpr = member.expression.length > 0;
|
|
4050
|
-
|
|
4051
|
-
if (isExpr) {
|
|
4052
|
-
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}
|
|
4053
|
-
: member.expression;
|
|
4054
|
-
} else {
|
|
4055
|
-
const {
|
|
4056
|
-
x,
|
|
4057
|
-
y,
|
|
4058
|
-
z
|
|
4059
|
-
} = member.value;
|
|
4060
|
-
value = angle ? {
|
|
4061
|
-
x: toDeg(x),
|
|
4062
|
-
y: toDeg(y),
|
|
4063
|
-
z: toDeg(z)
|
|
4064
|
-
} : {
|
|
4065
|
-
x,
|
|
4066
|
-
y,
|
|
4067
|
-
z
|
|
4068
|
-
};
|
|
4069
|
-
}
|
|
4045
|
+
const value = isExpr ? member.expression : _objectSpread$k({}, member.value);
|
|
4070
4046
|
return {
|
|
4071
4047
|
value,
|
|
4072
4048
|
isExpr
|
|
@@ -4075,18 +4051,15 @@ function createPointParam(member, angle) {
|
|
|
4075
4051
|
function usePointParam(drawingId, objId, memberName, options = {
|
|
4076
4052
|
angle: false
|
|
4077
4053
|
}) {
|
|
4078
|
-
const {
|
|
4079
|
-
angle
|
|
4080
|
-
} = options;
|
|
4081
4054
|
const member = react.useDrawing(drawingId, d => {
|
|
4082
4055
|
var _d$structure$tree$obj, _d$structure$tree$obj2;
|
|
4083
4056
|
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];
|
|
4084
4057
|
});
|
|
4085
|
-
const defaults = React.useMemo(() => createPointParam(member
|
|
4058
|
+
const defaults = React.useMemo(() => createPointParam(member), [member]);
|
|
4086
4059
|
const [userValue, setUserValue] = React.useState(defaults);
|
|
4087
4060
|
React.useEffect(() => {
|
|
4088
|
-
setUserValue(createPointParam(member
|
|
4089
|
-
}, [member
|
|
4061
|
+
setUserValue(createPointParam(member));
|
|
4062
|
+
}, [member]);
|
|
4090
4063
|
const isChanged = React.useCallback(() => {
|
|
4091
4064
|
if (userValue.isExpr !== defaults.isExpr) {
|
|
4092
4065
|
return true;
|
|
@@ -4099,35 +4072,12 @@ function usePointParam(drawingId, objId, memberName, options = {
|
|
|
4099
4072
|
return value.x !== defValue.x || value.y !== defValue.y || value.z !== defValue.z;
|
|
4100
4073
|
}
|
|
4101
4074
|
}, [defaults, userValue]);
|
|
4102
|
-
const getServValue = React.useCallback(userValue_ => {
|
|
4103
|
-
if (userValue_.isExpr) {
|
|
4104
|
-
return {
|
|
4105
|
-
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)}
|
|
4106
|
-
: userValue_.value,
|
|
4107
|
-
isExpr: true
|
|
4108
|
-
};
|
|
4109
|
-
} else {
|
|
4110
|
-
const {
|
|
4111
|
-
x,
|
|
4112
|
-
y,
|
|
4113
|
-
z
|
|
4114
|
-
} = userValue_.value;
|
|
4115
|
-
return {
|
|
4116
|
-
value: angle ? {
|
|
4117
|
-
x: degreesToRadians(x),
|
|
4118
|
-
y: degreesToRadians(y),
|
|
4119
|
-
z: degreesToRadians(z)
|
|
4120
|
-
} : userValue_.value,
|
|
4121
|
-
isExpr: false
|
|
4122
|
-
};
|
|
4123
|
-
}
|
|
4124
|
-
}, [angle]);
|
|
4125
4075
|
return useParam({
|
|
4126
4076
|
userValue,
|
|
4127
4077
|
setUserValue,
|
|
4128
4078
|
defaults,
|
|
4129
4079
|
isChanged
|
|
4130
|
-
}
|
|
4080
|
+
});
|
|
4131
4081
|
}
|
|
4132
4082
|
|
|
4133
4083
|
var img$10 = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAADcSURBVEhL3ZTbDcMgDEVJlsgonabfnanfmaajdIlSS0aU+lWEsaLmCCkhMfheB2fJOadI1nIN49wJlv0Jo0xGURPUrZ05wkskH1OuOl+3ctfQE3bERxaLbnyJ+2WFUSYMy4G9shO63lBqvDJQBVbtThNfi39qHDAhqyOqPSY+fcDV4b63xwunFTjsbTAPa7thXFonQidXdURaq4vEIBhJmnnQAf8l8Eoi3hJp+1bGE3ATAH/odQCACcOHKwHRK3qa4AARdwemJdCw+oCgabQJd3BEieby/yUKTpDSG4InWqXAb1/sAAAAAElFTkSuQmCC";
|
|
@@ -15737,7 +15687,7 @@ const RootImpl$9 = ({
|
|
|
15737
15687
|
}];
|
|
15738
15688
|
setName(undefined);
|
|
15739
15689
|
setExpression(undefined);
|
|
15740
|
-
return classcad.ccAPI.feature.
|
|
15690
|
+
return classcad.ccAPI.feature.updateExpressions(drawingId, [{
|
|
15741
15691
|
productId: productId,
|
|
15742
15692
|
toAddMembers: toAddMembers,
|
|
15743
15693
|
toModifyMembers: [],
|
|
@@ -15755,7 +15705,7 @@ const RootImpl$9 = ({
|
|
|
15755
15705
|
}
|
|
15756
15706
|
}, [deletedExpressions]);
|
|
15757
15707
|
const update = React.useCallback(() => {
|
|
15758
|
-
return classcad.ccAPI.feature.
|
|
15708
|
+
return classcad.ccAPI.feature.updateExpressions(drawingId, [{
|
|
15759
15709
|
productId: productId,
|
|
15760
15710
|
toAddMembers: [],
|
|
15761
15711
|
toModifyMembers: editedExpressions.serverValue,
|
|
@@ -18502,7 +18452,7 @@ const ImportModel = ({
|
|
|
18502
18452
|
content
|
|
18503
18453
|
}) => {
|
|
18504
18454
|
const type = pathBrowserify.extname(file.name).replace('.', '');
|
|
18505
|
-
if (['ofb', 'stp', 'step', 'stl'].includes(type)) {
|
|
18455
|
+
if (['ofb', 'stp', 'step', 'stl'].includes(type == null ? void 0 : type.toLowerCase())) {
|
|
18506
18456
|
classcad.ccAPI.assemblyBuilder.loadProduct(drawingId, content, type, file.name).catch(console.warn);
|
|
18507
18457
|
} else {
|
|
18508
18458
|
throw new Error('This type of file is not supported to import.');
|
|
@@ -18709,7 +18659,7 @@ const load = (file, singleDrawingApp) => {
|
|
|
18709
18659
|
try {
|
|
18710
18660
|
core.api.getState().api.setActiveDrawing(drawingId);
|
|
18711
18661
|
const type = pathBrowserify.extname(file.name).replace('.', '');
|
|
18712
|
-
if (['ofb', 'stp', 'step', 'stl'].includes(type)) {
|
|
18662
|
+
if (['ofb', 'stp', 'step', 'stl'].includes(type == null ? void 0 : type.toLowerCase())) {
|
|
18713
18663
|
await classcad.ccAPI.baseModeler.load(drawingId, result, type, file.name).catch(console.warn);
|
|
18714
18664
|
} else {
|
|
18715
18665
|
throw new Error('This type of file is not supported to load.');
|
|
@@ -19560,7 +19510,7 @@ const Divider = props => {
|
|
|
19560
19510
|
}));
|
|
19561
19511
|
};
|
|
19562
19512
|
|
|
19563
|
-
const animation = styled.keyframes`
|
|
19513
|
+
const animation$1 = styled.keyframes`
|
|
19564
19514
|
0%,
|
|
19565
19515
|
100% {
|
|
19566
19516
|
box-shadow: 0em -2.6em 0em 0em #ffffff, 1.8em -1.8em 0 0em rgba(255, 255, 255, 0.2),
|
|
@@ -19619,7 +19569,7 @@ const Spinner = styled.div`
|
|
|
19619
19569
|
border-radius: 50%;
|
|
19620
19570
|
position: relative;
|
|
19621
19571
|
text-indent: -9999em;
|
|
19622
|
-
animation: ${animation} 1.1s infinite ease;
|
|
19572
|
+
animation: ${animation$1} 1.1s infinite ease;
|
|
19623
19573
|
transform: translateZ(0);
|
|
19624
19574
|
`;
|
|
19625
19575
|
|
|
@@ -19667,6 +19617,9 @@ function createApi(set) {
|
|
|
19667
19617
|
msgs: newMsgs
|
|
19668
19618
|
});
|
|
19669
19619
|
}),
|
|
19620
|
+
deleteAllMsgs: () => set(prev => _objectSpread$4(_objectSpread$4({}, prev), {}, {
|
|
19621
|
+
msgs: {}
|
|
19622
|
+
})),
|
|
19670
19623
|
setShown: () => {
|
|
19671
19624
|
set(prev => {
|
|
19672
19625
|
const msgs = _objectSpread$4({}, prev.msgs);
|
|
@@ -19698,27 +19651,49 @@ function getBorderColor(msg) {
|
|
|
19698
19651
|
return '#91d5ff';
|
|
19699
19652
|
}
|
|
19700
19653
|
function getBackGrColor(msg) {
|
|
19701
|
-
if (msg.isShown) return '#
|
|
19654
|
+
if (msg.isShown) return '#fafafa';
|
|
19702
19655
|
if (msg.type === 'success') return '#f6ffed';
|
|
19703
19656
|
if (msg.type === 'error') return '#fff2f0';
|
|
19704
19657
|
if (msg.type === 'warning') return '#fffbe6';
|
|
19705
19658
|
if (msg.type === 'busy' || msg.type === 'info') return '#e6f7ff';
|
|
19706
19659
|
return '#e6f7ff';
|
|
19707
19660
|
}
|
|
19661
|
+
function isAccentuated(msg) {
|
|
19662
|
+
return msg.type === 'error' && !msg.isShown;
|
|
19663
|
+
}
|
|
19664
|
+
const animation = styled.keyframes`
|
|
19665
|
+
0% {
|
|
19666
|
+
background-color: #fff2f0;
|
|
19667
|
+
border-color: #ffccc7;
|
|
19668
|
+
}
|
|
19669
|
+
50% {
|
|
19670
|
+
background-color: #ffe8e0;
|
|
19671
|
+
border-color: #ffaca7;
|
|
19672
|
+
}
|
|
19673
|
+
100% {
|
|
19674
|
+
background-color: #fff2f0;
|
|
19675
|
+
border-color: #ffccc7;
|
|
19676
|
+
}
|
|
19677
|
+
`;
|
|
19708
19678
|
const MessageWrapper = styled.div`
|
|
19679
|
+
width: ${props => isAccentuated(props.msg) ? '100%' : '80%'};
|
|
19680
|
+
min-width: 0px;
|
|
19709
19681
|
border: 1px solid ${props => getBorderColor(props.msg)};
|
|
19710
19682
|
background-color: ${props => getBackGrColor(props.msg)};
|
|
19711
19683
|
padding: 8px 15px;
|
|
19712
|
-
margin
|
|
19684
|
+
margin: 0px 0px 4px auto;
|
|
19685
|
+
${props => isAccentuated(props.msg) && styled.css`
|
|
19686
|
+
-webkit-animation: ${animation} 0.5s infinite ease-in;
|
|
19687
|
+
`}
|
|
19713
19688
|
`;
|
|
19714
19689
|
const FlexContainer = styled.div`
|
|
19715
19690
|
display: flex;
|
|
19716
|
-
align-items:
|
|
19691
|
+
align-items: top;
|
|
19717
19692
|
`;
|
|
19718
19693
|
const MessageText = styled.div`
|
|
19719
|
-
flex-grow: 1;
|
|
19720
19694
|
overflow: auto;
|
|
19721
19695
|
overflow-wrap: break-word;
|
|
19696
|
+
min-width: 0px;
|
|
19722
19697
|
max-height: 300px;
|
|
19723
19698
|
&::-webkit-scrollbar {
|
|
19724
19699
|
width: 12px;
|
|
@@ -19731,14 +19706,19 @@ const MessageText = styled.div`
|
|
|
19731
19706
|
}
|
|
19732
19707
|
`;
|
|
19733
19708
|
const iconStyle = {
|
|
19734
|
-
marginRight: '8px'
|
|
19709
|
+
marginRight: '8px',
|
|
19710
|
+
marginTop: '1px',
|
|
19711
|
+
fontSize: '20px'
|
|
19735
19712
|
};
|
|
19736
19713
|
const CloseButton = styled.button`
|
|
19737
|
-
margin-left: 8px;
|
|
19738
19714
|
padding: 0;
|
|
19739
19715
|
overflow: hidden;
|
|
19716
|
+
width: 12px;
|
|
19717
|
+
height: 12px;
|
|
19740
19718
|
font-size: 12px;
|
|
19741
19719
|
line-height: 12px;
|
|
19720
|
+
margin-left: 8px;
|
|
19721
|
+
margin-top: 5px;
|
|
19742
19722
|
background-color: transparent;
|
|
19743
19723
|
border: none;
|
|
19744
19724
|
outline: none;
|
|
@@ -19747,7 +19727,7 @@ const CloseButton = styled.button`
|
|
|
19747
19727
|
const Time = styled.div`
|
|
19748
19728
|
font-size: 0.7rem;
|
|
19749
19729
|
color: #adadad;
|
|
19750
|
-
margin-left:
|
|
19730
|
+
margin-left: 28px;
|
|
19751
19731
|
`;
|
|
19752
19732
|
function getTime(timestamp) {
|
|
19753
19733
|
const date = new Date(timestamp);
|
|
@@ -19788,7 +19768,11 @@ const Message = ({
|
|
|
19788
19768
|
msg: msg
|
|
19789
19769
|
}, /*#__PURE__*/React.createElement(FlexContainer, null, /*#__PURE__*/React.createElement(Icon$1, {
|
|
19790
19770
|
type: type
|
|
19791
|
-
}), /*#__PURE__*/React.createElement(MessageText,
|
|
19771
|
+
}), /*#__PURE__*/React.createElement(MessageText, {
|
|
19772
|
+
style: {
|
|
19773
|
+
flex: 1
|
|
19774
|
+
}
|
|
19775
|
+
}, `${msg.title ? msg.title : ''} ${msg.text}`), /*#__PURE__*/React.createElement(CloseButton, {
|
|
19792
19776
|
onClick: () => msgApi.deleteMsg(msgId)
|
|
19793
19777
|
}, /*#__PURE__*/React.createElement(icons.CloseOutlined, null))), /*#__PURE__*/React.createElement(Time, null, getTime(msg.timestamp)));
|
|
19794
19778
|
};
|
|
@@ -19796,9 +19780,8 @@ const Message = ({
|
|
|
19796
19780
|
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; }
|
|
19797
19781
|
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; }
|
|
19798
19782
|
const MsgListWrapper = styled.div`
|
|
19783
|
+
width: 500px;
|
|
19799
19784
|
max-height: 500px;
|
|
19800
|
-
max-width: 400px;
|
|
19801
|
-
min-width: 300px;
|
|
19802
19785
|
overflow-y: auto;
|
|
19803
19786
|
&::-webkit-scrollbar {
|
|
19804
19787
|
width: 12px;
|
|
@@ -19812,19 +19795,22 @@ const MsgListWrapper = styled.div`
|
|
|
19812
19795
|
z-index: ${blankZIndex + 1};
|
|
19813
19796
|
`;
|
|
19814
19797
|
const MessageList = ({
|
|
19815
|
-
|
|
19798
|
+
isOpen
|
|
19816
19799
|
}) => {
|
|
19817
|
-
const
|
|
19800
|
+
const msgApi = useMsgStore(s => s.api);
|
|
19801
|
+
const msgIds = useMsgStore(s => {
|
|
19818
19802
|
// Return array of messages with fresh messages in the beginning
|
|
19819
|
-
|
|
19803
|
+
const allMsgIds = Object.keys(s.msgs).sort((id1, id2) => s.msgs[id2].timestamp - s.msgs[id1].timestamp);
|
|
19804
|
+
return isOpen ? allMsgIds : allMsgIds.filter(id => s.msgs[id].type === 'error' && !s.msgs[id].isShown);
|
|
19820
19805
|
});
|
|
19821
|
-
const msgsApi = useMsgStore(s => s.api);
|
|
19822
19806
|
|
|
19823
|
-
// Set
|
|
19807
|
+
// Set isShown = true for all messages in store on unhover / unpin
|
|
19824
19808
|
React.useEffect(() => {
|
|
19825
|
-
|
|
19826
|
-
|
|
19827
|
-
|
|
19809
|
+
if (!isOpen) {
|
|
19810
|
+
msgApi.setShown();
|
|
19811
|
+
}
|
|
19812
|
+
}, [isOpen, msgApi]);
|
|
19813
|
+
return /*#__PURE__*/React.createElement(MsgListWrapper, null, msgIds.map(msgId => /*#__PURE__*/React.createElement(Message, {
|
|
19828
19814
|
msgId: msgId,
|
|
19829
19815
|
key: msgId
|
|
19830
19816
|
})));
|
|
@@ -19832,15 +19818,30 @@ const MessageList = ({
|
|
|
19832
19818
|
const Messages = ({
|
|
19833
19819
|
drawingId
|
|
19834
19820
|
}) => {
|
|
19835
|
-
const [
|
|
19821
|
+
const [isHovered, setIsHovered] = React.useState(false);
|
|
19822
|
+
const [isPinned, setIsPinned] = React.useState(true);
|
|
19836
19823
|
const [showBadge, setShowBadge] = React.useState(false);
|
|
19824
|
+
const isOpen = isHovered || isPinned;
|
|
19837
19825
|
const timestamp = react.useBuerli(state => state.message.timestamp);
|
|
19838
19826
|
const msg = react.useBuerli(state => state.message.data);
|
|
19839
19827
|
const msgsApi = useMsgStore(s => s.api);
|
|
19840
|
-
const msgsLen = useMsgStore(s => Object.keys(s.msgs).length);
|
|
19841
|
-
React.useEffect(() => setShowBadge(true), [timestamp]);
|
|
19842
19828
|
|
|
19843
|
-
//
|
|
19829
|
+
// If there are some new messages, and the message list is not shown, then display the badge
|
|
19830
|
+
React.useEffect(() => {
|
|
19831
|
+
if (!isOpen) {
|
|
19832
|
+
setShowBadge(true);
|
|
19833
|
+
}
|
|
19834
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
19835
|
+
}, [timestamp]);
|
|
19836
|
+
|
|
19837
|
+
// Whenever the message list is opened, stop showing the badge
|
|
19838
|
+
React.useEffect(() => {
|
|
19839
|
+
if (isOpen) {
|
|
19840
|
+
setShowBadge(false);
|
|
19841
|
+
}
|
|
19842
|
+
}, [isOpen]);
|
|
19843
|
+
|
|
19844
|
+
// Add recent message to the store
|
|
19844
19845
|
React.useEffect(() => {
|
|
19845
19846
|
if (timestamp && msg && (msg.text || msg.title)) {
|
|
19846
19847
|
msgsApi.setMsg(msg.id, _objectSpread$3(_objectSpread$3({}, msg), {}, {
|
|
@@ -19850,36 +19851,49 @@ const Messages = ({
|
|
|
19850
19851
|
}
|
|
19851
19852
|
}, [timestamp, msg, msgsApi]);
|
|
19852
19853
|
|
|
19853
|
-
//
|
|
19854
|
+
// Clean up messages on drawingId change
|
|
19854
19855
|
React.useEffect(() => {
|
|
19855
|
-
|
|
19856
|
-
}, [
|
|
19857
|
-
const
|
|
19858
|
-
|
|
19859
|
-
|
|
19860
|
-
|
|
19861
|
-
|
|
19862
|
-
|
|
19863
|
-
setShowList(s => !s);
|
|
19864
|
-
setShowBadge(false);
|
|
19865
|
-
}, [showList]);
|
|
19856
|
+
msgsApi.deleteAllMsgs();
|
|
19857
|
+
}, [drawingId, msgsApi]);
|
|
19858
|
+
const onClearClick = React.useCallback(() => {
|
|
19859
|
+
msgsApi.deleteAllMsgs();
|
|
19860
|
+
}, [msgsApi]);
|
|
19861
|
+
const onMessagesClick = React.useCallback(() => {
|
|
19862
|
+
setIsPinned(s => !s);
|
|
19863
|
+
}, []);
|
|
19866
19864
|
return /*#__PURE__*/React.createElement("div", {
|
|
19867
19865
|
style: {
|
|
19868
19866
|
display: 'flex',
|
|
19869
19867
|
flexDirection: 'column',
|
|
19870
19868
|
alignItems: 'flex-end'
|
|
19871
|
-
}
|
|
19872
|
-
|
|
19873
|
-
|
|
19874
|
-
|
|
19875
|
-
|
|
19869
|
+
},
|
|
19870
|
+
onMouseLeave: () => setIsHovered(false)
|
|
19871
|
+
}, /*#__PURE__*/React.createElement(MessageList, {
|
|
19872
|
+
isOpen: isOpen
|
|
19873
|
+
}), /*#__PURE__*/React.createElement(antd.Space, {
|
|
19874
|
+
style: {
|
|
19875
|
+
marginTop: '5px'
|
|
19876
|
+
},
|
|
19877
|
+
onMouseEnter: () => setIsHovered(true)
|
|
19878
|
+
}, /*#__PURE__*/React.createElement(Tooltip, {
|
|
19879
|
+
title: "Clear messages"
|
|
19880
|
+
}, /*#__PURE__*/React.createElement(antd.Button, {
|
|
19881
|
+
style: {
|
|
19882
|
+
display: isOpen ? 'inline' : 'none'
|
|
19883
|
+
},
|
|
19884
|
+
size: "small",
|
|
19885
|
+
icon: /*#__PURE__*/React.createElement(icons.DeleteOutlined, null),
|
|
19886
|
+
onClick: onClearClick
|
|
19887
|
+
})), /*#__PURE__*/React.createElement(Tooltip, {
|
|
19888
|
+
title: "Messages (Pin / Unpin)"
|
|
19876
19889
|
}, /*#__PURE__*/React.createElement(antd.Badge, {
|
|
19877
19890
|
dot: showBadge
|
|
19878
19891
|
}, /*#__PURE__*/React.createElement(antd.Button, {
|
|
19879
19892
|
size: "small",
|
|
19880
|
-
|
|
19881
|
-
|
|
19882
|
-
|
|
19893
|
+
type: isPinned ? 'primary' : 'default',
|
|
19894
|
+
icon: /*#__PURE__*/React.createElement(icons.MessageOutlined, null),
|
|
19895
|
+
onClick: onMessagesClick
|
|
19896
|
+
})))));
|
|
19883
19897
|
};
|
|
19884
19898
|
|
|
19885
19899
|
const DraggableModalContext = /*#__PURE__*/React__namespace.createContext(null);
|
|
@@ -22356,8 +22370,8 @@ const Drawing = ({
|
|
|
22356
22370
|
}, children), /*#__PURE__*/React.createElement("div", {
|
|
22357
22371
|
style: {
|
|
22358
22372
|
position: 'absolute',
|
|
22359
|
-
bottom: '
|
|
22360
|
-
right: '
|
|
22373
|
+
bottom: '5px',
|
|
22374
|
+
right: '5px'
|
|
22361
22375
|
}
|
|
22362
22376
|
}, /*#__PURE__*/React.createElement(Messages, {
|
|
22363
22377
|
drawingId: drawingId
|