@hydrateless/vue 0.6.0 → 0.8.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
@@ -10,7 +10,7 @@ enhancers, with automatic cleanup when components unmount.
10
10
  npm install hydrateless @hydrateless/vue
11
11
  ```
12
12
 
13
- Import the CSS once (e.g. in your entry):
13
+ Import the CSS once (e.g., in your entry):
14
14
 
15
15
  ```ts
16
16
  import 'hydrateless/hydrateless.css';
@@ -43,7 +43,7 @@ Then use the directives in any template:
43
43
 
44
44
  Available directives: `v-hl-accordion`, `v-hl-disclosure`, `v-hl-tabs`,
45
45
  `v-hl-dropdown`, `v-hl-modal`, `v-hl-drawer`, `v-hl-popover`, `v-hl-tooltip`,
46
- `v-hl-toc`. You can also import individual directives (e.g. `vHlTabs`) and
46
+ `v-hl-toc`. You can also import individual directives (e.g., `vHlTabs`) and
47
47
  register them locally.
48
48
 
49
49
  ## Components
@@ -80,19 +80,17 @@ const open = ref(false);
80
80
 
81
81
  ```vue
82
82
  <script setup lang="ts">
83
- import { ref } from 'vue';
84
83
  import { useEnhancer, useToast } from '@hydrateless/vue';
85
84
  import { enhanceDropdown } from '@hydrateless/enhancers';
86
85
 
87
- const menu = ref<HTMLElement | null>(null);
88
- const dropdown = useEnhancer(menu, enhanceDropdown);
89
- // dropdown.value?.setOpen(true)
86
+ const { host, api } = useEnhancer((el) => enhanceDropdown(el));
87
+ // api.value?.setOpen(true)
90
88
 
91
89
  const toast = useToast(); // no provider required
92
90
  </script>
93
91
 
94
92
  <template>
95
- <div ref="menu" data-hl-dropdown>…</div>
93
+ <div ref="host" data-hl-dropdown>…</div>
96
94
  <button @click="toast.show('Saved')">Save</button>
97
95
  </template>
98
96
  ```
package/dist/index.d.ts CHANGED
@@ -1,25 +1,34 @@
1
1
  import * as vue from 'vue';
2
- import { Ref, ShallowRef, Plugin, Directive, PropType } from 'vue';
2
+ import { WatchSource, Ref, ShallowRef, Plugin, Directive, PropType } from 'vue';
3
+ import * as _hydrateless_enhancers from '@hydrateless/enhancers';
3
4
  import { EnhancerHandle, EnhanceToastOptions, ToastApi, EnhanceTabsOptions, EnhanceDropdownOptions, EnhanceMenuOptions, EnhanceComboboxOptions } from '@hydrateless/enhancers';
4
- export { AccordionApi, ComboboxApi, Disposer, DrawerApi, DropdownApi, EnhancerHandle, ModalApi, PopoverApi, TabsApi, ToastApi, TooltipApi } from '@hydrateless/enhancers';
5
+ export { AccordionApi, ComboboxApi, CommandApi, DisclosureApi, Disposer, DrawerApi, DropdownApi, EnhancerHandle, MenuApi, ModalApi, PopoverApi, TabsApi, ToastApi, TocApi, TooltipApi } from '@hydrateless/enhancers';
5
6
 
6
7
  /**
7
- * Attach any Hydrateless enhancer to a template ref for the lifetime of a
8
- * component. Returns a shallow ref to the enhancer's imperative API; the
9
- * instance is destroyed automatically on unmount.
8
+ * Attach any Hydrateless enhancer to a host element for the lifetime of a
9
+ * component. Returns a template ref to bind onto the element you want
10
+ * enhanced plus a shallow ref to the enhancer's imperative API (e.g.
11
+ * `setValue`/`setOpen`). The enhancer runs client-side only (so components
12
+ * stay SSR-safe) and is destroyed automatically on unmount. Pass a reactive
13
+ * `source` to destroy and re-attach whenever an enhancer option changes.
10
14
  *
11
- * ```ts
12
- * const el = ref<HTMLElement | null>(null);
13
- * const tabs = useEnhancer(el, enhanceTabs);
14
- * tabs.value?.setValue('install');
15
+ * ```vue
16
+ * <script setup>
17
+ * const { host, api } = useEnhancer((el) => enhanceTabs(el));
18
+ * // api.value?.setValue('two');
19
+ * </script>
20
+ * <template><div data-hl-tabs ref="host">…</div></template>
15
21
  * ```
16
22
  */
17
- declare function useEnhancer<Api = null>(target: Ref<HTMLElement | null | undefined>, enhance: (container: HTMLElement) => EnhancerHandle<Api>): ShallowRef<Api | null>;
23
+ declare function useEnhancer<Api = null>(enhance: (el: HTMLElement) => EnhancerHandle<Api>, source?: WatchSource<unknown>): {
24
+ host: Ref<HTMLElement | null>;
25
+ api: ShallowRef<Api | null>;
26
+ };
18
27
 
19
28
  /**
20
29
  * Imperative toast API backed by a lazily-created document-level region (or a
21
30
  * `[data-hl-toast-region]` you render yourself, e.g. via `<ToastRegion>`).
22
- * Safe to call from any component — no provider required.
31
+ * Safe to call from any component: no provider required.
23
32
  */
24
33
  declare function useToast(options?: EnhanceToastOptions): ToastApi;
25
34
 
@@ -35,17 +44,29 @@ declare function useToast(options?: EnhanceToastOptions): ToastApi;
35
44
  */
36
45
  declare const HydratelessPlugin: Plugin;
37
46
 
47
+ /** `v-hl-accordion` directive: single-open accordion behavior on the bound element. */
38
48
  declare const vHlAccordion: Directive<HTMLElement>;
49
+ /** `v-hl-disclosure` directive: groups `[data-hl-disclosure]` elements within the bound element. */
39
50
  declare const vHlDisclosure: Directive<HTMLElement>;
51
+ /** `v-hl-tabs` directive: ARIA and keyboard navigation for a `[data-hl-tabs]` element. */
40
52
  declare const vHlTabs: Directive<HTMLElement>;
53
+ /** `v-hl-dropdown` directive: menu-button behavior for a `[data-hl-dropdown]` element. */
41
54
  declare const vHlDropdown: Directive<HTMLElement>;
55
+ /** `v-hl-modal` directive: wires modal openers/closers and a focus trap within the bound element. */
42
56
  declare const vHlModal: Directive<HTMLElement>;
57
+ /** `v-hl-drawer` directive: wires drawer openers/closers within the bound element. */
43
58
  declare const vHlDrawer: Directive<HTMLElement>;
59
+ /** `v-hl-popover` directive: wires popover openers/closers within the bound element. */
44
60
  declare const vHlPopover: Directive<HTMLElement>;
61
+ /** `v-hl-tooltip` directive: wires `[data-hl-tooltip]` triggers within the bound element. */
45
62
  declare const vHlTooltip: Directive<HTMLElement>;
63
+ /** `v-hl-toc` directive: builds a table of contents from the surrounding document. */
46
64
  declare const vHlToc: Directive<HTMLElement>;
