@byyuurin/ui 0.0.3 → 0.0.5

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.
Files changed (142) hide show
  1. package/README.md +15 -24
  2. package/dist/index.d.ts +25 -2
  3. package/dist/index.mjs +25 -2
  4. package/dist/nuxt.d.mts +1 -1
  5. package/dist/nuxt.d.ts +1 -1
  6. package/dist/nuxt.mjs +14 -10
  7. package/dist/nuxt.mjs.map +1 -0
  8. package/dist/runtime/components/Accordion.vue +1 -1
  9. package/dist/runtime/components/Alert.vue +120 -0
  10. package/dist/runtime/components/App.vue +5 -1
  11. package/dist/runtime/components/Badge.vue +71 -0
  12. package/dist/runtime/components/Button.vue +3 -3
  13. package/dist/runtime/components/Card.vue +4 -4
  14. package/dist/runtime/components/Checkbox.vue +3 -6
  15. package/dist/runtime/components/Chip.vue +59 -0
  16. package/dist/runtime/components/Drawer.vue +2 -2
  17. package/dist/runtime/components/Input.vue +7 -2
  18. package/dist/runtime/components/Link.vue +1 -1
  19. package/dist/runtime/components/Modal.vue +2 -2
  20. package/dist/runtime/components/ModalProvider.vue +1 -1
  21. package/dist/runtime/components/PinInput.vue +86 -0
  22. package/dist/runtime/components/Popover.vue +1 -1
  23. package/dist/runtime/components/RadioGroup.vue +2 -8
  24. package/dist/runtime/components/ScrollArea.vue +72 -0
  25. package/dist/runtime/components/Select.vue +2 -1
  26. package/dist/runtime/components/Slider.vue +97 -0
  27. package/dist/runtime/components/Switch.vue +1 -2
  28. package/dist/runtime/components/Tabs.vue +6 -6
  29. package/dist/runtime/components/Textarea.vue +172 -0
  30. package/dist/runtime/components/Toast.vue +2 -2
  31. package/dist/runtime/components/Toaster.vue +2 -1
  32. package/dist/runtime/components/Tooltip.vue +1 -1
  33. package/dist/runtime/composables/defineInjection.d.ts +11 -0
  34. package/dist/runtime/composables/defineInjection.mjs +9 -0
  35. package/dist/runtime/composables/useModal.d.ts +1 -1
  36. package/dist/runtime/composables/useModal.mjs +3 -2
  37. package/dist/runtime/composables/useTheme.d.ts +3 -1
  38. package/dist/runtime/composables/useTheme.mjs +14 -6
  39. package/dist/runtime/theme/accordion.mjs +24 -21
  40. package/dist/runtime/theme/alert.d.ts +85 -0
  41. package/dist/runtime/theme/alert.mjs +47 -0
  42. package/dist/runtime/theme/app.mjs +1 -0
  43. package/dist/runtime/theme/badge.d.ts +79 -0
  44. package/dist/runtime/theme/badge.mjs +89 -0
  45. package/dist/runtime/theme/button.d.ts +4 -9
  46. package/dist/runtime/theme/button.mjs +130 -127
  47. package/dist/runtime/theme/card.d.ts +2 -2
  48. package/dist/runtime/theme/card.mjs +12 -9
  49. package/dist/runtime/theme/checkbox.d.ts +0 -12
  50. package/dist/runtime/theme/checkbox.mjs +45 -47
  51. package/dist/runtime/theme/chip.d.ts +56 -0
  52. package/dist/runtime/theme/chip.mjs +63 -0
  53. package/dist/runtime/theme/drawer.mjs +69 -66
  54. package/dist/runtime/theme/index.d.ts +7 -0
  55. package/dist/runtime/theme/index.mjs +7 -0
  56. package/dist/runtime/theme/input.d.ts +13 -5
  57. package/dist/runtime/theme/input.mjs +135 -122
  58. package/dist/runtime/theme/link.d.ts +1 -1
  59. package/dist/runtime/theme/link.mjs +23 -20
  60. package/dist/runtime/theme/modal.mjs +51 -48
  61. package/dist/runtime/theme/pinInput.d.ts +97 -0
  62. package/dist/runtime/theme/pinInput.mjs +108 -0
  63. package/dist/runtime/theme/popover.mjs +11 -8
  64. package/dist/runtime/theme/radioGroup.d.ts +0 -24
  65. package/dist/runtime/theme/radioGroup.mjs +50 -59
  66. package/dist/runtime/theme/scrollArea.d.ts +51 -0
  67. package/dist/runtime/theme/scrollArea.mjs +33 -0
  68. package/dist/runtime/theme/select.d.ts +5 -2
  69. package/dist/runtime/theme/select.mjs +156 -143
  70. package/dist/runtime/theme/slider.d.ts +73 -0
  71. package/dist/runtime/theme/slider.mjs +49 -0
  72. package/dist/runtime/theme/switch.d.ts +0 -12
  73. package/dist/runtime/theme/switch.mjs +66 -69
  74. package/dist/runtime/theme/tabs.d.ts +44 -13
  75. package/dist/runtime/theme/tabs.mjs +132 -106
  76. package/dist/runtime/theme/textarea.d.ts +93 -0
  77. package/dist/runtime/theme/textarea.mjs +113 -0
  78. package/dist/runtime/theme/toast.mjs +26 -23
  79. package/dist/runtime/theme/toaster.d.ts +2 -2
  80. package/dist/runtime/theme/toaster.mjs +84 -81
  81. package/dist/runtime/theme/tooltip.mjs +9 -6
  82. package/dist/runtime/types/components.d.ts +7 -0
  83. package/dist/runtime/types/index.d.ts +1 -3
  84. package/dist/runtime/utils/extend-theme.mjs +1 -1
  85. package/dist/runtime/utils/index.d.ts +0 -11
  86. package/dist/runtime/utils/index.mjs +0 -11
  87. package/dist/runtime/utils/link.d.ts +1 -1
  88. package/dist/shared/ui.CzDyI29e.mjs +8 -0
  89. package/dist/shared/ui.CzDyI29e.mjs.map +1 -0
  90. package/dist/unocss-preset.d.mts +15 -7
  91. package/dist/unocss-preset.d.ts +15 -7
  92. package/dist/unocss-preset.mjs +97 -384
  93. package/dist/unocss-preset.mjs.map +1 -0
  94. package/dist/unplugin.d.mts +25 -0
  95. package/dist/unplugin.d.ts +25 -0
  96. package/dist/unplugin.mjs +64 -0
  97. package/dist/unplugin.mjs.map +1 -0
  98. package/dist/vite.d.mts +9 -0
  99. package/dist/vite.d.ts +9 -0
  100. package/dist/vite.mjs +14 -0
  101. package/dist/vite.mjs.map +1 -0
  102. package/package.json +22 -14
  103. package/dist/index.cjs +0 -38
  104. package/dist/resolver.d.mts +0 -13
  105. package/dist/resolver.d.ts +0 -13
  106. package/dist/resolver.mjs +0 -21
  107. package/dist/runtime/components/index.cjs +0 -132
  108. package/dist/runtime/components/index.d.ts +0 -18
  109. package/dist/runtime/components/index.mjs +0 -18
  110. package/dist/runtime/composables/index.cjs +0 -33
  111. package/dist/runtime/composables/index.d.ts +0 -4
  112. package/dist/runtime/composables/index.mjs +0 -4
  113. package/dist/runtime/composables/useComponentIcons.cjs +0 -30
  114. package/dist/runtime/composables/useModal.cjs +0 -55
  115. package/dist/runtime/composables/useTheme.cjs +0 -30
  116. package/dist/runtime/composables/useToast.cjs +0 -51
  117. package/dist/runtime/theme/accordion.cjs +0 -27
  118. package/dist/runtime/theme/app.cjs +0 -15
  119. package/dist/runtime/theme/button.cjs +0 -127
  120. package/dist/runtime/theme/card.cjs +0 -17
  121. package/dist/runtime/theme/checkbox.cjs +0 -56
  122. package/dist/runtime/theme/drawer.cjs +0 -73
  123. package/dist/runtime/theme/index.cjs +0 -125
  124. package/dist/runtime/theme/input.cjs +0 -115
  125. package/dist/runtime/theme/link.cjs +0 -23
  126. package/dist/runtime/theme/modal.cjs +0 -55
  127. package/dist/runtime/theme/popover.cjs +0 -13
  128. package/dist/runtime/theme/radioGroup.cjs +0 -73
  129. package/dist/runtime/theme/select.cjs +0 -128
  130. package/dist/runtime/theme/switch.cjs +0 -73
  131. package/dist/runtime/theme/tabs.cjs +0 -105
  132. package/dist/runtime/theme/toast.cjs +0 -33
  133. package/dist/runtime/theme/toaster.cjs +0 -72
  134. package/dist/runtime/theme/tooltip.cjs +0 -14
  135. package/dist/runtime/types/components.cjs +0 -1
  136. package/dist/runtime/types/index.cjs +0 -27
  137. package/dist/runtime/types/utils.cjs +0 -1
  138. package/dist/runtime/utils/extend-theme.cjs +0 -24
  139. package/dist/runtime/utils/index.cjs +0 -119
  140. package/dist/runtime/utils/link.cjs +0 -10
  141. package/dist/runtime/utils/styler.cjs +0 -18
  142. package/dist/shared/ui.CPXA9QoM.mjs +0 -23
