mgv-backoffice 1.35.0 → 1.36.1

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 (62) hide show
  1. package/README.md +1794 -1686
  2. package/dist/components/BaseBarDistribution.vue.d.ts +24 -0
  3. package/dist/components/BasePageHeader.vue.d.ts +8 -2
  4. package/dist/index.d.ts +2 -0
  5. package/dist/types/distribution.d.ts +7 -0
  6. package/dist/ui-lib.css +1 -1
  7. package/dist/ui-lib.js +634 -574
  8. package/dist/ui-lib.umd.cjs +1 -1
  9. package/dist/utils/specForm.d.ts +1 -1
  10. package/package.json +54 -54
  11. package/src/components/BaseAlert.vue +104 -104
  12. package/src/components/BaseBarDistribution.test.ts +51 -0
  13. package/src/components/BaseBarDistribution.vue +73 -0
  14. package/src/components/BaseChipButton.vue +42 -42
  15. package/src/components/BaseCodeBlock.test.ts +70 -70
  16. package/src/components/BaseCodeBlock.vue +74 -74
  17. package/src/components/BaseCollapsibleSection.vue +113 -113
  18. package/src/components/BaseConfirmModal.vue +114 -114
  19. package/src/components/BaseCredentialsForm.test.ts +108 -108
  20. package/src/components/BaseCredentialsForm.vue +241 -241
  21. package/src/components/BaseDropdown.test.ts +87 -87
  22. package/src/components/BaseDropdown.vue +172 -172
  23. package/src/components/BaseEntityPickerModal.vue +330 -330
  24. package/src/components/BaseFileDropzone.vue +94 -94
  25. package/src/components/BaseFilterChip.test.ts +44 -44
  26. package/src/components/BaseFilterChip.vue +67 -67
  27. package/src/components/BaseModalShell.vue +209 -209
  28. package/src/components/BasePageHeader.vue +120 -103
  29. package/src/components/BasePillPickerModal.test.ts +95 -95
  30. package/src/components/BaseRemoveButton.vue +22 -22
  31. package/src/components/BaseSpecFields.test.ts +39 -0
  32. package/src/components/BaseSpecFields.vue +27 -3
  33. package/src/components/BaseStatBreakdown.test.ts +56 -56
  34. package/src/components/BaseStatBreakdown.vue +49 -49
  35. package/src/components/BaseStatusPill.vue +54 -54
  36. package/src/components/BaseTextInputModal.vue +140 -140
  37. package/src/components/BaseToolbarButton.test.ts +48 -48
  38. package/src/components/BaseToolbarButton.vue +94 -94
  39. package/src/composables/useFieldClasses.test.ts +55 -55
  40. package/src/composables/useFieldClasses.ts +56 -56
  41. package/src/composables/usePolling.test.ts +112 -112
  42. package/src/composables/usePolling.ts +102 -90
  43. package/src/composables/useQueryParamSync.test.ts +56 -56
  44. package/src/composables/useQueryParamSync.ts +42 -42
  45. package/src/composables/useThemeClasses.test.ts +34 -34
  46. package/src/composables/useThemeClasses.ts +137 -137
  47. package/src/index.ts +138 -136
  48. package/src/style.css +32 -32
  49. package/src/types/distribution.ts +7 -0
  50. package/src/types/pillPicker.ts +14 -14
  51. package/src/types/specField.ts +30 -30
  52. package/src/types/statBreakdown.ts +6 -6
  53. package/src/utils/format.test.ts +264 -264
  54. package/src/utils/format.ts +216 -216
  55. package/src/utils/httpColors.test.ts +100 -100
  56. package/src/utils/httpColors.ts +99 -99
  57. package/src/utils/kvRows.test.ts +47 -47
  58. package/src/utils/kvRows.ts +34 -34
  59. package/src/utils/specForm.test.ts +64 -53
  60. package/src/utils/specForm.ts +49 -48
  61. package/src/utils/validate.test.ts +82 -82
  62. package/src/utils/validate.ts +76 -76
