vim-web 0.3.44-dev.69 → 0.3.44-dev.70
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/dist/types/react-viewers/components/inputNumber.d.ts +4 -0
- package/dist/types/react-viewers/helpers/reactUtils.d.ts +1 -1
- package/dist/types/react-viewers/panels/genericPanel.d.ts +5 -1
- package/dist/types/react-viewers/state/sectionBoxState.d.ts +3 -3
- package/dist/types/react-viewers/state/sharedIsolation.d.ts +1 -1
- package/dist/types/utils/index.d.ts +0 -1
- package/dist/vim-web.iife.js +73 -47
- package/dist/vim-web.iife.js.map +1 -1
- package/dist/vim-web.js +74 -48
- package/dist/vim-web.js.map +1 -1
- package/package.json +1 -1
- package/dist/types/utils/strings.d.ts +0 -7
package/dist/vim-web.js
CHANGED
|
@@ -3,7 +3,7 @@ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { en
|
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
4
|
var _a2;
|
|
5
5
|
import * as React from "react";
|
|
6
|
-
import React__default, { useState, useRef, useEffect, useMemo, useCallback, useImperativeHandle, useContext, Component, forwardRef, useLayoutEffect } from "react";
|
|
6
|
+
import React__default, { useState, useRef, useEffect, useMemo, useCallback, useImperativeHandle, useContext, Component, forwardRef, useSyncExternalStore, useLayoutEffect } from "react";
|
|
7
7
|
import ReactDOM, { flushSync as flushSync$1 } from "react-dom";
|
|
8
8
|
function getDefaultExportFromCjs(x) {
|
|
9
9
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
@@ -50725,17 +50725,6 @@ function clamp$1(value, min2, max2) {
|
|
|
50725
50725
|
}
|
|
50726
50726
|
return Math.min(Math.max(value, min2), max2);
|
|
50727
50727
|
}
|
|
50728
|
-
function sanitize(value, strict, fallback) {
|
|
50729
|
-
if (!strict) {
|
|
50730
|
-
if (value === "" || value === "-") return value;
|
|
50731
|
-
}
|
|
50732
|
-
const num = parseFloat(value);
|
|
50733
|
-
console.log(num);
|
|
50734
|
-
if (isNaN(num)) {
|
|
50735
|
-
return strict ? fallback.toString() : void 0;
|
|
50736
|
-
}
|
|
50737
|
-
return String(num);
|
|
50738
|
-
}
|
|
50739
50728
|
function addBox(b1, b2) {
|
|
50740
50729
|
const r = b1.clone();
|
|
50741
50730
|
r.min.x += b2.min.x;
|
|
@@ -74676,10 +74665,10 @@ function useStateRef(initialValue) {
|
|
|
74676
74665
|
}
|
|
74677
74666
|
}
|
|
74678
74667
|
const event = useRef(new distExports.SimpleEventDispatcher());
|
|
74679
|
-
const validate = useRef((
|
|
74668
|
+
const validate = useRef((next, current) => next);
|
|
74680
74669
|
const confirm = useRef((value2) => value2);
|
|
74681
74670
|
const set3 = (value2) => {
|
|
74682
|
-
const finalValue = validate.current(value2);
|
|
74671
|
+
const finalValue = validate.current(value2, ref.current);
|
|
74683
74672
|
if (finalValue === ref.current) return;
|
|
74684
74673
|
ref.current = finalValue;
|
|
74685
74674
|
setValue(finalValue);
|
|
@@ -74730,7 +74719,7 @@ function useStateRef(initialValue) {
|
|
|
74730
74719
|
* @param on - A function that validates (and optionally transforms) the new state value.
|
|
74731
74720
|
*/
|
|
74732
74721
|
useValidate(on) {
|
|
74733
|
-
set3(on(ref.current));
|
|
74722
|
+
set3(on(ref.current, ref.current));
|
|
74734
74723
|
useEffect(() => {
|
|
74735
74724
|
validate.current = on;
|
|
74736
74725
|
}, []);
|
|
@@ -75544,6 +75533,44 @@ function modalContent(modal) {
|
|
|
75544
75533
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(LoadingBox, { content: modal });
|
|
75545
75534
|
}
|
|
75546
75535
|
}
|
|
75536
|
+
function InputNumber(props) {
|
|
75537
|
+
const defaultValue = useRef(props.state.get());
|
|
75538
|
+
const externalValue = useSyncExternalStore(
|
|
75539
|
+
(callback) => props.state.onChange.subscribe(callback),
|
|
75540
|
+
() => props.state.get()
|
|
75541
|
+
);
|
|
75542
|
+
const [inputValue, setInputValue] = useState(externalValue.toString());
|
|
75543
|
+
useEffect(() => {
|
|
75544
|
+
const parsed = parseFloat(inputValue);
|
|
75545
|
+
if (isNaN(parsed) || parsed !== externalValue) {
|
|
75546
|
+
setInputValue(externalValue.toString());
|
|
75547
|
+
}
|
|
75548
|
+
}, [externalValue]);
|
|
75549
|
+
const handleChange = (e) => {
|
|
75550
|
+
const input = e.target.value;
|
|
75551
|
+
setInputValue(input);
|
|
75552
|
+
const parsed = parseFloat(input);
|
|
75553
|
+
if (!isNaN(parsed)) {
|
|
75554
|
+
props.state.set(parsed);
|
|
75555
|
+
}
|
|
75556
|
+
};
|
|
75557
|
+
const handleBlur = () => {
|
|
75558
|
+
const parsed = parseFloat(inputValue);
|
|
75559
|
+
const value = isNaN(parsed) ? defaultValue.current : parsed;
|
|
75560
|
+
props.state.set(value);
|
|
75561
|
+
setInputValue(props.state.get().toString());
|
|
75562
|
+
};
|
|
75563
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
75564
|
+
"input",
|
|
75565
|
+
{
|
|
75566
|
+
type: "number",
|
|
75567
|
+
value: inputValue,
|
|
75568
|
+
onChange: handleChange,
|
|
75569
|
+
onBlur: handleBlur,
|
|
75570
|
+
className: "vc-border vc-inline vc-border-gray-300 vc-py-1 vc-w-full vc-px-1"
|
|
75571
|
+
}
|
|
75572
|
+
);
|
|
75573
|
+
}
|
|
75547
75574
|
function GenericPanel(props) {
|
|
75548
75575
|
const [panelPosition, setPanelPosition] = useState({
|
|
75549
75576
|
top: 0,
|
|
@@ -75568,17 +75595,19 @@ function GenericPanel(props) {
|
|
|
75568
75595
|
};
|
|
75569
75596
|
}, [props.showPanel.get()]);
|
|
75570
75597
|
if (!props.showPanel.get()) return null;
|
|
75571
|
-
const createTextBox = (field) =>
|
|
75572
|
-
|
|
75573
|
-
|
|
75574
|
-
|
|
75575
|
-
|
|
75576
|
-
|
|
75577
|
-
|
|
75578
|
-
|
|
75579
|
-
|
|
75580
|
-
|
|
75581
|
-
|
|
75598
|
+
const createTextBox = (field) => {
|
|
75599
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
75600
|
+
"input",
|
|
75601
|
+
{
|
|
75602
|
+
id: field.id,
|
|
75603
|
+
type: "number",
|
|
75604
|
+
value: field.state.get(),
|
|
75605
|
+
onChange: (e) => field.state.set(e.target.value),
|
|
75606
|
+
className: "vc-border vc-inline vc-border-gray-300 vc-py-1 vc-w-full vc-px-1",
|
|
75607
|
+
onBlur: () => field.state.confirm()
|
|
75608
|
+
}
|
|
75609
|
+
);
|
|
75610
|
+
};
|
|
75582
75611
|
const createCheckbox = (field) => /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
75583
75612
|
"input",
|
|
75584
75613
|
{
|
|
@@ -75591,7 +75620,9 @@ function GenericPanel(props) {
|
|
|
75591
75620
|
);
|
|
75592
75621
|
const renderField = (field) => {
|
|
75593
75622
|
let fieldElement = null;
|
|
75594
|
-
if (field.type === "
|
|
75623
|
+
if (field.type === "number") {
|
|
75624
|
+
fieldElement = /* @__PURE__ */ jsxRuntimeExports.jsx(InputNumber, { state: field.state });
|
|
75625
|
+
} else if (field.type === "text") {
|
|
75595
75626
|
fieldElement = createTextBox(field);
|
|
75596
75627
|
} else if (field.type === "bool") {
|
|
75597
75628
|
fieldElement = createCheckbox(field);
|
|
@@ -75662,9 +75693,9 @@ function SectionBoxPanel(props) {
|
|
|
75662
75693
|
header: "Section Box Offsets",
|
|
75663
75694
|
showPanel: props.state.showOffsetPanel,
|
|
75664
75695
|
fields: [
|
|
75665
|
-
{ type: "
|
|
75666
|
-
{ type: "
|
|
75667
|
-
{ type: "
|
|
75696
|
+
{ type: "number", id: "topOffset", label: "Top Offset", state: props.state.topOffset },
|
|
75697
|
+
{ type: "number", id: "sideOffset", label: "Side Offset", state: props.state.sideOffset },
|
|
75698
|
+
{ type: "number", id: "bottomOffset", label: "Bottom Offset", state: props.state.bottomOffset }
|
|
75668
75699
|
]
|
|
75669
75700
|
});
|
|
75670
75701
|
}
|
|
@@ -75673,9 +75704,9 @@ function useSectionBox(adapter) {
|
|
|
75673
75704
|
const visible2 = useStateRef(false);
|
|
75674
75705
|
const showOffsetPanel = useStateRef(false);
|
|
75675
75706
|
const auto = useStateRef(false);
|
|
75676
|
-
const topOffset = useStateRef(
|
|
75677
|
-
const sideOffset = useStateRef(
|
|
75678
|
-
const bottomOffset = useStateRef(
|
|
75707
|
+
const topOffset = useStateRef(1);
|
|
75708
|
+
const sideOffset = useStateRef(1);
|
|
75709
|
+
const bottomOffset = useStateRef(1);
|
|
75679
75710
|
const boxRef = useRef(adapter.getBox());
|
|
75680
75711
|
const getSelectionBox = useAsyncFuncRef(adapter.getSelectionBox);
|
|
75681
75712
|
const getSceneBox = useAsyncFuncRef(adapter.getSceneBox);
|
|
@@ -75698,9 +75729,6 @@ function useSectionBox(adapter) {
|
|
|
75698
75729
|
});
|
|
75699
75730
|
visible2.useValidate((v) => enable.get() && v);
|
|
75700
75731
|
showOffsetPanel.useValidate((v) => enable.get() && v);
|
|
75701
|
-
topOffset.useConfirm((v) => sanitize(v, true, 1));
|
|
75702
|
-
sideOffset.useConfirm((v) => sanitize(v, true, 1));
|
|
75703
|
-
bottomOffset.useConfirm((v) => sanitize(v, true, 1));
|
|
75704
75732
|
topOffset.useOnChange((v) => sectionBox2.call(boxRef.current));
|
|
75705
75733
|
sideOffset.useOnChange((v) => sectionBox2.call(boxRef.current));
|
|
75706
75734
|
bottomOffset.useOnChange((v) => sectionBox2.call(boxRef.current));
|
|
@@ -75711,7 +75739,7 @@ function useSectionBox(adapter) {
|
|
|
75711
75739
|
const sectionBox2 = useArgActionRef((baseBox) => {
|
|
75712
75740
|
if (baseBox === void 0) return;
|
|
75713
75741
|
boxRef.current = baseBox;
|
|
75714
|
-
const newBox = addBox(baseBox,
|
|
75742
|
+
const newBox = addBox(baseBox, offsetsToBox3_(topOffset.get(), sideOffset.get(), bottomOffset.get()));
|
|
75715
75743
|
adapter.setBox(newBox);
|
|
75716
75744
|
});
|
|
75717
75745
|
const sectionSelection2 = useFuncRef(async () => {
|
|
@@ -75739,14 +75767,10 @@ function useSectionBox(adapter) {
|
|
|
75739
75767
|
getSelectionBox
|
|
75740
75768
|
};
|
|
75741
75769
|
}
|
|
75742
|
-
function
|
|
75743
|
-
const getNumber = (s) => {
|
|
75744
|
-
const num = parseFloat(s);
|
|
75745
|
-
return isNaN(num) ? 0 : num;
|
|
75746
|
-
};
|
|
75770
|
+
function offsetsToBox3_(top, side, bottom) {
|
|
75747
75771
|
return new Box3(
|
|
75748
|
-
new Vector3(-
|
|
75749
|
-
new Vector3(
|
|
75772
|
+
new Vector3(-side, -side, -bottom),
|
|
75773
|
+
new Vector3(side, side, top)
|
|
75750
75774
|
);
|
|
75751
75775
|
}
|
|
75752
75776
|
function useWebglSectionBox(viewer) {
|
|
@@ -75837,7 +75861,7 @@ function IsolationSettingsPanel(props) {
|
|
|
75837
75861
|
fields: [
|
|
75838
75862
|
{ type: "bool", id: "showGhost", label: "Show Ghost", state: props.state.showGhost },
|
|
75839
75863
|
// { type: 'bool', id: 'showRooms', label: 'Show Rooms', state: props.state.showRooms },
|
|
75840
|
-
{ type: "
|
|
75864
|
+
{ type: "number", id: "ghostOpacity", label: "Ghost Opacity", state: props.state.ghostOpacity }
|
|
75841
75865
|
]
|
|
75842
75866
|
});
|
|
75843
75867
|
}
|
|
@@ -75848,7 +75872,7 @@ function useSharedIsolation(adapter) {
|
|
|
75848
75872
|
const showPanel = useStateRef(false);
|
|
75849
75873
|
const showRooms = useStateRef(false);
|
|
75850
75874
|
const showGhost = useStateRef(false);
|
|
75851
|
-
const ghostOpacity = useStateRef(() => adapter.getGhostOpacity()
|
|
75875
|
+
const ghostOpacity = useStateRef(() => adapter.getGhostOpacity());
|
|
75852
75876
|
const onAutoIsolate = useFuncRef(() => {
|
|
75853
75877
|
if (adapter.hasSelection()) {
|
|
75854
75878
|
adapter.isolateSelection();
|
|
@@ -75868,13 +75892,15 @@ function useSharedIsolation(adapter) {
|
|
|
75868
75892
|
if (autoIsolate2.get()) onAutoIsolate.call();
|
|
75869
75893
|
});
|
|
75870
75894
|
}, []);
|
|
75871
|
-
ghostOpacity.useConfirm((v) => sanitize(v, true, 0.04));
|
|
75872
75895
|
autoIsolate2.useOnChange((v) => {
|
|
75873
75896
|
if (v) onAutoIsolate.call();
|
|
75874
75897
|
});
|
|
75875
75898
|
showGhost.useOnChange((v) => adapter.showGhost(v));
|
|
75876
75899
|
showRooms.useOnChange((v) => adapter.setShowRooms(v));
|
|
75877
|
-
ghostOpacity.
|
|
75900
|
+
ghostOpacity.useValidate((next, current) => {
|
|
75901
|
+
return next <= 0 ? current : next;
|
|
75902
|
+
});
|
|
75903
|
+
ghostOpacity.useOnChange((v) => adapter.setGhostOpacity(v));
|
|
75878
75904
|
return {
|
|
75879
75905
|
adapter: _adapter,
|
|
75880
75906
|
visibility,
|