File tree 8 files changed +49
-15
lines changed
8 files changed +49
-15
lines changed Original file line number Diff line number Diff line change 22
22
>
23
23
<BooleanIcons
24
24
v-model =" truthyModelValue"
25
+ :false-value =" settings.falseValue"
25
26
:icon-false =" settings.iconFalse"
26
27
:icon-false-color =" settings.iconFalseColor"
27
28
:icon-false-title =" settings.iconFalseTitle"
28
29
:icon-true =" settings.iconTrue"
29
30
:icon-true-color =" settings.iconTrueColor"
30
31
:icon-true-title =" settings.iconTrueTitle"
32
+ :true-value =" settings.trueValue"
31
33
/>
32
34
</div >
33
35
@@ -386,5 +388,4 @@ onUnmounted(() => {
386
388
});
387
389
</script >
388
390
389
- <style lang="scss" scoped>
390
- </style >
391
+ <style lang="scss" scoped></style >
Original file line number Diff line number Diff line change @@ -6,9 +6,11 @@ import type VInlineCheckbox from './VInlineCheckbox.vue';
6
6
export interface VInlineCheckboxProps extends Omit < SharedProps ,
7
7
'autofocus' | 'truncateLength' | 'truncateSuffix'
8
8
> {
9
- density ?: VCheckbox [ '$props' ] [ ' density'] ;
9
+ density ?: VCheckbox [ 'density' ] ;
10
10
falseIcon ?: string | undefined ;
11
11
trueIcon ?: string | undefined ;
12
+ falseValue ?: VCheckbox [ 'falseValue' ] ;
13
+ trueValue ?: VCheckbox [ 'trueValue' ] ;
12
14
}
13
15
14
16
Original file line number Diff line number Diff line change 22
22
>
23
23
<BooleanIcons
24
24
v-model =" truthyModelValue"
25
+ :false-value =" settings.falseValue"
25
26
:icon-false =" settings.iconFalse"
26
27
:icon-false-color =" settings.iconFalseColor"
27
28
:icon-false-title =" settings.iconFalseTitle"
28
29
:icon-true =" settings.iconTrue"
29
30
:icon-true-color =" settings.iconTrueColor"
30
31
:icon-true-title =" settings.iconTrueTitle"
32
+ :true-value =" settings.trueValue"
31
33
/>
32
34
</div >
33
35
@@ -372,5 +374,4 @@ onUnmounted(() => {
372
374
});
373
375
</script >
374
376
375
- <style lang="scss" scoped>
376
- </style >
377
+ <style lang="scss" scoped></style >
Original file line number Diff line number Diff line change @@ -6,8 +6,10 @@ import type VInlineSwitch from './VInlineSwitch.vue';
6
6
export interface VInlineSwitchProps extends Omit < SharedProps ,
7
7
'autofocus' | 'truncateLength' | 'truncateSuffix'
8
8
> {
9
- density ?: VSwitch [ '$props' ] [ 'density' ] ;
10
- falseIcon ?: VSwitch [ '$props' ] [ 'falseIcon' ] ;
9
+ density ?: VSwitch [ 'density' ] ;
10
+ falseIcon ?: VSwitch [ 'falseIcon' ] ;
11
+ falseValue ?: VSwitch [ 'falseValue' ] ;
12
+ trueValue ?: VSwitch [ 'trueValue' ] ;
11
13
}
12
14
13
15
Original file line number Diff line number Diff line change 1
1
<template >
2
2
<v-icon
3
- v-if =" modelValue"
3
+ v-if =" truthyModelValue === true || modelValue === trueValue "
4
4
class =" v-inline-fields--boolean-icons fa-fw"
5
5
:color =" iconTrueColor"
6
6
:icon =" theTrueIcon"
22
22
import type { BooleanIcons } from ' ./' ;
23
23
import { useGetIcon } from ' @composables/icons' ;
24
24
import type { IconOptions } from ' vuetify' ;
25
+ import { useTruthyModelValue } from ' @composables/helpers' ;
25
26
26
27
import { VIcon } from ' vuetify/components' ;
27
28
@@ -36,6 +37,20 @@ watchEffect(() => {
36
37
37
38
const modelValue = defineModel ();
38
39
40
+ const truthyModelValue = computed (() => useTruthyModelValue ({
41
+ modelValue ,
42
+ trueValue: settings .trueValue ,
43
+ }));
44
+
45
+
46
+ const trueValue = computed (() => {
47
+ return settings .trueValue ?? true ;
48
+ });
49
+
50
+ // const falseValue = computed(() => {
51
+ // return settings.falseValue ?? false;
52
+ // });
53
+
39
54
const theFalseIcon = computed (() => {
40
55
return useGetIcon ({
41
56
icon: settings .iconFalse ,
@@ -53,5 +68,4 @@ const theTrueIcon = computed(() => {
53
68
});
54
69
</script >
55
70
56
- <style lang="scss">
57
- </style >
71
+ <style lang="scss"></style >
Original file line number Diff line number Diff line change @@ -11,7 +11,9 @@ export interface BooleanIcons extends
11
11
Required < Pick < SharedProps , 'iconFalseColor' | 'iconFalseTitle' | 'iconTrueColor' | 'iconTrueTitle' > > ,
12
12
Pick < SharedProps ,
13
13
'iconFalse' |
14
- 'iconTrue'
14
+ 'iconTrue' |
15
+ 'trueValue' |
16
+ 'falseValue'
15
17
> { } ;
16
18
17
19
Original file line number Diff line number Diff line change @@ -67,12 +67,24 @@ export const useTruthyModelValue: UseTruthyModelValue = (options) => {
67
67
return true ;
68
68
}
69
69
70
+ if ( typeof value === 'string' ) {
71
+ return value ;
72
+ }
73
+
74
+ if ( value === 1 || value === 0 ) {
75
+ return value ;
76
+ }
77
+
78
+ if ( value == 1 || value == 0 ) {
79
+ return value ;
80
+ }
81
+
70
82
if ( value === '1' ) {
71
- return true ;
83
+ return '1' ;
72
84
}
73
85
74
86
if ( value == '1' ) {
75
- return true ;
87
+ return '1' ;
76
88
}
77
89
78
90
if ( value === true ) {
Original file line number Diff line number Diff line change @@ -89,7 +89,7 @@ export interface SharedProps {
89
89
displayPrependInnerIconSize ?: VIconSize ;
90
90
emptyText ?: string ;
91
91
error ?: boolean ;
92
- falseValue ?: boolean | string | undefined ;
92
+ falseValue ?: any ;
93
93
fieldOnly ?: boolean ;
94
94
hideCancelIcon ?: boolean ;
95
95
hideDetails ?: boolean ;
@@ -115,7 +115,7 @@ export interface SharedProps {
115
115
saveIcon ?: string | undefined ;
116
116
saveIconColor ?: string ;
117
117
tableField ?: boolean ;
118
- trueValue ?: boolean | string | undefined ;
118
+ trueValue ?: any ;
119
119
truncateLength ?: number | undefined ;
120
120
truncateSuffix ?: string | undefined ;
121
121
underlineColor ?: string ;
You can’t perform that action at this time.
0 commit comments