Skip to content

Commit f6c4037

Browse files
committed
feat: Add enable-minutes prop (resolves #830)
1 parent 4f06ecb commit f6c4037

File tree

5 files changed

+23
-6
lines changed

5 files changed

+23
-6
lines changed

index.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ export interface VueDatePickerProps {
327327
yearFirst?: boolean;
328328
loading?: boolean;
329329
onInternalModelChange?: (...args: any[]) => void;
330+
enableMinutes?: boolean;
330331
}
331332

332333
export type DatePickerInstance = ComponentPublicInstance<PublicMethods> | null;

src/VueDatePicker/components/TimePicker/TimeInput.vue

+14-5
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@
151151
OverlayGridItem,
152152
DisabledTimesArrProp,
153153
TimeModel,
154+
TimeInput,
154155
} from '@/interfaces';
155156
156157
defineOptions({
@@ -255,11 +256,19 @@
255256
}),
256257
);
257258
258-
const timeInputs = computed((): { type: TimeType; separator?: boolean }[] => {
259-
const inputs = [{ type: 'hours' }, { type: '', separator: true }, { type: 'minutes' }];
260-
return (props.enableSeconds ? inputs.concat([{ type: '', separator: true }, { type: 'seconds' }]) : inputs) as {
261-
type: TimeType;
262-
}[];
259+
const timeInputs = computed((): TimeInput[] => {
260+
const inputs = [{ type: 'hours' }];
261+
if (props.enableMinutes) {
262+
inputs.push({ type: '', separator: true } as unknown as TimeInput, {
263+
type: 'minutes',
264+
});
265+
}
266+
if (props.enableSeconds) {
267+
inputs.push({ type: '', separator: true } as unknown as TimeInput, {
268+
type: 'seconds',
269+
});
270+
}
271+
return inputs as TimeInput[];
263272
});
264273
265274
const timeInputOverlays = computed(() => timeInputs.value.filter((input) => !input.separator));

src/VueDatePicker/composables/defaults.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ export const useDefaults = (props: AllPropsType | PickerBasePropsType) => {
2626
// Shared method for time format
2727
const getTimeFormat = (): string => {
2828
const seconds = props.enableSeconds ? ':ss' : '';
29-
return props.is24 ? `HH:mm${seconds}` : `hh:mm${seconds} aa`;
29+
const minutes = props.enableMinutes ? ':mm' : '';
30+
return props.is24 ? `HH${minutes}${seconds}` : `hh${minutes}${seconds} aa`;
3031
};
3132

3233
// Get default format pattern, returns user specified if defined first

src/VueDatePicker/interfaces.ts

+5
Original file line numberDiff line numberDiff line change
@@ -368,3 +368,8 @@ export interface MultiDatesDefault {
368368
}
369369

370370
export type MultiDatesProp = boolean | Partial<MultiDatesConfig>;
371+
372+
export interface TimeInput {
373+
type: TimeType;
374+
separator?: boolean;
375+
}

src/VueDatePicker/props.ts

+1
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ export const AllProps = {
164164
yearFirst: { type: Boolean as PropType<boolean>, default: false },
165165
loading: { type: Boolean as PropType<boolean>, default: false },
166166
onInternalModelChange: { type: [Function, Object] as PropType<(...args: any[]) => void>, default: null },
167+
enableMinutes: { type: Boolean as PropType<boolean>, default: true },
167168
};
168169

169170
export const PickerBaseProps = {

0 commit comments

Comments
 (0)