sprintify-ui 0.5.12 → 0.6.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 (31) hide show
  1. package/dist/sprintify-ui.es.js +11590 -11401
  2. package/dist/types/src/components/BaseAutocomplete.vue.d.ts +9 -0
  3. package/dist/types/src/components/BaseAutocompleteFetch.vue.d.ts +9 -0
  4. package/dist/types/src/components/BaseBelongsTo.vue.d.ts +9 -0
  5. package/dist/types/src/components/BaseBelongsToFetch.vue.d.ts +9 -0
  6. package/dist/types/src/components/BaseCharacterCounter.vue.d.ts +1 -1
  7. package/dist/types/src/components/BaseDropdown.vue.d.ts +12 -35
  8. package/dist/types/src/components/BaseDropdownAutocomplete.vue.d.ts +4 -14
  9. package/dist/types/src/components/BaseTagAutocomplete.vue.d.ts +9 -0
  10. package/dist/types/src/components/BaseTagAutocompleteFetch.vue.d.ts +9 -0
  11. package/dist/types/src/components/BaseTooltip.vue.d.ts +28 -8
  12. package/dist/types/src/components/index.d.ts +2 -2
  13. package/package.json +1 -1
  14. package/src/components/BaseAutocomplete.vue +27 -5
  15. package/src/components/BaseAutocompleteFetch.vue +5 -0
  16. package/src/components/BaseAvatar.vue +43 -40
  17. package/src/components/BaseBelongsTo.vue +5 -0
  18. package/src/components/BaseBelongsToFetch.vue +5 -0
  19. package/src/components/BaseDatePicker.vue +4 -4
  20. package/src/components/BaseDisplayRelativeTime.vue +21 -20
  21. package/src/components/BaseDropdown.stories.js +22 -65
  22. package/src/components/BaseDropdown.vue +37 -243
  23. package/src/components/BaseDropdownAutocomplete.vue +5 -30
  24. package/src/components/BaseInputLabel.vue +8 -14
  25. package/src/components/BaseTagAutocomplete.vue +19 -2
  26. package/src/components/BaseTagAutocompleteFetch.vue +5 -0
  27. package/src/components/BaseTooltip.stories.js +62 -0
  28. package/src/components/BaseTooltip.vue +33 -12
  29. package/src/components/index.ts +2 -2
  30. package/dist/types/src/components/BaseClickOutside.vue.d.ts +0 -28
  31. package/src/components/BaseClickOutside.vue +0 -37
@@ -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,62 @@
1
+ import BaseTooltip from './BaseTooltip.vue';
2
+ import BaseCard from './BaseCard.vue';
3
+ import BaseCardRow from './BaseCardRow.vue';
4
+
5
+ export default {
6
+ title: 'Components/BaseTooltip',
7
+ component: BaseTooltip,
8
+ args: {
9
+ text: 'Click here to learn more about this button',
10
+ },
11
+ };
12
+
13
+ const Template = (args) => ({
14
+ components: {
15
+ BaseCard,
16
+ BaseCardRow,
17
+ BaseTooltip,
18
+ },
19
+ setup() {
20
+ return { args };
21
+ },
22
+ template: `
23
+ <BaseCard>
24
+ <BaseCardRow size=sm>
25
+ <BaseTooltip class="inline-block" v-bind="args">
26
+ <div>Hover me, the tooltip show appear outside the BaseCard</div>
27
+ </BaseTooltip>
28
+ </BaseCardRow>
29
+ </BaseCard>
30
+ `,
31
+ });
32
+
33
+ export const Demo = Template.bind({});
34
+ Demo.args = {};
35
+
36
+ const CustomSlotTemplate = (args) => ({
37
+ components: {
38
+ BaseCard,
39
+ BaseCardRow,
40
+ BaseTooltip,
41
+ },
42
+ setup() {
43
+ return { args };
44
+ },
45
+ template: `
46
+ <BaseCard>
47
+ <BaseCardRow size=sm>
48
+ <BaseTooltip class="inline-block" v-bind="args">
49
+ <div>Hover me, the tooltip show appear outside the BaseCard</div>
50
+ <template #tooltip>
51
+ <div class="bg-black text-white text-xs p-3">
52
+ {{ args.text }}
53
+ </div>
54
+ </template>
55
+ </BaseTooltip>
56
+ </BaseCardRow>
57
+ </BaseCard>
58
+ `,
59
+ });
60
+
61
+ export const CustomSlot = CustomSlotTemplate.bind({});
62
+ CustomSlot.args = {};
@@ -1,5 +1,14 @@
1
1
  <template>
