@ankhorage/zora 2.6.1 → 2.7.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 (43) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +1 -1
  3. package/dist/index.d.ts +2 -0
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +1 -0
  6. package/dist/index.js.map +1 -1
  7. package/dist/metadata/componentMeta.d.ts.map +1 -1
  8. package/dist/metadata/componentMeta.js +4 -0
  9. package/dist/metadata/componentMeta.js.map +1 -1
  10. package/dist/patterns/scanner/BarcodeScannerView.d.ts +11 -0
  11. package/dist/patterns/scanner/BarcodeScannerView.d.ts.map +1 -0
  12. package/dist/patterns/scanner/BarcodeScannerView.js +77 -0
  13. package/dist/patterns/scanner/BarcodeScannerView.js.map +1 -0
  14. package/dist/patterns/scanner/CameraPermissionView.d.ts +11 -0
  15. package/dist/patterns/scanner/CameraPermissionView.d.ts.map +1 -0
  16. package/dist/patterns/scanner/CameraPermissionView.js +62 -0
  17. package/dist/patterns/scanner/CameraPermissionView.js.map +1 -0
  18. package/dist/patterns/scanner/ScanOverlay.d.ts +11 -0
  19. package/dist/patterns/scanner/ScanOverlay.d.ts.map +1 -0
  20. package/dist/patterns/scanner/ScanOverlay.js +85 -0
  21. package/dist/patterns/scanner/ScanOverlay.js.map +1 -0
  22. package/dist/patterns/scanner/index.d.ts +5 -0
  23. package/dist/patterns/scanner/index.d.ts.map +1 -0
  24. package/dist/patterns/scanner/index.js +4 -0
  25. package/dist/patterns/scanner/index.js.map +1 -0
  26. package/dist/patterns/scanner/meta.d.ts +190 -0
  27. package/dist/patterns/scanner/meta.d.ts.map +1 -0
  28. package/dist/patterns/scanner/meta.js +186 -0
  29. package/dist/patterns/scanner/meta.js.map +1 -0
  30. package/dist/patterns/scanner/types.d.ts +42 -0
  31. package/dist/patterns/scanner/types.d.ts.map +1 -0
  32. package/dist/patterns/scanner/types.js +2 -0
  33. package/dist/patterns/scanner/types.js.map +1 -0
  34. package/package.json +1 -1
  35. package/src/index.ts +8 -0
  36. package/src/metadata/componentMeta.test.ts +30 -105
  37. package/src/metadata/componentMeta.ts +8 -0
  38. package/src/patterns/scanner/BarcodeScannerView.tsx +127 -0
  39. package/src/patterns/scanner/CameraPermissionView.tsx +108 -0
  40. package/src/patterns/scanner/ScanOverlay.tsx +99 -0
  41. package/src/patterns/scanner/index.ts +10 -0
  42. package/src/patterns/scanner/meta.ts +190 -0
  43. package/src/patterns/scanner/types.ts +47 -0
