@volverjs/ui-vue 0.0.9-beta.2 → 0.0.9-beta.21
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 +3 -3
- package/auto-imports.d.ts +2 -0
- package/dist/components/VvAccordion/VvAccordion.es.js +15 -7
- package/dist/components/VvAccordionGroup/VvAccordionGroup.es.js +15 -7
- package/dist/components/VvAction/VvAction.es.js +17 -8
- package/dist/components/VvAction/VvAction.umd.js +1 -1
- package/dist/components/VvAction/VvAction.vue.d.ts +9 -0
- package/dist/components/VvAction/index.d.ts +4 -0
- package/dist/components/VvAlert/VvAlert.es.js +22 -13
- package/dist/components/VvAlert/VvAlert.umd.js +1 -1
- package/dist/components/VvAlert/VvAlert.vue.d.ts +6 -6
- package/dist/components/VvAlert/index.d.ts +3 -3
- package/dist/components/VvAlertGroup/VvAlertGroup.es.js +22 -13
- package/dist/components/VvAlertGroup/VvAlertGroup.umd.js +1 -1
- package/dist/components/VvAlertGroup/VvAlertGroup.vue.d.ts +6 -6
- package/dist/components/VvAlertGroup/index.d.ts +2 -2
- package/dist/components/VvAvatar/VvAvatar.es.js +15 -7
- package/dist/components/VvAvatarGroup/VvAvatarGroup.es.js +15 -7
- package/dist/components/VvBadge/VvBadge.es.js +15 -7
- package/dist/components/VvBreadcrumb/VvBreadcrumb.es.js +15 -7
- package/dist/components/VvButton/VvButton.es.js +19 -9
- package/dist/components/VvButton/VvButton.umd.js +1 -1
- package/dist/components/VvButton/VvButton.vue.d.ts +9 -0
- package/dist/components/VvButton/index.d.ts +4 -0
- package/dist/components/VvButtonGroup/VvButtonGroup.es.js +15 -7
- package/dist/components/VvCard/VvCard.es.js +15 -7
- package/dist/components/VvCheckbox/VvCheckbox.es.js +99 -21
- package/dist/components/VvCheckbox/VvCheckbox.umd.js +1 -1
- package/dist/components/VvCheckbox/VvCheckbox.vue.d.ts +4 -4
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.es.js +105 -22
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.umd.js +1 -1
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.vue.d.ts +4 -4
- package/dist/components/VvCombobox/VvCombobox.es.js +256 -191
- package/dist/components/VvCombobox/VvCombobox.umd.js +1 -1
- package/dist/components/VvCombobox/VvCombobox.vue.d.ts +329 -101
- package/dist/components/VvCombobox/index.d.ts +123 -37
- package/dist/components/VvDialog/VvDialog.es.js +50 -37
- package/dist/components/VvDialog/VvDialog.umd.js +1 -1
- package/dist/components/VvDropdown/VvDropdown.es.js +32 -18
- package/dist/components/VvDropdown/VvDropdown.umd.js +1 -1
- package/dist/components/VvDropdown/VvDropdown.vue.d.ts +300 -92
- package/dist/components/VvDropdown/VvDropdownAction.vue.d.ts +9 -0
- package/dist/components/VvDropdown/index.d.ts +99 -30
- package/dist/components/VvDropdownAction/VvDropdownAction.es.js +17 -8
- package/dist/components/VvDropdownAction/VvDropdownAction.umd.js +1 -1
- package/dist/components/VvDropdownOptgroup/VvDropdownOptgroup.es.js +15 -7
- package/dist/components/VvDropdownOption/VvDropdownOption.es.js +15 -7
- package/dist/components/VvInputText/VvInputText.es.js +279 -116
- package/dist/components/VvInputText/VvInputText.umd.js +1 -1
- package/dist/components/VvInputText/VvInputText.vue.d.ts +23 -41
- package/dist/components/VvInputText/index.d.ts +15 -33
- package/dist/components/VvNav/VvNav.es.js +18 -9
- package/dist/components/VvNav/VvNav.umd.js +1 -1
- package/dist/components/VvNav/index.d.ts +1 -1
- package/dist/components/VvProgress/VvProgress.es.js +15 -7
- package/dist/components/VvRadio/VvRadio.es.js +99 -21
- package/dist/components/VvRadio/VvRadio.umd.js +1 -1
- package/dist/components/VvRadio/VvRadio.vue.d.ts +4 -4
- package/dist/components/VvRadioGroup/VvRadioGroup.es.js +105 -22
- package/dist/components/VvRadioGroup/VvRadioGroup.umd.js +1 -1
- package/dist/components/VvRadioGroup/VvRadioGroup.vue.d.ts +4 -4
- package/dist/components/VvSelect/VvSelect.es.js +95 -21
- package/dist/components/VvSelect/VvSelect.umd.js +1 -1
- package/dist/components/VvSelect/VvSelect.vue.d.ts +5 -5
- package/dist/components/VvTab/VvTab.es.js +18 -9
- package/dist/components/VvTab/VvTab.umd.js +1 -1
- package/dist/components/VvTextarea/VvTextarea.es.js +103 -26
- package/dist/components/VvTextarea/VvTextarea.umd.js +1 -1
- package/dist/components/VvTextarea/VvTextarea.vue.d.ts +4 -4
- package/dist/components/VvTooltip/VvTooltip.es.js +15 -7
- package/dist/components/common/HintSlot.d.ts +4 -3
- package/dist/components/index.d.ts +5 -0
- package/dist/components/index.es.js +1212 -626
- package/dist/components/index.umd.js +1 -1
- package/dist/composables/alert/useAlert.d.ts +27 -0
- package/dist/composables/index.d.ts +1 -0
- package/dist/composables/index.es.js +81 -0
- package/dist/composables/index.umd.js +1 -0
- package/dist/constants.d.ts +14 -0
- package/dist/directives/index.es.js +15 -7
- package/dist/directives/v-tooltip.es.js +15 -7
- package/dist/icons.es.js +3 -3
- package/dist/icons.umd.js +1 -1
- package/dist/props/index.d.ts +107 -31
- package/dist/resolvers/unplugin.es.js +3 -0
- package/dist/resolvers/unplugin.umd.js +1 -1
- package/dist/stories/AccordionGroup/AccordionGroup.stories.d.ts +2 -2
- package/dist/stories/AccordionGroup/AccordionGroupSlots.stories.d.ts +54 -269
- package/dist/stories/Alert/Alert.settings.d.ts +3 -7
- package/dist/stories/AlertGroup/AlertGroupSlots.stories.d.ts +2 -2
- package/dist/stories/AlertGroup/AlertGroupWithComposable.stories.d.ts +6 -0
- package/dist/stories/Button/Button.settings.d.ts +3 -13
- package/dist/stories/Combobox/Combobox.settings.d.ts +117 -19
- package/dist/stories/InputText/InputText.settings.d.ts +31 -9
- package/dist/stories/InputText/InputText.stories.d.ts +0 -1
- package/dist/stories/InputText/InputTextMask.stories.d.ts +12 -0
- package/dist/stories/Nav/Nav.settings.d.ts +3 -21
- package/package.json +75 -66
- package/src/assets/icons/detailed.json +1 -1
- package/src/assets/icons/normal.json +1 -1
- package/src/assets/icons/simple.json +1 -1
- package/src/components/VvAction/VvAction.vue +2 -1
- package/src/components/VvAlert/VvAlert.vue +5 -1
- package/src/components/VvAlert/index.ts +3 -3
- package/src/components/VvAlertGroup/VvAlertGroup.vue +2 -0
- package/src/components/VvButton/VvButton.vue +1 -0
- package/src/components/VvCheckbox/VvCheckbox.vue +8 -1
- package/src/components/VvCheckboxGroup/VvCheckboxGroup.vue +8 -1
- package/src/components/VvCombobox/VvCombobox.vue +43 -23
- package/src/components/VvCombobox/index.ts +24 -0
- package/src/components/VvDialog/VvDialog.vue +22 -19
- package/src/components/VvDropdown/VvDropdown.vue +24 -18
- package/src/components/VvInputText/VvInputText.vue +177 -55
- package/src/components/VvInputText/index.ts +32 -34
- package/src/components/VvNav/VvNav.vue +1 -1
- package/src/components/VvNav/index.ts +1 -1
- package/src/components/VvRadio/VvRadio.vue +8 -1
- package/src/components/VvRadioGroup/VvRadioGroup.vue +8 -1
- package/src/components/VvSelect/VvSelect.vue +8 -1
- package/src/components/VvTextarea/VvTextarea.vue +16 -6
- package/src/components/common/HintSlot.ts +26 -13
- package/src/components/index.ts +5 -0
- package/src/composables/alert/useAlert.ts +103 -0
- package/src/composables/index.ts +1 -0
- package/src/constants.ts +26 -0
- package/src/props/index.ts +14 -11
- package/src/resolvers/unplugin.ts +3 -0
- package/src/stories/Alert/Alert.settings.ts +3 -1
- package/src/stories/AlertGroup/AlertGroup.test.ts +13 -0
- package/src/stories/AlertGroup/AlertGroupSlots.stories.ts +3 -3
- package/src/stories/AlertGroup/AlertGroupWithComposable.stories.ts +118 -0
- package/src/stories/Button/Button.settings.ts +5 -3
- package/src/stories/Combobox/Combobox.settings.ts +119 -2
- package/src/stories/Combobox/Combobox.test.ts +1 -1
- package/src/stories/InputText/InputText.settings.ts +36 -15
- package/src/stories/InputText/InputText.stories.ts +4 -12
- package/src/stories/InputText/InputText.test.ts +31 -15
- package/src/stories/InputText/InputTextMask.stories.ts +122 -0
- package/src/stories/Nav/Nav.settings.ts +3 -1
- package/src/stories/Tab/Tab.stories.ts +3 -3
- package/src/stories/Textarea/TextareaLength.stories.ts +1 -1
- package/src/types/alert.d.ts +20 -0
- /package/dist/components/{VvNavItemTitle → VvNav}/VvNavItemTitle.vue.d.ts +0 -0
- /package/dist/components/{VvNavSeparator → VvNav}/VvNavSeparator.d.ts +0 -0
- /package/src/components/{VvNavItemTitle → VvNav}/VvNavItemTitle.vue +0 -0
- /package/src/components/{VvNavSeparator → VvNav}/VvNavSeparator.ts +0 -0
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import type { PropType } from 'vue';
|
|
2
|
+
import type { Option } from '../../types/generic';
|
|
2
3
|
export declare const VvComboboxEvents: string[];
|
|
3
4
|
export declare const VvComboboxProps: {
|
|
5
|
+
/**
|
|
6
|
+
* Dropdown show / hide transition name
|
|
7
|
+
*/
|
|
8
|
+
transitionName: {
|
|
9
|
+
type: StringConstructor;
|
|
10
|
+
default: string;
|
|
11
|
+
};
|
|
4
12
|
/**
|
|
5
13
|
* modelValue can be a string, number, boolean, object or array of string, number, boolean, object
|
|
6
14
|
*/
|
|
@@ -50,6 +58,13 @@ export declare const VvComboboxProps: {
|
|
|
50
58
|
type: StringConstructor;
|
|
51
59
|
default: string;
|
|
52
60
|
};
|
|
61
|
+
/**
|
|
62
|
+
* Label close button
|
|
63
|
+
*/
|
|
64
|
+
closeLabel: {
|
|
65
|
+
type: StringConstructor;
|
|
66
|
+
default: string;
|
|
67
|
+
};
|
|
53
68
|
/**
|
|
54
69
|
* Select input placeholder
|
|
55
70
|
*/
|
|
@@ -58,6 +73,13 @@ export declare const VvComboboxProps: {
|
|
|
58
73
|
* Use input text to search on options
|
|
59
74
|
*/
|
|
60
75
|
searchable: BooleanConstructor;
|
|
76
|
+
/**
|
|
77
|
+
* Search function to filter options
|
|
78
|
+
*/
|
|
79
|
+
searchFunction: {
|
|
80
|
+
type: PropType<(search: string, options: (Option | string)[]) => (Option | string)[] | Promise<(Option | string)[]>>;
|
|
81
|
+
default: undefined;
|
|
82
|
+
};
|
|
61
83
|
/**
|
|
62
84
|
* On searchable select is the input search placeholder
|
|
63
85
|
*/
|
|
@@ -137,45 +159,103 @@ export declare const VvComboboxProps: {
|
|
|
137
159
|
validator: (value: never) => boolean;
|
|
138
160
|
};
|
|
139
161
|
strategy: {
|
|
140
|
-
type: PropType<"
|
|
141
|
-
default:
|
|
142
|
-
validator: (value: "
|
|
143
|
-
};
|
|
144
|
-
transitionName: {
|
|
145
|
-
type: StringConstructor;
|
|
162
|
+
type: PropType<"absolute" | "fixed">;
|
|
163
|
+
default: undefined;
|
|
164
|
+
validator: (value: import("../../constants").Strategy) => boolean;
|
|
146
165
|
};
|
|
147
166
|
offset: {
|
|
148
167
|
type: PropType<string | import("@floating-ui/core").OffsetOptions | undefined>;
|
|
149
168
|
default: number;
|
|
150
169
|
};
|
|
151
170
|
shift: {
|
|
152
|
-
type: PropType<boolean |
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
171
|
+
type: PropType<boolean | {
|
|
172
|
+
mainAxis?: boolean | undefined;
|
|
173
|
+
crossAxis?: boolean | undefined;
|
|
174
|
+
rootBoundary?: import("@floating-ui/core").RootBoundary | undefined;
|
|
175
|
+
elementContext?: import("@floating-ui/core").ElementContext | undefined;
|
|
176
|
+
altBoundary?: boolean | undefined;
|
|
177
|
+
padding?: import("@floating-ui/core").Padding | undefined;
|
|
178
|
+
limiter?: {
|
|
179
|
+
fn: (state: import("@floating-ui/core").MiddlewareState) => import("@floating-ui/core").Coords;
|
|
180
|
+
options?: any;
|
|
181
|
+
} | undefined;
|
|
182
|
+
boundary?: import("@floating-ui/dom").Boundary | undefined;
|
|
183
|
+
} | import("@floating-ui/dom").Derivable<{
|
|
184
|
+
mainAxis?: boolean | undefined;
|
|
185
|
+
crossAxis?: boolean | undefined;
|
|
186
|
+
rootBoundary?: import("@floating-ui/core").RootBoundary | undefined;
|
|
187
|
+
elementContext?: import("@floating-ui/core").ElementContext | undefined;
|
|
188
|
+
altBoundary?: boolean | undefined;
|
|
189
|
+
padding?: import("@floating-ui/core").Padding | undefined;
|
|
190
|
+
limiter?: {
|
|
191
|
+
fn: (state: import("@floating-ui/core").MiddlewareState) => import("@floating-ui/core").Coords;
|
|
192
|
+
options?: any;
|
|
193
|
+
} | undefined;
|
|
194
|
+
boundary?: import("@floating-ui/dom").Boundary | undefined;
|
|
158
195
|
}> | undefined>;
|
|
159
196
|
default: boolean;
|
|
160
197
|
};
|
|
161
198
|
flip: {
|
|
162
|
-
type: PropType<boolean |
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
199
|
+
type: PropType<boolean | {
|
|
200
|
+
mainAxis?: boolean | undefined;
|
|
201
|
+
crossAxis?: boolean | undefined;
|
|
202
|
+
rootBoundary?: import("@floating-ui/core").RootBoundary | undefined;
|
|
203
|
+
elementContext?: import("@floating-ui/core").ElementContext | undefined;
|
|
204
|
+
altBoundary?: boolean | undefined;
|
|
205
|
+
padding?: import("@floating-ui/core").Padding | undefined;
|
|
206
|
+
fallbackPlacements?: import("@floating-ui/core").Placement[] | undefined;
|
|
207
|
+
fallbackStrategy?: "initialPlacement" | "bestFit" | undefined;
|
|
208
|
+
fallbackAxisSideDirection?: "start" | "end" | "none" | undefined;
|
|
209
|
+
flipAlignment?: boolean | undefined;
|
|
210
|
+
boundary?: import("@floating-ui/dom").Boundary | undefined;
|
|
211
|
+
} | import("@floating-ui/dom").Derivable<{
|
|
212
|
+
mainAxis?: boolean | undefined;
|
|
213
|
+
crossAxis?: boolean | undefined;
|
|
214
|
+
rootBoundary?: import("@floating-ui/core").RootBoundary | undefined;
|
|
215
|
+
elementContext?: import("@floating-ui/core").ElementContext | undefined;
|
|
216
|
+
altBoundary?: boolean | undefined;
|
|
217
|
+
padding?: import("@floating-ui/core").Padding | undefined;
|
|
218
|
+
fallbackPlacements?: import("@floating-ui/core").Placement[] | undefined;
|
|
219
|
+
fallbackStrategy?: "initialPlacement" | "bestFit" | undefined;
|
|
220
|
+
fallbackAxisSideDirection?: "start" | "end" | "none" | undefined;
|
|
221
|
+
flipAlignment?: boolean | undefined;
|
|
222
|
+
boundary?: import("@floating-ui/dom").Boundary | undefined;
|
|
168
223
|
}> | undefined>;
|
|
169
224
|
default: boolean;
|
|
170
225
|
};
|
|
171
226
|
size: {
|
|
172
|
-
type: PropType<boolean |
|
|
173
|
-
|
|
227
|
+
type: PropType<boolean | {
|
|
228
|
+
rootBoundary?: import("@floating-ui/core").RootBoundary | undefined;
|
|
229
|
+
elementContext?: import("@floating-ui/core").ElementContext | undefined;
|
|
230
|
+
altBoundary?: boolean | undefined;
|
|
231
|
+
padding?: import("@floating-ui/core").Padding | undefined;
|
|
232
|
+
boundary?: import("@floating-ui/dom").Boundary | undefined;
|
|
233
|
+
apply?: ((args: {
|
|
174
234
|
x: number;
|
|
175
235
|
y: number;
|
|
236
|
+
initialPlacement: import("@floating-ui/core").Placement;
|
|
176
237
|
placement: import("@floating-ui/core").Placement;
|
|
177
238
|
strategy: import("@floating-ui/core").Strategy;
|
|
239
|
+
middlewareData: import("@floating-ui/core").MiddlewareData;
|
|
240
|
+
rects: import("@floating-ui/core").ElementRects;
|
|
241
|
+
platform: import("@floating-ui/core").Platform;
|
|
242
|
+
elements: import("@floating-ui/dom").Elements;
|
|
243
|
+
} & {
|
|
244
|
+
availableWidth: number;
|
|
245
|
+
availableHeight: number;
|
|
246
|
+
}) => void | Promise<void>) | undefined;
|
|
247
|
+
} | import("@floating-ui/dom").Derivable<{
|
|
248
|
+
rootBoundary?: import("@floating-ui/core").RootBoundary | undefined;
|
|
249
|
+
elementContext?: import("@floating-ui/core").ElementContext | undefined;
|
|
250
|
+
altBoundary?: boolean | undefined;
|
|
251
|
+
padding?: import("@floating-ui/core").Padding | undefined;
|
|
252
|
+
boundary?: import("@floating-ui/dom").Boundary | undefined;
|
|
253
|
+
apply?: ((args: {
|
|
254
|
+
x: number;
|
|
255
|
+
y: number;
|
|
178
256
|
initialPlacement: import("@floating-ui/core").Placement;
|
|
257
|
+
placement: import("@floating-ui/core").Placement;
|
|
258
|
+
strategy: import("@floating-ui/core").Strategy;
|
|
179
259
|
middlewareData: import("@floating-ui/core").MiddlewareData;
|
|
180
260
|
rects: import("@floating-ui/core").ElementRects;
|
|
181
261
|
platform: import("@floating-ui/core").Platform;
|
|
@@ -183,25 +263,33 @@ export declare const VvComboboxProps: {
|
|
|
183
263
|
} & {
|
|
184
264
|
availableWidth: number;
|
|
185
265
|
availableHeight: number;
|
|
186
|
-
}) => void | Promise<void
|
|
187
|
-
} & {
|
|
188
|
-
rootBoundary: import("@floating-ui/core").RootBoundary;
|
|
189
|
-
elementContext: import("@floating-ui/core").ElementContext;
|
|
190
|
-
altBoundary: boolean;
|
|
191
|
-
padding: import("@floating-ui/core").Padding;
|
|
192
|
-
boundary: import("@floating-ui/dom").Boundary;
|
|
266
|
+
}) => void | Promise<void>) | undefined;
|
|
193
267
|
}> | undefined>;
|
|
194
268
|
default: () => {
|
|
195
269
|
padding: number;
|
|
196
270
|
};
|
|
197
271
|
};
|
|
198
272
|
autoPlacement: {
|
|
199
|
-
type: PropType<boolean |
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
273
|
+
type: PropType<boolean | {
|
|
274
|
+
crossAxis?: boolean | undefined;
|
|
275
|
+
rootBoundary?: import("@floating-ui/core").RootBoundary | undefined;
|
|
276
|
+
elementContext?: import("@floating-ui/core").ElementContext | undefined;
|
|
277
|
+
altBoundary?: boolean | undefined;
|
|
278
|
+
padding?: import("@floating-ui/core").Padding | undefined;
|
|
279
|
+
alignment?: import("@floating-ui/core").Alignment | null | undefined;
|
|
280
|
+
autoAlignment?: boolean | undefined;
|
|
281
|
+
allowedPlacements?: import("@floating-ui/core").Placement[] | undefined;
|
|
282
|
+
boundary?: import("@floating-ui/dom").Boundary | undefined;
|
|
283
|
+
} | import("@floating-ui/dom").Derivable<{
|
|
284
|
+
crossAxis?: boolean | undefined;
|
|
285
|
+
rootBoundary?: import("@floating-ui/core").RootBoundary | undefined;
|
|
286
|
+
elementContext?: import("@floating-ui/core").ElementContext | undefined;
|
|
287
|
+
altBoundary?: boolean | undefined;
|
|
288
|
+
padding?: import("@floating-ui/core").Padding | undefined;
|
|
289
|
+
alignment?: import("@floating-ui/core").Alignment | null | undefined;
|
|
290
|
+
autoAlignment?: boolean | undefined;
|
|
291
|
+
allowedPlacements?: import("@floating-ui/core").Placement[] | undefined;
|
|
292
|
+
boundary?: import("@floating-ui/dom").Boundary | undefined;
|
|
205
293
|
}> | undefined>;
|
|
206
294
|
default: boolean;
|
|
207
295
|
};
|
|
@@ -227,7 +315,7 @@ export declare const VvComboboxProps: {
|
|
|
227
315
|
validation: (value: import("../../constants").Position) => boolean;
|
|
228
316
|
};
|
|
229
317
|
options: {
|
|
230
|
-
type: PropType<(string |
|
|
318
|
+
type: PropType<(string | Option)[]>;
|
|
231
319
|
default: () => never[];
|
|
232
320
|
};
|
|
233
321
|
labelKey: {
|
|
@@ -243,9 +331,7 @@ export declare const VvComboboxProps: {
|
|
|
243
331
|
default: string;
|
|
244
332
|
};
|
|
245
333
|
modifiers: PropType<string | string[]>;
|
|
246
|
-
readonly: BooleanConstructor;
|
|
247
|
-
* Manage modelValue as string[] or object[]
|
|
248
|
-
*/
|
|
334
|
+
readonly: BooleanConstructor;
|
|
249
335
|
disabled: BooleanConstructor;
|
|
250
336
|
loading: BooleanConstructor;
|
|
251
337
|
loadingLabel: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { inject, computed, unref, defineComponent, ref, toRefs, openBlock, createBlock, mergeProps, createCommentVNode, Transition, toHandlers, withCtx, withDirectives, createElementVNode, createElementBlock, renderSlot, createTextVNode, toDisplayString, createVNode, vShow } from "vue";
|
|
1
|
+
import { inject, computed, unref, defineComponent, ref, toRefs, openBlock, createBlock, mergeProps, createCommentVNode, Transition, toHandlers, withCtx, withDirectives, createElementVNode, withModifiers, createElementBlock, renderSlot, createTextVNode, toDisplayString, createVNode, vShow } from "vue";
|
|
2
2
|
import { iconExists, Icon, addIcon } from "@iconify/vue";
|
|
3
|
-
import {
|
|
3
|
+
import { useVModel, onClickOutside } from "@vueuse/core";
|
|
4
4
|
const VvIconProps = {
|
|
5
5
|
/**
|
|
6
6
|
* Color
|
|
@@ -95,6 +95,11 @@ const VvIconProps = {
|
|
|
95
95
|
type: [String, Array]
|
|
96
96
|
}
|
|
97
97
|
};
|
|
98
|
+
var Strategy = /* @__PURE__ */ ((Strategy2) => {
|
|
99
|
+
Strategy2["absolute"] = "absolute";
|
|
100
|
+
Strategy2["fixed"] = "fixed";
|
|
101
|
+
return Strategy2;
|
|
102
|
+
})(Strategy || {});
|
|
98
103
|
var Side = /* @__PURE__ */ ((Side2) => {
|
|
99
104
|
Side2["left"] = "left";
|
|
100
105
|
Side2["right"] = "right";
|
|
@@ -334,19 +339,15 @@ const IdProps = {
|
|
|
334
339
|
placement: {
|
|
335
340
|
type: String,
|
|
336
341
|
default: Side.bottom,
|
|
337
|
-
validator: (value) =>
|
|
338
|
-
return Object.values(Side).includes(value) || Object.values(Placement).includes(value);
|
|
339
|
-
}
|
|
342
|
+
validator: (value) => Object.values(Side).includes(value) || Object.values(Placement).includes(value)
|
|
340
343
|
},
|
|
341
344
|
/**
|
|
342
345
|
* Dropdown strategy
|
|
343
346
|
*/
|
|
344
347
|
strategy: {
|
|
345
348
|
type: String,
|
|
346
|
-
default:
|
|
347
|
-
validator: (value) =>
|
|
348
|
-
return ["fixed", "absolute"].includes(value);
|
|
349
|
-
}
|
|
349
|
+
default: void 0,
|
|
350
|
+
validator: (value) => Object.values(Strategy).includes(value)
|
|
350
351
|
},
|
|
351
352
|
/**
|
|
352
353
|
* Dropdown show / hide transition name
|
|
@@ -436,6 +437,13 @@ const IdProps = {
|
|
|
436
437
|
type: String,
|
|
437
438
|
default: ButtonType.button,
|
|
438
439
|
validator: (value) => Object.values(ButtonType).includes(value)
|
|
440
|
+
},
|
|
441
|
+
/**
|
|
442
|
+
* Button aria-label
|
|
443
|
+
*/
|
|
444
|
+
ariaLabel: {
|
|
445
|
+
type: String,
|
|
446
|
+
default: void 0
|
|
439
447
|
}
|
|
440
448
|
});
|
|
441
449
|
const VvDialogEvents = [
|
|
@@ -477,12 +485,13 @@ const VvDialogProps = {
|
|
|
477
485
|
*/
|
|
478
486
|
keepOpen: { type: Boolean, default: false }
|
|
479
487
|
};
|
|
480
|
-
const _hoisted_1 =
|
|
488
|
+
const _hoisted_1 = ["onCancel"];
|
|
489
|
+
const _hoisted_2 = {
|
|
481
490
|
key: 0,
|
|
482
491
|
class: "vv-dialog__header"
|
|
483
492
|
};
|
|
484
|
-
const
|
|
485
|
-
const
|
|
493
|
+
const _hoisted_3 = { class: "vv-dialog__content" };
|
|
494
|
+
const _hoisted_4 = {
|
|
486
495
|
key: 1,
|
|
487
496
|
class: "vv-dialog__footer"
|
|
488
497
|
};
|
|
@@ -496,16 +505,16 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
496
505
|
setup(__props, { expose: __expose, emit }) {
|
|
497
506
|
const props = __props;
|
|
498
507
|
const dialogEl = ref();
|
|
508
|
+
const modelValue = useVModel(props, "modelValue", emit);
|
|
499
509
|
const localModelValue = ref(false);
|
|
500
|
-
const
|
|
501
|
-
get()
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
localModelValue.value = value;
|
|
510
|
+
const isOpened = computed({
|
|
511
|
+
get: () => modelValue.value ?? localModelValue.value,
|
|
512
|
+
set: (newValue) => {
|
|
513
|
+
if (modelValue.value === void 0) {
|
|
514
|
+
localModelValue.value = newValue;
|
|
515
|
+
return;
|
|
507
516
|
}
|
|
508
|
-
|
|
517
|
+
modelValue.value = newValue;
|
|
509
518
|
}
|
|
510
519
|
});
|
|
511
520
|
const modalWrapper = ref(null);
|
|
@@ -524,14 +533,18 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
524
533
|
const transitioName = computed(() => `vv-dialog--${props.transition}`);
|
|
525
534
|
const dialogTransitionHandlers = {
|
|
526
535
|
"before-enter": () => {
|
|
527
|
-
var _a;
|
|
528
|
-
(_a = dialogEl.value) == null ? void 0 : _a.
|
|
536
|
+
var _a, _b;
|
|
537
|
+
if (!((_a = dialogEl.value) == null ? void 0 : _a.open)) {
|
|
538
|
+
(_b = dialogEl.value) == null ? void 0 : _b.showModal();
|
|
539
|
+
}
|
|
529
540
|
emit("open");
|
|
530
541
|
emit("before-enter");
|
|
531
542
|
},
|
|
532
543
|
"after-leave": () => {
|
|
533
|
-
var _a;
|
|
534
|
-
(_a = dialogEl.value) == null ? void 0 : _a.
|
|
544
|
+
var _a, _b;
|
|
545
|
+
if ((_a = dialogEl.value) == null ? void 0 : _a.open) {
|
|
546
|
+
(_b = dialogEl.value) == null ? void 0 : _b.close();
|
|
547
|
+
}
|
|
535
548
|
emit("close");
|
|
536
549
|
emit("after-leave");
|
|
537
550
|
},
|
|
@@ -556,36 +569,36 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
556
569
|
};
|
|
557
570
|
onClickOutside(modalWrapper, () => {
|
|
558
571
|
if (!props.keepOpen) {
|
|
559
|
-
|
|
572
|
+
close();
|
|
560
573
|
}
|
|
561
574
|
});
|
|
562
575
|
function close() {
|
|
563
|
-
|
|
576
|
+
isOpened.value = false;
|
|
564
577
|
}
|
|
565
578
|
function open() {
|
|
566
|
-
|
|
579
|
+
isOpened.value = true;
|
|
567
580
|
}
|
|
568
581
|
__expose({ close, open });
|
|
569
|
-
|
|
570
|
-
if (
|
|
571
|
-
e.preventDefault();
|
|
582
|
+
const onCancel = () => {
|
|
583
|
+
if (!props.keepOpen) {
|
|
572
584
|
close();
|
|
573
585
|
}
|
|
574
|
-
}
|
|
586
|
+
};
|
|
575
587
|
return (_ctx, _cache) => {
|
|
576
588
|
return openBlock(), createBlock(Transition, mergeProps({ name: unref(transitioName) }, toHandlers(dialogTransitionHandlers)), {
|
|
577
589
|
default: withCtx(() => [
|
|
578
590
|
withDirectives(createElementVNode("dialog", mergeProps(unref(dialogAttrs), {
|
|
579
591
|
ref_key: "dialogEl",
|
|
580
592
|
ref: dialogEl,
|
|
581
|
-
class: unref(dialogClass)
|
|
593
|
+
class: unref(dialogClass),
|
|
594
|
+
onCancel: withModifiers(onCancel, ["stop", "prevent"])
|
|
582
595
|
}), [
|
|
583
596
|
createElementVNode("article", {
|
|
584
597
|
ref_key: "modalWrapper",
|
|
585
598
|
ref: modalWrapper,
|
|
586
599
|
class: "vv-dialog__wrapper"
|
|
587
600
|
}, [
|
|
588
|
-
_ctx.$slots.header || _ctx.title ? (openBlock(), createElementBlock("header",
|
|
601
|
+
_ctx.$slots.header || _ctx.title ? (openBlock(), createElementBlock("header", _hoisted_2, [
|
|
589
602
|
renderSlot(_ctx.$slots, "header", {}, () => [
|
|
590
603
|
createTextVNode(toDisplayString(_ctx.title) + " ", 1),
|
|
591
604
|
createElementVNode("button", {
|
|
@@ -598,15 +611,15 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
598
611
|
], 32)
|
|
599
612
|
])
|
|
600
613
|
])) : createCommentVNode("", true),
|
|
601
|
-
createElementVNode("div",
|
|
614
|
+
createElementVNode("div", _hoisted_3, [
|
|
602
615
|
renderSlot(_ctx.$slots, "default")
|
|
603
616
|
]),
|
|
604
|
-
_ctx.$slots.footer ? (openBlock(), createElementBlock("footer",
|
|
617
|
+
_ctx.$slots.footer ? (openBlock(), createElementBlock("footer", _hoisted_4, [
|
|
605
618
|
renderSlot(_ctx.$slots, "footer")
|
|
606
619
|
])) : createCommentVNode("", true)
|
|
607
620
|
], 512)
|
|
608
|
-
], 16), [
|
|
609
|
-
[vShow, unref(
|
|
621
|
+
], 16, _hoisted_1), [
|
|
622
|
+
[vShow, unref(isOpened)]
|
|
610
623
|
])
|
|
611
624
|
]),
|
|
612
625
|
_: 3
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,o){"object"==typeof exports&&"undefined"!=typeof module?module.exports=o(require("vue"),require("@iconify/vue"),require("@vueuse/core")):"function"==typeof define&&define.amd?define(["vue","@iconify/vue","@vueuse/core"],o):(e="undefined"!=typeof globalThis?globalThis:e||self).VvDialog=o(e.vue,e.vue$1,e.core)}(this,(function(e,o,t){"use strict";const
|
|
1
|
+
!function(e,o){"object"==typeof exports&&"undefined"!=typeof module?module.exports=o(require("vue"),require("@iconify/vue"),require("@vueuse/core")):"function"==typeof define&&define.amd?define(["vue","@iconify/vue","@vueuse/core"],o):(e="undefined"!=typeof globalThis?globalThis:e||self).VvDialog=o(e.vue,e.vue$1,e.core)}(this,(function(e,o,t){"use strict";const n={color:String,width:{type:[String,Number]},height:{type:[String,Number]},name:{type:String,required:!0},provider:{type:String},prefix:{type:String,default:"normal"},src:String,horizontalFlip:Boolean,verticalFlip:Boolean,flip:String,mode:String,inline:Boolean,rotate:[Number,String],onLoad:Function,svg:String,modifiers:{type:[String,Array]}};var r=(e=>(e.left="left",e.right="right",e.top="top",e.bottom="bottom",e))(r||{}),l=(e=>(e.before="before",e.after="after",e))(l||{}),i=(e=>(e.button="button",e.submit="submit",e.reset="reset",e))(i||{});const a=Symbol.for("volver");const c=e.defineComponent({name:"VvIcon",props:n,setup(t){const n=t,r=e.computed((()=>"string"==typeof n.rotate?parseFloat(n.rotate):n.rotate)),l=e.ref(!0),i=e.inject(a),{modifiers:c}=e.toRefs(n),s=function(o,t,n){return e.computed((()=>{const r={[o]:!0},l="string"==typeof(null==t?void 0:t.value)?t.value.split(" "):null==t?void 0:t.value;return l&&Array.isArray(l)&&l.forEach((e=>{e&&(r[`${o}--${e}`]=!0)})),n&&Object.keys(n.value).forEach((t=>{r[`${o}--${t}`]=e.unref(n.value[t])})),r}))}("vv-icon",c),u=e.computed((()=>n.provider||(null==i?void 0:i.iconsProvider))),d=e.computed((()=>{const e=n.name??"",t=`@${u.value}:${n.prefix}:${e}`;if(o.iconExists(t))return t;const r=null==i?void 0:i.iconsCollections.find((t=>{const n=`@${u.value}:${t.prefix}:${e}`;return o.iconExists(n)}));return r?`@${u.value}:${r.prefix}:${e}`:e}));function v(e){const t=function(e){let o;if("undefined"==typeof window){const{JSDOM:e}=require("jsdom");o=(new e).window}return(o?new o.DOMParser:new window.DOMParser).parseFromString(e,"text/html").querySelector("svg")}(e),r=(null==t?void 0:t.innerHTML.trim())||"";t&&r&&o.addIcon(`@${u.value}:${n.prefix}:${n.name}`,{body:r,height:t.viewBox.baseVal.height,width:t.viewBox.baseVal.width})}return i&&n.src&&!o.iconExists(`@${u.value}:${n.prefix}:${n.name}`)&&(l.value=!1,i.fetchIcon(n.src).then((e=>{e&&(v(e),l.value=!0)})).catch((e=>{throw new Error(`Error during fetch icon: ${null==e?void 0:e.message}`)}))),n.svg&&v(n.svg),(t,n)=>e.unref(l)?(e.openBlock(),e.createBlock(e.unref(o.Icon),e.mergeProps({key:0,class:e.unref(s)},{inline:t.inline,width:t.width,height:t.height,horizontalFlip:t.horizontalFlip,verticalFlip:t.verticalFlip,flip:t.flip,rotate:e.unref(r),color:t.color,onLoad:t.onLoad,icon:e.unref(d)}),null,16,["class"])):e.createCommentVNode("",!0)}});Boolean,Boolean,Boolean;l.before;const s={id:[String,Number]};r.bottom,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,i.button;const u={...s,title:String,modelValue:{type:Boolean,default:void 0},transition:{type:String,default:"fade-block"},size:String,keepOpen:{type:Boolean,default:!1}},d=["onCancel"],v={key:0,class:"vv-dialog__header"},f={class:"vv-dialog__content"},p={key:1,class:"vv-dialog__footer"};return e.defineComponent({name:"VvDialog",props:u,emits:["open","close","update:modelValue","before-enter","after-leave","enter","after-enter","enter-cancelled","before-leave","leave","leave-cancelled"],setup(o,{expose:n,emit:r}){const l=o,i=e.ref(),a=t.useVModel(l,"modelValue",r),s=e.ref(!1),u=e.computed({get:()=>a.value??s.value,set:e=>{void 0!==a.value?a.value=e:s.value=e}}),m=e.ref(null),g=e.computed((()=>{const{id:e}=l;return{id:e}})),h=e.computed((()=>l.size?["vv-dialog",`vv-dialog--${l.size}`]:"vv-dialog")),b=e.computed((()=>`vv-dialog--${l.transition}`)),y={"before-enter":()=>{var e,o;(null==(e=i.value)?void 0:e.open)||null==(o=i.value)||o.showModal(),r("open"),r("before-enter")},"after-leave":()=>{var e,o;(null==(e=i.value)?void 0:e.open)&&(null==(o=i.value)||o.close()),r("close"),r("after-leave")},enter:()=>{r("enter")},"after-enter":()=>{r("after-enter")},"enter-cancelled":()=>{r("enter-cancelled")},"before-leave":()=>{r("before-leave")},leave:()=>{r("leave")},"leave-cancelled":()=>{r("leave-cancelled")}};function $(){u.value=!1}t.onClickOutside(m,(()=>{l.keepOpen||$()})),n({close:$,open:function(){u.value=!0}});const B=()=>{l.keepOpen||$()};return(o,t)=>(e.openBlock(),e.createBlock(e.Transition,e.mergeProps({name:e.unref(b)},e.toHandlers(y)),{default:e.withCtx((()=>[e.withDirectives(e.createElementVNode("dialog",e.mergeProps(e.unref(g),{ref_key:"dialogEl",ref:i,class:e.unref(h),onCancel:e.withModifiers(B,["stop","prevent"])}),[e.createElementVNode("article",{ref_key:"modalWrapper",ref:m,class:"vv-dialog__wrapper"},[o.$slots.header||o.title?(e.openBlock(),e.createElementBlock("header",v,[e.renderSlot(o.$slots,"header",{},(()=>[e.createTextVNode(e.toDisplayString(o.title)+" ",1),e.createElementVNode("button",{type:"button","aria-label":"Close",class:"vv-dialog__close",onClickPassive:$},[e.createVNode(c,{name:"close"})],32)]))])):e.createCommentVNode("",!0),e.createElementVNode("div",f,[e.renderSlot(o.$slots,"default")]),o.$slots.footer?(e.openBlock(),e.createElementBlock("footer",p,[e.renderSlot(o.$slots,"footer")])):e.createCommentVNode("",!0)],512)],16,d),[[e.vShow,e.unref(u)]])])),_:3},16,["name"]))}})}));
|
|
@@ -3,6 +3,11 @@ import { autoPlacement, flip, shift, size, offset, arrow, useFloating, autoUpdat
|
|
|
3
3
|
import { nanoid } from "nanoid";
|
|
4
4
|
import { useMutationObserver, useVModel, onClickOutside, useFocusWithin, onKeyStroke } from "@vueuse/core";
|
|
5
5
|
import mitt from "mitt";
|
|
6
|
+
var Strategy = /* @__PURE__ */ ((Strategy2) => {
|
|
7
|
+
Strategy2["absolute"] = "absolute";
|
|
8
|
+
Strategy2["fixed"] = "fixed";
|
|
9
|
+
return Strategy2;
|
|
10
|
+
})(Strategy || {});
|
|
6
11
|
var Side = /* @__PURE__ */ ((Side2) => {
|
|
7
12
|
Side2["left"] = "left";
|
|
8
13
|
Side2["right"] = "right";
|
|
@@ -141,19 +146,15 @@ const DropdownProps = {
|
|
|
141
146
|
placement: {
|
|
142
147
|
type: String,
|
|
143
148
|
default: Side.bottom,
|
|
144
|
-
validator: (value) =>
|
|
145
|
-
return Object.values(Side).includes(value) || Object.values(Placement).includes(value);
|
|
146
|
-
}
|
|
149
|
+
validator: (value) => Object.values(Side).includes(value) || Object.values(Placement).includes(value)
|
|
147
150
|
},
|
|
148
151
|
/**
|
|
149
152
|
* Dropdown strategy
|
|
150
153
|
*/
|
|
151
154
|
strategy: {
|
|
152
155
|
type: String,
|
|
153
|
-
default:
|
|
154
|
-
validator: (value) =>
|
|
155
|
-
return ["fixed", "absolute"].includes(value);
|
|
156
|
-
}
|
|
156
|
+
default: void 0,
|
|
157
|
+
validator: (value) => Object.values(Strategy).includes(value)
|
|
157
158
|
},
|
|
158
159
|
/**
|
|
159
160
|
* Dropdown show / hide transition name
|
|
@@ -243,6 +244,13 @@ const DropdownProps = {
|
|
|
243
244
|
type: String,
|
|
244
245
|
default: ButtonType.button,
|
|
245
246
|
validator: (value) => Object.values(ButtonType).includes(value)
|
|
247
|
+
},
|
|
248
|
+
/**
|
|
249
|
+
* Button aria-label
|
|
250
|
+
*/
|
|
251
|
+
ariaLabel: {
|
|
252
|
+
type: String,
|
|
253
|
+
default: void 0
|
|
246
254
|
}
|
|
247
255
|
});
|
|
248
256
|
const VvDropdownProps = {
|
|
@@ -403,7 +411,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
403
411
|
}
|
|
404
412
|
} else if (props.flip) {
|
|
405
413
|
if (typeof props.flip === "boolean") {
|
|
406
|
-
toReturn.push(flip());
|
|
414
|
+
toReturn.push(flip({ fallbackStrategy: "initialPlacement" }));
|
|
407
415
|
} else {
|
|
408
416
|
toReturn.push(flip(props.flip));
|
|
409
417
|
}
|
|
@@ -455,27 +463,33 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
455
463
|
}
|
|
456
464
|
return toReturn;
|
|
457
465
|
});
|
|
458
|
-
const { x, y,
|
|
466
|
+
const { x, y, middlewareData, placement, strategy } = useFloating(
|
|
459
467
|
referenceEl,
|
|
460
468
|
floatingEl,
|
|
461
469
|
{
|
|
462
|
-
whileElementsMounted:
|
|
470
|
+
whileElementsMounted: (...args) => {
|
|
471
|
+
return autoUpdate(...args, {
|
|
472
|
+
animationFrame: props.strategy === Strategy.fixed
|
|
473
|
+
});
|
|
474
|
+
},
|
|
463
475
|
placement: computed(() => props.placement),
|
|
464
476
|
strategy: computed(() => props.strategy),
|
|
465
477
|
middleware
|
|
466
478
|
}
|
|
467
479
|
);
|
|
468
480
|
const dropdownPlacement = computed(() => {
|
|
481
|
+
var _a;
|
|
469
482
|
if (hasCustomPosition.value) {
|
|
470
483
|
return void 0;
|
|
471
484
|
}
|
|
485
|
+
const width = props.triggerWidth && referenceEl.value ? `${(_a = referenceEl.value) == null ? void 0 : _a.offsetWidth}px` : void 0;
|
|
472
486
|
return {
|
|
473
487
|
position: strategy.value,
|
|
474
488
|
top: `${y.value ?? 0}px`,
|
|
475
489
|
left: `${x.value ?? 0}px`,
|
|
476
|
-
maxWidth: maxWidth.value,
|
|
490
|
+
maxWidth: width ? void 0 : maxWidth.value,
|
|
477
491
|
maxHeight: maxHeight.value,
|
|
478
|
-
width
|
|
492
|
+
width
|
|
479
493
|
};
|
|
480
494
|
});
|
|
481
495
|
const side = computed(
|
|
@@ -487,10 +501,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
487
501
|
return void 0;
|
|
488
502
|
}
|
|
489
503
|
const staticSide = {
|
|
490
|
-
top:
|
|
491
|
-
right:
|
|
492
|
-
bottom:
|
|
493
|
-
left:
|
|
504
|
+
[Side.top]: Side.bottom,
|
|
505
|
+
[Side.right]: Side.left,
|
|
506
|
+
[Side.bottom]: Side.top,
|
|
507
|
+
[Side.left]: Side.right
|
|
494
508
|
}[side.value];
|
|
495
509
|
return {
|
|
496
510
|
left: ((_a = middlewareData.value.arrow) == null ? void 0 : _a.x) !== void 0 ? `${(_b = middlewareData.value.arrow) == null ? void 0 : _b.x}px` : void 0,
|
|
@@ -546,7 +560,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
546
560
|
onClickOutside(
|
|
547
561
|
floatingEl,
|
|
548
562
|
() => {
|
|
549
|
-
if (!props.keepOpen) {
|
|
563
|
+
if (!props.keepOpen && expanded.value) {
|
|
550
564
|
expanded.value = false;
|
|
551
565
|
}
|
|
552
566
|
},
|
|
@@ -584,7 +598,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
584
598
|
}
|
|
585
599
|
return [
|
|
586
600
|
...element.querySelectorAll(
|
|
587
|
-
'a[href], button, input, textarea, select, details,[tabindex]:not([tabindex="-1"])'
|
|
601
|
+
'a[href], button, input, textarea, select, details, [tabindex]:not([tabindex="-1"])'
|
|
588
602
|
)
|
|
589
603
|
].filter(
|
|
590
604
|
(el) => !el.hasAttribute("disabled") && !el.getAttribute("aria-hidden")
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("vue"),require("@floating-ui/vue"),require("nanoid"),require("@vueuse/core"),require("mitt")):"function"==typeof define&&define.amd?define(["vue","@floating-ui/vue","nanoid","@vueuse/core","mitt"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).VvDropdown=t(e.vue,e.vue$1,e.nanoid,e.core,e.mitt)}(this,(function(e,t,o,r,l){"use strict";var a=(e=>(e.left="left",e.right="right",e.top="top",e.bottom="bottom",e))(
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("vue"),require("@floating-ui/vue"),require("nanoid"),require("@vueuse/core"),require("mitt")):"function"==typeof define&&define.amd?define(["vue","@floating-ui/vue","nanoid","@vueuse/core","mitt"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).VvDropdown=t(e.vue,e.vue$1,e.nanoid,e.core,e.mitt)}(this,(function(e,t,o,r,l){"use strict";var a=(e=>(e.absolute="absolute",e.fixed="fixed",e))(a||{}),n=(e=>(e.left="left",e.right="right",e.top="top",e.bottom="bottom",e))(n||{}),u=(e=>(e.topStart="top-start",e.topEnd="top-end",e.bottomStart="bottom-start",e.bottomEnd="bottom-end",e.leftStart="left-start",e.leftEnd="left-end",e.rightStart="right-start",e.rightEnd="right-end",e))(u||{}),i=(e=>(e.before="before",e.after="after",e))(i||{}),d=(e=>(e.button="button",e.submit="submit",e.reset="reset",e))(d||{}),s=(e=>(e.listbox="listbox",e.menu="menu",e))(s||{}),f=(e=>(e.option="option",e.presentation="presentation",e))(f||{});const p=Symbol.for("dropdownTrigger"),c=Symbol.for("dropdownItem"),v=(Boolean,Boolean,Boolean,{modifiers:[String,Array]});i.before;const m={id:[String,Number]},b={placement:{type:String,default:n.bottom,validator:e=>Object.values(n).includes(e)||Object.values(u).includes(e)},strategy:{type:String,default:void 0,validator:e=>Object.values(a).includes(e)},transitionName:{type:String},offset:{type:[Number,String,Object],default:0},shift:{type:[Boolean,Object],default:!1},flip:{type:[Boolean,Object],default:!0},size:{type:[Boolean,Object],default:()=>({padding:10})},autoPlacement:{type:[Boolean,Object],default:!1},arrow:{type:Boolean,default:!1},keepOpen:{type:Boolean,default:!1},autofocusFirst:{type:Boolean,default:!0},triggerWidth:{type:Boolean}};d.button;const g={...m,...b,...v,modelValue:{type:Boolean,default:void 0},reference:{type:Object,default:null},role:{type:String,default:s.menu,validator:e=>Object.values(s).includes(e)}};const h=["id","tabindex","role","aria-labelledby"];return e.defineComponent({name:"VvDropdown",inheritAttrs:!1,props:g,emits:["update:modelValue","beforeExpand","beforeCollapse","afterExpand","afterCollapse","before-enter","after-leave","enter","after-enter","enter-cancelled","before-leave","leave","leave-cancelled"],setup(u,{expose:i,emit:d}){const v=u,{id:m}=e.toRefs(v),b=(t=>e.computed((()=>String((null==t?void 0:t.value)||o.nanoid()))))(m),g=e.useAttrs(),y=e.ref("auto"),x=e.ref("auto"),w=e.ref(null),S=e.ref(),E=e.ref(null),k=e.ref(null),P=e.computed({get:()=>v.reference??w.value,set:e=>{w.value=e}}),O=e.ref(!1);e.onMounted((()=>{r.useMutationObserver(S.value,(()=>{var e;O.value="true"===(null==(e=window.getComputedStyle(S.value).getPropertyValue("--dropdown-custom-position"))?void 0:e.trim())}),{attributeFilter:["style"],window:window})}));const $=e.computed((()=>{const e=[];if(v.autoPlacement?"boolean"==typeof v.autoPlacement?e.push(t.autoPlacement()):e.push(t.autoPlacement(v.autoPlacement)):v.flip&&("boolean"==typeof v.flip?e.push(t.flip({fallbackStrategy:"initialPlacement"})):e.push(t.flip(v.flip))),v.shift&&("boolean"==typeof v.shift?e.push(t.shift()):e.push(t.shift(v.shift))),v.size){const o=({availableWidth:e,availableHeight:t})=>{y.value=`${e}px`,x.value=`${t}px`};"boolean"==typeof v.size?e.push(t.size({apply:o})):e.push(t.size({...v.size,apply:o}))}return v.offset&&(e.push(t.offset(Number(v.offset))),["string","number"].includes(typeof v.offset)?e.push(t.offset(Number(v.offset))):e.push(t.offset(v.offset))),v.arrow&&e.push(t.arrow({element:E})),e})),{x:B,y:z,middlewareData:V,placement:j,strategy:C}=t.useFloating(P,S,{whileElementsMounted:(...e)=>t.autoUpdate(...e,{animationFrame:v.strategy===a.fixed}),placement:e.computed((()=>v.placement)),strategy:e.computed((()=>v.strategy)),middleware:$}),A=e.computed((()=>{var e;if(O.value)return;const t=v.triggerWidth&&P.value?`${null==(e=P.value)?void 0:e.offsetWidth}px`:void 0;return{position:C.value,top:`${z.value??0}px`,left:`${B.value??0}px`,maxWidth:t?void 0:y.value,maxHeight:x.value,width:t}})),N=e.computed((()=>j.value.split("-")[0])),D=e.computed((()=>{var e,t,o,r,l;if(O.value)return;const a={[n.top]:n.bottom,[n.right]:n.left,[n.bottom]:n.top,[n.left]:n.right}[N.value];return{left:void 0!==(null==(e=V.value.arrow)?void 0:e.x)?`${null==(t=V.value.arrow)?void 0:t.x}px`:void 0,top:void 0!==(null==(o=V.value.arrow)?void 0:o.y)?`${null==(r=V.value.arrow)?void 0:r.y}px`:void 0,[a]:-((null==(l=E.value)?void 0:l.offsetWidth)??0)/2+"px"}})),_=r.useVModel(v,"modelValue",d),F=e.ref(!1),R=e.computed({get:()=>_.value??F.value,set:e=>{void 0!==_.value?_.value=e:F.value=e}}),T=()=>{R.value=!0},W=()=>{R.value=!1},q=()=>{R.value=!R.value},K=e=>{P.value=e};i({toggle:q,show:T,hide:W,init:K,customPosition:O}),e.watch(R,(t=>{t&&v.autofocusFirst&&e.nextTick((()=>{const e=Y(S.value);e.length>0&&e[0].focus({preventScroll:!0})}))})),r.onClickOutside(S,(()=>{!v.keepOpen&&R.value&&(R.value=!1)}),{ignore:[P]});const M=e.computed((()=>{var e,t;return(null==(t=null==(e=P.value)?void 0:e.getAttribute)?void 0:t.call(e,"id"))??void 0})),H=e.computed((()=>({"aria-controls":b.value,"aria-haspopup":!0,"aria-expanded":R.value}))),{component:U,bus:I}=function({reference:t,id:o,expanded:r,aria:a}){const n=l(),u=e.defineComponent({name:"VvDropdownTriggerProvider",setup(){e.provide(p,{reference:t,id:o,expanded:r,aria:a,bus:n})},render(){var t,o;return e.h(e.Fragment,{},null==(o=(t=this.$slots).default)?void 0:o.call(t))}});return{bus:n,component:u}}({reference:P,id:b,expanded:R,aria:H});I.on("click",q);const{role:G,modifiers:J}=e.toRefs(v),{itemRole:L}=function({role:t,expanded:o}){const r=e.computed((()=>t.value===s.listbox?f.option:f.presentation));return e.provide(c,{role:r,expanded:o}),{itemRole:r}}({role:G,expanded:R}),Q=function(t,o,r){return e.computed((()=>{const l={[t]:!0},a="string"==typeof(null==o?void 0:o.value)?o.value.split(" "):null==o?void 0:o.value;return a&&Array.isArray(a)&&a.forEach((e=>{e&&(l[`${t}--${e}`]=!0)})),r&&Object.keys(r.value).forEach((o=>{l[`${t}--${o}`]=e.unref(r.value[o])})),l}))}("vv-dropdown",J,e.computed((()=>({arrow:v.arrow})))),{focused:X}=r.useFocusWithin(S);function Y(e){return e?[...e.querySelectorAll('a[href], button, input, textarea, select, details, [tabindex]:not([tabindex="-1"])')].filter((e=>!e.hasAttribute("disabled")&&!e.getAttribute("aria-hidden"))):[]}r.onKeyStroke("Escape",(e=>{R.value&&(e.preventDefault(),W())})),r.onKeyStroke("ArrowDown",(t=>{R.value&&X.value&&(t.preventDefault(),e.nextTick((()=>{if(X.value){const e=Y(S.value);if(0===e.length||!document.activeElement)return;const t=e.indexOf(document.activeElement);t<e.length-1?e[t+1].focus({preventScroll:!0}):e[0].focus({preventScroll:!0})}})))})),r.onKeyStroke("ArrowUp",(t=>{R.value&&X.value&&(t.preventDefault(),e.nextTick((()=>{if(X.value){const e=Y(S.value);if(0===e.length||!document.activeElement)return;const t=e.indexOf(document.activeElement);t>0?e[t-1].focus({preventScroll:!0}):e[e.length-1].focus({preventScroll:!0})}})))})),r.onKeyStroke([" ","Enter"],(e=>{const t=e.target;R.value&&X.value&&t&&(null==t||t.click())}));const Z={"before-enter":()=>{d(R.value?"beforeExpand":"beforeCollapse"),d("before-enter")},"after-leave":()=>{d(R.value?"afterExpand":"afterCollapse"),d("after-leave")},enter:()=>{d("enter")},"after-enter":()=>{d("after-enter")},"enter-cancelled":()=>{d("enter-cancelled")},"before-leave":()=>{d("before-leave")},leave:()=>{d("leave")},"leave-cancelled":()=>{d("leave-cancelled")}};return(t,o)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createVNode(e.unref(U),null,{default:e.withCtx((()=>[e.renderSlot(t.$slots,"default",e.normalizeProps(e.guardReactiveProps({init:K,show:T,hide:W,toggle:q,expanded:e.unref(R),aria:e.unref(H)})))])),_:3}),e.createVNode(e.Transition,e.mergeProps({name:t.transitionName},e.toHandlers(Z)),{default:e.withCtx((()=>[e.withDirectives(e.createElementVNode("div",{ref_key:"floatingEl",ref:S,style:e.normalizeStyle(e.unref(A)),class:e.normalizeClass(e.unref(Q))},[v.arrow?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"arrowEl",ref:E,style:e.normalizeStyle(e.unref(D)),class:"vv-dropdown__arrow"},null,4)):e.createCommentVNode("",!0),e.renderSlot(t.$slots,"before",e.normalizeProps(e.guardReactiveProps({expanded:e.unref(R)}))),e.createElementVNode("div",e.mergeProps(e.unref(g),{id:e.unref(b),ref_key:"listEl",ref:k,tabindex:e.unref(R)?void 0:-1,role:e.unref(G),"aria-labelledby":e.unref(M),class:"vv-dropdown__list"}),[e.renderSlot(t.$slots,"items",e.normalizeProps(e.guardReactiveProps({role:e.unref(L)})))],16,h),e.renderSlot(t.$slots,"after",e.normalizeProps(e.guardReactiveProps({expanded:e.unref(R)})))],6),[[e.vShow,e.unref(R)]])])),_:3},16,["name"])],64))}})}));
|