@antify/ui-module 1.4.0 → 1.5.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 (88) hide show
  1. package/dist/module.json +1 -1
  2. package/dist/module.mjs +2 -1
  3. package/dist/runtime/components/AntAccordionItem.vue +17 -14
  4. package/dist/runtime/components/AntDropdown.vue +6 -6
  5. package/dist/runtime/components/AntListGroupItem.vue +16 -10
  6. package/dist/runtime/components/AntModal.vue +10 -9
  7. package/dist/runtime/components/AntPopover.vue +10 -8
  8. package/dist/runtime/components/AntTooltip.vue +32 -20
  9. package/dist/runtime/components/__stories/AntTooltip.stories.d.ts +1 -1
  10. package/dist/runtime/components/__stories/AntTooltip.stories.mjs +164 -12
  11. package/dist/runtime/components/buttons/AntActionButton.vue +40 -32
  12. package/dist/runtime/components/buttons/AntButton.vue +188 -168
  13. package/dist/runtime/components/buttons/AntCreateButton.vue +19 -6
  14. package/dist/runtime/components/buttons/AntDeleteButton.vue +21 -10
  15. package/dist/runtime/components/buttons/AntDuplicateButton.vue +54 -0
  16. package/dist/runtime/components/buttons/AntEditButton.vue +54 -0
  17. package/dist/runtime/components/buttons/AntSaveAndNewButton.vue +21 -8
  18. package/dist/runtime/components/buttons/AntSaveButton.vue +21 -10
  19. package/dist/runtime/components/buttons/__stories/AntActionButton.stories.d.ts +1 -1
  20. package/dist/runtime/components/buttons/__stories/AntActionButton.stories.mjs +22 -19
  21. package/dist/runtime/components/buttons/__stories/AntButton.stories.d.ts +1 -0
  22. package/dist/runtime/components/buttons/__stories/AntButton.stories.mjs +166 -131
  23. package/dist/runtime/components/buttons/__stories/AntCreateButton.stories.d.ts +1 -0
  24. package/dist/runtime/components/buttons/__stories/AntCreateButton.stories.mjs +16 -6
  25. package/dist/runtime/components/buttons/__stories/AntDeleteButton.stories.d.ts +1 -0
  26. package/dist/runtime/components/buttons/__stories/AntDeleteButton.stories.mjs +16 -6
  27. package/dist/runtime/components/buttons/__stories/AntDuplicateButton.stories.d.ts +12 -0
  28. package/dist/runtime/components/buttons/__stories/AntDuplicateButton.stories.mjs +76 -0
  29. package/dist/runtime/components/buttons/__stories/AntEditButton.stories.d.ts +12 -0
  30. package/dist/runtime/components/buttons/__stories/AntEditButton.stories.mjs +76 -0
  31. package/dist/runtime/components/buttons/__stories/AntSaveAndNewButton.stories.d.ts +1 -0
  32. package/dist/runtime/components/buttons/__stories/AntSaveAndNewButton.stories.mjs +16 -6
  33. package/dist/runtime/components/buttons/__stories/AntSaveButton.stories.d.ts +1 -0
  34. package/dist/runtime/components/buttons/__stories/AntSaveButton.stories.mjs +16 -6
  35. package/dist/runtime/components/crud/AntCrud.vue +13 -10
  36. package/dist/runtime/components/crud/AntCrudDetail.vue +1 -1
  37. package/dist/runtime/components/crud/AntCrudDetailActions.vue +1 -1
  38. package/dist/runtime/components/crud/AntCrudDetailNav.vue +1 -1
  39. package/dist/runtime/components/crud/AntCrudTableFilter.vue +1 -1
  40. package/dist/runtime/components/crud/AntCrudTableNav.vue +15 -4
  41. package/dist/runtime/components/dialogs/AntDialog.vue +7 -7
  42. package/dist/runtime/components/form/AntCheckboxWidget/AntCheckbox.vue +1 -2
  43. package/dist/runtime/components/form/AntFormGroup.vue +22 -7
  44. package/dist/runtime/components/form/AntSelect.vue +57 -53
  45. package/dist/runtime/components/form/AntSwitch.vue +13 -10
  46. package/dist/runtime/components/form/AntSwitcher.vue +4 -4
  47. package/dist/runtime/components/form/AntTextarea.vue +6 -3
  48. package/dist/runtime/components/form/Elements/AntBaseInput.vue +45 -41
  49. package/dist/runtime/components/form/Elements/AntDropDown.vue +1 -1
  50. package/dist/runtime/components/layouts/AntNavLeftLayout.vue +4 -4
  51. package/dist/runtime/components/table/AntTable.vue +95 -73
  52. package/dist/runtime/components/table/AntTableSortButton.vue +16 -4
  53. package/dist/runtime/components/tabs/AntTabItem.vue +7 -4
  54. package/dist/runtime/tailwind.config.mjs +1 -1
  55. package/package.json +11 -11
  56. package/src/runtime/components/AntAccordionItem.vue +17 -14
  57. package/src/runtime/components/AntDropdown.vue +6 -6
  58. package/src/runtime/components/AntListGroupItem.vue +16 -10
  59. package/src/runtime/components/AntModal.vue +10 -9
  60. package/src/runtime/components/AntPopover.vue +10 -8
  61. package/src/runtime/components/AntTooltip.vue +32 -20
  62. package/src/runtime/components/buttons/AntActionButton.vue +40 -32
  63. package/src/runtime/components/buttons/AntButton.vue +188 -168
  64. package/src/runtime/components/buttons/AntCreateButton.vue +19 -6
  65. package/src/runtime/components/buttons/AntDeleteButton.vue +21 -10
  66. package/src/runtime/components/buttons/AntDuplicateButton.vue +54 -0
  67. package/src/runtime/components/buttons/AntEditButton.vue +54 -0
  68. package/src/runtime/components/buttons/AntSaveAndNewButton.vue +21 -8
  69. package/src/runtime/components/buttons/AntSaveButton.vue +21 -10
  70. package/src/runtime/components/crud/AntCrud.vue +13 -10
  71. package/src/runtime/components/crud/AntCrudDetail.vue +1 -1
  72. package/src/runtime/components/crud/AntCrudDetailActions.vue +1 -1
  73. package/src/runtime/components/crud/AntCrudDetailNav.vue +1 -1
  74. package/src/runtime/components/crud/AntCrudTableFilter.vue +1 -1
  75. package/src/runtime/components/crud/AntCrudTableNav.vue +15 -4
  76. package/src/runtime/components/dialogs/AntDialog.vue +7 -7
  77. package/src/runtime/components/form/AntCheckboxWidget/AntCheckbox.vue +1 -2
  78. package/src/runtime/components/form/AntFormGroup.vue +22 -7
  79. package/src/runtime/components/form/AntSelect.vue +57 -53
  80. package/src/runtime/components/form/AntSwitch.vue +13 -10
  81. package/src/runtime/components/form/AntSwitcher.vue +4 -4
  82. package/src/runtime/components/form/AntTextarea.vue +6 -3
  83. package/src/runtime/components/form/Elements/AntBaseInput.vue +45 -41
  84. package/src/runtime/components/form/Elements/AntDropDown.vue +1 -1
  85. package/src/runtime/components/layouts/AntNavLeftLayout.vue +4 -4
  86. package/src/runtime/components/table/AntTable.vue +95 -73
  87. package/src/runtime/components/table/AntTableSortButton.vue +16 -4
  88. package/src/runtime/components/tabs/AntTabItem.vue +7 -4
