sprintify-ui 0.5.10 → 0.5.12

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 (44) hide show
  1. package/dist/sprintify-ui.es.js +15072 -16268
  2. package/dist/style.css +1 -1
  3. package/dist/tailwindcss/index.js +1 -0
  4. package/dist/types/src/components/BaseAddressForm.vue.d.ts +0 -5
  5. package/dist/types/src/components/BaseAutocomplete.vue.d.ts +1 -1
  6. package/dist/types/src/components/BaseAutocompleteFetch.vue.d.ts +1 -1
  7. package/dist/types/src/components/BaseAvatar.vue.d.ts +18 -0
  8. package/dist/types/src/components/BaseCalendar.vue.d.ts +2 -2
  9. package/dist/types/src/components/BaseClipboard.vue.d.ts +0 -1
  10. package/dist/types/src/components/BaseDisplayRelativeTime.vue.d.ts +3 -4
  11. package/dist/types/src/components/BaseDropdownAutocomplete.vue.d.ts +2 -2
  12. package/dist/types/src/components/BaseIconPicker.vue.d.ts +9 -9
  13. package/dist/types/src/components/BaseInput.vue.d.ts +2 -2
  14. package/dist/types/src/components/BaseInputLabel.vue.d.ts +0 -1
  15. package/dist/types/src/components/BaseInputPercent.vue.d.ts +2 -2
  16. package/dist/types/src/components/BaseLoadingCover.vue.d.ts +2 -2
  17. package/dist/types/src/components/BaseMediaLibrary.vue.d.ts +1 -1
  18. package/dist/types/src/components/BaseMenu.vue.d.ts +14 -5
  19. package/dist/types/src/components/BaseModalCenter.vue.d.ts +1 -1
  20. package/dist/types/src/components/BaseModalSide.vue.d.ts +1 -1
  21. package/dist/types/src/components/BaseRichText.vue.d.ts +1 -1
  22. package/dist/types/src/components/BaseSelect.vue.d.ts +1 -1
  23. package/dist/types/src/components/BaseTableColumn.vue.d.ts +2 -2
  24. package/dist/types/src/components/BaseTagAutocomplete.vue.d.ts +1 -1
  25. package/dist/types/src/components/BaseTagAutocompleteFetch.vue.d.ts +1 -1
  26. package/dist/types/src/components/BaseTextareaAutoresize.vue.d.ts +1 -1
  27. package/dist/types/src/components/BaseTooltip.vue.d.ts +20 -0
  28. package/dist/types/src/composables/tooltip.d.ts +7 -0
  29. package/package.json +2 -3
  30. package/src/assets/main.css +0 -1
  31. package/src/components/BaseAddressForm.vue +1 -2
  32. package/src/components/BaseAvatar.vue +42 -2
  33. package/src/components/BaseAvatarGroup.stories.js +1 -1
  34. package/src/components/BaseAvatarGroup.vue +2 -2
  35. package/src/components/BaseClipboard.vue +56 -34
  36. package/src/components/BaseCounter.vue +1 -1
  37. package/src/components/BaseDataTable.vue +3 -1
  38. package/src/components/BaseDisplayRelativeTime.vue +15 -12
  39. package/src/components/BaseHeader.vue +0 -1
  40. package/src/components/BaseInputLabel.vue +14 -11
  41. package/src/components/BaseLayoutNotificationDropdown.vue +3 -5
  42. package/src/components/BaseMenu.vue +121 -111
  43. package/src/components/BaseTooltip.vue +44 -0
  44. package/src/composables/tooltip.ts +43 -0
@@ -1,8 +1,7 @@
1
1
  <template>
2
2
  <BaseMenu
3
3
  class="inline-block"
4
- :position="mobile ? 'custom' : 'bottom-left'"
5
- :tw-menu="['sm:w-[320px] w-[280px]', mobile ? 'right-4' : '']"
4
+ :width="mobile ? 230 : 320"
6
5
  >
7
6
  <template #button="{ open }">
8
7
  <div
@@ -29,7 +28,7 @@
29
28
 
30
29
  <template #items>
31
30
  <template
32
- v-for="notification in notificationsConfig.items"
31
+ v-for="notification in notificationsConfig.items.slice(0, 4)"
33
32
  :key="notification.id + 'link'"
