@naptics/vue-collection 0.3.0 → 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.
@@ -47,15 +47,9 @@ jobs:
47
47
  id: nvm
48
48
  - name: Setup node environment
49
49
  uses: actions/setup-node@v4
50
- env:
51
- NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
52
50
  with:
53
51
  node-version: ${{ steps.nvm.outputs.NVMRC }}
54
52
  registry-url: https://registry.npmjs.org/
55
- # Ensure npm 11.5.1 or later for trusted publishing
56
- - name: Ensure latest npm version
57
- run: npm --version
58
- - run: npm install -g npm@latest --no-man
59
53
  - name: Download library artifact
60
54
  uses: actions/download-artifact@v4
61
55
  with:
@@ -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
  */
@@ -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
  */
@@ -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: {
@@ -29,6 +29,11 @@ export declare const nLinkProps: {
29
29
  readonly type: NumberConstructor;
30
30
  readonly default: 500;
31
31
  };
32
+ /**
33
+ * If set to `true` the link is disabled and no interaction is possible.
34
+ * Note: If the `route` prop is set, the link will still be clickable, because it becomes a {@link RouterLink}.
35
+ */
36
+ readonly disabled: BooleanConstructor;
32
37
  /**
33
38
  * This is called when the link is clicked but only, if the `route` prop is not set.
34
39
  * If the `route` prop is not set, the link will act as a regular button.
@@ -30,6 +30,11 @@ export const nLinkProps = {
30
30
  type: Number,
31
31
  default: 500
32
32
  },
33
+ /**
34
+ * If set to `true` the link is disabled and no interaction is possible.
35
+ * Note: If the `route` prop is set, the link will still be clickable, because it becomes a {@link RouterLink}.
36
+ */
37
+ disabled: Boolean,
33
38
  /**
34
39
  * This is called when the link is clicked but only, if the `route` prop is not set.
35
40
  * If the `route` prop is not set, the link will act as a regular button.
@@ -47,6 +52,7 @@ const Component = createComponent('NLink', nLinkProps, (props, {
47
52
  if (shade <= 500) return shade + 100;else return shade - 200;
48
53
  });
49
54
  const classes = computed(() => ['font-medium focus:outline-none focus-visible:ring-2 rounded-sm ring-offset-2 hover:underline text-left', `${props.textSize} text-${props.color}-${props.shade} hover:text-${props.color}-${hoverShade.value} focus-visible:ring-${props.color}-${props.shade}`]);
55
+ const disabledClasses = computed(() => ['font-medium text-left cursor-not-allowed', `${props.textSize} text-${props.color}-200`]);
50
56
  return () => props.route ? _createVNode(RouterLink, {
51
57
  "to": props.route,
52
58
  "class": classes.value
@@ -54,7 +60,8 @@ const Component = createComponent('NLink', nLinkProps, (props, {
54
60
  default: () => [slots.default?.() || props.text]
55
61
  }) : _createVNode("button", {
56
62
  "onClick": props.onClick,
57
- "class": classes.value
63
+ "class": props.disabled ? disabledClasses.value : classes.value,
64
+ "disabled": props.disabled
58
65
  }, [slots.default?.() || props.text]);
59
66
  });
60
67
  export { Component as NLink, Component as default };
@@ -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
  */
@@ -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.
@@ -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(destroyTooltip);
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 showTooltip = computed(() => props.show || !props.hide && isHovering.value);
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.0",
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": "^21.1.0",
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",
@@ -45,6 +45,16 @@ export default createView('LinkView', () => {
45
45
  </div>
46
46
  </ComponentGrid>
47
47
  </VariantSection>
48
+ <VariantSection title="Disabled Links">
49
+ <ComponentGrid cols={4}>
50
+ <div>
51
+ <NLink text="Disabled Link" disabled />
52
+ </div>
53
+ <div>
54
+ <NLink text="Disabled Link" onClick={hi} color="secondary" disabled />
55
+ </div>
56
+ </ComponentGrid>
57
+ </VariantSection>
48
58
  </ComponentSection>
49
59
  )
50
60
  })
@@ -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={4}>
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
 
@@ -31,6 +31,12 @@ export const nLinkProps = {
31
31
  type: Number,
32
32
  default: 500,
33
33
  },
34
+
35
+ /**
36
+ * If set to `true` the link is disabled and no interaction is possible.
37
+ * Note: If the `route` prop is set, the link will still be clickable, because it becomes a {@link RouterLink}.
38
+ */
39
+ disabled: Boolean,
34
40
  /**
35
41
  * This is called when the link is clicked but only, if the `route` prop is not set.
36
42
  * If the `route` prop is not set, the link will act as a regular button.
@@ -52,6 +58,10 @@ const Component = createComponent('NLink', nLinkProps, (props, { slots }) => {
52
58
  'font-medium focus:outline-none focus-visible:ring-2 rounded-sm ring-offset-2 hover:underline text-left',
53
59
  `${props.textSize} text-${props.color}-${props.shade} hover:text-${props.color}-${hoverShade.value} focus-visible:ring-${props.color}-${props.shade}`,
54
60
  ])
61
+ const disabledClasses = computed(() => [
62
+ 'font-medium text-left cursor-not-allowed',
63
+ `${props.textSize} text-${props.color}-200`,
64
+ ])
55
65
 
56
66
  return () =>
57
67
  props.route ? (
@@ -59,7 +69,11 @@ const Component = createComponent('NLink', nLinkProps, (props, { slots }) => {
59
69
  {slots.default?.() || props.text}
60
70
  </RouterLink>
61
71
  ) : (
62
- <button onClick={props.onClick} class={classes.value}>
72
+ <button
73
+ onClick={props.onClick}
74
+ class={props.disabled ? disabledClasses.value : classes.value}
75
+ disabled={props.disabled}
76
+ >
63
77
  {slots.default?.() || props.text}
64
78
  </button>
65
79
  )
@@ -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(destroyTooltip)
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 showTooltip = computed(() => props.show || (!props.hide && isHovering.value))
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