Skip to content

Commit

Permalink
fix: update to fix type issues (#151)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed May 4, 2023
1 parent b55a7c5 commit 11e00a1
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 40 deletions.
7 changes: 5 additions & 2 deletions src/module.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { defineNuxtModule, installModule, addComponentsDir, addImportsDir, createResolver, addPlugin } from '@nuxt/kit'
import colors from 'tailwindcss/colors.js'
import { iconsPlugin, getIconCollections } from '@egoist/tailwindcss-icons'
import { defu } from 'defu'
import { name, version } from '../package.json'
import { colorsAsRegex, excludeColors } from './runtime/utils/colors'
import preset from './runtime/app.config'
import { ui as preset } from './preset'
import type { DeepPartial } from './runtime/types'

// @ts-ignore
Expand All @@ -23,7 +24,7 @@ declare module 'nuxt/schema' {
primary?: string
gray?: string
colors?: string[]
} & DeepPartial<typeof preset.ui>
} & DeepPartial<typeof preset>
}
}

Expand Down Expand Up @@ -64,6 +65,8 @@ export default defineNuxtModule<ModuleOptions>({

nuxt.options.css.push(resolve(runtimeDir, 'ui.css'))

nuxt.options.appConfig.ui = defu(nuxt.options.appConfig.ui, preset)

nuxt.hook('app:resolve', (app) => {
app.configs.push(resolve(runtimeDir, 'app.config'))
})
Expand Down
54 changes: 26 additions & 28 deletions src/runtime/app.config.ts → src/preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -677,32 +677,30 @@ const notifications = {
container: 'px-4 sm:px-6 py-6 space-y-3 overflow-y-auto'
}

export default {
ui: {
avatar,
avatarGroup,
badge,
button,
buttonGroup,
dropdown,
input,
inputGroup,
textarea,
select,
selectMenu,
checkbox,
radio,
toggle,
card,
container,
verticalNavigation,
commandPalette,
modal,
slideover,
popover,
tooltip,
contextMenu,
notification,
notifications
}
export const ui = {
avatar,
avatarGroup,
badge,
button,
buttonGroup,
dropdown,
input,
inputGroup,
textarea,
select,
selectMenu,
checkbox,
radio,
toggle,
card,
container,
verticalNavigation,
commandPalette,
modal,
slideover,
popover,
tooltip,
contextMenu,
notification,
notifications
}
6 changes: 3 additions & 3 deletions src/runtime/components/forms/Input.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
:autocomplete="autocomplete"
:spellcheck="spellcheck"
:class="inputClass"
@input="onInput(($event.target as any).value)"
@input="onInput"
@focus="$emit('focus', $event)"
@blur="$emit('blur', $event)"
>
Expand Down Expand Up @@ -147,8 +147,8 @@ export default defineComponent({
}
}
const onInput = (value: string) => {
emit('update:modelValue', value)
const onInput = (event: InputEvent) => {
emit('update:modelValue', (event.target as any).value)
}
onMounted(() => {
Expand Down
6 changes: 3 additions & 3 deletions src/runtime/components/forms/Select.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
:required="required"
:disabled="disabled"
:class="selectClass"
@input="onInput(($event.target as any).value)"
@input="onInput"
>
<template v-for="(option, index) in normalizedOptionsWithPlaceholder">
<optgroup
Expand Down Expand Up @@ -127,8 +127,8 @@ export default defineComponent({
const ui = computed<Partial<typeof appConfig.ui.select>>(() => defu({}, props.ui, appConfig.ui.select))
const onInput = (value: string) => {
emit('update:modelValue', value)
const onInput = (event: InputEvent) => {
emit('update:modelValue', (event.target as any).value)
}
const guessOptionValue = (option: any) => {
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/components/forms/SelectMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
</span>

<slot name="label">
<span v-if="modelValue" class="block truncate">{{ typeof modelValue === 'string' ? modelValue : (modelValue as any)[optionAttribute] }}</span>
<span v-if="modelValue" class="block truncate">{{ typeof modelValue === 'string' ? modelValue : modelValue[optionAttribute] }}</span>
<span v-else class="block truncate text-gray-400 dark:text-gray-500">{{ placeholder || '&nbsp;' }}</span>
</slot>

Expand Down
6 changes: 3 additions & 3 deletions src/runtime/components/forms/Textarea.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
:placeholder="placeholder"
:autocomplete="autocomplete"
:class="textareaClass"
@input="onInput(($event.target as any).value)"
@input="onInput"
@focus="$emit('focus', $event)"
@blur="$emit('blur', $event)"
/>
Expand Down Expand Up @@ -128,10 +128,10 @@ export default defineComponent({
}
}
const onInput = (value: string) => {
const onInput = (event: InputEvent) => {
autoResize()
emit('update:modelValue', value)
emit('update:modelValue', (event.target as any).value)
}
watch(() => props.modelValue, () => {
Expand Down

0 comments on commit 11e00a1

Please sign in to comment.