34
33
  >
35
34
  <BaseLayoutNotificationItem
@@ -105,8 +104,7 @@ const props = defineProps({
105
104
  });
106
105
 
107
106
  const unreadNotifications = computed(() => {
108
- return props.notificationsConfig.items
109
- .filter(i => !i.read);
107
+ return props.notificationsConfig.items.filter(i => !i.read);
110
108
  });
111
109
 
112
110
  const breakpoints = useBreakpoints();
@@ -3,9 +3,8 @@
3
3
  v-slot="{ open }"
4
4
  as="div"
5
5
  class="text-left"
6
- :class="[position == 'custom' ? 'static' : 'relative']"
7
6
  >
8
- <div>
7
+ <div ref="buttonWrapRef">
9
8
  <MenuButton :class="twButton">
10
9
  <slot
11
10
  name="button"
@@ -14,104 +13,116 @@
14
13
  </MenuButton>
15
14
  </div>
16
15
 
17
- <transition
18
- enter-active-class="transition duration-200 ease-out"
19
- enter-from-class="transform scale-95 opacity-0"
20
- enter-to-class="transform scale-100 opacity-100"
21
- leave-active-class="transition duration-75 ease-in"
22
- leave-from-class="transform scale-100 opacity-100"
23
- leave-to-class="transform scale-95 opacity-0"
24
- >
25
- <MenuItems
26
- :style="menuPositionStyles"
27
- :class="twMerge('w-48', twMenu)"
28
- class="absolute z-menu mt-2 rounded-md bg-white p-1 shadow-lg outline-none ring-1 ring-black ring-opacity-10 focus:outline-none"
16
+ <Teleport to="body">
17
+ <div
18
+ ref="menuItemsRef"
19
+ :style="{
20
+ ...floatingStyles,
21
+ width: `${width}px`,
22
+ }"
23
+ class="fixed top-0 left-0 z-menu"
29
24
  >
30
- <slot
31
- name="items"
32
- :items="items"
25
+ <transition
26
+ enter-active-class="transition duration-200 ease-out"
27
+ enter-from-class="transform -translate-y-2 scale-95 opacity-0"
28
+ enter-to-class="transform translate-y-0 scale-100 opacity-100"
29
+ leave-active-class="transition duration-75 ease-in"
30
+ leave-from-class="transform translate-y-0 scale-100 opacity-100"
31
+ leave-to-class="transform -translate-y-2 scale-95 opacity-0"
33
32
  >
34
- <template
35
- v-for="item in items"
36
- :key="item.label + 'link'"
33
+ <MenuItems
34
+ :style="{
35
+ width: `${width}px`,
36
+ }"
37
+ :class="twMerge('rounded-md bg-white p-1 shadow-lg outline-none ring-1 ring-black ring-opacity-10 focus:outline-none', twMenu)"
37
38
  >
38
- <div
39
- v-if="item.meta?.line"
40
- class="-mx-1 my-1 flex h-px bg-slate-200"
41
- />
42
-
43
- <MenuItem
44
- v-else-if="item.to"
45
- v-slot="{ active, close }"
39
+ <slot
40
+ name="items"
41
+ :items="items"
46
42
  >
47
- <RouterLink
48
- :to="item.to"
49
- @mouseup="close"
43
+ <template
44
+ v-for="item in items"
45
+ :key="item.label + 'link'"
50
46
  >
51
- <slot
52
- name="item"
53
- :item="item"
47
+ <div
48
+ v-if="item.meta?.line"
49
+ class="-mx-1 my-1 flex h-px bg-slate-200"
50
+ />
51
+
52
+ <MenuItem
53
+ v-else-if="item.to"
54
+ v-slot="{ active, close }"
54
55
  >
55
- <BaseMenuItem
56
- :label="item.label"
57
- :count="item.count"
58
- :icon="item.icon"
59
- :color="item.color"
60
- :active="active"
61
- :size="size"
62
- />
63
- </slot>
64
- </RouterLink>
65
- </MenuItem>
56
+ <RouterLink
57
+ :to="item.to"
58
+ @mouseup="close"
59
+ >
60
+ <slot
61
+ name="item"
62
+ :item="item"
63
+ >
64
+ <BaseMenuItem
65
+ :label="item.label"
66
+ :count="item.count"
67
+ :icon="item.icon"
68
+ :color="item.color"
69
+ :active="active"
70
+ :size="size"
71
+ />
72
+ </slot>
73
+ </RouterLink>
74
+ </MenuItem>
66
75
 
