react-day-picker 8.8.2 → 8.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/index.d.ts +152 -71
- package/dist/index.esm.js +1481 -101
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1505 -142
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +10 -1
- package/dist/index.min.js.map +1 -1
- package/dist/style.css +8 -7
- package/dist/style.css.map +1 -1
- package/dist/style.module.css +8 -7
- package/package.json +27 -27
- package/src/DayPicker.tsx +0 -2
- package/src/components/Button/Button.test.tsx +0 -2
- package/src/components/Button/Button.tsx +1 -1
- package/src/components/Caption/Caption.test.tsx +0 -2
- package/src/components/Caption/Caption.tsx +0 -2
- package/src/components/CaptionDropdowns/CaptionDropdowns.test.tsx +0 -2
- package/src/components/CaptionDropdowns/CaptionDropdowns.tsx +0 -2
- package/src/components/CaptionLabel/CaptionLabel.test.tsx +0 -2
- package/src/components/CaptionLabel/CaptionLabel.tsx +0 -2
- package/src/components/CaptionNavigation/CaptionNavigation.test.tsx +0 -2
- package/src/components/CaptionNavigation/CaptionNavigation.tsx +3 -3
- package/src/components/Day/Day.test.tsx +0 -2
- package/src/components/Day/Day.tsx +1 -1
- package/src/components/DayContent/DayContent.test.tsx +0 -2
- package/src/components/DayContent/DayContent.tsx +0 -2
- package/src/components/Dropdown/Dropdown.test.tsx +0 -2
- package/src/components/Dropdown/Dropdown.tsx +10 -5
- package/src/components/Footer/Footer.test.tsx +0 -2
- package/src/components/Footer/Footer.tsx +0 -2
- package/src/components/Head/Head.test.tsx +0 -2
- package/src/components/Head/Head.tsx +0 -2
- package/src/components/HeadRow/HeadRow.test.tsx +0 -2
- package/src/components/HeadRow/HeadRow.tsx +0 -2
- package/src/components/IconDropdown/IconDropdown.test.tsx +0 -2
- package/src/components/IconDropdown/IconDropdown.tsx +0 -2
- package/src/components/IconLeft/IconLeft.test.tsx +0 -2
- package/src/components/IconLeft/IconLeft.tsx +0 -2
- package/src/components/IconRight/IconRight.test.tsx +0 -2
- package/src/components/IconRight/IconRight.tsx +0 -2
- package/src/components/Month/Month.test.tsx +0 -2
- package/src/components/Month/Month.tsx +0 -2
- package/src/components/Months/Months.test.tsx +27 -0
- package/src/components/Months/Months.tsx +19 -0
- package/src/components/Months/index.ts +1 -0
- package/src/components/MonthsDropdown/MonthsDropdown.test.tsx +0 -2
- package/src/components/MonthsDropdown/MonthsDropdown.tsx +2 -2
- package/src/components/Navigation/Navigation.test.tsx +0 -2
- package/src/components/Navigation/Navigation.tsx +3 -3
- package/src/components/Root/Root.test.tsx +58 -15
- package/src/components/Root/Root.tsx +9 -6
- package/src/components/Row/Row.test.tsx +0 -2
- package/src/components/Row/Row.tsx +0 -2
- package/src/components/Table/Table.test.tsx +0 -2
- package/src/components/Table/Table.tsx +0 -2
- package/src/components/WeekNumber/WeekNumber.test.tsx +1 -3
- package/src/components/WeekNumber/WeekNumber.tsx +2 -2
- package/src/components/YearsDropdown/YearsDropdown.test.tsx +0 -2
- package/src/components/YearsDropdown/YearsDropdown.tsx +2 -2
- package/src/contexts/DayPicker/DayPickerContext.tsx +2 -1
- package/src/contexts/DayPicker/formatters/formatDay.ts +1 -2
- package/src/contexts/DayPicker/formatters/formatMonthCaption.ts +1 -2
- package/src/contexts/DayPicker/formatters/formatWeekdayName.ts +1 -2
- package/src/contexts/DayPicker/formatters/formatYearCaption.ts +4 -2
- package/src/contexts/Focus/FocusContext.tsx +4 -2
- package/src/contexts/Modifiers/ModifiersContext.tsx +2 -4
- package/src/contexts/Navigation/NavigationContext.tsx +1 -1
- package/src/contexts/RootProvider.tsx +4 -5
- package/src/contexts/SelectMultiple/SelectMultipleContext.test.ts +6 -4
- package/src/contexts/SelectMultiple/SelectMultipleContext.tsx +6 -5
- package/src/contexts/SelectRange/SelectRangeContext.test.ts +3 -1
- package/src/contexts/SelectRange/SelectRangeContext.tsx +8 -7
- package/src/contexts/SelectSingle/SelectSingleContext.test.ts +3 -3
- package/src/contexts/SelectSingle/SelectSingleContext.tsx +8 -7
- package/src/hooks/useControlledValue/useControlledValue.ts +2 -2
- package/src/hooks/useDayRender/useDayRender.tsx +2 -2
- package/src/hooks/useDayRender/utils/getDayStyle.ts +4 -2
- package/src/hooks/useId/useId.ts +5 -7
- package/src/hooks/useId/useIsomorphicLayoutEffect.ts +31 -0
- package/src/hooks/useInput/useInput.ts +13 -8
- package/src/index.ts +1 -0
- package/src/style.css +8 -7
- package/src/types/DayPickerBase.ts +85 -11
- package/src/types/EventHandlers.ts +18 -10
- package/src/types/Formatters.ts +11 -5
- package/src/types/Labels.ts +16 -5
- package/src/types/Modifiers.ts +4 -2
- package/src/types/Styles.ts +5 -5
- package/tsconfig.json +5 -3
package/dist/index.esm.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import React__default, { createContext, useContext, useState, forwardRef, useEffect, useRef } from 'react';
|
|
1
|
+
import require$$0, { createContext, useContext, useState, forwardRef, useEffect, useRef, useLayoutEffect } from 'react';
|
|
3
2
|
import { format, startOfMonth, endOfMonth, startOfDay, isSameYear, setMonth, setYear, startOfYear, differenceInCalendarMonths, addMonths, isSameMonth, isBefore, startOfISOWeek, startOfWeek, addDays, isSameDay, isAfter, subDays, differenceInCalendarDays, isDate, max, min, addWeeks, addYears, endOfISOWeek, endOfWeek, getUnixTime, getISOWeek, getWeek, getWeeksInMonth, parse } from 'date-fns';
|
|
4
3
|
import { enUS } from 'date-fns/locale';
|
|
5
4
|
|
|
@@ -17,6 +16,8 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
17
16
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
18
17
|
PERFORMANCE OF THIS SOFTWARE.
|
|
19
18
|
***************************************************************************** */
|
|
19
|
+
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
20
|
+
|
|
20
21
|
|
|
21
22
|
var __assign = function() {
|
|
22
23
|
__assign = Object.assign || function __assign(t) {
|
|
@@ -56,6 +57,1360 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
56
57
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
57
58
|
};
|
|
58
59
|
|
|
60
|
+
var jsxRuntime = {exports: {}};
|
|
61
|
+
|
|
62
|
+
var reactJsxRuntime_production_min = {};
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* @license React
|
|
66
|
+
* react-jsx-runtime.production.min.js
|
|
67
|
+
*
|
|
68
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
69
|
+
*
|
|
70
|
+
* This source code is licensed under the MIT license found in the
|
|
71
|
+
* LICENSE file in the root directory of this source tree.
|
|
72
|
+
*/
|
|
73
|
+
|
|
74
|
+
var hasRequiredReactJsxRuntime_production_min;
|
|
75
|
+
|
|
76
|
+
function requireReactJsxRuntime_production_min () {
|
|
77
|
+
if (hasRequiredReactJsxRuntime_production_min) return reactJsxRuntime_production_min;
|
|
78
|
+
hasRequiredReactJsxRuntime_production_min = 1;
|
|
79
|
+
var f=require$$0,k=Symbol.for("react.element"),l=Symbol.for("react.fragment"),m=Object.prototype.hasOwnProperty,n=f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,p={key:!0,ref:!0,__self:!0,__source:!0};
|
|
80
|
+
function q(c,a,g){var b,d={},e=null,h=null;void 0!==g&&(e=""+g);void 0!==a.key&&(e=""+a.key);void 0!==a.ref&&(h=a.ref);for(b in a)m.call(a,b)&&!p.hasOwnProperty(b)&&(d[b]=a[b]);if(c&&c.defaultProps)for(b in a=c.defaultProps,a)void 0===d[b]&&(d[b]=a[b]);return {$$typeof:k,type:c,key:e,ref:h,props:d,_owner:n.current}}reactJsxRuntime_production_min.Fragment=l;reactJsxRuntime_production_min.jsx=q;reactJsxRuntime_production_min.jsxs=q;
|
|
81
|
+
return reactJsxRuntime_production_min;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
var reactJsxRuntime_development = {};
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* @license React
|
|
88
|
+
* react-jsx-runtime.development.js
|
|
89
|
+
*
|
|
90
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
91
|
+
*
|
|
92
|
+
* This source code is licensed under the MIT license found in the
|
|
93
|
+
* LICENSE file in the root directory of this source tree.
|
|
94
|
+
*/
|
|
95
|
+
|
|
96
|
+
var hasRequiredReactJsxRuntime_development;
|
|
97
|
+
|
|
98
|
+
function requireReactJsxRuntime_development () {
|
|
99
|
+
if (hasRequiredReactJsxRuntime_development) return reactJsxRuntime_development;
|
|
100
|
+
hasRequiredReactJsxRuntime_development = 1;
|
|
101
|
+
|
|
102
|
+
if (process.env.NODE_ENV !== "production") {
|
|
103
|
+
(function() {
|
|
104
|
+
|
|
105
|
+
var React = require$$0;
|
|
106
|
+
|
|
107
|
+
// ATTENTION
|
|
108
|
+
// When adding new symbols to this file,
|
|
109
|
+
// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
|
|
110
|
+
// The Symbol used to tag the ReactElement-like types.
|
|
111
|
+
var REACT_ELEMENT_TYPE = Symbol.for('react.element');
|
|
112
|
+
var REACT_PORTAL_TYPE = Symbol.for('react.portal');
|
|
113
|
+
var REACT_FRAGMENT_TYPE = Symbol.for('react.fragment');
|
|
114
|
+
var REACT_STRICT_MODE_TYPE = Symbol.for('react.strict_mode');
|
|
115
|
+
var REACT_PROFILER_TYPE = Symbol.for('react.profiler');
|
|
116
|
+
var REACT_PROVIDER_TYPE = Symbol.for('react.provider');
|
|
117
|
+
var REACT_CONTEXT_TYPE = Symbol.for('react.context');
|
|
118
|
+
var REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref');
|
|
119
|
+
var REACT_SUSPENSE_TYPE = Symbol.for('react.suspense');
|
|
120
|
+
var REACT_SUSPENSE_LIST_TYPE = Symbol.for('react.suspense_list');
|
|
121
|
+
var REACT_MEMO_TYPE = Symbol.for('react.memo');
|
|
122
|
+
var REACT_LAZY_TYPE = Symbol.for('react.lazy');
|
|
123
|
+
var REACT_OFFSCREEN_TYPE = Symbol.for('react.offscreen');
|
|
124
|
+
var MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
|
|
125
|
+
var FAUX_ITERATOR_SYMBOL = '@@iterator';
|
|
126
|
+
function getIteratorFn(maybeIterable) {
|
|
127
|
+
if (maybeIterable === null || typeof maybeIterable !== 'object') {
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
|
|
132
|
+
|
|
133
|
+
if (typeof maybeIterator === 'function') {
|
|
134
|
+
return maybeIterator;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
141
|
+
|
|
142
|
+
function error(format) {
|
|
143
|
+
{
|
|
144
|
+
{
|
|
145
|
+
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
146
|
+
args[_key2 - 1] = arguments[_key2];
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
printWarning('error', format, args);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function printWarning(level, format, args) {
|
|
155
|
+
// When changing this logic, you might want to also
|
|
156
|
+
// update consoleWithStackDev.www.js as well.
|
|
157
|
+
{
|
|
158
|
+
var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
|
|
159
|
+
var stack = ReactDebugCurrentFrame.getStackAddendum();
|
|
160
|
+
|
|
161
|
+
if (stack !== '') {
|
|
162
|
+
format += '%s';
|
|
163
|
+
args = args.concat([stack]);
|
|
164
|
+
} // eslint-disable-next-line react-internal/safe-string-coercion
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
var argsWithFormat = args.map(function (item) {
|
|
168
|
+
return String(item);
|
|
169
|
+
}); // Careful: RN currently depends on this prefix
|
|
170
|
+
|
|
171
|
+
argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
|
|
172
|
+
// breaks IE9: https://github.com/facebook/react/issues/13610
|
|
173
|
+
// eslint-disable-next-line react-internal/no-production-logging
|
|
174
|
+
|
|
175
|
+
Function.prototype.apply.call(console[level], console, argsWithFormat);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// -----------------------------------------------------------------------------
|
|
180
|
+
|
|
181
|
+
var enableScopeAPI = false; // Experimental Create Event Handle API.
|
|
182
|
+
var enableCacheElement = false;
|
|
183
|
+
var enableTransitionTracing = false; // No known bugs, but needs performance testing
|
|
184
|
+
|
|
185
|
+
var enableLegacyHidden = false; // Enables unstable_avoidThisFallback feature in Fiber
|
|
186
|
+
// stuff. Intended to enable React core members to more easily debug scheduling
|
|
187
|
+
// issues in DEV builds.
|
|
188
|
+
|
|
189
|
+
var enableDebugTracing = false; // Track which Fiber(s) schedule render work.
|
|
190
|
+
|
|
191
|
+
var REACT_MODULE_REFERENCE;
|
|
192
|
+
|
|
193
|
+
{
|
|
194
|
+
REACT_MODULE_REFERENCE = Symbol.for('react.module.reference');
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function isValidElementType(type) {
|
|
198
|
+
if (typeof type === 'string' || typeof type === 'function') {
|
|
199
|
+
return true;
|
|
200
|
+
} // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill).
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
if (type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || enableDebugTracing || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || enableLegacyHidden || type === REACT_OFFSCREEN_TYPE || enableScopeAPI || enableCacheElement || enableTransitionTracing ) {
|
|
204
|
+
return true;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
if (typeof type === 'object' && type !== null) {
|
|
208
|
+
if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || // This needs to include all possible module reference object
|
|
209
|
+
// types supported by any Flight configuration anywhere since
|
|
210
|
+
// we don't know which Flight build this will end up being used
|
|
211
|
+
// with.
|
|
212
|
+
type.$$typeof === REACT_MODULE_REFERENCE || type.getModuleId !== undefined) {
|
|
213
|
+
return true;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
return false;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
function getWrappedName(outerType, innerType, wrapperName) {
|
|
221
|
+
var displayName = outerType.displayName;
|
|
222
|
+
|
|
223
|
+
if (displayName) {
|
|
224
|
+
return displayName;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
var functionName = innerType.displayName || innerType.name || '';
|
|
228
|
+
return functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName;
|
|
229
|
+
} // Keep in sync with react-reconciler/getComponentNameFromFiber
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
function getContextName(type) {
|
|
233
|
+
return type.displayName || 'Context';
|
|
234
|
+
} // Note that the reconciler package should generally prefer to use getComponentNameFromFiber() instead.
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
function getComponentNameFromType(type) {
|
|
238
|
+
if (type == null) {
|
|
239
|
+
// Host root, text node or just invalid type.
|
|
240
|
+
return null;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
{
|
|
244
|
+
if (typeof type.tag === 'number') {
|
|
245
|
+
error('Received an unexpected object in getComponentNameFromType(). ' + 'This is likely a bug in React. Please file an issue.');
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
if (typeof type === 'function') {
|
|
250
|
+
return type.displayName || type.name || null;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
if (typeof type === 'string') {
|
|
254
|
+
return type;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
switch (type) {
|
|
258
|
+
case REACT_FRAGMENT_TYPE:
|
|
259
|
+
return 'Fragment';
|
|
260
|
+
|
|
261
|
+
case REACT_PORTAL_TYPE:
|
|
262
|
+
return 'Portal';
|
|
263
|
+
|
|
264
|
+
case REACT_PROFILER_TYPE:
|
|
265
|
+
return 'Profiler';
|
|
266
|
+
|
|
267
|
+
case REACT_STRICT_MODE_TYPE:
|
|
268
|
+
return 'StrictMode';
|
|
269
|
+
|
|
270
|
+
case REACT_SUSPENSE_TYPE:
|
|
271
|
+
return 'Suspense';
|
|
272
|
+
|
|
273
|
+
case REACT_SUSPENSE_LIST_TYPE:
|
|
274
|
+
return 'SuspenseList';
|
|
275
|
+
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
if (typeof type === 'object') {
|
|
279
|
+
switch (type.$$typeof) {
|
|
280
|
+
case REACT_CONTEXT_TYPE:
|
|
281
|
+
var context = type;
|
|
282
|
+
return getContextName(context) + '.Consumer';
|
|
283
|
+
|
|
284
|
+
case REACT_PROVIDER_TYPE:
|
|
285
|
+
var provider = type;
|
|
286
|
+
return getContextName(provider._context) + '.Provider';
|
|
287
|
+
|
|
288
|
+
case REACT_FORWARD_REF_TYPE:
|
|
289
|
+
return getWrappedName(type, type.render, 'ForwardRef');
|
|
290
|
+
|
|
291
|
+
case REACT_MEMO_TYPE:
|
|
292
|
+
var outerName = type.displayName || null;
|
|
293
|
+
|
|
294
|
+
if (outerName !== null) {
|
|
295
|
+
return outerName;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
return getComponentNameFromType(type.type) || 'Memo';
|
|
299
|
+
|
|
300
|
+
case REACT_LAZY_TYPE:
|
|
301
|
+
{
|
|
302
|
+
var lazyComponent = type;
|
|
303
|
+
var payload = lazyComponent._payload;
|
|
304
|
+
var init = lazyComponent._init;
|
|
305
|
+
|
|
306
|
+
try {
|
|
307
|
+
return getComponentNameFromType(init(payload));
|
|
308
|
+
} catch (x) {
|
|
309
|
+
return null;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
// eslint-disable-next-line no-fallthrough
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
return null;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
var assign = Object.assign;
|
|
321
|
+
|
|
322
|
+
// Helpers to patch console.logs to avoid logging during side-effect free
|
|
323
|
+
// replaying on render function. This currently only patches the object
|
|
324
|
+
// lazily which won't cover if the log function was extracted eagerly.
|
|
325
|
+
// We could also eagerly patch the method.
|
|
326
|
+
var disabledDepth = 0;
|
|
327
|
+
var prevLog;
|
|
328
|
+
var prevInfo;
|
|
329
|
+
var prevWarn;
|
|
330
|
+
var prevError;
|
|
331
|
+
var prevGroup;
|
|
332
|
+
var prevGroupCollapsed;
|
|
333
|
+
var prevGroupEnd;
|
|
334
|
+
|
|
335
|
+
function disabledLog() {}
|
|
336
|
+
|
|
337
|
+
disabledLog.__reactDisabledLog = true;
|
|
338
|
+
function disableLogs() {
|
|
339
|
+
{
|
|
340
|
+
if (disabledDepth === 0) {
|
|
341
|
+
/* eslint-disable react-internal/no-production-logging */
|
|
342
|
+
prevLog = console.log;
|
|
343
|
+
prevInfo = console.info;
|
|
344
|
+
prevWarn = console.warn;
|
|
345
|
+
prevError = console.error;
|
|
346
|
+
prevGroup = console.group;
|
|
347
|
+
prevGroupCollapsed = console.groupCollapsed;
|
|
348
|
+
prevGroupEnd = console.groupEnd; // https://github.com/facebook/react/issues/19099
|
|
349
|
+
|
|
350
|
+
var props = {
|
|
351
|
+
configurable: true,
|
|
352
|
+
enumerable: true,
|
|
353
|
+
value: disabledLog,
|
|
354
|
+
writable: true
|
|
355
|
+
}; // $FlowFixMe Flow thinks console is immutable.
|
|
356
|
+
|
|
357
|
+
Object.defineProperties(console, {
|
|
358
|
+
info: props,
|
|
359
|
+
log: props,
|
|
360
|
+
warn: props,
|
|
361
|
+
error: props,
|
|
362
|
+
group: props,
|
|
363
|
+
groupCollapsed: props,
|
|
364
|
+
groupEnd: props
|
|
365
|
+
});
|
|
366
|
+
/* eslint-enable react-internal/no-production-logging */
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
disabledDepth++;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
function reenableLogs() {
|
|
373
|
+
{
|
|
374
|
+
disabledDepth--;
|
|
375
|
+
|
|
376
|
+
if (disabledDepth === 0) {
|
|
377
|
+
/* eslint-disable react-internal/no-production-logging */
|
|
378
|
+
var props = {
|
|
379
|
+
configurable: true,
|
|
380
|
+
enumerable: true,
|
|
381
|
+
writable: true
|
|
382
|
+
}; // $FlowFixMe Flow thinks console is immutable.
|
|
383
|
+
|
|
384
|
+
Object.defineProperties(console, {
|
|
385
|
+
log: assign({}, props, {
|
|
386
|
+
value: prevLog
|
|
387
|
+
}),
|
|
388
|
+
info: assign({}, props, {
|
|
389
|
+
value: prevInfo
|
|
390
|
+
}),
|
|
391
|
+
warn: assign({}, props, {
|
|
392
|
+
value: prevWarn
|
|
393
|
+
}),
|
|
394
|
+
error: assign({}, props, {
|
|
395
|
+
value: prevError
|
|
396
|
+
}),
|
|
397
|
+
group: assign({}, props, {
|
|
398
|
+
value: prevGroup
|
|
399
|
+
}),
|
|
400
|
+
groupCollapsed: assign({}, props, {
|
|
401
|
+
value: prevGroupCollapsed
|
|
402
|
+
}),
|
|
403
|
+
groupEnd: assign({}, props, {
|
|
404
|
+
value: prevGroupEnd
|
|
405
|
+
})
|
|
406
|
+
});
|
|
407
|
+
/* eslint-enable react-internal/no-production-logging */
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
if (disabledDepth < 0) {
|
|
411
|
+
error('disabledDepth fell below zero. ' + 'This is a bug in React. Please file an issue.');
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
|
|
417
|
+
var prefix;
|
|
418
|
+
function describeBuiltInComponentFrame(name, source, ownerFn) {
|
|
419
|
+
{
|
|
420
|
+
if (prefix === undefined) {
|
|
421
|
+
// Extract the VM specific prefix used by each line.
|
|
422
|
+
try {
|
|
423
|
+
throw Error();
|
|
424
|
+
} catch (x) {
|
|
425
|
+
var match = x.stack.trim().match(/\n( *(at )?)/);
|
|
426
|
+
prefix = match && match[1] || '';
|
|
427
|
+
}
|
|
428
|
+
} // We use the prefix to ensure our stacks line up with native stack frames.
|
|
429
|
+
|
|
430
|
+
|
|
431
|
+
return '\n' + prefix + name;
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
var reentry = false;
|
|
435
|
+
var componentFrameCache;
|
|
436
|
+
|
|
437
|
+
{
|
|
438
|
+
var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map;
|
|
439
|
+
componentFrameCache = new PossiblyWeakMap();
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
function describeNativeComponentFrame(fn, construct) {
|
|
443
|
+
// If something asked for a stack inside a fake render, it should get ignored.
|
|
444
|
+
if ( !fn || reentry) {
|
|
445
|
+
return '';
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
{
|
|
449
|
+
var frame = componentFrameCache.get(fn);
|
|
450
|
+
|
|
451
|
+
if (frame !== undefined) {
|
|
452
|
+
return frame;
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
var control;
|
|
457
|
+
reentry = true;
|
|
458
|
+
var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe It does accept undefined.
|
|
459
|
+
|
|
460
|
+
Error.prepareStackTrace = undefined;
|
|
461
|
+
var previousDispatcher;
|
|
462
|
+
|
|
463
|
+
{
|
|
464
|
+
previousDispatcher = ReactCurrentDispatcher.current; // Set the dispatcher in DEV because this might be call in the render function
|
|
465
|
+
// for warnings.
|
|
466
|
+
|
|
467
|
+
ReactCurrentDispatcher.current = null;
|
|
468
|
+
disableLogs();
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
try {
|
|
472
|
+
// This should throw.
|
|
473
|
+
if (construct) {
|
|
474
|
+
// Something should be setting the props in the constructor.
|
|
475
|
+
var Fake = function () {
|
|
476
|
+
throw Error();
|
|
477
|
+
}; // $FlowFixMe
|
|
478
|
+
|
|
479
|
+
|
|
480
|
+
Object.defineProperty(Fake.prototype, 'props', {
|
|
481
|
+
set: function () {
|
|
482
|
+
// We use a throwing setter instead of frozen or non-writable props
|
|
483
|
+
// because that won't throw in a non-strict mode function.
|
|
484
|
+
throw Error();
|
|
485
|
+
}
|
|
486
|
+
});
|
|
487
|
+
|
|
488
|
+
if (typeof Reflect === 'object' && Reflect.construct) {
|
|
489
|
+
// We construct a different control for this case to include any extra
|
|
490
|
+
// frames added by the construct call.
|
|
491
|
+
try {
|
|
492
|
+
Reflect.construct(Fake, []);
|
|
493
|
+
} catch (x) {
|
|
494
|
+
control = x;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
Reflect.construct(fn, [], Fake);
|
|
498
|
+
} else {
|
|
499
|
+
try {
|
|
500
|
+
Fake.call();
|
|
501
|
+
} catch (x) {
|
|
502
|
+
control = x;
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
fn.call(Fake.prototype);
|
|
506
|
+
}
|
|
507
|
+
} else {
|
|
508
|
+
try {
|
|
509
|
+
throw Error();
|
|
510
|
+
} catch (x) {
|
|
511
|
+
control = x;
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
fn();
|
|
515
|
+
}
|
|
516
|
+
} catch (sample) {
|
|
517
|
+
// This is inlined manually because closure doesn't do it for us.
|
|
518
|
+
if (sample && control && typeof sample.stack === 'string') {
|
|
519
|
+
// This extracts the first frame from the sample that isn't also in the control.
|
|
520
|
+
// Skipping one frame that we assume is the frame that calls the two.
|
|
521
|
+
var sampleLines = sample.stack.split('\n');
|
|
522
|
+
var controlLines = control.stack.split('\n');
|
|
523
|
+
var s = sampleLines.length - 1;
|
|
524
|
+
var c = controlLines.length - 1;
|
|
525
|
+
|
|
526
|
+
while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) {
|
|
527
|
+
// We expect at least one stack frame to be shared.
|
|
528
|
+
// Typically this will be the root most one. However, stack frames may be
|
|
529
|
+
// cut off due to maximum stack limits. In this case, one maybe cut off
|
|
530
|
+
// earlier than the other. We assume that the sample is longer or the same
|
|
531
|
+
// and there for cut off earlier. So we should find the root most frame in
|
|
532
|
+
// the sample somewhere in the control.
|
|
533
|
+
c--;
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
for (; s >= 1 && c >= 0; s--, c--) {
|
|
537
|
+
// Next we find the first one that isn't the same which should be the
|
|
538
|
+
// frame that called our sample function and the control.
|
|
539
|
+
if (sampleLines[s] !== controlLines[c]) {
|
|
540
|
+
// In V8, the first line is describing the message but other VMs don't.
|
|
541
|
+
// If we're about to return the first line, and the control is also on the same
|
|
542
|
+
// line, that's a pretty good indicator that our sample threw at same line as
|
|
543
|
+
// the control. I.e. before we entered the sample frame. So we ignore this result.
|
|
544
|
+
// This can happen if you passed a class to function component, or non-function.
|
|
545
|
+
if (s !== 1 || c !== 1) {
|
|
546
|
+
do {
|
|
547
|
+
s--;
|
|
548
|
+
c--; // We may still have similar intermediate frames from the construct call.
|
|
549
|
+
// The next one that isn't the same should be our match though.
|
|
550
|
+
|
|
551
|
+
if (c < 0 || sampleLines[s] !== controlLines[c]) {
|
|
552
|
+
// V8 adds a "new" prefix for native classes. Let's remove it to make it prettier.
|
|
553
|
+
var _frame = '\n' + sampleLines[s].replace(' at new ', ' at '); // If our component frame is labeled "<anonymous>"
|
|
554
|
+
// but we have a user-provided "displayName"
|
|
555
|
+
// splice it in to make the stack more readable.
|
|
556
|
+
|
|
557
|
+
|
|
558
|
+
if (fn.displayName && _frame.includes('<anonymous>')) {
|
|
559
|
+
_frame = _frame.replace('<anonymous>', fn.displayName);
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
{
|
|
563
|
+
if (typeof fn === 'function') {
|
|
564
|
+
componentFrameCache.set(fn, _frame);
|
|
565
|
+
}
|
|
566
|
+
} // Return the line we found.
|
|
567
|
+
|
|
568
|
+
|
|
569
|
+
return _frame;
|
|
570
|
+
}
|
|
571
|
+
} while (s >= 1 && c >= 0);
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
break;
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
} finally {
|
|
579
|
+
reentry = false;
|
|
580
|
+
|
|
581
|
+
{
|
|
582
|
+
ReactCurrentDispatcher.current = previousDispatcher;
|
|
583
|
+
reenableLogs();
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
Error.prepareStackTrace = previousPrepareStackTrace;
|
|
587
|
+
} // Fallback to just using the name if we couldn't make it throw.
|
|
588
|
+
|
|
589
|
+
|
|
590
|
+
var name = fn ? fn.displayName || fn.name : '';
|
|
591
|
+
var syntheticFrame = name ? describeBuiltInComponentFrame(name) : '';
|
|
592
|
+
|
|
593
|
+
{
|
|
594
|
+
if (typeof fn === 'function') {
|
|
595
|
+
componentFrameCache.set(fn, syntheticFrame);
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
return syntheticFrame;
|
|
600
|
+
}
|
|
601
|
+
function describeFunctionComponentFrame(fn, source, ownerFn) {
|
|
602
|
+
{
|
|
603
|
+
return describeNativeComponentFrame(fn, false);
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
function shouldConstruct(Component) {
|
|
608
|
+
var prototype = Component.prototype;
|
|
609
|
+
return !!(prototype && prototype.isReactComponent);
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
function describeUnknownElementTypeFrameInDEV(type, source, ownerFn) {
|
|
613
|
+
|
|
614
|
+
if (type == null) {
|
|
615
|
+
return '';
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
if (typeof type === 'function') {
|
|
619
|
+
{
|
|
620
|
+
return describeNativeComponentFrame(type, shouldConstruct(type));
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
if (typeof type === 'string') {
|
|
625
|
+
return describeBuiltInComponentFrame(type);
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
switch (type) {
|
|
629
|
+
case REACT_SUSPENSE_TYPE:
|
|
630
|
+
return describeBuiltInComponentFrame('Suspense');
|
|
631
|
+
|
|
632
|
+
case REACT_SUSPENSE_LIST_TYPE:
|
|
633
|
+
return describeBuiltInComponentFrame('SuspenseList');
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
if (typeof type === 'object') {
|
|
637
|
+
switch (type.$$typeof) {
|
|
638
|
+
case REACT_FORWARD_REF_TYPE:
|
|
639
|
+
return describeFunctionComponentFrame(type.render);
|
|
640
|
+
|
|
641
|
+
case REACT_MEMO_TYPE:
|
|
642
|
+
// Memo may contain any component type so we recursively resolve it.
|
|
643
|
+
return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn);
|
|
644
|
+
|
|
645
|
+
case REACT_LAZY_TYPE:
|
|
646
|
+
{
|
|
647
|
+
var lazyComponent = type;
|
|
648
|
+
var payload = lazyComponent._payload;
|
|
649
|
+
var init = lazyComponent._init;
|
|
650
|
+
|
|
651
|
+
try {
|
|
652
|
+
// Lazy may contain any component type so we recursively resolve it.
|
|
653
|
+
return describeUnknownElementTypeFrameInDEV(init(payload), source, ownerFn);
|
|
654
|
+
} catch (x) {}
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
return '';
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
663
|
+
|
|
664
|
+
var loggedTypeFailures = {};
|
|
665
|
+
var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
|
|
666
|
+
|
|
667
|
+
function setCurrentlyValidatingElement(element) {
|
|
668
|
+
{
|
|
669
|
+
if (element) {
|
|
670
|
+
var owner = element._owner;
|
|
671
|
+
var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
|
|
672
|
+
ReactDebugCurrentFrame.setExtraStackFrame(stack);
|
|
673
|
+
} else {
|
|
674
|
+
ReactDebugCurrentFrame.setExtraStackFrame(null);
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
function checkPropTypes(typeSpecs, values, location, componentName, element) {
|
|
680
|
+
{
|
|
681
|
+
// $FlowFixMe This is okay but Flow doesn't know it.
|
|
682
|
+
var has = Function.call.bind(hasOwnProperty);
|
|
683
|
+
|
|
684
|
+
for (var typeSpecName in typeSpecs) {
|
|
685
|
+
if (has(typeSpecs, typeSpecName)) {
|
|
686
|
+
var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to
|
|
687
|
+
// fail the render phase where it didn't fail before. So we log it.
|
|
688
|
+
// After these have been cleaned up, we'll let them throw.
|
|
689
|
+
|
|
690
|
+
try {
|
|
691
|
+
// This is intentionally an invariant that gets caught. It's the same
|
|
692
|
+
// behavior as without this statement except with a better message.
|
|
693
|
+
if (typeof typeSpecs[typeSpecName] !== 'function') {
|
|
694
|
+
// eslint-disable-next-line react-internal/prod-error-codes
|
|
695
|
+
var err = Error((componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' + 'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.');
|
|
696
|
+
err.name = 'Invariant Violation';
|
|
697
|
+
throw err;
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED');
|
|
701
|
+
} catch (ex) {
|
|
702
|
+
error$1 = ex;
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
if (error$1 && !(error$1 instanceof Error)) {
|
|
706
|
+
setCurrentlyValidatingElement(element);
|
|
707
|
+
|
|
708
|
+
error('%s: type specification of %s' + ' `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error$1);
|
|
709
|
+
|
|
710
|
+
setCurrentlyValidatingElement(null);
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) {
|
|
714
|
+
// Only monitor this failure once because there tends to be a lot of the
|
|
715
|
+
// same error.
|
|
716
|
+
loggedTypeFailures[error$1.message] = true;
|
|
717
|
+
setCurrentlyValidatingElement(element);
|
|
718
|
+
|
|
719
|
+
error('Failed %s type: %s', location, error$1.message);
|
|
720
|
+
|
|
721
|
+
setCurrentlyValidatingElement(null);
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
var isArrayImpl = Array.isArray; // eslint-disable-next-line no-redeclare
|
|
729
|
+
|
|
730
|
+
function isArray(a) {
|
|
731
|
+
return isArrayImpl(a);
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
/*
|
|
735
|
+
* The `'' + value` pattern (used in in perf-sensitive code) throws for Symbol
|
|
736
|
+
* and Temporal.* types. See https://github.com/facebook/react/pull/22064.
|
|
737
|
+
*
|
|
738
|
+
* The functions in this module will throw an easier-to-understand,
|
|
739
|
+
* easier-to-debug exception with a clear errors message message explaining the
|
|
740
|
+
* problem. (Instead of a confusing exception thrown inside the implementation
|
|
741
|
+
* of the `value` object).
|
|
742
|
+
*/
|
|
743
|
+
// $FlowFixMe only called in DEV, so void return is not possible.
|
|
744
|
+
function typeName(value) {
|
|
745
|
+
{
|
|
746
|
+
// toStringTag is needed for namespaced types like Temporal.Instant
|
|
747
|
+
var hasToStringTag = typeof Symbol === 'function' && Symbol.toStringTag;
|
|
748
|
+
var type = hasToStringTag && value[Symbol.toStringTag] || value.constructor.name || 'Object';
|
|
749
|
+
return type;
|
|
750
|
+
}
|
|
751
|
+
} // $FlowFixMe only called in DEV, so void return is not possible.
|
|
752
|
+
|
|
753
|
+
|
|
754
|
+
function willCoercionThrow(value) {
|
|
755
|
+
{
|
|
756
|
+
try {
|
|
757
|
+
testStringCoercion(value);
|
|
758
|
+
return false;
|
|
759
|
+
} catch (e) {
|
|
760
|
+
return true;
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
function testStringCoercion(value) {
|
|
766
|
+
// If you ended up here by following an exception call stack, here's what's
|
|
767
|
+
// happened: you supplied an object or symbol value to React (as a prop, key,
|
|
768
|
+
// DOM attribute, CSS property, string ref, etc.) and when React tried to
|
|
769
|
+
// coerce it to a string using `'' + value`, an exception was thrown.
|
|
770
|
+
//
|
|
771
|
+
// The most common types that will cause this exception are `Symbol` instances
|
|
772
|
+
// and Temporal objects like `Temporal.Instant`. But any object that has a
|
|
773
|
+
// `valueOf` or `[Symbol.toPrimitive]` method that throws will also cause this
|
|
774
|
+
// exception. (Library authors do this to prevent users from using built-in
|
|
775
|
+
// numeric operators like `+` or comparison operators like `>=` because custom
|
|
776
|
+
// methods are needed to perform accurate arithmetic or comparison.)
|
|
777
|
+
//
|
|
778
|
+
// To fix the problem, coerce this object or symbol value to a string before
|
|
779
|
+
// passing it to React. The most reliable way is usually `String(value)`.
|
|
780
|
+
//
|
|
781
|
+
// To find which value is throwing, check the browser or debugger console.
|
|
782
|
+
// Before this exception was thrown, there should be `console.error` output
|
|
783
|
+
// that shows the type (Symbol, Temporal.PlainDate, etc.) that caused the
|
|
784
|
+
// problem and how that type was used: key, atrribute, input value prop, etc.
|
|
785
|
+
// In most cases, this console output also shows the component and its
|
|
786
|
+
// ancestor components where the exception happened.
|
|
787
|
+
//
|
|
788
|
+
// eslint-disable-next-line react-internal/safe-string-coercion
|
|
789
|
+
return '' + value;
|
|
790
|
+
}
|
|
791
|
+
function checkKeyStringCoercion(value) {
|
|
792
|
+
{
|
|
793
|
+
if (willCoercionThrow(value)) {
|
|
794
|
+
error('The provided key is an unsupported type %s.' + ' This value must be coerced to a string before before using it here.', typeName(value));
|
|
795
|
+
|
|
796
|
+
return testStringCoercion(value); // throw (to help callers find troubleshooting comments)
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
|
|
802
|
+
var RESERVED_PROPS = {
|
|
803
|
+
key: true,
|
|
804
|
+
ref: true,
|
|
805
|
+
__self: true,
|
|
806
|
+
__source: true
|
|
807
|
+
};
|
|
808
|
+
var specialPropKeyWarningShown;
|
|
809
|
+
var specialPropRefWarningShown;
|
|
810
|
+
var didWarnAboutStringRefs;
|
|
811
|
+
|
|
812
|
+
{
|
|
813
|
+
didWarnAboutStringRefs = {};
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
function hasValidRef(config) {
|
|
817
|
+
{
|
|
818
|
+
if (hasOwnProperty.call(config, 'ref')) {
|
|
819
|
+
var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;
|
|
820
|
+
|
|
821
|
+
if (getter && getter.isReactWarning) {
|
|
822
|
+
return false;
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
return config.ref !== undefined;
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
function hasValidKey(config) {
|
|
831
|
+
{
|
|
832
|
+
if (hasOwnProperty.call(config, 'key')) {
|
|
833
|
+
var getter = Object.getOwnPropertyDescriptor(config, 'key').get;
|
|
834
|
+
|
|
835
|
+
if (getter && getter.isReactWarning) {
|
|
836
|
+
return false;
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
return config.key !== undefined;
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
function warnIfStringRefCannotBeAutoConverted(config, self) {
|
|
845
|
+
{
|
|
846
|
+
if (typeof config.ref === 'string' && ReactCurrentOwner.current && self && ReactCurrentOwner.current.stateNode !== self) {
|
|
847
|
+
var componentName = getComponentNameFromType(ReactCurrentOwner.current.type);
|
|
848
|
+
|
|
849
|
+
if (!didWarnAboutStringRefs[componentName]) {
|
|
850
|
+
error('Component "%s" contains the string ref "%s". ' + 'Support for string refs will be removed in a future major release. ' + 'This case cannot be automatically converted to an arrow function. ' + 'We ask you to manually fix this case by using useRef() or createRef() instead. ' + 'Learn more about using refs safely here: ' + 'https://reactjs.org/link/strict-mode-string-ref', getComponentNameFromType(ReactCurrentOwner.current.type), config.ref);
|
|
851
|
+
|
|
852
|
+
didWarnAboutStringRefs[componentName] = true;
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
function defineKeyPropWarningGetter(props, displayName) {
|
|
859
|
+
{
|
|
860
|
+
var warnAboutAccessingKey = function () {
|
|
861
|
+
if (!specialPropKeyWarningShown) {
|
|
862
|
+
specialPropKeyWarningShown = true;
|
|
863
|
+
|
|
864
|
+
error('%s: `key` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName);
|
|
865
|
+
}
|
|
866
|
+
};
|
|
867
|
+
|
|
868
|
+
warnAboutAccessingKey.isReactWarning = true;
|
|
869
|
+
Object.defineProperty(props, 'key', {
|
|
870
|
+
get: warnAboutAccessingKey,
|
|
871
|
+
configurable: true
|
|
872
|
+
});
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
function defineRefPropWarningGetter(props, displayName) {
|
|
877
|
+
{
|
|
878
|
+
var warnAboutAccessingRef = function () {
|
|
879
|
+
if (!specialPropRefWarningShown) {
|
|
880
|
+
specialPropRefWarningShown = true;
|
|
881
|
+
|
|
882
|
+
error('%s: `ref` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName);
|
|
883
|
+
}
|
|
884
|
+
};
|
|
885
|
+
|
|
886
|
+
warnAboutAccessingRef.isReactWarning = true;
|
|
887
|
+
Object.defineProperty(props, 'ref', {
|
|
888
|
+
get: warnAboutAccessingRef,
|
|
889
|
+
configurable: true
|
|
890
|
+
});
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
/**
|
|
894
|
+
* Factory method to create a new React element. This no longer adheres to
|
|
895
|
+
* the class pattern, so do not use new to call it. Also, instanceof check
|
|
896
|
+
* will not work. Instead test $$typeof field against Symbol.for('react.element') to check
|
|
897
|
+
* if something is a React Element.
|
|
898
|
+
*
|
|
899
|
+
* @param {*} type
|
|
900
|
+
* @param {*} props
|
|
901
|
+
* @param {*} key
|
|
902
|
+
* @param {string|object} ref
|
|
903
|
+
* @param {*} owner
|
|
904
|
+
* @param {*} self A *temporary* helper to detect places where `this` is
|
|
905
|
+
* different from the `owner` when React.createElement is called, so that we
|
|
906
|
+
* can warn. We want to get rid of owner and replace string `ref`s with arrow
|
|
907
|
+
* functions, and as long as `this` and owner are the same, there will be no
|
|
908
|
+
* change in behavior.
|
|
909
|
+
* @param {*} source An annotation object (added by a transpiler or otherwise)
|
|
910
|
+
* indicating filename, line number, and/or other information.
|
|
911
|
+
* @internal
|
|
912
|
+
*/
|
|
913
|
+
|
|
914
|
+
|
|
915
|
+
var ReactElement = function (type, key, ref, self, source, owner, props) {
|
|
916
|
+
var element = {
|
|
917
|
+
// This tag allows us to uniquely identify this as a React Element
|
|
918
|
+
$$typeof: REACT_ELEMENT_TYPE,
|
|
919
|
+
// Built-in properties that belong on the element
|
|
920
|
+
type: type,
|
|
921
|
+
key: key,
|
|
922
|
+
ref: ref,
|
|
923
|
+
props: props,
|
|
924
|
+
// Record the component responsible for creating this element.
|
|
925
|
+
_owner: owner
|
|
926
|
+
};
|
|
927
|
+
|
|
928
|
+
{
|
|
929
|
+
// The validation flag is currently mutative. We put it on
|
|
930
|
+
// an external backing store so that we can freeze the whole object.
|
|
931
|
+
// This can be replaced with a WeakMap once they are implemented in
|
|
932
|
+
// commonly used development environments.
|
|
933
|
+
element._store = {}; // To make comparing ReactElements easier for testing purposes, we make
|
|
934
|
+
// the validation flag non-enumerable (where possible, which should
|
|
935
|
+
// include every environment we run tests in), so the test framework
|
|
936
|
+
// ignores it.
|
|
937
|
+
|
|
938
|
+
Object.defineProperty(element._store, 'validated', {
|
|
939
|
+
configurable: false,
|
|
940
|
+
enumerable: false,
|
|
941
|
+
writable: true,
|
|
942
|
+
value: false
|
|
943
|
+
}); // self and source are DEV only properties.
|
|
944
|
+
|
|
945
|
+
Object.defineProperty(element, '_self', {
|
|
946
|
+
configurable: false,
|
|
947
|
+
enumerable: false,
|
|
948
|
+
writable: false,
|
|
949
|
+
value: self
|
|
950
|
+
}); // Two elements created in two different places should be considered
|
|
951
|
+
// equal for testing purposes and therefore we hide it from enumeration.
|
|
952
|
+
|
|
953
|
+
Object.defineProperty(element, '_source', {
|
|
954
|
+
configurable: false,
|
|
955
|
+
enumerable: false,
|
|
956
|
+
writable: false,
|
|
957
|
+
value: source
|
|
958
|
+
});
|
|
959
|
+
|
|
960
|
+
if (Object.freeze) {
|
|
961
|
+
Object.freeze(element.props);
|
|
962
|
+
Object.freeze(element);
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
return element;
|
|
967
|
+
};
|
|
968
|
+
/**
|
|
969
|
+
* https://github.com/reactjs/rfcs/pull/107
|
|
970
|
+
* @param {*} type
|
|
971
|
+
* @param {object} props
|
|
972
|
+
* @param {string} key
|
|
973
|
+
*/
|
|
974
|
+
|
|
975
|
+
function jsxDEV(type, config, maybeKey, source, self) {
|
|
976
|
+
{
|
|
977
|
+
var propName; // Reserved names are extracted
|
|
978
|
+
|
|
979
|
+
var props = {};
|
|
980
|
+
var key = null;
|
|
981
|
+
var ref = null; // Currently, key can be spread in as a prop. This causes a potential
|
|
982
|
+
// issue if key is also explicitly declared (ie. <div {...props} key="Hi" />
|
|
983
|
+
// or <div key="Hi" {...props} /> ). We want to deprecate key spread,
|
|
984
|
+
// but as an intermediary step, we will use jsxDEV for everything except
|
|
985
|
+
// <div {...props} key="Hi" />, because we aren't currently able to tell if
|
|
986
|
+
// key is explicitly declared to be undefined or not.
|
|
987
|
+
|
|
988
|
+
if (maybeKey !== undefined) {
|
|
989
|
+
{
|
|
990
|
+
checkKeyStringCoercion(maybeKey);
|
|
991
|
+
}
|
|
992
|
+
|
|
993
|
+
key = '' + maybeKey;
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
if (hasValidKey(config)) {
|
|
997
|
+
{
|
|
998
|
+
checkKeyStringCoercion(config.key);
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
key = '' + config.key;
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
if (hasValidRef(config)) {
|
|
1005
|
+
ref = config.ref;
|
|
1006
|
+
warnIfStringRefCannotBeAutoConverted(config, self);
|
|
1007
|
+
} // Remaining properties are added to a new props object
|
|
1008
|
+
|
|
1009
|
+
|
|
1010
|
+
for (propName in config) {
|
|
1011
|
+
if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
|
|
1012
|
+
props[propName] = config[propName];
|
|
1013
|
+
}
|
|
1014
|
+
} // Resolve default props
|
|
1015
|
+
|
|
1016
|
+
|
|
1017
|
+
if (type && type.defaultProps) {
|
|
1018
|
+
var defaultProps = type.defaultProps;
|
|
1019
|
+
|
|
1020
|
+
for (propName in defaultProps) {
|
|
1021
|
+
if (props[propName] === undefined) {
|
|
1022
|
+
props[propName] = defaultProps[propName];
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
}
|
|
1026
|
+
|
|
1027
|
+
if (key || ref) {
|
|
1028
|
+
var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
|
|
1029
|
+
|
|
1030
|
+
if (key) {
|
|
1031
|
+
defineKeyPropWarningGetter(props, displayName);
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
if (ref) {
|
|
1035
|
+
defineRefPropWarningGetter(props, displayName);
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1038
|
+
|
|
1039
|
+
return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
|
|
1043
|
+
var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner;
|
|
1044
|
+
var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame;
|
|
1045
|
+
|
|
1046
|
+
function setCurrentlyValidatingElement$1(element) {
|
|
1047
|
+
{
|
|
1048
|
+
if (element) {
|
|
1049
|
+
var owner = element._owner;
|
|
1050
|
+
var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
|
|
1051
|
+
ReactDebugCurrentFrame$1.setExtraStackFrame(stack);
|
|
1052
|
+
} else {
|
|
1053
|
+
ReactDebugCurrentFrame$1.setExtraStackFrame(null);
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
var propTypesMisspellWarningShown;
|
|
1059
|
+
|
|
1060
|
+
{
|
|
1061
|
+
propTypesMisspellWarningShown = false;
|
|
1062
|
+
}
|
|
1063
|
+
/**
|
|
1064
|
+
* Verifies the object is a ReactElement.
|
|
1065
|
+
* See https://reactjs.org/docs/react-api.html#isvalidelement
|
|
1066
|
+
* @param {?object} object
|
|
1067
|
+
* @return {boolean} True if `object` is a ReactElement.
|
|
1068
|
+
* @final
|
|
1069
|
+
*/
|
|
1070
|
+
|
|
1071
|
+
|
|
1072
|
+
function isValidElement(object) {
|
|
1073
|
+
{
|
|
1074
|
+
return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
|
|
1078
|
+
function getDeclarationErrorAddendum() {
|
|
1079
|
+
{
|
|
1080
|
+
if (ReactCurrentOwner$1.current) {
|
|
1081
|
+
var name = getComponentNameFromType(ReactCurrentOwner$1.current.type);
|
|
1082
|
+
|
|
1083
|
+
if (name) {
|
|
1084
|
+
return '\n\nCheck the render method of `' + name + '`.';
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
|
|
1088
|
+
return '';
|
|
1089
|
+
}
|
|
1090
|
+
}
|
|
1091
|
+
|
|
1092
|
+
function getSourceInfoErrorAddendum(source) {
|
|
1093
|
+
{
|
|
1094
|
+
if (source !== undefined) {
|
|
1095
|
+
var fileName = source.fileName.replace(/^.*[\\\/]/, '');
|
|
1096
|
+
var lineNumber = source.lineNumber;
|
|
1097
|
+
return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.';
|
|
1098
|
+
}
|
|
1099
|
+
|
|
1100
|
+
return '';
|
|
1101
|
+
}
|
|
1102
|
+
}
|
|
1103
|
+
/**
|
|
1104
|
+
* Warn if there's no key explicitly set on dynamic arrays of children or
|
|
1105
|
+
* object keys are not valid. This allows us to keep track of children between
|
|
1106
|
+
* updates.
|
|
1107
|
+
*/
|
|
1108
|
+
|
|
1109
|
+
|
|
1110
|
+
var ownerHasKeyUseWarning = {};
|
|
1111
|
+
|
|
1112
|
+
function getCurrentComponentErrorInfo(parentType) {
|
|
1113
|
+
{
|
|
1114
|
+
var info = getDeclarationErrorAddendum();
|
|
1115
|
+
|
|
1116
|
+
if (!info) {
|
|
1117
|
+
var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
|
|
1118
|
+
|
|
1119
|
+
if (parentName) {
|
|
1120
|
+
info = "\n\nCheck the top-level render call using <" + parentName + ">.";
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1124
|
+
return info;
|
|
1125
|
+
}
|
|
1126
|
+
}
|
|
1127
|
+
/**
|
|
1128
|
+
* Warn if the element doesn't have an explicit key assigned to it.
|
|
1129
|
+
* This element is in an array. The array could grow and shrink or be
|
|
1130
|
+
* reordered. All children that haven't already been validated are required to
|
|
1131
|
+
* have a "key" property assigned to it. Error statuses are cached so a warning
|
|
1132
|
+
* will only be shown once.
|
|
1133
|
+
*
|
|
1134
|
+
* @internal
|
|
1135
|
+
* @param {ReactElement} element Element that requires a key.
|
|
1136
|
+
* @param {*} parentType element's parent's type.
|
|
1137
|
+
*/
|
|
1138
|
+
|
|
1139
|
+
|
|
1140
|
+
function validateExplicitKey(element, parentType) {
|
|
1141
|
+
{
|
|
1142
|
+
if (!element._store || element._store.validated || element.key != null) {
|
|
1143
|
+
return;
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1146
|
+
element._store.validated = true;
|
|
1147
|
+
var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
|
|
1148
|
+
|
|
1149
|
+
if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
|
|
1150
|
+
return;
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1153
|
+
ownerHasKeyUseWarning[currentComponentErrorInfo] = true; // Usually the current owner is the offender, but if it accepts children as a
|
|
1154
|
+
// property, it may be the creator of the child that's responsible for
|
|
1155
|
+
// assigning it a key.
|
|
1156
|
+
|
|
1157
|
+
var childOwner = '';
|
|
1158
|
+
|
|
1159
|
+
if (element && element._owner && element._owner !== ReactCurrentOwner$1.current) {
|
|
1160
|
+
// Give the component that originally created this child.
|
|
1161
|
+
childOwner = " It was passed a child from " + getComponentNameFromType(element._owner.type) + ".";
|
|
1162
|
+
}
|
|
1163
|
+
|
|
1164
|
+
setCurrentlyValidatingElement$1(element);
|
|
1165
|
+
|
|
1166
|
+
error('Each child in a list should have a unique "key" prop.' + '%s%s See https://reactjs.org/link/warning-keys for more information.', currentComponentErrorInfo, childOwner);
|
|
1167
|
+
|
|
1168
|
+
setCurrentlyValidatingElement$1(null);
|
|
1169
|
+
}
|
|
1170
|
+
}
|
|
1171
|
+
/**
|
|
1172
|
+
* Ensure that every element either is passed in a static location, in an
|
|
1173
|
+
* array with an explicit keys property defined, or in an object literal
|
|
1174
|
+
* with valid key property.
|
|
1175
|
+
*
|
|
1176
|
+
* @internal
|
|
1177
|
+
* @param {ReactNode} node Statically passed child of any type.
|
|
1178
|
+
* @param {*} parentType node's parent's type.
|
|
1179
|
+
*/
|
|
1180
|
+
|
|
1181
|
+
|
|
1182
|
+
function validateChildKeys(node, parentType) {
|
|
1183
|
+
{
|
|
1184
|
+
if (typeof node !== 'object') {
|
|
1185
|
+
return;
|
|
1186
|
+
}
|
|
1187
|
+
|
|
1188
|
+
if (isArray(node)) {
|
|
1189
|
+
for (var i = 0; i < node.length; i++) {
|
|
1190
|
+
var child = node[i];
|
|
1191
|
+
|
|
1192
|
+
if (isValidElement(child)) {
|
|
1193
|
+
validateExplicitKey(child, parentType);
|
|
1194
|
+
}
|
|
1195
|
+
}
|
|
1196
|
+
} else if (isValidElement(node)) {
|
|
1197
|
+
// This element was passed in a valid location.
|
|
1198
|
+
if (node._store) {
|
|
1199
|
+
node._store.validated = true;
|
|
1200
|
+
}
|
|
1201
|
+
} else if (node) {
|
|
1202
|
+
var iteratorFn = getIteratorFn(node);
|
|
1203
|
+
|
|
1204
|
+
if (typeof iteratorFn === 'function') {
|
|
1205
|
+
// Entry iterators used to provide implicit keys,
|
|
1206
|
+
// but now we print a separate warning for them later.
|
|
1207
|
+
if (iteratorFn !== node.entries) {
|
|
1208
|
+
var iterator = iteratorFn.call(node);
|
|
1209
|
+
var step;
|
|
1210
|
+
|
|
1211
|
+
while (!(step = iterator.next()).done) {
|
|
1212
|
+
if (isValidElement(step.value)) {
|
|
1213
|
+
validateExplicitKey(step.value, parentType);
|
|
1214
|
+
}
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1218
|
+
}
|
|
1219
|
+
}
|
|
1220
|
+
}
|
|
1221
|
+
/**
|
|
1222
|
+
* Given an element, validate that its props follow the propTypes definition,
|
|
1223
|
+
* provided by the type.
|
|
1224
|
+
*
|
|
1225
|
+
* @param {ReactElement} element
|
|
1226
|
+
*/
|
|
1227
|
+
|
|
1228
|
+
|
|
1229
|
+
function validatePropTypes(element) {
|
|
1230
|
+
{
|
|
1231
|
+
var type = element.type;
|
|
1232
|
+
|
|
1233
|
+
if (type === null || type === undefined || typeof type === 'string') {
|
|
1234
|
+
return;
|
|
1235
|
+
}
|
|
1236
|
+
|
|
1237
|
+
var propTypes;
|
|
1238
|
+
|
|
1239
|
+
if (typeof type === 'function') {
|
|
1240
|
+
propTypes = type.propTypes;
|
|
1241
|
+
} else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here.
|
|
1242
|
+
// Inner props are checked in the reconciler.
|
|
1243
|
+
type.$$typeof === REACT_MEMO_TYPE)) {
|
|
1244
|
+
propTypes = type.propTypes;
|
|
1245
|
+
} else {
|
|
1246
|
+
return;
|
|
1247
|
+
}
|
|
1248
|
+
|
|
1249
|
+
if (propTypes) {
|
|
1250
|
+
// Intentionally inside to avoid triggering lazy initializers:
|
|
1251
|
+
var name = getComponentNameFromType(type);
|
|
1252
|
+
checkPropTypes(propTypes, element.props, 'prop', name, element);
|
|
1253
|
+
} else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) {
|
|
1254
|
+
propTypesMisspellWarningShown = true; // Intentionally inside to avoid triggering lazy initializers:
|
|
1255
|
+
|
|
1256
|
+
var _name = getComponentNameFromType(type);
|
|
1257
|
+
|
|
1258
|
+
error('Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', _name || 'Unknown');
|
|
1259
|
+
}
|
|
1260
|
+
|
|
1261
|
+
if (typeof type.getDefaultProps === 'function' && !type.getDefaultProps.isReactClassApproved) {
|
|
1262
|
+
error('getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.');
|
|
1263
|
+
}
|
|
1264
|
+
}
|
|
1265
|
+
}
|
|
1266
|
+
/**
|
|
1267
|
+
* Given a fragment, validate that it can only be provided with fragment props
|
|
1268
|
+
* @param {ReactElement} fragment
|
|
1269
|
+
*/
|
|
1270
|
+
|
|
1271
|
+
|
|
1272
|
+
function validateFragmentProps(fragment) {
|
|
1273
|
+
{
|
|
1274
|
+
var keys = Object.keys(fragment.props);
|
|
1275
|
+
|
|
1276
|
+
for (var i = 0; i < keys.length; i++) {
|
|
1277
|
+
var key = keys[i];
|
|
1278
|
+
|
|
1279
|
+
if (key !== 'children' && key !== 'key') {
|
|
1280
|
+
setCurrentlyValidatingElement$1(fragment);
|
|
1281
|
+
|
|
1282
|
+
error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key);
|
|
1283
|
+
|
|
1284
|
+
setCurrentlyValidatingElement$1(null);
|
|
1285
|
+
break;
|
|
1286
|
+
}
|
|
1287
|
+
}
|
|
1288
|
+
|
|
1289
|
+
if (fragment.ref !== null) {
|
|
1290
|
+
setCurrentlyValidatingElement$1(fragment);
|
|
1291
|
+
|
|
1292
|
+
error('Invalid attribute `ref` supplied to `React.Fragment`.');
|
|
1293
|
+
|
|
1294
|
+
setCurrentlyValidatingElement$1(null);
|
|
1295
|
+
}
|
|
1296
|
+
}
|
|
1297
|
+
}
|
|
1298
|
+
|
|
1299
|
+
function jsxWithValidation(type, props, key, isStaticChildren, source, self) {
|
|
1300
|
+
{
|
|
1301
|
+
var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to
|
|
1302
|
+
// succeed and there will likely be errors in render.
|
|
1303
|
+
|
|
1304
|
+
if (!validType) {
|
|
1305
|
+
var info = '';
|
|
1306
|
+
|
|
1307
|
+
if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
|
|
1308
|
+
info += ' You likely forgot to export your component from the file ' + "it's defined in, or you might have mixed up default and named imports.";
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1311
|
+
var sourceInfo = getSourceInfoErrorAddendum(source);
|
|
1312
|
+
|
|
1313
|
+
if (sourceInfo) {
|
|
1314
|
+
info += sourceInfo;
|
|
1315
|
+
} else {
|
|
1316
|
+
info += getDeclarationErrorAddendum();
|
|
1317
|
+
}
|
|
1318
|
+
|
|
1319
|
+
var typeString;
|
|
1320
|
+
|
|
1321
|
+
if (type === null) {
|
|
1322
|
+
typeString = 'null';
|
|
1323
|
+
} else if (isArray(type)) {
|
|
1324
|
+
typeString = 'array';
|
|
1325
|
+
} else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {
|
|
1326
|
+
typeString = "<" + (getComponentNameFromType(type.type) || 'Unknown') + " />";
|
|
1327
|
+
info = ' Did you accidentally export a JSX literal instead of a component?';
|
|
1328
|
+
} else {
|
|
1329
|
+
typeString = typeof type;
|
|
1330
|
+
}
|
|
1331
|
+
|
|
1332
|
+
error('React.jsx: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info);
|
|
1333
|
+
}
|
|
1334
|
+
|
|
1335
|
+
var element = jsxDEV(type, props, key, source, self); // The result can be nullish if a mock or a custom function is used.
|
|
1336
|
+
// TODO: Drop this when these are no longer allowed as the type argument.
|
|
1337
|
+
|
|
1338
|
+
if (element == null) {
|
|
1339
|
+
return element;
|
|
1340
|
+
} // Skip key warning if the type isn't valid since our key validation logic
|
|
1341
|
+
// doesn't expect a non-string/function type and can throw confusing errors.
|
|
1342
|
+
// We don't want exception behavior to differ between dev and prod.
|
|
1343
|
+
// (Rendering will throw with a helpful message and as soon as the type is
|
|
1344
|
+
// fixed, the key warnings will appear.)
|
|
1345
|
+
|
|
1346
|
+
|
|
1347
|
+
if (validType) {
|
|
1348
|
+
var children = props.children;
|
|
1349
|
+
|
|
1350
|
+
if (children !== undefined) {
|
|
1351
|
+
if (isStaticChildren) {
|
|
1352
|
+
if (isArray(children)) {
|
|
1353
|
+
for (var i = 0; i < children.length; i++) {
|
|
1354
|
+
validateChildKeys(children[i], type);
|
|
1355
|
+
}
|
|
1356
|
+
|
|
1357
|
+
if (Object.freeze) {
|
|
1358
|
+
Object.freeze(children);
|
|
1359
|
+
}
|
|
1360
|
+
} else {
|
|
1361
|
+
error('React.jsx: Static children should always be an array. ' + 'You are likely explicitly calling React.jsxs or React.jsxDEV. ' + 'Use the Babel transform instead.');
|
|
1362
|
+
}
|
|
1363
|
+
} else {
|
|
1364
|
+
validateChildKeys(children, type);
|
|
1365
|
+
}
|
|
1366
|
+
}
|
|
1367
|
+
}
|
|
1368
|
+
|
|
1369
|
+
if (type === REACT_FRAGMENT_TYPE) {
|
|
1370
|
+
validateFragmentProps(element);
|
|
1371
|
+
} else {
|
|
1372
|
+
validatePropTypes(element);
|
|
1373
|
+
}
|
|
1374
|
+
|
|
1375
|
+
return element;
|
|
1376
|
+
}
|
|
1377
|
+
} // These two functions exist to still get child warnings in dev
|
|
1378
|
+
// even with the prod transform. This means that jsxDEV is purely
|
|
1379
|
+
// opt-in behavior for better messages but that we won't stop
|
|
1380
|
+
// giving you warnings if you use production apis.
|
|
1381
|
+
|
|
1382
|
+
function jsxWithValidationStatic(type, props, key) {
|
|
1383
|
+
{
|
|
1384
|
+
return jsxWithValidation(type, props, key, true);
|
|
1385
|
+
}
|
|
1386
|
+
}
|
|
1387
|
+
function jsxWithValidationDynamic(type, props, key) {
|
|
1388
|
+
{
|
|
1389
|
+
return jsxWithValidation(type, props, key, false);
|
|
1390
|
+
}
|
|
1391
|
+
}
|
|
1392
|
+
|
|
1393
|
+
var jsx = jsxWithValidationDynamic ; // we may want to special case jsxs internally to take advantage of static children.
|
|
1394
|
+
// for now we can ship identical prod functions
|
|
1395
|
+
|
|
1396
|
+
var jsxs = jsxWithValidationStatic ;
|
|
1397
|
+
|
|
1398
|
+
reactJsxRuntime_development.Fragment = REACT_FRAGMENT_TYPE;
|
|
1399
|
+
reactJsxRuntime_development.jsx = jsx;
|
|
1400
|
+
reactJsxRuntime_development.jsxs = jsxs;
|
|
1401
|
+
})();
|
|
1402
|
+
}
|
|
1403
|
+
return reactJsxRuntime_development;
|
|
1404
|
+
}
|
|
1405
|
+
|
|
1406
|
+
if (process.env.NODE_ENV === 'production') {
|
|
1407
|
+
jsxRuntime.exports = requireReactJsxRuntime_production_min();
|
|
1408
|
+
} else {
|
|
1409
|
+
jsxRuntime.exports = requireReactJsxRuntime_development();
|
|
1410
|
+
}
|
|
1411
|
+
|
|
1412
|
+
var jsxRuntimeExports = jsxRuntime.exports;
|
|
1413
|
+
|
|
59
1414
|
/** Returns true when the props are of type {@link DayPickerMultipleProps}. */
|
|
60
1415
|
function isDayPickerMultiple(props) {
|
|
61
1416
|
return props.mode === 'multiple';
|
|
@@ -309,7 +1664,7 @@ function DayPickerProvider(props) {
|
|
|
309
1664
|
onSelect = initialProps.onSelect;
|
|
310
1665
|
}
|
|
311
1666
|
var value = __assign(__assign(__assign({}, defaultContextValues), initialProps), { captionLayout: captionLayout, classNames: __assign(__assign({}, defaultContextValues.classNames), initialProps.classNames), components: __assign({}, initialProps.components), formatters: __assign(__assign({}, defaultContextValues.formatters), initialProps.formatters), fromDate: fromDate, labels: __assign(__assign({}, defaultContextValues.labels), initialProps.labels), mode: initialProps.mode || defaultContextValues.mode, modifiers: __assign(__assign({}, defaultContextValues.modifiers), initialProps.modifiers), modifiersClassNames: __assign(__assign({}, defaultContextValues.modifiersClassNames), initialProps.modifiersClassNames), onSelect: onSelect, styles: __assign(__assign({}, defaultContextValues.styles), initialProps.styles), toDate: toDate });
|
|
312
|
-
return (
|
|
1667
|
+
return (jsxRuntimeExports.jsx(DayPickerContext.Provider, __assign({ value: value }, { children: props.children })));
|
|
313
1668
|
}
|
|
314
1669
|
/**
|
|
315
1670
|
* Hook to access the {@link DayPickerContextValue}.
|
|
@@ -328,15 +1683,14 @@ function useDayPicker() {
|
|
|
328
1683
|
/** Render the caption for the displayed month. This component is used when `captionLayout="buttons"`. */
|
|
329
1684
|
function CaptionLabel(props) {
|
|
330
1685
|
var _a = useDayPicker(), locale = _a.locale, classNames = _a.classNames, styles = _a.styles, formatCaption = _a.formatters.formatCaption;
|
|
331
|
-
return (
|
|
1686
|
+
return (jsxRuntimeExports.jsx("div", __assign({ className: classNames.caption_label, style: styles.caption_label, "aria-live": "polite", role: "presentation", id: props.id }, { children: formatCaption(props.displayMonth, { locale: locale }) })));
|
|
332
1687
|
}
|
|
333
1688
|
|
|
334
1689
|
/**
|
|
335
1690
|
* Render the icon in the styled drop-down.
|
|
336
1691
|
*/
|
|
337
1692
|
function IconDropdown(props) {
|
|
338
|
-
return (
|
|
339
|
-
React__default.createElement("path", { d: "M4.22182541,48.2218254 C8.44222828,44.0014225 15.2388494,43.9273804 19.5496459,47.9996989 L19.7781746,48.2218254 L60,88.443 L100.221825,48.2218254 C104.442228,44.0014225 111.238849,43.9273804 115.549646,47.9996989 L115.778175,48.2218254 C119.998577,52.4422283 120.07262,59.2388494 116.000301,63.5496459 L115.778175,63.7781746 L67.7781746,111.778175 C63.5577717,115.998577 56.7611506,116.07262 52.4503541,112.000301 L52.2218254,111.778175 L4.22182541,63.7781746 C-0.0739418023,59.4824074 -0.0739418023,52.5175926 4.22182541,48.2218254 Z", fill: "currentColor", fillRule: "nonzero" })));
|
|
1693
|
+
return (jsxRuntimeExports.jsx("svg", __assign({ width: "8px", height: "8px", viewBox: "0 0 120 120", "data-testid": "iconDropdown" }, props, { children: jsxRuntimeExports.jsx("path", { d: "M4.22182541,48.2218254 C8.44222828,44.0014225 15.2388494,43.9273804 19.5496459,47.9996989 L19.7781746,48.2218254 L60,88.443 L100.221825,48.2218254 C104.442228,44.0014225 111.238849,43.9273804 115.549646,47.9996989 L115.778175,48.2218254 C119.998577,52.4422283 120.07262,59.2388494 116.000301,63.5496459 L115.778175,63.7781746 L67.7781746,111.778175 C63.5577717,115.998577 56.7611506,116.07262 52.4503541,112.000301 L52.2218254,111.778175 L4.22182541,63.7781746 C-0.0739418023,59.4824074 -0.0739418023,52.5175926 4.22182541,48.2218254 Z", fill: "currentColor", fillRule: "nonzero" }) })));
|
|
340
1694
|
}
|
|
341
1695
|
|
|
342
1696
|
/**
|
|
@@ -348,12 +1702,7 @@ function Dropdown(props) {
|
|
|
348
1702
|
var onChange = props.onChange, value = props.value, children = props.children, caption = props.caption, className = props.className, style = props.style;
|
|
349
1703
|
var dayPicker = useDayPicker();
|
|
350
1704
|
var IconDropdownComponent = (_b = (_a = dayPicker.components) === null || _a === void 0 ? void 0 : _a.IconDropdown) !== null && _b !== void 0 ? _b : IconDropdown;
|
|
351
|
-
return (
|
|
352
|
-
React__default.createElement("span", { className: dayPicker.classNames.vhidden }, props['aria-label']),
|
|
353
|
-
React__default.createElement("select", { name: props.name, "aria-label": props['aria-label'], className: dayPicker.classNames.dropdown, style: dayPicker.styles.dropdown, value: value, onChange: onChange }, children),
|
|
354
|
-
React__default.createElement("div", { className: dayPicker.classNames.caption_label, style: dayPicker.styles.caption_label, "aria-hidden": "true" },
|
|
355
|
-
caption,
|
|
356
|
-
React__default.createElement(IconDropdownComponent, { className: dayPicker.classNames.dropdown_icon, style: dayPicker.styles.dropdown_icon }))));
|
|
1705
|
+
return (jsxRuntimeExports.jsxs("div", __assign({ className: className, style: style }, { children: [jsxRuntimeExports.jsx("span", __assign({ className: dayPicker.classNames.vhidden }, { children: props['aria-label'] })), jsxRuntimeExports.jsx("select", __assign({ name: props.name, "aria-label": props['aria-label'], className: dayPicker.classNames.dropdown, style: dayPicker.styles.dropdown, value: value, onChange: onChange }, { children: children })), jsxRuntimeExports.jsxs("div", __assign({ className: dayPicker.classNames.caption_label, style: dayPicker.styles.caption_label, "aria-hidden": "true" }, { children: [caption, jsxRuntimeExports.jsx(IconDropdownComponent, { className: dayPicker.classNames.dropdown_icon, style: dayPicker.styles.dropdown_icon })] }))] })));
|
|
357
1706
|
}
|
|
358
1707
|
|
|
359
1708
|
/** Render the dropdown to navigate between months. */
|
|
@@ -362,9 +1711,9 @@ function MonthsDropdown(props) {
|
|
|
362
1711
|
var _b = useDayPicker(), fromDate = _b.fromDate, toDate = _b.toDate, styles = _b.styles, locale = _b.locale, formatMonthCaption = _b.formatters.formatMonthCaption, classNames = _b.classNames, components = _b.components, labelMonthDropdown = _b.labels.labelMonthDropdown;
|
|
363
1712
|
// Dropdown should appear only when both from/toDate is set
|
|
364
1713
|
if (!fromDate)
|
|
365
|
-
return
|
|
1714
|
+
return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, {});
|
|
366
1715
|
if (!toDate)
|
|
367
|
-
return
|
|
1716
|
+
return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, {});
|
|
368
1717
|
var dropdownMonths = [];
|
|
369
1718
|
if (isSameYear(fromDate, toDate)) {
|
|
370
1719
|
// only display the months included in the range
|
|
@@ -386,7 +1735,7 @@ function MonthsDropdown(props) {
|
|
|
386
1735
|
props.onChange(newMonth);
|
|
387
1736
|
};
|
|
388
1737
|
var DropdownComponent = (_a = components === null || components === void 0 ? void 0 : components.Dropdown) !== null && _a !== void 0 ? _a : Dropdown;
|
|
389
|
-
return (
|
|
1738
|
+
return (jsxRuntimeExports.jsx(DropdownComponent, __assign({ name: "months", "aria-label": labelMonthDropdown(), className: classNames.dropdown_month, style: styles.dropdown_month, onChange: handleChange, value: props.displayMonth.getMonth(), caption: formatMonthCaption(props.displayMonth, { locale: locale }) }, { children: dropdownMonths.map(function (m) { return (jsxRuntimeExports.jsx("option", __assign({ value: m.getMonth() }, { children: formatMonthCaption(m, { locale: locale }) }), m.getMonth())); }) })));
|
|
390
1739
|
}
|
|
391
1740
|
|
|
392
1741
|
/**
|
|
@@ -400,9 +1749,9 @@ function YearsDropdown(props) {
|
|
|
400
1749
|
var years = [];
|
|
401
1750
|
// Dropdown should appear only when both from/toDate is set
|
|
402
1751
|
if (!fromDate)
|
|
403
|
-
return
|
|
1752
|
+
return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, {});
|
|
404
1753
|
if (!toDate)
|
|
405
|
-
return
|
|
1754
|
+
return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, {});
|
|
406
1755
|
var fromYear = fromDate.getFullYear();
|
|
407
1756
|
var toYear = toDate.getFullYear();
|
|
408
1757
|
for (var year = fromYear; year <= toYear; year++) {
|
|
@@ -413,7 +1762,7 @@ function YearsDropdown(props) {
|
|
|
413
1762
|
props.onChange(newMonth);
|
|
414
1763
|
};
|
|
415
1764
|
var DropdownComponent = (_a = components === null || components === void 0 ? void 0 : components.Dropdown) !== null && _a !== void 0 ? _a : Dropdown;
|
|
416
|
-
return (
|
|
1765
|
+
return (jsxRuntimeExports.jsx(DropdownComponent, __assign({ name: "years", "aria-label": labelYearDropdown(), className: classNames.dropdown_year, style: styles.dropdown_year, onChange: handleChange, value: displayMonth.getFullYear(), caption: formatYearCaption(displayMonth, { locale: locale }) }, { children: years.map(function (year) { return (jsxRuntimeExports.jsx("option", __assign({ value: year.getFullYear() }, { children: formatYearCaption(year, { locale: locale }) }), year.getFullYear())); }) })));
|
|
417
1766
|
}
|
|
418
1767
|
|
|
419
1768
|
/**
|
|
@@ -577,7 +1926,7 @@ function NavigationProvider(props) {
|
|
|
577
1926
|
nextMonth: nextMonth,
|
|
578
1927
|
isDateDisplayed: isDateDisplayed
|
|
579
1928
|
};
|
|
580
|
-
return (
|
|
1929
|
+
return (jsxRuntimeExports.jsx(NavigationContext.Provider, __assign({ value: value }, { children: props.children })));
|
|
581
1930
|
}
|
|
582
1931
|
/**
|
|
583
1932
|
* Hook to access the {@link NavigationContextValue}. Use this hook to navigate
|
|
@@ -604,27 +1953,22 @@ function CaptionDropdowns(props) {
|
|
|
604
1953
|
goToMonth(addMonths(newMonth, props.displayIndex ? -props.displayIndex : 0));
|
|
605
1954
|
};
|
|
606
1955
|
var CaptionLabelComponent = (_a = components === null || components === void 0 ? void 0 : components.CaptionLabel) !== null && _a !== void 0 ? _a : CaptionLabel;
|
|
607
|
-
var captionLabel = (
|
|
608
|
-
return (
|
|
609
|
-
React__default.createElement("div", { className: classNames.vhidden }, captionLabel),
|
|
610
|
-
React__default.createElement(MonthsDropdown, { onChange: handleMonthChange, displayMonth: props.displayMonth }),
|
|
611
|
-
React__default.createElement(YearsDropdown, { onChange: handleMonthChange, displayMonth: props.displayMonth })));
|
|
1956
|
+
var captionLabel = (jsxRuntimeExports.jsx(CaptionLabelComponent, { id: props.id, displayMonth: props.displayMonth }));
|
|
1957
|
+
return (jsxRuntimeExports.jsxs("div", __assign({ className: classNames.caption_dropdowns, style: styles.caption_dropdowns }, { children: [jsxRuntimeExports.jsx("div", __assign({ className: classNames.vhidden }, { children: captionLabel })), jsxRuntimeExports.jsx(MonthsDropdown, { onChange: handleMonthChange, displayMonth: props.displayMonth }), jsxRuntimeExports.jsx(YearsDropdown, { onChange: handleMonthChange, displayMonth: props.displayMonth })] })));
|
|
612
1958
|
}
|
|
613
1959
|
|
|
614
1960
|
/**
|
|
615
1961
|
* Render the "previous month" button in the navigation.
|
|
616
1962
|
*/
|
|
617
1963
|
function IconLeft(props) {
|
|
618
|
-
return (
|
|
619
|
-
React__default.createElement("path", { d: "M69.490332,3.34314575 C72.6145263,0.218951416 77.6798462,0.218951416 80.8040405,3.34314575 C83.8617626,6.40086786 83.9268205,11.3179931 80.9992143,14.4548388 L80.8040405,14.6568542 L35.461,60 L80.8040405,105.343146 C83.8617626,108.400868 83.9268205,113.317993 80.9992143,116.454839 L80.8040405,116.656854 C77.7463184,119.714576 72.8291931,119.779634 69.6923475,116.852028 L69.490332,116.656854 L18.490332,65.6568542 C15.4326099,62.5991321 15.367552,57.6820069 18.2951583,54.5451612 L18.490332,54.3431458 L69.490332,3.34314575 Z", fill: "currentColor", fillRule: "nonzero" })));
|
|
1964
|
+
return (jsxRuntimeExports.jsx("svg", __assign({ width: "16px", height: "16px", viewBox: "0 0 120 120" }, props, { children: jsxRuntimeExports.jsx("path", { d: "M69.490332,3.34314575 C72.6145263,0.218951416 77.6798462,0.218951416 80.8040405,3.34314575 C83.8617626,6.40086786 83.9268205,11.3179931 80.9992143,14.4548388 L80.8040405,14.6568542 L35.461,60 L80.8040405,105.343146 C83.8617626,108.400868 83.9268205,113.317993 80.9992143,116.454839 L80.8040405,116.656854 C77.7463184,119.714576 72.8291931,119.779634 69.6923475,116.852028 L69.490332,116.656854 L18.490332,65.6568542 C15.4326099,62.5991321 15.367552,57.6820069 18.2951583,54.5451612 L18.490332,54.3431458 L69.490332,3.34314575 Z", fill: "currentColor", fillRule: "nonzero" }) })));
|
|
620
1965
|
}
|
|
621
1966
|
|
|
622
1967
|
/**
|
|
623
1968
|
* Render the "next month" button in the navigation.
|
|
624
1969
|
*/
|
|
625
1970
|
function IconRight(props) {
|
|
626
|
-
return (
|
|
627
|
-
React__default.createElement("path", { d: "M49.8040405,3.34314575 C46.6798462,0.218951416 41.6145263,0.218951416 38.490332,3.34314575 C35.4326099,6.40086786 35.367552,11.3179931 38.2951583,14.4548388 L38.490332,14.6568542 L83.8333725,60 L38.490332,105.343146 C35.4326099,108.400868 35.367552,113.317993 38.2951583,116.454839 L38.490332,116.656854 C41.5480541,119.714576 46.4651794,119.779634 49.602025,116.852028 L49.8040405,116.656854 L100.804041,65.6568542 C103.861763,62.5991321 103.926821,57.6820069 100.999214,54.5451612 L100.804041,54.3431458 L49.8040405,3.34314575 Z", fill: "currentColor" })));
|
|
1971
|
+
return (jsxRuntimeExports.jsx("svg", __assign({ width: "16px", height: "16px", viewBox: "0 0 120 120" }, props, { children: jsxRuntimeExports.jsx("path", { d: "M49.8040405,3.34314575 C46.6798462,0.218951416 41.6145263,0.218951416 38.490332,3.34314575 C35.4326099,6.40086786 35.367552,11.3179931 38.2951583,14.4548388 L38.490332,14.6568542 L83.8333725,60 L38.490332,105.343146 C35.4326099,108.400868 35.367552,113.317993 38.2951583,116.454839 L38.490332,116.656854 C41.5480541,119.714576 46.4651794,119.779634 49.602025,116.852028 L49.8040405,116.656854 L100.804041,65.6568542 C103.861763,62.5991321 103.926821,57.6820069 100.999214,54.5451612 L100.804041,54.3431458 L49.8040405,3.34314575 Z", fill: "currentColor" }) })));
|
|
628
1972
|
}
|
|
629
1973
|
|
|
630
1974
|
/** Render a button HTML element applying the reset class name. */
|
|
@@ -639,7 +1983,7 @@ var Button = forwardRef(function (props, ref) {
|
|
|
639
1983
|
if (props.style) {
|
|
640
1984
|
Object.assign(style, props.style);
|
|
641
1985
|
}
|
|
642
|
-
return (
|
|
1986
|
+
return (jsxRuntimeExports.jsx("button", __assign({}, props, { ref: ref, type: "button", className: className, style: style })));
|
|
643
1987
|
});
|
|
644
1988
|
|
|
645
1989
|
/** A component rendering the navigation buttons or the drop-downs. */
|
|
@@ -647,7 +1991,7 @@ function Navigation(props) {
|
|
|
647
1991
|
var _a, _b;
|
|
648
1992
|
var _c = useDayPicker(), dir = _c.dir, locale = _c.locale, classNames = _c.classNames, styles = _c.styles, _d = _c.labels, labelPrevious = _d.labelPrevious, labelNext = _d.labelNext, components = _c.components;
|
|
649
1993
|
if (!props.nextMonth && !props.previousMonth) {
|
|
650
|
-
return
|
|
1994
|
+
return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, {});
|
|
651
1995
|
}
|
|
652
1996
|
var previousLabel = labelPrevious(props.previousMonth, { locale: locale });
|
|
653
1997
|
var previousClassName = [
|
|
@@ -661,9 +2005,7 @@ function Navigation(props) {
|
|
|
661
2005
|
].join(' ');
|
|
662
2006
|
var IconRightComponent = (_a = components === null || components === void 0 ? void 0 : components.IconRight) !== null && _a !== void 0 ? _a : IconRight;
|
|
663
2007
|
var IconLeftComponent = (_b = components === null || components === void 0 ? void 0 : components.IconLeft) !== null && _b !== void 0 ? _b : IconLeft;
|
|
664
|
-
return (
|
|
665
|
-
!props.hidePrevious && (React__default.createElement(Button, { name: "previous-month", "aria-label": previousLabel, className: previousClassName, style: styles.nav_button_previous, disabled: !props.previousMonth, onClick: props.onPreviousClick }, dir === 'rtl' ? (React__default.createElement(IconRightComponent, { className: classNames.nav_icon, style: styles.nav_icon })) : (React__default.createElement(IconLeftComponent, { className: classNames.nav_icon, style: styles.nav_icon })))),
|
|
666
|
-
!props.hideNext && (React__default.createElement(Button, { name: "next-month", "aria-label": nextLabel, className: nextClassName, style: styles.nav_button_next, disabled: !props.nextMonth, onClick: props.onNextClick }, dir === 'rtl' ? (React__default.createElement(IconLeftComponent, { className: classNames.nav_icon, style: styles.nav_icon })) : (React__default.createElement(IconRightComponent, { className: classNames.nav_icon, style: styles.nav_icon }))))));
|
|
2008
|
+
return (jsxRuntimeExports.jsxs("div", __assign({ className: classNames.nav, style: styles.nav }, { children: [!props.hidePrevious && (jsxRuntimeExports.jsx(Button, __assign({ name: "previous-month", "aria-label": previousLabel, className: previousClassName, style: styles.nav_button_previous, disabled: !props.previousMonth, onClick: props.onPreviousClick }, { children: dir === 'rtl' ? (jsxRuntimeExports.jsx(IconRightComponent, { className: classNames.nav_icon, style: styles.nav_icon })) : (jsxRuntimeExports.jsx(IconLeftComponent, { className: classNames.nav_icon, style: styles.nav_icon })) }))), !props.hideNext && (jsxRuntimeExports.jsx(Button, __assign({ name: "next-month", "aria-label": nextLabel, className: nextClassName, style: styles.nav_button_next, disabled: !props.nextMonth, onClick: props.onNextClick }, { children: dir === 'rtl' ? (jsxRuntimeExports.jsx(IconLeftComponent, { className: classNames.nav_icon, style: styles.nav_icon })) : (jsxRuntimeExports.jsx(IconRightComponent, { className: classNames.nav_icon, style: styles.nav_icon })) })))] })));
|
|
667
2009
|
}
|
|
668
2010
|
|
|
669
2011
|
/**
|
|
@@ -689,7 +2031,7 @@ function CaptionNavigation(props) {
|
|
|
689
2031
|
return;
|
|
690
2032
|
goToMonth(nextMonth);
|
|
691
2033
|
};
|
|
692
|
-
return (
|
|
2034
|
+
return (jsxRuntimeExports.jsx(Navigation, { displayMonth: props.displayMonth, hideNext: hideNext, hidePrevious: hidePrevious, nextMonth: nextMonth, previousMonth: previousMonth, onPreviousClick: handlePreviousClick, onNextClick: handleNextClick }));
|
|
693
2035
|
}
|
|
694
2036
|
|
|
695
2037
|
/**
|
|
@@ -702,22 +2044,18 @@ function Caption(props) {
|
|
|
702
2044
|
var CaptionLabelComponent = (_a = components === null || components === void 0 ? void 0 : components.CaptionLabel) !== null && _a !== void 0 ? _a : CaptionLabel;
|
|
703
2045
|
var caption;
|
|
704
2046
|
if (disableNavigation) {
|
|
705
|
-
caption = (
|
|
2047
|
+
caption = (jsxRuntimeExports.jsx(CaptionLabelComponent, { id: props.id, displayMonth: props.displayMonth }));
|
|
706
2048
|
}
|
|
707
2049
|
else if (captionLayout === 'dropdown') {
|
|
708
|
-
caption = (
|
|
2050
|
+
caption = (jsxRuntimeExports.jsx(CaptionDropdowns, { displayMonth: props.displayMonth, id: props.id }));
|
|
709
2051
|
}
|
|
710
2052
|
else if (captionLayout === 'dropdown-buttons') {
|
|
711
|
-
caption = (
|
|
712
|
-
React__default.createElement(CaptionDropdowns, { displayMonth: props.displayMonth, displayIndex: props.displayIndex, id: props.id }),
|
|
713
|
-
React__default.createElement(CaptionNavigation, { displayMonth: props.displayMonth, displayIndex: props.displayIndex, id: props.id })));
|
|
2053
|
+
caption = (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx(CaptionDropdowns, { displayMonth: props.displayMonth, displayIndex: props.displayIndex, id: props.id }), jsxRuntimeExports.jsx(CaptionNavigation, { displayMonth: props.displayMonth, displayIndex: props.displayIndex, id: props.id })] }));
|
|
714
2054
|
}
|
|
715
2055
|
else {
|
|
716
|
-
caption = (
|
|
717
|
-
React__default.createElement(CaptionLabelComponent, { id: props.id, displayMonth: props.displayMonth, displayIndex: props.displayIndex }),
|
|
718
|
-
React__default.createElement(CaptionNavigation, { displayMonth: props.displayMonth, id: props.id })));
|
|
2056
|
+
caption = (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx(CaptionLabelComponent, { id: props.id, displayMonth: props.displayMonth, displayIndex: props.displayIndex }), jsxRuntimeExports.jsx(CaptionNavigation, { displayMonth: props.displayMonth, id: props.id })] }));
|
|
719
2057
|
}
|
|
720
|
-
return (
|
|
2058
|
+
return (jsxRuntimeExports.jsx("div", __assign({ className: classNames.caption, style: styles.caption }, { children: caption })));
|
|
721
2059
|
}
|
|
722
2060
|
|
|
723
2061
|
/** Render the Footer component (empty as default).*/
|
|
@@ -725,10 +2063,8 @@ function Caption(props) {
|
|
|
725
2063
|
function Footer(props) {
|
|
726
2064
|
var _a = useDayPicker(), footer = _a.footer, styles = _a.styles, tfoot = _a.classNames.tfoot;
|
|
727
2065
|
if (!footer)
|
|
728
|
-
return
|
|
729
|
-
return (
|
|
730
|
-
React__default.createElement("tr", null,
|
|
731
|
-
React__default.createElement("td", { colSpan: 8 }, footer))));
|
|
2066
|
+
return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, {});
|
|
2067
|
+
return (jsxRuntimeExports.jsx("tfoot", __assign({ className: tfoot, style: styles.tfoot }, { children: jsxRuntimeExports.jsx("tr", { children: jsxRuntimeExports.jsx("td", __assign({ colSpan: 8 }, { children: footer })) }) })));
|
|
732
2068
|
}
|
|
733
2069
|
|
|
734
2070
|
/**
|
|
@@ -757,9 +2093,7 @@ ISOWeek) {
|
|
|
757
2093
|
function HeadRow() {
|
|
758
2094
|
var _a = useDayPicker(), classNames = _a.classNames, styles = _a.styles, showWeekNumber = _a.showWeekNumber, locale = _a.locale, weekStartsOn = _a.weekStartsOn, ISOWeek = _a.ISOWeek, formatWeekdayName = _a.formatters.formatWeekdayName, labelWeekday = _a.labels.labelWeekday;
|
|
759
2095
|
var weekdays = getWeekdays(locale, weekStartsOn, ISOWeek);
|
|
760
|
-
return (
|
|
761
|
-
showWeekNumber && (React__default.createElement("td", { style: styles.head_cell, className: classNames.head_cell })),
|
|
762
|
-
weekdays.map(function (weekday, i) { return (React__default.createElement("th", { key: i, scope: "col", className: classNames.head_cell, style: styles.head_cell, "aria-label": labelWeekday(weekday, { locale: locale }) }, formatWeekdayName(weekday, { locale: locale }))); })));
|
|
2096
|
+
return (jsxRuntimeExports.jsxs("tr", __assign({ style: styles.head_row, className: classNames.head_row }, { children: [showWeekNumber && (jsxRuntimeExports.jsx("td", { style: styles.head_cell, className: classNames.head_cell })), weekdays.map(function (weekday, i) { return (jsxRuntimeExports.jsx("th", __assign({ scope: "col", className: classNames.head_cell, style: styles.head_cell, "aria-label": labelWeekday(weekday, { locale: locale }) }, { children: formatWeekdayName(weekday, { locale: locale }) }), i)); })] })));
|
|
763
2097
|
}
|
|
764
2098
|
|
|
765
2099
|
/** Render the table head. */
|
|
@@ -767,14 +2101,13 @@ function Head() {
|
|
|
767
2101
|
var _a;
|
|
768
2102
|
var _b = useDayPicker(), classNames = _b.classNames, styles = _b.styles, components = _b.components;
|
|
769
2103
|
var HeadRowComponent = (_a = components === null || components === void 0 ? void 0 : components.HeadRow) !== null && _a !== void 0 ? _a : HeadRow;
|
|
770
|
-
return (
|
|
771
|
-
React__default.createElement(HeadRowComponent, null)));
|
|
2104
|
+
return (jsxRuntimeExports.jsx("thead", __assign({ style: styles.head, className: classNames.head }, { children: jsxRuntimeExports.jsx(HeadRowComponent, {}) })));
|
|
772
2105
|
}
|
|
773
2106
|
|
|
774
2107
|
/** Render the content of the day cell. */
|
|
775
2108
|
function DayContent(props) {
|
|
776
2109
|
var _a = useDayPicker(), locale = _a.locale, formatDay = _a.formatters.formatDay;
|
|
777
|
-
return
|
|
2110
|
+
return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: formatDay(props.date, { locale: locale }) });
|
|
778
2111
|
}
|
|
779
2112
|
|
|
780
2113
|
/**
|
|
@@ -793,9 +2126,9 @@ function SelectMultipleProvider(props) {
|
|
|
793
2126
|
disabled: []
|
|
794
2127
|
}
|
|
795
2128
|
};
|
|
796
|
-
return (
|
|
2129
|
+
return (jsxRuntimeExports.jsx(SelectMultipleContext.Provider, __assign({ value: emptyContextValue }, { children: props.children })));
|
|
797
2130
|
}
|
|
798
|
-
return (
|
|
2131
|
+
return (jsxRuntimeExports.jsx(SelectMultipleProviderInternal, { initialProps: props.initialProps, children: props.children }));
|
|
799
2132
|
}
|
|
800
2133
|
function SelectMultipleProviderInternal(_a) {
|
|
801
2134
|
var initialProps = _a.initialProps, children = _a.children;
|
|
@@ -840,7 +2173,7 @@ function SelectMultipleProviderInternal(_a) {
|
|
|
840
2173
|
onDayClick: onDayClick,
|
|
841
2174
|
modifiers: modifiers
|
|
842
2175
|
};
|
|
843
|
-
return (
|
|
2176
|
+
return (jsxRuntimeExports.jsx(SelectMultipleContext.Provider, __assign({ value: contextValue }, { children: children })));
|
|
844
2177
|
}
|
|
845
2178
|
/**
|
|
846
2179
|
* Hook to access the {@link SelectMultipleContextValue}.
|
|
@@ -912,9 +2245,9 @@ function SelectRangeProvider(props) {
|
|
|
912
2245
|
disabled: []
|
|
913
2246
|
}
|
|
914
2247
|
};
|
|
915
|
-
return (
|
|
2248
|
+
return (jsxRuntimeExports.jsx(SelectRangeContext.Provider, __assign({ value: emptyContextValue }, { children: props.children })));
|
|
916
2249
|
}
|
|
917
|
-
return (
|
|
2250
|
+
return (jsxRuntimeExports.jsx(SelectRangeProviderInternal, { initialProps: props.initialProps, children: props.children }));
|
|
918
2251
|
}
|
|
919
2252
|
function SelectRangeProviderInternal(_a) {
|
|
920
2253
|
var initialProps = _a.initialProps, children = _a.children;
|
|
@@ -1003,7 +2336,7 @@ function SelectRangeProviderInternal(_a) {
|
|
|
1003
2336
|
});
|
|
1004
2337
|
}
|
|
1005
2338
|
}
|
|
1006
|
-
return (
|
|
2339
|
+
return (jsxRuntimeExports.jsx(SelectRangeContext.Provider, __assign({ value: { selected: selected, onDayClick: onDayClick, modifiers: modifiers } }, { children: children })));
|
|
1007
2340
|
}
|
|
1008
2341
|
/**
|
|
1009
2342
|
* Hook to access the {@link SelectRangeContextValue}.
|
|
@@ -1103,7 +2436,7 @@ function ModifiersProvider(props) {
|
|
|
1103
2436
|
var internalModifiers = getInternalModifiers(dayPicker, selectMultiple, selectRange);
|
|
1104
2437
|
var customModifiers = getCustomModifiers(dayPicker.modifiers);
|
|
1105
2438
|
var modifiers = __assign(__assign({}, internalModifiers), customModifiers);
|
|
1106
|
-
return (
|
|
2439
|
+
return (jsxRuntimeExports.jsx(ModifiersContext.Provider, __assign({ value: modifiers }, { children: props.children })));
|
|
1107
2440
|
}
|
|
1108
2441
|
/**
|
|
1109
2442
|
* Return the modifiers used by DayPicker.
|
|
@@ -1401,7 +2734,7 @@ function FocusProvider(props) {
|
|
|
1401
2734
|
focusStartOfWeek: function () { return moveFocus('startOfWeek', 'before'); },
|
|
1402
2735
|
focusEndOfWeek: function () { return moveFocus('endOfWeek', 'after'); }
|
|
1403
2736
|
};
|
|
1404
|
-
return (
|
|
2737
|
+
return (jsxRuntimeExports.jsx(FocusContext.Provider, __assign({ value: value }, { children: props.children })));
|
|
1405
2738
|
}
|
|
1406
2739
|
/**
|
|
1407
2740
|
* Hook to access the {@link FocusContextValue}. Use this hook to handle the
|
|
@@ -1449,9 +2782,9 @@ function SelectSingleProvider(props) {
|
|
|
1449
2782
|
var emptyContextValue = {
|
|
1450
2783
|
selected: undefined
|
|
1451
2784
|
};
|
|
1452
|
-
return (
|
|
2785
|
+
return (jsxRuntimeExports.jsx(SelectSingleContext.Provider, __assign({ value: emptyContextValue }, { children: props.children })));
|
|
1453
2786
|
}
|
|
1454
|
-
return (
|
|
2787
|
+
return (jsxRuntimeExports.jsx(SelectSingleProviderInternal, { initialProps: props.initialProps, children: props.children }));
|
|
1455
2788
|
}
|
|
1456
2789
|
function SelectSingleProviderInternal(_a) {
|
|
1457
2790
|
var initialProps = _a.initialProps, children = _a.children;
|
|
@@ -1468,7 +2801,7 @@ function SelectSingleProviderInternal(_a) {
|
|
|
1468
2801
|
selected: initialProps.selected,
|
|
1469
2802
|
onDayClick: onDayClick
|
|
1470
2803
|
};
|
|
1471
|
-
return (
|
|
2804
|
+
return (jsxRuntimeExports.jsx(SelectSingleContext.Provider, __assign({ value: contextValue }, { children: children })));
|
|
1472
2805
|
}
|
|
1473
2806
|
/**
|
|
1474
2807
|
* Hook to access the {@link SelectSingleContextValue}.
|
|
@@ -1738,7 +3071,7 @@ buttonRef) {
|
|
|
1738
3071
|
var isHidden = Boolean((activeModifiers.outside && !dayPicker.showOutsideDays) ||
|
|
1739
3072
|
activeModifiers.hidden);
|
|
1740
3073
|
var DayContentComponent = (_c = (_b = dayPicker.components) === null || _b === void 0 ? void 0 : _b.DayContent) !== null && _c !== void 0 ? _c : DayContent;
|
|
1741
|
-
var children = (
|
|
3074
|
+
var children = (jsxRuntimeExports.jsx(DayContentComponent, { date: day, displayMonth: displayMonth, activeModifiers: activeModifiers }));
|
|
1742
3075
|
var divProps = {
|
|
1743
3076
|
style: style,
|
|
1744
3077
|
className: className,
|
|
@@ -1769,12 +3102,12 @@ function Day(props) {
|
|
|
1769
3102
|
var buttonRef = useRef(null);
|
|
1770
3103
|
var dayRender = useDayRender(props.date, props.displayMonth, buttonRef);
|
|
1771
3104
|
if (dayRender.isHidden) {
|
|
1772
|
-
return
|
|
3105
|
+
return jsxRuntimeExports.jsx("div", { role: "gridcell" });
|
|
1773
3106
|
}
|
|
1774
3107
|
if (!dayRender.isButton) {
|
|
1775
|
-
return
|
|
3108
|
+
return jsxRuntimeExports.jsx("div", __assign({}, dayRender.divProps));
|
|
1776
3109
|
}
|
|
1777
|
-
return
|
|
3110
|
+
return jsxRuntimeExports.jsx(Button, __assign({ name: "day", ref: buttonRef }, dayRender.buttonProps));
|
|
1778
3111
|
}
|
|
1779
3112
|
|
|
1780
3113
|
/**
|
|
@@ -1786,13 +3119,13 @@ function WeekNumber(props) {
|
|
|
1786
3119
|
var _a = useDayPicker(), onWeekNumberClick = _a.onWeekNumberClick, styles = _a.styles, classNames = _a.classNames, locale = _a.locale, labelWeekNumber = _a.labels.labelWeekNumber, formatWeekNumber = _a.formatters.formatWeekNumber;
|
|
1787
3120
|
var content = formatWeekNumber(Number(weekNumber), { locale: locale });
|
|
1788
3121
|
if (!onWeekNumberClick) {
|
|
1789
|
-
return (
|
|
3122
|
+
return (jsxRuntimeExports.jsx("span", __assign({ className: classNames.weeknumber, style: styles.weeknumber }, { children: content })));
|
|
1790
3123
|
}
|
|
1791
3124
|
var label = labelWeekNumber(Number(weekNumber), { locale: locale });
|
|
1792
3125
|
var handleClick = function (e) {
|
|
1793
3126
|
onWeekNumberClick(weekNumber, dates, e);
|
|
1794
3127
|
};
|
|
1795
|
-
return (
|
|
3128
|
+
return (jsxRuntimeExports.jsx(Button, __assign({ name: "week-number", "aria-label": label, className: classNames.weeknumber, style: styles.weeknumber, onClick: handleClick }, { children: content })));
|
|
1796
3129
|
}
|
|
1797
3130
|
|
|
1798
3131
|
/** Render a row in the calendar, with the days and the week number. */
|
|
@@ -1803,13 +3136,9 @@ function Row(props) {
|
|
|
1803
3136
|
var WeeknumberComponent = (_b = components === null || components === void 0 ? void 0 : components.WeekNumber) !== null && _b !== void 0 ? _b : WeekNumber;
|
|
1804
3137
|
var weekNumberCell;
|
|
1805
3138
|
if (showWeekNumber) {
|
|
1806
|
-
weekNumberCell = (
|
|
1807
|
-
React__default.createElement(WeeknumberComponent, { number: props.weekNumber, dates: props.dates })));
|
|
3139
|
+
weekNumberCell = (jsxRuntimeExports.jsx("td", __assign({ className: classNames.cell, style: styles.cell }, { children: jsxRuntimeExports.jsx(WeeknumberComponent, { number: props.weekNumber, dates: props.dates }) })));
|
|
1808
3140
|
}
|
|
1809
|
-
return (
|
|
1810
|
-
weekNumberCell,
|
|
1811
|
-
props.dates.map(function (date) { return (React__default.createElement("td", { className: classNames.cell, style: styles.cell, key: getUnixTime(date), role: "presentation" },
|
|
1812
|
-
React__default.createElement(DayComponent, { displayMonth: props.displayMonth, date: date }))); })));
|
|
3141
|
+
return (jsxRuntimeExports.jsxs("tr", __assign({ className: classNames.row, style: styles.row }, { children: [weekNumberCell, props.dates.map(function (date) { return (jsxRuntimeExports.jsx("td", __assign({ className: classNames.cell, style: styles.cell, role: "presentation" }, { children: jsxRuntimeExports.jsx(DayComponent, { displayMonth: props.displayMonth, date: date }) }), getUnixTime(date))); })] })));
|
|
1813
3142
|
}
|
|
1814
3143
|
|
|
1815
3144
|
/** Return the weeks between two dates. */
|
|
@@ -1877,10 +3206,7 @@ function Table(props) {
|
|
|
1877
3206
|
var HeadComponent = (_a = components === null || components === void 0 ? void 0 : components.Head) !== null && _a !== void 0 ? _a : Head;
|
|
1878
3207
|
var RowComponent = (_b = components === null || components === void 0 ? void 0 : components.Row) !== null && _b !== void 0 ? _b : Row;
|
|
1879
3208
|
var FooterComponent = (_c = components === null || components === void 0 ? void 0 : components.Footer) !== null && _c !== void 0 ? _c : Footer;
|
|
1880
|
-
return (
|
|
1881
|
-
!hideHead && React__default.createElement(HeadComponent, null),
|
|
1882
|
-
React__default.createElement("tbody", { className: classNames.tbody, style: styles.tbody }, weeks.map(function (week) { return (React__default.createElement(RowComponent, { displayMonth: props.displayMonth, key: week.weekNumber, dates: week.dates, weekNumber: week.weekNumber })); })),
|
|
1883
|
-
React__default.createElement(FooterComponent, { displayMonth: props.displayMonth })));
|
|
3209
|
+
return (jsxRuntimeExports.jsxs("table", __assign({ id: props.id, className: classNames.table, style: styles.table, role: "grid", "aria-labelledby": props['aria-labelledby'] }, { children: [!hideHead && jsxRuntimeExports.jsx(HeadComponent, {}), jsxRuntimeExports.jsx("tbody", __assign({ className: classNames.tbody, style: styles.tbody }, { children: weeks.map(function (week) { return (jsxRuntimeExports.jsx(RowComponent, { displayMonth: props.displayMonth, dates: week.dates, weekNumber: week.weekNumber }, week.weekNumber)); }) })), jsxRuntimeExports.jsx(FooterComponent, { displayMonth: props.displayMonth })] })));
|
|
1884
3210
|
}
|
|
1885
3211
|
|
|
1886
3212
|
/*
|
|
@@ -1894,6 +3220,62 @@ The above copyright notice and this permission notice shall be included in all c
|
|
|
1894
3220
|
|
|
1895
3221
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
1896
3222
|
*/
|
|
3223
|
+
/* eslint-disable prefer-const */
|
|
3224
|
+
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
3225
|
+
/*
|
|
3226
|
+
* Welcome to @reach/auto-id!
|
|
3227
|
+
* Let's see if we can make sense of why this hook exists and its
|
|
3228
|
+
* implementation.
|
|
3229
|
+
*
|
|
3230
|
+
* Some background:
|
|
3231
|
+
* 1. Accessibility APIs rely heavily on element IDs
|
|
3232
|
+
* 2. Requiring developers to put IDs on every element in Reach UI is both
|
|
3233
|
+
* cumbersome and error-prone
|
|
3234
|
+
* 3. With a component model, we can generate IDs for them!
|
|
3235
|
+
*
|
|
3236
|
+
* Solution 1: Generate random IDs.
|
|
3237
|
+
*
|
|
3238
|
+
* This works great as long as you don't server render your app. When React (in
|
|
3239
|
+
* the client) tries to reuse the markup from the server, the IDs won't match
|
|
3240
|
+
* and React will then recreate the entire DOM tree.
|
|
3241
|
+
*
|
|
3242
|
+
* Solution 2: Increment an integer
|
|
3243
|
+
*
|
|
3244
|
+
* This sounds great. Since we're rendering the exact same tree on the server
|
|
3245
|
+
* and client, we can increment a counter and get a deterministic result between
|
|
3246
|
+
* client and server. Also, JS integers can go up to nine-quadrillion. I'm
|
|
3247
|
+
* pretty sure the tab will be closed before an app never needs
|
|
3248
|
+
* 10 quadrillion IDs!
|
|
3249
|
+
*
|
|
3250
|
+
* Problem solved, right?
|
|
3251
|
+
*
|
|
3252
|
+
* Ah, but there's a catch! React's concurrent rendering makes this approach
|
|
3253
|
+
* non-deterministic. While the client and server will end up with the same
|
|
3254
|
+
* elements in the end, depending on suspense boundaries (and possibly some user
|
|
3255
|
+
* input during the initial render) the incrementing integers won't always match
|
|
3256
|
+
* up.
|
|
3257
|
+
*
|
|
3258
|
+
* Solution 3: Don't use IDs at all on the server; patch after first render.
|
|
3259
|
+
*
|
|
3260
|
+
* What we've done here is solution 2 with some tricks. With this approach, the
|
|
3261
|
+
* ID returned is an empty string on the first render. This way the server and
|
|
3262
|
+
* client have the same markup no matter how wild the concurrent rendering may
|
|
3263
|
+
* have gotten.
|
|
3264
|
+
*
|
|
3265
|
+
* After the render, we patch up the components with an incremented ID. This
|
|
3266
|
+
* causes a double render on any components with `useId`. Shouldn't be a problem
|
|
3267
|
+
* since the components using this hook should be small, and we're only updating
|
|
3268
|
+
* the ID attribute on the DOM, nothing big is happening.
|
|
3269
|
+
*
|
|
3270
|
+
* It doesn't have to be an incremented number, though--we could do generate
|
|
3271
|
+
* random strings instead, but incrementing a number is probably the cheapest
|
|
3272
|
+
* thing we can do.
|
|
3273
|
+
*
|
|
3274
|
+
* Additionally, we only do this patchup on the very first client render ever.
|
|
3275
|
+
* Any calls to `useId` that happen dynamically in the client will be
|
|
3276
|
+
* populated immediately with a value. So, we only get the double render after
|
|
3277
|
+
* server hydration and never again, SO BACK OFF ALRIGHT?
|
|
3278
|
+
*/
|
|
1897
3279
|
function canUseDOM() {
|
|
1898
3280
|
return !!(typeof window !== 'undefined' &&
|
|
1899
3281
|
window.document &&
|
|
@@ -1923,9 +3305,7 @@ function canUseDOM() {
|
|
|
1923
3305
|
* @param effect
|
|
1924
3306
|
* @param deps
|
|
1925
3307
|
*/
|
|
1926
|
-
var useIsomorphicLayoutEffect = canUseDOM()
|
|
1927
|
-
? React.useLayoutEffect
|
|
1928
|
-
: React.useEffect;
|
|
3308
|
+
var useIsomorphicLayoutEffect = canUseDOM() ? useLayoutEffect : useEffect;
|
|
1929
3309
|
var serverHandoffComplete = false;
|
|
1930
3310
|
var id = 0;
|
|
1931
3311
|
function genId() {
|
|
@@ -1938,7 +3318,7 @@ function useId(providedId) {
|
|
|
1938
3318
|
// If this instance isn't part of the initial render, we don't have to do the
|
|
1939
3319
|
// double render/patch-up dance. We can just generate the ID and return it.
|
|
1940
3320
|
var initialId = providedId !== null && providedId !== void 0 ? providedId : (serverHandoffComplete ? genId() : null);
|
|
1941
|
-
var _b =
|
|
3321
|
+
var _b = useState(initialId), id = _b[0], setId = _b[1];
|
|
1942
3322
|
useIsomorphicLayoutEffect(function () {
|
|
1943
3323
|
if (id === null) {
|
|
1944
3324
|
// Patch the ID after render. We do this in `useLayoutEffect` to avoid any
|
|
@@ -1949,7 +3329,7 @@ function useId(providedId) {
|
|
|
1949
3329
|
}
|
|
1950
3330
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1951
3331
|
}, []);
|
|
1952
|
-
|
|
3332
|
+
useEffect(function () {
|
|
1953
3333
|
if (serverHandoffComplete === false) {
|
|
1954
3334
|
// Flag all future uses of `useId` to skip the update dance. This is in
|
|
1955
3335
|
// `useEffect` because it goes after `useLayoutEffect`, ensuring we don't
|
|
@@ -1992,18 +3372,25 @@ function Month(props) {
|
|
|
1992
3372
|
style = __assign(__assign({}, style), styles.caption_between);
|
|
1993
3373
|
}
|
|
1994
3374
|
var CaptionComponent = (_b = components === null || components === void 0 ? void 0 : components.Caption) !== null && _b !== void 0 ? _b : Caption;
|
|
1995
|
-
return (
|
|
1996
|
-
|
|
1997
|
-
|
|
3375
|
+
return (jsxRuntimeExports.jsxs("div", __assign({ className: className.join(' '), style: style }, { children: [jsxRuntimeExports.jsx(CaptionComponent, { id: captionId, displayMonth: props.displayMonth, displayIndex: props.displayIndex }), jsxRuntimeExports.jsx(Table, { id: tableId, "aria-labelledby": captionId, displayMonth: props.displayMonth })] }), props.displayIndex));
|
|
3376
|
+
}
|
|
3377
|
+
|
|
3378
|
+
/**
|
|
3379
|
+
* Render the wrapper for the month grids.
|
|
3380
|
+
*/
|
|
3381
|
+
function Months(props) {
|
|
3382
|
+
var _a = useDayPicker(), classNames = _a.classNames, styles = _a.styles;
|
|
3383
|
+
return (jsxRuntimeExports.jsx("div", __assign({ className: classNames.months, style: styles.months }, { children: props.children })));
|
|
1998
3384
|
}
|
|
1999
3385
|
|
|
2000
3386
|
/** Render the container with the months according to the number of months to display. */
|
|
2001
3387
|
function Root(_a) {
|
|
3388
|
+
var _b, _c;
|
|
2002
3389
|
var initialProps = _a.initialProps;
|
|
2003
3390
|
var dayPicker = useDayPicker();
|
|
2004
3391
|
var focusContext = useFocusContext();
|
|
2005
3392
|
var navigation = useNavigation();
|
|
2006
|
-
var
|
|
3393
|
+
var _d = useState(false), hasInitialFocus = _d[0], setHasInitialFocus = _d[1];
|
|
2007
3394
|
// Focus the focus target when initialFocus is passed in
|
|
2008
3395
|
useEffect(function () {
|
|
2009
3396
|
if (!dayPicker.initialFocus)
|
|
@@ -2036,20 +3423,14 @@ function Root(_a) {
|
|
|
2036
3423
|
var _a;
|
|
2037
3424
|
return __assign(__assign({}, attrs), (_a = {}, _a[key] = initialProps[key], _a));
|
|
2038
3425
|
}, {});
|
|
2039
|
-
|
|
2040
|
-
|
|
3426
|
+
var MonthsComponent = (_c = (_b = initialProps.components) === null || _b === void 0 ? void 0 : _b.Months) !== null && _c !== void 0 ? _c : Months;
|
|
3427
|
+
return (jsxRuntimeExports.jsx("div", __assign({ className: classNames.join(' '), style: style, dir: dayPicker.dir, id: dayPicker.id, nonce: initialProps.nonce, title: initialProps.title, lang: initialProps.lang }, dataAttributes, { children: jsxRuntimeExports.jsx(MonthsComponent, { children: navigation.displayMonths.map(function (month, i) { return (jsxRuntimeExports.jsx(Month, { displayIndex: i, displayMonth: month }, i)); }) }) })));
|
|
2041
3428
|
}
|
|
2042
3429
|
|
|
2043
3430
|
/** Provide the value for all the context providers. */
|
|
2044
3431
|
function RootProvider(props) {
|
|
2045
3432
|
var children = props.children, initialProps = __rest(props, ["children"]);
|
|
2046
|
-
return (
|
|
2047
|
-
React__default.createElement(NavigationProvider, null,
|
|
2048
|
-
React__default.createElement(SelectSingleProvider, { initialProps: initialProps },
|
|
2049
|
-
React__default.createElement(SelectMultipleProvider, { initialProps: initialProps },
|
|
2050
|
-
React__default.createElement(SelectRangeProvider, { initialProps: initialProps },
|
|
2051
|
-
React__default.createElement(ModifiersProvider, null,
|
|
2052
|
-
React__default.createElement(FocusProvider, null, children))))))));
|
|
3433
|
+
return (jsxRuntimeExports.jsx(DayPickerProvider, __assign({ initialProps: initialProps }, { children: jsxRuntimeExports.jsx(NavigationProvider, { children: jsxRuntimeExports.jsx(SelectSingleProvider, __assign({ initialProps: initialProps }, { children: jsxRuntimeExports.jsx(SelectMultipleProvider, __assign({ initialProps: initialProps }, { children: jsxRuntimeExports.jsx(SelectRangeProvider, __assign({ initialProps: initialProps }, { children: jsxRuntimeExports.jsx(ModifiersProvider, { children: jsxRuntimeExports.jsx(FocusProvider, { children: children }) }) })) })) })) }) })));
|
|
2053
3434
|
}
|
|
2054
3435
|
|
|
2055
3436
|
/**
|
|
@@ -2140,8 +3521,7 @@ function RootProvider(props) {
|
|
|
2140
3521
|
* ```
|
|
2141
3522
|
*/
|
|
2142
3523
|
function DayPicker(props) {
|
|
2143
|
-
return (
|
|
2144
|
-
React__default.createElement(Root, { initialProps: props })));
|
|
3524
|
+
return (jsxRuntimeExports.jsx(RootProvider, __assign({}, props, { children: jsxRuntimeExports.jsx(Root, { initialProps: props }) })));
|
|
2145
3525
|
}
|
|
2146
3526
|
|
|
2147
3527
|
/** @private */
|
|
@@ -2246,5 +3626,5 @@ function isDayPickerDefault(props) {
|
|
|
2246
3626
|
return props.mode === undefined || props.mode === 'default';
|
|
2247
3627
|
}
|
|
2248
3628
|
|
|
2249
|
-
export { Button, Caption, CaptionDropdowns, CaptionLabel, CaptionNavigation, Day, DayContent, DayPicker, DayPickerContext, DayPickerProvider, Dropdown, FocusContext, FocusProvider, Footer, Head, HeadRow, IconDropdown, IconLeft, IconRight, InternalModifier, NavigationContext, NavigationProvider, RootProvider, Row, SelectMultipleContext, SelectMultipleProvider, SelectMultipleProviderInternal, SelectRangeContext, SelectRangeProvider, SelectRangeProviderInternal, SelectSingleContext, SelectSingleProvider, SelectSingleProviderInternal, WeekNumber, addToRange, isDateAfterType, isDateBeforeType, isDateInterval, isDateRange, isDayOfWeekType, isDayPickerDefault, isDayPickerMultiple, isDayPickerRange, isDayPickerSingle, isMatch, useActiveModifiers, useDayPicker, useDayRender, useFocusContext, useInput, useNavigation, useSelectMultiple, useSelectRange, useSelectSingle };
|
|
3629
|
+
export { Button, Caption, CaptionDropdowns, CaptionLabel, CaptionNavigation, Day, DayContent, DayPicker, DayPickerContext, DayPickerProvider, Dropdown, FocusContext, FocusProvider, Footer, Head, HeadRow, IconDropdown, IconLeft, IconRight, InternalModifier, Months, NavigationContext, NavigationProvider, RootProvider, Row, SelectMultipleContext, SelectMultipleProvider, SelectMultipleProviderInternal, SelectRangeContext, SelectRangeProvider, SelectRangeProviderInternal, SelectSingleContext, SelectSingleProvider, SelectSingleProviderInternal, WeekNumber, addToRange, isDateAfterType, isDateBeforeType, isDateInterval, isDateRange, isDayOfWeekType, isDayPickerDefault, isDayPickerMultiple, isDayPickerRange, isDayPickerSingle, isMatch, useActiveModifiers, useDayPicker, useDayRender, useFocusContext, useInput, useNavigation, useSelectMultiple, useSelectRange, useSelectSingle };
|
|
2250
3630
|
//# sourceMappingURL=index.esm.js.map
|