65
+ /** `v-hl-menu` directive: menubar/navigation behavior for a `[data-hl-menu]` element. */
47
66
  declare const vHlMenu: Directive<HTMLElement>;
67
+ /** `v-hl-combobox` directive: editable combobox behavior for a `[data-hl-combobox]` element. */
48
68
  declare const vHlCombobox: Directive<HTMLElement>;
69
+ /** `v-hl-command` directive: command-palette behavior for a `[data-hl-command]` element. */
49
70
  declare const vHlCommand: Directive<HTMLElement>;
50
71
  /** Map of directive names (without the `v-` prefix) to their definitions. */
51
72
  declare const directives: Record<string, Directive<HTMLElement>>;
@@ -123,23 +144,39 @@ declare const AccordionItem: vue.DefineComponent<vue.ExtractPropTypes<{
123
144
  defaultOpen: boolean;
124
145
  }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
125
146
  /**
126
- * A single expandable section. Native `<details>` handles open/close; the
127
- * enhancer only matters for a mutually-exclusive group.
147
+ * A single expandable section built on native `<details>`, which handles
148
+ * open/close (and exclusive groups, via the `name` attribute) on its own.
149
+ * Open state works uncontrolled (`defaultOpen`) or with `v-model:open`.
128
150
  */
129
151
  declare const Disclosure: vue.DefineComponent<vue.ExtractPropTypes<{
152
+ /** Controlled open state (`v-model:open`). */
153
+ open: {
154
+ type: PropType<boolean | undefined>;
155
+ default: undefined;
156
+ };
157
+ /** Open the disclosure initially for uncontrolled usage. */
130
158
  defaultOpen: {
131
159
  type: BooleanConstructor;
132
160
  default: boolean;
133
161
  };
134
162
  }>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
135
163
  [key: string]: any;
136
- }>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
164
+ }>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, "update:open"[], "update:open", vue.PublicProps, Readonly<vue.ExtractPropTypes<{
165
+ /** Controlled open state (`v-model:open`). */
166
+ open: {
167
+ type: PropType<boolean | undefined>;
168
+ default: undefined;
169
+ };
170
+ /** Open the disclosure initially for uncontrolled usage. */
137
171
  defaultOpen: {
138
172
  type: BooleanConstructor;
139
173
  default: boolean;
140
174
  };
141
- }>> & Readonly<{}>, {
175
+ }>> & Readonly<{
176
+ "onUpdate:open"?: ((...args: any[]) => any) | undefined;
177
+ }>, {
142
178
  defaultOpen: boolean;
179
+ open: boolean | undefined;
143
180
  }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
144
181
 
145
182
  /**
@@ -275,8 +312,8 @@ declare const Dropdown: vue.DefineComponent<vue.ExtractPropTypes<{
275
312
  "onUpdate:open"?: ((...args: any[]) => any) | undefined;
276
313
  }>, {
277
314
  defaultOpen: boolean;
278
- placement: "bottom" | "top" | undefined;
279
315
  open: boolean | undefined;
316
+ placement: _hydrateless_enhancers.Placement | undefined;
280
317
  }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
281
318
  /** The button that opens the menu. */
282
319
  declare const DropdownTrigger: vue.DefineComponent<{}, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
@@ -298,22 +335,38 @@ declare const DropdownSeparator: vue.DefineComponent<{}, () => vue.VNode<vue.Ren
298
335
  }>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
299
336
 
300
337
  /**
301
- * Menubar / navigation menu with single-level submenus. Compose with
302
- * `<MenuItem>`; nest a flyout via the `submenu` slot.
338
+ * Menubar / navigation menu with single-level submenus rendered in the top
339
+ * layer. Compose with `<MenuItem>`; nest a flyout via the `submenu` slot. The
340
+ * open submenu works uncontrolled or with `v-model:open` (a submenu value or
341
+ * `null`), and activating a leaf item emits `select` with its value.
303
342
  */
304
343
  declare const Menu: vue.DefineComponent<vue.ExtractPropTypes<{
305
344
  orientation: {
306
345
  type: PropType<EnhanceMenuOptions["orientation"]>;
307
346
  default: string;
308
347
  };
348
+ /** Controlled open submenu value (`v-model:open`), or `null` for none. */
349
+ open: {
350
+ type: PropType<string | null | undefined>;
351
+ default: undefined;
352
+ };
309
353
  }>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
310
354
  [key: string]: any;
311
- }>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
355
+ }>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, ("select" | "update:open")[], "select" | "update:open", vue.PublicProps, Readonly<vue.ExtractPropTypes<{
312
356
  orientation: {
313
357
  type: PropType<EnhanceMenuOptions["orientation"]>;
314
358
  default: string;
315
359
  };
316
- }>> & Readonly<{}>, {
360
+ /** Controlled open submenu value (`v-model:open`), or `null` for none. */
361
+ open: {
362
+ type: PropType<string | null | undefined>;
363
+ default: undefined;
364
+ };
365
+ }>> & Readonly<{
366
+ onSelect?: ((...args: any[]) => any) | undefined;
367
+ "onUpdate:open"?: ((...args: any[]) => any) | undefined;
368
+ }>, {
369
+ open: string | null | undefined;
317
370
  orientation: "horizontal" | "vertical" | undefined;
318
371
  }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
319
372
  /**
@@ -325,6 +378,11 @@ declare const MenuItem: vue.DefineComponent<vue.ExtractPropTypes<{
325
378
  type: StringConstructor;
326
379
  default: undefined;
327
380
  };
381
+ /** Stable value identifying this item; defaults to its label text. */
382
+ value: {
383
+ type: StringConstructor;
384
+ default: undefined;
385
+ };
328
386
  }>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
329
387
  [key: string]: any;
330
388
  }>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, "select"[], "select", vue.PublicProps, Readonly<vue.ExtractPropTypes<{
@@ -332,22 +390,35 @@ declare const MenuItem: vue.DefineComponent<vue.ExtractPropTypes<{
332
390
  type: StringConstructor;
333
391
  default: undefined;
334
392
  };
393
+ /** Stable value identifying this item; defaults to its label text. */
394
+ value: {
395
+ type: StringConstructor;
396
+ default: undefined;
397
+ };
335
398
  }>> & Readonly<{
336
399
  onSelect?: ((...args: any[]) => any) | undefined;
337
400
  }>, {
401
+ value: string;
338
402
  href: string;
339
403
  }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
340
404
 
341
405
  /**
342
- * Controlled dialog overlay on the native `<dialog>` plus the modal enhancer
343
- * (focus trap, scroll-lock, background `inert`). Drive with `v-model:open`;
344
- * Escape and backdrop clicks emit `update:open`. Compose with `<ModalHeader>`,
345
- * `<ModalBody>`, `<ModalFooter>`.
406
+ * Dialog overlay on the native `<dialog>` plus the modal enhancer (focus
407
+ * trap, scroll-lock, background `inert`). Open state works uncontrolled
408
+ * (`defaultOpen`, or a `command="show-modal"` invoker button) or with
409
+ * `v-model:open`; Escape and backdrop clicks emit `update:open`. Compose
410
+ * with `<ModalHeader>`, `<ModalBody>`, `<ModalFooter>`.
346
411
  */
