1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | import locales from './locales'; import { POPOVER_VISIBILITIES } from './constants'; const popoverLabel = (attr) => { if (!attr.targetDate.isRange) return ''; const diff = attr.targetDate.daySpan; return `${diff + 1} Day${diff === 0 ? '' : 's'}, ${diff} Night${diff === 1 ? '' : 's'}`; }; const defaults = { firstDayOfWeek: 1, navVisibility: 'focus', titlePosition: 'center', titleTransition: 'slide-h', weeksTransition: 'slide-h', dateFormatter: d => d.toLocaleDateString(), dateParser: s => new Date(Date.parse(s)), datePickerInputClass: '', datePickerInputStyle: null, datePickerInputPlaceholder: '', datePickerSelectColor: '#66B3CC', datePickerDragColor: '#9FCFDF', datePickerShowCaps: false, datePickerDragAttribute: (color, showCaps) => ({ key: 'drag-select', highlight: { backgroundColor: color, height: '25px', }, contentHoverStyle: { backgroundColor: 'transparent', border: '0', }, popover: { label: popoverLabel, hideIndicator: true, }, ...(showCaps && { highlightCaps: { backgroundColor: '#fafafa', borderColor: color, borderWidth: '2px', }, contentStyleCaps: { color: '#333333', }, }), }), datePickerSelectAttribute: (color, showCaps) => ({ key: 'drag-select', highlight: { backgroundColor: color, }, contentStyle: { color: '#fafafa', }, contentHoverStyle: { backgroundColor: 'transparent', border: '0', }, popover: { label: popoverLabel, hideIndicator: true, }, ...(showCaps && { highlightCaps: { backgroundColor: '#fafafa', borderColor: color, borderWidth: '2px', }, contentStyleCaps: { color: '#333333', }, }), }), datePickerDisabledAttribute: { key: 'disabled', order: 100, contentStyle: { color: '#bcbcbc', textDecoration: 'line-through', }, contentHoverStyle: { cursor: 'not-allowed', backgroundColor: 'transparent', }, }, popoverExpanded: false, popoverDirection: 'bottom', popoverAlign: 'left', popoverVisibility: POPOVER_VISIBILITIES.HOVER, popoverContentOffset: '10px', maxSwipeTime: 300, // ms minHorizontalSwipeDistance: 60, // px maxVerticalSwipeDistance: 80, // px maxTapTolerance: 0, // ms maxTapDuration: 200, // ms highlight: { animated: true, height: '1.8rem', borderWidth: '0', borderStyle: 'solid', borderRadius: '290486px', opacity: 1, }, highlightCaps: { animated: true, height: '1.9rem', borderWidth: '0', borderStyle: 'solid', borderRadius: '290486px', opacity: 1, }, dot: { diameter: '5px', backgroundColor: '#66b3cc', borderWidth: '0', borderStyle: 'solid', borderRadius: '50%', opacity: 1, }, bar: { height: '3px', backgroundColor: '#66b3cc', borderWidth: '0', borderStyle: 'solid', opacity: 1, }, themeStyles: { wrapper: { backgroundColor: '#fafafa', border: '1px solid #dadada' }, verticalDivider: { borderLeft: '1px solid #dadada' }, // header: null, // headerTitle: null, // headerArrows: null, // headerVerticalDivider: null, // headerHorizontalDivider: null, // weekdays: null, // weekdaysVerticalDivider: null, // weekdaysHorizontalDivider: null, // weeks: null, // weeksVerticalDivider: null, // dayCell: null, dayCellNotInMonth: { opacity: 0.4 }, // dayContent: null, // dayContentHover: null, // dots: null, // bars: null, dayPopoverContent: { color: '#333333', fontSize: '.8rem', whiteSpace: 'nowrap', }, }, }; export default defaults; export const mergeDefaults = (otherDefaults) => { // Get the locale supplied by the user let locale; // Get the user supplied locale if (otherDefaults && otherDefaults.locale) locale = locales[otherDefaults.locale.substring(0, 2)]; // Get the detected browser locale if needed if (!locale) locale = locales[(window.navigator.userLanguage || window.navigator.language).substring(0, 2)]; // Fall back to english locale if needed if (!locale) locale = locales.en; // Assign the language defaults const languageDefaults = { monthLabels: locale.months, monthNavLabels: locale.monthsShort, weekdayLabels: locale.weekdaysMin, }; // Assign the defaults Object.assign(defaults, languageDefaults, otherDefaults); }; |