File tree Expand file tree Collapse file tree 8 files changed +49
-15
lines changed
Expand file tree Collapse file tree 8 files changed +49
-15
lines changed Original file line number Diff line number Diff line change 2222 >
2323 <BooleanIcons
2424 v-model =" truthyModelValue"
25+ :false-value =" settings.falseValue"
2526 :icon-false =" settings.iconFalse"
2627 :icon-false-color =" settings.iconFalseColor"
2728 :icon-false-title =" settings.iconFalseTitle"
2829 :icon-true =" settings.iconTrue"
2930 :icon-true-color =" settings.iconTrueColor"
3031 :icon-true-title =" settings.iconTrueTitle"
32+ :true-value =" settings.trueValue"
3133 />
3234 </div >
3335
@@ -386,5 +388,4 @@ onUnmounted(() => {
386388});
387389 </script >
388390
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';
66export interface VInlineCheckboxProps extends Omit < SharedProps ,
77 'autofocus' | 'truncateLength' | 'truncateSuffix'
88> {
9- density ?: VCheckbox [ '$props' ] [ ' density'] ;
9+ density ?: VCheckbox [ 'density' ] ;
1010 falseIcon ?: string | undefined ;
1111 trueIcon ?: string | undefined ;
12+ falseValue ?: VCheckbox [ 'falseValue' ] ;
13+ trueValue ?: VCheckbox [ 'trueValue' ] ;
1214}
1315
1416
Original file line number Diff line number Diff line change 2222 >
2323 <BooleanIcons
2424 v-model =" truthyModelValue"
25+ :false-value =" settings.falseValue"
2526 :icon-false =" settings.iconFalse"
2627 :icon-false-color =" settings.iconFalseColor"
2728 :icon-false-title =" settings.iconFalseTitle"
2829 :icon-true =" settings.iconTrue"
2930 :icon-true-color =" settings.iconTrueColor"
3031 :icon-true-title =" settings.iconTrueTitle"
32+ :true-value =" settings.trueValue"
3133 />
3234 </div >
3335
@@ -372,5 +374,4 @@ onUnmounted(() => {
372374});
373375 </script >
374376
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';
66export interface VInlineSwitchProps extends Omit < SharedProps ,
77 'autofocus' | 'truncateLength' | 'truncateSuffix'
88> {
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' ] ;
1113}
1214
1315
Original file line number Diff line number Diff line change 11<template >
22 <v-icon
3- v-if =" modelValue"
3+ v-if =" truthyModelValue === true || modelValue === trueValue "
44 class =" v-inline-fields--boolean-icons fa-fw"
55 :color =" iconTrueColor"
66 :icon =" theTrueIcon"
2222import type { BooleanIcons } from ' ./' ;
2323import { useGetIcon } from ' @composables/icons' ;
2424import type { IconOptions } from ' vuetify' ;
25+ import { useTruthyModelValue } from ' @composables/helpers' ;
2526
2627import { VIcon } from ' vuetify/components' ;
2728
@@ -36,6 +37,20 @@ watchEffect(() => {
3637
3738const modelValue = defineModel ();
3839
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+
3954const theFalseIcon = computed (() => {
4055 return useGetIcon ({
4156 icon: settings .iconFalse ,
@@ -53,5 +68,4 @@ const theTrueIcon = computed(() => {
5368});
5469 </script >
5570
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
1111 Required < Pick < SharedProps , 'iconFalseColor' | 'iconFalseTitle' | 'iconTrueColor' | 'iconTrueTitle' > > ,
1212 Pick < SharedProps ,
1313 'iconFalse' |
14- 'iconTrue'
14+ 'iconTrue' |
15+ 'trueValue' |
16+ 'falseValue'
1517 > { } ;
1618
1719
Original file line number Diff line number Diff line change @@ -67,12 +67,24 @@ export const useTruthyModelValue: UseTruthyModelValue = (options) => {
6767 return true ;
6868 }
6969
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+
7082 if ( value === '1' ) {
71- return true ;
83+ return '1' ;
7284 }
7385
7486 if ( value == '1' ) {
75- return true ;
87+ return '1' ;
7688 }
7789
7890 if ( value === true ) {
Original file line number Diff line number Diff line change @@ -89,7 +89,7 @@ export interface SharedProps {
8989 displayPrependInnerIconSize ?: VIconSize ;
9090 emptyText ?: string ;
9191 error ?: boolean ;
92- falseValue ?: boolean | string | undefined ;
92+ falseValue ?: any ;
9393 fieldOnly ?: boolean ;
9494 hideCancelIcon ?: boolean ;
9595 hideDetails ?: boolean ;
@@ -115,7 +115,7 @@ export interface SharedProps {
115115 saveIcon ?: string | undefined ;
116116 saveIconColor ?: string ;
117117 tableField ?: boolean ;
118- trueValue ?: boolean | string | undefined ;
118+ trueValue ?: any ;
119119 truncateLength ?: number | undefined ;
120120 truncateSuffix ?: string | undefined ;
121121 underlineColor ?: string ;
You can’t perform that action at this time.
0 commit comments