lew-ui 1.0.0
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/components/base/LewAvatar.vue +107 -0
- package/components/base/LewBadge.vue +126 -0
- package/components/base/LewButton.vue +193 -0
- package/components/base/LewTitle.vue +34 -0
- package/components/feedback/LewAlert.vue +150 -0
- package/components/feedback/LewMessage.vue +7 -0
- package/components/feedback/LewModal.vue +75 -0
- package/components/form/FormItem.vue +51 -0
- package/components/form/LewCheckbox.vue +153 -0
- package/components/form/LewCheckboxGroup.vue +99 -0
- package/components/form/LewInput.vue +73 -0
- package/components/form/LewRadio.vue +126 -0
- package/components/form/LewRadioGroup.vue +82 -0
- package/components/form/LewSelect.vue +141 -0
- package/components/form/LewSwitch.vue +108 -0
- package/components/form/LewTabs.vue +108 -0
- package/components/form/LewTextarea.vue +90 -0
- package/components/index.ts +35 -0
- package/directives/index.ts +3 -0
- package/directives/tooltips.ts +23 -0
- package/hooks/index.ts +3 -0
- package/hooks/useDOMCreate.ts +13 -0
- package/index.ts +3 -0
- package/package.json +29 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
const props = defineProps({
|
|
3
|
+
title: {
|
|
4
|
+
type: String,
|
|
5
|
+
default: '标题',
|
|
6
|
+
},
|
|
7
|
+
direction: {
|
|
8
|
+
type: String,
|
|
9
|
+
default: 'x',
|
|
10
|
+
},
|
|
11
|
+
});
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<template>
|
|
15
|
+
<div class="lew-form-item" :class="`lew-form-item-${direction}`">
|
|
16
|
+
<label class="title-label">{{ props.title }} </label>
|
|
17
|
+
<slot />
|
|
18
|
+
</div>
|
|
19
|
+
</template>
|
|
20
|
+
|
|
21
|
+
<style lang="scss" scoped>
|
|
22
|
+
.lew-form-item {
|
|
23
|
+
width: 100%;
|
|
24
|
+
margin-bottom: 20px;
|
|
25
|
+
text-align: left;
|
|
26
|
+
|
|
27
|
+
label {
|
|
28
|
+
display: block;
|
|
29
|
+
width: 100%;
|
|
30
|
+
margin: 0px 0px 10px 0px;
|
|
31
|
+
font-size: 14px;
|
|
32
|
+
color: var(--text-color);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.lew-form-item-x {
|
|
37
|
+
display: flex;
|
|
38
|
+
align-items: flex-start;
|
|
39
|
+
|
|
40
|
+
label {
|
|
41
|
+
white-space: nowrap;
|
|
42
|
+
width: auto;
|
|
43
|
+
margin-top: 8px;
|
|
44
|
+
padding-right: 10px;
|
|
45
|
+
display: inline-block;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.lew-form-item-y {
|
|
50
|
+
}
|
|
51
|
+
</style>
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<label
|
|
3
|
+
class="lew-checkbox"
|
|
4
|
+
:class="`${block ? 'lew-checkbox-block' : ''} ${
|
|
5
|
+
round ? 'lew-checkbox-round' : ''
|
|
6
|
+
}`"
|
|
7
|
+
>
|
|
8
|
+
<div class="icon-checkbox-box" :class="{ 'icon-checked-box': checked }">
|
|
9
|
+
<svg
|
|
10
|
+
class="icon-checkbox"
|
|
11
|
+
:class="{ 'icon-checked': checked }"
|
|
12
|
+
viewBox="0 0 24 24"
|
|
13
|
+
width="24"
|
|
14
|
+
height="24"
|
|
15
|
+
stroke="currentColor"
|
|
16
|
+
stroke-width="4"
|
|
17
|
+
fill="none"
|
|
18
|
+
stroke-linecap="round"
|
|
19
|
+
stroke-linejoin="round"
|
|
20
|
+
>
|
|
21
|
+
<polyline points="20 6 9 17 4 12"></polyline>
|
|
22
|
+
</svg>
|
|
23
|
+
</div>
|
|
24
|
+
<input
|
|
25
|
+
v-show="false"
|
|
26
|
+
type="checkbox"
|
|
27
|
+
:checked="checked"
|
|
28
|
+
@input="setChecked"
|
|
29
|
+
/>
|
|
30
|
+
{{ label }}
|
|
31
|
+
</label>
|
|
32
|
+
</template>
|
|
33
|
+
|
|
34
|
+
<script lang="ts" setup>
|
|
35
|
+
defineProps({
|
|
36
|
+
label: {
|
|
37
|
+
type: String,
|
|
38
|
+
required: true,
|
|
39
|
+
},
|
|
40
|
+
block: {
|
|
41
|
+
type: Boolean,
|
|
42
|
+
default: () => {
|
|
43
|
+
return false;
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
round: {
|
|
47
|
+
type: Boolean,
|
|
48
|
+
default: () => {
|
|
49
|
+
return false;
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
checked: {
|
|
53
|
+
type: Boolean,
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
const emit = defineEmits(['update:checked']);
|
|
58
|
+
|
|
59
|
+
const setChecked = (event: Event) => {
|
|
60
|
+
emit('update:checked', (event.target as HTMLInputElement).checked);
|
|
61
|
+
};
|
|
62
|
+
</script>
|
|
63
|
+
|
|
64
|
+
<style lang="scss" scoped>
|
|
65
|
+
.lew-checkbox {
|
|
66
|
+
display: inline-flex;
|
|
67
|
+
align-items: center;
|
|
68
|
+
user-select: none;
|
|
69
|
+
margin: 0px 20px 15px 0px;
|
|
70
|
+
cursor: pointer;
|
|
71
|
+
color: var(--text-color);
|
|
72
|
+
font-size: 14px;
|
|
73
|
+
transition: all 0.25s ease;
|
|
74
|
+
.icon-checkbox-box {
|
|
75
|
+
display: inline-flex;
|
|
76
|
+
align-items: center;
|
|
77
|
+
justify-content: center;
|
|
78
|
+
width: 18px;
|
|
79
|
+
height: 18px;
|
|
80
|
+
border: 2px rgba($color: #000000, $alpha: 0.1) solid;
|
|
81
|
+
box-sizing: border-box;
|
|
82
|
+
border-radius: 5px;
|
|
83
|
+
margin-right: 5px;
|
|
84
|
+
transition: all 0.25s ease;
|
|
85
|
+
|
|
86
|
+
.icon-checkbox {
|
|
87
|
+
transform: scale(0.6) translateY(50%);
|
|
88
|
+
transition: all 0.25s ease;
|
|
89
|
+
opacity: 0;
|
|
90
|
+
color: #fff;
|
|
91
|
+
font-size: 12px;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.icon-checked-box {
|
|
96
|
+
border: 2px var(--primary-color) solid;
|
|
97
|
+
background: var(--primary-color);
|
|
98
|
+
|
|
99
|
+
.icon-checkbox {
|
|
100
|
+
transform: scale(0.85) translateY(0px);
|
|
101
|
+
opacity: 1;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.lew-checkbox:hover {
|
|
107
|
+
.icon-checkbox-box {
|
|
108
|
+
border: 2px rgba($color: #000000, $alpha: 0.2) solid;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.icon-checked-box {
|
|
112
|
+
border: 2px var(--primary-color) solid;
|
|
113
|
+
background: var(--primary-color);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.lew-checkbox-block {
|
|
118
|
+
background: var(--form-bgcolor);
|
|
119
|
+
padding: 4px 8px 4px 6px;
|
|
120
|
+
border: var(--form-border);
|
|
121
|
+
border-radius: 8px;
|
|
122
|
+
.icon-checkbox-box {
|
|
123
|
+
border: 2px rgba(0, 0, 0, 0) solid;
|
|
124
|
+
background: var(--form-bgcolor-hover);
|
|
125
|
+
}
|
|
126
|
+
.icon-checked-box {
|
|
127
|
+
border: 2px var(--primary-color) solid;
|
|
128
|
+
background: var(--primary-color);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
.lew-checkbox-block:hover {
|
|
132
|
+
.icon-checkbox-box {
|
|
133
|
+
border: 2px rgba(0, 0, 0, 0) solid;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.lew-checkbox-round {
|
|
138
|
+
border-radius: 50px;
|
|
139
|
+
.icon-checkbox-box {
|
|
140
|
+
border-radius: 50%;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.lew-checkbox-block:hover {
|
|
145
|
+
background: var(--form-bgcolor-hover);
|
|
146
|
+
border: var(--form-border-hover);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.lew-checkbox-block:active {
|
|
150
|
+
background: var(--form-bgcolor-active);
|
|
151
|
+
border: var(--form-border-active);
|
|
152
|
+
}
|
|
153
|
+
</style>
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="lew-checkbox-group" :class="`lew-checkbox-group-${direction}`">
|
|
3
|
+
<lew-checkbox
|
|
4
|
+
v-for="option in options"
|
|
5
|
+
:key="option.id"
|
|
6
|
+
:block="block"
|
|
7
|
+
:round="round"
|
|
8
|
+
:label="option.name"
|
|
9
|
+
:checked="getChecked(option.id)"
|
|
10
|
+
@update:checked="check(option.id, $event)"
|
|
11
|
+
/>
|
|
12
|
+
</div>
|
|
13
|
+
</template>
|
|
14
|
+
|
|
15
|
+
<script lang="ts" setup>
|
|
16
|
+
import { PropType } from 'vue';
|
|
17
|
+
import { LewCheckbox } from '@/packages/lew';
|
|
18
|
+
type Options = {
|
|
19
|
+
name: string;
|
|
20
|
+
id: string | number;
|
|
21
|
+
};
|
|
22
|
+
const props = defineProps({
|
|
23
|
+
modelValue: {
|
|
24
|
+
type: Array,
|
|
25
|
+
default: () => {
|
|
26
|
+
return [];
|
|
27
|
+
},
|
|
28
|
+
required: true,
|
|
29
|
+
},
|
|
30
|
+
block: {
|
|
31
|
+
type: Boolean,
|
|
32
|
+
default: () => {
|
|
33
|
+
return false;
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
round: {
|
|
37
|
+
type: Boolean,
|
|
38
|
+
default: () => {
|
|
39
|
+
return false;
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
direction: {
|
|
43
|
+
type: String,
|
|
44
|
+
default: 'x',
|
|
45
|
+
},
|
|
46
|
+
options: {
|
|
47
|
+
type: Array as PropType<Options[]>,
|
|
48
|
+
default: () => {
|
|
49
|
+
return [];
|
|
50
|
+
},
|
|
51
|
+
required: true,
|
|
52
|
+
validator: (value: Array<number>) => {
|
|
53
|
+
const hasNameKey = value.every((option) =>
|
|
54
|
+
Object.keys(option).includes('name'),
|
|
55
|
+
);
|
|
56
|
+
const hasIdKey = value.every((option) =>
|
|
57
|
+
Object.keys(option).includes('id'),
|
|
58
|
+
);
|
|
59
|
+
return hasNameKey && hasIdKey;
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
const emit = defineEmits(['update:modelValue']);
|
|
65
|
+
|
|
66
|
+
const check = (optionId: number | string, checked: boolean) => {
|
|
67
|
+
let updatedValue = [...props.modelValue];
|
|
68
|
+
optionId = Number(optionId);
|
|
69
|
+
|
|
70
|
+
if (checked) {
|
|
71
|
+
updatedValue.push(optionId);
|
|
72
|
+
} else {
|
|
73
|
+
updatedValue.splice(updatedValue.indexOf(optionId), 1);
|
|
74
|
+
}
|
|
75
|
+
emit('update:modelValue', updatedValue);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const getChecked = (optionId: string | number) => {
|
|
79
|
+
optionId = Number(optionId);
|
|
80
|
+
return props.modelValue.includes(optionId);
|
|
81
|
+
};
|
|
82
|
+
</script>
|
|
83
|
+
<style lang="scss" scoped>
|
|
84
|
+
.lew-checkbox-group {
|
|
85
|
+
display: flex;
|
|
86
|
+
align-items: center;
|
|
87
|
+
font-size: 0px;
|
|
88
|
+
flex-wrap: wrap;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.lew-checkbox-group.lew-checkbox-group-x {
|
|
92
|
+
flex-direction: row;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.lew-checkbox-group.lew-checkbox-group-y {
|
|
96
|
+
align-items: flex-start;
|
|
97
|
+
flex-direction: column;
|
|
98
|
+
}
|
|
99
|
+
</style>
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { ref, watch } from 'vue';
|
|
3
|
+
const props = defineProps({
|
|
4
|
+
modelValue: {
|
|
5
|
+
// 父组件 v-model 没有指定参数名,则默认是 modelValue
|
|
6
|
+
type: String,
|
|
7
|
+
default: '',
|
|
8
|
+
},
|
|
9
|
+
disabled: {
|
|
10
|
+
type: Boolean,
|
|
11
|
+
default: false,
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
const v = ref(props.modelValue);
|
|
15
|
+
watch(
|
|
16
|
+
() => props.modelValue,
|
|
17
|
+
() => {
|
|
18
|
+
v.value = props.modelValue;
|
|
19
|
+
},
|
|
20
|
+
);
|
|
21
|
+
const emit = defineEmits(['update:modelValue']);
|
|
22
|
+
|
|
23
|
+
const input = (e: any) => {
|
|
24
|
+
let value = e.target.value;
|
|
25
|
+
emit('update:modelValue', value);
|
|
26
|
+
};
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
<template>
|
|
30
|
+
<input
|
|
31
|
+
v-model="v"
|
|
32
|
+
class="lew-input"
|
|
33
|
+
:disabled="props.disabled"
|
|
34
|
+
placeholder="请输入"
|
|
35
|
+
@input="input"
|
|
36
|
+
/>
|
|
37
|
+
</template>
|
|
38
|
+
|
|
39
|
+
<style lang="scss" scoped>
|
|
40
|
+
.lew-input {
|
|
41
|
+
width: 100%;
|
|
42
|
+
height: 35px;
|
|
43
|
+
padding: 5px 12px;
|
|
44
|
+
font-size: 14px;
|
|
45
|
+
line-height: 24px;
|
|
46
|
+
overflow: hidden;
|
|
47
|
+
white-space: nowrap;
|
|
48
|
+
text-overflow: ellipsis;
|
|
49
|
+
border: var(--form-border);
|
|
50
|
+
border-radius: var(--form-border-radius);
|
|
51
|
+
background-color: var(--form-bgcolor);
|
|
52
|
+
color: var(--form-text-color);
|
|
53
|
+
box-sizing: border-box;
|
|
54
|
+
transition: all 0.25s ease;
|
|
55
|
+
outline: none;
|
|
56
|
+
}
|
|
57
|
+
.lew-input::placeholder {
|
|
58
|
+
color: rgb(165, 165, 165);
|
|
59
|
+
}
|
|
60
|
+
.lew-input:hover {
|
|
61
|
+
border: var(--form-border-hover);
|
|
62
|
+
background-color: var(--form-bgcolor-hover);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.lew-input:active {
|
|
66
|
+
background-color: var(--form-bgcolor-active);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.lew-input:focus {
|
|
70
|
+
background-color: var(--form-bgcolor-focus);
|
|
71
|
+
border: var(--form-border-focus);
|
|
72
|
+
}
|
|
73
|
+
</style>
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<label class="lew-radio" :class="`${block ? 'lew-radio-block' : ''} `">
|
|
3
|
+
<div class="icon-radio-box" :class="{ 'icon-checked-box': checked }">
|
|
4
|
+
<div class="icon-radio"></div>
|
|
5
|
+
</div>
|
|
6
|
+
<input
|
|
7
|
+
v-show="false"
|
|
8
|
+
type="radio"
|
|
9
|
+
:checked="checked"
|
|
10
|
+
@input="setChecked"
|
|
11
|
+
/>
|
|
12
|
+
{{ label }}
|
|
13
|
+
</label>
|
|
14
|
+
</template>
|
|
15
|
+
|
|
16
|
+
<script lang="ts" setup>
|
|
17
|
+
defineProps({
|
|
18
|
+
label: {
|
|
19
|
+
type: String,
|
|
20
|
+
required: true,
|
|
21
|
+
},
|
|
22
|
+
block: {
|
|
23
|
+
type: Boolean,
|
|
24
|
+
default: () => {
|
|
25
|
+
return false;
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
checked: {
|
|
30
|
+
type: Boolean,
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const emit = defineEmits(['update:checked']);
|
|
35
|
+
|
|
36
|
+
const setChecked = () => {
|
|
37
|
+
emit('update:checked');
|
|
38
|
+
};
|
|
39
|
+
</script>
|
|
40
|
+
|
|
41
|
+
<style lang="scss" scoped>
|
|
42
|
+
.lew-radio {
|
|
43
|
+
display: inline-flex;
|
|
44
|
+
align-items: center;
|
|
45
|
+
user-select: none;
|
|
46
|
+
margin: 0px 20px 15px 0px;
|
|
47
|
+
cursor: pointer;
|
|
48
|
+
color: var(--text-color);
|
|
49
|
+
font-size: 14px;
|
|
50
|
+
border-radius: 50px;
|
|
51
|
+
.icon-radio-box {
|
|
52
|
+
display: inline-flex;
|
|
53
|
+
align-items: center;
|
|
54
|
+
justify-content: center;
|
|
55
|
+
width: 18px;
|
|
56
|
+
height: 18px;
|
|
57
|
+
border: 2px rgba($color: #000000, $alpha: 0.1) solid;
|
|
58
|
+
box-sizing: border-box;
|
|
59
|
+
margin-right: 5px;
|
|
60
|
+
transition: all 0.25s ease;
|
|
61
|
+
overflow: hidden;
|
|
62
|
+
border-radius: 50px;
|
|
63
|
+
.icon-radio {
|
|
64
|
+
width: 7px;
|
|
65
|
+
height: 7px;
|
|
66
|
+
background-color: #fff;
|
|
67
|
+
transform: translateY(100%);
|
|
68
|
+
opacity: 0;
|
|
69
|
+
border-radius: 2px;
|
|
70
|
+
transition: all 0.25s ease;
|
|
71
|
+
font-size: 12px;
|
|
72
|
+
border-radius: 50px;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.icon-checked-box {
|
|
77
|
+
border: 2px var(--primary-color) solid;
|
|
78
|
+
background: var(--primary-color);
|
|
79
|
+
|
|
80
|
+
.icon-radio {
|
|
81
|
+
transform: translateY(0%);
|
|
82
|
+
opacity: 1;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.lew-radio:hover {
|
|
88
|
+
.icon-radio-box {
|
|
89
|
+
border: 2px rgba($color: #000000, $alpha: 0.2) solid;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.icon-checked-box {
|
|
93
|
+
border: 2px var(--primary-color) solid;
|
|
94
|
+
background: var(--primary-color);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.lew-radio-block {
|
|
99
|
+
background: var(--form-bgcolor);
|
|
100
|
+
padding: 4px 8px 4px 6px;
|
|
101
|
+
border: var(--form-border);
|
|
102
|
+
border-radius: 30px;
|
|
103
|
+
.icon-radio-box {
|
|
104
|
+
border: 2px rgba(0, 0, 0, 0) solid;
|
|
105
|
+
background: var(--form-bgcolor-hover);
|
|
106
|
+
}
|
|
107
|
+
.icon-checked-box {
|
|
108
|
+
border: 2px var(--primary-color) solid;
|
|
109
|
+
background: var(--primary-color);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
.lew-radio-block:hover {
|
|
113
|
+
.icon-radio-box {
|
|
114
|
+
border: 2px rgba(0, 0, 0, 0) solid;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
.lew-radio-block:hover {
|
|
118
|
+
background: var(--form-bgcolor-hover);
|
|
119
|
+
border: var(--form-border-hover);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.lew-radio-block:active {
|
|
123
|
+
background: var(--form-bgcolor-active);
|
|
124
|
+
border: var(--form-border-active);
|
|
125
|
+
}
|
|
126
|
+
</style>
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="lew-radio-group" :class="`lew-radio-group-${direction}`">
|
|
3
|
+
<lew-radio
|
|
4
|
+
v-for="option in options"
|
|
5
|
+
:key="option.id"
|
|
6
|
+
:block="block"
|
|
7
|
+
:label="option.name"
|
|
8
|
+
:checked="modelValue == option.id"
|
|
9
|
+
@update:checked="check(option.id)"
|
|
10
|
+
/>
|
|
11
|
+
</div>
|
|
12
|
+
</template>
|
|
13
|
+
|
|
14
|
+
<script lang="ts" setup>
|
|
15
|
+
import { PropType } from 'vue';
|
|
16
|
+
import { LewRadio } from '@/packages/lew';
|
|
17
|
+
type Options = {
|
|
18
|
+
name: string;
|
|
19
|
+
id: string | number;
|
|
20
|
+
};
|
|
21
|
+
defineProps({
|
|
22
|
+
modelValue: {
|
|
23
|
+
type: Number,
|
|
24
|
+
default: () => {
|
|
25
|
+
return 0;
|
|
26
|
+
},
|
|
27
|
+
required: true,
|
|
28
|
+
},
|
|
29
|
+
block: {
|
|
30
|
+
type: Boolean,
|
|
31
|
+
default: () => {
|
|
32
|
+
return false;
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
direction: {
|
|
37
|
+
type: String,
|
|
38
|
+
default: 'x',
|
|
39
|
+
},
|
|
40
|
+
options: {
|
|
41
|
+
type: Array as PropType<Options[]>,
|
|
42
|
+
default: () => {
|
|
43
|
+
return [];
|
|
44
|
+
},
|
|
45
|
+
required: true,
|
|
46
|
+
validator: (value: Array<number>) => {
|
|
47
|
+
const hasNameKey = value.every((option) =>
|
|
48
|
+
Object.keys(option).includes('name'),
|
|
49
|
+
);
|
|
50
|
+
const hasIdKey = value.every((option) =>
|
|
51
|
+
Object.keys(option).includes('id'),
|
|
52
|
+
);
|
|
53
|
+
return hasNameKey && hasIdKey;
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
const emit = defineEmits(['update:modelValue']);
|
|
59
|
+
|
|
60
|
+
const check = (optionId: number | string) => {
|
|
61
|
+
emit('update:modelValue', Number(optionId));
|
|
62
|
+
};
|
|
63
|
+
</script>
|
|
64
|
+
|
|
65
|
+
<style lang="scss" scoped>
|
|
66
|
+
.lew-radio-group {
|
|
67
|
+
display: flex;
|
|
68
|
+
align-items: center;
|
|
69
|
+
flex-wrap: wrap;
|
|
70
|
+
font-size: 0px;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.lew-radio-group.lew-radio-group-x {
|
|
74
|
+
flex-direction: row;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.lew-radio-group.lew-radio-group-y {
|
|
78
|
+
flex-direction: column;
|
|
79
|
+
align-items: start;
|
|
80
|
+
justify-content: flex-start;
|
|
81
|
+
}
|
|
82
|
+
</style>
|