@volverjs/ui-vue 0.0.11 → 0.0.13-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/bin/icons.js +1 -93
  2. package/dist/components/VvAccordion/VvAccordion.es.js +1 -366
  3. package/dist/components/VvAccordion/VvAccordion.vue.d.ts +7 -2
  4. package/dist/components/VvAccordionGroup/VvAccordionGroup.es.js +2 -702
  5. package/dist/components/VvAccordionGroup/VvAccordionGroup.vue.d.ts +5 -2
  6. package/dist/components/VvAction/VvAction.es.js +1 -302
  7. package/dist/components/VvAction/VvAction.umd.js +1 -1
  8. package/dist/components/VvAction/VvAction.vue.d.ts +3 -2
  9. package/dist/components/VvAlert/VvAlert.es.js +1 -527
  10. package/dist/components/VvAlert/VvAlert.vue.d.ts +3 -2
  11. package/dist/components/VvAlertGroup/VvAlertGroup.es.js +1 -730
  12. package/dist/components/VvAlertGroup/VvAlertGroup.vue.d.ts +3 -3
  13. package/dist/components/VvAvatar/VvAvatar.es.js +1 -132
  14. package/dist/components/VvAvatar/VvAvatar.vue.d.ts +2 -2
  15. package/dist/components/VvAvatarGroup/VvAvatarGroup.es.js +1 -250
  16. package/dist/components/VvAvatarGroup/VvAvatarGroup.vue.d.ts +2 -2
  17. package/dist/components/VvBadge/VvBadge.es.js +1 -131
  18. package/dist/components/VvBadge/VvBadge.vue.d.ts +2 -2
  19. package/dist/components/VvBreadcrumb/VvBreadcrumb.es.js +1 -410
  20. package/dist/components/VvBreadcrumb/VvBreadcrumb.umd.js +1 -1
  21. package/dist/components/VvBreadcrumb/VvBreadcrumb.vue.d.ts +2 -2
  22. package/dist/components/VvButton/VvButton.es.js +1 -882
  23. package/dist/components/VvButton/VvButton.umd.js +1 -1
  24. package/dist/components/VvButton/VvButton.vue.d.ts +3 -2
  25. package/dist/components/VvButtonGroup/VvButtonGroup.es.js +1 -214
  26. package/dist/components/VvButtonGroup/VvButtonGroup.vue.d.ts +2 -2
  27. package/dist/components/VvCard/VvCard.es.js +1 -152
  28. package/dist/components/VvCard/VvCard.vue.d.ts +2 -2
  29. package/dist/components/VvCheckbox/VvCheckbox.es.js +1 -741
  30. package/dist/components/VvCheckbox/VvCheckbox.vue.d.ts +2 -2
  31. package/dist/components/VvCheckboxGroup/VvCheckboxGroup.es.js +1 -981
  32. package/dist/components/VvCheckboxGroup/VvCheckboxGroup.vue.d.ts +2 -2
  33. package/dist/components/VvCombobox/VvCombobox.es.js +1 -3463
  34. package/dist/components/VvCombobox/VvCombobox.umd.js +1 -1
  35. package/dist/components/VvCombobox/VvCombobox.vue.d.ts +16 -7
  36. package/dist/components/VvDialog/VvDialog.es.js +1 -317
  37. package/dist/components/VvDialog/VvDialog.vue.d.ts +4 -2
  38. package/dist/components/VvDropdown/VvDropdown.es.js +1 -750
  39. package/dist/components/VvDropdown/VvDropdown.vue.d.ts +14 -2
  40. package/dist/components/VvDropdown/VvDropdownAction.vue.d.ts +2 -2
  41. package/dist/components/VvDropdown/VvDropdownItem.vue.d.ts +2 -2
  42. package/dist/components/VvDropdown/VvDropdownOptgroup.vue.d.ts +11 -4
  43. package/dist/components/VvDropdown/VvDropdownOption.vue.d.ts +2 -2
  44. package/dist/components/VvDropdownAction/VvDropdownAction.es.js +1 -448
  45. package/dist/components/VvDropdownAction/VvDropdownAction.umd.js +1 -1
  46. package/dist/components/VvDropdownItem/VvDropdownItem.es.js +1 -149
  47. package/dist/components/VvDropdownOptgroup/VvDropdownOptgroup.es.js +1 -104
  48. package/dist/components/VvDropdownOptgroup/VvDropdownOptgroup.umd.js +1 -1
  49. package/dist/components/VvDropdownOption/VvDropdownOption.es.js +1 -281
  50. package/dist/components/VvIcon/VvIcon.es.js +1 -143
  51. package/dist/components/VvIcon/VvIcon.vue.d.ts +2 -2
  52. package/dist/components/VvInputFile/VvInputFile.es.js +1 -1704
  53. package/dist/components/VvInputFile/VvInputFile.umd.js +1 -1
  54. package/dist/components/VvInputFile/VvInputFile.vue.d.ts +34 -4
  55. package/dist/components/VvInputFile/index.d.ts +7 -0
  56. package/dist/components/VvInputText/VvInputText.es.js +4 -2790
  57. package/dist/components/VvInputText/VvInputText.umd.js +1 -1
  58. package/dist/components/VvInputText/VvInputText.vue.d.ts +8 -3
  59. package/dist/components/VvNav/VvNav.es.js +1 -438
  60. package/dist/components/VvNav/VvNav.umd.js +1 -1
  61. package/dist/components/VvNav/VvNav.vue.d.ts +2 -2
  62. package/dist/components/VvNav/VvNavItem.vue.d.ts +2 -2
  63. package/dist/components/VvNav/VvNavSeparator.vue.d.ts +1 -1
  64. package/dist/components/VvNavItem/VvNavItem.es.js +1 -337
  65. package/dist/components/VvNavItem/VvNavItem.umd.js +1 -1
  66. package/dist/components/VvNavSeparator/VvNavSeparator.es.js +1 -24
  67. package/dist/components/VvProgress/VvProgress.es.js +1 -163
  68. package/dist/components/VvProgress/VvProgress.vue.d.ts +2 -2
  69. package/dist/components/VvRadio/VvRadio.es.js +1 -661
  70. package/dist/components/VvRadio/VvRadio.vue.d.ts +2 -2
  71. package/dist/components/VvRadioGroup/VvRadioGroup.es.js +1 -901
  72. package/dist/components/VvRadioGroup/VvRadioGroup.vue.d.ts +2 -2
  73. package/dist/components/VvSelect/VvSelect.es.js +1 -1103
  74. package/dist/components/VvSelect/VvSelect.vue.d.ts +11 -7
  75. package/dist/components/VvTab/VvTab.es.js +1 -558
  76. package/dist/components/VvTab/VvTab.umd.js +1 -1
  77. package/dist/components/VvTab/VvTab.vue.d.ts +2 -2
  78. package/dist/components/VvTextarea/VvTextarea.es.js +2 -1989
  79. package/dist/components/VvTextarea/VvTextarea.vue.d.ts +3 -3
  80. package/dist/components/VvTooltip/VvTooltip.es.js +1 -154
  81. package/dist/components/VvTooltip/VvTooltip.vue.d.ts +2 -2
  82. package/dist/components/index.es.js +6 -8558
  83. package/dist/components/index.umd.js +1 -1
  84. package/dist/composables/index.es.js +2 -247
  85. package/dist/composables/index.umd.js +1 -1
  86. package/dist/directives/index.es.js +2 -311
  87. package/dist/directives/index.umd.js +1 -1
  88. package/dist/directives/v-contextmenu.es.js +2 -142
  89. package/dist/directives/v-contextmenu.umd.js +1 -1
  90. package/dist/directives/v-tooltip.es.js +1 -172
  91. package/dist/icons.es.js +1 -39
  92. package/dist/icons.umd.js +1 -1
  93. package/dist/index.es.js +1 -219
  94. package/dist/props/index.d.ts +7 -0
  95. package/dist/resolvers/unplugin.es.js +1 -187
  96. package/dist/stories/AccordionGroup/AccordionGroupSlots.stories.d.ts +2 -2
  97. package/dist/stories/Avatar/Avatar.settings.d.ts +1 -1
  98. package/package.json +47 -40
