@saasmakers/ui 0.1.73 → 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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
2
|
import type { BaseTags } from '../../types/bases'
|
|
3
3
|
|
|
4
|
-
const props = withDefaults(defineProps<Omit<BaseTags, '
|
|
4
|
+
const props = withDefaults(defineProps<Omit<BaseTags, 'modelValue'>>(), {
|
|
5
5
|
active: false,
|
|
6
6
|
clickable: true,
|
|
7
7
|
draggable: false,
|
|
@@ -27,7 +27,7 @@ const emit = defineEmits<{
|
|
|
27
27
|
update: [event: FocusEvent | KeyboardEvent, name: string, tagId?: number | string]
|
|
28
28
|
}>()
|
|
29
29
|
|
|
30
|
-
const modelValue = defineModel<
|
|
30
|
+
const modelValue = defineModel<BaseTags['modelValue']>({ default: () => [] })
|
|
31
31
|
|
|
32
32
|
const keyForTagCreation = ref(Date.now())
|
|
33
33
|
const keyForTagUpdate = ref(Date.now())
|
|
@@ -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':
|
|
65
|
-
'text-gray-700 dark:text-gray-300 hover:text-gray-900 dark:hover:text-gray-100':
|
|
66
|
-
'flex-1': !minimizeOnMobile ||
|
|
67
|
-
'flex-2 sm:flex-1': minimizeOnMobile &&
|
|
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':
|
|
78
|
-
'border-gray-100 dark:border-gray-900':
|
|
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':
|
|
82
|
-
'bg-gray-200 dark:bg-gray-800':
|
|
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="
|
|
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 &&
|
|
104
|
+
:class="{ 'hidden sm:inline': minimizeOnMobile && !isTabActive(tab.value) }"
|
|
97
105
|
>
|
|
98
106
|
{{ tab.label }}
|
|
99
107
|
</span>
|
package/app/types/bases.d.ts
CHANGED
|
@@ -295,12 +295,12 @@ export interface BaseTags {
|
|
|
295
295
|
hasBack?: boolean
|
|
296
296
|
hasCreation?: boolean
|
|
297
297
|
maxTags?: number
|
|
298
|
+
modelValue: (number | string)[]
|
|
298
299
|
removable?: boolean
|
|
299
300
|
selectable?: boolean
|
|
300
301
|
selectableUnique?: boolean
|
|
301
302
|
size?: BaseTagSize
|
|
302
303
|
tags: BaseTag[]
|
|
303
|
-
value?: (number | string)[]
|
|
304
304
|
wrap?: boolean
|
|
305
305
|
}
|
|
306
306
|
|
package/app/types/fields.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export interface FieldCheckbox {
|
|
|
13
13
|
labelIcon?: string
|
|
14
14
|
lineThrough?: boolean
|
|
15
15
|
loading?: boolean
|
|
16
|
-
modelValue
|
|
16
|
+
modelValue: boolean
|
|
17
17
|
required?: boolean
|
|
18
18
|
size?: FieldSize
|
|
19
19
|
truncate?: boolean
|
|
@@ -22,11 +22,11 @@ export interface FieldCheckbox {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
export interface FieldDays {
|
|
25
|
-
modelValue
|
|
25
|
+
modelValue: number[]
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
export interface FieldEmojis {
|
|
29
|
-
modelValue
|
|
29
|
+
modelValue: string
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
export interface FieldInput {
|
|
@@ -93,7 +93,7 @@ export interface FieldSelect {
|
|
|
93
93
|
label?: BaseTextText
|
|
94
94
|
labelIcon?: string
|
|
95
95
|
maxHeight?: FieldSelectMaxHeight
|
|
96
|
-
modelValue
|
|
96
|
+
modelValue: string
|
|
97
97
|
openOnHover?: boolean
|
|
98
98
|
options?: FieldSelectOption[]
|
|
99
99
|
padding?: boolean
|
|
@@ -122,7 +122,7 @@ export type FieldSelectMaxHeight = 'lg' | 'md' | 'sm' | 'xs'
|
|
|
122
122
|
|
|
123
123
|
export interface FieldTabs {
|
|
124
124
|
minimizeOnMobile?: boolean
|
|
125
|
-
modelValue
|
|
125
|
+
modelValue: Array<number | string> | number | string
|
|
126
126
|
multiple?: boolean
|
|
127
127
|
size?: FieldSize
|
|
128
128
|
tabs: FieldTabsTab[]
|
|
@@ -152,7 +152,7 @@ export interface FieldTextarea {
|
|
|
152
152
|
label?: BaseTextText
|
|
153
153
|
labelIcon?: string
|
|
154
154
|
loading?: boolean
|
|
155
|
-
modelValue
|
|
155
|
+
modelValue: string
|
|
156
156
|
padding?: boolean
|
|
157
157
|
placeholder?: string
|
|
158
158
|
required?: boolean
|