@naptics/vue-collection 0.3.1 → 0.3.2
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/components/NBadge.d.ts +4 -0
- package/components/NButton.d.ts +4 -0
- package/components/NIconButton.d.ts +4 -0
- package/components/NInput.d.ts +4 -0
- package/components/NInputPhone.d.ts +4 -0
- package/components/NInputSelect.d.ts +4 -0
- package/components/NInputSuggestion.d.ts +4 -0
- package/components/NSelect.d.ts +4 -0
- package/components/NTextArea.d.ts +4 -0
- package/components/NTooltip.d.ts +16 -0
- package/components/NTooltip.js +39 -5
- package/components/NValInput.d.ts +4 -0
- package/package.json +3 -3
- package/src/demo/views/presentation/TooltipView.tsx +7 -1
- package/src/lib/components/NTooltip.tsx +41 -2
package/components/NBadge.d.ts
CHANGED
|
@@ -16,6 +16,10 @@ export declare const nBadgeProps: {
|
|
|
16
16
|
readonly tooltipWrapperClass: StringConstructor;
|
|
17
17
|
readonly tooltipContentClass: StringConstructor;
|
|
18
18
|
readonly tooltipArrowClass: StringConstructor;
|
|
19
|
+
readonly tooltipDelay: {
|
|
20
|
+
readonly type: NumberConstructor;
|
|
21
|
+
readonly default: 0;
|
|
22
|
+
};
|
|
19
23
|
/**
|
|
20
24
|
* The text of the badge. Can alternatively be passed in the default slot.
|
|
21
25
|
*/
|
package/components/NButton.d.ts
CHANGED
|
@@ -15,6 +15,10 @@ export declare const nButtonProps: {
|
|
|
15
15
|
readonly tooltipWrapperClass: StringConstructor;
|
|
16
16
|
readonly tooltipContentClass: StringConstructor;
|
|
17
17
|
readonly tooltipArrowClass: StringConstructor;
|
|
18
|
+
readonly tooltipDelay: {
|
|
19
|
+
readonly type: NumberConstructor;
|
|
20
|
+
readonly default: 0;
|
|
21
|
+
};
|
|
18
22
|
/**
|
|
19
23
|
* The color of the button.
|
|
20
24
|
*/
|
|
@@ -17,6 +17,10 @@ export declare const nIconButtonProps: {
|
|
|
17
17
|
readonly tooltipWrapperClass: StringConstructor;
|
|
18
18
|
readonly tooltipContentClass: StringConstructor;
|
|
19
19
|
readonly tooltipArrowClass: StringConstructor;
|
|
20
|
+
readonly tooltipDelay: {
|
|
21
|
+
readonly type: NumberConstructor;
|
|
22
|
+
readonly default: 0;
|
|
23
|
+
};
|
|
20
24
|
/**
|
|
21
25
|
* The icon of the icon-button.
|
|
22
26
|
*/
|
package/components/NInput.d.ts
CHANGED
|
@@ -16,6 +16,10 @@ export declare const nInputProps: {
|
|
|
16
16
|
readonly tooltipWrapperClass: StringConstructor;
|
|
17
17
|
readonly tooltipContentClass: StringConstructor;
|
|
18
18
|
readonly tooltipArrowClass: StringConstructor;
|
|
19
|
+
readonly tooltipDelay: {
|
|
20
|
+
readonly type: NumberConstructor;
|
|
21
|
+
readonly default: 0;
|
|
22
|
+
};
|
|
19
23
|
/**
|
|
20
24
|
* The name of the input. Is displayed as a label above the input.
|
|
21
25
|
*/
|
|
@@ -26,6 +26,10 @@ export declare const nInputPhoneProps: {
|
|
|
26
26
|
readonly tooltipWrapperClass: StringConstructor;
|
|
27
27
|
readonly tooltipContentClass: StringConstructor;
|
|
28
28
|
readonly tooltipArrowClass: StringConstructor;
|
|
29
|
+
readonly tooltipDelay: {
|
|
30
|
+
readonly type: NumberConstructor;
|
|
31
|
+
readonly default: 0;
|
|
32
|
+
};
|
|
29
33
|
readonly name: StringConstructor;
|
|
30
34
|
readonly placeholder: StringConstructor;
|
|
31
35
|
readonly autocomplete: {
|
|
@@ -68,6 +68,10 @@ export declare const nInputSelectProps: {
|
|
|
68
68
|
readonly tooltipWrapperClass: StringConstructor;
|
|
69
69
|
readonly tooltipContentClass: StringConstructor;
|
|
70
70
|
readonly tooltipArrowClass: StringConstructor;
|
|
71
|
+
readonly tooltipDelay: {
|
|
72
|
+
readonly type: NumberConstructor;
|
|
73
|
+
readonly default: 0;
|
|
74
|
+
};
|
|
71
75
|
readonly name: StringConstructor;
|
|
72
76
|
readonly placeholder: StringConstructor;
|
|
73
77
|
readonly autocomplete: {
|
|
@@ -46,6 +46,10 @@ export declare const nInputSuggestionProps: {
|
|
|
46
46
|
readonly tooltipWrapperClass: StringConstructor;
|
|
47
47
|
readonly tooltipContentClass: StringConstructor;
|
|
48
48
|
readonly tooltipArrowClass: StringConstructor;
|
|
49
|
+
readonly tooltipDelay: {
|
|
50
|
+
readonly type: NumberConstructor;
|
|
51
|
+
readonly default: 0;
|
|
52
|
+
};
|
|
49
53
|
readonly name: StringConstructor;
|
|
50
54
|
readonly placeholder: StringConstructor;
|
|
51
55
|
readonly autocomplete: {
|
package/components/NSelect.d.ts
CHANGED
|
@@ -17,6 +17,10 @@ export declare const nSelectProps: {
|
|
|
17
17
|
readonly tooltipWrapperClass: StringConstructor;
|
|
18
18
|
readonly tooltipContentClass: StringConstructor;
|
|
19
19
|
readonly tooltipArrowClass: StringConstructor;
|
|
20
|
+
readonly tooltipDelay: {
|
|
21
|
+
readonly type: NumberConstructor;
|
|
22
|
+
readonly default: 0;
|
|
23
|
+
};
|
|
20
24
|
/**
|
|
21
25
|
* The id of the currently selected option of this input.
|
|
22
26
|
*/
|
|
@@ -26,6 +26,10 @@ export declare const nTextAreaProps: {
|
|
|
26
26
|
readonly tooltipWrapperClass: StringConstructor;
|
|
27
27
|
readonly tooltipContentClass: StringConstructor;
|
|
28
28
|
readonly tooltipArrowClass: StringConstructor;
|
|
29
|
+
readonly tooltipDelay: {
|
|
30
|
+
readonly type: NumberConstructor;
|
|
31
|
+
readonly default: 0;
|
|
32
|
+
};
|
|
29
33
|
/**
|
|
30
34
|
* The name of the text area. Is displayed as a label above the text area.
|
|
31
35
|
*/
|
package/components/NTooltip.d.ts
CHANGED
|
@@ -51,6 +51,14 @@ export declare const nTooltipProps: {
|
|
|
51
51
|
* to target the arrow (which is the before element).
|
|
52
52
|
*/
|
|
53
53
|
readonly arrowClass: StringConstructor;
|
|
54
|
+
/**
|
|
55
|
+
* The delay in milliseconds before the tooltip is shown.
|
|
56
|
+
* @default 0
|
|
57
|
+
*/
|
|
58
|
+
readonly delay: {
|
|
59
|
+
readonly type: NumberConstructor;
|
|
60
|
+
readonly default: 0;
|
|
61
|
+
};
|
|
54
62
|
};
|
|
55
63
|
/**
|
|
56
64
|
* These props are made to use on a component which implements the tooltip
|
|
@@ -104,6 +112,13 @@ export declare const nToolTipPropsForImplementor: {
|
|
|
104
112
|
* @see {@link nTooltipProps.arrowClass}
|
|
105
113
|
*/
|
|
106
114
|
tooltipArrowClass: StringConstructor;
|
|
115
|
+
/**
|
|
116
|
+
* @see {@link nTooltipProps.delay}
|
|
117
|
+
*/
|
|
118
|
+
tooltipDelay: {
|
|
119
|
+
readonly type: NumberConstructor;
|
|
120
|
+
readonly default: 0;
|
|
121
|
+
};
|
|
107
122
|
};
|
|
108
123
|
/**
|
|
109
124
|
* Maps the {@link nToolTipPropsForImplementor} props to normal tooltip props
|
|
@@ -119,6 +134,7 @@ export declare function mapTooltipProps(props: ExtractedProps<typeof nToolTipPro
|
|
|
119
134
|
wrapperClass: string | undefined;
|
|
120
135
|
contentClass: string | undefined;
|
|
121
136
|
arrowClass: string | undefined;
|
|
137
|
+
delay: number;
|
|
122
138
|
};
|
|
123
139
|
/**
|
|
124
140
|
* The `NTooltip` is a wrapper for any component which adds a tooltip to it.
|
package/components/NTooltip.js
CHANGED
|
@@ -53,7 +53,15 @@ export const nTooltipProps = {
|
|
|
53
53
|
* Adds the classes to the tooltip arrow. Make sure to use `before:` classes
|
|
54
54
|
* to target the arrow (which is the before element).
|
|
55
55
|
*/
|
|
56
|
-
arrowClass: String
|
|
56
|
+
arrowClass: String,
|
|
57
|
+
/**
|
|
58
|
+
* The delay in milliseconds before the tooltip is shown.
|
|
59
|
+
* @default 0
|
|
60
|
+
*/
|
|
61
|
+
delay: {
|
|
62
|
+
type: Number,
|
|
63
|
+
default: 0
|
|
64
|
+
}
|
|
57
65
|
};
|
|
58
66
|
/**
|
|
59
67
|
* These props are made to use on a component which implements the tooltip
|
|
@@ -100,7 +108,11 @@ export const nToolTipPropsForImplementor = {
|
|
|
100
108
|
/**
|
|
101
109
|
* @see {@link nTooltipProps.arrowClass}
|
|
102
110
|
*/
|
|
103
|
-
tooltipArrowClass: nTooltipProps.arrowClass
|
|
111
|
+
tooltipArrowClass: nTooltipProps.arrowClass,
|
|
112
|
+
/**
|
|
113
|
+
* @see {@link nTooltipProps.delay}
|
|
114
|
+
*/
|
|
115
|
+
tooltipDelay: nTooltipProps.delay
|
|
104
116
|
};
|
|
105
117
|
/**
|
|
106
118
|
* Maps the {@link nToolTipPropsForImplementor} props to normal tooltip props
|
|
@@ -116,7 +128,8 @@ export function mapTooltipProps(props) {
|
|
|
116
128
|
maxWidth: props.tooltipMaxWidth,
|
|
117
129
|
wrapperClass: props.tooltipWrapperClass,
|
|
118
130
|
contentClass: props.tooltipContentClass,
|
|
119
|
-
arrowClass: props.tooltipArrowClass
|
|
131
|
+
arrowClass: props.tooltipArrowClass,
|
|
132
|
+
delay: props.tooltipDelay
|
|
120
133
|
};
|
|
121
134
|
}
|
|
122
135
|
/**
|
|
@@ -168,14 +181,35 @@ const NTooltipBase = createComponent('NTooltipBase', nTooltipProps, (props, {
|
|
|
168
181
|
popperInstance = null;
|
|
169
182
|
}
|
|
170
183
|
onMounted(createTooltip);
|
|
171
|
-
onUnmounted(
|
|
184
|
+
onUnmounted(() => {
|
|
185
|
+
if (hoverTimeout) {
|
|
186
|
+
clearTimeout(hoverTimeout);
|
|
187
|
+
}
|
|
188
|
+
destroyTooltip();
|
|
189
|
+
});
|
|
172
190
|
watch(() => props.placement, newPlacement => popperInstance?.setOptions({
|
|
173
191
|
placement: newPlacement
|
|
174
192
|
}));
|
|
175
193
|
const isHoveringContent = ref(false);
|
|
176
194
|
const isHoveringTooltip = ref(false);
|
|
177
195
|
const isHovering = computed(() => isHoveringContent.value || isHoveringTooltip.value);
|
|
178
|
-
const
|
|
196
|
+
const delayedIsHovering = ref(false);
|
|
197
|
+
let hoverTimeout = null;
|
|
198
|
+
const showTooltip = computed(() => props.show || !props.hide && (props.delay > 0 ? delayedIsHovering.value : isHovering.value));
|
|
199
|
+
watch(isHovering, hovering => {
|
|
200
|
+
if (hoverTimeout) {
|
|
201
|
+
clearTimeout(hoverTimeout);
|
|
202
|
+
hoverTimeout = null;
|
|
203
|
+
}
|
|
204
|
+
if (hovering && props.delay > 0) {
|
|
205
|
+
hoverTimeout = setTimeout(() => {
|
|
206
|
+
delayedIsHovering.value = true;
|
|
207
|
+
hoverTimeout = null;
|
|
208
|
+
}, props.delay);
|
|
209
|
+
} else {
|
|
210
|
+
delayedIsHovering.value = hovering;
|
|
211
|
+
}
|
|
212
|
+
});
|
|
179
213
|
watchRef(showTooltip, () => popperInstance?.update());
|
|
180
214
|
return () => _createVNode(_Fragment, null, [_createVNode("div", {
|
|
181
215
|
"class": "p-[10px] -m-[10px]",
|
|
@@ -109,6 +109,10 @@ export declare const nValInputProps: {
|
|
|
109
109
|
readonly tooltipWrapperClass: StringConstructor;
|
|
110
110
|
readonly tooltipContentClass: StringConstructor;
|
|
111
111
|
readonly tooltipArrowClass: StringConstructor;
|
|
112
|
+
readonly tooltipDelay: {
|
|
113
|
+
readonly type: NumberConstructor;
|
|
114
|
+
readonly default: 0;
|
|
115
|
+
};
|
|
112
116
|
readonly name: StringConstructor;
|
|
113
117
|
readonly placeholder: StringConstructor;
|
|
114
118
|
readonly autocomplete: {
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@naptics/vue-collection",
|
|
3
|
-
"author": "Timo Siegenthaler",
|
|
3
|
+
"author": "Timo Siegenthaler and Jonas Schoch",
|
|
4
4
|
"description": "Vue Collection is a collection of styled and fully functional Vue components which can easily be integrated into our projects.",
|
|
5
|
-
"version": "0.3.
|
|
5
|
+
"version": "0.3.2",
|
|
6
6
|
"main": "./index.js",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"autoprefixer": "^10.4.13",
|
|
49
49
|
"eslint": "^9.17.0",
|
|
50
50
|
"eslint-plugin-vue": "^10.6.2",
|
|
51
|
-
"jsdom": "^
|
|
51
|
+
"jsdom": "^29.0.2",
|
|
52
52
|
"npm-run-all": "^4.1.5",
|
|
53
53
|
"postcss": "^8.4.21",
|
|
54
54
|
"prettier": "^3.0.0",
|
|
@@ -20,7 +20,7 @@ export default createView('TooltipView', () => {
|
|
|
20
20
|
title="Customization"
|
|
21
21
|
subtitle="The content of a tooltip can be a simple text or there is a slot available for customization. More properties like placement, maximum width and more can be configured."
|
|
22
22
|
>
|
|
23
|
-
<ComponentGrid cols={
|
|
23
|
+
<ComponentGrid cols={5}>
|
|
24
24
|
<div class="flex">
|
|
25
25
|
<NTooltip text="Hello tooltip!">
|
|
26
26
|
<NBadge text="Hover me" />
|
|
@@ -57,6 +57,12 @@ export default createView('TooltipView', () => {
|
|
|
57
57
|
<NBadge text="Hover me" />
|
|
58
58
|
</NTooltip>
|
|
59
59
|
</div>
|
|
60
|
+
|
|
61
|
+
<div class="flex">
|
|
62
|
+
<NTooltip text="I'm delayed 500ms, sorry." delay={500}>
|
|
63
|
+
<NBadge text="Delay" />
|
|
64
|
+
</NTooltip>
|
|
65
|
+
</div>
|
|
60
66
|
</ComponentGrid>
|
|
61
67
|
</VariantSection>
|
|
62
68
|
|
|
@@ -55,6 +55,14 @@ export const nTooltipProps = {
|
|
|
55
55
|
* to target the arrow (which is the before element).
|
|
56
56
|
*/
|
|
57
57
|
arrowClass: String,
|
|
58
|
+
/**
|
|
59
|
+
* The delay in milliseconds before the tooltip is shown.
|
|
60
|
+
* @default 0
|
|
61
|
+
*/
|
|
62
|
+
delay: {
|
|
63
|
+
type: Number,
|
|
64
|
+
default: 0,
|
|
65
|
+
},
|
|
58
66
|
} as const
|
|
59
67
|
|
|
60
68
|
/**
|
|
@@ -103,6 +111,10 @@ export const nToolTipPropsForImplementor = {
|
|
|
103
111
|
* @see {@link nTooltipProps.arrowClass}
|
|
104
112
|
*/
|
|
105
113
|
tooltipArrowClass: nTooltipProps.arrowClass,
|
|
114
|
+
/**
|
|
115
|
+
* @see {@link nTooltipProps.delay}
|
|
116
|
+
*/
|
|
117
|
+
tooltipDelay: nTooltipProps.delay,
|
|
106
118
|
}
|
|
107
119
|
|
|
108
120
|
/**
|
|
@@ -120,6 +132,7 @@ export function mapTooltipProps(props: ExtractedProps<typeof nToolTipPropsForImp
|
|
|
120
132
|
wrapperClass: props.tooltipWrapperClass,
|
|
121
133
|
contentClass: props.tooltipContentClass,
|
|
122
134
|
arrowClass: props.tooltipArrowClass,
|
|
135
|
+
delay: props.tooltipDelay,
|
|
123
136
|
}
|
|
124
137
|
}
|
|
125
138
|
|
|
@@ -179,7 +192,12 @@ const NTooltipBase = createComponent('NTooltipBase', nTooltipProps, (props, { sl
|
|
|
179
192
|
}
|
|
180
193
|
|
|
181
194
|
onMounted(createTooltip)
|
|
182
|
-
onUnmounted(
|
|
195
|
+
onUnmounted(() => {
|
|
196
|
+
if (hoverTimeout) {
|
|
197
|
+
clearTimeout(hoverTimeout)
|
|
198
|
+
}
|
|
199
|
+
destroyTooltip()
|
|
200
|
+
})
|
|
183
201
|
|
|
184
202
|
watch(
|
|
185
203
|
() => props.placement,
|
|
@@ -189,7 +207,28 @@ const NTooltipBase = createComponent('NTooltipBase', nTooltipProps, (props, { sl
|
|
|
189
207
|
const isHoveringContent = ref(false)
|
|
190
208
|
const isHoveringTooltip = ref(false)
|
|
191
209
|
const isHovering = computed(() => isHoveringContent.value || isHoveringTooltip.value)
|
|
192
|
-
const
|
|
210
|
+
const delayedIsHovering = ref(false)
|
|
211
|
+
let hoverTimeout: ReturnType<typeof setTimeout> | null = null
|
|
212
|
+
|
|
213
|
+
const showTooltip = computed(
|
|
214
|
+
() => props.show || (!props.hide && (props.delay > 0 ? delayedIsHovering.value : isHovering.value))
|
|
215
|
+
)
|
|
216
|
+
|
|
217
|
+
watch(isHovering, hovering => {
|
|
218
|
+
if (hoverTimeout) {
|
|
219
|
+
clearTimeout(hoverTimeout)
|
|
220
|
+
hoverTimeout = null
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
if (hovering && props.delay > 0) {
|
|
224
|
+
hoverTimeout = setTimeout(() => {
|
|
225
|
+
delayedIsHovering.value = true
|
|
226
|
+
hoverTimeout = null
|
|
227
|
+
}, props.delay)
|
|
228
|
+
} else {
|
|
229
|
+
delayedIsHovering.value = hovering
|
|
230
|
+
}
|
|
231
|
+
})
|
|
193
232
|
|
|
194
233
|
watchRef(showTooltip, () => popperInstance?.update())
|
|
195
234
|
|