sprintify-ui 0.5.11 → 0.6.0

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/dist/sprintify-ui.es.js +16157 -17178
  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 +10 -1
  6. package/dist/types/src/components/BaseAutocompleteFetch.vue.d.ts +10 -1
  7. package/dist/types/src/components/BaseAvatar.vue.d.ts +18 -0
  8. package/dist/types/src/components/BaseBelongsTo.vue.d.ts +9 -0
  9. package/dist/types/src/components/BaseBelongsToFetch.vue.d.ts +9 -0
  10. package/dist/types/src/components/BaseCalendar.vue.d.ts +2 -2
  11. package/dist/types/src/components/BaseClipboard.vue.d.ts +0 -1
  12. package/dist/types/src/components/BaseDisplayRelativeTime.vue.d.ts +3 -4
  13. package/dist/types/src/components/BaseDropdown.vue.d.ts +12 -35
  14. package/dist/types/src/components/BaseDropdownAutocomplete.vue.d.ts +5 -15
  15. package/dist/types/src/components/BaseIconPicker.vue.d.ts +9 -9
  16. package/dist/types/src/components/BaseInput.vue.d.ts +2 -2
  17. package/dist/types/src/components/BaseInputLabel.vue.d.ts +0 -1
  18. package/dist/types/src/components/BaseInputPercent.vue.d.ts +2 -2
  19. package/dist/types/src/components/BaseLoadingCover.vue.d.ts +2 -2
  20. package/dist/types/src/components/BaseMediaLibrary.vue.d.ts +1 -1
  21. package/dist/types/src/components/BaseMenu.vue.d.ts +14 -5
  22. package/dist/types/src/components/BaseModalCenter.vue.d.ts +1 -1
  23. package/dist/types/src/components/BaseModalSide.vue.d.ts +1 -1
  24. package/dist/types/src/components/BaseRichText.vue.d.ts +1 -1
  25. package/dist/types/src/components/BaseSelect.vue.d.ts +1 -1
  26. package/dist/types/src/components/BaseTableColumn.vue.d.ts +2 -2
  27. package/dist/types/src/components/BaseTagAutocomplete.vue.d.ts +10 -1
  28. package/dist/types/src/components/BaseTagAutocompleteFetch.vue.d.ts +10 -1
  29. package/dist/types/src/components/BaseTextareaAutoresize.vue.d.ts +1 -1
  30. package/dist/types/src/components/BaseTooltip.vue.d.ts +19 -0
  31. package/dist/types/src/components/index.d.ts +1 -2
  32. package/dist/types/src/composables/tooltip.d.ts +7 -0
  33. package/package.json +2 -3
  34. package/src/assets/main.css +0 -1
  35. package/src/components/BaseAddressForm.vue +1 -2
  36. package/src/components/BaseAutocomplete.vue +27 -5
  37. package/src/components/BaseAutocompleteFetch.vue +5 -0
  38. package/src/components/BaseAvatar.vue +42 -2
  39. package/src/components/BaseAvatarGroup.stories.js +1 -1
  40. package/src/components/BaseAvatarGroup.vue +2 -2
  41. package/src/components/BaseBelongsTo.vue +5 -0
  42. package/src/components/BaseBelongsToFetch.vue +5 -0
  43. package/src/components/BaseClipboard.vue +56 -34
  44. package/src/components/BaseCounter.vue +1 -1
  45. package/src/components/BaseDataTable.vue +3 -1
  46. package/src/components/BaseDatePicker.vue +4 -4
  47. package/src/components/BaseDisplayRelativeTime.vue +15 -12
  48. package/src/components/BaseDropdown.stories.js +22 -65
  49. package/src/components/BaseDropdown.vue +37 -243
  50. package/src/components/BaseDropdownAutocomplete.vue +5 -30
  51. package/src/components/BaseHeader.vue +0 -1
  52. package/src/components/BaseInputLabel.vue +14 -11
  53. package/src/components/BaseLayoutNotificationDropdown.vue +1 -2
  54. package/src/components/BaseMenu.vue +121 -111
  55. package/src/components/BaseTagAutocomplete.vue +19 -2
  56. package/src/components/BaseTagAutocompleteFetch.vue +5 -0
  57. package/src/components/BaseTooltip.vue +40 -0
  58. package/src/components/index.ts +0 -2
  59. package/src/composables/tooltip.ts +43 -0
  60. package/dist/types/src/components/BaseClickOutside.vue.d.ts +0 -28
  61. package/src/components/BaseClickOutside.vue +0 -37
