@byyuurin/ui 0.0.9 → 0.0.11
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 +2 -5
- package/dist/module.json +3 -3
- package/dist/module.mjs +1 -1
- package/dist/module.mjs.map +1 -1
- package/dist/runtime/app/injections.d.ts +9323 -3
- package/dist/runtime/app/injections.js +35 -0
- package/dist/runtime/components/Accordion.vue +36 -69
- package/dist/runtime/components/Accordion.vue.d.ts +52 -0
- package/dist/runtime/components/Alert.vue +37 -75
- package/dist/runtime/components/Alert.vue.d.ts +59 -0
- package/dist/runtime/components/App.vue +25 -40
- package/dist/runtime/components/App.vue.d.ts +24 -0
- package/dist/runtime/components/Avatar.vue +31 -51
- package/dist/runtime/components/Avatar.vue.d.ts +25 -0
- package/dist/runtime/components/AvatarGroup.vue +38 -69
- package/dist/runtime/components/AvatarGroup.vue.d.ts +27 -0
- package/dist/runtime/components/Badge.vue +25 -51
- package/dist/runtime/components/Badge.vue.d.ts +44 -0
- package/dist/runtime/components/Breadcrumb.vue +35 -77
- package/dist/runtime/components/Breadcrumb.vue.d.ts +52 -0
- package/dist/runtime/components/Button.vue +62 -51
- package/dist/runtime/components/Button.vue.d.ts +29 -0
- package/dist/runtime/components/ButtonGroup.vue +17 -37
- package/dist/runtime/components/ButtonGroup.vue.d.ts +26 -0
- package/dist/runtime/components/Calendar.vue +75 -101
- package/dist/runtime/components/Calendar.vue.d.ts +75 -0
- package/dist/runtime/components/Card.vue +25 -42
- package/dist/runtime/components/Card.vue.d.ts +30 -0
- package/dist/runtime/components/Carousel.vue +118 -223
- package/dist/runtime/components/Carousel.vue.d.ts +104 -0
- package/dist/runtime/components/Checkbox.vue +49 -71
- package/dist/runtime/components/Checkbox.vue.d.ts +56 -0
- package/dist/runtime/components/Chip.vue +31 -48
- package/dist/runtime/components/Chip.vue.d.ts +30 -0
- package/dist/runtime/components/Collapsible.vue +22 -30
- package/dist/runtime/components/Collapsible.vue.d.ts +26 -0
- package/dist/runtime/components/Drawer.vue +52 -102
- package/dist/runtime/components/Drawer.vue.d.ts +80 -0
- package/dist/runtime/components/DropdownMenu.vue +65 -0
- package/dist/runtime/components/DropdownMenu.vue.d.ts +99 -0
- package/dist/runtime/components/DropdownMenuContent.vue +192 -0
- package/dist/runtime/components/DropdownMenuContent.vue.d.ts +39 -0
- package/dist/runtime/components/Form.vue +197 -0
- package/dist/runtime/components/Form.vue.d.ts +78 -0
- package/dist/runtime/components/FormItem.vue +90 -0
- package/dist/runtime/components/FormItem.vue.d.ts +60 -0
- package/dist/runtime/components/Input.vue +93 -115
- package/dist/runtime/components/Input.vue.d.ts +64 -0
- package/dist/runtime/components/InputNumber.vue +81 -116
- package/dist/runtime/components/InputNumber.vue.d.ts +245 -0
- package/dist/runtime/components/Kbd.vue +18 -39
- package/dist/runtime/components/Kbd.vue.d.ts +28 -0
- package/dist/runtime/components/Link.vue +170 -244
- package/dist/runtime/components/Link.vue.d.ts +95 -0
- package/dist/runtime/components/LinkBase.vue +36 -54
- package/dist/runtime/components/LinkBase.vue.d.ts +28 -0
- package/dist/runtime/components/Modal.vue +50 -85
- package/dist/runtime/components/Modal.vue.d.ts +66 -0
- package/dist/runtime/components/OverlayProvider.vue +10 -14
- package/dist/runtime/components/OverlayProvider.vue.d.ts +2 -0
- package/dist/runtime/components/Pagination.vue +55 -121
- package/dist/runtime/components/Pagination.vue.d.ts +93 -0
- package/dist/runtime/components/PinInput.vue +57 -57
- package/dist/runtime/components/PinInput.vue.d.ts +35 -0
- package/dist/runtime/components/Popover.vue +39 -68
- package/dist/runtime/components/Popover.vue.d.ts +45 -0
- package/dist/runtime/components/Progress.vue +68 -120
- package/dist/runtime/components/Progress.vue.d.ts +54 -0
- package/dist/runtime/components/RadioGroup.vue +75 -129
- package/dist/runtime/components/RadioGroup.vue.d.ts +74 -0
- package/dist/runtime/components/ScrollArea.vue +31 -31
- package/dist/runtime/components/ScrollArea.vue.d.ts +17 -0
- package/dist/runtime/components/Select.vue +119 -199
- package/dist/runtime/components/Select.vue.d.ts +119 -0
- package/dist/runtime/components/Separator.vue +26 -44
- package/dist/runtime/components/Separator.vue.d.ts +27 -0
- package/dist/runtime/components/Skeleton.vue +12 -21
- package/dist/runtime/components/Skeleton.vue.d.ts +19 -0
- package/dist/runtime/components/Slider.vue +54 -71
- package/dist/runtime/components/Slider.vue.d.ts +36 -0
- package/dist/runtime/components/Switch.vue +54 -68
- package/dist/runtime/components/Switch.vue.d.ts +49 -0
- package/dist/runtime/components/Table.vue +113 -186
- package/dist/runtime/components/Table.vue.d.ts +148 -0
- package/dist/runtime/components/Tabs.vue +35 -79
- package/dist/runtime/components/Tabs.vue.d.ts +65 -0
- package/dist/runtime/components/Textarea.vue +82 -123
- package/dist/runtime/components/Textarea.vue.d.ts +60 -0
- package/dist/runtime/components/Toast.vue +51 -76
- package/dist/runtime/components/Toast.vue.d.ts +131 -0
- package/dist/runtime/components/ToastProvider.vue +65 -101
- package/dist/runtime/components/ToastProvider.vue.d.ts +38 -0
- package/dist/runtime/components/Tooltip.vue +36 -47
- package/dist/runtime/components/Tooltip.vue.d.ts +31 -0
- package/dist/runtime/composables/useAvatarGroup.d.ts +1 -1
- package/dist/runtime/composables/useButtonGroup.d.ts +2 -2
- package/dist/runtime/composables/useFormItem.d.ts +27 -0
- package/dist/runtime/composables/useFormItem.js +64 -0
- package/dist/runtime/composables/useKbd.d.ts +1 -1
- package/dist/runtime/composables/useLocale.d.ts +3 -3
- package/dist/runtime/composables/useTheme.d.ts +1 -1
- package/dist/runtime/composables/useTheme.js +2 -1
- package/dist/runtime/composables/useToast.d.ts +1 -1
- package/dist/runtime/index.d.ts +3 -0
- package/dist/runtime/index.js +3 -0
- package/dist/runtime/locale/en.d.ts +1 -1
- package/dist/runtime/locale/zh-tw.d.ts +1 -1
- package/dist/runtime/theme/accordion.d.ts +45 -51
- package/dist/runtime/theme/accordion.js +1 -1
- package/dist/runtime/theme/alert.d.ts +115 -121
- package/dist/runtime/theme/alert.js +1 -1
- package/dist/runtime/theme/app.d.ts +1 -0
- package/dist/runtime/theme/app.js +2 -1
- package/dist/runtime/theme/avatar-group.d.ts +42 -48
- package/dist/runtime/theme/avatar-group.js +1 -1
- package/dist/runtime/theme/avatar.d.ts +46 -52
- package/dist/runtime/theme/avatar.js +1 -1
- package/dist/runtime/theme/badge.d.ts +63 -93
- package/dist/runtime/theme/badge.js +1 -1
- package/dist/runtime/theme/breadcrumb.d.ts +52 -58
- package/dist/runtime/theme/breadcrumb.js +1 -1
- package/dist/runtime/theme/button-group.d.ts +36 -42
- package/dist/runtime/theme/button.d.ts +165 -117
- package/dist/runtime/theme/button.js +1 -1
- package/dist/runtime/theme/calendar.d.ts +52 -50
- package/dist/runtime/theme/calendar.js +20 -3
- package/dist/runtime/theme/card.d.ts +52 -58
- package/dist/runtime/theme/card.js +1 -1
- package/dist/runtime/theme/carousel.d.ts +98 -104
- package/dist/runtime/theme/carousel.js +1 -1
- package/dist/runtime/theme/checkbox.d.ts +77 -83
- package/dist/runtime/theme/checkbox.js +1 -1
- package/dist/runtime/theme/chip.d.ts +50 -89
- package/dist/runtime/theme/chip.js +1 -1
- package/dist/runtime/theme/collapsible.d.ts +29 -35
- package/dist/runtime/theme/collapsible.js +1 -1
- package/dist/runtime/theme/drawer.d.ts +131 -102
- package/dist/runtime/theme/drawer.js +1 -1
- package/dist/runtime/theme/dropdown-menu.d.ts +65 -0
- package/dist/runtime/theme/dropdown-menu.js +83 -0
- package/dist/runtime/theme/form-item.d.ts +70 -0
- package/dist/runtime/theme/form-item.js +34 -0
- package/dist/runtime/theme/form.d.ts +2 -0
- package/dist/runtime/theme/form.js +7 -0
- package/dist/runtime/theme/index.d.ts +3 -0
- package/dist/runtime/theme/index.js +3 -0
- package/dist/runtime/theme/input-number.d.ts +100 -126
- package/dist/runtime/theme/input-number.js +1 -1
- package/dist/runtime/theme/input.d.ts +153 -131
- package/dist/runtime/theme/input.js +3 -3
- package/dist/runtime/theme/kbd.d.ts +30 -36
- package/dist/runtime/theme/link.d.ts +37 -43
- package/dist/runtime/theme/modal.d.ts +35 -69
- package/dist/runtime/theme/modal.js +1 -1
- package/dist/runtime/theme/pagination.d.ts +71 -77
- package/dist/runtime/theme/pagination.js +1 -1
- package/dist/runtime/theme/pinInput.d.ts +82 -88
- package/dist/runtime/theme/pinInput.js +2 -2
- package/dist/runtime/theme/popover.d.ts +29 -35
- package/dist/runtime/theme/popover.js +1 -1
- package/dist/runtime/theme/progress.d.ts +167 -109
- package/dist/runtime/theme/progress.js +1 -1
- package/dist/runtime/theme/radio-group.d.ts +99 -105
- package/dist/runtime/theme/radio-group.js +1 -1
- package/dist/runtime/theme/scroll-area.d.ts +62 -68
- package/dist/runtime/theme/scroll-area.js +1 -1
- package/dist/runtime/theme/select.d.ts +168 -158
- package/dist/runtime/theme/select.js +3 -2
- package/dist/runtime/theme/separator.d.ts +64 -85
- package/dist/runtime/theme/separator.js +1 -1
- package/dist/runtime/theme/skeleton.d.ts +1 -7
- package/dist/runtime/theme/slider.d.ts +62 -68
- package/dist/runtime/theme/slider.js +1 -1
- package/dist/runtime/theme/switch.d.ts +111 -117
- package/dist/runtime/theme/switch.js +1 -1
- package/dist/runtime/theme/table.d.ts +75 -78
- package/dist/runtime/theme/table.js +3 -2
- package/dist/runtime/theme/tabs.d.ts +116 -139
- package/dist/runtime/theme/tabs.js +1 -1
- package/dist/runtime/theme/textarea.d.ts +78 -90
- package/dist/runtime/theme/textarea.js +2 -2
- package/dist/runtime/theme/toast-provider.d.ts +110 -131
- package/dist/runtime/theme/toast-provider.js +1 -1
- package/dist/runtime/theme/toast.d.ts +74 -80
- package/dist/runtime/theme/toast.js +1 -1
- package/dist/runtime/theme/tooltip.d.ts +35 -41
- package/dist/runtime/theme/tooltip.js +1 -1
- package/dist/runtime/types/components.d.ts +3 -0
- package/dist/runtime/types/form.d.ts +45 -0
- package/dist/runtime/types/form.js +0 -0
- package/dist/runtime/types/index.d.ts +5 -2
- package/dist/runtime/types/index.js +1 -0
- package/dist/runtime/types/utils.d.ts +37 -16
- package/dist/runtime/utils/extend-theme.js +15 -4
- package/dist/runtime/utils/form.d.ts +5 -0
- package/dist/runtime/utils/form.js +24 -0
- package/dist/runtime/utils/index.d.ts +2 -0
- package/dist/runtime/utils/index.js +4 -0
- package/dist/runtime/utils/link.d.ts +4 -28
- package/dist/runtime/utils/link.js +10 -3
- package/dist/runtime/utils/styler.d.ts +2 -2
- package/dist/runtime/utils/styler.js +2 -2
- package/dist/shared/ui.D1BTWZFB.mjs +5 -0
- package/dist/shared/ui.D1BTWZFB.mjs.map +1 -0
- package/dist/types.d.mts +1 -1
- package/dist/unocss.mjs +7 -6
- package/dist/unocss.mjs.map +1 -1
- package/dist/unplugin.mjs +1 -1
- package/dist/unplugin.mjs.map +1 -1
- package/dist/vite.mjs +1 -1
- package/package.json +78 -74
- package/dist/module.cjs +0 -5
- package/dist/shared/ui.1a1f119c.mjs +0 -5
- package/dist/shared/ui.1a1f119c.mjs.map +0 -1
- package/dist/types.d.ts +0 -1
|
@@ -1,141 +1,88 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import type { VariantProps } from '@byyuurin/ui-kit'
|
|
3
|
-
import type { PrimitiveProps, ProgressRootEmits, ProgressRootProps } from 'reka-ui'
|
|
4
|
-
import type { progress } from '../theme'
|
|
5
|
-
import type { ComponentAttrs } from '../types'
|
|
1
|
+
<script>
|
|
6
2
|
|
|
7
|
-
export interface ProgressEmits extends ProgressRootEmits {}
|
|
8
|
-
|
|
9
|
-
export type ProgressSlots = {
|
|
10
|
-
status?: (props: { percent?: number }) => any
|
|
11
|
-
} & {
|
|
12
|
-
[key: `step-${number}`]: (props: { step: string | number }) => any
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
type ProgressVariants = VariantProps<typeof progress>
|
|
16
|
-
|
|
17
|
-
export interface ProgressProps extends ComponentAttrs<typeof progress>, Pick<ProgressRootProps, 'getValueLabel' | 'modelValue'> {
|
|
18
|
-
/**
|
|
19
|
-
* The element or component this component should render as.
|
|
20
|
-
* @default "div"
|
|
21
|
-
*/
|
|
22
|
-
as?: PrimitiveProps['as']
|
|
23
|
-
/** The maximum progress value. */
|
|
24
|
-
max?: number | string[]
|
|
25
|
-
/**
|
|
26
|
-
* @default "md"
|
|
27
|
-
*/
|
|
28
|
-
size?: ProgressVariants['size']
|
|
29
|
-
/**
|
|
30
|
-
* The orientation of the progress bar.
|
|
31
|
-
* @default "horizontal"
|
|
32
|
-
*/
|
|
33
|
-
orientation?: ProgressVariants['orientation']
|
|
34
|
-
/** Display the current progress value. */
|
|
35
|
-
status?: boolean
|
|
36
|
-
/** Whether the progress is visually inverted. */
|
|
37
|
-
inverted?: boolean
|
|
38
|
-
}
|
|
39
3
|
</script>
|
|
40
4
|
|
|
41
|
-
<script setup
|
|
42
|
-
import { reactivePick } from
|
|
43
|
-
import { Primitive, ProgressIndicator, ProgressRoot, useForwardPropsEmits } from
|
|
44
|
-
import { computed } from
|
|
45
|
-
import { useLocale } from
|
|
46
|
-
import { useTheme } from
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
5
|
+
<script setup>
|
|
6
|
+
import { reactivePick } from "@vueuse/core";
|
|
7
|
+
import { Primitive, ProgressIndicator, ProgressRoot, useForwardPropsEmits } from "reka-ui";
|
|
8
|
+
import { computed } from "vue";
|
|
9
|
+
import { useLocale } from "../composables/useLocale";
|
|
10
|
+
import { useTheme } from "../composables/useTheme";
|
|
11
|
+
const props = defineProps({
|
|
12
|
+
as: { type: null, required: false },
|
|
13
|
+
max: { type: [Number, Array], required: false },
|
|
14
|
+
size: { type: null, required: false },
|
|
15
|
+
orientation: { type: null, required: false, default: "horizontal" },
|
|
16
|
+
status: { type: Boolean, required: false },
|
|
17
|
+
inverted: { type: Boolean, required: false },
|
|
18
|
+
class: { type: null, required: false },
|
|
19
|
+
ui: { type: null, required: false },
|
|
20
|
+
getValueLabel: { type: Function, required: false },
|
|
21
|
+
modelValue: { type: [Number, null], required: false, default: null }
|
|
22
|
+
});
|
|
23
|
+
const emit = defineEmits(["update:modelValue", "update:max"]);
|
|
24
|
+
const slots = defineSlots();
|
|
25
|
+
const rootProps = useForwardPropsEmits(reactivePick(props, "getValueLabel", "modelValue"), emit);
|
|
26
|
+
const isIndeterminate = computed(() => rootProps.value.modelValue === null || Number.isNaN(+rootProps.value.modelValue));
|
|
27
|
+
const hasSteps = computed(() => Array.isArray(props.max));
|
|
60
28
|
const max = computed(() => {
|
|
61
29
|
if (isIndeterminate.value || !props.max)
|
|
62
|
-
return
|
|
63
|
-
|
|
30
|
+
return;
|
|
64
31
|
if (Array.isArray(props.max))
|
|
65
|
-
return props.max.length - 1
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
})
|
|
69
|
-
|
|
32
|
+
return props.max.length - 1;
|
|
33
|
+
return Number(props.max);
|
|
34
|
+
});
|
|
70
35
|
const percent = computed(() => {
|
|
71
36
|
if (isIndeterminate.value)
|
|
72
|
-
return
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
})
|
|
84
|
-
|
|
85
|
-
const { dir } = useLocale()
|
|
86
|
-
const { generateStyle } = useTheme()
|
|
87
|
-
const style = computed(() => generateStyle('progress', props))
|
|
88
|
-
|
|
37
|
+
return;
|
|
38
|
+
if (rootProps.value.modelValue < 0)
|
|
39
|
+
return 0;
|
|
40
|
+
const _max = max.value ?? 100;
|
|
41
|
+
if (rootProps.value.modelValue > _max)
|
|
42
|
+
return 100;
|
|
43
|
+
return Math.round(rootProps.value.modelValue / _max * 100);
|
|
44
|
+
});
|
|
45
|
+
const { dir } = useLocale();
|
|
46
|
+
const { generateStyle } = useTheme();
|
|
47
|
+
const style = computed(() => generateStyle("progress", props));
|
|
89
48
|
const indicatorStyle = computed(() => {
|
|
90
|
-
if (percent.value ===
|
|
91
|
-
return
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
return { transform: `translateX(${props.inverted ? '' : '-'}${100 - percent.value}%)` }
|
|
100
|
-
})
|
|
101
|
-
|
|
49
|
+
if (percent.value === void 0)
|
|
50
|
+
return;
|
|
51
|
+
if (props.orientation === "vertical")
|
|
52
|
+
return { transform: `translateY(${props.inverted ? "" : "-"}${100 - percent.value}%)` };
|
|
53
|
+
if (dir.value === "rtl")
|
|
54
|
+
return { transform: `translateX(${props.inverted ? "-" : ""}${100 - percent.value}%)` };
|
|
55
|
+
return { transform: `translateX(${props.inverted ? "" : "-"}${100 - percent.value}%)` };
|
|
56
|
+
});
|
|
102
57
|
const statusStyle = computed(() => {
|
|
103
58
|
return {
|
|
104
|
-
[props.orientation ===
|
|
105
|
-
}
|
|
106
|
-
})
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
return index === Number(props.modelValue)
|
|
59
|
+
[props.orientation === "vertical" ? "height" : "width"]: percent.value ? `${percent.value}%` : "fit-content"
|
|
60
|
+
};
|
|
61
|
+
});
|
|
62
|
+
function isActive(index) {
|
|
63
|
+
return index === Number(props.modelValue);
|
|
110
64
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
return index === 0
|
|
65
|
+
function isFirst(index) {
|
|
66
|
+
return index === 0;
|
|
114
67
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
return index === max.value
|
|
68
|
+
function isLast(index) {
|
|
69
|
+
return index === max.value;
|
|
118
70
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
index = Number(index)
|
|
122
|
-
|
|
71
|
+
function stepVariant(index) {
|
|
72
|
+
index = Number(index);
|
|
123
73
|
if (isActive(index) && !isFirst(index))
|
|
124
|
-
return
|
|
125
|
-
|
|
74
|
+
return "active";
|
|
126
75
|
if (isFirst(index) && isActive(index))
|
|
127
|
-
return
|
|
128
|
-
|
|
76
|
+
return "first";
|
|
129
77
|
if (isLast(index) && isActive(index))
|
|
130
|
-
return
|
|
131
|
-
|
|
132
|
-
return 'other'
|
|
78
|
+
return "last";
|
|
79
|
+
return "other";
|
|
133
80
|
}
|
|
134
81
|
</script>
|
|
135
82
|
|
|
136
83
|
<template>
|
|
137
|
-
<Primitive :as="props.as" :class="style.wrapper({ class: [props.class, props.ui?.wrapper] })">
|
|
138
|
-
<div v-if="!isIndeterminate && (props.status || slots.status)" :class="style.status({ class: props.ui?.status })" :style="statusStyle">
|
|
84
|
+
<Primitive :as="props.as" :class="style.wrapper({ class: [props.class, props.ui?.wrapper] })" data-part="wrapper">
|
|
85
|
+
<div v-if="!isIndeterminate && (props.status || slots.status)" :class="style.status({ class: props.ui?.status })" data-part="status" :style="statusStyle">
|
|
139
86
|
<slot name="status" :percent="percent">
|
|
140
87
|
{{ percent }}%
|
|
141
88
|
</slot>
|
|
@@ -146,13 +93,14 @@ function stepVariant(index: number | string) {
|
|
|
146
93
|
:model-value="Number.isNaN(rootProps.modelValue) ? null : rootProps.modelValue"
|
|
147
94
|
:max="max"
|
|
148
95
|
:class="style.root({ class: props.ui?.root })"
|
|
96
|
+
data-part="root"
|
|
149
97
|
style="transform: translateZ(0)"
|
|
150
98
|
>
|
|
151
|
-
<ProgressIndicator :class="style.indicator({ class: props.ui?.indicator })" :style="indicatorStyle" />
|
|
99
|
+
<ProgressIndicator :class="style.indicator({ class: props.ui?.indicator })" data-part="indicator" :style="indicatorStyle" />
|
|
152
100
|
</ProgressRoot>
|
|
153
101
|
|
|
154
|
-
<div v-if="hasSteps" :class="style.steps({ class: props.ui?.steps })">
|
|
155
|
-
<div v-for="(step, index) in props.max" :key="index" :class="style.step({ class: props.ui?.step, step: stepVariant(index) })">
|
|
102
|
+
<div v-if="hasSteps" :class="style.steps({ class: props.ui?.steps })" data-part="steps">
|
|
103
|
+
<div v-for="(step, index) in props.max" :key="index" :class="style.step({ class: props.ui?.step, step: stepVariant(index) })" data-part="step">
|
|
156
104
|
<slot :name="`step-${index}`" :step="step">
|
|
157
105
|
{{ step }}
|
|
158
106
|
</slot>
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { VariantProps } from '@byyuurin/ui-kit';
|
|
2
|
+
import type { PrimitiveProps, ProgressRootEmits, ProgressRootProps } from 'reka-ui';
|
|
3
|
+
import type { progress } from '../theme/index.js';
|
|
4
|
+
import type { ComponentAttrs } from '../types/index.js';
|
|
5
|
+
export interface ProgressEmits extends ProgressRootEmits {
|
|
6
|
+
}
|
|
7
|
+
export type ProgressSlots = {
|
|
8
|
+
status?: (props: {
|
|
9
|
+
percent?: number;
|
|
10
|
+
}) => any;
|
|
11
|
+
} & {
|
|
12
|
+
[key: `step-${number}`]: (props: {
|
|
13
|
+
step: string | number;
|
|
14
|
+
}) => any;
|
|
15
|
+
};
|
|
16
|
+
type ProgressVariants = VariantProps<typeof progress>;
|
|
17
|
+
export interface ProgressProps extends ComponentAttrs<typeof progress>, Pick<ProgressRootProps, 'getValueLabel' | 'modelValue'> {
|
|
18
|
+
/**
|
|
19
|
+
* The element or component this component should render as.
|
|
20
|
+
* @default "div"
|
|
21
|
+
*/
|
|
22
|
+
as?: PrimitiveProps['as'];
|
|
23
|
+
/** The maximum progress value. */
|
|
24
|
+
max?: number | string[];
|
|
25
|
+
/**
|
|
26
|
+
* @default "md"
|
|
27
|
+
*/
|
|
28
|
+
size?: ProgressVariants['size'];
|
|
29
|
+
/**
|
|
30
|
+
* The orientation of the progress bar.
|
|
31
|
+
* @default "horizontal"
|
|
32
|
+
*/
|
|
33
|
+
orientation?: ProgressVariants['orientation'];
|
|
34
|
+
/** Display the current progress value. */
|
|
35
|
+
status?: boolean;
|
|
36
|
+
/** Whether the progress is visually inverted. */
|
|
37
|
+
inverted?: boolean;
|
|
38
|
+
}
|
|
39
|
+
declare const _default: __VLS_WithSlots<import("vue").DefineComponent<ProgressProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
40
|
+
"update:modelValue": (value: string[] | undefined) => any;
|
|
41
|
+
"update:max": (value: number) => any;
|
|
42
|
+
}, string, import("vue").PublicProps, Readonly<ProgressProps> & Readonly<{
|
|
43
|
+
"onUpdate:modelValue"?: ((value: string[] | undefined) => any) | undefined;
|
|
44
|
+
"onUpdate:max"?: ((value: number) => any) | undefined;
|
|
45
|
+
}>, {
|
|
46
|
+
orientation: "horizontal" | "vertical";
|
|
47
|
+
modelValue: number | null;
|
|
48
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, ProgressSlots>;
|
|
49
|
+
export default _default;
|
|
50
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
51
|
+
new (): {
|
|
52
|
+
$slots: S;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
@@ -1,170 +1,116 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import type { VariantProps } from '@byyuurin/ui-kit'
|
|
3
|
-
import type { AcceptableValue, PrimitiveProps, RadioGroupRootProps } from 'reka-ui'
|
|
4
|
-
import type { radioGroup } from '../theme'
|
|
5
|
-
import type { ComponentAttrs } from '../types'
|
|
1
|
+
<script>
|
|
6
2
|
|
|
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
|
-
|
|
32
|
-
type RadioGroupVariants = VariantProps<typeof radioGroup>
|
|
33
|
-
|
|
34
|
-
export interface RadioOption {
|
|
35
|
-
label?: string
|
|
36
|
-
description?: string
|
|
37
|
-
disabled?: boolean
|
|
38
|
-
value?: string
|
|
39
|
-
}
|
|
40
|
-
|
|
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
|
-
*/
|
|
46
|
-
as?: PrimitiveProps['as']
|
|
47
|
-
legend?: string
|
|
48
|
-
/**
|
|
49
|
-
* When `options` is an array of objects, select the field to use as the value.
|
|
50
|
-
* @default "value"
|
|
51
|
-
*/
|
|
52
|
-
valueKey?: string
|
|
53
|
-
/**
|
|
54
|
-
* When `options` is an array of objects, select the field to use as the label.
|
|
55
|
-
* @default "label"
|
|
56
|
-
*/
|
|
57
|
-
labelKey?: string
|
|
58
|
-
/**
|
|
59
|
-
* When `options` is an array of objects, select the field to use as the description.
|
|
60
|
-
* @default "description"
|
|
61
|
-
*/
|
|
62
|
-
descriptionKey?: string
|
|
63
|
-
options?: T[]
|
|
64
|
-
size?: RadioGroupVariants['size']
|
|
65
|
-
/**
|
|
66
|
-
* The orientation the radio buttons are laid out.
|
|
67
|
-
* @default "vertical"
|
|
68
|
-
*/
|
|
69
|
-
orientation?: RadioGroupRootProps['orientation']
|
|
70
|
-
}
|
|
71
3
|
</script>
|
|
72
4
|
|
|
73
|
-
<script
|
|
74
|
-
import { reactivePick } from
|
|
75
|
-
import { Label, RadioGroupIndicator, RadioGroupItem, RadioGroupRoot, useForwardPropsEmits } from
|
|
76
|
-
import { computed, useId } from
|
|
77
|
-
import {
|
|
78
|
-
import {
|
|
79
|
-
|
|
80
|
-
const props =
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
5
|
+
<script setup>
|
|
6
|
+
import { reactivePick } from "@vueuse/core";
|
|
7
|
+
import { Label, RadioGroupIndicator, RadioGroupItem, RadioGroupRoot, useForwardPropsEmits } from "reka-ui";
|
|
8
|
+
import { computed, useId } from "vue";
|
|
9
|
+
import { useFormItem } from "../composables/useFormItem";
|
|
10
|
+
import { useTheme } from "../composables/useTheme";
|
|
11
|
+
import { get } from "../utils";
|
|
12
|
+
const props = defineProps({
|
|
13
|
+
as: { type: null, required: false },
|
|
14
|
+
legend: { type: String, required: false },
|
|
15
|
+
valueKey: { type: String, required: false, default: "value" },
|
|
16
|
+
labelKey: { type: String, required: false, default: "label" },
|
|
17
|
+
descriptionKey: { type: String, required: false, default: "description" },
|
|
18
|
+
options: { type: Array, required: false },
|
|
19
|
+
size: { type: null, required: false },
|
|
20
|
+
orientation: { type: null, required: false, default: "vertical" },
|
|
21
|
+
class: { type: null, required: false },
|
|
22
|
+
ui: { type: null, required: false },
|
|
23
|
+
defaultValue: { type: null, required: false },
|
|
24
|
+
disabled: { type: Boolean, required: false },
|
|
25
|
+
loop: { type: Boolean, required: false },
|
|
26
|
+
modelValue: { type: null, required: false },
|
|
27
|
+
name: { type: String, required: false },
|
|
28
|
+
required: { type: Boolean, required: false }
|
|
29
|
+
});
|
|
30
|
+
const emit = defineEmits(["update:modelValue", "change"]);
|
|
31
|
+
const slots = defineSlots();
|
|
32
|
+
const rootProps = useForwardPropsEmits(reactivePick(props, "as", "modelValue", "defaultValue", "orientation", "loop", "required"), emit);
|
|
33
|
+
const { id: _id, name, size, disabled, ariaAttrs, emitFormChange, emitFormInput } = useFormItem(props);
|
|
34
|
+
const id = _id.value ?? useId();
|
|
35
|
+
const { generateStyle } = useTheme();
|
|
36
|
+
const style = computed(() => generateStyle("radioGroup", {
|
|
37
|
+
...props,
|
|
38
|
+
size: size.value,
|
|
39
|
+
disabled: disabled.value
|
|
40
|
+
}));
|
|
41
|
+
function normalizeItem(item) {
|
|
42
|
+
if (item === null) {
|
|
43
|
+
return {
|
|
44
|
+
id: `${id}:null`,
|
|
45
|
+
label: void 0,
|
|
46
|
+
value: void 0
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
if (typeof item === "string" || typeof item === "number") {
|
|
98
50
|
return {
|
|
99
51
|
id: `${id}:${item}`,
|
|
52
|
+
label: String(item),
|
|
100
53
|
value: item,
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
disabled: props.disabled,
|
|
104
|
-
} as any
|
|
54
|
+
disabled: disabled.value
|
|
55
|
+
};
|
|
105
56
|
}
|
|
106
|
-
|
|
107
|
-
const
|
|
108
|
-
const
|
|
109
|
-
const description = get(item, props.descriptionKey)
|
|
110
|
-
|
|
57
|
+
const value = get(item, props.valueKey);
|
|
58
|
+
const label = get(item, props.labelKey);
|
|
59
|
+
const description = get(item, props.descriptionKey);
|
|
111
60
|
return {
|
|
112
61
|
...item,
|
|
113
|
-
value
|
|
62
|
+
id: `${id}:${value}`,
|
|
114
63
|
label,
|
|
64
|
+
value,
|
|
115
65
|
description,
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}
|
|
66
|
+
disabled: disabled.value || item.disabled
|
|
67
|
+
};
|
|
119
68
|
}
|
|
120
|
-
|
|
121
69
|
const normalizedItems = computed(() => {
|
|
122
70
|
if (!props.options)
|
|
123
|
-
return []
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
emit('change', event)
|
|
71
|
+
return [];
|
|
72
|
+
return props.options.map(normalizeItem);
|
|
73
|
+
});
|
|
74
|
+
function onUpdate(value) {
|
|
75
|
+
const event = new Event("change", { target: { value } });
|
|
76
|
+
emit("change", event);
|
|
77
|
+
emitFormChange();
|
|
78
|
+
emitFormInput();
|
|
132
79
|
}
|
|
133
80
|
</script>
|
|
134
81
|
|
|
135
82
|
<template>
|
|
136
83
|
<RadioGroupRoot
|
|
137
|
-
:id="id"
|
|
138
84
|
v-slot="{ modelValue }"
|
|
139
|
-
v-bind="rootProps"
|
|
140
|
-
:name="props.name"
|
|
141
|
-
:disabled="props.disabled"
|
|
85
|
+
v-bind="{ ...rootProps, id, name, disabled }"
|
|
142
86
|
:class="style.root({ class: [props.class, props.ui?.root] })"
|
|
87
|
+
data-part="root"
|
|
143
88
|
@update:model-value="onUpdate"
|
|
144
89
|
>
|
|
145
|
-
<fieldset :class="style.fieldset({ class: props.ui?.fieldset })">
|
|
146
|
-
<legend v-if="props.legend || slots.legend" :class="style.legend({ class: props.ui?.legend })">
|
|
90
|
+
<fieldset v-bind="ariaAttrs" :class="style.fieldset({ class: props.ui?.fieldset })" data-part="fieldset">
|
|
91
|
+
<legend v-if="props.legend || slots.legend" :class="style.legend({ class: props.ui?.legend })" data-part="legend">
|
|
147
92
|
<slot name="legend">
|
|
148
93
|
{{ props.legend }}
|
|
149
94
|
</slot>
|
|
150
95
|
</legend>
|
|
151
|
-
<div v-for="item in normalizedItems" :key="item.value" :class="style.item({ class: props.ui?.item, disabled: item.disabled })">
|
|
152
|
-
<div :class="style.container({ class: props.ui?.container })">
|
|
96
|
+
<div v-for="item in normalizedItems" :key="item.value" :class="style.item({ class: props.ui?.item, disabled: item.disabled })" data-part="item">
|
|
97
|
+
<div :class="style.container({ class: props.ui?.container })" data-part="container">
|
|
153
98
|
<RadioGroupItem
|
|
154
99
|
:id="item.id"
|
|
155
100
|
:value="item.value"
|
|
156
101
|
:disabled="item.disabled"
|
|
157
102
|
:class="style.base({ class: props.ui?.base })"
|
|
103
|
+
data-part="base"
|
|
158
104
|
>
|
|
159
|
-
<RadioGroupIndicator :class="style.indicator({ class: props.ui?.indicator })" force-mount />
|
|
105
|
+
<RadioGroupIndicator :class="style.indicator({ class: props.ui?.indicator })" data-part="indicator" force-mount />
|
|
160
106
|
</RadioGroupItem>
|
|
161
107
|
</div>
|
|
162
108
|
|
|
163
|
-
<div :class="style.wrapper({ class: props.ui?.wrapper })">
|
|
164
|
-
<Label :for="item.id" :class="style.label({ class: props.ui?.label })">
|
|
109
|
+
<div :class="style.wrapper({ class: props.ui?.wrapper })" data-part="wrapper">
|
|
110
|
+
<Label :for="item.id" :class="style.label({ class: props.ui?.label })" data-part="label">
|
|
165
111
|
<slot name="label" :item="item" :model-value="modelValue">{{ item.label }}</slot>
|
|
166
112
|
</Label>
|
|
167
|
-
<p v-if="item.description || slots.description" :class="style.description({ class: props.ui?.description })">
|
|
113
|
+
<p v-if="item.description || slots.description" :class="style.description({ class: props.ui?.description })" data-part="description">
|
|
168
114
|
<slot name="description" :item="item" :model-value="modelValue">
|
|
169
115
|
{{ item.description }}
|
|
170
116
|
</slot>
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { VariantProps } from '@byyuurin/ui-kit';
|
|
2
|
+
import type { PrimitiveProps, RadioGroupRootProps } from 'reka-ui';
|
|
3
|
+
import type { radioGroup } from '../theme/index.js';
|
|
4
|
+
import type { AcceptableValue, ComponentAttrs } from '../types/index.js';
|
|
5
|
+
export interface RadioGroupEmits {
|
|
6
|
+
'update:modelValue': [payload: string];
|
|
7
|
+
'change': [payload: Event];
|
|
8
|
+
}
|
|
9
|
+
export type RadioGroupValue = AcceptableValue;
|
|
10
|
+
export type RadioGroupItem = {
|
|
11
|
+
label?: string;
|
|
12
|
+
description?: string;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
value?: RadioGroupValue;
|
|
15
|
+
[key: string]: any;
|
|
16
|
+
} | RadioGroupValue;
|
|
17
|
+
type SlotProps<T extends RadioGroupItem> = (props: {
|
|
18
|
+
item: T & {
|
|
19
|
+
id: string;
|
|
20
|
+
};
|
|
21
|
+
modelValue?: RadioGroupValue;
|
|
22
|
+
}) => any;
|
|
23
|
+
export interface RadioGroupSlots<T extends RadioGroupItem = RadioGroupItem> {
|
|
24
|
+
legend?: any;
|
|
25
|
+
label?: SlotProps<T>;
|
|
26
|
+
description?: SlotProps<T>;
|
|
27
|
+
}
|
|
28
|
+
type RadioGroupVariants = VariantProps<typeof radioGroup>;
|
|
29
|
+
export interface RadioGroupProps<T extends RadioGroupItem = RadioGroupItem> extends ComponentAttrs<typeof radioGroup>, Pick<RadioGroupRootProps, 'defaultValue' | 'disabled' | 'loop' | 'modelValue' | 'name' | 'required'> {
|
|
30
|
+
/**
|
|
31
|
+
* The element or component this component should render as.
|
|
32
|
+
* @default "div"
|
|
33
|
+
*/
|
|
34
|
+
as?: PrimitiveProps['as'];
|
|
35
|
+
legend?: string;
|
|
36
|
+
/**
|
|
37
|
+
* When `options` is an array of objects, select the field to use as the value.
|
|
38
|
+
* @default "value"
|
|
39
|
+
*/
|
|
40
|
+
valueKey?: string;
|
|
41
|
+
/**
|
|
42
|
+
* When `options` is an array of objects, select the field to use as the label.
|
|
43
|
+
* @default "label"
|
|
44
|
+
*/
|
|
45
|
+
labelKey?: string;
|
|
46
|
+
/**
|
|
47
|
+
* When `options` is an array of objects, select the field to use as the description.
|
|
48
|
+
* @default "description"
|
|
49
|
+
*/
|
|
50
|
+
descriptionKey?: string;
|
|
51
|
+
options?: T[];
|
|
52
|
+
size?: RadioGroupVariants['size'];
|
|
53
|
+
/**
|
|
54
|
+
* The orientation the radio buttons are laid out.
|
|
55
|
+
* @default "vertical"
|
|
56
|
+
*/
|
|
57
|
+
orientation?: RadioGroupRootProps['orientation'];
|
|
58
|
+
}
|
|
59
|
+
declare const _default: <T extends RadioGroupItem>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
60
|
+
props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
|
|
61
|
+
readonly onChange?: ((payload: Event) => any) | undefined;
|
|
62
|
+
readonly "onUpdate:modelValue"?: ((payload: string) => any) | undefined;
|
|
63
|
+
} & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, never>, "onChange" | "onUpdate:modelValue"> & RadioGroupProps<T> & Partial<{}>> & import("vue").PublicProps;
|
|
64
|
+
expose(exposed: import("vue").ShallowUnwrapRef<{}>): void;
|
|
65
|
+
attrs: any;
|
|
66
|
+
slots: RadioGroupSlots<T>;
|
|
67
|
+
emit: ((evt: "change", payload: Event) => void) & ((evt: "update:modelValue", payload: string) => void);
|
|
68
|
+
}>) => import("vue").VNode & {
|
|
69
|
+
__ctx?: Awaited<typeof __VLS_setup>;
|
|
70
|
+
};
|
|
71
|
+
export default _default;
|
|
72
|
+
type __VLS_PrettifyLocal<T> = {
|
|
73
|
+
[K in keyof T]: T[K];
|
|
74
|
+
} & {};
|