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