neogestify-ui-components 1.2.21 → 2.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.
Files changed (52) hide show
  1. package/README.md +352 -2
  2. package/dist/components/VenueMapEditor/index.d.mts +202 -0
  3. package/dist/components/VenueMapEditor/index.d.ts +202 -0
  4. package/dist/components/VenueMapEditor/index.js +2684 -0
  5. package/dist/components/VenueMapEditor/index.js.map +1 -0
  6. package/dist/components/VenueMapEditor/index.mjs +2676 -0
  7. package/dist/components/VenueMapEditor/index.mjs.map +1 -0
  8. package/dist/components/alerts/index.js.map +1 -1
  9. package/dist/components/alerts/index.mjs.map +1 -1
  10. package/dist/components/html/index.d.mts +2 -0
  11. package/dist/components/html/index.d.ts +2 -0
  12. package/dist/components/html/index.js +24 -58
  13. package/dist/components/html/index.js.map +1 -1
  14. package/dist/components/html/index.mjs +24 -58
  15. package/dist/components/html/index.mjs.map +1 -1
  16. package/dist/components/icons/index.d.mts +18 -2
  17. package/dist/components/icons/index.d.ts +18 -2
  18. package/dist/components/icons/index.js +97 -11
  19. package/dist/components/icons/index.js.map +1 -1
  20. package/dist/components/icons/index.mjs +82 -12
  21. package/dist/components/icons/index.mjs.map +1 -1
  22. package/dist/context/theme/index.js.map +1 -1
  23. package/dist/context/theme/index.mjs.map +1 -1
  24. package/dist/index.d.mts +2 -1
  25. package/dist/index.d.ts +2 -1
  26. package/dist/index.js +2734 -69
  27. package/dist/index.js.map +1 -1
  28. package/dist/index.mjs +2713 -71
  29. package/dist/index.mjs.map +1 -1
  30. package/package.json +9 -4
  31. package/src/components/VenueMapEditor/VenueMapEditor.tsx +851 -0
  32. package/src/components/VenueMapEditor/VenueMapViewer.tsx +13 -0
  33. package/src/components/VenueMapEditor/components/Artboard.tsx +405 -0
  34. package/src/components/VenueMapEditor/components/EditorCanvas.tsx +472 -0
  35. package/src/components/VenueMapEditor/components/ElementNode.tsx +357 -0
  36. package/src/components/VenueMapEditor/components/FloorTabs.tsx +137 -0
  37. package/src/components/VenueMapEditor/components/GridOverlay.tsx +67 -0
  38. package/src/components/VenueMapEditor/components/PropertiesPanel.tsx +198 -0
  39. package/src/components/VenueMapEditor/components/Toolbar.tsx +254 -0
  40. package/src/components/VenueMapEditor/components/WallLayer.tsx +117 -0
  41. package/src/components/VenueMapEditor/hooks/useDrag.ts +79 -0
  42. package/src/components/VenueMapEditor/hooks/useHistory.ts +74 -0
  43. package/src/components/VenueMapEditor/hooks/usePanZoom.ts +114 -0
  44. package/src/components/VenueMapEditor/hooks/useSelection.ts +42 -0
  45. package/src/components/VenueMapEditor/index.ts +34 -0
  46. package/src/components/VenueMapEditor/types.ts +173 -0
  47. package/src/components/VenueMapEditor/utils/idGen.ts +2 -0
  48. package/src/components/VenueMapEditor/utils/snapUtils.ts +38 -0
  49. package/src/components/VenueMapEditor/utils/wallGeometry.ts +83 -0
  50. package/src/components/html/Input.tsx +48 -80
  51. package/src/components/icons/icons.tsx +153 -14
  52. package/src/index.ts +1 -0