package/bin/icons.js CHANGED
@@ -1,94 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import fileSystem from "node:fs";
3
- import path from "node:path";
4
- import yargs from "yargs";
5
- import { hideBin } from "yargs/helpers";
6
- import { blankIconSet, SVG, cleanupSVG, parseColors, isEmptyColor, runSVGO } from "@iconify/tools";
7
- import { validateIconSet } from "@iconify/utils";
8
- import chokidar from "chokidar";
9
- function getAllFiles(dirPath, prefix = "iconify", objectFiles = {}) {
10
- const files = fileSystem.readdirSync(dirPath);
11
- files.forEach((file) => {
12
- if (fileSystem.statSync(`${dirPath}/${file}`).isDirectory()) {
13
- objectFiles = getAllFiles(`${dirPath}/${file}`, file, objectFiles);
14
- } else {
15
- if (file.includes(".svg")) {
16
- objectFiles[prefix] ? objectFiles[prefix].push(path.join(dirPath, "/", file)) : objectFiles[prefix] = [path.join(dirPath, "/", file)];
17
- }
18
- }
19
- });
20
- return objectFiles;
21
- }
22
- async function generateIcons(prefix, files, destPath2, options2) {
23
- const iconSet = blankIconSet(prefix);
24
- for (const file of files) {
25
- try {
26
- const content = await fileSystem.promises.readFile(file, {
27
- encoding: "utf-8"
28
- });
29
- const svg = new SVG(content);
30
- await cleanupSVG(svg);
31
- if (!options2?.keepColors) {
32
- await parseColors(svg, {
33
- defaultColor: "currentColor",
34
- callback: (_attr, colorStr, color) => {
35
- return !color || isEmptyColor(color) || colorStr.includes("var(") ? colorStr : "currentColor";
36
- }
37
- });
38
- }
39
- await runSVGO(svg);
40
- const fileName = file.replace(/^.*[\\/]/, "").split(".")[0].replace(/ /g, "-").replace(/[^a-z0-9-]/gi, "");
41
- iconSet.fromSVG(fileName, svg);
42
- } catch (error) {
43
- console.error(error);
44
- }
45
- }
46
- const iconifyJson = iconSet.export();
47
- try {
48
- validateIconSet(iconifyJson);
49
- } catch (error) {
50
- throw new Error(
51
- `Icon set is not valid: ${error?.message}`
52
- );
53
- }
54
- const filename = `${destPath2}/${iconifyJson.prefix}.json`;
55
- fileSystem.mkdirSync(path.dirname(filename), { recursive: true });
56
- fileSystem.writeFileSync(filename, JSON.stringify(iconifyJson));
57
- }
58
- function createIconifyJsonFiles(srcPath2, destPath2, options2) {
59
- const objectFiles = getAllFiles(srcPath2, options2?.prefix);
60
- if (!Object.keys(objectFiles).length) {
61
- console.error(`There are no files in ${srcPath2}`);
62
- } else {
63
- Object.keys(objectFiles).forEach((prefix) => {
64
- generateIcons(prefix, objectFiles[prefix], destPath2, options2);
65
- console.info(`Icons generated in: ${destPath2}/${prefix}.json
66
- `);
67
- });
68
- }
69
- }
70
- const argv = yargs(hideBin(process.argv)).argv;
71
- const srcPath = argv.srcPath;
72
- const destPath = argv.destPath || srcPath;
73
- if (!srcPath || !destPath) {
74
- console.error(
75
- "Please specify the srcPath and destPath with --srcPath and --destPath"
76
- );
77
- process.exit();
78
- }
79
- const options = { prefix: argv.prefix, keepColors: argv.keepColors };
80
- if (argv.watch) {
81
- createIconifyJsonFiles(srcPath, destPath, options);
82
- chokidar.watch(srcPath, {
83
- ignoreInitial: true
84
- }).on("add", () => {
85
- createIconifyJsonFiles(srcPath, destPath, options);
86
- }).on("change", () => {
87
- createIconifyJsonFiles(srcPath, destPath, options);
88
- });
89
- } else {
90
- createIconifyJsonFiles(srcPath, destPath, options);
91
- }
92
- export {
93
- createIconifyJsonFiles
94
- };
2
+ import o from"node:fs";import r from"node:path";import e from"yargs";import{hideBin as t}from"yargs/helpers";import{blankIconSet as n,SVG as i,cleanupSVG as c,parseColors as s,isEmptyColor as a,runSVGO as f}from"@iconify/tools";import{validateIconSet as l}from"@iconify/utils";import p from"chokidar";function h(e,t="iconify",n={}){return o.readdirSync(e).forEach(i=>{o.statSync(`${e}/${i}`).isDirectory()?n=h(`${e}/${i}`,i,n):i.includes(".svg")&&(n[t]?n[t].push(r.join(e,"/",i)):n[t]=[r.join(e,"/",i)])}),n}function d(e,t,p){const d=h(e,p?.prefix);Object.keys(d).length?Object.keys(d).forEach(e=>{!async function(e,t,p,h){const d=n(e);for(const r of t)try{const e=await o.promises.readFile(r,{encoding:"utf-8"}),t=new i(e);await c(t),h?.keepColors||await s(t,{defaultColor:"currentColor",callback:(o,r,e)=>!e||a(e)||r.includes("var(")?r:"currentColor"}),await f(t);const n=r.replace(/^.*[\\/]/,"").split(".")[0].replace(/ /g,"-").replace(/[^a-z0-9-]/gi,"");d.fromSVG(n,t)}catch(g){console.error(g)}const m=d.export();try{l(m)}catch(g){throw new Error(`Icon set is not valid: ${g?.message}`)}const y=`${p}/${m.prefix}.json`;o.mkdirSync(r.dirname(y),{recursive:!0}),o.writeFileSync(y,JSON.stringify(m))}(e,d[e],t,p),console.info(`Icons generated in: ${t}/${e}.json\n`)}):console.error(`There are no files in ${e}`)}const m=e(t(process.argv)).argv,y=m.srcPath,g=m.destPath||y;y&&g||(console.error("Please specify the srcPath and destPath with --srcPath and --destPath"),process.exit());const u={prefix:m.prefix,keepColors:m.keepColors};m.watch?(d(y,g,u),p.watch(y,{ignoreInitial:!0}).on("add",()=>{d(y,g,u)}).on("change",()=>{d(y,g,u)})):d(y,g,u);export{d as createIconifyJsonFiles};
@@ -1,366 +1 @@
1
- import { inject, computed, toRef, unref, defineComponent, useAttrs, useId, toRefs, ref, watch, onBeforeUnmount, createElementBlock, openBlock, normalizeClass, createElementVNode, withModifiers, renderSlot, normalizeProps, guardReactiveProps, createTextVNode, toDisplayString } from "vue";
2
- import { useVModel } from "@vueuse/core";
3
- var StorageType = /* @__PURE__ */ ((StorageType2) => {
4
- StorageType2["local"] = "local";
5
- StorageType2["session"] = "session";
6
- return StorageType2;
7
- })(StorageType || {});
8
- var Side = /* @__PURE__ */ ((Side2) => {
9
- Side2["left"] = "left";
10
- Side2["right"] = "right";
11
- Side2["top"] = "top";
12
- Side2["bottom"] = "bottom";
13
- return Side2;
14
- })(Side || {});
15
- var Position = /* @__PURE__ */ ((Position2) => {
16
- Position2["before"] = "before";
17
- Position2["after"] = "after";
18
- return Position2;
19
- })(Position || {});
20
- var ButtonType = /* @__PURE__ */ ((ButtonType2) => {
21
- ButtonType2["button"] = "button";
22
- ButtonType2["submit"] = "submit";
23
- ButtonType2["reset"] = "reset";
24
- return ButtonType2;
25
- })(ButtonType || {});
26
- var ActionTag = /* @__PURE__ */ ((ActionTag2) => {
27
- ActionTag2["nuxtLink"] = "nuxt-link";
28
- ActionTag2["routerLink"] = "router-link";
29
- ActionTag2["a"] = "a";
30
- ActionTag2["button"] = "button";
31
- return ActionTag2;
32
- })(ActionTag || {});
33
- const INJECTION_KEY_ACCORDION_GROUP = Symbol.for(
34
- "accordionGroup"
35
- );
36
- const ModifiersProps = {
37
- /**
38
- * Component BEM modifiers
39
- */
40
- modifiers: {
41
- type: [String, Array],
42
- default: void 0
43
- }
44
- };
45
- ({
46
- /**
47
- * VvIcon position
48
- */
49
- iconPosition: {
50
- default: Position.before
51
- }
52
- });
53
- ({
54
- /**
55
- * Dropdown placement
56
- */
57
- placement: {
58
- default: Side.bottom
59
- }
60
- });
61
- ({
62
- /**
63
- * Button type
64
- */
65
- type: {
66
- default: ButtonType.button
67
- },
68
- /**
69
- * Default tag for the action
70
- */
71
- defaultTag: {
72
- default: ActionTag.button
73
- }
74
- });
75
- ({
76
- storageType: {
77
- default: StorageType.local
78
- }
79
- });
80
- function useGroupStateInject(groupKey) {
81
- const group = inject(groupKey, void 0);
82
- const isInGroup = computed(() => group !== void 0);
83
- function getGroupOrLocalRef(propName, props, emit) {
84
- const groupPropValue = group?.[propName];
85
- if (groupPropValue) {
86
- return computed({
87
- get() {
88
- return groupPropValue.value;
89
- },
90
- set(value) {
91
- groupPropValue.value = value;
92
- }
93
- });
94
- }
95
- const propRef = toRef(props, propName);
96
- return computed({
97
- get() {
98
- return propRef.value;
99
- },
100
- set(value) {
101
- if (emit) {
102
- emit(`update:${propName}`, value);
103
- }
104
- }
105
- });
106
- }
107
- return {
108
- group,
109
- isInGroup,
110
- getGroupOrLocalRef
111
- };
112
- }
113
- const VvAccordionProps = {
114
- ...ModifiersProps,
115
- /**
116
- * Accordion name
117
- */
118
- name: String,
119
- /**
120
- * Header title
121
- */
122
- title: String,
123
- /**
124
- * Content text
125
- */
126
- content: String,
127
- /**
128
- * (Optional) Defines if item is open. Event "update:modelValue" is emitted on accordion header click
129
- */
130
- modelValue: {
131
- type: Boolean,
132
- default: void 0
133
- },
134
- /**
135
- * If true, the accordion will be disabled
136
- */
137
- disabled: Boolean,
138
- /**
139
- * If true, the accordion will be opened by default
140
- */
141
- not: Boolean
142
- };
143
- const VvAccordionEvents = ["update:modelValue"];
144
- function useGroupProps(props) {
145
- const { group, isInGroup } = useGroupStateInject(
146
- INJECTION_KEY_ACCORDION_GROUP
147
- );
148
- const disabled = computed(
149
- () => Boolean(props.disabled || group?.disabled.value)
150
- );
151
- const modifiers = computed(() => {
152
- let localModifiers = props.modifiers;
153
- let groupModifiers = group?.modifiers.value;
154
- const toReturn = /* @__PURE__ */ new Set();
155
- if (localModifiers) {
156
- if (!Array.isArray(localModifiers)) {
157
- localModifiers = localModifiers.split(" ");
158
- }
159
- localModifiers.forEach((modifier) => toReturn.add(modifier));
160
- }
161
- if (groupModifiers) {
162
- if (!Array.isArray(groupModifiers)) {
163
- groupModifiers = groupModifiers.split(" ");
164
- }
165
- groupModifiers.forEach((modifier) => toReturn.add(modifier));
166
- }
167
- return Array.from(toReturn);
168
- });
169
- return {
170
- // group props
171
- isInGroup,
172
- group,
173
- modifiers,
174
- disabled,
175
- bus: group?.bus
176
- };
177
- }
178
- function useModifiers(prefix, modifiers, others) {
179
- return computed(() => {
180
- const toReturn = {
181
- [prefix]: true
182
- };
183
- const modifiersArray = typeof modifiers?.value === "string" ? modifiers.value.split(" ") : modifiers?.value;
184
- if (modifiersArray) {
185
- if (Array.isArray(modifiersArray)) {
186
- modifiersArray.forEach((modifier) => {
187
- if (modifier) {
188
- toReturn[`${prefix}--${modifier}`] = true;
189
- }
190
- });
191
- }
192
- }
193
- if (others) {
194
- Object.keys(others.value).forEach((key) => {
195
- toReturn[`${prefix}--${key}`] = unref(others.value[key]);
196
- });
197
- }
198
- return toReturn;
199
- });
200
- }
201
- const _hoisted_1 = ["id", "open"];
202
- const _hoisted_2 = ["aria-controls", "aria-expanded"];
203
- const _hoisted_3 = ["aria-hidden"];
204
- const __default__ = {
205
- name: "VvAccordion"
206
- };
207
- const _sfc_main = /* @__PURE__ */ defineComponent({
208
- ...__default__,
209
- props: VvAccordionProps,
210
- emits: VvAccordionEvents,
211
- setup(__props, { expose: __expose, emit: __emit }) {
212
- const props = __props;
213
- const emit = __emit;
214
- const attrs = useAttrs();
215
- const modelValue = useVModel(props, "modelValue", emit);
216
- const accordionName = computed(
217
- () => props.name || attrs?.id || useId()
218
- );
219
- const { title, content, not } = toRefs(props);
220
- const { isInGroup, modifiers, disabled, bus } = useGroupProps(props);
221
- const isExpanded = ref(false);
222
- watch(
223
- modelValue,
224
- (newValue) => {
225
- if (typeof newValue === "boolean") {
226
- isExpanded.value = not.value ? !newValue : newValue;
227
- }
228
- },
229
- { immediate: true }
230
- );
231
- watch(isExpanded, (newValue) => {
232
- modelValue.value = not.value ? !newValue : newValue;
233
- });
234
- bus?.on("toggle", ({ name, value }) => {
235
- if (name !== accordionName.value) {
236
- return;
237
- }
238
- isExpanded.value = value;
239
- });
240
- function onClick() {
241
- if (disabled.value) {
242
- return;
243
- }
244
- if (isInGroup.value) {
245
- bus?.emit("toggle", {
246
- name: accordionName.value,
247
- value: !isExpanded.value
248
- });
249
- return;
250
- }
251
- isExpanded.value = !isExpanded.value;
252
- }
253
- watch(
254
- accordionName,
255
- (newValue, oldValue) => {
256
- if (bus) {
257
- if (oldValue && oldValue !== newValue) {
258
- bus.emit("unregister", { name: oldValue });
259
- }
260
- bus.emit("register", { name: newValue });
261
- }
262
- },
263
- {
264
- immediate: true
265
- }
266
- );
267
- onBeforeUnmount(() => {
268
- if (bus) {
269
- bus.emit("unregister", { name: accordionName.value });
270
- }
271
- });
272
- function expand() {
273
- if (isExpanded.value) {
274
- return;
275
- }
276
- onClick();
277
- }
278
- function collapse() {
279
- if (!isExpanded.value) {
280
- return;
281
- }
282
- onClick();
283
- }
284
- function groupExpand(name) {
285
- if (!bus) {
286
- console.warn(
287
- `[VvAccordion]: You are trying to expand accordion group of "${accordionName.value}" but it is not in a group`
288
- );
289
- return;
290
- }
291
- bus.emit("expand", { name });
292
- }
293
- function groupCollapse(name) {
294
- if (!bus) {
295
- console.warn(
296
- `[VvAccordion]: You are trying to collapse accordion group of "${accordionName.value}" but it is not in a group`
297
- );
298
- return;
299
- }
300
- bus?.emit("collapse", { name });
301
- }
302
- __expose({
303
- isExpanded,
304
- expand,
305
- collapse,
306
- groupExpand,
307
- groupCollapse
308
- });
309
- const bemCssClasses = useModifiers(
310
- "vv-accordion",
311
- modifiers,
312
- computed(() => ({
313
- disabled: disabled.value
314
- }))
315
- );
316
- return (_ctx, _cache) => {
317
- return openBlock(), createElementBlock("details", {
318
- id: unref(accordionName),
319
- class: normalizeClass(unref(bemCssClasses)),
320
- open: unref(isExpanded)
321
- }, [
322
- createElementVNode("summary", {
323
- "aria-controls": unref(accordionName),
324
- "aria-expanded": unref(isExpanded),
325
- class: "vv-accordion__summary",
326
- onClick: _cache[0] || (_cache[0] = withModifiers(($event) => onClick(), ["prevent"]))
327
- }, [
328
- renderSlot(_ctx.$slots, "summary", normalizeProps(guardReactiveProps({
329
- isExpanded: unref(isExpanded),
330
- expand,
331
- collapse,
332
- groupExpand,
333
- groupCollapse
334
- })), () => [
335
- createTextVNode(
336
- toDisplayString(unref(title)),
337
- 1
338
- /* TEXT */
339
- )
340
- ])
341
- ], 8, _hoisted_2),
342
- createElementVNode("div", {
343
- "aria-hidden": !unref(isExpanded),
344
- class: "vv-accordion__content"
345
- }, [
346
- renderSlot(_ctx.$slots, "default", normalizeProps(guardReactiveProps({
347
- isExpanded: unref(isExpanded),
348
- expand,
349
- collapse,
350
- groupExpand,
351
- groupCollapse
352
- })), () => [
353
- createTextVNode(
354
- toDisplayString(unref(content)),
355
- 1
356
- /* TEXT */
357
- )
358
- ])
359
- ], 8, _hoisted_3)
360
- ], 10, _hoisted_1);
361
- };
362
- }
363
- });
364
- export {
365
- _sfc_main as default
366
- };
1
+ import{inject as e,computed as o,toRef as a,unref as t,defineComponent as n,useAttrs as r,useId as i,toRefs as u,ref as l,watch as s,onBeforeUnmount as d,createElementBlock as c,openBlock as p,normalizeClass as v,createElementVNode as m,withModifiers as f,renderSlot as g,normalizeProps as b,guardReactiveProps as y,createTextVNode as x,toDisplayString as A}from"vue";import{useVModel as E}from"@vueuse/core";var $=/* @__PURE__ */(e=>(e.local="local",e.session="session",e))($||{}),h=/* @__PURE__ */(e=>(e.left="left",e.right="right",e.top="top",e.bottom="bottom",e))(h||{}),k=/* @__PURE__ */(e=>(e.before="before",e.after="after",e))(k||{}),G=/* @__PURE__ */(e=>(e.button="button",e.submit="submit",e.reset="reset",e))(G||{}),S=/* @__PURE__ */(e=>(e.nuxtLink="nuxt-link",e.routerLink="router-link",e.a="a",e.button="button",e))(S||{});const V=/* @__PURE__ */Symbol.for("accordionGroup"),B={modifiers:{type:[String,Array],default:void 0}};k.before,h.bottom,G.button,S.button,$.local;const C={...B,name:String,title:String,content:String,modelValue:{type:Boolean,default:void 0},disabled:Boolean,not:Boolean};function I(t){const{group:n,isInGroup:r}=function(t){const n=e(t,void 0),r=o(()=>void 0!==n);return{group:n,isInGroup:r,getGroupOrLocalRef:function(e,t,r){const i=n?.[e];if(i)return o({get:()=>i.value,set(e){i.value=e}});const u=a(t,e);return o({get:()=>u.value,set(o){r&&r(`update:${e}`,o)}})}}}(V),i=o(()=>Boolean(t.disabled||n?.disabled.value)),u=o(()=>{let e=t.modifiers,o=n?.modifiers.value;const a=/* @__PURE__ */new Set;return e&&(Array.isArray(e)||(e=e.split(" ")),e.forEach(e=>a.add(e))),o&&(Array.isArray(o)||(o=o.split(" ")),o.forEach(e=>a.add(e))),Array.from(a)});return{isInGroup:r,group:n,modifiers:u,disabled:i,bus:n?.bus}}const _=["id","open"],w=["aria-controls","aria-expanded"],L=["aria-hidden"],O=/* @__PURE__ */n({name:"VvAccordion",props:C,emits:["update:modelValue"],setup(e,{expose:a,emit:n}){const $=e,h=n,k=r(),G=E($,"modelValue",h),S=o(()=>$.name||k?.id||i()),{title:V,content:B,not:C}=u($),{isInGroup:O,modifiers:Y,disabled:j,bus:R}=I($),q=l(!1);function z(){j.value||(O.value?R?.emit("toggle",{name:S.value,value:!q.value}):q.value=!q.value)}function D(){q.value||z()}function F(){q.value&&z()}function H(e){R?R.emit("expand",{name:e}):console.warn(`[VvAccordion]: You are trying to expand accordion group of "${S.value}" but it is not in a group`)}function J(e){R?R?.emit("collapse",{name:e}):console.warn(`[VvAccordion]: You are trying to collapse accordion group of "${S.value}" but it is not in a group`)}s(G,e=>{"boolean"==typeof e&&(q.value=C.value?!e:e)},{immediate:!0}),s(q,e=>{G.value=C.value?!e:e}),R?.on("toggle",({name:e,value:o})=>{e===S.value&&(q.value=o)}),s(S,(e,o)=>{R&&(o&&o!==e&&R.emit("unregister",{name:o}),R.emit("register",{name:e}))},{immediate:!0}),d(()=>{R&&R.emit("unregister",{name:S.value})}),a({isExpanded:q,expand:D,collapse:F,groupExpand:H,groupCollapse:J});const K=function(e,a,n){return o(()=>{const o={[e]:!0},r="string"==typeof a?.value?a.value.split(" "):a?.value;return r&&Array.isArray(r)&&r.forEach(a=>{a&&(o[`${e}--${a}`]=!0)}),n&&Object.keys(n.value).forEach(a=>{o[`${e}--${a}`]=t(n.value[a])}),o})}("vv-accordion",Y,o(()=>({disabled:j.value})));return(e,o)=>(p(),c("details",{id:t(S),class:v(t(K)),open:t(q)},[m("summary",{"aria-controls":t(S),"aria-expanded":t(q),class:"vv-accordion__summary",onClick:o[0]||(o[0]=f(e=>z(),["prevent"]))},[g(e.$slots,"summary",b(y({isExpanded:t(q),expand:D,collapse:F,groupExpand:H,groupCollapse:J})),()=>[x(A(t(V)),1)])],8,w),m("div",{"aria-hidden":!t(q),class:"vv-accordion__content"},[g(e.$slots,"default",b(y({isExpanded:t(q),expand:D,collapse:F,groupExpand:H,groupCollapse:J})),()=>[x(A(t(B)),1)])],8,L)],10,_))}});export{O as default};
@@ -1,3 +1,5 @@
1
+ declare const _default: typeof __VLS_export;
2
+ export default _default;
1
3
  declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<globalThis.ExtractPropTypes<{
2
4
  name: StringConstructor;
3
5
  title: StringConstructor;
@@ -13,10 +15,15 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<global
13
15
  default: undefined;
14
16
  };
15
17
  }>, {
18
+ /** Whether the accordion is expanded */
16
19
  isExpanded: globalThis.Ref<boolean, boolean>;
20
+ /** Expand the accordion */
17
21
  expand: () => void;
22
+ /** Collapse the accordion */
18
23
  collapse: () => void;
24
+ /** Expand accordions in the same group */
19
25
  groupExpand: (name?: string | string[]) => void;
26
+ /** Collapse accordions in the same group */
20
27
  groupCollapse: (name?: string | string[]) => void;
21
28
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<globalThis.ExtractPropTypes<{
22
29
  name: StringConstructor;
@@ -54,8 +61,6 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<global
54
61
  groupCollapse: (name?: string | string[]) => void;
55
62
  }) => any;
56
63
  }>;
57
- declare const _default: typeof __VLS_export;
58
- export default _default;
59
64
  type __VLS_WithSlots<T, S> = T & {
60
65
  new (): {
61
66
  $slots: S;