sprintify-ui 0.11.24 → 0.11.26
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.
- package/dist/sprintify-ui.es.js +6885 -6806
- package/dist/types/components/BaseLoadingCover.vue.d.ts +15 -0
- package/dist/types/composables/tooltip.d.ts +1 -1
- package/package.json +1 -1
- package/src/components/BaseLoadingCover.stories.js +1 -1
- package/src/components/BaseLoadingCover.vue +24 -9
- package/src/components/BaseTooltip.vue +37 -8
- package/src/composables/tooltip.ts +9 -2
|
@@ -42,6 +42,13 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
42
42
|
default: number;
|
|
43
43
|
type: NumberConstructor;
|
|
44
44
|
};
|
|
45
|
+
/**
|
|
46
|
+
* Maximum distance in pixels from the top of the loading cover for the spinner center.
|
|
47
|
+
*/
|
|
48
|
+
maxSpinnerTopOffset: {
|
|
49
|
+
default: number;
|
|
50
|
+
type: NumberConstructor;
|
|
51
|
+
};
|
|
45
52
|
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
46
53
|
/**
|
|
47
54
|
* Show/Hide the loading cover
|
|
@@ -85,6 +92,13 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
85
92
|
default: number;
|
|
86
93
|
type: NumberConstructor;
|
|
87
94
|
};
|
|
95
|
+
/**
|
|
96
|
+
* Maximum distance in pixels from the top of the loading cover for the spinner center.
|
|
97
|
+
*/
|
|
98
|
+
maxSpinnerTopOffset: {
|
|
99
|
+
default: number;
|
|
100
|
+
type: NumberConstructor;
|
|
101
|
+
};
|
|
88
102
|
}>> & Readonly<{}>, {
|
|
89
103
|
size: "sm" | "lg";
|
|
90
104
|
duration: string;
|
|
@@ -92,5 +106,6 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
92
106
|
modelValue: boolean;
|
|
93
107
|
twIcon: string;
|
|
94
108
|
twBackdrop: string;
|
|
109
|
+
maxSpinnerTopOffset: number;
|
|
95
110
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
96
111
|
export default _default;
|
|
@@ -3,5 +3,5 @@ type ReturnType = UseFloatingReturn & {
|
|
|
3
3
|
showTooltip: Ref<boolean>;
|
|
4
4
|
};
|
|
5
5
|
import { Ref } from "vue";
|
|
6
|
-
declare function useTooltip(reference: Readonly<Ref<MaybeElement<any>>>, floating: Readonly<Ref<MaybeElement<HTMLElement>>>, interactive?: boolean, delay?: number, options?: UseFloatingOptions | undefined, offset?: number): ReturnType;
|
|
6
|
+
declare function useTooltip(reference: Readonly<Ref<MaybeElement<any>>>, floating: Readonly<Ref<MaybeElement<HTMLElement>>>, interactive?: boolean, delay?: number, options?: UseFloatingOptions | undefined, offset?: number, arrowRef?: Readonly<Ref<MaybeElement<HTMLElement>>>): ReturnType;
|
|
7
7
|
export { useTooltip };
|
package/package.json
CHANGED
|
@@ -24,7 +24,7 @@ const Template = (args) => ({
|
|
|
24
24
|
return { args };
|
|
25
25
|
},
|
|
26
26
|
template: `
|
|
27
|
-
<div class="relative bg-slate-100 p-6
|
|
27
|
+
<div class="relative bg-slate-100 p-6 h-[1000px] border border-slate-700 border-dashed">
|
|
28
28
|
<p class="text-center text-slate-700">Non dolor consectetur et occaecat.</p>
|
|
29
29
|
<BaseLoadingCover v-bind="args" />
|
|
30
30
|
</div>
|
|
@@ -9,18 +9,23 @@
|
|
|
9
9
|
>
|
|
10
10
|
<div
|
|
11
11
|
v-if="showSpinner"
|
|
12
|
-
class="absolute inset-0
|
|
12
|
+
class="absolute inset-0 h-full w-full"
|
|
13
13
|
>
|
|
14
14
|
<div :class="twMerge('absolute h-full w-full bg-white', twBackdrop)" />
|
|
15
15
|
|
|
16
|
-
<
|
|
17
|
-
|
|
18
|
-
:
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
<div
|
|
17
|
+
class="absolute left-1/2 -translate-x-1/2 -translate-y-1/2"
|
|
18
|
+
:style="{ top: spinnerTopOffset }"
|
|
19
|
+
>
|
|
20
|
+
<BaseSpinnerSmall
|
|
21
|
+
v-if="size == 'sm'"
|
|
22
|
+
:class="twMerge('h-10 w-10 text-blue-500', twIcon)"
|
|
23
|
+
/>
|
|
24
|
+
<BaseSpinnerLarge
|
|
25
|
+
v-else-if="size == 'lg'"
|
|
26
|
+
:class="twMerge('h-10 w-10 text-blue-500', twIcon)"
|
|
27
|
+
/>
|
|
28
|
+
</div>
|
|
24
29
|
</div>
|
|
25
30
|
</Transition>
|
|
26
31
|
</template>
|
|
@@ -74,11 +79,21 @@ const props = defineProps({
|
|
|
74
79
|
default: 0,
|
|
75
80
|
type: Number,
|
|
76
81
|
},
|
|
82
|
+
/**
|
|
83
|
+
* Maximum distance in pixels from the top of the loading cover for the spinner center.
|
|
84
|
+
*/
|
|
85
|
+
maxSpinnerTopOffset: {
|
|
86
|
+
default: 200,
|
|
87
|
+
type: Number,
|
|
88
|
+
},
|
|
77
89
|
});
|
|
78
90
|
|
|
79
91
|
let timeoutId = null as number | null;
|
|
80
92
|
|
|
81
93
|
const showSpinner = ref(false);
|
|
94
|
+
const spinnerTopOffset = computed(
|
|
95
|
+
() => `min(50%, ${props.maxSpinnerTopOffset}px)`
|
|
96
|
+
);
|
|
82
97
|
|
|
83
98
|
watch(
|
|
84
99
|
() => props.modelValue,
|
|
@@ -26,13 +26,23 @@
|
|
|
26
26
|
v-if="showTooltip"
|
|
27
27
|
name="tooltip"
|
|
28
28
|
>
|
|
29
|
-
<div
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
29
|
+
<div class="relative filter drop-shadow-[0_1px_2px_rgba(0,0,0,0.1)]">
|
|
30
|
+
<div
|
|
31
|
+
class="text-xs max-w-xs leading-snug rounded-md pt-1.5 pb-2 px-3"
|
|
32
|
+
:class="[
|
|
33
|
+
dark ? 'bg-slate-900 text-white' : 'bg-white text-slate-900',
|
|
34
|
+
]"
|
|
35
|
+
v-html="text"
|
|
36
|
+
/>
|
|
37
|
+
<div
|
|
38
|
+
ref="arrowRef"
|
|
39
|
+
class="absolute w-2 h-2 rotate-45"
|
|
40
|
+
:class="[
|
|
41
|
+
dark ? 'bg-slate-900' : 'bg-white',
|
|
42
|
+
]"
|
|
43
|
+
:style="arrowStyles"
|
|
44
|
+
/>
|
|
45
|
+
</div>
|
|
36
46
|
</slot>
|
|
37
47
|
</transition>
|
|
38
48
|
</div>
|
|
@@ -78,7 +88,26 @@ const targetRef = ref<HTMLElement | null>(null);
|
|
|
78
88
|
const targetInternal = computed(() => unrefElement(targetRef));
|
|
79
89
|
|
|
80
90
|
const tooltipRef = ref<HTMLElement | null>(null)
|
|
91
|
+
const arrowRef = ref<HTMLElement | null>(null)
|
|
81
92
|
|
|
82
|
-
const { floatingStyles, showTooltip } = useTooltip(targetInternal, tooltipRef, props.interactive, props.delay, props.floatingOptions, props.offset);
|
|
93
|
+
const { floatingStyles, showTooltip, middlewareData, placement } = useTooltip(targetInternal, tooltipRef, props.interactive, props.delay, props.floatingOptions, props.offset, arrowRef);
|
|
94
|
+
|
|
95
|
+
const arrowStyles = computed(() => {
|
|
96
|
+
const arrow = middlewareData.value.arrow;
|
|
97
|
+
const style: Record<string, string> = {};
|
|
98
|
+
|
|
99
|
+
if (arrow?.x != null) {
|
|
100
|
+
style.left = `${arrow.x}px`;
|
|
101
|
+
}
|
|
102
|
+
if (arrow?.y != null) {
|
|
103
|
+
style.top = `${arrow.y}px`;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const side = placement.value.split('-')[0];
|
|
107
|
+
const staticSide = { top: 'bottom', right: 'left', bottom: 'top', left: 'right' }[side]!;
|
|
108
|
+
style[staticSide] = '-4px';
|
|
109
|
+
|
|
110
|
+
return style;
|
|
111
|
+
});
|
|
83
112
|
|
|
84
113
|
</script>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { UseFloatingOptions, MaybeElement, UseFloatingReturn, autoUpdate, flip, offset as offset2, shift, useFloating } from "@floating-ui/vue";
|
|
1
|
+
import { UseFloatingOptions, MaybeElement, UseFloatingReturn, autoUpdate, flip, offset as offset2, shift, arrow, useFloating } from "@floating-ui/vue";
|
|
2
2
|
import { unrefElement, useEventListener, } from "@vueuse/core";
|
|
3
3
|
import { debounce } from "lodash";
|
|
4
4
|
|
|
@@ -15,6 +15,7 @@ function useTooltip(
|
|
|
15
15
|
delay: number = 0,
|
|
16
16
|
options: UseFloatingOptions | undefined = undefined,
|
|
17
17
|
offset: number = 6,
|
|
18
|
+
arrowRef?: Readonly<Ref<MaybeElement<HTMLElement>>>,
|
|
18
19
|
): ReturnType {
|
|
19
20
|
|
|
20
21
|
const show = ref(false);
|
|
@@ -80,9 +81,15 @@ function useTooltip(
|
|
|
80
81
|
show.value = false;
|
|
81
82
|
}, 0);
|
|
82
83
|
|
|
84
|
+
const middleware = [offset2(offset), flip(), shift()];
|
|
85
|
+
|
|
86
|
+
if (arrowRef) {
|
|
87
|
+
middleware.push(arrow({ element: arrowRef }));
|
|
88
|
+
}
|
|
89
|
+
|
|
83
90
|
const config = {
|
|
84
91
|
placement: 'top',
|
|
85
|
-
middleware
|
|
92
|
+
middleware,
|
|
86
93
|
whileElementsMounted: autoUpdate,
|
|
87
94
|
};
|
|
88
95
|
|