1.0.9 • Published 7 years ago

vue-date-text v1.0.9

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

Vue-Date-Text

A date-text Vue component. Compatible with Vue 2.x

Statement

Modify by vuejs-datepicker

Install

$ npm install vue-date-text --save
import DateText from 'vue-date-text';

Vue.component('my-component', {
    components: {
        DateText
    }
});

Usage

<datetext></datetext>

default-value prop if passed should be a Date object

<script>
var state = {
    date: new Date(2016, 9,  16)
}
</script>
<datetext :default-value="state.date"></datetext>

Use v-model for two-way binding

<datetext v-model="state.date" name="uniquename"></datetext>

Use dateText if you want only this date can select use prop :disabled="true"

<script>
var dateText: [
    {
      date: '2017-07-10',
      text: 'only 5 seat'
    },
    {
      date: '2017-07-11',
      text: 'only 6 seat'
    }
]
methods: {
    validate (day) {
      if (day.text && day.text.split(' ')[1] < 6) {
        console.log('not enough seat')
        return false
      }
      return true
    }
}
</script>
<datetext :dateText="dateText" :validate="validate"></datetext>

Emits events

<datetext v-on:selected="doSomethingInParentComponentFunction" v-on:opened="datepickerOpenedFunction" v-on:closed="datepickerClosedFunction"></datetext>

Inline always open version

<datetext :inline="true"></datetext>

Available props

PropTypeDefaultDescription
default-valueDate|StringDate value of the datepicker
formatStringdd MMM yyyyDate formatting string
languageStringenTranslation for days and months
calendar-classString|ObjectCSS class applied to the calendar el
wrapper-classString|ObjectCSS class applied to the outer div
monday-firstBooleanfalseTo start the week on Monday
clear-buttonBooleanfalseShow an icon for clearing the date
clear-button-iconStringUse icon for button (ex: fa fa-times)
calendar-buttonBooleanfalseShow an icon that that can be clicked
calendar-button-iconStringUse icon for button (ex: fa fa-calendar)
bootstrapStylingBooleanfalseOutput bootstrap styling classes
initial-viewString'day'If 'month' or 'year', open on that view
dateTextArraySets text for date [{date: StringDate}, text: String]
validateFunction() => truevalidata the text for that date
closeOnClickModalBooleantrueclose datepicker when click modal
is-fixedBooleantruefixed the datepicker

Events

These events are emitted on actions in the datepicker

EventOutputDescription
openedThe picker is opened
closedThe picker is closed
selectedDate|nullA date has been selected
inputDate|nullInput value has been modified
clearedSelected date has been cleared
changedMonthObjectMonth page has been changed
changedYearObjectYear page has been changed
changedDecadeObjectDecade page has been changed

Date formatting

NB. This is not very robust at all - use at your own risk! Needs a better implementation. default 'yyyy-MM-dd'

TokenDescExample
dday1
dd0 prefixed day01
Dabbr dayMon
sudate suffixst, nd, rd
Mmonth number (1 based)1 (for Jan)
MM0 prefixed month01
MMMabbreviated month nameJan
MMMMmonth nameJanuary
yytwo digit year16
yyyyfour digit year2016

Disabled Dates

Dates can disabled in a number of ways.

<script>
var state = {
    disabled: {
        to: new Date(2016, 0, 5), // Disable all dates up to specific date
        from: new Date(2016, 0, 26), // Disable all dates after specific date
        days: [6, 0], // Disable Saturday's and Sunday's
        dates: [ // Disable an array of dates
            new Date(2016, 9, 16),
            new Date(2016, 9, 17),
            new Date(2016, 9, 18)
        ]
    }
}
</script>
<datetext :disabled="state.disabled"></datetext>

Highlight Dates

Dates can be highlighted (e.g. for marking an appointment) in a number of ways. Important: You can only highlight dates, that aren't disabled. Note: Both to and from properties are require to define a range of dates to highlight

<script>
var state = {
    highlighted: {
        to: new Date(2016, 0, 5), // Highlight all dates up to specific date
        from: new Date(2016, 0, 26), // Highlight all dates after specific date
        days: [6, 0], // Highlight Saturday's and Sunday's
        dates: [ // Highlight an array of dates
            new Date(2016, 9, 16),
            new Date(2016, 9, 17),
            new Date(2016, 9, 18)
        ]
    }
}
</script>
<datetext :highlighted="state.highlighted"></datetext>

Translations

Contributing guide - please use appropriate code from this list as the translation property.

<datetext language="es"></datetext>

Available languages

AbbrLanguage
arArabic
bgBulgarian
bsBosnian
csCzech
daDanish
deGerman
eeEstonian
enEnglish
esSpanish
fiFinnish
frFrench
heHebrew
huHungarian
hrCroatian
idIndonesian
isIcelandic
itItalian
jaJapanese
koKorean
ltLithuanian
nb-noNorwegian Bokmål
nlDutch
plPolish
pt-brPortuguese-Brazil
roRomanian
ruRussian
skSlovak
sl-siSlovenian
svSwedish
thThai
trTurkish
ukUkrainian
viVietnamese
zhChineseDefault
1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago