@volverjs/ui-vue 0.0.9-beta.4 → 0.0.9-beta.6
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 +2 -2
- package/auto-imports.d.ts +2 -0
- package/dist/components/VvAlertGroup/VvAlertGroup.vue.d.ts +1 -1
- package/dist/components/VvCombobox/VvCombobox.es.js +15 -5
- package/dist/components/VvCombobox/VvCombobox.umd.js +1 -1
- package/dist/components/VvCombobox/VvCombobox.vue.d.ts +22 -10
- package/dist/components/VvCombobox/index.d.ts +15 -6
- package/dist/components/VvDropdown/VvDropdown.es.js +1 -1
- package/dist/components/VvDropdown/VvDropdown.umd.js +1 -1
- package/dist/components/VvDropdown/VvDropdown.vue.d.ts +4 -4
- package/dist/components/index.es.js +15 -5
- package/dist/components/index.umd.js +1 -1
- package/dist/composables/alert/useAlert.d.ts +27 -0
- package/dist/composables/index.d.ts +2 -0
- package/dist/composables/index.es.js +81 -0
- package/dist/composables/index.umd.js +1 -0
- package/dist/constants.d.ts +10 -0
- package/dist/icons.es.js +3 -3
- package/dist/icons.umd.js +1 -1
- package/dist/stories/AccordionGroup/AccordionGroup.stories.d.ts +1 -1
- package/dist/stories/AccordionGroup/AccordionGroupSlots.stories.d.ts +7 -7
- package/dist/stories/AlertGroup/AlertGroupSlots.stories.d.ts +2 -2
- package/dist/stories/AlertGroup/AlertGroupWithComposable.stories.d.ts +6 -0
- package/dist/stories/Combobox/Combobox.settings.d.ts +106 -12
- package/package.json +16 -8
- 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/VvCombobox/VvCombobox.vue +2 -3
- package/src/components/VvCombobox/index.ts +11 -0
- package/src/components/VvDropdown/VvDropdown.vue +1 -1
- package/src/composables/alert/useAlert.ts +103 -0
- package/src/composables/index.ts +3 -0
- package/src/constants.ts +21 -0
- 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/Combobox/Combobox.settings.ts +107 -1
- package/src/types/alert.d.ts +20 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { reactive, computed } from "vue";
|
|
2
|
+
const DEFAULT_ALERT_AUTO_CLOSE = 1e4;
|
|
3
|
+
const DEFAULT_ALERT_MODIFIERS = "info";
|
|
4
|
+
const DEFAULT_ALERT_DISMISSABLE = true;
|
|
5
|
+
const DEFAULT_ALERT_GROUP = "default";
|
|
6
|
+
const DEFAULT_ALERT_INFO_ICON = "information";
|
|
7
|
+
const DEFAULT_ALERT_SUCCESS_ICON = "check-circle";
|
|
8
|
+
const DEFAULT_ALERT_WARNING_ICON = "warning";
|
|
9
|
+
const DEFAULT_ALERT_DANGER_ICON = "error";
|
|
10
|
+
const DefaultAlertIconMap = /* @__PURE__ */ new Map([
|
|
11
|
+
["success", DEFAULT_ALERT_SUCCESS_ICON],
|
|
12
|
+
["info", DEFAULT_ALERT_INFO_ICON],
|
|
13
|
+
["warning", DEFAULT_ALERT_WARNING_ICON],
|
|
14
|
+
["danger", DEFAULT_ALERT_DANGER_ICON]
|
|
15
|
+
]);
|
|
16
|
+
const groups = reactive(
|
|
17
|
+
/* @__PURE__ */ new Map([
|
|
18
|
+
[DEFAULT_ALERT_GROUP, /* @__PURE__ */ new Map()]
|
|
19
|
+
])
|
|
20
|
+
);
|
|
21
|
+
const useAlert = () => {
|
|
22
|
+
const addAlert = ({
|
|
23
|
+
id = crypto.randomUUID(),
|
|
24
|
+
group = DEFAULT_ALERT_GROUP,
|
|
25
|
+
title,
|
|
26
|
+
icon = DEFAULT_ALERT_INFO_ICON,
|
|
27
|
+
content,
|
|
28
|
+
footer,
|
|
29
|
+
modifiers = DEFAULT_ALERT_MODIFIERS,
|
|
30
|
+
dismissable = DEFAULT_ALERT_DISMISSABLE,
|
|
31
|
+
autoClose = DEFAULT_ALERT_AUTO_CLOSE
|
|
32
|
+
} = {}) => {
|
|
33
|
+
if (!groups.has(group)) {
|
|
34
|
+
groups.set(group, /* @__PURE__ */ new Map());
|
|
35
|
+
}
|
|
36
|
+
const groupMap = groups.get(group);
|
|
37
|
+
const normalizedModifiers = typeof modifiers === "string" ? modifiers.split(" ") : modifiers;
|
|
38
|
+
if (!icon) {
|
|
39
|
+
const alertModifier = normalizedModifiers.find(
|
|
40
|
+
(modifier) => DefaultAlertIconMap.has(modifier)
|
|
41
|
+
);
|
|
42
|
+
if (alertModifier) {
|
|
43
|
+
icon = DefaultAlertIconMap.get(alertModifier);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
groupMap == null ? void 0 : groupMap.set(id.toString(), {
|
|
47
|
+
id,
|
|
48
|
+
group,
|
|
49
|
+
title,
|
|
50
|
+
icon,
|
|
51
|
+
content,
|
|
52
|
+
footer,
|
|
53
|
+
modifiers,
|
|
54
|
+
dismissable,
|
|
55
|
+
autoClose,
|
|
56
|
+
timestamp: Date.now()
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
const removeAlert = (id, group = DEFAULT_ALERT_GROUP) => {
|
|
60
|
+
const groupMap = groups.get(group);
|
|
61
|
+
groupMap == null ? void 0 : groupMap.delete(id.toString());
|
|
62
|
+
};
|
|
63
|
+
const getAlerts = (group = DEFAULT_ALERT_GROUP) => {
|
|
64
|
+
return computed(() => {
|
|
65
|
+
const groupMap = groups.get(group);
|
|
66
|
+
return groupMap && groupMap instanceof Map ? Array.from(groupMap == null ? void 0 : groupMap.values()).sort(
|
|
67
|
+
(a, b) => a.timestamp - b.timestamp
|
|
68
|
+
) : [];
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
return {
|
|
72
|
+
groups,
|
|
73
|
+
alerts: getAlerts(),
|
|
74
|
+
addAlert,
|
|
75
|
+
removeAlert,
|
|
76
|
+
getAlerts
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
export {
|
|
80
|
+
useAlert
|
|
81
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vue")):"function"==typeof define&&define.amd?define(["exports","vue"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).composables={},e.vue)}(this,(function(e,t){"use strict";const o="default",n="information",i=new Map([["success","check-circle"],["info",n],["warning","warning"],["danger","error"]]),s=t.reactive(new Map([[o,new Map]]));e.useAlert=()=>{const e=(e=o)=>t.computed((()=>{const t=s.get(e);return t&&t instanceof Map?Array.from(null==t?void 0:t.values()).sort(((e,t)=>e.timestamp-t.timestamp)):[]}));return{groups:s,alerts:e(),addAlert:({id:e=crypto.randomUUID(),group:t=o,title:r,icon:a=n,content:l,footer:u,modifiers:c="info",dismissable:f=true,autoClose:d=1e4}={})=>{s.has(t)||s.set(t,new Map);const p=s.get(t),m="string"==typeof c?c.split(" "):c;if(!a){const e=m.find((e=>i.has(e)));e&&(a=i.get(e))}null==p||p.set(e.toString(),{id:e,group:t,title:r,icon:a,content:l,footer:u,modifiers:c,dismissable:f,autoClose:d,timestamp:Date.now()})},removeAlert:(e,t=o)=>{const n=s.get(t);null==n||n.delete(e.toString())},getAlerts:e}},Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}));
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { InjectionKey, Ref } from 'vue';
|
|
2
2
|
import type { Emitter } from 'mitt';
|
|
3
3
|
import type { Volver } from './Volver';
|
|
4
|
+
import type { AlertModifiers } from './types/alert';
|
|
4
5
|
export declare const DEFAULT_ICONIFY_PROVIDER = "vv";
|
|
5
6
|
export declare enum Side {
|
|
6
7
|
left = "left",
|
|
@@ -86,3 +87,12 @@ export declare const INJECTION_KEY_ALERT_GROUP: InjectionKey<{
|
|
|
86
87
|
close: string;
|
|
87
88
|
}> | undefined;
|
|
88
89
|
}>;
|
|
90
|
+
export declare const DEFAULT_ALERT_AUTO_CLOSE = 10000;
|
|
91
|
+
export declare const DEFAULT_ALERT_MODIFIERS = "info";
|
|
92
|
+
export declare const DEFAULT_ALERT_DISMISSABLE = true;
|
|
93
|
+
export declare const DEFAULT_ALERT_GROUP = "default";
|
|
94
|
+
export declare const DEFAULT_ALERT_INFO_ICON = "information";
|
|
95
|
+
export declare const DEFAULT_ALERT_SUCCESS_ICON = "check-circle";
|
|
96
|
+
export declare const DEFAULT_ALERT_WARNING_ICON = "warning";
|
|
97
|
+
export declare const DEFAULT_ALERT_DANGER_ICON = "error";
|
|
98
|
+
export declare const DefaultAlertIconMap: Map<AlertModifiers, string>;
|
package/dist/icons.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const prefix$2 = "normal";
|
|
2
|
-
const lastModified$2 =
|
|
2
|
+
const lastModified$2 = 1686134214;
|
|
3
3
|
const icons$3 = {
|
|
4
4
|
add: {
|
|
5
5
|
body: '<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M4 12h16m-8-8v16"/>'
|
|
@@ -614,7 +614,7 @@ const normal = {
|
|
|
614
614
|
height: height$1
|
|
615
615
|
};
|
|
616
616
|
const prefix$1 = "detailed";
|
|
617
|
-
const lastModified$1 =
|
|
617
|
+
const lastModified$1 = 1686134214;
|
|
618
618
|
const icons$2 = {
|
|
619
619
|
add: {
|
|
620
620
|
body: '<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M4 15.999h24m-12-12v24"/>'
|
|
@@ -1227,7 +1227,7 @@ const detailed = {
|
|
|
1227
1227
|
height
|
|
1228
1228
|
};
|
|
1229
1229
|
const prefix = "simple";
|
|
1230
|
-
const lastModified =
|
|
1230
|
+
const lastModified = 1686134214;
|
|
1231
1231
|
const icons$1 = {
|
|
1232
1232
|
add: {
|
|
1233
1233
|
body: '<path fill="none" stroke="currentColor" stroke-linecap="round" d="M.5 8h15M8 .5v15"/>'
|