@@ -6,5 +6,5 @@ const { isOpen } = useModal()
6
6
  </script>
7
7
 
8
8
  <template>
9
- <component :is="modalState.component" v-if="modalState?.props.open" v-bind="modalState.props" v-model:open="isOpen" />
9
+ <component :is="modalState.component" v-if="modalState" v-bind="modalState.props" v-model:open="isOpen" />
10
10
  </template>
@@ -0,0 +1,86 @@
1
+ <script lang="ts">
2
+ import type { VariantProps } from '@byyuurin/ui-kit'
3
+ import type { PinInputRootProps } from 'reka-ui'
4
+ import type { pinInput } from '../theme'
5
+ import type { ComponentAttrs } from '../types'
6
+
7
+ type PinInputVariants = VariantProps<typeof pinInput>
8
+
9
+ export interface PinInputProps extends ComponentAttrs<typeof pinInput>, Pick<PinInputRootProps, 'as' | 'defaultValue' | 'disabled' | 'id' | 'mask' | 'modelValue' | 'name' | 'otp' | 'placeholder' | 'required' | 'type'> {
10
+ variant?: PinInputVariants['variant']
11
+ size?: PinInputVariants['size']
12
+ length?: number | string
13
+ underline?: boolean
14
+ highlight?: boolean
15
+ }
16
+
17
+ export interface PinInputEmits {
18
+ (event: 'update:modelValue', value: string[]): void
19
+ (event: 'complete', value: string[]): void
20
+ (event: 'change', payload: Event): void
21
+ (event: 'blur', payload: Event): void
22
+ }
23
+ </script>
24
+
25
+ <script setup lang="ts">
26
+ import { reactivePick } from '@vueuse/core'
27
+ import { PinInputInput, PinInputRoot, useForwardPropsEmits } from 'reka-ui'
28
+ import { computed, ref } from 'vue'
29
+ import { useTheme } from '../composables/useTheme'
30
+ import { looseToNumber } from '../utils'
31
+
32
+ const props = withDefaults(defineProps<PinInputProps>(), {
33
+ variant: 'outline',
34
+ size: 'md',
35
+ length: 5,
36
+ type: 'text',
37
+ })
38
+
39
+ const emit = defineEmits<PinInputEmits>()
40
+
41
+ const rootProps = useForwardPropsEmits(reactivePick(props, 'defaultValue', 'disabled', 'id', 'mask', 'modelValue', 'name', 'otp', 'placeholder', 'required', 'type'), emit)
42
+
43
+ const completed = ref(false)
44
+
45
+ const { theme, createStyler } = useTheme()
46
+ const style = computed(() => {
47
+ const styler = createStyler(theme.value.pinInput)
48
+ return styler(props)
49
+ })
50
+
51
+ function onComplete(value: string[]) {
52
+ // @ts-expect-error - 'target' does not exist in type 'EventInit'
53
+ const event = new Event('change', { target: { value } })
54
+ emit('change', event)
55
+ }
56
+
57
+ function onBlur(event: FocusEvent) {
58
+ if (!event.relatedTarget || completed.value)
59
+ emit('blur', event)
60
+ }
61
+ </script>
62
+
63
+ <template>
64
+ <PinInputRoot
65
+ v-bind="rootProps"
66
+ :id="props.id"
67
+ :name="props.name"
68
+ :class="style.root({ class: [props.class, props.ui?.root] })"
69
+ @complete="onComplete"
70
+ >
71
+ <span
72
+ v-for="(ids, index) in looseToNumber(props.length)"
73
+ :key="ids"
74
+ :class="style.container({ class: props.ui?.container })"
75
+ :aria-disabled="props.disabled ? true : undefined"
76
+ >
77
+ <PinInputInput
78
+ :index="index"
79
+ :class="style.base({ class: props.ui?.base })"
80
+ v-bind="$attrs"
81
+ :disabled="props.disabled"
82
+ @blur="onBlur"
83
+ />
84
+ </span>
85
+ </PinInputRoot>
86
+ </template>
@@ -35,7 +35,7 @@ import { defu } from 'defu'
35
35
  import { useForwardPropsEmits } from 'reka-ui'
