0.4.1 • Published 2 years ago

@dpa-id-components/ui-month-year-picker v0.4.1

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

@dpa-id-components/ui-month-year-picker

UiMonthYearPicker Vue 2.x UI component to select the month and year of a Date, based on the dpa Design Kit

Installation

yarn add @dpa-id-components/ui-month-year-picker

Usage

<!-- SomeComponent.vue using UiMonthYearPicker-->
<template>
  <ui-month-year-picker v-model="internalDate">
    <ui-button rounded size="small" slot="monthSelectorSlot">
      {{ formatDate(internalDate) }}
    </ui-button>
  </ui-month-year-picker>
</template>

<script>
  import UiMonthYearPicker from "@dpa-id-components/ui-month-year-picker";
  import UiButton from "@dpa-id-components/ui-button";
  import { format, parseISO } from "date-fns";
  import { de } from "date-fns/locale";

  export default {
    components: { UiMonthYearPicker, UiButton },
    data: () => ({
      internalDate: parseISO("2022-02-01T00:00:00.000Z"),
    }),
    methods: {
      formatDate: (date) => {
        const DATE_FORMAT_STR = "MMMM yyyy";
        if (date) {
          return `${format(date, DATE_FORMAT_STR, { locale: de })}`;
        }
        return "";
      },
    },
  };
</script>

Demo

View a demo of <ui-month-year-picker> on Storybook

API

Props

NameTypeRequiredDescription
valueDatetrueThe pickers's Date object value recieving
localeStringfalse ("de")Either "de" or "en"

Events

NameTypeDescription
inputDateEmitted when the user selects a month and/or year from the picker and clicks "apply"
toggleBooleanEmittes the opened or closed state whenever the user clicks on the picker's activator
0.3.0

2 years ago

0.4.1

2 years ago

0.2.3

2 years ago

0.4.0

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago