@moda/om 21.0.0-next.1 → 21.0.0
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/dist/index.cjs.js +2194 -1983
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +2193 -1982
- package/dist/index.esm.js.map +1 -1
- package/dist/src/components/Checkbox/Checkbox.d.ts +1 -1
- package/dist/src/components/Clickable/Clickable.d.ts +2 -7
- package/dist/src/components/Field/Field.d.ts +1 -1
- package/dist/src/components/NavigationPreventer/NavigationPreventer.d.ts +2 -1
- package/dist/src/components/PasswordInput/PasswordInput.d.ts +1 -1
- package/dist/src/components/Popover/Popover.d.ts +1 -1
- package/dist/src/components/PromoBanner/PromoBanner.d.ts +1 -1
- package/dist/src/components/RadioButton/RadioButton.d.ts +1 -1
- package/dist/src/components/Select/useSelect.d.ts +3 -3
- package/dist/src/components/Tabs/Tab.d.ts +1 -1
- package/dist/src/components/Text/Text.d.ts +2 -2
- package/dist/src/hooks/useClickOutside.d.ts +1 -1
- package/dist/src/index.d.ts +10 -1
- package/dist/src/utilities/States/State.d.ts +6 -7
- package/dist/src/utilities/States/StateProps.d.ts +7 -0
- package/dist/src/utilities/States/States.d.ts +6 -7
- package/dist/src/utilities/States/Styles.d.ts +14 -0
- package/dist/src/utilities/States/index.d.ts +1 -0
- package/dist/src/utilities/index.d.ts +7 -0
- package/dist/src/utilities/isEmpty.d.ts +1 -0
- package/dist/src/utilities/isRenderProps.d.ts +5 -0
- package/dist/src/utilities/stringifyProps.d.ts +1 -0
- package/dist/src/utilities/truncate.d.ts +1 -0
- package/dist/styles.css +1 -1
- package/package.json +71 -66
- package/src/components/AspectRatioBox/AspectRatioBox.stories.tsx +1 -1
- package/src/components/Badge/Badge.stories.tsx +1 -1
- package/src/components/Breadcrumbs/Breadcrumbs.stories.tsx +1 -1
- package/src/components/Breadcrumbs/Breadcrumbs.tsx +2 -2
- package/src/components/Breakpoint/Breakpoint.stories.tsx +3 -6
- package/src/components/Button/Button.stories.tsx +10 -7
- package/src/components/Checkbox/Checkbox.stories.tsx +1 -1
- package/src/components/Checkbox/Checkbox.tsx +1 -1
- package/src/components/Clickable/Clickable.stories.tsx +7 -4
- package/src/components/Clickable/Clickable.tsx +3 -6
- package/src/components/ColorSwatch/ColorSwatch.stories.tsx +1 -1
- package/src/components/ControlLink/ControlLink.stories.tsx +12 -7
- package/src/components/CreditCardNumberInput/CreditCardNumberInput.stories.tsx +1 -1
- package/src/components/CreditCardNumberInput/CreditCardNumberInput.test.tsx +3 -6
- package/src/components/CreditCardNumberInput/CreditCardNumberInput.tsx +5 -13
- package/src/components/DefinitionList/DefinitionList.stories.tsx +1 -1
- package/src/components/Divider/Divider.stories.tsx +1 -1
- package/src/components/Expandable/Expandable.stories.tsx +1 -1
- package/src/components/Field/Field.stories.tsx +1 -1
- package/src/components/Field/Field.tsx +1 -1
- package/src/components/Label/Label.stories.tsx +1 -1
- package/src/components/LoadingItemsLavenderBlue/LoadingItems.stories.tsx +1 -1
- package/src/components/LoadingItemsPinkGreen/LoadingItems.stories.tsx +1 -1
- package/src/components/LoadingShapes/LoadingShapes.stories.tsx +1 -1
- package/src/components/LoadingShapesLavenderBlue/LoadingShapesLavenderBlue.stories.tsx +1 -1
- package/src/components/LoadingShapesPinkGreen/LoadingShapesPinkGreen.stories.tsx +1 -1
- package/src/components/NavigationPreventer/NavigationPreventer.tsx +5 -5
- package/src/components/Overlay/Overlay.stories.tsx +1 -1
- package/src/components/PasswordInput/PasswordInput.stories.tsx +1 -1
- package/src/components/Popover/Popover.stories.tsx +1 -1
- package/src/components/Popover/Popover.tsx +1 -1
- package/src/components/PromoBanner/PromoBanner.stories.tsx +1 -1
- package/src/components/PromoBanner/PromoBanner.tsx +1 -1
- package/src/components/RadioButton/RadioButton.stories.tsx +1 -1
- package/src/components/RadioButton/RadioButton.tsx +1 -1
- package/src/components/SearchInput/SearchInput.stories.tsx +1 -1
- package/src/components/Select/Select.stories.tsx +2 -3
- package/src/components/Select/Select.test.tsx +5 -5
- package/src/components/SelectableButton/SelectableButton.stories.tsx +1 -1
- package/src/components/Shape/Shape.stories.tsx +1 -1
- package/src/components/Stack/Stack.stories.tsx +1 -1
- package/src/components/Tabs/Tab.tsx +1 -1
- package/src/components/Tabs/Tabs.stories.tsx +1 -1
- package/src/components/Tag/Tag.stories.tsx +1 -1
- package/src/components/Text/Text.scss +1 -1
- package/src/components/Text/Text.stories.tsx +1 -1
- package/src/components/Text/Text.tsx +2 -2
- package/src/components/TextInput/TextInput.stories.tsx +1 -1
- package/src/components/Textarea/Textarea.stories.tsx +1 -1
- package/src/components/Toast/Toast.stories.tsx +1 -1
- package/src/components/VerticalDivider/VerticalDivider.stories.tsx +1 -1
- package/src/hooks/useClickOutside.ts +4 -1
- package/src/index.scss +0 -1
- package/src/index.ts +2 -0
- package/src/utilities/States/State.tsx +13 -13
- package/src/utilities/States/StateProps.tsx +28 -0
- package/src/utilities/States/States.tsx +9 -11
- package/src/utilities/States/Styles.tsx +43 -0
- package/src/utilities/States/index.ts +1 -0
- package/src/utilities/index.ts +7 -0
- package/src/utilities/isEmpty.ts +1 -0
- package/src/utilities/isRenderProps.ts +9 -0
- package/src/utilities/{States/stringifyProps.tsx → stringifyProps.ts} +2 -7
- package/src/utilities/truncate.ts +5 -0
- package/dist/src/utilities/States/StatesProps.d.ts +0 -8
- package/dist/src/utilities/States/isRenderProps.d.ts +0 -4
- package/dist/src/utilities/States/stringifyProps.d.ts +0 -1
- package/src/functions/_functions.scss +0 -0
- package/src/utilities/States/State.scss +0 -11
- package/src/utilities/States/States.scss +0 -5
- package/src/utilities/States/StatesProps.scss +0 -24
- package/src/utilities/States/StatesProps.tsx +0 -31
- package/src/utilities/States/isRenderProps.ts +0 -7
package/dist/index.esm.js
CHANGED
|
@@ -1,12 +1,335 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import React__default, { useState, createContext,
|
|
3
|
-
import Link from '
|
|
4
|
-
import
|
|
2
|
+
import React__default, { useContext, useState, createContext, forwardRef, useRef, useCallback, useEffect, useMemo, Fragment, PureComponent, Children, isValidElement, cloneElement, useReducer } from 'react';
|
|
3
|
+
import { Link, Prompt } from 'react-router-dom';
|
|
4
|
+
import { createPortal } from 'react-dom';
|
|
5
5
|
|
|
6
6
|
function getDefaultExportFromCjs (x) {
|
|
7
7
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
+
function getAugmentedNamespace(n) {
|
|
11
|
+
if (Object.prototype.hasOwnProperty.call(n, '__esModule')) return n;
|
|
12
|
+
var f = n.default;
|
|
13
|
+
if (typeof f == "function") {
|
|
14
|
+
var a = function a () {
|
|
15
|
+
if (this instanceof a) {
|
|
16
|
+
return Reflect.construct(f, arguments, this.constructor);
|
|
17
|
+
}
|
|
18
|
+
return f.apply(this, arguments);
|
|
19
|
+
};
|
|
20
|
+
a.prototype = f.prototype;
|
|
21
|
+
} else a = {};
|
|
22
|
+
Object.defineProperty(a, '__esModule', {value: true});
|
|
23
|
+
Object.keys(n).forEach(function (k) {
|
|
24
|
+
var d = Object.getOwnPropertyDescriptor(n, k);
|
|
25
|
+
Object.defineProperty(a, k, d.get ? d : {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function () {
|
|
28
|
+
return n[k];
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
return a;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
var focusVisible$1 = {exports: {}};
|
|
36
|
+
|
|
37
|
+
var focusVisible = focusVisible$1.exports;
|
|
38
|
+
var hasRequiredFocusVisible;
|
|
39
|
+
function requireFocusVisible() {
|
|
40
|
+
if (hasRequiredFocusVisible) return focusVisible$1.exports;
|
|
41
|
+
hasRequiredFocusVisible = 1;
|
|
42
|
+
(function (module, exports) {
|
|
43
|
+
(function (global, factory) {
|
|
44
|
+
factory() ;
|
|
45
|
+
})(focusVisible, function () {
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Applies the :focus-visible polyfill at the given scope.
|
|
49
|
+
* A scope in this case is either the top-level Document or a Shadow Root.
|
|
50
|
+
*
|
|
51
|
+
* @param {(Document|ShadowRoot)} scope
|
|
52
|
+
* @see https://github.com/WICG/focus-visible
|
|
53
|
+
*/
|
|
54
|
+
function applyFocusVisiblePolyfill(scope) {
|
|
55
|
+
var hadKeyboardEvent = true;
|
|
56
|
+
var hadFocusVisibleRecently = false;
|
|
57
|
+
var hadFocusVisibleRecentlyTimeout = null;
|
|
58
|
+
var inputTypesAllowlist = {
|
|
59
|
+
text: true,
|
|
60
|
+
search: true,
|
|
61
|
+
url: true,
|
|
62
|
+
tel: true,
|
|
63
|
+
email: true,
|
|
64
|
+
password: true,
|
|
65
|
+
number: true,
|
|
66
|
+
date: true,
|
|
67
|
+
month: true,
|
|
68
|
+
week: true,
|
|
69
|
+
time: true,
|
|
70
|
+
datetime: true,
|
|
71
|
+
'datetime-local': true
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Helper function for legacy browsers and iframes which sometimes focus
|
|
76
|
+
* elements like document, body, and non-interactive SVG.
|
|
77
|
+
* @param {Element} el
|
|
78
|
+
*/
|
|
79
|
+
function isValidFocusTarget(el) {
|
|
80
|
+
if (el && el !== document && el.nodeName !== 'HTML' && el.nodeName !== 'BODY' && 'classList' in el && 'contains' in el.classList) {
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Computes whether the given element should automatically trigger the
|
|
88
|
+
* `focus-visible` class being added, i.e. whether it should always match
|
|
89
|
+
* `:focus-visible` when focused.
|
|
90
|
+
* @param {Element} el
|
|
91
|
+
* @return {boolean}
|
|
92
|
+
*/
|
|
93
|
+
function focusTriggersKeyboardModality(el) {
|
|
94
|
+
var type = el.type;
|
|
95
|
+
var tagName = el.tagName;
|
|
96
|
+
if (tagName === 'INPUT' && inputTypesAllowlist[type] && !el.readOnly) {
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
99
|
+
if (tagName === 'TEXTAREA' && !el.readOnly) {
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
if (el.isContentEditable) {
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Add the `focus-visible` class to the given element if it was not added by
|
|
110
|
+
* the author.
|
|
111
|
+
* @param {Element} el
|
|
112
|
+
*/
|
|
113
|
+
function addFocusVisibleClass(el) {
|
|
114
|
+
if (el.classList.contains('focus-visible')) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
el.classList.add('focus-visible');
|
|
118
|
+
el.setAttribute('data-focus-visible-added', '');
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Remove the `focus-visible` class from the given element if it was not
|
|
123
|
+
* originally added by the author.
|
|
124
|
+
* @param {Element} el
|
|
125
|
+
*/
|
|
126
|
+
function removeFocusVisibleClass(el) {
|
|
127
|
+
if (!el.hasAttribute('data-focus-visible-added')) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
el.classList.remove('focus-visible');
|
|
131
|
+
el.removeAttribute('data-focus-visible-added');
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* If the most recent user interaction was via the keyboard;
|
|
136
|
+
* and the key press did not include a meta, alt/option, or control key;
|
|
137
|
+
* then the modality is keyboard. Otherwise, the modality is not keyboard.
|
|
138
|
+
* Apply `focus-visible` to any current active element and keep track
|
|
139
|
+
* of our keyboard modality state with `hadKeyboardEvent`.
|
|
140
|
+
* @param {KeyboardEvent} e
|
|
141
|
+
*/
|
|
142
|
+
function onKeyDown(e) {
|
|
143
|
+
if (e.metaKey || e.altKey || e.ctrlKey) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
if (isValidFocusTarget(scope.activeElement)) {
|
|
147
|
+
addFocusVisibleClass(scope.activeElement);
|
|
148
|
+
}
|
|
149
|
+
hadKeyboardEvent = true;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* If at any point a user clicks with a pointing device, ensure that we change
|
|
154
|
+
* the modality away from keyboard.
|
|
155
|
+
* This avoids the situation where a user presses a key on an already focused
|
|
156
|
+
* element, and then clicks on a different element, focusing it with a
|
|
157
|
+
* pointing device, while we still think we're in keyboard modality.
|
|
158
|
+
* @param {Event} e
|
|
159
|
+
*/
|
|
160
|
+
function onPointerDown(e) {
|
|
161
|
+
hadKeyboardEvent = false;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* On `focus`, add the `focus-visible` class to the target if:
|
|
166
|
+
* - the target received focus as a result of keyboard navigation, or
|
|
167
|
+
* - the event target is an element that will likely require interaction
|
|
168
|
+
* via the keyboard (e.g. a text box)
|
|
169
|
+
* @param {Event} e
|
|
170
|
+
*/
|
|
171
|
+
function onFocus(e) {
|
|
172
|
+
// Prevent IE from focusing the document or HTML element.
|
|
173
|
+
if (!isValidFocusTarget(e.target)) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
if (hadKeyboardEvent || focusTriggersKeyboardModality(e.target)) {
|
|
177
|
+
addFocusVisibleClass(e.target);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* On `blur`, remove the `focus-visible` class from the target.
|
|
183
|
+
* @param {Event} e
|
|
184
|
+
*/
|
|
185
|
+
function onBlur(e) {
|
|
186
|
+
if (!isValidFocusTarget(e.target)) {
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
if (e.target.classList.contains('focus-visible') || e.target.hasAttribute('data-focus-visible-added')) {
|
|
190
|
+
// To detect a tab/window switch, we look for a blur event followed
|
|
191
|
+
// rapidly by a visibility change.
|
|
192
|
+
// If we don't see a visibility change within 100ms, it's probably a
|
|
193
|
+
// regular focus change.
|
|
194
|
+
hadFocusVisibleRecently = true;
|
|
195
|
+
window.clearTimeout(hadFocusVisibleRecentlyTimeout);
|
|
196
|
+
hadFocusVisibleRecentlyTimeout = window.setTimeout(function () {
|
|
197
|
+
hadFocusVisibleRecently = false;
|
|
198
|
+
}, 100);
|
|
199
|
+
removeFocusVisibleClass(e.target);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* If the user changes tabs, keep track of whether or not the previously
|
|
205
|
+
* focused element had .focus-visible.
|
|
206
|
+
* @param {Event} e
|
|
207
|
+
*/
|
|
208
|
+
function onVisibilityChange(e) {
|
|
209
|
+
if (document.visibilityState === 'hidden') {
|
|
210
|
+
// If the tab becomes active again, the browser will handle calling focus
|
|
211
|
+
// on the element (Safari actually calls it twice).
|
|
212
|
+
// If this tab change caused a blur on an element with focus-visible,
|
|
213
|
+
// re-apply the class when the user switches back to the tab.
|
|
214
|
+
if (hadFocusVisibleRecently) {
|
|
215
|
+
hadKeyboardEvent = true;
|
|
216
|
+
}
|
|
217
|
+
addInitialPointerMoveListeners();
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Add a group of listeners to detect usage of any pointing devices.
|
|
223
|
+
* These listeners will be added when the polyfill first loads, and anytime
|
|
224
|
+
* the window is blurred, so that they are active when the window regains
|
|
225
|
+
* focus.
|
|
226
|
+
*/
|
|
227
|
+
function addInitialPointerMoveListeners() {
|
|
228
|
+
document.addEventListener('mousemove', onInitialPointerMove);
|
|
229
|
+
document.addEventListener('mousedown', onInitialPointerMove);
|
|
230
|
+
document.addEventListener('mouseup', onInitialPointerMove);
|
|
231
|
+
document.addEventListener('pointermove', onInitialPointerMove);
|
|
232
|
+
document.addEventListener('pointerdown', onInitialPointerMove);
|
|
233
|
+
document.addEventListener('pointerup', onInitialPointerMove);
|
|
234
|
+
document.addEventListener('touchmove', onInitialPointerMove);
|
|
235
|
+
document.addEventListener('touchstart', onInitialPointerMove);
|
|
236
|
+
document.addEventListener('touchend', onInitialPointerMove);
|
|
237
|
+
}
|
|
238
|
+
function removeInitialPointerMoveListeners() {
|
|
239
|
+
document.removeEventListener('mousemove', onInitialPointerMove);
|
|
240
|
+
document.removeEventListener('mousedown', onInitialPointerMove);
|
|
241
|
+
document.removeEventListener('mouseup', onInitialPointerMove);
|
|
242
|
+
document.removeEventListener('pointermove', onInitialPointerMove);
|
|
243
|
+
document.removeEventListener('pointerdown', onInitialPointerMove);
|
|
244
|
+
document.removeEventListener('pointerup', onInitialPointerMove);
|
|
245
|
+
document.removeEventListener('touchmove', onInitialPointerMove);
|
|
246
|
+
document.removeEventListener('touchstart', onInitialPointerMove);
|
|
247
|
+
document.removeEventListener('touchend', onInitialPointerMove);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* When the polfyill first loads, assume the user is in keyboard modality.
|
|
252
|
+
* If any event is received from a pointing device (e.g. mouse, pointer,
|
|
253
|
+
* touch), turn off keyboard modality.
|
|
254
|
+
* This accounts for situations where focus enters the page from the URL bar.
|
|
255
|
+
* @param {Event} e
|
|
256
|
+
*/
|
|
257
|
+
function onInitialPointerMove(e) {
|
|
258
|
+
// Work around a Safari quirk that fires a mousemove on <html> whenever the
|
|
259
|
+
// window blurs, even if you're tabbing out of the page. ¯\_(ツ)_/¯
|
|
260
|
+
if (e.target.nodeName && e.target.nodeName.toLowerCase() === 'html') {
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
hadKeyboardEvent = false;
|
|
264
|
+
removeInitialPointerMoveListeners();
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
// For some kinds of state, we are interested in changes at the global scope
|
|
268
|
+
// only. For example, global pointer input, global key presses and global
|
|
269
|
+
// visibility change should affect the state at every scope:
|
|
270
|
+
document.addEventListener('keydown', onKeyDown, true);
|
|
271
|
+
document.addEventListener('mousedown', onPointerDown, true);
|
|
272
|
+
document.addEventListener('pointerdown', onPointerDown, true);
|
|
273
|
+
document.addEventListener('touchstart', onPointerDown, true);
|
|
274
|
+
document.addEventListener('visibilitychange', onVisibilityChange, true);
|
|
275
|
+
addInitialPointerMoveListeners();
|
|
276
|
+
|
|
277
|
+
// For focus and blur, we specifically care about state changes in the local
|
|
278
|
+
// scope. This is because focus / blur events that originate from within a
|
|
279
|
+
// shadow root are not re-dispatched from the host element if it was already
|
|
280
|
+
// the active element in its own scope:
|
|
281
|
+
scope.addEventListener('focus', onFocus, true);
|
|
282
|
+
scope.addEventListener('blur', onBlur, true);
|
|
283
|
+
|
|
284
|
+
// We detect that a node is a ShadowRoot by ensuring that it is a
|
|
285
|
+
// DocumentFragment and also has a host property. This check covers native
|
|
286
|
+
// implementation and polyfill implementation transparently. If we only cared
|
|
287
|
+
// about the native implementation, we could just check if the scope was
|
|
288
|
+
// an instance of a ShadowRoot.
|
|
289
|
+
if (scope.nodeType === Node.DOCUMENT_FRAGMENT_NODE && scope.host) {
|
|
290
|
+
// Since a ShadowRoot is a special kind of DocumentFragment, it does not
|
|
291
|
+
// have a root element to add a class to. So, we add this attribute to the
|
|
292
|
+
// host element instead:
|
|
293
|
+
scope.host.setAttribute('data-js-focus-visible', '');
|
|
294
|
+
} else if (scope.nodeType === Node.DOCUMENT_NODE) {
|
|
295
|
+
document.documentElement.classList.add('js-focus-visible');
|
|
296
|
+
document.documentElement.setAttribute('data-js-focus-visible', '');
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
// It is important to wrap all references to global window and document in
|
|
301
|
+
// these checks to support server-side rendering use cases
|
|
302
|
+
// @see https://github.com/WICG/focus-visible/issues/199
|
|
303
|
+
if (typeof window !== 'undefined' && typeof document !== 'undefined') {
|
|
304
|
+
// Make the polyfill helper globally available. This can be used as a signal
|
|
305
|
+
// to interested libraries that wish to coordinate with the polyfill for e.g.,
|
|
306
|
+
// applying the polyfill to a shadow root:
|
|
307
|
+
window.applyFocusVisiblePolyfill = applyFocusVisiblePolyfill;
|
|
308
|
+
|
|
309
|
+
// Notify interested libraries of the polyfill's presence, in case the
|
|
310
|
+
// polyfill was loaded lazily:
|
|
311
|
+
var event;
|
|
312
|
+
try {
|
|
313
|
+
event = new CustomEvent('focus-visible-polyfill-ready');
|
|
314
|
+
} catch (error) {
|
|
315
|
+
// IE11 does not support using CustomEvent as a constructor directly:
|
|
316
|
+
event = document.createEvent('CustomEvent');
|
|
317
|
+
event.initCustomEvent('focus-visible-polyfill-ready', false, false, {});
|
|
318
|
+
}
|
|
319
|
+
window.dispatchEvent(event);
|
|
320
|
+
}
|
|
321
|
+
if (typeof document !== 'undefined') {
|
|
322
|
+
// Apply the polyfill to the global document, so that no JavaScript
|
|
323
|
+
// coordination is required to use the polyfill in the top-level document:
|
|
324
|
+
applyFocusVisiblePolyfill(document);
|
|
325
|
+
}
|
|
326
|
+
});
|
|
327
|
+
})();
|
|
328
|
+
return focusVisible$1.exports;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
requireFocusVisible();
|
|
332
|
+
|
|
10
333
|
var dist$4 = {};
|
|
11
334
|
|
|
12
335
|
var colors = {};
|
|
@@ -37,6 +360,10 @@ function requireColors() {
|
|
|
37
360
|
"dark-fuchsia": "rgb(180, 60, 160)",
|
|
38
361
|
"teal": "rgb(0, 111, 98)",
|
|
39
362
|
"ivory": "rgb(242, 233, 219)",
|
|
363
|
+
"chatelle": "rgb(213, 194, 216)",
|
|
364
|
+
"edgewater": "rgb(198, 225, 209)",
|
|
365
|
+
"waikawa-gray": "rgb(86, 107, 136)",
|
|
366
|
+
"tuscany": "rgb(186, 83, 44)",
|
|
40
367
|
"klein-blue": "rgb(38, 48, 120)",
|
|
41
368
|
"persian-blue": "rgb(30, 34, 170)",
|
|
42
369
|
"brick": "rgb(147, 58, 32)",
|
|
@@ -60,7 +387,11 @@ function requireColors() {
|
|
|
60
387
|
"fuchsia": "rgb(196, 76, 176)",
|
|
61
388
|
"dark-fuchsia": "rgb(180, 60, 160)",
|
|
62
389
|
"teal": "rgb(0, 111, 98)",
|
|
63
|
-
"ivory": "rgb(242, 233, 219)"
|
|
390
|
+
"ivory": "rgb(242, 233, 219)",
|
|
391
|
+
"chatelle": "rgb(213, 194, 216)",
|
|
392
|
+
"edgewater": "rgb(198, 225, 209)",
|
|
393
|
+
"waikawa-gray": "rgb(86, 107, 136)",
|
|
394
|
+
"tuscany": "rgb(186, 83, 44)"
|
|
64
395
|
},
|
|
65
396
|
"global": {
|
|
66
397
|
"klein-blue": "rgb(38, 48, 120)",
|
|
@@ -237,407 +568,347 @@ function requireBreakpoints() {
|
|
|
237
568
|
|
|
238
569
|
var helpers = {};
|
|
239
570
|
|
|
240
|
-
var
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
return obj instanceof Array || Array.isArray(obj) || obj.length >= 0 && (obj.splice instanceof Function || Object.getOwnPropertyDescriptor(obj, obj.length - 1) && obj.constructor.name !== 'String');
|
|
412
|
-
};
|
|
413
|
-
return isArrayish;
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
var hasRequiredSimpleSwizzle;
|
|
417
|
-
function requireSimpleSwizzle() {
|
|
418
|
-
if (hasRequiredSimpleSwizzle) return simpleSwizzle.exports;
|
|
419
|
-
hasRequiredSimpleSwizzle = 1;
|
|
420
|
-
var isArrayish = requireIsArrayish();
|
|
421
|
-
var concat = Array.prototype.concat;
|
|
422
|
-
var slice = Array.prototype.slice;
|
|
423
|
-
var swizzle = simpleSwizzle.exports = function swizzle(args) {
|
|
424
|
-
var results = [];
|
|
425
|
-
for (var i = 0, len = args.length; i < len; i++) {
|
|
426
|
-
var arg = args[i];
|
|
427
|
-
if (isArrayish(arg)) {
|
|
428
|
-
// http://jsperf.com/javascript-array-concat-vs-push/98
|
|
429
|
-
results = concat.call(results, slice.call(arg));
|
|
430
|
-
} else {
|
|
431
|
-
results.push(arg);
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
return results;
|
|
435
|
-
};
|
|
436
|
-
swizzle.wrap = function (fn) {
|
|
437
|
-
return function () {
|
|
438
|
-
return fn(swizzle(arguments));
|
|
439
|
-
};
|
|
440
|
-
};
|
|
441
|
-
return simpleSwizzle.exports;
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
/* MIT license */
|
|
445
|
-
var hasRequiredColorString;
|
|
446
|
-
function requireColorString() {
|
|
447
|
-
if (hasRequiredColorString) return colorString.exports;
|
|
448
|
-
hasRequiredColorString = 1;
|
|
449
|
-
var colorNames = requireColorName();
|
|
450
|
-
var swizzle = requireSimpleSwizzle();
|
|
451
|
-
var hasOwnProperty = Object.hasOwnProperty;
|
|
452
|
-
var reverseNames = Object.create(null);
|
|
453
|
-
|
|
454
|
-
// create a list of reverse color names
|
|
455
|
-
for (var name in colorNames) {
|
|
456
|
-
if (hasOwnProperty.call(colorNames, name)) {
|
|
457
|
-
reverseNames[colorNames[name]] = name;
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
var cs = colorString.exports = {
|
|
461
|
-
to: {},
|
|
462
|
-
get: {}
|
|
463
|
-
};
|
|
464
|
-
cs.get = function (string) {
|
|
465
|
-
var prefix = string.substring(0, 3).toLowerCase();
|
|
466
|
-
var val;
|
|
467
|
-
var model;
|
|
468
|
-
switch (prefix) {
|
|
469
|
-
case 'hsl':
|
|
470
|
-
val = cs.get.hsl(string);
|
|
571
|
+
var colorNames = {
|
|
572
|
+
aliceblue: [240, 248, 255],
|
|
573
|
+
antiquewhite: [250, 235, 215],
|
|
574
|
+
aqua: [0, 255, 255],
|
|
575
|
+
aquamarine: [127, 255, 212],
|
|
576
|
+
azure: [240, 255, 255],
|
|
577
|
+
beige: [245, 245, 220],
|
|
578
|
+
bisque: [255, 228, 196],
|
|
579
|
+
black: [0, 0, 0],
|
|
580
|
+
blanchedalmond: [255, 235, 205],
|
|
581
|
+
blue: [0, 0, 255],
|
|
582
|
+
blueviolet: [138, 43, 226],
|
|
583
|
+
brown: [165, 42, 42],
|
|
584
|
+
burlywood: [222, 184, 135],
|
|
585
|
+
cadetblue: [95, 158, 160],
|
|
586
|
+
chartreuse: [127, 255, 0],
|
|
587
|
+
chocolate: [210, 105, 30],
|
|
588
|
+
coral: [255, 127, 80],
|
|
589
|
+
cornflowerblue: [100, 149, 237],
|
|
590
|
+
cornsilk: [255, 248, 220],
|
|
591
|
+
crimson: [220, 20, 60],
|
|
592
|
+
cyan: [0, 255, 255],
|
|
593
|
+
darkblue: [0, 0, 139],
|
|
594
|
+
darkcyan: [0, 139, 139],
|
|
595
|
+
darkgoldenrod: [184, 134, 11],
|
|
596
|
+
darkgray: [169, 169, 169],
|
|
597
|
+
darkgreen: [0, 100, 0],
|
|
598
|
+
darkgrey: [169, 169, 169],
|
|
599
|
+
darkkhaki: [189, 183, 107],
|
|
600
|
+
darkmagenta: [139, 0, 139],
|
|
601
|
+
darkolivegreen: [85, 107, 47],
|
|
602
|
+
darkorange: [255, 140, 0],
|
|
603
|
+
darkorchid: [153, 50, 204],
|
|
604
|
+
darkred: [139, 0, 0],
|
|
605
|
+
darksalmon: [233, 150, 122],
|
|
606
|
+
darkseagreen: [143, 188, 143],
|
|
607
|
+
darkslateblue: [72, 61, 139],
|
|
608
|
+
darkslategray: [47, 79, 79],
|
|
609
|
+
darkslategrey: [47, 79, 79],
|
|
610
|
+
darkturquoise: [0, 206, 209],
|
|
611
|
+
darkviolet: [148, 0, 211],
|
|
612
|
+
deeppink: [255, 20, 147],
|
|
613
|
+
deepskyblue: [0, 191, 255],
|
|
614
|
+
dimgray: [105, 105, 105],
|
|
615
|
+
dimgrey: [105, 105, 105],
|
|
616
|
+
dodgerblue: [30, 144, 255],
|
|
617
|
+
firebrick: [178, 34, 34],
|
|
618
|
+
floralwhite: [255, 250, 240],
|
|
619
|
+
forestgreen: [34, 139, 34],
|
|
620
|
+
fuchsia: [255, 0, 255],
|
|
621
|
+
gainsboro: [220, 220, 220],
|
|
622
|
+
ghostwhite: [248, 248, 255],
|
|
623
|
+
gold: [255, 215, 0],
|
|
624
|
+
goldenrod: [218, 165, 32],
|
|
625
|
+
gray: [128, 128, 128],
|
|
626
|
+
green: [0, 128, 0],
|
|
627
|
+
greenyellow: [173, 255, 47],
|
|
628
|
+
grey: [128, 128, 128],
|
|
629
|
+
honeydew: [240, 255, 240],
|
|
630
|
+
hotpink: [255, 105, 180],
|
|
631
|
+
indianred: [205, 92, 92],
|
|
632
|
+
indigo: [75, 0, 130],
|
|
633
|
+
ivory: [255, 255, 240],
|
|
634
|
+
khaki: [240, 230, 140],
|
|
635
|
+
lavender: [230, 230, 250],
|
|
636
|
+
lavenderblush: [255, 240, 245],
|
|
637
|
+
lawngreen: [124, 252, 0],
|
|
638
|
+
lemonchiffon: [255, 250, 205],
|
|
639
|
+
lightblue: [173, 216, 230],
|
|
640
|
+
lightcoral: [240, 128, 128],
|
|
641
|
+
lightcyan: [224, 255, 255],
|
|
642
|
+
lightgoldenrodyellow: [250, 250, 210],
|
|
643
|
+
lightgray: [211, 211, 211],
|
|
644
|
+
lightgreen: [144, 238, 144],
|
|
645
|
+
lightgrey: [211, 211, 211],
|
|
646
|
+
lightpink: [255, 182, 193],
|
|
647
|
+
lightsalmon: [255, 160, 122],
|
|
648
|
+
lightseagreen: [32, 178, 170],
|
|
649
|
+
lightskyblue: [135, 206, 250],
|
|
650
|
+
lightslategray: [119, 136, 153],
|
|
651
|
+
lightslategrey: [119, 136, 153],
|
|
652
|
+
lightsteelblue: [176, 196, 222],
|
|
653
|
+
lightyellow: [255, 255, 224],
|
|
654
|
+
lime: [0, 255, 0],
|
|
655
|
+
limegreen: [50, 205, 50],
|
|
656
|
+
linen: [250, 240, 230],
|
|
657
|
+
magenta: [255, 0, 255],
|
|
658
|
+
maroon: [128, 0, 0],
|
|
659
|
+
mediumaquamarine: [102, 205, 170],
|
|
660
|
+
mediumblue: [0, 0, 205],
|
|
661
|
+
mediumorchid: [186, 85, 211],
|
|
662
|
+
mediumpurple: [147, 112, 219],
|
|
663
|
+
mediumseagreen: [60, 179, 113],
|
|
664
|
+
mediumslateblue: [123, 104, 238],
|
|
665
|
+
mediumspringgreen: [0, 250, 154],
|
|
666
|
+
mediumturquoise: [72, 209, 204],
|
|
667
|
+
mediumvioletred: [199, 21, 133],
|
|
668
|
+
midnightblue: [25, 25, 112],
|
|
669
|
+
mintcream: [245, 255, 250],
|
|
670
|
+
mistyrose: [255, 228, 225],
|
|
671
|
+
moccasin: [255, 228, 181],
|
|
672
|
+
navajowhite: [255, 222, 173],
|
|
673
|
+
navy: [0, 0, 128],
|
|
674
|
+
oldlace: [253, 245, 230],
|
|
675
|
+
olive: [128, 128, 0],
|
|
676
|
+
olivedrab: [107, 142, 35],
|
|
677
|
+
orange: [255, 165, 0],
|
|
678
|
+
orangered: [255, 69, 0],
|
|
679
|
+
orchid: [218, 112, 214],
|
|
680
|
+
palegoldenrod: [238, 232, 170],
|
|
681
|
+
palegreen: [152, 251, 152],
|
|
682
|
+
paleturquoise: [175, 238, 238],
|
|
683
|
+
palevioletred: [219, 112, 147],
|
|
684
|
+
papayawhip: [255, 239, 213],
|
|
685
|
+
peachpuff: [255, 218, 185],
|
|
686
|
+
peru: [205, 133, 63],
|
|
687
|
+
pink: [255, 192, 203],
|
|
688
|
+
plum: [221, 160, 221],
|
|
689
|
+
powderblue: [176, 224, 230],
|
|
690
|
+
purple: [128, 0, 128],
|
|
691
|
+
rebeccapurple: [102, 51, 153],
|
|
692
|
+
red: [255, 0, 0],
|
|
693
|
+
rosybrown: [188, 143, 143],
|
|
694
|
+
royalblue: [65, 105, 225],
|
|
695
|
+
saddlebrown: [139, 69, 19],
|
|
696
|
+
salmon: [250, 128, 114],
|
|
697
|
+
sandybrown: [244, 164, 96],
|
|
698
|
+
seagreen: [46, 139, 87],
|
|
699
|
+
seashell: [255, 245, 238],
|
|
700
|
+
sienna: [160, 82, 45],
|
|
701
|
+
silver: [192, 192, 192],
|
|
702
|
+
skyblue: [135, 206, 235],
|
|
703
|
+
slateblue: [106, 90, 205],
|
|
704
|
+
slategray: [112, 128, 144],
|
|
705
|
+
slategrey: [112, 128, 144],
|
|
706
|
+
snow: [255, 250, 250],
|
|
707
|
+
springgreen: [0, 255, 127],
|
|
708
|
+
steelblue: [70, 130, 180],
|
|
709
|
+
tan: [210, 180, 140],
|
|
710
|
+
teal: [0, 128, 128],
|
|
711
|
+
thistle: [216, 191, 216],
|
|
712
|
+
tomato: [255, 99, 71],
|
|
713
|
+
turquoise: [64, 224, 208],
|
|
714
|
+
violet: [238, 130, 238],
|
|
715
|
+
wheat: [245, 222, 179],
|
|
716
|
+
white: [255, 255, 255],
|
|
717
|
+
whitesmoke: [245, 245, 245],
|
|
718
|
+
yellow: [255, 255, 0],
|
|
719
|
+
yellowgreen: [154, 205, 50]
|
|
720
|
+
};
|
|
721
|
+
|
|
722
|
+
var reverseNames = Object.create(null);
|
|
723
|
+
|
|
724
|
+
// Create a list of reverse color names
|
|
725
|
+
for (var name in colorNames) {
|
|
726
|
+
if (Object.hasOwn(colorNames, name)) {
|
|
727
|
+
reverseNames[colorNames[name]] = name;
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
var cs = {
|
|
731
|
+
to: {},
|
|
732
|
+
get: {}
|
|
733
|
+
};
|
|
734
|
+
cs.get = function (string) {
|
|
735
|
+
var prefix = string.slice(0, 3).toLowerCase();
|
|
736
|
+
var value;
|
|
737
|
+
var model;
|
|
738
|
+
switch (prefix) {
|
|
739
|
+
case 'hsl':
|
|
740
|
+
{
|
|
741
|
+
value = cs.get.hsl(string);
|
|
471
742
|
model = 'hsl';
|
|
472
743
|
break;
|
|
473
|
-
|
|
474
|
-
|
|
744
|
+
}
|
|
745
|
+
case 'hwb':
|
|
746
|
+
{
|
|
747
|
+
value = cs.get.hwb(string);
|
|
475
748
|
model = 'hwb';
|
|
476
749
|
break;
|
|
477
|
-
|
|
478
|
-
|
|
750
|
+
}
|
|
751
|
+
default:
|
|
752
|
+
{
|
|
753
|
+
value = cs.get.rgb(string);
|
|
479
754
|
model = 'rgb';
|
|
480
755
|
break;
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
if (!value) {
|
|
759
|
+
return null;
|
|
760
|
+
}
|
|
761
|
+
return {
|
|
762
|
+
model: model,
|
|
763
|
+
value: value
|
|
764
|
+
};
|
|
765
|
+
};
|
|
766
|
+
cs.get.rgb = function (string) {
|
|
767
|
+
if (!string) {
|
|
768
|
+
return null;
|
|
769
|
+
}
|
|
770
|
+
var abbr = /^#([a-f\d]{3,4})$/i;
|
|
771
|
+
var hex = /^#([a-f\d]{6})([a-f\d]{2})?$/i;
|
|
772
|
+
var rgba = /^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|/]\s*([+-]?[\d.]+)(%?)\s*)?\)$/;
|
|
773
|
+
var per = /^rgba?\(\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*(?:[,|/]\s*([+-]?[\d.]+)(%?)\s*)?\)$/;
|
|
774
|
+
var keyword = /^(\w+)$/;
|
|
775
|
+
var rgb = [0, 0, 0, 1];
|
|
776
|
+
var match;
|
|
777
|
+
var i;
|
|
778
|
+
var hexAlpha;
|
|
779
|
+
if (match = string.match(hex)) {
|
|
780
|
+
hexAlpha = match[2];
|
|
781
|
+
match = match[1];
|
|
782
|
+
for (i = 0; i < 3; i++) {
|
|
783
|
+
// https://jsperf.com/slice-vs-substr-vs-substring-methods-long-string/19
|
|
784
|
+
var i2 = i * 2;
|
|
785
|
+
rgb[i] = Number.parseInt(match.slice(i2, i2 + 2), 16);
|
|
481
786
|
}
|
|
482
|
-
if (
|
|
483
|
-
|
|
787
|
+
if (hexAlpha) {
|
|
788
|
+
rgb[3] = Number.parseInt(hexAlpha, 16) / 255;
|
|
484
789
|
}
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
cs.get.rgb = function (string) {
|
|
491
|
-
if (!string) {
|
|
492
|
-
return null;
|
|
790
|
+
} else if (match = string.match(abbr)) {
|
|
791
|
+
match = match[1];
|
|
792
|
+
hexAlpha = match[3];
|
|
793
|
+
for (i = 0; i < 3; i++) {
|
|
794
|
+
rgb[i] = Number.parseInt(match[i] + match[i], 16);
|
|
493
795
|
}
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
var rgba = /^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/;
|
|
497
|
-
var per = /^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/;
|
|
498
|
-
var keyword = /^(\w+)$/;
|
|
499
|
-
var rgb = [0, 0, 0, 1];
|
|
500
|
-
var match;
|
|
501
|
-
var i;
|
|
502
|
-
var hexAlpha;
|
|
503
|
-
if (match = string.match(hex)) {
|
|
504
|
-
hexAlpha = match[2];
|
|
505
|
-
match = match[1];
|
|
506
|
-
for (i = 0; i < 3; i++) {
|
|
507
|
-
// https://jsperf.com/slice-vs-substr-vs-substring-methods-long-string/19
|
|
508
|
-
var i2 = i * 2;
|
|
509
|
-
rgb[i] = parseInt(match.slice(i2, i2 + 2), 16);
|
|
510
|
-
}
|
|
511
|
-
if (hexAlpha) {
|
|
512
|
-
rgb[3] = parseInt(hexAlpha, 16) / 255;
|
|
513
|
-
}
|
|
514
|
-
} else if (match = string.match(abbr)) {
|
|
515
|
-
match = match[1];
|
|
516
|
-
hexAlpha = match[3];
|
|
517
|
-
for (i = 0; i < 3; i++) {
|
|
518
|
-
rgb[i] = parseInt(match[i] + match[i], 16);
|
|
519
|
-
}
|
|
520
|
-
if (hexAlpha) {
|
|
521
|
-
rgb[3] = parseInt(hexAlpha + hexAlpha, 16) / 255;
|
|
522
|
-
}
|
|
523
|
-
} else if (match = string.match(rgba)) {
|
|
524
|
-
for (i = 0; i < 3; i++) {
|
|
525
|
-
rgb[i] = parseInt(match[i + 1], 0);
|
|
526
|
-
}
|
|
527
|
-
if (match[4]) {
|
|
528
|
-
if (match[5]) {
|
|
529
|
-
rgb[3] = parseFloat(match[4]) * 0.01;
|
|
530
|
-
} else {
|
|
531
|
-
rgb[3] = parseFloat(match[4]);
|
|
532
|
-
}
|
|
533
|
-
}
|
|
534
|
-
} else if (match = string.match(per)) {
|
|
535
|
-
for (i = 0; i < 3; i++) {
|
|
536
|
-
rgb[i] = Math.round(parseFloat(match[i + 1]) * 2.55);
|
|
537
|
-
}
|
|
538
|
-
if (match[4]) {
|
|
539
|
-
if (match[5]) {
|
|
540
|
-
rgb[3] = parseFloat(match[4]) * 0.01;
|
|
541
|
-
} else {
|
|
542
|
-
rgb[3] = parseFloat(match[4]);
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
} else if (match = string.match(keyword)) {
|
|
546
|
-
if (match[1] === 'transparent') {
|
|
547
|
-
return [0, 0, 0, 0];
|
|
548
|
-
}
|
|
549
|
-
if (!hasOwnProperty.call(colorNames, match[1])) {
|
|
550
|
-
return null;
|
|
551
|
-
}
|
|
552
|
-
rgb = colorNames[match[1]];
|
|
553
|
-
rgb[3] = 1;
|
|
554
|
-
return rgb;
|
|
555
|
-
} else {
|
|
556
|
-
return null;
|
|
796
|
+
if (hexAlpha) {
|
|
797
|
+
rgb[3] = Number.parseInt(hexAlpha + hexAlpha, 16) / 255;
|
|
557
798
|
}
|
|
799
|
+
} else if (match = string.match(rgba)) {
|
|
558
800
|
for (i = 0; i < 3; i++) {
|
|
559
|
-
rgb[i] =
|
|
801
|
+
rgb[i] = Number.parseInt(match[i + 1], 10);
|
|
560
802
|
}
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
};
|
|
564
|
-
cs.get.hsl = function (string) {
|
|
565
|
-
if (!string) {
|
|
566
|
-
return null;
|
|
803
|
+
if (match[4]) {
|
|
804
|
+
rgb[3] = match[5] ? Number.parseFloat(match[4]) * 0.01 : Number.parseFloat(match[4]);
|
|
567
805
|
}
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
var alpha = parseFloat(match[4]);
|
|
572
|
-
var h = (parseFloat(match[1]) % 360 + 360) % 360;
|
|
573
|
-
var s = clamp(parseFloat(match[2]), 0, 100);
|
|
574
|
-
var l = clamp(parseFloat(match[3]), 0, 100);
|
|
575
|
-
var a = clamp(isNaN(alpha) ? 1 : alpha, 0, 1);
|
|
576
|
-
return [h, s, l, a];
|
|
806
|
+
} else if (match = string.match(per)) {
|
|
807
|
+
for (i = 0; i < 3; i++) {
|
|
808
|
+
rgb[i] = Math.round(Number.parseFloat(match[i + 1]) * 2.55);
|
|
577
809
|
}
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
cs.get.hwb = function (string) {
|
|
581
|
-
if (!string) {
|
|
582
|
-
return null;
|
|
810
|
+
if (match[4]) {
|
|
811
|
+
rgb[3] = match[5] ? Number.parseFloat(match[4]) * 0.01 : Number.parseFloat(match[4]);
|
|
583
812
|
}
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
var alpha = parseFloat(match[4]);
|
|
588
|
-
var h = (parseFloat(match[1]) % 360 + 360) % 360;
|
|
589
|
-
var w = clamp(parseFloat(match[2]), 0, 100);
|
|
590
|
-
var b = clamp(parseFloat(match[3]), 0, 100);
|
|
591
|
-
var a = clamp(isNaN(alpha) ? 1 : alpha, 0, 1);
|
|
592
|
-
return [h, w, b, a];
|
|
813
|
+
} else if (match = string.match(keyword)) {
|
|
814
|
+
if (match[1] === 'transparent') {
|
|
815
|
+
return [0, 0, 0, 0];
|
|
593
816
|
}
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
cs.to.hex = function () {
|
|
597
|
-
var rgba = swizzle(arguments);
|
|
598
|
-
return '#' + hexDouble(rgba[0]) + hexDouble(rgba[1]) + hexDouble(rgba[2]) + (rgba[3] < 1 ? hexDouble(Math.round(rgba[3] * 255)) : '');
|
|
599
|
-
};
|
|
600
|
-
cs.to.rgb = function () {
|
|
601
|
-
var rgba = swizzle(arguments);
|
|
602
|
-
return rgba.length < 4 || rgba[3] === 1 ? 'rgb(' + Math.round(rgba[0]) + ', ' + Math.round(rgba[1]) + ', ' + Math.round(rgba[2]) + ')' : 'rgba(' + Math.round(rgba[0]) + ', ' + Math.round(rgba[1]) + ', ' + Math.round(rgba[2]) + ', ' + rgba[3] + ')';
|
|
603
|
-
};
|
|
604
|
-
cs.to.rgb.percent = function () {
|
|
605
|
-
var rgba = swizzle(arguments);
|
|
606
|
-
var r = Math.round(rgba[0] / 255 * 100);
|
|
607
|
-
var g = Math.round(rgba[1] / 255 * 100);
|
|
608
|
-
var b = Math.round(rgba[2] / 255 * 100);
|
|
609
|
-
return rgba.length < 4 || rgba[3] === 1 ? 'rgb(' + r + '%, ' + g + '%, ' + b + '%)' : 'rgba(' + r + '%, ' + g + '%, ' + b + '%, ' + rgba[3] + ')';
|
|
610
|
-
};
|
|
611
|
-
cs.to.hsl = function () {
|
|
612
|
-
var hsla = swizzle(arguments);
|
|
613
|
-
return hsla.length < 4 || hsla[3] === 1 ? 'hsl(' + hsla[0] + ', ' + hsla[1] + '%, ' + hsla[2] + '%)' : 'hsla(' + hsla[0] + ', ' + hsla[1] + '%, ' + hsla[2] + '%, ' + hsla[3] + ')';
|
|
614
|
-
};
|
|
615
|
-
|
|
616
|
-
// hwb is a bit different than rgb(a) & hsl(a) since there is no alpha specific syntax
|
|
617
|
-
// (hwb have alpha optional & 1 is default value)
|
|
618
|
-
cs.to.hwb = function () {
|
|
619
|
-
var hwba = swizzle(arguments);
|
|
620
|
-
var a = '';
|
|
621
|
-
if (hwba.length >= 4 && hwba[3] !== 1) {
|
|
622
|
-
a = ', ' + hwba[3];
|
|
817
|
+
if (!Object.hasOwn(colorNames, match[1])) {
|
|
818
|
+
return null;
|
|
623
819
|
}
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
820
|
+
rgb = colorNames[match[1]];
|
|
821
|
+
rgb[3] = 1;
|
|
822
|
+
return rgb;
|
|
823
|
+
} else {
|
|
824
|
+
return null;
|
|
825
|
+
}
|
|
826
|
+
for (i = 0; i < 3; i++) {
|
|
827
|
+
rgb[i] = clamp(rgb[i], 0, 255);
|
|
828
|
+
}
|
|
829
|
+
rgb[3] = clamp(rgb[3], 0, 1);
|
|
830
|
+
return rgb;
|
|
831
|
+
};
|
|
832
|
+
cs.get.hsl = function (string) {
|
|
833
|
+
if (!string) {
|
|
834
|
+
return null;
|
|
835
|
+
}
|
|
836
|
+
var hsl = /^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*(?:[,|/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/;
|
|
837
|
+
var match = string.match(hsl);
|
|
838
|
+
if (match) {
|
|
839
|
+
var alpha = Number.parseFloat(match[4]);
|
|
840
|
+
var h = (Number.parseFloat(match[1]) % 360 + 360) % 360;
|
|
841
|
+
var s = clamp(Number.parseFloat(match[2]), 0, 100);
|
|
842
|
+
var l = clamp(Number.parseFloat(match[3]), 0, 100);
|
|
843
|
+
var a = clamp(Number.isNaN(alpha) ? 1 : alpha, 0, 1);
|
|
844
|
+
return [h, s, l, a];
|
|
845
|
+
}
|
|
846
|
+
return null;
|
|
847
|
+
};
|
|
848
|
+
cs.get.hwb = function (string) {
|
|
849
|
+
if (!string) {
|
|
850
|
+
return null;
|
|
851
|
+
}
|
|
852
|
+
var hwb = /^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d.]+)%\s*,\s*([+-]?[\d.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/;
|
|
853
|
+
var match = string.match(hwb);
|
|
854
|
+
if (match) {
|
|
855
|
+
var alpha = Number.parseFloat(match[4]);
|
|
856
|
+
var h = (Number.parseFloat(match[1]) % 360 + 360) % 360;
|
|
857
|
+
var w = clamp(Number.parseFloat(match[2]), 0, 100);
|
|
858
|
+
var b = clamp(Number.parseFloat(match[3]), 0, 100);
|
|
859
|
+
var a = clamp(Number.isNaN(alpha) ? 1 : alpha, 0, 1);
|
|
860
|
+
return [h, w, b, a];
|
|
861
|
+
}
|
|
862
|
+
return null;
|
|
863
|
+
};
|
|
864
|
+
cs.to.hex = function () {
|
|
865
|
+
return '#' + hexDouble(arguments.length <= 0 ? undefined : arguments[0]) + hexDouble(arguments.length <= 1 ? undefined : arguments[1]) + hexDouble(arguments.length <= 2 ? undefined : arguments[2]) + ((arguments.length <= 3 ? undefined : arguments[3]) < 1 ? hexDouble(Math.round((arguments.length <= 3 ? undefined : arguments[3]) * 255)) : '');
|
|
866
|
+
};
|
|
867
|
+
cs.to.rgb = function () {
|
|
868
|
+
return arguments.length < 4 || (arguments.length <= 3 ? undefined : arguments[3]) === 1 ? 'rgb(' + Math.round(arguments.length <= 0 ? undefined : arguments[0]) + ', ' + Math.round(arguments.length <= 1 ? undefined : arguments[1]) + ', ' + Math.round(arguments.length <= 2 ? undefined : arguments[2]) + ')' : 'rgba(' + Math.round(arguments.length <= 0 ? undefined : arguments[0]) + ', ' + Math.round(arguments.length <= 1 ? undefined : arguments[1]) + ', ' + Math.round(arguments.length <= 2 ? undefined : arguments[2]) + ', ' + (arguments.length <= 3 ? undefined : arguments[3]) + ')';
|
|
869
|
+
};
|
|
870
|
+
cs.to.rgb.percent = function () {
|
|
871
|
+
var r = Math.round((arguments.length <= 0 ? undefined : arguments[0]) / 255 * 100);
|
|
872
|
+
var g = Math.round((arguments.length <= 1 ? undefined : arguments[1]) / 255 * 100);
|
|
873
|
+
var b = Math.round((arguments.length <= 2 ? undefined : arguments[2]) / 255 * 100);
|
|
874
|
+
return arguments.length < 4 || (arguments.length <= 3 ? undefined : arguments[3]) === 1 ? 'rgb(' + r + '%, ' + g + '%, ' + b + '%)' : 'rgba(' + r + '%, ' + g + '%, ' + b + '%, ' + (arguments.length <= 3 ? undefined : arguments[3]) + ')';
|
|
875
|
+
};
|
|
876
|
+
cs.to.hsl = function () {
|
|
877
|
+
return arguments.length < 4 || (arguments.length <= 3 ? undefined : arguments[3]) === 1 ? 'hsl(' + (arguments.length <= 0 ? undefined : arguments[0]) + ', ' + (arguments.length <= 1 ? undefined : arguments[1]) + '%, ' + (arguments.length <= 2 ? undefined : arguments[2]) + '%)' : 'hsla(' + (arguments.length <= 0 ? undefined : arguments[0]) + ', ' + (arguments.length <= 1 ? undefined : arguments[1]) + '%, ' + (arguments.length <= 2 ? undefined : arguments[2]) + '%, ' + (arguments.length <= 3 ? undefined : arguments[3]) + ')';
|
|
878
|
+
};
|
|
629
879
|
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
880
|
+
// Hwb is a bit different than rgb(a) & hsl(a) since there is no alpha specific syntax
|
|
881
|
+
// (hwb have alpha optional & 1 is default value)
|
|
882
|
+
cs.to.hwb = function () {
|
|
883
|
+
var a = '';
|
|
884
|
+
if (arguments.length >= 4 && (arguments.length <= 3 ? undefined : arguments[3]) !== 1) {
|
|
885
|
+
a = ', ' + (arguments.length <= 3 ? undefined : arguments[3]);
|
|
633
886
|
}
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
887
|
+
return 'hwb(' + (arguments.length <= 0 ? undefined : arguments[0]) + ', ' + (arguments.length <= 1 ? undefined : arguments[1]) + '%, ' + (arguments.length <= 2 ? undefined : arguments[2]) + '%' + a + ')';
|
|
888
|
+
};
|
|
889
|
+
cs.to.keyword = function () {
|
|
890
|
+
for (var _len = arguments.length, rgb = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
891
|
+
rgb[_key] = arguments[_key];
|
|
637
892
|
}
|
|
638
|
-
return
|
|
893
|
+
return reverseNames[rgb.slice(0, 3)];
|
|
894
|
+
};
|
|
895
|
+
|
|
896
|
+
// Helpers
|
|
897
|
+
function clamp(number_, min, max) {
|
|
898
|
+
return Math.min(Math.max(min, number_), max);
|
|
899
|
+
}
|
|
900
|
+
function hexDouble(number_) {
|
|
901
|
+
var string_ = Math.round(number_).toString(16).toUpperCase();
|
|
902
|
+
return string_.length < 2 ? '0' + string_ : string_;
|
|
639
903
|
}
|
|
640
904
|
|
|
905
|
+
var colorString = /*#__PURE__*/Object.freeze({
|
|
906
|
+
__proto__: null,
|
|
907
|
+
default: cs
|
|
908
|
+
});
|
|
909
|
+
|
|
910
|
+
var require$$0 = /*@__PURE__*/getAugmentedNamespace(colorString);
|
|
911
|
+
|
|
641
912
|
var hasRequiredHelpers;
|
|
642
913
|
function requireHelpers() {
|
|
643
914
|
if (hasRequiredHelpers) return helpers;
|
|
@@ -654,20 +925,16 @@ function requireHelpers() {
|
|
|
654
925
|
};
|
|
655
926
|
return __assign.apply(this, arguments);
|
|
656
927
|
};
|
|
657
|
-
var
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
ar[i] = from[i];
|
|
662
|
-
}
|
|
663
|
-
}
|
|
664
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
928
|
+
var __importDefault = helpers && helpers.__importDefault || function (mod) {
|
|
929
|
+
return mod && mod.__esModule ? mod : {
|
|
930
|
+
"default": mod
|
|
931
|
+
};
|
|
665
932
|
};
|
|
666
933
|
Object.defineProperty(exports, "__esModule", {
|
|
667
934
|
value: true
|
|
668
935
|
});
|
|
669
936
|
exports.spacing = exports.colorInHex = exports.color = exports.remToUnitlessPx = exports.text = void 0;
|
|
670
|
-
var
|
|
937
|
+
var color_string_1 = __importDefault(require$$0);
|
|
671
938
|
var colors_1 = requireColors();
|
|
672
939
|
var space_1 = requireSpace();
|
|
673
940
|
var typography_1 = requireTypography();
|
|
@@ -689,13 +956,20 @@ function requireHelpers() {
|
|
|
689
956
|
var color = function color(name, alpha) {
|
|
690
957
|
var _a;
|
|
691
958
|
var color = colors_1.colors.all[name];
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
959
|
+
var _b = (_a = color_string_1["default"].get.rgb(color)) !== null && _a !== void 0 ? _a : [],
|
|
960
|
+
red = _b[0],
|
|
961
|
+
green = _b[1],
|
|
962
|
+
blue = _b[2];
|
|
963
|
+
return alpha != null ? color_string_1["default"].to.rgb(red, green, blue, alpha) : color;
|
|
695
964
|
};
|
|
696
965
|
exports.color = color;
|
|
697
966
|
var colorInHex = function colorInHex(name, alpha) {
|
|
698
|
-
|
|
967
|
+
var _a, _b, _c;
|
|
968
|
+
var _d = (_b = color_string_1["default"].get.rgb((_a = (0, exports.color)(name, alpha)) !== null && _a !== void 0 ? _a : '')) !== null && _b !== void 0 ? _b : [],
|
|
969
|
+
red = _d[0],
|
|
970
|
+
green = _d[1],
|
|
971
|
+
blue = _d[2];
|
|
972
|
+
return (_c = color_string_1["default"].to.hex(red, green, blue, alpha)) !== null && _c !== void 0 ? _c : '';
|
|
699
973
|
};
|
|
700
974
|
exports.colorInHex = colorInHex;
|
|
701
975
|
var spacing = function spacing(topY, rightX, bottom, left) {
|
|
@@ -796,9 +1070,9 @@ function _createForOfIteratorHelper(r, e) {
|
|
|
796
1070
|
s: F,
|
|
797
1071
|
n: function () {
|
|
798
1072
|
return n >= r.length ? {
|
|
799
|
-
done:
|
|
1073
|
+
done: true
|
|
800
1074
|
} : {
|
|
801
|
-
done:
|
|
1075
|
+
done: false,
|
|
802
1076
|
value: r[n++]
|
|
803
1077
|
};
|
|
804
1078
|
},
|
|
@@ -811,8 +1085,8 @@ function _createForOfIteratorHelper(r, e) {
|
|
|
811
1085
|
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
812
1086
|
}
|
|
813
1087
|
var o,
|
|
814
|
-
a =
|
|
815
|
-
u =
|
|
1088
|
+
a = true,
|
|
1089
|
+
u = false;
|
|
816
1090
|
return {
|
|
817
1091
|
s: function () {
|
|
818
1092
|
t = t.call(r);
|
|
@@ -822,7 +1096,7 @@ function _createForOfIteratorHelper(r, e) {
|
|
|
822
1096
|
return a = r.done, r;
|
|
823
1097
|
},
|
|
824
1098
|
e: function (r) {
|
|
825
|
-
u =
|
|
1099
|
+
u = true, o = r;
|
|
826
1100
|
},
|
|
827
1101
|
f: function () {
|
|
828
1102
|
try {
|
|
@@ -836,9 +1110,9 @@ function _createForOfIteratorHelper(r, e) {
|
|
|
836
1110
|
function _defineProperty$1(e, r, t) {
|
|
837
1111
|
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
838
1112
|
value: t,
|
|
839
|
-
enumerable:
|
|
840
|
-
configurable:
|
|
841
|
-
writable:
|
|
1113
|
+
enumerable: true,
|
|
1114
|
+
configurable: true,
|
|
1115
|
+
writable: true
|
|
842
1116
|
}) : e[r] = t, e;
|
|
843
1117
|
}
|
|
844
1118
|
function _extends$1() {
|
|
@@ -861,15 +1135,15 @@ function _iterableToArrayLimit(r, l) {
|
|
|
861
1135
|
i,
|
|
862
1136
|
u,
|
|
863
1137
|
a = [],
|
|
864
|
-
f =
|
|
865
|
-
o =
|
|
1138
|
+
f = true,
|
|
1139
|
+
o = false;
|
|
866
1140
|
try {
|
|
867
1141
|
if (i = (t = t.call(r)).next, 0 === l) {
|
|
868
1142
|
if (Object(t) !== t) return;
|
|
869
1143
|
f = !1;
|
|
870
1144
|
} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
|
|
871
1145
|
} catch (r) {
|
|
872
|
-
o =
|
|
1146
|
+
o = true, n = r;
|
|
873
1147
|
} finally {
|
|
874
1148
|
try {
|
|
875
1149
|
if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
|
|
@@ -902,7 +1176,7 @@ function ownKeys(e, r) {
|
|
|
902
1176
|
function _objectSpread2(e) {
|
|
903
1177
|
for (var r = 1; r < arguments.length; r++) {
|
|
904
1178
|
var t = null != arguments[r] ? arguments[r] : {};
|
|
905
|
-
r % 2 ? ownKeys(Object(t),
|
|
1179
|
+
r % 2 ? ownKeys(Object(t), true).forEach(function (r) {
|
|
906
1180
|
_defineProperty$1(e, r, t[r]);
|
|
907
1181
|
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
|
|
908
1182
|
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
@@ -916,8 +1190,8 @@ function _objectWithoutProperties(e, t) {
|
|
|
916
1190
|
r,
|
|
917
1191
|
i = _objectWithoutPropertiesLoose(e, t);
|
|
918
1192
|
if (Object.getOwnPropertySymbols) {
|
|
919
|
-
var
|
|
920
|
-
for (r = 0; r <
|
|
1193
|
+
var n = Object.getOwnPropertySymbols(e);
|
|
1194
|
+
for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
|
|
921
1195
|
}
|
|
922
1196
|
return i;
|
|
923
1197
|
}
|
|
@@ -925,7 +1199,7 @@ function _objectWithoutPropertiesLoose(r, e) {
|
|
|
925
1199
|
if (null == r) return {};
|
|
926
1200
|
var t = {};
|
|
927
1201
|
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
928
|
-
if (e.
|
|
1202
|
+
if (-1 !== e.indexOf(n)) continue;
|
|
929
1203
|
t[n] = r[n];
|
|
930
1204
|
}
|
|
931
1205
|
return t;
|
|
@@ -940,7 +1214,7 @@ function _toPrimitive(t, r) {
|
|
|
940
1214
|
if ("object" != typeof t || !t) return t;
|
|
941
1215
|
var e = t[Symbol.toPrimitive];
|
|
942
1216
|
if (void 0 !== e) {
|
|
943
|
-
var i = e.call(t, r
|
|
1217
|
+
var i = e.call(t, r);
|
|
944
1218
|
if ("object" != typeof i) return i;
|
|
945
1219
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
946
1220
|
}
|
|
@@ -971,108 +1245,6 @@ var isRenderProps = function isRenderProps(children) {
|
|
|
971
1245
|
return typeof children === 'function';
|
|
972
1246
|
};
|
|
973
1247
|
|
|
974
|
-
var classnames = {exports: {}};
|
|
975
|
-
|
|
976
|
-
var hasRequiredClassnames;
|
|
977
|
-
function requireClassnames() {
|
|
978
|
-
if (hasRequiredClassnames) return classnames.exports;
|
|
979
|
-
hasRequiredClassnames = 1;
|
|
980
|
-
(function (module) {
|
|
981
|
-
/* global define */
|
|
982
|
-
|
|
983
|
-
(function () {
|
|
984
|
-
|
|
985
|
-
var hasOwn = {}.hasOwnProperty;
|
|
986
|
-
function classNames() {
|
|
987
|
-
var classes = '';
|
|
988
|
-
for (var i = 0; i < arguments.length; i++) {
|
|
989
|
-
var arg = arguments[i];
|
|
990
|
-
if (arg) {
|
|
991
|
-
classes = appendClass(classes, parseValue(arg));
|
|
992
|
-
}
|
|
993
|
-
}
|
|
994
|
-
return classes;
|
|
995
|
-
}
|
|
996
|
-
function parseValue(arg) {
|
|
997
|
-
if (typeof arg === 'string' || typeof arg === 'number') {
|
|
998
|
-
return arg;
|
|
999
|
-
}
|
|
1000
|
-
if (_typeof$1(arg) !== 'object') {
|
|
1001
|
-
return '';
|
|
1002
|
-
}
|
|
1003
|
-
if (Array.isArray(arg)) {
|
|
1004
|
-
return classNames.apply(null, arg);
|
|
1005
|
-
}
|
|
1006
|
-
if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) {
|
|
1007
|
-
return arg.toString();
|
|
1008
|
-
}
|
|
1009
|
-
var classes = '';
|
|
1010
|
-
for (var key in arg) {
|
|
1011
|
-
if (hasOwn.call(arg, key) && arg[key]) {
|
|
1012
|
-
classes = appendClass(classes, key);
|
|
1013
|
-
}
|
|
1014
|
-
}
|
|
1015
|
-
return classes;
|
|
1016
|
-
}
|
|
1017
|
-
function appendClass(value, newClass) {
|
|
1018
|
-
if (!newClass) {
|
|
1019
|
-
return value;
|
|
1020
|
-
}
|
|
1021
|
-
if (value) {
|
|
1022
|
-
return value + ' ' + newClass;
|
|
1023
|
-
}
|
|
1024
|
-
return value + newClass;
|
|
1025
|
-
}
|
|
1026
|
-
if (module.exports) {
|
|
1027
|
-
classNames["default"] = classNames;
|
|
1028
|
-
module.exports = classNames;
|
|
1029
|
-
} else {
|
|
1030
|
-
window.classNames = classNames;
|
|
1031
|
-
}
|
|
1032
|
-
})();
|
|
1033
|
-
})(classnames);
|
|
1034
|
-
return classnames.exports;
|
|
1035
|
-
}
|
|
1036
|
-
|
|
1037
|
-
var classnamesExports = requireClassnames();
|
|
1038
|
-
var classNames = /*@__PURE__*/getDefaultExportFromCjs(classnamesExports);
|
|
1039
|
-
|
|
1040
|
-
var _excluded$G = ["className", "children", "space", "direction", "alignItems", "justifyContent", "style"];
|
|
1041
|
-
var Stack = function Stack(_ref) {
|
|
1042
|
-
var className = _ref.className,
|
|
1043
|
-
children = _ref.children,
|
|
1044
|
-
space = _ref.space,
|
|
1045
|
-
_ref$direction = _ref.direction,
|
|
1046
|
-
direction = _ref$direction === void 0 ? 'vertical' : _ref$direction,
|
|
1047
|
-
alignItems = _ref.alignItems,
|
|
1048
|
-
justifyContent = _ref.justifyContent,
|
|
1049
|
-
style = _ref.style,
|
|
1050
|
-
rest = _objectWithoutProperties(_ref, _excluded$G);
|
|
1051
|
-
return /*#__PURE__*/React__default.createElement("div", _extends$1({
|
|
1052
|
-
className: classNames("Stack Stack--".concat(direction, "-").concat(space), className),
|
|
1053
|
-
style: _objectSpread2(_objectSpread2({}, style), {}, {
|
|
1054
|
-
alignItems: alignItems,
|
|
1055
|
-
justifyContent: justifyContent
|
|
1056
|
-
})
|
|
1057
|
-
}, rest), children);
|
|
1058
|
-
};
|
|
1059
|
-
|
|
1060
|
-
var omit$1 = function omit(obj) {
|
|
1061
|
-
for (var _len = arguments.length, keys = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
1062
|
-
keys[_key - 1] = arguments[_key];
|
|
1063
|
-
}
|
|
1064
|
-
return Object.entries(obj).filter(function (_ref) {
|
|
1065
|
-
var _ref2 = _slicedToArray(_ref, 1),
|
|
1066
|
-
key = _ref2[0];
|
|
1067
|
-
return !keys.includes(key);
|
|
1068
|
-
}).reduce(function (obj, _ref3) {
|
|
1069
|
-
var _ref4 = _slicedToArray(_ref3, 2),
|
|
1070
|
-
key = _ref4[0],
|
|
1071
|
-
val = _ref4[1];
|
|
1072
|
-
return Object.assign(obj, _defineProperty$1({}, key, val));
|
|
1073
|
-
}, {});
|
|
1074
|
-
};
|
|
1075
|
-
|
|
1076
1248
|
var truncate = function truncate(string) {
|
|
1077
1249
|
var maxLength = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 25;
|
|
1078
1250
|
if (!string) return null;
|
|
@@ -1080,7 +1252,6 @@ var truncate = function truncate(string) {
|
|
|
1080
1252
|
return "".concat(string.substring(0, maxLength)).concat(ellipsis ? '...' : '');
|
|
1081
1253
|
};
|
|
1082
1254
|
|
|
1083
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1084
1255
|
var stringifyProps = function stringifyProps(props) {
|
|
1085
1256
|
var stringifiedProps = Object.entries(props || {}).reduce(function (memo, _ref) {
|
|
1086
1257
|
var _ref2 = _slicedToArray(_ref, 2),
|
|
@@ -1097,50 +1268,85 @@ var stringifyProps = function stringifyProps(props) {
|
|
|
1097
1268
|
return stringifiedProps.trim();
|
|
1098
1269
|
};
|
|
1099
1270
|
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1271
|
+
var omit$1 = function omit(obj) {
|
|
1272
|
+
for (var _len = arguments.length, keys = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
1273
|
+
keys[_key - 1] = arguments[_key];
|
|
1274
|
+
}
|
|
1275
|
+
return Object.entries(obj).filter(function (_ref) {
|
|
1276
|
+
var _ref2 = _slicedToArray(_ref, 1),
|
|
1277
|
+
key = _ref2[0];
|
|
1278
|
+
return !keys.includes(key);
|
|
1279
|
+
}).reduce(function (obj, _ref3) {
|
|
1280
|
+
var _ref4 = _slicedToArray(_ref3, 2),
|
|
1281
|
+
key = _ref4[0],
|
|
1282
|
+
val = _ref4[1];
|
|
1283
|
+
return Object.assign(obj, _defineProperty$1({}, key, val));
|
|
1284
|
+
}, {});
|
|
1285
|
+
};
|
|
1103
1286
|
|
|
1104
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1105
1287
|
var isEmpty = function isEmpty(obj) {
|
|
1106
1288
|
return Object.entries(obj || {}).length === 0;
|
|
1107
1289
|
};
|
|
1108
|
-
|
|
1290
|
+
|
|
1291
|
+
var DEFAULT_STYLES = {
|
|
1292
|
+
state: {
|
|
1293
|
+
border: '1px dotted #ddd',
|
|
1294
|
+
padding: '0.5rem',
|
|
1295
|
+
marginBottom: '1rem'
|
|
1296
|
+
},
|
|
1297
|
+
stateProps: {
|
|
1298
|
+
display: 'block',
|
|
1299
|
+
marginTop: '0.5rem',
|
|
1300
|
+
paddingTop: '0.5rem',
|
|
1301
|
+
fontFamily: "source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace",
|
|
1302
|
+
fontSize: '0.8125rem',
|
|
1303
|
+
color: '#999',
|
|
1304
|
+
borderTop: '1px dotted #ddd'
|
|
1305
|
+
},
|
|
1306
|
+
statePropsActive: {
|
|
1307
|
+
color: '#111',
|
|
1308
|
+
textDecoration: 'underline'
|
|
1309
|
+
}
|
|
1310
|
+
};
|
|
1311
|
+
var Styles = /*#__PURE__*/React__default.createContext(DEFAULT_STYLES);
|
|
1312
|
+
var useStyles = function useStyles() {
|
|
1313
|
+
return useContext(Styles);
|
|
1314
|
+
};
|
|
1315
|
+
|
|
1316
|
+
var StateProps = function StateProps(_ref) {
|
|
1109
1317
|
var props = _ref.props,
|
|
1110
1318
|
children = _ref.children;
|
|
1319
|
+
var styles = useStyles();
|
|
1111
1320
|
var childrenProps = omit$1.apply(void 0, [children.props].concat(_toConsumableArray(Object.keys(props || {}))));
|
|
1112
|
-
return /*#__PURE__*/React__default.createElement(
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
},
|
|
1321
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
1322
|
+
style: styles.stateProps
|
|
1323
|
+
}, '<', /*#__PURE__*/React__default.createElement("span", null, children.type.displayName || children.type.name), ' ', !isEmpty(props) && /*#__PURE__*/React__default.createElement("strong", {
|
|
1324
|
+
style: styles.statePropsActive
|
|
1325
|
+
}, stringifyProps(props)), ' ', !isRenderProps(children) && !isEmpty(childrenProps) && /*#__PURE__*/React__default.createElement("span", null, stringifyProps(childrenProps)), /*#__PURE__*/React__default.createElement("span", null, ' />'));
|
|
1117
1326
|
};
|
|
1118
1327
|
|
|
1119
|
-
var _excluded$
|
|
1328
|
+
var _excluded$G = ["props", "children"];
|
|
1120
1329
|
var State = function State(_ref) {
|
|
1121
1330
|
var props = _ref.props,
|
|
1122
1331
|
children = _ref.children,
|
|
1123
|
-
rest = _objectWithoutProperties(_ref, _excluded$
|
|
1332
|
+
rest = _objectWithoutProperties(_ref, _excluded$G);
|
|
1333
|
+
var styles = useStyles();
|
|
1124
1334
|
var Specimen = isRenderProps(children) ? children(props) : /*#__PURE__*/React__default.cloneElement(children, props);
|
|
1125
1335
|
var innerChildren = isRenderProps(children) ? children(props) : children;
|
|
1126
1336
|
return /*#__PURE__*/React__default.createElement("div", _extends$1({
|
|
1127
|
-
|
|
1128
|
-
}, rest), Specimen, /*#__PURE__*/React__default.createElement(
|
|
1129
|
-
className: "State__props"
|
|
1130
|
-
}, /*#__PURE__*/React__default.createElement(StatesProps, {
|
|
1337
|
+
style: styles.state
|
|
1338
|
+
}, rest), Specimen, /*#__PURE__*/React__default.createElement(StateProps, {
|
|
1131
1339
|
props: props
|
|
1132
|
-
}, innerChildren))
|
|
1340
|
+
}, innerChildren));
|
|
1133
1341
|
};
|
|
1134
1342
|
|
|
1135
|
-
var _excluded$
|
|
1343
|
+
var _excluded$F = ["states", "children"];
|
|
1136
1344
|
var States = function States(_ref) {
|
|
1137
1345
|
var _ref$states = _ref.states,
|
|
1138
1346
|
states = _ref$states === void 0 ? [{}] : _ref$states,
|
|
1139
1347
|
children = _ref.children,
|
|
1140
|
-
rest = _objectWithoutProperties(_ref, _excluded$
|
|
1141
|
-
return /*#__PURE__*/React__default.createElement(
|
|
1142
|
-
className: "States"
|
|
1143
|
-
}, states.map(function (props, index) {
|
|
1348
|
+
rest = _objectWithoutProperties(_ref, _excluded$F);
|
|
1349
|
+
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, states.map(function (props, index) {
|
|
1144
1350
|
return /*#__PURE__*/React__default.createElement(State, _extends$1({
|
|
1145
1351
|
key: index,
|
|
1146
1352
|
props: props
|
|
@@ -1148,6 +1354,11 @@ var States = function States(_ref) {
|
|
|
1148
1354
|
}));
|
|
1149
1355
|
};
|
|
1150
1356
|
|
|
1357
|
+
var preventNavigation = function preventNavigation(event) {
|
|
1358
|
+
event.preventDefault();
|
|
1359
|
+
event.returnValue = '';
|
|
1360
|
+
};
|
|
1361
|
+
|
|
1151
1362
|
/******************************************************************************
|
|
1152
1363
|
Copyright (c) Microsoft Corporation.
|
|
1153
1364
|
|
|
@@ -2693,16 +2904,16 @@ var mediumSidecar = createSidecarMedium({
|
|
|
2693
2904
|
var focusScope = /*#__PURE__*/createContext(undefined);
|
|
2694
2905
|
|
|
2695
2906
|
var emptyArray = [];
|
|
2696
|
-
var FocusLock = /*#__PURE__*/
|
|
2907
|
+
var FocusLock = /*#__PURE__*/forwardRef(function FocusLockUI(props, parentRef) {
|
|
2697
2908
|
var _extends2;
|
|
2698
|
-
var
|
|
2699
|
-
realObserved =
|
|
2700
|
-
setObserved =
|
|
2701
|
-
var observed =
|
|
2702
|
-
var isActive =
|
|
2703
|
-
var originalFocusedElement =
|
|
2704
|
-
var
|
|
2705
|
-
update =
|
|
2909
|
+
var _useState = useState(),
|
|
2910
|
+
realObserved = _useState[0],
|
|
2911
|
+
setObserved = _useState[1];
|
|
2912
|
+
var observed = useRef();
|
|
2913
|
+
var isActive = useRef(false);
|
|
2914
|
+
var originalFocusedElement = useRef(null);
|
|
2915
|
+
var _useState2 = useState({}),
|
|
2916
|
+
update = _useState2[1];
|
|
2706
2917
|
var children = props.children,
|
|
2707
2918
|
_props$disabled = props.disabled,
|
|
2708
2919
|
disabled = _props$disabled === void 0 ? false : _props$disabled,
|
|
@@ -2731,9 +2942,9 @@ var FocusLock = /*#__PURE__*/React.forwardRef(function FocusLockUI(props, parent
|
|
|
2731
2942
|
focusOptions = props.focusOptions,
|
|
2732
2943
|
onActivationCallback = props.onActivation,
|
|
2733
2944
|
onDeactivationCallback = props.onDeactivation;
|
|
2734
|
-
var
|
|
2735
|
-
id =
|
|
2736
|
-
var onActivation =
|
|
2945
|
+
var _useState3 = useState({}),
|
|
2946
|
+
id = _useState3[0];
|
|
2947
|
+
var onActivation = useCallback(function (_ref) {
|
|
2737
2948
|
var captureFocusRestore = _ref.captureFocusRestore;
|
|
2738
2949
|
if (!originalFocusedElement.current) {
|
|
2739
2950
|
var _document;
|
|
@@ -2749,14 +2960,14 @@ var FocusLock = /*#__PURE__*/React.forwardRef(function FocusLockUI(props, parent
|
|
|
2749
2960
|
isActive.current = true;
|
|
2750
2961
|
update();
|
|
2751
2962
|
}, [onActivationCallback]);
|
|
2752
|
-
var onDeactivation =
|
|
2963
|
+
var onDeactivation = useCallback(function () {
|
|
2753
2964
|
isActive.current = false;
|
|
2754
2965
|
if (onDeactivationCallback) {
|
|
2755
2966
|
onDeactivationCallback(observed.current);
|
|
2756
2967
|
}
|
|
2757
2968
|
update();
|
|
2758
2969
|
}, [onDeactivationCallback]);
|
|
2759
|
-
var returnFocus =
|
|
2970
|
+
var returnFocus = useCallback(function (allowDefer) {
|
|
2760
2971
|
var focusRestore = originalFocusedElement.current;
|
|
2761
2972
|
if (focusRestore) {
|
|
2762
2973
|
var returnFocusTo = (typeof focusRestore === 'function' ? focusRestore() : focusRestore) || document.body;
|
|
@@ -2774,13 +2985,13 @@ var FocusLock = /*#__PURE__*/React.forwardRef(function FocusLockUI(props, parent
|
|
|
2774
2985
|
}
|
|
2775
2986
|
}
|
|
2776
2987
|
}, [shouldReturnFocus]);
|
|
2777
|
-
var onFocus =
|
|
2988
|
+
var onFocus = useCallback(function (event) {
|
|
2778
2989
|
if (isActive.current) {
|
|
2779
2990
|
mediumFocus.useMedium(event);
|
|
2780
2991
|
}
|
|
2781
2992
|
}, []);
|
|
2782
2993
|
var onBlur = mediumBlur.useMedium;
|
|
2783
|
-
var setObserveNode =
|
|
2994
|
+
var setObserveNode = useCallback(function (newObserved) {
|
|
2784
2995
|
if (observed.current !== newObserved) {
|
|
2785
2996
|
observed.current = newObserved;
|
|
2786
2997
|
setObserved(newObserved);
|
|
@@ -2790,7 +3001,7 @@ var FocusLock = /*#__PURE__*/React.forwardRef(function FocusLockUI(props, parent
|
|
|
2790
3001
|
if (typeof allowTextSelection !== 'undefined') {
|
|
2791
3002
|
console.warn('React-Focus-Lock: allowTextSelection is deprecated and enabled by default');
|
|
2792
3003
|
}
|
|
2793
|
-
|
|
3004
|
+
useEffect(function () {
|
|
2794
3005
|
if (!observed.current && typeof Container !== 'string') {
|
|
2795
3006
|
console.error('FocusLock: could not obtain ref to internal node');
|
|
2796
3007
|
}
|
|
@@ -2800,7 +3011,7 @@ var FocusLock = /*#__PURE__*/React.forwardRef(function FocusLockUI(props, parent
|
|
|
2800
3011
|
var hasLeadingGuards = noFocusGuards !== true;
|
|
2801
3012
|
var hasTailingGuards = hasLeadingGuards && noFocusGuards !== 'tail';
|
|
2802
3013
|
var mergedRef = useMergeRefs([parentRef, setObserveNode]);
|
|
2803
|
-
var focusScopeValue =
|
|
3014
|
+
var focusScopeValue = useMemo(function () {
|
|
2804
3015
|
return {
|
|
2805
3016
|
observed: observed,
|
|
2806
3017
|
shards: shards,
|
|
@@ -2808,18 +3019,18 @@ var FocusLock = /*#__PURE__*/React.forwardRef(function FocusLockUI(props, parent
|
|
|
2808
3019
|
active: isActive.current
|
|
2809
3020
|
};
|
|
2810
3021
|
}, [disabled, isActive.current, shards, realObserved]);
|
|
2811
|
-
return /*#__PURE__*/
|
|
2812
|
-
|
|
3022
|
+
return /*#__PURE__*/React__default.createElement(Fragment, null, hasLeadingGuards && [/*#__PURE__*/
|
|
3023
|
+
React__default.createElement("div", {
|
|
2813
3024
|
key: "guard-first",
|
|
2814
3025
|
"data-focus-guard": true,
|
|
2815
3026
|
tabIndex: disabled ? -1 : 0,
|
|
2816
3027
|
style: hiddenGuard
|
|
2817
|
-
}), hasPositiveIndices ? /*#__PURE__*/
|
|
3028
|
+
}), hasPositiveIndices ? /*#__PURE__*/React__default.createElement("div", {
|
|
2818
3029
|
key: "guard-nearest",
|
|
2819
3030
|
"data-focus-guard": true,
|
|
2820
3031
|
tabIndex: disabled ? -1 : 1,
|
|
2821
3032
|
style: hiddenGuard
|
|
2822
|
-
}) : null], !disabled && /*#__PURE__*/
|
|
3033
|
+
}) : null], !disabled && /*#__PURE__*/React__default.createElement(SideCar, {
|
|
2823
3034
|
id: id,
|
|
2824
3035
|
sideCar: mediumSidecar,
|
|
2825
3036
|
observed: realObserved,
|
|
@@ -2834,15 +3045,15 @@ var FocusLock = /*#__PURE__*/React.forwardRef(function FocusLockUI(props, parent
|
|
|
2834
3045
|
returnFocus: returnFocus,
|
|
2835
3046
|
focusOptions: focusOptions,
|
|
2836
3047
|
noFocusGuards: noFocusGuards
|
|
2837
|
-
}), /*#__PURE__*/
|
|
3048
|
+
}), /*#__PURE__*/React__default.createElement(Container, _extends({
|
|
2838
3049
|
ref: mergedRef
|
|
2839
3050
|
}, lockProps, {
|
|
2840
3051
|
className: className,
|
|
2841
3052
|
onBlur: onBlur,
|
|
2842
3053
|
onFocus: onFocus
|
|
2843
|
-
}), /*#__PURE__*/
|
|
3054
|
+
}), /*#__PURE__*/React__default.createElement(focusScope.Provider, {
|
|
2844
3055
|
value: focusScopeValue
|
|
2845
|
-
}, children)), hasTailingGuards && /*#__PURE__*/
|
|
3056
|
+
}, children)), hasTailingGuards && /*#__PURE__*/React__default.createElement("div", {
|
|
2846
3057
|
"data-focus-guard": true,
|
|
2847
3058
|
tabIndex: disabled ? -1 : 0,
|
|
2848
3059
|
style: hiddenGuard
|
|
@@ -2969,7 +3180,7 @@ function toPrimitive(t, r) {
|
|
|
2969
3180
|
if ("object" != _typeof(t) || !t) return t;
|
|
2970
3181
|
var e = t[Symbol.toPrimitive];
|
|
2971
3182
|
if (void 0 !== e) {
|
|
2972
|
-
var i = e.call(t, r
|
|
3183
|
+
var i = e.call(t, r);
|
|
2973
3184
|
if ("object" != _typeof(i)) return i;
|
|
2974
3185
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
2975
3186
|
}
|
|
@@ -2984,9 +3195,9 @@ function toPropertyKey(t) {
|
|
|
2984
3195
|
function _defineProperty(e, r, t) {
|
|
2985
3196
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
2986
3197
|
value: t,
|
|
2987
|
-
enumerable:
|
|
2988
|
-
configurable:
|
|
2989
|
-
writable:
|
|
3198
|
+
enumerable: true,
|
|
3199
|
+
configurable: true,
|
|
3200
|
+
writable: true
|
|
2990
3201
|
}) : e[r] = t, e;
|
|
2991
3202
|
}
|
|
2992
3203
|
|
|
@@ -3519,8 +3730,18 @@ var newFocus = function newFocus(innerNodes, innerTabbables, outerNodes, activeE
|
|
|
3519
3730
|
var firstNodeIndex = outerNodes.indexOf(firstFocus);
|
|
3520
3731
|
var lastNodeIndex = outerNodes.indexOf(lastFocus);
|
|
3521
3732
|
var correctedNodes = correctNodes(outerNodes);
|
|
3522
|
-
var
|
|
3523
|
-
var
|
|
3733
|
+
var currentFocusableIndex = activeElement !== undefined ? correctedNodes.indexOf(activeElement) : -1;
|
|
3734
|
+
var previousFocusableIndex = lastNode ? correctedNodes.indexOf(lastNode) : currentFocusableIndex;
|
|
3735
|
+
var tabbableNodes = correctedNodes.filter(function (node) {
|
|
3736
|
+
return node.tabIndex >= 0;
|
|
3737
|
+
});
|
|
3738
|
+
var currentTabbableIndex = activeElement !== undefined ? tabbableNodes.indexOf(activeElement) : -1;
|
|
3739
|
+
var previousTabbableIndex = lastNode ? tabbableNodes.indexOf(lastNode) : currentTabbableIndex;
|
|
3740
|
+
var focusIndexDiff = currentTabbableIndex >= 0 && previousTabbableIndex >= 0 ?
|
|
3741
|
+
// old/new are tabbables, measure distance in tabbable space
|
|
3742
|
+
previousTabbableIndex - currentTabbableIndex :
|
|
3743
|
+
// or else measure in focusable space
|
|
3744
|
+
previousFocusableIndex - currentFocusableIndex;
|
|
3524
3745
|
// old focus
|
|
3525
3746
|
if (!indexDiff && lastNodeInside >= 0) {
|
|
3526
3747
|
return lastNodeInside;
|
|
@@ -3543,7 +3764,7 @@ var newFocus = function newFocus(innerNodes, innerTabbables, outerNodes, activeE
|
|
|
3543
3764
|
return returnFirstNode;
|
|
3544
3765
|
}
|
|
3545
3766
|
// jump out, but not on the guard
|
|
3546
|
-
if (indexDiff && Math.abs(
|
|
3767
|
+
if (indexDiff && Math.abs(focusIndexDiff) > 1) {
|
|
3547
3768
|
return lastNodeInside;
|
|
3548
3769
|
}
|
|
3549
3770
|
// focus above lock
|
|
@@ -4099,9 +4320,8 @@ var activateTrap = function activateTrap() {
|
|
|
4099
4320
|
focusOptions = _lastActiveTrap.focusOptions,
|
|
4100
4321
|
noFocusGuards = _lastActiveTrap.noFocusGuards;
|
|
4101
4322
|
var workingNode = observed || lastPortaledElement && lastPortaledElement.portaledElement;
|
|
4102
|
-
if (focusOnBody() && lastActiveFocus) {
|
|
4323
|
+
if (focusOnBody() && lastActiveFocus && lastActiveFocus !== document.body) {
|
|
4103
4324
|
if (!document.body.contains(lastActiveFocus) || isNotFocusable(lastActiveFocus)) {
|
|
4104
|
-
lastActiveFocus = null;
|
|
4105
4325
|
var newTarget = tryRestoreFocus();
|
|
4106
4326
|
if (newTarget) {
|
|
4107
4327
|
newTarget.focus();
|
|
@@ -4137,9 +4357,11 @@ var activateTrap = function activateTrap() {
|
|
|
4137
4357
|
lastPortaledElement = {};
|
|
4138
4358
|
}
|
|
4139
4359
|
}
|
|
4140
|
-
focusWasOutsideWindow = false;
|
|
4141
4360
|
lastActiveFocus = document && document.activeElement;
|
|
4142
|
-
|
|
4361
|
+
if (lastActiveFocus !== document.body) {
|
|
4362
|
+
tryRestoreFocus = captureFocusRestore(lastActiveFocus);
|
|
4363
|
+
}
|
|
4364
|
+
focusWasOutsideWindow = false;
|
|
4143
4365
|
}
|
|
4144
4366
|
}
|
|
4145
4367
|
if (document && activeElement !== document.activeElement && document.querySelector('[data-focus-auto-guard]')) {
|
|
@@ -4158,7 +4380,7 @@ var activateTrap = function activateTrap() {
|
|
|
4158
4380
|
var node = _ref4.node;
|
|
4159
4381
|
return node.removeAttribute('tabIndex');
|
|
4160
4382
|
});
|
|
4161
|
-
autoGuard(focusedIndex, allNodes.length,
|
|
4383
|
+
autoGuard(focusedIndex, allNodes.length, 1, allNodes);
|
|
4162
4384
|
autoGuard(focusedIndex, -1, -1, allNodes);
|
|
4163
4385
|
}
|
|
4164
4386
|
}
|
|
@@ -4565,9 +4787,9 @@ var handleScroll = function handleScroll(axis, endTarget, event, sourceDelta, no
|
|
|
4565
4787
|
// self content
|
|
4566
4788
|
targetInLock && (endTarget.contains(target) || endTarget === target));
|
|
4567
4789
|
// handle epsilon around 0 (non standard zoom levels)
|
|
4568
|
-
if (isDeltaPositive && (Math.abs(availableScroll) < 1 ||
|
|
4790
|
+
if (isDeltaPositive && (Math.abs(availableScroll) < 1 || false)) {
|
|
4569
4791
|
shouldCancelScroll = true;
|
|
4570
|
-
} else if (!isDeltaPositive && (Math.abs(availableScrollTop) < 1 ||
|
|
4792
|
+
} else if (!isDeltaPositive && (Math.abs(availableScrollTop) < 1 || false)) {
|
|
4571
4793
|
shouldCancelScroll = true;
|
|
4572
4794
|
}
|
|
4573
4795
|
return shouldCancelScroll;
|
|
@@ -4652,7 +4874,7 @@ function RemoveScrollSideCar(props) {
|
|
|
4652
4874
|
return true;
|
|
4653
4875
|
}
|
|
4654
4876
|
var cancelingAxis = activeAxis.current || currentAxis;
|
|
4655
|
-
return handleScroll(cancelingAxis, parent, event, cancelingAxis === 'h' ? deltaX : deltaY
|
|
4877
|
+
return handleScroll(cancelingAxis, parent, event, cancelingAxis === 'h' ? deltaX : deltaY);
|
|
4656
4878
|
}, []);
|
|
4657
4879
|
var shouldPrevent = React.useCallback(function (_event) {
|
|
4658
4880
|
var event = _event;
|
|
@@ -5010,6 +5232,72 @@ var FocusOn = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
5010
5232
|
}));
|
|
5011
5233
|
});
|
|
5012
5234
|
|
|
5235
|
+
var classnames = {exports: {}};
|
|
5236
|
+
|
|
5237
|
+
var hasRequiredClassnames;
|
|
5238
|
+
function requireClassnames() {
|
|
5239
|
+
if (hasRequiredClassnames) return classnames.exports;
|
|
5240
|
+
hasRequiredClassnames = 1;
|
|
5241
|
+
(function (module) {
|
|
5242
|
+
/* global define */
|
|
5243
|
+
|
|
5244
|
+
(function () {
|
|
5245
|
+
|
|
5246
|
+
var hasOwn = {}.hasOwnProperty;
|
|
5247
|
+
function classNames() {
|
|
5248
|
+
var classes = '';
|
|
5249
|
+
for (var i = 0; i < arguments.length; i++) {
|
|
5250
|
+
var arg = arguments[i];
|
|
5251
|
+
if (arg) {
|
|
5252
|
+
classes = appendClass(classes, parseValue(arg));
|
|
5253
|
+
}
|
|
5254
|
+
}
|
|
5255
|
+
return classes;
|
|
5256
|
+
}
|
|
5257
|
+
function parseValue(arg) {
|
|
5258
|
+
if (typeof arg === 'string' || typeof arg === 'number') {
|
|
5259
|
+
return arg;
|
|
5260
|
+
}
|
|
5261
|
+
if (_typeof$1(arg) !== 'object') {
|
|
5262
|
+
return '';
|
|
5263
|
+
}
|
|
5264
|
+
if (Array.isArray(arg)) {
|
|
5265
|
+
return classNames.apply(null, arg);
|
|
5266
|
+
}
|
|
5267
|
+
if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) {
|
|
5268
|
+
return arg.toString();
|
|
5269
|
+
}
|
|
5270
|
+
var classes = '';
|
|
5271
|
+
for (var key in arg) {
|
|
5272
|
+
if (hasOwn.call(arg, key) && arg[key]) {
|
|
5273
|
+
classes = appendClass(classes, key);
|
|
5274
|
+
}
|
|
5275
|
+
}
|
|
5276
|
+
return classes;
|
|
5277
|
+
}
|
|
5278
|
+
function appendClass(value, newClass) {
|
|
5279
|
+
if (!newClass) {
|
|
5280
|
+
return value;
|
|
5281
|
+
}
|
|
5282
|
+
if (value) {
|
|
5283
|
+
return value + ' ' + newClass;
|
|
5284
|
+
}
|
|
5285
|
+
return value + newClass;
|
|
5286
|
+
}
|
|
5287
|
+
if (module.exports) {
|
|
5288
|
+
classNames["default"] = classNames;
|
|
5289
|
+
module.exports = classNames;
|
|
5290
|
+
} else {
|
|
5291
|
+
window.classNames = classNames;
|
|
5292
|
+
}
|
|
5293
|
+
})();
|
|
5294
|
+
})(classnames);
|
|
5295
|
+
return classnames.exports;
|
|
5296
|
+
}
|
|
5297
|
+
|
|
5298
|
+
var classnamesExports = requireClassnames();
|
|
5299
|
+
var classNames = /*@__PURE__*/getDefaultExportFromCjs(classnamesExports);
|
|
5300
|
+
|
|
5013
5301
|
var dist$3 = {};
|
|
5014
5302
|
|
|
5015
5303
|
var scale = {};
|
|
@@ -5110,7 +5398,7 @@ function requireDist$3() {
|
|
|
5110
5398
|
|
|
5111
5399
|
var distExports$3 = requireDist$3();
|
|
5112
5400
|
|
|
5113
|
-
var _excluded$
|
|
5401
|
+
var _excluded$E = ["aspectWidth", "aspectHeight", "maxWidth", "maxHeight", "outlined", "children", "className"];
|
|
5114
5402
|
var DEFAULT_PRODUCT_ASPECT_WIDTH = 128;
|
|
5115
5403
|
var DEFAULT_PRODUCT_ASPECT_HEIGHT = 205;
|
|
5116
5404
|
var DEFAULT_PRODUCT_ASPECT_RATIO = DEFAULT_PRODUCT_ASPECT_HEIGHT / DEFAULT_PRODUCT_ASPECT_WIDTH;
|
|
@@ -5156,7 +5444,7 @@ var AspectRatioBox = /*#__PURE__*/React__default.forwardRef(function (_ref2, for
|
|
|
5156
5444
|
outlined = _ref2$outlined === void 0 ? false : _ref2$outlined,
|
|
5157
5445
|
children = _ref2.children,
|
|
5158
5446
|
className = _ref2.className,
|
|
5159
|
-
rest = _objectWithoutProperties(_ref2, _excluded$
|
|
5447
|
+
rest = _objectWithoutProperties(_ref2, _excluded$E);
|
|
5160
5448
|
var _scaleDimensions = scaleDimensions({
|
|
5161
5449
|
width: aspectWidth,
|
|
5162
5450
|
height: aspectHeight,
|
|
@@ -5184,22 +5472,22 @@ var AspectRatioBox = /*#__PURE__*/React__default.forwardRef(function (_ref2, for
|
|
|
5184
5472
|
});
|
|
5185
5473
|
AspectRatioBox.displayName = 'AspectRatioBox';
|
|
5186
5474
|
|
|
5187
|
-
var _excluded$
|
|
5475
|
+
var _excluded$D = ["className", "theme", "children"];
|
|
5188
5476
|
var Badge = function Badge(_ref) {
|
|
5189
5477
|
var className = _ref.className,
|
|
5190
5478
|
theme = _ref.theme,
|
|
5191
5479
|
children = _ref.children,
|
|
5192
|
-
rest = _objectWithoutProperties(_ref, _excluded$
|
|
5480
|
+
rest = _objectWithoutProperties(_ref, _excluded$D);
|
|
5193
5481
|
return /*#__PURE__*/React__default.createElement("span", _extends$1({
|
|
5194
5482
|
className: classNames('Badge', theme && "Badge--".concat(theme), className)
|
|
5195
5483
|
}, rest), children);
|
|
5196
5484
|
};
|
|
5197
5485
|
|
|
5198
|
-
var _excluded$
|
|
5486
|
+
var _excluded$C = ["children", "className"];
|
|
5199
5487
|
var Breadcrumbs = function Breadcrumbs(_ref) {
|
|
5200
5488
|
var children = _ref.children,
|
|
5201
5489
|
className = _ref.className,
|
|
5202
|
-
rest = _objectWithoutProperties(_ref, _excluded$
|
|
5490
|
+
rest = _objectWithoutProperties(_ref, _excluded$C);
|
|
5203
5491
|
var position = 0;
|
|
5204
5492
|
return /*#__PURE__*/React__default.createElement("ol", _extends$1({
|
|
5205
5493
|
itemScope: true,
|
|
@@ -5217,7 +5505,7 @@ var Breadcrumbs = function Breadcrumbs(_ref) {
|
|
|
5217
5505
|
}));
|
|
5218
5506
|
};
|
|
5219
5507
|
|
|
5220
|
-
var _excluded$
|
|
5508
|
+
var _excluded$B = ["className", "styleless", "disabled"];
|
|
5221
5509
|
var isLink = function isLink(props) {
|
|
5222
5510
|
return 'to' in props;
|
|
5223
5511
|
};
|
|
@@ -5232,7 +5520,7 @@ var Clickable = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
|
5232
5520
|
_ref$styleless = _ref.styleless,
|
|
5233
5521
|
styleless = _ref$styleless === void 0 ? false : _ref$styleless,
|
|
5234
5522
|
disabled = _ref.disabled,
|
|
5235
|
-
rest = _objectWithoutProperties(_ref, _excluded$
|
|
5523
|
+
rest = _objectWithoutProperties(_ref, _excluded$B);
|
|
5236
5524
|
var props = _objectSpread2(_objectSpread2({}, rest), {}, {
|
|
5237
5525
|
className: classNames({
|
|
5238
5526
|
Clickable: !styleless,
|
|
@@ -5241,7 +5529,6 @@ var Clickable = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
|
5241
5529
|
disabled: disabled
|
|
5242
5530
|
});
|
|
5243
5531
|
if (isLink(props)) return /*#__PURE__*/React__default.createElement(Link, _extends$1({}, props, {
|
|
5244
|
-
href: props.to,
|
|
5245
5532
|
ref: ref
|
|
5246
5533
|
}));
|
|
5247
5534
|
if (isAnchor(props)) return /*#__PURE__*/React__default.createElement("a", _extends$1({}, props, {
|
|
@@ -5254,14 +5541,14 @@ var Clickable = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
|
5254
5541
|
});
|
|
5255
5542
|
Clickable.displayName = 'Clickable';
|
|
5256
5543
|
|
|
5257
|
-
var _excluded$
|
|
5544
|
+
var _excluded$A = ["className", "disabled", "children", "underlined"];
|
|
5258
5545
|
var ControlLink = function ControlLink(_ref) {
|
|
5259
5546
|
var className = _ref.className,
|
|
5260
5547
|
disabled = _ref.disabled,
|
|
5261
5548
|
children = _ref.children,
|
|
5262
5549
|
_ref$underlined = _ref.underlined,
|
|
5263
5550
|
underlined = _ref$underlined === void 0 ? true : _ref$underlined,
|
|
5264
|
-
rest = _objectWithoutProperties(_ref, _excluded$
|
|
5551
|
+
rest = _objectWithoutProperties(_ref, _excluded$A);
|
|
5265
5552
|
return /*#__PURE__*/React__default.createElement(Clickable, _extends$1({}, rest, {
|
|
5266
5553
|
className: classNames('ControlLink', {
|
|
5267
5554
|
'ControlLink--underlined': underlined
|
|
@@ -5272,12 +5559,12 @@ var ControlLink = function ControlLink(_ref) {
|
|
|
5272
5559
|
}), children);
|
|
5273
5560
|
};
|
|
5274
5561
|
|
|
5275
|
-
var _excluded$
|
|
5562
|
+
var _excluded$z = ["children", "position", "className"];
|
|
5276
5563
|
var Breadcrumb = function Breadcrumb(_ref) {
|
|
5277
5564
|
var children = _ref.children,
|
|
5278
5565
|
position = _ref.position,
|
|
5279
5566
|
className = _ref.className,
|
|
5280
|
-
rest = _objectWithoutProperties(_ref, _excluded$
|
|
5567
|
+
rest = _objectWithoutProperties(_ref, _excluded$z);
|
|
5281
5568
|
return /*#__PURE__*/React__default.createElement("li", {
|
|
5282
5569
|
className: classNames('Breadcrumb', className),
|
|
5283
5570
|
itemProp: "itemListElement",
|
|
@@ -7001,11 +7288,11 @@ var useBreakpoint = function useBreakpoint(props) {
|
|
|
7001
7288
|
};
|
|
7002
7289
|
};
|
|
7003
7290
|
|
|
7004
|
-
var _excluded$
|
|
7291
|
+
var _excluded$y = ["children", "className"];
|
|
7005
7292
|
var Breakpoint = function Breakpoint(_ref) {
|
|
7006
7293
|
var children = _ref.children,
|
|
7007
7294
|
className = _ref.className,
|
|
7008
|
-
rest = _objectWithoutProperties(_ref, _excluded$
|
|
7295
|
+
rest = _objectWithoutProperties(_ref, _excluded$y);
|
|
7009
7296
|
var _discriminate = discriminate(rest),
|
|
7010
7297
|
mode = _discriminate.mode,
|
|
7011
7298
|
breakpoint = _discriminate.breakpoint;
|
|
@@ -7016,7 +7303,7 @@ var Breakpoint = function Breakpoint(_ref) {
|
|
|
7016
7303
|
}, omit(['at', 'gt', 'lt'], rest)), children) : null;
|
|
7017
7304
|
};
|
|
7018
7305
|
|
|
7019
|
-
var _excluded$
|
|
7306
|
+
var _excluded$x = ["secondary", "tertiary", "elevated", "chip", "hover", "focus", "disabled", "className"];
|
|
7020
7307
|
var Button = function Button(_ref) {
|
|
7021
7308
|
var secondary = _ref.secondary,
|
|
7022
7309
|
tertiary = _ref.tertiary,
|
|
@@ -7026,7 +7313,7 @@ var Button = function Button(_ref) {
|
|
|
7026
7313
|
focus = _ref.focus,
|
|
7027
7314
|
disabled = _ref.disabled,
|
|
7028
7315
|
className = _ref.className,
|
|
7029
|
-
rest = _objectWithoutProperties(_ref, _excluded$
|
|
7316
|
+
rest = _objectWithoutProperties(_ref, _excluded$x);
|
|
7030
7317
|
return /*#__PURE__*/React__default.createElement(Clickable, _extends$1({
|
|
7031
7318
|
className: classNames('Button', {
|
|
7032
7319
|
'Button--chip': chip,
|
|
@@ -7150,7 +7437,7 @@ var Circle12 = function Circle12(_a) {
|
|
|
7150
7437
|
};
|
|
7151
7438
|
Circle12.displayName = 'Circle12';
|
|
7152
7439
|
|
|
7153
|
-
var _excluded$
|
|
7440
|
+
var _excluded$w = ["className", "defaultChecked", "checked", "children", "value", "onChange", "disabled", "checkIcon", "dataTestId", "id"];
|
|
7154
7441
|
var CHECKED_ITEM_PROPS = {
|
|
7155
7442
|
className: 'Checkbox__check-mark',
|
|
7156
7443
|
height: '85%',
|
|
@@ -7169,7 +7456,7 @@ var Checkbox = function Checkbox(_ref) {
|
|
|
7169
7456
|
checkIcon = _ref$checkIcon === void 0 ? 'checkmark' : _ref$checkIcon,
|
|
7170
7457
|
dataTestId = _ref.dataTestId,
|
|
7171
7458
|
id = _ref.id,
|
|
7172
|
-
rest = _objectWithoutProperties(_ref, _excluded$
|
|
7459
|
+
rest = _objectWithoutProperties(_ref, _excluded$w);
|
|
7173
7460
|
var _useState = useState((_ref2 = checked !== null && checked !== void 0 ? checked : defaultChecked) !== null && _ref2 !== void 0 ? _ref2 : false),
|
|
7174
7461
|
_useState2 = _slicedToArray(_useState, 2),
|
|
7175
7462
|
isChecked = _useState2[0],
|
|
@@ -7261,7 +7548,7 @@ var SKU_COLORS = {
|
|
|
7261
7548
|
yellow: '#ffca44'
|
|
7262
7549
|
};
|
|
7263
7550
|
|
|
7264
|
-
var _excluded$
|
|
7551
|
+
var _excluded$v = ["className", "size", "color", "backgroundUrl", "focus", "hover", "selected", "soldOut", "onSale", "onClick", "onMouseEnter", "disabled", "title"];
|
|
7265
7552
|
var ColorSwatch = function ColorSwatch(_ref) {
|
|
7266
7553
|
var _SKU_COLORS;
|
|
7267
7554
|
var className = _ref.className,
|
|
@@ -7277,7 +7564,7 @@ var ColorSwatch = function ColorSwatch(_ref) {
|
|
|
7277
7564
|
onMouseEnter = _ref.onMouseEnter,
|
|
7278
7565
|
disabled = _ref.disabled,
|
|
7279
7566
|
title = _ref.title,
|
|
7280
|
-
rest = _objectWithoutProperties(_ref, _excluded$
|
|
7567
|
+
rest = _objectWithoutProperties(_ref, _excluded$v);
|
|
7281
7568
|
var handleClick = useCallback(function (_event) {
|
|
7282
7569
|
onClick === null || onClick === void 0 || onClick(color, title);
|
|
7283
7570
|
}, [color, title, onClick]);
|
|
@@ -7312,14 +7599,14 @@ var ColorSwatch = function ColorSwatch(_ref) {
|
|
|
7312
7599
|
}));
|
|
7313
7600
|
};
|
|
7314
7601
|
|
|
7315
|
-
var _excluded$
|
|
7602
|
+
var _excluded$u = ["className", "children", "onClose", "shards", "autoFocus"];
|
|
7316
7603
|
var Modal = function Modal(_ref) {
|
|
7317
7604
|
var className = _ref.className,
|
|
7318
7605
|
children = _ref.children,
|
|
7319
7606
|
onClose = _ref.onClose,
|
|
7320
7607
|
shards = _ref.shards,
|
|
7321
7608
|
autoFocus = _ref.autoFocus,
|
|
7322
|
-
rest = _objectWithoutProperties(_ref, _excluded$
|
|
7609
|
+
rest = _objectWithoutProperties(_ref, _excluded$u);
|
|
7323
7610
|
return /*#__PURE__*/React__default.createElement("div", _extends$1({
|
|
7324
7611
|
className: classNames('Modal', className)
|
|
7325
7612
|
}, rest), /*#__PURE__*/React__default.createElement(FocusOn, {
|
|
@@ -7330,14 +7617,14 @@ var Modal = function Modal(_ref) {
|
|
|
7330
7617
|
}, children));
|
|
7331
7618
|
};
|
|
7332
7619
|
|
|
7333
|
-
var _excluded$
|
|
7620
|
+
var _excluded$t = ["className", "children", "show"];
|
|
7334
7621
|
var UNMOUNT_DELAY_MS = 500;
|
|
7335
7622
|
var Overlay = /*#__PURE__*/forwardRef(function (_ref, forwardedRef) {
|
|
7336
7623
|
var className = _ref.className,
|
|
7337
7624
|
children = _ref.children,
|
|
7338
7625
|
_ref$show = _ref.show,
|
|
7339
7626
|
show = _ref$show === void 0 ? true : _ref$show,
|
|
7340
|
-
rest = _objectWithoutProperties(_ref, _excluded$
|
|
7627
|
+
rest = _objectWithoutProperties(_ref, _excluded$t);
|
|
7341
7628
|
var _useState = useState(show),
|
|
7342
7629
|
_useState2 = _slicedToArray(_useState, 2),
|
|
7343
7630
|
open = _useState2[0],
|
|
@@ -7364,7 +7651,7 @@ var Overlay = /*#__PURE__*/forwardRef(function (_ref, forwardedRef) {
|
|
|
7364
7651
|
});
|
|
7365
7652
|
Overlay.displayName = 'Overlay';
|
|
7366
7653
|
|
|
7367
|
-
var _excluded$
|
|
7654
|
+
var _excluded$s = ["children", "className", "contentClassName", "onClose", "overlayClassName", "show", "shards", "autoFocus"];
|
|
7368
7655
|
var ModalOverlay = function ModalOverlay(_ref) {
|
|
7369
7656
|
var children = _ref.children,
|
|
7370
7657
|
className = _ref.className,
|
|
@@ -7375,7 +7662,7 @@ var ModalOverlay = function ModalOverlay(_ref) {
|
|
|
7375
7662
|
show = _ref$show === void 0 ? true : _ref$show,
|
|
7376
7663
|
shards = _ref.shards,
|
|
7377
7664
|
autoFocus = _ref.autoFocus,
|
|
7378
|
-
rest = _objectWithoutProperties(_ref, _excluded$
|
|
7665
|
+
rest = _objectWithoutProperties(_ref, _excluded$s);
|
|
7379
7666
|
var element = useMemo(function () {
|
|
7380
7667
|
return typeof document !== 'undefined' ? document.createElement('div') : null;
|
|
7381
7668
|
}, []);
|
|
@@ -7401,6 +7688,26 @@ var ModalOverlay = function ModalOverlay(_ref) {
|
|
|
7401
7688
|
}, children))), element);
|
|
7402
7689
|
};
|
|
7403
7690
|
|
|
7691
|
+
var _excluded$r = ["className", "children", "space", "direction", "alignItems", "justifyContent", "style"];
|
|
7692
|
+
var Stack = function Stack(_ref) {
|
|
7693
|
+
var className = _ref.className,
|
|
7694
|
+
children = _ref.children,
|
|
7695
|
+
space = _ref.space,
|
|
7696
|
+
_ref$direction = _ref.direction,
|
|
7697
|
+
direction = _ref$direction === void 0 ? 'vertical' : _ref$direction,
|
|
7698
|
+
alignItems = _ref.alignItems,
|
|
7699
|
+
justifyContent = _ref.justifyContent,
|
|
7700
|
+
style = _ref.style,
|
|
7701
|
+
rest = _objectWithoutProperties(_ref, _excluded$r);
|
|
7702
|
+
return /*#__PURE__*/React__default.createElement("div", _extends$1({
|
|
7703
|
+
className: classNames("Stack Stack--".concat(direction, "-").concat(space), className),
|
|
7704
|
+
style: _objectSpread2(_objectSpread2({}, style), {}, {
|
|
7705
|
+
alignItems: alignItems,
|
|
7706
|
+
justifyContent: justifyContent
|
|
7707
|
+
})
|
|
7708
|
+
}, rest), children);
|
|
7709
|
+
};
|
|
7710
|
+
|
|
7404
7711
|
var _excluded$q = ["as", "className", "treatment", "color", "family", "children", "style"];
|
|
7405
7712
|
var Text = function Text(_ref) {
|
|
7406
7713
|
var _ref$as = _ref.as,
|
|
@@ -7549,516 +7856,7 @@ var ExceedConstrain = function ExceedConstrain(_ref) {
|
|
|
7549
7856
|
|
|
7550
7857
|
var reactInputMask = {exports: {}};
|
|
7551
7858
|
|
|
7552
|
-
var reactInputMask_production_min;
|
|
7553
|
-
var hasRequiredReactInputMask_production_min;
|
|
7554
|
-
function requireReactInputMask_production_min() {
|
|
7555
|
-
if (hasRequiredReactInputMask_production_min) return reactInputMask_production_min;
|
|
7556
|
-
hasRequiredReactInputMask_production_min = 1;
|
|
7557
|
-
function _interopDefault(e) {
|
|
7558
|
-
return e && "object" == _typeof$1(e) && "default" in e ? e["default"] : e;
|
|
7559
|
-
}
|
|
7560
|
-
var React = _interopDefault(React__default),
|
|
7561
|
-
reactDom = require$$1;
|
|
7562
|
-
function _defaults2(e, t) {
|
|
7563
|
-
for (var n = Object.getOwnPropertyNames(t), a = 0; a < n.length; a++) {
|
|
7564
|
-
var i = n[a],
|
|
7565
|
-
r = Object.getOwnPropertyDescriptor(t, i);
|
|
7566
|
-
r && r.configurable && e[i] === undefined && Object.defineProperty(e, i, r);
|
|
7567
|
-
}
|
|
7568
|
-
return e;
|
|
7569
|
-
}
|
|
7570
|
-
function _extends() {
|
|
7571
|
-
return (_extends = Object.assign || function (e) {
|
|
7572
|
-
for (var t = 1; t < arguments.length; t++) {
|
|
7573
|
-
var n = arguments[t];
|
|
7574
|
-
for (var a in n) Object.prototype.hasOwnProperty.call(n, a) && (e[a] = n[a]);
|
|
7575
|
-
}
|
|
7576
|
-
return e;
|
|
7577
|
-
}).apply(this, arguments);
|
|
7578
|
-
}
|
|
7579
|
-
function _inheritsLoose(e, t) {
|
|
7580
|
-
e.prototype = Object.create(t.prototype), _defaults2(e.prototype.constructor = e, t);
|
|
7581
|
-
}
|
|
7582
|
-
function _objectWithoutPropertiesLoose(e, t) {
|
|
7583
|
-
if (null == e) return {};
|
|
7584
|
-
var n,
|
|
7585
|
-
a,
|
|
7586
|
-
i = {},
|
|
7587
|
-
r = Object.keys(e);
|
|
7588
|
-
for (a = 0; a < r.length; a++) n = r[a], 0 <= t.indexOf(n) || (i[n] = e[n]);
|
|
7589
|
-
return i;
|
|
7590
|
-
}
|
|
7591
|
-
function _assertThisInitialized(e) {
|
|
7592
|
-
if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
7593
|
-
return e;
|
|
7594
|
-
}
|
|
7595
|
-
var invariant = function invariant(e, t, n, a, i, r, o, s) {
|
|
7596
|
-
if (!e) {
|
|
7597
|
-
var l;
|
|
7598
|
-
if (t === undefined) l = new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else {
|
|
7599
|
-
var u = [n, a, i, r, o, s],
|
|
7600
|
-
c = 0;
|
|
7601
|
-
(l = new Error(t.replace(/%s/g, function () {
|
|
7602
|
-
return u[c++];
|
|
7603
|
-
}))).name = "Invariant Violation";
|
|
7604
|
-
}
|
|
7605
|
-
throw l.framesToPop = 1, l;
|
|
7606
|
-
}
|
|
7607
|
-
},
|
|
7608
|
-
invariant_1 = invariant;
|
|
7609
|
-
function setInputSelection(e, t, n) {
|
|
7610
|
-
if ("selectionStart" in e && "selectionEnd" in e) e.selectionStart = t, e.selectionEnd = n;else {
|
|
7611
|
-
var a = e.createTextRange();
|
|
7612
|
-
a.collapse(!0), a.moveStart("character", t), a.moveEnd("character", n - t), a.select();
|
|
7613
|
-
}
|
|
7614
|
-
}
|
|
7615
|
-
function getInputSelection(e) {
|
|
7616
|
-
var t = 0,
|
|
7617
|
-
n = 0;
|
|
7618
|
-
if ("selectionStart" in e && "selectionEnd" in e) t = e.selectionStart, n = e.selectionEnd;else {
|
|
7619
|
-
var a = document.selection.createRange();
|
|
7620
|
-
a.parentElement() === e && (t = -a.moveStart("character", -e.value.length), n = -a.moveEnd("character", -e.value.length));
|
|
7621
|
-
}
|
|
7622
|
-
return {
|
|
7623
|
-
start: t,
|
|
7624
|
-
end: n,
|
|
7625
|
-
length: n - t
|
|
7626
|
-
};
|
|
7627
|
-
}
|
|
7628
|
-
var defaultFormatChars = {
|
|
7629
|
-
9: "[0-9]",
|
|
7630
|
-
a: "[A-Za-z]",
|
|
7631
|
-
"*": "[A-Za-z0-9]"
|
|
7632
|
-
},
|
|
7633
|
-
defaultMaskChar = "_";
|
|
7634
|
-
function parseMask(e, t, n) {
|
|
7635
|
-
var a = "",
|
|
7636
|
-
i = "",
|
|
7637
|
-
r = null,
|
|
7638
|
-
o = [];
|
|
7639
|
-
if (t === undefined && (t = defaultMaskChar), null == n && (n = defaultFormatChars), !e || "string" != typeof e) return {
|
|
7640
|
-
maskChar: t,
|
|
7641
|
-
formatChars: n,
|
|
7642
|
-
mask: null,
|
|
7643
|
-
prefix: null,
|
|
7644
|
-
lastEditablePosition: null,
|
|
7645
|
-
permanents: []
|
|
7646
|
-
};
|
|
7647
|
-
var s = !1;
|
|
7648
|
-
return e.split("").forEach(function (e) {
|
|
7649
|
-
s = !s && "\\" === e || (s || !n[e] ? (o.push(a.length), a.length === o.length - 1 && (i += e)) : r = a.length + 1, a += e, !1);
|
|
7650
|
-
}), {
|
|
7651
|
-
maskChar: t,
|
|
7652
|
-
formatChars: n,
|
|
7653
|
-
prefix: i,
|
|
7654
|
-
mask: a,
|
|
7655
|
-
lastEditablePosition: r,
|
|
7656
|
-
permanents: o
|
|
7657
|
-
};
|
|
7658
|
-
}
|
|
7659
|
-
function isPermanentCharacter(e, t) {
|
|
7660
|
-
return -1 !== e.permanents.indexOf(t);
|
|
7661
|
-
}
|
|
7662
|
-
function isAllowedCharacter(e, t, n) {
|
|
7663
|
-
var a = e.mask,
|
|
7664
|
-
i = e.formatChars;
|
|
7665
|
-
if (!n) return !1;
|
|
7666
|
-
if (isPermanentCharacter(e, t)) return a[t] === n;
|
|
7667
|
-
var r = i[a[t]];
|
|
7668
|
-
return new RegExp(r).test(n);
|
|
7669
|
-
}
|
|
7670
|
-
function isEmpty(n, e) {
|
|
7671
|
-
return e.split("").every(function (e, t) {
|
|
7672
|
-
return isPermanentCharacter(n, t) || !isAllowedCharacter(n, t, e);
|
|
7673
|
-
});
|
|
7674
|
-
}
|
|
7675
|
-
function getFilledLength(e, t) {
|
|
7676
|
-
var n = e.maskChar,
|
|
7677
|
-
a = e.prefix;
|
|
7678
|
-
if (!n) {
|
|
7679
|
-
for (; t.length > a.length && isPermanentCharacter(e, t.length - 1);) t = t.slice(0, t.length - 1);
|
|
7680
|
-
return t.length;
|
|
7681
|
-
}
|
|
7682
|
-
for (var i = a.length, r = t.length; r >= a.length; r--) {
|
|
7683
|
-
var o = t[r];
|
|
7684
|
-
if (!isPermanentCharacter(e, r) && isAllowedCharacter(e, r, o)) {
|
|
7685
|
-
i = r + 1;
|
|
7686
|
-
break;
|
|
7687
|
-
}
|
|
7688
|
-
}
|
|
7689
|
-
return i;
|
|
7690
|
-
}
|
|
7691
|
-
function isFilled(e, t) {
|
|
7692
|
-
return getFilledLength(e, t) === e.mask.length;
|
|
7693
|
-
}
|
|
7694
|
-
function formatValue(e, t) {
|
|
7695
|
-
var n = e.maskChar,
|
|
7696
|
-
a = e.mask,
|
|
7697
|
-
i = e.prefix;
|
|
7698
|
-
if (!n) {
|
|
7699
|
-
for ((t = insertString(e, "", t, 0)).length < i.length && (t = i); t.length < a.length && isPermanentCharacter(e, t.length);) t += a[t.length];
|
|
7700
|
-
return t;
|
|
7701
|
-
}
|
|
7702
|
-
if (t) return insertString(e, formatValue(e, ""), t, 0);
|
|
7703
|
-
for (var r = 0; r < a.length; r++) isPermanentCharacter(e, r) ? t += a[r] : t += n;
|
|
7704
|
-
return t;
|
|
7705
|
-
}
|
|
7706
|
-
function clearRange(n, e, a, t) {
|
|
7707
|
-
var i = a + t,
|
|
7708
|
-
r = n.maskChar,
|
|
7709
|
-
o = n.mask,
|
|
7710
|
-
s = n.prefix,
|
|
7711
|
-
l = e.split("");
|
|
7712
|
-
if (r) return l.map(function (e, t) {
|
|
7713
|
-
return t < a || i <= t ? e : isPermanentCharacter(n, t) ? o[t] : r;
|
|
7714
|
-
}).join("");
|
|
7715
|
-
for (var u = i; u < l.length; u++) isPermanentCharacter(n, u) && (l[u] = "");
|
|
7716
|
-
return a = Math.max(s.length, a), l.splice(a, i - a), e = l.join(""), formatValue(n, e);
|
|
7717
|
-
}
|
|
7718
|
-
function insertString(r, o, e, s) {
|
|
7719
|
-
var l = r.mask,
|
|
7720
|
-
u = r.maskChar,
|
|
7721
|
-
c = r.prefix,
|
|
7722
|
-
t = e.split(""),
|
|
7723
|
-
h = isFilled(r, o);
|
|
7724
|
-
return !u && s > o.length && (o += l.slice(o.length, s)), t.every(function (e) {
|
|
7725
|
-
for (; i = e, isPermanentCharacter(r, a = s) && i !== l[a];) {
|
|
7726
|
-
if (s >= o.length && (o += l[s]), t = e, n = s, u && isPermanentCharacter(r, n) && t === u) return !0;
|
|
7727
|
-
if (++s >= l.length) return !1;
|
|
7728
|
-
}
|
|
7729
|
-
var t, n, a, i;
|
|
7730
|
-
return !isAllowedCharacter(r, s, e) && e !== u || (s < o.length ? o = u || h || s < c.length ? o.slice(0, s) + e + o.slice(s + 1) : (o = o.slice(0, s) + e + o.slice(s), formatValue(r, o)) : u || (o += e), ++s < l.length);
|
|
7731
|
-
}), o;
|
|
7732
|
-
}
|
|
7733
|
-
function getInsertStringLength(a, e, t, i) {
|
|
7734
|
-
var r = a.mask,
|
|
7735
|
-
o = a.maskChar,
|
|
7736
|
-
n = t.split(""),
|
|
7737
|
-
s = i;
|
|
7738
|
-
return n.every(function (e) {
|
|
7739
|
-
for (; n = e, isPermanentCharacter(a, t = i) && n !== r[t];) if (++i >= r.length) return !1;
|
|
7740
|
-
var t, n;
|
|
7741
|
-
return (isAllowedCharacter(a, i, e) || e === o) && i++, i < r.length;
|
|
7742
|
-
}), i - s;
|
|
7743
|
-
}
|
|
7744
|
-
function getLeftEditablePosition(e, t) {
|
|
7745
|
-
for (var n = t; 0 <= n; --n) if (!isPermanentCharacter(e, n)) return n;
|
|
7746
|
-
return null;
|
|
7747
|
-
}
|
|
7748
|
-
function getRightEditablePosition(e, t) {
|
|
7749
|
-
for (var n = e.mask, a = t; a < n.length; ++a) if (!isPermanentCharacter(e, a)) return a;
|
|
7750
|
-
return null;
|
|
7751
|
-
}
|
|
7752
|
-
function getStringValue(e) {
|
|
7753
|
-
return e || 0 === e ? e + "" : "";
|
|
7754
|
-
}
|
|
7755
|
-
function processChange(e, t, n, a, i) {
|
|
7756
|
-
var r = e.mask,
|
|
7757
|
-
o = e.prefix,
|
|
7758
|
-
s = e.lastEditablePosition,
|
|
7759
|
-
l = t,
|
|
7760
|
-
u = "",
|
|
7761
|
-
c = 0,
|
|
7762
|
-
h = 0,
|
|
7763
|
-
f = Math.min(i.start, n.start);
|
|
7764
|
-
if (n.end > i.start ? h = (c = getInsertStringLength(e, a, u = l.slice(i.start, n.end), f)) ? i.length : 0 : l.length < a.length && (h = a.length - l.length), l = a, h) {
|
|
7765
|
-
if (1 === h && !i.length) f = i.start === n.start ? getRightEditablePosition(e, n.start) : getLeftEditablePosition(e, n.start);
|
|
7766
|
-
l = clearRange(e, l, f, h);
|
|
7767
|
-
}
|
|
7768
|
-
return l = insertString(e, l, u, f), (f += c) >= r.length ? f = r.length : f < o.length && !c ? f = o.length : f >= o.length && f < s && c && (f = getRightEditablePosition(e, f)), u || (u = null), {
|
|
7769
|
-
value: l = formatValue(e, l),
|
|
7770
|
-
enteredString: u,
|
|
7771
|
-
selection: {
|
|
7772
|
-
start: f,
|
|
7773
|
-
end: f
|
|
7774
|
-
}
|
|
7775
|
-
};
|
|
7776
|
-
}
|
|
7777
|
-
function isWindowsPhoneBrowser() {
|
|
7778
|
-
var e = new RegExp("windows", "i"),
|
|
7779
|
-
t = new RegExp("phone", "i"),
|
|
7780
|
-
n = navigator.userAgent;
|
|
7781
|
-
return e.test(n) && t.test(n);
|
|
7782
|
-
}
|
|
7783
|
-
function isFunction(e) {
|
|
7784
|
-
return "function" == typeof e;
|
|
7785
|
-
}
|
|
7786
|
-
function getRequestAnimationFrame() {
|
|
7787
|
-
return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame;
|
|
7788
|
-
}
|
|
7789
|
-
function getCancelAnimationFrame() {
|
|
7790
|
-
return window.cancelAnimationFrame || window.webkitCancelRequestAnimationFrame || window.webkitCancelAnimationFrame || window.mozCancelAnimationFrame;
|
|
7791
|
-
}
|
|
7792
|
-
function defer(e) {
|
|
7793
|
-
return (!!getCancelAnimationFrame() ? getRequestAnimationFrame() : function () {
|
|
7794
|
-
return setTimeout(e, 1e3 / 60);
|
|
7795
|
-
})(e);
|
|
7796
|
-
}
|
|
7797
|
-
function cancelDefer(e) {
|
|
7798
|
-
(getCancelAnimationFrame() || clearTimeout)(e);
|
|
7799
|
-
}
|
|
7800
|
-
var InputElement = function (c) {
|
|
7801
|
-
function e(e) {
|
|
7802
|
-
var f = c.call(this, e) || this;
|
|
7803
|
-
f.focused = !1, f.mounted = !1, f.previousSelection = null, f.selectionDeferId = null, f.saveSelectionLoopDeferId = null, f.saveSelectionLoop = function () {
|
|
7804
|
-
f.previousSelection = f.getSelection(), f.saveSelectionLoopDeferId = defer(f.saveSelectionLoop);
|
|
7805
|
-
}, f.runSaveSelectionLoop = function () {
|
|
7806
|
-
null === f.saveSelectionLoopDeferId && f.saveSelectionLoop();
|
|
7807
|
-
}, f.stopSaveSelectionLoop = function () {
|
|
7808
|
-
null !== f.saveSelectionLoopDeferId && (cancelDefer(f.saveSelectionLoopDeferId), f.saveSelectionLoopDeferId = null, f.previousSelection = null);
|
|
7809
|
-
}, f.getInputDOMNode = function () {
|
|
7810
|
-
if (!f.mounted) return null;
|
|
7811
|
-
var e = reactDom.findDOMNode(_assertThisInitialized(_assertThisInitialized(f))),
|
|
7812
|
-
t = "undefined" != typeof window && e instanceof window.Element;
|
|
7813
|
-
if (e && !t) return null;
|
|
7814
|
-
if ("INPUT" !== e.nodeName && (e = e.querySelector("input")), !e) throw new Error("react-input-mask: inputComponent doesn't contain input node");
|
|
7815
|
-
return e;
|
|
7816
|
-
}, f.getInputValue = function () {
|
|
7817
|
-
var e = f.getInputDOMNode();
|
|
7818
|
-
return e ? e.value : null;
|
|
7819
|
-
}, f.setInputValue = function (e) {
|
|
7820
|
-
var t = f.getInputDOMNode();
|
|
7821
|
-
t && (f.value = e, t.value = e);
|
|
7822
|
-
}, f.setCursorToEnd = function () {
|
|
7823
|
-
var e = getFilledLength(f.maskOptions, f.value),
|
|
7824
|
-
t = getRightEditablePosition(f.maskOptions, e);
|
|
7825
|
-
null !== t && f.setCursorPosition(t);
|
|
7826
|
-
}, f.setSelection = function (e, t, n) {
|
|
7827
|
-
void 0 === n && (n = {});
|
|
7828
|
-
var a = f.getInputDOMNode(),
|
|
7829
|
-
i = f.isFocused();
|
|
7830
|
-
a && i && (n.deferred || setInputSelection(a, e, t), null !== f.selectionDeferId && cancelDefer(f.selectionDeferId), f.selectionDeferId = defer(function () {
|
|
7831
|
-
f.selectionDeferId = null, setInputSelection(a, e, t);
|
|
7832
|
-
}), f.previousSelection = {
|
|
7833
|
-
start: e,
|
|
7834
|
-
end: t,
|
|
7835
|
-
length: Math.abs(t - e)
|
|
7836
|
-
});
|
|
7837
|
-
}, f.getSelection = function () {
|
|
7838
|
-
return getInputSelection(f.getInputDOMNode());
|
|
7839
|
-
}, f.getCursorPosition = function () {
|
|
7840
|
-
return f.getSelection().start;
|
|
7841
|
-
}, f.setCursorPosition = function (e) {
|
|
7842
|
-
f.setSelection(e, e);
|
|
7843
|
-
}, f.isFocused = function () {
|
|
7844
|
-
return f.focused;
|
|
7845
|
-
}, f.getBeforeMaskedValueChangeConfig = function () {
|
|
7846
|
-
var e = f.maskOptions,
|
|
7847
|
-
t = e.mask,
|
|
7848
|
-
n = e.maskChar,
|
|
7849
|
-
a = e.permanents,
|
|
7850
|
-
i = e.formatChars;
|
|
7851
|
-
return {
|
|
7852
|
-
mask: t,
|
|
7853
|
-
maskChar: n,
|
|
7854
|
-
permanents: a,
|
|
7855
|
-
alwaysShowMask: !!f.props.alwaysShowMask,
|
|
7856
|
-
formatChars: i
|
|
7857
|
-
};
|
|
7858
|
-
}, f.isInputAutofilled = function (e, t, n, a) {
|
|
7859
|
-
var i = f.getInputDOMNode();
|
|
7860
|
-
try {
|
|
7861
|
-
if (i.matches(":-webkit-autofill")) return !0;
|
|
7862
|
-
} catch (r) {}
|
|
7863
|
-
return !f.focused || a.end < n.length && t.end === e.length;
|
|
7864
|
-
}, f.onChange = function (e) {
|
|
7865
|
-
var t = _assertThisInitialized(_assertThisInitialized(f)).beforePasteState,
|
|
7866
|
-
n = _assertThisInitialized(_assertThisInitialized(f)).previousSelection,
|
|
7867
|
-
a = f.props.beforeMaskedValueChange,
|
|
7868
|
-
i = f.getInputValue(),
|
|
7869
|
-
r = f.value,
|
|
7870
|
-
o = f.getSelection();
|
|
7871
|
-
f.isInputAutofilled(i, o, r, n) && (r = formatValue(f.maskOptions, ""), n = {
|
|
7872
|
-
start: 0,
|
|
7873
|
-
end: 0,
|
|
7874
|
-
length: 0
|
|
7875
|
-
}), t && (n = t.selection, r = t.value, o = {
|
|
7876
|
-
start: n.start + i.length,
|
|
7877
|
-
end: n.start + i.length,
|
|
7878
|
-
length: 0
|
|
7879
|
-
}, i = r.slice(0, n.start) + i + r.slice(n.end), f.beforePasteState = null);
|
|
7880
|
-
var s = processChange(f.maskOptions, i, o, r, n),
|
|
7881
|
-
l = s.enteredString,
|
|
7882
|
-
u = s.selection,
|
|
7883
|
-
c = s.value;
|
|
7884
|
-
if (isFunction(a)) {
|
|
7885
|
-
var h = a({
|
|
7886
|
-
value: c,
|
|
7887
|
-
selection: u
|
|
7888
|
-
}, {
|
|
7889
|
-
value: r,
|
|
7890
|
-
selection: n
|
|
7891
|
-
}, l, f.getBeforeMaskedValueChangeConfig());
|
|
7892
|
-
c = h.value, u = h.selection;
|
|
7893
|
-
}
|
|
7894
|
-
f.setInputValue(c), isFunction(f.props.onChange) && f.props.onChange(e), f.isWindowsPhoneBrowser ? f.setSelection(u.start, u.end, {
|
|
7895
|
-
deferred: !0
|
|
7896
|
-
}) : f.setSelection(u.start, u.end);
|
|
7897
|
-
}, f.onFocus = function (e) {
|
|
7898
|
-
var t = f.props.beforeMaskedValueChange,
|
|
7899
|
-
n = f.maskOptions,
|
|
7900
|
-
a = n.mask,
|
|
7901
|
-
i = n.prefix;
|
|
7902
|
-
if (f.focused = !0, f.mounted = !0, a) {
|
|
7903
|
-
if (f.value) getFilledLength(f.maskOptions, f.value) < f.maskOptions.mask.length && f.setCursorToEnd();else {
|
|
7904
|
-
var r = formatValue(f.maskOptions, i),
|
|
7905
|
-
o = formatValue(f.maskOptions, r),
|
|
7906
|
-
s = getFilledLength(f.maskOptions, o),
|
|
7907
|
-
l = getRightEditablePosition(f.maskOptions, s),
|
|
7908
|
-
u = {
|
|
7909
|
-
start: l,
|
|
7910
|
-
end: l
|
|
7911
|
-
};
|
|
7912
|
-
if (isFunction(t)) {
|
|
7913
|
-
var c = t({
|
|
7914
|
-
value: o,
|
|
7915
|
-
selection: u
|
|
7916
|
-
}, {
|
|
7917
|
-
value: f.value,
|
|
7918
|
-
selection: null
|
|
7919
|
-
}, null, f.getBeforeMaskedValueChangeConfig());
|
|
7920
|
-
o = c.value, u = c.selection;
|
|
7921
|
-
}
|
|
7922
|
-
var h = o !== f.getInputValue();
|
|
7923
|
-
h && f.setInputValue(o), h && isFunction(f.props.onChange) && f.props.onChange(e), f.setSelection(u.start, u.end);
|
|
7924
|
-
}
|
|
7925
|
-
f.runSaveSelectionLoop();
|
|
7926
|
-
}
|
|
7927
|
-
isFunction(f.props.onFocus) && f.props.onFocus(e);
|
|
7928
|
-
}, f.onBlur = function (e) {
|
|
7929
|
-
var t = f.props.beforeMaskedValueChange,
|
|
7930
|
-
n = f.maskOptions.mask;
|
|
7931
|
-
if (f.stopSaveSelectionLoop(), f.focused = !1, n && !f.props.alwaysShowMask && isEmpty(f.maskOptions, f.value)) {
|
|
7932
|
-
var a = "";
|
|
7933
|
-
if (isFunction(t)) a = t({
|
|
7934
|
-
value: a,
|
|
7935
|
-
selection: null
|
|
7936
|
-
}, {
|
|
7937
|
-
value: f.value,
|
|
7938
|
-
selection: f.previousSelection
|
|
7939
|
-
}, null, f.getBeforeMaskedValueChangeConfig()).value;
|
|
7940
|
-
var i = a !== f.getInputValue();
|
|
7941
|
-
i && f.setInputValue(a), i && isFunction(f.props.onChange) && f.props.onChange(e);
|
|
7942
|
-
}
|
|
7943
|
-
isFunction(f.props.onBlur) && f.props.onBlur(e);
|
|
7944
|
-
}, f.onMouseDown = function (e) {
|
|
7945
|
-
if (!f.focused && document.addEventListener) {
|
|
7946
|
-
f.mouseDownX = e.clientX, f.mouseDownY = e.clientY, f.mouseDownTime = new Date().getTime();
|
|
7947
|
-
var r = function r(e) {
|
|
7948
|
-
if (document.removeEventListener("mouseup", r), f.focused) {
|
|
7949
|
-
var t = Math.abs(e.clientX - f.mouseDownX),
|
|
7950
|
-
n = Math.abs(e.clientY - f.mouseDownY),
|
|
7951
|
-
a = Math.max(t, n),
|
|
7952
|
-
i = new Date().getTime() - f.mouseDownTime;
|
|
7953
|
-
(a <= 10 && i <= 200 || a <= 5 && i <= 300) && f.setCursorToEnd();
|
|
7954
|
-
}
|
|
7955
|
-
};
|
|
7956
|
-
document.addEventListener("mouseup", r);
|
|
7957
|
-
}
|
|
7958
|
-
isFunction(f.props.onMouseDown) && f.props.onMouseDown(e);
|
|
7959
|
-
}, f.onPaste = function (e) {
|
|
7960
|
-
isFunction(f.props.onPaste) && f.props.onPaste(e), e.defaultPrevented || (f.beforePasteState = {
|
|
7961
|
-
value: f.getInputValue(),
|
|
7962
|
-
selection: f.getSelection()
|
|
7963
|
-
}, f.setInputValue(""));
|
|
7964
|
-
}, f.handleRef = function (e) {
|
|
7965
|
-
null == f.props.children && isFunction(f.props.inputRef) && f.props.inputRef(e);
|
|
7966
|
-
};
|
|
7967
|
-
var t = e.mask,
|
|
7968
|
-
n = e.maskChar,
|
|
7969
|
-
a = e.formatChars,
|
|
7970
|
-
i = e.alwaysShowMask,
|
|
7971
|
-
r = e.beforeMaskedValueChange,
|
|
7972
|
-
o = e.defaultValue,
|
|
7973
|
-
s = e.value;
|
|
7974
|
-
f.maskOptions = parseMask(t, n, a), null == o && (o = ""), null == s && (s = o);
|
|
7975
|
-
var l = getStringValue(s);
|
|
7976
|
-
if (f.maskOptions.mask && (i || l) && (l = formatValue(f.maskOptions, l), isFunction(r))) {
|
|
7977
|
-
var u = e.value;
|
|
7978
|
-
null == e.value && (u = o), l = r({
|
|
7979
|
-
value: l,
|
|
7980
|
-
selection: null
|
|
7981
|
-
}, {
|
|
7982
|
-
value: u = getStringValue(u),
|
|
7983
|
-
selection: null
|
|
7984
|
-
}, null, f.getBeforeMaskedValueChangeConfig()).value;
|
|
7985
|
-
}
|
|
7986
|
-
return f.value = l, f;
|
|
7987
|
-
}
|
|
7988
|
-
_inheritsLoose(e, c);
|
|
7989
|
-
var t = e.prototype;
|
|
7990
|
-
return t.componentDidMount = function () {
|
|
7991
|
-
this.mounted = !0, this.getInputDOMNode() && (this.isWindowsPhoneBrowser = isWindowsPhoneBrowser(), this.maskOptions.mask && this.getInputValue() !== this.value && this.setInputValue(this.value));
|
|
7992
|
-
}, t.componentDidUpdate = function () {
|
|
7993
|
-
var e = this.previousSelection,
|
|
7994
|
-
t = this.props,
|
|
7995
|
-
n = t.beforeMaskedValueChange,
|
|
7996
|
-
a = t.alwaysShowMask,
|
|
7997
|
-
i = t.mask,
|
|
7998
|
-
r = t.maskChar,
|
|
7999
|
-
o = t.formatChars,
|
|
8000
|
-
s = this.maskOptions,
|
|
8001
|
-
l = a || this.isFocused(),
|
|
8002
|
-
u = null != this.props.value,
|
|
8003
|
-
c = u ? getStringValue(this.props.value) : this.value,
|
|
8004
|
-
h = e ? e.start : null;
|
|
8005
|
-
if (this.maskOptions = parseMask(i, r, o), this.maskOptions.mask) {
|
|
8006
|
-
!s.mask && this.isFocused() && this.runSaveSelectionLoop();
|
|
8007
|
-
var f = this.maskOptions.mask && this.maskOptions.mask !== s.mask;
|
|
8008
|
-
if (s.mask || u || (c = this.getInputValue()), (f || this.maskOptions.mask && (c || l)) && (c = formatValue(this.maskOptions, c)), f) {
|
|
8009
|
-
var p = getFilledLength(this.maskOptions, c);
|
|
8010
|
-
(null === h || p < h) && (h = isFilled(this.maskOptions, c) ? p : getRightEditablePosition(this.maskOptions, p));
|
|
8011
|
-
}
|
|
8012
|
-
!this.maskOptions.mask || !isEmpty(this.maskOptions, c) || l || u && this.props.value || (c = "");
|
|
8013
|
-
var d = {
|
|
8014
|
-
start: h,
|
|
8015
|
-
end: h
|
|
8016
|
-
};
|
|
8017
|
-
if (isFunction(n)) {
|
|
8018
|
-
var m = n({
|
|
8019
|
-
value: c,
|
|
8020
|
-
selection: d
|
|
8021
|
-
}, {
|
|
8022
|
-
value: this.value,
|
|
8023
|
-
selection: this.previousSelection
|
|
8024
|
-
}, null, this.getBeforeMaskedValueChangeConfig());
|
|
8025
|
-
c = m.value, d = m.selection;
|
|
8026
|
-
}
|
|
8027
|
-
this.value = c;
|
|
8028
|
-
var g = this.getInputValue() !== this.value;
|
|
8029
|
-
g ? (this.setInputValue(this.value), this.forceUpdate()) : f && this.forceUpdate();
|
|
8030
|
-
var v = !1;
|
|
8031
|
-
null != d.start && null != d.end && (v = !e || e.start !== d.start || e.end !== d.end), (v || g) && this.setSelection(d.start, d.end);
|
|
8032
|
-
} else s.mask && (this.stopSaveSelectionLoop(), this.forceUpdate());
|
|
8033
|
-
}, t.componentWillUnmount = function () {
|
|
8034
|
-
this.mounted = !1, null !== this.selectionDeferId && cancelDefer(this.selectionDeferId), this.stopSaveSelectionLoop();
|
|
8035
|
-
}, t.render = function () {
|
|
8036
|
-
var t,
|
|
8037
|
-
e = this.props,
|
|
8038
|
-
n = (e.mask, e.alwaysShowMask, e.maskChar, e.formatChars, e.inputRef, e.beforeMaskedValueChange, e.children),
|
|
8039
|
-
a = _objectWithoutPropertiesLoose(e, ["mask", "alwaysShowMask", "maskChar", "formatChars", "inputRef", "beforeMaskedValueChange", "children"]);
|
|
8040
|
-
if (n) {
|
|
8041
|
-
isFunction(n) || invariant_1(!1);
|
|
8042
|
-
var i = ["onChange", "onPaste", "onMouseDown", "onFocus", "onBlur", "value", "disabled", "readOnly"],
|
|
8043
|
-
r = _extends({}, a);
|
|
8044
|
-
i.forEach(function (e) {
|
|
8045
|
-
return delete r[e];
|
|
8046
|
-
}), t = n(r), i.filter(function (e) {
|
|
8047
|
-
return null != t.props[e] && t.props[e] !== a[e];
|
|
8048
|
-
}).length && invariant_1(!1);
|
|
8049
|
-
} else t = React.createElement("input", _extends({
|
|
8050
|
-
ref: this.handleRef
|
|
8051
|
-
}, a));
|
|
8052
|
-
var o = {
|
|
8053
|
-
onFocus: this.onFocus,
|
|
8054
|
-
onBlur: this.onBlur
|
|
8055
|
-
};
|
|
8056
|
-
return this.maskOptions.mask && (a.disabled || a.readOnly || (o.onChange = this.onChange, o.onPaste = this.onPaste, o.onMouseDown = this.onMouseDown), null != a.value && (o.value = this.value)), t = React.cloneElement(t, o);
|
|
8057
|
-
}, e;
|
|
8058
|
-
}(React.Component);
|
|
8059
|
-
reactInputMask_production_min = InputElement;
|
|
8060
|
-
return reactInputMask_production_min;
|
|
8061
|
-
}
|
|
7859
|
+
var reactInputMask_production_min = {exports: {}};
|
|
8062
7860
|
|
|
8063
7861
|
/**
|
|
8064
7862
|
* Copyright (c) 2013-present, Facebook, Inc.
|
|
@@ -8170,31 +7968,527 @@ function requireWarning() {
|
|
|
8170
7968
|
return warning_1;
|
|
8171
7969
|
}
|
|
8172
7970
|
|
|
7971
|
+
var hasRequiredReactInputMask_production_min;
|
|
7972
|
+
function requireReactInputMask_production_min() {
|
|
7973
|
+
if (hasRequiredReactInputMask_production_min) return reactInputMask_production_min.exports;
|
|
7974
|
+
hasRequiredReactInputMask_production_min = 1;
|
|
7975
|
+
var e = React__default;
|
|
7976
|
+
var t = requireInvariant();
|
|
7977
|
+
function n() {
|
|
7978
|
+
return n = Object.assign ? Object.assign.bind() : function (e) {
|
|
7979
|
+
for (var t = 1; t < arguments.length; t++) {
|
|
7980
|
+
var n = arguments[t];
|
|
7981
|
+
for (var i in n) Object.prototype.hasOwnProperty.call(n, i) && (e[i] = n[i]);
|
|
7982
|
+
}
|
|
7983
|
+
return e;
|
|
7984
|
+
}, n.apply(this, arguments);
|
|
7985
|
+
}
|
|
7986
|
+
function i(e) {
|
|
7987
|
+
return requestAnimationFrame(e);
|
|
7988
|
+
}
|
|
7989
|
+
function r(e) {
|
|
7990
|
+
cancelAnimationFrame(e);
|
|
7991
|
+
}
|
|
7992
|
+
function a(e) {
|
|
7993
|
+
var t = e.ownerDocument;
|
|
7994
|
+
return t.hasFocus() && t.activeElement === e;
|
|
7995
|
+
}
|
|
7996
|
+
function l(e) {
|
|
7997
|
+
return null == e ? void 0 : e.ownerDocument;
|
|
7998
|
+
}
|
|
7999
|
+
function o(e) {
|
|
8000
|
+
var t = function (e) {
|
|
8001
|
+
var t;
|
|
8002
|
+
return null == (t = l(e)) ? void 0 : t.defaultView;
|
|
8003
|
+
}(e);
|
|
8004
|
+
return !!t && e instanceof t.HTMLElement;
|
|
8005
|
+
}
|
|
8006
|
+
function u(t) {
|
|
8007
|
+
return e.useCallback(function () {
|
|
8008
|
+
var e = t.current,
|
|
8009
|
+
n = "undefined" != typeof window && o(e);
|
|
8010
|
+
if (!e || !n) return null;
|
|
8011
|
+
if ("INPUT" !== e.nodeName && (e = e.querySelector("input")), !e) throw new Error("react-input-mask: inputComponent doesn't contain input node");
|
|
8012
|
+
return e;
|
|
8013
|
+
}, [t]);
|
|
8014
|
+
}
|
|
8015
|
+
function s(t, n) {
|
|
8016
|
+
var l,
|
|
8017
|
+
o,
|
|
8018
|
+
s,
|
|
8019
|
+
c,
|
|
8020
|
+
f = e.useRef({
|
|
8021
|
+
start: null,
|
|
8022
|
+
end: null
|
|
8023
|
+
}),
|
|
8024
|
+
h = u(t),
|
|
8025
|
+
g = e.useCallback(function () {
|
|
8026
|
+
return function (e) {
|
|
8027
|
+
var t = e.selectionStart,
|
|
8028
|
+
n = e.selectionEnd;
|
|
8029
|
+
return {
|
|
8030
|
+
start: t,
|
|
8031
|
+
end: n,
|
|
8032
|
+
length: n - t
|
|
8033
|
+
};
|
|
8034
|
+
}(h());
|
|
8035
|
+
}, [h]),
|
|
8036
|
+
v = e.useCallback(function () {
|
|
8037
|
+
return f.current;
|
|
8038
|
+
}, []),
|
|
8039
|
+
d = e.useCallback(function (e) {
|
|
8040
|
+
var t = h();
|
|
8041
|
+
t && a(t) && (!function (e, t, n) {
|
|
8042
|
+
void 0 === n && (n = t), e.setSelectionRange(t, n);
|
|
8043
|
+
}(t, e.start, e.end), f.current = g());
|
|
8044
|
+
}, [h, g]),
|
|
8045
|
+
m = e.useCallback(function () {
|
|
8046
|
+
f.current = g();
|
|
8047
|
+
}, [g]),
|
|
8048
|
+
p = (l = m, o = e.useRef(null), s = e.useCallback(function () {
|
|
8049
|
+
null === o.current && function e() {
|
|
8050
|
+
l(), o.current = i(e);
|
|
8051
|
+
}();
|
|
8052
|
+
}, [l]), c = e.useCallback(function () {
|
|
8053
|
+
r(o.current), o.current = null;
|
|
8054
|
+
}, []), e.useEffect(function () {
|
|
8055
|
+
o.current && (c(), s());
|
|
8056
|
+
}, [s, c]), e.useEffect(r, []), [s, c]),
|
|
8057
|
+
k = p[0],
|
|
8058
|
+
P = p[1];
|
|
8059
|
+
return e.useLayoutEffect(function () {
|
|
8060
|
+
if (n) {
|
|
8061
|
+
var e = h();
|
|
8062
|
+
return e.addEventListener("focus", k), e.addEventListener("blur", P), a(e) && k(), function () {
|
|
8063
|
+
e.removeEventListener("focus", k), e.removeEventListener("blur", P), P();
|
|
8064
|
+
};
|
|
8065
|
+
}
|
|
8066
|
+
}), {
|
|
8067
|
+
getSelection: g,
|
|
8068
|
+
getLastSelection: v,
|
|
8069
|
+
setSelection: d
|
|
8070
|
+
};
|
|
8071
|
+
}
|
|
8072
|
+
function c(t, n) {
|
|
8073
|
+
var i = e.useRef(),
|
|
8074
|
+
r = s(i, n),
|
|
8075
|
+
a = r.getSelection,
|
|
8076
|
+
l = r.getLastSelection,
|
|
8077
|
+
o = r.setSelection,
|
|
8078
|
+
c = function (t, n) {
|
|
8079
|
+
var i = u(t),
|
|
8080
|
+
r = e.useRef(n);
|
|
8081
|
+
return {
|
|
8082
|
+
getValue: e.useCallback(function () {
|
|
8083
|
+
return i().value;
|
|
8084
|
+
}, [i]),
|
|
8085
|
+
getLastValue: e.useCallback(function () {
|
|
8086
|
+
return r.current;
|
|
8087
|
+
}, []),
|
|
8088
|
+
setValue: e.useCallback(function (e) {
|
|
8089
|
+
r.current = e;
|
|
8090
|
+
var t = i();
|
|
8091
|
+
t && (t.value = e);
|
|
8092
|
+
}, [i])
|
|
8093
|
+
};
|
|
8094
|
+
}(i, t),
|
|
8095
|
+
f = c.getValue,
|
|
8096
|
+
h = c.getLastValue,
|
|
8097
|
+
g = c.setValue;
|
|
8098
|
+
return {
|
|
8099
|
+
inputRef: i,
|
|
8100
|
+
getInputState: function getInputState() {
|
|
8101
|
+
return {
|
|
8102
|
+
value: f(),
|
|
8103
|
+
selection: a()
|
|
8104
|
+
};
|
|
8105
|
+
},
|
|
8106
|
+
getLastInputState: function getLastInputState() {
|
|
8107
|
+
return {
|
|
8108
|
+
value: h(),
|
|
8109
|
+
selection: l()
|
|
8110
|
+
};
|
|
8111
|
+
},
|
|
8112
|
+
setInputState: function setInputState(e) {
|
|
8113
|
+
var t = e.value,
|
|
8114
|
+
n = e.selection;
|
|
8115
|
+
g(t), o(n);
|
|
8116
|
+
}
|
|
8117
|
+
};
|
|
8118
|
+
}
|
|
8119
|
+
requireWarning();
|
|
8120
|
+
var f = ["disabled", "onBlur", "onChange", "onFocus", "onMouseDown", "readOnly", "value"],
|
|
8121
|
+
h = {
|
|
8122
|
+
9: /[0-9]/,
|
|
8123
|
+
a: /[A-Za-z]/,
|
|
8124
|
+
"*": /[A-Za-z0-9]/
|
|
8125
|
+
};
|
|
8126
|
+
var g = function g(e) {
|
|
8127
|
+
var t = this;
|
|
8128
|
+
this.isCharacterAllowedAtPosition = function (e, n) {
|
|
8129
|
+
var i = t.maskOptions.maskPlaceholder;
|
|
8130
|
+
return !!t.isCharacterFillingPosition(e, n) || !!i && i[n] === e;
|
|
8131
|
+
}, this.isCharacterFillingPosition = function (e, n) {
|
|
8132
|
+
var i = t.maskOptions.mask;
|
|
8133
|
+
if (!e || n >= i.length) return false;
|
|
8134
|
+
if (!t.isPositionEditable(n)) return i[n] === e;
|
|
8135
|
+
var r = i[n];
|
|
8136
|
+
return new RegExp(r).test(e);
|
|
8137
|
+
}, this.isPositionEditable = function (e) {
|
|
8138
|
+
var n = t.maskOptions,
|
|
8139
|
+
i = n.mask,
|
|
8140
|
+
r = n.permanents;
|
|
8141
|
+
return e < i.length && -1 === r.indexOf(e);
|
|
8142
|
+
}, this.isValueEmpty = function (e) {
|
|
8143
|
+
return e.split("").every(function (e, n) {
|
|
8144
|
+
return !t.isPositionEditable(n) || !t.isCharacterFillingPosition(e, n);
|
|
8145
|
+
});
|
|
8146
|
+
}, this.isValueFilled = function (e) {
|
|
8147
|
+
return t.getFilledLength(e) === t.maskOptions.lastEditablePosition + 1;
|
|
8148
|
+
}, this.getDefaultSelectionForValue = function (e) {
|
|
8149
|
+
var n = t.getFilledLength(e),
|
|
8150
|
+
i = t.getRightEditablePosition(n);
|
|
8151
|
+
return {
|
|
8152
|
+
start: i,
|
|
8153
|
+
end: i
|
|
8154
|
+
};
|
|
8155
|
+
}, this.getFilledLength = function (e) {
|
|
8156
|
+
return function (e, t) {
|
|
8157
|
+
for (var n = e.length - 1; n >= 0; n--) if (t(e[n], n)) return n;
|
|
8158
|
+
return -1;
|
|
8159
|
+
}(e.split(""), function (e, n) {
|
|
8160
|
+
return t.isPositionEditable(n) && t.isCharacterFillingPosition(e, n);
|
|
8161
|
+
}) + 1;
|
|
8162
|
+
}, this.getStringFillingLengthAtPosition = function (e, n) {
|
|
8163
|
+
return e.split("").reduce(function (e, n) {
|
|
8164
|
+
return t.insertCharacterAtPosition(e, n, e.length);
|
|
8165
|
+
}, function (e, t) {
|
|
8166
|
+
void 0 === t && (t = 1);
|
|
8167
|
+
for (var n = "", i = 0; i < t; i++) n += e;
|
|
8168
|
+
return n;
|
|
8169
|
+
}(" ", n)).length - n;
|
|
8170
|
+
}, this.getLeftEditablePosition = function (e) {
|
|
8171
|
+
for (var n = e; n >= 0; n--) if (t.isPositionEditable(n)) return n;
|
|
8172
|
+
return null;
|
|
8173
|
+
}, this.getRightEditablePosition = function (e) {
|
|
8174
|
+
for (var n = t.maskOptions.mask, i = e; i < n.length; i++) if (t.isPositionEditable(i)) return i;
|
|
8175
|
+
return null;
|
|
8176
|
+
}, this.formatValue = function (e) {
|
|
8177
|
+
var n = t.maskOptions,
|
|
8178
|
+
i = n.maskPlaceholder,
|
|
8179
|
+
r = n.mask;
|
|
8180
|
+
if (!i) {
|
|
8181
|
+
for (e = t.insertStringAtPosition("", e, 0); e.length < r.length && !t.isPositionEditable(e.length);) e += r[e.length];
|
|
8182
|
+
return e;
|
|
8183
|
+
}
|
|
8184
|
+
return t.insertStringAtPosition(i, e, 0);
|
|
8185
|
+
}, this.clearRange = function (e, n, i) {
|
|
8186
|
+
if (!i) return e;
|
|
8187
|
+
var r = n + i,
|
|
8188
|
+
a = t.maskOptions,
|
|
8189
|
+
l = a.maskPlaceholder,
|
|
8190
|
+
o = a.mask,
|
|
8191
|
+
u = e.split("").map(function (e, i) {
|
|
8192
|
+
var a = t.isPositionEditable(i);
|
|
8193
|
+
return !l && i >= r && !a ? "" : i < n || i >= r ? e : a ? l ? l[i] : "" : o[i];
|
|
8194
|
+
}).join("");
|
|
8195
|
+
return t.formatValue(u);
|
|
8196
|
+
}, this.insertCharacterAtPosition = function (e, n, i) {
|
|
8197
|
+
var r = t.maskOptions,
|
|
8198
|
+
a = r.mask,
|
|
8199
|
+
l = r.maskPlaceholder;
|
|
8200
|
+
if (i >= a.length) return e;
|
|
8201
|
+
var o = t.isCharacterAllowedAtPosition(n, i),
|
|
8202
|
+
u = t.isPositionEditable(i),
|
|
8203
|
+
s = t.getRightEditablePosition(i),
|
|
8204
|
+
c = l && s ? n === l[s] : null,
|
|
8205
|
+
f = e.slice(0, i);
|
|
8206
|
+
!o && u || (e = f + (o ? n : a[i]));
|
|
8207
|
+
return o || u || c || (e = t.insertCharacterAtPosition(e, n, i + 1)), e;
|
|
8208
|
+
}, this.insertStringAtPosition = function (e, n, i) {
|
|
8209
|
+
var r = t.maskOptions,
|
|
8210
|
+
a = r.mask,
|
|
8211
|
+
l = r.maskPlaceholder;
|
|
8212
|
+
if (!n || i >= a.length) return e;
|
|
8213
|
+
var o = n.split(""),
|
|
8214
|
+
u = t.isValueFilled(e) || !!l,
|
|
8215
|
+
s = e.slice(i);
|
|
8216
|
+
if (e = o.reduce(function (e, n) {
|
|
8217
|
+
return t.insertCharacterAtPosition(e, n, e.length);
|
|
8218
|
+
}, e.slice(0, i)), u) e += s.slice(e.length - i);else if (t.isValueFilled(e)) e += a.slice(e.length).join("");else {
|
|
8219
|
+
e = s.split("").filter(function (e, n) {
|
|
8220
|
+
return t.isPositionEditable(i + n);
|
|
8221
|
+
}).reduce(function (e, n) {
|
|
8222
|
+
var i = t.getRightEditablePosition(e.length);
|
|
8223
|
+
return null === i ? e : (t.isPositionEditable(e.length) || (e += a.slice(e.length, i).join("")), t.insertCharacterAtPosition(e, n, e.length));
|
|
8224
|
+
}, e);
|
|
8225
|
+
}
|
|
8226
|
+
return e;
|
|
8227
|
+
}, this.processChange = function (e, n) {
|
|
8228
|
+
var i = t.maskOptions,
|
|
8229
|
+
r = i.mask,
|
|
8230
|
+
a = i.prefix,
|
|
8231
|
+
l = i.lastEditablePosition,
|
|
8232
|
+
o = e.value,
|
|
8233
|
+
u = e.selection,
|
|
8234
|
+
s = n.value,
|
|
8235
|
+
c = n.selection,
|
|
8236
|
+
f = o,
|
|
8237
|
+
h = "",
|
|
8238
|
+
g = 0,
|
|
8239
|
+
v = 0,
|
|
8240
|
+
d = Math.min(c.start, u.start);
|
|
8241
|
+
if (u.end > c.start ? (h = f.slice(c.start, u.end), v = (g = t.getStringFillingLengthAtPosition(h, d)) ? c.length : 0) : f.length < s.length && (v = s.length - f.length), f = s, v) {
|
|
8242
|
+
if (1 === v && !c.length) d = c.start === u.start ? t.getRightEditablePosition(u.start) : t.getLeftEditablePosition(u.start);
|
|
8243
|
+
f = t.clearRange(f, d, v);
|
|
8244
|
+
}
|
|
8245
|
+
return f = t.insertStringAtPosition(f, h, d), (d += g) >= r.length ? d = r.length : d < a.length && !g ? d = a.length : d >= a.length && d < l && g && (d = t.getRightEditablePosition(d)), {
|
|
8246
|
+
value: f = t.formatValue(f),
|
|
8247
|
+
enteredString: h,
|
|
8248
|
+
selection: {
|
|
8249
|
+
start: d,
|
|
8250
|
+
end: d
|
|
8251
|
+
}
|
|
8252
|
+
};
|
|
8253
|
+
}, this.maskOptions = function (e) {
|
|
8254
|
+
var t = e.mask,
|
|
8255
|
+
n = e.maskPlaceholder,
|
|
8256
|
+
i = [];
|
|
8257
|
+
if (!t) return {
|
|
8258
|
+
maskPlaceholder: null,
|
|
8259
|
+
mask: null,
|
|
8260
|
+
prefix: null,
|
|
8261
|
+
lastEditablePosition: null,
|
|
8262
|
+
permanents: []
|
|
8263
|
+
};
|
|
8264
|
+
if ("string" == typeof t) {
|
|
8265
|
+
var r = false,
|
|
8266
|
+
a = "";
|
|
8267
|
+
t.split("").forEach(function (e) {
|
|
8268
|
+
r || "\\" !== e ? (!r && h[e] || i.push(a.length), a += e, r = false) : r = true;
|
|
8269
|
+
}), t = a.split("").map(function (e, t) {
|
|
8270
|
+
return -1 === i.indexOf(t) ? h[e] : e;
|
|
8271
|
+
});
|
|
8272
|
+
} else t.forEach(function (e, t) {
|
|
8273
|
+
"string" == typeof e && i.push(t);
|
|
8274
|
+
});
|
|
8275
|
+
n && (n = 1 === n.length ? t.map(function (e, t) {
|
|
8276
|
+
return -1 !== i.indexOf(t) ? e : n;
|
|
8277
|
+
}) : n.split(""), i.forEach(function (e) {
|
|
8278
|
+
n[e] = t[e];
|
|
8279
|
+
}), n = n.join(""));
|
|
8280
|
+
for (var l = i.filter(function (e, t) {
|
|
8281
|
+
return e === t;
|
|
8282
|
+
}).map(function (e) {
|
|
8283
|
+
return t[e];
|
|
8284
|
+
}).join(""), o = t.length - 1; -1 !== i.indexOf(o);) o--;
|
|
8285
|
+
return {
|
|
8286
|
+
maskPlaceholder: n,
|
|
8287
|
+
prefix: l,
|
|
8288
|
+
mask: t,
|
|
8289
|
+
lastEditablePosition: o,
|
|
8290
|
+
permanents: i
|
|
8291
|
+
};
|
|
8292
|
+
}(e);
|
|
8293
|
+
},
|
|
8294
|
+
v = ["alwaysShowMask", "children", "mask", "maskPlaceholder", "beforeMaskedStateChange"],
|
|
8295
|
+
d = e.forwardRef(function (r, o) {
|
|
8296
|
+
var s = r.alwaysShowMask,
|
|
8297
|
+
h = r.children,
|
|
8298
|
+
d = r.mask,
|
|
8299
|
+
m = r.maskPlaceholder,
|
|
8300
|
+
p = r.beforeMaskedStateChange,
|
|
8301
|
+
k = function (e, t) {
|
|
8302
|
+
if (null == e) return {};
|
|
8303
|
+
var n,
|
|
8304
|
+
i,
|
|
8305
|
+
r = {},
|
|
8306
|
+
a = Object.keys(e);
|
|
8307
|
+
for (i = 0; i < a.length; i++) n = a[i], t.indexOf(n) >= 0 || (r[n] = e[n]);
|
|
8308
|
+
return r;
|
|
8309
|
+
}(r, v);
|
|
8310
|
+
!function (e) {
|
|
8311
|
+
var n = e.mask,
|
|
8312
|
+
i = e.maskPlaceholder;
|
|
8313
|
+
n && i && 1 !== i.length && i.length !== n.length && t(false);
|
|
8314
|
+
}(r);
|
|
8315
|
+
var P,
|
|
8316
|
+
b,
|
|
8317
|
+
E = new g({
|
|
8318
|
+
mask: d,
|
|
8319
|
+
maskPlaceholder: m
|
|
8320
|
+
}),
|
|
8321
|
+
S = !!d,
|
|
8322
|
+
C = !k.disabled && !k.readOnly,
|
|
8323
|
+
w = null !== r.value && void 0 !== r.value,
|
|
8324
|
+
V = (P = S, b = e.useRef(), e.useEffect(function () {
|
|
8325
|
+
b.current = P;
|
|
8326
|
+
}), b.current),
|
|
8327
|
+
F = function (e) {
|
|
8328
|
+
return "" + e;
|
|
8329
|
+
}((w ? r.value : r.defaultValue) || ""),
|
|
8330
|
+
y = c(F, S),
|
|
8331
|
+
O = y.inputRef,
|
|
8332
|
+
L = y.getInputState,
|
|
8333
|
+
A = y.setInputState,
|
|
8334
|
+
R = y.getLastInputState,
|
|
8335
|
+
x = u(O);
|
|
8336
|
+
if (S && w) {
|
|
8337
|
+
var M = x(),
|
|
8338
|
+
D = M && a(M) || s || r.value ? E.formatValue(r.value) : r.value;
|
|
8339
|
+
p && (D = p({
|
|
8340
|
+
nextState: {
|
|
8341
|
+
value: D,
|
|
8342
|
+
selection: {
|
|
8343
|
+
start: null,
|
|
8344
|
+
end: null
|
|
8345
|
+
}
|
|
8346
|
+
}
|
|
8347
|
+
}).value), A(n({}, R(), {
|
|
8348
|
+
value: D
|
|
8349
|
+
}));
|
|
8350
|
+
}
|
|
8351
|
+
var j = R(),
|
|
8352
|
+
I = j.selection,
|
|
8353
|
+
q = j.value;
|
|
8354
|
+
e.useLayoutEffect(function () {
|
|
8355
|
+
if (S) {
|
|
8356
|
+
var e = x();
|
|
8357
|
+
if (e) {
|
|
8358
|
+
var t = a(e),
|
|
8359
|
+
i = I,
|
|
8360
|
+
r = L(),
|
|
8361
|
+
l = n({}, r);
|
|
8362
|
+
if (!w) {
|
|
8363
|
+
var o = r.value,
|
|
8364
|
+
u = E.formatValue(o),
|
|
8365
|
+
c = E.isValueEmpty(u);
|
|
8366
|
+
!c || t || s ? l.value = u : c && !t && (l.value = "");
|
|
8367
|
+
}
|
|
8368
|
+
t && !V ? l.selection = E.getDefaultSelectionForValue(l.value) : w && t && i && null !== i.start && null !== i.end && (l.selection = i), p && (l = p({
|
|
8369
|
+
currentState: r,
|
|
8370
|
+
nextState: l
|
|
8371
|
+
})), A(l);
|
|
8372
|
+
}
|
|
8373
|
+
}
|
|
8374
|
+
});
|
|
8375
|
+
var B = function B(e) {
|
|
8376
|
+
O.current = e, !function (e) {
|
|
8377
|
+
return "function" == typeof e;
|
|
8378
|
+
}(o) ? null !== o && "object" == _typeof$1(o) && (o.current = e) : o(e);
|
|
8379
|
+
},
|
|
8380
|
+
T = n({}, k, {
|
|
8381
|
+
onFocus: function onFocus(e) {
|
|
8382
|
+
O.current = e.target;
|
|
8383
|
+
var t = L().value;
|
|
8384
|
+
if (S && !E.isValueFilled(t)) {
|
|
8385
|
+
var n = E.formatValue(t),
|
|
8386
|
+
a = E.getDefaultSelectionForValue(n),
|
|
8387
|
+
l = {
|
|
8388
|
+
value: n,
|
|
8389
|
+
selection: a
|
|
8390
|
+
};
|
|
8391
|
+
p && (n = (l = p({
|
|
8392
|
+
currentState: L(),
|
|
8393
|
+
nextState: l
|
|
8394
|
+
})).value, a = l.selection), A(l), n !== t && r.onChange && r.onChange(e), i(function () {
|
|
8395
|
+
A(R());
|
|
8396
|
+
});
|
|
8397
|
+
}
|
|
8398
|
+
r.onFocus && r.onFocus(e);
|
|
8399
|
+
},
|
|
8400
|
+
onBlur: function onBlur(e) {
|
|
8401
|
+
var t = L().value,
|
|
8402
|
+
n = R().value;
|
|
8403
|
+
if (S && !s && E.isValueEmpty(n)) {
|
|
8404
|
+
var i = "",
|
|
8405
|
+
a = {
|
|
8406
|
+
value: i,
|
|
8407
|
+
selection: {
|
|
8408
|
+
start: null,
|
|
8409
|
+
end: null
|
|
8410
|
+
}
|
|
8411
|
+
};
|
|
8412
|
+
p && (i = (a = p({
|
|
8413
|
+
currentState: L(),
|
|
8414
|
+
nextState: a
|
|
8415
|
+
})).value), A(a), i !== t && r.onChange && r.onChange(e);
|
|
8416
|
+
}
|
|
8417
|
+
r.onBlur && r.onBlur(e);
|
|
8418
|
+
},
|
|
8419
|
+
onChange: S && C ? function (e) {
|
|
8420
|
+
var t = L(),
|
|
8421
|
+
n = R(),
|
|
8422
|
+
i = E.processChange(t, n);
|
|
8423
|
+
p && (i = p({
|
|
8424
|
+
currentState: t,
|
|
8425
|
+
previousState: n,
|
|
8426
|
+
nextState: i
|
|
8427
|
+
})), A(i), r.onChange && r.onChange(e);
|
|
8428
|
+
} : r.onChange,
|
|
8429
|
+
onMouseDown: S && C ? function (e) {
|
|
8430
|
+
var t = x();
|
|
8431
|
+
if (t) {
|
|
8432
|
+
var i = L().value,
|
|
8433
|
+
o = l(t);
|
|
8434
|
+
if (!a(t) && !E.isValueFilled(i)) {
|
|
8435
|
+
var u = e.clientX,
|
|
8436
|
+
s = e.clientY,
|
|
8437
|
+
c = new Date().getTime();
|
|
8438
|
+
o.addEventListener("mouseup", function e(i) {
|
|
8439
|
+
if (o.removeEventListener("mouseup", e), a(t)) {
|
|
8440
|
+
var r = Math.abs(i.clientX - u),
|
|
8441
|
+
l = Math.abs(i.clientY - s),
|
|
8442
|
+
f = Math.max(r, l),
|
|
8443
|
+
h = new Date().getTime() - c;
|
|
8444
|
+
if (f <= 10 && h <= 200 || f <= 5 && h <= 300) {
|
|
8445
|
+
var g = R(),
|
|
8446
|
+
v = n({}, g, {
|
|
8447
|
+
selection: E.getDefaultSelectionForValue(g.value)
|
|
8448
|
+
});
|
|
8449
|
+
A(v);
|
|
8450
|
+
}
|
|
8451
|
+
}
|
|
8452
|
+
});
|
|
8453
|
+
}
|
|
8454
|
+
r.onMouseDown && r.onMouseDown(e);
|
|
8455
|
+
}
|
|
8456
|
+
} : r.onMouseDown,
|
|
8457
|
+
value: S && w ? q : r.value
|
|
8458
|
+
});
|
|
8459
|
+
if (h) {
|
|
8460
|
+
!function (e, n) {
|
|
8461
|
+
f.filter(function (t) {
|
|
8462
|
+
return null != n.props[t] && n.props[t] !== e[t];
|
|
8463
|
+
}).length && t(false);
|
|
8464
|
+
}(r, h);
|
|
8465
|
+
var N = e.Children.only(h);
|
|
8466
|
+
return e.cloneElement(N, n({}, T, {
|
|
8467
|
+
ref: B
|
|
8468
|
+
}));
|
|
8469
|
+
}
|
|
8470
|
+
return e.createElement("input", n({
|
|
8471
|
+
ref: B
|
|
8472
|
+
}, T));
|
|
8473
|
+
});
|
|
8474
|
+
d.displayName = "InputMask", d.defaultProps = {
|
|
8475
|
+
alwaysShowMask: false,
|
|
8476
|
+
maskPlaceholder: "_"
|
|
8477
|
+
}, reactInputMask_production_min.exports = d;
|
|
8478
|
+
return reactInputMask_production_min.exports;
|
|
8479
|
+
}
|
|
8480
|
+
|
|
8173
8481
|
var reactInputMask_development;
|
|
8174
8482
|
var hasRequiredReactInputMask_development;
|
|
8175
8483
|
function requireReactInputMask_development() {
|
|
8176
8484
|
if (hasRequiredReactInputMask_development) return reactInputMask_development;
|
|
8177
8485
|
hasRequiredReactInputMask_development = 1;
|
|
8178
|
-
|
|
8179
|
-
|
|
8180
|
-
|
|
8181
|
-
var
|
|
8182
|
-
var reactDom = require$$1;
|
|
8183
|
-
var invariant = _interopDefault(requireInvariant());
|
|
8184
|
-
var warning = _interopDefault(requireWarning());
|
|
8185
|
-
function _defaults2(obj, defaults) {
|
|
8186
|
-
var keys = Object.getOwnPropertyNames(defaults);
|
|
8187
|
-
for (var i = 0; i < keys.length; i++) {
|
|
8188
|
-
var key = keys[i];
|
|
8189
|
-
var value = Object.getOwnPropertyDescriptor(defaults, key);
|
|
8190
|
-
if (value && value.configurable && obj[key] === undefined) {
|
|
8191
|
-
Object.defineProperty(obj, key, value);
|
|
8192
|
-
}
|
|
8193
|
-
}
|
|
8194
|
-
return obj;
|
|
8195
|
-
}
|
|
8486
|
+
var React = React__default;
|
|
8487
|
+
var PropTypes = /*@__PURE__*/requirePropTypes();
|
|
8488
|
+
var invariant = requireInvariant();
|
|
8489
|
+
var warning = requireWarning();
|
|
8196
8490
|
function _extends() {
|
|
8197
|
-
_extends = Object.assign
|
|
8491
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
8198
8492
|
for (var i = 1; i < arguments.length; i++) {
|
|
8199
8493
|
var source = arguments[i];
|
|
8200
8494
|
for (var key in source) {
|
|
@@ -8207,11 +8501,6 @@ function requireReactInputMask_development() {
|
|
|
8207
8501
|
};
|
|
8208
8502
|
return _extends.apply(this, arguments);
|
|
8209
8503
|
}
|
|
8210
|
-
function _inheritsLoose(subClass, superClass) {
|
|
8211
|
-
subClass.prototype = Object.create(superClass.prototype);
|
|
8212
|
-
subClass.prototype.constructor = subClass;
|
|
8213
|
-
_defaults2(subClass, superClass);
|
|
8214
|
-
}
|
|
8215
8504
|
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
8216
8505
|
if (source == null) return {};
|
|
8217
8506
|
var target = {};
|
|
@@ -8224,895 +8513,825 @@ function requireReactInputMask_development() {
|
|
|
8224
8513
|
}
|
|
8225
8514
|
return target;
|
|
8226
8515
|
}
|
|
8227
|
-
function
|
|
8228
|
-
|
|
8229
|
-
|
|
8230
|
-
|
|
8231
|
-
|
|
8516
|
+
function defer(fn) {
|
|
8517
|
+
return requestAnimationFrame(fn);
|
|
8518
|
+
}
|
|
8519
|
+
function cancelDefer(deferId) {
|
|
8520
|
+
cancelAnimationFrame(deferId);
|
|
8232
8521
|
}
|
|
8233
8522
|
function setInputSelection(input, start, end) {
|
|
8234
|
-
if (
|
|
8235
|
-
|
|
8236
|
-
input.selectionEnd = end;
|
|
8237
|
-
} else {
|
|
8238
|
-
var range = input.createTextRange();
|
|
8239
|
-
range.collapse(true);
|
|
8240
|
-
range.moveStart('character', start);
|
|
8241
|
-
range.moveEnd('character', end - start);
|
|
8242
|
-
range.select();
|
|
8523
|
+
if (end === undefined) {
|
|
8524
|
+
end = start;
|
|
8243
8525
|
}
|
|
8526
|
+
input.setSelectionRange(start, end);
|
|
8244
8527
|
}
|
|
8245
8528
|
function getInputSelection(input) {
|
|
8246
|
-
var start =
|
|
8247
|
-
var end =
|
|
8248
|
-
if ('selectionStart' in input && 'selectionEnd' in input) {
|
|
8249
|
-
start = input.selectionStart;
|
|
8250
|
-
end = input.selectionEnd;
|
|
8251
|
-
} else {
|
|
8252
|
-
var range = document.selection.createRange();
|
|
8253
|
-
if (range.parentElement() === input) {
|
|
8254
|
-
start = -range.moveStart('character', -input.value.length);
|
|
8255
|
-
end = -range.moveEnd('character', -input.value.length);
|
|
8256
|
-
}
|
|
8257
|
-
}
|
|
8529
|
+
var start = input.selectionStart;
|
|
8530
|
+
var end = input.selectionEnd;
|
|
8258
8531
|
return {
|
|
8259
8532
|
start: start,
|
|
8260
8533
|
end: end,
|
|
8261
8534
|
length: end - start
|
|
8262
8535
|
};
|
|
8263
8536
|
}
|
|
8264
|
-
|
|
8265
|
-
|
|
8266
|
-
|
|
8267
|
-
'*': '[A-Za-z0-9]'
|
|
8268
|
-
};
|
|
8269
|
-
var defaultMaskChar = '_';
|
|
8270
|
-
function parseMask(mask, maskChar, formatChars) {
|
|
8271
|
-
var parsedMaskString = '';
|
|
8272
|
-
var prefix = '';
|
|
8273
|
-
var lastEditablePosition = null;
|
|
8274
|
-
var permanents = [];
|
|
8275
|
-
if (maskChar === undefined) {
|
|
8276
|
-
maskChar = defaultMaskChar;
|
|
8277
|
-
}
|
|
8278
|
-
if (formatChars == null) {
|
|
8279
|
-
formatChars = defaultFormatChars;
|
|
8280
|
-
}
|
|
8281
|
-
if (!mask || typeof mask !== 'string') {
|
|
8282
|
-
return {
|
|
8283
|
-
maskChar: maskChar,
|
|
8284
|
-
formatChars: formatChars,
|
|
8285
|
-
mask: null,
|
|
8286
|
-
prefix: null,
|
|
8287
|
-
lastEditablePosition: null,
|
|
8288
|
-
permanents: []
|
|
8289
|
-
};
|
|
8290
|
-
}
|
|
8291
|
-
var isPermanent = false;
|
|
8292
|
-
mask.split('').forEach(function (character) {
|
|
8293
|
-
if (!isPermanent && character === '\\') {
|
|
8294
|
-
isPermanent = true;
|
|
8295
|
-
} else {
|
|
8296
|
-
if (isPermanent || !formatChars[character]) {
|
|
8297
|
-
permanents.push(parsedMaskString.length);
|
|
8298
|
-
if (parsedMaskString.length === permanents.length - 1) {
|
|
8299
|
-
prefix += character;
|
|
8300
|
-
}
|
|
8301
|
-
} else {
|
|
8302
|
-
lastEditablePosition = parsedMaskString.length + 1;
|
|
8303
|
-
}
|
|
8304
|
-
parsedMaskString += character;
|
|
8305
|
-
isPermanent = false;
|
|
8306
|
-
}
|
|
8307
|
-
});
|
|
8308
|
-
return {
|
|
8309
|
-
maskChar: maskChar,
|
|
8310
|
-
formatChars: formatChars,
|
|
8311
|
-
prefix: prefix,
|
|
8312
|
-
mask: parsedMaskString,
|
|
8313
|
-
lastEditablePosition: lastEditablePosition,
|
|
8314
|
-
permanents: permanents
|
|
8315
|
-
};
|
|
8537
|
+
function isInputFocused(input) {
|
|
8538
|
+
var inputDocument = input.ownerDocument;
|
|
8539
|
+
return inputDocument.hasFocus() && inputDocument.activeElement === input;
|
|
8316
8540
|
}
|
|
8317
8541
|
|
|
8318
|
-
|
|
8319
|
-
|
|
8320
|
-
|
|
8542
|
+
// Element's window may differ from the one within React instance
|
|
8543
|
+
// if element rendered within iframe.
|
|
8544
|
+
// See https://github.com/sanniassin/react-input-mask/issues/182
|
|
8545
|
+
function getElementDocument(element) {
|
|
8546
|
+
return element == null ? void 0 : element.ownerDocument;
|
|
8321
8547
|
}
|
|
8322
|
-
function
|
|
8323
|
-
var
|
|
8324
|
-
|
|
8325
|
-
if (!character) {
|
|
8326
|
-
return false;
|
|
8327
|
-
}
|
|
8328
|
-
if (isPermanentCharacter(maskOptions, pos)) {
|
|
8329
|
-
return mask[pos] === character;
|
|
8330
|
-
}
|
|
8331
|
-
var ruleChar = mask[pos];
|
|
8332
|
-
var charRule = formatChars[ruleChar];
|
|
8333
|
-
return new RegExp(charRule).test(character);
|
|
8334
|
-
}
|
|
8335
|
-
function isEmpty(maskOptions, value) {
|
|
8336
|
-
return value.split('').every(function (character, i) {
|
|
8337
|
-
return isPermanentCharacter(maskOptions, i) || !isAllowedCharacter(maskOptions, i, character);
|
|
8338
|
-
});
|
|
8548
|
+
function getElementWindow(element) {
|
|
8549
|
+
var _getElementDocument;
|
|
8550
|
+
return (_getElementDocument = getElementDocument(element)) == null ? void 0 : _getElementDocument.defaultView;
|
|
8339
8551
|
}
|
|
8340
|
-
function
|
|
8341
|
-
var
|
|
8342
|
-
|
|
8343
|
-
if (!maskChar) {
|
|
8344
|
-
while (value.length > prefix.length && isPermanentCharacter(maskOptions, value.length - 1)) {
|
|
8345
|
-
value = value.slice(0, value.length - 1);
|
|
8346
|
-
}
|
|
8347
|
-
return value.length;
|
|
8348
|
-
}
|
|
8349
|
-
var filledLength = prefix.length;
|
|
8350
|
-
for (var i = value.length; i >= prefix.length; i--) {
|
|
8351
|
-
var character = value[i];
|
|
8352
|
-
var isEnteredCharacter = !isPermanentCharacter(maskOptions, i) && isAllowedCharacter(maskOptions, i, character);
|
|
8353
|
-
if (isEnteredCharacter) {
|
|
8354
|
-
filledLength = i + 1;
|
|
8355
|
-
break;
|
|
8356
|
-
}
|
|
8357
|
-
}
|
|
8358
|
-
return filledLength;
|
|
8552
|
+
function isDOMElement(element) {
|
|
8553
|
+
var elementWindow = getElementWindow(element);
|
|
8554
|
+
return !!elementWindow && element instanceof elementWindow.HTMLElement;
|
|
8359
8555
|
}
|
|
8360
|
-
function
|
|
8361
|
-
return
|
|
8556
|
+
function isFunction(value) {
|
|
8557
|
+
return typeof value === "function";
|
|
8362
8558
|
}
|
|
8363
|
-
function
|
|
8364
|
-
var
|
|
8365
|
-
|
|
8366
|
-
|
|
8367
|
-
|
|
8368
|
-
value = insertString(maskOptions, '', value, 0);
|
|
8369
|
-
if (value.length < prefix.length) {
|
|
8370
|
-
value = prefix;
|
|
8371
|
-
}
|
|
8372
|
-
while (value.length < mask.length && isPermanentCharacter(maskOptions, value.length)) {
|
|
8373
|
-
value += mask[value.length];
|
|
8559
|
+
function findLastIndex(array, predicate) {
|
|
8560
|
+
for (var i = array.length - 1; i >= 0; i--) {
|
|
8561
|
+
var x = array[i];
|
|
8562
|
+
if (predicate(x, i)) {
|
|
8563
|
+
return i;
|
|
8374
8564
|
}
|
|
8375
|
-
return value;
|
|
8376
8565
|
}
|
|
8377
|
-
|
|
8378
|
-
|
|
8379
|
-
|
|
8566
|
+
return -1;
|
|
8567
|
+
}
|
|
8568
|
+
function repeat(string, n) {
|
|
8569
|
+
if (n === void 0) {
|
|
8570
|
+
n = 1;
|
|
8380
8571
|
}
|
|
8381
|
-
|
|
8382
|
-
|
|
8383
|
-
|
|
8384
|
-
} else {
|
|
8385
|
-
value += maskChar;
|
|
8386
|
-
}
|
|
8387
|
-
}
|
|
8388
|
-
return value;
|
|
8389
|
-
}
|
|
8390
|
-
function clearRange(maskOptions, value, start, len) {
|
|
8391
|
-
var end = start + len;
|
|
8392
|
-
var maskChar = maskOptions.maskChar,
|
|
8393
|
-
mask = maskOptions.mask,
|
|
8394
|
-
prefix = maskOptions.prefix;
|
|
8395
|
-
var arrayValue = value.split('');
|
|
8396
|
-
if (!maskChar) {
|
|
8397
|
-
// remove any permanent chars after clear range, they will be added back by formatValue
|
|
8398
|
-
for (var i = end; i < arrayValue.length; i++) {
|
|
8399
|
-
if (isPermanentCharacter(maskOptions, i)) {
|
|
8400
|
-
arrayValue[i] = '';
|
|
8401
|
-
}
|
|
8402
|
-
}
|
|
8403
|
-
start = Math.max(prefix.length, start);
|
|
8404
|
-
arrayValue.splice(start, end - start);
|
|
8405
|
-
value = arrayValue.join('');
|
|
8406
|
-
return formatValue(maskOptions, value);
|
|
8572
|
+
var result = "";
|
|
8573
|
+
for (var i = 0; i < n; i++) {
|
|
8574
|
+
result += string;
|
|
8407
8575
|
}
|
|
8408
|
-
return
|
|
8409
|
-
if (i < start || i >= end) {
|
|
8410
|
-
return character;
|
|
8411
|
-
}
|
|
8412
|
-
if (isPermanentCharacter(maskOptions, i)) {
|
|
8413
|
-
return mask[i];
|
|
8414
|
-
}
|
|
8415
|
-
return maskChar;
|
|
8416
|
-
}).join('');
|
|
8576
|
+
return result;
|
|
8417
8577
|
}
|
|
8418
|
-
function
|
|
8419
|
-
|
|
8420
|
-
|
|
8421
|
-
|
|
8422
|
-
|
|
8423
|
-
|
|
8424
|
-
|
|
8425
|
-
return !isPermanentCharacter(maskOptions, pos) || character === mask[pos];
|
|
8426
|
-
};
|
|
8427
|
-
var isUsableCharacter = function isUsableCharacter(character, pos) {
|
|
8428
|
-
return !maskChar || !isPermanentCharacter(maskOptions, pos) || character !== maskChar;
|
|
8429
|
-
};
|
|
8430
|
-
if (!maskChar && insertPosition > value.length) {
|
|
8431
|
-
value += mask.slice(value.length, insertPosition);
|
|
8432
|
-
}
|
|
8433
|
-
arrayInsertStr.every(function (insertCharacter) {
|
|
8434
|
-
while (!isUsablePosition(insertPosition, insertCharacter)) {
|
|
8435
|
-
if (insertPosition >= value.length) {
|
|
8436
|
-
value += mask[insertPosition];
|
|
8437
|
-
}
|
|
8438
|
-
if (!isUsableCharacter(insertCharacter, insertPosition)) {
|
|
8439
|
-
return true;
|
|
8440
|
-
}
|
|
8441
|
-
insertPosition++; // stop iteration if maximum value length reached
|
|
8578
|
+
function toString(value) {
|
|
8579
|
+
return "" + value;
|
|
8580
|
+
}
|
|
8581
|
+
function useInputElement(inputRef) {
|
|
8582
|
+
return React.useCallback(function () {
|
|
8583
|
+
var input = inputRef.current;
|
|
8584
|
+
var isDOMNode = typeof window !== "undefined" && isDOMElement(input);
|
|
8442
8585
|
|
|
8443
|
-
|
|
8444
|
-
|
|
8445
|
-
|
|
8586
|
+
// workaround for react-test-renderer
|
|
8587
|
+
// https://github.com/sanniassin/react-input-mask/issues/147
|
|
8588
|
+
if (!input || !isDOMNode) {
|
|
8589
|
+
return null;
|
|
8590
|
+
}
|
|
8591
|
+
if (input.nodeName !== "INPUT") {
|
|
8592
|
+
input = input.querySelector("input");
|
|
8593
|
+
}
|
|
8594
|
+
if (!input) {
|
|
8595
|
+
throw new Error("react-input-mask: inputComponent doesn't contain input node");
|
|
8446
8596
|
}
|
|
8447
|
-
|
|
8448
|
-
|
|
8449
|
-
|
|
8597
|
+
return input;
|
|
8598
|
+
}, [inputRef]);
|
|
8599
|
+
}
|
|
8600
|
+
function useDeferLoop(callback) {
|
|
8601
|
+
var deferIdRef = React.useRef(null);
|
|
8602
|
+
var runLoop = React.useCallback(function () {
|
|
8603
|
+
// If there are simulated focus events, runLoop could be
|
|
8604
|
+
// called multiple times without blur or re-render
|
|
8605
|
+
if (deferIdRef.current !== null) {
|
|
8606
|
+
return;
|
|
8450
8607
|
}
|
|
8451
|
-
|
|
8452
|
-
|
|
8453
|
-
|
|
8454
|
-
} else {
|
|
8455
|
-
value = value.slice(0, insertPosition) + insertCharacter + value.slice(insertPosition);
|
|
8456
|
-
value = formatValue(maskOptions, value);
|
|
8457
|
-
}
|
|
8458
|
-
} else if (!maskChar) {
|
|
8459
|
-
value += insertCharacter;
|
|
8608
|
+
function loop() {
|
|
8609
|
+
callback();
|
|
8610
|
+
deferIdRef.current = defer(loop);
|
|
8460
8611
|
}
|
|
8461
|
-
|
|
8462
|
-
|
|
8463
|
-
|
|
8612
|
+
loop();
|
|
8613
|
+
}, [callback]);
|
|
8614
|
+
var stopLoop = React.useCallback(function () {
|
|
8615
|
+
cancelDefer(deferIdRef.current);
|
|
8616
|
+
deferIdRef.current = null;
|
|
8617
|
+
}, []);
|
|
8618
|
+
React.useEffect(function () {
|
|
8619
|
+
if (deferIdRef.current) {
|
|
8620
|
+
stopLoop();
|
|
8621
|
+
runLoop();
|
|
8622
|
+
}
|
|
8623
|
+
}, [runLoop, stopLoop]);
|
|
8624
|
+
React.useEffect(cancelDefer, []);
|
|
8625
|
+
return [runLoop, stopLoop];
|
|
8626
|
+
}
|
|
8627
|
+
function useSelection(inputRef, isMasked) {
|
|
8628
|
+
var selectionRef = React.useRef({
|
|
8629
|
+
start: null,
|
|
8630
|
+
end: null
|
|
8464
8631
|
});
|
|
8465
|
-
|
|
8466
|
-
|
|
8467
|
-
|
|
8468
|
-
|
|
8469
|
-
|
|
8470
|
-
var
|
|
8471
|
-
|
|
8472
|
-
|
|
8473
|
-
|
|
8474
|
-
|
|
8475
|
-
arrayInsertStr.every(function (insertCharacter) {
|
|
8476
|
-
while (!isUsablePosition(insertPosition, insertCharacter)) {
|
|
8477
|
-
insertPosition++; // stop iteration if maximum value length reached
|
|
8632
|
+
var getInputElement = useInputElement(inputRef);
|
|
8633
|
+
var getSelection = React.useCallback(function () {
|
|
8634
|
+
var input = getInputElement();
|
|
8635
|
+
return getInputSelection(input);
|
|
8636
|
+
}, [getInputElement]);
|
|
8637
|
+
var getLastSelection = React.useCallback(function () {
|
|
8638
|
+
return selectionRef.current;
|
|
8639
|
+
}, []);
|
|
8640
|
+
var setSelection = React.useCallback(function (selection) {
|
|
8641
|
+
var input = getInputElement();
|
|
8478
8642
|
|
|
8479
|
-
|
|
8480
|
-
|
|
8481
|
-
|
|
8643
|
+
// Don't change selection on unfocused input
|
|
8644
|
+
// because Safari sets focus on selection change (#154)
|
|
8645
|
+
if (!input || !isInputFocused(input)) {
|
|
8646
|
+
return;
|
|
8482
8647
|
}
|
|
8483
|
-
|
|
8484
|
-
|
|
8485
|
-
|
|
8486
|
-
|
|
8487
|
-
|
|
8488
|
-
|
|
8489
|
-
|
|
8490
|
-
|
|
8491
|
-
|
|
8492
|
-
|
|
8493
|
-
|
|
8494
|
-
|
|
8495
|
-
|
|
8648
|
+
setInputSelection(input, selection.start, selection.end);
|
|
8649
|
+
|
|
8650
|
+
// Use actual selection in case the requested one was out of range
|
|
8651
|
+
selectionRef.current = getSelection();
|
|
8652
|
+
}, [getInputElement, getSelection]);
|
|
8653
|
+
var selectionLoop = React.useCallback(function () {
|
|
8654
|
+
selectionRef.current = getSelection();
|
|
8655
|
+
}, [getSelection]);
|
|
8656
|
+
var _useDeferLoop = useDeferLoop(selectionLoop),
|
|
8657
|
+
runSelectionLoop = _useDeferLoop[0],
|
|
8658
|
+
stopSelectionLoop = _useDeferLoop[1];
|
|
8659
|
+
React.useLayoutEffect(function () {
|
|
8660
|
+
if (!isMasked) {
|
|
8661
|
+
return;
|
|
8496
8662
|
}
|
|
8497
|
-
|
|
8498
|
-
|
|
8499
|
-
|
|
8500
|
-
|
|
8501
|
-
|
|
8502
|
-
for (var i = pos; i < mask.length; ++i) {
|
|
8503
|
-
if (!isPermanentCharacter(maskOptions, i)) {
|
|
8504
|
-
return i;
|
|
8663
|
+
var input = getInputElement();
|
|
8664
|
+
input.addEventListener("focus", runSelectionLoop);
|
|
8665
|
+
input.addEventListener("blur", stopSelectionLoop);
|
|
8666
|
+
if (isInputFocused(input)) {
|
|
8667
|
+
runSelectionLoop();
|
|
8505
8668
|
}
|
|
8506
|
-
|
|
8507
|
-
|
|
8669
|
+
return function () {
|
|
8670
|
+
input.removeEventListener("focus", runSelectionLoop);
|
|
8671
|
+
input.removeEventListener("blur", stopSelectionLoop);
|
|
8672
|
+
stopSelectionLoop();
|
|
8673
|
+
};
|
|
8674
|
+
});
|
|
8675
|
+
return {
|
|
8676
|
+
getSelection: getSelection,
|
|
8677
|
+
getLastSelection: getLastSelection,
|
|
8678
|
+
setSelection: setSelection
|
|
8679
|
+
};
|
|
8508
8680
|
}
|
|
8509
|
-
function
|
|
8510
|
-
|
|
8511
|
-
|
|
8512
|
-
|
|
8513
|
-
|
|
8514
|
-
|
|
8515
|
-
|
|
8516
|
-
var
|
|
8517
|
-
|
|
8518
|
-
|
|
8519
|
-
var
|
|
8520
|
-
|
|
8521
|
-
|
|
8522
|
-
|
|
8523
|
-
|
|
8524
|
-
if (!formattedEnteredStringLength) {
|
|
8525
|
-
removedLength = 0;
|
|
8526
|
-
} else {
|
|
8527
|
-
removedLength = previousSelection.length;
|
|
8528
|
-
}
|
|
8529
|
-
} else if (newValue.length < previousValue.length) {
|
|
8530
|
-
removedLength = previousValue.length - newValue.length;
|
|
8531
|
-
}
|
|
8532
|
-
newValue = previousValue;
|
|
8533
|
-
if (removedLength) {
|
|
8534
|
-
if (removedLength === 1 && !previousSelection.length) {
|
|
8535
|
-
var deleteFromRight = previousSelection.start === selection.start;
|
|
8536
|
-
cursorPosition = deleteFromRight ? getRightEditablePosition(maskOptions, selection.start) : getLeftEditablePosition(maskOptions, selection.start);
|
|
8681
|
+
function useValue(inputRef, initialValue) {
|
|
8682
|
+
var getInputElement = useInputElement(inputRef);
|
|
8683
|
+
var valueRef = React.useRef(initialValue);
|
|
8684
|
+
var getValue = React.useCallback(function () {
|
|
8685
|
+
var input = getInputElement();
|
|
8686
|
+
return input.value;
|
|
8687
|
+
}, [getInputElement]);
|
|
8688
|
+
var getLastValue = React.useCallback(function () {
|
|
8689
|
+
return valueRef.current;
|
|
8690
|
+
}, []);
|
|
8691
|
+
var setValue = React.useCallback(function (newValue) {
|
|
8692
|
+
valueRef.current = newValue;
|
|
8693
|
+
var input = getInputElement();
|
|
8694
|
+
if (input) {
|
|
8695
|
+
input.value = newValue;
|
|
8537
8696
|
}
|
|
8538
|
-
|
|
8697
|
+
}, [getInputElement]);
|
|
8698
|
+
return {
|
|
8699
|
+
getValue: getValue,
|
|
8700
|
+
getLastValue: getLastValue,
|
|
8701
|
+
setValue: setValue
|
|
8702
|
+
};
|
|
8703
|
+
}
|
|
8704
|
+
function useInputState(initialValue, isMasked) {
|
|
8705
|
+
var inputRef = React.useRef();
|
|
8706
|
+
var _useSelection = useSelection(inputRef, isMasked),
|
|
8707
|
+
getSelection = _useSelection.getSelection,
|
|
8708
|
+
getLastSelection = _useSelection.getLastSelection,
|
|
8709
|
+
setSelection = _useSelection.setSelection;
|
|
8710
|
+
var _useValue = useValue(inputRef, initialValue),
|
|
8711
|
+
getValue = _useValue.getValue,
|
|
8712
|
+
getLastValue = _useValue.getLastValue,
|
|
8713
|
+
setValue = _useValue.setValue;
|
|
8714
|
+
function getLastInputState() {
|
|
8715
|
+
return {
|
|
8716
|
+
value: getLastValue(),
|
|
8717
|
+
selection: getLastSelection()
|
|
8718
|
+
};
|
|
8539
8719
|
}
|
|
8540
|
-
|
|
8541
|
-
|
|
8542
|
-
|
|
8543
|
-
|
|
8544
|
-
|
|
8545
|
-
cursorPosition = prefix.length;
|
|
8546
|
-
} else if (cursorPosition >= prefix.length && cursorPosition < lastEditablePosition && formattedEnteredStringLength) {
|
|
8547
|
-
cursorPosition = getRightEditablePosition(maskOptions, cursorPosition);
|
|
8720
|
+
function getInputState() {
|
|
8721
|
+
return {
|
|
8722
|
+
value: getValue(),
|
|
8723
|
+
selection: getSelection()
|
|
8724
|
+
};
|
|
8548
8725
|
}
|
|
8549
|
-
|
|
8550
|
-
|
|
8551
|
-
|
|
8726
|
+
function setInputState(_ref) {
|
|
8727
|
+
var value = _ref.value,
|
|
8728
|
+
selection = _ref.selection;
|
|
8729
|
+
setValue(value);
|
|
8730
|
+
setSelection(selection);
|
|
8552
8731
|
}
|
|
8553
8732
|
return {
|
|
8554
|
-
|
|
8555
|
-
|
|
8556
|
-
|
|
8557
|
-
|
|
8558
|
-
end: cursorPosition
|
|
8559
|
-
}
|
|
8733
|
+
inputRef: inputRef,
|
|
8734
|
+
getInputState: getInputState,
|
|
8735
|
+
getLastInputState: getLastInputState,
|
|
8736
|
+
setInputState: setInputState
|
|
8560
8737
|
};
|
|
8561
8738
|
}
|
|
8562
|
-
function
|
|
8563
|
-
var
|
|
8564
|
-
|
|
8565
|
-
|
|
8566
|
-
|
|
8739
|
+
function usePrevious(value) {
|
|
8740
|
+
var ref = React.useRef();
|
|
8741
|
+
React.useEffect(function () {
|
|
8742
|
+
ref.current = value;
|
|
8743
|
+
});
|
|
8744
|
+
return ref.current;
|
|
8567
8745
|
}
|
|
8568
|
-
|
|
8569
|
-
|
|
8746
|
+
var CONTROLLED_PROPS = ["disabled", "onBlur", "onChange", "onFocus", "onMouseDown", "readOnly", "value"];
|
|
8747
|
+
var defaultFormatChars = {
|
|
8748
|
+
9: /[0-9]/,
|
|
8749
|
+
a: /[A-Za-z]/,
|
|
8750
|
+
"*": /[A-Za-z0-9]/
|
|
8751
|
+
};
|
|
8752
|
+
function validateMaxLength(props) {
|
|
8753
|
+
process.env.NODE_ENV !== "production" ? warning(!props.maxLength || !props.mask, "react-input-mask: maxLength property shouldn't be passed to the masked input. It breaks masking and unnecessary because length is limited by the mask length.") : void 0;
|
|
8570
8754
|
}
|
|
8571
|
-
function
|
|
8572
|
-
|
|
8755
|
+
function validateMaskPlaceholder(props) {
|
|
8756
|
+
var mask = props.mask,
|
|
8757
|
+
maskPlaceholder = props.maskPlaceholder;
|
|
8758
|
+
!(!mask || !maskPlaceholder || maskPlaceholder.length === 1 || maskPlaceholder.length === mask.length) ? process.env.NODE_ENV !== "production" ? invariant(false, "react-input-mask: maskPlaceholder should either be a single character or have the same length as the mask:\n" + ("mask: " + mask + "\n") + ("maskPlaceholder: " + maskPlaceholder)) : invariant(false) : void 0;
|
|
8573
8759
|
}
|
|
8574
|
-
function
|
|
8575
|
-
|
|
8760
|
+
function validateChildren(props, inputElement) {
|
|
8761
|
+
var conflictProps = CONTROLLED_PROPS.filter(function (propId) {
|
|
8762
|
+
return inputElement.props[propId] != null && inputElement.props[propId] !== props[propId];
|
|
8763
|
+
});
|
|
8764
|
+
!!conflictProps.length ? process.env.NODE_ENV !== "production" ? invariant(false, "react-input-mask: the following props should be passed to the InputMask component, not to children: " + conflictProps.join(",")) : invariant(false) : void 0;
|
|
8576
8765
|
}
|
|
8577
|
-
function
|
|
8578
|
-
var
|
|
8579
|
-
|
|
8580
|
-
|
|
8581
|
-
|
|
8582
|
-
|
|
8583
|
-
|
|
8584
|
-
|
|
8766
|
+
var parseMask = function parseMask(_ref) {
|
|
8767
|
+
var mask = _ref.mask,
|
|
8768
|
+
maskPlaceholder = _ref.maskPlaceholder;
|
|
8769
|
+
var permanents = [];
|
|
8770
|
+
if (!mask) {
|
|
8771
|
+
return {
|
|
8772
|
+
maskPlaceholder: null,
|
|
8773
|
+
mask: null,
|
|
8774
|
+
prefix: null,
|
|
8775
|
+
lastEditablePosition: null,
|
|
8776
|
+
permanents: []
|
|
8585
8777
|
};
|
|
8586
8778
|
}
|
|
8587
|
-
|
|
8588
|
-
|
|
8589
|
-
|
|
8590
|
-
|
|
8591
|
-
|
|
8592
|
-
|
|
8593
|
-
|
|
8594
|
-
|
|
8595
|
-
|
|
8596
|
-
|
|
8597
|
-
|
|
8598
|
-
|
|
8599
|
-
_this.focused = false;
|
|
8600
|
-
_this.mounted = false;
|
|
8601
|
-
_this.previousSelection = null;
|
|
8602
|
-
_this.selectionDeferId = null;
|
|
8603
|
-
_this.saveSelectionLoopDeferId = null;
|
|
8604
|
-
_this.saveSelectionLoop = function () {
|
|
8605
|
-
_this.previousSelection = _this.getSelection();
|
|
8606
|
-
_this.saveSelectionLoopDeferId = defer(_this.saveSelectionLoop);
|
|
8607
|
-
};
|
|
8608
|
-
_this.runSaveSelectionLoop = function () {
|
|
8609
|
-
if (_this.saveSelectionLoopDeferId === null) {
|
|
8610
|
-
_this.saveSelectionLoop();
|
|
8611
|
-
}
|
|
8612
|
-
};
|
|
8613
|
-
_this.stopSaveSelectionLoop = function () {
|
|
8614
|
-
if (_this.saveSelectionLoopDeferId !== null) {
|
|
8615
|
-
cancelDefer(_this.saveSelectionLoopDeferId);
|
|
8616
|
-
_this.saveSelectionLoopDeferId = null;
|
|
8617
|
-
_this.previousSelection = null;
|
|
8618
|
-
}
|
|
8619
|
-
};
|
|
8620
|
-
_this.getInputDOMNode = function () {
|
|
8621
|
-
if (!_this.mounted) {
|
|
8622
|
-
return null;
|
|
8623
|
-
}
|
|
8624
|
-
var input = reactDom.findDOMNode(_assertThisInitialized(_assertThisInitialized(_this)));
|
|
8625
|
-
var isDOMNode = typeof window !== 'undefined' && input instanceof window.Element; // workaround for react-test-renderer
|
|
8626
|
-
// https://github.com/sanniassin/react-input-mask/issues/147
|
|
8627
|
-
|
|
8628
|
-
if (input && !isDOMNode) {
|
|
8629
|
-
return null;
|
|
8630
|
-
}
|
|
8631
|
-
if (input.nodeName !== 'INPUT') {
|
|
8632
|
-
input = input.querySelector('input');
|
|
8633
|
-
}
|
|
8634
|
-
if (!input) {
|
|
8635
|
-
throw new Error('react-input-mask: inputComponent doesn\'t contain input node');
|
|
8636
|
-
}
|
|
8637
|
-
return input;
|
|
8638
|
-
};
|
|
8639
|
-
_this.getInputValue = function () {
|
|
8640
|
-
var input = _this.getInputDOMNode();
|
|
8641
|
-
if (!input) {
|
|
8642
|
-
return null;
|
|
8643
|
-
}
|
|
8644
|
-
return input.value;
|
|
8645
|
-
};
|
|
8646
|
-
_this.setInputValue = function (value) {
|
|
8647
|
-
var input = _this.getInputDOMNode();
|
|
8648
|
-
if (!input) {
|
|
8649
|
-
return;
|
|
8650
|
-
}
|
|
8651
|
-
_this.value = value;
|
|
8652
|
-
input.value = value;
|
|
8653
|
-
};
|
|
8654
|
-
_this.setCursorToEnd = function () {
|
|
8655
|
-
var filledLength = getFilledLength(_this.maskOptions, _this.value);
|
|
8656
|
-
var pos = getRightEditablePosition(_this.maskOptions, filledLength);
|
|
8657
|
-
if (pos !== null) {
|
|
8658
|
-
_this.setCursorPosition(pos);
|
|
8659
|
-
}
|
|
8660
|
-
};
|
|
8661
|
-
_this.setSelection = function (start, end, options) {
|
|
8662
|
-
if (options === void 0) {
|
|
8663
|
-
options = {};
|
|
8779
|
+
if (typeof mask === "string") {
|
|
8780
|
+
var isPermanent = false;
|
|
8781
|
+
var parsedMaskString = "";
|
|
8782
|
+
mask.split("").forEach(function (character) {
|
|
8783
|
+
if (!isPermanent && character === "\\") {
|
|
8784
|
+
isPermanent = true;
|
|
8785
|
+
} else {
|
|
8786
|
+
if (isPermanent || !defaultFormatChars[character]) {
|
|
8787
|
+
permanents.push(parsedMaskString.length);
|
|
8788
|
+
}
|
|
8789
|
+
parsedMaskString += character;
|
|
8790
|
+
isPermanent = false;
|
|
8664
8791
|
}
|
|
8665
|
-
|
|
8666
|
-
|
|
8667
|
-
|
|
8668
|
-
|
|
8669
|
-
if (!input || !isFocused) {
|
|
8670
|
-
return;
|
|
8792
|
+
});
|
|
8793
|
+
mask = parsedMaskString.split("").map(function (character, index) {
|
|
8794
|
+
if (permanents.indexOf(index) === -1) {
|
|
8795
|
+
return defaultFormatChars[character];
|
|
8671
8796
|
}
|
|
8672
|
-
|
|
8673
|
-
|
|
8674
|
-
|
|
8675
|
-
|
|
8797
|
+
return character;
|
|
8798
|
+
});
|
|
8799
|
+
} else {
|
|
8800
|
+
mask.forEach(function (character, index) {
|
|
8801
|
+
if (typeof character === "string") {
|
|
8802
|
+
permanents.push(index);
|
|
8676
8803
|
}
|
|
8677
|
-
|
|
8678
|
-
|
|
8679
|
-
|
|
8680
|
-
|
|
8681
|
-
|
|
8682
|
-
|
|
8683
|
-
|
|
8684
|
-
setInputSelection(input, start, end);
|
|
8685
|
-
});
|
|
8686
|
-
_this.previousSelection = {
|
|
8687
|
-
start: start,
|
|
8688
|
-
end: end,
|
|
8689
|
-
length: Math.abs(end - start)
|
|
8690
|
-
};
|
|
8691
|
-
};
|
|
8692
|
-
_this.getSelection = function () {
|
|
8693
|
-
var input = _this.getInputDOMNode();
|
|
8694
|
-
return getInputSelection(input);
|
|
8695
|
-
};
|
|
8696
|
-
_this.getCursorPosition = function () {
|
|
8697
|
-
return _this.getSelection().start;
|
|
8698
|
-
};
|
|
8699
|
-
_this.setCursorPosition = function (pos) {
|
|
8700
|
-
_this.setSelection(pos, pos);
|
|
8701
|
-
};
|
|
8702
|
-
_this.isFocused = function () {
|
|
8703
|
-
return _this.focused;
|
|
8704
|
-
};
|
|
8705
|
-
_this.getBeforeMaskedValueChangeConfig = function () {
|
|
8706
|
-
var _this$maskOptions = _this.maskOptions,
|
|
8707
|
-
mask = _this$maskOptions.mask,
|
|
8708
|
-
maskChar = _this$maskOptions.maskChar,
|
|
8709
|
-
permanents = _this$maskOptions.permanents,
|
|
8710
|
-
formatChars = _this$maskOptions.formatChars;
|
|
8711
|
-
var alwaysShowMask = _this.props.alwaysShowMask;
|
|
8712
|
-
return {
|
|
8713
|
-
mask: mask,
|
|
8714
|
-
maskChar: maskChar,
|
|
8715
|
-
permanents: permanents,
|
|
8716
|
-
alwaysShowMask: !!alwaysShowMask,
|
|
8717
|
-
formatChars: formatChars
|
|
8718
|
-
};
|
|
8719
|
-
};
|
|
8720
|
-
_this.isInputAutofilled = function (value, selection, previousValue, previousSelection) {
|
|
8721
|
-
var input = _this.getInputDOMNode(); // only check for positive match because it will be false negative
|
|
8722
|
-
// in case of autofill simulation in tests
|
|
8723
|
-
//
|
|
8724
|
-
// input.matches throws an exception if selector isn't supported
|
|
8725
|
-
|
|
8726
|
-
try {
|
|
8727
|
-
if (input.matches(':-webkit-autofill')) {
|
|
8728
|
-
return true;
|
|
8804
|
+
});
|
|
8805
|
+
}
|
|
8806
|
+
if (maskPlaceholder) {
|
|
8807
|
+
if (maskPlaceholder.length === 1) {
|
|
8808
|
+
maskPlaceholder = mask.map(function (character, index) {
|
|
8809
|
+
if (permanents.indexOf(index) !== -1) {
|
|
8810
|
+
return character;
|
|
8729
8811
|
}
|
|
8730
|
-
|
|
8731
|
-
|
|
8732
|
-
|
|
8733
|
-
|
|
8734
|
-
|
|
8735
|
-
|
|
8736
|
-
|
|
8812
|
+
return maskPlaceholder;
|
|
8813
|
+
});
|
|
8814
|
+
} else {
|
|
8815
|
+
maskPlaceholder = maskPlaceholder.split("");
|
|
8816
|
+
}
|
|
8817
|
+
permanents.forEach(function (position) {
|
|
8818
|
+
maskPlaceholder[position] = mask[position];
|
|
8819
|
+
});
|
|
8820
|
+
maskPlaceholder = maskPlaceholder.join("");
|
|
8821
|
+
}
|
|
8822
|
+
var prefix = permanents.filter(function (position, index) {
|
|
8823
|
+
return position === index;
|
|
8824
|
+
}).map(function (position) {
|
|
8825
|
+
return mask[position];
|
|
8826
|
+
}).join("");
|
|
8827
|
+
var lastEditablePosition = mask.length - 1;
|
|
8828
|
+
while (permanents.indexOf(lastEditablePosition) !== -1) {
|
|
8829
|
+
lastEditablePosition--;
|
|
8830
|
+
}
|
|
8831
|
+
return {
|
|
8832
|
+
maskPlaceholder: maskPlaceholder,
|
|
8833
|
+
prefix: prefix,
|
|
8834
|
+
mask: mask,
|
|
8835
|
+
lastEditablePosition: lastEditablePosition,
|
|
8836
|
+
permanents: permanents
|
|
8837
|
+
};
|
|
8838
|
+
};
|
|
8737
8839
|
|
|
8738
|
-
|
|
8840
|
+
/* eslint no-use-before-define: ["error", { functions: false }] */
|
|
8841
|
+
var MaskUtils = function MaskUtils(options) {
|
|
8842
|
+
var _this = this;
|
|
8843
|
+
this.isCharacterAllowedAtPosition = function (character, position) {
|
|
8844
|
+
var maskPlaceholder = _this.maskOptions.maskPlaceholder;
|
|
8845
|
+
if (_this.isCharacterFillingPosition(character, position)) {
|
|
8846
|
+
return true;
|
|
8847
|
+
}
|
|
8848
|
+
if (!maskPlaceholder) {
|
|
8849
|
+
return false;
|
|
8850
|
+
}
|
|
8851
|
+
return maskPlaceholder[position] === character;
|
|
8852
|
+
};
|
|
8853
|
+
this.isCharacterFillingPosition = function (character, position) {
|
|
8854
|
+
var mask = _this.maskOptions.mask;
|
|
8855
|
+
if (!character || position >= mask.length) {
|
|
8856
|
+
return false;
|
|
8857
|
+
}
|
|
8858
|
+
if (!_this.isPositionEditable(position)) {
|
|
8859
|
+
return mask[position] === character;
|
|
8860
|
+
}
|
|
8861
|
+
var charRule = mask[position];
|
|
8862
|
+
return new RegExp(charRule).test(character);
|
|
8863
|
+
};
|
|
8864
|
+
this.isPositionEditable = function (position) {
|
|
8865
|
+
var _this$maskOptions = _this.maskOptions,
|
|
8866
|
+
mask = _this$maskOptions.mask,
|
|
8867
|
+
permanents = _this$maskOptions.permanents;
|
|
8868
|
+
return position < mask.length && permanents.indexOf(position) === -1;
|
|
8869
|
+
};
|
|
8870
|
+
this.isValueEmpty = function (value) {
|
|
8871
|
+
return value.split("").every(function (character, position) {
|
|
8872
|
+
return !_this.isPositionEditable(position) || !_this.isCharacterFillingPosition(character, position);
|
|
8873
|
+
});
|
|
8874
|
+
};
|
|
8875
|
+
this.isValueFilled = function (value) {
|
|
8876
|
+
return _this.getFilledLength(value) === _this.maskOptions.lastEditablePosition + 1;
|
|
8877
|
+
};
|
|
8878
|
+
this.getDefaultSelectionForValue = function (value) {
|
|
8879
|
+
var filledLength = _this.getFilledLength(value);
|
|
8880
|
+
var cursorPosition = _this.getRightEditablePosition(filledLength);
|
|
8881
|
+
return {
|
|
8882
|
+
start: cursorPosition,
|
|
8883
|
+
end: cursorPosition
|
|
8739
8884
|
};
|
|
8740
|
-
|
|
8741
|
-
|
|
8742
|
-
|
|
8743
|
-
|
|
8744
|
-
|
|
8745
|
-
|
|
8746
|
-
|
|
8747
|
-
|
|
8748
|
-
|
|
8749
|
-
|
|
8750
|
-
|
|
8751
|
-
|
|
8752
|
-
|
|
8753
|
-
|
|
8754
|
-
|
|
8755
|
-
|
|
8756
|
-
|
|
8757
|
-
|
|
8758
|
-
|
|
8759
|
-
// cleared input in onPaste handler
|
|
8760
|
-
|
|
8761
|
-
if (beforePasteState) {
|
|
8762
|
-
previousSelection = beforePasteState.selection;
|
|
8763
|
-
previousValue = beforePasteState.value;
|
|
8764
|
-
selection = {
|
|
8765
|
-
start: previousSelection.start + value.length,
|
|
8766
|
-
end: previousSelection.start + value.length,
|
|
8767
|
-
length: 0
|
|
8768
|
-
};
|
|
8769
|
-
value = previousValue.slice(0, previousSelection.start) + value + previousValue.slice(previousSelection.end);
|
|
8770
|
-
_this.beforePasteState = null;
|
|
8885
|
+
};
|
|
8886
|
+
this.getFilledLength = function (value) {
|
|
8887
|
+
var characters = value.split("");
|
|
8888
|
+
var lastFilledIndex = findLastIndex(characters, function (character, position) {
|
|
8889
|
+
return _this.isPositionEditable(position) && _this.isCharacterFillingPosition(character, position);
|
|
8890
|
+
});
|
|
8891
|
+
return lastFilledIndex + 1;
|
|
8892
|
+
};
|
|
8893
|
+
this.getStringFillingLengthAtPosition = function (string, position) {
|
|
8894
|
+
var characters = string.split("");
|
|
8895
|
+
var insertedValue = characters.reduce(function (value, character) {
|
|
8896
|
+
return _this.insertCharacterAtPosition(value, character, value.length);
|
|
8897
|
+
}, repeat(" ", position));
|
|
8898
|
+
return insertedValue.length - position;
|
|
8899
|
+
};
|
|
8900
|
+
this.getLeftEditablePosition = function (position) {
|
|
8901
|
+
for (var i = position; i >= 0; i--) {
|
|
8902
|
+
if (_this.isPositionEditable(i)) {
|
|
8903
|
+
return i;
|
|
8771
8904
|
}
|
|
8772
|
-
|
|
8773
|
-
|
|
8774
|
-
|
|
8775
|
-
|
|
8776
|
-
|
|
8777
|
-
|
|
8778
|
-
|
|
8779
|
-
|
|
8780
|
-
|
|
8781
|
-
|
|
8782
|
-
|
|
8783
|
-
|
|
8784
|
-
|
|
8785
|
-
|
|
8905
|
+
}
|
|
8906
|
+
return null;
|
|
8907
|
+
};
|
|
8908
|
+
this.getRightEditablePosition = function (position) {
|
|
8909
|
+
var mask = _this.maskOptions.mask;
|
|
8910
|
+
for (var i = position; i < mask.length; i++) {
|
|
8911
|
+
if (_this.isPositionEditable(i)) {
|
|
8912
|
+
return i;
|
|
8913
|
+
}
|
|
8914
|
+
}
|
|
8915
|
+
return null;
|
|
8916
|
+
};
|
|
8917
|
+
this.formatValue = function (value) {
|
|
8918
|
+
var _this$maskOptions2 = _this.maskOptions,
|
|
8919
|
+
maskPlaceholder = _this$maskOptions2.maskPlaceholder,
|
|
8920
|
+
mask = _this$maskOptions2.mask;
|
|
8921
|
+
if (!maskPlaceholder) {
|
|
8922
|
+
value = _this.insertStringAtPosition("", value, 0);
|
|
8923
|
+
while (value.length < mask.length && !_this.isPositionEditable(value.length)) {
|
|
8924
|
+
value += mask[value.length];
|
|
8786
8925
|
}
|
|
8787
|
-
|
|
8788
|
-
|
|
8789
|
-
|
|
8926
|
+
return value;
|
|
8927
|
+
}
|
|
8928
|
+
return _this.insertStringAtPosition(maskPlaceholder, value, 0);
|
|
8929
|
+
};
|
|
8930
|
+
this.clearRange = function (value, start, len) {
|
|
8931
|
+
if (!len) {
|
|
8932
|
+
return value;
|
|
8933
|
+
}
|
|
8934
|
+
var end = start + len;
|
|
8935
|
+
var _this$maskOptions3 = _this.maskOptions,
|
|
8936
|
+
maskPlaceholder = _this$maskOptions3.maskPlaceholder,
|
|
8937
|
+
mask = _this$maskOptions3.mask;
|
|
8938
|
+
var clearedValue = value.split("").map(function (character, i) {
|
|
8939
|
+
var isEditable = _this.isPositionEditable(i);
|
|
8940
|
+
if (!maskPlaceholder && i >= end && !isEditable) {
|
|
8941
|
+
return "";
|
|
8790
8942
|
}
|
|
8791
|
-
if (
|
|
8792
|
-
|
|
8793
|
-
deferred: true
|
|
8794
|
-
});
|
|
8795
|
-
} else {
|
|
8796
|
-
_this.setSelection(newSelection.start, newSelection.end);
|
|
8943
|
+
if (i < start || i >= end) {
|
|
8944
|
+
return character;
|
|
8797
8945
|
}
|
|
8798
|
-
|
|
8799
|
-
|
|
8800
|
-
var beforeMaskedValueChange = _this.props.beforeMaskedValueChange;
|
|
8801
|
-
var _this$maskOptions2 = _this.maskOptions,
|
|
8802
|
-
mask = _this$maskOptions2.mask,
|
|
8803
|
-
prefix = _this$maskOptions2.prefix;
|
|
8804
|
-
_this.focused = true; // if autoFocus is set, onFocus triggers before componentDidMount
|
|
8805
|
-
|
|
8806
|
-
_this.mounted = true;
|
|
8807
|
-
if (mask) {
|
|
8808
|
-
if (!_this.value) {
|
|
8809
|
-
var emptyValue = formatValue(_this.maskOptions, prefix);
|
|
8810
|
-
var newValue = formatValue(_this.maskOptions, emptyValue);
|
|
8811
|
-
var filledLength = getFilledLength(_this.maskOptions, newValue);
|
|
8812
|
-
var cursorPosition = getRightEditablePosition(_this.maskOptions, filledLength);
|
|
8813
|
-
var newSelection = {
|
|
8814
|
-
start: cursorPosition,
|
|
8815
|
-
end: cursorPosition
|
|
8816
|
-
};
|
|
8817
|
-
if (isFunction(beforeMaskedValueChange)) {
|
|
8818
|
-
var modifiedValue = beforeMaskedValueChange({
|
|
8819
|
-
value: newValue,
|
|
8820
|
-
selection: newSelection
|
|
8821
|
-
}, {
|
|
8822
|
-
value: _this.value,
|
|
8823
|
-
selection: null
|
|
8824
|
-
}, null, _this.getBeforeMaskedValueChangeConfig());
|
|
8825
|
-
newValue = modifiedValue.value;
|
|
8826
|
-
newSelection = modifiedValue.selection;
|
|
8827
|
-
}
|
|
8828
|
-
var isInputValueChanged = newValue !== _this.getInputValue();
|
|
8829
|
-
if (isInputValueChanged) {
|
|
8830
|
-
_this.setInputValue(newValue);
|
|
8831
|
-
}
|
|
8832
|
-
if (isInputValueChanged && isFunction(_this.props.onChange)) {
|
|
8833
|
-
_this.props.onChange(event);
|
|
8834
|
-
}
|
|
8835
|
-
_this.setSelection(newSelection.start, newSelection.end);
|
|
8836
|
-
} else if (getFilledLength(_this.maskOptions, _this.value) < _this.maskOptions.mask.length) {
|
|
8837
|
-
_this.setCursorToEnd();
|
|
8838
|
-
}
|
|
8839
|
-
_this.runSaveSelectionLoop();
|
|
8946
|
+
if (!isEditable) {
|
|
8947
|
+
return mask[i];
|
|
8840
8948
|
}
|
|
8841
|
-
if (
|
|
8842
|
-
|
|
8949
|
+
if (maskPlaceholder) {
|
|
8950
|
+
return maskPlaceholder[i];
|
|
8843
8951
|
}
|
|
8844
|
-
|
|
8845
|
-
|
|
8846
|
-
|
|
8847
|
-
|
|
8848
|
-
|
|
8849
|
-
|
|
8850
|
-
|
|
8851
|
-
|
|
8852
|
-
|
|
8853
|
-
|
|
8854
|
-
|
|
8855
|
-
|
|
8856
|
-
|
|
8857
|
-
|
|
8858
|
-
|
|
8859
|
-
|
|
8860
|
-
|
|
8861
|
-
|
|
8862
|
-
|
|
8863
|
-
|
|
8864
|
-
|
|
8952
|
+
return "";
|
|
8953
|
+
}).join("");
|
|
8954
|
+
return _this.formatValue(clearedValue);
|
|
8955
|
+
};
|
|
8956
|
+
this.insertCharacterAtPosition = function (value, character, position) {
|
|
8957
|
+
var _this$maskOptions4 = _this.maskOptions,
|
|
8958
|
+
mask = _this$maskOptions4.mask,
|
|
8959
|
+
maskPlaceholder = _this$maskOptions4.maskPlaceholder;
|
|
8960
|
+
if (position >= mask.length) {
|
|
8961
|
+
return value;
|
|
8962
|
+
}
|
|
8963
|
+
var isAllowed = _this.isCharacterAllowedAtPosition(character, position);
|
|
8964
|
+
var isEditable = _this.isPositionEditable(position);
|
|
8965
|
+
var nextEditablePosition = _this.getRightEditablePosition(position);
|
|
8966
|
+
var isNextPlaceholder = maskPlaceholder && nextEditablePosition ? character === maskPlaceholder[nextEditablePosition] : null;
|
|
8967
|
+
var valueBefore = value.slice(0, position);
|
|
8968
|
+
if (isAllowed || !isEditable) {
|
|
8969
|
+
var insertedCharacter = isAllowed ? character : mask[position];
|
|
8970
|
+
value = valueBefore + insertedCharacter;
|
|
8971
|
+
}
|
|
8972
|
+
if (!isAllowed && !isEditable && !isNextPlaceholder) {
|
|
8973
|
+
value = _this.insertCharacterAtPosition(value, character, position + 1);
|
|
8974
|
+
}
|
|
8975
|
+
return value;
|
|
8976
|
+
};
|
|
8977
|
+
this.insertStringAtPosition = function (value, string, position) {
|
|
8978
|
+
var _this$maskOptions5 = _this.maskOptions,
|
|
8979
|
+
mask = _this$maskOptions5.mask,
|
|
8980
|
+
maskPlaceholder = _this$maskOptions5.maskPlaceholder;
|
|
8981
|
+
if (!string || position >= mask.length) {
|
|
8982
|
+
return value;
|
|
8983
|
+
}
|
|
8984
|
+
var characters = string.split("");
|
|
8985
|
+
var isFixedLength = _this.isValueFilled(value) || !!maskPlaceholder;
|
|
8986
|
+
var valueAfter = value.slice(position);
|
|
8987
|
+
value = characters.reduce(function (value, character) {
|
|
8988
|
+
return _this.insertCharacterAtPosition(value, character, value.length);
|
|
8989
|
+
}, value.slice(0, position));
|
|
8990
|
+
if (isFixedLength) {
|
|
8991
|
+
value += valueAfter.slice(value.length - position);
|
|
8992
|
+
} else if (_this.isValueFilled(value)) {
|
|
8993
|
+
value += mask.slice(value.length).join("");
|
|
8994
|
+
} else {
|
|
8995
|
+
var editableCharactersAfter = valueAfter.split("").filter(function (character, i) {
|
|
8996
|
+
return _this.isPositionEditable(position + i);
|
|
8997
|
+
});
|
|
8998
|
+
value = editableCharactersAfter.reduce(function (value, character) {
|
|
8999
|
+
var nextEditablePosition = _this.getRightEditablePosition(value.length);
|
|
9000
|
+
if (nextEditablePosition === null) {
|
|
9001
|
+
return value;
|
|
8865
9002
|
}
|
|
8866
|
-
if (
|
|
8867
|
-
|
|
9003
|
+
if (!_this.isPositionEditable(value.length)) {
|
|
9004
|
+
value += mask.slice(value.length, nextEditablePosition).join("");
|
|
8868
9005
|
}
|
|
9006
|
+
return _this.insertCharacterAtPosition(value, character, value.length);
|
|
9007
|
+
}, value);
|
|
9008
|
+
}
|
|
9009
|
+
return value;
|
|
9010
|
+
};
|
|
9011
|
+
this.processChange = function (currentState, previousState) {
|
|
9012
|
+
var _this$maskOptions6 = _this.maskOptions,
|
|
9013
|
+
mask = _this$maskOptions6.mask,
|
|
9014
|
+
prefix = _this$maskOptions6.prefix,
|
|
9015
|
+
lastEditablePosition = _this$maskOptions6.lastEditablePosition;
|
|
9016
|
+
var value = currentState.value,
|
|
9017
|
+
selection = currentState.selection;
|
|
9018
|
+
var previousValue = previousState.value;
|
|
9019
|
+
var previousSelection = previousState.selection;
|
|
9020
|
+
var newValue = value;
|
|
9021
|
+
var enteredString = "";
|
|
9022
|
+
var formattedEnteredStringLength = 0;
|
|
9023
|
+
var removedLength = 0;
|
|
9024
|
+
var cursorPosition = Math.min(previousSelection.start, selection.start);
|
|
9025
|
+
if (selection.end > previousSelection.start) {
|
|
9026
|
+
enteredString = newValue.slice(previousSelection.start, selection.end);
|
|
9027
|
+
formattedEnteredStringLength = _this.getStringFillingLengthAtPosition(enteredString, cursorPosition);
|
|
9028
|
+
if (!formattedEnteredStringLength) {
|
|
9029
|
+
removedLength = 0;
|
|
9030
|
+
} else {
|
|
9031
|
+
removedLength = previousSelection.length;
|
|
8869
9032
|
}
|
|
8870
|
-
|
|
8871
|
-
|
|
8872
|
-
|
|
8873
|
-
|
|
8874
|
-
|
|
8875
|
-
|
|
8876
|
-
|
|
8877
|
-
|
|
8878
|
-
// https://github.com/sanniassin/react-input-mask/issues/108
|
|
8879
|
-
if (!_this.focused && document.addEventListener) {
|
|
8880
|
-
_this.mouseDownX = event.clientX;
|
|
8881
|
-
_this.mouseDownY = event.clientY;
|
|
8882
|
-
_this.mouseDownTime = new Date().getTime();
|
|
8883
|
-
var mouseUpHandler = function mouseUpHandler(mouseUpEvent) {
|
|
8884
|
-
document.removeEventListener('mouseup', mouseUpHandler);
|
|
8885
|
-
if (!_this.focused) {
|
|
8886
|
-
return;
|
|
8887
|
-
}
|
|
8888
|
-
var deltaX = Math.abs(mouseUpEvent.clientX - _this.mouseDownX);
|
|
8889
|
-
var deltaY = Math.abs(mouseUpEvent.clientY - _this.mouseDownY);
|
|
8890
|
-
var axisDelta = Math.max(deltaX, deltaY);
|
|
8891
|
-
var timeDelta = new Date().getTime() - _this.mouseDownTime;
|
|
8892
|
-
if (axisDelta <= 10 && timeDelta <= 200 || axisDelta <= 5 && timeDelta <= 300) {
|
|
8893
|
-
_this.setCursorToEnd();
|
|
8894
|
-
}
|
|
8895
|
-
};
|
|
8896
|
-
document.addEventListener('mouseup', mouseUpHandler);
|
|
9033
|
+
} else if (newValue.length < previousValue.length) {
|
|
9034
|
+
removedLength = previousValue.length - newValue.length;
|
|
9035
|
+
}
|
|
9036
|
+
newValue = previousValue;
|
|
9037
|
+
if (removedLength) {
|
|
9038
|
+
if (removedLength === 1 && !previousSelection.length) {
|
|
9039
|
+
var deleteFromRight = previousSelection.start === selection.start;
|
|
9040
|
+
cursorPosition = deleteFromRight ? _this.getRightEditablePosition(selection.start) : _this.getLeftEditablePosition(selection.start);
|
|
8897
9041
|
}
|
|
8898
|
-
|
|
8899
|
-
|
|
9042
|
+
newValue = _this.clearRange(newValue, cursorPosition, removedLength);
|
|
9043
|
+
}
|
|
9044
|
+
newValue = _this.insertStringAtPosition(newValue, enteredString, cursorPosition);
|
|
9045
|
+
cursorPosition += formattedEnteredStringLength;
|
|
9046
|
+
if (cursorPosition >= mask.length) {
|
|
9047
|
+
cursorPosition = mask.length;
|
|
9048
|
+
} else if (cursorPosition < prefix.length && !formattedEnteredStringLength) {
|
|
9049
|
+
cursorPosition = prefix.length;
|
|
9050
|
+
} else if (cursorPosition >= prefix.length && cursorPosition < lastEditablePosition && formattedEnteredStringLength) {
|
|
9051
|
+
cursorPosition = _this.getRightEditablePosition(cursorPosition);
|
|
9052
|
+
}
|
|
9053
|
+
newValue = _this.formatValue(newValue);
|
|
9054
|
+
return {
|
|
9055
|
+
value: newValue,
|
|
9056
|
+
enteredString: enteredString,
|
|
9057
|
+
selection: {
|
|
9058
|
+
start: cursorPosition,
|
|
9059
|
+
end: cursorPosition
|
|
8900
9060
|
}
|
|
8901
9061
|
};
|
|
8902
|
-
|
|
8903
|
-
|
|
8904
|
-
|
|
8905
|
-
|
|
8906
|
-
|
|
8907
|
-
|
|
8908
|
-
|
|
8909
|
-
|
|
8910
|
-
|
|
8911
|
-
|
|
8912
|
-
|
|
8913
|
-
|
|
9062
|
+
};
|
|
9063
|
+
this.maskOptions = parseMask(options);
|
|
9064
|
+
};
|
|
9065
|
+
var _excluded = ["alwaysShowMask", "children", "mask", "maskPlaceholder", "beforeMaskedStateChange"];
|
|
9066
|
+
|
|
9067
|
+
// eslint-disable-next-line prefer-arrow-callback
|
|
9068
|
+
var InputMask = /*#__PURE__*/React.forwardRef(function InputMask(props, forwardedRef) {
|
|
9069
|
+
var alwaysShowMask = props.alwaysShowMask,
|
|
9070
|
+
children = props.children,
|
|
9071
|
+
mask = props.mask,
|
|
9072
|
+
maskPlaceholder = props.maskPlaceholder,
|
|
9073
|
+
beforeMaskedStateChange = props.beforeMaskedStateChange,
|
|
9074
|
+
restProps = _objectWithoutPropertiesLoose(props, _excluded);
|
|
9075
|
+
validateMaxLength(props);
|
|
9076
|
+
validateMaskPlaceholder(props);
|
|
9077
|
+
var maskUtils = new MaskUtils({
|
|
9078
|
+
mask: mask,
|
|
9079
|
+
maskPlaceholder: maskPlaceholder
|
|
9080
|
+
});
|
|
9081
|
+
var isMasked = !!mask;
|
|
9082
|
+
var isEditable = !restProps.disabled && !restProps.readOnly;
|
|
9083
|
+
var isControlled = props.value !== null && props.value !== undefined;
|
|
9084
|
+
var previousIsMasked = usePrevious(isMasked);
|
|
9085
|
+
var initialValue = toString((isControlled ? props.value : props.defaultValue) || "");
|
|
9086
|
+
var _useInputState = useInputState(initialValue, isMasked),
|
|
9087
|
+
inputRef = _useInputState.inputRef,
|
|
9088
|
+
getInputState = _useInputState.getInputState,
|
|
9089
|
+
setInputState = _useInputState.setInputState,
|
|
9090
|
+
getLastInputState = _useInputState.getLastInputState;
|
|
9091
|
+
var getInputElement = useInputElement(inputRef);
|
|
9092
|
+
function onChange(event) {
|
|
9093
|
+
var currentState = getInputState();
|
|
9094
|
+
var previousState = getLastInputState();
|
|
9095
|
+
var newInputState = maskUtils.processChange(currentState, previousState);
|
|
9096
|
+
if (beforeMaskedStateChange) {
|
|
9097
|
+
newInputState = beforeMaskedStateChange({
|
|
9098
|
+
currentState: currentState,
|
|
9099
|
+
previousState: previousState,
|
|
9100
|
+
nextState: newInputState
|
|
9101
|
+
});
|
|
9102
|
+
}
|
|
9103
|
+
setInputState(newInputState);
|
|
9104
|
+
if (props.onChange) {
|
|
9105
|
+
props.onChange(event);
|
|
9106
|
+
}
|
|
9107
|
+
}
|
|
9108
|
+
function onFocus(event) {
|
|
9109
|
+
// If autoFocus property is set, focus event fires before the ref handler gets called
|
|
9110
|
+
inputRef.current = event.target;
|
|
9111
|
+
var currentValue = getInputState().value;
|
|
9112
|
+
if (isMasked && !maskUtils.isValueFilled(currentValue)) {
|
|
9113
|
+
var newValue = maskUtils.formatValue(currentValue);
|
|
9114
|
+
var newSelection = maskUtils.getDefaultSelectionForValue(newValue);
|
|
9115
|
+
var newInputState = {
|
|
9116
|
+
value: newValue,
|
|
9117
|
+
selection: newSelection
|
|
9118
|
+
};
|
|
9119
|
+
if (beforeMaskedStateChange) {
|
|
9120
|
+
newInputState = beforeMaskedStateChange({
|
|
9121
|
+
currentState: getInputState(),
|
|
9122
|
+
nextState: newInputState
|
|
9123
|
+
});
|
|
9124
|
+
newValue = newInputState.value;
|
|
9125
|
+
newSelection = newInputState.selection;
|
|
8914
9126
|
}
|
|
8915
|
-
|
|
8916
|
-
|
|
8917
|
-
|
|
8918
|
-
_this.props.inputRef(ref);
|
|
9127
|
+
setInputState(newInputState);
|
|
9128
|
+
if (newValue !== currentValue && props.onChange) {
|
|
9129
|
+
props.onChange(event);
|
|
8919
9130
|
}
|
|
8920
|
-
|
|
8921
|
-
|
|
8922
|
-
|
|
8923
|
-
|
|
8924
|
-
|
|
8925
|
-
|
|
8926
|
-
|
|
8927
|
-
|
|
8928
|
-
|
|
8929
|
-
|
|
8930
|
-
|
|
8931
|
-
|
|
8932
|
-
|
|
8933
|
-
|
|
8934
|
-
|
|
8935
|
-
|
|
8936
|
-
|
|
8937
|
-
|
|
8938
|
-
|
|
8939
|
-
|
|
8940
|
-
|
|
8941
|
-
oldValue = defaultValue;
|
|
9131
|
+
|
|
9132
|
+
// Chrome resets selection after focus event,
|
|
9133
|
+
// so we want to restore it later
|
|
9134
|
+
defer(function () {
|
|
9135
|
+
setInputState(getLastInputState());
|
|
9136
|
+
});
|
|
9137
|
+
}
|
|
9138
|
+
if (props.onFocus) {
|
|
9139
|
+
props.onFocus(event);
|
|
9140
|
+
}
|
|
9141
|
+
}
|
|
9142
|
+
function onBlur(event) {
|
|
9143
|
+
var currentValue = getInputState().value;
|
|
9144
|
+
var lastValue = getLastInputState().value;
|
|
9145
|
+
if (isMasked && !alwaysShowMask && maskUtils.isValueEmpty(lastValue)) {
|
|
9146
|
+
var newValue = "";
|
|
9147
|
+
var newInputState = {
|
|
9148
|
+
value: newValue,
|
|
9149
|
+
selection: {
|
|
9150
|
+
start: null,
|
|
9151
|
+
end: null
|
|
8942
9152
|
}
|
|
8943
|
-
|
|
8944
|
-
|
|
8945
|
-
|
|
8946
|
-
|
|
8947
|
-
|
|
8948
|
-
|
|
8949
|
-
|
|
8950
|
-
}, null, _this.getBeforeMaskedValueChangeConfig());
|
|
8951
|
-
_newValue = modifiedValue.value;
|
|
9153
|
+
};
|
|
9154
|
+
if (beforeMaskedStateChange) {
|
|
9155
|
+
newInputState = beforeMaskedStateChange({
|
|
9156
|
+
currentState: getInputState(),
|
|
9157
|
+
nextState: newInputState
|
|
9158
|
+
});
|
|
9159
|
+
newValue = newInputState.value;
|
|
8952
9160
|
}
|
|
9161
|
+
setInputState(newInputState);
|
|
9162
|
+
if (newValue !== currentValue && props.onChange) {
|
|
9163
|
+
props.onChange(event);
|
|
9164
|
+
}
|
|
9165
|
+
}
|
|
9166
|
+
if (props.onBlur) {
|
|
9167
|
+
props.onBlur(event);
|
|
8953
9168
|
}
|
|
8954
|
-
_this.value = _newValue;
|
|
8955
|
-
return _this;
|
|
8956
9169
|
}
|
|
8957
|
-
var _proto = InputElement.prototype;
|
|
8958
|
-
_proto.componentDidMount = function componentDidMount() {
|
|
8959
|
-
this.mounted = true; // workaround for react-test-renderer
|
|
8960
|
-
// https://github.com/sanniassin/react-input-mask/issues/147
|
|
8961
9170
|
|
|
8962
|
-
|
|
8963
|
-
|
|
8964
|
-
|
|
8965
|
-
|
|
8966
|
-
|
|
8967
|
-
|
|
8968
|
-
|
|
8969
|
-
};
|
|
8970
|
-
_proto.componentDidUpdate = function componentDidUpdate() {
|
|
8971
|
-
var previousSelection = this.previousSelection;
|
|
8972
|
-
var _this$props = this.props,
|
|
8973
|
-
beforeMaskedValueChange = _this$props.beforeMaskedValueChange,
|
|
8974
|
-
alwaysShowMask = _this$props.alwaysShowMask,
|
|
8975
|
-
mask = _this$props.mask,
|
|
8976
|
-
maskChar = _this$props.maskChar,
|
|
8977
|
-
formatChars = _this$props.formatChars;
|
|
8978
|
-
var previousMaskOptions = this.maskOptions;
|
|
8979
|
-
var showEmpty = alwaysShowMask || this.isFocused();
|
|
8980
|
-
var hasValue = this.props.value != null;
|
|
8981
|
-
var newValue = hasValue ? getStringValue(this.props.value) : this.value;
|
|
8982
|
-
var cursorPosition = previousSelection ? previousSelection.start : null;
|
|
8983
|
-
this.maskOptions = parseMask(mask, maskChar, formatChars);
|
|
8984
|
-
if (!this.maskOptions.mask) {
|
|
8985
|
-
if (previousMaskOptions.mask) {
|
|
8986
|
-
this.stopSaveSelectionLoop(); // render depends on this.maskOptions and this.value,
|
|
8987
|
-
// call forceUpdate to keep it in sync
|
|
8988
|
-
|
|
8989
|
-
this.forceUpdate();
|
|
8990
|
-
}
|
|
9171
|
+
// Tiny unintentional mouse movements can break cursor
|
|
9172
|
+
// position on focus, so we have to restore it in that case
|
|
9173
|
+
//
|
|
9174
|
+
// https://github.com/sanniassin/react-input-mask/issues/108
|
|
9175
|
+
function onMouseDown(event) {
|
|
9176
|
+
var input = getInputElement();
|
|
9177
|
+
if (!input) {
|
|
8991
9178
|
return;
|
|
8992
|
-
} else if (!previousMaskOptions.mask && this.isFocused()) {
|
|
8993
|
-
this.runSaveSelectionLoop();
|
|
8994
9179
|
}
|
|
8995
|
-
var
|
|
8996
|
-
|
|
8997
|
-
|
|
9180
|
+
var _getInputState = getInputState(),
|
|
9181
|
+
value = _getInputState.value;
|
|
9182
|
+
var inputDocument = getElementDocument(input);
|
|
9183
|
+
if (!isInputFocused(input) && !maskUtils.isValueFilled(value)) {
|
|
9184
|
+
var mouseDownX = event.clientX;
|
|
9185
|
+
var mouseDownY = event.clientY;
|
|
9186
|
+
var mouseDownTime = new Date().getTime();
|
|
9187
|
+
var mouseUpHandler = function mouseUpHandler(mouseUpEvent) {
|
|
9188
|
+
inputDocument.removeEventListener("mouseup", mouseUpHandler);
|
|
9189
|
+
if (!isInputFocused(input)) {
|
|
9190
|
+
return;
|
|
9191
|
+
}
|
|
9192
|
+
var deltaX = Math.abs(mouseUpEvent.clientX - mouseDownX);
|
|
9193
|
+
var deltaY = Math.abs(mouseUpEvent.clientY - mouseDownY);
|
|
9194
|
+
var axisDelta = Math.max(deltaX, deltaY);
|
|
9195
|
+
var timeDelta = new Date().getTime() - mouseDownTime;
|
|
9196
|
+
if (axisDelta <= 10 && timeDelta <= 200 || axisDelta <= 5 && timeDelta <= 300) {
|
|
9197
|
+
var _lastState = getLastInputState();
|
|
9198
|
+
var newSelection = maskUtils.getDefaultSelectionForValue(_lastState.value);
|
|
9199
|
+
var newState = _extends({}, _lastState, {
|
|
9200
|
+
selection: newSelection
|
|
9201
|
+
});
|
|
9202
|
+
setInputState(newState);
|
|
9203
|
+
}
|
|
9204
|
+
};
|
|
9205
|
+
inputDocument.addEventListener("mouseup", mouseUpHandler);
|
|
8998
9206
|
}
|
|
8999
|
-
if (
|
|
9000
|
-
|
|
9207
|
+
if (props.onMouseDown) {
|
|
9208
|
+
props.onMouseDown(event);
|
|
9001
9209
|
}
|
|
9002
|
-
|
|
9003
|
-
|
|
9004
|
-
|
|
9005
|
-
|
|
9006
|
-
|
|
9007
|
-
|
|
9008
|
-
|
|
9210
|
+
}
|
|
9211
|
+
|
|
9212
|
+
// For controlled inputs we want to provide properly formatted
|
|
9213
|
+
// value prop
|
|
9214
|
+
if (isMasked && isControlled) {
|
|
9215
|
+
var input = getInputElement();
|
|
9216
|
+
var isFocused = input && isInputFocused(input);
|
|
9217
|
+
var newValue = isFocused || alwaysShowMask || props.value ? maskUtils.formatValue(props.value) : props.value;
|
|
9218
|
+
if (beforeMaskedStateChange) {
|
|
9219
|
+
newValue = beforeMaskedStateChange({
|
|
9220
|
+
nextState: {
|
|
9221
|
+
value: newValue,
|
|
9222
|
+
selection: {
|
|
9223
|
+
start: null,
|
|
9224
|
+
end: null
|
|
9225
|
+
}
|
|
9009
9226
|
}
|
|
9010
|
-
}
|
|
9227
|
+
}).value;
|
|
9011
9228
|
}
|
|
9012
|
-
|
|
9013
|
-
newValue
|
|
9229
|
+
setInputState(_extends({}, getLastInputState(), {
|
|
9230
|
+
value: newValue
|
|
9231
|
+
}));
|
|
9232
|
+
}
|
|
9233
|
+
var lastState = getLastInputState();
|
|
9234
|
+
var lastSelection = lastState.selection;
|
|
9235
|
+
var lastValue = lastState.value;
|
|
9236
|
+
React.useLayoutEffect(function () {
|
|
9237
|
+
if (!isMasked) {
|
|
9238
|
+
return;
|
|
9014
9239
|
}
|
|
9015
|
-
var
|
|
9016
|
-
|
|
9017
|
-
|
|
9018
|
-
};
|
|
9019
|
-
if (isFunction(beforeMaskedValueChange)) {
|
|
9020
|
-
var modifiedValue = beforeMaskedValueChange({
|
|
9021
|
-
value: newValue,
|
|
9022
|
-
selection: newSelection
|
|
9023
|
-
}, {
|
|
9024
|
-
value: this.value,
|
|
9025
|
-
selection: this.previousSelection
|
|
9026
|
-
}, null, this.getBeforeMaskedValueChangeConfig());
|
|
9027
|
-
newValue = modifiedValue.value;
|
|
9028
|
-
newSelection = modifiedValue.selection;
|
|
9029
|
-
}
|
|
9030
|
-
this.value = newValue;
|
|
9031
|
-
var isValueChanged = this.getInputValue() !== this.value; // render depends on this.maskOptions and this.value,
|
|
9032
|
-
// call forceUpdate to keep it in sync
|
|
9033
|
-
|
|
9034
|
-
if (isValueChanged) {
|
|
9035
|
-
this.setInputValue(this.value);
|
|
9036
|
-
this.forceUpdate();
|
|
9037
|
-
} else if (isMaskChanged) {
|
|
9038
|
-
this.forceUpdate();
|
|
9039
|
-
}
|
|
9040
|
-
var isSelectionChanged = false;
|
|
9041
|
-
if (newSelection.start != null && newSelection.end != null) {
|
|
9042
|
-
isSelectionChanged = !previousSelection || previousSelection.start !== newSelection.start || previousSelection.end !== newSelection.end;
|
|
9043
|
-
}
|
|
9044
|
-
if (isSelectionChanged || isValueChanged) {
|
|
9045
|
-
this.setSelection(newSelection.start, newSelection.end);
|
|
9240
|
+
var input = getInputElement();
|
|
9241
|
+
if (!input) {
|
|
9242
|
+
return;
|
|
9046
9243
|
}
|
|
9047
|
-
|
|
9048
|
-
|
|
9049
|
-
|
|
9050
|
-
|
|
9051
|
-
|
|
9244
|
+
var isFocused = isInputFocused(input);
|
|
9245
|
+
var previousSelection = lastSelection;
|
|
9246
|
+
var currentState = getInputState();
|
|
9247
|
+
var newInputState = _extends({}, currentState);
|
|
9248
|
+
|
|
9249
|
+
// Update value for uncontrolled inputs to make sure
|
|
9250
|
+
// it's always in sync with mask props
|
|
9251
|
+
if (!isControlled) {
|
|
9252
|
+
var currentValue = currentState.value;
|
|
9253
|
+
var formattedValue = maskUtils.formatValue(currentValue);
|
|
9254
|
+
var isValueEmpty = maskUtils.isValueEmpty(formattedValue);
|
|
9255
|
+
var shouldFormatValue = !isValueEmpty || isFocused || alwaysShowMask;
|
|
9256
|
+
if (shouldFormatValue) {
|
|
9257
|
+
newInputState.value = formattedValue;
|
|
9258
|
+
} else if (isValueEmpty && !isFocused) {
|
|
9259
|
+
newInputState.value = "";
|
|
9260
|
+
}
|
|
9052
9261
|
}
|
|
9053
|
-
|
|
9054
|
-
|
|
9055
|
-
|
|
9056
|
-
|
|
9057
|
-
|
|
9058
|
-
|
|
9059
|
-
|
|
9060
|
-
|
|
9061
|
-
|
|
9062
|
-
|
|
9063
|
-
|
|
9064
|
-
|
|
9065
|
-
|
|
9066
|
-
process.env.NODE_ENV !== "production" ? warning(
|
|
9067
|
-
// parse mask to test against actual mask prop as this.maskOptions
|
|
9068
|
-
// will be updated later in componentDidUpdate
|
|
9069
|
-
!restProps.maxLength || !parseMask(mask, maskChar, formatChars).mask, 'react-input-mask: maxLength property shouldn\'t be passed to the masked input. It breaks masking and unnecessary because length is limited by the mask length.') : void 0;
|
|
9070
|
-
if (children) {
|
|
9071
|
-
!isFunction(children) ? process.env.NODE_ENV !== "production" ? invariant(false, 'react-input-mask: children must be a function') : invariant(false) : void 0;
|
|
9072
|
-
var controlledProps = ['onChange', 'onPaste', 'onMouseDown', 'onFocus', 'onBlur', 'value', 'disabled', 'readOnly'];
|
|
9073
|
-
var childrenProps = _extends({}, restProps);
|
|
9074
|
-
controlledProps.forEach(function (propId) {
|
|
9075
|
-
return delete childrenProps[propId];
|
|
9076
|
-
});
|
|
9077
|
-
inputElement = children(childrenProps);
|
|
9078
|
-
var conflictProps = controlledProps.filter(function (propId) {
|
|
9079
|
-
return inputElement.props[propId] != null && inputElement.props[propId] !== restProps[propId];
|
|
9262
|
+
if (isFocused && !previousIsMasked) {
|
|
9263
|
+
// Adjust selection if input got masked while being focused
|
|
9264
|
+
newInputState.selection = maskUtils.getDefaultSelectionForValue(newInputState.value);
|
|
9265
|
+
} else if (isControlled && isFocused && previousSelection) {
|
|
9266
|
+
// Restore cursor position if value has changed outside change event
|
|
9267
|
+
if (previousSelection.start !== null && previousSelection.end !== null) {
|
|
9268
|
+
newInputState.selection = previousSelection;
|
|
9269
|
+
}
|
|
9270
|
+
}
|
|
9271
|
+
if (beforeMaskedStateChange) {
|
|
9272
|
+
newInputState = beforeMaskedStateChange({
|
|
9273
|
+
currentState: currentState,
|
|
9274
|
+
nextState: newInputState
|
|
9080
9275
|
});
|
|
9081
|
-
!!conflictProps.length ? process.env.NODE_ENV !== "production" ? invariant(false, "react-input-mask: the following props should be passed to the react-input-mask's component and should not be altered in children's function: " + conflictProps.join(', ')) : invariant(false) : void 0;
|
|
9082
|
-
process.env.NODE_ENV !== "production" ? warning(!inputRef, 'react-input-mask: inputRef is ignored when children is passed, attach ref to the children instead') : void 0;
|
|
9083
|
-
} else {
|
|
9084
|
-
inputElement = React.createElement("input", _extends({
|
|
9085
|
-
ref: this.handleRef
|
|
9086
|
-
}, restProps));
|
|
9087
9276
|
}
|
|
9088
|
-
|
|
9089
|
-
|
|
9090
|
-
|
|
9091
|
-
|
|
9092
|
-
|
|
9093
|
-
|
|
9094
|
-
|
|
9095
|
-
|
|
9096
|
-
|
|
9097
|
-
|
|
9098
|
-
if (restProps.value != null) {
|
|
9099
|
-
changedProps.value = this.value;
|
|
9100
|
-
}
|
|
9277
|
+
setInputState(newInputState);
|
|
9278
|
+
});
|
|
9279
|
+
var refCallback = function refCallback(node) {
|
|
9280
|
+
inputRef.current = node;
|
|
9281
|
+
|
|
9282
|
+
// if a ref callback is passed to InputMask
|
|
9283
|
+
if (isFunction(forwardedRef)) {
|
|
9284
|
+
forwardedRef(node);
|
|
9285
|
+
} else if (forwardedRef !== null && _typeof$1(forwardedRef) === "object") {
|
|
9286
|
+
forwardedRef.current = node;
|
|
9101
9287
|
}
|
|
9102
|
-
inputElement = React.cloneElement(inputElement, changedProps);
|
|
9103
|
-
return inputElement;
|
|
9104
9288
|
};
|
|
9105
|
-
|
|
9106
|
-
|
|
9107
|
-
|
|
9289
|
+
var inputProps = _extends({}, restProps, {
|
|
9290
|
+
onFocus: onFocus,
|
|
9291
|
+
onBlur: onBlur,
|
|
9292
|
+
onChange: isMasked && isEditable ? onChange : props.onChange,
|
|
9293
|
+
onMouseDown: isMasked && isEditable ? onMouseDown : props.onMouseDown,
|
|
9294
|
+
value: isMasked && isControlled ? lastValue : props.value
|
|
9295
|
+
});
|
|
9296
|
+
if (children) {
|
|
9297
|
+
validateChildren(props, children);
|
|
9298
|
+
|
|
9299
|
+
// {@link https://stackoverflow.com/q/63149840/327074}
|
|
9300
|
+
var onlyChild = React.Children.only(children);
|
|
9301
|
+
return /*#__PURE__*/React.cloneElement(onlyChild, _extends({}, inputProps, {
|
|
9302
|
+
ref: refCallback
|
|
9303
|
+
}));
|
|
9304
|
+
}
|
|
9305
|
+
return /*#__PURE__*/React.createElement("input", _extends({
|
|
9306
|
+
ref: refCallback
|
|
9307
|
+
}, inputProps));
|
|
9308
|
+
});
|
|
9309
|
+
InputMask.displayName = "InputMask";
|
|
9310
|
+
InputMask.defaultProps = {
|
|
9311
|
+
alwaysShowMask: false,
|
|
9312
|
+
maskPlaceholder: "_"
|
|
9313
|
+
};
|
|
9314
|
+
InputMask.propTypes = {
|
|
9315
|
+
alwaysShowMask: PropTypes.bool,
|
|
9316
|
+
beforeMaskedStateChange: PropTypes.func,
|
|
9317
|
+
children: PropTypes.element,
|
|
9318
|
+
mask: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.instanceOf(RegExp)]))]),
|
|
9319
|
+
maskPlaceholder: PropTypes.string,
|
|
9320
|
+
onFocus: PropTypes.func,
|
|
9321
|
+
onBlur: PropTypes.func,
|
|
9322
|
+
onChange: PropTypes.func,
|
|
9323
|
+
onMouseDown: PropTypes.func
|
|
9324
|
+
};
|
|
9325
|
+
reactInputMask_development = InputMask;
|
|
9108
9326
|
return reactInputMask_development;
|
|
9109
9327
|
}
|
|
9110
9328
|
|
|
9329
|
+
/* eslint-disable import/no-unresolved */
|
|
9111
9330
|
var hasRequiredReactInputMask;
|
|
9112
9331
|
function requireReactInputMask() {
|
|
9113
9332
|
if (hasRequiredReactInputMask) return reactInputMask.exports;
|
|
9114
9333
|
hasRequiredReactInputMask = 1;
|
|
9115
|
-
if (process.env.NODE_ENV ===
|
|
9334
|
+
if (process.env.NODE_ENV === "production") {
|
|
9116
9335
|
reactInputMask.exports = requireReactInputMask_production_min();
|
|
9117
9336
|
} else {
|
|
9118
9337
|
reactInputMask.exports = requireReactInputMask_development();
|
|
@@ -10122,7 +10341,7 @@ var t = function t(_t) {
|
|
|
10122
10341
|
return !!e && (e.clientHeight < t.scrollHeight || e.clientWidth < t.scrollWidth);
|
|
10123
10342
|
}(t);
|
|
10124
10343
|
}
|
|
10125
|
-
return
|
|
10344
|
+
return false;
|
|
10126
10345
|
},
|
|
10127
10346
|
o$1 = function o(t, e, n, _o2, l, r, i, s) {
|
|
10128
10347
|
return r < t && i > e || r > t && i < e ? 0 : r <= t && s <= n || i >= e && s >= n ? r - t - _o2 : i > e && s < n || r < t && s > n ? i - e + l : 0;
|
|
@@ -10184,41 +10403,41 @@ var t = function t(_t) {
|
|
|
10184
10403
|
for (var _t2 = 0; _t2 < w.length; _t2++) {
|
|
10185
10404
|
var _e2 = w[_t2],
|
|
10186
10405
|
_e$getBoundingClientR2 = _e2.getBoundingClientRect(),
|
|
10187
|
-
|
|
10188
|
-
|
|
10189
|
-
|
|
10190
|
-
|
|
10191
|
-
|
|
10192
|
-
|
|
10193
|
-
if ("if-needed" === c && x >= 0 && R >= 0 && I <= H && C <= b && x >=
|
|
10194
|
-
var
|
|
10195
|
-
|
|
10196
|
-
|
|
10197
|
-
|
|
10198
|
-
|
|
10199
|
-
var
|
|
10200
|
-
|
|
10201
|
-
var
|
|
10202
|
-
|
|
10203
|
-
|
|
10204
|
-
|
|
10205
|
-
if (m === _e2)
|
|
10206
|
-
|
|
10406
|
+
_l = _e$getBoundingClientR2.height,
|
|
10407
|
+
_r = _e$getBoundingClientR2.width,
|
|
10408
|
+
_i = _e$getBoundingClientR2.top,
|
|
10409
|
+
_s = _e$getBoundingClientR2.right,
|
|
10410
|
+
_d = _e$getBoundingClientR2.bottom,
|
|
10411
|
+
_h = _e$getBoundingClientR2.left;
|
|
10412
|
+
if ("if-needed" === c && x >= 0 && R >= 0 && I <= H && C <= b && (_e2 === m && !n(_e2) || x >= _i && I <= _d && R >= _h && C <= _s)) return L;
|
|
10413
|
+
var _a = getComputedStyle(_e2),
|
|
10414
|
+
_g = parseInt(_a.borderLeftWidth, 10),
|
|
10415
|
+
_p = parseInt(_a.borderTopWidth, 10),
|
|
10416
|
+
_W = parseInt(_a.borderRightWidth, 10),
|
|
10417
|
+
_T = parseInt(_a.borderBottomWidth, 10);
|
|
10418
|
+
var _B = 0,
|
|
10419
|
+
_F = 0;
|
|
10420
|
+
var _V = "offsetWidth" in _e2 ? _e2.offsetWidth - _e2.clientWidth - _g - _W : 0,
|
|
10421
|
+
S = "offsetHeight" in _e2 ? _e2.offsetHeight - _e2.clientHeight - _p - _T : 0,
|
|
10422
|
+
X = "offsetWidth" in _e2 ? 0 === _e2.offsetWidth ? 0 : _r / _e2.offsetWidth : 0,
|
|
10423
|
+
Y = "offsetHeight" in _e2 ? 0 === _e2.offsetHeight ? 0 : _l / _e2.offsetHeight : 0;
|
|
10424
|
+
if (m === _e2) _B = "start" === f ? k : "end" === f ? k - H : "nearest" === f ? o$1(M, M + H, H, _p, _T, M + k, M + k + v, v) : k - H / 2, _F = "start" === u ? D : "center" === u ? D - b / 2 : "end" === u ? D - b : o$1(y, y + b, b, _g, _W, y + D, y + D + E, E), _B = Math.max(0, _B + M), _F = Math.max(0, _F + y);else {
|
|
10425
|
+
_B = "start" === f ? k - _i - _p : "end" === f ? k - _d + _T + S : "nearest" === f ? o$1(_i, _d, _l, _p, _T + S, k, k + v, v) : k - (_i + _l / 2) + S / 2, _F = "start" === u ? D - _h - _g : "center" === u ? D - (_h + _r / 2) + _V / 2 : "end" === u ? D - _s + _W + _V : o$1(_h, _s, _r, _g, _W + _V, D, D + E, E);
|
|
10207
10426
|
var _t3 = _e2.scrollLeft,
|
|
10208
|
-
|
|
10209
|
-
|
|
10427
|
+
_n2 = _e2.scrollTop;
|
|
10428
|
+
_B = 0 === Y ? 0 : Math.max(0, Math.min(_n2 + _B / Y, _e2.scrollHeight - _l / Y + S)), _F = 0 === X ? 0 : Math.max(0, Math.min(_t3 + _F / X, _e2.scrollWidth - _r / X + _V)), k += _n2 - _B, D += _t3 - _F;
|
|
10210
10429
|
}
|
|
10211
10430
|
L.push({
|
|
10212
10431
|
el: _e2,
|
|
10213
|
-
top:
|
|
10214
|
-
left:
|
|
10432
|
+
top: _B,
|
|
10433
|
+
left: _F
|
|
10215
10434
|
});
|
|
10216
10435
|
}
|
|
10217
10436
|
return L;
|
|
10218
10437
|
};
|
|
10219
10438
|
|
|
10220
10439
|
var o = function o(t) {
|
|
10221
|
-
return
|
|
10440
|
+
return false === t ? {
|
|
10222
10441
|
block: "end",
|
|
10223
10442
|
inline: "nearest"
|
|
10224
10443
|
} : function (t) {
|
|
@@ -10232,10 +10451,10 @@ function e(e, r$1) {
|
|
|
10232
10451
|
if (!e.isConnected || !function (t) {
|
|
10233
10452
|
var o = t;
|
|
10234
10453
|
for (; o && o.parentNode;) {
|
|
10235
|
-
if (o.parentNode === document) return
|
|
10454
|
+
if (o.parentNode === document) return true;
|
|
10236
10455
|
o = o.parentNode instanceof ShadowRoot ? o.parentNode.host : o.parentNode;
|
|
10237
10456
|
}
|
|
10238
|
-
return
|
|
10457
|
+
return false;
|
|
10239
10458
|
}(e)) return;
|
|
10240
10459
|
var n = function (t) {
|
|
10241
10460
|
var o = window.getComputedStyle(t);
|
|
@@ -10880,15 +11099,9 @@ var CreditCardNumberInput = function CreditCardNumberInput(_ref) {
|
|
|
10880
11099
|
setValue(event.target.value);
|
|
10881
11100
|
onChange === null || onChange === void 0 || onChange(event.target.value);
|
|
10882
11101
|
}, [setValue, onChange]);
|
|
10883
|
-
|
|
10884
|
-
// TODO: get rid of the any, the types of react-input-mask are incorrect here, it should expect a function as a child, but it expects a ReactNode
|
|
10885
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10886
|
-
var renderInputField = function renderInputField(inputProps) {
|
|
10887
|
-
return /*#__PURE__*/React__default.createElement(CreditCardNumberInputField, _extends$1({}, rest, inputProps));
|
|
10888
|
-
};
|
|
10889
11102
|
return /*#__PURE__*/React__default.createElement(InputMask, {
|
|
10890
11103
|
mask: mask,
|
|
10891
|
-
|
|
11104
|
+
maskPlaceholder: maskChar,
|
|
10892
11105
|
alwaysShowMask: alwaysShowMask,
|
|
10893
11106
|
disabled: disabled,
|
|
10894
11107
|
readOnly: readOnly,
|
|
@@ -10897,7 +11110,7 @@ var CreditCardNumberInput = function CreditCardNumberInput(_ref) {
|
|
|
10897
11110
|
onMouseDown: onMouseDown,
|
|
10898
11111
|
onFocus: onFocus,
|
|
10899
11112
|
onBlur: onBlur
|
|
10900
|
-
},
|
|
11113
|
+
}, /*#__PURE__*/React__default.createElement(CreditCardNumberInputField, rest));
|
|
10901
11114
|
};
|
|
10902
11115
|
|
|
10903
11116
|
var _excluded$e = ["term", "children", "className"];
|
|
@@ -11737,11 +11950,6 @@ var LoadingShapesLavenderBlue = function LoadingShapesLavenderBlue() {
|
|
|
11737
11950
|
}));
|
|
11738
11951
|
};
|
|
11739
11952
|
|
|
11740
|
-
var preventNavigation = function preventNavigation(event) {
|
|
11741
|
-
event.preventDefault();
|
|
11742
|
-
event.returnValue = '';
|
|
11743
|
-
};
|
|
11744
|
-
|
|
11745
11953
|
var usePreventNavigation = function usePreventNavigation() {
|
|
11746
11954
|
var enabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
11747
11955
|
useEffect(function () {
|
|
@@ -11756,11 +11964,14 @@ var usePreventNavigation = function usePreventNavigation() {
|
|
|
11756
11964
|
|
|
11757
11965
|
var NavigationPreventer = function NavigationPreventer(_ref) {
|
|
11758
11966
|
var _ref$enabled = _ref.enabled,
|
|
11759
|
-
enabled = _ref$enabled === void 0 ? false : _ref$enabled
|
|
11967
|
+
enabled = _ref$enabled === void 0 ? false : _ref$enabled,
|
|
11968
|
+
_ref$message = _ref.message,
|
|
11969
|
+
message = _ref$message === void 0 ? 'Changes that you made may not be saved.' : _ref$message;
|
|
11760
11970
|
usePreventNavigation(enabled);
|
|
11761
|
-
|
|
11762
|
-
|
|
11763
|
-
|
|
11971
|
+
return /*#__PURE__*/React__default.createElement(Prompt, {
|
|
11972
|
+
when: enabled,
|
|
11973
|
+
message: message
|
|
11974
|
+
});
|
|
11764
11975
|
};
|
|
11765
11976
|
|
|
11766
11977
|
var __assign$1 = undefined && undefined.__assign || function () {
|