mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-28 10:50:40 +01:00
chore(typescript): migrate components (#53)
This commit is contained in:
committed by
GitHub
parent
57354f64f9
commit
1bda2ec01f
@@ -70,7 +70,8 @@ const components = [
|
|||||||
to: '/components/Avatar',
|
to: '/components/Avatar',
|
||||||
nuxt3: true,
|
nuxt3: true,
|
||||||
preset: true,
|
preset: true,
|
||||||
capi: true
|
capi: true,
|
||||||
|
typescript: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'AvatarGroup',
|
label: 'AvatarGroup',
|
||||||
@@ -82,7 +83,8 @@ const components = [
|
|||||||
to: '/components/Badge',
|
to: '/components/Badge',
|
||||||
nuxt3: true,
|
nuxt3: true,
|
||||||
capi: true,
|
capi: true,
|
||||||
preset: true
|
preset: true,
|
||||||
|
typescript: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Button',
|
label: 'Button',
|
||||||
@@ -102,7 +104,8 @@ const components = [
|
|||||||
label: 'Icon',
|
label: 'Icon',
|
||||||
to: '/components/Icon',
|
to: '/components/Icon',
|
||||||
nuxt3: true,
|
nuxt3: true,
|
||||||
capi: true
|
capi: true,
|
||||||
|
typescript: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Link',
|
label: 'Link',
|
||||||
@@ -115,7 +118,8 @@ const components = [
|
|||||||
to: '/components/Toggle',
|
to: '/components/Toggle',
|
||||||
nuxt3: true,
|
nuxt3: true,
|
||||||
preset: true,
|
preset: true,
|
||||||
capi: true
|
capi: true,
|
||||||
|
typescript: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Alert',
|
label: 'Alert',
|
||||||
@@ -127,7 +131,8 @@ const components = [
|
|||||||
to: '/components/AlertDialog',
|
to: '/components/AlertDialog',
|
||||||
nuxt3: true,
|
nuxt3: true,
|
||||||
capi: true,
|
capi: true,
|
||||||
preset: true
|
preset: true,
|
||||||
|
typescript: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Input',
|
label: 'Input',
|
||||||
@@ -165,7 +170,8 @@ const components = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'SelectCustom',
|
label: 'SelectCustom',
|
||||||
to: '/components/SelectCustom'
|
to: '/components/SelectCustom',
|
||||||
|
typescript: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Textarea',
|
label: 'Textarea',
|
||||||
@@ -186,21 +192,24 @@ const components = [
|
|||||||
to: '/components/Container',
|
to: '/components/Container',
|
||||||
nuxt3: true,
|
nuxt3: true,
|
||||||
preset: true,
|
preset: true,
|
||||||
capi: true
|
capi: true,
|
||||||
|
typescript: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Tabs',
|
label: 'Tabs',
|
||||||
to: '/components/Tabs',
|
to: '/components/Tabs',
|
||||||
nuxt3: true,
|
nuxt3: true,
|
||||||
capi: true,
|
capi: true,
|
||||||
preset: true
|
preset: true,
|
||||||
|
typescript: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Pills',
|
label: 'Pills',
|
||||||
to: '/components/Pills',
|
to: '/components/Pills',
|
||||||
nuxt3: true,
|
nuxt3: true,
|
||||||
capi: true,
|
capi: true,
|
||||||
preset: true
|
preset: true,
|
||||||
|
typescript: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'VerticalNavigation',
|
label: 'VerticalNavigation',
|
||||||
@@ -226,7 +235,8 @@ const components = [
|
|||||||
label: 'Notifications',
|
label: 'Notifications',
|
||||||
to: '/components/Notifications',
|
to: '/components/Notifications',
|
||||||
nuxt3: true,
|
nuxt3: true,
|
||||||
capi: true
|
capi: true,
|
||||||
|
typescript: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Popover',
|
label: 'Popover',
|
||||||
@@ -238,7 +248,8 @@ const components = [
|
|||||||
label: 'Slideover',
|
label: 'Slideover',
|
||||||
to: '/components/Slideover',
|
to: '/components/Slideover',
|
||||||
nuxt3: true,
|
nuxt3: true,
|
||||||
capi: true
|
capi: true,
|
||||||
|
typescript: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Tooltip',
|
label: 'Tooltip',
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup lang="ts">
|
||||||
import { ref, computed, watch } from 'vue'
|
import { ref, computed, watch } from 'vue'
|
||||||
import { classNames } from '../../utils'
|
import { classNames } from '../../utils'
|
||||||
import $ui from '#build/ui'
|
import $ui from '#build/ui'
|
||||||
@@ -29,7 +29,7 @@ const props = defineProps({
|
|||||||
size: {
|
size: {
|
||||||
type: String,
|
type: String,
|
||||||
default: 'md',
|
default: 'md',
|
||||||
validator (value) {
|
validator (value: string) {
|
||||||
return Object.keys($ui.avatar.size).includes(value)
|
return Object.keys($ui.avatar.size).includes(value)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -44,14 +44,14 @@ const props = defineProps({
|
|||||||
chipVariant: {
|
chipVariant: {
|
||||||
type: String,
|
type: String,
|
||||||
default: 'primary',
|
default: 'primary',
|
||||||
validator (value) {
|
validator (value: string) {
|
||||||
return Object.keys($ui.avatar.chip.variant).includes(value)
|
return Object.keys($ui.avatar.chip.variant).includes(value)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
chipPosition: {
|
chipPosition: {
|
||||||
type: String,
|
type: String,
|
||||||
default: 'top-right',
|
default: 'top-right',
|
||||||
validator (value) {
|
validator (value: string) {
|
||||||
return Object.keys($ui.avatar.chip.position).includes(value)
|
return Object.keys($ui.avatar.chip.position).includes(value)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -4,53 +4,46 @@
|
|||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script setup lang="ts">
|
||||||
import { computed } from 'vue'
|
import { computed } from 'vue'
|
||||||
import { classNames } from '../../utils'
|
import { classNames } from '../../utils'
|
||||||
import $ui from '#build/ui'
|
import $ui from '#build/ui'
|
||||||
|
|
||||||
export default {
|
const props = defineProps({
|
||||||
props: {
|
size: {
|
||||||
size: {
|
type: String,
|
||||||
type: String,
|
default: 'md',
|
||||||
default: 'md',
|
validator (value: string) {
|
||||||
validator (value) {
|
return Object.keys($ui.badge.size).includes(value)
|
||||||
return Object.keys($ui.badge.size).includes(value)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
variant: {
|
|
||||||
type: String,
|
|
||||||
default: 'primary',
|
|
||||||
validator (value) {
|
|
||||||
return Object.keys($ui.badge.variant).includes(value)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
baseClass: {
|
|
||||||
type: String,
|
|
||||||
default: () => $ui.badge.base
|
|
||||||
},
|
|
||||||
rounded: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false
|
|
||||||
},
|
|
||||||
label: {
|
|
||||||
type: String,
|
|
||||||
default: null
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
setup (props) {
|
variant: {
|
||||||
const badgeClass = computed(() => {
|
type: String,
|
||||||
return classNames(
|
default: 'primary',
|
||||||
props.baseClass,
|
validator (value: string) {
|
||||||
$ui.badge.size[props.size],
|
return Object.keys($ui.badge.variant).includes(value)
|
||||||
$ui.badge.variant[props.variant],
|
|
||||||
props.rounded ? 'rounded-full' : 'rounded-md'
|
|
||||||
)
|
|
||||||
})
|
|
||||||
|
|
||||||
return {
|
|
||||||
badgeClass
|
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
baseClass: {
|
||||||
|
type: String,
|
||||||
|
default: () => $ui.badge.base
|
||||||
|
},
|
||||||
|
rounded: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
},
|
||||||
|
label: {
|
||||||
|
type: String,
|
||||||
|
default: null
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
|
|
||||||
|
const badgeClass = computed(() => {
|
||||||
|
return classNames(
|
||||||
|
props.baseClass,
|
||||||
|
$ui.badge.size[props.size],
|
||||||
|
$ui.badge.variant[props.variant],
|
||||||
|
props.rounded ? 'rounded-full' : 'rounded-md'
|
||||||
|
)
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -2,7 +2,9 @@
|
|||||||
<Icon :icon="icon" />
|
<Icon :icon="icon" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup lang="ts">
|
||||||
|
import type { Ref } from 'vue'
|
||||||
|
import type { IconifyIcon } from '@iconify/vue'
|
||||||
import { ref, watch } from 'vue'
|
import { ref, watch } from 'vue'
|
||||||
import { Icon } from '@iconify/vue/dist/offline'
|
import { Icon } from '@iconify/vue/dist/offline'
|
||||||
import { loadIcon } from '@iconify/vue'
|
import { loadIcon } from '@iconify/vue'
|
||||||
@@ -14,7 +16,7 @@ const props = defineProps({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const icon = ref(null)
|
const icon: Ref<IconifyIcon> = ref(null)
|
||||||
icon.value = await loadIcon(props.name)
|
icon.value = await loadIcon(props.name)
|
||||||
|
|
||||||
watch(() => props.name, async () => {
|
watch(() => props.name, async () => {
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
</Modal>
|
</Modal>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup lang="ts">
|
||||||
import { computed } from 'vue'
|
import { computed } from 'vue'
|
||||||
import { DialogTitle, DialogDescription } from '@headlessui/vue'
|
import { DialogTitle, DialogDescription } from '@headlessui/vue'
|
||||||
import Modal from '../overlays/Modal'
|
import Modal from '../overlays/Modal'
|
||||||
|
|||||||
@@ -44,7 +44,7 @@
|
|||||||
</Listbox>
|
</Listbox>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup lang="ts">
|
||||||
import { computed } from 'vue'
|
import { computed } from 'vue'
|
||||||
import {
|
import {
|
||||||
Listbox,
|
Listbox,
|
||||||
@@ -76,7 +76,7 @@ const props = defineProps({
|
|||||||
size: {
|
size: {
|
||||||
type: String,
|
type: String,
|
||||||
default: 'md',
|
default: 'md',
|
||||||
validator (value) {
|
validator (value: string) {
|
||||||
return Object.keys($ui.selectCustom.size).includes(value)
|
return Object.keys($ui.selectCustom.size).includes(value)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -161,7 +161,7 @@ const iconClass = computed(() => {
|
|||||||
|
|
||||||
const iconWrapperClass = $ui.selectCustom.icon.trailing.wrapper
|
const iconWrapperClass = $ui.selectCustom.icon.trailing.wrapper
|
||||||
|
|
||||||
function resolveOptionClass ({ active, disabled }) {
|
function resolveOptionClass ({ active, disabled }: { active: boolean, disabled: boolean }) {
|
||||||
return classNames(
|
return classNames(
|
||||||
props.listOptionBaseClass,
|
props.listOptionBaseClass,
|
||||||
active ? props.listOptionActiveClass : props.listOptionInactiveClass,
|
active ? props.listOptionActiveClass : props.listOptionInactiveClass,
|
||||||
@@ -169,7 +169,7 @@ function resolveOptionClass ({ active, disabled }) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function resolveOptionIconClass ({ active }) {
|
function resolveOptionIconClass ({ active }: { active: boolean }) {
|
||||||
return classNames(
|
return classNames(
|
||||||
props.listOptionIconBaseClass,
|
props.listOptionIconBaseClass,
|
||||||
active ? props.listOptionIconActiveClass : props.listOptionIconInactiveClass
|
active ? props.listOptionIconActiveClass : props.listOptionIconInactiveClass
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
</Switch>
|
</Switch>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup lang="ts">
|
||||||
import { computed } from 'vue'
|
import { computed } from 'vue'
|
||||||
import { Switch } from '@headlessui/vue'
|
import { Switch } from '@headlessui/vue'
|
||||||
import Icon from '../elements/Icon'
|
import Icon from '../elements/Icon'
|
||||||
|
|||||||
@@ -4,38 +4,31 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script setup lang="ts">
|
||||||
import { computed } from 'vue'
|
import { computed } from 'vue'
|
||||||
import { classNames } from '../../utils/'
|
import { classNames } from '../../utils/'
|
||||||
import $ui from '#build/ui'
|
import $ui from '#build/ui'
|
||||||
|
|
||||||
export default {
|
const props = defineProps({
|
||||||
props: {
|
padded: {
|
||||||
padded: {
|
type: Boolean,
|
||||||
type: Boolean,
|
default: false
|
||||||
default: false
|
|
||||||
},
|
|
||||||
constrained: {
|
|
||||||
type: Boolean,
|
|
||||||
default: true
|
|
||||||
},
|
|
||||||
constrainedClass: {
|
|
||||||
type: String,
|
|
||||||
default: () => $ui.container.constrained
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
setup (props) {
|
constrained: {
|
||||||
const containerClass = computed(() => {
|
type: Boolean,
|
||||||
return classNames(
|
default: true
|
||||||
'mx-auto sm:px-6 lg:px-8',
|
},
|
||||||
props.padded && 'px-4',
|
constrainedClass: {
|
||||||
props.constrained && props.constrainedClass
|
type: String,
|
||||||
)
|
default: () => $ui.container.constrained
|
||||||
})
|
|
||||||
|
|
||||||
return {
|
|
||||||
containerClass
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
|
|
||||||
|
const containerClass = computed(() => {
|
||||||
|
return classNames(
|
||||||
|
'mx-auto sm:px-6 lg:px-8',
|
||||||
|
props.padded && 'px-4',
|
||||||
|
props.constrained && props.constrainedClass
|
||||||
|
)
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
</nav>
|
</nav>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup lang="ts">
|
||||||
import Link from '../elements/Link'
|
import Link from '../elements/Link'
|
||||||
import $ui from '#build/ui'
|
import $ui from '#build/ui'
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
</nav>
|
</nav>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup lang="ts">
|
||||||
import Link from '../elements/Link'
|
import Link from '../elements/Link'
|
||||||
import $ui from '#build/ui'
|
import $ui from '#build/ui'
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup lang="ts">
|
||||||
import { useNuxtApp, useState } from '#app'
|
import { useNuxtApp, useState } from '#app'
|
||||||
import Notification from './Notification'
|
import Notification from './Notification'
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user