@@ -0,0 +1,202 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import * as React from 'react';
3
+ import { WheelEvent, MouseEvent } from 'react';
4
+
5
+ type WallMaterial = 'concrete' | 'brick' | 'glass' | 'drywall' | 'wood';
6
+ type AreaShape = 'rect' | 'polygon';
7
+ type ElementShape = 'rect' | 'circle' | 'arrow' | 'path';
8
+ type ToolMode = 'SELECT' | 'WALL' | 'PLACE' | 'PAN' | 'ERASE';
9
+ interface WallNode {
10
+ id: string;
11
+ x: number;
12
+ y: number;
13
+ }
14
+ interface Wall {
15
+ id: string;
16
+ nodeAId: string;
17
+ nodeBId: string;
18
+ /** Thickness in canvas px */
19
+ thickness: number;
20
+ material: WallMaterial;
21
+ }
22
+ interface MapElement {
23
+ id: string;
24
+ /** e.g. 'TABLE_ROUND', 'PARKING_SPOT', 'DOOR' */
25
+ type: string;
26
+ x: number;
27
+ y: number;
28
+ width: number;
29
+ height: number;
30
+ /** Rotation in degrees */
31
+ rotation: number;
32
+ label?: string;
33
+ metadata?: Record<string, unknown>;
34
+ }
35
+ interface FloorArea {
36
+ shape: AreaShape;
37
+ x?: number;
38
+ y?: number;
39
+ width?: number;
40
+ height?: number;
41
+ points?: [number, number][];
42
+ }
43
+ interface Floor {
44
+ id: string;
45
+ name: string;
46
+ order: number;
47
+ area: FloorArea;
48
+ wallNodes: WallNode[];
49
+ walls: Wall[];
50
+ elements: MapElement[];
51
+ }
52
+ interface VenueMap {
53
+ id: string;
54
+ name: string;
55
+ floors: Floor[];
56
+ /** Custom element libraries imported by the user; persisted with the map. */
57
+ libraries?: ElementLibrary;
58
+ }
59
+ interface ElementTypeDef {
60
+ id: string;
61
+ label: string;
62
+ shape: ElementShape;
63
+ defaultWidth: number;
64
+ defaultHeight: number;
65
+ /** SVG fill color */
66
+ color: string;
67
+ strokeColor: string;
68
+ /** Emoji or icon name */
69
+ icon?: string;
70
+ /**
71
+ * Raw SVG path `d` attribute for `shape === 'path'`.
72
+ * Define the path in the coordinate space of `viewBox` (default `"0 0 100 100"`).
73
+ * It will be automatically scaled to fit the element's `width × height` bounding box.
74
+ *
75
+ * @example
76
+ * // A 5-pointed star in a 100×100 viewBox
77
+ * svgPath: "M50 5 L61 35 L95 35 L68 57 L79 91 L50 70 L21 91 L32 57 L5 35 L39 35 Z"
78
+ */
79
+ svgPath?: string;
80
+ /**
81
+ * ViewBox for `svgPath`. Format: `"minX minY width height"`.
82
+ * Defaults to `"0 0 100 100"` when omitted.
83
+ */
84
+ viewBox?: string;
85
+ }
86
+ interface DomainConfig {
87
+ id: string;
88
+ name: string;
89
+ elementTypes: ElementTypeDef[];
90
+ }
91
+ interface ElementGroup {
92
+ name: string;
93
+ objects: ElementTypeDef[];
94
+ }
95
+ /** A library JSON file: top-level keys are group IDs. */
96
+ type ElementLibrary = Record<string, ElementGroup>;
97
+ interface ElementStatus {
98
+ elementId: string;
99
+ status: 'free' | 'occupied' | 'reserved' | 'disabled';
100
+ tooltip?: string;
101
+ }
102
+ interface VenueMapEditorProps {
103
+ /**
104
+ * Optional built-in element type catalog.
105
+ * If omitted the palette is empty until the user imports a library JSON.
106
+ */
107
+ domainConfig?: DomainConfig;
108
+ /**
109
+ * Map to render. When this prop changes (by reference) from outside the
110
+ * component, the editor resets its history to the new map — allowing the
111
+ * parent to hydrate the editor from an API or local storage without causing
112
+ * a render loop (changes made inside the editor that are echoed back via
113
+ * `onChange` are detected and ignored).
114
+ */
115
+ initialMap?: VenueMap;
116
+ /** Called every time the internal map state changes. */
117
+ onChange?: (map: VenueMap) => void;
118
+ width?: string | number;
119
+ height?: string | number;
120
+ gridSize?: number;
121
+ showGrid?: boolean;
122
+ snapToGrid?: boolean;
123
+ readOnly?: boolean;
124
+ /** Viewer-only mode: pan and zoom are allowed but nothing can be edited. */
125
+ fixed?: boolean;
126
+ elementStatus?: ElementStatus[];
127
+ onElementClick?: (element: MapElement) => void;
128
+ /**
129
+ * Per-type click handlers active in viewer/fixed mode.
130
+ * Keys are element type IDs (e.g. `'TABLE_ROUND'`).
131
+ * When an element is clicked, its type-specific handler fires first;
132
+ * if none is registered, `onElementClick` is used as fallback.
133
+ *
134
+ * @example
135
+ * ```tsx
136
+ * <VenueMapViewer
137
+ * onElementTypeClick={{
138
+ * TABLE_ROUND: (el) => openReservation(el.id),
139
+ * CHAIR: (el) => showInfo(el),
140
+ * }}
141
+ * />
142
+ * ```
143
+ */
144
+ onElementTypeClick?: Record<string, (element: MapElement) => void>;
145
+ }
146
+ type VenueMapViewerProps = VenueMapEditorProps;
147
+
148
+ declare function VenueMapEditor({ domainConfig, initialMap, onChange, width, height, gridSize, showGrid: showGridProp, snapToGrid: snapEnabled, readOnly, fixed, elementStatus, onElementClick, onElementTypeClick, }: VenueMapEditorProps): react_jsx_runtime.JSX.Element;
149
+
150
+ declare function VenueMapViewer({ elementStatus, onElementClick, ...rest }: VenueMapViewerProps): react_jsx_runtime.JSX.Element;
151
+
152
+ interface PaletteGroup {
153
+ id: string;
154
+ name: string;
155
+ /** True for the built-in domain config group; false for imported library groups. */
156
+ isBase?: boolean;
157
+ types: ElementTypeDef[];
158
+ }
159
+
160
+ interface PanZoomState {
161
+ panX: number;
162
+ panY: number;
163
+ zoom: number;
164
+ }
165
+ declare function usePanZoom(initialZoom?: number, leftClickPan?: boolean): {
166
+ state: PanZoomState;
167
+ setState: React.Dispatch<React.SetStateAction<PanZoomState>>;
168
+ isPanning: boolean;
169
+ handleWheel: (e: WheelEvent<SVGSVGElement>) => void;
170
+ handleMouseDown: (e: MouseEvent<SVGSVGElement>) => void;
171
+ handleMouseMove: (e: MouseEvent<SVGSVGElement>) => void;
172
+ handleMouseUp: (_e: MouseEvent<SVGSVGElement>) => void;
173
+ handleMouseLeave: () => void;
174
+ zoomBy: (factor: number, cx?: number, cy?: number) => void;
175
+ resetView: () => void;
176
+ };
177
+
178
+ /** Generates a globally-unique id using the Web Crypto API. */
179
+ declare const genId: () => string;
180
+
181
+ /** Snap a single value to the nearest grid line. */
182
+ declare const snapToGrid: (value: number, gridSize: number) => number;
183
+ /** Snap a 2-D point to the grid if `enabled`, otherwise return it unchanged. */
184
+ declare const snapPoint: (x: number, y: number, gridSize: number, enabled: boolean) => {
185
+ x: number;
186
+ y: number;
187
+ };
188
+ /**
189
+ * Find the closest WallNode within `threshold` canvas units.
190
+ * Returns the node's id and position, or null when nothing is close enough.
191
+ */
192
+ declare const findNearestNode: (x: number, y: number, nodes: Array<{
193
+ id: string;
194
+ x: number;
195
+ y: number;
196
+ }>, threshold: number) => {
197
+ id: string;
198
+ x: number;
199
+ y: number;
200
+ } | null;
201
+
202
+ export { type AreaShape, type DomainConfig, type ElementGroup, type ElementLibrary, type ElementShape, type ElementStatus, type ElementTypeDef, type Floor, type FloorArea, type MapElement, type PaletteGroup, type PanZoomState, type ToolMode, type VenueMap, VenueMapEditor, type VenueMapEditorProps, VenueMapViewer, type VenueMapViewerProps, type Wall, type WallMaterial, type WallNode, findNearestNode, genId, snapPoint, snapToGrid, usePanZoom };