@saasmakers/ui 0.1.74 → 0.1.75

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.
@@ -17,6 +17,14 @@ const emit = defineEmits<{
17
17
 
18
18
  const modelValue = defineModel<FieldTabs['modelValue']>({ default: () => [] })
19
19
 
20
+ function isTabActive(tabValue: number | string) {
21
+ if (props.multiple) {
22
+ return Array.isArray(modelValue.value) && modelValue.value.includes(tabValue)
23
+ }
24
+
25
+ return modelValue.value === tabValue
26
+ }
27
+
20
28
  function onTabClick(event: MouseEvent, tabValue: number | string) {
21
29
  let activeTabs = [tabValue]
22
30
 
@@ -61,10 +69,10 @@ function onTabClick(event: MouseEvent, tabValue: number | string) {
61
69
  :key="tab.value"
62
70
  class="flex cursor-pointer items-center justify-center text-xs"
63
71
  :class="{
64
- 'text-gray-900 dark:text-gray-100': modelValue === tab.value,
65
- 'text-gray-700 dark:text-gray-300 hover:text-gray-900 dark:hover:text-gray-100': modelValue !== tab.value,
66
- 'flex-1': !minimizeOnMobile || modelValue !== tab.value,
67
- 'flex-2 sm:flex-1': minimizeOnMobile && modelValue === tab.value,
72
+ 'text-gray-900 dark:text-gray-100': isTabActive(tab.value),
73
+ 'text-gray-700 dark:text-gray-300 hover:text-gray-900 dark:hover:text-gray-100': !isTabActive(tab.value),
74
+ 'flex-1': !minimizeOnMobile || !isTabActive(tab.value),
75
+ 'flex-2 sm:flex-1': minimizeOnMobile && isTabActive(tab.value),
68
76
 
69
77
  'py-1.5 px-2.5': size === 'xs' && theme === 'rounded',
70
78
  'py-2 px-3': size === 'sm' && theme === 'rounded',
@@ -74,12 +82,12 @@ function onTabClick(event: MouseEvent, tabValue: number | string) {
74
82
  'py-4 px-5': size === 'lg' && theme === 'border',
75
83
 
76
84
  'border-b-2 border-gray-300 dark:border-gray-700 transition duration-500': theme === 'border',
77
- 'border-gray-900 dark:border-gray-100': modelValue === tab.value && theme === 'border',
78
- 'border-gray-100 dark:border-gray-900': modelValue !== tab.value && theme === 'border',
85
+ 'border-gray-900 dark:border-gray-100': isTabActive(tab.value) && theme === 'border',
86
+ 'border-gray-100 dark:border-gray-900': !isTabActive(tab.value) && theme === 'border',
79
87
 
80
88
  'rounded-lg': theme === 'rounded',
81
- 'bg-white dark:bg-gray-900 shadow': modelValue === tab.value && theme === 'rounded',
82
- 'bg-gray-200 dark:bg-gray-800': modelValue !== tab.value && theme === 'rounded',
89
+ 'bg-white dark:bg-gray-900 shadow': isTabActive(tab.value) && theme === 'rounded',
90
+ 'bg-gray-200 dark:bg-gray-800': !isTabActive(tab.value) && theme === 'rounded',
83
91
  }"
84
92
  :to="tab.to"
85
93
  @click="onTabClick($event, tab.value)"
@@ -87,13 +95,13 @@ function onTabClick(event: MouseEvent, tabValue: number | string) {
87
95
  <BaseIcon
88
96
  v-if="tab.icon"
89
97
  class="mr-1.5 flex-initial"
90
- :color="modelValue === tab.value ? tab.activeColor : 'black'"
98
+ :color="isTabActive(tab.value) ? tab.activeColor : 'black'"
91
99
  :icon="tab.icon"
92
100
  />
93
101
 
94
102
  <span
95
103
  class="flex-initial"
96
- :class="{ 'hidden sm:inline': minimizeOnMobile && modelValue !== tab.value }"
104
+ :class="{ 'hidden sm:inline': minimizeOnMobile && !isTabActive(tab.value) }"
97
105
  >
98
106
  {{ tab.label }}
99
107
  </span>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@saasmakers/ui",
3
3
  "type": "module",
4
- "version": "0.1.74",
4
+ "version": "0.1.75",
5
5
  "private": false,
6
6
  "description": "Reusable Nuxt UI components for SaaS Makers projects",
7
7
  "license": "MIT",