2
- <Teleport to="body">
2
+ <div
3
+ ref="targetRef"
4
+ :class="props.class"
5
+ >
6
+ <slot />
7
+ </div>
8
+ <Teleport
9
+ v-if="visible"
10
+ to="body"
11
+ >
3
12
  <div
4
13
  ref="tooltipRef"
5
14
  class="fixed top-0 left-0 pointer-events-none z-tooltip"
@@ -13,12 +22,15 @@
13
22
  leave-from-class="transform scale-100 opacity-100"
14
23
  leave-to-class="transform scale-90 opacity-0"
15
24
  >
16
- <div
25
+ <slot
17
26
  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"
27
+ name="tooltip"
19
28
  >
20
- <slot />
21
- </div>
29
+ <div
30
+ class="bg-white shadow-md text-xs max-w-xs leading-snug ring-1 ring-black ring-opacity-10 text-slate-900 rounded-md pt-1.5 pb-2 px-3"
31
+ v-html="text"
32
+ />
33
+ </slot>
22
34
  </transition>
23
35
  </div>
24
36
  </Teleport>
@@ -26,16 +38,25 @@
26
38
 
27
39
  <script lang="ts" setup>
28
40
  import { useTooltip } from '@/composables/tooltip';
29
- import { PropType } from 'vue';
41
+ import { unrefElement } from '@vueuse/core';
30
42
 
31
- const props = defineProps({
32
- target: {
33
- required: true,
34
- type: Object as PropType<HTMLElement | null>,
35
- }
43
+ defineOptions({
44
+ inheritAttrs: false,
36
45
  });
37
46
 
38
- const targetInternal = computed(() => props.target ?? null);
47
+ const props = withDefaults(defineProps<{
48
+ visible?: boolean,
49
+ text?: string | null | undefined;
50
+ class?: string[] | string | null | undefined;
51
+ }>(), {
52
+ visible: true,
53
+ text: null,
54
+ class: null,
55
+ });
56
+
57
+ const targetRef = ref<HTMLElement | null>(null);
58
+
59
+ const targetInternal = computed(() => unrefElement(targetRef));
39
60
 
40
61
  const tooltipRef = ref<HTMLElement | null>(null)
41
62
 
@@ -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';
@@ -90,6 +89,7 @@ import BaseTextarea from './BaseTextarea.vue';
90
89
  import BaseTextareaAutoresize from './BaseTextareaAutoresize.vue';
91
90
  import BaseTimeline from './BaseTimeline.vue';
92
91
  import BaseTimelineItem from './BaseTimelineItem.vue';
92
+ import BaseTooltip from './BaseTooltip.vue';
93
93
  import BaseUniqueCode from './BaseUniqueCode.vue';
94
94
 
95
95
  import BaseLayoutStacked from './BaseLayoutStacked.vue';
@@ -118,7 +118,6 @@ export {
118
118
  BaseCard,
119
119
  BaseCardRow,
120
120
  BaseCharacterCounter,
121
- BaseClickOutside,
122
121
  BaseClipboard,
123
122
  BaseCalendar,
124
123
  BaseColor,
@@ -190,6 +189,7 @@ export {
190
189
  BaseTextareaAutoresize,
191
190
  BaseTimeline,
192
191
  BaseTimelineItem,
192
+ BaseTooltip,
193
193
  BaseUniqueCode,
194
194
  BaseLayoutStacked,
195
195
  BaseLayoutStackedConfigurable,
@@ -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>