canvu-react 0.4.38 → 0.4.40

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/native.d.cts CHANGED
@@ -296,6 +296,7 @@ type NativeVectorViewportProps = {
296
296
  readonly onCameraChange?: () => void;
297
297
  readonly customPlacement?: NativeCustomShapePlacementOptions;
298
298
  readonly customPlacements?: readonly NativeCustomShapePlacementOptions[];
299
+ readonly overlay?: React.ReactNode;
299
300
  readonly toolbar?: React.ReactNode;
300
301
  readonly showStyleInspector?: boolean;
301
302
  readonly styleInspectorPlacement?: "bottom" | "top-left";
package/dist/native.d.ts CHANGED
@@ -296,6 +296,7 @@ type NativeVectorViewportProps = {
296
296
  readonly onCameraChange?: () => void;
297
297
  readonly customPlacement?: NativeCustomShapePlacementOptions;
298
298
  readonly customPlacements?: readonly NativeCustomShapePlacementOptions[];
299
+ readonly overlay?: React.ReactNode;
299
300
  readonly toolbar?: React.ReactNode;
300
301
  readonly showStyleInspector?: boolean;
301
302
  readonly styleInspectorPlacement?: "bottom" | "top-left";
package/dist/native.js CHANGED
@@ -2180,6 +2180,11 @@ function rgba(hex, alpha) {
2180
2180
  if (Number.isNaN(r) || Number.isNaN(g) || Number.isNaN(b)) return hex;
2181
2181
  return `rgba(${r},${g},${b},${alpha})`;
2182
2182
  }
2183
+ function dashIntervalsFromStrokeDasharray2(strokeDasharray) {
2184
+ if (!strokeDasharray) return null;
2185
+ const intervals = strokeDasharray.split(/[\s,]+/).map((part) => Number(part)).filter((part) => Number.isFinite(part) && part > 0);
2186
+ return intervals.length > 0 ? intervals : null;
2187
+ }
2183
2188
  function localBounds(bounds) {
2184
2189
  const b = normalizeRect(bounds);
2185
2190
  return { w: Math.max(0, b.width), h: Math.max(0, b.height) };
@@ -2469,6 +2474,7 @@ function NativeShapeRenderer({ item }) {
2469
2474
  }
2470
2475
  );
2471
2476
  }
2477
+ const intervals = dashIntervalsFromStrokeDasharray2(payload.strokeDasharray);
2472
2478
  return /* @__PURE__ */ jsx(
2473
2479
  Path,
2474
2480
  {
@@ -2478,7 +2484,8 @@ function NativeShapeRenderer({ item }) {
2478
2484
  strokeWidth: payload.strokeWidth,
2479
2485
  strokeCap: "round",
2480
2486
  strokeJoin: "round",
2481
- antiAlias: true
2487
+ antiAlias: true,
2488
+ children: intervals ? /* @__PURE__ */ jsx(DashPathEffect, { intervals }) : null
2482
2489
  }
2483
2490
  );
2484
2491
  }
@@ -2652,7 +2659,7 @@ function pointsToSmoothPathD(points) {
2652
2659
  const d = smoothFreehandPointsToPathD(points);
2653
2660
  return d || null;
2654
2661
  }
2655
- function dashIntervalsFromStrokeDasharray2(strokeDasharray) {
2662
+ function dashIntervalsFromStrokeDasharray3(strokeDasharray) {
2656
2663
  if (!strokeDasharray) return null;
2657
2664
  const intervals = strokeDasharray.split(/\s+/).map((part) => Number(part)).filter((part) => Number.isFinite(part) && part > 0);
2658
2665
  return intervals.length > 0 ? intervals : null;
@@ -2942,7 +2949,7 @@ function NativeInteractionOverlay({
2942
2949
  );
2943
2950
  }
2944
2951
  if (payload.kind === "strokePath") {
2945
- const intervals = dashIntervalsFromStrokeDasharray2(payload.strokeDasharray);
2952
+ const intervals = dashIntervalsFromStrokeDasharray3(payload.strokeDasharray);
2946
2953
  return /* @__PURE__ */ jsx(
2947
2954
  Path,
2948
2955
  {
@@ -4680,6 +4687,8 @@ var MARKER_TOOL_STYLE = {
4680
4687
  strokeWidth: 16,
4681
4688
  strokeOpacity: 0.5
4682
4689
  };
4690
+ var NATIVE_VIEWPORT_OVERLAY_Z_INDEX = 40;
4691
+ var NATIVE_VIEWPORT_OVERLAY_ELEVATION = 40;
4683
4692
  function isPlacementTool(toolId) {
4684
4693
  return toolId === "rect" || toolId === "ellipse" || toolId === "architectural-cloud" || toolId === "line" || toolId === "arrow";
4685
4694
  }
@@ -4763,6 +4772,7 @@ var NativeVectorViewport = forwardRef(function NativeVectorViewport2({
4763
4772
  onCameraChange,
4764
4773
  customPlacement,
4765
4774
  customPlacements = [],
4775
+ overlay,
4766
4776
  toolbar,
4767
4777
  showStyleInspector = false,
4768
4778
  styleInspectorPlacement = "bottom"
@@ -5694,153 +5704,161 @@ var NativeVectorViewport = forwardRef(function NativeVectorViewport2({
5694
5704
  };
5695
5705
  const normalizedNativeLinkHref = normalizeNativeLinkHref(nativeLinkInputValue);
5696
5706
  const nativeLinkCanSubmit = pendingNativeLinkRequest !== null && normalizedNativeLinkHref !== null && onItemsChange != null;
5697
- return /* @__PURE__ */ jsxs(
5698
- View,
5699
- {
5700
- style: { flex: 1, overflow: "hidden" },
5701
- onLayout,
5702
- onPointerDown: handlePointerDown,
5703
- onPointerMove: handlePointerMove,
5704
- onPointerUp: handlePointerUp,
5705
- onPointerEnter: handlePointerMove,
5706
- onPointerLeave: () => {
5707
- hideToolCursor();
5708
- notifyWorldPointerLeave();
5709
- },
5710
- ...panResponder.panHandlers,
5711
- children: [
5712
- size.width > 0 && size.height > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
5713
- /* @__PURE__ */ jsx(
5714
- NativeSceneRenderer,
5707
+ return /* @__PURE__ */ jsxs(View, { style: { flex: 1, overflow: "hidden" }, onLayout, children: [
5708
+ size.width > 0 && size.height > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
5709
+ /* @__PURE__ */ jsxs(
5710
+ View,
5711
+ {
5712
+ style: StyleSheet.absoluteFill,
5713
+ onPointerDown: handlePointerDown,
5714
+ onPointerMove: handlePointerMove,
5715
+ onPointerUp: handlePointerUp,
5716
+ onPointerEnter: handlePointerMove,
5717
+ onPointerLeave: () => {
5718
+ hideToolCursor();
5719
+ notifyWorldPointerLeave();
5720
+ },
5721
+ ...panResponder.panHandlers,
5722
+ children: [
5723
+ /* @__PURE__ */ jsx(
5724
+ NativeSceneRenderer,
5725
+ {
5726
+ items: sceneItems,
5727
+ camera,
5728
+ width: size.width,
5729
+ height: size.height
5730
+ }
5731
+ ),
5732
+ interactive && /* @__PURE__ */ jsx(
5733
+ NativeInteractionOverlay,
5734
+ {
5735
+ camera,
5736
+ width: size.width,
5737
+ height: size.height,
5738
+ selectedItems,
5739
+ showResizeHandles,
5740
+ placementPreview,
5741
+ laserTrail,
5742
+ eraserTrail,
5743
+ eraserPreviewItems: items.filter(
5744
+ (it) => eraserPreviewIds.includes(it.id)
5745
+ ),
5746
+ previewStrokeStyle: strokeStyleState,
5747
+ remotePresence
5748
+ }
5749
+ )
5750
+ ]
5751
+ }
5752
+ ),
5753
+ overlay ? /* @__PURE__ */ jsx(View, { pointerEvents: "box-none", style: StyleSheet.absoluteFill, children: overlay }) : null,
5754
+ interactive && showStyleInspector && activeStyleToolId ? /* @__PURE__ */ jsx(
5755
+ View,
5756
+ {
5757
+ pointerEvents: "box-none",
5758
+ style: styleInspectorPlacement === "top-left" ? {
5759
+ position: "absolute",
5760
+ left: 16,
5761
+ top: 104,
5762
+ alignItems: "flex-start",
5763
+ zIndex: NATIVE_VIEWPORT_OVERLAY_Z_INDEX,
5764
+ elevation: NATIVE_VIEWPORT_OVERLAY_ELEVATION
5765
+ } : {
5766
+ position: "absolute",
5767
+ left: 16,
5768
+ right: 16,
5769
+ bottom: 84,
5770
+ alignItems: "center",
5771
+ zIndex: NATIVE_VIEWPORT_OVERLAY_Z_INDEX,
5772
+ elevation: NATIVE_VIEWPORT_OVERLAY_ELEVATION
5773
+ },
5774
+ children: /* @__PURE__ */ jsx(
5775
+ NativeVectorStyleInspector,
5715
5776
  {
5716
- items: sceneItems,
5717
- camera,
5718
- width: size.width,
5719
- height: size.height
5777
+ toolId: activeStyleToolId,
5778
+ value: strokeStyleState,
5779
+ onChange: patchCurrentStrokeStyle
5720
5780
  }
5721
- ),
5722
- interactive && /* @__PURE__ */ jsx(
5723
- NativeInteractionOverlay,
5781
+ )
5782
+ }
5783
+ ) : null,
5784
+ toolbar && /* @__PURE__ */ jsx(
5785
+ View,
5786
+ {
5787
+ style: {
5788
+ position: "absolute",
5789
+ bottom: 16,
5790
+ left: 16,
5791
+ right: 16,
5792
+ flexDirection: "row",
5793
+ justifyContent: "center",
5794
+ alignItems: "center",
5795
+ zIndex: NATIVE_VIEWPORT_OVERLAY_Z_INDEX,
5796
+ elevation: NATIVE_VIEWPORT_OVERLAY_ELEVATION
5797
+ },
5798
+ pointerEvents: "box-none",
5799
+ children: toolbar
5800
+ }
5801
+ )
5802
+ ] }),
5803
+ /* @__PURE__ */ jsx(
5804
+ Modal,
5805
+ {
5806
+ animationType: "fade",
5807
+ transparent: true,
5808
+ visible: pendingNativeLinkRequest !== null,
5809
+ onRequestClose: closeNativeLinkDialog,
5810
+ children: /* @__PURE__ */ jsx(View, { style: styles3.nativeLinkDialogBackdrop, children: /* @__PURE__ */ jsxs(View, { style: styles3.nativeLinkDialogCard, children: [
5811
+ /* @__PURE__ */ jsx(Text, { style: styles3.nativeLinkDialogTitle, children: nativeLinkDialogLabels.title }),
5812
+ /* @__PURE__ */ jsx(Text, { style: styles3.nativeLinkDialogDescription, children: nativeLinkDialogLabels.description }),
5813
+ /* @__PURE__ */ jsx(
5814
+ TextInput,
5724
5815
  {
5725
- camera,
5726
- width: size.width,
5727
- height: size.height,
5728
- selectedItems,
5729
- showResizeHandles,
5730
- placementPreview,
5731
- laserTrail,
5732
- eraserTrail,
5733
- eraserPreviewItems: items.filter(
5734
- (it) => eraserPreviewIds.includes(it.id)
5735
- ),
5736
- previewStrokeStyle: strokeStyleState,
5737
- remotePresence
5816
+ accessibilityLabel: nativeLinkDialogLabels.title,
5817
+ autoCapitalize: "none",
5818
+ autoCorrect: false,
5819
+ keyboardType: "url",
5820
+ onChangeText: setNativeLinkInputValue,
5821
+ onSubmitEditing: submitNativeLinkDialog,
5822
+ placeholder: nativeLinkDialogLabels.inputPlaceholder,
5823
+ returnKeyType: "done",
5824
+ style: styles3.nativeLinkDialogInput,
5825
+ value: nativeLinkInputValue
5738
5826
  }
5739
5827
  ),
5740
- interactive && showStyleInspector && activeStyleToolId ? /* @__PURE__ */ jsx(
5741
- View,
5742
- {
5743
- pointerEvents: "box-none",
5744
- style: styleInspectorPlacement === "top-left" ? {
5745
- position: "absolute",
5746
- left: 16,
5747
- top: 104,
5748
- alignItems: "flex-start"
5749
- } : {
5750
- position: "absolute",
5751
- left: 16,
5752
- right: 16,
5753
- bottom: 84,
5754
- alignItems: "center"
5755
- },
5756
- children: /* @__PURE__ */ jsx(
5757
- NativeVectorStyleInspector,
5758
- {
5759
- toolId: activeStyleToolId,
5760
- value: strokeStyleState,
5761
- onChange: patchCurrentStrokeStyle
5762
- }
5763
- )
5764
- }
5765
- ) : null,
5766
- toolbar && /* @__PURE__ */ jsx(
5767
- View,
5768
- {
5769
- style: {
5770
- position: "absolute",
5771
- bottom: 16,
5772
- left: 16,
5773
- right: 16,
5774
- flexDirection: "row",
5775
- justifyContent: "center",
5776
- alignItems: "center"
5777
- },
5778
- pointerEvents: "box-none",
5779
- children: toolbar
5780
- }
5781
- )
5782
- ] }),
5783
- /* @__PURE__ */ jsx(
5784
- Modal,
5785
- {
5786
- animationType: "fade",
5787
- transparent: true,
5788
- visible: pendingNativeLinkRequest !== null,
5789
- onRequestClose: closeNativeLinkDialog,
5790
- children: /* @__PURE__ */ jsx(View, { style: styles3.nativeLinkDialogBackdrop, children: /* @__PURE__ */ jsxs(View, { style: styles3.nativeLinkDialogCard, children: [
5791
- /* @__PURE__ */ jsx(Text, { style: styles3.nativeLinkDialogTitle, children: nativeLinkDialogLabels.title }),
5792
- /* @__PURE__ */ jsx(Text, { style: styles3.nativeLinkDialogDescription, children: nativeLinkDialogLabels.description }),
5793
- /* @__PURE__ */ jsx(
5794
- TextInput,
5795
- {
5796
- accessibilityLabel: nativeLinkDialogLabels.title,
5797
- autoCapitalize: "none",
5798
- autoCorrect: false,
5799
- keyboardType: "url",
5800
- onChangeText: setNativeLinkInputValue,
5801
- onSubmitEditing: submitNativeLinkDialog,
5802
- placeholder: nativeLinkDialogLabels.inputPlaceholder,
5803
- returnKeyType: "done",
5804
- style: styles3.nativeLinkDialogInput,
5805
- value: nativeLinkInputValue
5806
- }
5807
- ),
5808
- /* @__PURE__ */ jsxs(View, { style: styles3.nativeLinkDialogActions, children: [
5809
- /* @__PURE__ */ jsx(
5810
- Pressable,
5811
- {
5812
- accessibilityRole: "button",
5813
- onPress: closeNativeLinkDialog,
5814
- style: ({ pressed }) => [
5815
- styles3.nativeLinkDialogButton,
5816
- pressed ? styles3.nativeLinkDialogButtonPressed : void 0
5817
- ],
5818
- children: /* @__PURE__ */ jsx(Text, { style: styles3.nativeLinkDialogButtonText, children: nativeLinkDialogLabels.cancelLabel })
5819
- }
5820
- ),
5821
- /* @__PURE__ */ jsx(
5822
- Pressable,
5823
- {
5824
- accessibilityRole: "button",
5825
- accessibilityState: { disabled: !nativeLinkCanSubmit },
5826
- disabled: !nativeLinkCanSubmit,
5827
- onPress: submitNativeLinkDialog,
5828
- style: ({ pressed }) => [
5829
- styles3.nativeLinkDialogButton,
5830
- styles3.nativeLinkDialogPrimaryButton,
5831
- pressed && nativeLinkCanSubmit ? styles3.nativeLinkDialogPrimaryButtonPressed : void 0,
5832
- !nativeLinkCanSubmit ? styles3.nativeLinkDialogDisabledButton : void 0
5833
- ],
5834
- children: /* @__PURE__ */ jsx(Text, { style: styles3.nativeLinkDialogPrimaryButtonText, children: nativeLinkDialogLabels.addLabel })
5835
- }
5836
- )
5837
- ] })
5838
- ] }) })
5839
- }
5840
- )
5841
- ]
5842
- }
5843
- );
5828
+ /* @__PURE__ */ jsxs(View, { style: styles3.nativeLinkDialogActions, children: [
5829
+ /* @__PURE__ */ jsx(
5830
+ Pressable,
5831
+ {
5832
+ accessibilityRole: "button",
5833
+ onPress: closeNativeLinkDialog,
5834
+ style: ({ pressed }) => [
5835
+ styles3.nativeLinkDialogButton,
5836
+ pressed ? styles3.nativeLinkDialogButtonPressed : void 0
5837
+ ],
5838
+ children: /* @__PURE__ */ jsx(Text, { style: styles3.nativeLinkDialogButtonText, children: nativeLinkDialogLabels.cancelLabel })
5839
+ }
5840
+ ),
5841
+ /* @__PURE__ */ jsx(
5842
+ Pressable,
5843
+ {
5844
+ accessibilityRole: "button",
5845
+ accessibilityState: { disabled: !nativeLinkCanSubmit },
5846
+ disabled: !nativeLinkCanSubmit,
5847
+ onPress: submitNativeLinkDialog,
5848
+ style: ({ pressed }) => [
5849
+ styles3.nativeLinkDialogButton,
5850
+ styles3.nativeLinkDialogPrimaryButton,
5851
+ pressed && nativeLinkCanSubmit ? styles3.nativeLinkDialogPrimaryButtonPressed : void 0,
5852
+ !nativeLinkCanSubmit ? styles3.nativeLinkDialogDisabledButton : void 0
5853
+ ],
5854
+ children: /* @__PURE__ */ jsx(Text, { style: styles3.nativeLinkDialogPrimaryButtonText, children: nativeLinkDialogLabels.addLabel })
5855
+ }
5856
+ )
5857
+ ] })
5858
+ ] }) })
5859
+ }
5860
+ )
5861
+ ] });
5844
5862
  });
5845
5863
  var styles3 = StyleSheet.create({
5846
5864
  nativeLinkDialogBackdrop: {