canvu-react 0.4.4 → 0.4.6

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
@@ -1,10 +1,13 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { C as Camera2D } from './camera-CVVG7z56.cjs';
1
+ import { C as Camera2D } from './shape-builders-CKEMjivV.cjs';
2
+ export { o as createFreehandStrokeItem, t as createShapeId } from './shape-builders-CKEMjivV.cjs';
3
3
  import { V as VectorSceneItem, R as Rect } from './types-BCCvY6ie.cjs';
4
+ import * as react_jsx_runtime from 'react/jsx-runtime';
4
5
  import * as react from 'react';
6
+ import { ReactNode } from 'react';
7
+ import { StyleProp, ViewStyle, TextStyle } from 'react-native';
5
8
 
6
9
  type PlacementPreview = {
7
- readonly kind: "rect" | "ellipse";
10
+ readonly kind: "rect" | "ellipse" | "architectural-cloud";
8
11
  readonly rect: {
9
12
  readonly x: number;
10
13
  readonly y: number;
@@ -69,6 +72,81 @@ type NativeShapeRendererProps = {
69
72
  };
70
73
  declare function NativeShapeRenderer({ item }: NativeShapeRendererProps): react_jsx_runtime.JSX.Element | null;
71
74
 
75
+ /**
76
+ * Describes a single tool button rendered by {@link NativeVectorToolbar}.
77
+ *
78
+ * Use the built-in ids from {@link DEFAULT_NATIVE_VECTOR_TOOLS} when pairing
79
+ * the toolbar with {@link NativeVectorViewport}. Custom ids are useful only
80
+ * when the app also implements matching viewport behavior.
81
+ */
82
+ type NativeVectorToolDefinition = {
83
+ readonly id: string;
84
+ readonly label: string;
85
+ readonly shortLabel?: string;
86
+ readonly accessibilityLabel?: string;
87
+ readonly disabled?: boolean;
88
+ };
89
+ /**
90
+ * Render input for custom tool icons or complete custom tool buttons.
91
+ *
92
+ * Prefer `renderToolIcon` for app-specific icon packs. Use
93
+ * `renderToolButton` only when you need to replace the full touch target while
94
+ * keeping the toolbar's horizontal scrolling and tool list behavior.
95
+ */
96
+ type NativeVectorToolbarRenderToolInput = {
97
+ readonly tool: NativeVectorToolDefinition;
98
+ readonly selected: boolean;
99
+ readonly disabled: boolean;
100
+ readonly foregroundColor: string;
101
+ readonly onSelect: () => void;
102
+ };
103
+ /**
104
+ * Props for {@link NativeVectorToolbar}.
105
+ *
106
+ * The component is controlled: pass the same `value` to `NativeVectorViewport`
107
+ * as `toolId`, and update it from `onChange`. It is intentionally lightweight
108
+ * and native-only, with no dependency on the web toolbar implementation.
109
+ */
110
+ type NativeVectorToolbarProps = {
111
+ readonly value: string;
112
+ readonly onChange: (toolId: string) => void;
113
+ readonly tools?: readonly NativeVectorToolDefinition[];
114
+ readonly disabled?: boolean;
115
+ readonly disabledToolIds?: readonly string[];
116
+ readonly accessibilityLabel?: string;
117
+ readonly style?: StyleProp<ViewStyle>;
118
+ readonly contentContainerStyle?: StyleProp<ViewStyle>;
119
+ readonly toolButtonStyle?: StyleProp<ViewStyle>;
120
+ readonly activeToolButtonStyle?: StyleProp<ViewStyle>;
121
+ readonly toolLabelStyle?: StyleProp<TextStyle>;
122
+ readonly activeToolLabelStyle?: StyleProp<TextStyle>;
123
+ readonly renderToolIcon?: (input: NativeVectorToolbarRenderToolInput) => ReactNode;
124
+ readonly renderToolButton?: (input: NativeVectorToolbarRenderToolInput) => ReactNode;
125
+ };
126
+ /**
127
+ * Default mobile-friendly tool list for {@link NativeVectorToolbar}.
128
+ *
129
+ * The ids match the native viewport's built-in tool handling. Apps can pass a
130
+ * filtered or reordered list when permissions or product scope require it.
131
+ */
132
+ declare const DEFAULT_NATIVE_VECTOR_TOOLS: readonly NativeVectorToolDefinition[];
133
+ /**
134
+ * Horizontal, touch-sized toolbar for `canvu/native`.
135
+ *
136
+ * Use it with {@link NativeVectorViewport} by controlling the same `toolId`
137
+ * state. It intentionally uses React Native primitives only, so it works in
138
+ * Expo and bare React Native apps without a WebView.
139
+ *
140
+ * @example
141
+ * ```tsx
142
+ * const [toolId, setToolId] = useState("select");
143
+ *
144
+ * <NativeVectorViewport toolId={toolId} ... />
145
+ * <NativeVectorToolbar value={toolId} onChange={setToolId} />
146
+ * ```
147
+ */
148
+ declare function NativeVectorToolbar({ value, onChange, tools, disabled, disabledToolIds, accessibilityLabel, style, contentContainerStyle, toolButtonStyle, activeToolButtonStyle, toolLabelStyle, activeToolLabelStyle, renderToolIcon, renderToolButton, }: NativeVectorToolbarProps): react_jsx_runtime.JSX.Element;
149
+
72
150
  type NativeVectorViewportHandle = {
73
151
  getCamera: () => Camera2D | null;
74
152
  requestRender: () => void;
@@ -214,4 +292,4 @@ type SvgNode = SvgRectNode | SvgEllipseNode | SvgCircleNode | SvgLineNode | SvgP
214
292
  */
215
293
  declare function parseSvgFragment(xml: string): SvgNode[];
216
294
 
217
- export { NativeInteractionOverlay, type NativeInteractionOverlayProps, NativeSceneRenderer, type NativeSceneRendererProps, NativeShapeRenderer, type NativeShapeRendererProps, NativeVectorViewport, type NativeVectorViewportHandle, type NativeVectorViewportProps, type PlacementPreview, type SvgNode, parseSvgFragment };
295
+ export { DEFAULT_NATIVE_VECTOR_TOOLS, NativeInteractionOverlay, type NativeInteractionOverlayProps, NativeSceneRenderer, type NativeSceneRendererProps, NativeShapeRenderer, type NativeShapeRendererProps, type NativeVectorToolDefinition, NativeVectorToolbar, type NativeVectorToolbarProps, type NativeVectorToolbarRenderToolInput, NativeVectorViewport, type NativeVectorViewportHandle, type NativeVectorViewportProps, type PlacementPreview, type SvgNode, VectorSceneItem, parseSvgFragment };
package/dist/native.d.ts CHANGED
@@ -1,10 +1,13 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { C as Camera2D } from './camera-CoRYN_IV.js';
1
+ import { C as Camera2D } from './shape-builders-Cyh8zvDG.js';
2
+ export { o as createFreehandStrokeItem, t as createShapeId } from './shape-builders-Cyh8zvDG.js';
3
3
  import { V as VectorSceneItem, R as Rect } from './types-BCCvY6ie.js';
4
+ import * as react_jsx_runtime from 'react/jsx-runtime';
4
5
  import * as react from 'react';
6
+ import { ReactNode } from 'react';
7
+ import { StyleProp, ViewStyle, TextStyle } from 'react-native';
5
8
 
6
9
  type PlacementPreview = {
7
- readonly kind: "rect" | "ellipse";
10
+ readonly kind: "rect" | "ellipse" | "architectural-cloud";
8
11
  readonly rect: {
9
12
  readonly x: number;
10
13
  readonly y: number;
@@ -69,6 +72,81 @@ type NativeShapeRendererProps = {
69
72
  };
70
73
  declare function NativeShapeRenderer({ item }: NativeShapeRendererProps): react_jsx_runtime.JSX.Element | null;
71
74
 
75
+ /**
76
+ * Describes a single tool button rendered by {@link NativeVectorToolbar}.
77
+ *
78
+ * Use the built-in ids from {@link DEFAULT_NATIVE_VECTOR_TOOLS} when pairing
79
+ * the toolbar with {@link NativeVectorViewport}. Custom ids are useful only
80
+ * when the app also implements matching viewport behavior.
81
+ */
82
+ type NativeVectorToolDefinition = {
83
+ readonly id: string;
84
+ readonly label: string;
85
+ readonly shortLabel?: string;
86
+ readonly accessibilityLabel?: string;
87
+ readonly disabled?: boolean;
88
+ };
89
+ /**
90
+ * Render input for custom tool icons or complete custom tool buttons.
91
+ *
92
+ * Prefer `renderToolIcon` for app-specific icon packs. Use
93
+ * `renderToolButton` only when you need to replace the full touch target while
94
+ * keeping the toolbar's horizontal scrolling and tool list behavior.
95
+ */
96
+ type NativeVectorToolbarRenderToolInput = {
97
+ readonly tool: NativeVectorToolDefinition;
98
+ readonly selected: boolean;
99
+ readonly disabled: boolean;
100
+ readonly foregroundColor: string;
101
+ readonly onSelect: () => void;
102
+ };
103
+ /**
104
+ * Props for {@link NativeVectorToolbar}.
105
+ *
106
+ * The component is controlled: pass the same `value` to `NativeVectorViewport`
107
+ * as `toolId`, and update it from `onChange`. It is intentionally lightweight
108
+ * and native-only, with no dependency on the web toolbar implementation.
109
+ */
110
+ type NativeVectorToolbarProps = {
111
+ readonly value: string;
112
+ readonly onChange: (toolId: string) => void;
113
+ readonly tools?: readonly NativeVectorToolDefinition[];
114
+ readonly disabled?: boolean;
115
+ readonly disabledToolIds?: readonly string[];
116
+ readonly accessibilityLabel?: string;
117
+ readonly style?: StyleProp<ViewStyle>;
118
+ readonly contentContainerStyle?: StyleProp<ViewStyle>;
119
+ readonly toolButtonStyle?: StyleProp<ViewStyle>;
120
+ readonly activeToolButtonStyle?: StyleProp<ViewStyle>;
121
+ readonly toolLabelStyle?: StyleProp<TextStyle>;
122
+ readonly activeToolLabelStyle?: StyleProp<TextStyle>;
123
+ readonly renderToolIcon?: (input: NativeVectorToolbarRenderToolInput) => ReactNode;
124
+ readonly renderToolButton?: (input: NativeVectorToolbarRenderToolInput) => ReactNode;
125
+ };
126
+ /**
127
+ * Default mobile-friendly tool list for {@link NativeVectorToolbar}.
128
+ *
129
+ * The ids match the native viewport's built-in tool handling. Apps can pass a
130
+ * filtered or reordered list when permissions or product scope require it.
131
+ */
132
+ declare const DEFAULT_NATIVE_VECTOR_TOOLS: readonly NativeVectorToolDefinition[];
133
+ /**
134
+ * Horizontal, touch-sized toolbar for `canvu/native`.
135
+ *
136
+ * Use it with {@link NativeVectorViewport} by controlling the same `toolId`
137
+ * state. It intentionally uses React Native primitives only, so it works in
138
+ * Expo and bare React Native apps without a WebView.
139
+ *
140
+ * @example
141
+ * ```tsx
142
+ * const [toolId, setToolId] = useState("select");
143
+ *
144
+ * <NativeVectorViewport toolId={toolId} ... />
145
+ * <NativeVectorToolbar value={toolId} onChange={setToolId} />
146
+ * ```
147
+ */
148
+ declare function NativeVectorToolbar({ value, onChange, tools, disabled, disabledToolIds, accessibilityLabel, style, contentContainerStyle, toolButtonStyle, activeToolButtonStyle, toolLabelStyle, activeToolLabelStyle, renderToolIcon, renderToolButton, }: NativeVectorToolbarProps): react_jsx_runtime.JSX.Element;
149
+
72
150
  type NativeVectorViewportHandle = {
73
151
  getCamera: () => Camera2D | null;
74
152
  requestRender: () => void;
@@ -214,4 +292,4 @@ type SvgNode = SvgRectNode | SvgEllipseNode | SvgCircleNode | SvgLineNode | SvgP
214
292
  */
215
293
  declare function parseSvgFragment(xml: string): SvgNode[];
216
294
 
217
- export { NativeInteractionOverlay, type NativeInteractionOverlayProps, NativeSceneRenderer, type NativeSceneRendererProps, NativeShapeRenderer, type NativeShapeRendererProps, NativeVectorViewport, type NativeVectorViewportHandle, type NativeVectorViewportProps, type PlacementPreview, type SvgNode, parseSvgFragment };
295
+ export { DEFAULT_NATIVE_VECTOR_TOOLS, NativeInteractionOverlay, type NativeInteractionOverlayProps, NativeSceneRenderer, type NativeSceneRendererProps, NativeShapeRenderer, type NativeShapeRendererProps, type NativeVectorToolDefinition, NativeVectorToolbar, type NativeVectorToolbarProps, type NativeVectorToolbarRenderToolInput, NativeVectorViewport, type NativeVectorViewportHandle, type NativeVectorViewportProps, type PlacementPreview, type SvgNode, VectorSceneItem, parseSvgFragment };