@antify/ui 4.1.18 → 4.1.20

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.
@@ -1,6 +1,6 @@
1
1
  <script lang="ts" setup>
2
2
  import {
3
- computed, onMounted, ref,
3
+ computed, onMounted,
4
4
  } from 'vue';
5
5
  import AntField from '../forms/AntField.vue';
6
6
  import AntBaseInput from './Elements/AntBaseInput.vue';
@@ -67,7 +67,9 @@ const emit = defineEmits([
67
67
  'validate',
68
68
  ]);
69
69
  const _modelValue = useVModel(props, 'modelValue', emit);
70
- const _inputRef = useVModel(props, 'inputRef', emit);
70
+ const _inputRef = defineModel<HTMLInputElement | null>('inputRef', {
71
+ default: null,
72
+ });
71
73
  const iconColor = computed(() => {
72
74
  switch (props.state) {
73
75
  case InputState.info:
@@ -92,11 +94,11 @@ onMounted(() => {
92
94
  });
93
95
 
94
96
  function onClickCalendar() {
95
- if (!props.disabled && !props.readonly) {
96
- _inputRef.value?.showPicker();
97
- } else {
97
+ if (props.disabled || props.readonly) {
98
98
  return;
99
99
  }
100
+
101
+ _inputRef.value?.showPicker();
100
102
  }
101
103
  </script>
102
104
 
@@ -10,20 +10,31 @@ import {
10
10
  faChevronDown, faChevronUp,
11
11
  } from '@fortawesome/free-solid-svg-icons';
12
12
  import AntTransitionCollapseHeight from '../transitions/AntTransitionCollapseHeight.vue';
13
+ import AntTooltip from '../AntTooltip.vue';
13
14
 
14
15
  const props = defineProps<{
15
16
  navbarItem: NavbarItemTypes;
16
17
  }>();
17
18
 
19
+ const shouldRenderTooltip = computed(() =>
20
+ props.navbarItem.disabled && !!props.navbarItem.tooltipMessage
21
+ );
22
+
18
23
  const itemClasses = computed(() => ({
19
24
  'w-full text-sm p-1.5 rounded-md cursor-pointer flex items-center flex-nowrap gap-1': true,
20
25
  'transition-colors hover:bg-base-100': true,
21
26
  'text-primary-500': props.navbarItem.active,
27
+ 'cursor-default opacity-50': props.navbarItem.disabled,
28
+ 'transition-colors hover:bg-base-100 cursor-pointer': !props.navbarItem.disabled,
22
29
  }));
23
30
 
24
31
  const open = ref(false);
25
32
 
26
33
  function itemClick(): void {
34
+ if (props.navbarItem.disabled) {
35
+ return;
36
+ }
37
+
27
38
  if (props.navbarItem.click) {
28
39
  props.navbarItem.click();
29
40
  }
@@ -36,38 +47,37 @@ function itemClick(): void {
36
47
 
37
48
  <template>
38
49
  <component
39
- :is="navbarItem.to ? 'router-link' : 'div'"
40
- :to="navbarItem.to"
41
- v-bind="$attrs"
42
- :class="itemClasses"
43
- @click="itemClick"
44
- data-e2e="navbar-item"
50
+ :is="shouldRenderTooltip ? AntTooltip : 'div'"
45
51
  >
46
- <AntIcon
47
- v-if="navbarItem.icon"
48
- :icon="navbarItem.icon"
49
- :color="navbarItem.active ? 'text-primary-500' : 'text-for-white-bg-font'"
50
- />
51
-
52
- <div class="grow select-none">
53
- {{ navbarItem.label }}
54
- </div>
55
-
56
- <div
57
- v-if="navbarItem.children && navbarItem.children.length > 0"
52
+ <component
53
+ :is="navbarItem.to && !navbarItem.disabled ? 'router-link' : 'div'"
54
+ :to="navbarItem.to && !navbarItem.disabled ? navbarItem.to : undefined"
55
+ v-bind="$attrs"
56
+ :class="itemClasses"
57
+ @click.stop="itemClick"
58
+ data-e2e="navbar-item"
58
59
  >
59
60
  <AntIcon
60
- v-if="!open"
61
- :icon="faChevronDown"
61
+ v-if="navbarItem.icon"
62
+ :icon="navbarItem.icon"
62
63
  :color="navbarItem.active ? 'text-primary-500' : 'text-for-white-bg-font'"
63
64
  />
64
65
 
65
- <AntIcon
66
- v-if="open"
67
- :icon="faChevronUp"
68
- :color="navbarItem.active ? 'text-primary-500' : 'text-for-white-bg-font'"
69
- />
70
- </div>
66
+ <div class="grow select-none">
67
+ {{ navbarItem.label }}
68
+ </div>
69
+
70
+ <div v-if="navbarItem.children && navbarItem.children.length > 0">
71
+ <AntIcon
72
+ :icon="open ? faChevronUp : faChevronDown"
73
+ :color="navbarItem.active ? 'text-primary-500' : 'text-for-white-bg-font'"
74
+ />
75
+ </div>
76
+ </component>
77
+
78
+ <template #content v-if="shouldRenderTooltip">
79
+ <div>{{ navbarItem.tooltipMessage }}</div>
80
+ </template>
71
81
  </component>
72
82
 
73
83
  <AntTransitionCollapseHeight
@@ -43,7 +43,9 @@ const Docs = exports.Docs = {
43
43
  }]
44
44
  }, {
45
45
  icon: _freeSolidSvgIcons.faBook,
46
- label: "Navbar item"
46
+ label: "Navbar item",
47
+ disabled: true,
48
+ tooltipMessage: "Du hast keine Berechtigung um Rollen zu sehen."
47
49
  }, {
48
50
  label: "Navbar item"
49
51
  }, {
@@ -44,7 +44,9 @@ export const Docs = {
44
44
  },
45
45
  {
46
46
  icon: faBook,
47
- label: "Navbar item"
47
+ label: "Navbar item",
48
+ disabled: true,
49
+ tooltipMessage: "Du hast keine Berechtigung um Rollen zu sehen."
48
50
  },
49
51
  {
50
52
  label: "Navbar item"
@@ -7,4 +7,6 @@ export type NavbarItemTypes = {
7
7
  click?: () => void;
8
8
  icon?: IconDefinition;
9
9
  children?: NavbarItemTypes[];
10
+ disabled?: boolean;
11
+ tooltipMessage?: string;
10
12
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antify/ui",
3
- "version": "4.1.18",
3
+ "version": "4.1.20",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "exports": {