@hydrateless/vue 0.5.0 → 0.6.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 +33 -2
- package/dist/index.d.ts +178 -47
- package/dist/index.js +219 -132
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -46,6 +46,36 @@ Available directives: `v-hl-accordion`, `v-hl-disclosure`, `v-hl-tabs`,
|
|
|
46
46
|
`v-hl-toc`. You can also import individual directives (e.g. `vHlTabs`) and
|
|
47
47
|
register them locally.
|
|
48
48
|
|
|
49
|
+
## Components
|
|
50
|
+
|
|
51
|
+
Interactive components support `v-model` on their state:
|
|
52
|
+
|
|
53
|
+
```vue
|
|
54
|
+
<script setup lang="ts">
|
|
55
|
+
import { ref } from 'vue';
|
|
56
|
+
import { Tabs, TabList, Tab, TabPanel, Modal, ModalBody } from '@hydrateless/vue';
|
|
57
|
+
|
|
58
|
+
const tab = ref('overview');
|
|
59
|
+
const open = ref(false);
|
|
60
|
+
</script>
|
|
61
|
+
|
|
62
|
+
<template>
|
|
63
|
+
<Tabs v-model="tab">
|
|
64
|
+
<TabList>
|
|
65
|
+
<Tab value="overview">Overview</Tab>
|
|
66
|
+
<Tab value="install">Install</Tab>
|
|
67
|
+
</TabList>
|
|
68
|
+
<TabPanel>Zero runtime by default.</TabPanel>
|
|
69
|
+
<TabPanel><code>npm i hydrateless</code></TabPanel>
|
|
70
|
+
</Tabs>
|
|
71
|
+
|
|
72
|
+
<button @click="open = true">Open</button>
|
|
73
|
+
<Modal v-model:open="open">
|
|
74
|
+
<ModalBody>Body content.</ModalBody>
|
|
75
|
+
</Modal>
|
|
76
|
+
</template>
|
|
77
|
+
```
|
|
78
|
+
|
|
49
79
|
## Composables
|
|
50
80
|
|
|
51
81
|
```vue
|
|
@@ -55,9 +85,10 @@ import { useEnhancer, useToast } from '@hydrateless/vue';
|
|
|
55
85
|
import { enhanceDropdown } from '@hydrateless/enhancers';
|
|
56
86
|
|
|
57
87
|
const menu = ref<HTMLElement | null>(null);
|
|
58
|
-
useEnhancer(menu, enhanceDropdown);
|
|
88
|
+
const dropdown = useEnhancer(menu, enhanceDropdown);
|
|
89
|
+
// dropdown.value?.setOpen(true)
|
|
59
90
|
|
|
60
|
-
const toast = useToast();
|
|
91
|
+
const toast = useToast(); // no provider required
|
|
61
92
|
</script>
|
|
62
93
|
|
|
63
94
|
<template>
|
package/dist/index.d.ts
CHANGED
|
@@ -1,28 +1,27 @@
|
|
|
1
1
|
import * as vue from 'vue';
|
|
2
|
-
import { Ref, Plugin, Directive, PropType } from 'vue';
|
|
3
|
-
import {
|
|
4
|
-
export { Disposer } from '@hydrateless/enhancers';
|
|
2
|
+
import { Ref, ShallowRef, Plugin, Directive, PropType } from 'vue';
|
|
3
|
+
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
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Attach any Hydrateless enhancer to a template ref for the lifetime of a
|
|
8
|
-
* component.
|
|
8
|
+
* component. Returns a shallow ref to the enhancer's imperative API; the
|
|
9
|
+
* instance is destroyed automatically on unmount.
|
|
9
10
|
*
|
|
10
11
|
* ```ts
|
|
11
12
|
* const el = ref<HTMLElement | null>(null);
|
|
12
|
-
* useEnhancer(el, enhanceTabs);
|
|
13
|
+
* const tabs = useEnhancer(el, enhanceTabs);
|
|
14
|
+
* tabs.value?.setValue('install');
|
|
13
15
|
* ```
|
|
14
16
|
*/
|
|
15
|
-
declare function useEnhancer(target: Ref<HTMLElement | null | undefined>, enhance: (container: HTMLElement) =>
|
|
17
|
+
declare function useEnhancer<Api = null>(target: Ref<HTMLElement | null | undefined>, enhance: (container: HTMLElement) => EnhancerHandle<Api>): ShallowRef<Api | null>;
|
|
16
18
|
|
|
17
|
-
interface UseToastReturn {
|
|
18
|
-
show: (message: string, options?: ToastOptions) => HTMLElement;
|
|
19
|
-
dismiss: (toast: HTMLElement) => void;
|
|
20
|
-
}
|
|
21
19
|
/**
|
|
22
|
-
*
|
|
23
|
-
*
|
|
20
|
+
* Imperative toast API backed by a lazily-created document-level region (or a
|
|
21
|
+
* `[data-hl-toast-region]` you render yourself, e.g. via `<ToastRegion>`).
|
|
22
|
+
* Safe to call from any component — no provider required.
|
|
24
23
|
*/
|
|
25
|
-
declare function useToast():
|
|
24
|
+
declare function useToast(options?: EnhanceToastOptions): ToastApi;
|
|
26
25
|
|
|
27
26
|
/**
|
|
28
27
|
* Registers every Hydrateless directive globally:
|
|
@@ -52,26 +51,57 @@ declare const vHlCommand: Directive<HTMLElement>;
|
|
|
52
51
|
declare const directives: Record<string, Directive<HTMLElement>>;
|
|
53
52
|
|
|
54
53
|
/**
|
|
55
|
-
* Accordion root. Compose with `<AccordionItem>`.
|
|
56
|
-
*
|
|
54
|
+
* Accordion root of native `<details>` items. Compose with `<AccordionItem>`.
|
|
55
|
+
* Item values come from each `<AccordionItem value>`, defaulting to the index;
|
|
56
|
+
* open state works uncontrolled (`defaultValue` or `defaultOpen` on items) or
|
|
57
|
+
* with `v-model`.
|
|
57
58
|
*/
|
|
58
59
|
declare const Accordion: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
59
60
|
allowMultiple: {
|
|
60
61
|
type: BooleanConstructor;
|
|
61
62
|
default: boolean;
|
|
62
63
|
};
|
|
64
|
+
/** Controlled list of open item values (`v-model`). */
|
|
65
|
+
modelValue: {
|
|
66
|
+
type: PropType<string[]>;
|
|
67
|
+
default: undefined;
|
|
68
|
+
};
|
|
69
|
+
/** Initially open item values for uncontrolled usage. */
|
|
70
|
+
defaultValue: {
|
|
71
|
+
type: PropType<string[]>;
|
|
72
|
+
default: undefined;
|
|
73
|
+
};
|
|
63
74
|
}>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
64
75
|
[key: string]: any;
|
|
65
|
-
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin,
|
|
76
|
+
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, "update:modelValue"[], "update:modelValue", vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
66
77
|
allowMultiple: {
|
|
67
78
|
type: BooleanConstructor;
|
|
68
79
|
default: boolean;
|
|
69
80
|
};
|
|
70
|
-
|
|
81
|
+
/** Controlled list of open item values (`v-model`). */
|
|
82
|
+
modelValue: {
|
|
83
|
+
type: PropType<string[]>;
|
|
84
|
+
default: undefined;
|
|
85
|
+
};
|
|
86
|
+
/** Initially open item values for uncontrolled usage. */
|
|
87
|
+
defaultValue: {
|
|
88
|
+
type: PropType<string[]>;
|
|
89
|
+
default: undefined;
|
|
90
|
+
};
|
|
91
|
+
}>> & Readonly<{
|
|
92
|
+
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
93
|
+
}>, {
|
|
71
94
|
allowMultiple: boolean;
|
|
95
|
+
modelValue: string[];
|
|
96
|
+
defaultValue: string[];
|
|
72
97
|
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
73
98
|
/** A `<details>`-based accordion section. Use the `summary` slot for the trigger. */
|
|
74
99
|
declare const AccordionItem: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
100
|
+
/** Stable value identifying this item; defaults to its index. */
|
|
101
|
+
value: {
|
|
102
|
+
type: StringConstructor;
|
|
103
|
+
default: undefined;
|
|
104
|
+
};
|
|
75
105
|
defaultOpen: {
|
|
76
106
|
type: BooleanConstructor;
|
|
77
107
|
default: boolean;
|
|
@@ -79,11 +109,17 @@ declare const AccordionItem: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
79
109
|
}>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
80
110
|
[key: string]: any;
|
|
81
111
|
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
112
|
+
/** Stable value identifying this item; defaults to its index. */
|
|
113
|
+
value: {
|
|
114
|
+
type: StringConstructor;
|
|
115
|
+
default: undefined;
|
|
116
|
+
};
|
|
82
117
|
defaultOpen: {
|
|
83
118
|
type: BooleanConstructor;
|
|
84
119
|
default: boolean;
|
|
85
120
|
};
|
|
86
121
|
}>> & Readonly<{}>, {
|
|
122
|
+
value: string;
|
|
87
123
|
defaultOpen: boolean;
|
|
88
124
|
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
89
125
|
/**
|
|
@@ -108,12 +144,14 @@ declare const Disclosure: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
108
144
|
|
|
109
145
|
/**
|
|
110
146
|
* Tabbed interface root. Compose with `<TabList>`, `<Tab>`, and `<TabPanel>`.
|
|
147
|
+
* Tab values come from each `<Tab value>`, defaulting to the index; selection
|
|
148
|
+
* works uncontrolled (`defaultValue`) or with `v-model`.
|
|
111
149
|
*
|
|
112
150
|
* ```vue
|
|
113
|
-
* <Tabs>
|
|
151
|
+
* <Tabs v-model="tab">
|
|
114
152
|
* <TabList>
|
|
115
|
-
* <Tab>Overview</Tab>
|
|
116
|
-
* <Tab>Install</Tab>
|
|
153
|
+
* <Tab value="overview">Overview</Tab>
|
|
154
|
+
* <Tab value="install">Install</Tab>
|
|
117
155
|
* </TabList>
|
|
118
156
|
* <TabPanel>Zero runtime by default.</TabPanel>
|
|
119
157
|
* <TabPanel>npm install hydrateless</TabPanel>
|
|
@@ -129,9 +167,19 @@ declare const Tabs: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
129
167
|
type: PropType<EnhanceTabsOptions["orientation"]>;
|
|
130
168
|
default: undefined;
|
|
131
169
|
};
|
|
170
|
+
/** Controlled value of the selected tab (`v-model`). */
|
|
171
|
+
modelValue: {
|
|
172
|
+
type: StringConstructor;
|
|
173
|
+
default: undefined;
|
|
174
|
+
};
|
|
175
|
+
/** Initial value for uncontrolled usage. */
|
|
176
|
+
defaultValue: {
|
|
177
|
+
type: StringConstructor;
|
|
178
|
+
default: undefined;
|
|
179
|
+
};
|
|
132
180
|
}>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
133
181
|
[key: string]: any;
|
|
134
|
-
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin,
|
|
182
|
+
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, "update:modelValue"[], "update:modelValue", vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
135
183
|
activation: {
|
|
136
184
|
type: PropType<EnhanceTabsOptions["activation"]>;
|
|
137
185
|
default: undefined;
|
|
@@ -140,7 +188,21 @@ declare const Tabs: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
140
188
|
type: PropType<EnhanceTabsOptions["orientation"]>;
|
|
141
189
|
default: undefined;
|
|
142
190
|
};
|
|
143
|
-
|
|
191
|
+
/** Controlled value of the selected tab (`v-model`). */
|
|
192
|
+
modelValue: {
|
|
193
|
+
type: StringConstructor;
|
|
194
|
+
default: undefined;
|
|
195
|
+
};
|
|
196
|
+
/** Initial value for uncontrolled usage. */
|
|
197
|
+
defaultValue: {
|
|
198
|
+
type: StringConstructor;
|
|
199
|
+
default: undefined;
|
|
200
|
+
};
|
|
201
|
+
}>> & Readonly<{
|
|
202
|
+
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
203
|
+
}>, {
|
|
204
|
+
modelValue: string;
|
|
205
|
+
defaultValue: string;
|
|
144
206
|
activation: "manual" | "automatic" | undefined;
|
|
145
207
|
orientation: "horizontal" | "vertical" | undefined;
|
|
146
208
|
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
@@ -149,9 +211,23 @@ declare const TabList: vue.DefineComponent<{}, () => vue.VNode<vue.RendererNode,
|
|
|
149
211
|
[key: string]: any;
|
|
150
212
|
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
151
213
|
/** A single tab trigger (`role="tab"`). */
|
|
152
|
-
declare const Tab: vue.DefineComponent<
|
|
214
|
+
declare const Tab: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
215
|
+
/** Stable value identifying this tab; defaults to its index. */
|
|
216
|
+
value: {
|
|
217
|
+
type: StringConstructor;
|
|
218
|
+
default: undefined;
|
|
219
|
+
};
|
|
220
|
+
}>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
153
221
|
[key: string]: any;
|
|
154
|
-
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<
|
|
222
|
+
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
223
|
+
/** Stable value identifying this tab; defaults to its index. */
|
|
224
|
+
value: {
|
|
225
|
+
type: StringConstructor;
|
|
226
|
+
default: undefined;
|
|
227
|
+
};
|
|
228
|
+
}>> & Readonly<{}>, {
|
|
229
|
+
value: string;
|
|
230
|
+
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
155
231
|
/** Content for the matching tab (`role="tabpanel"`). */
|
|
156
232
|
declare const TabPanel: vue.DefineComponent<{}, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
157
233
|
[key: string]: any;
|
|
@@ -160,22 +236,47 @@ declare const TabPanel: vue.DefineComponent<{}, () => vue.VNode<vue.RendererNode
|
|
|
160
236
|
/**
|
|
161
237
|
* Button-triggered menu (WAI-ARIA menu-button pattern). Compose with
|
|
162
238
|
* `<DropdownTrigger>`, `<DropdownMenu>`, `<DropdownItem>`, and
|
|
163
|
-
* `<DropdownSeparator>`.
|
|
239
|
+
* `<DropdownSeparator>`. Open state works uncontrolled or with
|
|
240
|
+
* `v-model:open`.
|
|
164
241
|
*/
|
|
165
242
|
declare const Dropdown: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
166
243
|
placement: {
|
|
167
244
|
type: PropType<EnhanceDropdownOptions["placement"]>;
|
|
168
245
|
default: undefined;
|
|
169
246
|
};
|
|
247
|
+
/** Controlled open state (`v-model:open`). */
|
|
248
|
+
open: {
|
|
249
|
+
type: PropType<boolean | undefined>;
|
|
250
|
+
default: undefined;
|
|
251
|
+
};
|
|
252
|
+
/** Open the menu initially for uncontrolled usage. */
|
|
253
|
+
defaultOpen: {
|
|
254
|
+
type: BooleanConstructor;
|
|
255
|
+
default: boolean;
|
|
256
|
+
};
|
|
170
257
|
}>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
171
258
|
[key: string]: any;
|
|
172
|
-
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin,
|
|
259
|
+
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, "update:open"[], "update:open", vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
173
260
|
placement: {
|
|
174
261
|
type: PropType<EnhanceDropdownOptions["placement"]>;
|
|
175
262
|
default: undefined;
|
|
176
263
|
};
|
|
177
|
-
|
|
264
|
+
/** Controlled open state (`v-model:open`). */
|
|
265
|
+
open: {
|
|
266
|
+
type: PropType<boolean | undefined>;
|
|
267
|
+
default: undefined;
|
|
268
|
+
};
|
|
269
|
+
/** Open the menu initially for uncontrolled usage. */
|
|
270
|
+
defaultOpen: {
|
|
271
|
+
type: BooleanConstructor;
|
|
272
|
+
default: boolean;
|
|
273
|
+
};
|
|
274
|
+
}>> & Readonly<{
|
|
275
|
+
"onUpdate:open"?: ((...args: any[]) => any) | undefined;
|
|
276
|
+
}>, {
|
|
277
|
+
defaultOpen: boolean;
|
|
178
278
|
placement: "bottom" | "top" | undefined;
|
|
279
|
+
open: boolean | undefined;
|
|
179
280
|
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
180
281
|
/** The button that opens the menu. */
|
|
181
282
|
declare const DropdownTrigger: vue.DefineComponent<{}, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
@@ -238,8 +339,9 @@ declare const MenuItem: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
238
339
|
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
239
340
|
|
|
240
341
|
/**
|
|
241
|
-
* Controlled dialog overlay on the native `<dialog
|
|
242
|
-
*
|
|
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>`,
|
|
243
345
|
* `<ModalBody>`, `<ModalFooter>`.
|
|
244
346
|
*/
|
|
245
347
|
declare const Modal: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
@@ -253,7 +355,7 @@ declare const Modal: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
253
355
|
};
|
|
254
356
|
}>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
255
357
|
[key: string]: any;
|
|
256
|
-
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, "
|
|
358
|
+
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, "update:open"[], "update:open", vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
257
359
|
open: {
|
|
258
360
|
type: BooleanConstructor;
|
|
259
361
|
required: true;
|
|
@@ -263,14 +365,14 @@ declare const Modal: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
263
365
|
default: boolean;
|
|
264
366
|
};
|
|
265
367
|
}>> & Readonly<{
|
|
266
|
-
|
|
368
|
+
"onUpdate:open"?: ((...args: any[]) => any) | undefined;
|
|
267
369
|
}>, {
|
|
268
370
|
closeOnBackdrop: boolean;
|
|
269
371
|
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
270
372
|
/**
|
|
271
|
-
* Controlled off-canvas panel on the native `<dialog
|
|
272
|
-
* choose a `side`. Compose with
|
|
273
|
-
* `<DrawerFooter>`.
|
|
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>`.
|
|
274
376
|
*/
|
|
275
377
|
declare const Drawer: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
276
378
|
open: {
|
|
@@ -287,7 +389,7 @@ declare const Drawer: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
287
389
|
};
|
|
288
390
|
}>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
289
391
|
[key: string]: any;
|
|
290
|
-
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, "
|
|
392
|
+
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, "update:open"[], "update:open", vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
291
393
|
open: {
|
|
292
394
|
type: BooleanConstructor;
|
|
293
395
|
required: true;
|
|
@@ -301,7 +403,7 @@ declare const Drawer: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
301
403
|
default: boolean;
|
|
302
404
|
};
|
|
303
405
|
}>> & Readonly<{
|
|
304
|
-
|
|
406
|
+
"onUpdate:open"?: ((...args: any[]) => any) | undefined;
|
|
305
407
|
}>, {
|
|
306
408
|
closeOnBackdrop: boolean;
|
|
307
409
|
side: "left" | "right";
|
|
@@ -324,7 +426,11 @@ declare const DrawerBody: vue.DefineComponent<{}, () => vue.VNode<vue.RendererNo
|
|
|
324
426
|
declare const DrawerFooter: vue.DefineComponent<{}, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
325
427
|
[key: string]: any;
|
|
326
428
|
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
327
|
-
/**
|
|
429
|
+
/**
|
|
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.
|
|
433
|
+
*/
|
|
328
434
|
declare const Popover: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
329
435
|
open: {
|
|
330
436
|
type: BooleanConstructor;
|
|
@@ -332,12 +438,14 @@ declare const Popover: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
332
438
|
};
|
|
333
439
|
}>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
334
440
|
[key: string]: any;
|
|
335
|
-
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin,
|
|
441
|
+
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, "update:open"[], "update:open", vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
336
442
|
open: {
|
|
337
443
|
type: BooleanConstructor;
|
|
338
444
|
default: boolean;
|
|
339
445
|
};
|
|
340
|
-
}>> & Readonly<{
|
|
446
|
+
}>> & Readonly<{
|
|
447
|
+
"onUpdate:open"?: ((...args: any[]) => any) | undefined;
|
|
448
|
+
}>, {
|
|
341
449
|
open: boolean;
|
|
342
450
|
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
343
451
|
/**
|
|
@@ -404,8 +512,9 @@ declare const BreadcrumbItem: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
404
512
|
|
|
405
513
|
/**
|
|
406
514
|
* Editable combobox (input + listbox), APG pattern. Compose with
|
|
407
|
-
* `<ComboboxInput>`, `<ComboboxList>`, `<ComboboxOption>`.
|
|
408
|
-
*
|
|
515
|
+
* `<ComboboxInput>`, `<ComboboxList>`, `<ComboboxOption>`. The committed
|
|
516
|
+
* value works uncontrolled (`defaultValue`) or with `v-model`; selection also
|
|
517
|
+
* emits `select`.
|
|
409
518
|
*/
|
|
410
519
|
declare const Combobox: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
411
520
|
filter: {
|
|
@@ -416,9 +525,19 @@ declare const Combobox: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
416
525
|
type: PropType<EnhanceComboboxOptions["autoHighlight"]>;
|
|
417
526
|
default: undefined;
|
|
418
527
|
};
|
|
528
|
+
/** Controlled committed value (`v-model`). */
|
|
529
|
+
modelValue: {
|
|
530
|
+
type: StringConstructor;
|
|
531
|
+
default: undefined;
|
|
532
|
+
};
|
|
533
|
+
/** Initial committed value for uncontrolled usage. */
|
|
534
|
+
defaultValue: {
|
|
535
|
+
type: StringConstructor;
|
|
536
|
+
default: undefined;
|
|
537
|
+
};
|
|
419
538
|
}>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
420
539
|
[key: string]: any;
|
|
421
|
-
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, ("
|
|
540
|
+
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, ("update:modelValue" | "select")[], "update:modelValue" | "select", vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
422
541
|
filter: {
|
|
423
542
|
type: PropType<EnhanceComboboxOptions["filter"]>;
|
|
424
543
|
default: undefined;
|
|
@@ -427,10 +546,22 @@ declare const Combobox: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
427
546
|
type: PropType<EnhanceComboboxOptions["autoHighlight"]>;
|
|
428
547
|
default: undefined;
|
|
429
548
|
};
|
|
549
|
+
/** Controlled committed value (`v-model`). */
|
|
550
|
+
modelValue: {
|
|
551
|
+
type: StringConstructor;
|
|
552
|
+
default: undefined;
|
|
553
|
+
};
|
|
554
|
+
/** Initial committed value for uncontrolled usage. */
|
|
555
|
+
defaultValue: {
|
|
556
|
+
type: StringConstructor;
|
|
557
|
+
default: undefined;
|
|
558
|
+
};
|
|
430
559
|
}>> & Readonly<{
|
|
560
|
+
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
431
561
|
onSelect?: ((...args: any[]) => any) | undefined;
|
|
432
|
-
"onUpdate:value"?: ((...args: any[]) => any) | undefined;
|
|
433
562
|
}>, {
|
|
563
|
+
modelValue: string;
|
|
564
|
+
defaultValue: string;
|
|
434
565
|
filter: boolean | undefined;
|
|
435
566
|
autoHighlight: boolean | undefined;
|
|
436
567
|
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
@@ -637,8 +768,8 @@ declare const Input: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
637
768
|
}>> & Readonly<{
|
|
638
769
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
639
770
|
}>, {
|
|
640
|
-
invalid: boolean;
|
|
641
771
|
modelValue: string | number;
|
|
772
|
+
invalid: boolean;
|
|
642
773
|
size: Size;
|
|
643
774
|
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
644
775
|
/** Multi-line text input. Supports `v-model`. */
|
|
@@ -673,8 +804,8 @@ declare const Textarea: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
673
804
|
}>> & Readonly<{
|
|
674
805
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
675
806
|
}>, {
|
|
676
|
-
invalid: boolean;
|
|
677
807
|
modelValue: string;
|
|
808
|
+
invalid: boolean;
|
|
678
809
|
size: Size;
|
|
679
810
|
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
680
811
|
/** Native `<select>` styled with `hl-select`. Supports `v-model`. */
|
|
@@ -709,8 +840,8 @@ declare const Select: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
709
840
|
}>> & Readonly<{
|
|
710
841
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
711
842
|
}>, {
|
|
712
|
-
invalid: boolean;
|
|
713
843
|
modelValue: string;
|
|
844
|
+
invalid: boolean;
|
|
714
845
|
size: Size;
|
|
715
846
|
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
716
847
|
/** Checkbox built on a native input, label-wrapped. Supports `v-model`. */
|
|
@@ -1303,4 +1434,4 @@ declare const SkipLink: vue.DefineComponent<{}, () => vue.VNode<vue.RendererNode
|
|
|
1303
1434
|
[key: string]: any;
|
|
1304
1435
|
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
1305
1436
|
|
|
1306
|
-
export { Accordion, AccordionItem, Alert, Avatar, AvatarGroup, Badge, Breadcrumb, BreadcrumbItem, Button, Card, CardBody, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, Combobox, ComboboxInput, ComboboxList, ComboboxOption, Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, Disclosure, Drawer, DrawerBody, DrawerFooter, DrawerHeader, Dropdown, DropdownItem, DropdownMenu, DropdownSeparator, DropdownTrigger, Field, FieldError, FieldHelp, FieldLabel, Fieldset, HydratelessPlugin, Input, Kbd, Menu, MenuItem, Modal, ModalBody, ModalFooter, ModalHeader, Pagination, Popover, Progress, Radio, RadioGroup, SegmentedControl, Select, Separator, Skeleton, SkipLink, Slider, Spinner, Switch, Tab, TabList, TabPanel, Tabs, Textarea, ToastRegion, Toc, Tooltip,
|
|
1437
|
+
export { Accordion, AccordionItem, Alert, Avatar, AvatarGroup, Badge, Breadcrumb, BreadcrumbItem, Button, Card, CardBody, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, Combobox, ComboboxInput, ComboboxList, ComboboxOption, Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, Disclosure, Drawer, DrawerBody, DrawerFooter, DrawerHeader, Dropdown, DropdownItem, DropdownMenu, DropdownSeparator, DropdownTrigger, Field, FieldError, FieldHelp, FieldLabel, Fieldset, HydratelessPlugin, Input, Kbd, Menu, MenuItem, Modal, ModalBody, ModalFooter, ModalHeader, Pagination, Popover, Progress, Radio, RadioGroup, SegmentedControl, Select, Separator, Skeleton, SkipLink, Slider, Spinner, Switch, Tab, TabList, TabPanel, Tabs, Textarea, ToastRegion, Toc, Tooltip, directives, useEnhancer, useFieldBindings, useToast, vHlAccordion, vHlCombobox, vHlCommand, vHlDisclosure, vHlDrawer, vHlDropdown, vHlMenu, vHlModal, vHlPopover, vHlTabs, vHlToc, vHlTooltip };
|
package/dist/index.js
CHANGED
|
@@ -1,31 +1,34 @@
|
|
|
1
1
|
// src/useEnhancer.ts
|
|
2
|
-
import { onMounted, onUnmounted } from "vue";
|
|
2
|
+
import { onMounted, onUnmounted, shallowRef } from "vue";
|
|
3
3
|
function useEnhancer(target, enhance) {
|
|
4
|
-
|
|
4
|
+
const api = shallowRef(null);
|
|
5
|
+
let destroy = null;
|
|
5
6
|
onMounted(() => {
|
|
6
|
-
if (target.value)
|
|
7
|
+
if (!target.value) return;
|
|
8
|
+
const handle = enhance(target.value);
|
|
9
|
+
api.value = handle.api;
|
|
10
|
+
destroy = handle.destroy;
|
|
7
11
|
});
|
|
8
12
|
onUnmounted(() => {
|
|
9
|
-
|
|
10
|
-
|
|
13
|
+
destroy?.();
|
|
14
|
+
destroy = null;
|
|
15
|
+
api.value = null;
|
|
11
16
|
});
|
|
17
|
+
return api;
|
|
12
18
|
}
|
|
13
19
|
|
|
14
20
|
// src/useToast.ts
|
|
15
|
-
import { onMounted as onMounted2, onUnmounted as onUnmounted2 } from "vue";
|
|
16
21
|
import { enhanceToast } from "@hydrateless/enhancers";
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
onMounted2(() => {
|
|
20
|
-
api = enhanceToast(document);
|
|
21
|
-
});
|
|
22
|
-
onUnmounted2(() => {
|
|
23
|
-
api?.destroy();
|
|
24
|
-
api = null;
|
|
25
|
-
});
|
|
22
|
+
var shared = null;
|
|
23
|
+
function useToast(options) {
|
|
26
24
|
return {
|
|
27
|
-
show
|
|
28
|
-
|
|
25
|
+
show(message, opts) {
|
|
26
|
+
const api = shared ?? (shared = enhanceToast(document, options).api);
|
|
27
|
+
return api.show(message, opts);
|
|
28
|
+
},
|
|
29
|
+
dismiss(toast) {
|
|
30
|
+
shared?.dismiss(toast);
|
|
31
|
+
}
|
|
29
32
|
};
|
|
30
33
|
}
|
|
31
34
|
|
|
@@ -48,7 +51,7 @@ function directiveFor(enhance) {
|
|
|
48
51
|
const disposers = /* @__PURE__ */ new WeakMap();
|
|
49
52
|
return {
|
|
50
53
|
mounted(el) {
|
|
51
|
-
disposers.set(el, enhance(el));
|
|
54
|
+
disposers.set(el, enhance(el).destroy);
|
|
52
55
|
},
|
|
53
56
|
unmounted(el) {
|
|
54
57
|
disposers.get(el)?.();
|
|
@@ -93,25 +96,30 @@ var HydratelessPlugin = {
|
|
|
93
96
|
};
|
|
94
97
|
|
|
95
98
|
// src/components/disclosure.ts
|
|
96
|
-
import { defineComponent, h, onMounted as
|
|
99
|
+
import { defineComponent, h, onMounted as onMounted3, ref as ref2, watch } from "vue";
|
|
97
100
|
import { enhanceAccordion as enhanceAccordion2 } from "@hydrateless/enhancers";
|
|
98
101
|
|
|
99
102
|
// src/internal.ts
|
|
100
|
-
import { onBeforeUnmount, onMounted as
|
|
103
|
+
import { onBeforeUnmount, onMounted as onMounted2, ref, shallowRef as shallowRef2 } from "vue";
|
|
101
104
|
function cx(...classes) {
|
|
102
105
|
return classes.filter(Boolean).join(" ");
|
|
103
106
|
}
|
|
104
107
|
function useHostEnhancer(enhance) {
|
|
105
108
|
const host = ref(null);
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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;
|
|
109
116
|
});
|
|
110
117
|
onBeforeUnmount(() => {
|
|
111
|
-
|
|
112
|
-
|
|
118
|
+
destroy?.();
|
|
119
|
+
destroy = null;
|
|
120
|
+
api.value = null;
|
|
113
121
|
});
|
|
114
|
-
return host;
|
|
122
|
+
return { host, api };
|
|
115
123
|
}
|
|
116
124
|
|
|
117
125
|
// src/components/disclosure.ts
|
|
@@ -119,11 +127,26 @@ var Accordion = defineComponent({
|
|
|
119
127
|
name: "HlAccordion",
|
|
120
128
|
inheritAttrs: false,
|
|
121
129
|
props: {
|
|
122
|
-
allowMultiple: { type: Boolean, default: false }
|
|
130
|
+
allowMultiple: { type: Boolean, default: false },
|
|
131
|
+
/** Controlled list of open item values (`v-model`). */
|
|
132
|
+
modelValue: { type: Array, default: void 0 },
|
|
133
|
+
/** Initially open item values for uncontrolled usage. */
|
|
134
|
+
defaultValue: { type: Array, default: void 0 }
|
|
123
135
|
},
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
136
|
+
emits: ["update:modelValue"],
|
|
137
|
+
setup(props, { slots, attrs, emit }) {
|
|
138
|
+
const { host, api } = useHostEnhancer(
|
|
139
|
+
(el) => enhanceAccordion2(el, {
|
|
140
|
+
allowMultiple: props.allowMultiple,
|
|
141
|
+
defaultValue: props.modelValue ?? props.defaultValue,
|
|
142
|
+
onValueChange: (value) => emit("update:modelValue", value)
|
|
143
|
+
})
|
|
144
|
+
);
|
|
145
|
+
watch(
|
|
146
|
+
() => props.modelValue,
|
|
147
|
+
(value) => {
|
|
148
|
+
if (value != null) api.value?.setValue(value);
|
|
149
|
+
}
|
|
127
150
|
);
|
|
128
151
|
return () => h("div", { ...attrs, "data-hl-accordion": "", ref: host }, slots.default?.());
|
|
129
152
|
}
|
|
@@ -132,22 +155,18 @@ var AccordionItem = defineComponent({
|
|
|
132
155
|
name: "HlAccordionItem",
|
|
133
156
|
inheritAttrs: false,
|
|
134
157
|
props: {
|
|
158
|
+
/** Stable value identifying this item; defaults to its index. */
|
|
159
|
+
value: { type: String, default: void 0 },
|
|
135
160
|
defaultOpen: { type: Boolean, default: false }
|
|
136
161
|
},
|
|
137
162
|
setup(props, { slots, attrs }) {
|
|
138
163
|
const el = ref2(null);
|
|
139
|
-
|
|
164
|
+
onMounted3(() => {
|
|
140
165
|
if (el.value && props.defaultOpen) el.value.open = true;
|
|
141
166
|
});
|
|
142
|
-
|
|
143
|
-
() => props.defaultOpen,
|
|
144
|
-
(open) => {
|
|
145
|
-
if (el.value) el.value.open = open;
|
|
146
|
-
}
|
|
147
|
-
);
|
|
148
|
-
return () => h("details", { ...attrs, ref: el }, [
|
|
167
|
+
return () => h("details", { ...attrs, "data-hl-value": props.value, ref: el }, [
|
|
149
168
|
h("summary", slots.summary?.()),
|
|
150
|
-
h("div", { class: "accordion-panel" }, slots.default?.())
|
|
169
|
+
h("div", { class: "hl-accordion-panel" }, slots.default?.())
|
|
151
170
|
]);
|
|
152
171
|
}
|
|
153
172
|
});
|
|
@@ -159,22 +178,27 @@ var Disclosure = defineComponent({
|
|
|
159
178
|
},
|
|
160
179
|
setup(props, { slots, attrs }) {
|
|
161
180
|
const el = ref2(null);
|
|
162
|
-
|
|
181
|
+
onMounted3(() => {
|
|
163
182
|
if (el.value && props.defaultOpen) el.value.open = true;
|
|
164
183
|
});
|
|
165
184
|
return () => h(
|
|
166
185
|
"details",
|
|
167
|
-
{
|
|
186
|
+
{
|
|
187
|
+
...attrs,
|
|
188
|
+
class: cx("hl-disclosure", attrs.class),
|
|
189
|
+
"data-hl-disclosure": "",
|
|
190
|
+
ref: el
|
|
191
|
+
},
|
|
168
192
|
[
|
|
169
193
|
h("summary", slots.summary?.()),
|
|
170
|
-
h("div", { class: "disclosure-panel" }, slots.default?.())
|
|
194
|
+
h("div", { class: "hl-disclosure-panel" }, slots.default?.())
|
|
171
195
|
]
|
|
172
196
|
);
|
|
173
197
|
}
|
|
174
198
|
});
|
|
175
199
|
|
|
176
200
|
// src/components/tabs.ts
|
|
177
|
-
import { defineComponent as defineComponent2, h as h2 } from "vue";
|
|
201
|
+
import { defineComponent as defineComponent2, h as h2, watch as watch2 } from "vue";
|
|
178
202
|
import { enhanceTabs as enhanceTabs2 } from "@hydrateless/enhancers";
|
|
179
203
|
var Tabs = defineComponent2({
|
|
180
204
|
name: "HlTabs",
|
|
@@ -184,11 +208,27 @@ var Tabs = defineComponent2({
|
|
|
184
208
|
orientation: {
|
|
185
209
|
type: String,
|
|
186
210
|
default: void 0
|
|
187
|
-
}
|
|
211
|
+
},
|
|
212
|
+
/** Controlled value of the selected tab (`v-model`). */
|
|
213
|
+
modelValue: { type: String, default: void 0 },
|
|
214
|
+
/** Initial value for uncontrolled usage. */
|
|
215
|
+
defaultValue: { type: String, default: void 0 }
|
|
188
216
|
},
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
217
|
+
emits: ["update:modelValue"],
|
|
218
|
+
setup(props, { slots, attrs, emit }) {
|
|
219
|
+
const { host, api } = useHostEnhancer(
|
|
220
|
+
(el) => enhanceTabs2(el, {
|
|
221
|
+
activation: props.activation,
|
|
222
|
+
orientation: props.orientation,
|
|
223
|
+
defaultValue: props.modelValue ?? props.defaultValue,
|
|
224
|
+
onValueChange: (value) => emit("update:modelValue", value)
|
|
225
|
+
})
|
|
226
|
+
);
|
|
227
|
+
watch2(
|
|
228
|
+
() => props.modelValue,
|
|
229
|
+
(value) => {
|
|
230
|
+
if (value != null) api.value?.setValue(value);
|
|
231
|
+
}
|
|
192
232
|
);
|
|
193
233
|
return () => h2("div", { ...attrs, "data-hl-tabs": "", ref: host }, slots.default?.());
|
|
194
234
|
}
|
|
@@ -203,8 +243,16 @@ var TabList = defineComponent2({
|
|
|
203
243
|
var Tab = defineComponent2({
|
|
204
244
|
name: "HlTab",
|
|
205
245
|
inheritAttrs: false,
|
|
206
|
-
|
|
207
|
-
|
|
246
|
+
props: {
|
|
247
|
+
/** Stable value identifying this tab; defaults to its index. */
|
|
248
|
+
value: { type: String, default: void 0 }
|
|
249
|
+
},
|
|
250
|
+
setup(props, { slots, attrs }) {
|
|
251
|
+
return () => h2(
|
|
252
|
+
"button",
|
|
253
|
+
{ type: "button", ...attrs, role: "tab", "data-hl-value": props.value },
|
|
254
|
+
slots.default?.()
|
|
255
|
+
);
|
|
208
256
|
}
|
|
209
257
|
});
|
|
210
258
|
var TabPanel = defineComponent2({
|
|
@@ -216,8 +264,10 @@ var TabPanel = defineComponent2({
|
|
|
216
264
|
});
|
|
217
265
|
|
|
218
266
|
// src/components/dropdown.ts
|
|
219
|
-
import { defineComponent as defineComponent3, h as h3 } from "vue";
|
|
220
|
-
import {
|
|
267
|
+
import { defineComponent as defineComponent3, h as h3, watch as watch3 } from "vue";
|
|
268
|
+
import {
|
|
269
|
+
enhanceDropdown as enhanceDropdown2
|
|
270
|
+
} from "@hydrateless/enhancers";
|
|
221
271
|
var Dropdown = defineComponent3({
|
|
222
272
|
name: "HlDropdown",
|
|
223
273
|
inheritAttrs: false,
|
|
@@ -225,10 +275,27 @@ var Dropdown = defineComponent3({
|
|
|
225
275
|
placement: {
|
|
226
276
|
type: String,
|
|
227
277
|
default: void 0
|
|
228
|
-
}
|
|
278
|
+
},
|
|
279
|
+
/** Controlled open state (`v-model:open`). */
|
|
280
|
+
open: { type: Boolean, default: void 0 },
|
|
281
|
+
/** Open the menu initially for uncontrolled usage. */
|
|
282
|
+
defaultOpen: { type: Boolean, default: false }
|
|
229
283
|
},
|
|
230
|
-
|
|
231
|
-
|
|
284
|
+
emits: ["update:open"],
|
|
285
|
+
setup(props, { slots, attrs, emit }) {
|
|
286
|
+
const { host, api } = useHostEnhancer(
|
|
287
|
+
(el) => enhanceDropdown2(el, {
|
|
288
|
+
placement: props.placement,
|
|
289
|
+
defaultOpen: props.open ?? props.defaultOpen,
|
|
290
|
+
onOpenChange: (open) => emit("update:open", open)
|
|
291
|
+
})
|
|
292
|
+
);
|
|
293
|
+
watch3(
|
|
294
|
+
() => props.open,
|
|
295
|
+
(open) => {
|
|
296
|
+
if (open != null) api.value?.setOpen(open);
|
|
297
|
+
}
|
|
298
|
+
);
|
|
232
299
|
return () => h3("div", { ...attrs, "data-hl-dropdown": "", ref: host }, slots.default?.());
|
|
233
300
|
}
|
|
234
301
|
});
|
|
@@ -286,7 +353,7 @@ var Menu = defineComponent4({
|
|
|
286
353
|
}
|
|
287
354
|
},
|
|
288
355
|
setup(props, { slots, attrs }) {
|
|
289
|
-
const host = useHostEnhancer((el) => enhanceMenu2(el, { orientation: props.orientation }));
|
|
356
|
+
const { host } = useHostEnhancer((el) => enhanceMenu2(el, { orientation: props.orientation }));
|
|
290
357
|
return () => h4(
|
|
291
358
|
"ul",
|
|
292
359
|
{
|
|
@@ -327,22 +394,30 @@ var MenuItem = defineComponent4({
|
|
|
327
394
|
});
|
|
328
395
|
|
|
329
396
|
// src/components/overlay.ts
|
|
330
|
-
import { defineComponent as defineComponent5, h as h5, onBeforeUnmount as onBeforeUnmount2, onMounted as
|
|
331
|
-
import {
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
el
|
|
342
|
-
|
|
397
|
+
import { defineComponent as defineComponent5, h as h5, onBeforeUnmount as onBeforeUnmount2, onMounted as onMounted4, ref as ref3, watch as watch4 } from "vue";
|
|
398
|
+
import {
|
|
399
|
+
combine,
|
|
400
|
+
enhanceDrawer as enhanceDrawer2,
|
|
401
|
+
enhanceModal as enhanceModal2,
|
|
402
|
+
enhanceTooltip as enhanceTooltip2,
|
|
403
|
+
onClickOutside,
|
|
404
|
+
onEscape
|
|
405
|
+
} from "@hydrateless/enhancers";
|
|
406
|
+
function useDialogEnhancer(props, emit, enhance) {
|
|
407
|
+
const { host, api } = useHostEnhancer(
|
|
408
|
+
(el) => enhance(el, {
|
|
409
|
+
closeOnBackdrop: props.closeOnBackdrop,
|
|
410
|
+
onOpenChange: (open) => emit("update:open", open)
|
|
411
|
+
})
|
|
412
|
+
);
|
|
413
|
+
onMounted4(() => {
|
|
414
|
+
if (props.open) api.value?.setOpen(true);
|
|
343
415
|
});
|
|
344
|
-
|
|
345
|
-
|
|
416
|
+
watch4(
|
|
417
|
+
() => props.open,
|
|
418
|
+
(open) => api.value?.setOpen(open)
|
|
419
|
+
);
|
|
420
|
+
return host;
|
|
346
421
|
}
|
|
347
422
|
var Modal = defineComponent5({
|
|
348
423
|
name: "HlModal",
|
|
@@ -351,15 +426,17 @@ var Modal = defineComponent5({
|
|
|
351
426
|
open: { type: Boolean, required: true },
|
|
352
427
|
closeOnBackdrop: { type: Boolean, default: true }
|
|
353
428
|
},
|
|
354
|
-
emits: ["
|
|
429
|
+
emits: ["update:open"],
|
|
355
430
|
setup(props, { slots, attrs, emit }) {
|
|
356
|
-
const
|
|
357
|
-
const onClick = (e) => {
|
|
358
|
-
if (props.closeOnBackdrop && e.target === el.value) emit("close");
|
|
359
|
-
};
|
|
431
|
+
const host = useDialogEnhancer(props, emit, enhanceModal2);
|
|
360
432
|
return () => h5(
|
|
361
433
|
"dialog",
|
|
362
|
-
{
|
|
434
|
+
{
|
|
435
|
+
...attrs,
|
|
436
|
+
class: cx("hl-modal", attrs.class),
|
|
437
|
+
"data-hl-modal": "",
|
|
438
|
+
ref: host
|
|
439
|
+
},
|
|
363
440
|
slots.default?.()
|
|
364
441
|
);
|
|
365
442
|
}
|
|
@@ -372,20 +449,17 @@ var Drawer = defineComponent5({
|
|
|
372
449
|
side: { type: String, default: "right" },
|
|
373
450
|
closeOnBackdrop: { type: Boolean, default: true }
|
|
374
451
|
},
|
|
375
|
-
emits: ["
|
|
452
|
+
emits: ["update:open"],
|
|
376
453
|
setup(props, { slots, attrs, emit }) {
|
|
377
|
-
const
|
|
378
|
-
const onClick = (e) => {
|
|
379
|
-
if (props.closeOnBackdrop && e.target === el.value) emit("close");
|
|
380
|
-
};
|
|
454
|
+
const host = useDialogEnhancer(props, emit, enhanceDrawer2);
|
|
381
455
|
return () => h5(
|
|
382
456
|
"dialog",
|
|
383
457
|
{
|
|
384
458
|
...attrs,
|
|
385
|
-
class: cx("
|
|
459
|
+
class: cx("hl-drawer", attrs.class),
|
|
460
|
+
"data-hl-drawer": "",
|
|
386
461
|
"data-side": props.side,
|
|
387
|
-
ref:
|
|
388
|
-
onClick
|
|
462
|
+
ref: host
|
|
389
463
|
},
|
|
390
464
|
slots.default?.()
|
|
391
465
|
);
|
|
@@ -412,10 +486,27 @@ var Popover = defineComponent5({
|
|
|
412
486
|
props: {
|
|
413
487
|
open: { type: Boolean, default: false }
|
|
414
488
|
},
|
|
415
|
-
|
|
489
|
+
emits: ["update:open"],
|
|
490
|
+
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
|
+
});
|
|
416
507
|
return () => h5(
|
|
417
508
|
"div",
|
|
418
|
-
{ ...attrs, "data-hl-popover": "", role: "dialog", hidden: !props.open },
|
|
509
|
+
{ ...attrs, "data-hl-popover": "", role: "dialog", hidden: !props.open, ref: host },
|
|
419
510
|
slots.default?.()
|
|
420
511
|
);
|
|
421
512
|
}
|
|
@@ -431,18 +522,18 @@ var Tooltip = defineComponent5({
|
|
|
431
522
|
setup(props, { slots, attrs }) {
|
|
432
523
|
const tipId = props.id ?? `hl-tip-${tipCounter += 1}`;
|
|
433
524
|
const host = ref3(null);
|
|
434
|
-
let
|
|
435
|
-
|
|
525
|
+
let destroy = null;
|
|
526
|
+
onMounted4(() => {
|
|
436
527
|
const trigger = host.value?.querySelector(":scope > :first-child");
|
|
437
528
|
if (trigger) {
|
|
438
529
|
trigger.setAttribute("data-hl-tooltip", tipId);
|
|
439
530
|
trigger.setAttribute("aria-describedby", tipId);
|
|
440
531
|
}
|
|
441
|
-
if (host.value)
|
|
532
|
+
if (host.value) destroy = enhanceTooltip2(host.value).destroy;
|
|
442
533
|
});
|
|
443
534
|
onBeforeUnmount2(() => {
|
|
444
|
-
|
|
445
|
-
|
|
535
|
+
destroy?.();
|
|
536
|
+
destroy = null;
|
|
446
537
|
});
|
|
447
538
|
return () => h5("span", { ...attrs, ref: host, style: "position:relative;display:inline-block" }, [
|
|
448
539
|
slots.default?.(),
|
|
@@ -483,8 +574,10 @@ var BreadcrumbItem = defineComponent6({
|
|
|
483
574
|
});
|
|
484
575
|
|
|
485
576
|
// src/components/combobox.ts
|
|
486
|
-
import { defineComponent as defineComponent7, h as h7,
|
|
487
|
-
import {
|
|
577
|
+
import { defineComponent as defineComponent7, h as h7, watch as watch5 } from "vue";
|
|
578
|
+
import {
|
|
579
|
+
enhanceCombobox as enhanceCombobox2
|
|
580
|
+
} from "@hydrateless/enhancers";
|
|
488
581
|
var Combobox = defineComponent7({
|
|
489
582
|
name: "HlCombobox",
|
|
490
583
|
inheritAttrs: false,
|
|
@@ -493,30 +586,31 @@ var Combobox = defineComponent7({
|
|
|
493
586
|
autoHighlight: {
|
|
494
587
|
type: Boolean,
|
|
495
588
|
default: void 0
|
|
496
|
-
}
|
|
589
|
+
},
|
|
590
|
+
/** Controlled committed value (`v-model`). */
|
|
591
|
+
modelValue: { type: String, default: void 0 },
|
|
592
|
+
/** Initial committed value for uncontrolled usage. */
|
|
593
|
+
defaultValue: { type: String, default: void 0 }
|
|
497
594
|
},
|
|
498
|
-
emits: ["select", "update:
|
|
595
|
+
emits: ["select", "update:modelValue"],
|
|
499
596
|
setup(props, { slots, attrs, emit }) {
|
|
500
|
-
const host =
|
|
501
|
-
|
|
502
|
-
const onSelect = (e) => {
|
|
503
|
-
const value = e.detail.value;
|
|
504
|
-
emit("select", value);
|
|
505
|
-
emit("update:value", value);
|
|
506
|
-
};
|
|
507
|
-
onMounted6(() => {
|
|
508
|
-
if (!host.value) return;
|
|
509
|
-
dispose = enhanceCombobox2(host.value, {
|
|
597
|
+
const { host, api } = useHostEnhancer(
|
|
598
|
+
(el) => enhanceCombobox2(el, {
|
|
510
599
|
filter: props.filter,
|
|
511
|
-
autoHighlight: props.autoHighlight
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
600
|
+
autoHighlight: props.autoHighlight,
|
|
601
|
+
defaultValue: props.modelValue ?? props.defaultValue,
|
|
602
|
+
onValueChange: (value) => {
|
|
603
|
+
emit("select", value);
|
|
604
|
+
emit("update:modelValue", value);
|
|
605
|
+
}
|
|
606
|
+
})
|
|
607
|
+
);
|
|
608
|
+
watch5(
|
|
609
|
+
() => props.modelValue,
|
|
610
|
+
(value) => {
|
|
611
|
+
if (value != null) api.value?.setValue(value);
|
|
612
|
+
}
|
|
613
|
+
);
|
|
520
614
|
return () => h7("div", { ...attrs, "data-hl-combobox": "", ref: host }, slots.default?.());
|
|
521
615
|
}
|
|
522
616
|
});
|
|
@@ -553,7 +647,7 @@ var ComboboxOption = defineComponent7({
|
|
|
553
647
|
});
|
|
554
648
|
|
|
555
649
|
// src/components/command.ts
|
|
556
|
-
import { defineComponent as defineComponent8, h as h8
|
|
650
|
+
import { defineComponent as defineComponent8, h as h8 } from "vue";
|
|
557
651
|
import { enhanceCommand as enhanceCommand2 } from "@hydrateless/enhancers";
|
|
558
652
|
var Command = defineComponent8({
|
|
559
653
|
name: "HlCommand",
|
|
@@ -563,19 +657,12 @@ var Command = defineComponent8({
|
|
|
563
657
|
},
|
|
564
658
|
emits: ["select"],
|
|
565
659
|
setup(props, { slots, attrs, emit }) {
|
|
566
|
-
const host =
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
host.value.addEventListener("hl:command", onCommand);
|
|
573
|
-
});
|
|
574
|
-
onBeforeUnmount4(() => {
|
|
575
|
-
host.value?.removeEventListener("hl:command", onCommand);
|
|
576
|
-
dispose?.();
|
|
577
|
-
dispose = null;
|
|
578
|
-
});
|
|
660
|
+
const { host } = useHostEnhancer(
|
|
661
|
+
(el) => enhanceCommand2(el, {
|
|
662
|
+
hotkey: props.hotkey,
|
|
663
|
+
onCommand: (value) => emit("select", value)
|
|
664
|
+
})
|
|
665
|
+
);
|
|
579
666
|
return () => h8(
|
|
580
667
|
"div",
|
|
581
668
|
{ ...attrs, "data-hl-command": "", "data-hl-command-hotkey": props.hotkey, ref: host },
|
|
@@ -1140,7 +1227,7 @@ var ToastRegion = defineComponent11({
|
|
|
1140
1227
|
});
|
|
1141
1228
|
|
|
1142
1229
|
// src/components/data.ts
|
|
1143
|
-
import { defineComponent as defineComponent12, h as h12, ref as
|
|
1230
|
+
import { defineComponent as defineComponent12, h as h12, ref as ref4 } from "vue";
|
|
1144
1231
|
var Card = defineComponent12({
|
|
1145
1232
|
name: "HlCard",
|
|
1146
1233
|
inheritAttrs: false,
|
|
@@ -1183,7 +1270,7 @@ var Avatar = defineComponent12({
|
|
|
1183
1270
|
shape: { type: String, default: void 0 }
|
|
1184
1271
|
},
|
|
1185
1272
|
setup(props, { slots, attrs }) {
|
|
1186
|
-
const failed =
|
|
1273
|
+
const failed = ref4(false);
|
|
1187
1274
|
return () => h12(
|
|
1188
1275
|
"span",
|
|
1189
1276
|
{
|
|
@@ -1335,7 +1422,7 @@ var Toc = defineComponent13({
|
|
|
1335
1422
|
scrollSpy: { type: Boolean, default: void 0 }
|
|
1336
1423
|
},
|
|
1337
1424
|
setup(props, { attrs }) {
|
|
1338
|
-
const host = useHostEnhancer(
|
|
1425
|
+
const { host } = useHostEnhancer(
|
|
1339
1426
|
(el) => enhanceToc2(el.ownerDocument, {
|
|
1340
1427
|
contentSelector: props.contentSelector,
|
|
1341
1428
|
headings: props.headings,
|
|
@@ -1351,7 +1438,7 @@ var SkipLink = defineComponent13({
|
|
|
1351
1438
|
setup(_, { slots, attrs }) {
|
|
1352
1439
|
return () => h13(
|
|
1353
1440
|
"a",
|
|
1354
|
-
{ ...attrs, class: cx("
|
|
1441
|
+
{ ...attrs, class: cx("hl-skip-link", attrs.class) },
|
|
1355
1442
|
slots.default?.() ?? "Skip to content"
|
|
1356
1443
|
);
|
|
1357
1444
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hydrateless/vue",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Vue 3 bindings for Hydrateless — first-class components, directives, composables, and a plugin.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"test": "vitest run"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@hydrateless/enhancers": "^0.
|
|
31
|
+
"@hydrateless/enhancers": "^0.6.0"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
34
|
"vue": ">=3.3"
|