ng-zorro-antd-yj
Version:
An enterprise-class UI components based on Ant Design and Angular
215 lines • 17.2 kB
JavaScript
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
import { DatePipe } from '@angular/common';
import { Inject, Injectable, Injector, Optional } from '@angular/core';
import fnsFormat from 'date-fns/format';
import fnsGetISOWeek from 'date-fns/get_iso_week';
import fnsParse from 'date-fns/parse';
import { mergeDateConfig, NZ_DATE_CONFIG } from './date-config';
import { NzI18nService } from './nz-i18n.service';
import * as i0 from "@angular/core";
import * as i1 from "./public-api";
import * as i2 from "@angular/common";
/**
* @param {?} injector
* @param {?} config
* @param {?} datePipe
* @return {?}
*/
export function DATE_HELPER_SERVICE_FACTORY(injector, config, datePipe) {
/** @type {?} */
const i18n = injector.get(NzI18nService);
return i18n.getDateLocale()
? new DateHelperByDateFns(i18n, config)
: new DateHelperByDatePipe(i18n, config, datePipe);
}
/**
* Abstract DateHelperService(Token via Class)
* Compatibility: compact for original usage by default which using DatePipe
* @abstract
*/
export class DateHelperService {
// Indicate whether this service is rely on DatePipe
/**
* @param {?} i18n
* @param {?} config
*/
constructor(i18n, config) {
this.i18n = i18n;
this.config = config;
this.relyOnDatePipe = this instanceof DateHelperByDatePipe; // Indicate whether this service is rely on DatePipe
this.config = mergeDateConfig(this.config);
}
/**
* @param {?} text
* @return {?}
*/
parseDate(text) {
if (!text) {
return;
}
return fnsParse(text);
}
/**
* @param {?} text
* @return {?}
*/
parseTime(text) {
if (!text) {
return;
}
return fnsParse(`1970-01-01 ${text}`);
}
}
DateHelperService.decorators = [
{ type: Injectable, args: [{
providedIn: 'root',
useFactory: DATE_HELPER_SERVICE_FACTORY,
deps: [Injector, [new Optional(), NZ_DATE_CONFIG], DatePipe]
},] }
];
/** @nocollapse */
DateHelperService.ctorParameters = () => [
{ type: NzI18nService },
{ type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [NZ_DATE_CONFIG,] }] }
];
/** @nocollapse */ DateHelperService.ngInjectableDef = i0.defineInjectable({ factory: function DateHelperService_Factory() { return DATE_HELPER_SERVICE_FACTORY(i0.inject(i0.INJECTOR), i0.inject(i1.NZ_DATE_CONFIG, 8), i0.inject(i2.DatePipe)); }, token: i1.DateHelperService, providedIn: "root" });
if (false) {
/** @type {?} */
DateHelperService.prototype.relyOnDatePipe;
/**
* @type {?}
* @protected
*/
DateHelperService.prototype.i18n;
/**
* @type {?}
* @protected
*/
DateHelperService.prototype.config;
/**
* @abstract
* @param {?} date
* @return {?}
*/
DateHelperService.prototype.getISOWeek = function (date) { };
/**
* @abstract
* @return {?}
*/
DateHelperService.prototype.getFirstDayOfWeek = function () { };
/**
* @abstract
* @param {?} date
* @param {?} formatStr
* @return {?}
*/
DateHelperService.prototype.format = function (date, formatStr) { };
}
/**
* DateHelper that handles date formats with date-fns
*/
export class DateHelperByDateFns extends DateHelperService {
/**
* @param {?} date
* @return {?}
*/
getISOWeek(date) {
return fnsGetISOWeek(date);
}
// TODO: Use date-fns's "weekStartsOn" to support different locale when "config.firstDayOfWeek" is null
// when v2.0 is ready: https://github.com/date-fns/date-fns/blob/v2.0.0-alpha.27/src/locale/en-US/index.js#L23
/**
* @return {?}
*/
getFirstDayOfWeek() {
return this.config.firstDayOfWeek == null ? 1 : this.config.firstDayOfWeek;
}
/**
* Format a date
* @see https://date-fns.org/docs/format#description
* @param {?} date Date
* @param {?} formatStr format string
* @return {?}
*/
format(date, formatStr) {
return fnsFormat(date, formatStr, { locale: this.i18n.getDateLocale() });
}
}
/** @nocollapse */ DateHelperByDateFns.ngInjectableDef = i0.defineInjectable({ factory: function DateHelperByDateFns_Factory() { return DATE_HELPER_SERVICE_FACTORY(i0.inject(i0.INJECTOR), i0.inject(i1.NZ_DATE_CONFIG, 8), i0.inject(i2.DatePipe)); }, token: DateHelperByDateFns, providedIn: "root" });
/**
* DateHelper that handles date formats with angular's date-pipe
* [BUG] Use DatePipe may cause non-standard week bug, see: https://github.com/NG-ZORRO/ng-zorro-antd/issues/2406
*
* @deprecated Maybe removed in next major version due to this serious bug
*/
export class DateHelperByDatePipe extends DateHelperService {
/**
* @param {?} i18n
* @param {?} config
* @param {?} datePipe
*/
constructor(i18n, config, datePipe) {
super(i18n, config);
this.datePipe = datePipe;
}
/**
* @param {?} date
* @return {?}
*/
getISOWeek(date) {
return +this.format(date, 'w');
}
/**
* @return {?}
*/
getFirstDayOfWeek() {
if (this.config.firstDayOfWeek === undefined) {
/** @type {?} */
const locale = this.i18n.getLocaleId();
return locale && ['zh-cn', 'zh-tw'].indexOf(locale.toLowerCase()) > -1 ? 1 : 0;
}
return this.config.firstDayOfWeek;
}
/**
* @param {?} date
* @param {?} formatStr
* @return {?}
*/
format(date, formatStr) {
return date ? (/** @type {?} */ (this.datePipe.transform(date, formatStr, undefined, this.i18n.getLocaleId()))) : '';
}
/**
* Compatible translate the moment-like format pattern to angular's pattern
* Why? For now, we need to support the existing language formats in AntD, and AntD uses the default temporal syntax.
*
* TODO: compare and complete all format patterns
* Each format docs as below:
* @link https://momentjs.com/docs/#/displaying/format/ / https://angular.io/api/common/DatePipe#description
* @param {?} format input format pattern
* @return {?}
*/
transCompatFormat(format) {
return (format &&
format
.replace(/Y/g, 'y') // only support y, yy, yyy, yyyy
.replace(/D/g, 'd')); // d, dd represent of D, DD for momentjs, others are not support
}
}
/** @nocollapse */
DateHelperByDatePipe.ctorParameters = () => [
{ type: NzI18nService },
{ type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [NZ_DATE_CONFIG,] }] },
{ type: DatePipe }
];
/** @nocollapse */ DateHelperByDatePipe.ngInjectableDef = i0.defineInjectable({ factory: function DateHelperByDatePipe_Factory() { return DATE_HELPER_SERVICE_FACTORY(i0.inject(i0.INJECTOR), i0.inject(i1.NZ_DATE_CONFIG, 8), i0.inject(i2.DatePipe)); }, token: DateHelperByDatePipe, providedIn: "root" });
if (false) {
/**
* @type {?}
* @private
*/
DateHelperByDatePipe.prototype.datePipe;
}
//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