@@ -0,0 +1,190 @@
1
+ import type { ZoraComponentMeta } from '../../metadata';
2
+ import { CONTAINER_ALLOWED_CHILDREN } from '../../metadata/allowedChildren';
3
+
4
+ export const scanOverlayMeta = {
5
+ name: 'ScanOverlay',
6
+ category: 'pattern',
7
+ description: 'Camera-agnostic scan frame overlay for barcode and QR scanning flows.',
8
+ directManifestNode: true,
9
+ allowedChildren: [],
10
+ blueprint: {
11
+ label: 'Scan overlay',
12
+ defaultProps: {
13
+ title: 'Align the barcode',
14
+ description: 'Hold the barcode inside the frame. Scanning starts automatically.',
15
+ cornerLabel: 'SCAN',
16
+ },
17
+ },
18
+ props: {
19
+ title: {
20
+ type: 'string',
21
+ category: 'Content',
22
+ label: 'Title',
23
+ default: 'Align the barcode',
24
+ },
25
+ description: {
26
+ type: 'string',
27
+ category: 'Content',
28
+ label: 'Description',
29
+ default: 'Hold the barcode inside the frame. Scanning starts automatically.',
30
+ },
31
+ cornerLabel: {
32
+ type: 'string',
33
+ category: 'Content',
34
+ label: 'Corner label',
35
+ default: 'SCAN',
36
+ },
37
+ },
38
+ } as const satisfies ZoraComponentMeta;
39
+
40
+ export const cameraPermissionViewMeta = {
41
+ name: 'CameraPermissionView',
42
+ category: 'pattern',
43
+ description: 'ZORA-owned camera permission state for scanner flows.',
44
+ directManifestNode: true,
45
+ allowedChildren: [],
46
+ blueprint: {
47
+ label: 'Camera permission',
48
+ defaultProps: {
49
+ status: 'unknown',
50
+ requestLabel: 'Allow camera access',
51
+ manualEntryLabel: 'Enter barcode manually',
52
+ },
53
+ },
54
+ props: {
55
+ status: {
56
+ type: 'enum',
57
+ category: 'State',
58
+ label: 'Permission status',
59
+ enum: ['unknown', 'requesting', 'denied'],
60
+ default: 'unknown',
61
+ },
62
+ title: {
63
+ type: 'string',
64
+ category: 'Content',
65
+ label: 'Title',
66
+ },
67
+ description: {
68
+ type: 'string',
69
+ category: 'Content',
70
+ label: 'Description',
71
+ },
72
+ requestLabel: {
73
+ type: 'string',
74
+ category: 'Content',
75
+ label: 'Request label',
76
+ default: 'Allow camera access',
77
+ },
78
+ deniedLabel: {
79
+ type: 'string',
80
+ category: 'Content',
81
+ label: 'Denied label',
82
+ default: 'Open settings',
83
+ },
84
+ manualEntryLabel: {
85
+ type: 'string',
86
+ category: 'Content',
87
+ label: 'Manual entry label',
88
+ default: 'Enter barcode manually',
89
+ },
90
+ onRequestPermission: {
91
+ type: 'action',
92
+ category: 'Events',
93
+ label: 'Request permission action',
94
+ },
95
+ onManualEntry: {
96
+ type: 'action',
97
+ category: 'Events',
98
+ label: 'Manual entry action',
99
+ },
100
+ },
101
+ } as const satisfies ZoraComponentMeta;
102
+
103
+ export const barcodeScannerViewMeta = {
104
+ name: 'BarcodeScannerView',
105
+ category: 'pattern',
106
+ description:
107
+ 'Composed scanner shell with permission, camera slot, scan overlay, and manual entry affordance.',
108
+ directManifestNode: true,
109
+ allowedChildren: [...CONTAINER_ALLOWED_CHILDREN],
110
+ blueprint: {
111
+ label: 'Barcode scanner',
112
+ defaultProps: {
113
+ permissionStatus: 'unknown',
114
+ title: 'Scan barcode',
115
+ description: 'Point the camera at a barcode to continue.',
116
+ },
117
+ },
118
+ events: {
119
+ onBarcodeScanned: {
120
+ label: 'Barcode scanned',
121
+ eventType: 'scan',
122
+ description: 'Emitted by the app camera adapter after a barcode has been scanned.',
123
+ payloadFields: [
124
+ { path: 'value', type: 'string', label: 'Barcode value' },
125
+ { path: 'type', type: 'string', label: 'Barcode type' },
126
+ ],
127
+ },
128
+ },
129
+ slots: {
130
+ camera: {
131
+ label: 'Camera adapter',
132
+ allowedChildren: [],
133
+ },
134
+ children: {
135
+ label: 'Scanner footer',
136
+ allowedChildren: [...CONTAINER_ALLOWED_CHILDREN],
137
+ },
138
+ },
139
+ props: {
140
+ permissionStatus: {
141
+ type: 'enum',
142
+ category: 'State',
143
+ label: 'Permission status',
144
+ enum: ['unknown', 'requesting', 'granted', 'denied'],
145
+ default: 'unknown',
146
+ },
147
+ title: {
148
+ type: 'string',
149
+ category: 'Content',
150
+ label: 'Title',
151
+ default: 'Scan barcode',
152
+ },
153
+ description: {
154
+ type: 'string',
155
+ category: 'Content',
156
+ label: 'Description',
157
+ default: 'Point the camera at a barcode to continue.',
158
+ },
159
+ overlayTitle: {
160
+ type: 'string',
161
+ category: 'Content',
162
+ label: 'Overlay title',
163
+ },
164
+ overlayDescription: {
165
+ type: 'string',
166
+ category: 'Content',
167
+ label: 'Overlay description',
168
+ },
169
+ requestPermissionLabel: {
170
+ type: 'string',
171
+ category: 'Content',
172
+ label: 'Request permission label',
173
+ },
174
+ manualEntryLabel: {
175
+ type: 'string',
176
+ category: 'Content',
177
+ label: 'Manual entry label',
178
+ },
179
+ onRequestPermission: {
180
+ type: 'action',
181
+ category: 'Events',
182
+ label: 'Request permission action',
183
+ },
184
+ onManualEntry: {
185
+ type: 'action',
186
+ category: 'Events',
187
+ label: 'Manual entry action',
188
+ },
189
+ },
190
+ } as const satisfies ZoraComponentMeta;
@@ -0,0 +1,47 @@
1
+ import type React from 'react';
2
+
3
+ import type { ButtonProps } from '../../components/button';
4
+ import type { ZoraBaseProps } from '../../theme/ZoraBaseProps';
5
+
6
+ export type CameraPermissionStatus = 'unknown' | 'requesting' | 'granted' | 'denied';
7
+
8
+ export interface BarcodeScanResult {
9
+ value: string;
10
+ type?: string;
11
+ }
12
+
13
+ export interface ScanOverlayProps extends ZoraBaseProps {
14
+ title?: React.ReactNode;
15
+ description?: React.ReactNode;
16
+ cornerLabel?: React.ReactNode;
17
+ }
18
+
19
+ export interface CameraPermissionViewProps extends ZoraBaseProps {
20
+ status: Exclude<CameraPermissionStatus, 'granted'>;
21
+ title?: React.ReactNode;
22
+ description?: React.ReactNode;
23
+ requestLabel?: React.ReactNode;
24
+ deniedLabel?: React.ReactNode;
25
+ manualEntryLabel?: React.ReactNode;
26
+ onRequestPermission?: () => void | Promise<void>;
27
+ onManualEntry?: () => void | Promise<void>;
28
+ requestButtonProps?: Omit<ButtonProps, 'children' | 'onPress'>;
29
+ manualEntryButtonProps?: Omit<ButtonProps, 'children' | 'onPress'>;
30
+ }
31
+
32
+ export interface BarcodeScannerViewProps extends ZoraBaseProps {
33
+ permissionStatus: CameraPermissionStatus;
34
+ camera?: React.ReactNode;
35
+ children?: React.ReactNode;
36
+ title?: React.ReactNode;
37
+ description?: React.ReactNode;
38
+ overlayTitle?: React.ReactNode;
39
+ overlayDescription?: React.ReactNode;
40
+ cornerLabel?: React.ReactNode;
41
+ requestPermissionLabel?: React.ReactNode;
42
+ deniedPermissionLabel?: React.ReactNode;
43
+ manualEntryLabel?: React.ReactNode;
44
+ onRequestPermission?: () => void | Promise<void>;
45
+ onManualEntry?: () => void | Promise<void>;
46
+ onBarcodeScanned?: (result: BarcodeScanResult) => void | Promise<void>;
47
+ }