package/dist/module.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "ui-module",
3
3
  "configKey": "uiModule",
4
- "version": "1.4.0"
4
+ "version": "1.5.1"
5
5
  }
package/dist/module.mjs CHANGED
@@ -84,7 +84,7 @@ const colors = {
84
84
  "danger-950": defaultColors.red["950"]
85
85
  };
86
86
  const fontColors = {
87
- "for-white-bg-font": colors["neutral-900"],
87
+ "for-white-bg-font": colors["neutral-600"],
88
88
  "for-black-bg-font": colors["neutral-100"],
89
89
  "neutral-50-font": colors["neutral-600"],
90
90
  "neutral-100-font": colors["neutral-600"],
@@ -329,6 +329,7 @@ const module = defineNuxtModule({
329
329
  const { resolve } = createResolver(import.meta.url);
330
330
  const runtimeDir = resolve("./runtime");
331
331
  nuxt.options.build.transpile.push(runtimeDir);
332
+ nuxt.options.alias["#ui-module"] = resolve(runtimeDir, "types");
332
333
  addPlugin(resolve(runtimeDir, "plugins/ui-module"));
333
334
  addImportsDir(resolve(runtimeDir, "composables"));
334
335
  await addComponentsDir({
@@ -24,21 +24,24 @@ function onClick() {
24
24
 
25
25
  <template>
26
26
  <div
27
- class="p-2.5 select-none cursor-pointer transition-colors"
28
- :class="{'bg-primary-500 text-primary-500-font': isOpen, 'bg-neutral-50 text-neutral-50-font': !isOpen}"
29
- @click="onClick"
27
+ class="p-2.5 select-none cursor-pointer transition-colors"
28
+ :class="{'bg-primary-500 text-primary-500-font': isOpen, 'bg-white text-for-white-bg-font': !isOpen}"
29
+ @click="onClick"
30
30
  >
31
- <slot name="label" v-bind="{ isOpen: isOpen }">
31
+ <slot
32
+ name="label"
33
+ v-bind="{ isOpen: isOpen }"
34
+ >
32
35
  <div
33
- class="hover:text-gray-800 flex justify-between items-center"
36
+ class="hover:text-gray-800 flex justify-between items-center"
34
37
  >
35
38
  <span class="text-sm font-semibold">
36
39
  {{ label }}
37
40
  </span>
38
41
 
39
42
  <AntIcon
40
- :icon="isOpen ? faAngleUp : faAngleDown"
41
- :color="isOpen ? 'text-primary-500-font' : undefined"
43
+ :icon="isOpen ? faAngleUp : faAngleDown"
44
+ :color="isOpen ? 'text-primary-500-font' : undefined"
42
45
  />
43
46
  </div>
44
47
  </slot>
@@ -46,17 +49,17 @@ function onClick() {
46
49
 
47
50
  <AntTransitionCollapseHeight>
48
51
  <div
49
- v-show="isOpen"
50
- class="bg-white overflow-hidden -mt-px"
52
+ v-show="isOpen"
53
+ class="bg-white overflow-hidden -mt-px"
51
54
  >
52
- <transition name="bounce">
55
+ <Transition name="bounce">
53
56
  <div
54
- v-show="isOpen"
55
- class="p-2.5 bg-neutral-50"
57
+ v-show="isOpen"
58
+ class="p-2.5 bg-white"
56
59
  >
57
- <slot/>
60
+ <slot />
58
61
  </div>
59
- </transition>
62
+ </Transition>
60
63
  </div>
61
64
  </AntTransitionCollapseHeight>
62
65
  </template>
@@ -52,25 +52,25 @@ function onClickOutside() {
52
52
 
53
53
  <template>
54
54
  <div
55
+ v-on-click-outside="onClickOutside"
55
56
  class="relative inline-flex justify-center items-end z-40"
56
57
  data-e2e="dropdown"
57
- v-on-click-outside="onClickOutside"
58
58
  >
59
- <slot/>
59
+ <slot />
60
60
 
61
- <transition name="bounce">
61
+ <Transition name="bounce">
62
62
  <div
63
63
  v-if="showDropdown"
64
64
  :class="_dropdownClasses"
65
65
  >
66
66
  <div
67
- class="shadow-lg border border-neutral-300 rounded-md text-sm relative inline-flex flex-col relative bg-neutral-50 text-neutral-50-font w-full"
67
+ class="shadow-lg border border-neutral-300 rounded-md text-sm relative inline-flex flex-col relative bg-white text-for-white-bg-font w-full"
68
68
  :class="{'p-2.5': contentPadding}"
69
69
  >
70
- <slot name="content"/>
70
+ <slot name="content" />
71
71
  </div>
72
72
  </div>
73
- </transition>
73
+ </Transition>
74
74
  </div>
75
75
  </template>
76
76
 
@@ -21,7 +21,7 @@ const classes = computed(() => {
21
21
  [ListGroupItemColorType.info]: 'bg-info-500 text-info-500-font',
22
22
  [ListGroupItemColorType.neutral700]: 'bg-neutral-700 text-neutral-700-font',
23
23
  [ListGroupItemColorType.neutral300]: 'bg-neutral-300 text-neutral-300-font',
24
- [ListGroupItemColorType.neutral50]: 'bg-neutral-50 text-neutral-50-font',
24
+ [ListGroupItemColorType.neutral50]: 'bg-white text-for-white-bg-font',
25
25
  [ListGroupItemColorType.primary]: 'bg-primary-500 text-primary-500-font',
26
26
  [ListGroupItemColorType.secondary]: 'bg-secondary-500 text-secondary-500-font',
27
27
  [ListGroupItemColorType.success]: 'bg-success-500 text-success-500-font',
@@ -39,7 +39,7 @@ const contentWrapperClasses = computed(() => {
39
39
  [ListGroupItemColorType.info]: 'text-info-500-font',
40
40
  [ListGroupItemColorType.neutral700]: 'text-neutral-700-font',
41
41
  [ListGroupItemColorType.neutral300]: 'text-neutral-300-font',
42
- [ListGroupItemColorType.neutral50]: 'text-neutral-50-font',
42
+ [ListGroupItemColorType.neutral50]: 'text-for-white-bg-font',
43
43
  [ListGroupItemColorType.primary]: 'text-primary-500-font',
44
44
  [ListGroupItemColorType.secondary]: 'text-secondary-500-font',
45
45
  [ListGroupItemColorType.success]: 'text-success-500-font',
@@ -60,21 +60,27 @@ onMounted(() => {
60
60
 
61
61
  <template>
62
62
  <component
63
- :is="to !== undefined ? 'router-link' : 'div'"
64
- :to="to"
65
- :class="classes"
63
+ :is="to !== undefined ? 'router-link' : 'div'"
64
+ :to="to"
65
+ :class="classes"
66
66
  >
67
67
  <div :class="contentWrapperClasses">
68
68
  <div class="flex items-center gap-2.5">
69
- <slot v-if="iconLeft" name="icon-left">
70
- <AntIcon :icon="iconLeft"/>
69
+ <slot
70
+ v-if="iconLeft"
71
+ name="icon-left"
72
+ >
73
+ <AntIcon :icon="iconLeft" />
71
74
  </slot>
72
75
 
73
- <slot/>
76
+ <slot />
74
77
  </div>
75
78
 
76
- <slot v-if="iconRight" name="icon-right">
77
- <AntIcon :icon="iconRight"/>
79
+ <slot
80
+ v-if="iconRight"
81
+ name="icon-right"
82
+ >
83
+ <AntIcon :icon="iconRight" />
78
84
  </slot>
79
85
  </div>
80
86
  </component>
@@ -39,21 +39,22 @@ function closeModal() {
39
39
  </script>
40
40
 
41
41
  <template>
42
- <transition name="fade">
42
+ <Transition name="fade">
43
43
  <div
44
44
  v-if="openBackground"
45
45
  class="absolute inset-0 flex items-center justify-center z-50 cursor-pointer overflow-hidden"
46
46
  :class="{'bg-black/50 backdrop-blur-sm': !fullscreen}"
47
47
  @click.self="closeModal"
48
48
  >
49
- <transition :name="!fullscreen ? 'bounce' : 'bounce-slow'">
49
+ <Transition :name="!fullscreen ? 'bounce' : 'bounce-slow'">
50
50
  <div
51
51
  v-if="openModal"
52
52
  class="flex flex-col gap-px bg-neutral-300 overflow-hidden cursor-auto"
53
53
  :class="{'w-full h-full': fullscreen, 'border border-neutral-300 rounded-md shadow-md': !fullscreen}"
54
54
  >
55
55
  <div
56
- class="bg-neutral-50 p-2.5 flex items-center justify-between text-neutral-50-font text-lg font-medium">
56
+ class="bg-white p-2.5 flex items-center justify-between text-for-white-bg-font text-lg font-medium"
57
+ >
57
58
  <slot name="title">
58
59
  {{ title }}
59
60
  </slot>
@@ -66,20 +67,20 @@ function closeModal() {
66
67
  />
67
68
  </div>
68
69
 
69
- <div class="bg-neutral-50 p-2.5 grow overflow-y-auto">
70
- <slot/>
70
+ <div class="bg-white p-2.5 grow overflow-y-auto">
71
+ <slot />
71
72
  </div>
72
73
 
73
74
  <div
74
75
  v-if="useSlots()['footer'] || false"
75
- class="bg-neutral-50 p-2.5 text-neutral-50-font"
76
+ class="bg-white p-2.5 text-for-white-bg-font"
76
77
  >
77
- <slot name="footer"/>
78
+ <slot name="footer" />
78
79
  </div>
79
80
  </div>
80
- </transition>
81
+ </Transition>
81
82
  </div>
82
- </transition>
83
+ </Transition>
83
84
  </template>
84
85
 
85
86
  <style scoped>
@@ -44,9 +44,9 @@ onMounted(() => {
44
44
 
45
45
  <template>
46
46
  <div class="relative inline-flex justify-center items-end">
47
- <slot/>
47
+ <slot />
48
48
 
49
- <transition name="bounce">
49
+ <Transition name="bounce">
50
50
  <template v-if="showPopover">
51
51
  <div :class="_popoverClasses">
52
52
  <div class="shadow-lg border-neutral-300 rounded-md text-sm relative inline-flex flex-col relative">
@@ -66,12 +66,12 @@ onMounted(() => {
66
66
  >
67
67
  <path
68
68
  d="M20.3284 1.82843L23.1569 4.65685C24.6571 6.15715 26.692 7 28.8137 7L6.18629 7C8.30802 7 10.3429 6.15715 11.8431 4.65686L14.6716 1.82843C16.2337 0.266331 18.7663 0.266328 20.3284 1.82843Z"
69
- :class="{'fill-neutral-100': position === Position.bottom, 'fill-neutral-50': position === Position.top || position === Position.right || position === Position.left}"
69
+ :class="{'fill-neutral-100': position === Position.bottom, 'fill-white': position === Position.top || position === Position.right || position === Position.left}"
70
70
  />
71
71
 
72
72
  <path
73
73
  d="M34.5 7L28.8137 7C26.692 7 24.6571 6.15715 23.1569 4.65685L20.3284 1.82843C18.7663 0.266328 16.2337 0.266331 14.6716 1.82843L11.8431 4.65686C10.3429 6.15715 8.30802 7 6.18629 7L0.5 7L34.5 7Z"
74
- :class="{'stroke-neutral-100': position === Position.bottom, 'stroke-neutral-50': position === Position.top || position === Position.right || position === Position.left}"
74
+ :class="{'stroke-neutral-100': position === Position.bottom, 'stroke-white': position === Position.top || position === Position.right || position === Position.left}"
75
75
  />
76
76
  </svg>
77
77
 
@@ -92,18 +92,20 @@ onMounted(() => {
92
92
  </div>
93
93
 
94
94
  <div
95
- class="border-neutral-300 border-b p-2.5 bg-neutral-100 rounded-t-md border-t border-l border-r text-neutral-100-font font-semibold">
95
+ class="border-neutral-300 border-b p-2.5 bg-neutral-100 rounded-t-md border-t border-l border-r text-neutral-100-font font-semibold"
96
+ >
96
97
  {{ title }}
97
98
  </div>
98
99
 
99
100
  <div
100
- class="p-2.5 rounded-b-md text-neutral-50-font border-neutral-300 border-l border-b border-r bg-neutral-50">
101
- <slot name="content"/>
101
+ class="p-2.5 rounded-b-md text-for-white-bg-font border-neutral-300 border-l border-b border-r bg-white"
102
+ >
103
+ <slot name="content" />
102
104
  </div>
103
105
  </div>
104
106
  </div>
105
107
  </template>
106
- </transition>
108
+ </Transition>
107
109
  </div>
108
110
  </template>
109
111
 
@@ -1,5 +1,5 @@
1
1
  <script lang="ts" setup>
2
- import {computed, onMounted, ref} from 'vue';
2
+ import {computed, onMounted, ref, getCurrentInstance} from 'vue';
3
3
  import {handleEnumValidation} from '../handler';
4
4
  import {InputColorType, Position} from '../enums';
5
5
  import {classesToObjectSyntax} from '../utils';
@@ -10,11 +10,13 @@ const props = withDefaults(defineProps<{
10
10
  tooltipClasses?: string | Record<string, boolean>
11
11
  colorType?: InputColorType
12
12
  expanded?: boolean
13
+ delay?: number
13
14
  }>(), {
14
15
  position: Position.left,
15
16
  tooltipClasses: '',
16
17
  colorType: InputColorType.base,
17
- expanded: false
18
+ expanded: false,
19
+ delay: 800
18
20
  });
19
21
  const visible = ref(false);
20
22
  const _tooltipClasses = computed(() => ({
@@ -42,7 +44,7 @@ const itemContainerClasses = computed(() => ({
42
44
  }));
43
45
  const contentClasses = computed(() => {
44
46
  const variants: Record<InputColorType, string> = {
45
- [InputColorType.base]: 'text-neutral-50-font bg-neutral-50 border-neutral-300',
47
+ [InputColorType.base]: 'text-for-white-bg-font bg-white border-neutral-300',
46
48
  [InputColorType.danger]: 'text-danger-500-font bg-danger-500 border-danger-500',
47
49
  [InputColorType.info]: 'text-info-500-font bg-info-500 border-info-500',
48
50
  [InputColorType.success]: 'text-success-500-font bg-success-500 border-success-500',
@@ -53,7 +55,7 @@ const contentClasses = computed(() => {
53
55
  });
54
56
  const svgPathClasses = computed(() => {
55
57
  const variants: Record<InputColorType, string> = {
56
- [InputColorType.base]: 'fill-neutral-50 stroke-neutral-50',
58
+ [InputColorType.base]: 'fill-white stroke-white',
57
59
  [InputColorType.danger]: 'fill-danger-500 stroke-danger-500',
58
60
  [InputColorType.info]: 'fill-info-500 stroke-info-500',
59
61
  [InputColorType.success]: 'fill-success-500 stroke-success-500',
@@ -73,43 +75,53 @@ const arrowSvgPathClasses = computed(() => {
73
75
 
74
76
  return {[variants[props.colorType]]: true};
75
77
  });
78
+ const timeout = ref<number | undefined>();
79
+ const clickLock = ref(false);
80
+ const uuid = ref(getCurrentInstance()?.uid)
76
81
 
77
82
  onMounted(() => {
78
83
  handleEnumValidation(props.position, Position, 'Position')
79
84
  handleEnumValidation(props.colorType, InputColorType, 'colorType')
80
85
  });
81
86
 
82
- /**
83
- * To prevent a fliggering ux, add a delay on hover and leaving the hover target,
84
- * before showing the tooltip content.
85
- */
86
- const delayVisible = ref(visible.value);
87
-
88
87
  function onMouseOver() {
89
- delayVisible.value = true;
88
+ if (visible.value || clickLock.value) {
89
+ return;
90
+ }
90
91
 
91
- setTimeout(() => {
92
- if (delayVisible.value) {
93
- visible.value = true
94
- }
95
- }, 300)
92
+ timeout.value = setTimeout(() => visible.value = true, props.delay) as unknown as number
96
93
  }
97
94
 
98
95
  function onMouseLeave() {
99
- delayVisible.value = false
96
+ clearTimeout(timeout.value)
97
+
100
98
  visible.value = false
99
+ clickLock.value = false
100
+ }
101
+
102
+ function onClick() {
103
+ clearTimeout(timeout.value)
104
+
105
+ visible.value = false
106
+ clickLock.value = true
101
107
  }
102
108
  </script>
103
109
 
104
110
  <template>
105
111
  <div
112
+ :key="uuid"
106
113
  class="relative justify-center items-center"
107
114
  :class="{'flex w-full': props.expanded, 'inline-flex': !props.expanded}"
108
115
  data-e2e="tooltip"
109
- @mouseover="onMouseOver"
110
- @mouseleave="onMouseLeave"
116
+ @mouseover="() => onMouseOver()"
117
+ @mouseleave="() => onMouseLeave()"
111
118
  >
112
- <slot />
119
+ <div
120
+ class="w-full"
121
+ @click="() => onClick()"
122
+ >
123
+ <slot />
124
+ </div>
113
125
 
114
126
  <div
115
127
  v-if="visible && hasSlotContent($slots.content)"
@@ -8,4 +8,4 @@ export declare const Docs: Story;
8
8
  * Make sure, no tooltip get shown if no content is provided.
9
9
  */
10
10
  export declare const WithoutContent: Story;
11
- export declare const Expanded: Story;
11
+ export declare const Summary: Story;
@@ -1,11 +1,15 @@
1
1
  import AntTooltip from "../AntTooltip.vue";
2
- import AntButton from "../buttons/AntButton.vue";
2
+ import AntFormGroup from "../form/AntFormGroup.vue";
3
+ import AntFormGroupLabel from "../form/AntFormGroupLabel.vue";
3
4
  import { Position } from "../../enums/Position.enum.mjs";
4
5
  import { InputColorType } from "../../enums/index.mjs";
6
+ import { expect, userEvent, waitFor, within } from "@storybook/test";
5
7
  const meta = {
6
8
  title: "Components/Tooltip",
7
9
  component: AntTooltip,
8
- parameters: { controls: { sort: "requiredFirst" } },
10
+ parameters: {
11
+ controls: { sort: "requiredFirst" }
12
+ },
9
13
  argTypes: {
10
14
  position: {
11
15
  control: { type: "select" },
@@ -20,46 +24,194 @@ const meta = {
20
24
  export default meta;
21
25
  export const Docs = {
22
26
  render: (args) => ({
23
- components: { AntTooltip, AntButton },
27
+ components: { AntTooltip },
24
28
  setup() {
25
29
  return { args };
26
30
  },
27
31
  template: `
28
32
  <div class="p-32 flex justify-center items-center">
29
33
  <AntTooltip v-bind="args">
30
- <template #content>Lorem ipsum dolor sit amet <br/> foo</template>
34
+ <template #content>Lorem ipsum dolor sit <br/>amet</template>
31
35
  <template #default>
32
- <AntButton readonly filled expanded>Hover me</AntButton>
36
+ <div class="box">Hover me</div>
33
37
  </template>
34
38
  </AntTooltip>
35
39
  </div>
36
40
  `
37
41
  }),
42
+ play: async ({ canvasElement, step }) => {
43
+ const canvas = within(canvasElement);
44
+ const target = canvas.getByText("Hover me");
45
+ function queryTooltip() {
46
+ return canvas.queryByText("Lorem ipsum dolor sit amet");
47
+ }
48
+ await step("Hover over the target and expect showing the tooltip", async () => {
49
+ await userEvent.hover(target);
50
+ await waitFor(() => expect(queryTooltip()).toBeInTheDocument(), { timeout: 600 });
51
+ });
52
+ await step("Leave hover state and expect not showing the tooltip anymore", async () => {
53
+ await userEvent.unhover(target);
54
+ expect(queryTooltip()).not.toBeInTheDocument();
55
+ });
56
+ await step("Hover over the target, wait until the tooltip is visible, click the target and expect not showing the tooltip", async () => {
57
+ await userEvent.hover(target);
58
+ await waitFor(() => expect(queryTooltip()).toBeInTheDocument(), { timeout: 600 });
59
+ await userEvent.click(target);
60
+ expect(queryTooltip()).not.toBeInTheDocument();
61
+ });
62
+ await step("Hover over the target, click it while delay and expect not showing the tooltip", async () => {
63
+ await userEvent.hover(target);
64
+ await waitFor(() => expect(queryTooltip()).not.toBeInTheDocument(), { timeout: 200 });
65
+ await userEvent.click(target);
66
+ expect(queryTooltip()).not.toBeInTheDocument();
67
+ });
68
+ },
38
69
  args: {
70
+ delay: 600,
39
71
  position: Position.top
40
72
  }
41
73
  };
42
74
  export const WithoutContent = {
43
75
  render: (args) => ({
44
- components: { AntTooltip, AntButton },
76
+ components: { AntTooltip },
45
77
  setup() {
46
78
  return { args };
47
79
  },
48
80
  template: `
49
81
  <div class="p-32 flex justify-center items-center">
50
82
  <AntTooltip v-bind="args">
51
- <AntButton readonly filled expanded>Hover me</AntButton>
83
+ <div class="box">Hover me</div>
52
84
 
53
85
  <template #content></template>
54
86
  </AntTooltip>
55
87
  </div>
56
- `
88
+ `
57
89
  }),
90
+ play: async ({ canvasElement, step }) => {
91
+ const canvas = within(canvasElement);
92
+ await step("Hover over the target and expect not showing the tooltip", async () => {
93
+ await userEvent.hover(canvas.getByText("Hover me"));
94
+ await waitFor(() => expect(
95
+ canvas.queryByText(
96
+ "Lorem ipsum dolor sit amet"
97
+ )
98
+ ).not.toBeInTheDocument());
99
+ });
100
+ },
58
101
  args: {}
59
102
  };
60
- export const Expanded = {
61
- render: Docs.render,
62
- args: {
63
- expanded: true
103
+ export const Summary = {
104
+ render: (args) => ({
105
+ components: {
106
+ AntTooltip,
107
+ AntFormGroup,
108
+ AntFormGroupLabel
109
+ },
110
+ setup() {
111
+ return { args, Position, InputColorType };
112
+ },
113
+ template: `
114
+ <AntFormGroup>
115
+ <AntFormGroupLabel>Position</AntFormGroupLabel>
116
+ <AntFormGroup direction="row" class="gap-x-32 py-16 dashed">
117
+ <AntTooltip :position="Position.top">
118
+ <div class="box">Hover me</div>
119
+
120
+ <template #content>Lorem</template>
121
+ </AntTooltip>
122
+
123
+ <AntTooltip :position="Position.right">
124
+ <div class="box">Hover me</div>
125
+
126
+ <template #content>Lorem</template>
127
+ </AntTooltip>
128
+
129
+ <AntTooltip :position="Position.bottom">
130
+ <div class="box">Hover me</div>
131
+
132
+ <template #content>Lorem</template>
133
+ </AntTooltip>
134
+
135
+ <AntTooltip :position="Position.left">
136
+ <div class="box">Hover me</div>
137
+
138
+ <template #content>Lorem</template>
139
+ </AntTooltip>
140
+ </AntFormGroup>
141
+
142
+ <AntFormGroupLabel>Color type</AntFormGroupLabel>
143
+ <AntFormGroup direction="row" class="pb-16 dashed">
144
+ <AntTooltip :position="Position.bottom" :color-type="InputColorType.base">
145
+ <div class="box">Hover me</div>
146
+
147
+ <template #content>Lorem</template>
148
+ </AntTooltip>
149
+
150
+ <AntTooltip :position="Position.bottom" :color-type="InputColorType.info">
151
+ <div class="box">Hover me</div>
152
+
153
+ <template #content>Lorem</template>
154
+ </AntTooltip>
155
+
156
+ <AntTooltip :position="Position.bottom" :color-type="InputColorType.success">
157
+ <div class="box">Hover me</div>
158
+
159
+ <template #content>Lorem</template>
160
+ </AntTooltip>
161
+
162
+ <AntTooltip :position="Position.bottom" :color-type="InputColorType.warning">
163
+ <div class="box">Hover me</div>
164
+
165
+ <template #content>Lorem</template>
166
+ </AntTooltip>
167
+
168
+ <AntTooltip :position="Position.bottom" :color-type="InputColorType.danger">
169
+ <div class="box">Hover me</div>
170
+
171
+ <template #content>Lorem</template>
172
+ </AntTooltip>
173
+ </AntFormGroup>
174
+
175
+ <AntFormGroupLabel>Expanded</AntFormGroupLabel>
176
+ <AntFormGroup class="p-32 dashed gap-y-16">
177
+ <AntTooltip :position="Position.top" expanded>
178
+ <div class="box">Hover me</div>
179
+
180
+ <template #content>Lorem</template>
181
+ </AntTooltip>
182
+
183
+ <AntTooltip :position="Position.right" expanded>
184
+ <div class="box">Hover me</div>
185
+
186
+ <template #content>Lorem</template>
187
+ </AntTooltip>
188
+
189
+ <AntTooltip :position="Position.bottom" expanded>
190
+ <div class="box">Hover me</div>
191
+
192
+ <template #content>Lorem</template>
193
+ </AntTooltip>
194
+
195
+ <AntTooltip :position="Position.left" expanded>
196
+ <div class="box">Hover me</div>
197
+
198
+ <template #content>Lorem</template>
199
+ </AntTooltip>
200
+ </AntFormGroup>
201
+ </AntFormGroup>
202
+ `
203
+ }),
204
+ parameters: {
205
+ chromatic: { disableSnapshot: false }
206
+ },
207
+ play: async ({ canvasElement, step }) => {
208
+ const canvas = within(canvasElement);
209
+ await step("Hover over the targets and expect showing the tooltips", async () => {
210
+ const targets = canvas.getAllByText("Hover me");
211
+ await Promise.all(targets.map(async (target) => {
212
+ await userEvent.hover(target);
213
+ }));
214
+ await waitFor(() => expect(canvas.queryAllByText("Lorem")).toHaveLength(targets.length));
215
+ });
64
216
  }
65
217
  };