srcdev-nuxt-forms 6.1.0 → 6.1.1
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/app/components/forms/form-fieldset/FormFieldset.vue +19 -10
- package/app/components/forms/input-button/InputButtonCore.vue +25 -28
- package/app/components/forms/input-checkbox/MultipleCheckboxes.vue +48 -27
- package/app/components/forms/input-checkbox/SingleCheckbox.vue +52 -33
- package/app/components/forms/input-checkbox-radio/InputCheckboxRadioButton.vue +40 -22
- package/app/components/forms/input-checkbox-radio/InputCheckboxRadioWithLabel.vue +33 -17
- package/app/components/forms/input-label/InputLabel.vue +10 -12
- package/app/components/forms/input-number/InputNumberCore.vue +26 -22
- package/app/components/forms/input-number/variants/InputNumberDefault.vue +50 -27
- package/app/components/forms/input-radio/MultipleRadiobuttons.vue +31 -25
- package/app/components/forms/input-range/InputRangeCore.vue +30 -28
- package/app/components/forms/input-range/variants/InputRangeDefault.vue +45 -28
- package/app/components/forms/input-range-fancy/InputRangeFancyWithLabel.vue +31 -18
- package/app/components/forms/input-select/variants/InputSelectWithLabel.vue +48 -37
- package/app/components/forms/input-text/InputTextCore.vue +4 -6
- package/app/components/forms/input-text/variants/InputTextAsNumberWithLabel.vue +42 -33
- package/app/components/forms/input-text/variants/InputTextWithLabel.vue +51 -42
- package/app/components/forms/input-textarea/InputTextareaCore.vue +29 -24
- package/app/components/forms/input-textarea/variants/InputTextareaWithLabel.vue +41 -31
- package/app/components/forms/toggle-switch/ToggleSwitchCore.vue +43 -25
- package/app/components/forms/toggle-switch/ToggleSwitchCoreOld.vue +36 -22
- package/app/components/forms/toggle-switch/variants/ToggleSwitchWithLabel.vue +42 -25
- package/app/components/forms/toggle-switch/variants/ToggleSwitchWithLabelInline.vue +30 -26
- package/package.json +1 -1
|
@@ -1,18 +1,26 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="input-range-with-label" :data-theme="formTheme" :class="[elementClasses, { error: fieldHasError }]">
|
|
3
|
-
<InputLabel
|
|
3
|
+
<InputLabel
|
|
4
|
+
:for="id"
|
|
5
|
+
:id
|
|
6
|
+
:theme
|
|
7
|
+
:name
|
|
8
|
+
input-variant="normal"
|
|
9
|
+
:field-has-error
|
|
10
|
+
:style-class-passthrough="['input-number-label', 'body-normal-bold']"
|
|
11
|
+
>
|
|
4
12
|
<template #textLabel>{{ label }}</template>
|
|
5
13
|
</InputLabel>
|
|
6
14
|
|
|
7
|
-
<template v-if="
|
|
15
|
+
<template v-if="slots.description">
|
|
8
16
|
<slot name="description"></slot>
|
|
9
17
|
</template>
|
|
10
18
|
|
|
11
19
|
<InputRangeCore v-model="modelValue" :id :name :min :max :step :theme :required :size :weight :fieldHasError>
|
|
12
|
-
<template v-if="
|
|
20
|
+
<template v-if="slots.datalist" #datalist>
|
|
13
21
|
<slot name="datalist"></slot>
|
|
14
22
|
</template>
|
|
15
|
-
<template v-if="
|
|
23
|
+
<template v-if="slots.left" #left>
|
|
16
24
|
<InputButtonCore
|
|
17
25
|
type="button"
|
|
18
26
|
@click.stop.prevent="updateRange(-step, Number(modelValue) > min)"
|
|
@@ -27,7 +35,7 @@
|
|
|
27
35
|
</template>
|
|
28
36
|
</InputButtonCore>
|
|
29
37
|
</template>
|
|
30
|
-
<template v-if="
|
|
38
|
+
<template v-if="slots.right" #right>
|
|
31
39
|
<InputButtonCore
|
|
32
40
|
type="button"
|
|
33
41
|
@click.stop.prevent="updateRange(step, Number(modelValue) < max)"
|
|
@@ -48,9 +56,22 @@
|
|
|
48
56
|
</template>
|
|
49
57
|
|
|
50
58
|
<script setup lang="ts">
|
|
51
|
-
import propValidators from
|
|
59
|
+
import propValidators from "../../c12/prop-validators"
|
|
52
60
|
|
|
53
|
-
const {
|
|
61
|
+
const {
|
|
62
|
+
name,
|
|
63
|
+
label,
|
|
64
|
+
required,
|
|
65
|
+
min,
|
|
66
|
+
max,
|
|
67
|
+
step,
|
|
68
|
+
theme,
|
|
69
|
+
size,
|
|
70
|
+
weight,
|
|
71
|
+
styleClassPassthrough,
|
|
72
|
+
errorMessage,
|
|
73
|
+
fieldHasError,
|
|
74
|
+
} = defineProps({
|
|
54
75
|
name: {
|
|
55
76
|
type: String,
|
|
56
77
|
required: true,
|
|
@@ -73,7 +94,7 @@ const { name, label, required, min, max, step, theme, size, weight, styleClassPa
|
|
|
73
94
|
},
|
|
74
95
|
placeholder: {
|
|
75
96
|
type: String,
|
|
76
|
-
default:
|
|
97
|
+
default: "",
|
|
77
98
|
},
|
|
78
99
|
errorMessage: {
|
|
79
100
|
type: [Object, String],
|
|
@@ -89,23 +110,23 @@ const { name, label, required, min, max, step, theme, size, weight, styleClassPa
|
|
|
89
110
|
},
|
|
90
111
|
theme: {
|
|
91
112
|
type: String as PropType<string>,
|
|
92
|
-
default:
|
|
113
|
+
default: "primary",
|
|
93
114
|
validator(value: string) {
|
|
94
|
-
return propValidators.theme.includes(value)
|
|
115
|
+
return propValidators.theme.includes(value)
|
|
95
116
|
},
|
|
96
117
|
},
|
|
97
118
|
size: {
|
|
98
119
|
type: String as PropType<string>,
|
|
99
|
-
default:
|
|
120
|
+
default: "medium",
|
|
100
121
|
validator(value: string) {
|
|
101
|
-
return propValidators.size.includes(value)
|
|
122
|
+
return propValidators.size.includes(value)
|
|
102
123
|
},
|
|
103
124
|
},
|
|
104
125
|
weight: {
|
|
105
126
|
type: String as PropType<string>,
|
|
106
|
-
default:
|
|
127
|
+
default: "wght-400",
|
|
107
128
|
validator(value: string) {
|
|
108
|
-
return propValidators.weight.includes(value)
|
|
129
|
+
return propValidators.weight.includes(value)
|
|
109
130
|
},
|
|
110
131
|
},
|
|
111
132
|
styleClassPassthrough: {
|
|
@@ -114,29 +135,25 @@ const { name, label, required, min, max, step, theme, size, weight, styleClassPa
|
|
|
114
135
|
},
|
|
115
136
|
deepCssClassPassthrough: {
|
|
116
137
|
type: String,
|
|
117
|
-
default:
|
|
138
|
+
default: "",
|
|
118
139
|
},
|
|
119
|
-
})
|
|
140
|
+
})
|
|
120
141
|
|
|
121
|
-
const slots = useSlots()
|
|
122
|
-
const
|
|
123
|
-
const hasDataList = computed(() => slots.datalist !== undefined);
|
|
124
|
-
const hasLeftContent = computed(() => slots.left !== undefined);
|
|
125
|
-
const hasRightContent = computed(() => slots.right !== undefined);
|
|
126
|
-
const { elementClasses, updateElementClasses } = useStyleClassPassthrough(styleClassPassthrough);
|
|
142
|
+
const slots = useSlots()
|
|
143
|
+
const { elementClasses } = useStyleClassPassthrough(styleClassPassthrough)
|
|
127
144
|
|
|
128
|
-
const id = useId()
|
|
145
|
+
const id = useId()
|
|
129
146
|
const formTheme = computed(() => {
|
|
130
|
-
return fieldHasError ?
|
|
131
|
-
})
|
|
147
|
+
return fieldHasError ? "error" : theme
|
|
148
|
+
})
|
|
132
149
|
|
|
133
|
-
const modelValue = defineModel<number | readonly number[]>()
|
|
150
|
+
const modelValue = defineModel<number | readonly number[]>()
|
|
134
151
|
|
|
135
152
|
const updateRange = (step: number, withinRangeLimit: boolean) => {
|
|
136
153
|
if (withinRangeLimit) {
|
|
137
|
-
modelValue.value = (Number(modelValue.value) + step) as number
|
|
154
|
+
modelValue.value = (Number(modelValue.value) + step) as number
|
|
138
155
|
}
|
|
139
|
-
}
|
|
156
|
+
}
|
|
140
157
|
</script>
|
|
141
158
|
|
|
142
159
|
<style lang="css">
|
|
@@ -1,17 +1,31 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="input-range-fancy-with-label" :data-theme="formTheme" :class="[elementClasses, { error: fieldHasError }]">
|
|
3
3
|
<label class="input-range-fancy-label body-normal-bold" :for="id">{{ label }}</label>
|
|
4
|
-
<template v-if="
|
|
4
|
+
<template v-if="slots.description">
|
|
5
5
|
<slot name="description"></slot>
|
|
6
6
|
</template>
|
|
7
7
|
|
|
8
|
-
<InputRangeFancyCore
|
|
8
|
+
<InputRangeFancyCore
|
|
9
|
+
v-model="modelValue"
|
|
10
|
+
:id
|
|
11
|
+
:name
|
|
12
|
+
:rangeLowLabel
|
|
13
|
+
:rangeHighLabel
|
|
14
|
+
:min
|
|
15
|
+
:max
|
|
16
|
+
:step
|
|
17
|
+
:theme
|
|
18
|
+
:required
|
|
19
|
+
:size
|
|
20
|
+
:weight
|
|
21
|
+
:fieldHasError
|
|
22
|
+
/>
|
|
9
23
|
<InputError :errorMessage :showError="fieldHasError" :id :isDetached="true" :styleClassPassthrough="['mbe-20']" />
|
|
10
24
|
</div>
|
|
11
25
|
</template>
|
|
12
26
|
|
|
13
27
|
<script setup lang="ts">
|
|
14
|
-
import propValidators from
|
|
28
|
+
import propValidators from "../c12/prop-validators"
|
|
15
29
|
|
|
16
30
|
const props = defineProps({
|
|
17
31
|
id: {
|
|
@@ -48,7 +62,7 @@ const props = defineProps({
|
|
|
48
62
|
},
|
|
49
63
|
placeholder: {
|
|
50
64
|
type: String,
|
|
51
|
-
default:
|
|
65
|
+
default: "",
|
|
52
66
|
},
|
|
53
67
|
errorMessage: {
|
|
54
68
|
type: [Object, String],
|
|
@@ -64,23 +78,23 @@ const props = defineProps({
|
|
|
64
78
|
},
|
|
65
79
|
theme: {
|
|
66
80
|
type: String as PropType<string>,
|
|
67
|
-
default:
|
|
81
|
+
default: "primary",
|
|
68
82
|
validator(value: string) {
|
|
69
|
-
return propValidators.theme.includes(value)
|
|
83
|
+
return propValidators.theme.includes(value)
|
|
70
84
|
},
|
|
71
85
|
},
|
|
72
86
|
size: {
|
|
73
87
|
type: String as PropType<string>,
|
|
74
|
-
default:
|
|
88
|
+
default: "medium",
|
|
75
89
|
validator(value: string) {
|
|
76
|
-
return propValidators.size.includes(value)
|
|
90
|
+
return propValidators.size.includes(value)
|
|
77
91
|
},
|
|
78
92
|
},
|
|
79
93
|
weight: {
|
|
80
94
|
type: String as PropType<string>,
|
|
81
|
-
default:
|
|
95
|
+
default: "wght-400",
|
|
82
96
|
validator(value: string) {
|
|
83
|
-
return propValidators.weight.includes(value)
|
|
97
|
+
return propValidators.weight.includes(value)
|
|
84
98
|
},
|
|
85
99
|
},
|
|
86
100
|
styleClassPassthrough: {
|
|
@@ -89,19 +103,18 @@ const props = defineProps({
|
|
|
89
103
|
},
|
|
90
104
|
deepCssClassPassthrough: {
|
|
91
105
|
type: String,
|
|
92
|
-
default:
|
|
106
|
+
default: "",
|
|
93
107
|
},
|
|
94
|
-
})
|
|
108
|
+
})
|
|
95
109
|
|
|
96
|
-
const slots = useSlots()
|
|
97
|
-
const
|
|
98
|
-
const { elementClasses, updateElementClasses } = useStyleClassPassthrough(props.styleClassPassthrough);
|
|
110
|
+
const slots = useSlots()
|
|
111
|
+
const { elementClasses } = useStyleClassPassthrough(props.styleClassPassthrough)
|
|
99
112
|
|
|
100
113
|
const formTheme = computed(() => {
|
|
101
|
-
return props.fieldHasError ?
|
|
102
|
-
})
|
|
114
|
+
return props.fieldHasError ? "error" : props.theme
|
|
115
|
+
})
|
|
103
116
|
|
|
104
|
-
const modelValue = defineModel<number | readonly number[]>()
|
|
117
|
+
const modelValue = defineModel<number | readonly number[]>()
|
|
105
118
|
</script>
|
|
106
119
|
|
|
107
120
|
<style lang="css">
|
|
@@ -1,11 +1,25 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div>
|
|
3
|
-
<div
|
|
4
|
-
|
|
3
|
+
<div
|
|
4
|
+
class="input-select-with-label"
|
|
5
|
+
:class="[inputVariant, { dirty: isDirty }, { active: isActive }, { error: fieldHasError }]"
|
|
6
|
+
:data-testid
|
|
7
|
+
:data-theme="formTheme"
|
|
8
|
+
:data-size="size"
|
|
9
|
+
>
|
|
10
|
+
<InputLabel
|
|
11
|
+
:for="id"
|
|
12
|
+
:id
|
|
13
|
+
:theme
|
|
14
|
+
:name
|
|
15
|
+
:input-variant
|
|
16
|
+
:field-has-error
|
|
17
|
+
:style-class-passthrough="['input-select-label']"
|
|
18
|
+
>
|
|
5
19
|
<template #textLabel>{{ label }}</template>
|
|
6
20
|
</InputLabel>
|
|
7
21
|
|
|
8
|
-
<div v-if="inputVariant === 'normal' &&
|
|
22
|
+
<div v-if="inputVariant === 'normal' && slots.description" :id="`${id}-description`">
|
|
9
23
|
<slot name="description"></slot>
|
|
10
24
|
</div>
|
|
11
25
|
|
|
@@ -26,22 +40,28 @@
|
|
|
26
40
|
:inputVariant
|
|
27
41
|
/>
|
|
28
42
|
|
|
29
|
-
<InputError
|
|
43
|
+
<InputError
|
|
44
|
+
:errorMessage="errorMessage"
|
|
45
|
+
:showError="fieldHasError"
|
|
46
|
+
:id="errorId"
|
|
47
|
+
:isDetached="false"
|
|
48
|
+
:inputVariant
|
|
49
|
+
/>
|
|
30
50
|
</div>
|
|
31
|
-
<div v-if="inputVariant !== 'normal' &&
|
|
51
|
+
<div v-if="inputVariant !== 'normal' && slots.description" :id="`${id}-description`">
|
|
32
52
|
<slot name="description"></slot>
|
|
33
53
|
</div>
|
|
34
54
|
</div>
|
|
35
55
|
</template>
|
|
36
56
|
|
|
37
57
|
<script setup lang="ts">
|
|
38
|
-
import propValidators from
|
|
39
|
-
import type { IFormMultipleOptions } from
|
|
58
|
+
import propValidators from "../../c12/prop-validators"
|
|
59
|
+
import type { IFormMultipleOptions } from "../../../../../shared/types/types.forms"
|
|
40
60
|
|
|
41
61
|
const props = defineProps({
|
|
42
62
|
dataTestid: {
|
|
43
63
|
type: String,
|
|
44
|
-
default:
|
|
64
|
+
default: "input-select-with-label",
|
|
45
65
|
},
|
|
46
66
|
name: {
|
|
47
67
|
type: String,
|
|
@@ -53,7 +73,7 @@ const props = defineProps({
|
|
|
53
73
|
},
|
|
54
74
|
placeholder: {
|
|
55
75
|
type: String,
|
|
56
|
-
default:
|
|
76
|
+
default: "",
|
|
57
77
|
},
|
|
58
78
|
errorMessage: {
|
|
59
79
|
type: [Object, String],
|
|
@@ -69,9 +89,9 @@ const props = defineProps({
|
|
|
69
89
|
},
|
|
70
90
|
size: {
|
|
71
91
|
type: String as PropType<string>,
|
|
72
|
-
default:
|
|
92
|
+
default: "medium",
|
|
73
93
|
validator(value: string) {
|
|
74
|
-
return propValidators.size.includes(value)
|
|
94
|
+
return propValidators.size.includes(value)
|
|
75
95
|
},
|
|
76
96
|
},
|
|
77
97
|
styleClassPassthrough: {
|
|
@@ -80,44 +100,35 @@ const props = defineProps({
|
|
|
80
100
|
},
|
|
81
101
|
theme: {
|
|
82
102
|
type: String as PropType<string>,
|
|
83
|
-
default:
|
|
103
|
+
default: "primary",
|
|
84
104
|
validator(value: string) {
|
|
85
|
-
return propValidators.theme.includes(value)
|
|
105
|
+
return propValidators.theme.includes(value)
|
|
86
106
|
},
|
|
87
107
|
},
|
|
88
108
|
inputVariant: {
|
|
89
109
|
type: String as PropType<string>,
|
|
90
|
-
default:
|
|
110
|
+
default: "normal",
|
|
91
111
|
validator(value: string) {
|
|
92
|
-
return propValidators.inputVariant.includes(value)
|
|
112
|
+
return propValidators.inputVariant.includes(value)
|
|
93
113
|
},
|
|
94
114
|
},
|
|
95
|
-
})
|
|
115
|
+
})
|
|
96
116
|
|
|
97
|
-
const slots = useSlots()
|
|
98
|
-
const hasDescriptionSlot = computed(() => slots.description !== undefined);
|
|
99
|
-
const { elementClasses } = useStyleClassPassthrough(props.styleClassPassthrough);
|
|
117
|
+
const slots = useSlots()
|
|
100
118
|
|
|
101
119
|
const formTheme = computed(() => {
|
|
102
|
-
return props.fieldHasError ?
|
|
103
|
-
})
|
|
120
|
+
return props.fieldHasError ? "error" : props.theme
|
|
121
|
+
})
|
|
104
122
|
|
|
105
|
-
const id = `${props.name}-${useId()}
|
|
106
|
-
const errorId = `${name}-error-message
|
|
123
|
+
const id = `${props.name}-${useId()}`
|
|
124
|
+
const errorId = `${name}-error-message`
|
|
107
125
|
const ariaDescribedby = computed(() => {
|
|
108
|
-
const ariaDescribedbyId =
|
|
109
|
-
return props.fieldHasError ? errorId : ariaDescribedbyId
|
|
110
|
-
})
|
|
126
|
+
const ariaDescribedbyId = slots.description ? `${id}-description` : undefined
|
|
127
|
+
return props.fieldHasError ? errorId : ariaDescribedbyId
|
|
128
|
+
})
|
|
111
129
|
|
|
112
|
-
const modelValue = defineModel({ required: true })
|
|
113
|
-
const isDirty = defineModel(
|
|
114
|
-
const isActive = defineModel(
|
|
115
|
-
const fieldData = defineModel(
|
|
130
|
+
const modelValue = defineModel({ required: true })
|
|
131
|
+
const isDirty = defineModel("isDirty")
|
|
132
|
+
const isActive = defineModel("isActive")
|
|
133
|
+
const fieldData = defineModel("fieldData") as Ref<IFormMultipleOptions>
|
|
116
134
|
</script>
|
|
117
|
-
|
|
118
|
-
<style lang="css">
|
|
119
|
-
.input-select-with-label {
|
|
120
|
-
.input-select-label {
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
</style>
|
|
@@ -9,11 +9,11 @@
|
|
|
9
9
|
{ dirty: isDirty },
|
|
10
10
|
{ active: isActive },
|
|
11
11
|
{ error: fieldHasError },
|
|
12
|
-
{ 'has-left-slot':
|
|
13
|
-
{ 'has-right-slot':
|
|
12
|
+
{ 'has-left-slot': slots.left },
|
|
13
|
+
{ 'has-right-slot': slots.right },
|
|
14
14
|
]"
|
|
15
15
|
>
|
|
16
|
-
<span v-if="
|
|
16
|
+
<span v-if="slots.left" class="slot left-slot">
|
|
17
17
|
<slot name="left"></slot>
|
|
18
18
|
</span>
|
|
19
19
|
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
@focusout="updateFocus(false)"
|
|
36
36
|
/>
|
|
37
37
|
|
|
38
|
-
<span v-if="
|
|
38
|
+
<span v-if="slots.right" class="slot right-slot">
|
|
39
39
|
<slot name="right"></slot>
|
|
40
40
|
</span>
|
|
41
41
|
</div>
|
|
@@ -115,8 +115,6 @@ const props = defineProps({
|
|
|
115
115
|
})
|
|
116
116
|
|
|
117
117
|
const slots = useSlots()
|
|
118
|
-
const hasLeftSlot = computed(() => slots.left !== undefined)
|
|
119
|
-
const hasRightSlot = computed(() => slots.right !== undefined)
|
|
120
118
|
|
|
121
119
|
const formTheme = computed(() => {
|
|
122
120
|
return props.fieldHasError ? "error" : props.theme
|
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div
|
|
3
|
-
|
|
2
|
+
<div
|
|
3
|
+
class="input-text-with-label"
|
|
4
|
+
:data-theme="formTheme"
|
|
5
|
+
:class="[inputVariant, elementClasses, { dirty: isDirty }, { active: isActive }]"
|
|
6
|
+
>
|
|
7
|
+
<InputLabel
|
|
8
|
+
:for="id"
|
|
9
|
+
:id
|
|
10
|
+
:theme
|
|
11
|
+
:name
|
|
12
|
+
:input-variant
|
|
13
|
+
:field-has-error
|
|
14
|
+
:style-class-passthrough="['input-text-label', 'body-normal-bold']"
|
|
15
|
+
>
|
|
4
16
|
<template #textLabel>{{ label }}</template>
|
|
5
17
|
</InputLabel>
|
|
6
18
|
|
|
7
|
-
<div v-if="
|
|
19
|
+
<div v-if="slots.description" :id="`${id}-description`">
|
|
8
20
|
<slot name="description"></slot>
|
|
9
21
|
</div>
|
|
10
22
|
|
|
@@ -28,7 +40,7 @@
|
|
|
28
40
|
:size
|
|
29
41
|
:inputVariant
|
|
30
42
|
>
|
|
31
|
-
<template v-if="
|
|
43
|
+
<template v-if="slots.left" #left>
|
|
32
44
|
<InputButtonCore
|
|
33
45
|
type="button"
|
|
34
46
|
@click.stop.prevent="updateValue(-step, Number(modelValue) > min)"
|
|
@@ -43,7 +55,7 @@
|
|
|
43
55
|
</template>
|
|
44
56
|
</InputButtonCore>
|
|
45
57
|
</template>
|
|
46
|
-
<template v-if="
|
|
58
|
+
<template v-if="slots.right" #right>
|
|
47
59
|
<InputButtonCore
|
|
48
60
|
type="button"
|
|
49
61
|
@click.stop.prevent="updateValue(step, Number(modelValue) < max)"
|
|
@@ -64,7 +76,7 @@
|
|
|
64
76
|
</template>
|
|
65
77
|
|
|
66
78
|
<script setup lang="ts">
|
|
67
|
-
import propValidators from
|
|
79
|
+
import propValidators from "../../c12/prop-validators"
|
|
68
80
|
const props = defineProps({
|
|
69
81
|
maxlength: {
|
|
70
82
|
type: Number,
|
|
@@ -76,7 +88,7 @@ const props = defineProps({
|
|
|
76
88
|
},
|
|
77
89
|
placeholder: {
|
|
78
90
|
type: String,
|
|
79
|
-
default:
|
|
91
|
+
default: "",
|
|
80
92
|
},
|
|
81
93
|
label: {
|
|
82
94
|
type: String,
|
|
@@ -100,9 +112,9 @@ const props = defineProps({
|
|
|
100
112
|
},
|
|
101
113
|
theme: {
|
|
102
114
|
type: String as PropType<string>,
|
|
103
|
-
default:
|
|
115
|
+
default: "primary",
|
|
104
116
|
validator(value: string) {
|
|
105
|
-
return propValidators.theme.includes(value)
|
|
117
|
+
return propValidators.theme.includes(value)
|
|
106
118
|
},
|
|
107
119
|
},
|
|
108
120
|
min: {
|
|
@@ -119,50 +131,47 @@ const props = defineProps({
|
|
|
119
131
|
},
|
|
120
132
|
size: {
|
|
121
133
|
type: String as PropType<string>,
|
|
122
|
-
default:
|
|
134
|
+
default: "default",
|
|
123
135
|
validator(value: string) {
|
|
124
|
-
return propValidators.size.includes(value)
|
|
136
|
+
return propValidators.size.includes(value)
|
|
125
137
|
},
|
|
126
138
|
},
|
|
127
139
|
inputVariant: {
|
|
128
140
|
type: String as PropType<string>,
|
|
129
|
-
default:
|
|
141
|
+
default: "normal",
|
|
130
142
|
validator(value: string) {
|
|
131
|
-
return propValidators.inputVariant.includes(value)
|
|
143
|
+
return propValidators.inputVariant.includes(value)
|
|
132
144
|
},
|
|
133
145
|
},
|
|
134
|
-
})
|
|
146
|
+
})
|
|
135
147
|
|
|
136
|
-
const slots = useSlots()
|
|
137
|
-
const hasDescriptionSlot = computed(() => slots.description !== undefined);
|
|
138
|
-
const hasLeftSlot = computed(() => slots.left !== undefined);
|
|
139
|
-
const hasRightSlot = computed(() => slots.right !== undefined);
|
|
148
|
+
const slots = useSlots()
|
|
140
149
|
|
|
141
150
|
const formTheme = computed(() => {
|
|
142
|
-
return props.fieldHasError ?
|
|
143
|
-
})
|
|
151
|
+
return props.fieldHasError ? "error" : props.theme
|
|
152
|
+
})
|
|
144
153
|
|
|
145
|
-
const id = useId()
|
|
146
|
-
const errorId = `${id}-error-message
|
|
154
|
+
const id = useId()
|
|
155
|
+
const errorId = `${id}-error-message`
|
|
147
156
|
const ariaDescribedby = computed(() => {
|
|
148
|
-
const ariaDescribedbyId =
|
|
149
|
-
return props.fieldHasError ? errorId : ariaDescribedbyId
|
|
150
|
-
})
|
|
157
|
+
const ariaDescribedbyId = slots.description ? `${id}-description` : undefined
|
|
158
|
+
return props.fieldHasError ? errorId : ariaDescribedbyId
|
|
159
|
+
})
|
|
151
160
|
|
|
152
|
-
const modelValue = defineModel()
|
|
153
|
-
const isActive = ref<boolean>(false)
|
|
154
|
-
const isDirty = ref<boolean>(false)
|
|
161
|
+
const modelValue = defineModel()
|
|
162
|
+
const isActive = ref<boolean>(false)
|
|
163
|
+
const isDirty = ref<boolean>(false)
|
|
155
164
|
|
|
156
|
-
const { elementClasses, updateElementClasses } = useStyleClassPassthrough(props.styleClassPassthrough)
|
|
157
|
-
const minLength = computed(() => `${props.max.toString().length + 1}em`)
|
|
165
|
+
const { elementClasses, updateElementClasses } = useStyleClassPassthrough(props.styleClassPassthrough)
|
|
166
|
+
const minLength = computed(() => `${props.max.toString().length + 1}em`)
|
|
158
167
|
|
|
159
168
|
const updateValue = (step: number, withinRangeLimit: boolean) => {
|
|
160
169
|
if (withinRangeLimit) {
|
|
161
|
-
modelValue.value = (Number(modelValue.value) + step) as number
|
|
170
|
+
modelValue.value = (Number(modelValue.value) + step) as number
|
|
162
171
|
}
|
|
163
|
-
}
|
|
172
|
+
}
|
|
164
173
|
|
|
165
|
-
updateElementClasses([
|
|
174
|
+
updateElementClasses(["input-text-as-number", "has-left-button", "has-right-button"])
|
|
166
175
|
</script>
|
|
167
176
|
|
|
168
177
|
<style lang="css">
|