Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
mlmoravek committed Aug 6, 2024
1 parent 06e4319 commit 9bdb77d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
4 changes: 2 additions & 2 deletions packages/docs/components/Datetimepicker.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
| active | The active state of the dropdown, use v-model:active to make it two-way binding | boolean | - | <code style='white-space: nowrap; padding: 0;'>false</code> |
| datepicker | Define props for the underlying datepicker component | any | - | |
| datetimeCreator | Date creator function, default is `new Date()` | (date: Date) =&gt; Date | - | <div><small>From <b>config</b>:</small></div><code style='white-space: nowrap; padding: 0;'>datetimepicker: {<br>&nbsp;&nbsp;datetimeCreator: (d: Date) => new Date(d)<br>}</code> |
| datetimeFormatter | Custom function to format a date into a string | (date: Date) =&gt; string | - | <div><small>From <b>config</b>:</small></div><code style='white-space: nowrap; padding: 0;'>datetimepicker: {<br>&nbsp;&nbsp;dateFormatter: defaultFunction<br>}</code> |
| datetimeParser | Custom function to parse a string into a date | (date: string) =&gt; Date | - | <div><small>From <b>config</b>:</small></div><code style='white-space: nowrap; padding: 0;'>datetimepicker: {<br>&nbsp;&nbsp;dateParser: defaultFunction<br>}</code> |
| datetimeFormatter | Custom function to format a date into a string | (date: Date) =&gt; string | - | <div><small>From <b>config</b>:</small></div><code style='white-space: nowrap; padding: 0;'>datetimepicker: {<br>&nbsp;&nbsp;dateFormatter: (\_) => undefined<br>}</code> |
| datetimeParser | Custom function to parse a string into a date | (date: string) =&gt; Date | - | <div><small>From <b>config</b>:</small></div><code style='white-space: nowrap; padding: 0;'>datetimepicker: {<br>&nbsp;&nbsp;dateParser: (\_) => undefined<br>}</code> |
| disabled | Same as native disabled | boolean | - | <code style='white-space: nowrap; padding: 0;'>false</code> |
| expanded | | boolean | - | <code style='white-space: nowrap; padding: 0;'>false</code> |
| icon | Icon to be shown | string | - | <div><small>From <b>config</b>:</small></div><code style='white-space: nowrap; padding: 0;'>datetimepicker: {<br>&nbsp;&nbsp;icon: undefined<br>}</code> |
Expand Down
12 changes: 4 additions & 8 deletions packages/oruga/src/components/timepicker/Timepicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,7 @@ import OPickerWrapper from "../utils/PickerWrapper.vue";
import { getOption } from "@/utils/config";
import { isDate, pad } from "@/utils/helpers";
import {
defineClasses,
useMatchMedia,
getActiveClasses,
// useVModel,
} from "@/composables";
import { defineClasses, useMatchMedia, getActiveClasses } from "@/composables";
import { useTimepickerMixins } from "./useTimepickerMixins";
Expand Down Expand Up @@ -582,7 +577,7 @@ function updateDateSelected(
/** Format date into string */
function format(value: Date | Date[], isNative: boolean): string {
if (Array.isArray(value)) value = value[0];
if (Array.isArray(value)) return format(value[0], isNative);
if (isNative) return formatNative(value);
// call prop function
Expand All @@ -594,7 +589,8 @@ function format(value: Date | Date[], isNative: boolean): string {
/** Format date into string 'HH-MM-SS'*/
function formatNative(value: Date | Date[]): string {
if (Array.isArray(value)) value = value[0];
if (Array.isArray(value)) return formatNative(value[0]);
const date = new Date(value);
// return null if no value is given or value can't parse to proper date
if (!value || !date || isNaN(date.getTime())) return null;
Expand Down
2 changes: 1 addition & 1 deletion packages/oruga/src/components/utils/PickerWrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const props = defineProps({
min: { type: Date, default: undefined },
max: { type: Date, default: undefined },
stayOpen: { type: Boolean, default: false },
// the DateTimeFormat object to watch for to update the parsed input value
/** the DateTimeFormat object to watch for to update the parsed input value */
dtf: { type: Object, default: undefined },
rootClasses: { type: Array as PropType<ClassBind[]>, required: true },
dropdownClasses: { type: Array as PropType<ClassBind[]>, required: true },
Expand Down

0 comments on commit 9bdb77d

Please sign in to comment.