UNPKG

2.01 kBJavaScriptView Raw
1/*
2 * Copyright 2016 Palantir Technologies, Inc. All rights reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16import { Months } from "./common/months";
17export const DISABLED_MODIFIER = "disabled";
18export const HOVERED_RANGE_MODIFIER = "hovered-range";
19export const OUTSIDE_MODIFIER = "outside";
20export const SELECTED_MODIFIER = "selected";
21export const SELECTED_RANGE_MODIFIER = "selected-range";
22// modifiers the user can't set because they are used by Blueprint or react-day-picker
23export const DISALLOWED_MODIFIERS = [
24 DISABLED_MODIFIER,
25 HOVERED_RANGE_MODIFIER,
26 OUTSIDE_MODIFIER,
27 SELECTED_MODIFIER,
28 SELECTED_RANGE_MODIFIER,
29];
30export function getDefaultMaxDate() {
31 const date = new Date();
32 date.setMonth(date.getMonth() + 6);
33 return date;
34}
35export function getDefaultMinDate() {
36 const date = new Date();
37 date.setFullYear(date.getFullYear() - 20);
38 date.setMonth(Months.JANUARY, 1);
39 return date;
40}
41export function combineModifiers(baseModifiers, userModifiers) {
42 let modifiers = baseModifiers;
43 if (userModifiers != null) {
44 modifiers = {};
45 for (const key of Object.keys(userModifiers)) {
46 if (DISALLOWED_MODIFIERS.indexOf(key) === -1) {
47 modifiers[key] = userModifiers[key];
48 }
49 }
50 for (const key of Object.keys(baseModifiers)) {
51 modifiers[key] = baseModifiers[key];
52 }
53 }
54 return modifiers;
55}
56//# sourceMappingURL=datePickerCore.js.map
\No newline at end of file