UNPKG

ng-zorro-antd-yj

Version:

An enterprise-class UI components based on Ant Design and Angular

102 lines 7.72 kB
/** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ import * as tslib_1 from "tslib"; /** @type {?} */ var defaultDisabledTime = { nzDisabledHours: /** * @return {?} */ function () { return []; }, nzDisabledMinutes: /** * @return {?} */ function () { return []; }, nzDisabledSeconds: /** * @return {?} */ function () { return []; } }; /** * @param {?} value * @param {?} disabledTime * @return {?} */ export function getTimeConfig(value, disabledTime) { /** @type {?} */ var disabledTimeConfig = disabledTime ? disabledTime(value && value.nativeDate) : ((/** @type {?} */ ({}))); disabledTimeConfig = tslib_1.__assign({}, defaultDisabledTime, disabledTimeConfig); return disabledTimeConfig; } /** * @param {?} value * @param {?} disabledTimeConfig * @return {?} */ export function isTimeValidByConfig(value, disabledTimeConfig) { /** @type {?} */ var invalidTime = false; if (value) { /** @type {?} */ var hour = value.getHours(); /** @type {?} */ var minutes = value.getMinutes(); /** @type {?} */ var seconds = value.getSeconds(); /** @type {?} */ var disabledHours = disabledTimeConfig.nzDisabledHours(); if (disabledHours.indexOf(hour) === -1) { /** @type {?} */ var disabledMinutes = disabledTimeConfig.nzDisabledMinutes(hour); if (disabledMinutes.indexOf(minutes) === -1) { /** @type {?} */ var disabledSeconds = disabledTimeConfig.nzDisabledSeconds(hour, minutes); invalidTime = disabledSeconds.indexOf(seconds) !== -1; } else { invalidTime = true; } } else { invalidTime = true; } } return !invalidTime; } /** * @param {?} value * @param {?} disabledTime * @return {?} */ export function isTimeValid(value, disabledTime) { /** @type {?} */ var disabledTimeConfig = getTimeConfig(value, disabledTime); return isTimeValidByConfig(value, disabledTimeConfig); } /** * @param {?} value * @param {?=} disabledDate * @param {?=} disabledTime * @return {?} */ export function isAllowedDate(value, disabledDate, disabledTime) { if (disabledDate) { if (disabledDate(value.nativeDate)) { return false; } } if (disabledTime) { if (!isTimeValid(value, disabledTime)) { return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