@innertia-solutions/ui 0.1.1 → 0.1.4
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/Forms/Input.vue +72 -0
- package/components/Nav/Tabs.vue +39 -0
- package/nuxt.config.ts +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { ref, computed } from 'vue'
|
|
3
|
+
import { IconEye, IconEyeOff } from '@tabler/icons-vue'
|
|
4
|
+
|
|
5
|
+
const props = defineProps<{
|
|
6
|
+
type?: 'text' | 'email' | 'password' | 'number' | 'tel' | 'url' | 'search'
|
|
7
|
+
placeholder?: string
|
|
8
|
+
disabled?: boolean
|
|
9
|
+
error?: string | null
|
|
10
|
+
label?: string
|
|
11
|
+
hint?: string
|
|
12
|
+
iconLeft?: object | Function | null
|
|
13
|
+
autocomplete?: string
|
|
14
|
+
}>()
|
|
15
|
+
|
|
16
|
+
const modelValue = defineModel<string | number | null>({ default: '' })
|
|
17
|
+
|
|
18
|
+
const showPassword = ref(false)
|
|
19
|
+
|
|
20
|
+
const inputType = computed(() => {
|
|
21
|
+
if (props.type === 'password') return showPassword.value ? 'text' : 'password'
|
|
22
|
+
return props.type ?? 'text'
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
const baseClasses = 'py-2 px-3 block w-full rounded-lg text-sm text-slate-800 border border-gray-200 dark:border-slate-700 focus:ring-0 focus:border-gray-400 focus:outline-none disabled:opacity-50 dark:bg-transparent dark:text-slate-300 transition-colors placeholder:text-slate-400 dark:placeholder:text-slate-500'
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
<template>
|
|
29
|
+
<div class="w-full">
|
|
30
|
+
<label v-if="label" class="block text-sm font-medium text-slate-700 dark:text-slate-300 mb-1.5">
|
|
31
|
+
{{ label }}
|
|
32
|
+
</label>
|
|
33
|
+
|
|
34
|
+
<div class="relative">
|
|
35
|
+
<!-- Ícono izquierdo -->
|
|
36
|
+
<div v-if="iconLeft" class="absolute inset-y-0 start-0 flex items-center ps-3 pointer-events-none text-slate-400">
|
|
37
|
+
<component :is="iconLeft" class="size-4" />
|
|
38
|
+
</div>
|
|
39
|
+
|
|
40
|
+
<input
|
|
41
|
+
v-model="modelValue"
|
|
42
|
+
:type="inputType"
|
|
43
|
+
:placeholder="placeholder"
|
|
44
|
+
:disabled="disabled"
|
|
45
|
+
:autocomplete="autocomplete"
|
|
46
|
+
:class="[
|
|
47
|
+
baseClasses,
|
|
48
|
+
iconLeft ? 'ps-9' : '',
|
|
49
|
+
type === 'password' ? 'pe-10' : '',
|
|
50
|
+
error ? '!border-red-400 dark:!border-red-500' : '',
|
|
51
|
+
]"
|
|
52
|
+
/>
|
|
53
|
+
|
|
54
|
+
<!-- Toggle contraseña -->
|
|
55
|
+
<button
|
|
56
|
+
v-if="type === 'password'"
|
|
57
|
+
type="button"
|
|
58
|
+
tabindex="-1"
|
|
59
|
+
class="absolute inset-y-0 end-0 flex items-center px-3 text-slate-400 hover:text-slate-600 dark:hover:text-slate-300 transition-colors"
|
|
60
|
+
@click="showPassword = !showPassword"
|
|
61
|
+
>
|
|
62
|
+
<component :is="showPassword ? IconEyeOff : IconEye" class="size-4" />
|
|
63
|
+
</button>
|
|
64
|
+
</div>
|
|
65
|
+
|
|
66
|
+
<!-- Error -->
|
|
67
|
+
<p v-if="error" class="text-xs text-red-500 dark:text-red-400 mt-1">{{ error }}</p>
|
|
68
|
+
|
|
69
|
+
<!-- Hint -->
|
|
70
|
+
<p v-else-if="hint" class="text-xs text-slate-400 mt-1">{{ hint }}</p>
|
|
71
|
+
</div>
|
|
72
|
+
</template>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { useRoute } from 'vue-router'
|
|
3
|
+
|
|
4
|
+
interface Tab {
|
|
5
|
+
label: string
|
|
6
|
+
to: string
|
|
7
|
+
icon?: any
|
|
8
|
+
exact?: boolean
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const props = withDefaults(defineProps<{
|
|
12
|
+
tabs: Tab[]
|
|
13
|
+
activeClass?: string
|
|
14
|
+
}>(), {
|
|
15
|
+
activeClass: 'bg-white dark:bg-slate-800 text-blue-600 dark:text-blue-400 shadow-sm',
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
const route = useRoute()
|
|
19
|
+
|
|
20
|
+
const isActive = (tab: Tab) =>
|
|
21
|
+
tab.exact ? route.path === tab.to : route.path.startsWith(tab.to)
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<template>
|
|
25
|
+
<div class="flex items-center gap-x-1 p-1 bg-slate-100 dark:bg-slate-900/50 rounded-xl w-fit border border-slate-200 dark:border-slate-700">
|
|
26
|
+
<NuxtLink
|
|
27
|
+
v-for="tab in tabs"
|
|
28
|
+
:key="tab.to"
|
|
29
|
+
:to="tab.to"
|
|
30
|
+
class="flex items-center gap-x-2 px-4 py-2 text-xs font-bold rounded-lg transition-all"
|
|
31
|
+
:class="isActive(tab)
|
|
32
|
+
? activeClass
|
|
33
|
+
: 'text-slate-500 dark:text-slate-400 hover:text-slate-700 dark:hover:text-slate-200'"
|
|
34
|
+
>
|
|
35
|
+
<component :is="tab.icon" v-if="tab.icon" class="size-4" />
|
|
36
|
+
{{ tab.label }}
|
|
37
|
+
</NuxtLink>
|
|
38
|
+
</div>
|
|
39
|
+
</template>
|
package/nuxt.config.ts
CHANGED