@byyuurin/ui 0.0.7 → 0.0.9
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/dist/module.json +1 -1
- package/dist/module.mjs +8 -7
- package/dist/module.mjs.map +1 -1
- package/dist/runtime/app/injections.d.ts +11 -0
- package/dist/runtime/app/injections.js +26 -0
- package/dist/runtime/components/Accordion.vue +28 -26
- package/dist/runtime/components/Alert.vue +27 -23
- package/dist/runtime/components/App.vue +21 -26
- package/dist/runtime/components/Avatar.vue +70 -0
- package/dist/runtime/components/AvatarGroup.vue +87 -0
- package/dist/runtime/components/Badge.vue +17 -15
- package/dist/runtime/components/Breadcrumb.vue +108 -0
- package/dist/runtime/components/Button.vue +15 -16
- package/dist/runtime/components/ButtonGroup.vue +14 -15
- package/dist/runtime/components/Calendar.vue +176 -0
- package/dist/runtime/components/Card.vue +9 -7
- package/dist/runtime/components/Carousel.vue +22 -22
- package/dist/runtime/components/Checkbox.vue +15 -14
- package/dist/runtime/components/Chip.vue +23 -21
- package/dist/runtime/components/Collapsible.vue +5 -8
- package/dist/runtime/components/Drawer.vue +91 -49
- package/dist/runtime/components/Input.vue +33 -36
- package/dist/runtime/components/InputNumber.vue +9 -10
- package/dist/runtime/components/Kbd.vue +47 -0
- package/dist/runtime/components/Link.vue +15 -12
- package/dist/runtime/components/LinkBase.vue +1 -1
- package/dist/runtime/components/Modal.vue +31 -19
- package/dist/runtime/components/OverlayProvider.vue +29 -0
- package/dist/runtime/components/Pagination.vue +60 -53
- package/dist/runtime/components/PinInput.vue +9 -12
- package/dist/runtime/components/Popover.vue +9 -12
- package/dist/runtime/components/Progress.vue +162 -0
- package/dist/runtime/components/RadioGroup.vue +38 -35
- package/dist/runtime/components/ScrollArea.vue +2 -6
- package/dist/runtime/components/Select.vue +48 -51
- package/dist/runtime/components/Separator.vue +2 -6
- package/dist/runtime/components/Skeleton.vue +30 -0
- package/dist/runtime/components/Slider.vue +8 -11
- package/dist/runtime/components/Switch.vue +17 -17
- package/dist/runtime/components/Table.vue +21 -16
- package/dist/runtime/components/Tabs.vue +24 -23
- package/dist/runtime/components/Textarea.vue +13 -16
- package/dist/runtime/components/Toast.vue +21 -24
- package/dist/runtime/components/{Toaster.vue → ToastProvider.vue} +22 -20
- package/dist/runtime/components/Tooltip.vue +9 -12
- package/dist/runtime/composables/useAvatarGroup.d.ts +4 -0
- package/dist/runtime/composables/useAvatarGroup.js +8 -0
- package/dist/runtime/composables/useButtonGroup.d.ts +4 -12
- package/dist/runtime/composables/useButtonGroup.js +1 -6
- package/dist/runtime/composables/useComponentIcons.d.ts +9 -9
- package/dist/runtime/composables/useComponentIcons.js +11 -11
- package/dist/runtime/composables/useKbd.d.ts +35 -0
- package/dist/runtime/composables/useKbd.js +49 -0
- package/dist/runtime/composables/useLocale.d.ts +8 -0
- package/dist/runtime/composables/useLocale.js +22 -0
- package/dist/runtime/composables/useOverlay.d.ts +29 -0
- package/dist/runtime/composables/useOverlay.js +69 -0
- package/dist/runtime/composables/useTheme.d.ts +6 -6
- package/dist/runtime/composables/useTheme.js +11 -15
- package/dist/runtime/composables/useToast.d.ts +4 -20
- package/dist/runtime/composables/useToast.js +6 -5
- package/dist/runtime/index.d.ts +9 -2
- package/dist/runtime/index.js +9 -2
- package/dist/runtime/locale/en.d.ts +2 -0
- package/dist/runtime/locale/en.js +34 -0
- package/dist/runtime/locale/index.d.ts +2 -0
- package/dist/runtime/locale/index.js +2 -0
- package/dist/runtime/locale/zh-tw.d.ts +2 -0
- package/dist/runtime/locale/zh-tw.js +34 -0
- package/dist/runtime/theme/accordion.d.ts +6 -6
- package/dist/runtime/theme/accordion.js +5 -5
- package/dist/runtime/theme/alert.js +3 -3
- package/dist/runtime/theme/app.d.ts +6 -6
- package/dist/runtime/theme/app.js +7 -7
- package/dist/runtime/theme/avatar-group.d.ts +52 -0
- package/dist/runtime/theme/avatar-group.js +32 -0
- package/dist/runtime/theme/avatar.d.ts +56 -0
- package/dist/runtime/theme/avatar.js +34 -0
- package/dist/runtime/theme/breadcrumb.d.ts +67 -0
- package/dist/runtime/theme/breadcrumb.js +44 -0
- package/dist/runtime/theme/button.d.ts +8 -8
- package/dist/runtime/theme/button.js +22 -22
- package/dist/runtime/theme/calendar.d.ts +56 -0
- package/dist/runtime/theme/calendar.js +69 -0
- package/dist/runtime/theme/card.js +6 -6
- package/dist/runtime/theme/carousel.js +1 -1
- package/dist/runtime/theme/checkbox.js +5 -5
- package/dist/runtime/theme/chip.d.ts +4 -4
- package/dist/runtime/theme/chip.js +5 -5
- package/dist/runtime/theme/drawer.d.ts +24 -21
- package/dist/runtime/theme/drawer.js +47 -20
- package/dist/runtime/theme/index.d.ts +8 -1
- package/dist/runtime/theme/index.js +8 -1
- package/dist/runtime/theme/input-number.d.ts +6 -0
- package/dist/runtime/theme/input-number.js +6 -3
- package/dist/runtime/theme/input.d.ts +12 -12
- package/dist/runtime/theme/input.js +26 -26
- package/dist/runtime/theme/kbd.d.ts +39 -0
- package/dist/runtime/theme/kbd.js +26 -0
- package/dist/runtime/theme/link.d.ts +1 -1
- package/dist/runtime/theme/link.js +3 -3
- package/dist/runtime/theme/modal.js +5 -5
- package/dist/runtime/theme/pagination.d.ts +27 -3
- package/dist/runtime/theme/pagination.js +6 -2
- package/dist/runtime/theme/pinInput.js +13 -13
- package/dist/runtime/theme/popover.js +1 -1
- package/dist/runtime/theme/progress.d.ts +122 -0
- package/dist/runtime/theme/progress.js +95 -0
- package/dist/runtime/theme/radio-group.d.ts +2 -2
- package/dist/runtime/theme/radio-group.js +7 -7
- package/dist/runtime/theme/select.d.ts +18 -18
- package/dist/runtime/theme/select.js +34 -34
- package/dist/runtime/theme/separator.js +1 -1
- package/dist/runtime/theme/skeleton.d.ts +8 -0
- package/dist/runtime/theme/skeleton.js +7 -0
- package/dist/runtime/theme/slider.js +1 -1
- package/dist/runtime/theme/switch.js +6 -6
- package/dist/runtime/theme/table.js +7 -7
- package/dist/runtime/theme/tabs.d.ts +2 -2
- package/dist/runtime/theme/tabs.js +11 -11
- package/dist/runtime/theme/textarea.js +13 -13
- package/dist/runtime/theme/toast.js +6 -6
- package/dist/runtime/theme/tooltip.js +1 -1
- package/dist/runtime/types/components.d.ts +9 -1
- package/dist/runtime/types/index.d.ts +1 -0
- package/dist/runtime/types/index.js +1 -0
- package/dist/runtime/types/locale.d.ts +29 -0
- package/dist/runtime/types/locale.js +0 -0
- package/dist/runtime/types/utils.d.ts +5 -3
- package/dist/runtime/utils/index.d.ts +6 -1
- package/dist/runtime/utils/index.js +6 -4
- package/dist/runtime/utils/link.d.ts +1 -1
- package/dist/runtime/utils/translator.d.ts +18 -0
- package/dist/runtime/utils/translator.js +8 -0
- package/dist/shared/ui.1a1f119c.mjs +5 -0
- package/dist/shared/ui.1a1f119c.mjs.map +1 -0
- package/dist/unocss.mjs +19 -14
- package/dist/unocss.mjs.map +1 -1
- package/dist/unplugin.mjs +3 -12
- package/dist/unplugin.mjs.map +1 -1
- package/dist/vite.mjs +1 -1
- package/package.json +30 -19
- package/dist/runtime/components/ModalProvider.vue +0 -10
- package/dist/runtime/composables/useModal.d.ts +0 -15
- package/dist/runtime/composables/useModal.js +0 -52
- package/dist/shared/ui.d1728164.mjs +0 -4
- package/dist/shared/ui.d1728164.mjs.map +0 -1
- /package/dist/runtime/theme/{toaster.d.ts → toast-provider.d.ts} +0 -0
- /package/dist/runtime/theme/{toaster.js → toast-provider.js} +0 -0
- /package/dist/runtime/{composables/defineInjection.d.ts → utils/vue.d.ts} +0 -0
- /package/dist/runtime/{composables/defineInjection.js → utils/vue.js} +0 -0
|
@@ -4,6 +4,31 @@ import type { AcceptableValue, PrimitiveProps, RadioGroupRootProps } from 'reka-
|
|
|
4
4
|
import type { radioGroup } from '../theme'
|
|
5
5
|
import type { ComponentAttrs } from '../types'
|
|
6
6
|
|
|
7
|
+
export interface RadioGroupEmits {
|
|
8
|
+
(event: 'update:modelValue', payload: string): void
|
|
9
|
+
(event: 'change', payload: Event): void
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
type SlotProps<T> = (props: { item: NormalizeItem<T>, modelValue?: AcceptableValue }) => any
|
|
13
|
+
|
|
14
|
+
export interface RadioGroupSlots<T> {
|
|
15
|
+
legend?: (props?: {}) => any
|
|
16
|
+
label?: SlotProps<T>
|
|
17
|
+
description?: SlotProps<T>
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
type NormalizeItem<T> = { id: string } & (
|
|
21
|
+
T extends RadioOption
|
|
22
|
+
? T
|
|
23
|
+
: {
|
|
24
|
+
id: string
|
|
25
|
+
label: string
|
|
26
|
+
value: any
|
|
27
|
+
description: string
|
|
28
|
+
disabled: boolean
|
|
29
|
+
}
|
|
30
|
+
)
|
|
31
|
+
|
|
7
32
|
type RadioGroupVariants = VariantProps<typeof radioGroup>
|
|
8
33
|
|
|
9
34
|
export interface RadioOption {
|
|
@@ -14,56 +39,35 @@ export interface RadioOption {
|
|
|
14
39
|
}
|
|
15
40
|
|
|
16
41
|
export interface RadioGroupProps<T> extends ComponentAttrs<typeof radioGroup>, Pick<RadioGroupRootProps, 'defaultValue' | 'disabled' | 'loop' | 'modelValue' | 'name' | 'required'> {
|
|
42
|
+
/**
|
|
43
|
+
* The element or component this component should render as.
|
|
44
|
+
* @default "div"
|
|
45
|
+
*/
|
|
17
46
|
as?: PrimitiveProps['as']
|
|
18
47
|
legend?: string
|
|
19
48
|
/**
|
|
20
49
|
* When `options` is an array of objects, select the field to use as the value.
|
|
21
|
-
* @default
|
|
50
|
+
* @default "value"
|
|
22
51
|
*/
|
|
23
52
|
valueKey?: string
|
|
24
53
|
/**
|
|
25
54
|
* When `options` is an array of objects, select the field to use as the label.
|
|
26
|
-
* @default
|
|
55
|
+
* @default "label"
|
|
27
56
|
*/
|
|
28
57
|
labelKey?: string
|
|
29
58
|
/**
|
|
30
59
|
* When `options` is an array of objects, select the field to use as the description.
|
|
31
|
-
* @default
|
|
60
|
+
* @default "description"
|
|
32
61
|
*/
|
|
33
62
|
descriptionKey?: string
|
|
34
63
|
options?: T[]
|
|
35
64
|
size?: RadioGroupVariants['size']
|
|
36
65
|
/**
|
|
37
66
|
* The orientation the radio buttons are laid out.
|
|
38
|
-
* @default
|
|
67
|
+
* @default "vertical"
|
|
39
68
|
*/
|
|
40
69
|
orientation?: RadioGroupRootProps['orientation']
|
|
41
70
|
}
|
|
42
|
-
|
|
43
|
-
export interface RadioGroupEmits {
|
|
44
|
-
(event: 'update:modelValue', payload: string): void
|
|
45
|
-
(event: 'change', payload: Event): void
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
type SlotProps<T> = (props: { item: NormalizeItem<T>, modelValue?: AcceptableValue }) => any
|
|
49
|
-
|
|
50
|
-
export interface RadioGroupSlots<T> {
|
|
51
|
-
legend?: (props?: {}) => any
|
|
52
|
-
label?: SlotProps<T>
|
|
53
|
-
description?: SlotProps<T>
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
type NormalizeItem<T> = { id: string } & (
|
|
57
|
-
T extends RadioOption
|
|
58
|
-
? T
|
|
59
|
-
: {
|
|
60
|
-
id: string
|
|
61
|
-
label: string
|
|
62
|
-
value: any
|
|
63
|
-
description: string
|
|
64
|
-
disabled: false
|
|
65
|
-
}
|
|
66
|
-
)
|
|
67
71
|
</script>
|
|
68
72
|
|
|
69
73
|
<script lang="ts" setup generic="T extends RadioOption | AcceptableValue">
|
|
@@ -86,11 +90,8 @@ const slots = defineSlots<RadioGroupSlots<T>>()
|
|
|
86
90
|
const rootProps = useForwardPropsEmits(reactivePick(props, 'as', 'modelValue', 'defaultValue', 'orientation', 'loop', 'required'), emit)
|
|
87
91
|
const id = useId()
|
|
88
92
|
|
|
89
|
-
const {
|
|
90
|
-
const style = computed(() =>
|
|
91
|
-
const styler = createStyler(theme.value.radioGroup)
|
|
92
|
-
return styler(props)
|
|
93
|
-
})
|
|
93
|
+
const { generateStyle } = useTheme()
|
|
94
|
+
const style = computed(() => generateStyle('radioGroup', props))
|
|
94
95
|
|
|
95
96
|
function normalizeItem(item: any): NormalizeItem<T> {
|
|
96
97
|
if (['string', 'number', 'boolean'].includes(typeof item)) {
|
|
@@ -99,6 +100,7 @@ function normalizeItem(item: any): NormalizeItem<T> {
|
|
|
99
100
|
value: item,
|
|
100
101
|
label: item,
|
|
101
102
|
description: '',
|
|
103
|
+
disabled: props.disabled,
|
|
102
104
|
} as any
|
|
103
105
|
}
|
|
104
106
|
|
|
@@ -112,6 +114,7 @@ function normalizeItem(item: any): NormalizeItem<T> {
|
|
|
112
114
|
label,
|
|
113
115
|
description,
|
|
114
116
|
id: `${id}:${value}`,
|
|
117
|
+
disabled: props.disabled || item.disabled,
|
|
115
118
|
}
|
|
116
119
|
}
|
|
117
120
|
|
|
@@ -145,7 +148,7 @@ function onUpdate(value: any) {
|
|
|
145
148
|
{{ props.legend }}
|
|
146
149
|
</slot>
|
|
147
150
|
</legend>
|
|
148
|
-
<div v-for="item in normalizedItems" :key="item.value" :class="style.item({ class: props.ui?.item })">
|
|
151
|
+
<div v-for="item in normalizedItems" :key="item.value" :class="style.item({ class: props.ui?.item, disabled: item.disabled })">
|
|
149
152
|
<div :class="style.container({ class: props.ui?.container })">
|
|
150
153
|
<RadioGroupItem
|
|
151
154
|
:id="item.id"
|
|
@@ -17,12 +17,8 @@ const props = withDefaults(defineProps<ScrollAreaProps>(), {})
|
|
|
17
17
|
const rootRef = ref<InstanceType<typeof ScrollAreaRoot>>()
|
|
18
18
|
const rootProps = reactivePick(props, 'type', 'dir', 'scrollHideDelay')
|
|
19
19
|
|
|
20
|
-
const {
|
|
21
|
-
|
|
22
|
-
const style = computed(() => {
|
|
23
|
-
const styler = createStyler(theme.value.scrollArea)
|
|
24
|
-
return styler(props)
|
|
25
|
-
})
|
|
20
|
+
const { generateStyle } = useTheme()
|
|
21
|
+
const style = computed(() => generateStyle('scrollArea', props))
|
|
26
22
|
|
|
27
23
|
defineExpose({
|
|
28
24
|
scrollTop,
|
|
@@ -5,6 +5,26 @@ import type { UseComponentIconsProps } from '../composables/useComponentIcons'
|
|
|
5
5
|
import type { select } from '../theme'
|
|
6
6
|
import type { ComponentAttrs, MaybeArray, MaybeArrayOfArray, MaybeArrayOfArrayItem, SelectModelValue, SelectOptionKey } from '../types'
|
|
7
7
|
|
|
8
|
+
export interface SelectEmits<T, V, M extends boolean> {
|
|
9
|
+
(event: 'update:open', value: boolean): void
|
|
10
|
+
(event: 'update:modelValue', payload: SelectModelValue<T, V, M, T extends { value: infer U } ? U : never>): void
|
|
11
|
+
(event: 'change', payload: Event): void
|
|
12
|
+
(event: 'blur', payload: FocusEvent): void
|
|
13
|
+
(event: 'focus', payload: FocusEvent): void
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
type SlotProps<T> = (props: { item: T, index: number }) => any
|
|
17
|
+
|
|
18
|
+
export interface SelectSlots<T, M extends boolean> {
|
|
19
|
+
'leading'?: (props: { modelValue?: M extends true ? AcceptableValue[] : AcceptableValue, open: boolean, ui: ComponentAttrs<typeof select>['ui'] }) => any
|
|
20
|
+
'default'?: (props: { modelValue?: M extends true ? AcceptableValue[] : AcceptableValue, open: boolean }) => any
|
|
21
|
+
'trailing'?: (props: { modelValue?: M extends true ? AcceptableValue[] : AcceptableValue, open: boolean, ui: ComponentAttrs<typeof select>['ui'] }) => any
|
|
22
|
+
'item'?: SlotProps<T>
|
|
23
|
+
'item-leading'?: SlotProps<T>
|
|
24
|
+
'item-label'?: SlotProps<T>
|
|
25
|
+
'item-trailing'?: SlotProps<T>
|
|
26
|
+
}
|
|
27
|
+
|
|
8
28
|
type SelectVariants = VariantProps<typeof select>
|
|
9
29
|
|
|
10
30
|
export interface SelectOption {
|
|
@@ -12,7 +32,7 @@ export interface SelectOption {
|
|
|
12
32
|
icon?: string
|
|
13
33
|
/**
|
|
14
34
|
* The option type.
|
|
15
|
-
* @default
|
|
35
|
+
* @default "option"
|
|
16
36
|
*/
|
|
17
37
|
type?: 'label' | 'separator' | 'option'
|
|
18
38
|
value?: string
|
|
@@ -34,9 +54,9 @@ export interface SelectProps<
|
|
|
34
54
|
size?: SelectVariants['size']
|
|
35
55
|
/**
|
|
36
56
|
* The icon displayed to open the menu.
|
|
37
|
-
* @default app.icons.
|
|
57
|
+
* @default app.icons.chevronDown
|
|
38
58
|
*/
|
|
39
|
-
|
|
59
|
+
trailingIcon?: string
|
|
40
60
|
/**
|
|
41
61
|
* The icon displayed when an item is selected.
|
|
42
62
|
* @default app.icons.check
|
|
@@ -59,7 +79,7 @@ export interface SelectProps<
|
|
|
59
79
|
portal?: boolean
|
|
60
80
|
/**
|
|
61
81
|
* When `options` is an array of objects, select the field to use as the value.
|
|
62
|
-
* @default
|
|
82
|
+
* @default "value"
|
|
63
83
|
*/
|
|
64
84
|
valueKey?: V
|
|
65
85
|
/**
|
|
@@ -78,26 +98,6 @@ export interface SelectProps<
|
|
|
78
98
|
highlight?: boolean
|
|
79
99
|
underline?: boolean
|
|
80
100
|
}
|
|
81
|
-
|
|
82
|
-
export interface SelectEmits<T, V, M extends boolean> {
|
|
83
|
-
(event: 'update:open', value: boolean): void
|
|
84
|
-
(event: 'update:modelValue', payload: SelectModelValue<T, V, M, T extends { value: infer U } ? U : never>): void
|
|
85
|
-
(event: 'change', payload: Event): void
|
|
86
|
-
(event: 'blur', payload: FocusEvent): void
|
|
87
|
-
(event: 'focus', payload: FocusEvent): void
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
type SlotProps<T> = (props: { item: T, index: number }) => any
|
|
91
|
-
|
|
92
|
-
export interface SelectSlots<T, M extends boolean> {
|
|
93
|
-
prefix?: (props: { modelValue?: M extends true ? AcceptableValue[] : AcceptableValue, open: boolean, ui: ComponentAttrs<typeof select>['ui'] }) => any
|
|
94
|
-
default?: (props: { modelValue?: M extends true ? AcceptableValue[] : AcceptableValue, open: boolean }) => any
|
|
95
|
-
suffix?: (props: { modelValue?: M extends true ? AcceptableValue[] : AcceptableValue, open: boolean, ui: ComponentAttrs<typeof select>['ui'] }) => any
|
|
96
|
-
item?: SlotProps<T>
|
|
97
|
-
itemPrefix?: SlotProps<T>
|
|
98
|
-
itemLabel?: SlotProps<T>
|
|
99
|
-
itemSuffix?: SlotProps<T>
|
|
100
|
-
}
|
|
101
101
|
</script>
|
|
102
102
|
|
|
103
103
|
<script lang="ts" setup generic="T extends MaybeArrayOfArrayItem<I>, I extends MaybeArrayOfArray<SelectOption | AcceptableValue | boolean> = MaybeArrayOfArray<SelectOption | AcceptableValue | boolean>, V extends SelectOptionKey<T> | undefined = undefined, M extends boolean = false">
|
|
@@ -124,27 +124,24 @@ const rootProps = useForwardPropsEmits(reactivePick(props, 'open', 'defaultOpen'
|
|
|
124
124
|
const contentProps = toRef(() => defu(props.content, { side: 'bottom', sideOffset: 8, collisionPadding: 8, position: 'popper' }) as SelectContentProps)
|
|
125
125
|
const arrowProps = toRef(() => props.arrow as SelectArrowProps)
|
|
126
126
|
|
|
127
|
-
const { theme,
|
|
127
|
+
const { theme, generateStyle } = useTheme()
|
|
128
128
|
|
|
129
129
|
const { size, orientation } = useButtonGroup(props)
|
|
130
|
-
const {
|
|
131
|
-
|
|
130
|
+
const { isLeading, isTrailing, leadingIconName, trailingIconName } = useComponentIcons(toRef(() => defu(props, {
|
|
131
|
+
trailingIcon: theme.value.app.icons.chevronDown,
|
|
132
132
|
})))
|
|
133
133
|
|
|
134
|
+
const style = computed(() => generateStyle('select', {
|
|
135
|
+
...props,
|
|
136
|
+
size: size.value,
|
|
137
|
+
groupOrientation: orientation.value,
|
|
138
|
+
leading: isLeading.value,
|
|
139
|
+
trailing: isTrailing.value,
|
|
140
|
+
}))
|
|
141
|
+
|
|
134
142
|
const groups = computed(() => props.options?.length ? (Array.isArray(props.options[0]) ? props.options : [props.options]) as SelectOption[][] : [])
|
|
135
143
|
const items = computed(() => groups.value.flat() as T[])
|
|
136
144
|
|
|
137
|
-
const style = computed(() => {
|
|
138
|
-
const styler = createStyler(theme.value.select)
|
|
139
|
-
return styler({
|
|
140
|
-
...props,
|
|
141
|
-
size: size.value,
|
|
142
|
-
groupOrientation: orientation.value,
|
|
143
|
-
prefix: isPrefix.value,
|
|
144
|
-
suffix: isSuffix.value,
|
|
145
|
-
})
|
|
146
|
-
})
|
|
147
|
-
|
|
148
145
|
function typedItem(item: SelectOption) {
|
|
149
146
|
return item as unknown as T
|
|
150
147
|
}
|
|
@@ -162,7 +159,7 @@ function displayValue(value?: MaybeArray<AcceptableValue>): string | undefined {
|
|
|
162
159
|
return value.map((v) => displayValue(v)).filter(Boolean).join(', ')
|
|
163
160
|
|
|
164
161
|
const item = items.value.find((item) => compare(typeof item === 'object' ? get(item as Record<string, any>, props.valueKey as string) : item, value))
|
|
165
|
-
return item && (typeof item === 'object' ? get(item, props.labelKey as string) : item)
|
|
162
|
+
return (item != null) && (typeof item === 'object' ? get(item, props.labelKey as string) : item.toString())
|
|
166
163
|
}
|
|
167
164
|
|
|
168
165
|
function onUpdate(value: any) {
|
|
@@ -196,9 +193,9 @@ function onUpdateOpen(value: boolean) {
|
|
|
196
193
|
@update:open="onUpdateOpen"
|
|
197
194
|
>
|
|
198
195
|
<SelectTrigger :id="props.id" :class="style.base({ class: [props.class, props.ui?.base] })">
|
|
199
|
-
<span v-if="
|
|
200
|
-
<slot name="
|
|
201
|
-
<span v-if="
|
|
196
|
+
<span v-if="isLeading || slots.leading" :class="style.leading({ class: props.ui?.leading })">
|
|
197
|
+
<slot name="leading" :model-value="typedValue(innerValue)" :open="open" :ui="props.ui">
|
|
198
|
+
<span v-if="isLeading && leadingIconName" :class="style.leadingIcon({ class: [leadingIconName, props.ui?.leadingIcon] })"></span>
|
|
202
199
|
</slot>
|
|
203
200
|
</span>
|
|
204
201
|
|
|
@@ -213,9 +210,9 @@ function onUpdateOpen(value: boolean) {
|
|
|
213
210
|
</template>
|
|
214
211
|
</slot>
|
|
215
212
|
|
|
216
|
-
<span v-if="
|
|
217
|
-
<slot name="
|
|
218
|
-
<span v-if="
|
|
213
|
+
<span v-if="isTrailing || !!slots.trailing" :class="style.trailing({ class: props.ui?.trailing })">
|
|
214
|
+
<slot name="trailing" :model-value="typedValue(innerValue)" :open="open" :ui="props.ui">
|
|
215
|
+
<span v-if="trailingIconName" :class="style.trailingIcon({ class: [trailingIconName, props.ui?.trailingIcon] })"></span>
|
|
219
216
|
</slot>
|
|
220
217
|
</span>
|
|
221
218
|
</SelectTrigger>
|
|
@@ -237,21 +234,21 @@ function onUpdateOpen(value: boolean) {
|
|
|
237
234
|
:value="typeof item === 'object' ? get(item, props.valueKey as string) : item"
|
|
238
235
|
>
|
|
239
236
|
<slot name="item" :item="typedItem(item)" :index="index">
|
|
240
|
-
<slot name="
|
|
241
|
-
<span v-if="item.icon" :class="style.
|
|
237
|
+
<slot name="item-leading" :item="typedItem(item)" :index="index">
|
|
238
|
+
<span v-if="item.icon" :class="style.itemLeadingIcon({ class: [item.icon, props.ui?.itemLeadingIcon] })"></span>
|
|
242
239
|
</slot>
|
|
243
240
|
|
|
244
241
|
<SelectItemText :class="style.itemLabel({ class: props.ui?.itemLabel })">
|
|
245
|
-
<slot name="
|
|
242
|
+
<slot name="item-label" :item="typedItem(item)" :index="index">
|
|
246
243
|
{{ typeof item === 'object' ? get(item, props.labelKey as string) : item }}
|
|
247
244
|
</slot>
|
|
248
245
|
</SelectItemText>
|
|
249
246
|
|
|
250
|
-
<span :class="style.
|
|
251
|
-
<slot name="
|
|
247
|
+
<span :class="style.itemTrailing({ class: props.ui?.itemTrailing })">
|
|
248
|
+
<slot name="item-trailing" :item="typedItem(item)" :index="index"></slot>
|
|
252
249
|
|
|
253
250
|
<SelectItemIndicator as-child>
|
|
254
|
-
<span :class="style.
|
|
251
|
+
<span :class="style.itemTrailingIcon({ class: [props.selectedIcon || theme.app.icons.check, props.ui?.itemTrailingIcon] })"></span>
|
|
255
252
|
</SelectItemIndicator>
|
|
256
253
|
</span>
|
|
257
254
|
</slot>
|
|
@@ -37,12 +37,8 @@ const slots = defineSlots<SeparatorSlots>()
|
|
|
37
37
|
|
|
38
38
|
const rootProps = useForwardProps(reactivePick(props, 'as', 'decorative', 'orientation'))
|
|
39
39
|
|
|
40
|
-
const {
|
|
41
|
-
|
|
42
|
-
const style = computed(() => {
|
|
43
|
-
const styler = createStyler(theme.value.separator)
|
|
44
|
-
return styler(props)
|
|
45
|
-
})
|
|
40
|
+
const { generateStyle } = useTheme()
|
|
41
|
+
const style = computed(() => generateStyle('separator', props))
|
|
46
42
|
</script>
|
|
47
43
|
|
|
48
44
|
<template>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { PrimitiveProps } from 'reka-ui'
|
|
3
|
+
import type { skeleton } from '../theme'
|
|
4
|
+
import type { ComponentAttrs } from '../types'
|
|
5
|
+
|
|
6
|
+
export interface SkeletonProps extends Omit<ComponentAttrs<typeof skeleton>, 'ui'> {
|
|
7
|
+
/**
|
|
8
|
+
* The element or component this component should render as.
|
|
9
|
+
* @default "div"
|
|
10
|
+
*/
|
|
11
|
+
as?: PrimitiveProps['as']
|
|
12
|
+
}
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<script setup lang="ts">
|
|
16
|
+
import { Primitive } from 'reka-ui'
|
|
17
|
+
import { computed } from 'vue'
|
|
18
|
+
import { useTheme } from '../composables/useTheme'
|
|
19
|
+
|
|
20
|
+
const props = withDefaults(defineProps<SkeletonProps>(), {})
|
|
21
|
+
|
|
22
|
+
const { generateStyle } = useTheme()
|
|
23
|
+
const styler = computed(() => generateStyle('skeleton', props))
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<template>
|
|
27
|
+
<Primitive :as="props.as" :class="styler">
|
|
28
|
+
<slot></slot>
|
|
29
|
+
</Primitive>
|
|
30
|
+
</template>
|
|
@@ -4,6 +4,11 @@ import type { SliderRootProps } from 'reka-ui'
|
|
|
4
4
|
import type { slider } from '../theme'
|
|
5
5
|
import type { ComponentAttrs } from '../types'
|
|
6
6
|
|
|
7
|
+
export interface SliderEmits {
|
|
8
|
+
(event: 'update:modelValue', payload: number | number[]): void
|
|
9
|
+
(event: 'change', payload: Event): void
|
|
10
|
+
}
|
|
11
|
+
|
|
7
12
|
type SliderVariants = VariantProps<typeof slider>
|
|
8
13
|
|
|
9
14
|
export interface SliderProps extends ComponentAttrs<typeof slider>, Pick<SliderRootProps, 'as' | 'name' | 'disabled' | 'inverted' | 'min' | 'max' | 'step' | 'minStepsBetweenThumbs'> {
|
|
@@ -11,17 +16,12 @@ export interface SliderProps extends ComponentAttrs<typeof slider>, Pick<SliderR
|
|
|
11
16
|
size?: SliderVariants['size']
|
|
12
17
|
/**
|
|
13
18
|
* The orientation of the slider.
|
|
14
|
-
* @default
|
|
19
|
+
* @default "horizontal"
|
|
15
20
|
*/
|
|
16
21
|
orientation?: SliderVariants['orientation']
|
|
17
22
|
/** The value of the slider when initially rendered. Use when you do not need to control the state of the slider. */
|
|
18
23
|
defaultValue?: number | number[]
|
|
19
24
|
}
|
|
20
|
-
|
|
21
|
-
export interface SliderEmits {
|
|
22
|
-
(event: 'update:modelValue', payload: number | number[]): void
|
|
23
|
-
(event: 'change', payload: Event): void
|
|
24
|
-
}
|
|
25
25
|
</script>
|
|
26
26
|
|
|
27
27
|
<script setup lang="ts">
|
|
@@ -63,11 +63,8 @@ const sliderValue = computed({
|
|
|
63
63
|
|
|
64
64
|
const thumbsCount = computed(() => sliderValue.value?.length ?? 1)
|
|
65
65
|
|
|
66
|
-
const {
|
|
67
|
-
const style = computed(() =>
|
|
68
|
-
const styler = createStyler(theme.value.slider)
|
|
69
|
-
return styler(props)
|
|
70
|
-
})
|
|
66
|
+
const { generateStyle } = useTheme()
|
|
67
|
+
const style = computed(() => generateStyle('slider', props))
|
|
71
68
|
|
|
72
69
|
function onChange(value: any) {
|
|
73
70
|
// @ts-expect-error - 'target' does not exist in type 'EventInit'
|
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { VariantProps } from '@byyuurin/ui-kit'
|
|
3
|
-
import type {
|
|
3
|
+
import type { SwitchRootProps } from 'reka-ui'
|
|
4
4
|
import type { switch as _switch } from '../theme'
|
|
5
5
|
import type { ComponentAttrs } from '../types'
|
|
6
6
|
|
|
7
|
+
export interface SwitchEmits {
|
|
8
|
+
(event: 'change', payload: Event): void
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface SwitchSlots {
|
|
12
|
+
label?: (props: { label?: string }) => any
|
|
13
|
+
description?: (props: { description?: string }) => any
|
|
14
|
+
}
|
|
15
|
+
|
|
7
16
|
type SwitchVariants = VariantProps<typeof _switch>
|
|
8
17
|
|
|
9
|
-
export interface SwitchProps extends ComponentAttrs<typeof _switch>, Pick<SwitchRootProps, 'disabled' | 'id' | 'name' | 'required' | 'value' | 'defaultValue'> {
|
|
10
|
-
as?: PrimitiveProps['as']
|
|
18
|
+
export interface SwitchProps extends ComponentAttrs<typeof _switch>, Pick<SwitchRootProps, 'as' | 'disabled' | 'id' | 'name' | 'required' | 'value' | 'defaultValue'> {
|
|
11
19
|
size?: SwitchVariants['size']
|
|
12
20
|
/** When `true`, the loading icon will be displayed. */
|
|
13
21
|
loading?: boolean
|
|
@@ -23,15 +31,6 @@ export interface SwitchProps extends ComponentAttrs<typeof _switch>, Pick<Switch
|
|
|
23
31
|
label?: string
|
|
24
32
|
description?: string
|
|
25
33
|
}
|
|
26
|
-
|
|
27
|
-
export interface SwitchEmits {
|
|
28
|
-
(event: 'change', payload: Event): void
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export interface SwitchSlots {
|
|
32
|
-
label?: (props: { label?: string }) => any
|
|
33
|
-
description?: (props: { description?: string }) => any
|
|
34
|
-
}
|
|
35
34
|
</script>
|
|
36
35
|
|
|
37
36
|
<script lang="ts" setup>
|
|
@@ -48,11 +47,12 @@ const modelValue = defineModel<boolean>({ default: undefined })
|
|
|
48
47
|
const rootProps = useForwardProps(reactivePick(props, 'required', 'value', 'defaultValue'))
|
|
49
48
|
const id = useId()
|
|
50
49
|
|
|
51
|
-
const { theme,
|
|
52
|
-
const style = computed(() => {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
50
|
+
const { theme, generateStyle } = useTheme()
|
|
51
|
+
const style = computed(() => generateStyle('switch', {
|
|
52
|
+
...props,
|
|
53
|
+
checked: false,
|
|
54
|
+
unchecked: false,
|
|
55
|
+
}))
|
|
56
56
|
|
|
57
57
|
function onUpdate(value: any) {
|
|
58
58
|
// @ts-expect-error - 'target' does not exist in type 'EventInit'
|
|
@@ -5,16 +5,8 @@ import type { Ref } from 'vue'
|
|
|
5
5
|
import type { table } from '../theme'
|
|
6
6
|
import type { ComponentAttrs } from '../types'
|
|
7
7
|
|
|
8
|
-
export type TableData = RowData
|
|
9
|
-
export type TableColumn<T extends TableData, D = unknown> = ColumnDef<T, D> & { title?: string }
|
|
10
|
-
|
|
11
|
-
export interface TableOptions<T extends TableData> extends Omit<CoreOptions<T>, 'data' | 'columns' | 'getCoreRowModel' | 'state' | 'onStateChange' | 'renderFallbackValue'> {
|
|
12
|
-
state?: CoreOptions<T>['state']
|
|
13
|
-
onStateChange?: CoreOptions<T>['onStateChange']
|
|
14
|
-
renderFallbackValue?: CoreOptions<T>['renderFallbackValue']
|
|
15
|
-
}
|
|
16
|
-
|
|
17
8
|
type DynamicHeaderSlots<T, K = keyof T> = Record<string, (props: HeaderContext<T, unknown>) => any> & Record<`${K extends string ? K : never}-header`, (props: HeaderContext<T, unknown>) => any>
|
|
9
|
+
|
|
18
10
|
type DynamicCellSlots<T, K = keyof T> = Record<string, (props: CellContext<T, unknown>) => any> & Record<`${K extends string ? K : never}-cell`, (props: CellContext<T, unknown>) => any>
|
|
19
11
|
|
|
20
12
|
export type TableSlots<T> = {
|
|
@@ -23,7 +15,21 @@ export type TableSlots<T> = {
|
|
|
23
15
|
caption: (props?: {}) => any
|
|
24
16
|
} & DynamicHeaderSlots<T> & DynamicCellSlots<T>
|
|
25
17
|
|
|
26
|
-
export
|
|
18
|
+
export type TableData = RowData
|
|
19
|
+
export type TableColumn<T extends TableData, D = unknown> = ColumnDef<T, D> & { title?: string }
|
|
20
|
+
|
|
21
|
+
export interface TableOptions<T extends TableData> extends Omit<CoreOptions<T>, 'data' | 'columns' | 'getCoreRowModel' | 'state' | 'onStateChange' | 'renderFallbackValue'> {
|
|
22
|
+
state?: CoreOptions<T>['state']
|
|
23
|
+
onStateChange?: CoreOptions<T>['onStateChange']
|
|
24
|
+
renderFallbackValue?: CoreOptions<T>['renderFallbackValue']
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface TableProps<T extends TableData> extends ComponentAttrs<typeof table>, TableOptions<T> {
|
|
28
|
+
/**
|
|
29
|
+
* The element or component this component should render as.
|
|
30
|
+
* @default "div"
|
|
31
|
+
*/
|
|
32
|
+
as?: PrimitiveProps['as']
|
|
27
33
|
data?: T[]
|
|
28
34
|
columns?: TableColumn<T>[]
|
|
29
35
|
caption?: string
|
|
@@ -101,6 +107,7 @@ import { reactiveOmit } from '@vueuse/core'
|
|
|
101
107
|
import { Primitive } from 'reka-ui'
|
|
102
108
|
import { upperFirst } from 'scule'
|
|
103
109
|
import { computed } from 'vue'
|
|
110
|
+
import { useLocale } from '../composables/useLocale'
|
|
104
111
|
import { useTheme } from '../composables/useTheme'
|
|
105
112
|
|
|
106
113
|
const props = defineProps<TableProps<T>>()
|
|
@@ -221,11 +228,9 @@ function valueUpdater<T extends Updater<any>>(updaterOrValue: T, ref: Ref) {
|
|
|
221
228
|
ref.value = typeof updaterOrValue === 'function' ? updaterOrValue(ref.value) : updaterOrValue
|
|
222
229
|
}
|
|
223
230
|
|
|
224
|
-
const {
|
|
225
|
-
const
|
|
226
|
-
|
|
227
|
-
return styler(props)
|
|
228
|
-
})
|
|
231
|
+
const { t } = useLocale()
|
|
232
|
+
const { generateStyle } = useTheme()
|
|
233
|
+
const style = computed(() => generateStyle('table', props))
|
|
229
234
|
|
|
230
235
|
defineExpose({
|
|
231
236
|
tableApi,
|
|
@@ -282,7 +287,7 @@ defineExpose({
|
|
|
282
287
|
<tr v-else :class="style.tr({ class: props.ui?.tr })">
|
|
283
288
|
<td :colspan="columns.length" :class="style.empty({ class: props.ui?.empty })">
|
|
284
289
|
<slot name="empty">
|
|
285
|
-
|
|
290
|
+
{{ t('table.noData') }}
|
|
286
291
|
</slot>
|
|
287
292
|
</td>
|
|
288
293
|
</tr>
|
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { VariantProps } from '@byyuurin/ui-kit'
|
|
3
|
-
import type {
|
|
3
|
+
import type { TabsRootEmits, TabsRootProps } from 'reka-ui'
|
|
4
4
|
import type { tabs } from '../theme'
|
|
5
|
-
import type { ComponentAttrs } from '../types'
|
|
5
|
+
import type { ComponentAttrs, DynamicSlots } from '../types'
|
|
6
|
+
|
|
7
|
+
export interface TabsEmits extends TabsRootEmits<string | number> {}
|
|
8
|
+
|
|
9
|
+
type SlotProps<T> = (props: { item: T, index: number }) => any
|
|
10
|
+
|
|
11
|
+
export type TabsSlots<T extends { slot?: string }> = {
|
|
12
|
+
leading?: SlotProps<T>
|
|
13
|
+
default?: SlotProps<T>
|
|
14
|
+
trailing?: SlotProps<T>
|
|
15
|
+
content?: SlotProps<T>
|
|
16
|
+
} & DynamicSlots<T, SlotProps<T>>
|
|
6
17
|
|
|
7
18
|
export interface TabsItem {
|
|
8
19
|
label?: string
|
|
@@ -14,21 +25,14 @@ export interface TabsItem {
|
|
|
14
25
|
disabled?: boolean
|
|
15
26
|
}
|
|
16
27
|
|
|
17
|
-
export interface TabsEmits extends TabsRootEmits<string | number> {}
|
|
18
|
-
|
|
19
|
-
type SlotProps<T> = (props: { item: T, index: number }) => any
|
|
20
|
-
|
|
21
|
-
export type TabsSlots<T extends { slot?: string }> = {
|
|
22
|
-
prefix?: SlotProps<T>
|
|
23
|
-
default?: SlotProps<T>
|
|
24
|
-
suffix?: SlotProps<T>
|
|
25
|
-
content?: SlotProps<T>
|
|
26
|
-
} & Record<string, SlotProps<T>>
|
|
27
|
-
|
|
28
28
|
type TabsVariants = VariantProps<typeof tabs>
|
|
29
29
|
|
|
30
30
|
export interface TabsProps<T> extends ComponentAttrs<typeof tabs>, Pick<TabsRootProps<string | number>, 'defaultValue' | 'modelValue' | 'activationMode' | 'unmountOnHide'> {
|
|
31
|
-
|
|
31
|
+
/**
|
|
32
|
+
* The element or component this component should render as.
|
|
33
|
+
* @default "div"
|
|
34
|
+
*/
|
|
35
|
+
as?: TabsRootProps<string | number>['as']
|
|
32
36
|
items?: T[]
|
|
33
37
|
variant?: TabsVariants['variant']
|
|
34
38
|
orientation?: TabsVariants['orientation']
|
|
@@ -42,7 +46,7 @@ export interface TabsProps<T> extends ComponentAttrs<typeof tabs>, Pick<TabsRoot
|
|
|
42
46
|
content?: boolean
|
|
43
47
|
/**
|
|
44
48
|
* The key used to get the label from the item.
|
|
45
|
-
* @default
|
|
49
|
+
* @default "label"
|
|
46
50
|
*/
|
|
47
51
|
labelKey?: string
|
|
48
52
|
}
|
|
@@ -69,11 +73,8 @@ const slots = defineSlots<TabsSlots<T>>()
|
|
|
69
73
|
|
|
70
74
|
const rootProps = useForwardPropsEmits(reactivePick(props, 'as', 'modelValue', 'defaultValue', 'orientation', 'activationMode', 'unmountOnHide'), emit)
|
|
71
75
|
|
|
72
|
-
const {
|
|
73
|
-
const style = computed(() =>
|
|
74
|
-
const styler = createStyler(theme.value.tabs)
|
|
75
|
-
return styler(props)
|
|
76
|
-
})
|
|
76
|
+
const { generateStyle } = useTheme()
|
|
77
|
+
const style = computed(() => generateStyle('tabs', props))
|
|
77
78
|
</script>
|
|
78
79
|
|
|
79
80
|
<template>
|
|
@@ -88,15 +89,15 @@ const style = computed(() => {
|
|
|
88
89
|
:disabled="item.disabled"
|
|
89
90
|
:class="style.trigger({ class: props.ui?.trigger })"
|
|
90
91
|
>
|
|
91
|
-
<slot name="
|
|
92
|
-
<span v-if="item.icon" :class="style.
|
|
92
|
+
<slot name="leading" :item="item" :index="index">
|
|
93
|
+
<span v-if="item.icon" :class="style.leadingIcon({ class: [item.icon, props.ui?.leadingIcon] })"></span>
|
|
93
94
|
</slot>
|
|
94
95
|
|
|
95
96
|
<span v-if="get(item, props.labelKey) || slots.default" :class="style.label({ class: props.ui?.label })">
|
|
96
97
|
<slot :item="item" :index="index">{{ get(item, props.labelKey) }}</slot>
|
|
97
98
|
</span>
|
|
98
99
|
|
|
99
|
-
<slot name="
|
|
100
|
+
<slot name="trailing" :item="item" :index="index"></slot>
|
|
100
101
|
</TabsTrigger>
|
|
101
102
|
</TabsList>
|
|
102
103
|
|