@bagelink/vue 1.9.81 → 1.9.83
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/components/Loading.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/RadioGroup.vue.d.ts +12 -3
- package/dist/components/form/inputs/RadioGroup.vue.d.ts.map +1 -1
- package/dist/index.cjs +36 -36
- package/dist/index.mjs +1265 -1251
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/src/components/Loading.vue +0 -1
- package/src/components/form/inputs/RadioGroup.vue +24 -13
package/package.json
CHANGED
|
@@ -96,7 +96,6 @@ const svgCircumference = computed(() => Math.PI * 2 * svgRadius.value)
|
|
|
96
96
|
.lds-bar {
|
|
97
97
|
height: var(--thickness, 4px);
|
|
98
98
|
width: 100%;
|
|
99
|
-
max-width: 130px;
|
|
100
99
|
--c: no-repeat linear-gradient(currentColor 0 0);
|
|
101
100
|
background: var(--c), var(--c), #ddd;
|
|
102
101
|
background-size: 60% 100%;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
<script setup lang="ts" generic="ContextObjType extends { [key: string]: any }">
|
|
2
|
+
import type { Option } from '@bagelink/vue'
|
|
2
3
|
import { Btn } from '@bagelink/vue'
|
|
3
4
|
import { computed, ref, watch } from 'vue'
|
|
4
5
|
|
|
5
|
-
export interface RadioOption<T> {
|
|
6
|
+
export interface RadioOption<T = any> {
|
|
6
7
|
imgAlt?: string
|
|
7
8
|
imgSrc?: string
|
|
8
9
|
subLabel?: string
|
|
@@ -12,7 +13,9 @@ export interface RadioOption<T> {
|
|
|
12
13
|
value: any
|
|
13
14
|
}
|
|
14
15
|
|
|
15
|
-
type
|
|
16
|
+
type NormalizedRadioOption<T> = Required<Pick<RadioOption<T>, 'value'>> & Omit<RadioOption<T>, 'value'>
|
|
17
|
+
|
|
18
|
+
type RadioOptionsSource<T> = (Option | RadioOption<T>)[] | (() => Promise<(Option | RadioOption<T>)[]>)
|
|
16
19
|
|
|
17
20
|
const props = withDefaults(
|
|
18
21
|
defineProps<{
|
|
@@ -41,6 +44,13 @@ const props = withDefaults(
|
|
|
41
44
|
|
|
42
45
|
const emit = defineEmits(['delete', 'focus', 'blur', 'change'])
|
|
43
46
|
|
|
47
|
+
function normalizeOption<T>(opt: Option | RadioOption<T>): NormalizedRadioOption<T> {
|
|
48
|
+
if (typeof opt === 'string') { return { label: opt, value: opt } }
|
|
49
|
+
if (typeof opt === 'number') { return { label: `${opt}`, value: opt } }
|
|
50
|
+
if (typeof opt === 'boolean') { return { label: `${opt}`, value: opt } }
|
|
51
|
+
return opt as NormalizedRadioOption<T>
|
|
52
|
+
}
|
|
53
|
+
|
|
44
54
|
const name = computed(
|
|
45
55
|
() => (
|
|
46
56
|
props.groupName
|
|
@@ -49,8 +59,11 @@ const name = computed(
|
|
|
49
59
|
)
|
|
50
60
|
)
|
|
51
61
|
const selectedOption = defineModel('modelValue')
|
|
52
|
-
const loadedOptions = ref<
|
|
53
|
-
const visibleOptions = computed(() =>
|
|
62
|
+
const loadedOptions = ref<(Option | RadioOption<ContextObjType>)[]>([])
|
|
63
|
+
const visibleOptions = computed<NormalizedRadioOption<ContextObjType>[]>(() => {
|
|
64
|
+
const raw = Array.isArray(props.options) ? props.options : loadedOptions.value
|
|
65
|
+
return raw.map(opt => normalizeOption<ContextObjType>(opt))
|
|
66
|
+
})
|
|
54
67
|
|
|
55
68
|
async function loadOptionsIfNeeded() {
|
|
56
69
|
if (typeof props.options === 'function') {
|
|
@@ -93,8 +106,7 @@ function handleChange() {
|
|
|
93
106
|
<div :class="containerClasses">
|
|
94
107
|
<label
|
|
95
108
|
v-for="(opt, index) in visibleOptions" :key="opt.id || `${name}-${index}`"
|
|
96
|
-
class="border rounded flex active-list-item hover"
|
|
97
|
-
:for="opt.id || `${name}-${index}`"
|
|
109
|
+
class="border rounded flex active-list-item hover" :for="opt.id || `${name}-${index}`"
|
|
98
110
|
:class="{ 'p-05 gap-025': thin, 'py-1 gap-075': !thin, 'ps-05': !hideRadio, 'bg-gray-light': !bgColor && !flat, 'align-items-start': align === 'start' || align === 'top', 'align-items-center': align === 'center', 'align-items-end': align === 'end' || align === 'bottom', invertedActive }"
|
|
99
111
|
:style="{ backgroundColor: bgColor, borderColor }"
|
|
100
112
|
>
|
|
@@ -104,9 +116,7 @@ function handleChange() {
|
|
|
104
116
|
'mt-025': align === 'start' || align === 'top',
|
|
105
117
|
'mb-025': align === 'end' || align === 'bottom',
|
|
106
118
|
'hideRadio': hideRadio,
|
|
107
|
-
}" @focus="handleFocus"
|
|
108
|
-
@blur="handleBlur"
|
|
109
|
-
@change="handleChange"
|
|
119
|
+
}" @focus="handleFocus" @blur="handleBlur" @change="handleChange"
|
|
110
120
|
>
|
|
111
121
|
<div
|
|
112
122
|
class="flex w-100 gap-1 flex-wrap m_gap-05 m_gap-row-025"
|
|
@@ -114,8 +124,8 @@ function handleChange() {
|
|
|
114
124
|
:style="{ color: textColor }"
|
|
115
125
|
>
|
|
116
126
|
<img
|
|
117
|
-
v-if="opt.imgSrc" class="
|
|
118
|
-
:alt="opt.imgAlt"
|
|
127
|
+
v-if="opt.imgSrc" class="py-025 radius-05 m_w40 object-fit" height="40" width="40"
|
|
128
|
+
:src="opt.imgSrc" :alt="opt.imgAlt"
|
|
119
129
|
>
|
|
120
130
|
<div class="">
|
|
121
131
|
<div v-if="opt.label" class="m-0 m_txt-14 line-height-14" v-html="opt.label" />
|
|
@@ -132,11 +142,12 @@ function handleChange() {
|
|
|
132
142
|
.hideRadio.radio-input-list {
|
|
133
143
|
display: none !important;
|
|
134
144
|
}
|
|
145
|
+
|
|
135
146
|
.radio-input-list {
|
|
136
147
|
width: auto;
|
|
137
148
|
transform: scale(1.2);
|
|
138
|
-
|
|
139
|
-
|
|
149
|
+
margin-inline-end: 0.5rem;
|
|
150
|
+
margin-top: 0;
|
|
140
151
|
}
|
|
141
152
|
|
|
142
153
|
.radio-input-list.hidden {
|