Skip to content

Commit

Permalink
Updated mscheckbox init
Browse files Browse the repository at this point in the history
  • Loading branch information
Max-7 committed Oct 11, 2024
1 parent cec6e1c commit 3ab7822
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions lib/components/ms-checkbox/MsCheckbox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,18 @@
import { IonCheckbox } from '@ionic/vue';
import { ref, watch, onUnmounted } from 'vue';
const props = defineProps<{
modelValue?: boolean;
checked?: boolean;
indeterminate?: boolean;
}>();
const props = withDefaults(
defineProps<{
modelValue?: boolean;
checked?: boolean;
indeterminate?: boolean;
}>(),
{
modelValue: undefined,
checked: undefined,
indeterminate: undefined,
},
);
const emits = defineEmits<{
(e: 'change', value: boolean): void;
Expand All @@ -29,19 +36,19 @@ const emits = defineEmits<{
const watchModelCancel = watch(
() => props.modelValue,
(newValue: boolean) => {
(newValue?: boolean) => {
value.value = newValue;
},
);
const watchCheckedCancel = watch(
() => props.checked,
(newValue: boolean) => {
(newValue?: boolean) => {
value.value = newValue;
},
);
const value = ref(props.modelValue);
const value = ref(props.modelValue !== undefined ? props.modelValue : props.checked);
onUnmounted(() => {
watchModelCancel();
Expand Down

0 comments on commit 3ab7822

Please sign in to comment.