@volverjs/ui-vue 0.0.10-beta.28 → 0.0.10-beta.29

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 (61) hide show
  1. package/README.md +8 -7
  2. package/dist/components/VvAlert/VvAlert.es.js +13 -11
  3. package/dist/components/VvAlert/VvAlert.umd.js +1 -1
  4. package/dist/components/VvAlert/VvAlert.vue.d.ts +10 -10
  5. package/dist/components/VvAlert/index.d.ts +12 -8
  6. package/dist/components/VvAlertGroup/VvAlertGroup.es.js +13 -2
  7. package/dist/components/VvAlertGroup/VvAlertGroup.umd.js +1 -1
  8. package/dist/components/VvAlertGroup/VvAlertGroup.vue.d.ts +3 -3
  9. package/dist/components/VvAlertGroup/index.d.ts +2 -14
  10. package/dist/components/VvCombobox/VvCombobox.es.js +1 -0
  11. package/dist/components/VvCombobox/VvCombobox.umd.js +1 -1
  12. package/dist/components/VvDropdownOption/VvDropdownOption.es.js +1 -0
  13. package/dist/components/VvDropdownOption/VvDropdownOption.umd.js +1 -1
  14. package/dist/components/VvInputText/VvInputText.es.js +1 -0
  15. package/dist/components/VvInputText/VvInputText.umd.js +1 -1
  16. package/dist/components/index.es.js +14 -2
  17. package/dist/components/index.umd.js +1 -1
  18. package/dist/composables/alert/useAlert.d.ts +80 -18
  19. package/dist/composables/index.es.js +3 -2
  20. package/dist/composables/index.umd.js +1 -1
  21. package/dist/constants.d.ts +5 -2
  22. package/dist/icons.es.js +3 -3
  23. package/dist/icons.umd.js +1 -1
  24. package/dist/stories/AccordionGroup/AccordionGroupSlots.stories.d.ts +2 -2
  25. package/dist/test/expect.d.ts +1 -1
  26. package/dist/types/alert.d.ts +9 -7
  27. package/package.json +24 -34
  28. package/src/assets/icons/detailed.json +1 -1
  29. package/src/assets/icons/normal.json +1 -1
  30. package/src/assets/icons/simple.json +1 -1
  31. package/src/components/VvAlert/index.ts +13 -6
  32. package/src/components/VvAlertGroup/index.ts +3 -16
  33. package/src/components/VvDropdown/VvDropdownOption.vue +1 -0
  34. package/src/composables/alert/useAlert.ts +12 -9
  35. package/src/constants.ts +7 -2
  36. package/src/stories/Accordion/Accordion.test.ts +1 -1
  37. package/src/stories/AccordionGroup/AccordionGroup.test.ts +1 -1
  38. package/src/stories/Alert/Alert.test.ts +1 -1
  39. package/src/stories/AlertGroup/AlertGroup.test.ts +1 -1
  40. package/src/stories/Avatar/Avatar.test.ts +1 -1
  41. package/src/stories/AvatarGroup/AvatarGroup.test.ts +1 -1
  42. package/src/stories/Badge/Badge.test.ts +1 -1
  43. package/src/stories/Button/Button.test.ts +1 -1
  44. package/src/stories/ButtonGroup/ButtonGroup.test.ts +1 -1
  45. package/src/stories/Card/Card.test.ts +1 -1
  46. package/src/stories/Checkbox/Checkbox.test.ts +1 -1
  47. package/src/stories/CheckboxGroup/CheckboxGroup.test.ts +1 -1
  48. package/src/stories/Combobox/Combobox.test.ts +1 -1
  49. package/src/stories/Dialog/Dialog.test.ts +2 -2
  50. package/src/stories/Dropdown/Dropdown.test.ts +1 -1
  51. package/src/stories/InputText/InputText.test.ts +1 -1
  52. package/src/stories/Nav/Nav.test.ts +1 -1
  53. package/src/stories/Progress/Progress.test.ts +1 -1
  54. package/src/stories/Radio/Radio.test.ts +1 -1
  55. package/src/stories/RadioGroup/RadioGroup.test.ts +1 -1
  56. package/src/stories/Select/Select.test.ts +1 -1
  57. package/src/stories/Tab/Tab.test.ts +1 -1
  58. package/src/stories/Textarea/Textarea.test.ts +1 -1
  59. package/src/stories/Tooltip/Tooltip.test.ts +1 -1
  60. package/src/test/expect.ts +2 -4
  61. package/src/types/alert.ts +11 -7