347
412
  declare const Modal: vue.DefineComponent<vue.ExtractPropTypes<{
413
+ /** Controlled open state (`v-model:open`). */
348
414
  open: {
415
+ type: PropType<boolean | undefined>;
416
+ default: undefined;
417
+ };
418
+ /** Open the dialog initially for uncontrolled usage. */
419
+ defaultOpen: {
349
420
  type: BooleanConstructor;
350
- required: true;
421
+ default: boolean;
351
422
  };
352
423
  closeOnBackdrop: {
353
424
  type: BooleanConstructor;
@@ -356,9 +427,15 @@ declare const Modal: vue.DefineComponent<vue.ExtractPropTypes<{
356
427
  }>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
357
428
  [key: string]: any;
358
429
  }>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, "update:open"[], "update:open", vue.PublicProps, Readonly<vue.ExtractPropTypes<{
430
+ /** Controlled open state (`v-model:open`). */
359
431
  open: {
432
+ type: PropType<boolean | undefined>;
433
+ default: undefined;
434
+ };
435
+ /** Open the dialog initially for uncontrolled usage. */
436
+ defaultOpen: {
360
437
  type: BooleanConstructor;
361
- required: true;
438
+ default: boolean;
362
439
  };
363
440
  closeOnBackdrop: {
364
441
  type: BooleanConstructor;
@@ -367,17 +444,26 @@ declare const Modal: vue.DefineComponent<vue.ExtractPropTypes<{
367
444
  }>> & Readonly<{
368
445
  "onUpdate:open"?: ((...args: any[]) => any) | undefined;
369
446
  }>, {
447
+ defaultOpen: boolean;
448
+ open: boolean | undefined;
370
449
  closeOnBackdrop: boolean;
371
450
  }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
372
451
  /**
373
- * Controlled off-canvas panel on the native `<dialog>` plus the drawer
374
- * enhancer. Drive with `v-model:open`; choose a `side`. Compose with
375
- * `<DrawerHeader>`, `<DrawerBody>`, `<DrawerFooter>`.
452
+ * Off-canvas panel on the native `<dialog>` plus the drawer enhancer. Open
453
+ * state works uncontrolled (`defaultOpen`, or an invoker button) or with
454
+ * `v-model:open`; choose a `side`. Compose with `<DrawerHeader>`,
455
+ * `<DrawerBody>`, `<DrawerFooter>`.
376
456
  */
377
457
  declare const Drawer: vue.DefineComponent<vue.ExtractPropTypes<{
458
+ /** Controlled open state (`v-model:open`). */
378
459
  open: {
460
+ type: PropType<boolean | undefined>;
461
+ default: undefined;
462
+ };
463
+ /** Open the drawer initially for uncontrolled usage. */
464
+ defaultOpen: {
379
465
  type: BooleanConstructor;
380
- required: true;
466
+ default: boolean;
381
467
  };
382
468
  side: {
383
469
  type: PropType<"left" | "right">;
@@ -390,9 +476,15 @@ declare const Drawer: vue.DefineComponent<vue.ExtractPropTypes<{
390
476
  }>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
391
477
  [key: string]: any;
392
478
  }>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, "update:open"[], "update:open", vue.PublicProps, Readonly<vue.ExtractPropTypes<{
479
+ /** Controlled open state (`v-model:open`). */
393
480
  open: {
481
+ type: PropType<boolean | undefined>;
482
+ default: undefined;
483
+ };
484
+ /** Open the drawer initially for uncontrolled usage. */
485
+ defaultOpen: {
394
486
  type: BooleanConstructor;
395
- required: true;
487
+ default: boolean;
396
488
  };
397
489
  side: {
398
490
  type: PropType<"left" | "right">;
@@ -405,48 +497,71 @@ declare const Drawer: vue.DefineComponent<vue.ExtractPropTypes<{
405
497
  }>> & Readonly<{
406
498
  "onUpdate:open"?: ((...args: any[]) => any) | undefined;
407
499
  }>, {
500
+ defaultOpen: boolean;
501
+ open: boolean | undefined;
408
502
  closeOnBackdrop: boolean;
409
503
  side: "left" | "right";
410
504
  }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
505
+ /** Header region of a {@link Modal}. */
411
506
  declare const ModalHeader: vue.DefineComponent<{}, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
412
507
  [key: string]: any;
413
508
  }>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
509
+ /** Body region of a {@link Modal}. */
414
510
  declare const ModalBody: vue.DefineComponent<{}, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
415
511
  [key: string]: any;
416
512
  }>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
513
+ /** Footer region of a {@link Modal}. */
417
514
  declare const ModalFooter: vue.DefineComponent<{}, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
418
515
  [key: string]: any;
419
516
  }>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
517
+ /** Header region of a {@link Drawer}. */
420
518
  declare const DrawerHeader: vue.DefineComponent<{}, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
421
519
  [key: string]: any;
422
520
  }>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
521
+ /** Body region of a {@link Drawer}. */
423
522
  declare const DrawerBody: vue.DefineComponent<{}, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
424
523
  [key: string]: any;
425
524
  }>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
525
+ /** Footer region of a {@link Drawer}. */
426
526
  declare const DrawerFooter: vue.DefineComponent<{}, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
427
527
  [key: string]: any;
428
528
  }>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
429
529
  /**
430
- * Controlled floating content. Visibility follows `open`; Escape and outside
431
- * clicks emit `update:open` so `v-model:open` can dismiss it. Pair with your
432
- * own trigger.
530
+ * Floating content built on the native Popover API. The surface lives in the
531
+ * top layer with light-dismiss and Escape handled by the browser; visibility
532
+ * works uncontrolled (`defaultOpen`, or a `popovertarget` trigger button) or
533
+ * with `v-model:open` (`update:open` is emitted when the browser dismisses
534
+ * it).
433
535
  */
434
536
  declare const Popover: vue.DefineComponent<vue.ExtractPropTypes<{
537
+ /** Controlled open state (`v-model:open`). */
435
538
  open: {
539
+ type: PropType<boolean | undefined>;
540
+ default: undefined;
541
+ };
542
+ /** Show the popover initially for uncontrolled usage. */
543
+ defaultOpen: {
436
544
  type: BooleanConstructor;
437
545
  default: boolean;
438
546
  };
439
547
  }>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
440
548
  [key: string]: any;
441
549
  }>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, "update:open"[], "update:open", vue.PublicProps, Readonly<vue.ExtractPropTypes<{
550
+ /** Controlled open state (`v-model:open`). */
442
551
  open: {
552
+ type: PropType<boolean | undefined>;
553
+ default: undefined;
554
+ };
555
+ /** Show the popover initially for uncontrolled usage. */
556
+ defaultOpen: {
443
557
  type: BooleanConstructor;
444
558
  default: boolean;
445
559
  };
446
560
  }>> & Readonly<{
447
561
  "onUpdate:open"?: ((...args: any[]) => any) | undefined;
448
562
  }>, {
449
- open: boolean;
563
+ defaultOpen: boolean;
564
+ open: boolean | undefined;
450
565
  }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