67
- <MenuItem
68
- v-else-if="item.href"
69
- v-slot="{ active }"
70
- as="a"
71
- :href="item.href"
72
- >
73
- <slot
74
- name="item"
75
- :item="item"
76
- >
77
- <BaseMenuItem
78
- :label="item.label"
79
- :count="item.count"
80
- :icon="item.icon"
81
- :color="item.color"
82
- :active="active"
83
- :size="size"
84
- />
85
- </slot>
86
- </MenuItem>
76
+ <MenuItem
77
+ v-else-if="item.href"
78
+ v-slot="{ active }"
79
+ as="a"
80
+ :href="item.href"
81
+ >
82
+ <slot
83
+ name="item"
84
+ :item="item"
85
+ >
86
+ <BaseMenuItem
87
+ :label="item.label"
88
+ :count="item.count"
89
+ :icon="item.icon"
90
+ :color="item.color"
91
+ :active="active"
92
+ :size="size"
93
+ />
94
+ </slot>
95
+ </MenuItem>
87
96
 
88
- <MenuItem
89
- v-else-if="item.action"
90
- v-slot="{ active }"
91
- as="button"
92
- type="button"
93
- class="w-full"
94
- @click="item.action"
95
- >
96
- <slot
97
- name="item"
98
- :item="item"
99
- :active="active"
100
- >
101
- <BaseMenuItem
102
- :label="item.label"
103
- :count="item.count"
104
- :icon="item.icon"
105
- :color="item.color"
106
- :active="active"
107
- :size="size"
108
- />
109
- </slot>
110
- </MenuItem>
111
- </template>
112
- </slot>
113
- </MenuItems>
114
- </transition>
97
+ <MenuItem
98
+ v-else-if="item.action"
99
+ v-slot="{ active }"
100
+ as="button"
101
+ type="button"
102
+ class="w-full"
103
+ @click="item.action"
104
+ >
105
+ <slot
106
+ name="item"
107
+ :item="item"
108
+ :active="active"
109
+ >
110
+ <BaseMenuItem
111
+ :label="item.label"
112
+ :count="item.count"
113
+ :icon="item.icon"
114
+ :color="item.color"
115
+ :active="active"
116
+ :size="size"
117
+ />
118
+ </slot>
119
+ </MenuItem>
120
+ </template>
121
+ </slot>
122
+ </MenuItems>
123
+ </transition>
124
+ </div>
125
+ </Teleport>
115
126
  </Menu>
116
127
  </template>
117
128
 
@@ -121,20 +132,25 @@ import { Menu, MenuButton, MenuItem, MenuItems } from '@headlessui/vue';
121
132
  import BaseMenuItem from './BaseMenuItem.vue';
122
133
  import { twMerge } from 'tailwind-merge';
123
134
  import { ActionItem } from '@/types';
135
+ import { autoUpdate, flip, offset, useFloating } from '@floating-ui/vue';
124
136
 