@@ -1,11 +1,18 @@
1
- import { IconProps, IdProps, ModifiersProps } from '@/props'
2
- import type { ExtractPropTypes, PropType } from 'vue'
3
- import { withModifiers } from 'vue'
1
+ import { type ExtractPropTypes, type PropType, withModifiers } from 'vue'
2
+ import { AlertRole } from '@/constants'
3
+ import { IconProps, IdProps } from '@/props'
4
+ import type { AlertModifier } from '@/types'
4
5
 
5
6
  export const VvAlertProps = {
6
7
  ...IdProps,
7
- ...ModifiersProps,
8
8
  ...IconProps,
9
+ /**
10
+ * Component BEM modifiers
11
+ */
12
+ modifiers: {
13
+ type: [String, Array] as PropType<AlertModifier | AlertModifier[]>,
14
+ default: undefined,
15
+ },
9
16
  /**
10
17
  * The alert is dismissable
11
18
  * @default false
@@ -69,8 +76,8 @@ export const VvAlertProps = {
69
76
  * @see https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/Alertdialog_role
70
77
  */
71
78
  role: {
72
- type: String as PropType<'alert' | 'alertdialog'>,
73
- default: 'alert',
79
+ type: String as PropType<`${AlertRole}`>,
80
+ default: AlertRole.alert,
74
81
  },
75
82
  }
76
83
 
@@ -1,19 +1,6 @@
1
- import { ModifiersProps } from '@/props'
2
1
  import type { ExtractPropTypes } from 'vue'
3
- import type { VvIconProps } from '../VvIcon'
4
-
5
- export type AlertItem = {
6
- id: string | number
7
- title?: string
8
- icon?: string | VvIconProps
9
- content?: string
10
- footer?: string
11
- modifiers?: string | string[]
12
- dismissable?: boolean
13
- autoClose?: number
14
- closeLabel?: string
15
- role?: 'alert' | 'alertdialog'
16
- }
2
+ import type { Alert } from '@/types'
3
+ import { ModifiersProps } from '@/props'
17
4
 
18
5
  export const VvAlertGroupProps = {
19
6
  ...ModifiersProps,
@@ -22,7 +9,7 @@ export const VvAlertGroupProps = {
22
9
  required: true,
23
10
  },
24
11
  items: {
25
- type: Array as PropType<AlertItem[]>,
12
+ type: Array as PropType<Alert[]>,
26
13
  default: () => [],
27
14
  },
28
15
  stack: {
@@ -33,6 +33,7 @@
33
33
  if (!props.disabled) {
34
34
  return props.selectHintLabel
35
35
  }
36
+ return ''
36
37
  })
37
38
  </script>
38
39
 
@@ -6,11 +6,13 @@ import {
6
6
  DEFAULT_ALERT_INFO_ICON,
7
7
  DefaultAlertIconMap,
8
8
  } from '@/constants'
9
- import type { Alert, AlertModifiers } from '@/types/alert'
9
+ import type { Alert, AlertModifier } from '@/types/alert'
10
+
11
+ type AlertInGroup = Alert & { timestamp: number; group: string }
10
12
 
