diff --git a/demo/src/app/components/+datepicker/datepicker-section.component.ts b/demo/src/app/components/+datepicker/datepicker-section.component.ts index a32c8320e9..8b69d7f72c 100644 --- a/demo/src/app/components/+datepicker/datepicker-section.component.ts +++ b/demo/src/app/components/+datepicker/datepicker-section.component.ts @@ -7,57 +7,66 @@ let titleDoc = require('html-loader!markdown-loader!./docs/title.md'); @Component({ selector: 'datepicker-section', template: ` - -

Datepicker is a highly configurable component that adds datepicker functionality to your pages. You can customize the date format and language, restrict the selectable date ranges.

+ +

Datepicker is a highly configurable component that adds datepicker functionality to your pages. You can + customize the date format and language, restrict the selectable date ranges.

-

Contents

- + +

Usage

+ +

+ +

Examples

+ + +

BsDatepickerModule is activily developed but you can use it already

+

Notebale change is additional css for it "/datepicker/bs-datepicker.css"

+

In nearest time will be added:

+
    +
  • 1. Month and year selection
  • +
  • 2. Min/max dates restrcitions
  • +
  • 3. Color theming
  • +
  • 4. Options to replace any part of template
  • +
  • 5. Configuration
  • +
  • 6. Integration with forms, only for input fields
  • +
  • etc.
  • +
+ +
+ + + + -

Usage

- -

- -

Examples

- - -

BsDatepickerModule is activily developed but you can use it already

-

Notebale change is additional css for it "/datepicker/bs-datepicker.css"

-

In nearest time will be added:

-
    -
  • 1. Month and year selection
  • -
  • 2. Min/max dates restrcitions
  • -
  • 3. Theming - this will be a small breaking change
  • -
  • 4. Options to replace any part of template
  • -
  • 5. Configuration
  • -
  • 6. Integration with forms, only for input fields
  • -
  • etc.
  • -
- -
- - - - - -

API Reference

- -
` + + + + + + + + +

API Reference

+ +
` }) export class DatepickerSectionComponent { - public name:string = 'Datepicker'; - public src:string = 'https://github.com/valor-software/ngx-bootstrap/tree/development/src/datepicker'; + public name: string = 'Datepicker'; + public src: string = 'https://github.com/valor-software/ngx-bootstrap/tree/development/src/datepicker'; public demos: any = DEMOS; - public titleDoc:string = titleDoc; + public titleDoc: string = titleDoc; } diff --git a/demo/src/app/components/+datepicker/demo-datepicker.module.ts b/demo/src/app/components/+datepicker/demo-datepicker.module.ts index f0d5d18b84..a8f0e8adb0 100644 --- a/demo/src/app/components/+datepicker/demo-datepicker.module.ts +++ b/demo/src/app/components/+datepicker/demo-datepicker.module.ts @@ -8,15 +8,24 @@ import { SharedModule } from '../../shared'; import { DatepickerSectionComponent } from './datepicker-section.component'; import { DEMO_COMPONENTS } from './demos'; import { routes } from './demo-datepicker.routes'; -import { DemoDatePickerPopupComponent } from './demos/bs-popup/date-picker-popup'; + +import { defineLocale, getSetGlobalLocale } from 'ngx-bootstrap/bs-moment'; +import { + ar, de, enGb, es, esDo, esUs, fr, hi, it, ja, ko, nl, nlBe, pl, ptBr, ru, zhCn +} from 'ngx-bootstrap/locale'; + +const locales = [ar, de, enGb, es, esDo, esUs, fr, hi, it, ja, ko, nl, nlBe, pl, ptBr, ru, zhCn]; + +locales.forEach(locale => defineLocale(locale.abbr, locale)); + +getSetGlobalLocale('en'); @NgModule({ - declarations:[ - DemoDatePickerPopupComponent, + declarations: [ DatepickerSectionComponent, ...DEMO_COMPONENTS ], - imports:[ + imports: [ DatepickerModule.forRoot(), BsDatepickerModule.forRoot(), CommonModule, diff --git a/demo/src/app/components/+datepicker/demos/change-locale/change-locale.html b/demo/src/app/components/+datepicker/demos/change-locale/change-locale.html new file mode 100644 index 0000000000..cce1fec060 --- /dev/null +++ b/demo/src/app/components/+datepicker/demos/change-locale/change-locale.html @@ -0,0 +1,33 @@ +
+
+ +
+ +
+
+ +
+
+ +
+ +
+ diff --git a/demo/src/app/components/+datepicker/demos/change-locale/change-locale.ts b/demo/src/app/components/+datepicker/demos/change-locale/change-locale.ts new file mode 100644 index 0000000000..b2bbfdbd20 --- /dev/null +++ b/demo/src/app/components/+datepicker/demos/change-locale/change-locale.ts @@ -0,0 +1,23 @@ +import { Component } from '@angular/core'; +import { BsDatepickerConfig } from 'ngx-bootstrap/datepicker'; +import { listLocales } from 'ngx-bootstrap/bs-moment'; + +@Component({ + selector: 'demo-datepicker-change-locale', + templateUrl: './change-locale.html' +}) +export class DemoDatepickerChangeLocaleComponent { + locale = 'en'; + locales = listLocales(); + bsConfig: Partial; + + applyLocale(pop: any) { + // create new object on each property change + // so Angular can catch object reference change + this.bsConfig = Object.assign({}, {locale: this.locale}); + setTimeout(() => { + pop.hide(); + pop.show(); + }); + } +} diff --git a/demo/src/app/components/+datepicker/demos/color-theming/color-theming.html b/demo/src/app/components/+datepicker/demos/color-theming/color-theming.html new file mode 100644 index 0000000000..76c5345de3 --- /dev/null +++ b/demo/src/app/components/+datepicker/demos/color-theming/color-theming.html @@ -0,0 +1,47 @@ +
+
+ +
+
+ +
+
+
+ +
+
+ +
+
+ +
+
+ diff --git a/demo/src/app/components/+datepicker/demos/color-theming/color-theming.ts b/demo/src/app/components/+datepicker/demos/color-theming/color-theming.ts new file mode 100644 index 0000000000..c4cbb92cbe --- /dev/null +++ b/demo/src/app/components/+datepicker/demos/color-theming/color-theming.ts @@ -0,0 +1,21 @@ +import { Component } from '@angular/core'; +import { BsDatepickerConfig } from 'ngx-bootstrap/datepicker'; + +@Component({ + selector: 'demo-datepicker-color-theming', + templateUrl: './color-theming.html' +}) +export class DemoDatepickerColorThemingComponent { + colorTheme = 'theme-green'; + + bsConfig: Partial; + + applyTheme(pop: any) { + // create new object on each property change + // so Angular can catch object reference change + this.bsConfig = Object.assign({}, {containerClass: this.colorTheme}); + setTimeout(() => { + pop.show(); + }); + } +} diff --git a/demo/src/app/components/+datepicker/demos/index.ts b/demo/src/app/components/+datepicker/demos/index.ts index 17a76d259c..8695e4193b 100644 --- a/demo/src/app/components/+datepicker/demos/index.ts +++ b/demo/src/app/components/+datepicker/demos/index.ts @@ -1,7 +1,13 @@ import { DatepickerDemoComponent } from './datepicker-demo.component'; +import { DemoDatePickerPopupComponent } from './bs-popup/date-picker-popup'; +import { DemoDatepickerColorThemingComponent } from './color-theming/color-theming'; +import { DemoDatepickerChangeLocaleComponent } from './change-locale/change-locale'; export const DEMO_COMPONENTS = [ - DatepickerDemoComponent + DatepickerDemoComponent, + DemoDatePickerPopupComponent, + DemoDatepickerColorThemingComponent, + DemoDatepickerChangeLocaleComponent ]; export const DEMOS = { @@ -12,5 +18,13 @@ export const DEMOS = { pop: { component: require('!!raw-loader?lang=typescript!./bs-popup/date-picker-popup.ts'), html: require('!!raw-loader?lang=markup!./bs-popup/date-picker-popup.html') + }, + colorTheming: { + component: require('!!raw-loader?lang=typescript!./color-theming/color-theming.ts'), + html: require('!!raw-loader?lang=markup!./color-theming/color-theming.html') + }, + changeLocale: { + component: require('!!raw-loader?lang=typescript!./change-locale/change-locale.ts'), + html: require('!!raw-loader?lang=markup!./change-locale/change-locale.html') } }; diff --git a/src/bs-moment/format.ts b/src/bs-moment/format.ts index 8a6c8221d2..335490c3ba 100644 --- a/src/bs-moment/format.ts +++ b/src/bs-moment/format.ts @@ -13,7 +13,11 @@ import { isDateValid } from './utils/type-checks'; export function formatDate(date: Date, format: string, locale = 'en'): string { const _locale = getLocale(locale); + if (!_locale) { + throw new Error(`Locale "${locale}" is not defined, please add it with "defineLocale(...)"`); + } const output = formatMoment(date, format, _locale); + return _locale.postformat(output); } diff --git a/src/bs-moment/i18n/de.ts b/src/bs-moment/i18n/de.ts new file mode 100644 index 0000000000..7e2abcda10 --- /dev/null +++ b/src/bs-moment/i18n/de.ts @@ -0,0 +1,72 @@ +// moment.js locale configuration +// locale : German [de] +// author : lluchs : https://github.com/lluchs +// author: Menelion Elensúle: https://github.com/Oire +// author : Mikolaj Dadela : https://github.com/mik01aj + +import { LocaleData } from '../locale/locale.class'; + +function processRelativeTime(num: number, withoutSuffix: boolean, key: string, isFuture: boolean): string { + const str = num.toString(); + + const format: any = { + m: ['eine Minute', 'einer Minute'], + h: ['eine Stunde', 'einer Stunde'], + d: ['ein Tag', 'einem Tag'], + dd: [`${str} Tage`, `${str} Tagen`], + M: ['ein Monat', 'einem Monat'], + MM: [`${str} Monate`, `${str} Monaten`], + y: ['ein Jahr', 'einem Jahr'], + yy: [`${str} Jahre`, `${str} Jahren`] + }; + + return withoutSuffix ? format[key][0] : format[key][1]; +} + +export const de: LocaleData = { + abbr: 'de', + months: 'Januar_Februar_März_April_Mai_Juni_Juli_August_September_Oktober_November_Dezember'.split('_'), + monthsShort: 'Jan._Feb._März_Apr._Mai_Juni_Juli_Aug._Sep._Okt._Nov._Dez.'.split('_'), + monthsParseExact: true, + weekdays: 'Sonntag_Montag_Dienstag_Mittwoch_Donnerstag_Freitag_Samstag'.split('_'), + weekdaysShort: 'So._Mo._Di._Mi._Do._Fr._Sa.'.split('_'), + weekdaysMin: 'So_Mo_Di_Mi_Do_Fr_Sa'.split('_'), + weekdaysParseExact: true, + longDateFormat: { + LT: 'HH:mm', + LTS: 'HH:mm:ss', + L: 'DD.MM.YYYY', + LL: 'D. MMMM YYYY', + LLL: 'D. MMMM YYYY HH:mm', + LLLL: 'dddd, D. MMMM YYYY HH:mm' + }, + calendar: { + sameDay: '[heute um] LT [Uhr]', + sameElse: 'L', + nextDay: '[morgen um] LT [Uhr]', + nextWeek: 'dddd [um] LT [Uhr]', + lastDay: '[gestern um] LT [Uhr]', + lastWeek: '[letzten] dddd [um] LT [Uhr]' + }, + relativeTime: { + future: 'in %s', + past: 'vor %s', + s: 'ein paar Sekunden', + m: processRelativeTime, + mm: '%d Minuten', + h: processRelativeTime, + hh: '%d Stunden', + d: processRelativeTime, + dd: processRelativeTime, + M: processRelativeTime, + MM: processRelativeTime, + y: processRelativeTime, + yy: processRelativeTime + }, + dayOfMonthOrdinalParse: /\d{1,2}\./, + ordinal(num: number, token?: string): string { return `${num}.`; }, + week: { + dow: 1, // Monday is the first day of the week. + doy: 4 // The week that contains Jan 4th is the first week of the year. + } +}; diff --git a/src/bs-moment/i18n/en-gb.ts b/src/bs-moment/i18n/en-gb.ts new file mode 100644 index 0000000000..cbbd10c86f --- /dev/null +++ b/src/bs-moment/i18n/en-gb.ts @@ -0,0 +1,63 @@ +// moment.js locale configuration +// locale : English (United Kingdom) [en-gb] +// author : Chris Gedrim : https://github.com/chrisgedrim + +import { LocaleData } from '../locale/locale.class'; + +export const enGb: LocaleData = { + abbr: 'en-gb', + months: 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'), + monthsShort: 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'), + weekdays: 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'), + weekdaysShort: 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'), + weekdaysMin: 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'), + longDateFormat: { + LT: 'HH:mm', + LTS: 'HH:mm:ss', + L: 'DD/MM/YYYY', + LL: 'D MMMM YYYY', + LLL: 'D MMMM YYYY HH:mm', + LLLL: 'dddd, D MMMM YYYY HH:mm' + }, + calendar: { + sameDay: '[Today at] LT', + nextDay: '[Tomorrow at] LT', + nextWeek: 'dddd [at] LT', + lastDay: '[Yesterday at] LT', + lastWeek: '[Last] dddd [at] LT', + sameElse: 'L' + }, + relativeTime: { + future: 'in %s', + past: '%s ago', + s: 'a few seconds', + m: 'a minute', + mm: '%d minutes', + h: 'an hour', + hh: '%d hours', + d: 'a day', + dd: '%d days', + M: 'a month', + MM: '%d months', + y: 'a year', + yy: '%d years' + }, + dayOfMonthOrdinalParse: /\d{1,2}(st|nd|rd|th)/, + ordinal(num) { + const b = num % 10; + const output = (~~(num % 100 / 10) === 1) + ? 'th' + : (b === 1) + ? 'st' + : (b === 2) + ? 'nd' + : (b === 3) + ? 'rd' : 'th'; + + return num + output; + }, + week: { + dow: 1, // Monday is the first day of the week. + doy: 4 // The week that contains Jan 4th is the first week of the year. + } +}; diff --git a/src/bs-moment/i18n/es-do.ts b/src/bs-moment/i18n/es-do.ts new file mode 100644 index 0000000000..f15f97138e --- /dev/null +++ b/src/bs-moment/i18n/es-do.ts @@ -0,0 +1,65 @@ +// moment.js locale configuration +// locale : Spanish (Dominican Republic) [es-do] + +import { LocaleData } from '../locale/locale.class'; + +// const monthsShortDot = 'ene._feb._mar._abr._may._jun._jul._ago._sep._oct._nov._dic.'.split('_'); +const monthsShort = 'ene_feb_mar_abr_may_jun_jul_ago_sep_oct_nov_dic'.split('_'); + +const monthsParse = [/^ene/i, /^feb/i, /^mar/i, /^abr/i, /^may/i, /^jun/i, /^jul/i, /^ago/i, /^sep/i, /^oct/i, /^nov/i, /^dic/i]; +const monthsRegex = /^(enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|octubre|noviembre|diciembre|ene\.?|feb\.?|mar\.?|abr\.?|may\.?|jun\.?|jul\.?|ago\.?|sep\.?|oct\.?|nov\.?|dic\.?)/i; + +export const esDo: LocaleData = { + abbr: 'es-do', + months: 'enero_febrero_marzo_abril_mayo_junio_julio_agosto_septiembre_octubre_noviembre_diciembre'.split('_'), + monthsShort, + // monthsShort(date: Date, format: string): string { + // if (!date) { + // return monthsShortDot; + // } else if (/-MMM-/.test(format)) { + // return monthsShort[getMonth(date)]; + // } else { + // return monthsShortDot[getMonth(date)]; + // } + // }, + monthsRegex, + monthsShortRegex: monthsRegex, + monthsStrictRegex: /^(enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|octubre|noviembre|diciembre)/i, + monthsShortStrictRegex: /^(ene\.?|feb\.?|mar\.?|abr\.?|may\.?|jun\.?|jul\.?|ago\.?|sep\.?|oct\.?|nov\.?|dic\.?)/i, + monthsParse, + longMonthsParse: monthsParse, + shortMonthsParse: monthsParse, + weekdays: 'domingo_lunes_martes_miércoles_jueves_viernes_sábado'.split('_'), + weekdaysShort: 'dom._lun._mar._mié._jue._vie._sáb.'.split('_'), + weekdaysMin: 'do_lu_ma_mi_ju_vi_sá'.split('_'), + weekdaysParseExact: true, + longDateFormat: { + LT: 'h:mm A', + LTS: 'h:mm:ss A', + L: 'DD/MM/YYYY', + LL: 'D [de] MMMM [de] YYYY', + LLL: 'D [de] MMMM [de] YYYY h:mm A', + LLLL: 'dddd, D [de] MMMM [de] YYYY h:mm A' + }, + relativeTime: { + future: 'en %s', + past: 'hace %s', + s: 'unos segundos', + m: 'un minuto', + mm: '%d minutos', + h: 'una hora', + hh: '%d horas', + d: 'un día', + dd: '%d días', + M: 'un mes', + MM: '%d meses', + y: 'un año', + yy: '%d años' + }, + dayOfMonthOrdinalParse: /\d{1,2}º/, + ordinal(num: number): string { return `${num}º`; }, + week: { + dow: 1, // Monday is the first day of the week. + doy: 4 // The week that contains Jan 4th is the first week of the year. + } +}; diff --git a/src/bs-moment/i18n/es-us.ts b/src/bs-moment/i18n/es-us.ts new file mode 100644 index 0000000000..7d73b50543 --- /dev/null +++ b/src/bs-moment/i18n/es-us.ts @@ -0,0 +1,57 @@ +// moment.js locale configuration +// locale : Spanish(United State) [es-us] +// author : bustta : https://github.com/bustta + +import { LocaleData } from '../locale/locale.class'; + +// const monthsShortDot = 'ene._feb._mar._abr._may._jun._jul._ago._sep._oct._nov._dic.'.split('_'); +const monthsShort = 'ene_feb_mar_abr_may_jun_jul_ago_sep_oct_nov_dic'.split('_'); + +export const esUs: LocaleData = { + abbr: 'es-us', + months: 'enero_febrero_marzo_abril_mayo_junio_julio_agosto_septiembre_octubre_noviembre_diciembre'.split('_'), + monthsShort, + // monthsShort(date: Date, format: string): string { + // if (!date) { + // return monthsShortDot; + // } else if (/-MMM-/.test(format)) { + // return monthsShort[getMonth(date)]; + // } else { + // return monthsShortDot[getMonth(date)]; + // } + // }, + monthsParseExact: true, + weekdays: 'domingo_lunes_martes_miércoles_jueves_viernes_sábado'.split('_'), + weekdaysShort: 'dom._lun._mar._mié._jue._vie._sáb.'.split('_'), + weekdaysMin: 'do_lu_ma_mi_ju_vi_sá'.split('_'), + weekdaysParseExact: true, + longDateFormat: { + LT: 'H:mm', + LTS: 'H:mm:ss', + L: 'MM/DD/YYYY', + LL: 'MMMM [de] D [de] YYYY', + LLL: 'MMMM [de] D [de] YYYY H:mm', + LLLL: 'dddd, MMMM [de] D [de] YYYY H:mm' + }, + relativeTime: { + future: 'en %s', + past: 'hace %s', + s: 'unos segundos', + m: 'un minuto', + mm: '%d minutos', + h: 'una hora', + hh: '%d horas', + d: 'un día', + dd: '%d días', + M: 'un mes', + MM: '%d meses', + y: 'un año', + yy: '%d años' + }, + dayOfMonthOrdinalParse: /\d{1,2}º/, + ordinal(num: number): string { return `${num}º`; }, + week: { + dow: 0, // Sunday is the first day of the week. + doy: 6 // The week that contains Jan 1st is the first week of the year. + } +}; diff --git a/src/bs-moment/i18n/es.ts b/src/bs-moment/i18n/es.ts new file mode 100644 index 0000000000..aa8e3db994 --- /dev/null +++ b/src/bs-moment/i18n/es.ts @@ -0,0 +1,66 @@ +// moment.js locale configuration +// locale : Spanish [es] +// author : Julio Napurí : https://github.com/julionc + +import { LocaleData } from '../locale/locale.class'; + +// const monthsShortDot = 'ene._feb._mar._abr._may._jun._jul._ago._sep._oct._nov._dic.'.split('_'); +const monthsShort = 'ene_feb_mar_abr_may_jun_jul_ago_sep_oct_nov_dic'.split('_'); + +const monthsParse = [/^ene/i, /^feb/i, /^mar/i, /^abr/i, /^may/i, /^jun/i, /^jul/i, /^ago/i, /^sep/i, /^oct/i, /^nov/i, /^dic/i]; +const monthsRegex = /^(enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|octubre|noviembre|diciembre|ene\.?|feb\.?|mar\.?|abr\.?|may\.?|jun\.?|jul\.?|ago\.?|sep\.?|oct\.?|nov\.?|dic\.?)/i; + +export const es: LocaleData = { + abbr: 'es', + months: 'enero_febrero_marzo_abril_mayo_junio_julio_agosto_septiembre_octubre_noviembre_diciembre'.split('_'), + // monthsShort(date: Date, format: string): string { + // if (!date) { + // return monthsShortDot; + // } else if (/-MMM-/.test(format)) { + // return monthsShort[getMonth(date)]; + // } else { + // return monthsShortDot[getMonth(date)]; + // } + // }, + monthsShort, + monthsRegex, + monthsShortRegex: monthsRegex, + monthsStrictRegex: /^(enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|octubre|noviembre|diciembre)/i, + monthsShortStrictRegex: /^(ene\.?|feb\.?|mar\.?|abr\.?|may\.?|jun\.?|jul\.?|ago\.?|sep\.?|oct\.?|nov\.?|dic\.?)/i, + monthsParse, + longMonthsParse: monthsParse, + shortMonthsParse: monthsParse, + weekdays: 'domingo_lunes_martes_miércoles_jueves_viernes_sábado'.split('_'), + weekdaysShort: 'dom._lun._mar._mié._jue._vie._sáb.'.split('_'), + weekdaysMin: 'do_lu_ma_mi_ju_vi_sá'.split('_'), + weekdaysParseExact: true, + longDateFormat: { + LT: 'H:mm', + LTS: 'H:mm:ss', + L: 'DD/MM/YYYY', + LL: 'D [de] MMMM [de] YYYY', + LLL: 'D [de] MMMM [de] YYYY H:mm', + LLLL: 'dddd, D [de] MMMM [de] YYYY H:mm' + }, + relativeTime: { + future: 'en %s', + past: 'hace %s', + s: 'unos segundos', + m: 'un minuto', + mm: '%d minutos', + h: 'una hora', + hh: '%d horas', + d: 'un día', + dd: '%d días', + M: 'un mes', + MM: '%d meses', + y: 'un año', + yy: '%d años' + }, + dayOfMonthOrdinalParse: /\d{1,2}º/, + ordinal(num: number): string { return `${num}º`; }, + week: { + dow: 1, // Monday is the first day of the week. + doy: 4 // The week that contains Jan 4th is the first week of the year. + } +}; diff --git a/src/bs-moment/i18n/fr.ts b/src/bs-moment/i18n/fr.ts new file mode 100644 index 0000000000..ee37bd534d --- /dev/null +++ b/src/bs-moment/i18n/fr.ts @@ -0,0 +1,75 @@ +// moment.js locale configuration +// locale : French [fr] +// author : John Fischer : https://github.com/jfroffice + +import { LocaleData } from '../locale/locale.class'; + +export const fr: LocaleData = { + abbr: 'fr', + months: 'janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre'.split('_'), + monthsShort: 'janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.'.split('_'), + monthsParseExact: true, + weekdays: 'dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi'.split('_'), + weekdaysShort: 'dim._lun._mar._mer._jeu._ven._sam.'.split('_'), + weekdaysMin: 'Di_Lu_Ma_Me_Je_Ve_Sa'.split('_'), + weekdaysParseExact: true, + longDateFormat: { + LT: 'HH:mm', + LTS: 'HH:mm:ss', + L: 'DD/MM/YYYY', + LL: 'D MMMM YYYY', + LLL: 'D MMMM YYYY HH:mm', + LLLL: 'dddd D MMMM YYYY HH:mm' + }, + calendar: { + sameDay: '[Aujourd’hui à] LT', + nextDay: '[Demain à] LT', + nextWeek: 'dddd [à] LT', + lastDay: '[Hier à] LT', + lastWeek: 'dddd [dernier à] LT', + sameElse: 'L' + }, + relativeTime: { + future: 'dans %s', + past: 'il y a %s', + s: 'quelques secondes', + m: 'une minute', + mm: '%d minutes', + h: 'une heure', + hh: '%d heures', + d: 'un jour', + dd: '%d jours', + M: 'un mois', + MM: '%d mois', + y: 'un an', + yy: '%d ans' + }, + dayOfMonthOrdinalParse: /\d{1,2}(er|)/, + ordinal(num: number, period: string) { + switch (period) { + // TODO: Return 'e' when day of month > 1. Move this case inside + // block for masculine words below. + // See https://github.com/moment/moment/issues/3375 + case 'D': + return num + (num === 1 ? 'er' : ''); + + // Words with masculine grammatical gender: mois, trimestre, jour + default: + case 'M': + case 'Q': + case 'DDD': + case 'd': + return num + (num === 1 ? 'er' : 'e'); + + // Words with feminine grammatical gender: semaine + case 'w': + case 'W': + return num + (num === 1 ? 're' : 'e'); + } + }, + week: { + dow: 1, // Monday is the first day of the week. + doy: 4 // The week that contains Jan 4th is the first week of the year. + } +}; + diff --git a/src/bs-moment/i18n/hi.ts b/src/bs-moment/i18n/hi.ts new file mode 100644 index 0000000000..36cce497e6 --- /dev/null +++ b/src/bs-moment/i18n/hi.ts @@ -0,0 +1,115 @@ +// moment.js locale configuration +// locale : Hindi [hi] +// author : Mayank Singhal : https://github.com/mayanksinghal + +import { LocaleData } from '../locale/locale.class'; + +const symbolMap: any = { + '1': '१', + '2': '२', + '3': '३', + '4': '४', + '5': '५', + '6': '६', + '7': '७', + '8': '८', + '9': '९', + '0': '०' +}; +const numberMap: any = { + '१': '1', + '२': '2', + '३': '3', + '४': '4', + '५': '5', + '६': '6', + '७': '7', + '८': '8', + '९': '9', + '०': '0' +}; + +export const hi: LocaleData = { + abbr: 'hi', + months: 'जनवरी_फ़रवरी_मार्च_अप्रैल_मई_जून_जुलाई_अगस्त_सितम्बर_अक्टूबर_नवम्बर_दिसम्बर'.split('_'), + monthsShort: 'जन._फ़र._मार्च_अप्रै._मई_जून_जुल._अग._सित._अक्टू._नव._दिस.'.split('_'), + monthsParseExact: true, + weekdays: 'रविवार_सोमवार_मंगलवार_बुधवार_गुरूवार_शुक्रवार_शनिवार'.split('_'), + weekdaysShort: 'रवि_सोम_मंगल_बुध_गुरू_शुक्र_शनि'.split('_'), + weekdaysMin: 'र_सो_मं_बु_गु_शु_श'.split('_'), + longDateFormat: { + LT: 'A h:mm बजे', + LTS: 'A h:mm:ss बजे', + L: 'DD/MM/YYYY', + LL: 'D MMMM YYYY', + LLL: 'D MMMM YYYY, A h:mm बजे', + LLLL: 'dddd, D MMMM YYYY, A h:mm बजे' + }, + calendar: { + sameDay: '[आज] LT', + nextDay: '[कल] LT', + nextWeek: 'dddd, LT', + lastDay: '[कल] LT', + lastWeek: '[पिछले] dddd, LT', + sameElse: 'L' + }, + relativeTime: { + future: '%s में', + past: '%s पहले', + s: 'कुछ ही क्षण', + m: 'एक मिनट', + mm: '%d मिनट', + h: 'एक घंटा', + hh: '%d घंटे', + d: 'एक दिन', + dd: '%d दिन', + M: 'एक महीने', + MM: '%d महीने', + y: 'एक वर्ष', + yy: '%d वर्ष' + }, + preparse(str: string): string { + return str.replace(/[१२३४५६७८९०]/g, function (match) { + return numberMap[match]; + }); + }, + postformat(str: string): string { + return str.replace(/\d/g, function (match) { + return symbolMap[match]; + }); + }, + // Hindi notation for meridiems are quite fuzzy in practice. While there exists + // a rigid notion of a 'Pahar' it is not used as rigidly in modern Hindi. + meridiemParse: /रात|सुबह|दोपहर|शाम/, + meridiemHour(hour: number, meridiem: string): number { + if (hour === 12) { + hour = 0; + } + if (meridiem === 'रात') { + return hour < 4 ? hour : hour + 12; + } else if (meridiem === 'सुबह') { + return hour; + } else if (meridiem === 'दोपहर') { + return hour >= 10 ? hour : hour + 12; + } else if (meridiem === 'शाम') { + return hour + 12; + } + }, + meridiem(hour: number): string { + if (hour < 4) { + return 'रात'; + } else if (hour < 10) { + return 'सुबह'; + } else if (hour < 17) { + return 'दोपहर'; + } else if (hour < 20) { + return 'शाम'; + } else { + return 'रात'; + } + }, + week: { + dow: 0, // Sunday is the first day of the week. + doy: 6 // The week that contains Jan 1st is the first week of the year. + } +}; diff --git a/src/bs-moment/i18n/it.ts b/src/bs-moment/i18n/it.ts new file mode 100644 index 0000000000..d2e56b2410 --- /dev/null +++ b/src/bs-moment/i18n/it.ts @@ -0,0 +1,30 @@ +// moment.js locale configuration +// locale : Italian [it] +// author : Lorenzo : https://github.com/aliem +// author: Mattia Larentis: https://github.com/nostalgiaz + +import { LocaleData } from '../locale/locale.class'; + +export const it: LocaleData = { + abbr: 'it', + months: 'gennaio_febbraio_marzo_aprile_maggio_giugno_luglio_agosto_settembre_ottobre_novembre_dicembre'.split('_'), + monthsShort: 'gen_feb_mar_apr_mag_giu_lug_ago_set_ott_nov_dic'.split('_'), + weekdays: 'domenica_lunedì_martedì_mercoledì_giovedì_venerdì_sabato'.split('_'), + weekdaysShort: 'dom_lun_mar_mer_gio_ven_sab'.split('_'), + weekdaysMin: 'do_lu_ma_me_gi_ve_sa'.split('_'), + longDateFormat: { + LT: 'HH:mm', + LTS: 'HH:mm:ss', + L: 'DD/MM/YYYY', + LL: 'D MMMM YYYY', + LLL: 'D MMMM YYYY HH:mm', + LLLL: 'dddd, D MMMM YYYY HH:mm' + }, + dayOfMonthOrdinalParse: /\d{1,2}º/, + ordinal(num: number): string { return `${num}º`; }, + week: { + dow: 1, // Monday is the first day of the week. + doy: 4 // The week that contains Jan 4th is the first week of the year. + } +}; + diff --git a/src/bs-moment/i18n/ja.ts b/src/bs-moment/i18n/ja.ts new file mode 100644 index 0000000000..3a93838574 --- /dev/null +++ b/src/bs-moment/i18n/ja.ts @@ -0,0 +1,67 @@ +// moment.js locale configuration +// locale : Japanese [ja] +// author : LI Long : https://github.com/baryon + +import { LocaleData } from '../locale/locale.class'; + +export const ja: LocaleData = { + abbr: 'ja', + months: '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split('_'), + monthsShort: '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split('_'), + weekdays: '日曜日_月曜日_火曜日_水曜日_木曜日_金曜日_土曜日'.split('_'), + weekdaysShort: '日_月_火_水_木_金_土'.split('_'), + weekdaysMin: '日_月_火_水_木_金_土'.split('_'), + longDateFormat: { + LT: 'HH:mm', + LTS: 'HH:mm:ss', + L: 'YYYY/MM/DD', + LL: 'YYYY年M月D日', + LLL: 'YYYY年M月D日 HH:mm', + LLLL: 'YYYY年M月D日 HH:mm dddd', + l: 'YYYY/MM/DD', + ll: 'YYYY年M月D日', + lll: 'YYYY年M月D日 HH:mm', + llll: 'YYYY年M月D日 HH:mm dddd' + }, + meridiemParse: /午前|午後/i, + isPM(input: string): boolean { + return input === '午後'; + }, + meridiem(hour: number): string { + return hour < 12 ? '午前' : '午後'; + }, + calendar: { + sameDay: '[今日] LT', + nextDay: '[明日] LT', + nextWeek: '[来週]dddd LT', + lastDay: '[昨日] LT', + lastWeek: '[前週]dddd LT', + sameElse: 'L' + }, + dayOfMonthOrdinalParse: /\d{1,2}日/, + ordinal(num: number, period: string): string { + switch (period) { + case 'd': + case 'D': + case 'DDD': + return `${num}日`; + default: + return num.toString(); + } + }, + relativeTime: { + future: '%s後', + past: '%s前', + s: '数秒', + m: '1分', + mm: '%d分', + h: '1時間', + hh: '%d時間', + d: '1日', + dd: '%d日', + M: '1ヶ月', + MM: '%dヶ月', + y: '1年', + yy: '%d年' + } +}; diff --git a/src/bs-moment/i18n/ko.ts b/src/bs-moment/i18n/ko.ts new file mode 100644 index 0000000000..df5a709929 --- /dev/null +++ b/src/bs-moment/i18n/ko.ts @@ -0,0 +1,74 @@ +// moment.js locale configuration +// locale : Korean [ko] +// author : Kyungwook, Park : https://github.com/kyungw00k +// author : Jeeeyul Lee + +import { LocaleData } from '../locale/locale.class'; + +export const ko: LocaleData = { + abbr: 'ko', + months: '1월_2월_3월_4월_5월_6월_7월_8월_9월_10월_11월_12월'.split('_'), + monthsShort: '1월_2월_3월_4월_5월_6월_7월_8월_9월_10월_11월_12월'.split('_'), + weekdays: '일요일_월요일_화요일_수요일_목요일_금요일_토요일'.split('_'), + weekdaysShort: '일_월_화_수_목_금_토'.split('_'), + weekdaysMin: '일_월_화_수_목_금_토'.split('_'), + longDateFormat: { + LT: 'A h:mm', + LTS: 'A h:mm:ss', + L: 'YYYY.MM.DD', + LL: 'YYYY년 MMMM D일', + LLL: 'YYYY년 MMMM D일 A h:mm', + LLLL: 'YYYY년 MMMM D일 dddd A h:mm', + l: 'YYYY.MM.DD', + ll: 'YYYY년 MMMM D일', + lll: 'YYYY년 MMMM D일 A h:mm', + llll: 'YYYY년 MMMM D일 dddd A h:mm' + }, + calendar: { + sameDay: '오늘 LT', + nextDay: '내일 LT', + nextWeek: 'dddd LT', + lastDay: '어제 LT', + lastWeek: '지난주 dddd LT', + sameElse: 'L' + }, + relativeTime: { + future: '%s 후', + past: '%s 전', + s: '몇 초', + ss: '%d초', + m: '1분', + mm: '%d분', + h: '한 시간', + hh: '%d시간', + d: '하루', + dd: '%d일', + M: '한 달', + MM: '%d달', + y: '일 년', + yy: '%d년' + }, + dayOfMonthOrdinalParse: /\d{1,2}(일|월|주)/, + ordinal(num: number, period: string): string { + switch (period) { + case 'd': + case 'D': + case 'DDD': + return `${num}일`; + case 'M': + return `${num}월`; + case 'w': + case 'W': + return `${num}주`; + default: + return num.toString(10); + } + }, + meridiemParse: /오전|오후/, + isPM(token: string): boolean { + return token === '오후'; + }, + meridiem(hour: number): string { + return hour < 12 ? '오전' : '오후'; + } +}; diff --git a/src/bs-moment/i18n/nl-be.ts b/src/bs-moment/i18n/nl-be.ts new file mode 100644 index 0000000000..c9c2de4f21 --- /dev/null +++ b/src/bs-moment/i18n/nl-be.ts @@ -0,0 +1,80 @@ +// moment.js locale configuration +// locale : Dutch (Belgium) [nl-be] +// author : Joris Röling : https://github.com/jorisroling +// author : Jacob Middag : https://github.com/middagj + +import { LocaleData } from '../locale/locale.class'; + +// const monthsShortWithDots = 'jan._feb._mrt._apr._mei_jun._jul._aug._sep._okt._nov._dec.'.split('_'); +const monthsShort = 'jan_feb_mrt_apr_mei_jun_jul_aug_sep_okt_nov_dec'.split('_'); + +const monthsParse = [/^jan/i, /^feb/i, /^maart|mrt.?$/i, /^apr/i, /^mei$/i, /^jun[i.]?$/i, /^jul[i.]?$/i, /^aug/i, /^sep/i, /^okt/i, /^nov/i, /^dec/i]; +const monthsRegex = /^(januari|februari|maart|april|mei|april|ju[nl]i|augustus|september|oktober|november|december|jan\.?|feb\.?|mrt\.?|apr\.?|ju[nl]\.?|aug\.?|sep\.?|okt\.?|nov\.?|dec\.?)/i; + +export const nlBe: LocaleData = { + abbr: 'nl-be', + months: 'januari_februari_maart_april_mei_juni_juli_augustus_september_oktober_november_december'.split('_'), + monthsShort, + // monthsShort(date: Date, format: string): string { + // if (!date) { + // return monthsShortWithDots; + // } else if (/-MMM-/.test(format)) { + // return monthsShortWithoutDots[getMonth(date)]; + // } else { + // return monthsShortWithDots[getMonth(date)]; + // } + // }, + + monthsRegex, + monthsShortRegex: monthsRegex, + monthsStrictRegex: /^(januari|februari|maart|mei|ju[nl]i|april|augustus|september|oktober|november|december)/i, + monthsShortStrictRegex: /^(jan\.?|feb\.?|mrt\.?|apr\.?|mei|ju[nl]\.?|aug\.?|sep\.?|okt\.?|nov\.?|dec\.?)/i, + + monthsParse, + longMonthsParse: monthsParse, + shortMonthsParse: monthsParse, + + weekdays: 'zondag_maandag_dinsdag_woensdag_donderdag_vrijdag_zaterdag'.split('_'), + weekdaysShort: 'zo._ma._di._wo._do._vr._za.'.split('_'), + weekdaysMin: 'zo_ma_di_wo_do_vr_za'.split('_'), + weekdaysParseExact: true, + longDateFormat: { + LT: 'HH:mm', + LTS: 'HH:mm:ss', + L: 'DD/MM/YYYY', + LL: 'D MMMM YYYY', + LLL: 'D MMMM YYYY HH:mm', + LLLL: 'dddd D MMMM YYYY HH:mm' + }, + calendar: { + sameDay: '[vandaag om] LT', + nextDay: '[morgen om] LT', + nextWeek: 'dddd [om] LT', + lastDay: '[gisteren om] LT', + lastWeek: '[afgelopen] dddd [om] LT', + sameElse: 'L' + }, + relativeTime: { + future: 'over %s', + past: '%s geleden', + s: 'een paar seconden', + m: 'één minuut', + mm: '%d minuten', + h: 'één uur', + hh: '%d uur', + d: 'één dag', + dd: '%d dagen', + M: 'één maand', + MM: '%d maanden', + y: 'één jaar', + yy: '%d jaar' + }, + dayOfMonthOrdinalParse: /\d{1,2}(ste|de)/, + ordinal(num: number): string { + return num + ((num === 1 || num === 8 || num >= 20) ? 'ste' : 'de'); + }, + week: { + dow: 1, // Monday is the first day of the week. + doy: 4 // The week that contains Jan 4th is the first week of the year. + } +}; diff --git a/src/bs-moment/i18n/nl.ts b/src/bs-moment/i18n/nl.ts new file mode 100644 index 0000000000..326da801d0 --- /dev/null +++ b/src/bs-moment/i18n/nl.ts @@ -0,0 +1,81 @@ +// moment.js locale configuration +// locale : Dutch [nl] +// author : Joris Röling : https://github.com/jorisroling +// author : Jacob Middag : https://github.com/middagj + +import { LocaleData } from '../locale/locale.class'; + +// const monthsShortWithDots = 'jan._feb._mrt._apr._mei_jun._jul._aug._sep._okt._nov._dec.'.split('_'); +const monthsShort = 'jan_feb_mrt_apr_mei_jun_jul_aug_sep_okt_nov_dec'.split('_'); + +const monthsParse = [/^jan/i, /^feb/i, /^maart|mrt.?$/i, /^apr/i, /^mei$/i, /^jun[i.]?$/i, /^jul[i.]?$/i, /^aug/i, /^sep/i, /^okt/i, /^nov/i, /^dec/i]; +const monthsRegex = /^(januari|februari|maart|april|mei|april|ju[nl]i|augustus|september|oktober|november|december|jan\.?|feb\.?|mrt\.?|apr\.?|ju[nl]\.?|aug\.?|sep\.?|okt\.?|nov\.?|dec\.?)/i; + +export const nl: LocaleData = { + abbr: 'nl', + months: 'januari_februari_maart_april_mei_juni_juli_augustus_september_oktober_november_december'.split('_'), + monthsShort, + // monthsShort(date: Date, format: string): string { + // if (!date) { + // return monthsShortWithDots; + // } else if (/-MMM-/.test(format)) { + // return monthsShortWithoutDots[getMonth(date)]; + // } else { + // return monthsShortWithDots[getMonth(date)]; + // } + // }, + + monthsRegex, + monthsShortRegex: monthsRegex, + monthsStrictRegex: /^(januari|februari|maart|mei|ju[nl]i|april|augustus|september|oktober|november|december)/i, + monthsShortStrictRegex: /^(jan\.?|feb\.?|mrt\.?|apr\.?|mei|ju[nl]\.?|aug\.?|sep\.?|okt\.?|nov\.?|dec\.?)/i, + + monthsParse, + longMonthsParse: monthsParse, + shortMonthsParse: monthsParse, + + weekdays: 'zondag_maandag_dinsdag_woensdag_donderdag_vrijdag_zaterdag'.split('_'), + weekdaysShort: 'zo._ma._di._wo._do._vr._za.'.split('_'), + weekdaysMin: 'zo_ma_di_wo_do_vr_za'.split('_'), + weekdaysParseExact: true, + longDateFormat: { + LT: 'HH:mm', + LTS: 'HH:mm:ss', + L: 'DD-MM-YYYY', + LL: 'D MMMM YYYY', + LLL: 'D MMMM YYYY HH:mm', + LLLL: 'dddd D MMMM YYYY HH:mm' + }, + calendar: { + sameDay: '[vandaag om] LT', + nextDay: '[morgen om] LT', + nextWeek: 'dddd [om] LT', + lastDay: '[gisteren om] LT', + lastWeek: '[afgelopen] dddd [om] LT', + sameElse: 'L' + }, + relativeTime: { + future: 'over %s', + past: '%s geleden', + s: 'een paar seconden', + m: 'één minuut', + mm: '%d minuten', + h: 'één uur', + hh: '%d uur', + d: 'één dag', + dd: '%d dagen', + M: 'één maand', + MM: '%d maanden', + y: 'één jaar', + yy: '%d jaar' + }, + dayOfMonthOrdinalParse: /\d{1,2}(ste|de)/, + ordinal(num: number): string { + return num + ((num === 1 || num === 8 || num >= 20) ? 'ste' : 'de'); + }, + week: { + dow: 1, // Monday is the first day of the week. + doy: 4 // The week that contains Jan 4th is the first week of the year. + } +}; + diff --git a/src/bs-moment/i18n/pl.ts b/src/bs-moment/i18n/pl.ts new file mode 100755 index 0000000000..073b784235 --- /dev/null +++ b/src/bs-moment/i18n/pl.ts @@ -0,0 +1,82 @@ +// moment.js locale configuration +// locale : Polish [pl] +// author : Rafal Hirsz : https://github.com/evoL + +import { LocaleData } from '../locale/locale.class'; + +const months = 'styczeń_luty_marzec_kwiecień_maj_czerwiec_lipiec_sierpień_wrzesień_październik_listopad_grudzień'.split('_'); +// const monthsSubjective = 'stycznia_lutego_marca_kwietnia_maja_czerwca_lipca_sierpnia_września_października_listopada_grudnia'.split('_'); + +function plural(n: number): boolean { + return (n % 10 < 5) && (n % 10 > 1) && ((~~(n / 10) % 10) !== 1); +} + +function translate(num: number, withoutSuffix: boolean, key: string): string { + const result = `${num} `; + switch (key) { + case 'm': + return withoutSuffix ? 'minuta' : 'minutę'; + case 'mm': + return result + (plural(num) ? 'minuty' : 'minut'); + case 'h': + return withoutSuffix ? 'godzina' : 'godzinę'; + case 'hh': + return result + (plural(num) ? 'godziny' : 'godzin'); + case 'MM': + return result + (plural(num) ? 'miesiące' : 'miesięcy'); + case 'yy': + return result + (plural(num) ? 'lata' : 'lat'); + } +} + +export const pl: LocaleData = { + abbr: 'pl', + months, + // months(date: Date, format: string): string { + // if (!date) { + // return monthsNominative; + // } else if (format === '') { + // Hack: if format empty we know this is used to generate + // RegExp by moment. Give then back both valid forms of months + // in RegExp ready format. + // return `(${monthsSubjective[getMonth(date)]}|${monthsNominative[getMonth(date)]})`; + // } else if (/D MMMM/.test(format)) { + // return monthsSubjective[getMonth(date)]; + // } else { + // return monthsNominative[getMonth(date)]; + // } + // }, + monthsShort: 'sty_lut_mar_kwi_maj_cze_lip_sie_wrz_paź_lis_gru'.split('_'), + weekdays: 'niedziela_poniedziałek_wtorek_środa_czwartek_piątek_sobota'.split('_'), + weekdaysShort: 'ndz_pon_wt_śr_czw_pt_sob'.split('_'), + weekdaysMin: 'Nd_Pn_Wt_Śr_Cz_Pt_So'.split('_'), + longDateFormat: { + LT: 'HH:mm', + LTS: 'HH:mm:ss', + L: 'DD.MM.YYYY', + LL: 'D MMMM YYYY', + LLL: 'D MMMM YYYY HH:mm', + LLLL: 'dddd, D MMMM YYYY HH:mm' + }, + relativeTime: { + future: 'za %s', + past: '%s temu', + s: 'kilka sekund', + m: translate, + mm: translate, + h: translate, + hh: translate, + d: '1 dzień', + dd: '%d dni', + M: 'miesiąc', + MM: translate, + y: 'rok', + yy: translate + }, + dayOfMonthOrdinalParse: /\d{1,2}\./, + ordinal(num: number): string { return `${num}.`; }, + week: { + dow: 1, // Monday is the first day of the week. + doy: 4 // The week that contains Jan 4th is the first week of the year. + } +}; diff --git a/src/bs-moment/i18n/pt-br.ts b/src/bs-moment/i18n/pt-br.ts new file mode 100644 index 0000000000..0844ca2f74 --- /dev/null +++ b/src/bs-moment/i18n/pt-br.ts @@ -0,0 +1,41 @@ +// moment.js locale configuration +// locale : Portuguese (Brazil) [pt-br] +// author : Caio Ribeiro Pereira : https://github.com/caio-ribeiro-pereira + +import { LocaleData } from '../locale/locale.class'; + +export const ptBr: LocaleData = { + abbr: 'pt-br', + months: 'janeiro_fevereiro_março_abril_maio_junho_julho_agosto_setembro_outubro_novembro_dezembro'.split('_'), + monthsShort: 'jan_fev_mar_abr_mai_jun_jul_ago_set_out_nov_dez'.split('_'), + weekdays: 'Domingo_Segunda-feira_Terça-feira_Quarta-feira_Quinta-feira_Sexta-feira_Sábado'.split('_'), + weekdaysShort: 'Dom_Seg_Ter_Qua_Qui_Sex_Sáb'.split('_'), + weekdaysMin: 'Do_2ª_3ª_4ª_5ª_6ª_Sá'.split('_'), + weekdaysParseExact: true, + longDateFormat: { + LT: 'HH:mm', + LTS: 'HH:mm:ss', + L: 'DD/MM/YYYY', + LL: 'D [de] MMMM [de] YYYY', + LLL: 'D [de] MMMM [de] YYYY [às] HH:mm', + LLLL: 'dddd, D [de] MMMM [de] YYYY [às] HH:mm' + }, + relativeTime: { + future: 'em %s', + past: '%s atrás', + s: 'poucos segundos', + ss: '%d segundos', + m: 'um minuto', + mm: '%d minutos', + h: 'uma hora', + hh: '%d horas', + d: 'um dia', + dd: '%d dias', + M: 'um mês', + MM: '%d meses', + y: 'um ano', + yy: '%d anos' + }, + dayOfMonthOrdinalParse: /\d{1,2}º/, + ordinal(num: number): string { return `${num}º`; } +}; diff --git a/src/bs-moment/i18n/ru.ts b/src/bs-moment/i18n/ru.ts new file mode 100644 index 0000000000..6db68a0a86 --- /dev/null +++ b/src/bs-moment/i18n/ru.ts @@ -0,0 +1,126 @@ +// moment.js locale configuration +// locale : Russian [ru] +// author : Viktorminator : https://github.com/Viktorminator +// Author : Menelion Elensúle : https://github.com/Oire +// author : Коренберг Марк : https://github.com/socketpair + +import { LocaleData } from '../locale/locale.class'; + +function plural(word: string, num: number): string { + const forms = word.split('_'); + + return num % 10 === 1 && num % 100 !== 11 ? forms[0] : (num % 10 >= 2 && num % 10 <= 4 && (num % 100 < 10 || num % 100 >= 20) ? forms[1] : forms[2]); +} + +function relativeTimeWithPlural(num: number, withoutSuffix: boolean, key: string): string { + const format: any = { + mm: withoutSuffix ? 'минута_минуты_минут' : 'минуту_минуты_минут', + hh: 'час_часа_часов', + dd: 'день_дня_дней', + MM: 'месяц_месяца_месяцев', + yy: 'год_года_лет' + }; + if (key === 'm') { + return withoutSuffix ? 'минута' : 'минуту'; + } else { + return `${num} ${plural(format[key], +num)}`; + } +} + +const monthsParse = [/^янв/i, /^фев/i, /^мар/i, /^апр/i, /^ма[йя]/i, /^июн/i, /^июл/i, /^авг/i, /^сен/i, /^окт/i, /^ноя/i, /^дек/i]; + +// http://new.gramota.ru/spravka/rules/139-prop : § 103 +// Сокращения месяцев: http://new.gramota.ru/spravka/buro/search-answer?s=242637 +// CLDR data: http://www.unicode.org/cldr/charts/28/summary/ru.html#1753 +export const ru: LocaleData = { + abbr: 'ru', + months: { + format: 'января_февраля_марта_апреля_мая_июня_июля_августа_сентября_октября_ноября_декабря'.split('_'), + standalone: 'январь_февраль_март_апрель_май_июнь_июль_август_сентябрь_октябрь_ноябрь_декабрь'.split('_') + }, + monthsShort: { + // по CLDR именно "июл." и "июн.", но какой смысл менять букву на точку ? + format: 'янв._февр._мар._апр._мая_июня_июля_авг._сент._окт._нояб._дек.'.split('_'), + standalone: 'янв._февр._март_апр._май_июнь_июль_авг._сент._окт._нояб._дек.'.split('_') + }, + weekdays: { + standalone: 'воскресенье_понедельник_вторник_среда_четверг_пятница_суббота'.split('_'), + format: 'воскресенье_понедельник_вторник_среду_четверг_пятницу_субботу'.split('_'), + isFormat: /\[ ?[Вв] ?(?:прошлую|следующую|эту)? ?\] ?dddd/ + }, + weekdaysShort: 'вс_пн_вт_ср_чт_пт_сб'.split('_'), + weekdaysMin: 'вс_пн_вт_ср_чт_пт_сб'.split('_'), + monthsParse, + longMonthsParse: monthsParse, + shortMonthsParse: monthsParse, + + // полные названия с падежами, по три буквы, для некоторых, по 4 буквы, сокращения с точкой и без точки + monthsRegex: /^(январ[ья]|янв\.?|феврал[ья]|февр?\.?|марта?|мар\.?|апрел[ья]|апр\.?|ма[йя]|июн[ья]|июн\.?|июл[ья]|июл\.?|августа?|авг\.?|сентябр[ья]|сент?\.?|октябр[ья]|окт\.?|ноябр[ья]|нояб?\.?|декабр[ья]|дек\.?)/i, + + // копия предыдущего + monthsShortRegex: /^(январ[ья]|янв\.?|феврал[ья]|февр?\.?|марта?|мар\.?|апрел[ья]|апр\.?|ма[йя]|июн[ья]|июн\.?|июл[ья]|июл\.?|августа?|авг\.?|сентябр[ья]|сент?\.?|октябр[ья]|окт\.?|ноябр[ья]|нояб?\.?|декабр[ья]|дек\.?)/i, + + // полные названия с падежами + monthsStrictRegex: /^(январ[яь]|феврал[яь]|марта?|апрел[яь]|ма[яй]|июн[яь]|июл[яь]|августа?|сентябр[яь]|октябр[яь]|ноябр[яь]|декабр[яь])/i, + + // Выражение, которое соотвествует только сокращённым формам + monthsShortStrictRegex: /^(янв\.|февр?\.|мар[т.]|апр\.|ма[яй]|июн[ья.]|июл[ья.]|авг\.|сент?\.|окт\.|нояб?\.|дек\.)/i, + longDateFormat: { + LT: 'HH:mm', + LTS: 'HH:mm:ss', + L: 'DD.MM.YYYY', + LL: 'D MMMM YYYY г.', + LLL: 'D MMMM YYYY г., HH:mm', + LLLL: 'dddd, D MMMM YYYY г., HH:mm' + }, + relativeTime: { + future: 'через %s', + past: '%s назад', + s: 'несколько секунд', + m: relativeTimeWithPlural, + mm: relativeTimeWithPlural, + h: 'час', + hh: relativeTimeWithPlural, + d: 'день', + dd: relativeTimeWithPlural, + M: 'месяц', + MM: relativeTimeWithPlural, + y: 'год', + yy: relativeTimeWithPlural + }, + meridiemParse: /ночи|утра|дня|вечера/i, + isPM(input: string): boolean { + return /^(дня|вечера)$/.test(input); + }, + meridiem(hour: number): string { + if (hour < 4) { + return 'ночи'; + } else if (hour < 12) { + return 'утра'; + } else if (hour < 17) { + return 'дня'; + } else { + return 'вечера'; + } + }, + dayOfMonthOrdinalParse: /\d{1,2}-(й|го|я)/, + ordinal(num: number, period: string): string { + switch (period) { + case 'M': + case 'd': + case 'DDD': + return `${num}-й`; + case 'D': + return `${num}-го`; + case 'w': + case 'W': + return `${num}-я`; + default: + return num.toString(10); + } + }, + week: { + dow: 1, // Monday is the first day of the week. + doy: 4 // The week that contains Jan 4th is the first week of the year. + } +}; diff --git a/src/bs-moment/i18n/zh-cn.ts b/src/bs-moment/i18n/zh-cn.ts new file mode 100644 index 0000000000..eba07e2d94 --- /dev/null +++ b/src/bs-moment/i18n/zh-cn.ts @@ -0,0 +1,102 @@ +// moment.js locale configuration +// locale : Chinese (China) [zh-cn] +// author : suupic : https://github.com/suupic +// author : Zeno Zeng : https://github.com/zenozeng + +import { LocaleData } from '../locale/locale.class'; + +export const zhCn: LocaleData = { + abbr: 'zh-cn', + months: '一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月'.split('_'), + monthsShort: '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split('_'), + weekdays: '星期日_星期一_星期二_星期三_星期四_星期五_星期六'.split('_'), + weekdaysShort: '周日_周一_周二_周三_周四_周五_周六'.split('_'), + weekdaysMin: '日_一_二_三_四_五_六'.split('_'), + longDateFormat: { + LT: 'HH:mm', + LTS: 'HH:mm:ss', + L: 'YYYY年MMMD日', + LL: 'YYYY年MMMD日', + LLL: 'YYYY年MMMD日Ah点mm分', + LLLL: 'YYYY年MMMD日ddddAh点mm分', + l: 'YYYY年MMMD日', + ll: 'YYYY年MMMD日', + lll: 'YYYY年MMMD日 HH:mm', + llll: 'YYYY年MMMD日dddd HH:mm' + }, + meridiemParse: /凌晨|早上|上午|中午|下午|晚上/, + meridiemHour(hour: number, meridiem: string): number { + if (hour === 12) { + hour = 0; + } + if (meridiem === '凌晨' || meridiem === '早上' || + meridiem === '上午') { + return hour; + } else if (meridiem === '下午' || meridiem === '晚上') { + return hour + 12; + } else { + // '中午' + return hour >= 11 ? hour : hour + 12; + } + }, + meridiem(hour: number, minute: number): string { + const hm = hour * 100 + minute; + if (hm < 600) { + return '凌晨'; + } else if (hm < 900) { + return '早上'; + } else if (hm < 1130) { + return '上午'; + } else if (hm < 1230) { + return '中午'; + } else if (hm < 1800) { + return '下午'; + } else { + return '晚上'; + } + }, + calendar: { + sameDay: '[今天]LT', + nextDay: '[明天]LT', + nextWeek: '[下]ddddLT', + lastDay: '[昨天]LT', + lastWeek: '[上]ddddLT', + sameElse: 'L' + }, + dayOfMonthOrdinalParse: /\d{1,2}(日|月|周)/, + ordinal(num: number, period: string): string { + switch (period) { + case 'd': + case 'D': + case 'DDD': + return `${num}日`; + case 'M': + return `${num}月`; + case 'w': + case 'W': + return `${num}周`; + default: + return num.toString(10); + } + }, + relativeTime: { + future: '%s内', + past: '%s前', + s: '几秒', + m: '1 分钟', + mm: '%d 分钟', + h: '1 小时', + hh: '%d 小时', + d: '1 天', + dd: '%d 天', + M: '1 个月', + MM: '%d 个月', + y: '1 年', + yy: '%d 年' + }, + week: { + // GB/T 7408-1994《数据元和交换格式·信息交换·日期和时间表示法》与ISO 8601:1988等效 + dow: 1, // Monday is the first day of the week. + doy: 4 // The week that contains Jan 4th is the first week of the year. + } +}; diff --git a/src/bs-moment/index.ts b/src/bs-moment/index.ts new file mode 100644 index 0000000000..9f5d081291 --- /dev/null +++ b/src/bs-moment/index.ts @@ -0,0 +1,2 @@ +export { defineLocale, getSetGlobalLocale, listLocales } from './locale/locales.service'; + diff --git a/src/bs-moment/locale/locale.class.ts b/src/bs-moment/locale/locale.class.ts index fc4c223cc7..149340068d 100644 --- a/src/bs-moment/locale/locale.class.ts +++ b/src/bs-moment/locale/locale.class.ts @@ -5,7 +5,7 @@ import { getDayOfWeek, getMonth } from '../utils/date-getters'; export interface LocaleOptionsFormat { format: string[]; standalone: string[]; - isFormat: RegExp; + isFormat?: RegExp; } export type LocaleOptions = string[] | LocaleOptionsFormat; @@ -24,7 +24,7 @@ export interface LocaleData { abbr?: string; months?: LocaleOptions; - monthsShort?: string[]; + monthsShort?: LocaleOptions; weekdays?: LocaleOptions; weekdaysMin?: string[]; weekdaysShort?: string[]; diff --git a/src/datepicker/base/bs-datepicker-container.ts b/src/datepicker/base/bs-datepicker-container.ts index 11085fca03..1c9392a5e0 100644 --- a/src/datepicker/base/bs-datepicker-container.ts +++ b/src/datepicker/base/bs-datepicker-container.ts @@ -11,15 +11,10 @@ import { } from '../models/index'; export abstract class BsDatepickerContainer { - /** @deperecated */ - _customRangesFish: BsCustomDates[] = [ - {label: 'today', value: new Date()}, - {label: 'today1', value: new Date()}, - {label: 'today2', value: new Date()}, - {label: 'today3', value: new Date()} - ]; + containerClass: string; _effects: BsDatepickerEffects; + _customRangesFish: BsCustomDates[] = []; set minDate(value: Date) { this._effects.setMinDate(value); diff --git a/src/datepicker/bs-datepicker.component.ts b/src/datepicker/bs-datepicker.component.ts index e787cb0895..6afe3fe255 100644 --- a/src/datepicker/bs-datepicker.component.ts +++ b/src/datepicker/bs-datepicker.component.ts @@ -19,7 +19,7 @@ import { BsDatepickerConfig } from './bs-datepicker.config'; @Component({ selector: 'bs-datepicker,[bsDatepicker]', exportAs: 'bsDatepicker', - template: ' ' + template: '' }) export class BsDatepickerComponent implements OnInit, OnDestroy, OnChanges { /** @@ -71,6 +71,7 @@ export class BsDatepickerComponent implements OnInit, OnDestroy, OnChanges { this.bsValueChange.emit(value); } + @Input() bsConfig: Partial; @Input() minDate: Date; @Input() maxDate: Date; @@ -124,7 +125,7 @@ export class BsDatepickerComponent implements OnInit, OnDestroy, OnChanges { return; } - const config = Object.assign({}, this._config, { + const config = Object.assign({}, this._config, this.bsConfig, { value: this._bsValue, minDate: this.minDate || this._config.minDate, maxDate: this.maxDate || this._config.maxDate diff --git a/src/datepicker/bs-datepicker.config.ts b/src/datepicker/bs-datepicker.config.ts index 715db9529d..0f6eea90bb 100644 --- a/src/datepicker/bs-datepicker.config.ts +++ b/src/datepicker/bs-datepicker.config.ts @@ -9,6 +9,8 @@ export class BsDatepickerConfig implements DatepickerRenderOptions, minDate?: Date; maxDate?: Date; + containerClass = 'theme-green'; + // DatepickerRenderOptions displayMonths = 1; showWeekNumbers = true; diff --git a/src/datepicker/bs-daterangepicker.component.ts b/src/datepicker/bs-daterangepicker.component.ts index c50ea9d2b0..b96c6a04ea 100644 --- a/src/datepicker/bs-daterangepicker.component.ts +++ b/src/datepicker/bs-daterangepicker.component.ts @@ -53,10 +53,6 @@ export class BsDaterangepickerComponent implements OnInit, OnDestroy, OnChanges */ @Output() onHidden: EventEmitter; - // here will be parsed options and set defaults - // @Input() config: BsDatePickerOptions; - // configChange: EventEmitter = new EventEmitter(); - _bsValue: Date[]; @Input() set bsValue(value: Date[]) { @@ -65,12 +61,13 @@ export class BsDaterangepickerComponent implements OnInit, OnDestroy, OnChanges this.bsValueChange.emit(value); } + @Input() bsConfig: Partial; @Input() minDate: Date; @Input() maxDate: Date; @Output() bsValueChange: EventEmitter = new EventEmitter(); - protected subscriptions: Subscription[] = []; + protected _subs: Subscription[] = []; private _datepicker: ComponentLoader; private _datepickerRef: ComponentRef; @@ -118,12 +115,15 @@ export class BsDaterangepickerComponent implements OnInit, OnDestroy, OnChanges return; } - const config = Object.assign({}, this._config, { - displayMonths: 2, - value: this._bsValue, - minDate: this.minDate || this._config.minDate, - maxDate: this.maxDate || this._config.maxDate - }); + const config = Object.assign({}, + this._config, + {displayMonths: 2}, + this.bsConfig, + { + value: this._bsValue, + minDate: this.minDate || this._config.minDate, + maxDate: this.maxDate || this._config.maxDate + }); this._datepickerRef = this._datepicker .provide({provide: BsDatepickerConfig, useValue: config}) @@ -133,12 +133,12 @@ export class BsDaterangepickerComponent implements OnInit, OnDestroy, OnChanges .show({placement: this.placement}); // if date changes from external source (model -> view) - this.subscriptions.push(this.bsValueChange.subscribe((value: Date[]) => { + this._subs.push(this.bsValueChange.subscribe((value: Date[]) => { this._datepickerRef.instance.value = value; })); // if date changes from picker (view -> model) - this.subscriptions.push(this._datepickerRef.instance + this._subs.push(this._datepickerRef.instance .valueChange .filter((range: Date[]) => range && range[0] && !!range[1]) .subscribe((value: Date[]) => { @@ -155,6 +155,9 @@ export class BsDaterangepickerComponent implements OnInit, OnDestroy, OnChanges if (this.isOpen) { this._datepicker.hide(); } + for (const sub of this._subs) { + sub.unsubscribe(); + } } /** diff --git a/src/datepicker/engine/flag-days-calendar.ts b/src/datepicker/engine/flag-days-calendar.ts index ed8c4a0086..e675fbb8d8 100644 --- a/src/datepicker/engine/flag-days-calendar.ts +++ b/src/datepicker/engine/flag-days-calendar.ts @@ -24,13 +24,19 @@ export function flagDaysCalendar(formattedMonth: DaysCalendarViewModel, const isHovered = !isOtherMonth && isSameDay(day.date, options.hoveredDate); // date range picker - const isSelectionStart = !isOtherMonth && isSameDay(day.date, options.selectedRange[0]); - const isSelectionEnd = !isOtherMonth && isSameDay(day.date, options.selectedRange[1]); + const isSelectionStart = !isOtherMonth + && options.selectedRange + && isSameDay(day.date, options.selectedRange[0]); + const isSelectionEnd = !isOtherMonth + && options.selectedRange + && isSameDay(day.date, options.selectedRange[1]); const isSelected = !isOtherMonth && isSameDay(day.date, options.selectedDate) || isSelectionStart || isSelectionEnd; - const isInRange = !isOtherMonth && isDateInRange(day.date, options.selectedRange, options.hoveredDate); + const isInRange = !isOtherMonth + && options.selectedRange + && isDateInRange(day.date, options.selectedRange, options.hoveredDate); const isDisabled = isSameOrBefore(day.date, options.minDate, 'day') || isSameOrAfter(day.date, options.maxDate, 'day'); diff --git a/src/datepicker/index.ts b/src/datepicker/index.ts index 03a1a56953..c243449f80 100644 --- a/src/datepicker/index.ts +++ b/src/datepicker/index.ts @@ -9,3 +9,4 @@ export { DatepickerConfig } from './datepicker.config'; export { BsDatepickerModule } from './bs-datepicker.module'; export { BsDatepickerComponent } from './bs-datepicker.component'; export { BsDaterangepickerComponent } from './bs-daterangepicker.component'; +export { BsDatepickerConfig } from './bs-datepicker.config'; diff --git a/src/datepicker/reducer/bs-datepicker.effects.ts b/src/datepicker/reducer/bs-datepicker.effects.ts index 4c757f0a27..1224f0ee06 100644 --- a/src/datepicker/reducer/bs-datepicker.effects.ts +++ b/src/datepicker/reducer/bs-datepicker.effects.ts @@ -43,10 +43,14 @@ export class BsDatepickerEffects { /** setters */ - setValue(value: Date) { + setValue(value: Date): void { this._store.dispatch(this._actions.select(value)); } + setRangeValue(value: Date[]): void { + this._store.dispatch(this._actions.selectRange(value)); + } + setMinDate(value: Date): BsDatepickerEffects { this._store.dispatch(this._actions.minDate(value)); diff --git a/src/datepicker/reducer/bs-datepicker.reducer.ts b/src/datepicker/reducer/bs-datepicker.reducer.ts index 10fa14f962..0c1a124395 100644 --- a/src/datepicker/reducer/bs-datepicker.reducer.ts +++ b/src/datepicker/reducer/bs-datepicker.reducer.ts @@ -18,9 +18,6 @@ import { BsViewNavigationEvent, DatepickerFormatOptions } from '../models/index' import { isArray } from '../../bs-moment/utils/type-checks'; export function bsDatepickerReducer(state = initialDatepickerState, action: Action): BsDatepickerState { - if (!(/hover/.test(action.type))) { - console.log(action); - } switch (action.type) { case(BsDatepickerActions.CALCULATE): { return calculateReducer(state); diff --git a/src/datepicker/themes/bs/bs-datepicker-container.component.ts b/src/datepicker/themes/bs/bs-datepicker-container.component.ts index a922cd2ccd..3075c22e03 100644 --- a/src/datepicker/themes/bs/bs-datepicker-container.component.ts +++ b/src/datepicker/themes/bs/bs-datepicker-container.component.ts @@ -24,7 +24,6 @@ export class BsDatepickerContainerComponent set value(value: Date) { this._effects.setValue(value); } - valueChange: EventEmitter = new EventEmitter(); _subs: Subscription[] = []; @@ -37,6 +36,7 @@ export class BsDatepickerContainerComponent } ngOnInit(): void { + this.containerClass = this._config.containerClass; this._effects .init(this._store) // intial state options diff --git a/src/datepicker/themes/bs/bs-datepicker-view.html b/src/datepicker/themes/bs/bs-datepicker-view.html index f4467b26d3..2548ff5553 100644 --- a/src/datepicker/themes/bs/bs-datepicker-view.html +++ b/src/datepicker/themes/bs/bs-datepicker-view.html @@ -1,5 +1,5 @@ -
+
diff --git a/src/datepicker/themes/bs/bs-daterangepicker-container.component.ts b/src/datepicker/themes/bs/bs-daterangepicker-container.component.ts index 458f96dad6..d324cb9b39 100644 --- a/src/datepicker/themes/bs/bs-daterangepicker-container.component.ts +++ b/src/datepicker/themes/bs/bs-daterangepicker-container.component.ts @@ -1,10 +1,11 @@ -import { Component, EventEmitter, OnInit } from '@angular/core'; +import { Component, EventEmitter, OnDestroy, OnInit } from '@angular/core'; import { BsDatepickerContainer } from '../../base/bs-datepicker-container'; import { BsDatepickerConfig } from '../../bs-datepicker.config'; import { DayViewModel } from '../../models/index'; import { BsDatepickerActions } from '../../reducer/bs-datepicker.actions'; import { BsDatepickerEffects } from '../../reducer/bs-datepicker.effects'; import { BsDatepickerStore } from '../../reducer/bs-datepicker.store'; +import { Subscription } from 'rxjs/Subscription'; @Component({ selector: 'bs-daterangepicker-container', @@ -17,16 +18,16 @@ import { BsDatepickerStore } from '../../reducer/bs-datepicker.store'; }) export class BsDaterangepickerContainerComponent extends BsDatepickerContainer - implements OnInit { + implements OnInit, OnDestroy { set value(value: Date[]) { - this._store.dispatch(this._actions.selectRange(value || [])); + this._effects.setRangeValue(value); } valueChange = new EventEmitter(); _rangeStack: Date[] = []; - + _subs: Subscription[] = []; constructor(private _config: BsDatepickerConfig, private _store: BsDatepickerStore, private _actions: BsDatepickerActions, @@ -36,6 +37,7 @@ export class BsDaterangepickerContainerComponent } ngOnInit(): void { + this.containerClass = this._config.containerClass; this._effects .init(this._store) // intial state options @@ -49,8 +51,9 @@ export class BsDaterangepickerContainerComponent // todo: move it somewhere else // on selected date change - this._store.select(state => state.selectedRange) - .subscribe(date => this.valueChange.emit(date)); + this._subs.push(this._store + .select(state => state.selectedRange) + .subscribe(date => this.valueChange.emit(date))); } daySelectHandler(day: DayViewModel): void { @@ -79,4 +82,11 @@ export class BsDaterangepickerContainerComponent this._rangeStack = []; } } + + ngOnDestroy(): void { + for (const sub of this._subs) { + sub.unsubscribe(); + } + this._effects.destroy(); + } } diff --git a/src/index.ts b/src/index.ts index c16be5412b..1472e2c5ee 100644 --- a/src/index.ts +++ b/src/index.ts @@ -99,6 +99,8 @@ export { Positioning, PositioningOptions, PositioningService, positionElements } from './positioning'; +export { defineLocale, getSetGlobalLocale } from './bs-moment'; + const MODULES = [ AccordionModule, AlertModule, ButtonsModule, CarouselModule, CollapseModule, DatepickerModule, diff --git a/src/locale.ts b/src/locale.ts index 7accda2bec..319f0e3e5c 100644 --- a/src/locale.ts +++ b/src/locale.ts @@ -1 +1,17 @@ export { ar } from './bs-moment/i18n/ar'; +export { de } from './bs-moment/i18n/de'; +export { enGb } from './bs-moment/i18n/en-gb'; +export { es } from './bs-moment/i18n/es'; +export { esDo } from './bs-moment/i18n/es-do'; +export { esUs } from './bs-moment/i18n/es-us'; +export { fr } from './bs-moment/i18n/fr'; +export { hi } from './bs-moment/i18n/hi'; +export { it } from './bs-moment/i18n/it'; +export { ja } from './bs-moment/i18n/ja'; +export { ko } from './bs-moment/i18n/ko'; +export { nl } from './bs-moment/i18n/nl'; +export { nlBe } from './bs-moment/i18n/nl-be'; +export { pl } from './bs-moment/i18n/pl'; +export { ptBr } from './bs-moment/i18n/pt-br'; +export { ru } from './bs-moment/i18n/ru'; +export { zhCn } from './bs-moment/i18n/zh-cn'; diff --git a/src/spec/ng-bootstrap/tooltip.spec.ts b/src/spec/ng-bootstrap/tooltip.spec.ts index 0e8c5a6ade..6c66def28c 100644 --- a/src/spec/ng-bootstrap/tooltip.spec.ts +++ b/src/spec/ng-bootstrap/tooltip.spec.ts @@ -44,7 +44,7 @@ describe('tooltip', () => { beforeEach(() => { TestBed.configureTestingModule( - {declarations: [TestComponent, TestOnPushComponent], imports: [TooltipModule.forRoot()]}); + {declarations: [TestComponent, TestOnPushComponent], imports: [TooltipModule.forRoot()]}); }); function getWindow(element: any): HTMLElement { return element.querySelector('bs-tooltip-container'); } @@ -233,7 +233,7 @@ describe('tooltip', () => { it('should support multiple triggers', () => { const fixture = - createTestComponent(`
`); + createTestComponent(`
`); const directive = fixture.debugElement.query(By.directive(TooltipDirective)); directive.triggerEventHandler('mouseover', {}); @@ -333,7 +333,7 @@ describe('tooltip', () => { it('should properly destroy tooltips when the "container" option is used', () => { const selector = 'body'; const fixture = - createTestComponent(`
`); + createTestComponent(`
`); const directive = fixture.debugElement.query(By.directive(TooltipDirective)); directive.triggerEventHandler('mouseover', {}); @@ -349,7 +349,7 @@ describe('tooltip', () => { describe('visibility', () => { it('should emit events when showing and hiding popover', () => { const fixture = createTestComponent( - `
`); + `
`); const directive = fixture.debugElement.query(By.directive(TooltipDirective)); let shownSpy = spyOn(fixture.componentInstance, 'shown'); @@ -368,7 +368,7 @@ describe('tooltip', () => { it('should not emit close event when already closed', () => { const fixture = createTestComponent( - `
`); + `
`); let shownSpy = spyOn(fixture.componentInstance, 'shown'); let hiddenSpy = spyOn(fixture.componentInstance, 'hidden'); @@ -387,7 +387,7 @@ describe('tooltip', () => { it('should not emit open event when already opened', () => { const fixture = createTestComponent( - `
`); + `
`); let shownSpy = spyOn(fixture.componentInstance, 'shown'); let hiddenSpy = spyOn(fixture.componentInstance, 'hidden'); @@ -450,7 +450,7 @@ describe('tooltip', () => { beforeEach(() => { TestBed.configureTestingModule( - {imports: [TooltipModule.forRoot()], providers: [{provide: TooltipConfig, useValue: config}]}); + {imports: [TooltipModule.forRoot()], providers: [{provide: TooltipConfig, useValue: config}]}); }); it('should initialize inputs with provided config as provider', () => {