125
137
  const props = defineProps({
126
138
  items: {
127
139
  default: undefined,
128
140
  type: Array as PropType<ActionItem[]>,
129
141
  },
130
- position: {
131
- default: 'bottom-left',
132
- type: String as PropType<'bottom-left' | 'bottom-right' | 'custom'>,
142
+ placement: {
143
+ default: 'bottom-end',
144
+ type: String as PropType<'bottom-end' | 'bottom-start' | 'bottom' | 'top' | 'top-start' | 'top-end'>,
133
145
  },
134
146
  size: {
135
147
  default: 'sm',
136
148
  type: String as PropType<'xs' | 'sm' | 'md'>,
137
149
  },
150
+ width: {
151
+ default: 200,
152
+ type: Number,
153
+ },
138
154
  twMenu: {
139
155
  default: '',
140
156
  type: [String, Array] as PropType<string | string[]>,
@@ -145,21 +161,15 @@ const props = defineProps({
145
161
  },
146
162
  });
147
163
 
148
- const menuPositionStyles = computed(() => {
149
- if (props.position == 'custom') {
150
- return {};
151
- }
152
- if (props.position == 'bottom-left') {
153
- return {
154
- origin: 'top-right',
155
- right: '0',
156
- };
157
- }
158
- if (props.position == 'bottom-right') {
159
- return {
160
- origin: 'top-left',
161
- left: '0',
162
- };
163
- }
164
+ const buttonWrapRef = ref<HTMLElement | null>(null);
165
+ const menuItemsRef = ref<InstanceType<typeof MenuItems> | null>(null);
166
+
167
+ const { floatingStyles } = useFloating(buttonWrapRef, menuItemsRef, {
168
+ placement: props.placement,
169
+ middleware: [offset(4), flip({
170
+ fallbackPlacements: ['right', 'bottom'],
171
+ })],
172
+ whileElementsMounted: autoUpdate,
164
173
  });
174
+
165
175
  </script>
@@ -0,0 +1,44 @@
1
+ <template>
2
+ <Teleport to="body">
3
+ <div
4
+ ref="tooltipRef"
5
+ class="fixed top-0 left-0 pointer-events-none z-tooltip"
6
+ :style="floatingStyles"
7
+ >
8
+ <transition
9
+ enter-active-class="transition duration-200 ease-out"
10
+ enter-from-class="transform scale-90 opacity-0"
11
+ enter-to-class="transform scale-100 opacity-100"
12
+ leave-active-class="transition duration-75 ease-in"
13
+ leave-from-class="transform scale-100 opacity-100"
14
+ leave-to-class="transform scale-90 opacity-0"
15
+ >
16
+ <div
17
+ v-if="showTooltip"
18
+ class="bg-white shadow-md ring-1 ring-black ring-opacity-10 text-slate-900 rounded-md pt-1.5 pb-2 px-3"
19
+ >
20
+ <slot />
21
+ </div>
22
+ </transition>
23
+ </div>
24
+ </Teleport>
25
+ </template>
26
+
27
+ <script lang="ts" setup>
28
+ import { useTooltip } from '@/composables/tooltip';
29
+ import { PropType } from 'vue';
30
+
31
+ const props = defineProps({
32
+ target: {
33
+ required: true,
34
+ type: Object as PropType<HTMLElement | null>,
35
+ }
36
+ });
37
+
38
+ const targetInternal = computed(() => props.target ?? null);
39
+
40
+ const tooltipRef = ref<HTMLElement | null>(null)
41
+
42
+ const { floatingStyles, showTooltip } = useTooltip(targetInternal, tooltipRef);
43
+
44
+ </script>
@@ -0,0 +1,43 @@
1
+ import { UseFloatingOptions, MaybeElement, UseFloatingReturn, autoUpdate, flip, offset, shift, useFloating } from "@floating-ui/vue";
2
+ import { unrefElement, useEventListener, } from "@vueuse/core";
3
+
4
+ type ReturnType = UseFloatingReturn & {
5
+ showTooltip: Ref<boolean>;
6
+ };
7
+
8
+ import { Ref } from "vue";
9
+
10
+ function useTooltip(
11
+ reference: Readonly<Ref<MaybeElement<any>>>,
12
+ floating: Readonly<Ref<MaybeElement<HTMLElement>>>,
13
+ options: UseFloatingOptions | undefined = undefined
14
+ ): ReturnType {
15
+
16
+ const show = ref(false);
17
+
18
+ const elementRef = computed(() => {
19
+ return unrefElement(reference);
20
+ });
21
+
22
+ useEventListener(elementRef, 'mouseenter', () => {
23
+ show.value = true;
24
+ });
25
+
26
+ useEventListener(elementRef, 'mouseleave', () => {
27
+ show.value = false;
28
+ });
29
+
30
+ const config = {
31
+ placement: 'top',
32
+ middleware: [offset(6), flip(), shift()],
33
+ whileElementsMounted: autoUpdate,
34
+ };
35
+
36
+ const useFloatingReturn = useFloating(reference, floating, Object.assign(config, options));
37
+
38
+ return {
39
+ ...useFloatingReturn,
40
+ showTooltip: show,
41
+ };
42
+ }
43
+ export { useTooltip };