11
13
  const groups = reactive(
12
- new Map<string, Map<string, Alert>>([
13
- [DEFAULT_ALERT_GROUP, new Map<string, Alert>()],
14
+ new Map<string, Map<string, AlertInGroup>>([
15
+ [DEFAULT_ALERT_GROUP, new Map<string, AlertInGroup>()],
14
16
  ]),
15
17
  )
16
18
 
@@ -45,10 +47,11 @@ export const useAlert = () => {
45
47
  modifiers = DEFAULT_ALERT_MODIFIERS,
46
48
  dismissable = DEFAULT_ALERT_DISMISSABLE,
47
49
  autoClose = DEFAULT_ALERT_AUTO_CLOSE,
48
- } = {} as Partial<Alert>,
50
+ timestamp = Date.now(),
51
+ } = {} as Partial<AlertInGroup>,
49
52
  ) => {
50
53
  if (!groups.has(group)) {
51
- groups.set(group, new Map<string, Alert>())
54
+ groups.set(group, new Map<string, AlertInGroup>())
52
55
  }
53
56
  const groupMap = groups.get(group)
54
57
  const normalizedModifiers =
@@ -56,8 +59,8 @@ export const useAlert = () => {
56
59
 
57
60
  if (!icon) {
58
61
  const alertModifier = normalizedModifiers.find((modifier) =>
59
- DefaultAlertIconMap.has(modifier as AlertModifiers),
60
- ) as AlertModifiers | undefined
62
+ DefaultAlertIconMap.has(modifier as AlertModifier),
63
+ ) as AlertModifier | undefined
61
64
 
62
65
  if (alertModifier) {
63
66
  icon = DefaultAlertIconMap.get(alertModifier) as string
@@ -73,7 +76,7 @@ export const useAlert = () => {
73
76
  modifiers,
74
77
  dismissable,
75
78
  autoClose,
76
- timestamp: Date.now(),
79
+ timestamp,
77
80
  })
78
81
  }
79
82
 
@@ -88,7 +91,7 @@ export const useAlert = () => {
88
91
  return groupMap && groupMap instanceof Map
89
92
  ? Array.from(groupMap?.values()).sort(
90
93
  (a, b) => a.timestamp - b.timestamp,
91
- )
94
+ )
92
95
  : []
93
96
  })
94
97
  }
package/src/constants.ts CHANGED
@@ -1,12 +1,12 @@
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'
5
4
  import type {
6
5
  AccordionGroupState,
7
6
  InputGroupState,
8
7
  ButtonGroupState,
9
8
  AlertGroupState,
9
+ AlertModifier,
10
10
  } from './types'
11
11
 
12
12
  export const DEFAULT_ICONIFY_PROVIDER = 'vv'
@@ -73,6 +73,11 @@ export enum DropdownItemRole {
73
73
  presentation = 'presentation',
74
74
  }
75
75
 
76
+ export enum AlertRole {
77
+ alert = 'alert',
78
+ alertdialog = 'alertdialog',
79
+ }
80
+
76
81
  // volver
77
82
  export const INJECTION_KEY_VOLVER = Symbol.for('volver') as InjectionKey<Volver>
78
83
 
@@ -140,7 +145,7 @@ export const DEFAULT_ALERT_INFO_ICON = 'information'
140
145
  export const DEFAULT_ALERT_SUCCESS_ICON = 'check-circle'
141
146
  export const DEFAULT_ALERT_WARNING_ICON = 'warning'
142
147
  export const DEFAULT_ALERT_DANGER_ICON = 'error'
