@reekon-tools/boldr-cad 0.1.0 → 1.0.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/README.md +81 -9
- package/dist/app/edit.d.ts +12 -1
- package/dist/app/edit.js +96 -11
- package/dist/app/edit.js.map +1 -1
- package/dist/app/state.d.ts +31 -4
- package/dist/app/state.js +31 -2
- package/dist/app/state.js.map +1 -1
- package/dist/data/memory.d.ts +5 -0
- package/dist/data/memory.js +2 -2
- package/dist/data/memory.js.map +1 -1
- package/dist/data/provider.d.ts +19 -7
- package/dist/data/sync.d.ts +7 -2
- package/dist/data/sync.js +115 -64
- package/dist/data/sync.js.map +1 -1
- package/dist/editor/actions.d.ts +1 -2
- package/dist/editor/actions.js +391 -113
- package/dist/editor/actions.js.map +1 -1
- package/dist/editor/confirm.d.ts +23 -0
- package/dist/editor/confirm.js +35 -0
- package/dist/editor/confirm.js.map +1 -0
- package/dist/editor/elevation.d.ts +191 -90
- package/dist/editor/elevation.js +812 -616
- package/dist/editor/elevation.js.map +1 -1
- package/dist/editor/face.d.ts +73 -0
- package/dist/editor/face.js +269 -0
- package/dist/editor/face.js.map +1 -0
- package/dist/editor/files.d.ts +6 -0
- package/dist/editor/files.js +50 -4
- package/dist/editor/files.js.map +1 -1
- package/dist/editor/gestures.d.ts +18 -3
- package/dist/editor/gestures.js +145 -30
- package/dist/editor/gestures.js.map +1 -1
- package/dist/editor/keypad.d.ts +19 -4
- package/dist/editor/keypad.js +39 -9
- package/dist/editor/keypad.js.map +1 -1
- package/dist/editor/keys.js +36 -4
- package/dist/editor/keys.js.map +1 -1
- package/dist/editor/laser.d.ts +20 -4
- package/dist/editor/laser.js +104 -21
- package/dist/editor/laser.js.map +1 -1
- package/dist/editor/linkActions.d.ts +49 -0
- package/dist/editor/linkActions.js +210 -0
- package/dist/editor/linkActions.js.map +1 -0
- package/dist/editor/linkFollow.d.ts +2 -0
- package/dist/editor/linkFollow.js +53 -0
- package/dist/editor/linkFollow.js.map +1 -0
- package/dist/editor/linkWrite.d.ts +13 -0
- package/dist/editor/linkWrite.js +84 -0
- package/dist/editor/linkWrite.js.map +1 -0
- package/dist/editor/links.d.ts +84 -0
- package/dist/editor/links.js +130 -0
- package/dist/editor/links.js.map +1 -0
- package/dist/editor/markup.d.ts +29 -3
- package/dist/editor/markup.js +95 -10
- package/dist/editor/markup.js.map +1 -1
- package/dist/editor/mode.d.ts +40 -2
- package/dist/editor/mode.js +71 -4
- package/dist/editor/mode.js.map +1 -1
- package/dist/editor/ports.d.ts +36 -6
- package/dist/editor/ports.js +10 -1
- package/dist/editor/ports.js.map +1 -1
- package/dist/editor/project.d.ts +38 -6
- package/dist/editor/project.js +167 -27
- package/dist/editor/project.js.map +1 -1
- package/dist/editor/selection.d.ts +10 -0
- package/dist/editor/selection.js +62 -8
- package/dist/editor/selection.js.map +1 -1
- package/dist/editor/status.js +3 -0
- package/dist/editor/status.js.map +1 -1
- package/dist/editor/tooltips.d.ts +5 -0
- package/dist/editor/tooltips.js +48 -0
- package/dist/editor/tooltips.js.map +1 -0
- package/dist/editor/view3d.d.ts +17 -0
- package/dist/editor/view3d.js +135 -0
- package/dist/editor/view3d.js.map +1 -0
- package/dist/editor/view3dState.d.ts +39 -0
- package/dist/editor/view3dState.js +44 -0
- package/dist/editor/view3dState.js.map +1 -0
- package/dist/export/dxf.js +1 -1
- package/dist/export/dxf.js.map +1 -1
- package/dist/export/pdf.js +17 -12
- package/dist/export/pdf.js.map +1 -1
- package/dist/export/plan.d.ts +23 -6
- package/dist/export/plan.js +127 -44
- package/dist/export/plan.js.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/model/constraints.js +15 -4
- package/dist/model/constraints.js.map +1 -1
- package/dist/model/demo.js +3 -3
- package/dist/model/demo.js.map +1 -1
- package/dist/model/elevation.d.ts +6 -9
- package/dist/model/elevation.js +5 -13
- package/dist/model/elevation.js.map +1 -1
- package/dist/model/faces.d.ts +58 -0
- package/dist/model/faces.js +197 -0
- package/dist/model/faces.js.map +1 -0
- package/dist/model/facesolve.d.ts +72 -0
- package/dist/model/facesolve.js +369 -0
- package/dist/model/facesolve.js.map +1 -0
- package/dist/model/history.d.ts +3 -2
- package/dist/model/history.js +17 -11
- package/dist/model/history.js.map +1 -1
- package/dist/model/images.d.ts +18 -0
- package/dist/model/images.js +26 -0
- package/dist/model/images.js.map +1 -0
- package/dist/model/links.d.ts +46 -0
- package/dist/model/links.js +73 -0
- package/dist/model/links.js.map +1 -0
- package/dist/model/markup.d.ts +46 -0
- package/dist/model/markup.js +71 -0
- package/dist/model/markup.js.map +1 -0
- package/dist/model/measurement.d.ts +11 -0
- package/dist/model/measurement.js +24 -0
- package/dist/model/measurement.js.map +1 -0
- package/dist/model/openings.d.ts +4 -0
- package/dist/model/openings.js +4 -0
- package/dist/model/openings.js.map +1 -1
- package/dist/model/planGeom.d.ts +72 -2
- package/dist/model/planGeom.js +184 -10
- package/dist/model/planGeom.js.map +1 -1
- package/dist/model/project.js +3 -2
- package/dist/model/project.js.map +1 -1
- package/dist/model/projectfile.js +2 -1
- package/dist/model/projectfile.js.map +1 -1
- package/dist/model/rooms.js +2 -2
- package/dist/model/rooms.js.map +1 -1
- package/dist/model/settings.d.ts +6 -0
- package/dist/model/settings.js +2 -2
- package/dist/model/settings.js.map +1 -1
- package/dist/model/sketch.d.ts +14 -0
- package/dist/model/sketch.js +143 -24
- package/dist/model/sketch.js.map +1 -1
- package/dist/model/smooth.d.ts +6 -0
- package/dist/model/smooth.js +52 -0
- package/dist/model/smooth.js.map +1 -0
- package/dist/model/store.d.ts +12 -0
- package/dist/model/store.js +35 -3
- package/dist/model/store.js.map +1 -1
- package/dist/model/types.d.ts +173 -8
- package/dist/model/wallfaces.d.ts +32 -0
- package/dist/model/wallfaces.js +133 -20
- package/dist/model/wallfaces.js.map +1 -1
- package/dist/model/wallshape.d.ts +15 -0
- package/dist/model/wallshape.js +89 -0
- package/dist/model/wallshape.js.map +1 -0
- package/dist/react/BottomBar.d.ts +9 -5
- package/dist/react/BottomBar.js +213 -24
- package/dist/react/BottomBar.js.map +1 -1
- package/dist/react/Buttons.d.ts +13 -2
- package/dist/react/Buttons.js +37 -5
- package/dist/react/Buttons.js.map +1 -1
- package/dist/react/CadEditor.d.ts +46 -3
- package/dist/react/CadEditor.js +77 -20
- package/dist/react/CadEditor.js.map +1 -1
- package/dist/react/ConfirmSheet.d.ts +4 -0
- package/dist/react/ConfirmSheet.js +31 -0
- package/dist/react/ConfirmSheet.js.map +1 -0
- package/dist/react/ConflictSheet.d.ts +2 -1
- package/dist/react/ConflictSheet.js +16 -8
- package/dist/react/ConflictSheet.js.map +1 -1
- package/dist/react/Drawer.d.ts +8 -2
- package/dist/react/Drawer.js +167 -38
- package/dist/react/Drawer.js.map +1 -1
- package/dist/react/Duck.d.ts +13 -0
- package/dist/react/Duck.js +45 -0
- package/dist/react/Duck.js.map +1 -0
- package/dist/react/Empty3D.d.ts +2 -0
- package/dist/react/Empty3D.js +39 -0
- package/dist/react/Empty3D.js.map +1 -0
- package/dist/react/FitScroll.d.ts +6 -0
- package/dist/react/FitScroll.js +14 -0
- package/dist/react/FitScroll.js.map +1 -0
- package/dist/react/Icon.native.d.ts +6 -0
- package/dist/react/Icon.native.js +4 -0
- package/dist/react/Icon.native.js.map +1 -1
- package/dist/react/Icon.web.d.ts +6 -0
- package/dist/react/Icon.web.js +4 -0
- package/dist/react/Icon.web.js.map +1 -1
- package/dist/react/KeypadSheet.d.ts +9 -2
- package/dist/react/KeypadSheet.js +174 -42
- package/dist/react/KeypadSheet.js.map +1 -1
- package/dist/react/LaserTray.js +8 -5
- package/dist/react/LaserTray.js.map +1 -1
- package/dist/react/MarkupPanel.d.ts +8 -0
- package/dist/react/MarkupPanel.js +67 -0
- package/dist/react/MarkupPanel.js.map +1 -0
- package/dist/react/PageThumb.native.d.ts +7 -2
- package/dist/react/PageThumb.native.js +19 -7
- package/dist/react/PageThumb.native.js.map +1 -1
- package/dist/react/PageThumb.web.d.ts +3 -2
- package/dist/react/PageThumb.web.js +4 -4
- package/dist/react/PageThumb.web.js.map +1 -1
- package/dist/react/PlanCanvas.native.d.ts +1 -1
- package/dist/react/PlanCanvas.native.js +134 -36
- package/dist/react/PlanCanvas.native.js.map +1 -1
- package/dist/react/PlanCanvas.web.js +16 -5
- package/dist/react/PlanCanvas.web.js.map +1 -1
- package/dist/react/Popovers.d.ts +12 -6
- package/dist/react/Popovers.js +53 -26
- package/dist/react/Popovers.js.map +1 -1
- package/dist/react/Rail.d.ts +24 -0
- package/dist/react/Rail.js +324 -34
- package/dist/react/Rail.js.map +1 -1
- package/dist/react/ShapeMenu.d.ts +7 -0
- package/dist/react/ShapeMenu.js +58 -0
- package/dist/react/ShapeMenu.js.map +1 -0
- package/dist/react/Sheet.d.ts +14 -4
- package/dist/react/Sheet.js +54 -9
- package/dist/react/Sheet.js.map +1 -1
- package/dist/react/Slider.d.ts +18 -0
- package/dist/react/Slider.js +27 -0
- package/dist/react/Slider.js.map +1 -0
- package/dist/react/Toast.js +14 -6
- package/dist/react/Toast.js.map +1 -1
- package/dist/react/ToolTip.d.ts +7 -0
- package/dist/react/ToolTip.js +43 -0
- package/dist/react/ToolTip.js.map +1 -0
- package/dist/react/TopBar.d.ts +6 -3
- package/dist/react/TopBar.js +48 -17
- package/dist/react/TopBar.js.map +1 -1
- package/dist/react/Tween.d.ts +7 -0
- package/dist/react/Tween.js +26 -0
- package/dist/react/Tween.js.map +1 -0
- package/dist/react/Tween.native.d.ts +6 -0
- package/dist/react/Tween.native.js +43 -0
- package/dist/react/Tween.native.js.map +1 -0
- package/dist/react/View3D.native.d.ts +4 -0
- package/dist/react/View3D.native.js +103 -0
- package/dist/react/View3D.native.js.map +1 -0
- package/dist/react/View3D.web.d.ts +4 -0
- package/dist/react/View3D.web.js +151 -0
- package/dist/react/View3D.web.js.map +1 -0
- package/dist/react/View3DHost.d.ts +143 -0
- package/dist/react/View3DHost.js +377 -0
- package/dist/react/View3DHost.js.map +1 -0
- package/dist/react/corners.d.ts +7 -0
- package/dist/react/corners.js +51 -0
- package/dist/react/corners.js.map +1 -0
- package/dist/react/easing.d.ts +15 -0
- package/dist/react/easing.js +10 -0
- package/dist/react/easing.js.map +1 -0
- package/dist/react/host.d.ts +7 -2
- package/dist/react/host.js +8 -3
- package/dist/react/host.js.map +1 -1
- package/dist/react/hostKeypad.d.ts +56 -0
- package/dist/react/hostKeypad.js +5 -0
- package/dist/react/hostKeypad.js.map +1 -0
- package/dist/react/motion.d.ts +77 -0
- package/dist/react/motion.js +173 -0
- package/dist/react/motion.js.map +1 -0
- package/dist/react/ports.js +90 -8
- package/dist/react/ports.js.map +1 -1
- package/dist/react/saving.d.ts +15 -0
- package/dist/react/saving.js +76 -0
- package/dist/react/saving.js.map +1 -0
- package/dist/react/store.d.ts +38 -1
- package/dist/react/store.js +31 -1
- package/dist/react/store.js.map +1 -1
- package/dist/react/theme.d.ts +10 -0
- package/dist/react/theme.js +8 -0
- package/dist/react/theme.js.map +1 -1
- package/dist/react/topRow.d.ts +22 -0
- package/dist/react/topRow.js +61 -0
- package/dist/react/topRow.js.map +1 -0
- package/dist/react/touch.d.ts +6 -0
- package/dist/react/touch.js +9 -0
- package/dist/react/touch.js.map +1 -0
- package/dist/render/ctx.d.ts +8 -0
- package/dist/render/draw.d.ts +33 -1
- package/dist/render/draw.js +593 -215
- package/dist/render/draw.js.map +1 -1
- package/dist/render/elevation.d.ts +65 -43
- package/dist/render/elevation.js +414 -140
- package/dist/render/elevation.js.map +1 -1
- package/dist/render/figmaIcons.d.ts +12 -0
- package/dist/render/figmaIcons.js +21 -0
- package/dist/render/figmaIcons.js.map +1 -0
- package/dist/render/hit.d.ts +22 -2
- package/dist/render/hit.js +168 -25
- package/dist/render/hit.js.map +1 -1
- package/dist/render/icons.js +69 -10
- package/dist/render/icons.js.map +1 -1
- package/dist/render/linkTile.d.ts +15 -0
- package/dist/render/linkTile.js +369 -0
- package/dist/render/linkTile.js.map +1 -0
- package/dist/render/markup.d.ts +11 -0
- package/dist/render/markup.js +112 -0
- package/dist/render/markup.js.map +1 -0
- package/dist/render/navigate.d.ts +88 -0
- package/dist/render/navigate.js +100 -0
- package/dist/render/navigate.js.map +1 -0
- package/dist/render/snap.d.ts +20 -1
- package/dist/render/snap.js +118 -25
- package/dist/render/snap.js.map +1 -1
- package/dist/render/squircle.d.ts +8 -0
- package/dist/render/squircle.js +71 -0
- package/dist/render/squircle.js.map +1 -0
- package/dist/render/view.d.ts +115 -2
- package/dist/render/view.js +244 -19
- package/dist/render/view.js.map +1 -1
- package/dist/skia/SkiaDrawCtx.d.ts +30 -2
- package/dist/skia/SkiaDrawCtx.js +198 -43
- package/dist/skia/SkiaDrawCtx.js.map +1 -1
- package/dist/skia/host.d.ts +18 -2
- package/dist/skia/host.js +46 -1
- package/dist/skia/host.js.map +1 -1
- package/dist/solver/equations.js +37 -2
- package/dist/solver/equations.js.map +1 -1
- package/dist/solver/gauss-newton.d.ts +17 -0
- package/dist/solver/gauss-newton.js +144 -36
- package/dist/solver/gauss-newton.js.map +1 -1
- package/dist/solver/linalg.d.ts +45 -2
- package/dist/solver/linalg.js +164 -10
- package/dist/solver/linalg.js.map +1 -1
- package/dist/solver/types.d.ts +5 -0
- package/dist/tools/annotate.d.ts +57 -1
- package/dist/tools/annotate.js +64 -43
- package/dist/tools/annotate.js.map +1 -1
- package/dist/tools/chamfer.d.ts +12 -0
- package/dist/tools/chamfer.js +114 -0
- package/dist/tools/chamfer.js.map +1 -0
- package/dist/tools/corner.d.ts +38 -0
- package/dist/tools/corner.js +99 -0
- package/dist/tools/corner.js.map +1 -0
- package/dist/tools/dim.d.ts +86 -9
- package/dist/tools/dim.js +581 -96
- package/dist/tools/dim.js.map +1 -1
- package/dist/tools/elevation.js +1 -1
- package/dist/tools/elevation.js.map +1 -1
- package/dist/tools/fillet.d.ts +9 -0
- package/dist/tools/fillet.js +86 -0
- package/dist/tools/fillet.js.map +1 -0
- package/dist/tools/freehand.d.ts +3 -2
- package/dist/tools/freehand.js +19 -12
- package/dist/tools/freehand.js.map +1 -1
- package/dist/tools/index.js +14 -4
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/line.d.ts +8 -3
- package/dist/tools/line.js +66 -30
- package/dist/tools/line.js.map +1 -1
- package/dist/tools/modify.d.ts +13 -0
- package/dist/tools/modify.js +105 -25
- package/dist/tools/modify.js.map +1 -1
- package/dist/tools/openings.js +22 -15
- package/dist/tools/openings.js.map +1 -1
- package/dist/tools/registry.d.ts +8 -0
- package/dist/tools/registry.js +42 -2
- package/dist/tools/registry.js.map +1 -1
- package/dist/tools/select.d.ts +77 -3
- package/dist/tools/select.js +560 -74
- package/dist/tools/select.js.map +1 -1
- package/dist/tools/shapes.d.ts +14 -0
- package/dist/tools/shapes.js +154 -75
- package/dist/tools/shapes.js.map +1 -1
- package/dist/units/format.d.ts +10 -2
- package/dist/units/format.js +18 -3
- package/dist/units/format.js.map +1 -1
- package/dist/view3d/build.d.ts +35 -0
- package/dist/view3d/build.js +630 -0
- package/dist/view3d/build.js.map +1 -0
- package/dist/view3d/camera.d.ts +60 -0
- package/dist/view3d/camera.js +84 -0
- package/dist/view3d/camera.js.map +1 -0
- package/dist/view3d/fatLines.d.ts +11 -0
- package/dist/view3d/fatLines.js +83 -0
- package/dist/view3d/fatLines.js.map +1 -0
- package/dist/view3d/lines.d.ts +17 -0
- package/dist/view3d/lines.js +271 -0
- package/dist/view3d/lines.js.map +1 -0
- package/dist/view3d/mesh.d.ts +51 -0
- package/dist/view3d/mesh.js +101 -0
- package/dist/view3d/mesh.js.map +1 -0
- package/dist/view3d/poly.d.ts +16 -0
- package/dist/view3d/poly.js +109 -0
- package/dist/view3d/poly.js.map +1 -0
- package/dist/view3d/viewer.d.ts +86 -0
- package/dist/view3d/viewer.js +350 -0
- package/dist/view3d/viewer.js.map +1 -0
- package/package.json +15 -2
- package/src/app/edit.ts +83 -12
- package/src/app/main.ts +11 -5
- package/src/app/state.ts +38 -5
- package/src/data/memory.ts +2 -2
- package/src/data/provider.ts +15 -7
- package/src/data/sync.ts +87 -50
- package/src/editor/actions.ts +292 -83
- package/src/editor/confirm.ts +58 -0
- package/src/editor/elevation.ts +698 -478
- package/src/editor/face.ts +227 -0
- package/src/editor/files.ts +40 -4
- package/src/editor/gestures.ts +147 -31
- package/src/editor/keypad.ts +43 -11
- package/src/editor/keys.ts +25 -5
- package/src/editor/laser.ts +98 -20
- package/src/editor/linkActions.ts +194 -0
- package/src/editor/linkFollow.ts +43 -0
- package/src/editor/linkWrite.ts +77 -0
- package/src/editor/links.ts +181 -0
- package/src/editor/markup.ts +92 -8
- package/src/editor/mode.ts +83 -7
- package/src/editor/ports.ts +37 -6
- package/src/editor/project.ts +155 -26
- package/src/editor/selection.ts +54 -8
- package/src/editor/status.ts +2 -0
- package/src/editor/tooltips.ts +47 -0
- package/src/editor/view3d.ts +119 -0
- package/src/editor/view3dState.ts +61 -0
- package/src/export/dxf.ts +1 -1
- package/src/export/pdf.ts +15 -7
- package/src/export/plan.ts +119 -35
- package/src/index.ts +5 -0
- package/src/input/keyboard.ts +2 -4
- package/src/model/constraints.ts +13 -4
- package/src/model/demo.ts +3 -3
- package/src/model/elevation.ts +6 -16
- package/src/model/faces.ts +153 -0
- package/src/model/facesolve.ts +322 -0
- package/src/model/history.ts +19 -11
- package/src/model/images.ts +35 -0
- package/src/model/links.ts +77 -0
- package/src/model/markup.ts +80 -0
- package/src/model/measurement.ts +26 -0
- package/src/model/openings.ts +6 -0
- package/src/model/planGeom.ts +174 -8
- package/src/model/project.ts +3 -2
- package/src/model/projectfile.ts +2 -1
- package/src/model/rooms.ts +1 -1
- package/src/model/settings.ts +8 -2
- package/src/model/sketch.ts +101 -14
- package/src/model/smooth.ts +51 -0
- package/src/model/store.ts +35 -4
- package/src/model/types.ts +170 -8
- package/src/model/wallfaces.ts +126 -17
- package/src/model/wallshape.ts +97 -0
- package/src/react/BottomBar.tsx +263 -46
- package/src/react/Buttons.tsx +50 -9
- package/src/react/CadEditor.tsx +133 -30
- package/src/react/ConfirmSheet.tsx +38 -0
- package/src/react/ConflictSheet.tsx +19 -12
- package/src/react/Drawer.tsx +213 -110
- package/src/react/Duck.tsx +50 -0
- package/src/react/Empty3D.tsx +32 -0
- package/src/react/FitScroll.tsx +19 -0
- package/src/react/Icon.native.tsx +5 -0
- package/src/react/Icon.web.tsx +5 -0
- package/src/react/KeypadSheet.tsx +253 -60
- package/src/react/LaserTray.tsx +12 -8
- package/src/react/MarkupPanel.tsx +150 -0
- package/src/react/PageThumb.native.tsx +18 -7
- package/src/react/PageThumb.web.tsx +4 -4
- package/src/react/PlanCanvas.native.tsx +151 -34
- package/src/react/PlanCanvas.web.tsx +15 -5
- package/src/react/Popovers.tsx +116 -51
- package/src/react/Rail.tsx +360 -27
- package/src/react/ShapeMenu.tsx +66 -0
- package/src/react/Sheet.tsx +56 -11
- package/src/react/Slider.tsx +48 -0
- package/src/react/Toast.tsx +16 -9
- package/src/react/ToolTip.tsx +49 -0
- package/src/react/TopBar.tsx +97 -39
- package/src/react/Tween.native.tsx +36 -0
- package/src/react/Tween.tsx +24 -0
- package/src/react/View3D.native.tsx +131 -0
- package/src/react/View3D.web.tsx +131 -0
- package/src/react/View3DHost.ts +367 -0
- package/src/react/corners.ts +52 -0
- package/src/react/easing.ts +14 -0
- package/src/react/host.ts +8 -3
- package/src/react/hostKeypad.ts +66 -0
- package/src/react/motion.tsx +239 -0
- package/src/react/ports.ts +78 -9
- package/src/react/saving.ts +80 -0
- package/src/react/store.ts +35 -3
- package/src/react/theme.ts +8 -0
- package/src/react/topRow.ts +71 -0
- package/src/react/touch.ts +10 -0
- package/src/render/ctx.ts +8 -0
- package/src/render/draw.ts +437 -175
- package/src/render/elevation.ts +349 -143
- package/src/render/figmaIcons.ts +22 -0
- package/src/render/hit.ts +140 -21
- package/src/render/icons.ts +69 -10
- package/src/render/linkTile.ts +297 -0
- package/src/render/markup.ts +91 -0
- package/src/render/navigate.ts +114 -0
- package/src/render/snap.ts +105 -22
- package/src/render/squircle.ts +73 -0
- package/src/render/view.ts +255 -19
- package/src/skia/SkiaDrawCtx.ts +163 -41
- package/src/skia/host.ts +46 -1
- package/src/solver/equations.ts +37 -2
- package/src/solver/gauss-newton.ts +125 -28
- package/src/solver/linalg.ts +141 -5
- package/src/solver/types.ts +5 -0
- package/src/styles.css +91 -42
- package/src/tools/annotate.ts +58 -29
- package/src/tools/chamfer.ts +103 -0
- package/src/tools/corner.ts +99 -0
- package/src/tools/dim.ts +524 -92
- package/src/tools/elevation.ts +1 -1
- package/src/tools/fillet.ts +82 -0
- package/src/tools/freehand.ts +20 -16
- package/src/tools/index.ts +17 -4
- package/src/tools/line.ts +59 -23
- package/src/tools/modify.ts +86 -24
- package/src/tools/openings.ts +8 -13
- package/src/tools/registry.ts +27 -2
- package/src/tools/select.ts +424 -75
- package/src/tools/shapes.ts +119 -58
- package/src/ui/ctx.ts +2 -1
- package/src/ui/domPorts.ts +23 -4
- package/src/ui/drawer.ts +6 -26
- package/src/ui/elevation.ts +10 -101
- package/src/ui/keypad.ts +8 -14
- package/src/ui/laser.ts +2 -2
- package/src/ui/menu.ts +63 -17
- package/src/ui/noteinput.ts +3 -3
- package/src/ui/opacity.ts +108 -0
- package/src/ui/palette.ts +67 -12
- package/src/ui/rail.ts +21 -7
- package/src/ui/topbar.ts +4 -14
- package/src/units/format.ts +18 -3
- package/src/view3d/build.ts +607 -0
- package/src/view3d/camera.ts +113 -0
- package/src/view3d/fatLines.ts +83 -0
- package/src/view3d/lines.ts +258 -0
- package/src/view3d/mesh.ts +111 -0
- package/src/view3d/poly.ts +104 -0
- package/src/view3d/viewer.ts +348 -0
- package/dist/react/ElevCanvas.native.d.ts +0 -3
- package/dist/react/ElevCanvas.native.js +0 -58
- package/dist/react/ElevCanvas.native.js.map +0 -1
- package/dist/react/ElevCanvas.web.d.ts +0 -4
- package/dist/react/ElevCanvas.web.js +0 -44
- package/dist/react/ElevCanvas.web.js.map +0 -1
- package/dist/react/ElevationSheet.d.ts +0 -2
- package/dist/react/ElevationSheet.js +0 -38
- package/dist/react/ElevationSheet.js.map +0 -1
- package/dist/render/elevationView.d.ts +0 -3
- package/dist/render/elevationView.js +0 -100
- package/dist/render/elevationView.js.map +0 -1
- package/src/react/ElevCanvas.native.tsx +0 -68
- package/src/react/ElevCanvas.web.tsx +0 -42
- package/src/react/ElevationSheet.tsx +0 -88
- package/src/render/elevationView.ts +0 -73
package/src/react/CadEditor.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useEffect, useRef, useState, type ReactNode } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { useColorScheme, useWindowDimensions, View } from 'react-native';
|
|
3
3
|
import { analyze } from '../app/edit';
|
|
4
4
|
import { ed } from '../app/state';
|
|
5
5
|
import { setPorts } from '../editor/ports';
|
|
@@ -12,33 +12,50 @@ import { setLengthFormatter } from '../units';
|
|
|
12
12
|
import { CANVAS_THEMES, setCanvasTheme } from '../render/theme';
|
|
13
13
|
import { requestDraw, setImageResolver } from '../render/view';
|
|
14
14
|
import { registerTools } from '../tools';
|
|
15
|
-
import { BottomBar,
|
|
15
|
+
import { BottomBar, SpokenHint } from './BottomBar';
|
|
16
16
|
import { ConflictSheet } from './ConflictSheet';
|
|
17
|
+
import { ConfirmSheet } from './ConfirmSheet';
|
|
18
|
+
import { confirmCancel, confirmOpen } from '../editor/confirm';
|
|
17
19
|
import { Drawer } from './Drawer';
|
|
18
|
-
import {
|
|
20
|
+
import { Duck } from './Duck';
|
|
21
|
+
import { elevOpen } from '../editor/elevation';
|
|
19
22
|
import { LaserTray } from './LaserTray';
|
|
20
|
-
import {
|
|
23
|
+
import { MarkupPanel } from './MarkupPanel';
|
|
24
|
+
import { Menu, NoteInput } from './Popovers';
|
|
21
25
|
import { KeypadSheet } from './KeypadSheet';
|
|
22
26
|
import { PlanCanvas } from './PlanCanvas';
|
|
27
|
+
import { View3D } from './View3D';
|
|
28
|
+
import { Empty3D } from './Empty3D';
|
|
29
|
+
import { is3d } from '../editor/view3dState';
|
|
23
30
|
import { reactPorts, setFileSaver } from './ports';
|
|
24
31
|
import { editorHost } from './host';
|
|
32
|
+
import { checkChanges, startManualSave, stopManualSave, type CadSaveState } from './saving';
|
|
25
33
|
import { PAGE_LOCK_ROOT, usePageLock } from './pageLock';
|
|
26
34
|
import { setSkiaFonts } from '../skia/fonts';
|
|
27
35
|
import type { SkiaFonts } from '../skia/SkiaDrawCtx';
|
|
28
36
|
import { pickImage as pickImageInBrowser } from './files';
|
|
29
|
-
import { placeUnderlay } from '../editor/project';
|
|
37
|
+
import { placeUnderlay, restoreUnits } from '../editor/project';
|
|
38
|
+
import { keypadSpec } from '../editor/keypad';
|
|
30
39
|
import { Backdrop } from './Sheet';
|
|
31
|
-
import {
|
|
40
|
+
import { useEditorKey, ui } from './store';
|
|
32
41
|
import { Toast } from './Toast';
|
|
33
42
|
import { ModeTabs, TopBar } from './TopBar';
|
|
43
|
+
import { ToolTip } from './ToolTip';
|
|
34
44
|
import { Rail } from './Rail';
|
|
45
|
+
import { setHostKeypad, type HostKeypad, type MeasurementList } from './hostKeypad';
|
|
46
|
+
import { setLinksHost, type CadLinks } from '../editor/links';
|
|
47
|
+
import { ShapeMenu } from './ShapeMenu';
|
|
35
48
|
import { PHONE_MAX } from './theme';
|
|
49
|
+
import { createSheet } from './corners';
|
|
36
50
|
|
|
37
51
|
export interface CadEditorProps {
|
|
38
52
|
/** Back to the host (otherwise the back button opens the project's pages) */
|
|
39
53
|
onBack?: () => void;
|
|
40
|
-
/**
|
|
41
|
-
|
|
54
|
+
/**
|
|
55
|
+
* The host's own buttons in the top bar (e.g. Bluetooth status). As a function it's given the size of the bar's
|
|
56
|
+
* round buttons (42 pt on a phone, 46 otherwise), to draw its own the same size.
|
|
57
|
+
*/
|
|
58
|
+
headerRight?: ReactNode | ((buttonSize: number) => ReactNode);
|
|
42
59
|
/** How to pick a photo or plan to trace (a data URL and its size); in a browser a file picker is the default. */
|
|
43
60
|
pickImage?: () => Promise<{ dataUrl: string; w: number; h: number } | null>;
|
|
44
61
|
/** Canvas colors (the chrome is dark either way). Without it, the person's Theme setting decides: Auto follows the system. */
|
|
@@ -53,33 +70,78 @@ export interface CadEditorProps {
|
|
|
53
70
|
readOnly?: boolean;
|
|
54
71
|
/** On a device: the typefaces to draw text on the plan with, by weight (default: the device's own sans-serif). */
|
|
55
72
|
fonts?: SkiaFonts;
|
|
73
|
+
/**
|
|
74
|
+
* How to pick a project file (.boldr.json) to open from the ⋯ menu — its text, null if none was picked. On a device
|
|
75
|
+
* the host passes its own (a document picker); in a browser it's a file picker.
|
|
76
|
+
*/
|
|
77
|
+
pickTextFile?: () => Promise<string | null>;
|
|
56
78
|
/** How exported files (PDF, DXF, project) reach the person, e.g. a share sheet on a device; in a browser they download. */
|
|
57
79
|
saveFile?: (name: string, mime: string, data: string) => void;
|
|
80
|
+
/**
|
|
81
|
+
* Save only when the person presses Save (BOLDR's annotation behaviour), instead of as they draw. Closing the editor
|
|
82
|
+
* then drops unsaved edits: warn with onSaveState, or save on the way out with saveCadDrawing. Needs `sync`.
|
|
83
|
+
*/
|
|
84
|
+
manualSave?: boolean;
|
|
85
|
+
/** With manualSave: 'saved', 'dirty' (unsaved edits), 'saving' or 'error' (the last save failed), as it changes. */
|
|
86
|
+
onSaveState?: (state: CadSaveState) => void;
|
|
87
|
+
/**
|
|
88
|
+
* On a phone, the host's own keypad for lengths and angles (BOLDR's measurement keypads) instead of the editor's:
|
|
89
|
+
* called with what's asked for when a keypad opens, and with null when the editor closes it (see hostKeypad.ts).
|
|
90
|
+
* Tablets and browsers keep the editor's keypad.
|
|
91
|
+
*/
|
|
92
|
+
keypad?: HostKeypad;
|
|
93
|
+
/**
|
|
94
|
+
* The job's files and measurements, to link on the drawing (Annotate's +) and to drive lines with (Draft): how to
|
|
95
|
+
* pick them, say what they are now, open them, and change or save measurements (see editor/links.ts). Without it
|
|
96
|
+
* there's nothing to link. Pass the same object for as long as the drawing is open.
|
|
97
|
+
*/
|
|
98
|
+
links?: CadLinks;
|
|
99
|
+
/**
|
|
100
|
+
* The job's measurements on the editor keypad's page of them (a line's length, a dimension's angle), drawn by the
|
|
101
|
+
* host in place of the editor's grid, so they look as they do everywhere else in it (BOLDR: its group headers and
|
|
102
|
+
* measurement tiles). Rendered from when the page is first shown, and again when what it's given changes: its kind,
|
|
103
|
+
* its size, and what to call with the measurement picked (see hostKeypad.ts). Return the list's element
|
|
104
|
+
* (`page => <JobList {...page} />`) and keep what it fetches inside it.
|
|
105
|
+
*
|
|
106
|
+
* The page is there when `links` offers the job's measurements (`measurements` or `pickMeasurement`; the editor
|
|
107
|
+
* calls neither for this page when it's the host's). A touch screen always swipes to it. A desktop shows it from
|
|
108
|
+
* Select from list only when the host has no `pickMeasurement`, which is its own drawer instead. A phone with a
|
|
109
|
+
* `keypad` of the host's own doesn't use it: that keypad has its own list.
|
|
110
|
+
*/
|
|
111
|
+
measurementList?: MeasurementList;
|
|
58
112
|
}
|
|
59
113
|
|
|
60
114
|
/**
|
|
61
115
|
* The layout editor as a React Native component: the plan canvas with its chrome. One per screen: mounting starts a
|
|
62
116
|
* new editing session (the drawing, tools and selection start fresh), unmounting saves.
|
|
63
117
|
*/
|
|
64
|
-
export function CadEditor({ onBack, headerRight, pickImage = pickImageInBrowser, theme: hostTheme, sync, units, devTools = true, readOnly = false, fonts, saveFile }: CadEditorProps) {
|
|
118
|
+
export function CadEditor({ onBack, headerRight, pickImage = pickImageInBrowser, pickTextFile, theme: hostTheme, sync, units, devTools = true, readOnly = false, fonts, saveFile, manualSave, onSaveState, keypad, links, measurementList }: CadEditorProps) {
|
|
65
119
|
const system = useColorScheme();
|
|
66
120
|
// start the session before the canvas mounts (children's effects run before this component's)
|
|
67
121
|
useState(() => {
|
|
68
122
|
setPorts(reactPorts);
|
|
69
123
|
resetSession();
|
|
70
|
-
|
|
124
|
+
const manual = !!(manualSave && sync && !readOnly);
|
|
125
|
+
// read-only saves nothing; manual saving only notes the edits until Save (see saving.ts)
|
|
126
|
+
setPersistence(sync
|
|
127
|
+
? (readOnly ? { load: sync.persistence.load, save: () => true }
|
|
128
|
+
: manual ? { load: sync.persistence.load, save: () => { checkChanges(); return true; } }
|
|
129
|
+
: sync.persistence)
|
|
130
|
+
: null);
|
|
71
131
|
if (units) {
|
|
72
132
|
settings.unit = units.metric ? 'mm' : 'ftin';
|
|
73
133
|
if (units.denom) settings.denom = units.denom;
|
|
74
134
|
}
|
|
75
|
-
setLengthFormatter(units ? units.format : null);
|
|
135
|
+
setLengthFormatter(units ? units.format : null, { unit: settings.unit, denom: settings.denom });
|
|
76
136
|
setSkiaFonts(fonts ?? null);
|
|
77
137
|
setFileSaver(saveFile ?? null);
|
|
78
138
|
setImageResolver(sync?.imageUrl ?? null);
|
|
79
139
|
registerTools();
|
|
80
140
|
ed.readOnly = readOnly;
|
|
81
141
|
load();
|
|
142
|
+
restoreUnits(); // the units the person picked last time, over the host's
|
|
82
143
|
analyze();
|
|
144
|
+
if (manual) startManualSave(sync!, onSaveState ?? null);
|
|
83
145
|
return null;
|
|
84
146
|
});
|
|
85
147
|
const closing = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);
|
|
@@ -88,40 +150,81 @@ export function CadEditor({ onBack, headerRight, pickImage = pickImageInBrowser,
|
|
|
88
150
|
setPorts(reactPorts);
|
|
89
151
|
editorHost.open = true;
|
|
90
152
|
return () => {
|
|
91
|
-
|
|
92
|
-
if (
|
|
153
|
+
// saving as they draw: the last edits and the preview go now. Saving manually: unsaved edits are dropped.
|
|
154
|
+
if (!manualSave) {
|
|
155
|
+
saveNow();
|
|
156
|
+
if (sync && !readOnly && store.project) { const t = renderThumbnail(store.project.pages[0]); if (t) sync.saveThumbnail(t); }
|
|
157
|
+
}
|
|
93
158
|
// React's StrictMode unmounts and remounts at once: only let go of the drawing if it stays unmounted
|
|
94
|
-
closing.current = setTimeout(() => { editorHost.open = false; sync?.stop(); setPersistence(null); setLengthFormatter(null); setFileSaver(null); setSkiaFonts(null); setImageResolver(null); setPorts(null); }, 0);
|
|
159
|
+
closing.current = setTimeout(() => { editorHost.open = false; sync?.stop(); setPersistence(null); setLengthFormatter(null); setFileSaver(null); setSkiaFonts(null); setImageResolver(null); stopManualSave(); setPorts(null); }, 0);
|
|
95
160
|
};
|
|
96
161
|
}, []);
|
|
97
|
-
|
|
162
|
+
// (only what this level decides: which sheets are open, the wall view, the theme — each part of the interface
|
|
163
|
+
// follows the editor itself, see useEditorKey)
|
|
164
|
+
useEditorKey(() => [ui.keypad, keypadSpec()?.modeless ?? '', !!ui.conflict, confirmOpen(), elevOpen(), is3d(), settings.theme].join('|'));
|
|
98
165
|
usePageLock();
|
|
99
166
|
const theme = hostTheme ?? (settings.theme === 'system' ? (system === 'dark' ? 'dark' : 'light') : settings.theme);
|
|
100
167
|
// the canvases read their colors when they draw: set them before this render's children draw
|
|
101
168
|
setCanvasTheme(theme);
|
|
102
169
|
useEffect(() => { requestDraw(); }, [theme]);
|
|
103
170
|
const { width } = useWindowDimensions(), phone = width < PHONE_MAX, wide = width >= 900;
|
|
104
|
-
|
|
171
|
+
// (asked about once the drawing's loaded: what it links to)
|
|
172
|
+
useEffect(() => {
|
|
173
|
+
setLinksHost(links ?? null);
|
|
174
|
+
return () => setLinksHost(null);
|
|
175
|
+
}, [links]);
|
|
176
|
+
// (a phone asks with the host's keypad, when it has one)
|
|
177
|
+
useEffect(() => {
|
|
178
|
+
setHostKeypad(phone && keypad ? keypad : null);
|
|
179
|
+
return () => setHostKeypad(null);
|
|
180
|
+
}, [phone, keypad]);
|
|
181
|
+
// (a modeless keypad leaves the drawing live: no backdrop. On a tablet or a computer the drawing stays in reach
|
|
182
|
+
// around a sheet too — it pans and zooms, and a tap on it (or the chrome over it) closes the sheet: see
|
|
183
|
+
// editor/gestures.ts sheetUp. A phone's sheet covers most of it: there a backdrop closes it.)
|
|
184
|
+
const sheet = (ui.keypad && !keypadSpec()?.modeless) || !!ui.conflict || confirmOpen(), threeD = is3d();
|
|
185
|
+
// the 3D view: made as its tab first opens and kept, hidden, while it's left — coming back, it's there at once (made
|
|
186
|
+
// again each time, its GL context, renderer and shaders were a pause every time). Let go after a while away: on a
|
|
187
|
+
// device it holds its GL buffers (a phone's screen, four times over for antialiasing).
|
|
188
|
+
const [kept3d, setKept3d] = useState(false);
|
|
189
|
+
useEffect(() => {
|
|
190
|
+
if (threeD) { setKept3d(true); return; }
|
|
191
|
+
if (!kept3d) return;
|
|
192
|
+
const t = setTimeout(() => setKept3d(false), KEEP_3D_MS);
|
|
193
|
+
return () => clearTimeout(t);
|
|
194
|
+
}, [threeD, kept3d]);
|
|
105
195
|
return (
|
|
106
196
|
<View nativeID={PAGE_LOCK_ROOT} style={[s.root, { backgroundColor: CANVAS_THEMES[theme].bg }]}>
|
|
107
197
|
<PlanCanvas />
|
|
108
|
-
|
|
109
|
-
{
|
|
110
|
-
<
|
|
111
|
-
{
|
|
112
|
-
|
|
113
|
-
|
|
198
|
+
{/* the 3D tab: over the plan, which stays as it was underneath */}
|
|
199
|
+
{(threeD || kept3d) && <View3D theme={theme} active={threeD} />}
|
|
200
|
+
{threeD && <Empty3D />}
|
|
201
|
+
{/* the floating chrome: on a phone it steps aside while a stroke, drag, pan or pinch is moving (Duck) */}
|
|
202
|
+
<Duck active={phone} held={sheet && !phone}>
|
|
203
|
+
<TopBar onBack={onBack} headerRight={headerRight} phone={phone} readOnly={readOnly} />
|
|
204
|
+
{!readOnly && !elevOpen() && <ModeTabs phone={phone} />}
|
|
205
|
+
{!readOnly && <ToolTip phone={phone} />}
|
|
206
|
+
<SpokenHint />
|
|
207
|
+
{/* (none in 3D: it's a view, its camera moved with the fingers) */}
|
|
208
|
+
{!readOnly && !threeD && <Rail phone={phone} onAddImage={() => { pickImage().then(img => { if (img) placeUnderlay(img.dataUrl, img.w, img.h); }); }} />}
|
|
209
|
+
{!readOnly && <BottomBar phone={phone} />}
|
|
210
|
+
{!threeD && <LaserTray phone={phone} />}
|
|
211
|
+
{!threeD && <MarkupPanel phone={phone} />}
|
|
212
|
+
</Duck>
|
|
213
|
+
{!readOnly && !elevOpen() && !threeD && <ShapeMenu />}
|
|
114
214
|
<NoteInput />
|
|
115
|
-
<
|
|
116
|
-
<
|
|
117
|
-
<Drawer />
|
|
118
|
-
<ElevationSheet />
|
|
215
|
+
<Menu themeChoice={!hostTheme} accountUnits={!!units} devTools={devTools} pickText={pickTextFile} readOnly={readOnly} phone={phone} />
|
|
216
|
+
<Drawer phone={phone} />
|
|
119
217
|
<Toast phone={phone} />
|
|
120
|
-
{sheet && <Backdrop wide={wide} onClose={() => (ui.keypad ? reactPorts.closeKeypad() : reactPorts.dismissConflict())} />}
|
|
121
|
-
{
|
|
122
|
-
{
|
|
218
|
+
{sheet && phone && <Backdrop wide={wide} onClose={() => (ui.keypad ? reactPorts.closeKeypad() : confirmOpen() ? confirmCancel() : reactPorts.dismissConflict())} />}
|
|
219
|
+
{/* (always there: each shows itself, and stays as it slides away) */}
|
|
220
|
+
<KeypadSheet wide={wide} open={ui.keypad} measurementList={measurementList} />
|
|
221
|
+
<ConflictSheet wide={wide} open={!!ui.conflict && !ui.keypad} />
|
|
222
|
+
<ConfirmSheet wide={wide} />
|
|
123
223
|
</View>
|
|
124
224
|
);
|
|
125
225
|
}
|
|
126
226
|
|
|
127
|
-
|
|
227
|
+
/** How long the 3D view is kept after its tab is left (ms). */
|
|
228
|
+
const KEEP_3D_MS = 60_000;
|
|
229
|
+
|
|
230
|
+
const s = createSheet({ root: { flex: 1, overflow: 'hidden' } });
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
import { Text, View } from 'react-native';
|
|
3
|
+
import { confirmChoose, confirmSeq, confirmSpec } from '../editor/confirm';
|
|
4
|
+
import { Pill } from './Buttons';
|
|
5
|
+
import { Sheet, useSheetMotion } from './Sheet';
|
|
6
|
+
import { ui, useEditorKey } from './store';
|
|
7
|
+
import { C, FONT } from './theme';
|
|
8
|
+
import { createSheet } from './corners';
|
|
9
|
+
|
|
10
|
+
/** A question before the editor does something past the drawing (editor/confirm.ts): its choices, as pills. */
|
|
11
|
+
export function ConfirmSheet({ wide }: { wide: boolean }) {
|
|
12
|
+
useEditorKey(() => (confirmSpec() ? String(confirmSeq()) : ''));
|
|
13
|
+
// in and out as the other sheets come and go, still saying what it said as it goes
|
|
14
|
+
const now = confirmSpec(), last = useRef(now), { present, motion } = useSheetMotion(!!now, wide);
|
|
15
|
+
if (now) last.current = now;
|
|
16
|
+
// (taps on the backdrop just after it opens are the opening tap's ghost)
|
|
17
|
+
const seq = now ? confirmSeq() : 0;
|
|
18
|
+
useEffect(() => { if (seq) ui.sheetOpenedAt = Date.now(); }, [seq]);
|
|
19
|
+
const c = last.current;
|
|
20
|
+
if (!present || !c) return null;
|
|
21
|
+
return (
|
|
22
|
+
<Sheet wide={wide} label={c.title} testID={now ? 'confirm' : undefined} motion={motion} live={!!now}>
|
|
23
|
+
<Text style={s.title}>{c.title}</Text>
|
|
24
|
+
{c.msg ? <Text style={s.msg}>{c.msg}</Text> : null}
|
|
25
|
+
<View style={s.actions}>
|
|
26
|
+
{c.choices.map((ch, i) => (
|
|
27
|
+
<Pill key={i + ch.label} label={ch.label} kind={ch.kind ?? (i === 0 ? 'yellow' : 'grey')} testID={'confirm-' + i} onPress={() => confirmChoose(i)} />
|
|
28
|
+
))}
|
|
29
|
+
</View>
|
|
30
|
+
</Sheet>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const s = createSheet({
|
|
35
|
+
title: { fontFamily: FONT, fontSize: 18, fontWeight: '600', color: '#fff', marginBottom: 6 },
|
|
36
|
+
msg: { fontFamily: FONT, fontSize: 14, lineHeight: 20, color: C.lg1, marginBottom: 12 },
|
|
37
|
+
actions: { flexDirection: 'row', gap: 10, marginTop: 6, flexWrap: 'wrap' },
|
|
38
|
+
});
|
|
@@ -1,27 +1,34 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useRef } from 'react';
|
|
2
|
+
import { Text, View } from 'react-native';
|
|
2
3
|
import { conflictHover, conflictRemove } from '../editor/conflict';
|
|
3
4
|
import { Pill } from './Buttons';
|
|
4
5
|
import { reactPorts } from './ports';
|
|
5
|
-
import { Sheet } from './Sheet';
|
|
6
|
-
import { ui } from './store';
|
|
6
|
+
import { Sheet, useSheetMotion } from './Sheet';
|
|
7
|
+
import { editorVersion, ui, useEditorKey } from './store';
|
|
7
8
|
import { C, FONT } from './theme';
|
|
9
|
+
import { Tap } from './motion';
|
|
10
|
+
import { createSheet } from './corners';
|
|
8
11
|
|
|
9
12
|
/** What fights a new constraint: the culprits, each with Remove; hovering a row highlights it on the drawing. */
|
|
10
|
-
export function ConflictSheet({ wide }: { wide: boolean }) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
export function ConflictSheet({ wide, open }: { wide: boolean; open: boolean }) {
|
|
14
|
+
useEditorKey(() => (open ? String(editorVersion()) : ''));
|
|
15
|
+
// in from the side (a phone: up from the bottom) as the keypad comes, and out again still saying what it said
|
|
16
|
+
const now = open ? ui.conflict : null, last = useRef(now), { present, motion } = useSheetMotion(!!now, wide);
|
|
17
|
+
if (now) last.current = now;
|
|
18
|
+
const cf = last.current;
|
|
19
|
+
if (!present || !cf) return null;
|
|
13
20
|
return (
|
|
14
|
-
<Sheet wide={wide} label="Constraint conflict" testID=
|
|
21
|
+
<Sheet wide={wide} label="Constraint conflict" testID={now ? 'cf' : undefined} motion={motion} live={!!now}>
|
|
15
22
|
<Text style={s.title}>{cf.spec.title}</Text>
|
|
16
23
|
<Text style={s.msg}>{cf.spec.msg}</Text>
|
|
17
24
|
{cf.rows.length === 0 && <Text style={s.msg}>Try a different value, or undo the last step.</Text>}
|
|
18
25
|
{cf.rows.map(r => (
|
|
19
|
-
<
|
|
26
|
+
<Tap feel="dim" key={r.id} onHoverIn={() => conflictHover(r.id)} onHoverOut={() => conflictHover(null)} style={s.item}>
|
|
20
27
|
<Text style={s.itemText}>{r.label}</Text>
|
|
21
|
-
<
|
|
28
|
+
<Tap accessibilityRole="button" accessibilityLabel={'Remove ' + r.label} onPress={() => conflictRemove(r.id)}>
|
|
22
29
|
<Text style={s.remove}>Remove</Text>
|
|
23
|
-
</
|
|
24
|
-
</
|
|
30
|
+
</Tap>
|
|
31
|
+
</Tap>
|
|
25
32
|
))}
|
|
26
33
|
<View style={s.actions}>
|
|
27
34
|
<Pill label="Keep the drawing as is" onPress={() => reactPorts.dismissConflict()} />
|
|
@@ -30,7 +37,7 @@ export function ConflictSheet({ wide }: { wide: boolean }) {
|
|
|
30
37
|
);
|
|
31
38
|
}
|
|
32
39
|
|
|
33
|
-
const s =
|
|
40
|
+
const s = createSheet({
|
|
34
41
|
title: { fontFamily: FONT, fontSize: 18, fontWeight: '600', color: '#fff', marginBottom: 6 },
|
|
35
42
|
msg: { fontFamily: FONT, fontSize: 14, lineHeight: 20, color: C.lg1, marginBottom: 12 },
|
|
36
43
|
item: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', gap: 10, backgroundColor: C.g2, borderRadius: 10, paddingVertical: 10, paddingHorizontal: 12, marginBottom: 8 },
|