451
566
  /**
452
567
  * Accessible tooltip wrapping a single focusable trigger (the default slot).
@@ -603,7 +718,8 @@ declare const ComboboxOption: vue.DefineComponent<vue.ExtractPropTypes<{
603
718
  /**
604
719
  * Command palette. Compose with `<CommandInput>`, `<CommandList>`,
605
720
  * `<CommandGroup>`, `<CommandItem>`, `<CommandEmpty>`. Emits `select` with the
606
- * chosen value. Place inside a `<dialog>` to use `hotkey`.
721
+ * chosen value and `update:query` as the filter changes. Place inside a
722
+ * `<dialog>` to use `hotkey`.
607
723
  */
608
724
  declare const Command: vue.DefineComponent<vue.ExtractPropTypes<{
609
725
  hotkey: {
@@ -612,13 +728,14 @@ declare const Command: vue.DefineComponent<vue.ExtractPropTypes<{
612
728
  };
613
729
  }>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
614
730
  [key: string]: any;
615
- }>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, "select"[], "select", vue.PublicProps, Readonly<vue.ExtractPropTypes<{
731
+ }>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, ("select" | "update:query")[], "select" | "update:query", vue.PublicProps, Readonly<vue.ExtractPropTypes<{
616
732
  hotkey: {
617
733
  type: StringConstructor;
618
734
  default: undefined;
619
735
  };
620
736
  }>> & Readonly<{
621
737
  onSelect?: ((...args: any[]) => any) | undefined;
738
+ "onUpdate:query"?: ((...args: any[]) => any) | undefined;
622
739
  }>, {
623
740
  hotkey: string;
624
741
  }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
@@ -711,8 +828,8 @@ declare const Field: vue.DefineComponent<vue.ExtractPropTypes<{
711
828
  };
712
829
  }>> & Readonly<{}>, {
713
830
  invalid: boolean;
714
- required: boolean;
715
831
  id: string;
832
+ required: boolean;
716
833
  }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
717
834
  /** Returns props (`id`, `aria-describedby`, `aria-invalid`) to bind onto a control. */
718
835
  declare function useFieldBindings(): {
@@ -724,15 +841,19 @@ declare function useFieldBindings(): {
724
841
  'aria-describedby': string | undefined;
725
842
  'aria-invalid': true | undefined;
726
843
  };
844
+ /** Label for a {@link Field}'s control, associated with it by id. */
727
845
  declare const FieldLabel: vue.DefineComponent<{}, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
728
846
  [key: string]: any;
729
847
  }>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
848
+ /** Help text for a {@link Field}, linked to its control via `aria-describedby`. */
730
849
  declare const FieldHelp: vue.DefineComponent<{}, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
731
850
  [key: string]: any;
732
851
  }>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
852
+ /** Validation message for a {@link Field}; renders nothing until it has content. */
733
853
  declare const FieldError: vue.DefineComponent<{}, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
734
854
  [key: string]: any;
735
855
  }> | null, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
856
+ /** Groups related controls in a native fieldset with an optional `legend` slot. */
736
857
  declare const Fieldset: vue.DefineComponent<{}, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
737
858
  [key: string]: any;
738
859
  }>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
@@ -939,12 +1060,20 @@ declare const Radio: vue.DefineComponent<vue.ExtractPropTypes<{
939
1060
  required: true;
940
1061
  };
941
1062
  }>> & Readonly<{}>, {}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
