@byyuurin/ui 0.0.3 → 0.0.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/README.md +4 -2
- package/dist/nuxt.mjs +1 -1
- package/dist/resolver.mjs +1 -1
- package/dist/runtime/components/App.vue +5 -1
- package/dist/runtime/components/Button.vue +0 -1
- package/dist/runtime/components/Checkbox.vue +2 -5
- package/dist/runtime/components/Input.vue +5 -1
- package/dist/runtime/components/ModalProvider.vue +1 -1
- package/dist/runtime/components/RadioGroup.vue +1 -7
- package/dist/runtime/components/ScrollArea.vue +72 -0
- package/dist/runtime/components/Switch.vue +0 -1
- package/dist/runtime/components/Tabs.vue +5 -5
- package/dist/runtime/components/Textarea.vue +173 -0
- package/dist/runtime/components/Toast.vue +1 -1
- package/dist/runtime/components/index.d.ts +2 -0
- package/dist/runtime/components/index.mjs +2 -0
- package/dist/runtime/composables/defineInjection.d.ts +11 -0
- package/dist/runtime/composables/defineInjection.mjs +9 -0
- package/dist/runtime/composables/index.d.ts +1 -0
- package/dist/runtime/composables/index.mjs +1 -0
- package/dist/runtime/composables/useModal.d.ts +1 -1
- package/dist/runtime/composables/useModal.mjs +3 -2
- package/dist/runtime/composables/useTheme.d.ts +3 -1
- package/dist/runtime/composables/useTheme.mjs +14 -6
- package/dist/runtime/theme/button.d.ts +0 -8
- package/dist/runtime/theme/button.mjs +1 -9
- package/dist/runtime/theme/checkbox.d.ts +0 -12
- package/dist/runtime/theme/checkbox.mjs +4 -9
- package/dist/runtime/theme/index.d.ts +2 -0
- package/dist/runtime/theme/index.mjs +2 -0
- package/dist/runtime/theme/radioGroup.d.ts +0 -24
- package/dist/runtime/theme/radioGroup.mjs +8 -20
- package/dist/runtime/theme/scrollArea.d.ts +51 -0
- package/dist/runtime/theme/scrollArea.mjs +30 -0
- package/dist/runtime/theme/switch.d.ts +0 -12
- package/dist/runtime/theme/switch.mjs +2 -8
- package/dist/runtime/theme/tabs.d.ts +32 -11
- package/dist/runtime/theme/tabs.mjs +19 -12
- package/dist/runtime/theme/textarea.d.ts +90 -0
- package/dist/runtime/theme/textarea.mjs +100 -0
- package/dist/runtime/theme/toast.mjs +1 -1
- package/dist/runtime/types/components.d.ts +2 -0
- package/dist/runtime/utils/index.d.ts +0 -11
- package/dist/runtime/utils/index.mjs +0 -11
- package/dist/shared/{ui.CPXA9QoM.mjs → ui.Cmq14xN9.mjs} +2 -0
- package/dist/unocss-preset.d.mts +15 -7
- package/dist/unocss-preset.d.ts +15 -7
- package/dist/unocss-preset.mjs +90 -386
- package/package.json +6 -5
- package/dist/index.cjs +0 -38
- package/dist/runtime/components/index.cjs +0 -132
- package/dist/runtime/composables/index.cjs +0 -33
- package/dist/runtime/composables/useComponentIcons.cjs +0 -30
- package/dist/runtime/composables/useModal.cjs +0 -55
- package/dist/runtime/composables/useTheme.cjs +0 -30
- package/dist/runtime/composables/useToast.cjs +0 -51
- package/dist/runtime/theme/accordion.cjs +0 -27
- package/dist/runtime/theme/app.cjs +0 -15
- package/dist/runtime/theme/button.cjs +0 -127
- package/dist/runtime/theme/card.cjs +0 -17
- package/dist/runtime/theme/checkbox.cjs +0 -56
- package/dist/runtime/theme/drawer.cjs +0 -73
- package/dist/runtime/theme/index.cjs +0 -125
- package/dist/runtime/theme/input.cjs +0 -115
- package/dist/runtime/theme/link.cjs +0 -23
- package/dist/runtime/theme/modal.cjs +0 -55
- package/dist/runtime/theme/popover.cjs +0 -13
- package/dist/runtime/theme/radioGroup.cjs +0 -73
- package/dist/runtime/theme/select.cjs +0 -128
- package/dist/runtime/theme/switch.cjs +0 -73
- package/dist/runtime/theme/tabs.cjs +0 -105
- package/dist/runtime/theme/toast.cjs +0 -33
- package/dist/runtime/theme/toaster.cjs +0 -72
- package/dist/runtime/theme/tooltip.cjs +0 -14
- package/dist/runtime/types/components.cjs +0 -1
- package/dist/runtime/types/index.cjs +0 -27
- package/dist/runtime/types/utils.cjs +0 -1
- package/dist/runtime/utils/extend-theme.cjs +0 -24
- package/dist/runtime/utils/index.cjs +0 -119
- package/dist/runtime/utils/link.cjs +0 -10
- package/dist/runtime/utils/styler.cjs +0 -18
package/README.md
CHANGED
|
@@ -107,16 +107,18 @@ export default defineNuxtConfig({
|
|
|
107
107
|
'@unocss/reset/tailwind.css',
|
|
108
108
|
],
|
|
109
109
|
ui: {
|
|
110
|
-
prefix: 'U',
|
|
110
|
+
prefix: 'U', // optional
|
|
111
111
|
},
|
|
112
112
|
})
|
|
113
113
|
```
|
|
114
114
|
|
|
115
|
-
##
|
|
115
|
+
## Credits
|
|
116
116
|
|
|
117
117
|
- [UnoCSS](https://github.com/unocss/unocss)
|
|
118
118
|
- [daisyui](https://github.com/saadeghi/daisyui)
|
|
119
119
|
- [@nuxt/ui](https://github.com/nuxt/ui)
|
|
120
|
+
- [Reka UI](https://github.com/unovue/radix-vue)
|
|
121
|
+
- [VueUse](https://github.com/vueuse/vueuse)
|
|
120
122
|
|
|
121
123
|
## License
|
|
122
124
|
|
package/dist/nuxt.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineNuxtModule, useLogger, addComponent } from '@nuxt/kit';
|
|
2
|
-
import { p as packageName, c as componentNames } from './shared/ui.
|
|
2
|
+
import { p as packageName, c as componentNames } from './shared/ui.Cmq14xN9.mjs';
|
|
3
3
|
|
|
4
4
|
const nuxt = defineNuxtModule({
|
|
5
5
|
meta: {
|
package/dist/resolver.mjs
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { ConfigProviderProps, TooltipProviderProps } from 'reka-ui'
|
|
3
|
+
import type { UserConfig } from 'unocss'
|
|
3
4
|
import type { ThemeExtension, ToasterProps } from '../types'
|
|
4
5
|
|
|
5
6
|
export interface AppProps extends Omit<ConfigProviderProps, 'useId' | 'dir' | 'locale'> {
|
|
7
|
+
unoConfig?: UserConfig
|
|
6
8
|
ui?: ThemeExtension
|
|
7
9
|
tooltip?: TooltipProviderProps
|
|
8
10
|
toaster?: ToasterProps
|
|
@@ -19,11 +21,12 @@ import { ConfigProvider, TooltipProvider, useForwardProps } from 'reka-ui'
|
|
|
19
21
|
import { computed, shallowRef, toRef, useId } from 'vue'
|
|
20
22
|
import type { ModalState } from '../composables/useModal'
|
|
21
23
|
import { provideModalState } from '../composables/useModal'
|
|
22
|
-
import { provideThemeExtension } from '../composables/useTheme'
|
|
24
|
+
import { provideThemeExtension, provideUnoConfig } from '../composables/useTheme'
|
|
23
25
|
import ModalProvider from './ModalProvider.vue'
|
|
24
26
|
import Toaster from './Toaster.vue'
|
|
25
27
|
|
|
26
28
|
const props = withDefaults(defineProps<AppProps>(), {
|
|
29
|
+
unoConfig: () => ({}),
|
|
27
30
|
ui: () => ({}),
|
|
28
31
|
})
|
|
29
32
|
|
|
@@ -41,6 +44,7 @@ const modalState = shallowRef<ModalState>({
|
|
|
41
44
|
const themeExtension = computed(() => props.ui)
|
|
42
45
|
|
|
43
46
|
provideModalState(modalState)
|
|
47
|
+
provideUnoConfig(props.unoConfig)
|
|
44
48
|
provideThemeExtension(themeExtension)
|
|
45
49
|
</script>
|
|
46
50
|
|
|
@@ -55,10 +55,7 @@ const id = props.id ?? useId()
|
|
|
55
55
|
const { theme, createStyler } = useTheme()
|
|
56
56
|
const style = computed(() => {
|
|
57
57
|
const styler = createStyler(theme.value.checkbox)
|
|
58
|
-
return styler(
|
|
59
|
-
...props,
|
|
60
|
-
checked: Boolean(innerValue.value ?? props.defaultValue),
|
|
61
|
-
})
|
|
58
|
+
return styler(props)
|
|
62
59
|
})
|
|
63
60
|
|
|
64
61
|
function onUpdate(value: any) {
|
|
@@ -81,7 +78,7 @@ function onUpdate(value: any) {
|
|
|
81
78
|
:class="style.base({ class: props.ui?.base })"
|
|
82
79
|
@update:model-value="onUpdate"
|
|
83
80
|
>
|
|
84
|
-
<CheckboxIndicator as-child>
|
|
81
|
+
<CheckboxIndicator as-child force-mount>
|
|
85
82
|
<i
|
|
86
83
|
v-if="modelValue === 'indeterminate'"
|
|
87
84
|
:class="style.icon({ class: [props.indeterminateIcon || theme.app.icons.indeterminate, props.ui?.icon] })"
|
|
@@ -128,7 +128,11 @@ onMounted(() => {
|
|
|
128
128
|
</script>
|
|
129
129
|
|
|
130
130
|
<template>
|
|
131
|
-
<Primitive
|
|
131
|
+
<Primitive
|
|
132
|
+
:as="as"
|
|
133
|
+
:class="style.root({ class: [props.class, props.ui?.root] })"
|
|
134
|
+
:aria-disabled="props.disabled ? true : undefined"
|
|
135
|
+
>
|
|
132
136
|
<span v-if="isPrefix || slots.prefix" :class="style.prefix({ class: props.ui?.prefix })">
|
|
133
137
|
<slot name="prefix">
|
|
134
138
|
<i
|
|
@@ -6,5 +6,5 @@ const { isOpen } = useModal()
|
|
|
6
6
|
</script>
|
|
7
7
|
|
|
8
8
|
<template>
|
|
9
|
-
<component :is="modalState.component" v-if="modalState
|
|
9
|
+
<component :is="modalState.component" v-if="modalState" v-bind="modalState.props" v-model:open="isOpen" />
|
|
10
10
|
</template>
|
|
@@ -38,10 +38,6 @@ export interface RadioGroupProps<T> extends ComponentAttrs<typeof radioGroup>, P
|
|
|
38
38
|
* @default 'vertical'
|
|
39
39
|
*/
|
|
40
40
|
orientation?: RadioGroupRootProps['orientation']
|
|
41
|
-
/** @default true */
|
|
42
|
-
round?: boolean
|
|
43
|
-
/** @default true */
|
|
44
|
-
dot?: boolean
|
|
45
41
|
}
|
|
46
42
|
|
|
47
43
|
export interface RadioGroupEmits {
|
|
@@ -83,8 +79,6 @@ const props = withDefaults(defineProps<RadioGroupProps<T>>(), {
|
|
|
83
79
|
labelKey: 'label',
|
|
84
80
|
descriptionKey: 'description',
|
|
85
81
|
orientation: 'vertical',
|
|
86
|
-
dot: true,
|
|
87
|
-
round: true,
|
|
88
82
|
})
|
|
89
83
|
|
|
90
84
|
const emit = defineEmits<RadioGroupEmits>()
|
|
@@ -160,7 +154,7 @@ function onUpdate(value: any) {
|
|
|
160
154
|
:disabled="item.disabled"
|
|
161
155
|
:class="style.base({ class: props.ui?.base })"
|
|
162
156
|
>
|
|
163
|
-
<RadioGroupIndicator :class="style.indicator({ class: props.ui?.indicator })" />
|
|
157
|
+
<RadioGroupIndicator :class="style.indicator({ class: props.ui?.indicator })" force-mount />
|
|
164
158
|
</RadioGroupItem>
|
|
165
159
|
</div>
|
|
166
160
|
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { ScrollAreaRootProps } from 'reka-ui'
|
|
3
|
+
import type { scrollArea } from '../theme'
|
|
4
|
+
import { transitionProps } from '../theme/scrollArea'
|
|
5
|
+
import type { ComponentAttrs } from '../types'
|
|
6
|
+
|
|
7
|
+
export interface ScrollAreaProps extends ComponentAttrs<typeof scrollArea>, Pick<ScrollAreaRootProps, 'type' | 'dir' | 'scrollHideDelay'> {}
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<script setup lang="ts">
|
|
11
|
+
import { reactivePick } from '@vueuse/core'
|
|
12
|
+
import { ScrollAreaCorner, ScrollAreaRoot, ScrollAreaScrollbar, ScrollAreaThumb, ScrollAreaViewport } from 'reka-ui'
|
|
13
|
+
import { computed, ref } from 'vue'
|
|
14
|
+
import { useTheme } from '../composables'
|
|
15
|
+
|
|
16
|
+
const props = withDefaults(defineProps<ScrollAreaProps>(), {})
|
|
17
|
+
const rootRef = ref<InstanceType<typeof ScrollAreaRoot>>()
|
|
18
|
+
const rootProps = reactivePick(props, 'type', 'dir', 'scrollHideDelay')
|
|
19
|
+
|
|
20
|
+
const { theme, createStyler } = useTheme()
|
|
21
|
+
|
|
22
|
+
const style = computed(() => {
|
|
23
|
+
const styler = createStyler(theme.value.scrollArea)
|
|
24
|
+
return styler(props)
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
defineExpose({
|
|
28
|
+
scrollTop,
|
|
29
|
+
scrollTopLeft,
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
function scrollTop() {
|
|
33
|
+
rootRef.value?.scrollTop()
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function scrollTopLeft() {
|
|
37
|
+
rootRef.value?.scrollTopLeft()
|
|
38
|
+
}
|
|
39
|
+
</script>
|
|
40
|
+
|
|
41
|
+
<template>
|
|
42
|
+
<ScrollAreaRoot
|
|
43
|
+
ref="rootRef"
|
|
44
|
+
v-bind="rootProps"
|
|
45
|
+
:class="style.root({ class: [props.class, props.ui?.root] })"
|
|
46
|
+
>
|
|
47
|
+
<ScrollAreaViewport :class="style.viewport({ class: props.ui?.viewport })">
|
|
48
|
+
<slot></slot>
|
|
49
|
+
</ScrollAreaViewport>
|
|
50
|
+
|
|
51
|
+
<TransitionGroup v-bind="transitionProps">
|
|
52
|
+
<ScrollAreaScrollbar
|
|
53
|
+
key="scrollbar-horizontal"
|
|
54
|
+
:class="style.scrollbar({ class: props.ui?.scrollbar })"
|
|
55
|
+
orientation="horizontal"
|
|
56
|
+
>
|
|
57
|
+
<ScrollAreaThumb :class="style.thumb({ class: props.ui?.thumb })" />
|
|
58
|
+
</ScrollAreaScrollbar>
|
|
59
|
+
<ScrollAreaScrollbar
|
|
60
|
+
key="scrollbar-vertical"
|
|
61
|
+
:class="style.scrollbar({ class: props.ui?.scrollbar })"
|
|
62
|
+
orientation="vertical"
|
|
63
|
+
>
|
|
64
|
+
<ScrollAreaThumb :class="style.thumb({ class: props.ui?.thumb })" />
|
|
65
|
+
</ScrollAreaScrollbar>
|
|
66
|
+
<ScrollAreaCorner
|
|
67
|
+
key="corner"
|
|
68
|
+
:class="style.corner({ class: props.ui?.corner })"
|
|
69
|
+
/>
|
|
70
|
+
</TransitionGroup>
|
|
71
|
+
</ScrollAreaRoot>
|
|
72
|
+
</template>
|
|
@@ -41,9 +41,9 @@ export interface TabsEmits extends TabsRootEmits<string | number> {}
|
|
|
41
41
|
type SlotProps<T> = (props: { item: T, index: number }) => any
|
|
42
42
|
|
|
43
43
|
export type TabsSlots<T extends { slot?: string }> = {
|
|
44
|
-
|
|
44
|
+
prefix?: SlotProps<T>
|
|
45
45
|
default?: SlotProps<T>
|
|
46
|
-
|
|
46
|
+
suffix?: SlotProps<T>
|
|
47
47
|
content?: SlotProps<T>
|
|
48
48
|
} & DynamicSlots<T, SlotProps<T>>
|
|
49
49
|
</script>
|
|
@@ -89,15 +89,15 @@ const style = computed(() => {
|
|
|
89
89
|
:disabled="item.disabled"
|
|
90
90
|
:class="style.trigger({ class: props.ui?.trigger })"
|
|
91
91
|
>
|
|
92
|
-
<slot name="
|
|
93
|
-
<i v-if="item.icon" :class="style.
|
|
92
|
+
<slot name="prefix" :item="item" :index="index">
|
|
93
|
+
<i v-if="item.icon" :class="style.prefixIcon({ class: [item.icon, props.ui?.prefixIcon] })"></i>
|
|
94
94
|
</slot>
|
|
95
95
|
|
|
96
96
|
<span v-if="get(item, props.labelKey) || slots.default" :class="style.label({ class: props.ui?.label })">
|
|
97
97
|
<slot :item="item" :index="index">{{ get(item, props.labelKey) }}</slot>
|
|
98
98
|
</span>
|
|
99
99
|
|
|
100
|
-
<slot name="
|
|
100
|
+
<slot name="suffix" :item="item" :index="index"></slot>
|
|
101
101
|
</TabsTrigger>
|
|
102
102
|
</TabsList>
|
|
103
103
|
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { VariantProps } from '@byyuurin/ui-kit'
|
|
3
|
+
import type { PrimitiveProps } from 'reka-ui'
|
|
4
|
+
import type { textarea } from '../theme'
|
|
5
|
+
import type { ComponentAttrs } from '../types'
|
|
6
|
+
|
|
7
|
+
type TextareaVariants = VariantProps<typeof textarea>
|
|
8
|
+
|
|
9
|
+
export interface TextareaProps extends ComponentAttrs<typeof textarea> {
|
|
10
|
+
/**
|
|
11
|
+
* The element or component this component should render as.
|
|
12
|
+
* @defaultValue 'div'
|
|
13
|
+
*/
|
|
14
|
+
as?: PrimitiveProps['as']
|
|
15
|
+
id?: string
|
|
16
|
+
name?: string
|
|
17
|
+
placeholder?: string
|
|
18
|
+
size?: TextareaVariants['size']
|
|
19
|
+
variant?: TextareaVariants['variant']
|
|
20
|
+
highlight?: boolean
|
|
21
|
+
underline?: boolean
|
|
22
|
+
required?: boolean
|
|
23
|
+
autofocus?: boolean
|
|
24
|
+
autofocusDelay?: number
|
|
25
|
+
disabled?: boolean
|
|
26
|
+
rows?: number
|
|
27
|
+
maxRows?: number
|
|
28
|
+
autoResize?: boolean
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface TextareaEmits {
|
|
32
|
+
(e: 'update:modelValue', payload: string): void
|
|
33
|
+
(e: 'blur', event: FocusEvent): void
|
|
34
|
+
(e: 'change', event: Event): void
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface TextareaSlots {
|
|
38
|
+
default?: (props?: {}) => any
|
|
39
|
+
}
|
|
40
|
+
</script>
|
|
41
|
+
|
|
42
|
+
<script setup lang="ts">
|
|
43
|
+
import { Primitive } from 'reka-ui'
|
|
44
|
+
import { computed, nextTick, onMounted, ref, watch } from 'vue'
|
|
45
|
+
import { useTheme } from '../composables'
|
|
46
|
+
|
|
47
|
+
defineOptions({
|
|
48
|
+
inheritAttrs: false,
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
const props = withDefaults(defineProps<TextareaProps>(), {
|
|
52
|
+
size: 'md',
|
|
53
|
+
variant: 'outline',
|
|
54
|
+
rows: 3,
|
|
55
|
+
maxRows: 0,
|
|
56
|
+
autofocusDelay: 0,
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
const emit = defineEmits<TextareaEmits>()
|
|
60
|
+
defineSlots<TextareaSlots>()
|
|
61
|
+
const [modelValue, modelModifiers] = defineModel<string | number>()
|
|
62
|
+
|
|
63
|
+
const textareaRef = ref<HTMLTextAreaElement | null>(null)
|
|
64
|
+
|
|
65
|
+
const { theme, createStyler } = useTheme()
|
|
66
|
+
const style = computed(() => {
|
|
67
|
+
const styler = createStyler(theme.value.textarea)
|
|
68
|
+
return styler(props)
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
function autoFocus() {
|
|
72
|
+
if (props.autofocus)
|
|
73
|
+
textareaRef.value?.focus()
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function updateInput(value: string) {
|
|
77
|
+
if (modelModifiers.trim)
|
|
78
|
+
value = value.trim()
|
|
79
|
+
|
|
80
|
+
modelValue.value = value
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function onInput(event: Event) {
|
|
84
|
+
autoResize()
|
|
85
|
+
|
|
86
|
+
if (!modelModifiers.lazy)
|
|
87
|
+
updateInput((event.target as HTMLInputElement).value)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function onChange(event: Event) {
|
|
91
|
+
const value = (event.target as HTMLInputElement).value
|
|
92
|
+
|
|
93
|
+
if (modelModifiers.lazy)
|
|
94
|
+
updateInput(value)
|
|
95
|
+
|
|
96
|
+
if (modelModifiers.trim)
|
|
97
|
+
(event.target as HTMLInputElement).value = value.trim()
|
|
98
|
+
|
|
99
|
+
emit('change', event)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function onBlur(event: FocusEvent) {
|
|
103
|
+
emit('blur', event)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function autoResize() {
|
|
107
|
+
if (!props.autoResize)
|
|
108
|
+
return
|
|
109
|
+
|
|
110
|
+
if (!textareaRef.value)
|
|
111
|
+
return
|
|
112
|
+
|
|
113
|
+
textareaRef.value.rows = props.rows
|
|
114
|
+
|
|
115
|
+
const overflow = textareaRef.value.style.overflow
|
|
116
|
+
textareaRef.value.style.overflow = 'hidden'
|
|
117
|
+
|
|
118
|
+
const styles = window.getComputedStyle(textareaRef.value)
|
|
119
|
+
const paddingTop = Number.parseInt(styles.paddingTop)
|
|
120
|
+
const paddingBottom = Number.parseInt(styles.paddingBottom)
|
|
121
|
+
const padding = paddingTop + paddingBottom
|
|
122
|
+
const lineHeight = Number.parseInt(styles.lineHeight)
|
|
123
|
+
const { scrollHeight } = textareaRef.value
|
|
124
|
+
const newRows = Math.ceil((scrollHeight - padding) / lineHeight)
|
|
125
|
+
|
|
126
|
+
if (newRows > props.rows)
|
|
127
|
+
textareaRef.value.rows = props.maxRows ? Math.min(newRows, props.maxRows) : newRows
|
|
128
|
+
|
|
129
|
+
textareaRef.value.style.overflow = overflow
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
watch(modelValue, () => {
|
|
133
|
+
nextTick(autoResize)
|
|
134
|
+
})
|
|
135
|
+
|
|
136
|
+
defineExpose({
|
|
137
|
+
textareaRef,
|
|
138
|
+
})
|
|
139
|
+
|
|
140
|
+
onMounted(() => {
|
|
141
|
+
setTimeout(() => {
|
|
142
|
+
autoFocus()
|
|
143
|
+
}, props.autofocusDelay)
|
|
144
|
+
})
|
|
145
|
+
</script>
|
|
146
|
+
|
|
147
|
+
<template>
|
|
148
|
+
<Primitive
|
|
149
|
+
:as="props.as"
|
|
150
|
+
:class="style.root({ class: [props.class, props.ui?.root] })"
|
|
151
|
+
:aria-disabled="props.disabled ? true : undefined"
|
|
152
|
+
>
|
|
153
|
+
<textarea
|
|
154
|
+
:id="props.id"
|
|
155
|
+
ref="textareaRef"
|
|
156
|
+
:value="modelValue"
|
|
157
|
+
:name="props.name"
|
|
158
|
+
:rows="props.rows"
|
|
159
|
+
:placeholder="props.placeholder"
|
|
160
|
+
:class="style.base({ class: props.ui?.base })"
|
|
161
|
+
:disabled="props.disabled"
|
|
162
|
+
:required="props.required"
|
|
163
|
+
v-bind="$attrs"
|
|
164
|
+
@input="onInput"
|
|
165
|
+
@blur="onBlur"
|
|
166
|
+
@change="onChange"
|
|
167
|
+
@focus="autoResize"
|
|
168
|
+
>
|
|
169
|
+
</textarea>
|
|
170
|
+
|
|
171
|
+
<slot></slot>
|
|
172
|
+
</Primitive>
|
|
173
|
+
</template>
|
|
@@ -121,6 +121,6 @@ defineExpose({
|
|
|
121
121
|
</ToastClose>
|
|
122
122
|
</div>
|
|
123
123
|
|
|
124
|
-
<div v-if="remaining
|
|
124
|
+
<div v-if="remaining >= 0 && duration" :class="style.progress({ class: props.ui?.progress })" :style="{ width: `${remaining / duration * 100}%` }"></div>
|
|
125
125
|
</ToastRoot>
|
|
126
126
|
</template>
|
|
@@ -10,9 +10,11 @@ export { default as Modal } from './Modal.vue';
|
|
|
10
10
|
export { default as ModalProvider } from './ModalProvider.vue';
|
|
11
11
|
export { default as Popover } from './Popover.vue';
|
|
12
12
|
export { default as RadioGroup } from './RadioGroup.vue';
|
|
13
|
+
export { default as ScrollArea } from './ScrollArea.vue';
|
|
13
14
|
export { default as Select } from './Select.vue';
|
|
14
15
|
export { default as Switch } from './Switch.vue';
|
|
15
16
|
export { default as Tabs } from './Tabs.vue';
|
|
17
|
+
export { default as Textarea } from './Textarea.vue';
|
|
16
18
|
export { default as Toast } from './Toast.vue';
|
|
17
19
|
export { default as Toaster } from './Toaster.vue';
|
|
18
20
|
export { default as Tooltip } from './Tooltip.vue';
|
|
@@ -10,9 +10,11 @@ export { default as Modal } from "./Modal.vue";
|
|
|
10
10
|
export { default as ModalProvider } from "./ModalProvider.vue";
|
|
11
11
|
export { default as Popover } from "./Popover.vue";
|
|
12
12
|
export { default as RadioGroup } from "./RadioGroup.vue";
|
|
13
|
+
export { default as ScrollArea } from "./ScrollArea.vue";
|
|
13
14
|
export { default as Select } from "./Select.vue";
|
|
14
15
|
export { default as Switch } from "./Switch.vue";
|
|
15
16
|
export { default as Tabs } from "./Tabs.vue";
|
|
17
|
+
export { default as Textarea } from "./Textarea.vue";
|
|
16
18
|
export { default as Toast } from "./Toast.vue";
|
|
17
19
|
export { default as Toaster } from "./Toaster.vue";
|
|
18
20
|
export { default as Tooltip } from "./Tooltip.vue";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { InjectionKey } from 'vue';
|
|
2
|
+
export declare function defineInjection<T>(name: string): {
|
|
3
|
+
InjectionKey: InjectionKey<T>;
|
|
4
|
+
provide: (value: T) => void;
|
|
5
|
+
inject: () => T | undefined;
|
|
6
|
+
};
|
|
7
|
+
export declare function defineInjection<T>(name: string, defaultValue: T): {
|
|
8
|
+
InjectionKey: InjectionKey<T>;
|
|
9
|
+
provide: (value: T) => void;
|
|
10
|
+
inject: () => T;
|
|
11
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { inject, provide } from "vue";
|
|
2
|
+
export function defineInjection(name, defaultValue) {
|
|
3
|
+
const InjectionKey = Symbol(name);
|
|
4
|
+
return {
|
|
5
|
+
InjectionKey,
|
|
6
|
+
provide: (value) => provide(InjectionKey, value),
|
|
7
|
+
inject: () => inject(InjectionKey, defaultValue)
|
|
8
|
+
};
|
|
9
|
+
}
|
|
@@ -5,7 +5,7 @@ export interface ModalState {
|
|
|
5
5
|
component: Component | string;
|
|
6
6
|
props: ModalProps;
|
|
7
7
|
}
|
|
8
|
-
export declare const injectModalState: () => ShallowRef<ModalState> | undefined, provideModalState: (value: ShallowRef<ModalState>) => void;
|
|
8
|
+
export declare const InjectionKeyModalState: import("vue").InjectionKey<ShallowRef<ModalState>>, injectModalState: () => ShallowRef<ModalState> | undefined, provideModalState: (value: ShallowRef<ModalState>) => void;
|
|
9
9
|
export declare const useModal: () => {
|
|
10
10
|
open: <T extends Component>(component: T, props?: ModalProps & ComponentProps<T>) => void;
|
|
11
11
|
close: () => void;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { createSharedComposable } from "@vueuse/core";
|
|
2
2
|
import { ref } from "vue";
|
|
3
|
-
import {
|
|
3
|
+
import { defineInjection } from "./defineInjection.mjs";
|
|
4
4
|
export const {
|
|
5
|
+
InjectionKey: InjectionKeyModalState,
|
|
5
6
|
inject: injectModalState,
|
|
6
7
|
provide: provideModalState
|
|
7
|
-
} =
|
|
8
|
+
} = defineInjection("ui.modal");
|
|
8
9
|
export const useModal = createSharedComposable(() => {
|
|
9
10
|
const modalState = injectModalState();
|
|
10
11
|
const isOpen = ref(false);
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import type { UserConfig } from 'unocss';
|
|
1
2
|
import type { MaybeRefOrGetter } from 'vue';
|
|
2
3
|
import * as theme from '../theme';
|
|
3
|
-
export declare const provideThemeExtension: (value: MaybeRefOrGetter<import("../types").PartialTheme<typeof theme>>) => void, injectThemeExtension: () => MaybeRefOrGetter<import("../types").PartialTheme<typeof theme>>;
|
|
4
|
+
export declare const InjectionKeyThemeExtension: import("vue").InjectionKey<MaybeRefOrGetter<import("../types").PartialTheme<typeof theme>>>, provideThemeExtension: (value: MaybeRefOrGetter<import("../types").PartialTheme<typeof theme>>) => void, injectThemeExtension: () => MaybeRefOrGetter<import("../types").PartialTheme<typeof theme>>;
|
|
5
|
+
export declare const InjectionKeyUnoConfig: import("vue").InjectionKey<UserConfig<object>>, provideUnoConfig: (value: UserConfig<object>) => void, injectUnoConfig: () => UserConfig<object>;
|
|
4
6
|
export declare const useTheme: () => {
|
|
5
7
|
theme: import("vue").ComputedRef<typeof theme>;
|
|
6
8
|
createStyler: <V extends import("@byyuurin/ui-kit/index").CVVariants<S, B>, CV extends import("@byyuurin/ui-kit/index").CVCompoundVariants<V, S, B>, B extends import("@byyuurin/ui-kit/index").ClassValue = undefined, S extends import("@byyuurin/ui-kit/index").CVSlots = undefined>(theme: import("@byyuurin/ui-kit/index").CVMeta<V, CV, never, B, S>) => [keyof V] extends string[] ? (props: Required<import("@byyuurin/ui-kit/index").VariantProps<import("@byyuurin/ui-kit/index").CVReturnType<V, S, B>>> & import("../types").StylerBaseProps) => S extends undefined ? string : { [K in keyof S | (B extends undefined ? never : "base")]: import("@byyuurin/ui-kit/index").CVHandler<V, S, string>; } : (props?: import("../types").StylerBaseProps) => S extends undefined ? string : { [K in keyof S | (B extends undefined ? never : "base")]: import("@byyuurin/ui-kit/index").CVHandler<V, S, string>; };
|
|
@@ -1,18 +1,26 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { transformUnoRules } from "@byyuurin/ui/unocss-preset";
|
|
2
2
|
import { createSharedComposable } from "@vueuse/core";
|
|
3
3
|
import { computed, toValue } from "vue";
|
|
4
4
|
import * as theme from "../theme/index.mjs";
|
|
5
|
-
import {
|
|
5
|
+
import { extendTheme, prepareStyler } from "../utils/index.mjs";
|
|
6
|
+
import { defineInjection } from "./defineInjection.mjs";
|
|
6
7
|
export const {
|
|
8
|
+
InjectionKey: InjectionKeyThemeExtension,
|
|
7
9
|
provide: provideThemeExtension,
|
|
8
10
|
inject: injectThemeExtension
|
|
9
|
-
} =
|
|
11
|
+
} = defineInjection("ui.themeExtension", {});
|
|
12
|
+
export const {
|
|
13
|
+
InjectionKey: InjectionKeyUnoConfig,
|
|
14
|
+
provide: provideUnoConfig,
|
|
15
|
+
inject: injectUnoConfig
|
|
16
|
+
} = defineInjection("ui.unoConfig", {});
|
|
10
17
|
export const useTheme = createSharedComposable(() => {
|
|
11
|
-
const
|
|
12
|
-
const
|
|
18
|
+
const themeExtension = injectThemeExtension();
|
|
19
|
+
const unoConfig = injectUnoConfig();
|
|
20
|
+
const mergeRules = transformUnoRules(unoConfig);
|
|
13
21
|
const { createStyler } = prepareStyler(mergeRules);
|
|
14
22
|
return {
|
|
15
|
-
theme: computed(() => extendTheme(toValue(
|
|
23
|
+
theme: computed(() => extendTheme(toValue(themeExtension), theme)),
|
|
16
24
|
createStyler
|
|
17
25
|
};
|
|
18
26
|
});
|
|
@@ -2,7 +2,7 @@ import { ct } from "@byyuurin/ui-kit";
|
|
|
2
2
|
export default ct({
|
|
3
3
|
slots: {
|
|
4
4
|
base: [
|
|
5
|
-
"inline-flex items-center leading-normal transition-colors",
|
|
5
|
+
"inline-flex items-center rounded-ui-button leading-normal transition-colors",
|
|
6
6
|
"disabled:cursor-not-allowed aria-disabled:cursor-not-allowed disabled:opacity-50 aria-disabled:opacity-50"
|
|
7
7
|
],
|
|
8
8
|
label: "color-inherit",
|
|
@@ -64,14 +64,6 @@ export default ct({
|
|
|
64
64
|
base: "text-xl"
|
|
65
65
|
}
|
|
66
66
|
},
|
|
67
|
-
round: {
|
|
68
|
-
true: {
|
|
69
|
-
base: "rounded-full"
|
|
70
|
-
},
|
|
71
|
-
false: {
|
|
72
|
-
base: "rounded-ui-button"
|
|
73
|
-
}
|
|
74
|
-
},
|
|
75
67
|
active: {
|
|
76
68
|
true: ""
|
|
77
69
|
},
|
|
@@ -40,12 +40,6 @@ declare const _default: {
|
|
|
40
40
|
label: string;
|
|
41
41
|
};
|
|
42
42
|
};
|
|
43
|
-
checked: {
|
|
44
|
-
true: {
|
|
45
|
-
base: string;
|
|
46
|
-
icon: string;
|
|
47
|
-
};
|
|
48
|
-
};
|
|
49
43
|
};
|
|
50
44
|
compoundVariants: import("@byyuurin/ui-kit/index").CVCompoundVariants<{
|
|
51
45
|
size: {
|
|
@@ -78,12 +72,6 @@ declare const _default: {
|
|
|
78
72
|
label: string;
|
|
79
73
|
};
|
|
80
74
|
};
|
|
81
|
-
checked: {
|
|
82
|
-
true: {
|
|
83
|
-
base: string;
|
|
84
|
-
icon: string;
|
|
85
|
-
};
|
|
86
|
-
};
|
|
87
75
|
}, {
|
|
88
76
|
root: string;
|
|
89
77
|
base: string[];
|