@volverjs/ui-vue 0.0.9-beta.4 → 0.0.9-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,13 +1,13 @@
1
1
  <div align="center">
2
2
 
3
- [![volverjs](.storybook/static/volverjs-beta.svg)](https://volverjs.github.io/ui-vue)
3
+ [![volverjs](.storybook/static/volverjs-ui-vue.svg)](https://volverjs.github.io/ui-vue)
4
4
 
5
5
  ## @volverjs/ui-vue
6
6
 
7
7
  `vue` `components` `component-library` `design-system` \
8
8
  `input` `button` `accordion` `badge` `combobox` `breadcrumb` `dialog`\
9
9
  `checkbox` `radio` `textarea` `badge`
10
-
10
+
11
11
  [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=volverjs_ui-vue&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=volverjs_ui-vue) [![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=volverjs_ui-vue&metric=sqale_rating)](https://sonarcloud.io/summary/new_code?id=volverjs_ui-vue) [![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=volverjs_ui-vue&metric=security_rating)](https://sonarcloud.io/summary/new_code?id=volverjs_ui-vue) [![Depfu](https://badges.depfu.com/badges/4b0c9d8ea210e93aa7a181e7252716f2/status.svg)](https://depfu.com) [![Depfu](https://badges.depfu.com/badges/4b0c9d8ea210e93aa7a181e7252716f2/overview.svg)](https://depfu.com/github/volverjs/ui-vue?project_id=38572)
12
12
 
13
13
  <br>
package/auto-imports.d.ts CHANGED
@@ -7,6 +7,7 @@ declare global {
7
7
  const EffectScope: typeof import('vue')['EffectScope']
8
8
  const asyncComputed: typeof import('@vueuse/core')['asyncComputed']
9
9
  const autoResetRef: typeof import('@vueuse/core')['autoResetRef']
10
+ const composables: typeof import('./src/composables/index')['default']
10
11
  const computed: typeof import('vue')['computed']
11
12
  const computedAsync: typeof import('@vueuse/core')['computedAsync']
12
13
  const computedEager: typeof import('@vueuse/core')['computedEager']
@@ -115,6 +116,7 @@ declare global {
115
116
  const unrefElement: typeof import('@vueuse/core')['unrefElement']
116
117
  const until: typeof import('@vueuse/core')['until']
117
118
  const useActiveElement: typeof import('@vueuse/core')['useActiveElement']
119
+ const useAlert: typeof import('./src/composables/index')['useAlert']
118
120
  const useAnimate: typeof import('@vueuse/core')['useAnimate']
119
121
  const useArrayDifference: typeof import('@vueuse/core')['useArrayDifference']
120
122
  const useArrayEvery: typeof import('@vueuse/core')['useArrayEvery']
@@ -0,0 +1,27 @@
1
+ import type { Alert } from '@/types/alert';
2
+ /**
3
+ * @description Composable to access alert groups, alerts and functions to add, remove and get alerts by group.
4
+ * @example
5
+ * const { groups, alerts, addAlert, removeAlert, getAlerts } = useAlert()
6
+ * addAlert({
7
+ * title: 'Success!',
8
+ * modifiers: 'success',
9
+ * })
10
+ *
11
+ * `<vv-alert-group :items="alerts" :onClose="removeAlert" />`
12
+ *
13
+ * @returns {
14
+ * alerts: ComputedRef<Alert[]> reactive list of alerts default group,
15
+ * groups: ReactiveRef<Map<string, Map<string, Alert>>>,
16
+ * addAlert: Function to add alert,
17
+ * removeAlert: Function to remove alert,
18
+ * getAlerts: Function to get alerts by group
19
+ * }
20
+ */
21
+ export declare const useAlert: () => {
22
+ groups: Map<string, Map<string, Alert>>;
23
+ alerts: globalThis.ComputedRef<Alert[]>;
24
+ addAlert: ({ id, group, title, icon, content, footer, modifiers, dismissable, autoClose, }?: Partial<Alert>) => void;
25
+ removeAlert: (id: string | number, group?: string) => void;
26
+ getAlerts: (group?: string) => globalThis.ComputedRef<Alert[]>;
27
+ };
@@ -0,0 +1,2 @@
1
+ import { useAlert } from './alert/useAlert';
2
+ export { useAlert };
@@ -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"})}));
@@ -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 = 1685977703;
2
+ const lastModified$2 = 1686056093;
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 = 1685977702;
617
+ const lastModified$1 = 1686056093;
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 = 1685977703;
1230
+ const lastModified = 1686056093;
1231
1231
  const icons$1 = {
1232
1232
  add: {
1233
1233
  body: '<path fill="none" stroke="currentColor" stroke-linecap="round" d="M.5 8h15M8 .5v15"/>'