@@ -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>
@@ -160,7 +160,6 @@ const props = defineProps({
160
160
  default: false,
161
161
  type: Boolean,
162
162
  },
163
-
164
163
  max: {
165
164
  default: undefined,
166
165
  type: Number,
@@ -185,9 +184,13 @@ const props = defineProps({
185
184
  default: 'focus',
186
185
  type: String as PropType<'focus' | 'always'>,
187
186
  },
187
+ focusOnMount: {
188
+ default: false,
189
+ type: Boolean,
190
+ },
188
191
  twContainer: {
189
192
  default: '',
190
- type: [String, Array] as PropType<string|string[]>,
193
+ type: [String, Array] as PropType<string | string[]>,
191
194
  },
192
195
  });
193
196
 
@@ -214,6 +217,20 @@ const hasOptions = useHasOptions(
214
217
  computed(() => true)
215
218
  );
216
219
 
220
+ let openOfFocusTimeout = 0;
221
+
222
+ onMounted(() => {
223
+ openOfFocusTimeout = setTimeout(() => {
224
+ if (props.focusOnMount) {
225
+ open();
226
+ }
227
+ }, 10)
228
+ });
229
+
230
+ onBeforeUnmount(() => {
231
+ clearTimeout(openOfFocusTimeout);
232
+ });
233
+
217
234
  const drawer = ref<InstanceType<typeof BaseAutocompleteDrawer> | null>(null);
218
235
 
219
236
  const keywords = ref('');
@@ -12,6 +12,7 @@
12
12
  :has-error="hasError"
13
13
  :max="max"
14
14
  :filter="() => true"
15
+ :focus-on-mount="focusOnMount"
15
16
  @open="onOpen"
16
17
  @typing="onTyping"
17
18
  @scroll-bottom="scrollBottom"
@@ -111,6 +112,10 @@ const props = defineProps({
111
112
  default: false,
112
113
  type: Boolean,
113
114
  },
115
+ focusOnMount: {
116
+ default: false,
117
+ type: Boolean,
118
+ },
114
119
  });
115
120
 
116
121
  defineEmits(['update:modelValue', 'typing', 'focus', 'scrollBottom']);
@@ -0,0 +1,40 @@
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
+
30
+ const props = defineProps<{
31
+ target: HTMLElement | null;
32
+ }>();
33
+
34
+ const targetInternal = computed(() => props.target ?? null);
35
+
36
+ const tooltipRef = ref<HTMLElement | null>(null)
37
+
38
+ const { floatingStyles, showTooltip } = useTooltip(targetInternal, tooltipRef);
39
+
40
+ </script>
@@ -18,7 +18,6 @@ import BaseButtonGroup from './BaseButtonGroup.vue';
18
18
  import BaseCard from './BaseCard.vue';
19
19
  import BaseCardRow from './BaseCardRow.vue';
20
20
  import BaseCharacterCounter from './BaseCharacterCounter.vue';
21
- import BaseClickOutside from './BaseClickOutside.vue';
22
21
  import BaseClipboard from './BaseClipboard.vue';
23
22
  import BaseCalendar from './BaseCalendar.vue';
24
23
  import BaseColor from './BaseColor.vue';
@@ -118,7 +117,6 @@ export {
118
117
  BaseCard,
119
118
  BaseCardRow,
120
119
  BaseCharacterCounter,
121
- BaseClickOutside,
122
120
  BaseClipboard,
123
121
  BaseCalendar,
124
122
  BaseColor,
@@ -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 };
@@ -1,28 +0,0 @@
1
- import { MaybeElement } from '@vueuse/core';
2
- import { MaybeRef } from '@vueuse/shared';
3
- import { PropType } from 'vue';
4
- declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
5
- includes: {
6
- type: PropType<(string | MaybeRef<MaybeElement>)[]>;
7
- default: () => never[];
8
- };
9
- }, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
10
- clickOutside: (...args: any[]) => void;
11
- }, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
12
- includes: {
13
- type: PropType<(string | MaybeRef<MaybeElement>)[]>;
14
- default: () => never[];
15
- };
16
- }>> & {
17
- onClickOutside?: ((...args: any[]) => any) | undefined;
18
- }, {
19
- includes: (string | MaybeRef<MaybeElement>)[];
20
- }, {}>, {
21
- default?(_: {}): any;
22
- }>;
23
- export default _default;
24
- type __VLS_WithTemplateSlots<T, S> = T & {
25
- new (): {
26
- $slots: S;
27
- };
28
- };
@@ -1,37 +0,0 @@
1
- <template>
2
- <div ref="root">
3
- <slot />
4
- </div>
5
- </template>
6
-
7
- <script lang="ts" setup>
8
- import { useClickOutside } from '@/composables/clickOutside';
9
- import { MaybeElement } from '@vueuse/core';
10
- import { MaybeRef } from '@vueuse/shared';
11
- import { PropType } from 'vue';
12
-
13
- const props = defineProps({
14
- includes: {
15
- type: Array as PropType<(MaybeRef<MaybeElement> | string)[]>,
16
- default: () => [],
17
- },
18
- });
19
-
20
- const emit = defineEmits(['clickOutside']);
21
-
22
- const root = ref<null | HTMLElement>(null);
23
-
24
- const includes = [] as (MaybeRef<MaybeElement> | string)[];
25
-
26
- function addInclude(include: MaybeRef<MaybeElement> | string) {
27
- includes.push(include);
28
- }
29
-
30
- provide('clickOutside:addInclude', addInclude);
31
-
32
- useClickOutside(root, () => emit('clickOutside'), {
33
- includes: () => {
34
- return [...includes, ...props.includes];
35
- },
36
- });
37
- </script>