36
36
  import { HoverCard, Popover } from 'reka-ui/namespaced'
37
37
  import { computed, toRef } from 'vue'
38
- import { useTheme } from '../composables'
38
+ import { useTheme } from '../composables/useTheme'
39
39
 
40
40
  const props = withDefaults(defineProps<PopoverProps>(), {
41
41
  mode: 'click',
@@ -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 {
@@ -74,7 +70,7 @@ type NormalizeItem<T> = { id: string } & (
74
70
  import { reactivePick } from '@vueuse/core'
75
71
  import { Label, RadioGroupIndicator, RadioGroupItem, RadioGroupRoot, useForwardPropsEmits } from 'reka-ui'
76
72
  import { computed, useId } from 'vue'
77
- import { useTheme } from '../composables'
73
+ import { useTheme } from '../composables/useTheme'
78
74
  import { get } from '../utils'
79
75
 
80
76
  const props = withDefaults(defineProps<RadioGroupProps<T>>(), {
@@ -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/useTheme'
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>
@@ -105,7 +105,8 @@ import { reactivePick } from '@vueuse/core'
105
105
  import { defu } from 'defu'
106
106
  import { SelectArrow, SelectContent, SelectGroup, SelectItem, SelectItemIndicator, SelectItemText, SelectLabel, SelectPortal, SelectRoot, SelectSeparator, SelectTrigger, SelectViewport, useForwardPropsEmits } from 'reka-ui'
107
107
  import { computed, toRef } from 'vue'
108
- import { useComponentIcons, useTheme } from '../composables'
108
+ import { useComponentIcons } from '../composables/useComponentIcons'
109
+ import { useTheme } from '../composables/useTheme'
109
110
  import { compare, get } from '../utils'
110
111
 
111
112
  const props = withDefaults(defineProps<SelectProps<T, I, V, M>>(), {
@@ -0,0 +1,97 @@
1
+ <script lang="ts">
2
+ import type { VariantProps } from '@byyuurin/ui-kit'
3
+ import type { SliderRootProps } from 'reka-ui'
4
+ import type { slider } from '../theme'
5
+ import type { ComponentAttrs } from '../types'
6
+
7
+ type SliderVariants = VariantProps<typeof slider>
8
+
9
+ export interface SliderProps extends ComponentAttrs<typeof slider>, Pick<SliderRootProps, 'as' | 'name' | 'disabled' | 'inverted' | 'min' | 'max' | 'step' | 'minStepsBetweenThumbs'> {
10
+ modelValue?: number | number[]
11
+ size?: SliderVariants['size']
12
+ /**
13
+ * The orientation of the slider.
14
+ * @default 'horizontal'
15
+ */
16
+ orientation?: SliderVariants['orientation']
17
+ /** The value of the slider when initially rendered. Use when you do not need to control the state of the slider. */
18
+ defaultValue?: number | number[]
19
+ }
20
+
21
+ export interface SliderEmits {
22
+ (event: 'update:modelValue', payload: number | number[]): void
23
+ (event: 'change', payload: Event): void
24
+ }
25
+ </script>
26
+
27
+ <script setup lang="ts">
28
+ import { reactivePick } from '@vueuse/core'
29
+ import { SliderRange, SliderRoot, SliderThumb, SliderTrack, useForwardPropsEmits } from 'reka-ui'
30
+ import { computed } from 'vue'
31
+ import { useTheme } from '../composables/useTheme'
32
+
33
+ const props = withDefaults(defineProps<SliderProps>(), {
34
+ size: 'md',
35
+ orientation: 'horizontal',
36
+ step: 1,
37
+ max: 100,
38
+ })
39
+
40
+ const emit = defineEmits<SliderEmits>()
41
+
42
+ const rootProps = useForwardPropsEmits(reactivePick(props, 'as', 'orientation', 'min', 'max', 'step', 'minStepsBetweenThumbs', 'inverted'), emit)
43
+
44
+ const modelValue = defineModel<number | number[]>()
45
+
46
+ const defaultSliderValue = computed(() => {
47
+ if (typeof props.defaultValue === 'number')
48
+ return [props.defaultValue]
49
+
50
+ return props.defaultValue
51
+ })
52
+
53
+ const sliderValue = computed({
54
+ get() {
55
+ if (typeof modelValue.value === 'number')
56
+ return [modelValue.value]
57
+
58
+ return modelValue.value ?? defaultSliderValue.value
59
+ },
60
+ set(value) {
61
+ modelValue.value = value?.length === 1 ? value[0] : value
62
+ },
63
+ })
64
+
65
+ const thumbsCount = computed(() => sliderValue.value?.length ?? 1)
66
+
67
+ const { theme, createStyler } = useTheme()
68
+ const style = computed(() => {
69
+ const styler = createStyler(theme.value.slider)
70
+ return styler(props)
71
+ })
72
+
73
+ function onChange(value: any) {
74
+ // @ts-expect-error - 'target' does not exist in type 'EventInit'
75
+ const event = new Event('change', { target: { value } })
76
+ emit('change', event)
77
+ }
78
+ </script>
79
+
80
+ <template>
81
+ <SliderRoot
82
+ v-bind="rootProps"
83
+ v-model="sliderValue"
84
+ :name="props.name"
85
+ :disabled="props.disabled"
86
+ :class="style.root({ class: [props.class, props.ui?.root] })"
87
+ :default-value="defaultSliderValue"
88
+ :data-steps="thumbsCount"
89
+ @value-commit="onChange"
90
+ >
91
+ <SliderTrack :class="style.track({ class: props.ui?.track })">
92
+ <SliderRange :class="style.range({ class: props.ui?.range })" />
93
+ </SliderTrack>
94
+
95
+ <SliderThumb v-for="count in thumbsCount" :key="count" :class="style.thumb({ class: props.ui?.thumb })" />
96
+ </SliderRoot>
97
+ </template>
@@ -22,7 +22,6 @@ export interface SwitchProps extends ComponentAttrs<typeof _switch>, Pick<Switch
22
22
  uncheckedIcon?: string
23
23
  label?: string
24
24
  description?: string
25
- round?: boolean
26
25
  }
27
26
 
28
27
  export interface SwitchEmits {
@@ -39,7 +38,7 @@ export interface SwitchSlots {
39
38
  import { reactivePick } from '@vueuse/core'
40
39
  import { Label, Primitive, SwitchRoot, SwitchThumb, useForwardProps } from 'reka-ui'
41
40
  import { computed, useId } from 'vue'
42
- import { useTheme } from '../composables'
41
+ import { useTheme } from '../composables/useTheme'
43
42
 
44
43
  const props = withDefaults(defineProps<SwitchProps>(), {
45
44
  size: 'md',
@@ -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
- leading?: SlotProps<T>
44
+ prefix?: SlotProps<T>
45
45
  default?: SlotProps<T>
46
- trailing?: SlotProps<T>
46
+ suffix?: SlotProps<T>
47
47
  content?: SlotProps<T>
48
48
  } & DynamicSlots<T, SlotProps<T>>
49
49
  </script>
@@ -52,7 +52,7 @@ export type TabsSlots<T extends { slot?: string }> = {
52
52
  import { reactivePick } from '@vueuse/core'
53
53
  import { TabsContent, TabsIndicator, TabsList, TabsRoot, TabsTrigger, useForwardPropsEmits } from 'reka-ui'
54
54
  import { computed } from 'vue'
55
- import { useTheme } from '../composables'
55
+ import { useTheme } from '../composables/useTheme'
56
56
  import { get } from '../utils'
57
57
 
58
58
  const props = withDefaults(defineProps<TabsProps<T>>(), {
@@ -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="leading" :item="item" :index="index">
93
- <i v-if="item.icon" :class="style.leadingIcon({ class: [item.icon, props.ui?.leadingIcon] })"></i>
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="trailing" :item="item" :index="index"></slot>
100
+ <slot name="suffix" :item="item" :index="index"></slot>
101
101
  </TabsTrigger>
102
102
  </TabsList>
103
103
 
@@ -0,0 +1,172 @@
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/useTheme'
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
+ ></textarea>
169
+
170
+ <slot></slot>
171
+ </Primitive>
172
+ </template>
@@ -35,7 +35,7 @@ export interface ToastSlots {
35
35
  import { reactivePick, useElementBounding } from '@vueuse/core'
36
36
  import { ToastAction, ToastClose, ToastDescription, ToastRoot, ToastTitle, useForwardPropsEmits } from 'reka-ui'
37
37
  import { computed, ref } from 'vue'
38
- import { useTheme } from '../composables'
38
+ import { useTheme } from '../composables/useTheme'
39
39
  import Button from './Button.vue'
40
40
 
41
41
  const props = withDefaults(defineProps<ToastProps>(), {
@@ -121,6 +121,6 @@ defineExpose({
121
121
  </ToastClose>
122
122
  </div>
123
123
 
124
- <div v-if="remaining > 0 && duration" :class="style.progress({ class: props.ui?.progress })" :style="{ width: `${remaining / duration * 100}%` }"></div>
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>
@@ -30,7 +30,8 @@ export interface ToasterSlots {
30
30
  import { reactivePick } from '@vueuse/core'
31
31
  import { ToastPortal, ToastProvider, ToastViewport, useForwardProps } from 'reka-ui'
32
32
  import { computed, ref } from 'vue'
33
- import { useTheme, useToast } from '../composables'
33
+ import { useTheme } from '../composables/useTheme'
34
+ import { useToast } from '../composables/useToast'
34
35
  import { omit } from '../utils'
35
36
  import Toast from './Toast.vue'
36
37
 
@@ -24,7 +24,7 @@ import { reactivePick } from '@vueuse/core'
24
24
  import { defu } from 'defu'
25
25
  import { TooltipArrow, TooltipContent, TooltipPortal, TooltipRoot, TooltipTrigger, useForwardPropsEmits } from 'reka-ui'
26
26
  import { computed, toRef } from 'vue'
27
- import { useTheme } from '../composables'
27
+ import { useTheme } from '../composables/useTheme'
28
28
 
29
29
  const props = withDefaults(defineProps<TooltipProps>(), {
30
30
  portal: true,
@@ -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 { createInjection } from "../utils/index.mjs";
3
+ import { defineInjection } from "./defineInjection.mjs";
4
4
  export const {
5
+ InjectionKey: InjectionKeyModalState,
5
6
  inject: injectModalState,
6
7
  provide: provideModalState
7
- } = createInjection("ui.modal");
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>; };