package/README.md CHANGED
@@ -1,1686 +1,1794 @@
1
- # mgv-backoffice
2
-
3
- Shared Vue 3 UI component library built with TypeScript and Tailwind CSS.
4
-
5
- ## Installation
6
-
7
- ```bash
8
- npm install mgv-backoffice
9
- ```
10
-
11
- ### Peer Dependencies
12
-
13
- These must be installed in your project:
14
-
15
- ```bash
16
- npm install vue@^3.5.0 vue-router@^5.0.0 @heroicons/vue@^2.0.0
17
- ```
18
-
19
- > `vue-router` 5.x is required (peer range `^5.0.0`) — it's what the library is
20
- > developed and tested against. Upgrade from Router 4 before installing this library.
21
-
22
- ### Import Styles
23
-
24
- Include the library's stylesheet in your app entry point:
25
-
26
- ```ts
27
- import 'mgv-backoffice/dist/style.css'
28
- ```
29
-
30
- ### Tailwind Safelist
31
-
32
- If your project uses Tailwind, import the safelist so dynamic classes used by this library are generated correctly:
33
-
34
- ```js
35
- // In your Tailwind config
36
- import safelist from 'mgv-backoffice/tailwind.safelist'
37
- ```
38
-
39
- Or include the pre-built CSS safelist:
40
-
41
- ```css
42
- @import 'mgv-backoffice/tailwind.safelist.css';
43
- ```
44
-
45
- > Maintainers: `tailwind.safelist.js` is the single source of truth.
46
- > `tailwind.safelist.css` is generated from it via `npm run safelist`
47
- > (runs automatically before `npm run build`) — don't edit it by hand.
48
-
49
- ---
50
-
51
- ## Components
52
-
53
- ### BaseAlert
54
-
55
- Inline notice panel with color-coded variants (error / warning / success /
56
- info), theme-aware via the shared `isDark` ref. The optional default slot
57
- renders body content under the title, and `compact` gives a slim text-xs
58
- variant for in-form warnings.
59
-
60
- **Props:**
61
-
62
- | Prop | Type | Default | Description |
63
- | --------- | ----------- | ------------------ | ------------------------ |
64
- | `title` | `String` | `''` | Bold headline (optional when the slot carries the message). |
65
- | `color` | `AlertEnum` | `AlertEnum.ERROR` | Alert color variant. |
66
- | `compact` | `Boolean` | `false` | Slim variant: text-xs, smaller icon/padding. |
67
-
68
- **Slots:** default — body content rendered under the title.
69
-
70
- **Example:**
71
-
72
- ```vue
73
- <template>
74
- <BaseAlert title="Operation successful" :color="AlertEnum.SUCCESS" />
75
- <BaseAlert title="Proxying is active." :color="AlertEnum.WARNING">
76
- <p class="mt-0.5 text-xs opacity-90">The canned response below is ignored.</p>
77
- </BaseAlert>
78
- <BaseAlert compact :color="AlertEnum.WARNING">
79
- Chunked dribble is ignored while Fault Simulation is active.
80
- </BaseAlert>
81
- </template>
82
-
83
- <script setup lang="ts">
84
- import { BaseAlert, AlertEnum } from 'mgv-backoffice'
85
- </script>
86
- ```
87
-
88
- ---
89
-
90
- ### BaseBadge
91
-
92
- Colored status badge/pill.
93
-
94
- **Props:**
95
-
96
- | Prop | Type | Default | Description |
97
- | ------- | -------- | ------- | --------------------------------- |
98
- | `color` | `String` | | Color variant (use `ColorsEnums`) |
99
-
100
- **Slots:** `default` — badge label content.
101
-
102
- **Example:**
103
-
104
- ```vue
105
- <template>
106
- <BaseBadge :color="ColorsEnums.GREEN">Active</BaseBadge>
107
- <BaseBadge :color="ColorsEnums.RED">Inactive</BaseBadge>
108
- </template>
109
-
110
- <script setup lang="ts">
111
- import { BaseBadge, ColorsEnums } from 'mgv-backoffice'
112
- </script>
113
- ```
114
-
115
- ---
116
-
117
- ### BaseBreadcrumb
118
-
119
- Breadcrumb navigation. Provide items manually or pass a URL path for auto-generation.
120
-
121
- **Props:**
122
-
123
- | Prop | Type | Default | Description |
124
- | ------- | --------------- | ----------- | ------------------------------------------ |
125
- | `items` | `BreadCrumb[]` | `undefined` | Manual breadcrumb entries |
126
- | `path` | `String` | `undefined` | URL path for auto-generated breadcrumbs |
127
-
128
- **BreadCrumb type:**
129
-
130
- ```ts
131
- interface BreadCrumb {
132
- name: string
133
- url: string
134
- }
135
- ```
136
-
137
- **Example:**
138
-
139
- ```vue
140
- <template>
141
- <!-- Manual -->
142
- <BaseBreadcrumb :items="[
143
- { name: 'Home', url: '/' },
144
- { name: 'Users', url: '/users' },
145
- { name: 'Profile', url: '/users/1' }
146
- ]" />
147
-
148
- <!-- Auto-generated from path -->
149
- <BaseBreadcrumb path="/users/settings/profile" />
150
- </template>
151
-
152
- <script setup lang="ts">
153
- import { BaseBreadcrumb } from 'mgv-backoffice'
154
- import type { BreadCrumb } from 'mgv-backoffice'
155
- </script>
156
- ```
157
-
158
- ---
159
-
160
- ### BaseButton
161
-
162
- Button with color, size, loading state, and Vue Router integration.
163
-
164
- **Props:**
165
-
166
- | Prop | Type | Default | Description |
167
- | ------------- | ----------------------------------- | --------------------- | ------------------------------------ |
168
- | `description` | `String` | **required** | Button label text |
169
- | `color` | `String` | `BaseButtonEnum.BLUE` | Color variant (`BLUE`/`WHITE`/`DARK`/`GREEN`/`EMERALD`/`RED`/`YELLOW`/`PURPLE`/`SKY`/`GRAY`/`AMBER`) |
170
- | `outline` | `Boolean` | `false` | Outlined/secondary style transparent fill, coloured text + border, tinted hover (theme-aware) |
171
- | `ghost` | `Boolean` | `false` | Ghost/borderless style — no border or fill, coloured text + tinted hover (theme-aware). For compact toolbar/action buttons |
172
- | `to` | `String` | | Vue Router path (renders `<router-link>`) |
173
- | `type` | `'button' \| 'submit' \| 'reset'` | `'button'` | HTML button type |
174
- | `iconLeft` | `Boolean` | `false` | Render the slot icon before the label |
175
- | `isRounded` | `Boolean` | — | Fully rounded corners |
176
- | `isDisable` | `Boolean` | | Disabled state |
177
- | `size` | `String` | | Size variant (use `BaseButtonSizeEnum`) |
178
- | `isLoading` | `Boolean` | — | Show loading spinner |
179
-
180
- **Slots:** `default`
181
-
182
- **Example:**
183
-
184
- ```vue
185
- <template>
186
- <BaseButton description="Submit" :color="BaseButtonEnum.GREEN" type="submit" />
187
- <BaseButton description="Go to Users" :to="'/users'" />
188
- <BaseButton description="Saving..." :isLoading="true" :isDisable="true" />
189
- <BaseButton
190
- description="Delete"
191
- :color="BaseButtonEnum.RED"
192
- :size="BaseButtonSizeEnum.SMALL"
193
- />
194
- <!-- Outlined / secondary -->
195
- <BaseButton description="Import" :color="BaseButtonEnum.EMERALD" outline iconLeft>
196
- <ArrowUpTrayIcon class="w-4 h-4 mr-1.5" />
197
- </BaseButton>
198
- <!-- Ghost / borderless toolbar action -->
199
- <BaseButton description="Logs" :color="BaseButtonEnum.SKY" ghost iconLeft :size="BaseButtonSizeEnum.SMALL">
200
- <ClipboardDocumentListIcon class="w-4 h-4 mr-1.5" />
201
- </BaseButton>
202
- </template>
203
-
204
- <script setup lang="ts">
205
- import { BaseButton, BaseButtonEnum, BaseButtonSizeEnum } from 'mgv-backoffice'
206
- </script>
207
- ```
208
-
209
- ---
210
-
211
- ### BaseLine
212
-
213
- Horizontal divider with style variants.
214
-
215
- **Props:**
216
-
217
- | Prop | Type | Default | Description |
218
- | ------ | -------- | --------------- | ----------------- |
219
- | `mode` | `String` | `LineEnum.BASE` | Divider style |
220
-
221
- **Example:**
222
-
223
- ```vue
224
- <template>
225
- <BaseLine />
226
- <BaseLine :mode="LineEnum.SQUARE" />
227
- </template>
228
-
229
- <script setup lang="ts">
230
- import { BaseLine, LineEnum } from 'mgv-backoffice'
231
- </script>
232
- ```
233
-
234
- ---
235
-
236
- ### BaseLogo
237
-
238
- SVG brand logo component.
239
-
240
- **Props:**
241
-
242
- | Prop | Type | Default | Description |
243
- | ------ | -------- | ---------------------- | ------------ |
244
- | `size` | `String` | `BaseLogoEnum.MEDIUM` | Logo size |
245
-
246
- **Example:**
247
-
248
- ```vue
249
- <template>
250
- <BaseLogo :size="BaseLogoEnum.LARGE" />
251
- </template>
252
-
253
- <script setup lang="ts">
254
- import { BaseLogo, BaseLogoEnum } from 'mgv-backoffice'
255
- </script>
256
- ```
257
-
258
- ---
259
-
260
- ### BaseModal
261
-
262
- > ⚠️ **Deprecated.** Prefer [`BaseConfirmModal`](#baseconfirmmodal) for confirm/cancel
263
- > flows or [`BaseModalShell`](#basemodalshell) for custom dialogs — they support dark
264
- > mode, teleport to `<body>`, and slot-based composition. Kept for backward
265
- > compatibility.
266
-
267
- Confirmation dialog with support for delete and success modes. `DELETE` mode renders
268
- the confirm/cancel pair; any other mode renders the title, optional `description`,
269
- the default slot, and a single OK button that emits `closeModal`.
270
-
271
- **Props:**
272
-
273
- | Prop | Type | Default | Description |
274
- | ------------- | -------- | ----------- |-------------------------------------|
275
- | `title` | `String` | **required**| Modal heading |
276
- | `description` | `String` | | Body text |
277
- | `to` | `String` | `"/"` | Redirect path on confirm |
278
- | `mode` | `String` | `'SUCCESS'` | Modal variant (use `BaseModalEnum`) |
279
-
280
- **Events:**
281
-
282
- | Event | Description |
283
- | -------------- | ------------------------------- |
284
- | `closeModal` | Emitted when modal is dismissed |
285
- | `confirmModal` | Emitted on confirm action |
286
-
287
- **Example:**
288
-
289
- ```vue
290
- <template>
291
- <BaseModal
292
- title="Delete this item?"
293
- description="This action cannot be undone."
294
- :mode="BaseModalEnum.DELETE"
295
- @closeModal="showModal = false"
296
- @confirmModal="handleDelete"
297
- />
298
- </template>
299
-
300
- <script setup lang="ts">
301
- import { ref } from 'vue'
302
- import { BaseModal, BaseModalEnum } from 'mgv-backoffice'
303
-
304
- const showModal = ref(true)
305
- const handleDelete = () => { /* ... */ }
306
- </script>
307
- ```
308
-
309
- ---
310
-
311
- ### BaseRow
312
-
313
- Card-like content container with border and shadow.
314
-
315
- **Props:**
316
-
317
- | Prop | Type | Default | Description |
318
- | --------- | -------- | --------- | ---------------------- |
319
- | `bgColor` | `String` | `"white"` | Background color class |
320
-
321
- **Slots:** `default` row content.
322
-
323
- **Example:**
324
-
325
- ```vue
326
- <template>
327
- <BaseRow>
328
- <p>Card content goes here</p>
329
- </BaseRow>
330
- </template>
331
-
332
- <script setup lang="ts">
333
- import { BaseRow } from 'mgv-backoffice'
334
- </script>
335
- ```
336
-
337
- ---
338
-
339
- ### BaseSpinner
340
-
341
- Animated loading spinner — a neutral ring with a coloured leading arc.
342
-
343
- **Props:**
344
-
345
- | Prop | Type | Default | Description |
346
- |---------|----------------------------------------------------------------------------|----------|-------------------------------------------------------------|
347
- | `size` | `'sm' \| 'md' \| 'lg' \| 'xl'` | `'sm'` | Diameter + ring thickness — 16 / 24 / 32 / 48px. |
348
- | `color` | `'blue' \| 'emerald' \| 'sky' \| 'indigo' \| 'teal' \| 'purple' \| 'red' \| 'amber'` | `'blue'` | Colour of the spinning arc. The track stays neutral gray. |
349
-
350
- With no props it renders the original 16px blue spinner, so existing call sites are unaffected.
351
-
352
- **Example:**
353
-
354
- ```vue
355
- <template>
356
- <!-- legacy default -->
357
- <BaseSpinner />
358
- <!-- larger, themed -->
359
- <BaseSpinner size="lg" color="emerald" />
360
- </template>
361
-
362
- <script setup lang="ts">
363
- import { BaseSpinner } from 'mgv-backoffice'
364
- </script>
365
- ```
366
-
367
- ---
368
-
369
- ### BaseToast
370
-
371
- Toast notification with positioning and auto-dismiss.
372
-
373
- **Props:**
374
-
375
- | Prop | Type | Default | Description |
376
- | -------------- | ---------------- | --------- | ------------------------------------------ |
377
- | `mode` | `BaseToastEnum` | **required** | Toast variant (SUCCESS, WARNING, ERROR) |
378
- | `description` | `String` | **required** | Message text |
379
- | `hasCloseIcon` | `Boolean` | `true` | Show close button |
380
- | `positioning` | `String` | `'right'` | Screen position (use `PositioningEnum`) |
381
-
382
- **Example:**
383
-
384
- ```vue
385
- <template>
386
- <BaseToast
387
- :mode="BaseToastEnum.SUCCESS"
388
- description="Changes saved successfully!"
389
- :positioning="PositioningEnum.TOP_RIGHT"
390
- />
391
- </template>
392
-
393
- <script setup lang="ts">
394
- import { BaseToast, BaseToastEnum, PositioningEnum } from 'mgv-backoffice'
395
- </script>
396
- ```
397
-
398
- ---
399
-
400
- ### ColoredSquares
401
-
402
- Colored square indicator with randomized pastel accent.
403
-
404
- **Props:**
405
-
406
- | Prop | Type | Default | Description |
407
- | ------- | -------- | ------- | --------------------------------- |
408
- | `color` | `String` | — | Color variant (use `ColorsEnums`) |
409
-
410
- **Slots:** `default` label content.
411
-
412
- **Example:**
413
-
414
- ```vue
415
- <template>
416
- <ColoredSquares :color="ColorsEnums.BLUE">Category A</ColoredSquares>
417
- </template>
418
-
419
- <script setup lang="ts">
420
- import { ColoredSquares, ColorsEnums } from 'mgv-backoffice'
421
- </script>
422
- ```
423
-
424
- ---
425
-
426
- ### EarningsCard
427
-
428
- Earnings summary card with formatted currency display. Supports a signed P&L
429
- mode that renders a red loss theme (and a downward trend glyph) for negative
430
- amounts.
431
-
432
- **Props:**
433
-
434
- | Prop | Type | Default | Description |
435
- | ---------- | -------- |-------------------------|----------------------|
436
- | `title` | `String` | `'TOTAL EARNINGS'` | Card heading |
437
- | `amount` | `Number` | `0` | Monetary value (a stringified number is coerced) |
438
- | `subtitle` | `String` | `'Lifetime commission'` | Subheading text |
439
- | `badge` | `String` | `''` | Optional badge label |
440
- | `currency` | `String` | `'$'` | Currency symbol |
441
- | `decimals` | `Number` | `2` | Fraction digits shown for the amount |
442
- | `accent` | `'orange' \| 'emerald' \| 'red'` | `'orange'` | Card theme. `emerald` tints it green; `red` is the loss theme. |
443
- | `signed` | `Boolean` | `false` | Treat `amount` as a signed P&L figure: a negative value automatically switches to the `red` loss theme and flips the trend glyph to point **down**; a non-negative value keeps the chosen `accent` and the upward glyph. |
444
-
445
- **Example:**
446
-
447
- ```vue
448
- <template>
449
- <!-- Always-positive total: original behaviour. -->
450
- <EarningsCard
451
- title="Monthly Revenue"
452
- :amount="12500"
453
- subtitle="April 2026"
454
- currency="€"
455
- />
456
-
457
- <!-- Signed P&L: renders red + a down arrow when the amount is negative. -->
458
- <EarningsCard
459
- title="TOTAL P&L"
460
- :amount="-128.4"
461
- subtitle="Realised + unrealised"
462
- accent="emerald"
463
- signed
464
- />
465
- </template>
466
-
467
- <script setup lang="ts">
468
- import { EarningsCard } from 'mgv-backoffice'
469
- </script>
470
- ```
471
-
472
- ---
473
-
474
- ### EuroAmount
475
-
476
- Formatted euro currency display with conditional color coding.
477
-
478
- **Props:**
479
-
480
- | Prop | Type | Default | Description |
481
- | -------------- | --------- | ------- |-------------------------------------------------|
482
- | `amount` | `Number` | — | Value to display |
483
- | `beforeAmount` | `Number` | `null` | Previous value (green if amount > beforeAmount) |
484
- | `showCurrency` | `Boolean` | `true` | Show euro symbol |
485
-
486
- **Example:**
487
-
488
- ```vue
489
- <template>
490
- <!-- Shows green (amount > beforeAmount) -->
491
- <EuroAmount :amount="1500" :beforeAmount="1200" />
492
-
493
- <!-- Shows red (negative) -->
494
- <EuroAmount :amount="-300" />
495
-
496
- <!-- Without currency symbol -->
497
- <EuroAmount :amount="800" :showCurrency="false" />
498
- </template>
499
-
500
- <script setup lang="ts">
501
- import { EuroAmount } from 'mgv-backoffice'
502
- </script>
503
- ```
504
-
505
- ---
506
-
507
- ### Pagination
508
-
509
- Page navigation with smart ellipsis for large page counts.
510
-
511
- **Props:**
512
-
513
- | Prop | Type | Default | Description |
514
- | -------------- | -------- | ------- | ----------------------- |
515
- | `totalItems` | `Number` | `10` | Total number of items |
516
- | `itemsPerPage` | `Number` | `20` | Items shown per page |
517
-
518
- **Events:**
519
-
520
- | Event | Payload | Description |
521
- | -------------- | -------- |----------------------------------|
522
- | `page-changed` | `Number` | Emitted with the new page number |
523
-
524
- **Example:**
525
-
526
- ```vue
527
- <template>
528
- <Pagination
529
- :totalItems="200"
530
- :itemsPerPage="10"
531
- @page-changed="onPageChange"
532
- />
533
- </template>
534
-
535
- <script setup lang="ts">
536
- import { Pagination } from 'mgv-backoffice'
537
-
538
- const onPageChange = (page: number) => {
539
- console.log('Page:', page)
540
- }
541
- </script>
542
- ```
543
-
544
- ---
545
-
546
- ### TrendArrow
547
-
548
- Up/down trend indicator displayed as a colored badge.
549
-
550
- **Props:**
551
-
552
- | Prop | Type | Default | Description |
553
- | -------- | -------- | ------- |------------------------------------------------------|
554
- | `number` | `Number` | — | Positive = green arrow up, negative = red arrow down, zero = neutral gray dash |
555
- | `icon` | `String` | — | Optional suffix appended after the number (e.g. `"%"`) |
556
-
557
- **Example:**
558
-
559
- ```vue
560
- <template>
561
- <TrendArrow :number="12.5" /> <!-- Green up arrow -->
562
- <TrendArrow :number="-3.2" /> <!-- Red down arrow -->
563
- <TrendArrow :number="0" /> <!-- Neutral gray dash -->
564
- </template>
565
-
566
- <script setup lang="ts">
567
- import { TrendArrow } from 'mgv-backoffice'
568
- </script>
569
- ```
570
-
571
- ---
572
-
573
- ## Enums
574
-
575
- All enums are importable directly from the package:
576
-
577
- ```ts
578
- import {
579
- AlertEnum,
580
- BaseBadgeEnum,
581
- BaseButtonEnum,
582
- BaseButtonSizeEnum,
583
- BaseLogoEnum,
584
- BaseModalEnum,
585
- BaseToastEnum,
586
- ColorsEnums,
587
- LineEnum,
588
- PositioningEnum
589
- } from 'mgv-backoffice'
590
- ```
591
-
592
- | Enum | Values |
593
- | -------------------- |---------------------------------------------------------------|
594
- | `AlertEnum` | `WARNING`, `ERROR`, `SUCCESS`, `INFO` |
595
- | `BaseBadgeEnum` | `WIN`, `LOSE` |
596
- | `BaseButtonEnum` | `RED`, `BLUE`, `WHITE`, `DARK`, `GREEN`, `EMERALD`, `YELLOW`, `PURPLE`, `SKY`, `GRAY`, `AMBER` |
597
- | `BaseButtonSizeEnum` | `EXTRA_SMALL`, `SMALL`, `BASE`, `LARGE`, `EXTRA_LARGE` |
598
- | `BaseLogoEnum` | `SMALL`, `MEDIUM`, `LARGE` (`BaseLoginEnum` is a deprecated alias) |
599
- | `BaseModalEnum` | `DELETE`, `SUCCESS` |
600
- | `BaseToastEnum` | `SUCCESS`, `WARNING`, `ERROR` |
601
- | `ColorsEnums` | `NONE`, `RED`, `YELLOW`, `BLACK`, `GRAY`, `GREEN`, `BLUE` |
602
- | `LineEnum` | `BASE`, `BASE_SHORTER`, `SQUARE` |
603
- | `PositioningEnum` | `TOP_LEFT`, `TOP_RIGHT`, `BOTTOM_LEFT`, `BOTTOM_RIGHT` |
604
-
605
- ---
606
-
607
- ## Types
608
-
609
- ```ts
610
- import type { BreadCrumb, PnL, PnLInputs } from 'mgv-backoffice'
611
- ```
612
-
613
- | Type | Shape |
614
- | ---------------- | -------------------------------------- |
615
- | `BreadCrumb` | `{ name: string; url: string }` |
616
- | `DropdownOption` | `{ value: string \| number; label: string; title?: string; disabled?: boolean }` |
617
- | `PnLInputs` | `{ buyPrice; lastPrice; filledQty }` (each `number \| string \| null \| undefined`) |
618
- | `PnL` | `{ pnlUsd: number \| null; pnlPct: number \| null }` |
619
-
620
- ---
621
-
622
- ## Utilities
623
-
624
- ```ts
625
- import { getBaseColor, getBaseColorOf } from 'mgv-backoffice'
626
- ```
627
-
628
- | Function | Signature | Returns |
629
- | ---------------- | ---------------------------------- | ----------------------------------- |
630
- | `getBaseColor` | `(c: AlertEnum) => string` | Tailwind color name for alert type |
631
- | `getBaseColorOf` | `(c: ColorsEnums) => string` | Tailwind color name for color enum |
632
-
633
- ### HTTP colours
634
-
635
- ```ts
636
- import {
637
- methodBadgeSolid,
638
- methodBadgeBright,
639
- methodBadgeTinted,
640
- statusBadgeSolid,
641
- statusBadgeTinted,
642
- statusBadgeSoft,
643
- } from 'mgv-backoffice'
644
- ```
645
-
646
- Tailwind class helpers for HTTP method and status code badges. `Solid` variants
647
- return saturated `bg-*-600` classes for use on neutral surfaces; `Bright` /
648
- `Tinted` variants return softer combinations suitable for cards. `statusBadgeTinted`
649
- takes `(status, isDark)` to adapt between themes.
650
-
651
- `methodBadgeTinted(method, isDark)` gives each method its own hue on a soft
652
- tinted surface (`bg-*-500/15` dark / `bg-*-100` light; GET blue, POST emerald,
653
- PUT amber, DELETE red, PATCH purple, HEAD sky) — the card-chip palette used by
654
- WireMate's mock/stub cards. `statusBadgeSoft(status, isDark)` is its status
655
- companion keyed by status class (emerald 2xx / sky 3xx / amber 4xx / red 5xx).
656
-
657
- ### Key/value row validators
658
-
659
- ```ts
660
- import { rowKeyMissing, rowValueMissing } from 'mgv-backoffice'
661
- ```
662
-
663
- | Function | Signature | Returns |
664
- | ----------------- | ---------------------------------------------------------------------- | ------- |
665
- | `rowValueMissing` | `(row: { key?, value?, matcherType? }) => boolean` | `true` when the row has a key but no value. |
666
- | `rowKeyMissing` | `(row: { key?, value?, matcherType? }) => boolean` | `true` when the row has a value but no key. |
667
-
668
- Consistency checks for dynamic key/value grids (header lists, query params,
669
- metadata rows). Rows with `matcherType: 'absent'` are exempt — an absent
670
- matcher intentionally carries no value.
671
-
672
- ### Input validators
673
-
674
- ```ts
675
- import { isValidAbsoluteUrl, isValidJson, isValidXml, isValidBase64 } from 'mgv-backoffice'
676
- ```
677
-
678
- Pure, dependency-free form-input validators. The payload validators treat
679
- empty/whitespace-only input as **valid** — required-ness is a separate rule
680
- from well-formedness; `isValidAbsoluteUrl` validates a value that must exist,
681
- so empty is invalid there.
682
-
683
- | Function | Signature | Returns |
684
- | -------------------- | ---------------------------- | ------- |
685
- | `isValidAbsoluteUrl` | `(value: string) => boolean` | `true` for an absolute `http://` / `https://` URL (other schemes rejected). |
686
- | `isValidJson` | `(str: string) => boolean` | `true` when empty or parseable as JSON. |
687
- | `isValidXml` | `(str: string) => boolean` | `true` when empty or well-formed XML (DOMParser `<parsererror>` check; browser-only). |
688
- | `isValidBase64` | `(str: string) => boolean` | `true` when empty or well-formed base64 (whitespace stripped, length/alphabet checked, then `atob` as the final authority). |
689
-
690
- ### HTML sanitizer
691
-
692
- ```ts
693
- import { sanitizeHtml, isSafeHref } from 'mgv-backoffice'
694
- ```
695
-
696
- | Function | Signature | Returns |
697
- | -------------- | ----------------------------------------------- | ------- |
698
- | `sanitizeHtml` | `(raw: string \| undefined \| null) => string` | Allow-list–sanitised HTML safe for `v-html`. |
699
- | `isSafeHref` | `(value: string) => boolean` | `true` if the href uses a safe scheme (http/https/mailto/tel, root-relative, or anchor). |
700
-
701
- Allow-list sanitizer for strings bound into `v-html`. Keeps a small set of
702
- formatting tags (`a`, `b`/`strong`, `i`/`em`, `code`, `pre`, `p`, `ul`/`ol`/`li`,
703
- `span`, `div`, `br`), strips all other elements (unwrapping to text, or dropping
704
- content entirely for `script`/`style`/`iframe`/etc.), removes every attribute
705
- except `href`/`title` on anchors, rejects unsafe href schemes
706
- (`javascript:`/`data:`/`vbscript:`/`file:`), and hardens surviving links with
707
- `rel="noopener noreferrer" target="_blank"`. Browser-only (uses `DOMParser`).
708
-
709
- ```ts
710
- sanitizeHtml('<p>Hi<script>alert(1)<\/script></p>') // '<p>Hi</p>'
711
- ```
712
-
713
- ### Display formatters
714
-
715
- ```ts
716
- import {
717
- fmtNumber,
718
- fmtDate,
719
- fmtDateTime,
720
- fmtDateShort,
721
- fmtPrice,
722
- fmtPct,
723
- fmtUsd,
724
- } from 'mgv-backoffice'
725
- ```
726
-
727
- Locale-aware, pure, dependency-free formatters for tables, logs and charts.
728
- They handle missing/non-finite input gracefully (rendering an em-dash) so raw
729
- API values can be passed without pre-sanitising.
730
-
731
- | Function | Signature | Returns |
732
- | -------------- | --------------------------------------------------------------- | ------- |
733
- | `fmtNumber` | `(n: number \| string \| null \| undefined, digits = 4) => string` | Fixed-fraction number; em-dash for null/undefined/non-finite. Accepts numeric strings. |
734
- | `fmtDate` | `(s: string \| number \| null \| undefined) => string` | Locale date-time from ISO string or epoch; em-dash on empty, raw value on parse failure. |
735
- | `fmtDateTime` | `(ms: number) => string` | Compact `"Mon D, HH:MM"` label from epoch-millis (chart axes/tooltips). |
736
- | `fmtDateTimeMs`| `(s: string \| number) => string` | Full 24-hour locale date-time WITH the millisecond fraction — for dense feeds where same-second rows must stay distinguishable. |
737
- | `fmtDateShort` | `(ms: number) => string` | Short `"Mon D"` calendar label from epoch-millis. |
738
- | `fmtCalendarDate` | `(s: string \| number \| null \| undefined) => string` | `"Mon D, YYYY"` en-US calendar label; em-dash on empty, raw value on parse failure. |
739
- | `fmtCalendarDateTime` | `(s: string \| number \| null \| undefined) => string` | `"Mon D, YYYY, HH:MM"` en-US calendar label with time of day. |
740
- | `fmtMsAsSeconds` | `(ms: number \| null \| undefined) => string` | `"= 1.50 s"` magnitude hint for millisecond inputs (3 decimals below 1 s); `''` for non-positive input. |
741
- | `fmtBytes` | `(bytes: number \| null \| undefined) => string` | `"512 B"` / `"1.5 KB"` / `"2.0 MB"`; `''` for zero/falsy input. |
742
- | `fmtPrice` | `(n: number) => string` | Price with precision that scales to magnitude (more decimals for sub-cent values). |
743
- | `fmtPct` | `(n: number, digits = 2) => string` | Percentage with explicit sign, e.g. `"+2.50%"`. |
744
- | `fmtUsd` | `(v: number) => string` | Signed USD amount with leading sign, e.g. `"+$5.00"`. |
745
- | `formatJson` | `(content: string) => string` | Pretty-prints parseable JSON with 2-space indentation; returns anything else verbatim. |
746
- | `stringifyValue` | `(value: unknown) => string` | Display string for an unknown value: strings pass through, null/undefined → `''`, everything else JSON-serialized (`String()` fallback). |
747
-
748
- ### Spec-form helpers
749
-
750
- ```ts
751
- import { buildSpecParams, firstInvalidNumericSpec } from 'mgv-backoffice'
752
- ```
753
-
754
- Value-map helpers for spec-driven forms (the state behind `BaseSpecFields`).
755
- A spec whose `default` is `null` is treated as OPTIONALblank means "knob
756
- disabled" and passes validation.
757
-
758
- | Function | Signature | Returns |
759
- | ------------------------ | --------- | ------- |
760
- | `buildSpecParams` | `(specs: SpecField[] \| undefined, existing: Record<string, SpecFieldValue>) => Record<string, SpecFieldValue>` | Value map seeded from each spec's `default`, keeping overlapping values the caller already has. |
761
- | `firstInvalidNumericSpec`| `(specs: SpecField[] \| undefined, params: Record<string, SpecFieldValue>) => string \| null` | Label of the first blank / NaN numeric field, or `null` when all numerics are valid. |
762
-
763
- ### Profit & loss
764
-
765
- ```ts
766
- import { computePnL } from 'mgv-backoffice'
767
- import type { PnL, PnLInputs } from 'mgv-backoffice'
768
- ```
769
-
770
- | Function | Signature | Returns |
771
- | ------------ | ------------------------------- | ------- |
772
- | `computePnL` | `(row: PnLInputs) => PnL` | Unrealised mark-to-market PnL in absolute USD and percent. Returns `{ pnlUsd: null, pnlPct: null }` when any input is missing, non-finite, or `buyPrice <= 0`. |
773
-
774
- ```ts
775
- interface PnLInputs {
776
- buyPrice: number | string | null | undefined
777
- lastPrice: number | string | null | undefined
778
- filledQty: number | string | null | undefined
779
- }
780
-
781
- interface PnL {
782
- pnlUsd: number | null
783
- pnlPct: number | null
784
- }
785
- ```
786
-
787
- ```ts
788
- computePnL({ buyPrice: 100, lastPrice: 110, filledQty: 5 })
789
- // { pnlUsd: 50, pnlPct: 10 }
790
- ```
791
-
792
- ---
793
-
794
- ## Layout & shells (Tier 2 — full backoffice chrome)
795
-
796
- ### BaseAppLayout
797
-
798
- Root layout: dark/light page background, skip link, `<main>`-with-inert wrapper.
799
- The `<main>` content offset tracks the sidebar width automatically —
800
- `lg:ml-60` when expanded, `lg:ml-16` when collapsed (via `useSidebarCollapse()`).
801
-
802
- **Props:**
803
-
804
- | Prop | Type | Default | Description |
805
- | ---- | ---- | ------- | ----------- |
806
- | `showSidebar` | `Boolean` | `true` | Render the `sidebar` slot. Set false for full-bleed pages. |
807
- | `skipLinkLabel` | `String` | `'Skip to main content'` | Label for the accessibility skip link. |
808
-
809
- **Slots:** `sidebar`, `default` (page content).
810
-
811
- ```vue
812
- <BaseAppLayout :show-sidebar="route.name !== 'presentation'">
813
- <template #sidebar><AppSidebar /></template>
814
- <RouterView />
815
- </BaseAppLayout>
816
- ```
817
-
818
- ### BaseSidebar
819
-
820
- Responsive sidebar with desktop fixed-positioning and mobile off-canvas
821
- behavior, focus management, optional theme toggle, a desktop collapse
822
- toggle (icon-only rail), an optional notifications bell, and configurable
823
- nav sections.
824
-
825
- **Props:**
826
-
827
- | Prop | Type | Default | Description |
828
- | ---- | ---- | ------- | ----------- |
829
- | `sections` | `NavSection[]` | **required** | Grouped nav items. |
830
- | `homeRouteName` | `String` | `'home'` | Route name for the logo / "go home" click. |
831
- | `appName` | `String` | `''` | Optional app name in the footer. |
832
- | `version` | `String` | `''` | Optional version string in the footer. |
833
- | `showThemeToggle` | `Boolean` | `true` | Toggle the dark/light switch in the footer. |
834
- | `collapsible` | `Boolean` | `true` | Show the desktop collapse toggle that shrinks the sidebar to an icon-only rail. |
835
- | `showNotifications` | `Boolean` | `false` | Show the notifications bell (with unread badge) that toggles `BaseNotificationPanel`. |
836
-
837
- > **Collapse state** is shared via `useSidebarCollapse()` (and persisted to
838
- > localStorage) so `BaseAppLayout` can shrink the content offset from
839
- > `lg:ml-60` to `lg:ml-16` in step with the rail. Collapsing only affects
840
- > desktop (`lg+`); on mobile the sidebar stays a full off-canvas panel.
841
-
842
- > **Notifications:** set `:show-notifications="true"` to render the bell,
843
- > then drop a [`BaseNotificationPanel`](#basenotificationpanel) in your app.
844
- > Both share state through `useNotifications()`, so the unread badge and the
845
- > panel stay in sync.
846
-
847
- **Slots:**
848
-
849
- | Slot | Slot props | Description |
850
- | -------- | ---------- | ----------- |
851
- | `logo` | `{ size }` | Brand logo. Receives a `size` hint (28px in mobile bar, 52px in sidebar). |
852
- | `status` | | Footer status row (e.g. health indicator, sync state). |
853
- | `footer` | | Replaces the default `appName v0` line. |
854
-
855
- **Types:**
856
-
857
- ```ts
858
- import type { NavItem, NavSection } from 'mgv-backoffice'
859
-
860
- interface NavItem {
861
- name: string // Vue Router route name
862
- label: string // display text
863
- icon: Component // typically a Heroicon
864
- }
865
-
866
- interface NavSection {
867
- title: string
868
- items: NavItem[]
869
- }
870
- ```
871
-
872
- ```vue
873
- <BaseSidebar :sections="navSections" home-route-name="projects" app-name="WireMate UI" :version="appVersion">
874
- <template #logo="{ size }"><WireMateLogo :size="size" /></template>
875
- <template #status>
876
- <HealthIndicator />
877
- </template>
878
- </BaseSidebar>
879
- ```
880
-
881
- ---
882
-
883
- ### BaseNotificationPanel
884
-
885
- Left-anchored notification drawer (teleported to `<body>`, slides in from
886
- the left, backdrop + Escape to close). Open/close state and the list live
887
- in `useNotifications()`, so the sidebar bell and the panel stay in sync.
888
-
889
- Enable the bell on the sidebar with `:show-notifications="true"`, drop one
890
- `<BaseNotificationPanel />` anywhere in your app, and feed it data via the
891
- composable.
892
-
893
- **Props:**
894
-
895
- | Prop | Type | Default | Description |
896
- | ----------------- | --------- | ------------------------------ | ----------- |
897
- | `title` | `String` | `'Notifications'` | Panel heading. |
898
- | `emptyText` | `String` | `'You have no notifications.'` | Shown when the list is empty. |
899
- | `showMarkAllRead` | `Boolean` | `true` | Render the "Mark all as read" action when there are unread items. |
900
-
901
- **Emits:** `select` (the clicked notification's `id`; the row is also marked read).
902
-
903
- ```vue
904
- <script setup lang="ts">
905
- import { BaseNotificationPanel, useNotifications } from 'mgv-backoffice'
906
- const { setNotifications } = useNotifications()
907
- setNotifications([
908
- { id: 1, title: 'New comment', message: 'Alice replied to your post', time: '2m ago', type: 'info' },
909
- { id: 2, title: 'Build passed', time: '1h ago', read: true, type: 'success' },
910
- ])
911
- </script>
912
-
913
- <template>
914
- <BaseSidebar :sections="navSections" :show-notifications="true" />
915
- <BaseNotificationPanel @select="(id) => goTo(id)" />
916
- </template>
917
- ```
918
-
919
- ```ts
920
- import type { NotificationItem } from 'mgv-backoffice'
921
-
922
- interface NotificationItem {
923
- id: string | number
924
- title: string
925
- message?: string
926
- time?: string // pre-formatted by you
927
- read?: boolean
928
- type?: 'info' | 'success' | 'warning' | 'error' // status dot colour
929
- }
930
- ```
931
-
932
- ---
933
-
934
- ## Authentication
935
-
936
- ### BaseGoogleSignInButton
937
-
938
- Google-branded "Sign in with Google" button (official multi-colour "G",
939
- dark-mode surface swap). Purely presentational — it runs no OAuth itself;
940
- listen on `click` and start your own Google Identity / Firebase / backend
941
- flow there.
942
-
943
- **Props:**
944
-
945
- | Prop | Type | Default | Description |
946
- | ---------- | --------- | -------------------------- | ----------- |
947
- | `label` | `String` | `'Sign in with Google'` | Button text. |
948
- | `loading` | `Boolean` | `false` | Disables and shows a spinner. |
949
- | `disabled` | `Boolean` | `false` | Disables without the spinner. |
950
- | `block` | `Boolean` | `true` | Full-width layout. |
951
-
952
- **Emits:** `click` (only when not disabled/loading).
953
-
954
- ### BaseLoginForm
955
-
956
- Presentational sign-in card: email + password (with show/hide), an optional
957
- "Remember me" checkbox, an error banner, the Google button + "or" divider,
958
- and `logo` / `forgot` / `footer` slots. Owns its input state and emits
959
- `submit` / `google-sign-in`; the app handles the actual request and feeds
960
- back `loading` / `error`.
961
-
962
- **Props:**
963
-
964
- | Prop | Type | Default | Description |
965
- | --------------- | --------- | ----------- | ----------- |
966
- | `title` | `String` | `'Sign in'` | Card heading. |
967
- | `subtitle` | `String` | `''` | Muted line under the heading. |
968
- | `submitLabel` | `String` | `'Sign in'` | Submit button text. |
969
- | `loading` | `Boolean` | `false` | Disables the form, spinner on submit. |
970
- | `googleLoading` | `Boolean` | `false` | Disables the form, spinner on the Google button. |
971
- | `error` | `String` | `''` | Error banner above the form. |
972
- | `showGoogle` | `Boolean` | `true` | Render the Google button + divider. |
973
- | `showRemember` | `Boolean` | `false` | Render the "Remember me" checkbox. |
974
-
975
- **Emits:** `submit` (`LoginCredentials`), `google-sign-in`.
976
-
977
- **Slots:** `logo`, `forgot` (next to the password label), `footer`.
978
-
979
- ```vue
980
- <script setup lang="ts">
981
- import { BaseLoginForm } from 'mgv-backoffice'
982
- import type { LoginCredentials } from 'mgv-backoffice'
983
-
984
- async function onSubmit(creds: LoginCredentials) { /* call your API */ }
985
- function onGoogle() { /* start Google OAuth */ }
986
- </script>
987
-
988
- <template>
989
- <BaseLoginForm
990
- subtitle="Welcome back"
991
- :show-remember="true"
992
- @submit="onSubmit"
993
- @google-sign-in="onGoogle"
994
- >
995
- <template #logo><MyLogo /></template>
996
- <template #forgot><a href="/forgot" class="text-sm text-emerald-600">Forgot?</a></template>
997
- <template #footer>No account? <a href="/signup" class="text-emerald-600">Sign up</a></template>
998
- </BaseLoginForm>
999
- </template>
1000
- ```
1001
-
1002
- ---
1003
-
1004
- ## Modals & sections
1005
-
1006
- ### BaseModalShell
1007
-
1008
- Shared modal chrome — `Teleport` to body, backdrop, themed card, escape key,
1009
- aria-modal. Compose this rather than building modals from scratch.
1010
-
1011
- **Props:**
1012
-
1013
- | Prop | Type | Default | Description |
1014
- | --------------- | --------- | ----------- | ----------- |
1015
- | `title` | `String` | **required** | Modal heading. |
1016
- | `maxWidthClass` | `String` | `'max-w-md'` | Tailwind max-w utility for the card. |
1017
- | `manualClose` | `Boolean` | `false` | If true, backdrop click and Escape do NOT auto-emit `cancel`. |
1018
- | `scrollable` | `Boolean` | `false` | Switch to the large-content layout: a flex column capped at `90vh` with a fixed header/footer and a scrolling body. |
1019
- | `subtitle` | `String` | `''` | Muted line under the title (scrollable layout only). |
1020
-
1021
- **Slots:** `icon`, `default`, `footer`, and (scrollable layout) `header-actions` — content on the right of the header, e.g. a close button.
1022
- **Events:** `cancel`, `backdrop`.
1023
-
1024
- ### BaseConfirmModal
1025
-
1026
- Confirmation dialog built on `BaseModalShell`. Variant chooses red (danger) or
1027
- amber (warning) styling.
1028
-
1029
- **Props:** `title`, `message`, `confirmText`, `cancelText`, `submittingText`,
1030
- `variant: 'danger' | 'warning'`, `submitting`.
1031
-
1032
- **Events:** `confirm`, `cancel`.
1033
-
1034
- ### BaseTextInputModal
1035
-
1036
- "Ask the user for a single string and confirm" dialog. Preserves typed input
1037
- on stray backdrop clicks; Escape always cancels.
1038
-
1039
- **Props:** `title`, `message`, `initialValue`, `placeholder`, `inputLabel`,
1040
- `confirmText`, `cancelText`, `submittingText`, `submitting`.
1041
-
1042
- **Slots:** `icon` override the default emerald document icon.
1043
- **Events:** `confirm(value: string)`, `cancel`.
1044
-
1045
- ### BaseEntityPickerModal
1046
-
1047
- Searchable "pick one from a list" dialog. Pass `items` directly or an async
1048
- `loader` that runs on mount.
1049
-
1050
- **Props:** `title`, `message?`, `items?: EntityPickerItem[]`,
1051
- `loader?: () => Promise<EntityPickerItem[]>`, `excludeId?`,
1052
- `variant: 'emerald' | 'purple' | 'blue' | 'red' | 'amber'`,
1053
- `searchPlaceholder`, `emptyMessage`, `noMatchMessage`, `confirmText`,
1054
- `cancelText`, `submittingText`, `submitting`.
1055
-
1056
- **Events:** `confirm(itemId: string)`, `cancel`.
1057
-
1058
- ```ts
1059
- interface EntityPickerItem { id: string; label: string }
1060
- ```
1061
-
1062
- ### BaseCollapsibleSection
1063
-
1064
- Section wrapper with a clickable header, optional badge, and a `default` slot
1065
- for the body. Parent owns the `collapsed` state.
1066
-
1067
- **Props:** `title`, `collapsed`, `badge?`, `bodyClass?`.
1068
- **Events:** `toggle`.
1069
-
1070
- ### BaseNotFoundPage
1071
-
1072
- Drop-in 404 view.
1073
-
1074
- **Props:** `code` (`'404'`), `message` (`'Page not found'`),
1075
- `homeRouteName` (`'home'`), `homeLabel` (`'Go home'`).
1076
-
1077
- ### BasePageHeader
1078
-
1079
- Page-level header: icon badge + title/subtitle on the left, action
1080
- buttons on the right. Gives top-level views a consistent header shape
1081
- and width.
1082
-
1083
- **Props:**
1084
-
1085
- | Prop | Type | Default | Description |
1086
- | --------------- | -------- | ------------- | ----------- |
1087
- | `title` | `String` | **required** | H1 text. |
1088
- | `subtitle` | `String` | `''` | Muted line below the title. |
1089
- | `iconColor` | `String` | `'emerald'` | Badge + icon colour: `'emerald' \| 'sky' \| 'red' \| 'amber'`. |
1090
- | `maxWidthClass` | `String` | `'max-w-4xl'` | Tailwind max-w utility constraining header width. |
1091
-
1092
- **Slots:**
1093
-
1094
- | Slot | Slot props | Description |
1095
- | --------- | ----------------- | ----------- |
1096
- | `icon` | `{ iconClass }` | Page Heroicon. Bind `:class="iconClass"` for the theme-aware colour. |
1097
- | `actions` | — | Buttons rendered on the right (refresh, destructive, etc.). |
1098
-
1099
- ```vue
1100
- <template>
1101
- <BasePageHeader title="Request Journal" subtitle="Recent matched requests" icon-color="sky">
1102
- <template #icon="{ iconClass }">
1103
- <DocumentTextIcon class="w-5 h-5" :class="iconClass" />
1104
- </template>
1105
- <template #actions>
1106
- <BaseButton description="Refresh" @click="reload" />
1107
- </template>
1108
- </BasePageHeader>
1109
- </template>
1110
-
1111
- <script setup lang="ts">
1112
- import { BasePageHeader, BaseButton } from 'mgv-backoffice'
1113
- import { DocumentTextIcon } from '@heroicons/vue/24/outline'
1114
- </script>
1115
- ```
1116
-
1117
- ---
1118
-
1119
- ### BaseToolbarButton
1120
-
1121
- Bordered toolbar button the "Refresh / Delete All" row that sits under
1122
- a page header. Optional leading icon (via slot) plus a label.
1123
-
1124
- **Props:**
1125
-
1126
- | Prop | Type | Default | Description |
1127
- | ---------- | --------- | ----------- | ----------- |
1128
- | `label` | `String` | `''` | Button text. Omit for an icon-only button. |
1129
- | `variant` | `String` | `'neutral'` | `'neutral'` (grey), `'danger'` (solid red) or `'ghost'` (slate h-9 outline — toolbar/modal-footer buttons). |
1130
- | `disabled` | `Boolean` | `false` | Greys out and blocks the click. |
1131
- | `title` | `String` | `undefined` | Native tooltip / a11y text. |
1132
- | `type` | `String` | `'button'` | Native button type. |
1133
-
1134
- **Slots:**
1135
-
1136
- | Slot | Slot props | Description |
1137
- | ------ | --------------- | ----------- |
1138
- | `icon` | `{ iconClass }` | Leading Heroicon. Bind `:class="iconClass"` (`w-4 h-4`); add state classes as needed. |
1139
-
1140
- **Emits:** `click` (native `MouseEvent`).
1141
-
1142
- ```vue
1143
- <template>
1144
- <BaseToolbarButton label="Refresh" :disabled="isLoading" title="Refresh" @click="reload">
1145
- <template #icon="{ iconClass }">
1146
- <ArrowPathIcon :class="[iconClass, { 'animate-spin': isLoading }]" />
1147
- </template>
1148
- </BaseToolbarButton>
1149
- <BaseToolbarButton label="Delete All" variant="danger" @click="deleteAll">
1150
- <template #icon="{ iconClass }">
1151
- <TrashIcon :class="iconClass" />
1152
- </template>
1153
- </BaseToolbarButton>
1154
- </template>
1155
- ```
1156
-
1157
- ---
1158
-
1159
- ### BaseActionButton
1160
-
1161
- Compact ghost action button the colour-coded "Edit / Logs / Stub /
1162
- Delete" actions on a card footer or action row. No border/fill at rest;
1163
- a tinted hover background keyed to the semantic colour.
1164
-
1165
- **Props:**
1166
-
1167
- | Prop | Type | Default | Description |
1168
- | ----------- | --------- | ----------- | ----------- |
1169
- | `label` | `String` | `''` | Button text. Omit for an icon-only button. |
1170
- | `color` | `String` | `'emerald'` | `'emerald' \| 'sky' \| 'indigo' \| 'teal' \| 'purple' \| 'red' \| 'amber' \| 'amberStrong'`. |
1171
- | `disabled` | `Boolean` | `false` | Dims via opacity and suppresses the hover tint. |
1172
- | `fullWidth` | `Boolean` | `false` | Stretch to fill its flex row (`flex-1`). |
1173
- | `title` | `String` | `undefined` | Native tooltip. |
1174
- | `ariaLabel` | `String` | `undefined` | Accessible label. |
1175
- | `type` | `String` | `'button'` | Native button type. |
1176
-
1177
- **Slots:**
1178
-
1179
- | Slot | Slot props | Description |
1180
- | ------ | --------------- | ----------- |
1181
- | `icon` | `{ iconClass }` | Leading Heroicon. Bind `:class="iconClass"` (`w-4 h-4`). |
1182
-
1183
- **Emits:** `click` (native `MouseEvent`).
1184
-
1185
- ```vue
1186
- <template>
1187
- <BaseActionButton label="Edit" color="emerald" full-width title="Edit this mock" @click="edit">
1188
- <template #icon="{ iconClass }">
1189
- <PencilSquareIcon :class="iconClass" />
1190
- </template>
1191
- </BaseActionButton>
1192
- <BaseActionButton label="Delete" color="red" @click="remove">
1193
- <template #icon="{ iconClass }">
1194
- <TrashIcon :class="iconClass" />
1195
- </template>
1196
- </BaseActionButton>
1197
- </template>
1198
- ```
1199
-
1200
- ---
1201
-
1202
- ### BaseCopyButton
1203
-
1204
- Copy-to-clipboard icon button with transient "copied" feedback clicks
1205
- write `text` to the clipboard, swap the clipboard icon for a checkmark
1206
- for `resetMs`, then revert. Uses the async Clipboard API with a
1207
- hidden-textarea `execCommand` fallback for insecure origins. Emits
1208
- `copied` / `error` so the parent can fire its own toast.
1209
-
1210
- **Props:**
1211
-
1212
- | Prop | Type | Default | Description |
1213
- | ----------- | --------- | --------- | ----------- |
1214
- | `text` | `String` | **required** | Value written to the clipboard. |
1215
- | `label` | `String` | `''` | Used in the tooltip / aria-label (`Copy {label}`). |
1216
- | `variant` | `String` | `'ghost'` | `'ghost'` (borderless `p-1` icon) or `'bordered'` (`w-9 h-9` boxed, turns emerald while copied). |
1217
- | `resetMs` | `Number` | `1500` | How long the checkmark stays before reverting. |
1218
- | `iconClass` | `String` | `'w-4 h-4'` | Icon size class. |
1219
-
1220
- **Emits:** `copied`, `error(err)`.
1221
-
1222
- ```vue
1223
- <template>
1224
- <!-- Inline ID copy, parent fires the toast -->
1225
- <BaseCopyButton
1226
- :text="stub.id"
1227
- label="Stub ID"
1228
- @copied="showToastMessage('Stub ID copied to clipboard', BaseToastEnum.SUCCESS)"
1229
- @error="showToastMessage('Failed to copy stub ID', BaseToastEnum.ERROR)"
1230
- />
1231
- <!-- Boxed copy next to a read-only input -->
1232
- <BaseCopyButton :text="mock.id" label="Mock ID" variant="bordered" :reset-ms="2000" />
1233
- </template>
1234
-
1235
- <script setup lang="ts">
1236
- import { BaseCopyButton, BaseToastEnum } from 'mgv-backoffice'
1237
- </script>
1238
- ```
1239
-
1240
- ---
1241
-
1242
- ### BaseChipButton
1243
-
1244
- Small tinted emerald "chip" action button — the compact "+ Add" pill used
1245
- above repeatable form rows. Label comes from the default slot.
1246
-
1247
- **Props:**
1248
-
1249
- | Prop | Type | Default | Description |
1250
- | ---------- | --------- | ------- | ----------- |
1251
- | `size` | `String` | `'sm'` | `'sm'` = `px-2.5 py-1`; `'xs'` = `px-2 py-0.5` for tight corners. |
1252
- | `disabled` | `Boolean` | `false` | Dims the chip and blocks clicks. |
1253
-
1254
- **Emits:** `click`.
1255
-
1256
- ```vue
1257
- <BaseChipButton @click="addRow(rows)">+ Add</BaseChipButton>
1258
- <BaseChipButton size="xs" @click="addNamespace">+ Add</BaseChipButton>
1259
- ```
1260
-
1261
- ---
1262
-
1263
- ### BaseRemoveButton
1264
-
1265
- The red "×" remove-row affordance used beside repeatable form rows. Name it
1266
- for screen readers via `aria-label`; `title`, `disabled` and extra classes
1267
- (`pt-1`, `self-start`, …) fall through as attrs.
1268
-
1269
- **Emits:** `click`.
1270
-
1271
- ```vue
1272
- <BaseRemoveButton :aria-label="`Remove header ${i + 1}`" @click="rows.splice(i, 1)" />
1273
- ```
1274
-
1275
- ---
1276
-
1277
- ### BaseStatusPill
1278
-
1279
- Connection/health status pill: a colored dot (pulsing while `ok`) next to a
1280
- short label on a tinted background.
1281
-
1282
- **Props:**
1283
-
1284
- | Prop | Type | Default | Description |
1285
- | -------- | -------- | ------- | ----------- |
1286
- | `status` | `String` | **required** | `'ok'` (emerald, pulsing), `'error'` (red), `'unknown'` (gray). |
1287
- | `label` | `String` | **required** | Short text next to the dot, e.g. `WireMock Connected`. |
1288
-
1289
- ```vue
1290
- <BaseStatusPill :status="healthy ? 'ok' : 'error'" :label="healthy ? 'Connected' : 'Disconnected'" />
1291
- ```
1292
-
1293
- ---
1294
-
1295
- ### BaseFileDropzone
1296
-
1297
- Dashed "click to select a file" upload zone (extracted from WireMate's
1298
- Postman-import modal). Renders a document-arrow-up icon (overridable via the
1299
- `#icon` slot), a label line, and an optional dimmed hint line. Clicking opens
1300
- the native file picker; dragging files onto the zone also works (the border
1301
- highlights emerald while dragging). The hidden input resets after every
1302
- selection, so picking the same file twice still emits.
1303
-
1304
- **Props:**
1305
-
1306
- | Prop | Type | Default | Description |
1307
- | ---------- | --------- | ------- | ----------- |
1308
- | `label` | `String` | **required** | Main line, e.g. `Click to select a Postman collection (.json)`. |
1309
- | `hint` | `String` | `''` | Dimmed helper line below the label. |
1310
- | `accept` | `String` | `''` | Forwarded to the input's `accept`. Dropped files are **not** filtered by it. |
1311
- | `multiple` | `Boolean` | `false` | Allow multi-select; when `false`, a multi-file drop emits only the first file. |
1312
- | `disabled` | `Boolean` | `false` | Dims the zone and ignores clicks/drops. |
1313
-
1314
- **Emits:** `files` (`File[]`, never empty).
1315
-
1316
- **Slots:** `icon` replaces the default upload icon.
1317
-
1318
- ```vue
1319
- <BaseFileDropzone
1320
- accept="application/json,.json"
1321
- label="Click to select a Postman collection (.json)"
1322
- hint="Exported from Postman Export Collection v2.1"
1323
- @files="onFiles"
1324
- />
1325
- ```
1326
-
1327
- ### BaseCodeBlock
1328
-
1329
- Themed monospace `<pre>` for JSON payloads, request dumps and code snippets
1330
- (extracted from WireMate's stub/request detail views). Preserves whitespace
1331
- verbatim, scrolls both axes, and adapts to the theme. Extra classes (margins
1332
- etc.) fall through via the normal class merge.
1333
-
1334
- **Props:**
1335
-
1336
- | Prop | Type | Default | Description |
1337
- | ---------------- | -------- | -------- | ----------- |
1338
- | `code` | `String` | **required** | The raw text to render. |
1339
- | `variant` | `String` | `'soft'` | `'soft'` = tinted fill, no border (in-card look); `'bordered'` = bordered card fill (standalone look). |
1340
- | `size` | `String` | `'sm'` | `'sm'` = `text-sm px-5 py-4`; `'xs'` = dense `text-xs p-3`. |
1341
- | `maxHeightClass` | `String` | `''` | Optional Tailwind max-height utility, e.g. `max-h-96`. |
1342
-
1343
- ```vue
1344
- <BaseCodeBlock :code="formatJson(response.body)" size="xs" max-height-class="max-h-64" />
1345
- ```
1346
-
1347
- ---
1348
-
1349
- ## Forms & tables
1350
-
1351
- These components use `dark:` Tailwind variants, so the consuming app must map
1352
- the `dark` variant to the `.dark` class that `useTheme()` toggles (see
1353
- [Tailwind setup for consumers](#tailwind-setup-for-consumers)).
1354
-
1355
- ### BaseInput
1356
-
1357
- Themed text/number input carrying the shared field skin (slate border,
1358
- `bg-slate-50` / dark `bg-slate-900` surface). Everything else — `placeholder`,
1359
- `id`, `disabled`, `step`/`min`, extra classes like `font-mono` or
1360
- `placeholder:*` — falls through via attrs and Vue class merging.
1361
-
1362
- **Props:**
1363
-
1364
- | Prop | Type | Default | Description |
1365
- | ------------ | ------------------ | -------- | ----------- |
1366
- | `modelValue` | `String \| Number` | `''` | `v-model` value. |
1367
- | `type` | `String` | `'text'` | Native input type. |
1368
- | `size` | `String` | `'md'` | `'md'` = `px-3 py-2`, `'sm'` = `px-2 py-1.5`. |
1369
- | `block` | `Boolean` | `true` | Full-width (`w-full`); set `false` for inline fields. |
1370
-
1371
- **Emits:** `update:modelValue(value: string)` always the raw string; parse
1372
- numbers in the owner.
1373
-
1374
- ```vue
1375
- <BaseInput v-model="query" placeholder="e.g. AMD or BTC" class="font-mono" />
1376
- ```
1377
-
1378
- ### BaseSelect
1379
-
1380
- Themed `<select>` sharing BaseInput's field skin. Options come from the
1381
- default slot so callers keep full control of `<option>` rendering.
1382
-
1383
- **Props:**
1384
-
1385
- | Prop | Type | Default | Description |
1386
- | ------------ | ------------------ | ------- | ----------- |
1387
- | `modelValue` | `String \| Number` | `''` | `v-model` value. |
1388
- | `size` | `String` | `'sm'` | `'sm'` = `px-2 py-1.5`, `'md'` = `px-3 py-2`. |
1389
- | `block` | `Boolean` | `true` | Full-width; set `false` for inline selects. |
1390
-
1391
- **Slots:** `default` the `<option>` elements.
1392
- **Emits:** `update:modelValue(value: string)`.
1393
-
1394
- ```vue
1395
- <BaseSelect v-model="strategyType">
1396
- <option v-for="e in catalog" :key="e.type" :value="e.type" :title="e.description">
1397
- {{ e.label }}
1398
- </option>
1399
- </BaseSelect>
1400
- ```
1401
-
1402
- ### BaseDropdown
1403
-
1404
- Button-style single-select dropdown ("Select Social User ⌄"). Unlike
1405
- `BaseSelect` (a native `<select>`), this renders a trigger button plus a
1406
- floating menu, so the closed control shows a placeholder and a chevron that
1407
- rotates while open matching the app's filter dropdowns. Selecting a row
1408
- emits its `value` and closes the menu; Escape and an outside click also close
1409
- it.
1410
-
1411
- **Props:**
1412
-
1413
- | Prop | Type | Default | Description |
1414
- | ------------- | -------------------------- | ------------ | ----------- |
1415
- | `options` | `DropdownOption[]` | **required** | `{ value, label, title?, disabled? }` per row. |
1416
- | `modelValue` | `String \| Number \| null` | `null` | Selected option's `value` (`v-model`). |
1417
- | `placeholder` | `String` | `'Select'` | Trigger text shown when nothing is selected. |
1418
- | `size` | `String` | `'md'` | `'md'` = `px-4 py-2.5` (app filter height), `'sm'` = `px-3 py-2`. |
1419
- | `block` | `Boolean` | `true` | Full-width; set `false` for an inline, content-width dropdown. |
1420
- | `disabled` | `Boolean` | `false` | Disables the trigger. |
1421
- | `ariaLabel` | `String` | `''` | Accessible name for the trigger/listbox when there is no visible label. |
1422
-
1423
- **Emits:** `update:modelValue(value)`.
1424
-
1425
- ```vue
1426
- <BaseDropdown
1427
- v-model="socialUserId"
1428
- :options="socialUsers.map((u) => ({ value: u.id, label: u.name }))"
1429
- placeholder="Select Social User"
1430
- aria-label="Social user"
1431
- />
1432
- ```
1433
-
1434
- ### BaseSegmentedControl
1435
-
1436
- Segmented button group ("All | Stock | Crypto"). One button per option; the
1437
- selected one gets the filled treatment and `aria-pressed="true"`.
1438
-
1439
- **Props:**
1440
-
1441
- | Prop | Type | Default | Description |
1442
- | ------------- | ------------------- | -------- | ----------- |
1443
- | `options` | `SegmentedOption[]` | **required** | `{ value, label, title? }` per button. |
1444
- | `modelValue` | `String \| Number` | **required** | Selected option's `value` (`v-model`). |
1445
- | `variant` | `String` | `'base'` | `'base'` (`px-3 py-2`, emerald-500 fill), `'wide'` (`px-4 py-2`, emerald-600 fill), `'toolbar'` (`h-9` uppercase `text-xs` with focus-visible rings). |
1446
- | `ariaLabel` | `String` | `''` | When set, the wrapper renders `role="group"` + `aria-label`. |
1447
- | `optionClass` | `Function` | | `(option, active) => string` override for per-button fill classes (e.g. severity colours); layout stays owned by the variant. |
1448
-
1449
- **Emits:** `update:modelValue(value)`.
1450
-
1451
- ```vue
1452
- <BaseSegmentedControl v-model="assetFilter" :options="ASSET_FILTERS" />
1453
- <BaseSegmentedControl v-model="exchange" :options="EXCHANGES" variant="wide" aria-label="Exchange" />
1454
- ```
1455
-
1456
- ### BaseTable
1457
-
1458
- Styling shell for data tables — **not** a data grid. Owns the table skin
1459
- (slate header band, `px-4 py-3` header cells, empty-state row); body rows are
1460
- the caller's own `<tr>` markup via the default slot. Wrap it yourself for
1461
- scrolling/card chrome (e.g. a `BaseRow` with `overflow-x-auto`).
1462
-
1463
- **Props:**
1464
-
1465
- | Prop | Type | Default | Description |
1466
- | ----------- | --------------- | ------------ | ----------- |
1467
- | `columns` | `TableColumn[]` | **required** | `{ label, align? }`; `align: 'right'` right-aligns the header cell. |
1468
- | `empty` | `Boolean` | `false` | True renders the empty-state row spanning every column. |
1469
- | `emptyText` | `String` | `'No rows.'` | Fallback empty-state text. |
1470
-
1471
- **Slots:** `default` the `<tr>` rows; `empty` — custom empty-state content.
1472
-
1473
- ```vue
1474
- <BaseTable :columns="COLUMNS" :empty="rows.length === 0">
1475
- <template #empty>No trades match your filters.</template>
1476
- <tr v-for="row in rows" :key="row.id" class="border-t border-slate-200 dark:border-slate-700">
1477
-
1478
- </tr>
1479
- </BaseTable>
1480
- ```
1481
-
1482
- ### BaseSpecFields
1483
-
1484
- Spec-driven form fields: renders a select / checkbox / number input per
1485
- `SpecField`, with labels and help text, in a responsive two-column grid. Feed
1486
- it a backend-described catalogue and every form editing those values stays in
1487
- lockstep. Never mutates `params` every edit is emitted as `(key, value)`
1488
- and the owner writes it back into its own state.
1489
-
1490
- **Props:**
1491
-
1492
- | Prop | Type | Default | Description |
1493
- | -------- | -------------------------------- | ------------ | ----------- |
1494
- | `specs` | `SpecField[]` | **required** | `{ key, label, type: 'decimal' \| 'integer' \| 'boolean' \| 'select', options?, step?, min?, help? }`. |
1495
- | `params` | `Record<string, SpecFieldValue>` | **required** | Current values keyed by `spec.key`. |
1496
-
1497
- **Slots:** `after` (`{ spec }`) — extra content under each field (e.g. a live
1498
- preview attached to one key).
1499
- **Emits:** `update(key: string, value: SpecFieldValue)` — numbers are parsed
1500
- (`parseFloat`); unparseable input passes through raw so the owner's
1501
- validation can catch it.
1502
-
1503
- ```vue
1504
- <BaseSpecFields :specs="entry.params" :params="form.params"
1505
- @update="(key, value) => (form.params[key] = value)" />
1506
- ```
1507
-
1508
- ### BaseFilterChip
1509
-
1510
- Colour-coded toggleable filter chip one-click event/category filters above
1511
- a data feed. Idle renders a tinted border/background in the semantic colour;
1512
- active renders a solid fill with white text (`aria-pressed` reflects the
1513
- state). Layout classes (`h-9 flex-1`, …) pass through the class attribute;
1514
- click handlers bind natively on the component.
1515
-
1516
- **Props:**
1517
-
1518
- | Prop | Type | Default | Description |
1519
- | ---------- | --------- | --------- | ----------- |
1520
- | `label` | `String` | `''` | Chip text; the default slot overrides it. |
1521
- | `color` | `'emerald' \| 'sky' \| 'amber' \| 'red' \| 'slate'` | `'slate'` | Semantic colour of the idle tint and active fill. |
1522
- | `active` | `Boolean` | `false` | Whether the chip's filter is applied (solid fill). |
1523
- | `disabled` | `Boolean` | `false` | Greys out + blocks the click. |
1524
- | `title` | `String` | — | Native tooltip. |
1525
-
1526
- ```vue
1527
- <BaseFilterChip
1528
- v-for="f in filters"
1529
- :key="f.key"
1530
- class="h-9 flex-1"
1531
- :color="f.color"
1532
- :active="isActive(f)"
1533
- :title="f.title"
1534
- @click="toggle(f)"
1535
- >{{ f.label }}</BaseFilterChip>
1536
- ```
1537
-
1538
- ### BaseCredentialsForm
1539
-
1540
- One service's API-credentials card: key id + secret + base/data URLs, with
1541
- the has-secret handling (placeholder dots, blank-keeps-stored-secret), the
1542
- save-validation ladder and a saving spinner. Load/save results are EMITTED —
1543
- the parent owns toasts / error banners. Exposes `load()` so a parent Reload
1544
- button can re-pull several cards in parallel.
1545
-
1546
- **Props:** `title` + `idPrefix` + `fetchFn: () => Promise<CredentialsView>` +
1547
- `updateFn: (body: CredentialsUpdate) => Promise<CredentialsView>` +
1548
- `defaults: { baseUrl, dataUrl }` (required); `subtitle`, `keyLabel`,
1549
- `keyPlaceholder`, `secretLabel`, `secretPlaceholder`, `secretSetHint`,
1550
- `permissionsHint`, `requiredKeyMessage`, `requiredSecretMessage`,
1551
- `savedMessage`, `saveLabel` (optional copy overrides).
1552
-
1553
- **Slots:** `no-secret-hint` rich help while no secret is stored;
1554
- `base-url-extra` (`{ form }`) extras under the Base URL field (e.g.
1555
- live/paper shortcut buttons that write into the form); `footer` extra
1556
- content at the card's bottom.
1557
-
1558
- **Emits:** `saved(message)`, `error(message)`, `load-error(message)`.
1559
-
1560
- ```vue
1561
- <BaseCredentialsForm
1562
- ref="card"
1563
- title="Alpaca API"
1564
- id-prefix="alpaca"
1565
- :fetch-fn="fetchAlpaca"
1566
- :update-fn="updateAlpaca"
1567
- :defaults="{ baseUrl: LIVE_BASE, dataUrl: DATA_URL }"
1568
- @saved="onSaved"
1569
- @error="onError"
1570
- @load-error="onLoadError"
1571
- />
1572
- ```
1573
-
1574
- ---
1575
-
1576
- ### BasePillPickerModal
1577
-
1578
- "Pick one of many" modal: every item rendered as a clickable pill, narrowed
1579
- by a free-text filter and an optional segmented group toggle. Clicking a pill
1580
- emits `pick` with the item; backdrop / Escape / the footer Close emit `close`.
1581
- Narrowing state lives inside, so a `v-if`-mounted instance always opens fresh.
1582
-
1583
- **Props:** `title` + `items: PillPickerItem[]` (required);
1584
- `groups?: SegmentedOption<string>[]` (renders the group toggle with an
1585
- `allLabel` option prepended, narrowing by each item's `group`); `icon?`
1586
- (defaults to the magnifying glass), `subtitle?`, `searchPlaceholder`,
1587
- `emptyMessage`, `noMatchMessage`, `mono` (mono font for the filter input and
1588
- pills symbols, codes, ids), `maxWidthClass` (default `max-w-2xl`),
1589
- `closeText`, `groupAriaLabel`, `allLabel`.
1590
-
1591
- **Emits:** `pick(item: PillPickerItem)`, `close`.
1592
-
1593
- ```ts
1594
- interface PillPickerItem {
1595
- id: string // unique key; identifies the pick
1596
- label: string // pill text; what the filter matches
1597
- group?: string // segmented-toggle bucket
1598
- title?: string // pill tooltip
1599
- }
1600
- ```
1601
-
1602
- ```vue
1603
- <BasePillPickerModal
1604
- v-if="open"
1605
- title="Symbols"
1606
- :items="symbols.map(s => ({ id: s.id, label: s.symbol, group: s.assetClass }))"
1607
- :groups="[{ value: 'STOCK', label: 'STOCK' }, { value: 'CRYPTO', label: 'CRYPTO' }]"
1608
- mono
1609
- @pick="apply"
1610
- @close="open = false"
1611
- />
1612
- ```
1613
-
1614
- ---
1615
-
1616
- ## Composables
1617
-
1618
- ```ts
1619
- import {
1620
- initTheme,
1621
- useTheme,
1622
- useThemeClasses,
1623
- useEscapeKey,
1624
- useDebouncedRef,
1625
- useToast,
1626
- useMobileSidebar,
1627
- useSidebarCollapse,
1628
- useNotifications,
1629
- useQueryParamSync,
1630
- useFieldClasses,
1631
- usePolling,
1632
- } from 'mgv-backoffice'
1633
- ```
1634
-
1635
- | Composable | Purpose |
1636
- | ---------- | ------- |
1637
- | `initTheme({ storageKey? })` | Explicitly initialize the theme singleton. Call in your app entry point **before mounting** when you need a custom storage key — library components call `useTheme()` internally, so a component mounting first would otherwise lock in the default key (a dev-mode warning fires if that happens). |
1638
- | `useTheme({ storageKey? })` | Singleton dark/light controller. Toggles `<html class="dark">` and persists via localStorage (default key `'mgv-theme'`). Prefer `initTheme` at app entry for custom keys. |
1639
- | `useThemeClasses()` | Named Tailwind class roles for dark/light (card, border, primaryText, mutedText, dimText, input, ghostButton, emeraldText, redText, …). Since 1.34.0 returns a `reactive` object of plain strings — bind `t.card` directly, never `t.card.value` (the old ComputedRef shape leaked ref internals into `:class` bindings). |
1640
- | `useEscapeKey(handler)` | Component-scoped Escape key listener. |
1641
- | `useDebouncedRef(source, delay?)` | Debounced mirror of a ref. Timer cleared on scope dispose. |
1642
- | `useToast(durationMs?)` | Per-component toast state: `{ showToast, toastMessage, toastType, showToastMessage }`. |
1643
- | `useMobileSidebar()` | Singleton state shared between `BaseSidebar` and `BaseAppLayout` for the off-canvas open/closed flag. |
1644
- | `useSidebarCollapse({ storageKey? })` | Singleton collapsed/expanded state for the desktop sidebar rail, shared between `BaseSidebar` and `BaseAppLayout` and persisted to localStorage (default key `'mgv-sidebar-collapsed'`). |
1645
- | `useNotifications()` | Singleton notification state shared by the sidebar bell and `BaseNotificationPanel`: `{ notifications, unreadCount, open, openPanel, closePanel, togglePanel, setNotifications, add, remove, markRead, markAllRead, clear }`. |
1646
- | `useQueryParamSync()` | URL-query mirroring for filterable views: `{ qparam(name), qenum(name, allowed, fallback), replaceQuery(next) }`. Read filters from the query string once on setup, write changes back with `router.replace` (no-op when unchanged) so filtered views stay shareable without polluting history. |
1647
- | `useFieldClasses()` | Shared form-field class strings for the gray/emerald form skin: `{ label, input, requiredInput(value) }`. `requiredInput` returns a red border+ring skin while the value is empty and the standard skin otherwise. |
1648
- | `usePolling(fn, intervalMs, { immediate?, pauseWhenHidden? })` | Visibility-gated polling loop bound to the component lifecycle: starts on mount, stops on unmount, pauses while the tab is hidden and refreshes + resumes on return to visible (both default on). Pass `intervalMs: null` for refresh-only mode (run on mount + each return-to-visible, no timer). Returns `{ start, stop, active }`. Catch errors inside `fn` — the loop never swallows rejections. |
1649
-
1650
- ---
1651
-
1652
- ## Typography
1653
-
1654
- Since 1.33.0 the library ships the shared brand typography: the stylesheet
1655
- loads **Fira Sans** (UI text) and **Fira Code** (numerals/data) from Google
1656
- Fonts via `@import`, registers them as the Tailwind `--font-sans` /
1657
- `--font-mono` theme defaults, and applies `font-family: var(--font-sans)` to
1658
- `body`. Consumers get the fonts just by importing the lib CSS — remove any
1659
- app-local Google Fonts `<link rel="stylesheet">` and `--font-sans`/`--font-mono`
1660
- overrides. Keep (or add) the preconnect hints in `index.html` for a faster
1661
- first paint:
1662
-
1663
- ```html
1664
- <link rel="preconnect" href="https://fonts.googleapis.com" />
1665
- <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
1666
- ```
1667
-
1668
- ## Tailwind setup for consumers
1669
-
1670
- The lib's components rely on Tailwind utility classes (including dark-mode
1671
- variants). Consumers should add the lib's `dist` output to their Tailwind
1672
- `content` paths so the JIT can see the class names:
1673
-
1674
- ```js
1675
- // tailwind.config.js
1676
- export default {
1677
- content: [
1678
- './index.html',
1679
- './src/**/*.{vue,ts}',
1680
- './node_modules/mgv-backoffice/dist/**/*.{js,mjs,cjs,vue}',
1681
- ],
1682
- }
1683
- ```
1684
-
1685
- The legacy `tailwind.safelist.js` only covers the v1 components; the
1686
- recommended path for v4+ is the `content` glob above.
1
+ # mgv-backoffice
2
+
3
+ Shared Vue 3 UI component library built with TypeScript and Tailwind CSS.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install mgv-backoffice
9
+ ```
10
+
11
+ ### Peer Dependencies
12
+
13
+ These must be installed in your project:
14
+
15
+ ```bash
16
+ npm install vue@^3.5.0 vue-router@^5.0.0 @heroicons/vue@^2.0.0
17
+ ```
18
+
19
+ > `vue-router` 5.x is required (peer range `^5.0.0`) — it's what the library is
20
+ > developed and tested against. Upgrade from Router 4 before installing this library.
21
+
22
+ ### Import Styles
23
+
24
+ Include the library's stylesheet in your app entry point:
25
+
26
+ ```ts
27
+ import 'mgv-backoffice/dist/style.css'
28
+ ```
29
+
30
+ ### Tailwind Safelist
31
+
32
+ If your project uses Tailwind, import the safelist so dynamic classes used by this library are generated correctly:
33
+
34
+ ```js
35
+ // In your Tailwind config
36
+ import safelist from 'mgv-backoffice/tailwind.safelist'
37
+ ```
38
+
39
+ Or include the pre-built CSS safelist:
40
+
41
+ ```css
42
+ @import 'mgv-backoffice/tailwind.safelist.css';
43
+ ```
44
+
45
+ > Maintainers: `tailwind.safelist.js` is the single source of truth.
46
+ > `tailwind.safelist.css` is generated from it via `npm run safelist`
47
+ > (runs automatically before `npm run build`) — don't edit it by hand.
48
+
49
+ ---
50
+
51
+ ## Components
52
+
53
+ ### BaseAlert
54
+
55
+ Inline notice panel with color-coded variants (error / warning / success /
56
+ info), theme-aware via the shared `isDark` ref. The optional default slot
57
+ renders body content under the title, and `compact` gives a slim text-xs
58
+ variant for in-form warnings.
59
+
60
+ **Props:**
61
+
62
+ | Prop | Type | Default | Description |
63
+ | --------- | ----------- | ------------------ | ------------------------ |
64
+ | `title` | `String` | `''` | Bold headline (optional when the slot carries the message). |
65
+ | `color` | `AlertEnum` | `AlertEnum.ERROR` | Alert color variant. |
66
+ | `compact` | `Boolean` | `false` | Slim variant: text-xs, smaller icon/padding. |
67
+
68
+ **Slots:** default — body content rendered under the title.
69
+
70
+ **Example:**
71
+
72
+ ```vue
73
+ <template>
74
+ <BaseAlert title="Operation successful" :color="AlertEnum.SUCCESS" />
75
+ <BaseAlert title="Proxying is active." :color="AlertEnum.WARNING">
76
+ <p class="mt-0.5 text-xs opacity-90">The canned response below is ignored.</p>
77
+ </BaseAlert>
78
+ <BaseAlert compact :color="AlertEnum.WARNING">
79
+ Chunked dribble is ignored while Fault Simulation is active.
80
+ </BaseAlert>
81
+ </template>
82
+
83
+ <script setup lang="ts">
84
+ import { BaseAlert, AlertEnum } from 'mgv-backoffice'
85
+ </script>
86
+ ```
87
+
88
+ ---
89
+
90
+ ### BaseBadge
91
+
92
+ Colored status badge/pill. Renders nothing when the default slot is empty;
93
+ an omitted or unrecognized `color` falls back to the red palette.
94
+
95
+ **Props:**
96
+
97
+ | Prop | Type | Default | Description |
98
+ | ------- | -------- | ------- | --------------------------------- |
99
+ | `color` | `String` | — | Color variant (use `ColorsEnums`) |
100
+
101
+ **Slots:** `default` — badge label content.
102
+
103
+ **Example:**
104
+
105
+ ```vue
106
+ <template>
107
+ <BaseBadge :color="ColorsEnums.GREEN">Active</BaseBadge>
108
+ <BaseBadge :color="ColorsEnums.RED">Inactive</BaseBadge>
109
+ </template>
110
+
111
+ <script setup lang="ts">
112
+ import { BaseBadge, ColorsEnums } from 'mgv-backoffice'
113
+ </script>
114
+ ```
115
+
116
+ ---
117
+
118
+ ### BaseBreadcrumb
119
+
120
+ Breadcrumb navigation. Provide items manually or pass a URL path for
121
+ auto-generation; with neither prop it auto-generates from
122
+ `window.location.pathname`. A "Home" crumb linking to `/` is always prepended.
123
+
124
+ **Props:**
125
+
126
+ | Prop | Type | Default | Description |
127
+ | ------- | --------------- | ----------- | ------------------------------------------ |
128
+ | `items` | `BreadCrumb[]` | `undefined` | Manual breadcrumb entries |
129
+ | `path` | `String` | `undefined` | URL path for auto-generated breadcrumbs |
130
+
131
+ **BreadCrumb type:**
132
+
133
+ ```ts
134
+ interface BreadCrumb {
135
+ name: string
136
+ url: string
137
+ }
138
+ ```
139
+
140
+ **Example:**
141
+
142
+ ```vue
143
+ <template>
144
+ <!-- Manual -->
145
+ <BaseBreadcrumb :items="[
146
+ { name: 'Home', url: '/' },
147
+ { name: 'Users', url: '/users' },
148
+ { name: 'Profile', url: '/users/1' }
149
+ ]" />
150
+
151
+ <!-- Auto-generated from path -->
152
+ <BaseBreadcrumb path="/users/settings/profile" />
153
+ </template>
154
+
155
+ <script setup lang="ts">
156
+ import { BaseBreadcrumb } from 'mgv-backoffice'
157
+ import type { BreadCrumb } from 'mgv-backoffice'
158
+ </script>
159
+ ```
160
+
161
+ ---
162
+
163
+ ### BaseButton
164
+
165
+ Button with color, size, loading state, and Vue Router integration.
166
+
167
+ **Props:**
168
+
169
+ | Prop | Type | Default | Description |
170
+ | ------------- | ----------------------------------- | --------------------- | ------------------------------------ |
171
+ | `description` | `String` | **required** | Button label text |
172
+ | `color` | `String` | `BaseButtonEnum.BLUE` | Color variant (`BLUE`/`WHITE`/`DARK`/`GREEN`/`EMERALD`/`RED`/`YELLOW`/`PURPLE`/`SKY`/`GRAY`/`AMBER`) |
173
+ | `outline` | `Boolean` | `false` | Outlined/secondary style — transparent fill, coloured text + border, tinted hover (theme-aware) |
174
+ | `ghost` | `Boolean` | `false` | Ghost/borderless style no border or fill, coloured text + tinted hover (theme-aware). For compact toolbar/action buttons |
175
+ | `to` | `String` | — | Vue Router path (renders `<router-link>`) |
176
+ | `type` | `'button' \| 'submit' \| 'reset'` | `'button'` | HTML button type |
177
+ | `iconLeft` | `Boolean` | `false` | Render the slot icon before the label |
178
+ | `isRounded` | `Boolean` | — | Fully rounded corners |
179
+ | `isDisable` | `Boolean` | — | Disabled state |
180
+ | `size` | `String` | — | Size variant (use `BaseButtonSizeEnum`) |
181
+ | `isLoading` | `Boolean` | — | Show loading spinner |
182
+
183
+ **Slots:** `default`
184
+
185
+ **Example:**
186
+
187
+ ```vue
188
+ <template>
189
+ <BaseButton description="Submit" :color="BaseButtonEnum.GREEN" type="submit" />
190
+ <BaseButton description="Go to Users" :to="'/users'" />
191
+ <BaseButton description="Saving..." :isLoading="true" :isDisable="true" />
192
+ <BaseButton
193
+ description="Delete"
194
+ :color="BaseButtonEnum.RED"
195
+ :size="BaseButtonSizeEnum.SMALL"
196
+ />
197
+ <!-- Outlined / secondary -->
198
+ <BaseButton description="Import" :color="BaseButtonEnum.EMERALD" outline iconLeft>
199
+ <ArrowUpTrayIcon class="w-4 h-4 mr-1.5" />
200
+ </BaseButton>
201
+ <!-- Ghost / borderless toolbar action -->
202
+ <BaseButton description="Logs" :color="BaseButtonEnum.SKY" ghost iconLeft :size="BaseButtonSizeEnum.SMALL">
203
+ <ClipboardDocumentListIcon class="w-4 h-4 mr-1.5" />
204
+ </BaseButton>
205
+ </template>
206
+
207
+ <script setup lang="ts">
208
+ import { BaseButton, BaseButtonEnum, BaseButtonSizeEnum } from 'mgv-backoffice'
209
+ </script>
210
+ ```
211
+
212
+ ---
213
+
214
+ ### BaseLine
215
+
216
+ Horizontal divider with style variants.
217
+
218
+ **Props:**
219
+
220
+ | Prop | Type | Default | Description |
221
+ | ------ | -------- | --------------- | ----------------- |
222
+ | `mode` | `String` | `LineEnum.BASE` | Divider style |
223
+
224
+ **Example:**
225
+
226
+ ```vue
227
+ <template>
228
+ <BaseLine />
229
+ <BaseLine :mode="LineEnum.SQUARE" />
230
+ </template>
231
+
232
+ <script setup lang="ts">
233
+ import { BaseLine, LineEnum } from 'mgv-backoffice'
234
+ </script>
235
+ ```
236
+
237
+ ---
238
+
239
+ ### BaseLogo
240
+
241
+ SVG brand logo component.
242
+
243
+ **Props:**
244
+
245
+ | Prop | Type | Default | Description |
246
+ | ------ | -------- | ---------------------- | ------------ |
247
+ | `size` | `String` | `BaseLogoEnum.MEDIUM` | Logo size |
248
+
249
+ **Example:**
250
+
251
+ ```vue
252
+ <template>
253
+ <BaseLogo :size="BaseLogoEnum.LARGE" />
254
+ </template>
255
+
256
+ <script setup lang="ts">
257
+ import { BaseLogo, BaseLogoEnum } from 'mgv-backoffice'
258
+ </script>
259
+ ```
260
+
261
+ ---
262
+
263
+ ### BaseModal
264
+
265
+ > ⚠️ **Deprecated.** Prefer [`BaseConfirmModal`](#baseconfirmmodal) for confirm/cancel
266
+ > flows or [`BaseModalShell`](#basemodalshell) for custom dialogs — they support dark
267
+ > mode, teleport to `<body>`, and slot-based composition. Kept for backward
268
+ > compatibility.
269
+
270
+ Confirmation dialog with support for delete and success modes. `DELETE` mode renders
271
+ the confirm/cancel pair; any other mode renders the title, optional `description`,
272
+ the default slot, and a single OK button that emits `closeModal`.
273
+
274
+ **Props:**
275
+
276
+ | Prop | Type | Default | Description |
277
+ | ------------- | -------- | ----------- |-------------------------------------|
278
+ | `title` | `String` | **required**| Modal heading |
279
+ | `description` | `String` | — | Body text |
280
+ | `to` | `String` | `"/"` | Unused — declared for backward compatibility only; confirm just emits `confirmModal`, no navigation happens |
281
+ | `mode` | `String` | `'SUCCESS'` | Modal variant (use `BaseModalEnum`) |
282
+
283
+ **Events:**
284
+
285
+ | Event | Description |
286
+ | -------------- | ------------------------------- |
287
+ | `closeModal` | Emitted when modal is dismissed (cancel/OK button, backdrop click, or Escape) |
288
+ | `confirmModal` | Emitted on confirm action |
289
+
290
+ **Example:**
291
+
292
+ ```vue
293
+ <template>
294
+ <BaseModal
295
+ title="Delete this item?"
296
+ description="This action cannot be undone."
297
+ :mode="BaseModalEnum.DELETE"
298
+ @closeModal="showModal = false"
299
+ @confirmModal="handleDelete"
300
+ />
301
+ </template>
302
+
303
+ <script setup lang="ts">
304
+ import { ref } from 'vue'
305
+ import { BaseModal, BaseModalEnum } from 'mgv-backoffice'
306
+
307
+ const showModal = ref(true)
308
+ const handleDelete = () => { /* ... */ }
309
+ </script>
310
+ ```
311
+
312
+ ---
313
+
314
+ ### BaseRow
315
+
316
+ Card-like content container with border and shadow.
317
+
318
+ **Props:**
319
+
320
+ | Prop | Type | Default | Description |
321
+ | --------- | -------- | --------- | ---------------------- |
322
+ | `bgColor` | `String` | `"bg-white"` | Background color — a full Tailwind class (e.g. `"bg-slate-50"`), not a bare color name |
323
+
324
+ **Slots:** `default` — row content.
325
+
326
+ **Example:**
327
+
328
+ ```vue
329
+ <template>
330
+ <BaseRow>
331
+ <p>Card content goes here</p>
332
+ </BaseRow>
333
+ </template>
334
+
335
+ <script setup lang="ts">
336
+ import { BaseRow } from 'mgv-backoffice'
337
+ </script>
338
+ ```
339
+
340
+ ---
341
+
342
+ ### BaseSpinner
343
+
344
+ Animated loading spinner — a neutral ring with a coloured leading arc.
345
+
346
+ **Props:**
347
+
348
+ | Prop | Type | Default | Description |
349
+ |---------|----------------------------------------------------------------------------|----------|-------------------------------------------------------------|
350
+ | `size` | `'sm' \| 'md' \| 'lg' \| 'xl'` | `'sm'` | Diameter + ring thickness 16 / 24 / 32 / 48px. |
351
+ | `color` | `'blue' \| 'emerald' \| 'sky' \| 'indigo' \| 'teal' \| 'purple' \| 'red' \| 'amber'` | `'blue'` | Colour of the spinning arc. The track stays neutral gray. |
352
+
353
+ With no props it renders the original 16px blue spinner, so existing call sites are unaffected.
354
+
355
+ **Example:**
356
+
357
+ ```vue
358
+ <template>
359
+ <!-- legacy default -->
360
+ <BaseSpinner />
361
+ <!-- larger, themed -->
362
+ <BaseSpinner size="lg" color="emerald" />
363
+ </template>
364
+
365
+ <script setup lang="ts">
366
+ import { BaseSpinner } from 'mgv-backoffice'
367
+ </script>
368
+ ```
369
+
370
+ ---
371
+
372
+ ### BaseToast
373
+
374
+ Toast notification with positioning and auto-dismiss.
375
+
376
+ **Props:**
377
+
378
+ | Prop | Type | Default | Description |
379
+ | -------------- | ---------------- | --------- | ------------------------------------------ |
380
+ | `mode` | `BaseToastEnum` | **required** | Toast variant (SUCCESS, WARNING, ERROR) |
381
+ | `description` | `String` | **required** | Message text |
382
+ | `hasCloseIcon` | `Boolean` | `true` | Show close button |
383
+ | `positioning` | `String` | `PositioningEnum.TOP_RIGHT` | Screen position (use `PositioningEnum`) |
384
+ | `duration` | `Number` | `5000` | Auto-dismiss delay in milliseconds |
385
+
386
+ **Example:**
387
+
388
+ ```vue
389
+ <template>
390
+ <BaseToast
391
+ :mode="BaseToastEnum.SUCCESS"
392
+ description="Changes saved successfully!"
393
+ :positioning="PositioningEnum.TOP_RIGHT"
394
+ />
395
+ </template>
396
+
397
+ <script setup lang="ts">
398
+ import { BaseToast, BaseToastEnum, PositioningEnum } from 'mgv-backoffice'
399
+ </script>
400
+ ```
401
+
402
+ ---
403
+
404
+ ### ColoredSquares
405
+
406
+ Colored square indicator with randomized pastel accent.
407
+
408
+ **Props:**
409
+
410
+ | Prop | Type | Default | Description |
411
+ | ------- | -------- | ------- | --------------------------------- |
412
+ | `color` | `String` | — | Color variant (use `ColorsEnums`) |
413
+
414
+ **Slots:** `default` — label content.
415
+
416
+ **Example:**
417
+
418
+ ```vue
419
+ <template>
420
+ <ColoredSquares :color="ColorsEnums.BLUE">Category A</ColoredSquares>
421
+ </template>
422
+
423
+ <script setup lang="ts">
424
+ import { ColoredSquares, ColorsEnums } from 'mgv-backoffice'
425
+ </script>
426
+ ```
427
+
428
+ ---
429
+
430
+ ### EarningsCard
431
+
432
+ Earnings summary card with formatted currency display. Supports a signed P&L
433
+ mode that renders a red loss theme (and a downward trend glyph) for negative
434
+ amounts.
435
+
436
+ **Props:**
437
+
438
+ | Prop | Type | Default | Description |
439
+ | ---------- | -------- |-------------------------|----------------------|
440
+ | `title` | `String` | `'TOTAL EARNINGS'` | Card heading |
441
+ | `amount` | `Number` | `0` | Monetary value (a stringified number is coerced) |
442
+ | `subtitle` | `String` | `'Lifetime commission'` | Subheading text |
443
+ | `badge` | `String` | `''` | Optional badge label |
444
+ | `currency` | `String` | `'$'` | Currency symbol |
445
+ | `decimals` | `Number` | `2` | Fraction digits shown for the amount |
446
+ | `accent` | `'orange' \| 'emerald' \| 'red'` | `'orange'` | Card theme. `emerald` tints it green; `red` is the loss theme. |
447
+ | `signed` | `Boolean` | `false` | Treat `amount` as a signed P&L figure: a negative value automatically switches to the `red` loss theme and flips the trend glyph to point **down**; a non-negative value keeps the chosen `accent` and the upward glyph. |
448
+ | `compact` | `Boolean` | `false` | Dense variant for dashboards that tile many cards on one row: tighter padding, smaller type, trend glyph shrunk into the top-right corner. Don't combine with `badge` — both occupy the top-right corner. |
449
+
450
+ **Example:**
451
+
452
+ ```vue
453
+ <template>
454
+ <!-- Always-positive total: original behaviour. -->
455
+ <EarningsCard
456
+ title="Monthly Revenue"
457
+ :amount="12500"
458
+ subtitle="April 2026"
459
+ currency=""
460
+ />
461
+
462
+ <!-- Signed P&L: renders red + a down arrow when the amount is negative. -->
463
+ <EarningsCard
464
+ title="TOTAL P&L"
465
+ :amount="-128.4"
466
+ subtitle="Realised + unrealised"
467
+ accent="emerald"
468
+ signed
469
+ />
470
+ </template>
471
+
472
+ <script setup lang="ts">
473
+ import { EarningsCard } from 'mgv-backoffice'
474
+ </script>
475
+ ```
476
+
477
+ ---
478
+
479
+ ### EuroAmount
480
+
481
+ Formatted euro currency display with conditional color coding.
482
+
483
+ **Props:**
484
+
485
+ | Prop | Type | Default | Description |
486
+ | -------------- | --------- | ------- |-------------------------------------------------|
487
+ | `amount` | `Number` | — | Value to display |
488
+ | `beforeAmount` | `Number` | `null` | Previous value: red if `amount < beforeAmount`, green if `amount >= beforeAmount`. When omitted, a non-negative amount renders neutral (never green); a negative amount is always red. |
489
+ | `showCurrency` | `Boolean` | `true` | Show euro symbol |
490
+
491
+ **Example:**
492
+
493
+ ```vue
494
+ <template>
495
+ <!-- Shows green (amount > beforeAmount) -->
496
+ <EuroAmount :amount="1500" :beforeAmount="1200" />
497
+
498
+ <!-- Shows red (negative) -->
499
+ <EuroAmount :amount="-300" />
500
+
501
+ <!-- Without currency symbol -->
502
+ <EuroAmount :amount="800" :showCurrency="false" />
503
+ </template>
504
+
505
+ <script setup lang="ts">
506
+ import { EuroAmount } from 'mgv-backoffice'
507
+ </script>
508
+ ```
509
+
510
+ ---
511
+
512
+ ### Pagination
513
+
514
+ Page navigation with smart ellipsis for large page counts.
515
+
516
+ **Props:**
517
+
518
+ | Prop | Type | Default | Description |
519
+ | -------------- | -------- | ------- | ----------------------- |
520
+ | `totalItems` | `Number` | **required** | Total number of items |
521
+ | `itemsPerPage` | `Number` | `20` | Items shown per page |
522
+
523
+ **Events:**
524
+
525
+ | Event | Payload | Description |
526
+ | -------------- | -------- |----------------------------------|
527
+ | `page-changed` | `Number` | Emitted with the new page number |
528
+
529
+ **Example:**
530
+
531
+ ```vue
532
+ <template>
533
+ <Pagination
534
+ :totalItems="200"
535
+ :itemsPerPage="10"
536
+ @page-changed="onPageChange"
537
+ />
538
+ </template>
539
+
540
+ <script setup lang="ts">
541
+ import { Pagination } from 'mgv-backoffice'
542
+
543
+ const onPageChange = (page: number) => {
544
+ console.log('Page:', page)
545
+ }
546
+ </script>
547
+ ```
548
+
549
+ ---
550
+
551
+ ### TrendArrow
552
+
553
+ Up/down trend indicator displayed as a colored badge.
554
+
555
+ **Props:**
556
+
557
+ | Prop | Type | Default | Description |
558
+ | -------- | -------- | ------- |------------------------------------------------------|
559
+ | `number` | `Number` | — | Positive = green arrow up, negative = red arrow down, zero = neutral gray dash |
560
+ | `icon` | `String` | — | Optional suffix appended after the number (e.g. `"%"`) |
561
+
562
+ **Example:**
563
+
564
+ ```vue
565
+ <template>
566
+ <TrendArrow :number="12.5" /> <!-- Green up arrow -->
567
+ <TrendArrow :number="-3.2" /> <!-- Red down arrow -->
568
+ <TrendArrow :number="0" /> <!-- Neutral gray dash -->
569
+ </template>
570
+
571
+ <script setup lang="ts">
572
+ import { TrendArrow } from 'mgv-backoffice'
573
+ </script>
574
+ ```
575
+
576
+ ---
577
+
578
+ ## Enums
579
+
580
+ All enums are importable directly from the package:
581
+
582
+ ```ts
583
+ import {
584
+ AlertEnum,
585
+ BaseBadgeEnum,
586
+ BaseButtonEnum,
587
+ BaseButtonSizeEnum,
588
+ BaseLogoEnum,
589
+ BaseModalEnum,
590
+ BaseToastEnum,
591
+ ColorsEnums,
592
+ LineEnum,
593
+ PositioningEnum
594
+ } from 'mgv-backoffice'
595
+ ```
596
+
597
+ | Enum | Values |
598
+ | -------------------- |---------------------------------------------------------------|
599
+ | `AlertEnum` | `WARNING`, `ERROR`, `SUCCESS`, `INFO` |
600
+ | `BaseBadgeEnum` | `WIN`, `LOSE` |
601
+ | `BaseButtonEnum` | `RED`, `BLUE`, `WHITE`, `DARK`, `GREEN`, `EMERALD`, `YELLOW`, `PURPLE`, `SKY`, `GRAY`, `AMBER` |
602
+ | `BaseButtonSizeEnum` | `EXTRA_SMALL`, `SMALL`, `BASE`, `LARGE`, `EXTRA_LARGE` |
603
+ | `BaseLogoEnum` | `SMALL`, `MEDIUM`, `LARGE` (`BaseLoginEnum` is a deprecated alias) |
604
+ | `BaseModalEnum` | `DELETE`, `SUCCESS` |
605
+ | `BaseToastEnum` | `SUCCESS`, `WARNING`, `ERROR` |
606
+ | `ColorsEnums` | `NONE`, `RED`, `YELLOW`, `BLACK`, `GRAY`, `GREEN`, `BLUE` |
607
+ | `LineEnum` | `BASE`, `BASE_SHORTER`, `SQUARE` |
608
+ | `PositioningEnum` | `TOP_LEFT`, `TOP_RIGHT`, `BOTTOM_LEFT`, `BOTTOM_RIGHT` |
609
+
610
+ ---
611
+
612
+ ## Types
613
+
614
+ ```ts
615
+ import type { BreadCrumb, DropdownOption, PnL, PnLInputs } from 'mgv-backoffice'
616
+ ```
617
+
618
+ | Type | Shape |
619
+ | ---------------- | -------------------------------------- |
620
+ | `BreadCrumb` | `{ name: string; url: string }` |
621
+ | `DropdownOption` | `{ value: string \| number; label: string; title?: string; disabled?: boolean }` |
622
+ | `PnLInputs` | `{ buyPrice; lastPrice; filledQty }` (each `number \| string \| null \| undefined`) |
623
+ | `PnL` | `{ pnlUsd: number \| null; pnlPct: number \| null }` |
624
+
625
+ The other exported types `NavItem`, `NavSection`, `EntityPickerItem`,
626
+ `LoginCredentials`, `NotificationItem`, `SegmentedOption`, `TableColumn`,
627
+ `SpecField`, `SpecFieldType`, `SpecFieldValue`, `StatBreakdownItem`,
628
+ `PillPickerItem`, `DistributionBar`, `CredentialsView`, `CredentialsUpdate` —
629
+ are documented in their component's section.
630
+
631
+ ---
632
+
633
+ ## Utilities
634
+
635
+ ```ts
636
+ import { getBaseColor, getBaseColorOf } from 'mgv-backoffice'
637
+ ```
638
+
639
+ | Function | Signature | Returns |
640
+ | ---------------- | ---------------------------------- | ----------------------------------- |
641
+ | `getBaseColor` | `(c: AlertEnum) => string` | Tailwind color name for alert type |
642
+ | `getBaseColorOf` | `(c: ColorsEnums) => string` | Tailwind color name for color enum |
643
+
644
+ ### HTTP colours
645
+
646
+ ```ts
647
+ import {
648
+ methodBadgeSolid,
649
+ methodBadgeBright,
650
+ methodBadgeTinted,
651
+ statusBadgeSolid,
652
+ statusBadgeTinted,
653
+ statusBadgeSoft,
654
+ } from 'mgv-backoffice'
655
+ ```
656
+
657
+ Tailwind class helpers for HTTP method and status code badges. `Solid` variants
658
+ return saturated `bg-*-600` classes for use on neutral surfaces; `Bright` /
659
+ `Tinted` variants return softer combinations suitable for cards. `statusBadgeTinted`
660
+ takes `(status, isDark)` to adapt between themes.
661
+
662
+ `methodBadgeTinted(method, isDark)` gives each method its own hue on a soft
663
+ tinted surface (`bg-*-500/15` dark / `bg-*-100` light; GET blue, POST emerald,
664
+ PUT amber, DELETE red, PATCH purple, HEAD sky) — the card-chip palette used by
665
+ WireMate's mock/stub cards. `statusBadgeSoft(status, isDark)` is its status
666
+ companion keyed by status class (emerald 2xx / sky 3xx / amber 4xx / red 5xx).
667
+
668
+ ### Key/value row validators
669
+
670
+ ```ts
671
+ import { rowKeyMissing, rowValueMissing } from 'mgv-backoffice'
672
+ import type { KeyValueRowLike } from 'mgv-backoffice'
673
+ ```
674
+
675
+ | Function | Signature | Returns |
676
+ | ----------------- | ---------------------------------------------------------------------- | ------- |
677
+ | `rowValueMissing` | `(row: { key?, value?, matcherType? }) => boolean` | `true` when the row has a key but no value. |
678
+ | `rowKeyMissing` | `(row: { key?, value?, matcherType? }) => boolean` | `true` when the row has a value but no key. |
679
+
680
+ Consistency checks for dynamic key/value grids (header lists, query params,
681
+ metadata rows). Rows with `matcherType: 'absent'` are exempt — an absent
682
+ matcher intentionally carries no value.
683
+
684
+ ### Input validators
685
+
686
+ ```ts
687
+ import { isValidAbsoluteUrl, isValidJson, isValidXml, isValidBase64 } from 'mgv-backoffice'
688
+ ```
689
+
690
+ Pure, dependency-free form-input validators. The payload validators treat
691
+ empty/whitespace-only input as **valid** — required-ness is a separate rule
692
+ from well-formedness; `isValidAbsoluteUrl` validates a value that must exist,
693
+ so empty is invalid there.
694
+
695
+ | Function | Signature | Returns |
696
+ | -------------------- | ---------------------------- | ------- |
697
+ | `isValidAbsoluteUrl` | `(value: string) => boolean` | `true` for an absolute `http://` / `https://` URL (other schemes rejected). |
698
+ | `isValidJson` | `(str: string) => boolean` | `true` when empty or parseable as JSON. |
699
+ | `isValidXml` | `(str: string) => boolean` | `true` when empty or well-formed XML (DOMParser `<parsererror>` check; browser-only). |
700
+ | `isValidBase64` | `(str: string) => boolean` | `true` when empty or well-formed base64 (whitespace stripped, length/alphabet checked, then `atob` as the final authority). |
701
+
702
+ ### HTML sanitizer
703
+
704
+ ```ts
705
+ import { sanitizeHtml, isSafeHref } from 'mgv-backoffice'
706
+ ```
707
+
708
+ | Function | Signature | Returns |
709
+ | -------------- | ----------------------------------------------- | ------- |
710
+ | `sanitizeHtml` | `(raw: string \| undefined \| null) => string` | Allow-list–sanitised HTML safe for `v-html`. |
711
+ | `isSafeHref` | `(value: string) => boolean` | `true` if the href uses a safe scheme (http/https/mailto/tel, root-relative, or anchor) or is empty/whitespace-only. |
712
+
713
+ Allow-list sanitizer for strings bound into `v-html`. Keeps a small set of
714
+ formatting tags (`a`, `b`/`strong`, `i`/`em`, `code`, `pre`, `p`, `ul`/`ol`/`li`,
715
+ `span`, `div`, `br`), strips all other elements (unwrapping to text, or dropping
716
+ content entirely for `script`/`style`/`iframe`/etc.), removes every attribute
717
+ except `href`/`title` on anchors, keeps only allow-listed hrefs (http/https/
718
+ mailto/tel, root-relative `/`, anchors `#`, or empty — every other scheme such
719
+ as `javascript:`, `data:`, `ftp:` is stripped), and hardens surviving links with
720
+ `rel="noopener noreferrer" target="_blank"`. Browser-only (uses `DOMParser`).
721
+
722
+ ```ts
723
+ sanitizeHtml('<p>Hi<script>alert(1)<\/script></p>') // '<p>Hi</p>'
724
+ ```
725
+
726
+ ### Display formatters
727
+
728
+ ```ts
729
+ import {
730
+ fmtNumber,
731
+ fmtDate,
732
+ fmtDateTime,
733
+ fmtDateShort,
734
+ fmtPrice,
735
+ fmtPct,
736
+ fmtUsd,
737
+ // …plus fmtDateTimeMs, fmtCalendarDate, fmtCalendarDateTime,
738
+ // fmtMsAsSeconds, fmtBytes, fmtDuration, formatJson, stringifyValue
739
+ } from 'mgv-backoffice'
740
+ ```
741
+
742
+ Locale-aware, pure, dependency-free formatters for tables, logs and charts.
743
+ `fmtNumber`, `fmtDate`, `fmtCalendarDate`, `fmtCalendarDateTime` and
744
+ `fmtDuration` handle missing/non-finite input gracefully (rendering an
745
+ em-dash) so raw API values can be passed without pre-sanitising; the
746
+ epoch/numeric formatters (`fmtDateTime`, `fmtDateShort`, `fmtDateTimeMs`,
747
+ `fmtPrice`, `fmtPct`, `fmtUsd`) expect valid input and will render
748
+ `"Invalid Date"` / `"NaN"` otherwise.
749
+
750
+ | Function | Signature | Returns |
751
+ | -------------- | --------------------------------------------------------------- | ------- |
752
+ | `fmtNumber` | `(n: number \| string \| null \| undefined, digits = 4) => string` | Fixed-fraction number; em-dash for null/undefined/non-finite. Accepts numeric strings. |
753
+ | `fmtDate` | `(s: string \| number \| null \| undefined) => string` | Locale date-time from ISO string or epoch; em-dash on empty, raw value on parse failure. |
754
+ | `fmtDateTime` | `(ms: number) => string` | Compact `"Mon D, HH:MM"` label from epoch-millis (chart axes/tooltips). |
755
+ | `fmtDateTimeMs`| `(s: string \| number) => string` | Full 24-hour locale date-time WITH the millisecond fraction for dense feeds where same-second rows must stay distinguishable. |
756
+ | `fmtDateShort` | `(ms: number) => string` | Short `"Mon D"` calendar label from epoch-millis. |
757
+ | `fmtCalendarDate` | `(s: string \| number \| null \| undefined) => string` | `"Mon D, YYYY"` en-US calendar label; em-dash on empty, raw value on parse failure. |
758
+ | `fmtCalendarDateTime` | `(s: string \| number \| null \| undefined) => string` | `"Mon D, YYYY, HH:MM"` en-US calendar label with time of day. |
759
+ | `fmtMsAsSeconds` | `(ms: number \| null \| undefined) => string` | `"= 1.50 s"` magnitude hint for millisecond inputs (3 decimals below 1 s); `''` for non-positive input. |
760
+ | `fmtBytes` | `(bytes: number \| null \| undefined) => string` | `"512 B"` / `"1.5 KB"` / `"2.0 MB"`; `''` for zero/falsy input. |
761
+ | `fmtDuration` | `(ms: number \| null \| undefined, maxUnits = 2) => string` | Compact day/hour/minute duration, e.g. `"3d 5h"` / `"5h 12m"` / `"12m"`. Zero-value leading units are dropped; `maxUnits` caps how many units render. Em-dash for null/undefined/non-finite. |
762
+ | `fmtPrice` | `(n: number) => string` | Price with precision that scales to magnitude (more decimals for sub-cent values). |
763
+ | `fmtPct` | `(n: number, digits = 2) => string` | Percentage with explicit sign, e.g. `"+2.50%"`. |
764
+ | `fmtUsd` | `(v: number) => string` | Signed USD amount with leading sign, e.g. `"+$5.00"`. |
765
+ | `formatJson` | `(content: string) => string` | Pretty-prints parseable JSON with 2-space indentation; returns anything else verbatim. |
766
+ | `stringifyValue` | `(value: unknown) => string` | Display string for an unknown value: strings pass through, null/undefined → `''`, everything else JSON-serialized (`String()` fallback). |
767
+
768
+ ### Spec-form helpers
769
+
770
+ ```ts
771
+ import { buildSpecParams, firstInvalidNumericSpec } from 'mgv-backoffice'
772
+ ```
773
+
774
+ Value-map helpers for spec-driven forms (the state behind `BaseSpecFields`).
775
+ A spec whose `default` is `null` is treated as OPTIONAL — blank means "knob
776
+ disabled" and passes validation.
777
+
778
+ | Function | Signature | Returns |
779
+ | ------------------------ | --------- | ------- |
780
+ | `buildSpecParams` | `(specs: SpecField[] \| undefined, existing: Record<string, SpecFieldValue>) => Record<string, SpecFieldValue>` | Value map seeded from each spec's `default`, keeping non-null overlapping values the caller already has (an existing `null` is re-seeded from the spec's `default`). |
781
+ | `firstInvalidNumericSpec`| `(specs: SpecField[] \| undefined, params: Record<string, SpecFieldValue>) => string \| null` | Label of the first blank / NaN numeric field, or `null` when all numerics are valid. |
782
+
783
+ ### Profit & loss
784
+
785
+ ```ts
786
+ import { computePnL } from 'mgv-backoffice'
787
+ import type { PnL, PnLInputs } from 'mgv-backoffice'
788
+ ```
789
+
790
+ | Function | Signature | Returns |
791
+ | ------------ | ------------------------------- | ------- |
792
+ | `computePnL` | `(row: PnLInputs) => PnL` | Unrealised mark-to-market PnL in absolute USD and percent. Returns `{ pnlUsd: null, pnlPct: null }` when any input is missing, non-finite, or `buyPrice <= 0` / `lastPrice <= 0`. |
793
+
794
+ ```ts
795
+ interface PnLInputs {
796
+ buyPrice: number | string | null | undefined
797
+ lastPrice: number | string | null | undefined
798
+ filledQty: number | string | null | undefined
799
+ }
800
+
801
+ interface PnL {
802
+ pnlUsd: number | null
803
+ pnlPct: number | null
804
+ }
805
+ ```
806
+
807
+ ```ts
808
+ computePnL({ buyPrice: 100, lastPrice: 110, filledQty: 5 })
809
+ // { pnlUsd: 50, pnlPct: 10 }
810
+ ```
811
+
812
+ ---
813
+
814
+ ## Layout & shells (Tier 2 — full backoffice chrome)
815
+
816
+ ### BaseAppLayout
817
+
818
+ Root layout: dark/light page background, skip link, `<main>`-with-inert wrapper.
819
+ The `<main>` content offset tracks the sidebar width automatically —
820
+ `lg:ml-60` when expanded, `lg:ml-16` when collapsed (via `useSidebarCollapse()`) —
821
+ and adds `pt-14 lg:pt-0` for the mobile top bar while the sidebar is shown.
822
+
823
+ **Props:**
824
+
825
+ | Prop | Type | Default | Description |
826
+ | ---- | ---- | ------- | ----------- |
827
+ | `showSidebar` | `Boolean` | `true` | Render the `sidebar` slot. Set false for full-bleed pages. |
828
+ | `skipLinkLabel` | `String` | `'Skip to main content'` | Label for the accessibility skip link. |
829
+
830
+ **Slots:** `sidebar`, `default` (page content).
831
+
832
+ ```vue
833
+ <BaseAppLayout :show-sidebar="route.name !== 'presentation'">
834
+ <template #sidebar><AppSidebar /></template>
835
+ <RouterView />
836
+ </BaseAppLayout>
837
+ ```
838
+
839
+ ### BaseSidebar
840
+
841
+ Responsive sidebar with desktop fixed-positioning and mobile off-canvas
842
+ behavior, focus management, optional theme toggle, a desktop collapse
843
+ toggle (icon-only rail), an optional notifications bell, and configurable
844
+ nav sections.
845
+
846
+ **Props:**
847
+
848
+ | Prop | Type | Default | Description |
849
+ | ---- | ---- | ------- | ----------- |
850
+ | `sections` | `NavSection[]` | **required** | Grouped nav items. |
851
+ | `homeRouteName` | `String` | `'home'` | Route name for the logo / "go home" click. |
852
+ | `appName` | `String` | `''` | Optional app name in the footer. |
853
+ | `version` | `String` | `''` | Optional version string in the footer. |
854
+ | `showThemeToggle` | `Boolean` | `true` | Toggle the dark/light switch in the footer. |
855
+ | `collapsible` | `Boolean` | `true` | Show the desktop collapse toggle that shrinks the sidebar to an icon-only rail. |
856
+ | `showNotifications` | `Boolean` | `false` | Show the notifications bell (with unread badge) that toggles `BaseNotificationPanel`. |
857
+
858
+ > **Collapse state** is shared via `useSidebarCollapse()` (and persisted to
859
+ > localStorage) so `BaseAppLayout` can shrink the content offset from
860
+ > `lg:ml-60` to `lg:ml-16` in step with the rail. Collapsing only affects
861
+ > desktop (`lg+`); on mobile the sidebar stays a full off-canvas panel.
862
+
863
+ > **Notifications:** set `:show-notifications="true"` to render the bell,
864
+ > then drop a [`BaseNotificationPanel`](#basenotificationpanel) in your app.
865
+ > Both share state through `useNotifications()`, so the unread badge and the
866
+ > panel stay in sync.
867
+
868
+ **Slots:**
869
+
870
+ | Slot | Slot props | Description |
871
+ | -------- | ---------- | ----------- |
872
+ | `logo` | `{ size }` | Brand logo. Receives a `size` hint (28px in mobile bar, 52px in expanded sidebar, 36px in the collapsed rail). |
873
+ | `status` | — | Footer status row (e.g. health indicator, sync state). |
874
+ | `footer` | — | Replaces the default `appName` + `v{version}` line. |
875
+
876
+ **Types:**
877
+
878
+ ```ts
879
+ import type { NavItem, NavSection } from 'mgv-backoffice'
880
+
881
+ interface NavItem {
882
+ name: string // Vue Router route name
883
+ label: string // display text
884
+ icon: Component // typically a Heroicon
885
+ }
886
+
887
+ interface NavSection {
888
+ title: string
889
+ items: NavItem[]
890
+ }
891
+ ```
892
+
893
+ ```vue
894
+ <BaseSidebar :sections="navSections" home-route-name="projects" app-name="WireMate UI" :version="appVersion">
895
+ <template #logo="{ size }"><WireMateLogo :size="size" /></template>
896
+ <template #status>
897
+ <HealthIndicator />
898
+ </template>
899
+ </BaseSidebar>
900
+ ```
901
+
902
+ ---
903
+
904
+ ### BaseNotificationPanel
905
+
906
+ Left-anchored notification drawer (teleported to `<body>`, slides in from
907
+ the left, backdrop + Escape to close). Open/close state and the list live
908
+ in `useNotifications()`, so the sidebar bell and the panel stay in sync.
909
+
910
+ Enable the bell on the sidebar with `:show-notifications="true"`, drop one
911
+ `<BaseNotificationPanel />` anywhere in your app, and feed it data via the
912
+ composable.
913
+
914
+ **Props:**
915
+
916
+ | Prop | Type | Default | Description |
917
+ | ----------------- | --------- | ------------------------------ | ----------- |
918
+ | `title` | `String` | `'Notifications'` | Panel heading. |
919
+ | `emptyText` | `String` | `'You have no notifications.'` | Shown when the list is empty. |
920
+ | `showMarkAllRead` | `Boolean` | `true` | Render the "Mark all as read" action when there are unread items. |
921
+
922
+ **Emits:** `select` (the clicked notification's `id`; the row is also marked read).
923
+
924
+ ```vue
925
+ <script setup lang="ts">
926
+ import { BaseNotificationPanel, useNotifications } from 'mgv-backoffice'
927
+ const { setNotifications } = useNotifications()
928
+ setNotifications([
929
+ { id: 1, title: 'New comment', message: 'Alice replied to your post', time: '2m ago', type: 'info' },
930
+ { id: 2, title: 'Build passed', time: '1h ago', read: true, type: 'success' },
931
+ ])
932
+ </script>
933
+
934
+ <template>
935
+ <BaseSidebar :sections="navSections" :show-notifications="true" />
936
+ <BaseNotificationPanel @select="(id) => goTo(id)" />
937
+ </template>
938
+ ```
939
+
940
+ ```ts
941
+ import type { NotificationItem } from 'mgv-backoffice'
942
+
943
+ interface NotificationItem {
944
+ id: string | number
945
+ title: string
946
+ message?: string
947
+ time?: string // pre-formatted by you
948
+ read?: boolean
949
+ type?: 'info' | 'success' | 'warning' | 'error' // status dot colour
950
+ }
951
+ ```
952
+
953
+ ---
954
+
955
+ ## Authentication
956
+
957
+ ### BaseGoogleSignInButton
958
+
959
+ Google-branded "Sign in with Google" button (official multi-colour "G",
960
+ dark-mode surface swap). Purely presentational — it runs no OAuth itself;
961
+ listen on `click` and start your own Google Identity / Firebase / backend
962
+ flow there.
963
+
964
+ **Props:**
965
+
966
+ | Prop | Type | Default | Description |
967
+ | ---------- | --------- | -------------------------- | ----------- |
968
+ | `label` | `String` | `'Sign in with Google'` | Button text. |
969
+ | `loading` | `Boolean` | `false` | Disables and shows a spinner. |
970
+ | `disabled` | `Boolean` | `false` | Disables without the spinner. |
971
+ | `block` | `Boolean` | `true` | Full-width layout. |
972
+
973
+ **Emits:** `click` (only when not disabled/loading).
974
+
975
+ ### BaseLoginForm
976
+
977
+ Presentational sign-in card: email + password (with show/hide), an optional
978
+ "Remember me" checkbox, an error banner, the Google button + "or" divider,
979
+ and `logo` / `forgot` / `footer` slots. Owns its input state and emits
980
+ `submit` / `google-sign-in`; the app handles the actual request and feeds
981
+ back `loading` / `error`.
982
+
983
+ **Props:**
984
+
985
+ | Prop | Type | Default | Description |
986
+ | --------------- | --------- | ----------- | ----------- |
987
+ | `title` | `String` | `'Sign in'` | Card heading. |
988
+ | `subtitle` | `String` | `''` | Muted line under the heading. |
989
+ | `submitLabel` | `String` | `'Sign in'` | Submit button text. |
990
+ | `loading` | `Boolean` | `false` | Disables the form, spinner on submit. |
991
+ | `googleLoading` | `Boolean` | `false` | Disables the form, spinner on the Google button. |
992
+ | `error` | `String` | `''` | Error banner above the form. |
993
+ | `showGoogle` | `Boolean` | `true` | Render the Google button + divider. |
994
+ | `showRemember` | `Boolean` | `false` | Render the "Remember me" checkbox. |
995
+
996
+ **Emits:** `submit` (`LoginCredentials`), `google-sign-in`.
997
+
998
+ **Slots:** `logo`, `forgot` (next to the password label), `footer`.
999
+
1000
+ ```vue
1001
+ <script setup lang="ts">
1002
+ import { BaseLoginForm } from 'mgv-backoffice'
1003
+ import type { LoginCredentials } from 'mgv-backoffice'
1004
+
1005
+ async function onSubmit(creds: LoginCredentials) { /* call your API */ }
1006
+ function onGoogle() { /* start Google OAuth */ }
1007
+ </script>
1008
+
1009
+ <template>
1010
+ <BaseLoginForm
1011
+ subtitle="Welcome back"
1012
+ :show-remember="true"
1013
+ @submit="onSubmit"
1014
+ @google-sign-in="onGoogle"
1015
+ >
1016
+ <template #logo><MyLogo /></template>
1017
+ <template #forgot><a href="/forgot" class="text-sm text-emerald-600">Forgot?</a></template>
1018
+ <template #footer>No account? <a href="/signup" class="text-emerald-600">Sign up</a></template>
1019
+ </BaseLoginForm>
1020
+ </template>
1021
+ ```
1022
+
1023
+ ---
1024
+
1025
+ ## Modals & sections
1026
+
1027
+ ### BaseModalShell
1028
+
1029
+ Shared modal chrome `Teleport` to body, backdrop, themed card, escape key,
1030
+ aria-modal. Compose this rather than building modals from scratch.
1031
+
1032
+ **Props:**
1033
+
1034
+ | Prop | Type | Default | Description |
1035
+ | --------------- | --------- | ----------- | ----------- |
1036
+ | `title` | `String` | **required** | Modal heading. |
1037
+ | `icon` | `Component` | **required** | Heroicon rendered in a tinted circular chip left of the title (the `icon` slot can override the whole chip). |
1038
+ | `iconBgClass` | `String` | `''` | Background classes of the icon chip; empty falls back to the emerald tint (dark-mode aware). |
1039
+ | `iconClass` | `String` | `'text-emerald-600'` | Classes applied to the icon itself. |
1040
+ | `maxWidthClass` | `String` | `'max-w-md'` | Tailwind max-w utility for the card. |
1041
+ | `manualClose` | `Boolean` | `false` | If true, backdrop click and Escape do NOT auto-emit `cancel`. |
1042
+ | `scrollable` | `Boolean` | `false` | Switch to the large-content layout: a flex column capped at `90vh` with a fixed header/footer and a scrolling body. |
1043
+ | `subtitle` | `String` | `''` | Muted line under the title (scrollable layout only). |
1044
+
1045
+ **Slots:** `icon`, `default`, `footer`, and (scrollable layout) `header-actions` — content on the right of the header, e.g. a close button.
1046
+ **Events:** `cancel`, `backdrop`.
1047
+
1048
+ ### BaseConfirmModal
1049
+
1050
+ Confirmation dialog built on `BaseModalShell`. Variant chooses red (danger) or
1051
+ amber (warning) styling.
1052
+
1053
+ **Props:** `title`, `message`, `confirmText`, `cancelText`, `submittingText`,
1054
+ `variant: 'danger' | 'warning'`, `submitting`. While `submitting` is true,
1055
+ backdrop clicks and Escape stop dismissing the dialog.
1056
+
1057
+ **Slots:** `message` — rich markup replacing the plain `message` string;
1058
+ `default` — extra content below the message (warning banner, opt-in checkbox).
1059
+ **Events:** `confirm`, `cancel`.
1060
+
1061
+ ### BaseTextInputModal
1062
+
1063
+ "Ask the user for a single string and confirm" dialog. Preserves typed input
1064
+ on stray backdrop clicks; Escape always cancels.
1065
+
1066
+ **Props:** `title`, `message`, `initialValue`, `placeholder`, `inputLabel`,
1067
+ `confirmText`, `cancelText`, `submittingText`, `submitting`.
1068
+
1069
+ **Slots:** `icon` — override the default emerald document icon.
1070
+ **Events:** `confirm(value: string)`, `cancel`.
1071
+
1072
+ ### BaseEntityPickerModal
1073
+
1074
+ Searchable "pick one from a list" dialog. Pass `items` directly or an async
1075
+ `loader` that runs on mount.
1076
+
1077
+ **Props:** `title`, `message?`, `items?: EntityPickerItem[]`,
1078
+ `loader?: () => Promise<EntityPickerItem[]>`, `excludeId?`,
1079
+ `variant: 'emerald' | 'purple' | 'blue' | 'red' | 'amber'`,
1080
+ `searchPlaceholder`, `emptyMessage`, `noMatchMessage`, `confirmText`,
1081
+ `cancelText`, `submittingText`, `submitting`.
1082
+
1083
+ **Slots:** `icon` — override the default icon chip.
1084
+ **Events:** `confirm(itemId: string)`, `cancel`.
1085
+
1086
+ ```ts
1087
+ interface EntityPickerItem { id: string; label: string }
1088
+ ```
1089
+
1090
+ ### BaseCollapsibleSection
1091
+
1092
+ Section wrapper with a clickable header, optional badge, and a `default` slot
1093
+ for the body. Parent owns the `collapsed` state.
1094
+
1095
+ **Props:** `title`, `collapsed`, `badge?`, `bodyClass?`.
1096
+ **Events:** `toggle`.
1097
+
1098
+ ### BaseNotFoundPage
1099
+
1100
+ Drop-in 404 view.
1101
+
1102
+ **Props:** `code` (`'404'`), `message` (`'Page not found'`),
1103
+ `homeRouteName` (`'home'`), `homeLabel` (`'Go home'`).
1104
+
1105
+ ### BasePageHeader
1106
+
1107
+ Page-level header: icon badge + title/subtitle on the left, action
1108
+ buttons on the right. Gives top-level views a consistent header shape
1109
+ and width. The icon badge only renders when the `icon` slot is filled,
1110
+ so icon-less apps get a plain title/subtitle header.
1111
+
1112
+ **Props:**
1113
+
1114
+ | Prop | Type | Default | Description |
1115
+ | --------------- | -------- | ------------- | ----------- |
1116
+ | `title` | `String` | **required** | H1 text. |
1117
+ | `subtitle` | `String` | `''` | Muted line below the title. |
1118
+ | `iconColor` | `String` | `'emerald'` | Badge + icon colour: `'emerald' \| 'sky' \| 'red' \| 'amber'`. |
1119
+ | `maxWidthClass` | `String` | `'max-w-4xl'` | Tailwind max-w utility constraining header width. Pass `''` to skip the width wrapper entirely — the header then spans its container. |
1120
+ | `align` | `String` | `'center'` | Vertical alignment of the title block vs the actions: `'center'` or `'end'` (actions sit on the title baseline). |
1121
+ | `marginClass` | `String` | `'mb-8'` | Space under the header. Pass `''` when the parent manages vertical rhythm (`space-y-*`). |
1122
+
1123
+ **Slots:**
1124
+
1125
+ | Slot | Slot props | Description |
1126
+ | ---------- | ----------------- | ----------- |
1127
+ | `icon` | `{ iconClass }` | Page Heroicon. Bind `:class="iconClass"` for the theme-aware colour. Badge square renders only when this slot is filled. |
1128
+ | `subtitle` | | Rich subtitle content (links, `<strong>`, interpolation); overrides the `subtitle` prop. |
1129
+ | `actions` | | Buttons rendered on the right (refresh, destructive, etc.). |
1130
+
1131
+ ```vue
1132
+ <template>
1133
+ <BasePageHeader title="Request Journal" subtitle="Recent matched requests" icon-color="sky">
1134
+ <template #icon="{ iconClass }">
1135
+ <DocumentTextIcon class="w-5 h-5" :class="iconClass" />
1136
+ </template>
1137
+ <template #actions>
1138
+ <BaseButton description="Refresh" @click="reload" />
1139
+ </template>
1140
+ </BasePageHeader>
1141
+ </template>
1142
+
1143
+ <script setup lang="ts">
1144
+ import { BasePageHeader, BaseButton } from 'mgv-backoffice'
1145
+ import { DocumentTextIcon } from '@heroicons/vue/24/outline'
1146
+ </script>
1147
+ ```
1148
+
1149
+ ---
1150
+
1151
+ ### BaseToolbarButton
1152
+
1153
+ Bordered toolbar button — the "Refresh / Delete All" row that sits under
1154
+ a page header. Optional leading icon (via slot) plus a label.
1155
+
1156
+ **Props:**
1157
+
1158
+ | Prop | Type | Default | Description |
1159
+ | ---------- | --------- | ----------- | ----------- |
1160
+ | `label` | `String` | `''` | Button text. Omit for an icon-only button. |
1161
+ | `variant` | `String` | `'neutral'` | `'neutral'` (grey), `'danger'` (solid red) or `'ghost'` (slate h-9 outline toolbar/modal-footer buttons). |
1162
+ | `disabled` | `Boolean` | `false` | Greys out and blocks the click. |
1163
+ | `title` | `String` | `undefined` | Native tooltip / a11y text. |
1164
+ | `type` | `String` | `'button'` | Native button type. |
1165
+
1166
+ **Slots:**
1167
+
1168
+ | Slot | Slot props | Description |
1169
+ | ------ | --------------- | ----------- |
1170
+ | `icon` | `{ iconClass }` | Leading Heroicon. Bind `:class="iconClass"` (`w-4 h-4`); add state classes as needed. |
1171
+
1172
+ **Emits:** `click` (native `MouseEvent`).
1173
+
1174
+ ```vue
1175
+ <template>
1176
+ <BaseToolbarButton label="Refresh" :disabled="isLoading" title="Refresh" @click="reload">
1177
+ <template #icon="{ iconClass }">
1178
+ <ArrowPathIcon :class="[iconClass, { 'animate-spin': isLoading }]" />
1179
+ </template>
1180
+ </BaseToolbarButton>
1181
+ <BaseToolbarButton label="Delete All" variant="danger" @click="deleteAll">
1182
+ <template #icon="{ iconClass }">
1183
+ <TrashIcon :class="iconClass" />
1184
+ </template>
1185
+ </BaseToolbarButton>
1186
+ </template>
1187
+ ```
1188
+
1189
+ ---
1190
+
1191
+ ### BaseActionButton
1192
+
1193
+ Compact ghost action button — the colour-coded "Edit / Logs / Stub /
1194
+ Delete" actions on a card footer or action row. No border/fill at rest;
1195
+ a tinted hover background keyed to the semantic colour.
1196
+
1197
+ **Props:**
1198
+
1199
+ | Prop | Type | Default | Description |
1200
+ | ----------- | --------- | ----------- | ----------- |
1201
+ | `label` | `String` | `''` | Button text. Omit for an icon-only button. |
1202
+ | `color` | `String` | `'emerald'` | `'emerald' \| 'sky' \| 'indigo' \| 'teal' \| 'purple' \| 'red' \| 'amber' \| 'amberStrong'`. |
1203
+ | `disabled` | `Boolean` | `false` | Dims via opacity and suppresses the hover tint. |
1204
+ | `fullWidth` | `Boolean` | `false` | Stretch to fill its flex row (`flex-1`). |
1205
+ | `title` | `String` | `undefined` | Native tooltip. |
1206
+ | `ariaLabel` | `String` | `undefined` | Accessible label. |
1207
+ | `type` | `String` | `'button'` | Native button type. |
1208
+
1209
+ **Slots:**
1210
+
1211
+ | Slot | Slot props | Description |
1212
+ | ------ | --------------- | ----------- |
1213
+ | `icon` | `{ iconClass }` | Leading Heroicon. Bind `:class="iconClass"` (`w-4 h-4`). |
1214
+
1215
+ **Emits:** `click` (native `MouseEvent`).
1216
+
1217
+ ```vue
1218
+ <template>
1219
+ <BaseActionButton label="Edit" color="emerald" full-width title="Edit this mock" @click="edit">
1220
+ <template #icon="{ iconClass }">
1221
+ <PencilSquareIcon :class="iconClass" />
1222
+ </template>
1223
+ </BaseActionButton>
1224
+ <BaseActionButton label="Delete" color="red" @click="remove">
1225
+ <template #icon="{ iconClass }">
1226
+ <TrashIcon :class="iconClass" />
1227
+ </template>
1228
+ </BaseActionButton>
1229
+ </template>
1230
+ ```
1231
+
1232
+ ---
1233
+
1234
+ ### BaseCopyButton
1235
+
1236
+ Copy-to-clipboard icon button with transient "copied" feedback — clicks
1237
+ write `text` to the clipboard, swap the clipboard icon for a checkmark
1238
+ for `resetMs`, then revert. Uses the async Clipboard API with a
1239
+ hidden-textarea `execCommand` fallback for insecure origins. Emits
1240
+ `copied` / `error` so the parent can fire its own toast.
1241
+
1242
+ **Props:**
1243
+
1244
+ | Prop | Type | Default | Description |
1245
+ | ----------- | --------- | --------- | ----------- |
1246
+ | `text` | `String` | **required** | Value written to the clipboard. |
1247
+ | `label` | `String` | `''` | Used in the tooltip / aria-label (`Copy {label}`). |
1248
+ | `variant` | `String` | `'ghost'` | `'ghost'` (borderless `p-1` icon) or `'bordered'` (`w-9 h-9` boxed, turns emerald while copied). |
1249
+ | `resetMs` | `Number` | `1500` | How long the checkmark stays before reverting. |
1250
+ | `iconClass` | `String` | `'w-4 h-4'` | Icon size class. |
1251
+
1252
+ **Emits:** `copied`, `error(err)`.
1253
+
1254
+ ```vue
1255
+ <template>
1256
+ <!-- Inline ID copy, parent fires the toast -->
1257
+ <BaseCopyButton
1258
+ :text="stub.id"
1259
+ label="Stub ID"
1260
+ @copied="showToastMessage('Stub ID copied to clipboard', BaseToastEnum.SUCCESS)"
1261
+ @error="showToastMessage('Failed to copy stub ID', BaseToastEnum.ERROR)"
1262
+ />
1263
+ <!-- Boxed copy next to a read-only input -->
1264
+ <BaseCopyButton :text="mock.id" label="Mock ID" variant="bordered" :reset-ms="2000" />
1265
+ </template>
1266
+
1267
+ <script setup lang="ts">
1268
+ import { BaseCopyButton, BaseToastEnum } from 'mgv-backoffice'
1269
+ </script>
1270
+ ```
1271
+
1272
+ ---
1273
+
1274
+ ### BaseChipButton
1275
+
1276
+ Small tinted emerald "chip" action button — the compact "+ Add" pill used
1277
+ above repeatable form rows. Label comes from the default slot.
1278
+
1279
+ **Props:**
1280
+
1281
+ | Prop | Type | Default | Description |
1282
+ | ---------- | --------- | ------- | ----------- |
1283
+ | `size` | `String` | `'sm'` | `'sm'` = `px-2.5 py-1`; `'xs'` = `px-2 py-0.5` for tight corners. |
1284
+ | `disabled` | `Boolean` | `false` | Dims the chip and blocks clicks. |
1285
+
1286
+ **Emits:** `click`.
1287
+
1288
+ ```vue
1289
+ <BaseChipButton @click="addRow(rows)">+ Add</BaseChipButton>
1290
+ <BaseChipButton size="xs" @click="addNamespace">+ Add</BaseChipButton>
1291
+ ```
1292
+
1293
+ ---
1294
+
1295
+ ### BaseRemoveButton
1296
+
1297
+ The red "×" remove-row affordance used beside repeatable form rows. Name it
1298
+ for screen readers via `aria-label`; `title`, `disabled` and extra classes
1299
+ (`pt-1`, `self-start`, …) fall through as attrs.
1300
+
1301
+ **Emits:** `click`.
1302
+
1303
+ ```vue
1304
+ <BaseRemoveButton :aria-label="`Remove header ${i + 1}`" @click="rows.splice(i, 1)" />
1305
+ ```
1306
+
1307
+ ---
1308
+
1309
+ ### BaseStatusPill
1310
+
1311
+ Connection/health status pill: a colored dot (pulsing while `ok`) next to a
1312
+ short label on a tinted background.
1313
+
1314
+ **Props:**
1315
+
1316
+ | Prop | Type | Default | Description |
1317
+ | -------- | -------- | ------- | ----------- |
1318
+ | `status` | `String` | **required** | `'ok'` (emerald, pulsing), `'error'` (red), `'unknown'` (gray). |
1319
+ | `label` | `String` | **required** | Short text next to the dot, e.g. `WireMock Connected`. |
1320
+
1321
+ ```vue
1322
+ <BaseStatusPill :status="healthy ? 'ok' : 'error'" :label="healthy ? 'Connected' : 'Disconnected'" />
1323
+ ```
1324
+
1325
+ ---
1326
+
1327
+ ### BaseFileDropzone
1328
+
1329
+ Dashed "click to select a file" upload zone (extracted from WireMate's
1330
+ Postman-import modal). Renders a document-arrow-up icon (overridable via the
1331
+ `#icon` slot), a label line, and an optional dimmed hint line. Clicking opens
1332
+ the native file picker; dragging files onto the zone also works (the border
1333
+ highlights emerald while dragging). The hidden input resets after every
1334
+ selection, so picking the same file twice still emits.
1335
+
1336
+ **Props:**
1337
+
1338
+ | Prop | Type | Default | Description |
1339
+ | ---------- | --------- | ------- | ----------- |
1340
+ | `label` | `String` | **required** | Main line, e.g. `Click to select a Postman collection (.json)`. |
1341
+ | `hint` | `String` | `''` | Dimmed helper line below the label. |
1342
+ | `accept` | `String` | `''` | Forwarded to the input's `accept`. Dropped files are **not** filtered by it. |
1343
+ | `multiple` | `Boolean` | `false` | Allow multi-select; when `false`, a multi-file drop emits only the first file. |
1344
+ | `disabled` | `Boolean` | `false` | Dims the zone and ignores clicks/drops. |
1345
+
1346
+ **Emits:** `files` (`File[]`, never empty).
1347
+
1348
+ **Slots:** `icon` — replaces the default upload icon.
1349
+
1350
+ ```vue
1351
+ <BaseFileDropzone
1352
+ accept="application/json,.json"
1353
+ label="Click to select a Postman collection (.json)"
1354
+ hint="Exported from Postman → Export → Collection v2.1"
1355
+ @files="onFiles"
1356
+ />
1357
+ ```
1358
+
1359
+ ### BaseCodeBlock
1360
+
1361
+ Themed monospace `<pre>` for JSON payloads, request dumps and code snippets
1362
+ (extracted from WireMate's stub/request detail views). Preserves whitespace
1363
+ verbatim, scrolls both axes, and adapts to the theme. Extra classes (margins
1364
+ etc.) fall through via the normal class merge.
1365
+
1366
+ **Props:**
1367
+
1368
+ | Prop | Type | Default | Description |
1369
+ | ---------------- | -------- | -------- | ----------- |
1370
+ | `code` | `String` | **required** | The raw text to render. |
1371
+ | `variant` | `String` | `'soft'` | `'soft'` = tinted fill, no border (in-card look); `'bordered'` = bordered card fill (standalone look). |
1372
+ | `size` | `String` | `'sm'` | `'sm'` = `text-sm px-5 py-4`; `'xs'` = dense `text-xs p-3`. |
1373
+ | `maxHeightClass` | `String` | `''` | Optional Tailwind max-height utility, e.g. `max-h-96`. |
1374
+
1375
+ ```vue
1376
+ <BaseCodeBlock :code="formatJson(response.body)" size="xs" max-height-class="max-h-64" />
1377
+ ```
1378
+
1379
+ ---
1380
+
1381
+ ## Forms & tables
1382
+
1383
+ These components use `dark:` Tailwind variants, so the consuming app must map
1384
+ the `dark` variant to the `.dark` class that `useTheme()` toggles (see
1385
+ [Tailwind setup for consumers](#tailwind-setup-for-consumers)).
1386
+
1387
+ ### BaseInput
1388
+
1389
+ Themed text/number input carrying the shared field skin (slate border,
1390
+ `bg-slate-50` / dark `bg-slate-900` surface). Everything else — `placeholder`,
1391
+ `id`, `disabled`, `step`/`min`, extra classes like `font-mono` or
1392
+ `placeholder:*` — falls through via attrs and Vue class merging.
1393
+
1394
+ **Props:**
1395
+
1396
+ | Prop | Type | Default | Description |
1397
+ | ------------ | ------------------ | -------- | ----------- |
1398
+ | `modelValue` | `String \| Number \| null` | `''` | `v-model` value. |
1399
+ | `type` | `String` | `'text'` | Native input type. |
1400
+ | `size` | `String` | `'md'` | `'md'` = `px-3 py-2`, `'sm'` = `px-2 py-1.5`. |
1401
+ | `block` | `Boolean` | `true` | Full-width (`w-full`); set `false` for inline fields. |
1402
+
1403
+ **Emits:** `update:modelValue(value: string)` — always the raw string; parse
1404
+ numbers in the owner.
1405
+
1406
+ ```vue
1407
+ <BaseInput v-model="query" placeholder="e.g. AMD or BTC" class="font-mono" />
1408
+ ```
1409
+
1410
+ ### BaseSelect
1411
+
1412
+ Themed `<select>` sharing BaseInput's field skin. Options come from the
1413
+ default slot so callers keep full control of `<option>` rendering.
1414
+
1415
+ **Props:**
1416
+
1417
+ | Prop | Type | Default | Description |
1418
+ | ------------ | ------------------ | ------- | ----------- |
1419
+ | `modelValue` | `String \| null` | `undefined` | `v-model` value. When left undefined the browser keeps its own default selection. |
1420
+ | `size` | `String` | `'sm'` | `'sm'` = `px-2 py-1.5`, `'md'` = `px-3 py-2`. |
1421
+ | `block` | `Boolean` | `true` | Full-width; set `false` for inline selects. |
1422
+
1423
+ **Slots:** `default` — the `<option>` elements.
1424
+ **Emits:** `update:modelValue(value: string)`.
1425
+
1426
+ ```vue
1427
+ <BaseSelect v-model="strategyType">
1428
+ <option v-for="e in catalog" :key="e.type" :value="e.type" :title="e.description">
1429
+ {{ e.label }}
1430
+ </option>
1431
+ </BaseSelect>
1432
+ ```
1433
+
1434
+ ### BaseDropdown
1435
+
1436
+ Button-style single-select dropdown ("Select Social User "). Unlike
1437
+ `BaseSelect` (a native `<select>`), this renders a trigger button plus a
1438
+ floating menu, so the closed control shows a placeholder and a chevron that
1439
+ rotates while open — matching the app's filter dropdowns. Selecting a row
1440
+ emits its `value` and closes the menu; Escape and an outside click also close
1441
+ it.
1442
+
1443
+ **Props:**
1444
+
1445
+ | Prop | Type | Default | Description |
1446
+ | ------------- | -------------------------- | ------------ | ----------- |
1447
+ | `options` | `DropdownOption[]` | **required** | `{ value, label, title?, disabled? }` per row. |
1448
+ | `modelValue` | `String \| Number \| null` | `null` | Selected option's `value` (`v-model`). |
1449
+ | `placeholder` | `String` | `'Select'` | Trigger text shown when nothing is selected. |
1450
+ | `size` | `String` | `'md'` | `'md'` = `px-4 py-2.5` (app filter height), `'sm'` = `px-3 py-2`. Ignored when `triggerClass` is set. |
1451
+ | `block` | `Boolean` | `true` | Full-width; set `false` for an inline, content-width dropdown. |
1452
+ | `disabled` | `Boolean` | `false` | Disables the trigger. |
1453
+ | `ariaLabel` | `String` | `''` | Accessible name for the trigger/listbox when there is no visible label. |
1454
+ | `triggerClass`| `String` | `''` | Replaces the trigger's default slate skin entirely (including the `size` padding). |
1455
+ | `chevronClass`| `String` | `'w-5 h-5 text-slate-500 dark:text-slate-400'` | Classes for the chevron icon. |
1456
+
1457
+ **Emits:** `update:modelValue(value)`.
1458
+
1459
+ ```vue
1460
+ <BaseDropdown
1461
+ v-model="socialUserId"
1462
+ :options="socialUsers.map((u) => ({ value: u.id, label: u.name }))"
1463
+ placeholder="Select Social User"
1464
+ aria-label="Social user"
1465
+ />
1466
+ ```
1467
+
1468
+ ### BaseSegmentedControl
1469
+
1470
+ Segmented button group ("All | Stock | Crypto"). One button per option; the
1471
+ selected one gets the filled treatment and `aria-pressed="true"`.
1472
+
1473
+ **Props:**
1474
+
1475
+ | Prop | Type | Default | Description |
1476
+ | ------------- | ------------------- | -------- | ----------- |
1477
+ | `options` | `SegmentedOption[]` | **required** | `{ value, label, title? }` per button. |
1478
+ | `modelValue` | `String \| Number` | **required** | Selected option's `value` (`v-model`). |
1479
+ | `variant` | `String` | `'base'` | `'base'` (`px-3 py-2`, emerald-500 fill), `'wide'` (`px-4 py-2`, emerald-600 fill), `'toolbar'` (`h-9` uppercase `text-xs` with focus-visible rings). |
1480
+ | `ariaLabel` | `String` | `''` | When set, the wrapper renders `role="group"` + `aria-label`. |
1481
+ | `optionClass` | `Function` | — | `(option, active) => string` override for per-button fill classes (e.g. severity colours); layout stays owned by the variant. |
1482
+
1483
+ **Emits:** `update:modelValue(value)`.
1484
+
1485
+ ```vue
1486
+ <BaseSegmentedControl v-model="assetFilter" :options="ASSET_FILTERS" />
1487
+ <BaseSegmentedControl v-model="exchange" :options="EXCHANGES" variant="wide" aria-label="Exchange" />
1488
+ ```
1489
+
1490
+ ### BaseTable
1491
+
1492
+ Styling shell for data tables — **not** a data grid. Owns the table skin
1493
+ (slate header band, `px-4 py-3` header cells, empty-state row); body rows are
1494
+ the caller's own `<tr>` markup via the default slot. Wrap it yourself for
1495
+ scrolling/card chrome (e.g. a `BaseRow` with `overflow-x-auto`).
1496
+
1497
+ **Props:**
1498
+
1499
+ | Prop | Type | Default | Description |
1500
+ | ----------- | --------------- | ------------ | ----------- |
1501
+ | `columns` | `TableColumn[]` | **required** | `{ label, align? }`; `align: 'right'` right-aligns the header cell. |
1502
+ | `empty` | `Boolean` | `false` | True renders the empty-state row spanning every column. |
1503
+ | `emptyText` | `String` | `'No rows.'` | Fallback empty-state text. |
1504
+
1505
+ **Slots:** `default` the `<tr>` rows; `empty` — custom empty-state content.
1506
+
1507
+ ```vue
1508
+ <BaseTable :columns="COLUMNS" :empty="rows.length === 0">
1509
+ <template #empty>No trades match your filters.</template>
1510
+ <tr v-for="row in rows" :key="row.id" class="border-t border-slate-200 dark:border-slate-700">
1511
+
1512
+ </tr>
1513
+ </BaseTable>
1514
+ ```
1515
+
1516
+ ### BaseSpecFields
1517
+
1518
+ Spec-driven form fields: renders a select / checkbox / number input per
1519
+ `SpecField`, with labels and help text, in a responsive two-column grid. Feed
1520
+ it a backend-described catalogue and every form editing those values stays in
1521
+ lockstep. Never mutates `params` every edit is emitted as `(key, value)`
1522
+ and the owner writes it back into its own state.
1523
+
1524
+ **Props:**
1525
+
1526
+ | Prop | Type | Default | Description |
1527
+ | -------- | -------------------------------- | ------------ | ----------- |
1528
+ | `specs` | `SpecField[]` | **required** | `{ key, label, type: 'decimal' \| 'integer' \| 'boolean' \| 'select', default?, options?, step?, min?, help? }` (optional members are nullable). |
1529
+ | `params` | `Record<string, SpecFieldValue>` | **required** | Current values keyed by `spec.key`. |
1530
+
1531
+ **Slots:** `after` (`{ spec }`) — extra content under each field (e.g. a live
1532
+ preview attached to one key).
1533
+ **Emits:** `update(key: string, value: SpecFieldValue)` — numbers are parsed
1534
+ (`parseFloat`); unparseable input passes through raw so the owner's
1535
+ validation can catch it.
1536
+
1537
+ ```vue
1538
+ <BaseSpecFields :specs="entry.params" :params="form.params"
1539
+ @update="(key, value) => (form.params[key] = value)" />
1540
+ ```
1541
+
1542
+ ### BaseStatBreakdown
1543
+
1544
+ Compact per-item breakdown meant to sit under a summary/stat card (pairs with
1545
+ [`EarningsCard`](#earningscard)). Each item renders on its own line — label
1546
+ left, value right in monospace. A `null`/`undefined` value (a source that is
1547
+ unconfigured, unreachable, or has no matching rows) shows an em-dash rather
1548
+ than a misleading 0. With `signed`, values gain an explicit "+" and are
1549
+ coloured green/red by sign (same `"-$3.00"` / `"+$5.00"` shape as `fmtUsd`).
1550
+
1551
+ **Props:**
1552
+
1553
+ | Prop | Type | Default | Description |
1554
+ | ---------- | --------------------- | ------------ | ----------- |
1555
+ | `items` | `StatBreakdownItem[]` | **required** | `{ label, value }` per row. |
1556
+ | `currency` | `String` | `''` | Currency symbol placed after the sign, e.g. `'$'`. |
1557
+ | `decimals` | `Number` | `2` | Fraction digits shown for each value. |
1558
+ | `signed` | `Boolean` | `false` | Show an explicit "+" on non-negative values and colour rows green/red by sign. |
1559
+
1560
+ ```ts
1561
+ import type { StatBreakdownItem } from 'mgv-backoffice'
1562
+
1563
+ interface StatBreakdownItem {
1564
+ label: string // row label rendered on the left
1565
+ value: number | null | undefined // null/undefined renders as an em-dash
1566
+ }
1567
+ ```
1568
+
1569
+ ```vue
1570
+ <EarningsCard title="TOTAL P&L" :amount="totalPnl" signed />
1571
+ <BaseStatBreakdown
1572
+ :items="[
1573
+ { label: 'Alpaca', value: 42.5 },
1574
+ { label: 'Binance', value: -3.1 },
1575
+ { label: 'Kraken', value: null },
1576
+ ]"
1577
+ currency="$"
1578
+ signed
1579
+ />
1580
+ ```
1581
+
1582
+ ### BaseFilterChip
1583
+
1584
+ Colour-coded toggleable filter chip one-click event/category filters above
1585
+ a data feed. Idle renders a tinted border/background in the semantic colour;
1586
+ active renders a solid fill with white text (`aria-pressed` reflects the
1587
+ state). Layout classes (`h-9 flex-1`, …) pass through the class attribute;
1588
+ click handlers bind natively on the component.
1589
+
1590
+ **Props:**
1591
+
1592
+ | Prop | Type | Default | Description |
1593
+ | ---------- | --------- | --------- | ----------- |
1594
+ | `label` | `String` | `''` | Chip text; the default slot overrides it. |
1595
+ | `color` | `'emerald' \| 'sky' \| 'amber' \| 'red' \| 'slate'` | `'slate'` | Semantic colour of the idle tint and active fill. |
1596
+ | `active` | `Boolean` | `false` | Whether the chip's filter is applied (solid fill). |
1597
+ | `disabled` | `Boolean` | `false` | Greys out + blocks the click. |
1598
+ | `title` | `String` | — | Native tooltip. |
1599
+
1600
+ ```vue
1601
+ <BaseFilterChip
1602
+ v-for="f in filters"
1603
+ :key="f.key"
1604
+ class="h-9 flex-1"
1605
+ :color="f.color"
1606
+ :active="isActive(f)"
1607
+ :title="f.title"
1608
+ @click="toggle(f)"
1609
+ >{{ f.label }}</BaseFilterChip>
1610
+ ```
1611
+
1612
+ ### BaseCredentialsForm
1613
+
1614
+ One service's API-credentials card: key id + secret + base/data URLs, with
1615
+ the has-secret handling (placeholder dots, blank-keeps-stored-secret), the
1616
+ save-validation ladder and a saving spinner. Load/save results are EMITTED —
1617
+ the parent owns toasts / error banners. Exposes `load()` so a parent Reload
1618
+ button can re-pull several cards in parallel.
1619
+
1620
+ **Props:** `title` + `idPrefix` + `fetchFn: () => Promise<CredentialsView>` +
1621
+ `updateFn: (body: CredentialsUpdate) => Promise<CredentialsView>` +
1622
+ `defaults: { baseUrl, dataUrl }` (required); `subtitle`, `keyLabel`,
1623
+ `keyPlaceholder`, `secretLabel`, `secretPlaceholder`, `secretSetHint`,
1624
+ `permissionsHint`, `requiredKeyMessage`, `requiredSecretMessage`,
1625
+ `savedMessage`, `saveLabel` (optional copy overrides).
1626
+
1627
+ **Slots:** `no-secret-hint` — rich help while no secret is stored;
1628
+ `base-url-extra` (`{ form }`) — extras under the Base URL field (e.g.
1629
+ live/paper shortcut buttons that write into the form); `footer` — extra
1630
+ content at the card's bottom.
1631
+
1632
+ **Emits:** `saved(message)`, `error(message)`, `load-error(message)`.
1633
+
1634
+ ```vue
1635
+ <BaseCredentialsForm
1636
+ ref="card"
1637
+ title="Alpaca API"
1638
+ id-prefix="alpaca"
1639
+ :fetch-fn="fetchAlpaca"
1640
+ :update-fn="updateAlpaca"
1641
+ :defaults="{ baseUrl: LIVE_BASE, dataUrl: DATA_URL }"
1642
+ @saved="onSaved"
1643
+ @error="onError"
1644
+ @load-error="onLoadError"
1645
+ />
1646
+ ```
1647
+
1648
+ ---
1649
+
1650
+ ### BasePillPickerModal
1651
+
1652
+ "Pick one of many" modal: every item rendered as a clickable pill, narrowed
1653
+ by a free-text filter and an optional segmented group toggle. Clicking a pill
1654
+ emits `pick` with the item; backdrop / Escape / the footer Close emit `close`.
1655
+ Narrowing state lives inside, so a `v-if`-mounted instance always opens fresh.
1656
+
1657
+ **Props:** `title` + `items: PillPickerItem[]` (required);
1658
+ `groups?: SegmentedOption<string>[]` (renders the group toggle with an
1659
+ `allLabel` option prepended, narrowing by each item's `group`); `icon?`
1660
+ (defaults to the magnifying glass), `subtitle?`, `searchPlaceholder`,
1661
+ `emptyMessage`, `noMatchMessage`, `mono` (mono font for the filter input and
1662
+ pills — symbols, codes, ids), `maxWidthClass` (default `max-w-2xl`),
1663
+ `closeText`, `groupAriaLabel`, `allLabel`.
1664
+
1665
+ **Emits:** `pick(item: PillPickerItem)`, `close`.
1666
+
1667
+ ```ts
1668
+ interface PillPickerItem {
1669
+ id: string // unique key; identifies the pick
1670
+ label: string // pill text; what the filter matches
1671
+ group?: string // segmented-toggle bucket
1672
+ title?: string // pill tooltip
1673
+ }
1674
+ ```
1675
+
1676
+ ```vue
1677
+ <BasePillPickerModal
1678
+ v-if="open"
1679
+ title="Symbols"
1680
+ :items="symbols.map(s => ({ id: s.id, label: s.symbol, group: s.assetClass }))"
1681
+ :groups="[{ value: 'STOCK', label: 'STOCK' }, { value: 'CRYPTO', label: 'CRYPTO' }]"
1682
+ mono
1683
+ @pick="apply"
1684
+ @close="open = false"
1685
+ />
1686
+ ```
1687
+
1688
+ ---
1689
+
1690
+ ### BaseBarDistribution
1691
+
1692
+ Compact value-distribution chart: one thin rounded bar per distinct
1693
+ value, count labelled on top and the value underneath — scrolls
1694
+ sideways when there are many bars. Pure Tailwind, no chart library.
1695
+ Extracted from TradeAutomation's variant-stats modal.
1696
+
1697
+ **Props:**
1698
+
1699
+ | Prop | Type | Default | Description |
1700
+ | -------------- | -------- | ---------------------- | ----------- |
1701
+ | `bars` | `Array` | **required** | `DistributionBar[]` — `{ label, count }` per bar, in display order (sort ascending for numeric values). |
1702
+ | `ariaLabel` | `String` | `'Value distribution'` | Accessible description of the chart. |
1703
+ | `countNoun` | `String` | `'item'` | Noun for each bar's tooltip count, e.g. `'variant'` → "3 variants". |
1704
+ | `titlePrefix` | `String` | `''` | Tooltip prefix before the value, e.g. the field name. |
1705
+ | `maxBarHeight` | `Number` | `56` | Height of the tallest bar, in px. |
1706
+ | `barClass` | `String` | emerald fill | Tailwind classes for the bar fill. |
1707
+
1708
+ ```vue
1709
+ <BaseBarDistribution
1710
+ :bars="[{ label: '0.5', count: 1 }, { label: '1', count: 4 }]"
1711
+ aria-label="Distribution of Take profit across variants"
1712
+ title-prefix="Take profit"
1713
+ count-noun="variant"
1714
+ />
1715
+ ```
1716
+
1717
+ ---
1718
+
1719
+ ## Composables
1720
+
1721
+ ```ts
1722
+ import {
1723
+ initTheme,
1724
+ useTheme,
1725
+ useThemeClasses,
1726
+ useEscapeKey,
1727
+ useDebouncedRef,
1728
+ useToast,
1729
+ useMobileSidebar,
1730
+ useSidebarCollapse,
1731
+ useNotifications,
1732
+ useQueryParamSync,
1733
+ useFieldClasses,
1734
+ usePolling,
1735
+ } from 'mgv-backoffice'
1736
+ import type {
1737
+ UseThemeOptions,
1738
+ UseSidebarCollapseOptions,
1739
+ UsePollingOptions,
1740
+ } from 'mgv-backoffice'
1741
+ ```
1742
+
1743
+ | Composable | Purpose |
1744
+ | ---------- | ------- |
1745
+ | `initTheme({ storageKey? })` | Explicitly initialize the theme singleton. Call in your app entry point **before mounting** when you need a custom storage key — library components call `useTheme()` internally, so a component mounting first would otherwise lock in the default key (a dev-mode warning fires if that happens). |
1746
+ | `useTheme({ storageKey? })` | Singleton dark/light controller. Toggles `<html class="dark">` and persists via localStorage (default key `'mgv-theme'`). Prefer `initTheme` at app entry for custom keys. |
1747
+ | `useThemeClasses()` | Named Tailwind class roles for dark/light (card, border, primaryText, mutedText, dimText, input, ghostButton, emeraldText, redText, …). Since 1.34.0 returns a `reactive` object of plain strings — bind `t.card` directly, never `t.card.value` (the old ComputedRef shape leaked ref internals into `:class` bindings). |
1748
+ | `useEscapeKey(handler)` | Component-scoped Escape key listener. |
1749
+ | `useDebouncedRef(source, delay?)` | Debounced mirror of a ref. Timer cleared on scope dispose. |
1750
+ | `useToast(durationMs?)` | Per-component toast state: `{ showToast, toastMessage, toastType, showToastMessage }`. `showToastMessage` also accepts a per-call duration override. |
1751
+ | `useMobileSidebar()` | Singleton state shared between `BaseSidebar` and `BaseAppLayout` for the off-canvas open/closed flag. |
1752
+ | `useSidebarCollapse({ storageKey? })` | Singleton collapsed/expanded state for the desktop sidebar rail, shared between `BaseSidebar` and `BaseAppLayout` and persisted to localStorage (default key `'mgv-sidebar-collapsed'`). |
1753
+ | `useNotifications()` | Singleton notification state shared by the sidebar bell and `BaseNotificationPanel`: `{ notifications, unreadCount, open, openPanel, closePanel, togglePanel, setNotifications, add, remove, markRead, markAllRead, clear }`. |
1754
+ | `useQueryParamSync()` | URL-query mirroring for filterable views: `{ qparam(name), qenum(name, allowed, fallback), replaceQuery(next) }`. Read filters from the query string once on setup, write changes back with `router.replace` (no-op when unchanged) so filtered views stay shareable without polluting history. |
1755
+ | `useFieldClasses()` | Shared form-field class strings for the gray/emerald form skin: `{ label, input, requiredInput(value) }`. `requiredInput` returns a red border+ring skin while the value is empty and the standard skin otherwise. |
1756
+ | `usePolling(fn, intervalMs, { immediate?, pauseWhenHidden? })` | Visibility-gated polling loop bound to the component lifecycle: starts on mount, stops on unmount, pauses while the tab is hidden and refreshes + resumes on return to visible (both default on). Pass `intervalMs: null` for refresh-only mode (run on mount + each return-to-visible, no timer). Returns `{ start, stop, active }`. A loop stopped via `stop()` stays stopped across hide/show cycles (since 1.36.0) — only a visibility-paused loop auto-resumes. Catch errors inside `fn` — the loop never swallows rejections. |
1757
+
1758
+ ---
1759
+
1760
+ ## Typography
1761
+
1762
+ Since 1.33.0 the library ships the shared brand typography: the stylesheet
1763
+ loads **Fira Sans** (UI text) and **Fira Code** (numerals/data) from Google
1764
+ Fonts via `@import`, registers them as the Tailwind `--font-sans` /
1765
+ `--font-mono` theme defaults, and applies `font-family: var(--font-sans)` to
1766
+ `body`. Consumers get the fonts just by importing the lib CSS — remove any
1767
+ app-local Google Fonts `<link rel="stylesheet">` and `--font-sans`/`--font-mono`
1768
+ overrides. Keep (or add) the preconnect hints in `index.html` for a faster
1769
+ first paint:
1770
+
1771
+ ```html
1772
+ <link rel="preconnect" href="https://fonts.googleapis.com" />
1773
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
1774
+ ```
1775
+
1776
+ ## Tailwind setup for consumers
1777
+
1778
+ The lib's components rely on Tailwind utility classes (including dark-mode
1779
+ variants). Consumers should add the lib's `dist` output to their Tailwind
1780
+ `content` paths so the JIT can see the class names:
1781
+
1782
+ ```js
1783
+ // tailwind.config.js
1784
+ export default {
1785
+ content: [
1786
+ './index.html',
1787
+ './src/**/*.{vue,ts}',
1788
+ './node_modules/mgv-backoffice/dist/**/*.{js,mjs,cjs,vue}',
1789
+ ],
1790
+ }
1791
+ ```
1792
+
1793
+ The legacy `tailwind.safelist.js` only covers the v1 components; the
1794
+ recommended path for v4+ is the `content` glob above.