hazo_notes 1.1.4 → 1.1.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/README.md +81 -83
- package/SETUP_CHECKLIST.md +17 -35
- package/dist/api/create_notes_handler.d.ts.map +1 -1
- package/dist/api/create_notes_handler.js +1 -5
- package/dist/api/create_notes_handler.js.map +1 -1
- package/dist/components/hazo_notes_entry.d.ts +1 -1
- package/dist/components/hazo_notes_entry.d.ts.map +1 -1
- package/dist/components/hazo_notes_entry.js +6 -31
- package/dist/components/hazo_notes_entry.js.map +1 -1
- package/dist/components/hazo_notes_file_preview.d.ts +2 -2
- package/dist/components/hazo_notes_file_preview.d.ts.map +1 -1
- package/dist/components/hazo_notes_file_preview.js +8 -6
- package/dist/components/hazo_notes_file_preview.js.map +1 -1
- package/dist/components/hazo_notes_icon.d.ts.map +1 -1
- package/dist/components/hazo_notes_icon.js +36 -4
- package/dist/components/hazo_notes_icon.js.map +1 -1
- package/dist/components/hazo_notes_panel.d.ts.map +1 -1
- package/dist/components/hazo_notes_panel.js +6 -59
- package/dist/components/hazo_notes_panel.js.map +1 -1
- package/dist/hooks/use_notes.js +2 -2
- package/dist/hooks/use_notes.js.map +1 -1
- package/dist/index.client.d.ts +3 -0
- package/dist/index.client.d.ts.map +1 -1
- package/dist/index.client.js +2 -0
- package/dist/index.client.js.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/config.js +1 -1
- package/dist/lib/config.js.map +1 -1
- package/dist/types/index.d.ts +5 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/avatar_utils.d.ts +13 -0
- package/dist/utils/avatar_utils.d.ts.map +1 -0
- package/dist/utils/avatar_utils.js +34 -0
- package/dist/utils/avatar_utils.js.map +1 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +2 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/theme_utils.d.ts +30 -0
- package/dist/utils/theme_utils.d.ts.map +1 -0
- package/dist/utils/theme_utils.js +204 -0
- package/dist/utils/theme_utils.js.map +1 -0
- package/package.json +1 -4
package/README.md
CHANGED
|
@@ -35,26 +35,18 @@ npm install hazo_notes
|
|
|
35
35
|
Install these based on your needs:
|
|
36
36
|
|
|
37
37
|
```bash
|
|
38
|
-
# Required for UI components
|
|
39
|
-
npm install @radix-ui/react-popover @radix-ui/react-dialog react-icons
|
|
40
|
-
|
|
41
38
|
# Recommended for full functionality
|
|
42
|
-
npm install hazo_connect hazo_auth hazo_logs
|
|
39
|
+
npm install hazo_connect hazo_auth hazo_logs react-icons
|
|
43
40
|
```
|
|
44
41
|
|
|
42
|
+
**Note:** Radix UI primitives (`@radix-ui/react-popover` and `@radix-ui/react-dialog`) are bundled with this package. You don't need to install them separately.
|
|
43
|
+
|
|
45
44
|
## Quick Start
|
|
46
45
|
|
|
47
46
|
### 1. Add the Component
|
|
48
47
|
|
|
49
|
-
**Important:** You must pass your UI components via the `popover_components` or `sheet_components` prop. The component cannot auto-import these across package boundaries.
|
|
50
|
-
|
|
51
48
|
```tsx
|
|
52
49
|
import { HazoNotesIcon } from 'hazo_notes';
|
|
53
|
-
// Import your shadcn/ui components
|
|
54
|
-
import { Popover, PopoverTrigger, PopoverContent } from '@/components/ui/popover';
|
|
55
|
-
|
|
56
|
-
// Create the components object
|
|
57
|
-
const popover_components = { Popover, PopoverTrigger, PopoverContent };
|
|
58
50
|
|
|
59
51
|
function MyComponent() {
|
|
60
52
|
return (
|
|
@@ -63,13 +55,14 @@ function MyComponent() {
|
|
|
63
55
|
<HazoNotesIcon
|
|
64
56
|
ref_id="customer-info-section"
|
|
65
57
|
label="Customer Information"
|
|
66
|
-
popover_components={popover_components}
|
|
67
58
|
/>
|
|
68
59
|
</div>
|
|
69
60
|
);
|
|
70
61
|
}
|
|
71
62
|
```
|
|
72
63
|
|
|
64
|
+
The component bundles its own Radix UI primitives, so no additional UI component setup is required.
|
|
65
|
+
|
|
73
66
|
### 2. Create API Route
|
|
74
67
|
|
|
75
68
|
Create `app/api/hazo_notes/[ref_id]/route.ts`:
|
|
@@ -156,9 +149,6 @@ For detailed setup instructions, see [SETUP_CHECKLIST.md](./SETUP_CHECKLIST.md).
|
|
|
156
149
|
|
|
157
150
|
```tsx
|
|
158
151
|
import { HazoNotesIcon } from 'hazo_notes';
|
|
159
|
-
import { Popover, PopoverTrigger, PopoverContent } from '@/components/ui/popover';
|
|
160
|
-
|
|
161
|
-
const popover_components = { Popover, PopoverTrigger, PopoverContent };
|
|
162
152
|
|
|
163
153
|
export default function FormPage() {
|
|
164
154
|
return (
|
|
@@ -168,7 +158,6 @@ export default function FormPage() {
|
|
|
168
158
|
<HazoNotesIcon
|
|
169
159
|
ref_id="income-field"
|
|
170
160
|
label="Annual Income"
|
|
171
|
-
popover_components={popover_components}
|
|
172
161
|
/>
|
|
173
162
|
</div>
|
|
174
163
|
<input type="number" name="income" />
|
|
@@ -189,7 +178,6 @@ export default function FormPage() {
|
|
|
189
178
|
max_files_per_note={5}
|
|
190
179
|
allowed_file_types={['pdf', 'docx', 'png', 'jpg']}
|
|
191
180
|
max_file_size_mb={10}
|
|
192
|
-
popover_components={popover_components}
|
|
193
181
|
/>
|
|
194
182
|
```
|
|
195
183
|
|
|
@@ -201,15 +189,10 @@ export default function FormPage() {
|
|
|
201
189
|
### Slide Panel Style
|
|
202
190
|
|
|
203
191
|
```tsx
|
|
204
|
-
import { Sheet, SheetTrigger, SheetContent } from '@/components/ui/sheet';
|
|
205
|
-
|
|
206
|
-
const sheet_components = { Sheet, SheetTrigger, SheetContent };
|
|
207
|
-
|
|
208
192
|
<HazoNotesIcon
|
|
209
193
|
ref_id="detailed-notes"
|
|
210
194
|
label="Detailed Notes"
|
|
211
195
|
panel_style="slide_panel"
|
|
212
|
-
sheet_components={sheet_components}
|
|
213
196
|
/>
|
|
214
197
|
```
|
|
215
198
|
|
|
@@ -222,7 +205,6 @@ const sheet_components = { Sheet, SheetTrigger, SheetContent };
|
|
|
222
205
|
ref_id="quick-notes"
|
|
223
206
|
label="Quick Notes"
|
|
224
207
|
save_mode="auto"
|
|
225
|
-
popover_components={popover_components}
|
|
226
208
|
/>
|
|
227
209
|
```
|
|
228
210
|
|
|
@@ -234,13 +216,24 @@ const sheet_components = { Sheet, SheetTrigger, SheetContent };
|
|
|
234
216
|
<HazoNotesIcon
|
|
235
217
|
ref_id="styled-notes"
|
|
236
218
|
label="Styled Notes"
|
|
237
|
-
background_color="bg-blue-
|
|
219
|
+
background_color="bg-blue-100"
|
|
220
|
+
icon_size={24}
|
|
221
|
+
show_border={false}
|
|
238
222
|
className="ml-2"
|
|
239
|
-
popover_components={popover_components}
|
|
240
223
|
/>
|
|
241
224
|
```
|
|
242
225
|
|
|
243
|
-
|
|
226
|
+
**Supported color themes**: yellow (default), amber, green, blue, red, orange, purple, pink, teal, gray. The `background_color` prop accepts any Tailwind `bg-{color}-{shade}` class — matching colors from the supported list will apply a full coordinated theme (header, text, borders, buttons). Unknown colors fall back to yellow.
|
|
227
|
+
|
|
228
|
+
```tsx
|
|
229
|
+
{/* Blue-themed notes */}
|
|
230
|
+
<HazoNotesIcon ref_id="blue-notes" background_color="bg-blue-100" />
|
|
231
|
+
|
|
232
|
+
{/* Green-themed notes */}
|
|
233
|
+
<HazoNotesIcon ref_id="green-notes" background_color="bg-green-100" />
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
### Controlled Mode (Notes State)
|
|
244
237
|
|
|
245
238
|
```tsx
|
|
246
239
|
'use client';
|
|
@@ -248,11 +241,8 @@ const sheet_components = { Sheet, SheetTrigger, SheetContent };
|
|
|
248
241
|
import { useState } from 'react';
|
|
249
242
|
import { HazoNotesIcon } from 'hazo_notes';
|
|
250
243
|
import type { NoteEntry } from 'hazo_notes/types';
|
|
251
|
-
import { Popover, PopoverTrigger, PopoverContent } from '@/components/ui/popover';
|
|
252
244
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
export default function ControlledExample() {
|
|
245
|
+
export default function ControlledNotesExample() {
|
|
256
246
|
const [notes, setNotes] = useState<NoteEntry[]>([]);
|
|
257
247
|
|
|
258
248
|
return (
|
|
@@ -261,7 +251,6 @@ export default function ControlledExample() {
|
|
|
261
251
|
label="Controlled Notes"
|
|
262
252
|
notes={notes}
|
|
263
253
|
on_notes_change={setNotes}
|
|
264
|
-
popover_components={popover_components}
|
|
265
254
|
/>
|
|
266
255
|
);
|
|
267
256
|
}
|
|
@@ -269,6 +258,35 @@ export default function ControlledExample() {
|
|
|
269
258
|
|
|
270
259
|
**Use Case**: Sync notes with parent component state or external state management.
|
|
271
260
|
|
|
261
|
+
### Controlled Mode (Open State)
|
|
262
|
+
|
|
263
|
+
Control when the panel opens/closes programmatically:
|
|
264
|
+
|
|
265
|
+
```tsx
|
|
266
|
+
'use client';
|
|
267
|
+
|
|
268
|
+
import { useState } from 'react';
|
|
269
|
+
import { HazoNotesIcon } from 'hazo_notes';
|
|
270
|
+
|
|
271
|
+
export default function ControlledOpenExample() {
|
|
272
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
273
|
+
|
|
274
|
+
return (
|
|
275
|
+
<>
|
|
276
|
+
<button onClick={() => setIsOpen(true)}>Open Notes</button>
|
|
277
|
+
<HazoNotesIcon
|
|
278
|
+
ref_id="controlled-open"
|
|
279
|
+
label="Controlled Open"
|
|
280
|
+
open={isOpen}
|
|
281
|
+
onOpenChange={setIsOpen}
|
|
282
|
+
/>
|
|
283
|
+
</>
|
|
284
|
+
);
|
|
285
|
+
}
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
**Note**: When using controlled open mode, the component applies a small delay (100ms) before opening the panel. This prevents conflicts when opening notes from dropdown menus or other overlays that need to close first.
|
|
289
|
+
|
|
272
290
|
## Configuration
|
|
273
291
|
|
|
274
292
|
Configuration options in `config/hazo_notes_config.ini`:
|
|
@@ -315,27 +333,20 @@ interface HazoNotesIconProps {
|
|
|
315
333
|
// Required
|
|
316
334
|
ref_id: string; // Unique identifier for this notes instance
|
|
317
335
|
|
|
318
|
-
// UI Components (REQUIRED - must pass one based on panel_style)
|
|
319
|
-
popover_components?: { // Required for panel_style="popover" (default)
|
|
320
|
-
Popover: React.ComponentType<any>;
|
|
321
|
-
PopoverTrigger: React.ComponentType<any>;
|
|
322
|
-
PopoverContent: React.ComponentType<any>;
|
|
323
|
-
};
|
|
324
|
-
sheet_components?: { // Required for panel_style="slide_panel"
|
|
325
|
-
Sheet: React.ComponentType<any>;
|
|
326
|
-
SheetTrigger: React.ComponentType<any>;
|
|
327
|
-
SheetContent: React.ComponentType<any>;
|
|
328
|
-
};
|
|
329
|
-
|
|
330
336
|
// Display
|
|
331
|
-
label?: string; // Panel header label
|
|
332
|
-
has_notes?: boolean; //
|
|
333
|
-
note_count?: number; //
|
|
337
|
+
label?: string; // Panel header label (default: 'Notes')
|
|
338
|
+
has_notes?: boolean; // Override indicator when notes exist
|
|
339
|
+
note_count?: number; // Override display count badge
|
|
334
340
|
|
|
335
|
-
// Controlled mode
|
|
341
|
+
// Controlled mode (notes state)
|
|
336
342
|
notes?: NoteEntry[]; // Controlled notes array
|
|
337
343
|
on_notes_change?: (notes: NoteEntry[]) => void;
|
|
338
344
|
|
|
345
|
+
// Controlled mode (open state)
|
|
346
|
+
open?: boolean; // Control panel open state
|
|
347
|
+
onOpenChange?: (open: boolean) => void;
|
|
348
|
+
default_open?: boolean; // Initial open state (uncontrolled)
|
|
349
|
+
|
|
339
350
|
// User context
|
|
340
351
|
current_user?: NoteUserInfo; // User info (auto-fetched if not provided)
|
|
341
352
|
|
|
@@ -345,21 +356,25 @@ interface HazoNotesIconProps {
|
|
|
345
356
|
background_color?: string; // Tailwind class
|
|
346
357
|
|
|
347
358
|
// File options
|
|
348
|
-
enable_files?: boolean; // Enable file attachments
|
|
349
|
-
max_files_per_note?: number;
|
|
350
|
-
allowed_file_types?: string[];
|
|
351
|
-
max_file_size_mb?: number;
|
|
359
|
+
enable_files?: boolean; // Enable file attachments (default: true)
|
|
360
|
+
max_files_per_note?: number; // Default: 5
|
|
361
|
+
allowed_file_types?: string[]; // Default: ['pdf', 'png', 'jpg', ...]
|
|
362
|
+
max_file_size_mb?: number; // Default: 10
|
|
352
363
|
|
|
353
364
|
// Callbacks
|
|
354
|
-
on_open?: () => void;
|
|
355
|
-
on_close?: () => void;
|
|
365
|
+
on_open?: () => void; // Called when panel opens
|
|
366
|
+
on_close?: () => void; // Called when panel closes
|
|
356
367
|
|
|
357
368
|
// Styling
|
|
358
|
-
disabled?: boolean;
|
|
359
|
-
className?: string;
|
|
369
|
+
disabled?: boolean; // Disable and hide the component
|
|
370
|
+
className?: string; // Additional CSS classes
|
|
371
|
+
icon_size?: number; // Button size in pixels (default: 28)
|
|
372
|
+
show_border?: boolean; // Show border around button (default: true)
|
|
360
373
|
}
|
|
361
374
|
```
|
|
362
375
|
|
|
376
|
+
**Note:** The component bundles Radix UI primitives internally. No UI component props are required.
|
|
377
|
+
|
|
363
378
|
## Hooks API
|
|
364
379
|
|
|
365
380
|
### use_notes
|
|
@@ -601,42 +616,25 @@ Each note entry in the JSONB array:
|
|
|
601
616
|
|
|
602
617
|
## Troubleshooting
|
|
603
618
|
|
|
604
|
-
### Notes icon doesn't
|
|
605
|
-
|
|
606
|
-
**Problem**: Icon renders but clicking shows "Notes unavailable - pass popover_components prop" tooltip.
|
|
619
|
+
### Notes icon doesn't render
|
|
607
620
|
|
|
608
|
-
**
|
|
621
|
+
**Problem**: The HazoNotesIcon component doesn't appear.
|
|
609
622
|
|
|
610
|
-
**
|
|
623
|
+
**Possible Causes**:
|
|
624
|
+
1. Missing `ref_id` prop - The component requires a valid `ref_id` and will not render without one
|
|
625
|
+
2. `disabled={true}` is set
|
|
626
|
+
3. Tailwind CSS is not configured
|
|
611
627
|
|
|
628
|
+
**Solution**:
|
|
612
629
|
```tsx
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
const popover_components = { Popover, PopoverTrigger, PopoverContent };
|
|
616
|
-
|
|
617
|
-
<HazoNotesIcon
|
|
618
|
-
ref_id="my-notes"
|
|
619
|
-
popover_components={popover_components} // Required!
|
|
620
|
-
/>
|
|
621
|
-
```
|
|
622
|
-
|
|
623
|
-
For slide panel style, use `sheet_components` instead:
|
|
624
|
-
```tsx
|
|
625
|
-
import { Sheet, SheetTrigger, SheetContent } from '@/components/ui/sheet';
|
|
626
|
-
|
|
627
|
-
const sheet_components = { Sheet, SheetTrigger, SheetContent };
|
|
628
|
-
|
|
630
|
+
// Check that ref_id is provided and valid
|
|
629
631
|
<HazoNotesIcon
|
|
630
|
-
ref_id="my-
|
|
631
|
-
|
|
632
|
-
sheet_components={sheet_components}
|
|
632
|
+
ref_id="my-field-123" // Required - must be a non-empty string
|
|
633
|
+
label="My Notes"
|
|
633
634
|
/>
|
|
634
635
|
```
|
|
635
636
|
|
|
636
|
-
|
|
637
|
-
```bash
|
|
638
|
-
npm install @radix-ui/react-popover @radix-ui/react-dialog
|
|
639
|
-
```
|
|
637
|
+
In development, a console warning will appear if `ref_id` is missing.
|
|
640
638
|
|
|
641
639
|
### User shows as "Unknown User"
|
|
642
640
|
|
package/SETUP_CHECKLIST.md
CHANGED
|
@@ -21,13 +21,12 @@ npm install hazo_notes
|
|
|
21
21
|
### 2. Install peer dependencies (if not already installed)
|
|
22
22
|
|
|
23
23
|
```bash
|
|
24
|
-
# Required UI components
|
|
25
|
-
npm install @radix-ui/react-popover @radix-ui/react-dialog react-icons
|
|
26
|
-
|
|
27
24
|
# Optional but recommended
|
|
28
|
-
npm install hazo_connect hazo_auth hazo_logs
|
|
25
|
+
npm install hazo_connect hazo_auth hazo_logs react-icons
|
|
29
26
|
```
|
|
30
27
|
|
|
28
|
+
**Note:** Radix UI primitives (`@radix-ui/react-popover` and `@radix-ui/react-dialog`) are bundled with this package. You don't need to install them separately.
|
|
29
|
+
|
|
31
30
|
## Database Setup
|
|
32
31
|
|
|
33
32
|
### 3. Create the database table
|
|
@@ -215,15 +214,10 @@ logfile = logs/hazo_notes.log
|
|
|
215
214
|
|
|
216
215
|
### 8. Add the HazoNotesIcon component
|
|
217
216
|
|
|
218
|
-
|
|
217
|
+
The component bundles its own Radix UI primitives, so no additional UI component setup is required.
|
|
219
218
|
|
|
220
219
|
```tsx
|
|
221
220
|
import { HazoNotesIcon } from 'hazo_notes';
|
|
222
|
-
// Import your shadcn/ui popover components
|
|
223
|
-
import { Popover, PopoverTrigger, PopoverContent } from '@/components/ui/popover';
|
|
224
|
-
|
|
225
|
-
// Create the components object once
|
|
226
|
-
const popover_components = { Popover, PopoverTrigger, PopoverContent };
|
|
227
221
|
|
|
228
222
|
function MyComponent() {
|
|
229
223
|
return (
|
|
@@ -232,24 +226,19 @@ function MyComponent() {
|
|
|
232
226
|
<HazoNotesIcon
|
|
233
227
|
ref_id="customer-info-section"
|
|
234
228
|
label="Customer Information"
|
|
235
|
-
popover_components={popover_components} // Required!
|
|
236
229
|
/>
|
|
237
230
|
</div>
|
|
238
231
|
);
|
|
239
232
|
}
|
|
240
233
|
```
|
|
241
234
|
|
|
242
|
-
For slide panel style,
|
|
235
|
+
For slide panel style, just set the `panel_style` prop:
|
|
243
236
|
|
|
244
237
|
```tsx
|
|
245
|
-
import { Sheet, SheetTrigger, SheetContent } from '@/components/ui/sheet';
|
|
246
|
-
|
|
247
|
-
const sheet_components = { Sheet, SheetTrigger, SheetContent };
|
|
248
|
-
|
|
249
238
|
<HazoNotesIcon
|
|
250
239
|
ref_id="field-id"
|
|
240
|
+
label="Field Notes"
|
|
251
241
|
panel_style="slide_panel"
|
|
252
|
-
sheet_components={sheet_components} // Required for slide_panel!
|
|
253
242
|
/>
|
|
254
243
|
```
|
|
255
244
|
|
|
@@ -261,7 +250,6 @@ You can override config file settings via component props:
|
|
|
261
250
|
<HazoNotesIcon
|
|
262
251
|
ref_id="field-123"
|
|
263
252
|
label="Customer Notes"
|
|
264
|
-
popover_components={popover_components} // Required!
|
|
265
253
|
|
|
266
254
|
// UI configuration overrides
|
|
267
255
|
panel_style="slide_panel" // 'popover' | 'slide_panel'
|
|
@@ -279,6 +267,8 @@ You can override config file settings via component props:
|
|
|
279
267
|
on_close={() => console.log('Notes closed')}
|
|
280
268
|
|
|
281
269
|
// Styling
|
|
270
|
+
icon_size={24} // Button size in pixels
|
|
271
|
+
show_border={false} // Hide border for inline usage
|
|
282
272
|
className="ml-2"
|
|
283
273
|
/>
|
|
284
274
|
```
|
|
@@ -413,30 +403,22 @@ After setup, verify everything works:
|
|
|
413
403
|
## Troubleshooting
|
|
414
404
|
|
|
415
405
|
### Notes icon doesn't appear
|
|
416
|
-
- Check that Tailwind CSS is configured
|
|
417
|
-
- Verify `@radix-ui/react-popover` or `@radix-ui/react-dialog` is installed
|
|
418
|
-
- Check browser console for import errors
|
|
419
|
-
|
|
420
|
-
### Notes icon doesn't open panel (shows "Notes unavailable" tooltip)
|
|
421
|
-
This is the most common issue. The component cannot auto-import UI components across package boundaries.
|
|
422
406
|
|
|
423
|
-
**
|
|
407
|
+
**Possible Causes**:
|
|
408
|
+
1. Missing `ref_id` prop - The component requires a valid `ref_id` and will not render without one
|
|
409
|
+
2. `disabled={true}` is set
|
|
410
|
+
3. Tailwind CSS is not configured
|
|
424
411
|
|
|
412
|
+
**Solution**:
|
|
425
413
|
```tsx
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
const popover_components = { Popover, PopoverTrigger, PopoverContent };
|
|
429
|
-
|
|
414
|
+
// Check that ref_id is provided and valid
|
|
430
415
|
<HazoNotesIcon
|
|
431
|
-
ref_id="my-
|
|
432
|
-
|
|
416
|
+
ref_id="my-field-123" // Required - must be a non-empty string
|
|
417
|
+
label="My Notes"
|
|
433
418
|
/>
|
|
434
419
|
```
|
|
435
420
|
|
|
436
|
-
|
|
437
|
-
- UI components are installed: `npm install @radix-ui/react-popover @radix-ui/react-dialog`
|
|
438
|
-
- You have shadcn/ui components at `@/components/ui/popover` (or your equivalent path)
|
|
439
|
-
- For slide_panel style, use `sheet_components` with Sheet components instead
|
|
421
|
+
In development, a console warning will appear if `ref_id` is missing.
|
|
440
422
|
|
|
441
423
|
### Notes not saving
|
|
442
424
|
- Check that `getUserIdFromRequest` returns a valid user ID
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create_notes_handler.d.ts","sourceRoot":"","sources":["../../src/api/create_notes_handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,KAAK,EACV,yBAAyB,EAIzB,gBAAgB,EAChB,kBAAkB,EAEnB,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"create_notes_handler.d.ts","sourceRoot":"","sources":["../../src/api/create_notes_handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,KAAK,EACV,yBAAyB,EAIzB,gBAAgB,EAChB,kBAAkB,EAEnB,MAAM,mBAAmB,CAAC;AA2C3B;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,yBAAyB;mBAWxD,OAAO,WACP;QAAE,MAAM,EAAE,OAAO,CAAC;YAAE,MAAM,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KAAE,KAC/C,OAAO,CAAC,YAAY,CAAC,gBAAgB,CAAC,CAAC;oBAoE/B,OAAO,WACP;QAAE,MAAM,EAAE,OAAO,CAAC;YAAE,MAAM,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KAAE,KAC/C,OAAO,CAAC,YAAY,CAAC,kBAAkB,CAAC,CAAC;EAkJ7C"}
|
|
@@ -40,11 +40,7 @@ const DEFAULT_MAX_FILES_PER_NOTE = 5;
|
|
|
40
40
|
// ============================================================================
|
|
41
41
|
/** Generate a UUID v4 */
|
|
42
42
|
function generateUUID() {
|
|
43
|
-
return
|
|
44
|
-
const r = (Math.random() * 16) | 0;
|
|
45
|
-
const v = c === 'x' ? r : (r & 0x3) | 0x8;
|
|
46
|
-
return v.toString(16);
|
|
47
|
-
});
|
|
43
|
+
return crypto.randomUUID();
|
|
48
44
|
}
|
|
49
45
|
/** Create a standardized error response */
|
|
50
46
|
function createErrorResponse(error, status) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create_notes_handler.js","sourceRoot":"","sources":["../../src/api/create_notes_handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAW3C,+EAA+E;AAC/E,YAAY;AACZ,+EAA+E;AAE/E,6CAA6C;AAC7C,MAAM,oBAAoB,GAAG,KAAK,CAAC;AAEnC,6BAA6B;AAC7B,MAAM,0BAA0B,GAAG,CAAC,CAAC;AAErC,+EAA+E;AAC/E,mBAAmB;AACnB,+EAA+E;AAE/E,yBAAyB;AACzB,SAAS,YAAY;IACnB,OAAO,
|
|
1
|
+
{"version":3,"file":"create_notes_handler.js","sourceRoot":"","sources":["../../src/api/create_notes_handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAW3C,+EAA+E;AAC/E,YAAY;AACZ,+EAA+E;AAE/E,6CAA6C;AAC7C,MAAM,oBAAoB,GAAG,KAAK,CAAC;AAEnC,6BAA6B;AAC7B,MAAM,0BAA0B,GAAG,CAAC,CAAC;AAErC,+EAA+E;AAC/E,mBAAmB;AACnB,+EAA+E;AAE/E,yBAAyB;AACzB,SAAS,YAAY;IACnB,OAAO,MAAM,CAAC,UAAU,EAAE,CAAC;AAC7B,CAAC;AAED,2CAA2C;AAC3C,SAAS,mBAAmB,CAC1B,KAAa,EACb,MAAc;IAEd,OAAO,YAAY,CA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AG,QAAQ;gBACX,SAAS,EAAE,OAAO,EAAE,IAAI,IAAI,cAAc;gBAC1C,UAAU,EAAE,OAAO,EAAE,KAAK,IAAI,EAAE;gBAChC,WAAW,EAAE,OAAO,EAAE,aAAa;aACpC,CAAC;YAEF,OAAO,YAAY,CAAC,IAAI,CAAC;gBACvB,OAAO,EAAE,IAAI;gBACb,IAAI,EAAE,aAAa;gBACnB,UAAU,EAAE,aAAa;aAC1B,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,KAAK,CAAC,yBAAyB,EAAE;gBACtC,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;aAC9D,CAAC,CAAC;YACH,OAAO,YAAY,CAAC,IAAI,CACtB,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,oBAAoB,EAAE,EAC/C,EAAE,MAAM,EAAE,GAAG,EAAE,CAChB,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC;AACvB,CAAC"}
|
|
@@ -2,5 +2,5 @@ import type { HazoNotesEntryProps } from '../types/index.js';
|
|
|
2
2
|
/**
|
|
3
3
|
* Single note entry display component
|
|
4
4
|
*/
|
|
5
|
-
export declare function HazoNotesEntry({ note, ProfileStampComponent }: HazoNotesEntryProps): import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
export declare function HazoNotesEntry({ note, ProfileStampComponent, background_color }: HazoNotesEntryProps): import("react/jsx-runtime").JSX.Element;
|
|
6
6
|
//# sourceMappingURL=hazo_notes_entry.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hazo_notes_entry.d.ts","sourceRoot":"","sources":["../../src/components/hazo_notes_entry.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"hazo_notes_entry.d.ts","sourceRoot":"","sources":["../../src/components/hazo_notes_entry.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAuB7D;;GAEG;AACH,wBAAgB,cAAc,CAAC,EAAE,IAAI,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,EAAE,mBAAmB,2CAqEpG"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { cn } from '../utils/cn.js';
|
|
3
4
|
import { render_note_with_files } from './hazo_notes_file_preview.js';
|
|
5
|
+
import { get_initials, get_avatar_color } from '../utils/avatar_utils.js';
|
|
6
|
+
import { get_theme_classes } from '../utils/theme_utils.js';
|
|
4
7
|
/**
|
|
5
8
|
* Format timestamp for display
|
|
6
9
|
*/
|
|
@@ -18,40 +21,12 @@ function format_timestamp(iso_timestamp) {
|
|
|
18
21
|
return iso_timestamp;
|
|
19
22
|
}
|
|
20
23
|
}
|
|
21
|
-
/**
|
|
22
|
-
* Get initials from name for avatar
|
|
23
|
-
*/
|
|
24
|
-
function get_initials(name) {
|
|
25
|
-
if (!name)
|
|
26
|
-
return '??';
|
|
27
|
-
const parts = name.trim().split(/\s+/);
|
|
28
|
-
if (parts.length >= 2) {
|
|
29
|
-
return (parts[0][0] + parts[parts.length - 1][0]).toUpperCase();
|
|
30
|
-
}
|
|
31
|
-
return name.substring(0, 2).toUpperCase();
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Generate consistent hex color from name for avatar background
|
|
35
|
-
*/
|
|
36
|
-
function get_avatar_color(name) {
|
|
37
|
-
const colors = [
|
|
38
|
-
'#ef4444', '#f97316', '#d97706', '#22c55e',
|
|
39
|
-
'#14b8a6', '#3b82f6', '#6366f1', '#a855f7',
|
|
40
|
-
'#ec4899', '#f43f5e',
|
|
41
|
-
];
|
|
42
|
-
if (!name)
|
|
43
|
-
return colors[0]; // default to first color
|
|
44
|
-
let hash = 0;
|
|
45
|
-
for (let i = 0; i < name.length; i++) {
|
|
46
|
-
hash = name.charCodeAt(i) + ((hash << 5) - hash);
|
|
47
|
-
}
|
|
48
|
-
return colors[Math.abs(hash) % colors.length];
|
|
49
|
-
}
|
|
50
24
|
/**
|
|
51
25
|
* Single note entry display component
|
|
52
26
|
*/
|
|
53
|
-
export function HazoNotesEntry({ note, ProfileStampComponent }) {
|
|
27
|
+
export function HazoNotesEntry({ note, ProfileStampComponent, background_color }) {
|
|
54
28
|
const { user_name, user_avatar, created_at, note_text, note_files } = note;
|
|
29
|
+
const theme = get_theme_classes(background_color ?? '');
|
|
55
30
|
// Render avatar
|
|
56
31
|
const render_avatar = () => {
|
|
57
32
|
if (ProfileStampComponent) {
|
|
@@ -69,6 +44,6 @@ export function HazoNotesEntry({ note, ProfileStampComponent }) {
|
|
|
69
44
|
color: '#ffffff',
|
|
70
45
|
}, title: display_name, children: get_initials(user_name) }));
|
|
71
46
|
};
|
|
72
|
-
return (_jsxs("div", { className: "cls_hazo_notes_entry p-3", children: [_jsxs("div", { className: "flex items-center gap-2 mb-2", children: [render_avatar(), !ProfileStampComponent && (_jsx("span", { className:
|
|
47
|
+
return (_jsxs("div", { className: "cls_hazo_notes_entry p-3", children: [_jsxs("div", { className: "flex items-center gap-2 mb-2", children: [render_avatar(), !ProfileStampComponent && (_jsx("span", { className: cn('text-xs flex-shrink-0', theme.text_secondary), children: format_timestamp(created_at) }))] }), _jsx("div", { className: "cls_hazo_notes_entry_content ml-9 overflow-hidden", children: _jsx("div", { className: cn('w-full min-h-[40px] rounded-md border px-3 py-2 text-sm overflow-hidden', theme.border_accent, theme.text_primary), style: { backgroundColor: theme.content_bg }, children: render_note_with_files(note_text, note_files, background_color) }) })] }));
|
|
73
48
|
}
|
|
74
49
|
//# sourceMappingURL=hazo_notes_entry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hazo_notes_entry.js","sourceRoot":"","sources":["../../src/components/hazo_notes_entry.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAUb,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"hazo_notes_entry.js","sourceRoot":"","sources":["../../src/components/hazo_notes_entry.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAUb,OAAO,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AACpC,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D;;GAEG;AACH,SAAS,gBAAgB,CAAC,aAAqB;IAC7C,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,aAAa,CAAC,CAAC;QACrC,OAAO,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE;YAClC,KAAK,EAAE,OAAO;YACd,GAAG,EAAE,SAAS;YACd,IAAI,EAAE,SAAS;YACf,MAAM,EAAE,SAAS;SAClB,CAAC,CAAC;IACL,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,aAAa,CAAC;IACvB,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,EAAE,IAAI,EAAE,qBAAqB,EAAE,gBAAgB,EAAuB;IACnG,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC;IAC3E,MAAM,KAAK,GAAG,iBAAiB,CAAC,gBAAgB,IAAI,EAAE,CAAC,CAAC;IAExD,gBAAgB;IAChB,MAAM,aAAa,GAAG,GAAG,EAAE;QACzB,IAAI,qBAAqB,EAAE,CAAC;YAC1B,MAAM,aAAa,GAAG,CAAC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CACP,CAAC;AACJ,CAAC"}
|
|
@@ -8,9 +8,9 @@ import type { HazoNotesFilePreviewProps, NoteFile } from '../types/index.js';
|
|
|
8
8
|
/**
|
|
9
9
|
* Render a file preview based on display mode and file type
|
|
10
10
|
*/
|
|
11
|
-
export declare function HazoNotesFilePreview({ file, display_mode, }: HazoNotesFilePreviewProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export declare function HazoNotesFilePreview({ file, display_mode, background_color, }: HazoNotesFilePreviewProps): import("react/jsx-runtime").JSX.Element;
|
|
12
12
|
/**
|
|
13
13
|
* Parse note text and render with inline file previews
|
|
14
14
|
*/
|
|
15
|
-
export declare function render_note_with_files(note_text: string, note_files?: NoteFile[]): React.ReactNode;
|
|
15
|
+
export declare function render_note_with_files(note_text: string, note_files?: NoteFile[], background_color?: string): React.ReactNode;
|
|
16
16
|
//# sourceMappingURL=hazo_notes_file_preview.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hazo_notes_file_preview.d.ts","sourceRoot":"","sources":["../../src/components/hazo_notes_file_preview.tsx"],"names":[],"mappings":"AAEA;;;;GAIG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,yBAAyB,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"hazo_notes_file_preview.d.ts","sourceRoot":"","sources":["../../src/components/hazo_notes_file_preview.tsx"],"names":[],"mappings":"AAEA;;;;GAIG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,yBAAyB,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAK7E;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,EACnC,IAAI,EACJ,YAAY,EACZ,gBAAgB,GACjB,EAAE,yBAAyB,2CAiD3B;AA8CD;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,MAAM,EACjB,UAAU,CAAC,EAAE,QAAQ,EAAE,EACvB,gBAAgB,CAAC,EAAE,MAAM,GACxB,KAAK,CAAC,SAAS,CAwDjB"}
|
|
@@ -2,22 +2,24 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { cn } from '../utils/cn.js';
|
|
4
4
|
import { format_file_size, is_image_file } from '../utils/file_utils.js';
|
|
5
|
+
import { get_theme_classes } from '../utils/theme_utils.js';
|
|
5
6
|
/**
|
|
6
7
|
* Render a file preview based on display mode and file type
|
|
7
8
|
*/
|
|
8
|
-
export function HazoNotesFilePreview({ file, display_mode, }) {
|
|
9
|
+
export function HazoNotesFilePreview({ file, display_mode, background_color, }) {
|
|
10
|
+
const theme = get_theme_classes(background_color ?? '');
|
|
9
11
|
const is_image = is_image_file(file.filename);
|
|
10
12
|
// For embedded images
|
|
11
13
|
if (display_mode === 'embed' && is_image) {
|
|
12
14
|
const src = file.filedata.startsWith('/')
|
|
13
15
|
? file.filedata // Filesystem path
|
|
14
16
|
: `data:${file.mime_type || 'image/png'};base64,${file.filedata}`; // Base64
|
|
15
|
-
return (_jsxs("div", { className: "cls_hazo_notes_file_embed my-2", children: [_jsx("img", { src: src, alt: file.filename, className:
|
|
17
|
+
return (_jsxs("div", { className: "cls_hazo_notes_file_embed my-2", children: [_jsx("img", { src: src, alt: file.filename, className: cn('max-w-full max-h-64 rounded-md border', theme.border), loading: "lazy" }), _jsx("p", { className: cn('text-xs mt-1', theme.text_secondary), children: file.filename })] }));
|
|
16
18
|
}
|
|
17
19
|
// For attachments or non-image embeds
|
|
18
20
|
return (_jsx("div", { className: "cls_hazo_notes_file_attachment my-2 overflow-hidden", children: _jsxs("a", { href: file.filedata.startsWith('/')
|
|
19
21
|
? file.filedata
|
|
20
|
-
: `data:${file.mime_type || 'application/octet-stream'};base64,${file.filedata}`, download: file.filename, className: cn('flex items-center gap-2 px-3 py-2 rounded-md text-sm max-w-full',
|
|
22
|
+
: `data:${file.mime_type || 'application/octet-stream'};base64,${file.filedata}`, download: file.filename, className: cn('flex items-center gap-2 px-3 py-2 rounded-md text-sm max-w-full', theme.file_bg, theme.file_bg_hover, theme.file_text, 'border', theme.border_accent, 'transition-colors'), children: [_jsx(FileIcon, { mime_type: file.mime_type }), _jsx("span", { className: "font-medium truncate min-w-0 flex-1", children: file.filename }), file.file_size && (_jsxs("span", { className: cn(theme.text_secondary, 'text-xs whitespace-nowrap flex-shrink-0'), children: ["(", format_file_size(file.file_size), ")"] }))] }) }));
|
|
21
23
|
}
|
|
22
24
|
/**
|
|
23
25
|
* File icon based on MIME type
|
|
@@ -38,7 +40,7 @@ function FileIcon({ mime_type }) {
|
|
|
38
40
|
/**
|
|
39
41
|
* Parse note text and render with inline file previews
|
|
40
42
|
*/
|
|
41
|
-
export function render_note_with_files(note_text, note_files) {
|
|
43
|
+
export function render_note_with_files(note_text, note_files, background_color) {
|
|
42
44
|
if (!note_files || note_files.length === 0) {
|
|
43
45
|
return note_text;
|
|
44
46
|
}
|
|
@@ -60,11 +62,11 @@ export function render_note_with_files(note_text, note_files) {
|
|
|
60
62
|
const [, type, file_no] = match;
|
|
61
63
|
const file = file_map.get(file_no);
|
|
62
64
|
if (file) {
|
|
63
|
-
parts.push(_jsx(HazoNotesFilePreview, { file: file, display_mode: type }, key++));
|
|
65
|
+
parts.push(_jsx(HazoNotesFilePreview, { file: file, display_mode: type, background_color: background_color }, key++));
|
|
64
66
|
}
|
|
65
67
|
else {
|
|
66
68
|
// File not found - show placeholder
|
|
67
|
-
parts.push(_jsxs("span", { className:
|
|
69
|
+
parts.push(_jsxs("span", { className: cn(get_theme_classes(background_color ?? '').text_muted, 'italic'), children: ["[File not found: ", file_no, "]"] }, key++));
|
|
68
70
|
}
|
|
69
71
|
last_index = match.index + match[0].length;
|
|
70
72
|
}
|