143
- export const DefaultAlertIconMap = new Map<AlertModifiers, string>([
148
+ export const DefaultAlertIconMap = new Map<AlertModifier, string>([
144
149
  ['success', DEFAULT_ALERT_SUCCESS_ICON],
145
150
  ['info', DEFAULT_ALERT_INFO_ICON],
146
151
  ['warning', DEFAULT_ALERT_WARNING_ICON],
@@ -1,7 +1,7 @@
1
1
  import type { PlayAttributes } from '@/test/types'
2
2
  import { expect } from '@/test/expect'
3
3
  import { sleep } from '@/test/sleep'
4
- import { within } from '@storybook/testing-library'
4
+ import { within } from '@storybook/test'
5
5
 
6
6
  export async function defaultTest({ canvasElement, args }: PlayAttributes) {
7
7
  const element = (await within(canvasElement).findByTestId(
@@ -1,7 +1,7 @@
1
1
  import type { PlayAttributes } from '@/test/types'
2
2
  import { expect } from '@/test/expect'
3
3
  import { sleep } from '@/test/sleep'
4
- import { within } from '@storybook/testing-library'
4
+ import { within } from '@storybook/test'
5
5
 
6
6
  export async function defaultTest({ canvasElement, args }: PlayAttributes) {
7
7
  const element = (await within(canvasElement).findByTestId(
@@ -1,6 +1,6 @@
1
1
  import type { PlayAttributes } from '@/test/types'
2
2
  import { expect } from '@/test/expect'
3
- import { within } from '@storybook/testing-library'
3
+ import { within } from '@storybook/test'
4
4
 
5
5
  export async function defaultTest({ canvasElement, args }: PlayAttributes) {
6
6
  const element = (await within(canvasElement).findByTestId(
@@ -1,6 +1,6 @@
1
1
  import type { PlayAttributes } from '@/test/types'
2
2
  import { expect } from '@/test/expect'
3
- import { within } from '@storybook/testing-library'
3
+ import { within } from '@storybook/test'
4
4
 
5
5
  export async function defaultTest({ canvasElement, args }: PlayAttributes) {
6
6
  const element = (await within(canvasElement).findByTestId(
@@ -1,6 +1,6 @@
1
1
  import type { PlayAttributes } from '@/test/types'
2
2
  import { expect } from '@/test/expect'
3
- import { within } from '@storybook/testing-library'
3
+ import { within } from '@storybook/test'
4
4
 
5
5
  export async function defaultTest({ canvasElement, args }: PlayAttributes) {
6
6
  const element = (await within(canvasElement).findByTestId(
@@ -1,6 +1,6 @@
1
1
  import type { PlayAttributes } from '@/test/types'
2
2
  import { expect } from '@/test/expect'
3
- import { within } from '@storybook/testing-library'
3
+ import { within } from '@storybook/test'
4
4
 
5
5
  export async function defaultTest({ canvasElement, args }: PlayAttributes) {
6
6
  const element = (await within(canvasElement).findByTestId(
@@ -1,5 +1,5 @@
1
1
  import type { PlayAttributes } from '@/test/types'
2
- import { within } from '@storybook/testing-library'
2
+ import { within } from '@storybook/test'
3
3
  import { expect } from '@/test/expect'
4
4
 
5
5
  export const defaultTest = async ({ canvasElement, args }: PlayAttributes) => {
@@ -1,5 +1,5 @@
1
1
  import type { PlayAttributes } from '@/test/types'
2
- import { within } from '@storybook/testing-library'
2
+ import { within } from '@storybook/test'
3
3
  import { expect } from '@/test/expect'
4
4
 
5
5
  export async function defaultTest(
@@ -1,6 +1,6 @@
1
1
  import type { PlayAttributes } from '@/test/types'
2
2
  import { expect } from '@/test/expect'
3
- import { within } from '@storybook/testing-library'
3
+ import { within } from '@storybook/test'
4
4
 
5
5
  export async function defaultTest(
6
6
  { canvasElement, args }: PlayAttributes = {} as PlayAttributes,
@@ -1,6 +1,6 @@
1
1
  import type { PlayAttributes } from '@/test/types'
2
2
  import { expect } from '@/test/expect'
3
- import { within } from '@storybook/testing-library'
3
+ import { within } from '@storybook/test'
4
4
 
5
5
  export async function defaulTest({ canvasElement, args }: PlayAttributes) {
6
6
  const element = (await within(canvasElement).findByTestId(
@@ -1,7 +1,7 @@
1
1
  import type { PlayAttributes } from '@/test/types'
2
2
  import { expect } from '@/test/expect'
3
3
  import { sleep } from '@/test/sleep'
4
- import { within } from '@storybook/testing-library'
4
+ import { within } from '@storybook/test'
5
5
 
6
6
  export async function defaultTest({ canvasElement, args }: PlayAttributes) {
7
7
  const element = (await within(canvasElement).findByTestId(
@@ -1,7 +1,7 @@
1
1
  import type { PlayAttributes } from '@/test/types'
2
2
  import { expect } from '@/test/expect'
3
3
  import { sleep } from '@/test/sleep'
4
- import { within } from '@storybook/testing-library'
4
+ import { within } from '@storybook/test'
5
5
  import { getOptionValue } from '@/test/options'
6
6
 
7
7
  export async function defaultTest({ canvasElement, args }: PlayAttributes) {
@@ -1,6 +1,6 @@
1
1
  import type { PlayAttributes } from '@/test/types'
2
2
  import { expect } from '@/test/expect'
3
- import { within } from '@storybook/testing-library'
3
+ import { within } from '@storybook/test'
4
4
  import { sleep } from '@/test/sleep'
5
5
  import { defaultTest as selectDefaultTest } from '@/stories/Select/Select.test'
6
6
 
@@ -1,7 +1,7 @@
1
1
  import type { PlayAttributes } from '@/test/types'
2
2
  import { expect } from '@/test/expect'
3
- import { userEvent } from '@storybook/testing-library'
4
- import { within } from '@storybook/testing-library'
3
+ import { userEvent } from '@storybook/test'
4
+ import { within } from '@storybook/test'
5
5
  import { sleep } from '@/test/sleep'
6
6
 
7
7
  export async function defaultTest(
@@ -1,7 +1,7 @@
1
1
  import type { PlayAttributes } from '@/test/types'
2
2
  import { expect } from '@/test/expect'
3
3
  import { sleep } from '@/test/sleep'
4
- import { within } from '@storybook/testing-library'
4
+ import { within } from '@storybook/test'
5
5
 
6
6
  export async function defaultTest({ canvasElement }: PlayAttributes) {
7
7
  const wrapper = (await within(canvasElement).findByTestId(
@@ -1,7 +1,7 @@
1
1
  import type { PlayAttributes } from '@/test/types'
2
2
  import { expect } from '@/test/expect'
3
3
  import { sleep } from '@/test/sleep'
4
- import { within, userEvent } from '@storybook/testing-library'
4
+ import { within, userEvent } from '@storybook/test'
5
5
  import { INPUT_TYPES, type InputType } from '@/components/VvInputText'
6
6
 
7
7
  const valueByType = (type: InputType, mask?: string, id?: string) => {
@@ -1,6 +1,6 @@
1
1
  import type { PlayAttributes } from '@/test/types'
2
2
  import { expect } from '@/test/expect'
3
- import { within } from '@storybook/testing-library'
3
+ import { within } from '@storybook/test'
4
4
 
5
5
  export async function defaultTest({ canvasElement, args }: PlayAttributes) {
6
6
  const element = (await within(canvasElement).findByTestId(
@@ -1,6 +1,6 @@
1
1
  import { expect } from '@/test/expect'
2
2
  import type { PlayAttributes } from '@/test/types'
3
- import { within } from '@storybook/testing-library'
3
+ import { within } from '@storybook/test'
4
4
 
5
5
  export async function defaultTest({ canvasElement }: PlayAttributes) {
6
6
  const progress = await within(canvasElement).findByRole('progressbar')
@@ -1,7 +1,7 @@
1
1
  import type { PlayAttributes } from '@/test/types'
2
2
  import { expect } from '@/test/expect'
3
3
  import { sleep } from '@/test/sleep'
4
- import { within } from '@storybook/testing-library'
4
+ import { within } from '@storybook/test'
5
5
 
6
6
  export async function defaultTest({ canvasElement, args }: PlayAttributes) {
7
7
  const element = (await within(canvasElement).findByTestId(
@@ -1,7 +1,7 @@
1
1
  import type { PlayAttributes } from '@/test/types'
2
2
  import { expect } from '@/test/expect'
3
3
  import { sleep } from '@/test/sleep'
4
- import { within } from '@storybook/testing-library'
4
+ import { within } from '@storybook/test'
5
5
  import { getOptionValue } from '@/test/options'
6
6
 
7
7
  export async function defaultTest({ canvasElement, args }: PlayAttributes) {
@@ -1,5 +1,5 @@
1
1
  import type { PlayAttributes } from '@/test/types'
2
- import { within } from '@storybook/testing-library'
2
+ import { within } from '@storybook/test'
3
3
  import { expect } from '@/test/expect'
4
4
  import { sleep } from '@/test/sleep'
5
5
 
@@ -1,6 +1,6 @@
1
1
  import type { PlayAttributes } from '@/test/types'
2
2
  import { expect } from '@/test/expect'
3
- import { within } from '@storybook/testing-library'
3
+ import { within } from '@storybook/test'
4
4
 
5
5
  export async function defaultTest({ canvasElement, args }: PlayAttributes) {
6
6
  const element = (await within(canvasElement).findByTestId(
@@ -1,7 +1,7 @@
1
1
  import type { PlayAttributes } from '@/test/types'
2
2
  import { expect } from '@/test/expect'
3
3
  import { sleep } from '@/test/sleep'
4
- import { within, userEvent } from '@storybook/testing-library'
4
+ import { within, userEvent } from '@storybook/test'
5
5
 
6
6
  export async function defaultTest({ canvasElement, args }: PlayAttributes) {
7
7
  const element = (await within(canvasElement).findByTestId(
@@ -1,7 +1,7 @@
1
1
  import type { PlayAttributes } from '@/test/types'
2
2
  import { expect } from '@/test/expect'
3
3
  import { sleep } from '@/test/sleep'
4
- import { within } from '@storybook/testing-library'
4
+ import { within } from '@storybook/test'
5
5
 
6
6
  export async function defaultTest({ canvasElement, args }: PlayAttributes) {
7
7
  const parentElement = (await within(canvasElement).findByTestId(
@@ -1,5 +1,4 @@
1
- import { expect } from '@storybook/jest'
2
- import { userEvent } from '@storybook/testing-library'
1
+ import { userEvent, expect } from '@storybook/test'
3
2
  import { axe } from 'jest-axe'
4
3
  import { sleep } from '@/test/sleep'
5
4
 
@@ -79,8 +78,7 @@ expect.extend({
79
78
  const img = element.getElementsByTagName(imgTag)
80
79
  return {
81
80
  pass: img.length === 1,
82
- message: () =>
83
- `${imgTag} not exist!`,
81
+ message: () => `${imgTag} not exist!`,
84
82
  }
85
83
  },
86
84
  })
@@ -1,20 +1,24 @@
1
- export type AlertModifiers =
1
+ import type { VvIconProps } from '@/components/VvIcon'
2
+ import { AlertRole } from '@/constants'
3
+
4
+ export type AlertModifier =
2
5
  | 'success'
3
6
  | 'info'
4
7
  | 'warning'
5
8
  | 'danger'
6
9
  | 'brand'
7
10
  | 'accent'
11
+ | string
8
12
 
9
13
  export type Alert = {
10
14
  id: string | number
11
- group: string
12
15
  title?: string
13
- icon: string | Record<string, unknown>
16
+ icon?: string | VvIconProps
14
17
  content?: string
15
18
  footer?: string
16
- modifiers: AlertModifiers
17
- dismissable: boolean
18
- autoClose: number
19
- timestamp: number
19
+ modifiers?: AlertModifier | AlertModifier[]
20
+ dismissable?: boolean
21
+ autoClose?: number
22
+ closeLabel?: string
23
+ role?: AlertRole
20
24
  }