942
- /** Segmented control — a styled radiogroup. Supports `v-model`. */
1063
+ /**
1064
+ * Segmented control: a styled radiogroup. The selected value works
1065
+ * uncontrolled (`defaultValue`) or with `v-model`.
1066
+ */
943
1067
  declare const SegmentedControl: vue.DefineComponent<vue.ExtractPropTypes<{
944
1068
  modelValue: {
945
1069
  type: StringConstructor;
946
1070
  default: undefined;
947
1071
  };
1072
+ /** Initially selected value for uncontrolled usage. */
1073
+ defaultValue: {
1074
+ type: StringConstructor;
1075
+ default: undefined;
1076
+ };
948
1077
  options: {
949
1078
  type: PropType<Array<{
950
1079
  label: string;
@@ -968,6 +1097,11 @@ declare const SegmentedControl: vue.DefineComponent<vue.ExtractPropTypes<{
968
1097
  type: StringConstructor;
969
1098
  default: undefined;
970
1099
  };
1100
+ /** Initially selected value for uncontrolled usage. */
1101
+ defaultValue: {
1102
+ type: StringConstructor;
1103
+ default: undefined;
1104
+ };
971
1105
  options: {
972
1106
  type: PropType<Array<{
973
1107
  label: string;
@@ -989,6 +1123,7 @@ declare const SegmentedControl: vue.DefineComponent<vue.ExtractPropTypes<{
989
1123
  }>, {
990
1124
  name: string;
991
1125
  modelValue: string;
1126
+ defaultValue: string;
992
1127
  size: Size;
993
1128
  options: {
994
1129
  label: string;
@@ -997,7 +1132,7 @@ declare const SegmentedControl: vue.DefineComponent<vue.ExtractPropTypes<{
997
1132
  }[];
998
1133
  }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
999
1134
 
1000
- /** Button primitive — `hl-button` with intent/variant/size modifiers. */
1135
+ /** Button primitive: `hl-button` with intent/variant/size modifiers. */
1001
1136
  declare const Button: vue.DefineComponent<vue.ExtractPropTypes<{
1002
1137
  variant: {
1003
1138
  type: PropType<"solid" | "soft" | "outline" | "ghost" | "link">;
@@ -1060,7 +1195,7 @@ declare const Button: vue.DefineComponent<vue.ExtractPropTypes<{
1060
1195
  }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
1061
1196
 
1062
1197
  type Intent = 'neutral' | 'primary' | 'danger' | 'success' | 'warning' | 'info';
1063
- /** Alert primitive — `hl-alert` with intent, optional `icon` slot + `title`. */
1198
+ /** Alert primitive: `hl-alert` with intent, optional `icon` slot + `title`. */
1064
1199
  declare const Alert: vue.DefineComponent<vue.ExtractPropTypes<{
1065
1200
  intent: {
1066
1201
  type: PropType<Intent>;
@@ -1085,7 +1220,7 @@ declare const Alert: vue.DefineComponent<vue.ExtractPropTypes<{
1085
1220
  title: string;
1086
1221
  intent: Intent;
1087
1222
  }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
1088
- /** Badge primitive — `hl-badge` with intent/variant/size modifiers. */
1223
+ /** Badge primitive: `hl-badge` with intent/variant/size modifiers. */
1089
1224
  declare const Badge: vue.DefineComponent<vue.ExtractPropTypes<{
1090
1225
  intent: {
1091
1226
  type: PropType<Intent>;
@@ -1119,7 +1254,7 @@ declare const Badge: vue.DefineComponent<vue.ExtractPropTypes<{
1119
1254
  variant: "solid" | "soft" | "outline";
1120
1255
  intent: Intent;
1121
1256
  }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
1122
- /** Progress primitive — native `<progress class="hl-progress">`. */
1257
+ /** Progress primitive: native `<progress class="hl-progress">`. */
1123
1258
  declare const Progress: vue.DefineComponent<vue.ExtractPropTypes<{
1124
1259
  value: {
1125
1260
  type: NumberConstructor;
@@ -1162,7 +1297,7 @@ declare const Progress: vue.DefineComponent<vue.ExtractPropTypes<{
1162
1297
  intent: "primary" | "danger" | "success" | "warning" | "info";
1163
1298
  max: number;
1164
1299
  }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
1165
- /** Spinner primitive — `hl-spinner`, announced via `role="status"`. */
1300
+ /** Spinner primitive: `hl-spinner`, announced via `role="status"`. */
1166
1301
  declare const Spinner: vue.DefineComponent<vue.ExtractPropTypes<{
1167
1302
  size: {
1168
1303
  type: PropType<"sm" | "md" | "lg" | "xl">;
@@ -1187,7 +1322,7 @@ declare const Spinner: vue.DefineComponent<vue.ExtractPropTypes<{
1187
1322
  label: string;
1188
1323
  size: "sm" | "md" | "lg" | "xl";
1189
1324
  }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
1190
- /** Skeleton placeholder primitive — `hl-skeleton`. */
1325
+ /** Skeleton placeholder primitive: `hl-skeleton`. */
1191
1326
  declare const Skeleton: vue.DefineComponent<vue.ExtractPropTypes<{
1192
1327
  variant: {
1193
1328
  type: PropType<"rect" | "text" | "circle">;
@@ -1226,7 +1361,7 @@ declare const ToastRegion: vue.DefineComponent<{}, () => vue.VNode<vue.RendererN
1226
1361
  [key: string]: any;
1227
1362
  }>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
1228
1363
 
1229
- /** Card container — `hl-card`. Compose with the Card* parts. */
1364
+ /** Card container: `hl-card`. Compose with the Card* parts. */
1230
1365
  declare const Card: vue.DefineComponent<vue.ExtractPropTypes<{
1231
1366
  interactive: {
1232
1367
  type: BooleanConstructor;
@@ -1242,22 +1377,27 @@ declare const Card: vue.DefineComponent<vue.ExtractPropTypes<{
1242
1377
  }>> & Readonly<{}>, {
1243
1378
  interactive: boolean;
1244
1379
  }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
1380
+ /** Header region of a {@link Card}. */
1245
1381
  declare const CardHeader: vue.DefineComponent<{}, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
1246
1382
  [key: string]: any;
1247
1383
  }>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
1384
+ /** Body region of a {@link Card}. */
1248
1385
  declare const CardBody: vue.DefineComponent<{}, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
1249
1386
  [key: string]: any;
1250
1387
  }>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
1388
+ /** Footer region of a {@link Card}. */
1251
1389
  declare const CardFooter: vue.DefineComponent<{}, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
1252
1390
  [key: string]: any;
1253
1391
  }>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
1392
+ /** Title heading of a {@link Card}. */
1254
1393
  declare const CardTitle: vue.DefineComponent<{}, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
1255
1394
  [key: string]: any;
1256
1395
  }>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
1396
+ /** Descriptive text of a {@link Card}. */
1257
1397
  declare const CardDescription: vue.DefineComponent<{}, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
1258
1398
  [key: string]: any;
1259
1399
  }>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
1260
- /** Avatar primitive — `hl-avatar` with image + graceful fallback. */
1400
+ /** Avatar primitive: `hl-avatar` with image + graceful fallback. */
1261
1401
  declare const Avatar: vue.DefineComponent<vue.ExtractPropTypes<{
1262
1402
  src: {
1263
1403
  type: StringConstructor;
@@ -1304,11 +1444,11 @@ declare const Avatar: vue.DefineComponent<vue.ExtractPropTypes<{
1304
1444
  declare const AvatarGroup: vue.DefineComponent<{}, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
1305
1445
  [key: string]: any;
1306
1446
  }>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
1307
- /** Keyboard key primitive — `<kbd class="hl-kbd">`. */
1447
+ /** Keyboard key primitive: `<kbd class="hl-kbd">`. */
1308
1448
  declare const Kbd: vue.DefineComponent<{}, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
1309
1449
  [key: string]: any;
1310
1450
  }>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
1311
- /** Separator primitive — `<hr class="hl-separator">`. */
1451
+ /** Separator primitive: `<hr class="hl-separator">`. */
1312
1452
  declare const Separator: vue.DefineComponent<vue.ExtractPropTypes<{
1313
1453
  orientation: {
1314
1454
  type: PropType<"horizontal" | "vertical">;
@@ -1334,7 +1474,7 @@ declare const Separator: vue.DefineComponent<vue.ExtractPropTypes<{
1334
1474
  decorative: boolean;
1335
1475
  }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
1336
1476
 
1337
- /** Pagination primitive — `hl-pagination` with smart ellipsis truncation. Emits `update:page`. */
1477
+ /** Pagination primitive: `hl-pagination` with smart ellipsis truncation. Emits `update:page`. */
1338
1478
  declare const Pagination: vue.DefineComponent<vue.ExtractPropTypes<{
1339
1479
  page: {
1340
1480
  type: NumberConstructor;
package/dist/index.js CHANGED
@@ -1,20 +1,31 @@
1
1
  // src/useEnhancer.ts
2
- import { onMounted, onUnmounted, shallowRef } from "vue";
3
- function useEnhancer(target, enhance) {
2
+ import {
3
+ onBeforeUnmount,
4
+ onMounted,
5
+ ref,
6
+ shallowRef,
7
+ watch
8
+ } from "vue";
9
+ function useEnhancer(enhance, source) {
10
+ const host = ref(null);
4
11
  const api = shallowRef(null);
5
12
  let destroy = null;
6
- onMounted(() => {
7
- if (!target.value) return;
8
- const handle = enhance(target.value);
9
- api.value = handle.api;
10
- destroy = handle.destroy;
11
- });
12
- onUnmounted(() => {
13
+ const detach = () => {
13
14
  destroy?.();
14
15
  destroy = null;
15
16
  api.value = null;
16
- });
17
- return api;
17
+ };
18
+ const attach = () => {
19
+ detach();
20
+ if (!host.value) return;
21
+ const handle = enhance(host.value);
22
+ api.value = handle.api;
23
+ destroy = handle.destroy;
24
+ };
25
+ onMounted(attach);
26
+ if (source) watch(source, attach);
27
+ onBeforeUnmount(detach);
28
+ return { host, api };
18
29
  }
19
30
 
20
31
  // src/useToast.ts
@@ -96,31 +107,16 @@ var HydratelessPlugin = {
96
107
  };
97
108
 
98
109
  // src/components/disclosure.ts
99
- import { defineComponent, h, onMounted as onMounted3, ref as ref2, watch } from "vue";
100
- import { enhanceAccordion as enhanceAccordion2 } from "@hydrateless/enhancers";
110
+ import { defineComponent, h, onMounted as onMounted2, ref as ref2, watch as watch2 } from "vue";
111
+ import {
112
+ enhanceAccordion as enhanceAccordion2,
113
+ enhanceDisclosure as enhanceDisclosure2
114
+ } from "@hydrateless/enhancers";
101
115
 
102
116
  // src/internal.ts
103
- import { onBeforeUnmount, onMounted as onMounted2, ref, shallowRef as shallowRef2 } from "vue";
104
117
  function cx(...classes) {
105
118
  return classes.filter(Boolean).join(" ");
106
119
  }
107
- function useHostEnhancer(enhance) {
108
- const host = ref(null);
109
- const api = shallowRef2(null);
110
- let destroy = null;
111
- onMounted2(() => {
112
- if (!host.value) return;
113
- const handle = enhance(host.value);
114
- api.value = handle.api;
115
- destroy = handle.destroy;
116
- });
117
- onBeforeUnmount(() => {
118
- destroy?.();
119
- destroy = null;
120
- api.value = null;
121
- });
122
- return { host, api };
123
- }
124
120
 
125
121
  // src/components/disclosure.ts
126
122
  var Accordion = defineComponent({
@@ -135,14 +131,15 @@ var Accordion = defineComponent({
135
131
  },
136
132
  emits: ["update:modelValue"],
137
133
  setup(props, { slots, attrs, emit }) {
138
- const { host, api } = useHostEnhancer(
134
+ const { host, api } = useEnhancer(
139
135
  (el) => enhanceAccordion2(el, {
140
136
  allowMultiple: props.allowMultiple,
141
137
  defaultValue: props.modelValue ?? props.defaultValue,
142
138
  onValueChange: (value) => emit("update:modelValue", value)
143
- })
139
+ }),
140
+ () => props.allowMultiple
144
141
  );
145
- watch(
142
+ watch2(
146
143
  () => props.modelValue,
147
144
  (value) => {
148
145
  if (value != null) api.value?.setValue(value);
@@ -161,7 +158,7 @@ var AccordionItem = defineComponent({
161
158
  },
162
159
  setup(props, { slots, attrs }) {
163
160
  const el = ref2(null);
164
- onMounted3(() => {
161
+ onMounted2(() => {
165
162
  if (el.value && props.defaultOpen) el.value.open = true;
166
163
  });
167
164
  return () => h("details", { ...attrs, "data-hl-value": props.value, ref: el }, [
@@ -174,20 +171,32 @@ var Disclosure = defineComponent({
174
171
  name: "HlDisclosure",
175
172
  inheritAttrs: false,
176
173
  props: {
174
+ /** Controlled open state (`v-model:open`). */
175
+ open: { type: Boolean, default: void 0 },
176
+ /** Open the disclosure initially for uncontrolled usage. */
177
177
  defaultOpen: { type: Boolean, default: false }
178
178
  },
179
- setup(props, { slots, attrs }) {
180
- const el = ref2(null);
181
- onMounted3(() => {
182
- if (el.value && props.defaultOpen) el.value.open = true;
183
- });
179
+ emits: ["update:open"],
180
+ setup(props, { slots, attrs, emit }) {
181
+ const { host, api } = useEnhancer(
182
+ (el) => enhanceDisclosure2(el, {
183
+ defaultOpen: props.open ?? props.defaultOpen,
184
+ onOpenChange: (open) => emit("update:open", open)
185
+ })
186
+ );
187
+ watch2(
188
+ () => props.open,
189
+ (open) => {
190
+ if (open != null) api.value?.setOpen(open);
191
+ }
192
+ );
184
193
  return () => h(
185
194
  "details",
186
195
  {
187
196
  ...attrs,
188
197
  class: cx("hl-disclosure", attrs.class),
189
198
  "data-hl-disclosure": "",
190
- ref: el
199
+ ref: host
191
200
  },
192
201
  [
193
202
  h("summary", slots.summary?.()),
@@ -198,7 +207,7 @@ var Disclosure = defineComponent({
198
207
  });
199
208
 
200
209
  // src/components/tabs.ts
201
- import { defineComponent as defineComponent2, h as h2, watch as watch2 } from "vue";
210
+ import { defineComponent as defineComponent2, h as h2, watch as watch3 } from "vue";
202
211
  import { enhanceTabs as enhanceTabs2 } from "@hydrateless/enhancers";
203
212
  var Tabs = defineComponent2({
204
213
  name: "HlTabs",
@@ -216,15 +225,16 @@ var Tabs = defineComponent2({
216
225
  },
217
226
  emits: ["update:modelValue"],
218
227
  setup(props, { slots, attrs, emit }) {
219
- const { host, api } = useHostEnhancer(
228
+ const { host, api } = useEnhancer(
220
229
  (el) => enhanceTabs2(el, {
221
230
  activation: props.activation,
222
231
  orientation: props.orientation,
223
232
  defaultValue: props.modelValue ?? props.defaultValue,
224
233
  onValueChange: (value) => emit("update:modelValue", value)
225
- })
234
+ }),
235
+ () => [props.activation, props.orientation]
226
236
  );
227
- watch2(
237
+ watch3(
228
238
  () => props.modelValue,
229
239
  (value) => {
230
240
  if (value != null) api.value?.setValue(value);
@@ -264,7 +274,7 @@ var TabPanel = defineComponent2({
264
274
  });
265
275
 
266
276
  // src/components/dropdown.ts
267
- import { defineComponent as defineComponent3, h as h3, watch as watch3 } from "vue";
277
+ import { defineComponent as defineComponent3, h as h3, watch as watch4 } from "vue";
268
278
  import {
269
279
  enhanceDropdown as enhanceDropdown2
270
280
  } from "@hydrateless/enhancers";
@@ -283,14 +293,15 @@ var Dropdown = defineComponent3({
283
293
  },
284
294
  emits: ["update:open"],
285
295
  setup(props, { slots, attrs, emit }) {
286
- const { host, api } = useHostEnhancer(
296
+ const { host, api } = useEnhancer(
287
297
  (el) => enhanceDropdown2(el, {
288
298
  placement: props.placement,
289
299
  defaultOpen: props.open ?? props.defaultOpen,
290
300
  onOpenChange: (open) => emit("update:open", open)
291
- })
301
+ }),
302
+ () => props.placement
292
303
  );
293
- watch3(
304
+ watch4(
294
305
  () => props.open,
295
306
  (open) => {
296
307
  if (open != null) api.value?.setOpen(open);
@@ -341,7 +352,7 @@ var DropdownSeparator = defineComponent3({
341
352
  });
342
353
 
343
354
  // src/components/menu.ts
344
- import { defineComponent as defineComponent4, h as h4 } from "vue";
355
+ import { defineComponent as defineComponent4, h as h4, watch as watch5 } from "vue";
345
356
  import { enhanceMenu as enhanceMenu2 } from "@hydrateless/enhancers";
346
357
  var Menu = defineComponent4({
347
358
  name: "HlMenu",
@@ -350,10 +361,26 @@ var Menu = defineComponent4({
350
361
  orientation: {
351
362
  type: String,
352
363
  default: "horizontal"
353
- }
364
+ },
365
+ /** Controlled open submenu value (`v-model:open`), or `null` for none. */
366
+ open: { type: String, default: void 0 }
354
367
  },
355
- setup(props, { slots, attrs }) {
356
- const { host } = useHostEnhancer((el) => enhanceMenu2(el, { orientation: props.orientation }));
368
+ emits: ["update:open", "select"],
369
+ setup(props, { slots, attrs, emit }) {
370
+ const { host, api } = useEnhancer(
371
+ (el) => enhanceMenu2(el, {
372
+ orientation: props.orientation,
373
+ onOpenChange: (value) => emit("update:open", value),
374
+ onSelect: (value) => emit("select", value)
375
+ }),
376
+ () => props.orientation
377
+ );
378
+ watch5(
379
+ () => props.open,
380
+ (open) => {
381
+ if (open !== void 0) api.value?.setOpen(open);
382
+ }
383
+ );
357
384
  return () => h4(
358
385
  "ul",
359
386
  {
@@ -371,15 +398,27 @@ var MenuItem = defineComponent4({
371
398
  name: "HlMenuItem",
372
399
  inheritAttrs: false,
373
400
  props: {
374
- href: { type: String, default: void 0 }
401
+ href: { type: String, default: void 0 },
402
+ /** Stable value identifying this item; defaults to its label text. */
403
+ value: { type: String, default: void 0 }
375
404
  },
376
405
  emits: ["select"],
377
406
  setup(props, { slots, attrs, emit }) {
378
407
  return () => {
379
408
  const hasSubmenu = !!slots.submenu;
380
- const label = props.href && !hasSubmenu ? h4("a", { ...attrs, role: "menuitem", href: props.href }, slots.default?.()) : h4(
409
+ const label = props.href && !hasSubmenu ? h4(
410
+ "a",
411
+ { ...attrs, role: "menuitem", href: props.href, "data-hl-value": props.value },
412
+ slots.default?.()
413
+ ) : h4(
381
414
  "button",
382
- { type: "button", ...attrs, role: "menuitem", onClick: () => emit("select") },
415
+ {
416
+ type: "button",
417
+ ...attrs,
418
+ role: "menuitem",
419
+ "data-hl-value": props.value,
420
+ onClick: () => emit("select")
421
+ },
383
422
  slots.default?.()
384
423
  );
385
424
  const children = [label];
@@ -394,28 +433,27 @@ var MenuItem = defineComponent4({
394
433
  });
395
434
 
396
435
  // src/components/overlay.ts
397
- import { defineComponent as defineComponent5, h as h5, onBeforeUnmount as onBeforeUnmount2, onMounted as onMounted4, ref as ref3, watch as watch4 } from "vue";
436
+ import { defineComponent as defineComponent5, h as h5, onBeforeUnmount as onBeforeUnmount2, onMounted as onMounted3, ref as ref3, watch as watch6 } from "vue";
398
437
  import {
399
- combine,
400
438
  enhanceDrawer as enhanceDrawer2,
401
439
  enhanceModal as enhanceModal2,
402
- enhanceTooltip as enhanceTooltip2,
403
- onClickOutside,
404
- onEscape
440
+ enhancePopover as enhancePopover2,
441
+ enhanceTooltip as enhanceTooltip2
405
442
  } from "@hydrateless/enhancers";
406
443
  function useDialogEnhancer(props, emit, enhance) {
407
- const { host, api } = useHostEnhancer(
444
+ const { host, api } = useEnhancer(
408
445
  (el) => enhance(el, {
409
446
  closeOnBackdrop: props.closeOnBackdrop,
447
+ defaultOpen: props.open ?? props.defaultOpen,
410
448
  onOpenChange: (open) => emit("update:open", open)
411
- })
449
+ }),
450
+ () => props.closeOnBackdrop
412
451
  );
413
- onMounted4(() => {
414
- if (props.open) api.value?.setOpen(true);
415
- });
416
- watch4(
452
+ watch6(
417
453
  () => props.open,
418
- (open) => api.value?.setOpen(open)
454
+ (open) => {
455
+ if (open != null) api.value?.setOpen(open);
456
+ }
419
457
  );
420
458
  return host;
421
459
  }
@@ -423,7 +461,10 @@ var Modal = defineComponent5({
423
461
  name: "HlModal",
424
462
  inheritAttrs: false,
425
463
  props: {
426
- open: { type: Boolean, required: true },
464
+ /** Controlled open state (`v-model:open`). */
465
+ open: { type: Boolean, default: void 0 },
466
+ /** Open the dialog initially for uncontrolled usage. */
467
+ defaultOpen: { type: Boolean, default: false },
427
468
  closeOnBackdrop: { type: Boolean, default: true }
428
469
  },
429
470
  emits: ["update:open"],
@@ -445,7 +486,10 @@ var Drawer = defineComponent5({
445
486
  name: "HlDrawer",
446
487
  inheritAttrs: false,
447
488
  props: {
448
- open: { type: Boolean, required: true },
489
+ /** Controlled open state (`v-model:open`). */
490
+ open: { type: Boolean, default: void 0 },
491
+ /** Open the drawer initially for uncontrolled usage. */
492
+ defaultOpen: { type: Boolean, default: false },
449
493
  side: { type: String, default: "right" },
450
494
  closeOnBackdrop: { type: Boolean, default: true }
451
495
  },
@@ -484,29 +528,28 @@ var Popover = defineComponent5({
484
528
  name: "HlPopover",
485
529
  inheritAttrs: false,
486
530
  props: {
487
- open: { type: Boolean, default: false }
531
+ /** Controlled open state (`v-model:open`). */
532
+ open: { type: Boolean, default: void 0 },
533
+ /** Show the popover initially for uncontrolled usage. */
534
+ defaultOpen: { type: Boolean, default: false }
488
535
  },
489
536
  emits: ["update:open"],
490
537
  setup(props, { slots, attrs, emit }) {
491
- const host = ref3(null);
492
- let dispose = null;
493
- const sync = () => {
494
- dispose?.();
495
- dispose = null;
496
- const el = host.value;
497
- if (!el || !props.open) return;
498
- const dismiss = () => emit("update:open", false);
499
- dispose = combine([onClickOutside(el, dismiss), onEscape(dismiss, el.ownerDocument)]);
500
- };
501
- onMounted4(sync);
502
- watch4(() => props.open, sync);
503
- onBeforeUnmount2(() => {
504
- dispose?.();
505
- dispose = null;
506
- });
538
+ const { host, api } = useEnhancer(
539
+ (el) => enhancePopover2(el, {
540
+ defaultOpen: props.open ?? props.defaultOpen,
541
+ onOpenChange: (open) => emit("update:open", open)
542
+ })
543
+ );
544
+ watch6(
545
+ () => props.open,
546
+ (open) => {
547
+ if (open != null) api.value?.setOpen(open);
548
+ }
549
+ );
507
550
  return () => h5(
508
551
  "div",
509
- { ...attrs, "data-hl-popover": "", role: "dialog", hidden: !props.open, ref: host },
552
+ { ...attrs, "data-hl-popover": "", popover: "auto", role: "dialog", ref: host },
510
553
  slots.default?.()
511
554
  );
512
555
  }
@@ -523,7 +566,7 @@ var Tooltip = defineComponent5({
523
566
  const tipId = props.id ?? `hl-tip-${tipCounter += 1}`;
524
567
  const host = ref3(null);
525
568
  let destroy = null;
526
- onMounted4(() => {
569
+ onMounted3(() => {
527
570
  const trigger = host.value?.querySelector(":scope > :first-child");
528
571
  if (trigger) {
529
572
  trigger.setAttribute("data-hl-tooltip", tipId);
@@ -574,7 +617,7 @@ var BreadcrumbItem = defineComponent6({
574
617
  });
575
618
 
576
619
  // src/components/combobox.ts
577
- import { defineComponent as defineComponent7, h as h7, watch as watch5 } from "vue";
620
+ import { defineComponent as defineComponent7, h as h7, watch as watch7 } from "vue";
578
621
  import {
579
622
  enhanceCombobox as enhanceCombobox2
580
623
  } from "@hydrateless/enhancers";
@@ -594,7 +637,7 @@ var Combobox = defineComponent7({
594
637
  },
595
638
  emits: ["select", "update:modelValue"],
596
639
  setup(props, { slots, attrs, emit }) {
597
- const { host, api } = useHostEnhancer(
640
+ const { host, api } = useEnhancer(
598
641
  (el) => enhanceCombobox2(el, {
599
642
  filter: props.filter,
600
643
  autoHighlight: props.autoHighlight,
@@ -603,9 +646,10 @@ var Combobox = defineComponent7({
603
646
  emit("select", value);
604
647
  emit("update:modelValue", value);
605
648
  }
606
- })
649
+ }),
650
+ () => [props.filter, props.autoHighlight]
607
651
  );
608
- watch5(
652
+ watch7(
609
653
  () => props.modelValue,
610
654
  (value) => {
611
655
  if (value != null) api.value?.setValue(value);
@@ -655,13 +699,15 @@ var Command = defineComponent8({
655
699
  props: {
656
700
  hotkey: { type: String, default: void 0 }
657
701
  },
658
- emits: ["select"],
702
+ emits: ["select", "update:query"],
659
703
  setup(props, { slots, attrs, emit }) {
660
- const { host } = useHostEnhancer(
704
+ const { host } = useEnhancer(
661
705
  (el) => enhanceCommand2(el, {
662
706
  hotkey: props.hotkey,
707
+ onValueChange: (value) => emit("update:query", value),
663
708
  onCommand: (value) => emit("select", value)
664
- })
709
+ }),
710
+ () => props.hotkey
665
711
  );
666
712
  return () => h8(
667
713
  "div",
@@ -745,7 +791,8 @@ import {
745
791
  defineComponent as defineComponent9,
746
792
  h as h9,
747
793
  inject,
748
- provide
794
+ provide,
795
+ ref as ref4
749
796
  } from "vue";
750
797
  var FieldKey = /* @__PURE__ */ Symbol("hl-field");
751
798
  var fieldCounter = 0;
@@ -1031,6 +1078,8 @@ var SegmentedControl = defineComponent9({
1031
1078
  inheritAttrs: false,
1032
1079
  props: {
1033
1080
  modelValue: { type: String, default: void 0 },
1081
+ /** Initially selected value for uncontrolled usage. */
1082
+ defaultValue: { type: String, default: void 0 },
1034
1083
  options: {
1035
1084
  type: Array,
1036
1085
  default: () => []
@@ -1041,6 +1090,8 @@ var SegmentedControl = defineComponent9({
1041
1090
  emits: ["update:modelValue"],
1042
1091
  setup(props, { attrs, emit }) {
1043
1092
  const groupName = props.name ?? `hl-seg-${fieldCounter += 1}`;
1093
+ const internal = ref4(props.defaultValue);
1094
+ const current = computed(() => props.modelValue ?? internal.value);
1044
1095
  return () => h9(
1045
1096
  "div",
1046
1097
  {
@@ -1055,9 +1106,12 @@ var SegmentedControl = defineComponent9({
1055
1106
  type: "radio",
1056
1107
  name: groupName,
1057
1108
  value: option.value,
1058
- checked: props.modelValue === option.value,
1109
+ checked: current.value === option.value,
1059
1110
  disabled: option.disabled,
1060
- onChange: () => emit("update:modelValue", option.value)
1111
+ onChange: () => {
1112
+ internal.value = option.value;
1113
+ emit("update:modelValue", option.value);
1114
+ }
1061
1115
  }),
1062
1116
  h9("span", option.label)
1063
1117
  ])
@@ -1227,7 +1281,7 @@ var ToastRegion = defineComponent11({
1227
1281
  });
1228
1282
 
1229
1283
  // src/components/data.ts
1230
- import { defineComponent as defineComponent12, h as h12, ref as ref4 } from "vue";
1284
+ import { defineComponent as defineComponent12, h as h12, ref as ref5 } from "vue";
1231
1285
  var Card = defineComponent12({
1232
1286
  name: "HlCard",
1233
1287
  inheritAttrs: false,
@@ -1270,7 +1324,7 @@ var Avatar = defineComponent12({
1270
1324
  shape: { type: String, default: void 0 }
1271
1325
  },
1272
1326
  setup(props, { slots, attrs }) {
1273
- const failed = ref4(false);
1327
+ const failed = ref5(false);
1274
1328
  return () => h12(
1275
1329
  "span",
1276
1330
  {
@@ -1422,12 +1476,13 @@ var Toc = defineComponent13({
1422
1476
  scrollSpy: { type: Boolean, default: void 0 }
1423
1477
  },
1424
1478
  setup(props, { attrs }) {
1425
- const { host } = useHostEnhancer(
1479
+ const { host } = useEnhancer(
1426
1480
  (el) => enhanceToc2(el.ownerDocument, {
1427
1481
  contentSelector: props.contentSelector,
1428
1482
  headings: props.headings,
1429
1483
  scrollSpy: props.scrollSpy
1430
- })
1484
+ }),
1485
+ () => [props.contentSelector, props.headings, props.scrollSpy]
1431
1486
  );
1432
1487
  return () => h13("nav", { ...attrs, "data-hl-toc": "", ref: host });
1433
1488
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hydrateless/vue",
3
- "version": "0.6.0",
4
- "description": "Vue 3 bindings for Hydrateless — first-class components, directives, composables, and a plugin.",
3
+ "version": "0.8.0",
4
+ "description": "Vue 3 bindings for Hydrateless: first-class components, directives, composables, and a plugin.",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
@@ -28,7 +28,7 @@
28
28
  "test": "vitest run"
29
29
  },
30
30
  "dependencies": {
31
- "@hydrateless/enhancers": "^0.6.0"
31
+ "@hydrateless/enhancers": "^0.8.0"
32
32
  },
33
33
  "peerDependencies": {
34
34
  "vue": ">=3.3"