Skip to content
This repository was archived by the owner on Apr 17, 2022. It is now read-only.

Commit cc8ec74

Browse files
committed
fix: Inline and disabled for inline mode (#70)
1 parent 0dce831 commit cc8ec74

File tree

4 files changed

+35
-1
lines changed

4 files changed

+35
-1
lines changed

src/Vue3DatePicker/Vue3DatePicker.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@
9999
spaceConfirm,
100100
monthChangeOnArrows,
101101
textInput,
102+
disabled,
103+
readonly,
102104
}"
103105
v-model:internalModelValue="internalModelValue"
104106
@close-picker="closeMenu"

src/Vue3DatePicker/components/DatepickerMenu.vue

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
@keydown.left="handleArrow('left', false)"
1414
@keydown.right="handleArrow('right', false)"
1515
>
16+
<div :class="disabledReadonlyOverlay" v-if="(disabled || readonly) && inline"></div>
1617
<div :class="arrowClass" v-if="!inline"></div>
1718
<div :class="menuCalendarClassWrapper" ref="calendarWrapperRef" role="document">
1819
<Calendar
@@ -178,6 +179,8 @@
178179
spaceConfirm: { type: Boolean as PropType<boolean>, default: true },
179180
monthChangeOnArrows: { type: Boolean as PropType<boolean>, default: true },
180181
textInput: { type: Boolean as PropType<boolean>, default: false },
182+
disabled: { type: Boolean as PropType<boolean>, default: false },
183+
readonly: { type: Boolean as PropType<boolean>, default: false },
181184
});
182185
const slots = useSlots();
183186
const calendarWrapperRef = ref(null);
@@ -282,6 +285,10 @@
282285
}),
283286
);
284287
288+
const disabledReadonlyOverlay = computed(() => ({
289+
dp__menu_disabled: props.disabled,
290+
dp__menu_readonly: props.readonly,
291+
}));
285292
/**
286293
* Array of the dates from which calendar is built.
287294
* It also sets classes depending on picker modes, active dates, today, v-model.

src/Vue3DatePicker/components/composition/calendar.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,9 @@ export const useCalendar = (props: UseCalendar, emit: VueEmit): IUseCalendar =>
120120
return props.internalModelValue;
121121
},
122122
set: (value: InternalModuleValue): void => {
123-
emit('update:internalModelValue', value);
123+
if (!props.readonly && !props.disabled) {
124+
emit('update:internalModelValue', value);
125+
}
124126
},
125127
});
126128

src/Vue3DatePicker/style/components/_DatepickerMenu.scss

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,29 @@
2424
}
2525
}
2626

27+
%__dp_menu_readonly_disabled {
28+
position: absolute;
29+
top: 0;
30+
left: 0;
31+
right: 0;
32+
bottom: 0;
33+
z-index: 99999;
34+
}
35+
36+
.dp__menu_disabled {
37+
@extend %__dp_menu_readonly_disabled;
38+
39+
background: rgb(255 255 255 / 50%);
40+
cursor: not-allowed;
41+
}
42+
43+
.dp__menu_readonly {
44+
@extend %__dp_menu_readonly_disabled;
45+
46+
background: transparent;
47+
cursor: default;
48+
}
49+
2750
.dp__arrow_top {
2851
left: 50%;
2952
top: -1px;

0 commit comments

Comments
 (0)