mgv-backoffice 1.42.0 → 1.43.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,1999 +1,2000 @@
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.GREEN` | 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'` | `'emerald'` | Colour of the spinning arc. The track stays neutral gray. |
352
-
353
- With no props it renders a 16px emerald spinner. For page loaders use `size="xl"` centered, e.g. `<div class="flex justify-center py-12"><BaseSpinner size="xl" /></div>`.
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
- ### BaseSidebarUser
905
-
906
- Signed-in user block for the `BaseSidebar` `footer` slot: initials avatar,
907
- name and email (a link to the profile page when `to` is set) and a Logout
908
- button that emits `logout`.
909
-
910
- **Props:** `name` (required), `email`, `to` (profile route), `showLogout` (`true`),
911
- `logoutLabel` (`'Logout'`), `profileLabel` (`'View profile'`, tooltip).
912
- **Emits:** `logout`.
913
-
914
- ```vue
915
- <BaseSidebar :sections="nav">
916
- <template #footer>
917
- <BaseSidebarUser :name="me.username" :email="me.email" :to="{ name: 'Profile' }" @logout="logOut" />
918
- </template>
919
- </BaseSidebar>
920
- ```
921
-
922
- ### BaseNotificationPanel
923
-
924
- Left-anchored notification drawer (teleported to `<body>`, slides in from
925
- the left, backdrop + Escape to close). Open/close state and the list live
926
- in `useNotifications()`, so the sidebar bell and the panel stay in sync.
927
-
928
- Enable the bell on the sidebar with `:show-notifications="true"`, drop one
929
- `<BaseNotificationPanel />` anywhere in your app, and feed it data via the
930
- composable.
931
-
932
- **Props:**
933
-
934
- | Prop | Type | Default | Description |
935
- | ----------------- | --------- | ------------------------------ | ----------- |
936
- | `title` | `String` | `'Notifications'` | Panel heading. |
937
- | `emptyText` | `String` | `'You have no notifications.'` | Shown when the list is empty. |
938
- | `showMarkAllRead` | `Boolean` | `true` | Render the "Mark all as read" action when there are unread items. |
939
-
940
- **Emits:** `select` (the clicked notification's `id`; the row is also marked read).
941
-
942
- ```vue
943
- <script setup lang="ts">
944
- import { BaseNotificationPanel, useNotifications } from 'mgv-backoffice'
945
- const { setNotifications } = useNotifications()
946
- setNotifications([
947
- { id: 1, title: 'New comment', message: 'Alice replied to your post', time: '2m ago', type: 'info' },
948
- { id: 2, title: 'Build passed', time: '1h ago', read: true, type: 'success' },
949
- ])
950
- </script>
951
-
952
- <template>
953
- <BaseSidebar :sections="navSections" :show-notifications="true" />
954
- <BaseNotificationPanel @select="(id) => goTo(id)" />
955
- </template>
956
- ```
957
-
958
- ```ts
959
- import type { NotificationItem } from 'mgv-backoffice'
960
-
961
- interface NotificationItem {
962
- id: string | number
963
- title: string
964
- message?: string
965
- time?: string // pre-formatted by you
966
- read?: boolean
967
- type?: 'info' | 'success' | 'warning' | 'error' // status dot colour
968
- }
969
- ```
970
-
971
- ---
972
-
973
- ## Authentication
974
-
975
- ### BaseGoogleSignInButton
976
-
977
- Google-branded "Sign in with Google" button (official multi-colour "G",
978
- dark-mode surface swap). Purely presentational — it runs no OAuth itself;
979
- listen on `click` and start your own Google Identity / Firebase / backend
980
- flow there.
981
-
982
- **Props:**
983
-
984
- | Prop | Type | Default | Description |
985
- | ---------- | --------- | -------------------------- | ----------- |
986
- | `label` | `String` | `'Sign in with Google'` | Button text. |
987
- | `loading` | `Boolean` | `false` | Disables and shows a spinner. |
988
- | `disabled` | `Boolean` | `false` | Disables without the spinner. |
989
- | `block` | `Boolean` | `true` | Full-width layout. |
990
-
991
- **Emits:** `click` (only when not disabled/loading).
992
-
993
- ### BaseLoginForm
994
-
995
- Presentational sign-in card: email + password (with show/hide), an optional
996
- "Remember me" checkbox, an error banner, the Google button + "or" divider,
997
- and `logo` / `forgot` / `footer` slots. Owns its input state and emits
998
- `submit` / `google-sign-in`; the app handles the actual request and feeds
999
- back `loading` / `error`.
1000
-
1001
- **Props:**
1002
-
1003
- | Prop | Type | Default | Description |
1004
- | --------------- | --------- | ----------- | ----------- |
1005
- | `title` | `String` | `'Sign in'` | Card heading. |
1006
- | `subtitle` | `String` | `''` | Muted line under the heading. |
1007
- | `submitLabel` | `String` | `'Sign in'` | Submit button text. |
1008
- | `loading` | `Boolean` | `false` | Disables the form, spinner on submit. |
1009
- | `googleLoading` | `Boolean` | `false` | Disables the form, spinner on the Google button. |
1010
- | `error` | `String` | `''` | Error banner above the form. |
1011
- | `showGoogle` | `Boolean` | `true` | Render the Google button + divider. |
1012
- | `showRemember` | `Boolean` | `false` | Render the "Remember me" checkbox. |
1013
-
1014
- **Emits:** `submit` (`LoginCredentials`), `google-sign-in`.
1015
-
1016
- **Slots:** `logo`, `forgot` (next to the password label), `footer`.
1017
-
1018
- ```vue
1019
- <script setup lang="ts">
1020
- import { BaseLoginForm } from 'mgv-backoffice'
1021
- import type { LoginCredentials } from 'mgv-backoffice'
1022
-
1023
- async function onSubmit(creds: LoginCredentials) { /* call your API */ }
1024
- function onGoogle() { /* start Google OAuth */ }
1025
- </script>
1026
-
1027
- <template>
1028
- <BaseLoginForm
1029
- subtitle="Welcome back"
1030
- :show-remember="true"
1031
- @submit="onSubmit"
1032
- @google-sign-in="onGoogle"
1033
- >
1034
- <template #logo><MyLogo /></template>
1035
- <template #forgot><a href="/forgot" class="text-sm text-emerald-600">Forgot?</a></template>
1036
- <template #footer>No account? <a href="/signup" class="text-emerald-600">Sign up</a></template>
1037
- </BaseLoginForm>
1038
- </template>
1039
- ```
1040
-
1041
- ---
1042
-
1043
- ## Modals & sections
1044
-
1045
- ### BaseModalShell
1046
-
1047
- Shared modal chrome — `Teleport` to body, backdrop, themed card, escape key,
1048
- aria-modal. Compose this rather than building modals from scratch.
1049
-
1050
- **Props:**
1051
-
1052
- | Prop | Type | Default | Description |
1053
- | --------------- | --------- | ----------- | ----------- |
1054
- | `title` | `String` | **required** | Modal heading. |
1055
- | `icon` | `Component` | **required** | Heroicon rendered in a tinted circular chip left of the title (the `icon` slot can override the whole chip). |
1056
- | `iconBgClass` | `String` | `''` | Background classes of the icon chip; empty falls back to the emerald tint (dark-mode aware). |
1057
- | `iconClass` | `String` | `'text-emerald-600'` | Classes applied to the icon itself. |
1058
- | `maxWidthClass` | `String` | `'max-w-md'` | Tailwind max-w utility for the card. |
1059
- | `manualClose` | `Boolean` | `false` | If true, backdrop click and Escape do NOT auto-emit `cancel`. |
1060
- | `scrollable` | `Boolean` | `false` | Switch to the large-content layout: a flex column capped at `90vh` with a fixed header/footer and a scrolling body. |
1061
- | `subtitle` | `String` | `''` | Muted line under the title (scrollable layout only). |
1062
-
1063
- **Slots:** `icon`, `default`, `footer`, and (scrollable layout) `header-actions` — content on the right of the header, e.g. a close button.
1064
- **Events:** `cancel`, `backdrop`.
1065
-
1066
- ### BaseConfirmModal
1067
-
1068
- Confirmation dialog built on `BaseModalShell`. Variant chooses red (danger) or
1069
- amber (warning) styling.
1070
-
1071
- **Props:** `title`, `message`, `confirmText`, `cancelText`, `submittingText`,
1072
- `variant: 'danger' | 'warning'`, `submitting`. While `submitting` is true,
1073
- backdrop clicks and Escape stop dismissing the dialog.
1074
-
1075
- **Slots:** `message` — rich markup replacing the plain `message` string;
1076
- `default` — extra content below the message (warning banner, opt-in checkbox).
1077
- **Events:** `confirm`, `cancel`.
1078
-
1079
- ### BaseTextInputModal
1080
-
1081
- "Ask the user for a single string and confirm" dialog. Preserves typed input
1082
- on stray backdrop clicks; Escape always cancels.
1083
-
1084
- **Props:** `title`, `message`, `initialValue`, `placeholder`, `inputLabel`,
1085
- `confirmText`, `cancelText`, `submittingText`, `submitting`.
1086
-
1087
- **Slots:** `icon` — override the default emerald document icon.
1088
- **Events:** `confirm(value: string)`, `cancel`.
1089
-
1090
- ### BaseEntityPickerModal
1091
-
1092
- Searchable "pick one from a list" dialog. Pass `items` directly or an async
1093
- `loader` that runs on mount.
1094
-
1095
- **Props:** `title`, `message?`, `items?: EntityPickerItem[]`,
1096
- `loader?: () => Promise<EntityPickerItem[]>`, `excludeId?`,
1097
- `variant: 'emerald' | 'purple' | 'blue' | 'red' | 'amber'`,
1098
- `searchPlaceholder`, `emptyMessage`, `noMatchMessage`, `confirmText`,
1099
- `cancelText`, `submittingText`, `submitting`.
1100
-
1101
- **Slots:** `icon` — override the default icon chip.
1102
- **Events:** `confirm(itemId: string)`, `cancel`.
1103
-
1104
- ```ts
1105
- interface EntityPickerItem { id: string; label: string }
1106
- ```
1107
-
1108
- ### BaseCollapsibleSection
1109
-
1110
- Section wrapper with a clickable header, optional badge, and a `default` slot
1111
- for the body. Parent owns the `collapsed` state.
1112
-
1113
- **Props:** `title`, `collapsed`, `badge?`, `bodyClass?`.
1114
- **Events:** `toggle`.
1115
-
1116
- ### BaseNotFoundPage
1117
-
1118
- Drop-in 404 view.
1119
-
1120
- **Props:** `code` (`'404'`), `message` (`'Page not found'`),
1121
- `homeRouteName` (`'home'`), `homeLabel` (`'Go home'`).
1122
-
1123
- ### BasePageHeader
1124
-
1125
- Page-level header: icon badge + title/subtitle on the left, action
1126
- buttons on the right. Gives top-level views a consistent header shape
1127
- and width. The icon badge only renders when the `icon` slot is filled,
1128
- so icon-less apps get a plain title/subtitle header.
1129
-
1130
- **Props:**
1131
-
1132
- | Prop | Type | Default | Description |
1133
- | --------------- | -------- | ------------- | ----------- |
1134
- | `title` | `String` | **required** | H1 text. |
1135
- | `subtitle` | `String` | `''` | Muted line below the title. |
1136
- | `iconColor` | `String` | `'emerald'` | Badge + icon colour: `'emerald' \| 'sky' \| 'red' \| 'amber'`. |
1137
- | `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. |
1138
- | `align` | `String` | `'center'` | Vertical alignment of the title block vs the actions: `'center'` or `'end'` (actions sit on the title baseline). |
1139
- | `marginClass` | `String` | `'mb-8'` | Space under the header. Pass `''` when the parent manages vertical rhythm (`space-y-*`). |
1140
- | `accent` | `Boolean` | `false` | Brand-green gauge bar in front of the title (icon-less headers). |
1141
-
1142
- **Slots:**
1143
-
1144
- | Slot | Slot props | Description |
1145
- | ---------- | ----------------- | ----------- |
1146
- | `icon` | `{ iconClass }` | Page Heroicon. Bind `:class="iconClass"` for the theme-aware colour. Badge square renders only when this slot is filled. |
1147
- | `subtitle` | — | Rich subtitle content (links, `<strong>`, interpolation); overrides the `subtitle` prop. |
1148
- | `actions` | — | Buttons rendered on the right (refresh, destructive, etc.). |
1149
-
1150
- ```vue
1151
- <template>
1152
- <BasePageHeader title="Request Journal" subtitle="Recent matched requests" icon-color="sky">
1153
- <template #icon="{ iconClass }">
1154
- <DocumentTextIcon class="w-5 h-5" :class="iconClass" />
1155
- </template>
1156
- <template #actions>
1157
- <BaseButton description="Refresh" @click="reload" />
1158
- </template>
1159
- </BasePageHeader>
1160
- </template>
1161
-
1162
- <script setup lang="ts">
1163
- import { BasePageHeader, BaseButton } from 'mgv-backoffice'
1164
- import { DocumentTextIcon } from '@heroicons/vue/24/outline'
1165
- </script>
1166
- ```
1167
-
1168
- ---
1169
-
1170
- ### BaseToolbarButton
1171
-
1172
- Bordered toolbar button — the "Refresh / Delete All" row that sits under
1173
- a page header. Optional leading icon (via slot) plus a label.
1174
-
1175
- **Props:**
1176
-
1177
- | Prop | Type | Default | Description |
1178
- | ---------- | --------- | ----------- | ----------- |
1179
- | `label` | `String` | `''` | Button text. Omit for an icon-only button. |
1180
- | `variant` | `String` | `'neutral'` | `'neutral'` (grey), `'danger'` (solid red) or `'ghost'` (slate h-9 outline — toolbar/modal-footer buttons). |
1181
- | `disabled` | `Boolean` | `false` | Greys out and blocks the click. |
1182
- | `title` | `String` | `undefined` | Native tooltip / a11y text. |
1183
- | `type` | `String` | `'button'` | Native button type. |
1184
-
1185
- **Slots:**
1186
-
1187
- | Slot | Slot props | Description |
1188
- | ------ | --------------- | ----------- |
1189
- | `icon` | `{ iconClass }` | Leading Heroicon. Bind `:class="iconClass"` (`w-4 h-4`); add state classes as needed. |
1190
-
1191
- **Emits:** `click` (native `MouseEvent`).
1192
-
1193
- ```vue
1194
- <template>
1195
- <BaseToolbarButton label="Refresh" :disabled="isLoading" title="Refresh" @click="reload">
1196
- <template #icon="{ iconClass }">
1197
- <ArrowPathIcon :class="[iconClass, { 'animate-spin': isLoading }]" />
1198
- </template>
1199
- </BaseToolbarButton>
1200
- <BaseToolbarButton label="Delete All" variant="danger" @click="deleteAll">
1201
- <template #icon="{ iconClass }">
1202
- <TrashIcon :class="iconClass" />
1203
- </template>
1204
- </BaseToolbarButton>
1205
- </template>
1206
- ```
1207
-
1208
- ---
1209
-
1210
- ### BaseActionButton
1211
-
1212
- Compact ghost action button — the colour-coded "Edit / Logs / Stub /
1213
- Delete" actions on a card footer or action row. No border/fill at rest;
1214
- a tinted hover background keyed to the semantic colour.
1215
-
1216
- **Props:**
1217
-
1218
- | Prop | Type | Default | Description |
1219
- | ----------- | --------- | ----------- | ----------- |
1220
- | `label` | `String` | `''` | Button text. Omit for an icon-only button. |
1221
- | `color` | `String` | `'emerald'` | `'emerald' \| 'sky' \| 'indigo' \| 'teal' \| 'purple' \| 'red' \| 'amber' \| 'amberStrong'`. |
1222
- | `disabled` | `Boolean` | `false` | Dims via opacity and suppresses the hover tint. |
1223
- | `fullWidth` | `Boolean` | `false` | Stretch to fill its flex row (`flex-1`). |
1224
- | `title` | `String` | `undefined` | Native tooltip. |
1225
- | `ariaLabel` | `String` | `undefined` | Accessible label. |
1226
- | `type` | `String` | `'button'` | Native button type. |
1227
-
1228
- **Slots:**
1229
-
1230
- | Slot | Slot props | Description |
1231
- | ------ | --------------- | ----------- |
1232
- | `icon` | `{ iconClass }` | Leading Heroicon. Bind `:class="iconClass"` (`w-4 h-4`). |
1233
-
1234
- **Emits:** `click` (native `MouseEvent`).
1235
-
1236
- ```vue
1237
- <template>
1238
- <BaseActionButton label="Edit" color="emerald" full-width title="Edit this mock" @click="edit">
1239
- <template #icon="{ iconClass }">
1240
- <PencilSquareIcon :class="iconClass" />
1241
- </template>
1242
- </BaseActionButton>
1243
- <BaseActionButton label="Delete" color="red" @click="remove">
1244
- <template #icon="{ iconClass }">
1245
- <TrashIcon :class="iconClass" />
1246
- </template>
1247
- </BaseActionButton>
1248
- </template>
1249
- ```
1250
-
1251
- ---
1252
-
1253
- ### BaseCopyButton
1254
-
1255
- Copy-to-clipboard icon button with transient "copied" feedback — clicks
1256
- write `text` to the clipboard, swap the clipboard icon for a checkmark
1257
- for `resetMs`, then revert. Uses the async Clipboard API with a
1258
- hidden-textarea `execCommand` fallback for insecure origins. Emits
1259
- `copied` / `error` so the parent can fire its own toast.
1260
-
1261
- **Props:**
1262
-
1263
- | Prop | Type | Default | Description |
1264
- | ----------- | --------- | --------- | ----------- |
1265
- | `text` | `String` | **required** | Value written to the clipboard. |
1266
- | `label` | `String` | `''` | Used in the tooltip / aria-label (`Copy {label}`). |
1267
- | `variant` | `String` | `'ghost'` | `'ghost'` (borderless `p-1` icon) or `'bordered'` (`w-9 h-9` boxed, turns emerald while copied). |
1268
- | `resetMs` | `Number` | `1500` | How long the checkmark stays before reverting. |
1269
- | `iconClass` | `String` | `'w-4 h-4'` | Icon size class. |
1270
-
1271
- **Emits:** `copied`, `error(err)`.
1272
-
1273
- ```vue
1274
- <template>
1275
- <!-- Inline ID copy, parent fires the toast -->
1276
- <BaseCopyButton
1277
- :text="stub.id"
1278
- label="Stub ID"
1279
- @copied="showToastMessage('Stub ID copied to clipboard', BaseToastEnum.SUCCESS)"
1280
- @error="showToastMessage('Failed to copy stub ID', BaseToastEnum.ERROR)"
1281
- />
1282
- <!-- Boxed copy next to a read-only input -->
1283
- <BaseCopyButton :text="mock.id" label="Mock ID" variant="bordered" :reset-ms="2000" />
1284
- </template>
1285
-
1286
- <script setup lang="ts">
1287
- import { BaseCopyButton, BaseToastEnum } from 'mgv-backoffice'
1288
- </script>
1289
- ```
1290
-
1291
- ---
1292
-
1293
- ### BaseChipButton
1294
-
1295
- Small tinted emerald "chip" action button — the compact "+ Add" pill used
1296
- above repeatable form rows. Label comes from the default slot.
1297
-
1298
- **Props:**
1299
-
1300
- | Prop | Type | Default | Description |
1301
- | ---------- | --------- | ------- | ----------- |
1302
- | `size` | `String` | `'sm'` | `'sm'` = `px-2.5 py-1`; `'xs'` = `px-2 py-0.5` for tight corners. |
1303
- | `disabled` | `Boolean` | `false` | Dims the chip and blocks clicks. |
1304
-
1305
- **Emits:** `click`.
1306
-
1307
- ```vue
1308
- <BaseChipButton @click="addRow(rows)">+ Add</BaseChipButton>
1309
- <BaseChipButton size="xs" @click="addNamespace">+ Add</BaseChipButton>
1310
- ```
1311
-
1312
- ---
1313
-
1314
- ### BaseRemoveButton
1315
-
1316
- The red "×" remove-row affordance used beside repeatable form rows. Name it
1317
- for screen readers via `aria-label`; `title`, `disabled` and extra classes
1318
- (`pt-1`, `self-start`, …) fall through as attrs.
1319
-
1320
- **Emits:** `click`.
1321
-
1322
- ```vue
1323
- <BaseRemoveButton :aria-label="`Remove header ${i + 1}`" @click="rows.splice(i, 1)" />
1324
- ```
1325
-
1326
- ---
1327
-
1328
- ### BaseStatusPill
1329
-
1330
- Connection/health status pill: a colored dot (pulsing while `ok`) next to a
1331
- short label on a tinted background.
1332
-
1333
- **Props:**
1334
-
1335
- | Prop | Type | Default | Description |
1336
- | -------- | -------- | ------- | ----------- |
1337
- | `status` | `String` | **required** | `'ok'` (emerald, pulsing), `'error'` (red), `'unknown'` (gray). |
1338
- | `label` | `String` | **required** | Short text next to the dot, e.g. `WireMock Connected`. |
1339
-
1340
- ```vue
1341
- <BaseStatusPill :status="healthy ? 'ok' : 'error'" :label="healthy ? 'Connected' : 'Disconnected'" />
1342
- ```
1343
-
1344
- ---
1345
-
1346
- ### BaseFileDropzone
1347
-
1348
- Dashed "click to select a file" upload zone (extracted from WireMate's
1349
- Postman-import modal). Renders a document-arrow-up icon (overridable via the
1350
- `#icon` slot), a label line, and an optional dimmed hint line. Clicking opens
1351
- the native file picker; dragging files onto the zone also works (the border
1352
- highlights emerald while dragging). The hidden input resets after every
1353
- selection, so picking the same file twice still emits.
1354
-
1355
- **Props:**
1356
-
1357
- | Prop | Type | Default | Description |
1358
- | ---------- | --------- | ------- | ----------- |
1359
- | `label` | `String` | **required** | Main line, e.g. `Click to select a Postman collection (.json)`. |
1360
- | `hint` | `String` | `''` | Dimmed helper line below the label. |
1361
- | `accept` | `String` | `''` | Forwarded to the input's `accept`. Dropped files are **not** filtered by it. |
1362
- | `multiple` | `Boolean` | `false` | Allow multi-select; when `false`, a multi-file drop emits only the first file. |
1363
- | `disabled` | `Boolean` | `false` | Dims the zone and ignores clicks/drops. |
1364
-
1365
- **Emits:** `files` (`File[]`, never empty).
1366
-
1367
- **Slots:** `icon` — replaces the default upload icon.
1368
-
1369
- ```vue
1370
- <BaseFileDropzone
1371
- accept="application/json,.json"
1372
- label="Click to select a Postman collection (.json)"
1373
- hint="Exported from Postman → Export → Collection v2.1"
1374
- @files="onFiles"
1375
- />
1376
- ```
1377
-
1378
- ### BaseCodeBlock
1379
-
1380
- Themed monospace `<pre>` for JSON payloads, request dumps and code snippets
1381
- (extracted from WireMate's stub/request detail views). Preserves whitespace
1382
- verbatim, scrolls both axes, and adapts to the theme. Extra classes (margins
1383
- etc.) fall through via the normal class merge.
1384
-
1385
- **Props:**
1386
-
1387
- | Prop | Type | Default | Description |
1388
- | ---------------- | -------- | -------- | ----------- |
1389
- | `code` | `String` | **required** | The raw text to render. |
1390
- | `variant` | `String` | `'soft'` | `'soft'` = tinted fill, no border (in-card look); `'bordered'` = bordered card fill (standalone look). |
1391
- | `size` | `String` | `'sm'` | `'sm'` = `text-sm px-5 py-4`; `'xs'` = dense `text-xs p-3`. |
1392
- | `maxHeightClass` | `String` | `''` | Optional Tailwind max-height utility, e.g. `max-h-96`. |
1393
-
1394
- ```vue
1395
- <BaseCodeBlock :code="formatJson(response.body)" size="xs" max-height-class="max-h-64" />
1396
- ```
1397
-
1398
- ---
1399
-
1400
- ## Forms & tables
1401
-
1402
- These components use `dark:` Tailwind variants, so the consuming app must map
1403
- the `dark` variant to the `.dark` class that `useTheme()` toggles (see
1404
- [Tailwind setup for consumers](#tailwind-setup-for-consumers)).
1405
-
1406
- ### BaseInput
1407
-
1408
- Themed text/number input carrying the shared field skin (slate border,
1409
- `bg-slate-50` / dark `bg-slate-900` surface). Everything else — `placeholder`,
1410
- `id`, `disabled`, `step`/`min`, extra classes like `font-mono` or
1411
- `placeholder:*` — falls through via attrs and Vue class merging.
1412
-
1413
- **Props:**
1414
-
1415
- | Prop | Type | Default | Description |
1416
- | ------------ | ------------------ | -------- | ----------- |
1417
- | `modelValue` | `String \| Number \| null` | `''` | `v-model` value. |
1418
- | `type` | `String` | `'text'` | Native input type. |
1419
- | `size` | `String` | `'md'` | `'md'` = `px-3 py-2`, `'sm'` = `px-2 py-1.5`. |
1420
- | `block` | `Boolean` | `true` | Full-width (`w-full`); set `false` for inline fields. |
1421
-
1422
- **Emits:** `update:modelValue(value: string)` — always the raw string; parse
1423
- numbers in the owner.
1424
-
1425
- ```vue
1426
- <BaseInput v-model="query" placeholder="e.g. AMD or BTC" class="font-mono" />
1427
- ```
1428
-
1429
- ### BaseSelect
1430
-
1431
- Themed `<select>` sharing BaseInput's field skin. Options come from the
1432
- default slot so callers keep full control of `<option>` rendering.
1433
-
1434
- **Props:**
1435
-
1436
- | Prop | Type | Default | Description |
1437
- | ------------ | ------------------ | ------- | ----------- |
1438
- | `modelValue` | `String \| null` | `undefined` | `v-model` value. When left undefined the browser keeps its own default selection. |
1439
- | `size` | `String` | `'sm'` | `'sm'` = `px-2 py-1.5`, `'md'` = `px-3 py-2`. |
1440
- | `block` | `Boolean` | `true` | Full-width; set `false` for inline selects. |
1441
-
1442
- **Slots:** `default` — the `<option>` elements.
1443
- **Emits:** `update:modelValue(value: string)`.
1444
-
1445
- ```vue
1446
- <BaseSelect v-model="strategyType">
1447
- <option v-for="e in catalog" :key="e.type" :value="e.type" :title="e.description">
1448
- {{ e.label }}
1449
- </option>
1450
- </BaseSelect>
1451
- ```
1452
-
1453
- ### BaseDropdown
1454
-
1455
- Button-style single-select dropdown ("Select Social User ⌄"). Unlike
1456
- `BaseSelect` (a native `<select>`), this renders a trigger button plus a
1457
- floating menu, so the closed control shows a placeholder and a chevron that
1458
- rotates while open — matching the app's filter dropdowns. Selecting a row
1459
- emits its `value` and closes the menu; Escape and an outside click also close
1460
- it.
1461
-
1462
- **Props:**
1463
-
1464
- | Prop | Type | Default | Description |
1465
- | ------------- | -------------------------- | ------------ | ----------- |
1466
- | `options` | `DropdownOption[]` | **required** | `{ value, label, title?, disabled? }` per row. |
1467
- | `modelValue` | `String \| Number \| null` | `null` | Selected option's `value` (`v-model`). |
1468
- | `placeholder` | `String` | `'Select'` | Trigger text shown when nothing is selected. |
1469
- | `size` | `String` | `'md'` | `'md'` = `px-4 py-2.5` (app filter height), `'sm'` = `px-3 py-2`. Ignored when `triggerClass` is set. |
1470
- | `block` | `Boolean` | `true` | Full-width; set `false` for an inline, content-width dropdown. |
1471
- | `disabled` | `Boolean` | `false` | Disables the trigger. |
1472
- | `ariaLabel` | `String` | `''` | Accessible name for the trigger/listbox when there is no visible label. |
1473
- | `triggerClass`| `String` | `''` | Replaces the trigger's default slate skin entirely (including the `size` padding). |
1474
- | `chevronClass`| `String` | `'w-5 h-5 text-slate-500 dark:text-slate-400'` | Classes for the chevron icon. |
1475
-
1476
- **Emits:** `update:modelValue(value)`.
1477
-
1478
- ```vue
1479
- <BaseDropdown
1480
- v-model="socialUserId"
1481
- :options="socialUsers.map((u) => ({ value: u.id, label: u.name }))"
1482
- placeholder="Select Social User"
1483
- aria-label="Social user"
1484
- />
1485
- ```
1486
-
1487
- ### BaseDateTimePicker
1488
-
1489
- Date / date-time / time picker built on
1490
- [@vuepic/vue-datepicker](https://vue3datepicker.com). The package is a regular
1491
- dependency of this lib (installed automatically) and its CSS ships inside
1492
- `ui-lib.css`, so consumers install and import nothing extra. Dark mode follows
1493
- `useTheme()`; the skin matches BaseInput (slate surfaces, emerald accent).
1494
-
1495
- **Props:**
1496
-
1497
- | Prop | Type | Default | Description |
1498
- | ------------ | ------------------ | ------------ | ----------- |
1499
- | `modelValue` | `ModelValue` | `null` | `v-model` value — `Date`, `Date[]` for ranges, a time object in `'time'` mode, or a string/number with `model-type`. |
1500
- | `mode` | `'date' \| 'datetime' \| 'time'` | `'datetime'` | Calendar only, calendar + time, or time only. |
1501
- | `format` | `String` | per mode | date-fns input pattern. Defaults: `dd/MM/yyyy`, `dd/MM/yyyy HH:mm`, `HH:mm` (`hh:mm a` when `is24` is false). |
1502
- | `is24` | `Boolean` | `true` | 24-hour clock. |
1503
- | `autoApply` | `Boolean` | `false` | Select on click, without the Cancel/Select row. |
1504
- | `teleport` | `Boolean \| String \| HTMLElement` | `true` | Menu mount target; `true` = body, so modals don't clip it. |
1505
- | `timeConfig` | `Partial<TimeConfig>` | — | Extra time options (seconds, increments…), merged over the defaults. |
1506
-
1507
- Every other VueDatePicker prop (`range`, `min-date`, `max-date`,
1508
- `disabled-dates`, `placeholder`, `model-type`, …), event and slot is passed
1509
- straight through.
1510
-
1511
- **Emits:** `update:modelValue(value)`.
1512
-
1513
- ```vue
1514
- <BaseDateTimePicker v-model="startsAt" placeholder="Start" />
1515
- <BaseDateTimePicker v-model="day" mode="date" :min-date="new Date()" auto-apply />
1516
- <BaseDateTimePicker v-model="period" mode="date" range />
1517
- ```
1518
-
1519
- ### BaseSegmentedControl
1520
-
1521
- Segmented button group ("All | Stock | Crypto"). One button per option; the
1522
- selected one gets the filled treatment and `aria-pressed="true"`.
1523
-
1524
- **Props:**
1525
-
1526
- | Prop | Type | Default | Description |
1527
- | ------------- | ------------------- | -------- | ----------- |
1528
- | `options` | `SegmentedOption[]` | **required** | `{ value, label, title? }` per button. |
1529
- | `modelValue` | `String \| Number` | **required** | Selected option's `value` (`v-model`). |
1530
- | `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). |
1531
- | `ariaLabel` | `String` | `''` | When set, the wrapper renders `role="group"` + `aria-label`. |
1532
- | `optionClass` | `Function` | — | `(option, active) => string` override for per-button fill classes (e.g. severity colours); layout stays owned by the variant. |
1533
-
1534
- **Emits:** `update:modelValue(value)`.
1535
-
1536
- ```vue
1537
- <BaseSegmentedControl v-model="assetFilter" :options="ASSET_FILTERS" />
1538
- <BaseSegmentedControl v-model="exchange" :options="EXCHANGES" variant="wide" aria-label="Exchange" />
1539
- ```
1540
-
1541
- ### BaseTable
1542
-
1543
- Styling shell for data tables — **not** a data grid. Owns the table skin
1544
- (slate header band, `px-4 py-3` header cells, row dividers + hover, empty-state
1545
- row); body rows are the caller's own `<tr>` markup via the default slot. Pass
1546
- `card` for the rounded, bordered, horizontally scrolling card chrome, or wrap
1547
- it yourself (e.g. a `BaseRow` with `overflow-x-auto`).
1548
-
1549
- **Props:**
1550
-
1551
- | Prop | Type | Default | Description |
1552
- | ----------- | --------------- | ------------ | ----------- |
1553
- | `columns` | `TableColumn[]` | **required** | `{ label, align? }`; `align: 'right'` right-aligns the header cell. |
1554
- | `empty` | `Boolean` | `false` | True renders the empty-state row spanning every column. |
1555
- | `emptyText` | `String` | `'No rows.'` | Fallback empty-state text. |
1556
- | `card` | `Boolean` | `false` | Wrap in the rounded, bordered, scrolling card. |
1557
-
1558
- **Slots:** `default` — the `<tr>` rows; `empty` — custom empty-state content.
1559
-
1560
- ```vue
1561
- <BaseTable :columns="COLUMNS" :empty="rows.length === 0">
1562
- <template #empty>No trades match your filters.</template>
1563
- <tr v-for="row in rows" :key="row.id" class="border-t border-slate-200 dark:border-slate-700">
1564
- …
1565
- </tr>
1566
- </BaseTable>
1567
- ```
1568
-
1569
- ### BaseSpecFields
1570
-
1571
- Spec-driven form fields: renders a select / checkbox / number input per
1572
- `SpecField`, with labels and help text, in a responsive two-column grid. Feed
1573
- it a backend-described catalogue and every form editing those values stays in
1574
- lockstep. Never mutates `params` — every edit is emitted as `(key, value)`
1575
- and the owner writes it back into its own state.
1576
-
1577
- **Props:**
1578
-
1579
- | Prop | Type | Default | Description |
1580
- | -------- | -------------------------------- | ------------ | ----------- |
1581
- | `specs` | `SpecField[]` | **required** | `{ key, label, type: 'decimal' \| 'integer' \| 'boolean' \| 'select', default?, options?, step?, min?, help? }` (optional members are nullable). |
1582
- | `params` | `Record<string, SpecFieldValue>` | **required** | Current values keyed by `spec.key`. |
1583
-
1584
- **Slots:** `after` (`{ spec }`) — extra content under each field (e.g. a live
1585
- preview attached to one key).
1586
- **Emits:** `update(key: string, value: SpecFieldValue)` — numbers are parsed
1587
- (`parseFloat`); unparseable input passes through raw so the owner's
1588
- validation can catch it.
1589
-
1590
- ```vue
1591
- <BaseSpecFields :specs="entry.params" :params="form.params"
1592
- @update="(key, value) => (form.params[key] = value)" />
1593
- ```
1594
-
1595
- ### BaseStatBreakdown
1596
-
1597
- Compact per-item breakdown meant to sit under a summary/stat card (pairs with
1598
- [`EarningsCard`](#earningscard)). Each item renders on its own line — label
1599
- left, value right in monospace. A `null`/`undefined` value (a source that is
1600
- unconfigured, unreachable, or has no matching rows) shows an em-dash rather
1601
- than a misleading 0. With `signed`, values gain an explicit "+" and are
1602
- coloured green/red by sign (same `"-$3.00"` / `"+$5.00"` shape as `fmtUsd`).
1603
-
1604
- **Props:**
1605
-
1606
- | Prop | Type | Default | Description |
1607
- | ---------- | --------------------- | ------------ | ----------- |
1608
- | `items` | `StatBreakdownItem[]` | **required** | `{ label, value }` per row. |
1609
- | `currency` | `String` | `''` | Currency symbol placed after the sign, e.g. `'$'`. |
1610
- | `decimals` | `Number` | `2` | Fraction digits shown for each value. |
1611
- | `signed` | `Boolean` | `false` | Show an explicit "+" on non-negative values and colour rows green/red by sign. |
1612
-
1613
- ```ts
1614
- import type { StatBreakdownItem } from 'mgv-backoffice'
1615
-
1616
- interface StatBreakdownItem {
1617
- label: string // row label rendered on the left
1618
- value: number | null | undefined // null/undefined renders as an em-dash
1619
- }
1620
- ```
1621
-
1622
- ```vue
1623
- <EarningsCard title="TOTAL P&L" :amount="totalPnl" signed />
1624
- <BaseStatBreakdown
1625
- :items="[
1626
- { label: 'Alpaca', value: 42.5 },
1627
- { label: 'Binance', value: -3.1 },
1628
- { label: 'Kraken', value: null },
1629
- ]"
1630
- currency="$"
1631
- signed
1632
- />
1633
- ```
1634
-
1635
- ### BaseFilterChip
1636
-
1637
- Colour-coded toggleable filter chip — one-click event/category filters above
1638
- a data feed. Idle renders a tinted border/background in the semantic colour;
1639
- active renders a solid fill with white text (`aria-pressed` reflects the
1640
- state). Layout classes (`h-9 flex-1`, …) pass through the class attribute;
1641
- click handlers bind natively on the component.
1642
-
1643
- **Props:**
1644
-
1645
- | Prop | Type | Default | Description |
1646
- | ---------- | --------- | --------- | ----------- |
1647
- | `label` | `String` | `''` | Chip text; the default slot overrides it. |
1648
- | `color` | `'emerald' \| 'sky' \| 'amber' \| 'red' \| 'slate'` | `'slate'` | Semantic colour of the idle tint and active fill. |
1649
- | `active` | `Boolean` | `false` | Whether the chip's filter is applied (solid fill). |
1650
- | `disabled` | `Boolean` | `false` | Greys out + blocks the click. |
1651
- | `title` | `String` | — | Native tooltip. |
1652
-
1653
- ```vue
1654
- <BaseFilterChip
1655
- v-for="f in filters"
1656
- :key="f.key"
1657
- class="h-9 flex-1"
1658
- :color="f.color"
1659
- :active="isActive(f)"
1660
- :title="f.title"
1661
- @click="toggle(f)"
1662
- >{{ f.label }}</BaseFilterChip>
1663
- ```
1664
-
1665
- ### BaseCredentialsForm
1666
-
1667
- One service's API-credentials card: key id + secret + base/data URLs, with
1668
- the has-secret handling (placeholder dots, blank-keeps-stored-secret), the
1669
- save-validation ladder and a saving spinner. Load/save results are EMITTED —
1670
- the parent owns toasts / error banners. Exposes `load()` so a parent Reload
1671
- button can re-pull several cards in parallel.
1672
-
1673
- **Props:** `title` + `idPrefix` + `fetchFn: () => Promise<CredentialsView>` +
1674
- `updateFn: (body: CredentialsUpdate) => Promise<CredentialsView>` +
1675
- `defaults: { baseUrl, dataUrl }` (required); `subtitle`, `keyLabel`,
1676
- `keyPlaceholder`, `secretLabel`, `secretPlaceholder`, `secretSetHint`,
1677
- `permissionsHint`, `requiredKeyMessage`, `requiredSecretMessage`,
1678
- `savedMessage`, `saveLabel` (optional copy overrides).
1679
-
1680
- **Slots:** `no-secret-hint` — rich help while no secret is stored;
1681
- `base-url-extra` (`{ form }`) — extras under the Base URL field (e.g.
1682
- live/paper shortcut buttons that write into the form); `footer` — extra
1683
- content at the card's bottom.
1684
-
1685
- **Emits:** `saved(message)`, `error(message)`, `load-error(message)`.
1686
-
1687
- ```vue
1688
- <BaseCredentialsForm
1689
- ref="card"
1690
- title="Alpaca API"
1691
- id-prefix="alpaca"
1692
- :fetch-fn="fetchAlpaca"
1693
- :update-fn="updateAlpaca"
1694
- :defaults="{ baseUrl: LIVE_BASE, dataUrl: DATA_URL }"
1695
- @saved="onSaved"
1696
- @error="onError"
1697
- @load-error="onLoadError"
1698
- />
1699
- ```
1700
-
1701
- ---
1702
-
1703
- ### BasePillPickerModal
1704
-
1705
- "Pick one of many" modal: every item rendered as a clickable pill, narrowed
1706
- by a free-text filter and an optional segmented group toggle. Clicking a pill
1707
- emits `pick` with the item; backdrop / Escape / the footer Close emit `close`.
1708
- Narrowing state lives inside, so a `v-if`-mounted instance always opens fresh.
1709
-
1710
- **Props:** `title` + `items: PillPickerItem[]` (required);
1711
- `groups?: SegmentedOption<string>[]` (renders the group toggle with an
1712
- `allLabel` option prepended, narrowing by each item's `group`); `icon?`
1713
- (defaults to the magnifying glass), `subtitle?`, `searchPlaceholder`,
1714
- `emptyMessage`, `noMatchMessage`, `mono` (mono font for the filter input and
1715
- pills — symbols, codes, ids), `maxWidthClass` (default `max-w-2xl`),
1716
- `closeText`, `groupAriaLabel`, `allLabel`.
1717
-
1718
- **Emits:** `pick(item: PillPickerItem)`, `close`.
1719
-
1720
- ```ts
1721
- interface PillPickerItem {
1722
- id: string // unique key; identifies the pick
1723
- label: string // pill text; what the filter matches
1724
- group?: string // segmented-toggle bucket
1725
- title?: string // pill tooltip
1726
- }
1727
- ```
1728
-
1729
- ```vue
1730
- <BasePillPickerModal
1731
- v-if="open"
1732
- title="Symbols"
1733
- :items="symbols.map(s => ({ id: s.id, label: s.symbol, group: s.assetClass }))"
1734
- :groups="[{ value: 'STOCK', label: 'STOCK' }, { value: 'CRYPTO', label: 'CRYPTO' }]"
1735
- mono
1736
- @pick="apply"
1737
- @close="open = false"
1738
- />
1739
- ```
1740
-
1741
- ---
1742
-
1743
- ### BaseBarDistribution
1744
-
1745
- Compact value-distribution chart: one thin rounded bar per distinct
1746
- value, count labelled on top and the value underneath — scrolls
1747
- sideways when there are many bars. Pure Tailwind, no chart library.
1748
- Extracted from TradeAutomation's variant-stats modal.
1749
-
1750
- **Props:**
1751
-
1752
- | Prop | Type | Default | Description |
1753
- | -------------- | -------- | ---------------------- | ----------- |
1754
- | `bars` | `Array` | **required** | `DistributionBar[]` — `{ label, count }` per bar, in display order (sort ascending for numeric values). |
1755
- | `ariaLabel` | `String` | `'Value distribution'` | Accessible description of the chart. |
1756
- | `countNoun` | `String` | `'item'` | Noun for each bar's tooltip count, e.g. `'variant'` → "3 variants". |
1757
- | `titlePrefix` | `String` | `''` | Tooltip prefix before the value, e.g. the field name. |
1758
- | `maxBarHeight` | `Number` | `56` | Height of the tallest bar, in px. |
1759
- | `barClass` | `String` | emerald fill | Tailwind classes for the bar fill. |
1760
-
1761
- ```vue
1762
- <BaseBarDistribution
1763
- :bars="[{ label: '0.5', count: 1 }, { label: '1', count: 4 }]"
1764
- aria-label="Distribution of Take profit across variants"
1765
- title-prefix="Take profit"
1766
- count-noun="variant"
1767
- />
1768
- ```
1769
-
1770
- ---
1771
-
1772
- ### BaseSearchSelect
1773
-
1774
- Searchable select (combobox): type to filter, pick with the mouse or
1775
- ArrowUp/ArrowDown + Enter. `multiple` turns it into a tag picker with removable
1776
- chips (Backspace on an empty search removes the last one). Same field skin as
1777
- `BaseInput` / `BaseSelect`; Escape and an outside click close the menu.
1778
-
1779
- **Props:**
1780
-
1781
- | Prop | Type | Default | Description |
1782
- | --------------- | ----------------------------- | --------------- | ----------- |
1783
- | `options` | `DropdownOption[]` | **required** | `{ value, label, title?, disabled? }` per row. |
1784
- | `modelValue` | `value \| null \| value[]` | `null` | Selected value, or values with `multiple`. |
1785
- | `multiple` | `Boolean` | `false` | Pick several (chips). |
1786
- | `placeholder` | `String` | `'Select'` | Shown when nothing is selected. |
1787
- | `searchable` | `Boolean` | `true` | Typing filters the options. |
1788
- | `clearable` | `Boolean` | `true` | Show the × clear button while something is selected. |
1789
- | `block` | `Boolean` | `true` | Full-width. |
1790
- | `disabled` | `Boolean` | `false` | |
1791
- | `ariaLabel` | `String` | `''` | Accessible name without a visible label. |
1792
- | `noResultsText` | `String` | `'No matches.'` | |
1793
- | `emptyText` | `String` | `'No options.'` | |
1794
-
1795
- **Emits:** `update:modelValue` — the value (single; `null` when cleared) or the
1796
- array of values (`multiple`).
1797
-
1798
- ```vue
1799
- <BaseSearchSelect v-model="userId" :options="users.map(u => ({ value: u.id, label: u.name }))" placeholder="Select User" />
1800
- <BaseSearchSelect v-model="tags" :options="TAGS" multiple />
1801
- ```
1802
-
1803
- ### BaseCard
1804
-
1805
- Bordered surface card — the shared chrome for forms, filter/search panels and
1806
- grouped content.
1807
-
1808
- **Props:** `title`, `subtitle`, `padding: 'md' | 'sm' | 'none'` (`'md'`).
1809
- **Slots:** `default` (body), `actions` (header, right), `footer` (bottom, right-aligned — submit/cancel).
1810
-
1811
- ```vue
1812
- <BaseCard title="Template">
1813
- <form>…</form>
1814
- <template #footer><BaseButton type="submit" description="Save" /></template>
1815
- </BaseCard>
1816
- ```
1817
-
1818
- ### BaseField
1819
-
1820
- Label + control + message wrapper for forms and filter bars.
1821
-
1822
- **Props:** `label`, `labelFor` (the control's id), `required`, `error`
1823
- (red, replaces the hint), `hint`, `compact` (small uppercase filter-bar label),
1824
- `grow` (takes the free space in a flex row).
1825
-
1826
- ```vue
1827
- <BaseCard padding="sm">
1828
- <div class="flex flex-wrap items-end gap-4">
1829
- <BaseField label="Search symbol" label-for="q" compact grow>
1830
- <BaseInput id="q" v-model="query" />
1831
- </BaseField>
1832
- <BaseField label="Class" compact>
1833
- <BaseSegmentedControl v-model="cls" :options="CLASSES" />
1834
- </BaseField>
1835
- </div>
1836
- </BaseCard>
1837
- ```
1838
-
1839
- ### BaseStatCard
1840
-
1841
- Dashboard stat tile in the `EarningsCard` style (dashed accent border, bold
1842
- title, big value) for any value — counts, labels, pre-formatted numbers.
1843
-
1844
- **Props:** `title` (required), `value`, `subtitle`,
1845
- `accent: 'emerald' | 'sky' | 'amber' | 'red' | 'slate'` (`'emerald'`),
1846
- `to` (router location — makes the whole card a link).
1847
- **Slots:** `icon` (fills the tinted chip; receives `iconClass`), `default` (extra content).
1848
-
1849
- ```vue
1850
- <BaseStatCard title="Categories" :value="71" accent="sky" :to="{ name: 'Category List' }">
1851
- <template #icon="{ iconClass }"><SwatchIcon :class="iconClass" /></template>
1852
- </BaseStatCard>
1853
- ```
1854
-
1855
- ### BaseCheckbox
1856
-
1857
- Rounded checkbox, emerald when checked (works with or without a forms plugin).
1858
- `v-model` is the boolean; `change` fires with the new value; attrs (`id`, `name`)
1859
- go to the `<input>`.
1860
-
1861
- **Props:** `modelValue`, `label`, `disabled`. **Slots:** `default` (rich label).
1862
- **Emits:** `update:modelValue(value)`, `change(value)`.
1863
-
1864
- ```vue
1865
- <BaseCheckbox v-model="remember" id="remember" label="Remember me" />
1866
- ```
1867
-
1868
- ### BaseToggle
1869
-
1870
- On/off switch (`role="switch"`). `v-model` is the boolean; `change` fires after
1871
- every user toggle with the new value.
1872
-
1873
- **Props:** `modelValue`, `label` (visible label, also the accessible name),
1874
- `ariaLabel` (when there is no label), `color: 'emerald' | 'red' | 'sky' | 'amber'`
1875
- (on state, `'emerald'`), `offTone: 'slate' | 'red'` (off track, `'slate'`), `disabled`.
1876
- **Emits:** `update:modelValue(value)`, `change(value)`.
1877
-
1878
- ```vue
1879
- <BaseToggle v-model="task.alive" :label="task.name" color="red" @change="save(task)" />
1880
- <BaseToggle v-model="account.alive" off-tone="red" aria-label="Alive" />
1881
- ```
1882
-
1883
- ### BaseAuthLayout
1884
-
1885
- Full-page, centred shell for sign-in / sign-up / password-recovery screens:
1886
- logo on top (defaults to `BaseLogo`), then a bordered card with the title,
1887
- content and an optional footer.
1888
-
1889
- **Props:** `title`, `subtitle`, `wide` (max-w-3xl card for multi-column forms; default max-w-md).
1890
- **Slots:** `default` (form), `logo` (replaces `BaseLogo`), `footer` ("No account? Sign up").
1891
-
1892
- ```vue
1893
- <BaseAuthLayout title="Forgot password">
1894
- <form>…</form>
1895
- <template #footer>No account? <RouterLink to="/register">Sign up</RouterLink></template>
1896
- </BaseAuthLayout>
1897
- ```
1898
-
1899
- ### BaseBooleanBadge
1900
-
1901
- Yes/no pill for boolean columns: green check when true, red cross when false.
1902
-
1903
- **Props:** `value` (`boolean | null`), `trueLabel` (`'Yes'`), `falseLabel` (`'No'`).
1904
-
1905
- ```vue
1906
- <BaseBooleanBadge :value="user.hasVerifiedEmail" true-label="Verified" false-label="Not verified" />
1907
- ```
1908
-
1909
- ### BaseDetailList
1910
-
1911
- Read-only label/value grid for detail pages (the "view" counterpart of a form).
1912
- Empty values show `emptyText`; `href` renders the value as an external link;
1913
- `mono` uses the monospace face.
1914
-
1915
- **Props:** `items: DetailItem[]` (`{ label, value?, href?, mono? }`, required),
1916
- `columns: 1 | 2 | 3` (`2`, from `sm` up), `emptyText` (`'—'`).
1917
-
1918
- ```vue
1919
- <BaseCard title="Details">
1920
- <BaseDetailList :items="[{ label: 'Status', value: post.status }, { label: 'Link', value: post.link, href: post.link }]" />
1921
- </BaseCard>
1922
- ```
1923
-
1924
- ## Composables
1925
-
1926
- ```ts
1927
- import {
1928
- initTheme,
1929
- useTheme,
1930
- useThemeClasses,
1931
- useEscapeKey,
1932
- useDebouncedRef,
1933
- useToast,
1934
- useMobileSidebar,
1935
- useSidebarCollapse,
1936
- useNotifications,
1937
- useQueryParamSync,
1938
- useFieldClasses,
1939
- usePolling,
1940
- } from 'mgv-backoffice'
1941
- import type {
1942
- UseThemeOptions,
1943
- UseSidebarCollapseOptions,
1944
- UsePollingOptions,
1945
- } from 'mgv-backoffice'
1946
- ```
1947
-
1948
- | Composable | Purpose |
1949
- | ---------- | ------- |
1950
- | `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). |
1951
- | `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. |
1952
- | `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). |
1953
- | `useEscapeKey(handler)` | Component-scoped Escape key listener. |
1954
- | `useDebouncedRef(source, delay?)` | Debounced mirror of a ref. Timer cleared on scope dispose. |
1955
- | `useToast(durationMs?)` | Per-component toast state: `{ showToast, toastMessage, toastType, showToastMessage }`. `showToastMessage` also accepts a per-call duration override. |
1956
- | `useMobileSidebar()` | Singleton state shared between `BaseSidebar` and `BaseAppLayout` for the off-canvas open/closed flag. |
1957
- | `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'`). |
1958
- | `useNotifications()` | Singleton notification state shared by the sidebar bell and `BaseNotificationPanel`: `{ notifications, unreadCount, open, openPanel, closePanel, togglePanel, setNotifications, add, remove, markRead, markAllRead, clear }`. |
1959
- | `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. |
1960
- | `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. |
1961
- | `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. |
1962
-
1963
- ---
1964
-
1965
- ## Typography
1966
-
1967
- Since 1.33.0 the library ships the shared brand typography: the stylesheet
1968
- loads **Fira Sans** (UI text) and **Fira Code** (numerals/data) from Google
1969
- Fonts via `@import`, registers them as the Tailwind `--font-sans` /
1970
- `--font-mono` theme defaults, and applies `font-family: var(--font-sans)` to
1971
- `body`. Consumers get the fonts just by importing the lib CSS — remove any
1972
- app-local Google Fonts `<link rel="stylesheet">` and `--font-sans`/`--font-mono`
1973
- overrides. Keep (or add) the preconnect hints in `index.html` for a faster
1974
- first paint:
1975
-
1976
- ```html
1977
- <link rel="preconnect" href="https://fonts.googleapis.com" />
1978
- <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
1979
- ```
1980
-
1981
- ## Tailwind setup for consumers
1982
-
1983
- The lib's components rely on Tailwind utility classes (including dark-mode
1984
- variants). Consumers should add the lib's `dist` output to their Tailwind
1985
- `content` paths so the JIT can see the class names:
1986
-
1987
- ```js
1988
- // tailwind.config.js
1989
- export default {
1990
- content: [
1991
- './index.html',
1992
- './src/**/*.{vue,ts}',
1993
- './node_modules/mgv-backoffice/dist/**/*.{js,mjs,cjs,vue}',
1994
- ],
1995
- }
1996
- ```
1997
-
1998
- The legacy `tailwind.safelist.js` only covers the v1 components; the
1999
- 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.GREEN` | 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'` | `'emerald'` | Colour of the spinning arc. The track stays neutral gray. |
352
+
353
+ With no props it renders a 16px emerald spinner. For page loaders use `size="xl"` centered, e.g. `<div class="flex justify-center py-12"><BaseSpinner size="xl" /></div>`.
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
+ ### BaseSidebarUser
905
+
906
+ Signed-in user block for the `BaseSidebar` `footer` slot: initials avatar,
907
+ name and email (a link to the profile page when `to` is set) and a Logout
908
+ button that emits `logout`.
909
+
910
+ **Props:** `name` (required), `email`, `to` (profile route), `showLogout` (`true`),
911
+ `logoutLabel` (`'Logout'`), `profileLabel` (`'View profile'`, tooltip).
912
+ **Emits:** `logout`.
913
+
914
+ ```vue
915
+ <BaseSidebar :sections="nav">
916
+ <template #footer>
917
+ <BaseSidebarUser :name="me.username" :email="me.email" :to="{ name: 'Profile' }" @logout="logOut" />
918
+ </template>
919
+ </BaseSidebar>
920
+ ```
921
+
922
+ ### BaseNotificationPanel
923
+
924
+ Left-anchored notification drawer (teleported to `<body>`, slides in from
925
+ the left, backdrop + Escape to close). Open/close state and the list live
926
+ in `useNotifications()`, so the sidebar bell and the panel stay in sync.
927
+
928
+ Enable the bell on the sidebar with `:show-notifications="true"`, drop one
929
+ `<BaseNotificationPanel />` anywhere in your app, and feed it data via the
930
+ composable.
931
+
932
+ **Props:**
933
+
934
+ | Prop | Type | Default | Description |
935
+ | ----------------- | --------- | ------------------------------ | ----------- |
936
+ | `title` | `String` | `'Notifications'` | Panel heading. |
937
+ | `emptyText` | `String` | `'You have no notifications.'` | Shown when the list is empty. |
938
+ | `showMarkAllRead` | `Boolean` | `true` | Render the "Mark all as read" action when there are unread items. |
939
+
940
+ **Emits:** `select` (the clicked notification's `id`; the row is also marked read).
941
+
942
+ ```vue
943
+ <script setup lang="ts">
944
+ import { BaseNotificationPanel, useNotifications } from 'mgv-backoffice'
945
+ const { setNotifications } = useNotifications()
946
+ setNotifications([
947
+ { id: 1, title: 'New comment', message: 'Alice replied to your post', time: '2m ago', type: 'info' },
948
+ { id: 2, title: 'Build passed', time: '1h ago', read: true, type: 'success' },
949
+ ])
950
+ </script>
951
+
952
+ <template>
953
+ <BaseSidebar :sections="navSections" :show-notifications="true" />
954
+ <BaseNotificationPanel @select="(id) => goTo(id)" />
955
+ </template>
956
+ ```
957
+
958
+ ```ts
959
+ import type { NotificationItem } from 'mgv-backoffice'
960
+
961
+ interface NotificationItem {
962
+ id: string | number
963
+ title: string
964
+ message?: string
965
+ time?: string // pre-formatted by you
966
+ read?: boolean
967
+ type?: 'info' | 'success' | 'warning' | 'error' // status dot colour
968
+ }
969
+ ```
970
+
971
+ ---
972
+
973
+ ## Authentication
974
+
975
+ ### BaseGoogleSignInButton
976
+
977
+ Google-branded "Sign in with Google" button (official multi-colour "G",
978
+ dark-mode surface swap). Purely presentational — it runs no OAuth itself;
979
+ listen on `click` and start your own Google Identity / Firebase / backend
980
+ flow there.
981
+
982
+ **Props:**
983
+
984
+ | Prop | Type | Default | Description |
985
+ | ---------- | --------- | -------------------------- | ----------- |
986
+ | `label` | `String` | `'Sign in with Google'` | Button text. |
987
+ | `loading` | `Boolean` | `false` | Disables and shows a spinner. |
988
+ | `disabled` | `Boolean` | `false` | Disables without the spinner. |
989
+ | `block` | `Boolean` | `true` | Full-width layout. |
990
+
991
+ **Emits:** `click` (only when not disabled/loading).
992
+
993
+ ### BaseLoginForm
994
+
995
+ Presentational sign-in card: email + password (with show/hide), an optional
996
+ "Remember me" checkbox, an error banner, the Google button + "or" divider,
997
+ and `logo` / `forgot` / `footer` slots. Owns its input state and emits
998
+ `submit` / `google-sign-in`; the app handles the actual request and feeds
999
+ back `loading` / `error`.
1000
+
1001
+ **Props:**
1002
+
1003
+ | Prop | Type | Default | Description |
1004
+ | --------------- | --------- | ----------- | ----------- |
1005
+ | `title` | `String` | `'Sign in'` | Card heading. |
1006
+ | `subtitle` | `String` | `''` | Muted line under the heading. |
1007
+ | `submitLabel` | `String` | `'Sign in'` | Submit button text. |
1008
+ | `loading` | `Boolean` | `false` | Disables the form, spinner on submit. |
1009
+ | `googleLoading` | `Boolean` | `false` | Disables the form, spinner on the Google button. |
1010
+ | `error` | `String` | `''` | Error banner above the form. |
1011
+ | `showGoogle` | `Boolean` | `true` | Render the Google button + divider. |
1012
+ | `showRemember` | `Boolean` | `false` | Render the "Remember me" checkbox. |
1013
+
1014
+ **Emits:** `submit` (`LoginCredentials`), `google-sign-in`.
1015
+
1016
+ **Slots:** `logo`, `forgot` (next to the password label), `footer`.
1017
+
1018
+ ```vue
1019
+ <script setup lang="ts">
1020
+ import { BaseLoginForm } from 'mgv-backoffice'
1021
+ import type { LoginCredentials } from 'mgv-backoffice'
1022
+
1023
+ async function onSubmit(creds: LoginCredentials) { /* call your API */ }
1024
+ function onGoogle() { /* start Google OAuth */ }
1025
+ </script>
1026
+
1027
+ <template>
1028
+ <BaseLoginForm
1029
+ subtitle="Welcome back"
1030
+ :show-remember="true"
1031
+ @submit="onSubmit"
1032
+ @google-sign-in="onGoogle"
1033
+ >
1034
+ <template #logo><MyLogo /></template>
1035
+ <template #forgot><a href="/forgot" class="text-sm text-emerald-600">Forgot?</a></template>
1036
+ <template #footer>No account? <a href="/signup" class="text-emerald-600">Sign up</a></template>
1037
+ </BaseLoginForm>
1038
+ </template>
1039
+ ```
1040
+
1041
+ ---
1042
+
1043
+ ## Modals & sections
1044
+
1045
+ ### BaseModalShell
1046
+
1047
+ Shared modal chrome — `Teleport` to body, backdrop, themed card, escape key,
1048
+ aria-modal. Compose this rather than building modals from scratch.
1049
+
1050
+ **Props:**
1051
+
1052
+ | Prop | Type | Default | Description |
1053
+ | --------------- | --------- | ----------- | ----------- |
1054
+ | `title` | `String` | **required** | Modal heading. |
1055
+ | `icon` | `Component` | **required** | Heroicon rendered in a tinted circular chip left of the title (the `icon` slot can override the whole chip). |
1056
+ | `iconBgClass` | `String` | `''` | Background classes of the icon chip; empty falls back to the emerald tint (dark-mode aware). |
1057
+ | `iconClass` | `String` | `'text-emerald-600'` | Classes applied to the icon itself. |
1058
+ | `maxWidthClass` | `String` | `'max-w-md'` | Tailwind max-w utility for the card. |
1059
+ | `manualClose` | `Boolean` | `false` | If true, backdrop click and Escape do NOT auto-emit `cancel`. |
1060
+ | `scrollable` | `Boolean` | `false` | Switch to the large-content layout: a flex column capped at `90vh` with a fixed header/footer and a scrolling body. |
1061
+ | `subtitle` | `String` | `''` | Muted line under the title (scrollable layout only). |
1062
+
1063
+ **Slots:** `icon`, `default`, `footer`, and (scrollable layout) `header-actions` — content on the right of the header, e.g. a close button.
1064
+ **Events:** `cancel`, `backdrop`.
1065
+
1066
+ ### BaseConfirmModal
1067
+
1068
+ Confirmation dialog built on `BaseModalShell`. Variant chooses red (danger) or
1069
+ amber (warning) styling.
1070
+
1071
+ **Props:** `title`, `message`, `confirmText`, `cancelText`, `submittingText`,
1072
+ `variant: 'danger' | 'warning'`, `submitting`. While `submitting` is true,
1073
+ backdrop clicks and Escape stop dismissing the dialog.
1074
+
1075
+ **Slots:** `message` — rich markup replacing the plain `message` string;
1076
+ `default` — extra content below the message (warning banner, opt-in checkbox).
1077
+ **Events:** `confirm`, `cancel`.
1078
+
1079
+ ### BaseTextInputModal
1080
+
1081
+ "Ask the user for a single string and confirm" dialog. Preserves typed input
1082
+ on stray backdrop clicks; Escape always cancels.
1083
+
1084
+ **Props:** `title`, `message`, `initialValue`, `placeholder`, `inputLabel`,
1085
+ `confirmText`, `cancelText`, `submittingText`, `submitting`.
1086
+
1087
+ **Slots:** `icon` — override the default emerald document icon.
1088
+ **Events:** `confirm(value: string)`, `cancel`.
1089
+
1090
+ ### BaseEntityPickerModal
1091
+
1092
+ Searchable "pick one from a list" dialog. Pass `items` directly or an async
1093
+ `loader` that runs on mount.
1094
+
1095
+ **Props:** `title`, `message?`, `items?: EntityPickerItem[]`,
1096
+ `loader?: () => Promise<EntityPickerItem[]>`, `excludeId?`,
1097
+ `variant: 'emerald' | 'purple' | 'blue' | 'red' | 'amber'`,
1098
+ `searchPlaceholder`, `emptyMessage`, `noMatchMessage`, `confirmText`,
1099
+ `cancelText`, `submittingText`, `submitting`.
1100
+
1101
+ **Slots:** `icon` — override the default icon chip.
1102
+ **Events:** `confirm(itemId: string)`, `cancel`.
1103
+
1104
+ ```ts
1105
+ interface EntityPickerItem { id: string; label: string }
1106
+ ```
1107
+
1108
+ ### BaseCollapsibleSection
1109
+
1110
+ Section wrapper with a clickable header, optional badge, and a `default` slot
1111
+ for the body. Parent owns the `collapsed` state.
1112
+
1113
+ **Props:** `title`, `collapsed`, `badge?`, `bodyClass?`.
1114
+ **Events:** `toggle`.
1115
+
1116
+ ### BaseNotFoundPage
1117
+
1118
+ Drop-in 404 view.
1119
+
1120
+ **Props:** `code` (`'404'`), `message` (`'Page not found'`),
1121
+ `homeRouteName` (`'home'`), `homeLabel` (`'Go home'`).
1122
+
1123
+ ### BasePageHeader
1124
+
1125
+ Page-level header: icon badge + title/subtitle on the left, action
1126
+ buttons on the right. Gives top-level views a consistent header shape
1127
+ and width. The icon badge only renders when the `icon` slot is filled,
1128
+ so icon-less apps get a plain title/subtitle header.
1129
+
1130
+ **Props:**
1131
+
1132
+ | Prop | Type | Default | Description |
1133
+ | --------------- | -------- | ------------- | ----------- |
1134
+ | `title` | `String` | **required** | H1 text. |
1135
+ | `subtitle` | `String` | `''` | Muted line below the title. |
1136
+ | `iconColor` | `String` | `'emerald'` | Badge + icon colour: `'emerald' \| 'sky' \| 'red' \| 'amber'`. |
1137
+ | `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. |
1138
+ | `align` | `String` | `'center'` | Vertical alignment of the title block vs the actions: `'center'` or `'end'` (actions sit on the title baseline). |
1139
+ | `marginClass` | `String` | `'mb-8'` | Space under the header. Pass `''` when the parent manages vertical rhythm (`space-y-*`). |
1140
+ | `accent` | `Boolean` | `false` | Brand-green gauge bar in front of the title (icon-less headers). |
1141
+
1142
+ **Slots:**
1143
+
1144
+ | Slot | Slot props | Description |
1145
+ | ---------- | ----------------- | ----------- |
1146
+ | `icon` | `{ iconClass }` | Page Heroicon. Bind `:class="iconClass"` for the theme-aware colour. Badge square renders only when this slot is filled. |
1147
+ | `subtitle` | — | Rich subtitle content (links, `<strong>`, interpolation); overrides the `subtitle` prop. |
1148
+ | `actions` | — | Buttons rendered on the right (refresh, destructive, etc.). |
1149
+
1150
+ ```vue
1151
+ <template>
1152
+ <BasePageHeader title="Request Journal" subtitle="Recent matched requests" icon-color="sky">
1153
+ <template #icon="{ iconClass }">
1154
+ <DocumentTextIcon class="w-5 h-5" :class="iconClass" />
1155
+ </template>
1156
+ <template #actions>
1157
+ <BaseButton description="Refresh" @click="reload" />
1158
+ </template>
1159
+ </BasePageHeader>
1160
+ </template>
1161
+
1162
+ <script setup lang="ts">
1163
+ import { BasePageHeader, BaseButton } from 'mgv-backoffice'
1164
+ import { DocumentTextIcon } from '@heroicons/vue/24/outline'
1165
+ </script>
1166
+ ```
1167
+
1168
+ ---
1169
+
1170
+ ### BaseToolbarButton
1171
+
1172
+ Bordered toolbar button — the "Refresh / Delete All" row that sits under
1173
+ a page header. Optional leading icon (via slot) plus a label.
1174
+
1175
+ **Props:**
1176
+
1177
+ | Prop | Type | Default | Description |
1178
+ | ---------- | --------- | ----------- | ----------- |
1179
+ | `label` | `String` | `''` | Button text. Omit for an icon-only button. |
1180
+ | `variant` | `String` | `'neutral'` | `'neutral'` (grey), `'danger'` (solid red) or `'ghost'` (slate h-9 outline — toolbar/modal-footer buttons). |
1181
+ | `disabled` | `Boolean` | `false` | Greys out and blocks the click. |
1182
+ | `title` | `String` | `undefined` | Native tooltip / a11y text. |
1183
+ | `type` | `String` | `'button'` | Native button type. |
1184
+
1185
+ **Slots:**
1186
+
1187
+ | Slot | Slot props | Description |
1188
+ | ------ | --------------- | ----------- |
1189
+ | `icon` | `{ iconClass }` | Leading Heroicon. Bind `:class="iconClass"` (`w-4 h-4`); add state classes as needed. |
1190
+
1191
+ **Emits:** `click` (native `MouseEvent`).
1192
+
1193
+ ```vue
1194
+ <template>
1195
+ <BaseToolbarButton label="Refresh" :disabled="isLoading" title="Refresh" @click="reload">
1196
+ <template #icon="{ iconClass }">
1197
+ <ArrowPathIcon :class="[iconClass, { 'animate-spin': isLoading }]" />
1198
+ </template>
1199
+ </BaseToolbarButton>
1200
+ <BaseToolbarButton label="Delete All" variant="danger" @click="deleteAll">
1201
+ <template #icon="{ iconClass }">
1202
+ <TrashIcon :class="iconClass" />
1203
+ </template>
1204
+ </BaseToolbarButton>
1205
+ </template>
1206
+ ```
1207
+
1208
+ ---
1209
+
1210
+ ### BaseActionButton
1211
+
1212
+ Compact ghost action button — the colour-coded "Edit / Logs / Stub /
1213
+ Delete" actions on a card footer or action row. No border/fill at rest;
1214
+ a tinted hover background keyed to the semantic colour.
1215
+
1216
+ **Props:**
1217
+
1218
+ | Prop | Type | Default | Description |
1219
+ | ----------- | --------- | ----------- | ----------- |
1220
+ | `label` | `String` | `''` | Button text. Omit for an icon-only button. |
1221
+ | `color` | `String` | `'emerald'` | `'emerald' \| 'sky' \| 'indigo' \| 'teal' \| 'purple' \| 'red' \| 'amber' \| 'amberStrong'`. |
1222
+ | `disabled` | `Boolean` | `false` | Dims via opacity and suppresses the hover tint. |
1223
+ | `fullWidth` | `Boolean` | `false` | Stretch to fill its flex row (`flex-1`). |
1224
+ | `title` | `String` | `undefined` | Native tooltip. |
1225
+ | `ariaLabel` | `String` | `undefined` | Accessible label. |
1226
+ | `type` | `String` | `'button'` | Native button type. |
1227
+
1228
+ **Slots:**
1229
+
1230
+ | Slot | Slot props | Description |
1231
+ | ------ | --------------- | ----------- |
1232
+ | `icon` | `{ iconClass }` | Leading Heroicon. Bind `:class="iconClass"` (`w-4 h-4`). |
1233
+
1234
+ **Emits:** `click` (native `MouseEvent`).
1235
+
1236
+ ```vue
1237
+ <template>
1238
+ <BaseActionButton label="Edit" color="emerald" full-width title="Edit this mock" @click="edit">
1239
+ <template #icon="{ iconClass }">
1240
+ <PencilSquareIcon :class="iconClass" />
1241
+ </template>
1242
+ </BaseActionButton>
1243
+ <BaseActionButton label="Delete" color="red" @click="remove">
1244
+ <template #icon="{ iconClass }">
1245
+ <TrashIcon :class="iconClass" />
1246
+ </template>
1247
+ </BaseActionButton>
1248
+ </template>
1249
+ ```
1250
+
1251
+ ---
1252
+
1253
+ ### BaseCopyButton
1254
+
1255
+ Copy-to-clipboard icon button with transient "copied" feedback — clicks
1256
+ write `text` to the clipboard, swap the clipboard icon for a checkmark
1257
+ for `resetMs`, then revert. Uses the async Clipboard API with a
1258
+ hidden-textarea `execCommand` fallback for insecure origins. Emits
1259
+ `copied` / `error` so the parent can fire its own toast.
1260
+
1261
+ **Props:**
1262
+
1263
+ | Prop | Type | Default | Description |
1264
+ | ----------- | --------- | --------- | ----------- |
1265
+ | `text` | `String` | **required** | Value written to the clipboard. |
1266
+ | `label` | `String` | `''` | Used in the tooltip / aria-label (`Copy {label}`). |
1267
+ | `variant` | `String` | `'ghost'` | `'ghost'` (borderless `p-1` icon) or `'bordered'` (`w-9 h-9` boxed, turns emerald while copied). |
1268
+ | `resetMs` | `Number` | `1500` | How long the checkmark stays before reverting. |
1269
+ | `iconClass` | `String` | `'w-4 h-4'` | Icon size class. |
1270
+
1271
+ **Emits:** `copied`, `error(err)`.
1272
+
1273
+ ```vue
1274
+ <template>
1275
+ <!-- Inline ID copy, parent fires the toast -->
1276
+ <BaseCopyButton
1277
+ :text="stub.id"
1278
+ label="Stub ID"
1279
+ @copied="showToastMessage('Stub ID copied to clipboard', BaseToastEnum.SUCCESS)"
1280
+ @error="showToastMessage('Failed to copy stub ID', BaseToastEnum.ERROR)"
1281
+ />
1282
+ <!-- Boxed copy next to a read-only input -->
1283
+ <BaseCopyButton :text="mock.id" label="Mock ID" variant="bordered" :reset-ms="2000" />
1284
+ </template>
1285
+
1286
+ <script setup lang="ts">
1287
+ import { BaseCopyButton, BaseToastEnum } from 'mgv-backoffice'
1288
+ </script>
1289
+ ```
1290
+
1291
+ ---
1292
+
1293
+ ### BaseChipButton
1294
+
1295
+ Small tinted emerald "chip" action button — the compact "+ Add" pill used
1296
+ above repeatable form rows. Label comes from the default slot.
1297
+
1298
+ **Props:**
1299
+
1300
+ | Prop | Type | Default | Description |
1301
+ | ---------- | --------- | ------- | ----------- |
1302
+ | `size` | `String` | `'sm'` | `'sm'` = `px-2.5 py-1`; `'xs'` = `px-2 py-0.5` for tight corners. |
1303
+ | `disabled` | `Boolean` | `false` | Dims the chip and blocks clicks. |
1304
+
1305
+ **Emits:** `click`.
1306
+
1307
+ ```vue
1308
+ <BaseChipButton @click="addRow(rows)">+ Add</BaseChipButton>
1309
+ <BaseChipButton size="xs" @click="addNamespace">+ Add</BaseChipButton>
1310
+ ```
1311
+
1312
+ ---
1313
+
1314
+ ### BaseRemoveButton
1315
+
1316
+ The red "×" remove-row affordance used beside repeatable form rows. Name it
1317
+ for screen readers via `aria-label`; `title`, `disabled` and extra classes
1318
+ (`pt-1`, `self-start`, …) fall through as attrs.
1319
+
1320
+ **Emits:** `click`.
1321
+
1322
+ ```vue
1323
+ <BaseRemoveButton :aria-label="`Remove header ${i + 1}`" @click="rows.splice(i, 1)" />
1324
+ ```
1325
+
1326
+ ---
1327
+
1328
+ ### BaseStatusPill
1329
+
1330
+ Connection/health status pill: a colored dot (pulsing while `ok`) next to a
1331
+ short label on a tinted background.
1332
+
1333
+ **Props:**
1334
+
1335
+ | Prop | Type | Default | Description |
1336
+ | -------- | -------- | ------- | ----------- |
1337
+ | `status` | `String` | **required** | `'ok'` (emerald, pulsing), `'error'` (red), `'unknown'` (gray). |
1338
+ | `label` | `String` | **required** | Short text next to the dot, e.g. `WireMock Connected`. |
1339
+
1340
+ ```vue
1341
+ <BaseStatusPill :status="healthy ? 'ok' : 'error'" :label="healthy ? 'Connected' : 'Disconnected'" />
1342
+ ```
1343
+
1344
+ ---
1345
+
1346
+ ### BaseFileDropzone
1347
+
1348
+ Dashed "click to select a file" upload zone (extracted from WireMate's
1349
+ Postman-import modal). Renders a document-arrow-up icon (overridable via the
1350
+ `#icon` slot), a label line, and an optional dimmed hint line. Clicking opens
1351
+ the native file picker; dragging files onto the zone also works (the border
1352
+ highlights emerald while dragging). The hidden input resets after every
1353
+ selection, so picking the same file twice still emits.
1354
+
1355
+ **Props:**
1356
+
1357
+ | Prop | Type | Default | Description |
1358
+ | ---------- | --------- | ------- | ----------- |
1359
+ | `label` | `String` | **required** | Main line, e.g. `Click to select a Postman collection (.json)`. |
1360
+ | `hint` | `String` | `''` | Dimmed helper line below the label. |
1361
+ | `accept` | `String` | `''` | Forwarded to the input's `accept`. Dropped files are **not** filtered by it. |
1362
+ | `multiple` | `Boolean` | `false` | Allow multi-select; when `false`, a multi-file drop emits only the first file. |
1363
+ | `disabled` | `Boolean` | `false` | Dims the zone and ignores clicks/drops. |
1364
+
1365
+ **Emits:** `files` (`File[]`, never empty).
1366
+
1367
+ **Slots:** `icon` — replaces the default upload icon.
1368
+
1369
+ ```vue
1370
+ <BaseFileDropzone
1371
+ accept="application/json,.json"
1372
+ label="Click to select a Postman collection (.json)"
1373
+ hint="Exported from Postman → Export → Collection v2.1"
1374
+ @files="onFiles"
1375
+ />
1376
+ ```
1377
+
1378
+ ### BaseCodeBlock
1379
+
1380
+ Themed monospace `<pre>` for JSON payloads, request dumps and code snippets
1381
+ (extracted from WireMate's stub/request detail views). Preserves whitespace
1382
+ verbatim, scrolls both axes, and adapts to the theme. Extra classes (margins
1383
+ etc.) fall through via the normal class merge.
1384
+
1385
+ **Props:**
1386
+
1387
+ | Prop | Type | Default | Description |
1388
+ | ---------------- | -------- | -------- | ----------- |
1389
+ | `code` | `String` | **required** | The raw text to render. |
1390
+ | `variant` | `String` | `'soft'` | `'soft'` = tinted fill, no border (in-card look); `'bordered'` = bordered card fill (standalone look). |
1391
+ | `size` | `String` | `'sm'` | `'sm'` = `text-sm px-5 py-4`; `'xs'` = dense `text-xs p-3`. |
1392
+ | `maxHeightClass` | `String` | `''` | Optional Tailwind max-height utility, e.g. `max-h-96`. |
1393
+
1394
+ ```vue
1395
+ <BaseCodeBlock :code="formatJson(response.body)" size="xs" max-height-class="max-h-64" />
1396
+ ```
1397
+
1398
+ ---
1399
+
1400
+ ## Forms & tables
1401
+
1402
+ These components use `dark:` Tailwind variants, so the consuming app must map
1403
+ the `dark` variant to the `.dark` class that `useTheme()` toggles (see
1404
+ [Tailwind setup for consumers](#tailwind-setup-for-consumers)).
1405
+
1406
+ ### BaseInput
1407
+
1408
+ Themed text/number input carrying the shared field skin (slate border,
1409
+ `bg-slate-50` / dark `bg-slate-900` surface). Everything else — `placeholder`,
1410
+ `id`, `disabled`, `step`/`min`, extra classes like `font-mono` or
1411
+ `placeholder:*` — falls through via attrs and Vue class merging.
1412
+
1413
+ **Props:**
1414
+
1415
+ | Prop | Type | Default | Description |
1416
+ | ------------ | ------------------ | -------- | ----------- |
1417
+ | `modelValue` | `String \| Number \| null` | `''` | `v-model` value. |
1418
+ | `type` | `String` | `'text'` | Native input type. |
1419
+ | `size` | `String` | `'md'` | `'md'` = `px-3 py-2`, `'sm'` = `px-2 py-1.5`. |
1420
+ | `block` | `Boolean` | `true` | Full-width (`w-full`); set `false` for inline fields. |
1421
+
1422
+ **Emits:** `update:modelValue(value: string)` — always the raw string; parse
1423
+ numbers in the owner.
1424
+
1425
+ ```vue
1426
+ <BaseInput v-model="query" placeholder="e.g. AMD or BTC" class="font-mono" />
1427
+ ```
1428
+
1429
+ ### BaseSelect
1430
+
1431
+ Themed `<select>` sharing BaseInput's field skin. Options come from the
1432
+ default slot so callers keep full control of `<option>` rendering.
1433
+
1434
+ **Props:**
1435
+
1436
+ | Prop | Type | Default | Description |
1437
+ | ------------ | ------------------ | ------- | ----------- |
1438
+ | `modelValue` | `String \| null` | `undefined` | `v-model` value. When left undefined the browser keeps its own default selection. |
1439
+ | `size` | `String` | `'sm'` | `'sm'` = `px-2 py-1.5`, `'md'` = `px-3 py-2`. |
1440
+ | `block` | `Boolean` | `true` | Full-width; set `false` for inline selects. |
1441
+
1442
+ **Slots:** `default` — the `<option>` elements.
1443
+ **Emits:** `update:modelValue(value: string)`.
1444
+
1445
+ ```vue
1446
+ <BaseSelect v-model="strategyType">
1447
+ <option v-for="e in catalog" :key="e.type" :value="e.type" :title="e.description">
1448
+ {{ e.label }}
1449
+ </option>
1450
+ </BaseSelect>
1451
+ ```
1452
+
1453
+ ### BaseDropdown
1454
+
1455
+ Button-style single-select dropdown ("Select Social User ⌄"). Unlike
1456
+ `BaseSelect` (a native `<select>`), this renders a trigger button plus a
1457
+ floating menu, so the closed control shows a placeholder and a chevron that
1458
+ rotates while open — matching the app's filter dropdowns. Selecting a row
1459
+ emits its `value` and closes the menu; Escape and an outside click also close
1460
+ it.
1461
+
1462
+ **Props:**
1463
+
1464
+ | Prop | Type | Default | Description |
1465
+ | ------------- | -------------------------- | ------------ | ----------- |
1466
+ | `options` | `DropdownOption[]` | **required** | `{ value, label, title?, disabled? }` per row. |
1467
+ | `modelValue` | `String \| Number \| null` | `null` | Selected option's `value` (`v-model`). |
1468
+ | `placeholder` | `String` | `'Select'` | Trigger text shown when nothing is selected. |
1469
+ | `size` | `String` | `'md'` | `'md'` = `px-4 py-2.5` (app filter height), `'sm'` = `px-3 py-2`. Ignored when `triggerClass` is set. |
1470
+ | `block` | `Boolean` | `true` | Full-width; set `false` for an inline, content-width dropdown. |
1471
+ | `disabled` | `Boolean` | `false` | Disables the trigger. |
1472
+ | `ariaLabel` | `String` | `''` | Accessible name for the trigger/listbox when there is no visible label. |
1473
+ | `triggerClass`| `String` | `''` | Replaces the trigger's default slate skin entirely (including the `size` padding). |
1474
+ | `chevronClass`| `String` | `'w-5 h-5 text-slate-500 dark:text-slate-400'` | Classes for the chevron icon. |
1475
+ | `tone` | `'neutral' \| 'success' \| 'danger'` | `'neutral'` | Tints the default skin (slate / emerald / red) while keeping the `size` padding — e.g. an Active/Paused status dropdown. Ignored when `triggerClass` is set. |
1476
+
1477
+ **Emits:** `update:modelValue(value)`.
1478
+
1479
+ ```vue
1480
+ <BaseDropdown
1481
+ v-model="socialUserId"
1482
+ :options="socialUsers.map((u) => ({ value: u.id, label: u.name }))"
1483
+ placeholder="Select Social User"
1484
+ aria-label="Social user"
1485
+ />
1486
+ ```
1487
+
1488
+ ### BaseDateTimePicker
1489
+
1490
+ Date / date-time / time picker built on
1491
+ [@vuepic/vue-datepicker](https://vue3datepicker.com). The package is a regular
1492
+ dependency of this lib (installed automatically) and its CSS ships inside
1493
+ `ui-lib.css`, so consumers install and import nothing extra. Dark mode follows
1494
+ `useTheme()`; the skin matches BaseInput (slate surfaces, emerald accent).
1495
+
1496
+ **Props:**
1497
+
1498
+ | Prop | Type | Default | Description |
1499
+ | ------------ | ------------------ | ------------ | ----------- |
1500
+ | `modelValue` | `ModelValue` | `null` | `v-model` value — `Date`, `Date[]` for ranges, a time object in `'time'` mode, or a string/number with `model-type`. |
1501
+ | `mode` | `'date' \| 'datetime' \| 'time'` | `'datetime'` | Calendar only, calendar + time, or time only. |
1502
+ | `format` | `String` | per mode | date-fns input pattern. Defaults: `dd/MM/yyyy`, `dd/MM/yyyy HH:mm`, `HH:mm` (`hh:mm a` when `is24` is false). |
1503
+ | `is24` | `Boolean` | `true` | 24-hour clock. |
1504
+ | `autoApply` | `Boolean` | `false` | Select on click, without the Cancel/Select row. |
1505
+ | `teleport` | `Boolean \| String \| HTMLElement` | `true` | Menu mount target; `true` = body, so modals don't clip it. |
1506
+ | `timeConfig` | `Partial<TimeConfig>` | — | Extra time options (seconds, increments…), merged over the defaults. |
1507
+
1508
+ Every other VueDatePicker prop (`range`, `min-date`, `max-date`,
1509
+ `disabled-dates`, `placeholder`, `model-type`, …), event and slot is passed
1510
+ straight through.
1511
+
1512
+ **Emits:** `update:modelValue(value)`.
1513
+
1514
+ ```vue
1515
+ <BaseDateTimePicker v-model="startsAt" placeholder="Start" />
1516
+ <BaseDateTimePicker v-model="day" mode="date" :min-date="new Date()" auto-apply />
1517
+ <BaseDateTimePicker v-model="period" mode="date" range />
1518
+ ```
1519
+
1520
+ ### BaseSegmentedControl
1521
+
1522
+ Segmented button group ("All | Stock | Crypto"). One button per option; the
1523
+ selected one gets the filled treatment and `aria-pressed="true"`.
1524
+
1525
+ **Props:**
1526
+
1527
+ | Prop | Type | Default | Description |
1528
+ | ------------- | ------------------- | -------- | ----------- |
1529
+ | `options` | `SegmentedOption[]` | **required** | `{ value, label, title? }` per button. |
1530
+ | `modelValue` | `String \| Number` | **required** | Selected option's `value` (`v-model`). |
1531
+ | `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). |
1532
+ | `ariaLabel` | `String` | `''` | When set, the wrapper renders `role="group"` + `aria-label`. |
1533
+ | `optionClass` | `Function` | — | `(option, active) => string` override for per-button fill classes (e.g. severity colours); layout stays owned by the variant. |
1534
+
1535
+ **Emits:** `update:modelValue(value)`.
1536
+
1537
+ ```vue
1538
+ <BaseSegmentedControl v-model="assetFilter" :options="ASSET_FILTERS" />
1539
+ <BaseSegmentedControl v-model="exchange" :options="EXCHANGES" variant="wide" aria-label="Exchange" />
1540
+ ```
1541
+
1542
+ ### BaseTable
1543
+
1544
+ Styling shell for data tables — **not** a data grid. Owns the table skin
1545
+ (slate header band, `px-4 py-3` header cells, row dividers + hover, empty-state
1546
+ row); body rows are the caller's own `<tr>` markup via the default slot. Pass
1547
+ `card` for the rounded, bordered, horizontally scrolling card chrome, or wrap
1548
+ it yourself (e.g. a `BaseRow` with `overflow-x-auto`).
1549
+
1550
+ **Props:**
1551
+
1552
+ | Prop | Type | Default | Description |
1553
+ | ----------- | --------------- | ------------ | ----------- |
1554
+ | `columns` | `TableColumn[]` | **required** | `{ label, align? }`; `align: 'right'` right-aligns the header cell. |
1555
+ | `empty` | `Boolean` | `false` | True renders the empty-state row spanning every column. |
1556
+ | `emptyText` | `String` | `'No rows.'` | Fallback empty-state text. |
1557
+ | `card` | `Boolean` | `false` | Wrap in the rounded, bordered, scrolling card. |
1558
+
1559
+ **Slots:** `default` — the `<tr>` rows; `empty` — custom empty-state content.
1560
+
1561
+ ```vue
1562
+ <BaseTable :columns="COLUMNS" :empty="rows.length === 0">
1563
+ <template #empty>No trades match your filters.</template>
1564
+ <tr v-for="row in rows" :key="row.id" class="border-t border-slate-200 dark:border-slate-700">
1565
+ …
1566
+ </tr>
1567
+ </BaseTable>
1568
+ ```
1569
+
1570
+ ### BaseSpecFields
1571
+
1572
+ Spec-driven form fields: renders a select / checkbox / number input per
1573
+ `SpecField`, with labels and help text, in a responsive two-column grid. Feed
1574
+ it a backend-described catalogue and every form editing those values stays in
1575
+ lockstep. Never mutates `params` — every edit is emitted as `(key, value)`
1576
+ and the owner writes it back into its own state.
1577
+
1578
+ **Props:**
1579
+
1580
+ | Prop | Type | Default | Description |
1581
+ | -------- | -------------------------------- | ------------ | ----------- |
1582
+ | `specs` | `SpecField[]` | **required** | `{ key, label, type: 'decimal' \| 'integer' \| 'boolean' \| 'select', default?, options?, step?, min?, help? }` (optional members are nullable). |
1583
+ | `params` | `Record<string, SpecFieldValue>` | **required** | Current values keyed by `spec.key`. |
1584
+
1585
+ **Slots:** `after` (`{ spec }`) — extra content under each field (e.g. a live
1586
+ preview attached to one key).
1587
+ **Emits:** `update(key: string, value: SpecFieldValue)` — numbers are parsed
1588
+ (`parseFloat`); unparseable input passes through raw so the owner's
1589
+ validation can catch it.
1590
+
1591
+ ```vue
1592
+ <BaseSpecFields :specs="entry.params" :params="form.params"
1593
+ @update="(key, value) => (form.params[key] = value)" />
1594
+ ```
1595
+
1596
+ ### BaseStatBreakdown
1597
+
1598
+ Compact per-item breakdown meant to sit under a summary/stat card (pairs with
1599
+ [`EarningsCard`](#earningscard)). Each item renders on its own line — label
1600
+ left, value right in monospace. A `null`/`undefined` value (a source that is
1601
+ unconfigured, unreachable, or has no matching rows) shows an em-dash rather
1602
+ than a misleading 0. With `signed`, values gain an explicit "+" and are
1603
+ coloured green/red by sign (same `"-$3.00"` / `"+$5.00"` shape as `fmtUsd`).
1604
+
1605
+ **Props:**
1606
+
1607
+ | Prop | Type | Default | Description |
1608
+ | ---------- | --------------------- | ------------ | ----------- |
1609
+ | `items` | `StatBreakdownItem[]` | **required** | `{ label, value }` per row. |
1610
+ | `currency` | `String` | `''` | Currency symbol placed after the sign, e.g. `'$'`. |
1611
+ | `decimals` | `Number` | `2` | Fraction digits shown for each value. |
1612
+ | `signed` | `Boolean` | `false` | Show an explicit "+" on non-negative values and colour rows green/red by sign. |
1613
+
1614
+ ```ts
1615
+ import type { StatBreakdownItem } from 'mgv-backoffice'
1616
+
1617
+ interface StatBreakdownItem {
1618
+ label: string // row label rendered on the left
1619
+ value: number | null | undefined // null/undefined renders as an em-dash
1620
+ }
1621
+ ```
1622
+
1623
+ ```vue
1624
+ <EarningsCard title="TOTAL P&L" :amount="totalPnl" signed />
1625
+ <BaseStatBreakdown
1626
+ :items="[
1627
+ { label: 'Alpaca', value: 42.5 },
1628
+ { label: 'Binance', value: -3.1 },
1629
+ { label: 'Kraken', value: null },
1630
+ ]"
1631
+ currency="$"
1632
+ signed
1633
+ />
1634
+ ```
1635
+
1636
+ ### BaseFilterChip
1637
+
1638
+ Colour-coded toggleable filter chip — one-click event/category filters above
1639
+ a data feed. Idle renders a tinted border/background in the semantic colour;
1640
+ active renders a solid fill with white text (`aria-pressed` reflects the
1641
+ state). Layout classes (`h-9 flex-1`, …) pass through the class attribute;
1642
+ click handlers bind natively on the component.
1643
+
1644
+ **Props:**
1645
+
1646
+ | Prop | Type | Default | Description |
1647
+ | ---------- | --------- | --------- | ----------- |
1648
+ | `label` | `String` | `''` | Chip text; the default slot overrides it. |
1649
+ | `color` | `'emerald' \| 'sky' \| 'amber' \| 'red' \| 'slate'` | `'slate'` | Semantic colour of the idle tint and active fill. |
1650
+ | `active` | `Boolean` | `false` | Whether the chip's filter is applied (solid fill). |
1651
+ | `disabled` | `Boolean` | `false` | Greys out + blocks the click. |
1652
+ | `title` | `String` | — | Native tooltip. |
1653
+
1654
+ ```vue
1655
+ <BaseFilterChip
1656
+ v-for="f in filters"
1657
+ :key="f.key"
1658
+ class="h-9 flex-1"
1659
+ :color="f.color"
1660
+ :active="isActive(f)"
1661
+ :title="f.title"
1662
+ @click="toggle(f)"
1663
+ >{{ f.label }}</BaseFilterChip>
1664
+ ```
1665
+
1666
+ ### BaseCredentialsForm
1667
+
1668
+ One service's API-credentials card: key id + secret + base/data URLs, with
1669
+ the has-secret handling (placeholder dots, blank-keeps-stored-secret), the
1670
+ save-validation ladder and a saving spinner. Load/save results are EMITTED —
1671
+ the parent owns toasts / error banners. Exposes `load()` so a parent Reload
1672
+ button can re-pull several cards in parallel.
1673
+
1674
+ **Props:** `title` + `idPrefix` + `fetchFn: () => Promise<CredentialsView>` +
1675
+ `updateFn: (body: CredentialsUpdate) => Promise<CredentialsView>` +
1676
+ `defaults: { baseUrl, dataUrl }` (required); `subtitle`, `keyLabel`,
1677
+ `keyPlaceholder`, `secretLabel`, `secretPlaceholder`, `secretSetHint`,
1678
+ `permissionsHint`, `requiredKeyMessage`, `requiredSecretMessage`,
1679
+ `savedMessage`, `saveLabel` (optional copy overrides).
1680
+
1681
+ **Slots:** `no-secret-hint` — rich help while no secret is stored;
1682
+ `base-url-extra` (`{ form }`) — extras under the Base URL field (e.g.
1683
+ live/paper shortcut buttons that write into the form); `footer` — extra
1684
+ content at the card's bottom.
1685
+
1686
+ **Emits:** `saved(message)`, `error(message)`, `load-error(message)`.
1687
+
1688
+ ```vue
1689
+ <BaseCredentialsForm
1690
+ ref="card"
1691
+ title="Alpaca API"
1692
+ id-prefix="alpaca"
1693
+ :fetch-fn="fetchAlpaca"
1694
+ :update-fn="updateAlpaca"
1695
+ :defaults="{ baseUrl: LIVE_BASE, dataUrl: DATA_URL }"
1696
+ @saved="onSaved"
1697
+ @error="onError"
1698
+ @load-error="onLoadError"
1699
+ />
1700
+ ```
1701
+
1702
+ ---
1703
+
1704
+ ### BasePillPickerModal
1705
+
1706
+ "Pick one of many" modal: every item rendered as a clickable pill, narrowed
1707
+ by a free-text filter and an optional segmented group toggle. Clicking a pill
1708
+ emits `pick` with the item; backdrop / Escape / the footer Close emit `close`.
1709
+ Narrowing state lives inside, so a `v-if`-mounted instance always opens fresh.
1710
+
1711
+ **Props:** `title` + `items: PillPickerItem[]` (required);
1712
+ `groups?: SegmentedOption<string>[]` (renders the group toggle with an
1713
+ `allLabel` option prepended, narrowing by each item's `group`); `icon?`
1714
+ (defaults to the magnifying glass), `subtitle?`, `searchPlaceholder`,
1715
+ `emptyMessage`, `noMatchMessage`, `mono` (mono font for the filter input and
1716
+ pills — symbols, codes, ids), `maxWidthClass` (default `max-w-2xl`),
1717
+ `closeText`, `groupAriaLabel`, `allLabel`.
1718
+
1719
+ **Emits:** `pick(item: PillPickerItem)`, `close`.
1720
+
1721
+ ```ts
1722
+ interface PillPickerItem {
1723
+ id: string // unique key; identifies the pick
1724
+ label: string // pill text; what the filter matches
1725
+ group?: string // segmented-toggle bucket
1726
+ title?: string // pill tooltip
1727
+ }
1728
+ ```
1729
+
1730
+ ```vue
1731
+ <BasePillPickerModal
1732
+ v-if="open"
1733
+ title="Symbols"
1734
+ :items="symbols.map(s => ({ id: s.id, label: s.symbol, group: s.assetClass }))"
1735
+ :groups="[{ value: 'STOCK', label: 'STOCK' }, { value: 'CRYPTO', label: 'CRYPTO' }]"
1736
+ mono
1737
+ @pick="apply"
1738
+ @close="open = false"
1739
+ />
1740
+ ```
1741
+
1742
+ ---
1743
+
1744
+ ### BaseBarDistribution
1745
+
1746
+ Compact value-distribution chart: one thin rounded bar per distinct
1747
+ value, count labelled on top and the value underneath — scrolls
1748
+ sideways when there are many bars. Pure Tailwind, no chart library.
1749
+ Extracted from TradeAutomation's variant-stats modal.
1750
+
1751
+ **Props:**
1752
+
1753
+ | Prop | Type | Default | Description |
1754
+ | -------------- | -------- | ---------------------- | ----------- |
1755
+ | `bars` | `Array` | **required** | `DistributionBar[]` — `{ label, count }` per bar, in display order (sort ascending for numeric values). |
1756
+ | `ariaLabel` | `String` | `'Value distribution'` | Accessible description of the chart. |
1757
+ | `countNoun` | `String` | `'item'` | Noun for each bar's tooltip count, e.g. `'variant'` → "3 variants". |
1758
+ | `titlePrefix` | `String` | `''` | Tooltip prefix before the value, e.g. the field name. |
1759
+ | `maxBarHeight` | `Number` | `56` | Height of the tallest bar, in px. |
1760
+ | `barClass` | `String` | emerald fill | Tailwind classes for the bar fill. |
1761
+
1762
+ ```vue
1763
+ <BaseBarDistribution
1764
+ :bars="[{ label: '0.5', count: 1 }, { label: '1', count: 4 }]"
1765
+ aria-label="Distribution of Take profit across variants"
1766
+ title-prefix="Take profit"
1767
+ count-noun="variant"
1768
+ />
1769
+ ```
1770
+
1771
+ ---
1772
+
1773
+ ### BaseSearchSelect
1774
+
1775
+ Searchable select (combobox): type to filter, pick with the mouse or
1776
+ ArrowUp/ArrowDown + Enter. `multiple` turns it into a tag picker with removable
1777
+ chips (Backspace on an empty search removes the last one). Same field skin as
1778
+ `BaseInput` / `BaseSelect`; Escape and an outside click close the menu.
1779
+
1780
+ **Props:**
1781
+
1782
+ | Prop | Type | Default | Description |
1783
+ | --------------- | ----------------------------- | --------------- | ----------- |
1784
+ | `options` | `DropdownOption[]` | **required** | `{ value, label, title?, disabled? }` per row. |
1785
+ | `modelValue` | `value \| null \| value[]` | `null` | Selected value, or values with `multiple`. |
1786
+ | `multiple` | `Boolean` | `false` | Pick several (chips). |
1787
+ | `placeholder` | `String` | `'Select'` | Shown when nothing is selected. |
1788
+ | `searchable` | `Boolean` | `true` | Typing filters the options. |
1789
+ | `clearable` | `Boolean` | `true` | Show the × clear button while something is selected. |
1790
+ | `block` | `Boolean` | `true` | Full-width. |
1791
+ | `disabled` | `Boolean` | `false` | |
1792
+ | `ariaLabel` | `String` | `''` | Accessible name without a visible label. |
1793
+ | `noResultsText` | `String` | `'No matches.'` | |
1794
+ | `emptyText` | `String` | `'No options.'` | |
1795
+
1796
+ **Emits:** `update:modelValue` — the value (single; `null` when cleared) or the
1797
+ array of values (`multiple`).
1798
+
1799
+ ```vue
1800
+ <BaseSearchSelect v-model="userId" :options="users.map(u => ({ value: u.id, label: u.name }))" placeholder="Select User" />
1801
+ <BaseSearchSelect v-model="tags" :options="TAGS" multiple />
1802
+ ```
1803
+
1804
+ ### BaseCard
1805
+
1806
+ Bordered surface card — the shared chrome for forms, filter/search panels and
1807
+ grouped content.
1808
+
1809
+ **Props:** `title`, `subtitle`, `padding: 'md' | 'sm' | 'none'` (`'md'`).
1810
+ **Slots:** `default` (body), `actions` (header, right), `footer` (bottom, right-aligned — submit/cancel).
1811
+
1812
+ ```vue
1813
+ <BaseCard title="Template">
1814
+ <form>…</form>
1815
+ <template #footer><BaseButton type="submit" description="Save" /></template>
1816
+ </BaseCard>
1817
+ ```
1818
+
1819
+ ### BaseField
1820
+
1821
+ Label + control + message wrapper for forms and filter bars.
1822
+
1823
+ **Props:** `label`, `labelFor` (the control's id), `required`, `error`
1824
+ (red, replaces the hint), `hint`, `compact` (small uppercase filter-bar label),
1825
+ `grow` (takes the free space in a flex row).
1826
+
1827
+ ```vue
1828
+ <BaseCard padding="sm">
1829
+ <div class="flex flex-wrap items-end gap-4">
1830
+ <BaseField label="Search symbol" label-for="q" compact grow>
1831
+ <BaseInput id="q" v-model="query" />
1832
+ </BaseField>
1833
+ <BaseField label="Class" compact>
1834
+ <BaseSegmentedControl v-model="cls" :options="CLASSES" />
1835
+ </BaseField>
1836
+ </div>
1837
+ </BaseCard>
1838
+ ```
1839
+
1840
+ ### BaseStatCard
1841
+
1842
+ Dashboard stat tile in the `EarningsCard` style (dashed accent border, bold
1843
+ title, big value) for any value — counts, labels, pre-formatted numbers.
1844
+
1845
+ **Props:** `title` (required), `value`, `subtitle`,
1846
+ `accent: 'emerald' | 'sky' | 'amber' | 'red' | 'slate'` (`'emerald'`),
1847
+ `to` (router location — makes the whole card a link).
1848
+ **Slots:** `icon` (fills the tinted chip; receives `iconClass`), `default` (extra content).
1849
+
1850
+ ```vue
1851
+ <BaseStatCard title="Categories" :value="71" accent="sky" :to="{ name: 'Category List' }">
1852
+ <template #icon="{ iconClass }"><SwatchIcon :class="iconClass" /></template>
1853
+ </BaseStatCard>
1854
+ ```
1855
+
1856
+ ### BaseCheckbox
1857
+
1858
+ Rounded checkbox, emerald when checked (works with or without a forms plugin).
1859
+ `v-model` is the boolean; `change` fires with the new value; attrs (`id`, `name`)
1860
+ go to the `<input>`.
1861
+
1862
+ **Props:** `modelValue`, `label`, `disabled`. **Slots:** `default` (rich label).
1863
+ **Emits:** `update:modelValue(value)`, `change(value)`.
1864
+
1865
+ ```vue
1866
+ <BaseCheckbox v-model="remember" id="remember" label="Remember me" />
1867
+ ```
1868
+
1869
+ ### BaseToggle
1870
+
1871
+ On/off switch (`role="switch"`). `v-model` is the boolean; `change` fires after
1872
+ every user toggle with the new value.
1873
+
1874
+ **Props:** `modelValue`, `label` (visible label, also the accessible name),
1875
+ `ariaLabel` (when there is no label), `color: 'emerald' | 'red' | 'sky' | 'amber'`
1876
+ (on state, `'emerald'`), `offTone: 'slate' | 'red'` (off track, `'slate'`), `disabled`.
1877
+ **Emits:** `update:modelValue(value)`, `change(value)`.
1878
+
1879
+ ```vue
1880
+ <BaseToggle v-model="task.alive" :label="task.name" color="red" @change="save(task)" />
1881
+ <BaseToggle v-model="account.alive" off-tone="red" aria-label="Alive" />
1882
+ ```
1883
+
1884
+ ### BaseAuthLayout
1885
+
1886
+ Full-page, centred shell for sign-in / sign-up / password-recovery screens:
1887
+ logo on top (defaults to `BaseLogo`), then a bordered card with the title,
1888
+ content and an optional footer.
1889
+
1890
+ **Props:** `title`, `subtitle`, `wide` (max-w-3xl card for multi-column forms; default max-w-md).
1891
+ **Slots:** `default` (form), `logo` (replaces `BaseLogo`), `footer` ("No account? Sign up").
1892
+
1893
+ ```vue
1894
+ <BaseAuthLayout title="Forgot password">
1895
+ <form>…</form>
1896
+ <template #footer>No account? <RouterLink to="/register">Sign up</RouterLink></template>
1897
+ </BaseAuthLayout>
1898
+ ```
1899
+
1900
+ ### BaseBooleanBadge
1901
+
1902
+ Yes/no pill for boolean columns: green check when true, red cross when false.
1903
+
1904
+ **Props:** `value` (`boolean | null`), `trueLabel` (`'Yes'`), `falseLabel` (`'No'`).
1905
+
1906
+ ```vue
1907
+ <BaseBooleanBadge :value="user.hasVerifiedEmail" true-label="Verified" false-label="Not verified" />
1908
+ ```
1909
+
1910
+ ### BaseDetailList
1911
+
1912
+ Read-only label/value grid for detail pages (the "view" counterpart of a form).
1913
+ Empty values show `emptyText`; `href` renders the value as an external link;
1914
+ `mono` uses the monospace face.
1915
+
1916
+ **Props:** `items: DetailItem[]` (`{ label, value?, href?, mono? }`, required),
1917
+ `columns: 1 | 2 | 3` (`2`, from `sm` up), `emptyText` (`'—'`).
1918
+
1919
+ ```vue
1920
+ <BaseCard title="Details">
1921
+ <BaseDetailList :items="[{ label: 'Status', value: post.status }, { label: 'Link', value: post.link, href: post.link }]" />
1922
+ </BaseCard>
1923
+ ```
1924
+
1925
+ ## Composables
1926
+
1927
+ ```ts
1928
+ import {
1929
+ initTheme,
1930
+ useTheme,
1931
+ useThemeClasses,
1932
+ useEscapeKey,
1933
+ useDebouncedRef,
1934
+ useToast,
1935
+ useMobileSidebar,
1936
+ useSidebarCollapse,
1937
+ useNotifications,
1938
+ useQueryParamSync,
1939
+ useFieldClasses,
1940
+ usePolling,
1941
+ } from 'mgv-backoffice'
1942
+ import type {
1943
+ UseThemeOptions,
1944
+ UseSidebarCollapseOptions,
1945
+ UsePollingOptions,
1946
+ } from 'mgv-backoffice'
1947
+ ```
1948
+
1949
+ | Composable | Purpose |
1950
+ | ---------- | ------- |
1951
+ | `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). |
1952
+ | `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. |
1953
+ | `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). |
1954
+ | `useEscapeKey(handler)` | Component-scoped Escape key listener. |
1955
+ | `useDebouncedRef(source, delay?)` | Debounced mirror of a ref. Timer cleared on scope dispose. |
1956
+ | `useToast(durationMs?)` | Per-component toast state: `{ showToast, toastMessage, toastType, showToastMessage }`. `showToastMessage` also accepts a per-call duration override. |
1957
+ | `useMobileSidebar()` | Singleton state shared between `BaseSidebar` and `BaseAppLayout` for the off-canvas open/closed flag. |
1958
+ | `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'`). |
1959
+ | `useNotifications()` | Singleton notification state shared by the sidebar bell and `BaseNotificationPanel`: `{ notifications, unreadCount, open, openPanel, closePanel, togglePanel, setNotifications, add, remove, markRead, markAllRead, clear }`. |
1960
+ | `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. |
1961
+ | `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. |
1962
+ | `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. |
1963
+
1964
+ ---
1965
+
1966
+ ## Typography
1967
+
1968
+ Since 1.33.0 the library ships the shared brand typography: the stylesheet
1969
+ loads **Fira Sans** (UI text) and **Fira Code** (numerals/data) from Google
1970
+ Fonts via `@import`, registers them as the Tailwind `--font-sans` /
1971
+ `--font-mono` theme defaults, and applies `font-family: var(--font-sans)` to
1972
+ `body`. Consumers get the fonts just by importing the lib CSS — remove any
1973
+ app-local Google Fonts `<link rel="stylesheet">` and `--font-sans`/`--font-mono`
1974
+ overrides. Keep (or add) the preconnect hints in `index.html` for a faster
1975
+ first paint:
1976
+
1977
+ ```html
1978
+ <link rel="preconnect" href="https://fonts.googleapis.com" />
1979
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
1980
+ ```
1981
+
1982
+ ## Tailwind setup for consumers
1983
+
1984
+ The lib's components rely on Tailwind utility classes (including dark-mode
1985
+ variants). Consumers should add the lib's `dist` output to their Tailwind
1986
+ `content` paths so the JIT can see the class names:
1987
+
1988
+ ```js
1989
+ // tailwind.config.js
1990
+ export default {
1991
+ content: [
1992
+ './index.html',
1993
+ './src/**/*.{vue,ts}',
1994
+ './node_modules/mgv-backoffice/dist/**/*.{js,mjs,cjs,vue}',
1995
+ ],
1996
+ }
1997
+ ```
1998
+
1999
+ The legacy `tailwind.safelist.js` only covers the v1 components; the
2000
+ recommended path for v4+ is the `content` glob above.