@hunterchen/canvas 0.4.1 → 0.6.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 +94 -0
- package/dist/components/canvas/canvas.d.ts +3 -1
- package/dist/components/canvas/canvas.d.ts.map +1 -1
- package/dist/components/canvas/canvas.js +6 -4
- package/dist/components/canvas/canvas.js.map +1 -1
- package/dist/components/canvas/draggable.d.ts +1 -0
- package/dist/components/canvas/draggable.d.ts.map +1 -1
- package/dist/components/canvas/draggable.js +3 -3
- package/dist/components/canvas/draggable.js.map +1 -1
- package/dist/components/canvas/toolbar.d.ts +3 -1
- package/dist/components/canvas/toolbar.d.ts.map +1 -1
- package/dist/components/canvas/toolbar.js +67 -9
- package/dist/components/canvas/toolbar.js.map +1 -1
- package/dist/index.d.ts +19 -19
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -15
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/types/index.d.ts +43 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/components/canvas/canvas.tsx +40 -25
- package/src/components/canvas/draggable.tsx +4 -2
- package/src/components/canvas/toolbar.tsx +129 -16
- package/src/index.ts +46 -28
- package/src/types/index.ts +59 -0
package/src/index.ts
CHANGED
|
@@ -1,41 +1,59 @@
|
|
|
1
1
|
// Components
|
|
2
|
-
export { default as Canvas } from
|
|
3
|
-
export { CanvasComponent } from
|
|
4
|
-
export { Draggable, DraggableImage } from
|
|
5
|
-
export { CanvasWrapper, growTransition } from
|
|
6
|
-
export { default as CanvasToolbar } from
|
|
7
|
-
export { default as CanvasNavbar } from
|
|
2
|
+
export { default as Canvas } from "./components/canvas/canvas";
|
|
3
|
+
export { CanvasComponent } from "./components/canvas/component";
|
|
4
|
+
export { Draggable, DraggableImage } from "./components/canvas/draggable";
|
|
5
|
+
export { CanvasWrapper, growTransition } from "./components/canvas/wrapper";
|
|
6
|
+
export { default as CanvasToolbar } from "./components/canvas/toolbar";
|
|
7
|
+
export { default as CanvasNavbar } from "./components/canvas/navbar";
|
|
8
8
|
|
|
9
9
|
// Background Components
|
|
10
10
|
export {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
} from
|
|
11
|
+
DefaultCanvasBackground,
|
|
12
|
+
DefaultWrapperBackground,
|
|
13
|
+
DefaultIntroContent,
|
|
14
|
+
DEFAULT_CANVAS_GRADIENT,
|
|
15
|
+
DEFAULT_INTRO_GRADIENT,
|
|
16
|
+
DEFAULT_CANVAS_BOX_GRADIENT,
|
|
17
|
+
} from "./components/canvas/backgrounds";
|
|
18
18
|
export type {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
} from
|
|
19
|
+
DefaultCanvasBackgroundProps,
|
|
20
|
+
DefaultWrapperBackgroundProps,
|
|
21
|
+
DefaultIntroContentProps,
|
|
22
|
+
} from "./components/canvas/backgrounds";
|
|
23
23
|
|
|
24
24
|
// Contexts
|
|
25
|
-
export {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
export {
|
|
26
|
+
CanvasContext,
|
|
27
|
+
CanvasProvider,
|
|
28
|
+
useCanvasContext,
|
|
29
|
+
} from "./contexts/CanvasContext";
|
|
30
|
+
export type { CanvasContextState } from "./contexts/CanvasContext";
|
|
31
|
+
export {
|
|
32
|
+
PerformanceProvider,
|
|
33
|
+
usePerformanceMode,
|
|
34
|
+
usePerformance,
|
|
35
|
+
} from "./contexts/PerformanceContext";
|
|
36
|
+
export type {
|
|
37
|
+
PerformanceMode,
|
|
38
|
+
PerformanceConfig,
|
|
39
|
+
} from "./contexts/PerformanceContext";
|
|
29
40
|
|
|
30
41
|
// Hooks
|
|
31
|
-
export { default as useWindowDimensions } from
|
|
32
|
-
export { usePerformanceMode as usePerformanceModeLegacy } from
|
|
42
|
+
export { default as useWindowDimensions } from "./hooks/useWindowDimensions";
|
|
43
|
+
export { usePerformanceMode as usePerformanceModeLegacy } from "./hooks/usePerformanceMode";
|
|
33
44
|
|
|
34
45
|
// Utilities
|
|
35
|
-
export * from
|
|
36
|
-
export * from
|
|
37
|
-
export * from
|
|
38
|
-
export * from
|
|
46
|
+
export * from "./lib/canvas";
|
|
47
|
+
export * from "./lib/constants";
|
|
48
|
+
export * from "./lib/utils";
|
|
49
|
+
export * from "./utils/performance";
|
|
39
50
|
|
|
40
51
|
// Types
|
|
41
|
-
export type {
|
|
52
|
+
export type {
|
|
53
|
+
SectionCoordinates,
|
|
54
|
+
NavItem,
|
|
55
|
+
CanvasSection,
|
|
56
|
+
ToolbarConfig,
|
|
57
|
+
ToolbarPosition,
|
|
58
|
+
ToolbarDisplayMode,
|
|
59
|
+
} from "./types";
|
package/src/types/index.ts
CHANGED
|
@@ -38,3 +38,62 @@ export interface NavItem {
|
|
|
38
38
|
/** If true, clicking this section triggers the reset/home behavior */
|
|
39
39
|
isHome?: boolean;
|
|
40
40
|
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Preset positions for the toolbar
|
|
44
|
+
*/
|
|
45
|
+
export type ToolbarPosition = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* What to display in the toolbar
|
|
49
|
+
*/
|
|
50
|
+
export type ToolbarDisplayMode = 'coordinates' | 'scale' | 'both';
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Configuration options for the canvas toolbar
|
|
54
|
+
*/
|
|
55
|
+
export interface ToolbarConfig {
|
|
56
|
+
// === Visibility ===
|
|
57
|
+
/** Hide the toolbar entirely. Default: false */
|
|
58
|
+
hidden?: boolean;
|
|
59
|
+
|
|
60
|
+
// === Display Mode ===
|
|
61
|
+
/** What to show: 'coordinates', 'scale', or 'both'. Default: 'both' */
|
|
62
|
+
display?: ToolbarDisplayMode;
|
|
63
|
+
|
|
64
|
+
// === Positioning ===
|
|
65
|
+
/** Preset position. Default: 'top-left' */
|
|
66
|
+
position?: ToolbarPosition;
|
|
67
|
+
|
|
68
|
+
// === Auto-hide Behavior ===
|
|
69
|
+
/** Disable auto-hide when at home position. Default: false */
|
|
70
|
+
disableAutoHide?: boolean;
|
|
71
|
+
|
|
72
|
+
// === Styling (Tailwind-friendly) ===
|
|
73
|
+
/** Additional className for the container */
|
|
74
|
+
className?: string;
|
|
75
|
+
/** Additional className for the coordinates text */
|
|
76
|
+
coordinatesClassName?: string;
|
|
77
|
+
/** Additional className for the scale text */
|
|
78
|
+
scaleClassName?: string;
|
|
79
|
+
/** Additional className for the separator */
|
|
80
|
+
separatorClassName?: string;
|
|
81
|
+
|
|
82
|
+
// === Styling (non-Tailwind / inline styles) ===
|
|
83
|
+
/** Inline styles for the container */
|
|
84
|
+
style?: React.CSSProperties;
|
|
85
|
+
/** Inline styles for the coordinates */
|
|
86
|
+
coordinatesStyle?: React.CSSProperties;
|
|
87
|
+
/** Inline styles for the scale */
|
|
88
|
+
scaleStyle?: React.CSSProperties;
|
|
89
|
+
|
|
90
|
+
// === Content Customization ===
|
|
91
|
+
/** Custom separator between coordinates and scale. Default: ' | ' */
|
|
92
|
+
separator?: string;
|
|
93
|
+
/** Gap around the separator in pixels or CSS value. Default: undefined (uses inline spacing) */
|
|
94
|
+
separatorGap?: number | string;
|
|
95
|
+
/** Format for coordinates. Default: '(x, y)' */
|
|
96
|
+
coordinatesFormat?: (x: number, y: number) => string;
|
|
97
|
+
/** Format for scale. Default: '1.00x' */
|
|
98
|
+
scaleFormat?: (scale: number) => string;
|
|
99
|
+
}
|