@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.cjs.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var React = require('react');
|
|
4
|
-
var
|
|
5
|
-
var
|
|
4
|
+
var reactRouterDom = require('react-router-dom');
|
|
5
|
+
var reactDom = require('react-dom');
|
|
6
6
|
|
|
7
7
|
function _interopNamespaceDefault(e) {
|
|
8
8
|
var n = Object.create(null);
|
|
@@ -27,6 +27,329 @@ function getDefaultExportFromCjs (x) {
|
|
|
27
27
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
function getAugmentedNamespace(n) {
|
|
31
|
+
if (Object.prototype.hasOwnProperty.call(n, '__esModule')) return n;
|
|
32
|
+
var f = n.default;
|
|
33
|
+
if (typeof f == "function") {
|
|
34
|
+
var a = function a () {
|
|
35
|
+
if (this instanceof a) {
|
|
36
|
+
return Reflect.construct(f, arguments, this.constructor);
|
|
37
|
+
}
|
|
38
|
+
return f.apply(this, arguments);
|
|
39
|
+
};
|
|
40
|
+
a.prototype = f.prototype;
|
|
41
|
+
} else a = {};
|
|
42
|
+
Object.defineProperty(a, '__esModule', {value: true});
|
|
43
|
+
Object.keys(n).forEach(function (k) {
|
|
44
|
+
var d = Object.getOwnPropertyDescriptor(n, k);
|
|
45
|
+
Object.defineProperty(a, k, d.get ? d : {
|
|
46
|
+
enumerable: true,
|
|
47
|
+
get: function () {
|
|
48
|
+
return n[k];
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
return a;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
var focusVisible$1 = {exports: {}};
|
|
56
|
+
|
|
57
|
+
var focusVisible = focusVisible$1.exports;
|
|
58
|
+
var hasRequiredFocusVisible;
|
|
59
|
+
function requireFocusVisible() {
|
|
60
|
+
if (hasRequiredFocusVisible) return focusVisible$1.exports;
|
|
61
|
+
hasRequiredFocusVisible = 1;
|
|
62
|
+
(function (module, exports) {
|
|
63
|
+
(function (global, factory) {
|
|
64
|
+
factory() ;
|
|
65
|
+
})(focusVisible, function () {
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Applies the :focus-visible polyfill at the given scope.
|
|
69
|
+
* A scope in this case is either the top-level Document or a Shadow Root.
|
|
70
|
+
*
|
|
71
|
+
* @param {(Document|ShadowRoot)} scope
|
|
72
|
+
* @see https://github.com/WICG/focus-visible
|
|
73
|
+
*/
|
|
74
|
+
function applyFocusVisiblePolyfill(scope) {
|
|
75
|
+
var hadKeyboardEvent = true;
|
|
76
|
+
var hadFocusVisibleRecently = false;
|
|
77
|
+
var hadFocusVisibleRecentlyTimeout = null;
|
|
78
|
+
var inputTypesAllowlist = {
|
|
79
|
+
text: true,
|
|
80
|
+
search: true,
|
|
81
|
+
url: true,
|
|
82
|
+
tel: true,
|
|
83
|
+
email: true,
|
|
84
|
+
password: true,
|
|
85
|
+
number: true,
|
|
86
|
+
date: true,
|
|
87
|
+
month: true,
|
|
88
|
+
week: true,
|
|
89
|
+
time: true,
|
|
90
|
+
datetime: true,
|
|
91
|
+
'datetime-local': true
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Helper function for legacy browsers and iframes which sometimes focus
|
|
96
|
+
* elements like document, body, and non-interactive SVG.
|
|
97
|
+
* @param {Element} el
|
|
98
|
+
*/
|
|
99
|
+
function isValidFocusTarget(el) {
|
|
100
|
+
if (el && el !== document && el.nodeName !== 'HTML' && el.nodeName !== 'BODY' && 'classList' in el && 'contains' in el.classList) {
|
|
101
|
+
return true;
|
|
102
|
+
}
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Computes whether the given element should automatically trigger the
|
|
108
|
+
* `focus-visible` class being added, i.e. whether it should always match
|
|
109
|
+
* `:focus-visible` when focused.
|
|
110
|
+
* @param {Element} el
|
|
111
|
+
* @return {boolean}
|
|
112
|
+
*/
|
|
113
|
+
function focusTriggersKeyboardModality(el) {
|
|
114
|
+
var type = el.type;
|
|
115
|
+
var tagName = el.tagName;
|
|
116
|
+
if (tagName === 'INPUT' && inputTypesAllowlist[type] && !el.readOnly) {
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
if (tagName === 'TEXTAREA' && !el.readOnly) {
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
if (el.isContentEditable) {
|
|
123
|
+
return true;
|
|
124
|
+
}
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Add the `focus-visible` class to the given element if it was not added by
|
|
130
|
+
* the author.
|
|
131
|
+
* @param {Element} el
|
|
132
|
+
*/
|
|
133
|
+
function addFocusVisibleClass(el) {
|
|
134
|
+
if (el.classList.contains('focus-visible')) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
el.classList.add('focus-visible');
|
|
138
|
+
el.setAttribute('data-focus-visible-added', '');
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Remove the `focus-visible` class from the given element if it was not
|
|
143
|
+
* originally added by the author.
|
|
144
|
+
* @param {Element} el
|
|
145
|
+
*/
|
|
146
|
+
function removeFocusVisibleClass(el) {
|
|
147
|
+
if (!el.hasAttribute('data-focus-visible-added')) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
el.classList.remove('focus-visible');
|
|
151
|
+
el.removeAttribute('data-focus-visible-added');
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* If the most recent user interaction was via the keyboard;
|
|
156
|
+
* and the key press did not include a meta, alt/option, or control key;
|
|
157
|
+
* then the modality is keyboard. Otherwise, the modality is not keyboard.
|
|
158
|
+
* Apply `focus-visible` to any current active element and keep track
|
|
159
|
+
* of our keyboard modality state with `hadKeyboardEvent`.
|
|
160
|
+
* @param {KeyboardEvent} e
|
|
161
|
+
*/
|
|
162
|
+
function onKeyDown(e) {
|
|
163
|
+
if (e.metaKey || e.altKey || e.ctrlKey) {
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
if (isValidFocusTarget(scope.activeElement)) {
|
|
167
|
+
addFocusVisibleClass(scope.activeElement);
|
|
168
|
+
}
|
|
169
|
+
hadKeyboardEvent = true;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* If at any point a user clicks with a pointing device, ensure that we change
|
|
174
|
+
* the modality away from keyboard.
|
|
175
|
+
* This avoids the situation where a user presses a key on an already focused
|
|
176
|
+
* element, and then clicks on a different element, focusing it with a
|
|
177
|
+
* pointing device, while we still think we're in keyboard modality.
|
|
178
|
+
* @param {Event} e
|
|
179
|
+
*/
|
|
180
|
+
function onPointerDown(e) {
|
|
181
|
+
hadKeyboardEvent = false;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* On `focus`, add the `focus-visible` class to the target if:
|
|
186
|
+
* - the target received focus as a result of keyboard navigation, or
|
|
187
|
+
* - the event target is an element that will likely require interaction
|
|
188
|
+
* via the keyboard (e.g. a text box)
|
|
189
|
+
* @param {Event} e
|
|
190
|
+
*/
|
|
191
|
+
function onFocus(e) {
|
|
192
|
+
// Prevent IE from focusing the document or HTML element.
|
|
193
|
+
if (!isValidFocusTarget(e.target)) {
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
if (hadKeyboardEvent || focusTriggersKeyboardModality(e.target)) {
|
|
197
|
+
addFocusVisibleClass(e.target);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* On `blur`, remove the `focus-visible` class from the target.
|
|
203
|
+
* @param {Event} e
|
|
204
|
+
*/
|
|
205
|
+
function onBlur(e) {
|
|
206
|
+
if (!isValidFocusTarget(e.target)) {
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
if (e.target.classList.contains('focus-visible') || e.target.hasAttribute('data-focus-visible-added')) {
|
|
210
|
+
// To detect a tab/window switch, we look for a blur event followed
|
|
211
|
+
// rapidly by a visibility change.
|
|
212
|
+
// If we don't see a visibility change within 100ms, it's probably a
|
|
213
|
+
// regular focus change.
|
|
214
|
+
hadFocusVisibleRecently = true;
|
|
215
|
+
window.clearTimeout(hadFocusVisibleRecentlyTimeout);
|
|
216
|
+
hadFocusVisibleRecentlyTimeout = window.setTimeout(function () {
|
|
217
|
+
hadFocusVisibleRecently = false;
|
|
218
|
+
}, 100);
|
|
219
|
+
removeFocusVisibleClass(e.target);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* If the user changes tabs, keep track of whether or not the previously
|
|
225
|
+
* focused element had .focus-visible.
|
|
226
|
+
* @param {Event} e
|
|
227
|
+
*/
|
|
228
|
+
function onVisibilityChange(e) {
|
|
229
|
+
if (document.visibilityState === 'hidden') {
|
|
230
|
+
// If the tab becomes active again, the browser will handle calling focus
|
|
231
|
+
// on the element (Safari actually calls it twice).
|
|
232
|
+
// If this tab change caused a blur on an element with focus-visible,
|
|
233
|
+
// re-apply the class when the user switches back to the tab.
|
|
234
|
+
if (hadFocusVisibleRecently) {
|
|
235
|
+
hadKeyboardEvent = true;
|
|
236
|
+
}
|
|
237
|
+
addInitialPointerMoveListeners();
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Add a group of listeners to detect usage of any pointing devices.
|
|
243
|
+
* These listeners will be added when the polyfill first loads, and anytime
|
|
244
|
+
* the window is blurred, so that they are active when the window regains
|
|
245
|
+
* focus.
|
|
246
|
+
*/
|
|
247
|
+
function addInitialPointerMoveListeners() {
|
|
248
|
+
document.addEventListener('mousemove', onInitialPointerMove);
|
|
249
|
+
document.addEventListener('mousedown', onInitialPointerMove);
|
|
250
|
+
document.addEventListener('mouseup', onInitialPointerMove);
|
|
251
|
+
document.addEventListener('pointermove', onInitialPointerMove);
|
|
252
|
+
document.addEventListener('pointerdown', onInitialPointerMove);
|
|
253
|
+
document.addEventListener('pointerup', onInitialPointerMove);
|
|
254
|
+
document.addEventListener('touchmove', onInitialPointerMove);
|
|
255
|
+
document.addEventListener('touchstart', onInitialPointerMove);
|
|
256
|
+
document.addEventListener('touchend', onInitialPointerMove);
|
|
257
|
+
}
|
|
258
|
+
function removeInitialPointerMoveListeners() {
|
|
259
|
+
document.removeEventListener('mousemove', onInitialPointerMove);
|
|
260
|
+
document.removeEventListener('mousedown', onInitialPointerMove);
|
|
261
|
+
document.removeEventListener('mouseup', onInitialPointerMove);
|
|
262
|
+
document.removeEventListener('pointermove', onInitialPointerMove);
|
|
263
|
+
document.removeEventListener('pointerdown', onInitialPointerMove);
|
|
264
|
+
document.removeEventListener('pointerup', onInitialPointerMove);
|
|
265
|
+
document.removeEventListener('touchmove', onInitialPointerMove);
|
|
266
|
+
document.removeEventListener('touchstart', onInitialPointerMove);
|
|
267
|
+
document.removeEventListener('touchend', onInitialPointerMove);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* When the polfyill first loads, assume the user is in keyboard modality.
|
|
272
|
+
* If any event is received from a pointing device (e.g. mouse, pointer,
|
|
273
|
+
* touch), turn off keyboard modality.
|
|
274
|
+
* This accounts for situations where focus enters the page from the URL bar.
|
|
275
|
+
* @param {Event} e
|
|
276
|
+
*/
|
|
277
|
+
function onInitialPointerMove(e) {
|
|
278
|
+
// Work around a Safari quirk that fires a mousemove on <html> whenever the
|
|
279
|
+
// window blurs, even if you're tabbing out of the page. ¯\_(ツ)_/¯
|
|
280
|
+
if (e.target.nodeName && e.target.nodeName.toLowerCase() === 'html') {
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
hadKeyboardEvent = false;
|
|
284
|
+
removeInitialPointerMoveListeners();
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// For some kinds of state, we are interested in changes at the global scope
|
|
288
|
+
// only. For example, global pointer input, global key presses and global
|
|
289
|
+
// visibility change should affect the state at every scope:
|
|
290
|
+
document.addEventListener('keydown', onKeyDown, true);
|
|
291
|
+
document.addEventListener('mousedown', onPointerDown, true);
|
|
292
|
+
document.addEventListener('pointerdown', onPointerDown, true);
|
|
293
|
+
document.addEventListener('touchstart', onPointerDown, true);
|
|
294
|
+
document.addEventListener('visibilitychange', onVisibilityChange, true);
|
|
295
|
+
addInitialPointerMoveListeners();
|
|
296
|
+
|
|
297
|
+
// For focus and blur, we specifically care about state changes in the local
|
|
298
|
+
// scope. This is because focus / blur events that originate from within a
|
|
299
|
+
// shadow root are not re-dispatched from the host element if it was already
|
|
300
|
+
// the active element in its own scope:
|
|
301
|
+
scope.addEventListener('focus', onFocus, true);
|
|
302
|
+
scope.addEventListener('blur', onBlur, true);
|
|
303
|
+
|
|
304
|
+
// We detect that a node is a ShadowRoot by ensuring that it is a
|
|
305
|
+
// DocumentFragment and also has a host property. This check covers native
|
|
306
|
+
// implementation and polyfill implementation transparently. If we only cared
|
|
307
|
+
// about the native implementation, we could just check if the scope was
|
|
308
|
+
// an instance of a ShadowRoot.
|
|
309
|
+
if (scope.nodeType === Node.DOCUMENT_FRAGMENT_NODE && scope.host) {
|
|
310
|
+
// Since a ShadowRoot is a special kind of DocumentFragment, it does not
|
|
311
|
+
// have a root element to add a class to. So, we add this attribute to the
|
|
312
|
+
// host element instead:
|
|
313
|
+
scope.host.setAttribute('data-js-focus-visible', '');
|
|
314
|
+
} else if (scope.nodeType === Node.DOCUMENT_NODE) {
|
|
315
|
+
document.documentElement.classList.add('js-focus-visible');
|
|
316
|
+
document.documentElement.setAttribute('data-js-focus-visible', '');
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
// It is important to wrap all references to global window and document in
|
|
321
|
+
// these checks to support server-side rendering use cases
|
|
322
|
+
// @see https://github.com/WICG/focus-visible/issues/199
|
|
323
|
+
if (typeof window !== 'undefined' && typeof document !== 'undefined') {
|
|
324
|
+
// Make the polyfill helper globally available. This can be used as a signal
|
|
325
|
+
// to interested libraries that wish to coordinate with the polyfill for e.g.,
|
|
326
|
+
// applying the polyfill to a shadow root:
|
|
327
|
+
window.applyFocusVisiblePolyfill = applyFocusVisiblePolyfill;
|
|
328
|
+
|
|
329
|
+
// Notify interested libraries of the polyfill's presence, in case the
|
|
330
|
+
// polyfill was loaded lazily:
|
|
331
|
+
var event;
|
|
332
|
+
try {
|
|
333
|
+
event = new CustomEvent('focus-visible-polyfill-ready');
|
|
334
|
+
} catch (error) {
|
|
335
|
+
// IE11 does not support using CustomEvent as a constructor directly:
|
|
336
|
+
event = document.createEvent('CustomEvent');
|
|
337
|
+
event.initCustomEvent('focus-visible-polyfill-ready', false, false, {});
|
|
338
|
+
}
|
|
339
|
+
window.dispatchEvent(event);
|
|
340
|
+
}
|
|
341
|
+
if (typeof document !== 'undefined') {
|
|
342
|
+
// Apply the polyfill to the global document, so that no JavaScript
|
|
343
|
+
// coordination is required to use the polyfill in the top-level document:
|
|
344
|
+
applyFocusVisiblePolyfill(document);
|
|
345
|
+
}
|
|
346
|
+
});
|
|
347
|
+
})();
|
|
348
|
+
return focusVisible$1.exports;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
requireFocusVisible();
|
|
352
|
+
|
|
30
353
|
var dist$4 = {};
|
|
31
354
|
|
|
32
355
|
var colors = {};
|
|
@@ -57,6 +380,10 @@ function requireColors() {
|
|
|
57
380
|
"dark-fuchsia": "rgb(180, 60, 160)",
|
|
58
381
|
"teal": "rgb(0, 111, 98)",
|
|
59
382
|
"ivory": "rgb(242, 233, 219)",
|
|
383
|
+
"chatelle": "rgb(213, 194, 216)",
|
|
384
|
+
"edgewater": "rgb(198, 225, 209)",
|
|
385
|
+
"waikawa-gray": "rgb(86, 107, 136)",
|
|
386
|
+
"tuscany": "rgb(186, 83, 44)",
|
|
60
387
|
"klein-blue": "rgb(38, 48, 120)",
|
|
61
388
|
"persian-blue": "rgb(30, 34, 170)",
|
|
62
389
|
"brick": "rgb(147, 58, 32)",
|
|
@@ -80,7 +407,11 @@ function requireColors() {
|
|
|
80
407
|
"fuchsia": "rgb(196, 76, 176)",
|
|
81
408
|
"dark-fuchsia": "rgb(180, 60, 160)",
|
|
82
409
|
"teal": "rgb(0, 111, 98)",
|
|
83
|
-
"ivory": "rgb(242, 233, 219)"
|
|
410
|
+
"ivory": "rgb(242, 233, 219)",
|
|
411
|
+
"chatelle": "rgb(213, 194, 216)",
|
|
412
|
+
"edgewater": "rgb(198, 225, 209)",
|
|
413
|
+
"waikawa-gray": "rgb(86, 107, 136)",
|
|
414
|
+
"tuscany": "rgb(186, 83, 44)"
|
|
84
415
|
},
|
|
85
416
|
"global": {
|
|
86
417
|
"klein-blue": "rgb(38, 48, 120)",
|
|
@@ -257,407 +588,347 @@ function requireBreakpoints() {
|
|
|
257
588
|
|
|
258
589
|
var helpers = {};
|
|
259
590
|
|
|
260
|
-
var
|
|
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
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
return obj instanceof Array || Array.isArray(obj) || obj.length >= 0 && (obj.splice instanceof Function || Object.getOwnPropertyDescriptor(obj, obj.length - 1) && obj.constructor.name !== 'String');
|
|
432
|
-
};
|
|
433
|
-
return isArrayish;
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
var hasRequiredSimpleSwizzle;
|
|
437
|
-
function requireSimpleSwizzle() {
|
|
438
|
-
if (hasRequiredSimpleSwizzle) return simpleSwizzle.exports;
|
|
439
|
-
hasRequiredSimpleSwizzle = 1;
|
|
440
|
-
var isArrayish = requireIsArrayish();
|
|
441
|
-
var concat = Array.prototype.concat;
|
|
442
|
-
var slice = Array.prototype.slice;
|
|
443
|
-
var swizzle = simpleSwizzle.exports = function swizzle(args) {
|
|
444
|
-
var results = [];
|
|
445
|
-
for (var i = 0, len = args.length; i < len; i++) {
|
|
446
|
-
var arg = args[i];
|
|
447
|
-
if (isArrayish(arg)) {
|
|
448
|
-
// http://jsperf.com/javascript-array-concat-vs-push/98
|
|
449
|
-
results = concat.call(results, slice.call(arg));
|
|
450
|
-
} else {
|
|
451
|
-
results.push(arg);
|
|
452
|
-
}
|
|
453
|
-
}
|
|
454
|
-
return results;
|
|
455
|
-
};
|
|
456
|
-
swizzle.wrap = function (fn) {
|
|
457
|
-
return function () {
|
|
458
|
-
return fn(swizzle(arguments));
|
|
459
|
-
};
|
|
460
|
-
};
|
|
461
|
-
return simpleSwizzle.exports;
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
/* MIT license */
|
|
465
|
-
var hasRequiredColorString;
|
|
466
|
-
function requireColorString() {
|
|
467
|
-
if (hasRequiredColorString) return colorString.exports;
|
|
468
|
-
hasRequiredColorString = 1;
|
|
469
|
-
var colorNames = requireColorName();
|
|
470
|
-
var swizzle = requireSimpleSwizzle();
|
|
471
|
-
var hasOwnProperty = Object.hasOwnProperty;
|
|
472
|
-
var reverseNames = Object.create(null);
|
|
473
|
-
|
|
474
|
-
// create a list of reverse color names
|
|
475
|
-
for (var name in colorNames) {
|
|
476
|
-
if (hasOwnProperty.call(colorNames, name)) {
|
|
477
|
-
reverseNames[colorNames[name]] = name;
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
var cs = colorString.exports = {
|
|
481
|
-
to: {},
|
|
482
|
-
get: {}
|
|
483
|
-
};
|
|
484
|
-
cs.get = function (string) {
|
|
485
|
-
var prefix = string.substring(0, 3).toLowerCase();
|
|
486
|
-
var val;
|
|
487
|
-
var model;
|
|
488
|
-
switch (prefix) {
|
|
489
|
-
case 'hsl':
|
|
490
|
-
val = cs.get.hsl(string);
|
|
591
|
+
var colorNames = {
|
|
592
|
+
aliceblue: [240, 248, 255],
|
|
593
|
+
antiquewhite: [250, 235, 215],
|
|
594
|
+
aqua: [0, 255, 255],
|
|
595
|
+
aquamarine: [127, 255, 212],
|
|
596
|
+
azure: [240, 255, 255],
|
|
597
|
+
beige: [245, 245, 220],
|
|
598
|
+
bisque: [255, 228, 196],
|
|
599
|
+
black: [0, 0, 0],
|
|
600
|
+
blanchedalmond: [255, 235, 205],
|
|
601
|
+
blue: [0, 0, 255],
|
|
602
|
+
blueviolet: [138, 43, 226],
|
|
603
|
+
brown: [165, 42, 42],
|
|
604
|
+
burlywood: [222, 184, 135],
|
|
605
|
+
cadetblue: [95, 158, 160],
|
|
606
|
+
chartreuse: [127, 255, 0],
|
|
607
|
+
chocolate: [210, 105, 30],
|
|
608
|
+
coral: [255, 127, 80],
|
|
609
|
+
cornflowerblue: [100, 149, 237],
|
|
610
|
+
cornsilk: [255, 248, 220],
|
|
611
|
+
crimson: [220, 20, 60],
|
|
612
|
+
cyan: [0, 255, 255],
|
|
613
|
+
darkblue: [0, 0, 139],
|
|
614
|
+
darkcyan: [0, 139, 139],
|
|
615
|
+
darkgoldenrod: [184, 134, 11],
|
|
616
|
+
darkgray: [169, 169, 169],
|
|
617
|
+
darkgreen: [0, 100, 0],
|
|
618
|
+
darkgrey: [169, 169, 169],
|
|
619
|
+
darkkhaki: [189, 183, 107],
|
|
620
|
+
darkmagenta: [139, 0, 139],
|
|
621
|
+
darkolivegreen: [85, 107, 47],
|
|
622
|
+
darkorange: [255, 140, 0],
|
|
623
|
+
darkorchid: [153, 50, 204],
|
|
624
|
+
darkred: [139, 0, 0],
|
|
625
|
+
darksalmon: [233, 150, 122],
|
|
626
|
+
darkseagreen: [143, 188, 143],
|
|
627
|
+
darkslateblue: [72, 61, 139],
|
|
628
|
+
darkslategray: [47, 79, 79],
|
|
629
|
+
darkslategrey: [47, 79, 79],
|
|
630
|
+
darkturquoise: [0, 206, 209],
|
|
631
|
+
darkviolet: [148, 0, 211],
|
|
632
|
+
deeppink: [255, 20, 147],
|
|
633
|
+
deepskyblue: [0, 191, 255],
|
|
634
|
+
dimgray: [105, 105, 105],
|
|
635
|
+
dimgrey: [105, 105, 105],
|
|
636
|
+
dodgerblue: [30, 144, 255],
|
|
637
|
+
firebrick: [178, 34, 34],
|
|
638
|
+
floralwhite: [255, 250, 240],
|
|
639
|
+
forestgreen: [34, 139, 34],
|
|
640
|
+
fuchsia: [255, 0, 255],
|
|
641
|
+
gainsboro: [220, 220, 220],
|
|
642
|
+
ghostwhite: [248, 248, 255],
|
|
643
|
+
gold: [255, 215, 0],
|
|
644
|
+
goldenrod: [218, 165, 32],
|
|
645
|
+
gray: [128, 128, 128],
|
|
646
|
+
green: [0, 128, 0],
|
|
647
|
+
greenyellow: [173, 255, 47],
|
|
648
|
+
grey: [128, 128, 128],
|
|
649
|
+
honeydew: [240, 255, 240],
|
|
650
|
+
hotpink: [255, 105, 180],
|
|
651
|
+
indianred: [205, 92, 92],
|
|
652
|
+
indigo: [75, 0, 130],
|
|
653
|
+
ivory: [255, 255, 240],
|
|
654
|
+
khaki: [240, 230, 140],
|
|
655
|
+
lavender: [230, 230, 250],
|
|
656
|
+
lavenderblush: [255, 240, 245],
|
|
657
|
+
lawngreen: [124, 252, 0],
|
|
658
|
+
lemonchiffon: [255, 250, 205],
|
|
659
|
+
lightblue: [173, 216, 230],
|
|
660
|
+
lightcoral: [240, 128, 128],
|
|
661
|
+
lightcyan: [224, 255, 255],
|
|
662
|
+
lightgoldenrodyellow: [250, 250, 210],
|
|
663
|
+
lightgray: [211, 211, 211],
|
|
664
|
+
lightgreen: [144, 238, 144],
|
|
665
|
+
lightgrey: [211, 211, 211],
|
|
666
|
+
lightpink: [255, 182, 193],
|
|
667
|
+
lightsalmon: [255, 160, 122],
|
|
668
|
+
lightseagreen: [32, 178, 170],
|
|
669
|
+
lightskyblue: [135, 206, 250],
|
|
670
|
+
lightslategray: [119, 136, 153],
|
|
671
|
+
lightslategrey: [119, 136, 153],
|
|
672
|
+
lightsteelblue: [176, 196, 222],
|
|
673
|
+
lightyellow: [255, 255, 224],
|
|
674
|
+
lime: [0, 255, 0],
|
|
675
|
+
limegreen: [50, 205, 50],
|
|
676
|
+
linen: [250, 240, 230],
|
|
677
|
+
magenta: [255, 0, 255],
|
|
678
|
+
maroon: [128, 0, 0],
|
|
679
|
+
mediumaquamarine: [102, 205, 170],
|
|
680
|
+
mediumblue: [0, 0, 205],
|
|
681
|
+
mediumorchid: [186, 85, 211],
|
|
682
|
+
mediumpurple: [147, 112, 219],
|
|
683
|
+
mediumseagreen: [60, 179, 113],
|
|
684
|
+
mediumslateblue: [123, 104, 238],
|
|
685
|
+
mediumspringgreen: [0, 250, 154],
|
|
686
|
+
mediumturquoise: [72, 209, 204],
|
|
687
|
+
mediumvioletred: [199, 21, 133],
|
|
688
|
+
midnightblue: [25, 25, 112],
|
|
689
|
+
mintcream: [245, 255, 250],
|
|
690
|
+
mistyrose: [255, 228, 225],
|
|
691
|
+
moccasin: [255, 228, 181],
|
|
692
|
+
navajowhite: [255, 222, 173],
|
|
693
|
+
navy: [0, 0, 128],
|
|
694
|
+
oldlace: [253, 245, 230],
|
|
695
|
+
olive: [128, 128, 0],
|
|
696
|
+
olivedrab: [107, 142, 35],
|
|
697
|
+
orange: [255, 165, 0],
|
|
698
|
+
orangered: [255, 69, 0],
|
|
699
|
+
orchid: [218, 112, 214],
|
|
700
|
+
palegoldenrod: [238, 232, 170],
|
|
701
|
+
palegreen: [152, 251, 152],
|
|
702
|
+
paleturquoise: [175, 238, 238],
|
|
703
|
+
palevioletred: [219, 112, 147],
|
|
704
|
+
papayawhip: [255, 239, 213],
|
|
705
|
+
peachpuff: [255, 218, 185],
|
|
706
|
+
peru: [205, 133, 63],
|
|
707
|
+
pink: [255, 192, 203],
|
|
708
|
+
plum: [221, 160, 221],
|
|
709
|
+
powderblue: [176, 224, 230],
|
|
710
|
+
purple: [128, 0, 128],
|
|
711
|
+
rebeccapurple: [102, 51, 153],
|
|
712
|
+
red: [255, 0, 0],
|
|
713
|
+
rosybrown: [188, 143, 143],
|
|
714
|
+
royalblue: [65, 105, 225],
|
|
715
|
+
saddlebrown: [139, 69, 19],
|
|
716
|
+
salmon: [250, 128, 114],
|
|
717
|
+
sandybrown: [244, 164, 96],
|
|
718
|
+
seagreen: [46, 139, 87],
|
|
719
|
+
seashell: [255, 245, 238],
|
|
720
|
+
sienna: [160, 82, 45],
|
|
721
|
+
silver: [192, 192, 192],
|
|
722
|
+
skyblue: [135, 206, 235],
|
|
723
|
+
slateblue: [106, 90, 205],
|
|
724
|
+
slategray: [112, 128, 144],
|
|
725
|
+
slategrey: [112, 128, 144],
|
|
726
|
+
snow: [255, 250, 250],
|
|
727
|
+
springgreen: [0, 255, 127],
|
|
728
|
+
steelblue: [70, 130, 180],
|
|
729
|
+
tan: [210, 180, 140],
|
|
730
|
+
teal: [0, 128, 128],
|
|
731
|
+
thistle: [216, 191, 216],
|
|
732
|
+
tomato: [255, 99, 71],
|
|
733
|
+
turquoise: [64, 224, 208],
|
|
734
|
+
violet: [238, 130, 238],
|
|
735
|
+
wheat: [245, 222, 179],
|
|
736
|
+
white: [255, 255, 255],
|
|
737
|
+
whitesmoke: [245, 245, 245],
|
|
738
|
+
yellow: [255, 255, 0],
|
|
739
|
+
yellowgreen: [154, 205, 50]
|
|
740
|
+
};
|
|
741
|
+
|
|
742
|
+
var reverseNames = Object.create(null);
|
|
743
|
+
|
|
744
|
+
// Create a list of reverse color names
|
|
745
|
+
for (var name in colorNames) {
|
|
746
|
+
if (Object.hasOwn(colorNames, name)) {
|
|
747
|
+
reverseNames[colorNames[name]] = name;
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
var cs = {
|
|
751
|
+
to: {},
|
|
752
|
+
get: {}
|
|
753
|
+
};
|
|
754
|
+
cs.get = function (string) {
|
|
755
|
+
var prefix = string.slice(0, 3).toLowerCase();
|
|
756
|
+
var value;
|
|
757
|
+
var model;
|
|
758
|
+
switch (prefix) {
|
|
759
|
+
case 'hsl':
|
|
760
|
+
{
|
|
761
|
+
value = cs.get.hsl(string);
|
|
491
762
|
model = 'hsl';
|
|
492
763
|
break;
|
|
493
|
-
|
|
494
|
-
|
|
764
|
+
}
|
|
765
|
+
case 'hwb':
|
|
766
|
+
{
|
|
767
|
+
value = cs.get.hwb(string);
|
|
495
768
|
model = 'hwb';
|
|
496
769
|
break;
|
|
497
|
-
|
|
498
|
-
|
|
770
|
+
}
|
|
771
|
+
default:
|
|
772
|
+
{
|
|
773
|
+
value = cs.get.rgb(string);
|
|
499
774
|
model = 'rgb';
|
|
500
775
|
break;
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
if (!value) {
|
|
779
|
+
return null;
|
|
780
|
+
}
|
|
781
|
+
return {
|
|
782
|
+
model: model,
|
|
783
|
+
value: value
|
|
784
|
+
};
|
|
785
|
+
};
|
|
786
|
+
cs.get.rgb = function (string) {
|
|
787
|
+
if (!string) {
|
|
788
|
+
return null;
|
|
789
|
+
}
|
|
790
|
+
var abbr = /^#([a-f\d]{3,4})$/i;
|
|
791
|
+
var hex = /^#([a-f\d]{6})([a-f\d]{2})?$/i;
|
|
792
|
+
var rgba = /^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|/]\s*([+-]?[\d.]+)(%?)\s*)?\)$/;
|
|
793
|
+
var per = /^rgba?\(\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*(?:[,|/]\s*([+-]?[\d.]+)(%?)\s*)?\)$/;
|
|
794
|
+
var keyword = /^(\w+)$/;
|
|
795
|
+
var rgb = [0, 0, 0, 1];
|
|
796
|
+
var match;
|
|
797
|
+
var i;
|
|
798
|
+
var hexAlpha;
|
|
799
|
+
if (match = string.match(hex)) {
|
|
800
|
+
hexAlpha = match[2];
|
|
801
|
+
match = match[1];
|
|
802
|
+
for (i = 0; i < 3; i++) {
|
|
803
|
+
// https://jsperf.com/slice-vs-substr-vs-substring-methods-long-string/19
|
|
804
|
+
var i2 = i * 2;
|
|
805
|
+
rgb[i] = Number.parseInt(match.slice(i2, i2 + 2), 16);
|
|
501
806
|
}
|
|
502
|
-
if (
|
|
503
|
-
|
|
807
|
+
if (hexAlpha) {
|
|
808
|
+
rgb[3] = Number.parseInt(hexAlpha, 16) / 255;
|
|
504
809
|
}
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
cs.get.rgb = function (string) {
|
|
511
|
-
if (!string) {
|
|
512
|
-
return null;
|
|
810
|
+
} else if (match = string.match(abbr)) {
|
|
811
|
+
match = match[1];
|
|
812
|
+
hexAlpha = match[3];
|
|
813
|
+
for (i = 0; i < 3; i++) {
|
|
814
|
+
rgb[i] = Number.parseInt(match[i] + match[i], 16);
|
|
513
815
|
}
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
var rgba = /^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/;
|
|
517
|
-
var per = /^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/;
|
|
518
|
-
var keyword = /^(\w+)$/;
|
|
519
|
-
var rgb = [0, 0, 0, 1];
|
|
520
|
-
var match;
|
|
521
|
-
var i;
|
|
522
|
-
var hexAlpha;
|
|
523
|
-
if (match = string.match(hex)) {
|
|
524
|
-
hexAlpha = match[2];
|
|
525
|
-
match = match[1];
|
|
526
|
-
for (i = 0; i < 3; i++) {
|
|
527
|
-
// https://jsperf.com/slice-vs-substr-vs-substring-methods-long-string/19
|
|
528
|
-
var i2 = i * 2;
|
|
529
|
-
rgb[i] = parseInt(match.slice(i2, i2 + 2), 16);
|
|
530
|
-
}
|
|
531
|
-
if (hexAlpha) {
|
|
532
|
-
rgb[3] = parseInt(hexAlpha, 16) / 255;
|
|
533
|
-
}
|
|
534
|
-
} else if (match = string.match(abbr)) {
|
|
535
|
-
match = match[1];
|
|
536
|
-
hexAlpha = match[3];
|
|
537
|
-
for (i = 0; i < 3; i++) {
|
|
538
|
-
rgb[i] = parseInt(match[i] + match[i], 16);
|
|
539
|
-
}
|
|
540
|
-
if (hexAlpha) {
|
|
541
|
-
rgb[3] = parseInt(hexAlpha + hexAlpha, 16) / 255;
|
|
542
|
-
}
|
|
543
|
-
} else if (match = string.match(rgba)) {
|
|
544
|
-
for (i = 0; i < 3; i++) {
|
|
545
|
-
rgb[i] = parseInt(match[i + 1], 0);
|
|
546
|
-
}
|
|
547
|
-
if (match[4]) {
|
|
548
|
-
if (match[5]) {
|
|
549
|
-
rgb[3] = parseFloat(match[4]) * 0.01;
|
|
550
|
-
} else {
|
|
551
|
-
rgb[3] = parseFloat(match[4]);
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
} else if (match = string.match(per)) {
|
|
555
|
-
for (i = 0; i < 3; i++) {
|
|
556
|
-
rgb[i] = Math.round(parseFloat(match[i + 1]) * 2.55);
|
|
557
|
-
}
|
|
558
|
-
if (match[4]) {
|
|
559
|
-
if (match[5]) {
|
|
560
|
-
rgb[3] = parseFloat(match[4]) * 0.01;
|
|
561
|
-
} else {
|
|
562
|
-
rgb[3] = parseFloat(match[4]);
|
|
563
|
-
}
|
|
564
|
-
}
|
|
565
|
-
} else if (match = string.match(keyword)) {
|
|
566
|
-
if (match[1] === 'transparent') {
|
|
567
|
-
return [0, 0, 0, 0];
|
|
568
|
-
}
|
|
569
|
-
if (!hasOwnProperty.call(colorNames, match[1])) {
|
|
570
|
-
return null;
|
|
571
|
-
}
|
|
572
|
-
rgb = colorNames[match[1]];
|
|
573
|
-
rgb[3] = 1;
|
|
574
|
-
return rgb;
|
|
575
|
-
} else {
|
|
576
|
-
return null;
|
|
816
|
+
if (hexAlpha) {
|
|
817
|
+
rgb[3] = Number.parseInt(hexAlpha + hexAlpha, 16) / 255;
|
|
577
818
|
}
|
|
819
|
+
} else if (match = string.match(rgba)) {
|
|
578
820
|
for (i = 0; i < 3; i++) {
|
|
579
|
-
rgb[i] =
|
|
821
|
+
rgb[i] = Number.parseInt(match[i + 1], 10);
|
|
580
822
|
}
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
};
|
|
584
|
-
cs.get.hsl = function (string) {
|
|
585
|
-
if (!string) {
|
|
586
|
-
return null;
|
|
823
|
+
if (match[4]) {
|
|
824
|
+
rgb[3] = match[5] ? Number.parseFloat(match[4]) * 0.01 : Number.parseFloat(match[4]);
|
|
587
825
|
}
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
var alpha = parseFloat(match[4]);
|
|
592
|
-
var h = (parseFloat(match[1]) % 360 + 360) % 360;
|
|
593
|
-
var s = clamp(parseFloat(match[2]), 0, 100);
|
|
594
|
-
var l = clamp(parseFloat(match[3]), 0, 100);
|
|
595
|
-
var a = clamp(isNaN(alpha) ? 1 : alpha, 0, 1);
|
|
596
|
-
return [h, s, l, a];
|
|
826
|
+
} else if (match = string.match(per)) {
|
|
827
|
+
for (i = 0; i < 3; i++) {
|
|
828
|
+
rgb[i] = Math.round(Number.parseFloat(match[i + 1]) * 2.55);
|
|
597
829
|
}
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
cs.get.hwb = function (string) {
|
|
601
|
-
if (!string) {
|
|
602
|
-
return null;
|
|
830
|
+
if (match[4]) {
|
|
831
|
+
rgb[3] = match[5] ? Number.parseFloat(match[4]) * 0.01 : Number.parseFloat(match[4]);
|
|
603
832
|
}
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
var alpha = parseFloat(match[4]);
|
|
608
|
-
var h = (parseFloat(match[1]) % 360 + 360) % 360;
|
|
609
|
-
var w = clamp(parseFloat(match[2]), 0, 100);
|
|
610
|
-
var b = clamp(parseFloat(match[3]), 0, 100);
|
|
611
|
-
var a = clamp(isNaN(alpha) ? 1 : alpha, 0, 1);
|
|
612
|
-
return [h, w, b, a];
|
|
833
|
+
} else if (match = string.match(keyword)) {
|
|
834
|
+
if (match[1] === 'transparent') {
|
|
835
|
+
return [0, 0, 0, 0];
|
|
613
836
|
}
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
cs.to.hex = function () {
|
|
617
|
-
var rgba = swizzle(arguments);
|
|
618
|
-
return '#' + hexDouble(rgba[0]) + hexDouble(rgba[1]) + hexDouble(rgba[2]) + (rgba[3] < 1 ? hexDouble(Math.round(rgba[3] * 255)) : '');
|
|
619
|
-
};
|
|
620
|
-
cs.to.rgb = function () {
|
|
621
|
-
var rgba = swizzle(arguments);
|
|
622
|
-
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] + ')';
|
|
623
|
-
};
|
|
624
|
-
cs.to.rgb.percent = function () {
|
|
625
|
-
var rgba = swizzle(arguments);
|
|
626
|
-
var r = Math.round(rgba[0] / 255 * 100);
|
|
627
|
-
var g = Math.round(rgba[1] / 255 * 100);
|
|
628
|
-
var b = Math.round(rgba[2] / 255 * 100);
|
|
629
|
-
return rgba.length < 4 || rgba[3] === 1 ? 'rgb(' + r + '%, ' + g + '%, ' + b + '%)' : 'rgba(' + r + '%, ' + g + '%, ' + b + '%, ' + rgba[3] + ')';
|
|
630
|
-
};
|
|
631
|
-
cs.to.hsl = function () {
|
|
632
|
-
var hsla = swizzle(arguments);
|
|
633
|
-
return hsla.length < 4 || hsla[3] === 1 ? 'hsl(' + hsla[0] + ', ' + hsla[1] + '%, ' + hsla[2] + '%)' : 'hsla(' + hsla[0] + ', ' + hsla[1] + '%, ' + hsla[2] + '%, ' + hsla[3] + ')';
|
|
634
|
-
};
|
|
635
|
-
|
|
636
|
-
// hwb is a bit different than rgb(a) & hsl(a) since there is no alpha specific syntax
|
|
637
|
-
// (hwb have alpha optional & 1 is default value)
|
|
638
|
-
cs.to.hwb = function () {
|
|
639
|
-
var hwba = swizzle(arguments);
|
|
640
|
-
var a = '';
|
|
641
|
-
if (hwba.length >= 4 && hwba[3] !== 1) {
|
|
642
|
-
a = ', ' + hwba[3];
|
|
837
|
+
if (!Object.hasOwn(colorNames, match[1])) {
|
|
838
|
+
return null;
|
|
643
839
|
}
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
840
|
+
rgb = colorNames[match[1]];
|
|
841
|
+
rgb[3] = 1;
|
|
842
|
+
return rgb;
|
|
843
|
+
} else {
|
|
844
|
+
return null;
|
|
845
|
+
}
|
|
846
|
+
for (i = 0; i < 3; i++) {
|
|
847
|
+
rgb[i] = clamp(rgb[i], 0, 255);
|
|
848
|
+
}
|
|
849
|
+
rgb[3] = clamp(rgb[3], 0, 1);
|
|
850
|
+
return rgb;
|
|
851
|
+
};
|
|
852
|
+
cs.get.hsl = function (string) {
|
|
853
|
+
if (!string) {
|
|
854
|
+
return null;
|
|
855
|
+
}
|
|
856
|
+
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*)?\)$/;
|
|
857
|
+
var match = string.match(hsl);
|
|
858
|
+
if (match) {
|
|
859
|
+
var alpha = Number.parseFloat(match[4]);
|
|
860
|
+
var h = (Number.parseFloat(match[1]) % 360 + 360) % 360;
|
|
861
|
+
var s = clamp(Number.parseFloat(match[2]), 0, 100);
|
|
862
|
+
var l = clamp(Number.parseFloat(match[3]), 0, 100);
|
|
863
|
+
var a = clamp(Number.isNaN(alpha) ? 1 : alpha, 0, 1);
|
|
864
|
+
return [h, s, l, a];
|
|
865
|
+
}
|
|
866
|
+
return null;
|
|
867
|
+
};
|
|
868
|
+
cs.get.hwb = function (string) {
|
|
869
|
+
if (!string) {
|
|
870
|
+
return null;
|
|
871
|
+
}
|
|
872
|
+
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*)?\)$/;
|
|
873
|
+
var match = string.match(hwb);
|
|
874
|
+
if (match) {
|
|
875
|
+
var alpha = Number.parseFloat(match[4]);
|
|
876
|
+
var h = (Number.parseFloat(match[1]) % 360 + 360) % 360;
|
|
877
|
+
var w = clamp(Number.parseFloat(match[2]), 0, 100);
|
|
878
|
+
var b = clamp(Number.parseFloat(match[3]), 0, 100);
|
|
879
|
+
var a = clamp(Number.isNaN(alpha) ? 1 : alpha, 0, 1);
|
|
880
|
+
return [h, w, b, a];
|
|
881
|
+
}
|
|
882
|
+
return null;
|
|
883
|
+
};
|
|
884
|
+
cs.to.hex = function () {
|
|
885
|
+
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)) : '');
|
|
886
|
+
};
|
|
887
|
+
cs.to.rgb = function () {
|
|
888
|
+
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]) + ')';
|
|
889
|
+
};
|
|
890
|
+
cs.to.rgb.percent = function () {
|
|
891
|
+
var r = Math.round((arguments.length <= 0 ? undefined : arguments[0]) / 255 * 100);
|
|
892
|
+
var g = Math.round((arguments.length <= 1 ? undefined : arguments[1]) / 255 * 100);
|
|
893
|
+
var b = Math.round((arguments.length <= 2 ? undefined : arguments[2]) / 255 * 100);
|
|
894
|
+
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]) + ')';
|
|
895
|
+
};
|
|
896
|
+
cs.to.hsl = function () {
|
|
897
|
+
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]) + ')';
|
|
898
|
+
};
|
|
649
899
|
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
900
|
+
// Hwb is a bit different than rgb(a) & hsl(a) since there is no alpha specific syntax
|
|
901
|
+
// (hwb have alpha optional & 1 is default value)
|
|
902
|
+
cs.to.hwb = function () {
|
|
903
|
+
var a = '';
|
|
904
|
+
if (arguments.length >= 4 && (arguments.length <= 3 ? undefined : arguments[3]) !== 1) {
|
|
905
|
+
a = ', ' + (arguments.length <= 3 ? undefined : arguments[3]);
|
|
653
906
|
}
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
907
|
+
return 'hwb(' + (arguments.length <= 0 ? undefined : arguments[0]) + ', ' + (arguments.length <= 1 ? undefined : arguments[1]) + '%, ' + (arguments.length <= 2 ? undefined : arguments[2]) + '%' + a + ')';
|
|
908
|
+
};
|
|
909
|
+
cs.to.keyword = function () {
|
|
910
|
+
for (var _len = arguments.length, rgb = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
911
|
+
rgb[_key] = arguments[_key];
|
|
657
912
|
}
|
|
658
|
-
return
|
|
913
|
+
return reverseNames[rgb.slice(0, 3)];
|
|
914
|
+
};
|
|
915
|
+
|
|
916
|
+
// Helpers
|
|
917
|
+
function clamp(number_, min, max) {
|
|
918
|
+
return Math.min(Math.max(min, number_), max);
|
|
919
|
+
}
|
|
920
|
+
function hexDouble(number_) {
|
|
921
|
+
var string_ = Math.round(number_).toString(16).toUpperCase();
|
|
922
|
+
return string_.length < 2 ? '0' + string_ : string_;
|
|
659
923
|
}
|
|
660
924
|
|
|
925
|
+
var colorString = /*#__PURE__*/Object.freeze({
|
|
926
|
+
__proto__: null,
|
|
927
|
+
default: cs
|
|
928
|
+
});
|
|
929
|
+
|
|
930
|
+
var require$$0 = /*@__PURE__*/getAugmentedNamespace(colorString);
|
|
931
|
+
|
|
661
932
|
var hasRequiredHelpers;
|
|
662
933
|
function requireHelpers() {
|
|
663
934
|
if (hasRequiredHelpers) return helpers;
|
|
@@ -674,20 +945,16 @@ function requireHelpers() {
|
|
|
674
945
|
};
|
|
675
946
|
return __assign.apply(this, arguments);
|
|
676
947
|
};
|
|
677
|
-
var
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
ar[i] = from[i];
|
|
682
|
-
}
|
|
683
|
-
}
|
|
684
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
948
|
+
var __importDefault = helpers && helpers.__importDefault || function (mod) {
|
|
949
|
+
return mod && mod.__esModule ? mod : {
|
|
950
|
+
"default": mod
|
|
951
|
+
};
|
|
685
952
|
};
|
|
686
953
|
Object.defineProperty(exports, "__esModule", {
|
|
687
954
|
value: true
|
|
688
955
|
});
|
|
689
956
|
exports.spacing = exports.colorInHex = exports.color = exports.remToUnitlessPx = exports.text = void 0;
|
|
690
|
-
var
|
|
957
|
+
var color_string_1 = __importDefault(require$$0);
|
|
691
958
|
var colors_1 = requireColors();
|
|
692
959
|
var space_1 = requireSpace();
|
|
693
960
|
var typography_1 = requireTypography();
|
|
@@ -709,13 +976,20 @@ function requireHelpers() {
|
|
|
709
976
|
var color = function color(name, alpha) {
|
|
710
977
|
var _a;
|
|
711
978
|
var color = colors_1.colors.all[name];
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
979
|
+
var _b = (_a = color_string_1["default"].get.rgb(color)) !== null && _a !== void 0 ? _a : [],
|
|
980
|
+
red = _b[0],
|
|
981
|
+
green = _b[1],
|
|
982
|
+
blue = _b[2];
|
|
983
|
+
return alpha != null ? color_string_1["default"].to.rgb(red, green, blue, alpha) : color;
|
|
715
984
|
};
|
|
716
985
|
exports.color = color;
|
|
717
986
|
var colorInHex = function colorInHex(name, alpha) {
|
|
718
|
-
|
|
987
|
+
var _a, _b, _c;
|
|
988
|
+
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 : [],
|
|
989
|
+
red = _d[0],
|
|
990
|
+
green = _d[1],
|
|
991
|
+
blue = _d[2];
|
|
992
|
+
return (_c = color_string_1["default"].to.hex(red, green, blue, alpha)) !== null && _c !== void 0 ? _c : '';
|
|
719
993
|
};
|
|
720
994
|
exports.colorInHex = colorInHex;
|
|
721
995
|
var spacing = function spacing(topY, rightX, bottom, left) {
|
|
@@ -816,9 +1090,9 @@ function _createForOfIteratorHelper(r, e) {
|
|
|
816
1090
|
s: F,
|
|
817
1091
|
n: function () {
|
|
818
1092
|
return n >= r.length ? {
|
|
819
|
-
done:
|
|
1093
|
+
done: true
|
|
820
1094
|
} : {
|
|
821
|
-
done:
|
|
1095
|
+
done: false,
|
|
822
1096
|
value: r[n++]
|
|
823
1097
|
};
|
|
824
1098
|
},
|
|
@@ -831,8 +1105,8 @@ function _createForOfIteratorHelper(r, e) {
|
|
|
831
1105
|
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
832
1106
|
}
|
|
833
1107
|
var o,
|
|
834
|
-
a =
|
|
835
|
-
u =
|
|
1108
|
+
a = true,
|
|
1109
|
+
u = false;
|
|
836
1110
|
return {
|
|
837
1111
|
s: function () {
|
|
838
1112
|
t = t.call(r);
|
|
@@ -842,7 +1116,7 @@ function _createForOfIteratorHelper(r, e) {
|
|
|
842
1116
|
return a = r.done, r;
|
|
843
1117
|
},
|
|
844
1118
|
e: function (r) {
|
|
845
|
-
u =
|
|
1119
|
+
u = true, o = r;
|
|
846
1120
|
},
|
|
847
1121
|
f: function () {
|
|
848
1122
|
try {
|
|
@@ -856,9 +1130,9 @@ function _createForOfIteratorHelper(r, e) {
|
|
|
856
1130
|
function _defineProperty$1(e, r, t) {
|
|
857
1131
|
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
858
1132
|
value: t,
|
|
859
|
-
enumerable:
|
|
860
|
-
configurable:
|
|
861
|
-
writable:
|
|
1133
|
+
enumerable: true,
|
|
1134
|
+
configurable: true,
|
|
1135
|
+
writable: true
|
|
862
1136
|
}) : e[r] = t, e;
|
|
863
1137
|
}
|
|
864
1138
|
function _extends$1() {
|
|
@@ -881,15 +1155,15 @@ function _iterableToArrayLimit(r, l) {
|
|
|
881
1155
|
i,
|
|
882
1156
|
u,
|
|
883
1157
|
a = [],
|
|
884
|
-
f =
|
|
885
|
-
o =
|
|
1158
|
+
f = true,
|
|
1159
|
+
o = false;
|
|
886
1160
|
try {
|
|
887
1161
|
if (i = (t = t.call(r)).next, 0 === l) {
|
|
888
1162
|
if (Object(t) !== t) return;
|
|
889
1163
|
f = !1;
|
|
890
1164
|
} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
|
|
891
1165
|
} catch (r) {
|
|
892
|
-
o =
|
|
1166
|
+
o = true, n = r;
|
|
893
1167
|
} finally {
|
|
894
1168
|
try {
|
|
895
1169
|
if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
|
|
@@ -922,7 +1196,7 @@ function ownKeys(e, r) {
|
|
|
922
1196
|
function _objectSpread2(e) {
|
|
923
1197
|
for (var r = 1; r < arguments.length; r++) {
|
|
924
1198
|
var t = null != arguments[r] ? arguments[r] : {};
|
|
925
|
-
r % 2 ? ownKeys(Object(t),
|
|
1199
|
+
r % 2 ? ownKeys(Object(t), true).forEach(function (r) {
|
|
926
1200
|
_defineProperty$1(e, r, t[r]);
|
|
927
1201
|
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
|
|
928
1202
|
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
@@ -936,8 +1210,8 @@ function _objectWithoutProperties(e, t) {
|
|
|
936
1210
|
r,
|
|
937
1211
|
i = _objectWithoutPropertiesLoose(e, t);
|
|
938
1212
|
if (Object.getOwnPropertySymbols) {
|
|
939
|
-
var
|
|
940
|
-
for (r = 0; r <
|
|
1213
|
+
var n = Object.getOwnPropertySymbols(e);
|
|
1214
|
+
for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
|
|
941
1215
|
}
|
|
942
1216
|
return i;
|
|
943
1217
|
}
|
|
@@ -945,7 +1219,7 @@ function _objectWithoutPropertiesLoose(r, e) {
|
|
|
945
1219
|
if (null == r) return {};
|
|
946
1220
|
var t = {};
|
|
947
1221
|
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
948
|
-
if (e.
|
|
1222
|
+
if (-1 !== e.indexOf(n)) continue;
|
|
949
1223
|
t[n] = r[n];
|
|
950
1224
|
}
|
|
951
1225
|
return t;
|
|
@@ -960,7 +1234,7 @@ function _toPrimitive(t, r) {
|
|
|
960
1234
|
if ("object" != typeof t || !t) return t;
|
|
961
1235
|
var e = t[Symbol.toPrimitive];
|
|
962
1236
|
if (void 0 !== e) {
|
|
963
|
-
var i = e.call(t, r
|
|
1237
|
+
var i = e.call(t, r);
|
|
964
1238
|
if ("object" != typeof i) return i;
|
|
965
1239
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
966
1240
|
}
|
|
@@ -991,108 +1265,6 @@ var isRenderProps = function isRenderProps(children) {
|
|
|
991
1265
|
return typeof children === 'function';
|
|
992
1266
|
};
|
|
993
1267
|
|
|
994
|
-
var classnames = {exports: {}};
|
|
995
|
-
|
|
996
|
-
var hasRequiredClassnames;
|
|
997
|
-
function requireClassnames() {
|
|
998
|
-
if (hasRequiredClassnames) return classnames.exports;
|
|
999
|
-
hasRequiredClassnames = 1;
|
|
1000
|
-
(function (module) {
|
|
1001
|
-
/* global define */
|
|
1002
|
-
|
|
1003
|
-
(function () {
|
|
1004
|
-
|
|
1005
|
-
var hasOwn = {}.hasOwnProperty;
|
|
1006
|
-
function classNames() {
|
|
1007
|
-
var classes = '';
|
|
1008
|
-
for (var i = 0; i < arguments.length; i++) {
|
|
1009
|
-
var arg = arguments[i];
|
|
1010
|
-
if (arg) {
|
|
1011
|
-
classes = appendClass(classes, parseValue(arg));
|
|
1012
|
-
}
|
|
1013
|
-
}
|
|
1014
|
-
return classes;
|
|
1015
|
-
}
|
|
1016
|
-
function parseValue(arg) {
|
|
1017
|
-
if (typeof arg === 'string' || typeof arg === 'number') {
|
|
1018
|
-
return arg;
|
|
1019
|
-
}
|
|
1020
|
-
if (_typeof$1(arg) !== 'object') {
|
|
1021
|
-
return '';
|
|
1022
|
-
}
|
|
1023
|
-
if (Array.isArray(arg)) {
|
|
1024
|
-
return classNames.apply(null, arg);
|
|
1025
|
-
}
|
|
1026
|
-
if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) {
|
|
1027
|
-
return arg.toString();
|
|
1028
|
-
}
|
|
1029
|
-
var classes = '';
|
|
1030
|
-
for (var key in arg) {
|
|
1031
|
-
if (hasOwn.call(arg, key) && arg[key]) {
|
|
1032
|
-
classes = appendClass(classes, key);
|
|
1033
|
-
}
|
|
1034
|
-
}
|
|
1035
|
-
return classes;
|
|
1036
|
-
}
|
|
1037
|
-
function appendClass(value, newClass) {
|
|
1038
|
-
if (!newClass) {
|
|
1039
|
-
return value;
|
|
1040
|
-
}
|
|
1041
|
-
if (value) {
|
|
1042
|
-
return value + ' ' + newClass;
|
|
1043
|
-
}
|
|
1044
|
-
return value + newClass;
|
|
1045
|
-
}
|
|
1046
|
-
if (module.exports) {
|
|
1047
|
-
classNames["default"] = classNames;
|
|
1048
|
-
module.exports = classNames;
|
|
1049
|
-
} else {
|
|
1050
|
-
window.classNames = classNames;
|
|
1051
|
-
}
|
|
1052
|
-
})();
|
|
1053
|
-
})(classnames);
|
|
1054
|
-
return classnames.exports;
|
|
1055
|
-
}
|
|
1056
|
-
|
|
1057
|
-
var classnamesExports = requireClassnames();
|
|
1058
|
-
var classNames = /*@__PURE__*/getDefaultExportFromCjs(classnamesExports);
|
|
1059
|
-
|
|
1060
|
-
var _excluded$G = ["className", "children", "space", "direction", "alignItems", "justifyContent", "style"];
|
|
1061
|
-
var Stack = function Stack(_ref) {
|
|
1062
|
-
var className = _ref.className,
|
|
1063
|
-
children = _ref.children,
|
|
1064
|
-
space = _ref.space,
|
|
1065
|
-
_ref$direction = _ref.direction,
|
|
1066
|
-
direction = _ref$direction === void 0 ? 'vertical' : _ref$direction,
|
|
1067
|
-
alignItems = _ref.alignItems,
|
|
1068
|
-
justifyContent = _ref.justifyContent,
|
|
1069
|
-
style = _ref.style,
|
|
1070
|
-
rest = _objectWithoutProperties(_ref, _excluded$G);
|
|
1071
|
-
return /*#__PURE__*/React.createElement("div", _extends$1({
|
|
1072
|
-
className: classNames("Stack Stack--".concat(direction, "-").concat(space), className),
|
|
1073
|
-
style: _objectSpread2(_objectSpread2({}, style), {}, {
|
|
1074
|
-
alignItems: alignItems,
|
|
1075
|
-
justifyContent: justifyContent
|
|
1076
|
-
})
|
|
1077
|
-
}, rest), children);
|
|
1078
|
-
};
|
|
1079
|
-
|
|
1080
|
-
var omit$1 = function omit(obj) {
|
|
1081
|
-
for (var _len = arguments.length, keys = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
1082
|
-
keys[_key - 1] = arguments[_key];
|
|
1083
|
-
}
|
|
1084
|
-
return Object.entries(obj).filter(function (_ref) {
|
|
1085
|
-
var _ref2 = _slicedToArray(_ref, 1),
|
|
1086
|
-
key = _ref2[0];
|
|
1087
|
-
return !keys.includes(key);
|
|
1088
|
-
}).reduce(function (obj, _ref3) {
|
|
1089
|
-
var _ref4 = _slicedToArray(_ref3, 2),
|
|
1090
|
-
key = _ref4[0],
|
|
1091
|
-
val = _ref4[1];
|
|
1092
|
-
return Object.assign(obj, _defineProperty$1({}, key, val));
|
|
1093
|
-
}, {});
|
|
1094
|
-
};
|
|
1095
|
-
|
|
1096
1268
|
var truncate = function truncate(string) {
|
|
1097
1269
|
var maxLength = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 25;
|
|
1098
1270
|
if (!string) return null;
|
|
@@ -1100,7 +1272,6 @@ var truncate = function truncate(string) {
|
|
|
1100
1272
|
return "".concat(string.substring(0, maxLength)).concat(ellipsis ? '...' : '');
|
|
1101
1273
|
};
|
|
1102
1274
|
|
|
1103
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1104
1275
|
var stringifyProps = function stringifyProps(props) {
|
|
1105
1276
|
var stringifiedProps = Object.entries(props || {}).reduce(function (memo, _ref) {
|
|
1106
1277
|
var _ref2 = _slicedToArray(_ref, 2),
|
|
@@ -1117,50 +1288,85 @@ var stringifyProps = function stringifyProps(props) {
|
|
|
1117
1288
|
return stringifiedProps.trim();
|
|
1118
1289
|
};
|
|
1119
1290
|
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1291
|
+
var omit$1 = function omit(obj) {
|
|
1292
|
+
for (var _len = arguments.length, keys = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
1293
|
+
keys[_key - 1] = arguments[_key];
|
|
1294
|
+
}
|
|
1295
|
+
return Object.entries(obj).filter(function (_ref) {
|
|
1296
|
+
var _ref2 = _slicedToArray(_ref, 1),
|
|
1297
|
+
key = _ref2[0];
|
|
1298
|
+
return !keys.includes(key);
|
|
1299
|
+
}).reduce(function (obj, _ref3) {
|
|
1300
|
+
var _ref4 = _slicedToArray(_ref3, 2),
|
|
1301
|
+
key = _ref4[0],
|
|
1302
|
+
val = _ref4[1];
|
|
1303
|
+
return Object.assign(obj, _defineProperty$1({}, key, val));
|
|
1304
|
+
}, {});
|
|
1305
|
+
};
|
|
1123
1306
|
|
|
1124
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1125
1307
|
var isEmpty = function isEmpty(obj) {
|
|
1126
1308
|
return Object.entries(obj || {}).length === 0;
|
|
1127
1309
|
};
|
|
1128
|
-
|
|
1310
|
+
|
|
1311
|
+
var DEFAULT_STYLES = {
|
|
1312
|
+
state: {
|
|
1313
|
+
border: '1px dotted #ddd',
|
|
1314
|
+
padding: '0.5rem',
|
|
1315
|
+
marginBottom: '1rem'
|
|
1316
|
+
},
|
|
1317
|
+
stateProps: {
|
|
1318
|
+
display: 'block',
|
|
1319
|
+
marginTop: '0.5rem',
|
|
1320
|
+
paddingTop: '0.5rem',
|
|
1321
|
+
fontFamily: "source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace",
|
|
1322
|
+
fontSize: '0.8125rem',
|
|
1323
|
+
color: '#999',
|
|
1324
|
+
borderTop: '1px dotted #ddd'
|
|
1325
|
+
},
|
|
1326
|
+
statePropsActive: {
|
|
1327
|
+
color: '#111',
|
|
1328
|
+
textDecoration: 'underline'
|
|
1329
|
+
}
|
|
1330
|
+
};
|
|
1331
|
+
var Styles = /*#__PURE__*/React.createContext(DEFAULT_STYLES);
|
|
1332
|
+
var useStyles = function useStyles() {
|
|
1333
|
+
return React.useContext(Styles);
|
|
1334
|
+
};
|
|
1335
|
+
|
|
1336
|
+
var StateProps = function StateProps(_ref) {
|
|
1129
1337
|
var props = _ref.props,
|
|
1130
1338
|
children = _ref.children;
|
|
1339
|
+
var styles = useStyles();
|
|
1131
1340
|
var childrenProps = omit$1.apply(void 0, [children.props].concat(_toConsumableArray(Object.keys(props || {}))));
|
|
1132
|
-
return /*#__PURE__*/React.createElement(
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
},
|
|
1341
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
1342
|
+
style: styles.stateProps
|
|
1343
|
+
}, '<', /*#__PURE__*/React.createElement("span", null, children.type.displayName || children.type.name), ' ', !isEmpty(props) && /*#__PURE__*/React.createElement("strong", {
|
|
1344
|
+
style: styles.statePropsActive
|
|
1345
|
+
}, stringifyProps(props)), ' ', !isRenderProps(children) && !isEmpty(childrenProps) && /*#__PURE__*/React.createElement("span", null, stringifyProps(childrenProps)), /*#__PURE__*/React.createElement("span", null, ' />'));
|
|
1137
1346
|
};
|
|
1138
1347
|
|
|
1139
|
-
var _excluded$
|
|
1348
|
+
var _excluded$G = ["props", "children"];
|
|
1140
1349
|
var State = function State(_ref) {
|
|
1141
1350
|
var props = _ref.props,
|
|
1142
1351
|
children = _ref.children,
|
|
1143
|
-
rest = _objectWithoutProperties(_ref, _excluded$
|
|
1352
|
+
rest = _objectWithoutProperties(_ref, _excluded$G);
|
|
1353
|
+
var styles = useStyles();
|
|
1144
1354
|
var Specimen = isRenderProps(children) ? children(props) : /*#__PURE__*/React.cloneElement(children, props);
|
|
1145
1355
|
var innerChildren = isRenderProps(children) ? children(props) : children;
|
|
1146
1356
|
return /*#__PURE__*/React.createElement("div", _extends$1({
|
|
1147
|
-
|
|
1148
|
-
}, rest), Specimen, /*#__PURE__*/React.createElement(
|
|
1149
|
-
className: "State__props"
|
|
1150
|
-
}, /*#__PURE__*/React.createElement(StatesProps, {
|
|
1357
|
+
style: styles.state
|
|
1358
|
+
}, rest), Specimen, /*#__PURE__*/React.createElement(StateProps, {
|
|
1151
1359
|
props: props
|
|
1152
|
-
}, innerChildren))
|
|
1360
|
+
}, innerChildren));
|
|
1153
1361
|
};
|
|
1154
1362
|
|
|
1155
|
-
var _excluded$
|
|
1363
|
+
var _excluded$F = ["states", "children"];
|
|
1156
1364
|
var States = function States(_ref) {
|
|
1157
1365
|
var _ref$states = _ref.states,
|
|
1158
1366
|
states = _ref$states === void 0 ? [{}] : _ref$states,
|
|
1159
1367
|
children = _ref.children,
|
|
1160
|
-
rest = _objectWithoutProperties(_ref, _excluded$
|
|
1161
|
-
return /*#__PURE__*/React.createElement(
|
|
1162
|
-
className: "States"
|
|
1163
|
-
}, states.map(function (props, index) {
|
|
1368
|
+
rest = _objectWithoutProperties(_ref, _excluded$F);
|
|
1369
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, states.map(function (props, index) {
|
|
1164
1370
|
return /*#__PURE__*/React.createElement(State, _extends$1({
|
|
1165
1371
|
key: index,
|
|
1166
1372
|
props: props
|
|
@@ -1168,6 +1374,11 @@ var States = function States(_ref) {
|
|
|
1168
1374
|
}));
|
|
1169
1375
|
};
|
|
1170
1376
|
|
|
1377
|
+
var preventNavigation = function preventNavigation(event) {
|
|
1378
|
+
event.preventDefault();
|
|
1379
|
+
event.returnValue = '';
|
|
1380
|
+
};
|
|
1381
|
+
|
|
1171
1382
|
/******************************************************************************
|
|
1172
1383
|
Copyright (c) Microsoft Corporation.
|
|
1173
1384
|
|
|
@@ -2713,16 +2924,16 @@ var mediumSidecar = createSidecarMedium({
|
|
|
2713
2924
|
var focusScope = /*#__PURE__*/React.createContext(undefined);
|
|
2714
2925
|
|
|
2715
2926
|
var emptyArray = [];
|
|
2716
|
-
var FocusLock = /*#__PURE__*/
|
|
2927
|
+
var FocusLock = /*#__PURE__*/React.forwardRef(function FocusLockUI(props, parentRef) {
|
|
2717
2928
|
var _extends2;
|
|
2718
|
-
var
|
|
2719
|
-
realObserved =
|
|
2720
|
-
setObserved =
|
|
2721
|
-
var observed =
|
|
2722
|
-
var isActive =
|
|
2723
|
-
var originalFocusedElement =
|
|
2724
|
-
var
|
|
2725
|
-
update =
|
|
2929
|
+
var _useState = React.useState(),
|
|
2930
|
+
realObserved = _useState[0],
|
|
2931
|
+
setObserved = _useState[1];
|
|
2932
|
+
var observed = React.useRef();
|
|
2933
|
+
var isActive = React.useRef(false);
|
|
2934
|
+
var originalFocusedElement = React.useRef(null);
|
|
2935
|
+
var _useState2 = React.useState({}),
|
|
2936
|
+
update = _useState2[1];
|
|
2726
2937
|
var children = props.children,
|
|
2727
2938
|
_props$disabled = props.disabled,
|
|
2728
2939
|
disabled = _props$disabled === void 0 ? false : _props$disabled,
|
|
@@ -2751,9 +2962,9 @@ var FocusLock = /*#__PURE__*/React__namespace.forwardRef(function FocusLockUI(pr
|
|
|
2751
2962
|
focusOptions = props.focusOptions,
|
|
2752
2963
|
onActivationCallback = props.onActivation,
|
|
2753
2964
|
onDeactivationCallback = props.onDeactivation;
|
|
2754
|
-
var
|
|
2755
|
-
id =
|
|
2756
|
-
var onActivation =
|
|
2965
|
+
var _useState3 = React.useState({}),
|
|
2966
|
+
id = _useState3[0];
|
|
2967
|
+
var onActivation = React.useCallback(function (_ref) {
|
|
2757
2968
|
var captureFocusRestore = _ref.captureFocusRestore;
|
|
2758
2969
|
if (!originalFocusedElement.current) {
|
|
2759
2970
|
var _document;
|
|
@@ -2769,14 +2980,14 @@ var FocusLock = /*#__PURE__*/React__namespace.forwardRef(function FocusLockUI(pr
|
|
|
2769
2980
|
isActive.current = true;
|
|
2770
2981
|
update();
|
|
2771
2982
|
}, [onActivationCallback]);
|
|
2772
|
-
var onDeactivation =
|
|
2983
|
+
var onDeactivation = React.useCallback(function () {
|
|
2773
2984
|
isActive.current = false;
|
|
2774
2985
|
if (onDeactivationCallback) {
|
|
2775
2986
|
onDeactivationCallback(observed.current);
|
|
2776
2987
|
}
|
|
2777
2988
|
update();
|
|
2778
2989
|
}, [onDeactivationCallback]);
|
|
2779
|
-
var returnFocus =
|
|
2990
|
+
var returnFocus = React.useCallback(function (allowDefer) {
|
|
2780
2991
|
var focusRestore = originalFocusedElement.current;
|
|
2781
2992
|
if (focusRestore) {
|
|
2782
2993
|
var returnFocusTo = (typeof focusRestore === 'function' ? focusRestore() : focusRestore) || document.body;
|
|
@@ -2794,13 +3005,13 @@ var FocusLock = /*#__PURE__*/React__namespace.forwardRef(function FocusLockUI(pr
|
|
|
2794
3005
|
}
|
|
2795
3006
|
}
|
|
2796
3007
|
}, [shouldReturnFocus]);
|
|
2797
|
-
var onFocus =
|
|
3008
|
+
var onFocus = React.useCallback(function (event) {
|
|
2798
3009
|
if (isActive.current) {
|
|
2799
3010
|
mediumFocus.useMedium(event);
|
|
2800
3011
|
}
|
|
2801
3012
|
}, []);
|
|
2802
3013
|
var onBlur = mediumBlur.useMedium;
|
|
2803
|
-
var setObserveNode =
|
|
3014
|
+
var setObserveNode = React.useCallback(function (newObserved) {
|
|
2804
3015
|
if (observed.current !== newObserved) {
|
|
2805
3016
|
observed.current = newObserved;
|
|
2806
3017
|
setObserved(newObserved);
|
|
@@ -2810,7 +3021,7 @@ var FocusLock = /*#__PURE__*/React__namespace.forwardRef(function FocusLockUI(pr
|
|
|
2810
3021
|
if (typeof allowTextSelection !== 'undefined') {
|
|
2811
3022
|
console.warn('React-Focus-Lock: allowTextSelection is deprecated and enabled by default');
|
|
2812
3023
|
}
|
|
2813
|
-
|
|
3024
|
+
React.useEffect(function () {
|
|
2814
3025
|
if (!observed.current && typeof Container !== 'string') {
|
|
2815
3026
|
console.error('FocusLock: could not obtain ref to internal node');
|
|
2816
3027
|
}
|
|
@@ -2820,7 +3031,7 @@ var FocusLock = /*#__PURE__*/React__namespace.forwardRef(function FocusLockUI(pr
|
|
|
2820
3031
|
var hasLeadingGuards = noFocusGuards !== true;
|
|
2821
3032
|
var hasTailingGuards = hasLeadingGuards && noFocusGuards !== 'tail';
|
|
2822
3033
|
var mergedRef = useMergeRefs([parentRef, setObserveNode]);
|
|
2823
|
-
var focusScopeValue =
|
|
3034
|
+
var focusScopeValue = React.useMemo(function () {
|
|
2824
3035
|
return {
|
|
2825
3036
|
observed: observed,
|
|
2826
3037
|
shards: shards,
|
|
@@ -2828,18 +3039,18 @@ var FocusLock = /*#__PURE__*/React__namespace.forwardRef(function FocusLockUI(pr
|
|
|
2828
3039
|
active: isActive.current
|
|
2829
3040
|
};
|
|
2830
3041
|
}, [disabled, isActive.current, shards, realObserved]);
|
|
2831
|
-
return /*#__PURE__*/
|
|
2832
|
-
|
|
3042
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, hasLeadingGuards && [/*#__PURE__*/
|
|
3043
|
+
React.createElement("div", {
|
|
2833
3044
|
key: "guard-first",
|
|
2834
3045
|
"data-focus-guard": true,
|
|
2835
3046
|
tabIndex: disabled ? -1 : 0,
|
|
2836
3047
|
style: hiddenGuard
|
|
2837
|
-
}), hasPositiveIndices ? /*#__PURE__*/
|
|
3048
|
+
}), hasPositiveIndices ? /*#__PURE__*/React.createElement("div", {
|
|
2838
3049
|
key: "guard-nearest",
|
|
2839
3050
|
"data-focus-guard": true,
|
|
2840
3051
|
tabIndex: disabled ? -1 : 1,
|
|
2841
3052
|
style: hiddenGuard
|
|
2842
|
-
}) : null], !disabled && /*#__PURE__*/
|
|
3053
|
+
}) : null], !disabled && /*#__PURE__*/React.createElement(SideCar, {
|
|
2843
3054
|
id: id,
|
|
2844
3055
|
sideCar: mediumSidecar,
|
|
2845
3056
|
observed: realObserved,
|
|
@@ -2854,15 +3065,15 @@ var FocusLock = /*#__PURE__*/React__namespace.forwardRef(function FocusLockUI(pr
|
|
|
2854
3065
|
returnFocus: returnFocus,
|
|
2855
3066
|
focusOptions: focusOptions,
|
|
2856
3067
|
noFocusGuards: noFocusGuards
|
|
2857
|
-
}), /*#__PURE__*/
|
|
3068
|
+
}), /*#__PURE__*/React.createElement(Container, _extends({
|
|
2858
3069
|
ref: mergedRef
|
|
2859
3070
|
}, lockProps, {
|
|
2860
3071
|
className: className,
|
|
2861
3072
|
onBlur: onBlur,
|
|
2862
3073
|
onFocus: onFocus
|
|
2863
|
-
}), /*#__PURE__*/
|
|
3074
|
+
}), /*#__PURE__*/React.createElement(focusScope.Provider, {
|
|
2864
3075
|
value: focusScopeValue
|
|
2865
|
-
}, children)), hasTailingGuards && /*#__PURE__*/
|
|
3076
|
+
}, children)), hasTailingGuards && /*#__PURE__*/React.createElement("div", {
|
|
2866
3077
|
"data-focus-guard": true,
|
|
2867
3078
|
tabIndex: disabled ? -1 : 0,
|
|
2868
3079
|
style: hiddenGuard
|
|
@@ -2989,7 +3200,7 @@ function toPrimitive(t, r) {
|
|
|
2989
3200
|
if ("object" != _typeof(t) || !t) return t;
|
|
2990
3201
|
var e = t[Symbol.toPrimitive];
|
|
2991
3202
|
if (void 0 !== e) {
|
|
2992
|
-
var i = e.call(t, r
|
|
3203
|
+
var i = e.call(t, r);
|
|
2993
3204
|
if ("object" != _typeof(i)) return i;
|
|
2994
3205
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
2995
3206
|
}
|
|
@@ -3004,9 +3215,9 @@ function toPropertyKey(t) {
|
|
|
3004
3215
|
function _defineProperty(e, r, t) {
|
|
3005
3216
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
3006
3217
|
value: t,
|
|
3007
|
-
enumerable:
|
|
3008
|
-
configurable:
|
|
3009
|
-
writable:
|
|
3218
|
+
enumerable: true,
|
|
3219
|
+
configurable: true,
|
|
3220
|
+
writable: true
|
|
3010
3221
|
}) : e[r] = t, e;
|
|
3011
3222
|
}
|
|
3012
3223
|
|
|
@@ -3539,8 +3750,18 @@ var newFocus = function newFocus(innerNodes, innerTabbables, outerNodes, activeE
|
|
|
3539
3750
|
var firstNodeIndex = outerNodes.indexOf(firstFocus);
|
|
3540
3751
|
var lastNodeIndex = outerNodes.indexOf(lastFocus);
|
|
3541
3752
|
var correctedNodes = correctNodes(outerNodes);
|
|
3542
|
-
var
|
|
3543
|
-
var
|
|
3753
|
+
var currentFocusableIndex = activeElement !== undefined ? correctedNodes.indexOf(activeElement) : -1;
|
|
3754
|
+
var previousFocusableIndex = lastNode ? correctedNodes.indexOf(lastNode) : currentFocusableIndex;
|
|
3755
|
+
var tabbableNodes = correctedNodes.filter(function (node) {
|
|
3756
|
+
return node.tabIndex >= 0;
|
|
3757
|
+
});
|
|
3758
|
+
var currentTabbableIndex = activeElement !== undefined ? tabbableNodes.indexOf(activeElement) : -1;
|
|
3759
|
+
var previousTabbableIndex = lastNode ? tabbableNodes.indexOf(lastNode) : currentTabbableIndex;
|
|
3760
|
+
var focusIndexDiff = currentTabbableIndex >= 0 && previousTabbableIndex >= 0 ?
|
|
3761
|
+
// old/new are tabbables, measure distance in tabbable space
|
|
3762
|
+
previousTabbableIndex - currentTabbableIndex :
|
|
3763
|
+
// or else measure in focusable space
|
|
3764
|
+
previousFocusableIndex - currentFocusableIndex;
|
|
3544
3765
|
// old focus
|
|
3545
3766
|
if (!indexDiff && lastNodeInside >= 0) {
|
|
3546
3767
|
return lastNodeInside;
|
|
@@ -3563,7 +3784,7 @@ var newFocus = function newFocus(innerNodes, innerTabbables, outerNodes, activeE
|
|
|
3563
3784
|
return returnFirstNode;
|
|
3564
3785
|
}
|
|
3565
3786
|
// jump out, but not on the guard
|
|
3566
|
-
if (indexDiff && Math.abs(
|
|
3787
|
+
if (indexDiff && Math.abs(focusIndexDiff) > 1) {
|
|
3567
3788
|
return lastNodeInside;
|
|
3568
3789
|
}
|
|
3569
3790
|
// focus above lock
|
|
@@ -4119,9 +4340,8 @@ var activateTrap = function activateTrap() {
|
|
|
4119
4340
|
focusOptions = _lastActiveTrap.focusOptions,
|
|
4120
4341
|
noFocusGuards = _lastActiveTrap.noFocusGuards;
|
|
4121
4342
|
var workingNode = observed || lastPortaledElement && lastPortaledElement.portaledElement;
|
|
4122
|
-
if (focusOnBody() && lastActiveFocus) {
|
|
4343
|
+
if (focusOnBody() && lastActiveFocus && lastActiveFocus !== document.body) {
|
|
4123
4344
|
if (!document.body.contains(lastActiveFocus) || isNotFocusable(lastActiveFocus)) {
|
|
4124
|
-
lastActiveFocus = null;
|
|
4125
4345
|
var newTarget = tryRestoreFocus();
|
|
4126
4346
|
if (newTarget) {
|
|
4127
4347
|
newTarget.focus();
|
|
@@ -4157,9 +4377,11 @@ var activateTrap = function activateTrap() {
|
|
|
4157
4377
|
lastPortaledElement = {};
|
|
4158
4378
|
}
|
|
4159
4379
|
}
|
|
4160
|
-
focusWasOutsideWindow = false;
|
|
4161
4380
|
lastActiveFocus = document && document.activeElement;
|
|
4162
|
-
|
|
4381
|
+
if (lastActiveFocus !== document.body) {
|
|
4382
|
+
tryRestoreFocus = captureFocusRestore(lastActiveFocus);
|
|
4383
|
+
}
|
|
4384
|
+
focusWasOutsideWindow = false;
|
|
4163
4385
|
}
|
|
4164
4386
|
}
|
|
4165
4387
|
if (document && activeElement !== document.activeElement && document.querySelector('[data-focus-auto-guard]')) {
|
|
@@ -4178,7 +4400,7 @@ var activateTrap = function activateTrap() {
|
|
|
4178
4400
|
var node = _ref4.node;
|
|
4179
4401
|
return node.removeAttribute('tabIndex');
|
|
4180
4402
|
});
|
|
4181
|
-
autoGuard(focusedIndex, allNodes.length,
|
|
4403
|
+
autoGuard(focusedIndex, allNodes.length, 1, allNodes);
|
|
4182
4404
|
autoGuard(focusedIndex, -1, -1, allNodes);
|
|
4183
4405
|
}
|
|
4184
4406
|
}
|
|
@@ -4585,9 +4807,9 @@ var handleScroll = function handleScroll(axis, endTarget, event, sourceDelta, no
|
|
|
4585
4807
|
// self content
|
|
4586
4808
|
targetInLock && (endTarget.contains(target) || endTarget === target));
|
|
4587
4809
|
// handle epsilon around 0 (non standard zoom levels)
|
|
4588
|
-
if (isDeltaPositive && (Math.abs(availableScroll) < 1 ||
|
|
4810
|
+
if (isDeltaPositive && (Math.abs(availableScroll) < 1 || false)) {
|
|
4589
4811
|
shouldCancelScroll = true;
|
|
4590
|
-
} else if (!isDeltaPositive && (Math.abs(availableScrollTop) < 1 ||
|
|
4812
|
+
} else if (!isDeltaPositive && (Math.abs(availableScrollTop) < 1 || false)) {
|
|
4591
4813
|
shouldCancelScroll = true;
|
|
4592
4814
|
}
|
|
4593
4815
|
return shouldCancelScroll;
|
|
@@ -4672,7 +4894,7 @@ function RemoveScrollSideCar(props) {
|
|
|
4672
4894
|
return true;
|
|
4673
4895
|
}
|
|
4674
4896
|
var cancelingAxis = activeAxis.current || currentAxis;
|
|
4675
|
-
return handleScroll(cancelingAxis, parent, event, cancelingAxis === 'h' ? deltaX : deltaY
|
|
4897
|
+
return handleScroll(cancelingAxis, parent, event, cancelingAxis === 'h' ? deltaX : deltaY);
|
|
4676
4898
|
}, []);
|
|
4677
4899
|
var shouldPrevent = React__namespace.useCallback(function (_event) {
|
|
4678
4900
|
var event = _event;
|
|
@@ -5030,6 +5252,72 @@ var FocusOn = /*#__PURE__*/React__namespace.forwardRef(function (props, ref) {
|
|
|
5030
5252
|
}));
|
|
5031
5253
|
});
|
|
5032
5254
|
|
|
5255
|
+
var classnames = {exports: {}};
|
|
5256
|
+
|
|
5257
|
+
var hasRequiredClassnames;
|
|
5258
|
+
function requireClassnames() {
|
|
5259
|
+
if (hasRequiredClassnames) return classnames.exports;
|
|
5260
|
+
hasRequiredClassnames = 1;
|
|
5261
|
+
(function (module) {
|
|
5262
|
+
/* global define */
|
|
5263
|
+
|
|
5264
|
+
(function () {
|
|
5265
|
+
|
|
5266
|
+
var hasOwn = {}.hasOwnProperty;
|
|
5267
|
+
function classNames() {
|
|
5268
|
+
var classes = '';
|
|
5269
|
+
for (var i = 0; i < arguments.length; i++) {
|
|
5270
|
+
var arg = arguments[i];
|
|
5271
|
+
if (arg) {
|
|
5272
|
+
classes = appendClass(classes, parseValue(arg));
|
|
5273
|
+
}
|
|
5274
|
+
}
|
|
5275
|
+
return classes;
|
|
5276
|
+
}
|
|
5277
|
+
function parseValue(arg) {
|
|
5278
|
+
if (typeof arg === 'string' || typeof arg === 'number') {
|
|
5279
|
+
return arg;
|
|
5280
|
+
}
|
|
5281
|
+
if (_typeof$1(arg) !== 'object') {
|
|
5282
|
+
return '';
|
|
5283
|
+
}
|
|
5284
|
+
if (Array.isArray(arg)) {
|
|
5285
|
+
return classNames.apply(null, arg);
|
|
5286
|
+
}
|
|
5287
|
+
if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) {
|
|
5288
|
+
return arg.toString();
|
|
5289
|
+
}
|
|
5290
|
+
var classes = '';
|
|
5291
|
+
for (var key in arg) {
|
|
5292
|
+
if (hasOwn.call(arg, key) && arg[key]) {
|
|
5293
|
+
classes = appendClass(classes, key);
|
|
5294
|
+
}
|
|
5295
|
+
}
|
|
5296
|
+
return classes;
|
|
5297
|
+
}
|
|
5298
|
+
function appendClass(value, newClass) {
|
|
5299
|
+
if (!newClass) {
|
|
5300
|
+
return value;
|
|
5301
|
+
}
|
|
5302
|
+
if (value) {
|
|
5303
|
+
return value + ' ' + newClass;
|
|
5304
|
+
}
|
|
5305
|
+
return value + newClass;
|
|
5306
|
+
}
|
|
5307
|
+
if (module.exports) {
|
|
5308
|
+
classNames["default"] = classNames;
|
|
5309
|
+
module.exports = classNames;
|
|
5310
|
+
} else {
|
|
5311
|
+
window.classNames = classNames;
|
|
5312
|
+
}
|
|
5313
|
+
})();
|
|
5314
|
+
})(classnames);
|
|
5315
|
+
return classnames.exports;
|
|
5316
|
+
}
|
|
5317
|
+
|
|
5318
|
+
var classnamesExports = requireClassnames();
|
|
5319
|
+
var classNames = /*@__PURE__*/getDefaultExportFromCjs(classnamesExports);
|
|
5320
|
+
|
|
5033
5321
|
var dist$3 = {};
|
|
5034
5322
|
|
|
5035
5323
|
var scale = {};
|
|
@@ -5130,7 +5418,7 @@ function requireDist$3() {
|
|
|
5130
5418
|
|
|
5131
5419
|
var distExports$3 = requireDist$3();
|
|
5132
5420
|
|
|
5133
|
-
var _excluded$
|
|
5421
|
+
var _excluded$E = ["aspectWidth", "aspectHeight", "maxWidth", "maxHeight", "outlined", "children", "className"];
|
|
5134
5422
|
var DEFAULT_PRODUCT_ASPECT_WIDTH = 128;
|
|
5135
5423
|
var DEFAULT_PRODUCT_ASPECT_HEIGHT = 205;
|
|
5136
5424
|
var DEFAULT_PRODUCT_ASPECT_RATIO = DEFAULT_PRODUCT_ASPECT_HEIGHT / DEFAULT_PRODUCT_ASPECT_WIDTH;
|
|
@@ -5176,7 +5464,7 @@ var AspectRatioBox = /*#__PURE__*/React.forwardRef(function (_ref2, forwardedRef
|
|
|
5176
5464
|
outlined = _ref2$outlined === void 0 ? false : _ref2$outlined,
|
|
5177
5465
|
children = _ref2.children,
|
|
5178
5466
|
className = _ref2.className,
|
|
5179
|
-
rest = _objectWithoutProperties(_ref2, _excluded$
|
|
5467
|
+
rest = _objectWithoutProperties(_ref2, _excluded$E);
|
|
5180
5468
|
var _scaleDimensions = scaleDimensions({
|
|
5181
5469
|
width: aspectWidth,
|
|
5182
5470
|
height: aspectHeight,
|
|
@@ -5204,22 +5492,22 @@ var AspectRatioBox = /*#__PURE__*/React.forwardRef(function (_ref2, forwardedRef
|
|
|
5204
5492
|
});
|
|
5205
5493
|
AspectRatioBox.displayName = 'AspectRatioBox';
|
|
5206
5494
|
|
|
5207
|
-
var _excluded$
|
|
5495
|
+
var _excluded$D = ["className", "theme", "children"];
|
|
5208
5496
|
var Badge = function Badge(_ref) {
|
|
5209
5497
|
var className = _ref.className,
|
|
5210
5498
|
theme = _ref.theme,
|
|
5211
5499
|
children = _ref.children,
|
|
5212
|
-
rest = _objectWithoutProperties(_ref, _excluded$
|
|
5500
|
+
rest = _objectWithoutProperties(_ref, _excluded$D);
|
|
5213
5501
|
return /*#__PURE__*/React.createElement("span", _extends$1({
|
|
5214
5502
|
className: classNames('Badge', theme && "Badge--".concat(theme), className)
|
|
5215
5503
|
}, rest), children);
|
|
5216
5504
|
};
|
|
5217
5505
|
|
|
5218
|
-
var _excluded$
|
|
5506
|
+
var _excluded$C = ["children", "className"];
|
|
5219
5507
|
var Breadcrumbs = function Breadcrumbs(_ref) {
|
|
5220
5508
|
var children = _ref.children,
|
|
5221
5509
|
className = _ref.className,
|
|
5222
|
-
rest = _objectWithoutProperties(_ref, _excluded$
|
|
5510
|
+
rest = _objectWithoutProperties(_ref, _excluded$C);
|
|
5223
5511
|
var position = 0;
|
|
5224
5512
|
return /*#__PURE__*/React.createElement("ol", _extends$1({
|
|
5225
5513
|
itemScope: true,
|
|
@@ -5237,7 +5525,7 @@ var Breadcrumbs = function Breadcrumbs(_ref) {
|
|
|
5237
5525
|
}));
|
|
5238
5526
|
};
|
|
5239
5527
|
|
|
5240
|
-
var _excluded$
|
|
5528
|
+
var _excluded$B = ["className", "styleless", "disabled"];
|
|
5241
5529
|
var isLink = function isLink(props) {
|
|
5242
5530
|
return 'to' in props;
|
|
5243
5531
|
};
|
|
@@ -5252,7 +5540,7 @@ var Clickable = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
5252
5540
|
_ref$styleless = _ref.styleless,
|
|
5253
5541
|
styleless = _ref$styleless === void 0 ? false : _ref$styleless,
|
|
5254
5542
|
disabled = _ref.disabled,
|
|
5255
|
-
rest = _objectWithoutProperties(_ref, _excluded$
|
|
5543
|
+
rest = _objectWithoutProperties(_ref, _excluded$B);
|
|
5256
5544
|
var props = _objectSpread2(_objectSpread2({}, rest), {}, {
|
|
5257
5545
|
className: classNames({
|
|
5258
5546
|
Clickable: !styleless,
|
|
@@ -5260,8 +5548,7 @@ var Clickable = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
5260
5548
|
}, className),
|
|
5261
5549
|
disabled: disabled
|
|
5262
5550
|
});
|
|
5263
|
-
if (isLink(props)) return /*#__PURE__*/React.createElement(Link, _extends$1({}, props, {
|
|
5264
|
-
href: props.to,
|
|
5551
|
+
if (isLink(props)) return /*#__PURE__*/React.createElement(reactRouterDom.Link, _extends$1({}, props, {
|
|
5265
5552
|
ref: ref
|
|
5266
5553
|
}));
|
|
5267
5554
|
if (isAnchor(props)) return /*#__PURE__*/React.createElement("a", _extends$1({}, props, {
|
|
@@ -5274,14 +5561,14 @@ var Clickable = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
5274
5561
|
});
|
|
5275
5562
|
Clickable.displayName = 'Clickable';
|
|
5276
5563
|
|
|
5277
|
-
var _excluded$
|
|
5564
|
+
var _excluded$A = ["className", "disabled", "children", "underlined"];
|
|
5278
5565
|
var ControlLink = function ControlLink(_ref) {
|
|
5279
5566
|
var className = _ref.className,
|
|
5280
5567
|
disabled = _ref.disabled,
|
|
5281
5568
|
children = _ref.children,
|
|
5282
5569
|
_ref$underlined = _ref.underlined,
|
|
5283
5570
|
underlined = _ref$underlined === void 0 ? true : _ref$underlined,
|
|
5284
|
-
rest = _objectWithoutProperties(_ref, _excluded$
|
|
5571
|
+
rest = _objectWithoutProperties(_ref, _excluded$A);
|
|
5285
5572
|
return /*#__PURE__*/React.createElement(Clickable, _extends$1({}, rest, {
|
|
5286
5573
|
className: classNames('ControlLink', {
|
|
5287
5574
|
'ControlLink--underlined': underlined
|
|
@@ -5292,12 +5579,12 @@ var ControlLink = function ControlLink(_ref) {
|
|
|
5292
5579
|
}), children);
|
|
5293
5580
|
};
|
|
5294
5581
|
|
|
5295
|
-
var _excluded$
|
|
5582
|
+
var _excluded$z = ["children", "position", "className"];
|
|
5296
5583
|
var Breadcrumb = function Breadcrumb(_ref) {
|
|
5297
5584
|
var children = _ref.children,
|
|
5298
5585
|
position = _ref.position,
|
|
5299
5586
|
className = _ref.className,
|
|
5300
|
-
rest = _objectWithoutProperties(_ref, _excluded$
|
|
5587
|
+
rest = _objectWithoutProperties(_ref, _excluded$z);
|
|
5301
5588
|
return /*#__PURE__*/React.createElement("li", {
|
|
5302
5589
|
className: classNames('Breadcrumb', className),
|
|
5303
5590
|
itemProp: "itemListElement",
|
|
@@ -7021,11 +7308,11 @@ var useBreakpoint = function useBreakpoint(props) {
|
|
|
7021
7308
|
};
|
|
7022
7309
|
};
|
|
7023
7310
|
|
|
7024
|
-
var _excluded$
|
|
7311
|
+
var _excluded$y = ["children", "className"];
|
|
7025
7312
|
var Breakpoint = function Breakpoint(_ref) {
|
|
7026
7313
|
var children = _ref.children,
|
|
7027
7314
|
className = _ref.className,
|
|
7028
|
-
rest = _objectWithoutProperties(_ref, _excluded$
|
|
7315
|
+
rest = _objectWithoutProperties(_ref, _excluded$y);
|
|
7029
7316
|
var _discriminate = discriminate(rest),
|
|
7030
7317
|
mode = _discriminate.mode,
|
|
7031
7318
|
breakpoint = _discriminate.breakpoint;
|
|
@@ -7036,7 +7323,7 @@ var Breakpoint = function Breakpoint(_ref) {
|
|
|
7036
7323
|
}, omit(['at', 'gt', 'lt'], rest)), children) : null;
|
|
7037
7324
|
};
|
|
7038
7325
|
|
|
7039
|
-
var _excluded$
|
|
7326
|
+
var _excluded$x = ["secondary", "tertiary", "elevated", "chip", "hover", "focus", "disabled", "className"];
|
|
7040
7327
|
var Button = function Button(_ref) {
|
|
7041
7328
|
var secondary = _ref.secondary,
|
|
7042
7329
|
tertiary = _ref.tertiary,
|
|
@@ -7046,7 +7333,7 @@ var Button = function Button(_ref) {
|
|
|
7046
7333
|
focus = _ref.focus,
|
|
7047
7334
|
disabled = _ref.disabled,
|
|
7048
7335
|
className = _ref.className,
|
|
7049
|
-
rest = _objectWithoutProperties(_ref, _excluded$
|
|
7336
|
+
rest = _objectWithoutProperties(_ref, _excluded$x);
|
|
7050
7337
|
return /*#__PURE__*/React.createElement(Clickable, _extends$1({
|
|
7051
7338
|
className: classNames('Button', {
|
|
7052
7339
|
'Button--chip': chip,
|
|
@@ -7170,7 +7457,7 @@ var Circle12 = function Circle12(_a) {
|
|
|
7170
7457
|
};
|
|
7171
7458
|
Circle12.displayName = 'Circle12';
|
|
7172
7459
|
|
|
7173
|
-
var _excluded$
|
|
7460
|
+
var _excluded$w = ["className", "defaultChecked", "checked", "children", "value", "onChange", "disabled", "checkIcon", "dataTestId", "id"];
|
|
7174
7461
|
var CHECKED_ITEM_PROPS = {
|
|
7175
7462
|
className: 'Checkbox__check-mark',
|
|
7176
7463
|
height: '85%',
|
|
@@ -7189,7 +7476,7 @@ var Checkbox = function Checkbox(_ref) {
|
|
|
7189
7476
|
checkIcon = _ref$checkIcon === void 0 ? 'checkmark' : _ref$checkIcon,
|
|
7190
7477
|
dataTestId = _ref.dataTestId,
|
|
7191
7478
|
id = _ref.id,
|
|
7192
|
-
rest = _objectWithoutProperties(_ref, _excluded$
|
|
7479
|
+
rest = _objectWithoutProperties(_ref, _excluded$w);
|
|
7193
7480
|
var _useState = React.useState((_ref2 = checked !== null && checked !== void 0 ? checked : defaultChecked) !== null && _ref2 !== void 0 ? _ref2 : false),
|
|
7194
7481
|
_useState2 = _slicedToArray(_useState, 2),
|
|
7195
7482
|
isChecked = _useState2[0],
|
|
@@ -7281,7 +7568,7 @@ var SKU_COLORS = {
|
|
|
7281
7568
|
yellow: '#ffca44'
|
|
7282
7569
|
};
|
|
7283
7570
|
|
|
7284
|
-
var _excluded$
|
|
7571
|
+
var _excluded$v = ["className", "size", "color", "backgroundUrl", "focus", "hover", "selected", "soldOut", "onSale", "onClick", "onMouseEnter", "disabled", "title"];
|
|
7285
7572
|
var ColorSwatch = function ColorSwatch(_ref) {
|
|
7286
7573
|
var _SKU_COLORS;
|
|
7287
7574
|
var className = _ref.className,
|
|
@@ -7297,7 +7584,7 @@ var ColorSwatch = function ColorSwatch(_ref) {
|
|
|
7297
7584
|
onMouseEnter = _ref.onMouseEnter,
|
|
7298
7585
|
disabled = _ref.disabled,
|
|
7299
7586
|
title = _ref.title,
|
|
7300
|
-
rest = _objectWithoutProperties(_ref, _excluded$
|
|
7587
|
+
rest = _objectWithoutProperties(_ref, _excluded$v);
|
|
7301
7588
|
var handleClick = React.useCallback(function (_event) {
|
|
7302
7589
|
onClick === null || onClick === void 0 || onClick(color, title);
|
|
7303
7590
|
}, [color, title, onClick]);
|
|
@@ -7332,14 +7619,14 @@ var ColorSwatch = function ColorSwatch(_ref) {
|
|
|
7332
7619
|
}));
|
|
7333
7620
|
};
|
|
7334
7621
|
|
|
7335
|
-
var _excluded$
|
|
7622
|
+
var _excluded$u = ["className", "children", "onClose", "shards", "autoFocus"];
|
|
7336
7623
|
var Modal = function Modal(_ref) {
|
|
7337
7624
|
var className = _ref.className,
|
|
7338
7625
|
children = _ref.children,
|
|
7339
7626
|
onClose = _ref.onClose,
|
|
7340
7627
|
shards = _ref.shards,
|
|
7341
7628
|
autoFocus = _ref.autoFocus,
|
|
7342
|
-
rest = _objectWithoutProperties(_ref, _excluded$
|
|
7629
|
+
rest = _objectWithoutProperties(_ref, _excluded$u);
|
|
7343
7630
|
return /*#__PURE__*/React.createElement("div", _extends$1({
|
|
7344
7631
|
className: classNames('Modal', className)
|
|
7345
7632
|
}, rest), /*#__PURE__*/React.createElement(FocusOn, {
|
|
@@ -7350,14 +7637,14 @@ var Modal = function Modal(_ref) {
|
|
|
7350
7637
|
}, children));
|
|
7351
7638
|
};
|
|
7352
7639
|
|
|
7353
|
-
var _excluded$
|
|
7640
|
+
var _excluded$t = ["className", "children", "show"];
|
|
7354
7641
|
var UNMOUNT_DELAY_MS = 500;
|
|
7355
7642
|
var Overlay = /*#__PURE__*/React.forwardRef(function (_ref, forwardedRef) {
|
|
7356
7643
|
var className = _ref.className,
|
|
7357
7644
|
children = _ref.children,
|
|
7358
7645
|
_ref$show = _ref.show,
|
|
7359
7646
|
show = _ref$show === void 0 ? true : _ref$show,
|
|
7360
|
-
rest = _objectWithoutProperties(_ref, _excluded$
|
|
7647
|
+
rest = _objectWithoutProperties(_ref, _excluded$t);
|
|
7361
7648
|
var _useState = React.useState(show),
|
|
7362
7649
|
_useState2 = _slicedToArray(_useState, 2),
|
|
7363
7650
|
open = _useState2[0],
|
|
@@ -7384,7 +7671,7 @@ var Overlay = /*#__PURE__*/React.forwardRef(function (_ref, forwardedRef) {
|
|
|
7384
7671
|
});
|
|
7385
7672
|
Overlay.displayName = 'Overlay';
|
|
7386
7673
|
|
|
7387
|
-
var _excluded$
|
|
7674
|
+
var _excluded$s = ["children", "className", "contentClassName", "onClose", "overlayClassName", "show", "shards", "autoFocus"];
|
|
7388
7675
|
var ModalOverlay = function ModalOverlay(_ref) {
|
|
7389
7676
|
var children = _ref.children,
|
|
7390
7677
|
className = _ref.className,
|
|
@@ -7395,7 +7682,7 @@ var ModalOverlay = function ModalOverlay(_ref) {
|
|
|
7395
7682
|
show = _ref$show === void 0 ? true : _ref$show,
|
|
7396
7683
|
shards = _ref.shards,
|
|
7397
7684
|
autoFocus = _ref.autoFocus,
|
|
7398
|
-
rest = _objectWithoutProperties(_ref, _excluded$
|
|
7685
|
+
rest = _objectWithoutProperties(_ref, _excluded$s);
|
|
7399
7686
|
var element = React.useMemo(function () {
|
|
7400
7687
|
return typeof document !== 'undefined' ? document.createElement('div') : null;
|
|
7401
7688
|
}, []);
|
|
@@ -7408,7 +7695,7 @@ var ModalOverlay = function ModalOverlay(_ref) {
|
|
|
7408
7695
|
};
|
|
7409
7696
|
}, [element]);
|
|
7410
7697
|
if (!element) return null;
|
|
7411
|
-
return /*#__PURE__*/
|
|
7698
|
+
return /*#__PURE__*/reactDom.createPortal(/*#__PURE__*/React.createElement(Overlay, _extends$1({
|
|
7412
7699
|
className: classNames('ModalOverlay', overlayClassName),
|
|
7413
7700
|
show: show
|
|
7414
7701
|
}, rest), /*#__PURE__*/React.createElement(Modal, {
|
|
@@ -7421,6 +7708,26 @@ var ModalOverlay = function ModalOverlay(_ref) {
|
|
|
7421
7708
|
}, children))), element);
|
|
7422
7709
|
};
|
|
7423
7710
|
|
|
7711
|
+
var _excluded$r = ["className", "children", "space", "direction", "alignItems", "justifyContent", "style"];
|
|
7712
|
+
var Stack = function Stack(_ref) {
|
|
7713
|
+
var className = _ref.className,
|
|
7714
|
+
children = _ref.children,
|
|
7715
|
+
space = _ref.space,
|
|
7716
|
+
_ref$direction = _ref.direction,
|
|
7717
|
+
direction = _ref$direction === void 0 ? 'vertical' : _ref$direction,
|
|
7718
|
+
alignItems = _ref.alignItems,
|
|
7719
|
+
justifyContent = _ref.justifyContent,
|
|
7720
|
+
style = _ref.style,
|
|
7721
|
+
rest = _objectWithoutProperties(_ref, _excluded$r);
|
|
7722
|
+
return /*#__PURE__*/React.createElement("div", _extends$1({
|
|
7723
|
+
className: classNames("Stack Stack--".concat(direction, "-").concat(space), className),
|
|
7724
|
+
style: _objectSpread2(_objectSpread2({}, style), {}, {
|
|
7725
|
+
alignItems: alignItems,
|
|
7726
|
+
justifyContent: justifyContent
|
|
7727
|
+
})
|
|
7728
|
+
}, rest), children);
|
|
7729
|
+
};
|
|
7730
|
+
|
|
7424
7731
|
var _excluded$q = ["as", "className", "treatment", "color", "family", "children", "style"];
|
|
7425
7732
|
var Text = function Text(_ref) {
|
|
7426
7733
|
var _ref$as = _ref.as,
|
|
@@ -7569,516 +7876,7 @@ var ExceedConstrain = function ExceedConstrain(_ref) {
|
|
|
7569
7876
|
|
|
7570
7877
|
var reactInputMask = {exports: {}};
|
|
7571
7878
|
|
|
7572
|
-
var reactInputMask_production_min;
|
|
7573
|
-
var hasRequiredReactInputMask_production_min;
|
|
7574
|
-
function requireReactInputMask_production_min() {
|
|
7575
|
-
if (hasRequiredReactInputMask_production_min) return reactInputMask_production_min;
|
|
7576
|
-
hasRequiredReactInputMask_production_min = 1;
|
|
7577
|
-
function _interopDefault(e) {
|
|
7578
|
-
return e && "object" == _typeof$1(e) && "default" in e ? e["default"] : e;
|
|
7579
|
-
}
|
|
7580
|
-
var React$1 = _interopDefault(React),
|
|
7581
|
-
reactDom = require$$1;
|
|
7582
|
-
function _defaults2(e, t) {
|
|
7583
|
-
for (var n = Object.getOwnPropertyNames(t), a = 0; a < n.length; a++) {
|
|
7584
|
-
var i = n[a],
|
|
7585
|
-
r = Object.getOwnPropertyDescriptor(t, i);
|
|
7586
|
-
r && r.configurable && e[i] === undefined && Object.defineProperty(e, i, r);
|
|
7587
|
-
}
|
|
7588
|
-
return e;
|
|
7589
|
-
}
|
|
7590
|
-
function _extends() {
|
|
7591
|
-
return (_extends = Object.assign || function (e) {
|
|
7592
|
-
for (var t = 1; t < arguments.length; t++) {
|
|
7593
|
-
var n = arguments[t];
|
|
7594
|
-
for (var a in n) Object.prototype.hasOwnProperty.call(n, a) && (e[a] = n[a]);
|
|
7595
|
-
}
|
|
7596
|
-
return e;
|
|
7597
|
-
}).apply(this, arguments);
|
|
7598
|
-
}
|
|
7599
|
-
function _inheritsLoose(e, t) {
|
|
7600
|
-
e.prototype = Object.create(t.prototype), _defaults2(e.prototype.constructor = e, t);
|
|
7601
|
-
}
|
|
7602
|
-
function _objectWithoutPropertiesLoose(e, t) {
|
|
7603
|
-
if (null == e) return {};
|
|
7604
|
-
var n,
|
|
7605
|
-
a,
|
|
7606
|
-
i = {},
|
|
7607
|
-
r = Object.keys(e);
|
|
7608
|
-
for (a = 0; a < r.length; a++) n = r[a], 0 <= t.indexOf(n) || (i[n] = e[n]);
|
|
7609
|
-
return i;
|
|
7610
|
-
}
|
|
7611
|
-
function _assertThisInitialized(e) {
|
|
7612
|
-
if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
7613
|
-
return e;
|
|
7614
|
-
}
|
|
7615
|
-
var invariant = function invariant(e, t, n, a, i, r, o, s) {
|
|
7616
|
-
if (!e) {
|
|
7617
|
-
var l;
|
|
7618
|
-
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 {
|
|
7619
|
-
var u = [n, a, i, r, o, s],
|
|
7620
|
-
c = 0;
|
|
7621
|
-
(l = new Error(t.replace(/%s/g, function () {
|
|
7622
|
-
return u[c++];
|
|
7623
|
-
}))).name = "Invariant Violation";
|
|
7624
|
-
}
|
|
7625
|
-
throw l.framesToPop = 1, l;
|
|
7626
|
-
}
|
|
7627
|
-
},
|
|
7628
|
-
invariant_1 = invariant;
|
|
7629
|
-
function setInputSelection(e, t, n) {
|
|
7630
|
-
if ("selectionStart" in e && "selectionEnd" in e) e.selectionStart = t, e.selectionEnd = n;else {
|
|
7631
|
-
var a = e.createTextRange();
|
|
7632
|
-
a.collapse(!0), a.moveStart("character", t), a.moveEnd("character", n - t), a.select();
|
|
7633
|
-
}
|
|
7634
|
-
}
|
|
7635
|
-
function getInputSelection(e) {
|
|
7636
|
-
var t = 0,
|
|
7637
|
-
n = 0;
|
|
7638
|
-
if ("selectionStart" in e && "selectionEnd" in e) t = e.selectionStart, n = e.selectionEnd;else {
|
|
7639
|
-
var a = document.selection.createRange();
|
|
7640
|
-
a.parentElement() === e && (t = -a.moveStart("character", -e.value.length), n = -a.moveEnd("character", -e.value.length));
|
|
7641
|
-
}
|
|
7642
|
-
return {
|
|
7643
|
-
start: t,
|
|
7644
|
-
end: n,
|
|
7645
|
-
length: n - t
|
|
7646
|
-
};
|
|
7647
|
-
}
|
|
7648
|
-
var defaultFormatChars = {
|
|
7649
|
-
9: "[0-9]",
|
|
7650
|
-
a: "[A-Za-z]",
|
|
7651
|
-
"*": "[A-Za-z0-9]"
|
|
7652
|
-
},
|
|
7653
|
-
defaultMaskChar = "_";
|
|
7654
|
-
function parseMask(e, t, n) {
|
|
7655
|
-
var a = "",
|
|
7656
|
-
i = "",
|
|
7657
|
-
r = null,
|
|
7658
|
-
o = [];
|
|
7659
|
-
if (t === undefined && (t = defaultMaskChar), null == n && (n = defaultFormatChars), !e || "string" != typeof e) return {
|
|
7660
|
-
maskChar: t,
|
|
7661
|
-
formatChars: n,
|
|
7662
|
-
mask: null,
|
|
7663
|
-
prefix: null,
|
|
7664
|
-
lastEditablePosition: null,
|
|
7665
|
-
permanents: []
|
|
7666
|
-
};
|
|
7667
|
-
var s = !1;
|
|
7668
|
-
return e.split("").forEach(function (e) {
|
|
7669
|
-
s = !s && "\\" === e || (s || !n[e] ? (o.push(a.length), a.length === o.length - 1 && (i += e)) : r = a.length + 1, a += e, !1);
|
|
7670
|
-
}), {
|
|
7671
|
-
maskChar: t,
|
|
7672
|
-
formatChars: n,
|
|
7673
|
-
prefix: i,
|
|
7674
|
-
mask: a,
|
|
7675
|
-
lastEditablePosition: r,
|
|
7676
|
-
permanents: o
|
|
7677
|
-
};
|
|
7678
|
-
}
|
|
7679
|
-
function isPermanentCharacter(e, t) {
|
|
7680
|
-
return -1 !== e.permanents.indexOf(t);
|
|
7681
|
-
}
|
|
7682
|
-
function isAllowedCharacter(e, t, n) {
|
|
7683
|
-
var a = e.mask,
|
|
7684
|
-
i = e.formatChars;
|
|
7685
|
-
if (!n) return !1;
|
|
7686
|
-
if (isPermanentCharacter(e, t)) return a[t] === n;
|
|
7687
|
-
var r = i[a[t]];
|
|
7688
|
-
return new RegExp(r).test(n);
|
|
7689
|
-
}
|
|
7690
|
-
function isEmpty(n, e) {
|
|
7691
|
-
return e.split("").every(function (e, t) {
|
|
7692
|
-
return isPermanentCharacter(n, t) || !isAllowedCharacter(n, t, e);
|
|
7693
|
-
});
|
|
7694
|
-
}
|
|
7695
|
-
function getFilledLength(e, t) {
|
|
7696
|
-
var n = e.maskChar,
|
|
7697
|
-
a = e.prefix;
|
|
7698
|
-
if (!n) {
|
|
7699
|
-
for (; t.length > a.length && isPermanentCharacter(e, t.length - 1);) t = t.slice(0, t.length - 1);
|
|
7700
|
-
return t.length;
|
|
7701
|
-
}
|
|
7702
|
-
for (var i = a.length, r = t.length; r >= a.length; r--) {
|
|
7703
|
-
var o = t[r];
|
|
7704
|
-
if (!isPermanentCharacter(e, r) && isAllowedCharacter(e, r, o)) {
|
|
7705
|
-
i = r + 1;
|
|
7706
|
-
break;
|
|
7707
|
-
}
|
|
7708
|
-
}
|
|
7709
|
-
return i;
|
|
7710
|
-
}
|
|
7711
|
-
function isFilled(e, t) {
|
|
7712
|
-
return getFilledLength(e, t) === e.mask.length;
|
|
7713
|
-
}
|
|
7714
|
-
function formatValue(e, t) {
|
|
7715
|
-
var n = e.maskChar,
|
|
7716
|
-
a = e.mask,
|
|
7717
|
-
i = e.prefix;
|
|
7718
|
-
if (!n) {
|
|
7719
|
-
for ((t = insertString(e, "", t, 0)).length < i.length && (t = i); t.length < a.length && isPermanentCharacter(e, t.length);) t += a[t.length];
|
|
7720
|
-
return t;
|
|
7721
|
-
}
|
|
7722
|
-
if (t) return insertString(e, formatValue(e, ""), t, 0);
|
|
7723
|
-
for (var r = 0; r < a.length; r++) isPermanentCharacter(e, r) ? t += a[r] : t += n;
|
|
7724
|
-
return t;
|
|
7725
|
-
}
|
|
7726
|
-
function clearRange(n, e, a, t) {
|
|
7727
|
-
var i = a + t,
|
|
7728
|
-
r = n.maskChar,
|
|
7729
|
-
o = n.mask,
|
|
7730
|
-
s = n.prefix,
|
|
7731
|
-
l = e.split("");
|
|
7732
|
-
if (r) return l.map(function (e, t) {
|
|
7733
|
-
return t < a || i <= t ? e : isPermanentCharacter(n, t) ? o[t] : r;
|
|
7734
|
-
}).join("");
|
|
7735
|
-
for (var u = i; u < l.length; u++) isPermanentCharacter(n, u) && (l[u] = "");
|
|
7736
|
-
return a = Math.max(s.length, a), l.splice(a, i - a), e = l.join(""), formatValue(n, e);
|
|
7737
|
-
}
|
|
7738
|
-
function insertString(r, o, e, s) {
|
|
7739
|
-
var l = r.mask,
|
|
7740
|
-
u = r.maskChar,
|
|
7741
|
-
c = r.prefix,
|
|
7742
|
-
t = e.split(""),
|
|
7743
|
-
h = isFilled(r, o);
|
|
7744
|
-
return !u && s > o.length && (o += l.slice(o.length, s)), t.every(function (e) {
|
|
7745
|
-
for (; i = e, isPermanentCharacter(r, a = s) && i !== l[a];) {
|
|
7746
|
-
if (s >= o.length && (o += l[s]), t = e, n = s, u && isPermanentCharacter(r, n) && t === u) return !0;
|
|
7747
|
-
if (++s >= l.length) return !1;
|
|
7748
|
-
}
|
|
7749
|
-
var t, n, a, i;
|
|
7750
|
-
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);
|
|
7751
|
-
}), o;
|
|
7752
|
-
}
|
|
7753
|
-
function getInsertStringLength(a, e, t, i) {
|
|
7754
|
-
var r = a.mask,
|
|
7755
|
-
o = a.maskChar,
|
|
7756
|
-
n = t.split(""),
|
|
7757
|
-
s = i;
|
|
7758
|
-
return n.every(function (e) {
|
|
7759
|
-
for (; n = e, isPermanentCharacter(a, t = i) && n !== r[t];) if (++i >= r.length) return !1;
|
|
7760
|
-
var t, n;
|
|
7761
|
-
return (isAllowedCharacter(a, i, e) || e === o) && i++, i < r.length;
|
|
7762
|
-
}), i - s;
|
|
7763
|
-
}
|
|
7764
|
-
function getLeftEditablePosition(e, t) {
|
|
7765
|
-
for (var n = t; 0 <= n; --n) if (!isPermanentCharacter(e, n)) return n;
|
|
7766
|
-
return null;
|
|
7767
|
-
}
|
|
7768
|
-
function getRightEditablePosition(e, t) {
|
|
7769
|
-
for (var n = e.mask, a = t; a < n.length; ++a) if (!isPermanentCharacter(e, a)) return a;
|
|
7770
|
-
return null;
|
|
7771
|
-
}
|
|
7772
|
-
function getStringValue(e) {
|
|
7773
|
-
return e || 0 === e ? e + "" : "";
|
|
7774
|
-
}
|
|
7775
|
-
function processChange(e, t, n, a, i) {
|
|
7776
|
-
var r = e.mask,
|
|
7777
|
-
o = e.prefix,
|
|
7778
|
-
s = e.lastEditablePosition,
|
|
7779
|
-
l = t,
|
|
7780
|
-
u = "",
|
|
7781
|
-
c = 0,
|
|
7782
|
-
h = 0,
|
|
7783
|
-
f = Math.min(i.start, n.start);
|
|
7784
|
-
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) {
|
|
7785
|
-
if (1 === h && !i.length) f = i.start === n.start ? getRightEditablePosition(e, n.start) : getLeftEditablePosition(e, n.start);
|
|
7786
|
-
l = clearRange(e, l, f, h);
|
|
7787
|
-
}
|
|
7788
|
-
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), {
|
|
7789
|
-
value: l = formatValue(e, l),
|
|
7790
|
-
enteredString: u,
|
|
7791
|
-
selection: {
|
|
7792
|
-
start: f,
|
|
7793
|
-
end: f
|
|
7794
|
-
}
|
|
7795
|
-
};
|
|
7796
|
-
}
|
|
7797
|
-
function isWindowsPhoneBrowser() {
|
|
7798
|
-
var e = new RegExp("windows", "i"),
|
|
7799
|
-
t = new RegExp("phone", "i"),
|
|
7800
|
-
n = navigator.userAgent;
|
|
7801
|
-
return e.test(n) && t.test(n);
|
|
7802
|
-
}
|
|
7803
|
-
function isFunction(e) {
|
|
7804
|
-
return "function" == typeof e;
|
|
7805
|
-
}
|
|
7806
|
-
function getRequestAnimationFrame() {
|
|
7807
|
-
return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame;
|
|
7808
|
-
}
|
|
7809
|
-
function getCancelAnimationFrame() {
|
|
7810
|
-
return window.cancelAnimationFrame || window.webkitCancelRequestAnimationFrame || window.webkitCancelAnimationFrame || window.mozCancelAnimationFrame;
|
|
7811
|
-
}
|
|
7812
|
-
function defer(e) {
|
|
7813
|
-
return (!!getCancelAnimationFrame() ? getRequestAnimationFrame() : function () {
|
|
7814
|
-
return setTimeout(e, 1e3 / 60);
|
|
7815
|
-
})(e);
|
|
7816
|
-
}
|
|
7817
|
-
function cancelDefer(e) {
|
|
7818
|
-
(getCancelAnimationFrame() || clearTimeout)(e);
|
|
7819
|
-
}
|
|
7820
|
-
var InputElement = function (c) {
|
|
7821
|
-
function e(e) {
|
|
7822
|
-
var f = c.call(this, e) || this;
|
|
7823
|
-
f.focused = !1, f.mounted = !1, f.previousSelection = null, f.selectionDeferId = null, f.saveSelectionLoopDeferId = null, f.saveSelectionLoop = function () {
|
|
7824
|
-
f.previousSelection = f.getSelection(), f.saveSelectionLoopDeferId = defer(f.saveSelectionLoop);
|
|
7825
|
-
}, f.runSaveSelectionLoop = function () {
|
|
7826
|
-
null === f.saveSelectionLoopDeferId && f.saveSelectionLoop();
|
|
7827
|
-
}, f.stopSaveSelectionLoop = function () {
|
|
7828
|
-
null !== f.saveSelectionLoopDeferId && (cancelDefer(f.saveSelectionLoopDeferId), f.saveSelectionLoopDeferId = null, f.previousSelection = null);
|
|
7829
|
-
}, f.getInputDOMNode = function () {
|
|
7830
|
-
if (!f.mounted) return null;
|
|
7831
|
-
var e = reactDom.findDOMNode(_assertThisInitialized(_assertThisInitialized(f))),
|
|
7832
|
-
t = "undefined" != typeof window && e instanceof window.Element;
|
|
7833
|
-
if (e && !t) return null;
|
|
7834
|
-
if ("INPUT" !== e.nodeName && (e = e.querySelector("input")), !e) throw new Error("react-input-mask: inputComponent doesn't contain input node");
|
|
7835
|
-
return e;
|
|
7836
|
-
}, f.getInputValue = function () {
|
|
7837
|
-
var e = f.getInputDOMNode();
|
|
7838
|
-
return e ? e.value : null;
|
|
7839
|
-
}, f.setInputValue = function (e) {
|
|
7840
|
-
var t = f.getInputDOMNode();
|
|
7841
|
-
t && (f.value = e, t.value = e);
|
|
7842
|
-
}, f.setCursorToEnd = function () {
|
|
7843
|
-
var e = getFilledLength(f.maskOptions, f.value),
|
|
7844
|
-
t = getRightEditablePosition(f.maskOptions, e);
|
|
7845
|
-
null !== t && f.setCursorPosition(t);
|
|
7846
|
-
}, f.setSelection = function (e, t, n) {
|
|
7847
|
-
void 0 === n && (n = {});
|
|
7848
|
-
var a = f.getInputDOMNode(),
|
|
7849
|
-
i = f.isFocused();
|
|
7850
|
-
a && i && (n.deferred || setInputSelection(a, e, t), null !== f.selectionDeferId && cancelDefer(f.selectionDeferId), f.selectionDeferId = defer(function () {
|
|
7851
|
-
f.selectionDeferId = null, setInputSelection(a, e, t);
|
|
7852
|
-
}), f.previousSelection = {
|
|
7853
|
-
start: e,
|
|
7854
|
-
end: t,
|
|
7855
|
-
length: Math.abs(t - e)
|
|
7856
|
-
});
|
|
7857
|
-
}, f.getSelection = function () {
|
|
7858
|
-
return getInputSelection(f.getInputDOMNode());
|
|
7859
|
-
}, f.getCursorPosition = function () {
|
|
7860
|
-
return f.getSelection().start;
|
|
7861
|
-
}, f.setCursorPosition = function (e) {
|
|
7862
|
-
f.setSelection(e, e);
|
|
7863
|
-
}, f.isFocused = function () {
|
|
7864
|
-
return f.focused;
|
|
7865
|
-
}, f.getBeforeMaskedValueChangeConfig = function () {
|
|
7866
|
-
var e = f.maskOptions,
|
|
7867
|
-
t = e.mask,
|
|
7868
|
-
n = e.maskChar,
|
|
7869
|
-
a = e.permanents,
|
|
7870
|
-
i = e.formatChars;
|
|
7871
|
-
return {
|
|
7872
|
-
mask: t,
|
|
7873
|
-
maskChar: n,
|
|
7874
|
-
permanents: a,
|
|
7875
|
-
alwaysShowMask: !!f.props.alwaysShowMask,
|
|
7876
|
-
formatChars: i
|
|
7877
|
-
};
|
|
7878
|
-
}, f.isInputAutofilled = function (e, t, n, a) {
|
|
7879
|
-
var i = f.getInputDOMNode();
|
|
7880
|
-
try {
|
|
7881
|
-
if (i.matches(":-webkit-autofill")) return !0;
|
|
7882
|
-
} catch (r) {}
|
|
7883
|
-
return !f.focused || a.end < n.length && t.end === e.length;
|
|
7884
|
-
}, f.onChange = function (e) {
|
|
7885
|
-
var t = _assertThisInitialized(_assertThisInitialized(f)).beforePasteState,
|
|
7886
|
-
n = _assertThisInitialized(_assertThisInitialized(f)).previousSelection,
|
|
7887
|
-
a = f.props.beforeMaskedValueChange,
|
|
7888
|
-
i = f.getInputValue(),
|
|
7889
|
-
r = f.value,
|
|
7890
|
-
o = f.getSelection();
|
|
7891
|
-
f.isInputAutofilled(i, o, r, n) && (r = formatValue(f.maskOptions, ""), n = {
|
|
7892
|
-
start: 0,
|
|
7893
|
-
end: 0,
|
|
7894
|
-
length: 0
|
|
7895
|
-
}), t && (n = t.selection, r = t.value, o = {
|
|
7896
|
-
start: n.start + i.length,
|
|
7897
|
-
end: n.start + i.length,
|
|
7898
|
-
length: 0
|
|
7899
|
-
}, i = r.slice(0, n.start) + i + r.slice(n.end), f.beforePasteState = null);
|
|
7900
|
-
var s = processChange(f.maskOptions, i, o, r, n),
|
|
7901
|
-
l = s.enteredString,
|
|
7902
|
-
u = s.selection,
|
|
7903
|
-
c = s.value;
|
|
7904
|
-
if (isFunction(a)) {
|
|
7905
|
-
var h = a({
|
|
7906
|
-
value: c,
|
|
7907
|
-
selection: u
|
|
7908
|
-
}, {
|
|
7909
|
-
value: r,
|
|
7910
|
-
selection: n
|
|
7911
|
-
}, l, f.getBeforeMaskedValueChangeConfig());
|
|
7912
|
-
c = h.value, u = h.selection;
|
|
7913
|
-
}
|
|
7914
|
-
f.setInputValue(c), isFunction(f.props.onChange) && f.props.onChange(e), f.isWindowsPhoneBrowser ? f.setSelection(u.start, u.end, {
|
|
7915
|
-
deferred: !0
|
|
7916
|
-
}) : f.setSelection(u.start, u.end);
|
|
7917
|
-
}, f.onFocus = function (e) {
|
|
7918
|
-
var t = f.props.beforeMaskedValueChange,
|
|
7919
|
-
n = f.maskOptions,
|
|
7920
|
-
a = n.mask,
|
|
7921
|
-
i = n.prefix;
|
|
7922
|
-
if (f.focused = !0, f.mounted = !0, a) {
|
|
7923
|
-
if (f.value) getFilledLength(f.maskOptions, f.value) < f.maskOptions.mask.length && f.setCursorToEnd();else {
|
|
7924
|
-
var r = formatValue(f.maskOptions, i),
|
|
7925
|
-
o = formatValue(f.maskOptions, r),
|
|
7926
|
-
s = getFilledLength(f.maskOptions, o),
|
|
7927
|
-
l = getRightEditablePosition(f.maskOptions, s),
|
|
7928
|
-
u = {
|
|
7929
|
-
start: l,
|
|
7930
|
-
end: l
|
|
7931
|
-
};
|
|
7932
|
-
if (isFunction(t)) {
|
|
7933
|
-
var c = t({
|
|
7934
|
-
value: o,
|
|
7935
|
-
selection: u
|
|
7936
|
-
}, {
|
|
7937
|
-
value: f.value,
|
|
7938
|
-
selection: null
|
|
7939
|
-
}, null, f.getBeforeMaskedValueChangeConfig());
|
|
7940
|
-
o = c.value, u = c.selection;
|
|
7941
|
-
}
|
|
7942
|
-
var h = o !== f.getInputValue();
|
|
7943
|
-
h && f.setInputValue(o), h && isFunction(f.props.onChange) && f.props.onChange(e), f.setSelection(u.start, u.end);
|
|
7944
|
-
}
|
|
7945
|
-
f.runSaveSelectionLoop();
|
|
7946
|
-
}
|
|
7947
|
-
isFunction(f.props.onFocus) && f.props.onFocus(e);
|
|
7948
|
-
}, f.onBlur = function (e) {
|
|
7949
|
-
var t = f.props.beforeMaskedValueChange,
|
|
7950
|
-
n = f.maskOptions.mask;
|
|
7951
|
-
if (f.stopSaveSelectionLoop(), f.focused = !1, n && !f.props.alwaysShowMask && isEmpty(f.maskOptions, f.value)) {
|
|
7952
|
-
var a = "";
|
|
7953
|
-
if (isFunction(t)) a = t({
|
|
7954
|
-
value: a,
|
|
7955
|
-
selection: null
|
|
7956
|
-
}, {
|
|
7957
|
-
value: f.value,
|
|
7958
|
-
selection: f.previousSelection
|
|
7959
|
-
}, null, f.getBeforeMaskedValueChangeConfig()).value;
|
|
7960
|
-
var i = a !== f.getInputValue();
|
|
7961
|
-
i && f.setInputValue(a), i && isFunction(f.props.onChange) && f.props.onChange(e);
|
|
7962
|
-
}
|
|
7963
|
-
isFunction(f.props.onBlur) && f.props.onBlur(e);
|
|
7964
|
-
}, f.onMouseDown = function (e) {
|
|
7965
|
-
if (!f.focused && document.addEventListener) {
|
|
7966
|
-
f.mouseDownX = e.clientX, f.mouseDownY = e.clientY, f.mouseDownTime = new Date().getTime();
|
|
7967
|
-
var r = function r(e) {
|
|
7968
|
-
if (document.removeEventListener("mouseup", r), f.focused) {
|
|
7969
|
-
var t = Math.abs(e.clientX - f.mouseDownX),
|
|
7970
|
-
n = Math.abs(e.clientY - f.mouseDownY),
|
|
7971
|
-
a = Math.max(t, n),
|
|
7972
|
-
i = new Date().getTime() - f.mouseDownTime;
|
|
7973
|
-
(a <= 10 && i <= 200 || a <= 5 && i <= 300) && f.setCursorToEnd();
|
|
7974
|
-
}
|
|
7975
|
-
};
|
|
7976
|
-
document.addEventListener("mouseup", r);
|
|
7977
|
-
}
|
|
7978
|
-
isFunction(f.props.onMouseDown) && f.props.onMouseDown(e);
|
|
7979
|
-
}, f.onPaste = function (e) {
|
|
7980
|
-
isFunction(f.props.onPaste) && f.props.onPaste(e), e.defaultPrevented || (f.beforePasteState = {
|
|
7981
|
-
value: f.getInputValue(),
|
|
7982
|
-
selection: f.getSelection()
|
|
7983
|
-
}, f.setInputValue(""));
|
|
7984
|
-
}, f.handleRef = function (e) {
|
|
7985
|
-
null == f.props.children && isFunction(f.props.inputRef) && f.props.inputRef(e);
|
|
7986
|
-
};
|
|
7987
|
-
var t = e.mask,
|
|
7988
|
-
n = e.maskChar,
|
|
7989
|
-
a = e.formatChars,
|
|
7990
|
-
i = e.alwaysShowMask,
|
|
7991
|
-
r = e.beforeMaskedValueChange,
|
|
7992
|
-
o = e.defaultValue,
|
|
7993
|
-
s = e.value;
|
|
7994
|
-
f.maskOptions = parseMask(t, n, a), null == o && (o = ""), null == s && (s = o);
|
|
7995
|
-
var l = getStringValue(s);
|
|
7996
|
-
if (f.maskOptions.mask && (i || l) && (l = formatValue(f.maskOptions, l), isFunction(r))) {
|
|
7997
|
-
var u = e.value;
|
|
7998
|
-
null == e.value && (u = o), l = r({
|
|
7999
|
-
value: l,
|
|
8000
|
-
selection: null
|
|
8001
|
-
}, {
|
|
8002
|
-
value: u = getStringValue(u),
|
|
8003
|
-
selection: null
|
|
8004
|
-
}, null, f.getBeforeMaskedValueChangeConfig()).value;
|
|
8005
|
-
}
|
|
8006
|
-
return f.value = l, f;
|
|
8007
|
-
}
|
|
8008
|
-
_inheritsLoose(e, c);
|
|
8009
|
-
var t = e.prototype;
|
|
8010
|
-
return t.componentDidMount = function () {
|
|
8011
|
-
this.mounted = !0, this.getInputDOMNode() && (this.isWindowsPhoneBrowser = isWindowsPhoneBrowser(), this.maskOptions.mask && this.getInputValue() !== this.value && this.setInputValue(this.value));
|
|
8012
|
-
}, t.componentDidUpdate = function () {
|
|
8013
|
-
var e = this.previousSelection,
|
|
8014
|
-
t = this.props,
|
|
8015
|
-
n = t.beforeMaskedValueChange,
|
|
8016
|
-
a = t.alwaysShowMask,
|
|
8017
|
-
i = t.mask,
|
|
8018
|
-
r = t.maskChar,
|
|
8019
|
-
o = t.formatChars,
|
|
8020
|
-
s = this.maskOptions,
|
|
8021
|
-
l = a || this.isFocused(),
|
|
8022
|
-
u = null != this.props.value,
|
|
8023
|
-
c = u ? getStringValue(this.props.value) : this.value,
|
|
8024
|
-
h = e ? e.start : null;
|
|
8025
|
-
if (this.maskOptions = parseMask(i, r, o), this.maskOptions.mask) {
|
|
8026
|
-
!s.mask && this.isFocused() && this.runSaveSelectionLoop();
|
|
8027
|
-
var f = this.maskOptions.mask && this.maskOptions.mask !== s.mask;
|
|
8028
|
-
if (s.mask || u || (c = this.getInputValue()), (f || this.maskOptions.mask && (c || l)) && (c = formatValue(this.maskOptions, c)), f) {
|
|
8029
|
-
var p = getFilledLength(this.maskOptions, c);
|
|
8030
|
-
(null === h || p < h) && (h = isFilled(this.maskOptions, c) ? p : getRightEditablePosition(this.maskOptions, p));
|
|
8031
|
-
}
|
|
8032
|
-
!this.maskOptions.mask || !isEmpty(this.maskOptions, c) || l || u && this.props.value || (c = "");
|
|
8033
|
-
var d = {
|
|
8034
|
-
start: h,
|
|
8035
|
-
end: h
|
|
8036
|
-
};
|
|
8037
|
-
if (isFunction(n)) {
|
|
8038
|
-
var m = n({
|
|
8039
|
-
value: c,
|
|
8040
|
-
selection: d
|
|
8041
|
-
}, {
|
|
8042
|
-
value: this.value,
|
|
8043
|
-
selection: this.previousSelection
|
|
8044
|
-
}, null, this.getBeforeMaskedValueChangeConfig());
|
|
8045
|
-
c = m.value, d = m.selection;
|
|
8046
|
-
}
|
|
8047
|
-
this.value = c;
|
|
8048
|
-
var g = this.getInputValue() !== this.value;
|
|
8049
|
-
g ? (this.setInputValue(this.value), this.forceUpdate()) : f && this.forceUpdate();
|
|
8050
|
-
var v = !1;
|
|
8051
|
-
null != d.start && null != d.end && (v = !e || e.start !== d.start || e.end !== d.end), (v || g) && this.setSelection(d.start, d.end);
|
|
8052
|
-
} else s.mask && (this.stopSaveSelectionLoop(), this.forceUpdate());
|
|
8053
|
-
}, t.componentWillUnmount = function () {
|
|
8054
|
-
this.mounted = !1, null !== this.selectionDeferId && cancelDefer(this.selectionDeferId), this.stopSaveSelectionLoop();
|
|
8055
|
-
}, t.render = function () {
|
|
8056
|
-
var t,
|
|
8057
|
-
e = this.props,
|
|
8058
|
-
n = (e.mask, e.alwaysShowMask, e.maskChar, e.formatChars, e.inputRef, e.beforeMaskedValueChange, e.children),
|
|
8059
|
-
a = _objectWithoutPropertiesLoose(e, ["mask", "alwaysShowMask", "maskChar", "formatChars", "inputRef", "beforeMaskedValueChange", "children"]);
|
|
8060
|
-
if (n) {
|
|
8061
|
-
isFunction(n) || invariant_1(!1);
|
|
8062
|
-
var i = ["onChange", "onPaste", "onMouseDown", "onFocus", "onBlur", "value", "disabled", "readOnly"],
|
|
8063
|
-
r = _extends({}, a);
|
|
8064
|
-
i.forEach(function (e) {
|
|
8065
|
-
return delete r[e];
|
|
8066
|
-
}), t = n(r), i.filter(function (e) {
|
|
8067
|
-
return null != t.props[e] && t.props[e] !== a[e];
|
|
8068
|
-
}).length && invariant_1(!1);
|
|
8069
|
-
} else t = React$1.createElement("input", _extends({
|
|
8070
|
-
ref: this.handleRef
|
|
8071
|
-
}, a));
|
|
8072
|
-
var o = {
|
|
8073
|
-
onFocus: this.onFocus,
|
|
8074
|
-
onBlur: this.onBlur
|
|
8075
|
-
};
|
|
8076
|
-
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$1.cloneElement(t, o);
|
|
8077
|
-
}, e;
|
|
8078
|
-
}(React$1.Component);
|
|
8079
|
-
reactInputMask_production_min = InputElement;
|
|
8080
|
-
return reactInputMask_production_min;
|
|
8081
|
-
}
|
|
7879
|
+
var reactInputMask_production_min = {exports: {}};
|
|
8082
7880
|
|
|
8083
7881
|
/**
|
|
8084
7882
|
* Copyright (c) 2013-present, Facebook, Inc.
|
|
@@ -8190,31 +7988,527 @@ function requireWarning() {
|
|
|
8190
7988
|
return warning_1;
|
|
8191
7989
|
}
|
|
8192
7990
|
|
|
7991
|
+
var hasRequiredReactInputMask_production_min;
|
|
7992
|
+
function requireReactInputMask_production_min() {
|
|
7993
|
+
if (hasRequiredReactInputMask_production_min) return reactInputMask_production_min.exports;
|
|
7994
|
+
hasRequiredReactInputMask_production_min = 1;
|
|
7995
|
+
var e = React;
|
|
7996
|
+
var t = requireInvariant();
|
|
7997
|
+
function n() {
|
|
7998
|
+
return n = Object.assign ? Object.assign.bind() : function (e) {
|
|
7999
|
+
for (var t = 1; t < arguments.length; t++) {
|
|
8000
|
+
var n = arguments[t];
|
|
8001
|
+
for (var i in n) Object.prototype.hasOwnProperty.call(n, i) && (e[i] = n[i]);
|
|
8002
|
+
}
|
|
8003
|
+
return e;
|
|
8004
|
+
}, n.apply(this, arguments);
|
|
8005
|
+
}
|
|
8006
|
+
function i(e) {
|
|
8007
|
+
return requestAnimationFrame(e);
|
|
8008
|
+
}
|
|
8009
|
+
function r(e) {
|
|
8010
|
+
cancelAnimationFrame(e);
|
|
8011
|
+
}
|
|
8012
|
+
function a(e) {
|
|
8013
|
+
var t = e.ownerDocument;
|
|
8014
|
+
return t.hasFocus() && t.activeElement === e;
|
|
8015
|
+
}
|
|
8016
|
+
function l(e) {
|
|
8017
|
+
return null == e ? void 0 : e.ownerDocument;
|
|
8018
|
+
}
|
|
8019
|
+
function o(e) {
|
|
8020
|
+
var t = function (e) {
|
|
8021
|
+
var t;
|
|
8022
|
+
return null == (t = l(e)) ? void 0 : t.defaultView;
|
|
8023
|
+
}(e);
|
|
8024
|
+
return !!t && e instanceof t.HTMLElement;
|
|
8025
|
+
}
|
|
8026
|
+
function u(t) {
|
|
8027
|
+
return e.useCallback(function () {
|
|
8028
|
+
var e = t.current,
|
|
8029
|
+
n = "undefined" != typeof window && o(e);
|
|
8030
|
+
if (!e || !n) return null;
|
|
8031
|
+
if ("INPUT" !== e.nodeName && (e = e.querySelector("input")), !e) throw new Error("react-input-mask: inputComponent doesn't contain input node");
|
|
8032
|
+
return e;
|
|
8033
|
+
}, [t]);
|
|
8034
|
+
}
|
|
8035
|
+
function s(t, n) {
|
|
8036
|
+
var l,
|
|
8037
|
+
o,
|
|
8038
|
+
s,
|
|
8039
|
+
c,
|
|
8040
|
+
f = e.useRef({
|
|
8041
|
+
start: null,
|
|
8042
|
+
end: null
|
|
8043
|
+
}),
|
|
8044
|
+
h = u(t),
|
|
8045
|
+
g = e.useCallback(function () {
|
|
8046
|
+
return function (e) {
|
|
8047
|
+
var t = e.selectionStart,
|
|
8048
|
+
n = e.selectionEnd;
|
|
8049
|
+
return {
|
|
8050
|
+
start: t,
|
|
8051
|
+
end: n,
|
|
8052
|
+
length: n - t
|
|
8053
|
+
};
|
|
8054
|
+
}(h());
|
|
8055
|
+
}, [h]),
|
|
8056
|
+
v = e.useCallback(function () {
|
|
8057
|
+
return f.current;
|
|
8058
|
+
}, []),
|
|
8059
|
+
d = e.useCallback(function (e) {
|
|
8060
|
+
var t = h();
|
|
8061
|
+
t && a(t) && (!function (e, t, n) {
|
|
8062
|
+
void 0 === n && (n = t), e.setSelectionRange(t, n);
|
|
8063
|
+
}(t, e.start, e.end), f.current = g());
|
|
8064
|
+
}, [h, g]),
|
|
8065
|
+
m = e.useCallback(function () {
|
|
8066
|
+
f.current = g();
|
|
8067
|
+
}, [g]),
|
|
8068
|
+
p = (l = m, o = e.useRef(null), s = e.useCallback(function () {
|
|
8069
|
+
null === o.current && function e() {
|
|
8070
|
+
l(), o.current = i(e);
|
|
8071
|
+
}();
|
|
8072
|
+
}, [l]), c = e.useCallback(function () {
|
|
8073
|
+
r(o.current), o.current = null;
|
|
8074
|
+
}, []), e.useEffect(function () {
|
|
8075
|
+
o.current && (c(), s());
|
|
8076
|
+
}, [s, c]), e.useEffect(r, []), [s, c]),
|
|
8077
|
+
k = p[0],
|
|
8078
|
+
P = p[1];
|
|
8079
|
+
return e.useLayoutEffect(function () {
|
|
8080
|
+
if (n) {
|
|
8081
|
+
var e = h();
|
|
8082
|
+
return e.addEventListener("focus", k), e.addEventListener("blur", P), a(e) && k(), function () {
|
|
8083
|
+
e.removeEventListener("focus", k), e.removeEventListener("blur", P), P();
|
|
8084
|
+
};
|
|
8085
|
+
}
|
|
8086
|
+
}), {
|
|
8087
|
+
getSelection: g,
|
|
8088
|
+
getLastSelection: v,
|
|
8089
|
+
setSelection: d
|
|
8090
|
+
};
|
|
8091
|
+
}
|
|
8092
|
+
function c(t, n) {
|
|
8093
|
+
var i = e.useRef(),
|
|
8094
|
+
r = s(i, n),
|
|
8095
|
+
a = r.getSelection,
|
|
8096
|
+
l = r.getLastSelection,
|
|
8097
|
+
o = r.setSelection,
|
|
8098
|
+
c = function (t, n) {
|
|
8099
|
+
var i = u(t),
|
|
8100
|
+
r = e.useRef(n);
|
|
8101
|
+
return {
|
|
8102
|
+
getValue: e.useCallback(function () {
|
|
8103
|
+
return i().value;
|
|
8104
|
+
}, [i]),
|
|
8105
|
+
getLastValue: e.useCallback(function () {
|
|
8106
|
+
return r.current;
|
|
8107
|
+
}, []),
|
|
8108
|
+
setValue: e.useCallback(function (e) {
|
|
8109
|
+
r.current = e;
|
|
8110
|
+
var t = i();
|
|
8111
|
+
t && (t.value = e);
|
|
8112
|
+
}, [i])
|
|
8113
|
+
};
|
|
8114
|
+
}(i, t),
|
|
8115
|
+
f = c.getValue,
|
|
8116
|
+
h = c.getLastValue,
|
|
8117
|
+
g = c.setValue;
|
|
8118
|
+
return {
|
|
8119
|
+
inputRef: i,
|
|
8120
|
+
getInputState: function getInputState() {
|
|
8121
|
+
return {
|
|
8122
|
+
value: f(),
|
|
8123
|
+
selection: a()
|
|
8124
|
+
};
|
|
8125
|
+
},
|
|
8126
|
+
getLastInputState: function getLastInputState() {
|
|
8127
|
+
return {
|
|
8128
|
+
value: h(),
|
|
8129
|
+
selection: l()
|
|
8130
|
+
};
|
|
8131
|
+
},
|
|
8132
|
+
setInputState: function setInputState(e) {
|
|
8133
|
+
var t = e.value,
|
|
8134
|
+
n = e.selection;
|
|
8135
|
+
g(t), o(n);
|
|
8136
|
+
}
|
|
8137
|
+
};
|
|
8138
|
+
}
|
|
8139
|
+
requireWarning();
|
|
8140
|
+
var f = ["disabled", "onBlur", "onChange", "onFocus", "onMouseDown", "readOnly", "value"],
|
|
8141
|
+
h = {
|
|
8142
|
+
9: /[0-9]/,
|
|
8143
|
+
a: /[A-Za-z]/,
|
|
8144
|
+
"*": /[A-Za-z0-9]/
|
|
8145
|
+
};
|
|
8146
|
+
var g = function g(e) {
|
|
8147
|
+
var t = this;
|
|
8148
|
+
this.isCharacterAllowedAtPosition = function (e, n) {
|
|
8149
|
+
var i = t.maskOptions.maskPlaceholder;
|
|
8150
|
+
return !!t.isCharacterFillingPosition(e, n) || !!i && i[n] === e;
|
|
8151
|
+
}, this.isCharacterFillingPosition = function (e, n) {
|
|
8152
|
+
var i = t.maskOptions.mask;
|
|
8153
|
+
if (!e || n >= i.length) return false;
|
|
8154
|
+
if (!t.isPositionEditable(n)) return i[n] === e;
|
|
8155
|
+
var r = i[n];
|
|
8156
|
+
return new RegExp(r).test(e);
|
|
8157
|
+
}, this.isPositionEditable = function (e) {
|
|
8158
|
+
var n = t.maskOptions,
|
|
8159
|
+
i = n.mask,
|
|
8160
|
+
r = n.permanents;
|
|
8161
|
+
return e < i.length && -1 === r.indexOf(e);
|
|
8162
|
+
}, this.isValueEmpty = function (e) {
|
|
8163
|
+
return e.split("").every(function (e, n) {
|
|
8164
|
+
return !t.isPositionEditable(n) || !t.isCharacterFillingPosition(e, n);
|
|
8165
|
+
});
|
|
8166
|
+
}, this.isValueFilled = function (e) {
|
|
8167
|
+
return t.getFilledLength(e) === t.maskOptions.lastEditablePosition + 1;
|
|
8168
|
+
}, this.getDefaultSelectionForValue = function (e) {
|
|
8169
|
+
var n = t.getFilledLength(e),
|
|
8170
|
+
i = t.getRightEditablePosition(n);
|
|
8171
|
+
return {
|
|
8172
|
+
start: i,
|
|
8173
|
+
end: i
|
|
8174
|
+
};
|
|
8175
|
+
}, this.getFilledLength = function (e) {
|
|
8176
|
+
return function (e, t) {
|
|
8177
|
+
for (var n = e.length - 1; n >= 0; n--) if (t(e[n], n)) return n;
|
|
8178
|
+
return -1;
|
|
8179
|
+
}(e.split(""), function (e, n) {
|
|
8180
|
+
return t.isPositionEditable(n) && t.isCharacterFillingPosition(e, n);
|
|
8181
|
+
}) + 1;
|
|
8182
|
+
}, this.getStringFillingLengthAtPosition = function (e, n) {
|
|
8183
|
+
return e.split("").reduce(function (e, n) {
|
|
8184
|
+
return t.insertCharacterAtPosition(e, n, e.length);
|
|
8185
|
+
}, function (e, t) {
|
|
8186
|
+
void 0 === t && (t = 1);
|
|
8187
|
+
for (var n = "", i = 0; i < t; i++) n += e;
|
|
8188
|
+
return n;
|
|
8189
|
+
}(" ", n)).length - n;
|
|
8190
|
+
}, this.getLeftEditablePosition = function (e) {
|
|
8191
|
+
for (var n = e; n >= 0; n--) if (t.isPositionEditable(n)) return n;
|
|
8192
|
+
return null;
|
|
8193
|
+
}, this.getRightEditablePosition = function (e) {
|
|
8194
|
+
for (var n = t.maskOptions.mask, i = e; i < n.length; i++) if (t.isPositionEditable(i)) return i;
|
|
8195
|
+
return null;
|
|
8196
|
+
}, this.formatValue = function (e) {
|
|
8197
|
+
var n = t.maskOptions,
|
|
8198
|
+
i = n.maskPlaceholder,
|
|
8199
|
+
r = n.mask;
|
|
8200
|
+
if (!i) {
|
|
8201
|
+
for (e = t.insertStringAtPosition("", e, 0); e.length < r.length && !t.isPositionEditable(e.length);) e += r[e.length];
|
|
8202
|
+
return e;
|
|
8203
|
+
}
|
|
8204
|
+
return t.insertStringAtPosition(i, e, 0);
|
|
8205
|
+
}, this.clearRange = function (e, n, i) {
|
|
8206
|
+
if (!i) return e;
|
|
8207
|
+
var r = n + i,
|
|
8208
|
+
a = t.maskOptions,
|
|
8209
|
+
l = a.maskPlaceholder,
|
|
8210
|
+
o = a.mask,
|
|
8211
|
+
u = e.split("").map(function (e, i) {
|
|
8212
|
+
var a = t.isPositionEditable(i);
|
|
8213
|
+
return !l && i >= r && !a ? "" : i < n || i >= r ? e : a ? l ? l[i] : "" : o[i];
|
|
8214
|
+
}).join("");
|
|
8215
|
+
return t.formatValue(u);
|
|
8216
|
+
}, this.insertCharacterAtPosition = function (e, n, i) {
|
|
8217
|
+
var r = t.maskOptions,
|
|
8218
|
+
a = r.mask,
|
|
8219
|
+
l = r.maskPlaceholder;
|
|
8220
|
+
if (i >= a.length) return e;
|
|
8221
|
+
var o = t.isCharacterAllowedAtPosition(n, i),
|
|
8222
|
+
u = t.isPositionEditable(i),
|
|
8223
|
+
s = t.getRightEditablePosition(i),
|
|
8224
|
+
c = l && s ? n === l[s] : null,
|
|
8225
|
+
f = e.slice(0, i);
|
|
8226
|
+
!o && u || (e = f + (o ? n : a[i]));
|
|
8227
|
+
return o || u || c || (e = t.insertCharacterAtPosition(e, n, i + 1)), e;
|
|
8228
|
+
}, this.insertStringAtPosition = function (e, n, i) {
|
|
8229
|
+
var r = t.maskOptions,
|
|
8230
|
+
a = r.mask,
|
|
8231
|
+
l = r.maskPlaceholder;
|
|
8232
|
+
if (!n || i >= a.length) return e;
|
|
8233
|
+
var o = n.split(""),
|
|
8234
|
+
u = t.isValueFilled(e) || !!l,
|
|
8235
|
+
s = e.slice(i);
|
|
8236
|
+
if (e = o.reduce(function (e, n) {
|
|
8237
|
+
return t.insertCharacterAtPosition(e, n, e.length);
|
|
8238
|
+
}, e.slice(0, i)), u) e += s.slice(e.length - i);else if (t.isValueFilled(e)) e += a.slice(e.length).join("");else {
|
|
8239
|
+
e = s.split("").filter(function (e, n) {
|
|
8240
|
+
return t.isPositionEditable(i + n);
|
|
8241
|
+
}).reduce(function (e, n) {
|
|
8242
|
+
var i = t.getRightEditablePosition(e.length);
|
|
8243
|
+
return null === i ? e : (t.isPositionEditable(e.length) || (e += a.slice(e.length, i).join("")), t.insertCharacterAtPosition(e, n, e.length));
|
|
8244
|
+
}, e);
|
|
8245
|
+
}
|
|
8246
|
+
return e;
|
|
8247
|
+
}, this.processChange = function (e, n) {
|
|
8248
|
+
var i = t.maskOptions,
|
|
8249
|
+
r = i.mask,
|
|
8250
|
+
a = i.prefix,
|
|
8251
|
+
l = i.lastEditablePosition,
|
|
8252
|
+
o = e.value,
|
|
8253
|
+
u = e.selection,
|
|
8254
|
+
s = n.value,
|
|
8255
|
+
c = n.selection,
|
|
8256
|
+
f = o,
|
|
8257
|
+
h = "",
|
|
8258
|
+
g = 0,
|
|
8259
|
+
v = 0,
|
|
8260
|
+
d = Math.min(c.start, u.start);
|
|
8261
|
+
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) {
|
|
8262
|
+
if (1 === v && !c.length) d = c.start === u.start ? t.getRightEditablePosition(u.start) : t.getLeftEditablePosition(u.start);
|
|
8263
|
+
f = t.clearRange(f, d, v);
|
|
8264
|
+
}
|
|
8265
|
+
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)), {
|
|
8266
|
+
value: f = t.formatValue(f),
|
|
8267
|
+
enteredString: h,
|
|
8268
|
+
selection: {
|
|
8269
|
+
start: d,
|
|
8270
|
+
end: d
|
|
8271
|
+
}
|
|
8272
|
+
};
|
|
8273
|
+
}, this.maskOptions = function (e) {
|
|
8274
|
+
var t = e.mask,
|
|
8275
|
+
n = e.maskPlaceholder,
|
|
8276
|
+
i = [];
|
|
8277
|
+
if (!t) return {
|
|
8278
|
+
maskPlaceholder: null,
|
|
8279
|
+
mask: null,
|
|
8280
|
+
prefix: null,
|
|
8281
|
+
lastEditablePosition: null,
|
|
8282
|
+
permanents: []
|
|
8283
|
+
};
|
|
8284
|
+
if ("string" == typeof t) {
|
|
8285
|
+
var r = false,
|
|
8286
|
+
a = "";
|
|
8287
|
+
t.split("").forEach(function (e) {
|
|
8288
|
+
r || "\\" !== e ? (!r && h[e] || i.push(a.length), a += e, r = false) : r = true;
|
|
8289
|
+
}), t = a.split("").map(function (e, t) {
|
|
8290
|
+
return -1 === i.indexOf(t) ? h[e] : e;
|
|
8291
|
+
});
|
|
8292
|
+
} else t.forEach(function (e, t) {
|
|
8293
|
+
"string" == typeof e && i.push(t);
|
|
8294
|
+
});
|
|
8295
|
+
n && (n = 1 === n.length ? t.map(function (e, t) {
|
|
8296
|
+
return -1 !== i.indexOf(t) ? e : n;
|
|
8297
|
+
}) : n.split(""), i.forEach(function (e) {
|
|
8298
|
+
n[e] = t[e];
|
|
8299
|
+
}), n = n.join(""));
|
|
8300
|
+
for (var l = i.filter(function (e, t) {
|
|
8301
|
+
return e === t;
|
|
8302
|
+
}).map(function (e) {
|
|
8303
|
+
return t[e];
|
|
8304
|
+
}).join(""), o = t.length - 1; -1 !== i.indexOf(o);) o--;
|
|
8305
|
+
return {
|
|
8306
|
+
maskPlaceholder: n,
|
|
8307
|
+
prefix: l,
|
|
8308
|
+
mask: t,
|
|
8309
|
+
lastEditablePosition: o,
|
|
8310
|
+
permanents: i
|
|
8311
|
+
};
|
|
8312
|
+
}(e);
|
|
8313
|
+
},
|
|
8314
|
+
v = ["alwaysShowMask", "children", "mask", "maskPlaceholder", "beforeMaskedStateChange"],
|
|
8315
|
+
d = e.forwardRef(function (r, o) {
|
|
8316
|
+
var s = r.alwaysShowMask,
|
|
8317
|
+
h = r.children,
|
|
8318
|
+
d = r.mask,
|
|
8319
|
+
m = r.maskPlaceholder,
|
|
8320
|
+
p = r.beforeMaskedStateChange,
|
|
8321
|
+
k = function (e, t) {
|
|
8322
|
+
if (null == e) return {};
|
|
8323
|
+
var n,
|
|
8324
|
+
i,
|
|
8325
|
+
r = {},
|
|
8326
|
+
a = Object.keys(e);
|
|
8327
|
+
for (i = 0; i < a.length; i++) n = a[i], t.indexOf(n) >= 0 || (r[n] = e[n]);
|
|
8328
|
+
return r;
|
|
8329
|
+
}(r, v);
|
|
8330
|
+
!function (e) {
|
|
8331
|
+
var n = e.mask,
|
|
8332
|
+
i = e.maskPlaceholder;
|
|
8333
|
+
n && i && 1 !== i.length && i.length !== n.length && t(false);
|
|
8334
|
+
}(r);
|
|
8335
|
+
var P,
|
|
8336
|
+
b,
|
|
8337
|
+
E = new g({
|
|
8338
|
+
mask: d,
|
|
8339
|
+
maskPlaceholder: m
|
|
8340
|
+
}),
|
|
8341
|
+
S = !!d,
|
|
8342
|
+
C = !k.disabled && !k.readOnly,
|
|
8343
|
+
w = null !== r.value && void 0 !== r.value,
|
|
8344
|
+
V = (P = S, b = e.useRef(), e.useEffect(function () {
|
|
8345
|
+
b.current = P;
|
|
8346
|
+
}), b.current),
|
|
8347
|
+
F = function (e) {
|
|
8348
|
+
return "" + e;
|
|
8349
|
+
}((w ? r.value : r.defaultValue) || ""),
|
|
8350
|
+
y = c(F, S),
|
|
8351
|
+
O = y.inputRef,
|
|
8352
|
+
L = y.getInputState,
|
|
8353
|
+
A = y.setInputState,
|
|
8354
|
+
R = y.getLastInputState,
|
|
8355
|
+
x = u(O);
|
|
8356
|
+
if (S && w) {
|
|
8357
|
+
var M = x(),
|
|
8358
|
+
D = M && a(M) || s || r.value ? E.formatValue(r.value) : r.value;
|
|
8359
|
+
p && (D = p({
|
|
8360
|
+
nextState: {
|
|
8361
|
+
value: D,
|
|
8362
|
+
selection: {
|
|
8363
|
+
start: null,
|
|
8364
|
+
end: null
|
|
8365
|
+
}
|
|
8366
|
+
}
|
|
8367
|
+
}).value), A(n({}, R(), {
|
|
8368
|
+
value: D
|
|
8369
|
+
}));
|
|
8370
|
+
}
|
|
8371
|
+
var j = R(),
|
|
8372
|
+
I = j.selection,
|
|
8373
|
+
q = j.value;
|
|
8374
|
+
e.useLayoutEffect(function () {
|
|
8375
|
+
if (S) {
|
|
8376
|
+
var e = x();
|
|
8377
|
+
if (e) {
|
|
8378
|
+
var t = a(e),
|
|
8379
|
+
i = I,
|
|
8380
|
+
r = L(),
|
|
8381
|
+
l = n({}, r);
|
|
8382
|
+
if (!w) {
|
|
8383
|
+
var o = r.value,
|
|
8384
|
+
u = E.formatValue(o),
|
|
8385
|
+
c = E.isValueEmpty(u);
|
|
8386
|
+
!c || t || s ? l.value = u : c && !t && (l.value = "");
|
|
8387
|
+
}
|
|
8388
|
+
t && !V ? l.selection = E.getDefaultSelectionForValue(l.value) : w && t && i && null !== i.start && null !== i.end && (l.selection = i), p && (l = p({
|
|
8389
|
+
currentState: r,
|
|
8390
|
+
nextState: l
|
|
8391
|
+
})), A(l);
|
|
8392
|
+
}
|
|
8393
|
+
}
|
|
8394
|
+
});
|
|
8395
|
+
var B = function B(e) {
|
|
8396
|
+
O.current = e, !function (e) {
|
|
8397
|
+
return "function" == typeof e;
|
|
8398
|
+
}(o) ? null !== o && "object" == _typeof$1(o) && (o.current = e) : o(e);
|
|
8399
|
+
},
|
|
8400
|
+
T = n({}, k, {
|
|
8401
|
+
onFocus: function onFocus(e) {
|
|
8402
|
+
O.current = e.target;
|
|
8403
|
+
var t = L().value;
|
|
8404
|
+
if (S && !E.isValueFilled(t)) {
|
|
8405
|
+
var n = E.formatValue(t),
|
|
8406
|
+
a = E.getDefaultSelectionForValue(n),
|
|
8407
|
+
l = {
|
|
8408
|
+
value: n,
|
|
8409
|
+
selection: a
|
|
8410
|
+
};
|
|
8411
|
+
p && (n = (l = p({
|
|
8412
|
+
currentState: L(),
|
|
8413
|
+
nextState: l
|
|
8414
|
+
})).value, a = l.selection), A(l), n !== t && r.onChange && r.onChange(e), i(function () {
|
|
8415
|
+
A(R());
|
|
8416
|
+
});
|
|
8417
|
+
}
|
|
8418
|
+
r.onFocus && r.onFocus(e);
|
|
8419
|
+
},
|
|
8420
|
+
onBlur: function onBlur(e) {
|
|
8421
|
+
var t = L().value,
|
|
8422
|
+
n = R().value;
|
|
8423
|
+
if (S && !s && E.isValueEmpty(n)) {
|
|
8424
|
+
var i = "",
|
|
8425
|
+
a = {
|
|
8426
|
+
value: i,
|
|
8427
|
+
selection: {
|
|
8428
|
+
start: null,
|
|
8429
|
+
end: null
|
|
8430
|
+
}
|
|
8431
|
+
};
|
|
8432
|
+
p && (i = (a = p({
|
|
8433
|
+
currentState: L(),
|
|
8434
|
+
nextState: a
|
|
8435
|
+
})).value), A(a), i !== t && r.onChange && r.onChange(e);
|
|
8436
|
+
}
|
|
8437
|
+
r.onBlur && r.onBlur(e);
|
|
8438
|
+
},
|
|
8439
|
+
onChange: S && C ? function (e) {
|
|
8440
|
+
var t = L(),
|
|
8441
|
+
n = R(),
|
|
8442
|
+
i = E.processChange(t, n);
|
|
8443
|
+
p && (i = p({
|
|
8444
|
+
currentState: t,
|
|
8445
|
+
previousState: n,
|
|
8446
|
+
nextState: i
|
|
8447
|
+
})), A(i), r.onChange && r.onChange(e);
|
|
8448
|
+
} : r.onChange,
|
|
8449
|
+
onMouseDown: S && C ? function (e) {
|
|
8450
|
+
var t = x();
|
|
8451
|
+
if (t) {
|
|
8452
|
+
var i = L().value,
|
|
8453
|
+
o = l(t);
|
|
8454
|
+
if (!a(t) && !E.isValueFilled(i)) {
|
|
8455
|
+
var u = e.clientX,
|
|
8456
|
+
s = e.clientY,
|
|
8457
|
+
c = new Date().getTime();
|
|
8458
|
+
o.addEventListener("mouseup", function e(i) {
|
|
8459
|
+
if (o.removeEventListener("mouseup", e), a(t)) {
|
|
8460
|
+
var r = Math.abs(i.clientX - u),
|
|
8461
|
+
l = Math.abs(i.clientY - s),
|
|
8462
|
+
f = Math.max(r, l),
|
|
8463
|
+
h = new Date().getTime() - c;
|
|
8464
|
+
if (f <= 10 && h <= 200 || f <= 5 && h <= 300) {
|
|
8465
|
+
var g = R(),
|
|
8466
|
+
v = n({}, g, {
|
|
8467
|
+
selection: E.getDefaultSelectionForValue(g.value)
|
|
8468
|
+
});
|
|
8469
|
+
A(v);
|
|
8470
|
+
}
|
|
8471
|
+
}
|
|
8472
|
+
});
|
|
8473
|
+
}
|
|
8474
|
+
r.onMouseDown && r.onMouseDown(e);
|
|
8475
|
+
}
|
|
8476
|
+
} : r.onMouseDown,
|
|
8477
|
+
value: S && w ? q : r.value
|
|
8478
|
+
});
|
|
8479
|
+
if (h) {
|
|
8480
|
+
!function (e, n) {
|
|
8481
|
+
f.filter(function (t) {
|
|
8482
|
+
return null != n.props[t] && n.props[t] !== e[t];
|
|
8483
|
+
}).length && t(false);
|
|
8484
|
+
}(r, h);
|
|
8485
|
+
var N = e.Children.only(h);
|
|
8486
|
+
return e.cloneElement(N, n({}, T, {
|
|
8487
|
+
ref: B
|
|
8488
|
+
}));
|
|
8489
|
+
}
|
|
8490
|
+
return e.createElement("input", n({
|
|
8491
|
+
ref: B
|
|
8492
|
+
}, T));
|
|
8493
|
+
});
|
|
8494
|
+
d.displayName = "InputMask", d.defaultProps = {
|
|
8495
|
+
alwaysShowMask: false,
|
|
8496
|
+
maskPlaceholder: "_"
|
|
8497
|
+
}, reactInputMask_production_min.exports = d;
|
|
8498
|
+
return reactInputMask_production_min.exports;
|
|
8499
|
+
}
|
|
8500
|
+
|
|
8193
8501
|
var reactInputMask_development;
|
|
8194
8502
|
var hasRequiredReactInputMask_development;
|
|
8195
8503
|
function requireReactInputMask_development() {
|
|
8196
8504
|
if (hasRequiredReactInputMask_development) return reactInputMask_development;
|
|
8197
8505
|
hasRequiredReactInputMask_development = 1;
|
|
8198
|
-
|
|
8199
|
-
|
|
8200
|
-
|
|
8201
|
-
var
|
|
8202
|
-
var reactDom = require$$1;
|
|
8203
|
-
var invariant = _interopDefault(requireInvariant());
|
|
8204
|
-
var warning = _interopDefault(requireWarning());
|
|
8205
|
-
function _defaults2(obj, defaults) {
|
|
8206
|
-
var keys = Object.getOwnPropertyNames(defaults);
|
|
8207
|
-
for (var i = 0; i < keys.length; i++) {
|
|
8208
|
-
var key = keys[i];
|
|
8209
|
-
var value = Object.getOwnPropertyDescriptor(defaults, key);
|
|
8210
|
-
if (value && value.configurable && obj[key] === undefined) {
|
|
8211
|
-
Object.defineProperty(obj, key, value);
|
|
8212
|
-
}
|
|
8213
|
-
}
|
|
8214
|
-
return obj;
|
|
8215
|
-
}
|
|
8506
|
+
var React$1 = React;
|
|
8507
|
+
var PropTypes = /*@__PURE__*/requirePropTypes();
|
|
8508
|
+
var invariant = requireInvariant();
|
|
8509
|
+
var warning = requireWarning();
|
|
8216
8510
|
function _extends() {
|
|
8217
|
-
_extends = Object.assign
|
|
8511
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
8218
8512
|
for (var i = 1; i < arguments.length; i++) {
|
|
8219
8513
|
var source = arguments[i];
|
|
8220
8514
|
for (var key in source) {
|
|
@@ -8227,11 +8521,6 @@ function requireReactInputMask_development() {
|
|
|
8227
8521
|
};
|
|
8228
8522
|
return _extends.apply(this, arguments);
|
|
8229
8523
|
}
|
|
8230
|
-
function _inheritsLoose(subClass, superClass) {
|
|
8231
|
-
subClass.prototype = Object.create(superClass.prototype);
|
|
8232
|
-
subClass.prototype.constructor = subClass;
|
|
8233
|
-
_defaults2(subClass, superClass);
|
|
8234
|
-
}
|
|
8235
8524
|
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
8236
8525
|
if (source == null) return {};
|
|
8237
8526
|
var target = {};
|
|
@@ -8244,895 +8533,825 @@ function requireReactInputMask_development() {
|
|
|
8244
8533
|
}
|
|
8245
8534
|
return target;
|
|
8246
8535
|
}
|
|
8247
|
-
function
|
|
8248
|
-
|
|
8249
|
-
|
|
8250
|
-
|
|
8251
|
-
|
|
8536
|
+
function defer(fn) {
|
|
8537
|
+
return requestAnimationFrame(fn);
|
|
8538
|
+
}
|
|
8539
|
+
function cancelDefer(deferId) {
|
|
8540
|
+
cancelAnimationFrame(deferId);
|
|
8252
8541
|
}
|
|
8253
8542
|
function setInputSelection(input, start, end) {
|
|
8254
|
-
if (
|
|
8255
|
-
|
|
8256
|
-
input.selectionEnd = end;
|
|
8257
|
-
} else {
|
|
8258
|
-
var range = input.createTextRange();
|
|
8259
|
-
range.collapse(true);
|
|
8260
|
-
range.moveStart('character', start);
|
|
8261
|
-
range.moveEnd('character', end - start);
|
|
8262
|
-
range.select();
|
|
8543
|
+
if (end === undefined) {
|
|
8544
|
+
end = start;
|
|
8263
8545
|
}
|
|
8546
|
+
input.setSelectionRange(start, end);
|
|
8264
8547
|
}
|
|
8265
8548
|
function getInputSelection(input) {
|
|
8266
|
-
var start =
|
|
8267
|
-
var end =
|
|
8268
|
-
if ('selectionStart' in input && 'selectionEnd' in input) {
|
|
8269
|
-
start = input.selectionStart;
|
|
8270
|
-
end = input.selectionEnd;
|
|
8271
|
-
} else {
|
|
8272
|
-
var range = document.selection.createRange();
|
|
8273
|
-
if (range.parentElement() === input) {
|
|
8274
|
-
start = -range.moveStart('character', -input.value.length);
|
|
8275
|
-
end = -range.moveEnd('character', -input.value.length);
|
|
8276
|
-
}
|
|
8277
|
-
}
|
|
8549
|
+
var start = input.selectionStart;
|
|
8550
|
+
var end = input.selectionEnd;
|
|
8278
8551
|
return {
|
|
8279
8552
|
start: start,
|
|
8280
8553
|
end: end,
|
|
8281
8554
|
length: end - start
|
|
8282
8555
|
};
|
|
8283
8556
|
}
|
|
8284
|
-
|
|
8285
|
-
|
|
8286
|
-
|
|
8287
|
-
'*': '[A-Za-z0-9]'
|
|
8288
|
-
};
|
|
8289
|
-
var defaultMaskChar = '_';
|
|
8290
|
-
function parseMask(mask, maskChar, formatChars) {
|
|
8291
|
-
var parsedMaskString = '';
|
|
8292
|
-
var prefix = '';
|
|
8293
|
-
var lastEditablePosition = null;
|
|
8294
|
-
var permanents = [];
|
|
8295
|
-
if (maskChar === undefined) {
|
|
8296
|
-
maskChar = defaultMaskChar;
|
|
8297
|
-
}
|
|
8298
|
-
if (formatChars == null) {
|
|
8299
|
-
formatChars = defaultFormatChars;
|
|
8300
|
-
}
|
|
8301
|
-
if (!mask || typeof mask !== 'string') {
|
|
8302
|
-
return {
|
|
8303
|
-
maskChar: maskChar,
|
|
8304
|
-
formatChars: formatChars,
|
|
8305
|
-
mask: null,
|
|
8306
|
-
prefix: null,
|
|
8307
|
-
lastEditablePosition: null,
|
|
8308
|
-
permanents: []
|
|
8309
|
-
};
|
|
8310
|
-
}
|
|
8311
|
-
var isPermanent = false;
|
|
8312
|
-
mask.split('').forEach(function (character) {
|
|
8313
|
-
if (!isPermanent && character === '\\') {
|
|
8314
|
-
isPermanent = true;
|
|
8315
|
-
} else {
|
|
8316
|
-
if (isPermanent || !formatChars[character]) {
|
|
8317
|
-
permanents.push(parsedMaskString.length);
|
|
8318
|
-
if (parsedMaskString.length === permanents.length - 1) {
|
|
8319
|
-
prefix += character;
|
|
8320
|
-
}
|
|
8321
|
-
} else {
|
|
8322
|
-
lastEditablePosition = parsedMaskString.length + 1;
|
|
8323
|
-
}
|
|
8324
|
-
parsedMaskString += character;
|
|
8325
|
-
isPermanent = false;
|
|
8326
|
-
}
|
|
8327
|
-
});
|
|
8328
|
-
return {
|
|
8329
|
-
maskChar: maskChar,
|
|
8330
|
-
formatChars: formatChars,
|
|
8331
|
-
prefix: prefix,
|
|
8332
|
-
mask: parsedMaskString,
|
|
8333
|
-
lastEditablePosition: lastEditablePosition,
|
|
8334
|
-
permanents: permanents
|
|
8335
|
-
};
|
|
8557
|
+
function isInputFocused(input) {
|
|
8558
|
+
var inputDocument = input.ownerDocument;
|
|
8559
|
+
return inputDocument.hasFocus() && inputDocument.activeElement === input;
|
|
8336
8560
|
}
|
|
8337
8561
|
|
|
8338
|
-
|
|
8339
|
-
|
|
8340
|
-
|
|
8341
|
-
|
|
8342
|
-
|
|
8343
|
-
var mask = maskOptions.mask,
|
|
8344
|
-
formatChars = maskOptions.formatChars;
|
|
8345
|
-
if (!character) {
|
|
8346
|
-
return false;
|
|
8347
|
-
}
|
|
8348
|
-
if (isPermanentCharacter(maskOptions, pos)) {
|
|
8349
|
-
return mask[pos] === character;
|
|
8350
|
-
}
|
|
8351
|
-
var ruleChar = mask[pos];
|
|
8352
|
-
var charRule = formatChars[ruleChar];
|
|
8353
|
-
return new RegExp(charRule).test(character);
|
|
8562
|
+
// Element's window may differ from the one within React instance
|
|
8563
|
+
// if element rendered within iframe.
|
|
8564
|
+
// See https://github.com/sanniassin/react-input-mask/issues/182
|
|
8565
|
+
function getElementDocument(element) {
|
|
8566
|
+
return element == null ? void 0 : element.ownerDocument;
|
|
8354
8567
|
}
|
|
8355
|
-
function
|
|
8356
|
-
|
|
8357
|
-
|
|
8358
|
-
});
|
|
8568
|
+
function getElementWindow(element) {
|
|
8569
|
+
var _getElementDocument;
|
|
8570
|
+
return (_getElementDocument = getElementDocument(element)) == null ? void 0 : _getElementDocument.defaultView;
|
|
8359
8571
|
}
|
|
8360
|
-
function
|
|
8361
|
-
var
|
|
8362
|
-
|
|
8363
|
-
if (!maskChar) {
|
|
8364
|
-
while (value.length > prefix.length && isPermanentCharacter(maskOptions, value.length - 1)) {
|
|
8365
|
-
value = value.slice(0, value.length - 1);
|
|
8366
|
-
}
|
|
8367
|
-
return value.length;
|
|
8368
|
-
}
|
|
8369
|
-
var filledLength = prefix.length;
|
|
8370
|
-
for (var i = value.length; i >= prefix.length; i--) {
|
|
8371
|
-
var character = value[i];
|
|
8372
|
-
var isEnteredCharacter = !isPermanentCharacter(maskOptions, i) && isAllowedCharacter(maskOptions, i, character);
|
|
8373
|
-
if (isEnteredCharacter) {
|
|
8374
|
-
filledLength = i + 1;
|
|
8375
|
-
break;
|
|
8376
|
-
}
|
|
8377
|
-
}
|
|
8378
|
-
return filledLength;
|
|
8572
|
+
function isDOMElement(element) {
|
|
8573
|
+
var elementWindow = getElementWindow(element);
|
|
8574
|
+
return !!elementWindow && element instanceof elementWindow.HTMLElement;
|
|
8379
8575
|
}
|
|
8380
|
-
function
|
|
8381
|
-
return
|
|
8576
|
+
function isFunction(value) {
|
|
8577
|
+
return typeof value === "function";
|
|
8382
8578
|
}
|
|
8383
|
-
function
|
|
8384
|
-
var
|
|
8385
|
-
|
|
8386
|
-
|
|
8387
|
-
|
|
8388
|
-
value = insertString(maskOptions, '', value, 0);
|
|
8389
|
-
if (value.length < prefix.length) {
|
|
8390
|
-
value = prefix;
|
|
8391
|
-
}
|
|
8392
|
-
while (value.length < mask.length && isPermanentCharacter(maskOptions, value.length)) {
|
|
8393
|
-
value += mask[value.length];
|
|
8579
|
+
function findLastIndex(array, predicate) {
|
|
8580
|
+
for (var i = array.length - 1; i >= 0; i--) {
|
|
8581
|
+
var x = array[i];
|
|
8582
|
+
if (predicate(x, i)) {
|
|
8583
|
+
return i;
|
|
8394
8584
|
}
|
|
8395
|
-
return value;
|
|
8396
8585
|
}
|
|
8397
|
-
|
|
8398
|
-
|
|
8399
|
-
|
|
8586
|
+
return -1;
|
|
8587
|
+
}
|
|
8588
|
+
function repeat(string, n) {
|
|
8589
|
+
if (n === void 0) {
|
|
8590
|
+
n = 1;
|
|
8400
8591
|
}
|
|
8401
|
-
|
|
8402
|
-
|
|
8403
|
-
|
|
8404
|
-
} else {
|
|
8405
|
-
value += maskChar;
|
|
8406
|
-
}
|
|
8407
|
-
}
|
|
8408
|
-
return value;
|
|
8409
|
-
}
|
|
8410
|
-
function clearRange(maskOptions, value, start, len) {
|
|
8411
|
-
var end = start + len;
|
|
8412
|
-
var maskChar = maskOptions.maskChar,
|
|
8413
|
-
mask = maskOptions.mask,
|
|
8414
|
-
prefix = maskOptions.prefix;
|
|
8415
|
-
var arrayValue = value.split('');
|
|
8416
|
-
if (!maskChar) {
|
|
8417
|
-
// remove any permanent chars after clear range, they will be added back by formatValue
|
|
8418
|
-
for (var i = end; i < arrayValue.length; i++) {
|
|
8419
|
-
if (isPermanentCharacter(maskOptions, i)) {
|
|
8420
|
-
arrayValue[i] = '';
|
|
8421
|
-
}
|
|
8422
|
-
}
|
|
8423
|
-
start = Math.max(prefix.length, start);
|
|
8424
|
-
arrayValue.splice(start, end - start);
|
|
8425
|
-
value = arrayValue.join('');
|
|
8426
|
-
return formatValue(maskOptions, value);
|
|
8592
|
+
var result = "";
|
|
8593
|
+
for (var i = 0; i < n; i++) {
|
|
8594
|
+
result += string;
|
|
8427
8595
|
}
|
|
8428
|
-
return
|
|
8429
|
-
if (i < start || i >= end) {
|
|
8430
|
-
return character;
|
|
8431
|
-
}
|
|
8432
|
-
if (isPermanentCharacter(maskOptions, i)) {
|
|
8433
|
-
return mask[i];
|
|
8434
|
-
}
|
|
8435
|
-
return maskChar;
|
|
8436
|
-
}).join('');
|
|
8596
|
+
return result;
|
|
8437
8597
|
}
|
|
8438
|
-
function
|
|
8439
|
-
|
|
8440
|
-
|
|
8441
|
-
|
|
8442
|
-
|
|
8443
|
-
|
|
8444
|
-
|
|
8445
|
-
return !isPermanentCharacter(maskOptions, pos) || character === mask[pos];
|
|
8446
|
-
};
|
|
8447
|
-
var isUsableCharacter = function isUsableCharacter(character, pos) {
|
|
8448
|
-
return !maskChar || !isPermanentCharacter(maskOptions, pos) || character !== maskChar;
|
|
8449
|
-
};
|
|
8450
|
-
if (!maskChar && insertPosition > value.length) {
|
|
8451
|
-
value += mask.slice(value.length, insertPosition);
|
|
8452
|
-
}
|
|
8453
|
-
arrayInsertStr.every(function (insertCharacter) {
|
|
8454
|
-
while (!isUsablePosition(insertPosition, insertCharacter)) {
|
|
8455
|
-
if (insertPosition >= value.length) {
|
|
8456
|
-
value += mask[insertPosition];
|
|
8457
|
-
}
|
|
8458
|
-
if (!isUsableCharacter(insertCharacter, insertPosition)) {
|
|
8459
|
-
return true;
|
|
8460
|
-
}
|
|
8461
|
-
insertPosition++; // stop iteration if maximum value length reached
|
|
8598
|
+
function toString(value) {
|
|
8599
|
+
return "" + value;
|
|
8600
|
+
}
|
|
8601
|
+
function useInputElement(inputRef) {
|
|
8602
|
+
return React$1.useCallback(function () {
|
|
8603
|
+
var input = inputRef.current;
|
|
8604
|
+
var isDOMNode = typeof window !== "undefined" && isDOMElement(input);
|
|
8462
8605
|
|
|
8463
|
-
|
|
8464
|
-
|
|
8465
|
-
|
|
8606
|
+
// workaround for react-test-renderer
|
|
8607
|
+
// https://github.com/sanniassin/react-input-mask/issues/147
|
|
8608
|
+
if (!input || !isDOMNode) {
|
|
8609
|
+
return null;
|
|
8466
8610
|
}
|
|
8467
|
-
|
|
8468
|
-
|
|
8469
|
-
return true;
|
|
8611
|
+
if (input.nodeName !== "INPUT") {
|
|
8612
|
+
input = input.querySelector("input");
|
|
8470
8613
|
}
|
|
8471
|
-
if (
|
|
8472
|
-
|
|
8473
|
-
value = value.slice(0, insertPosition) + insertCharacter + value.slice(insertPosition + 1);
|
|
8474
|
-
} else {
|
|
8475
|
-
value = value.slice(0, insertPosition) + insertCharacter + value.slice(insertPosition);
|
|
8476
|
-
value = formatValue(maskOptions, value);
|
|
8477
|
-
}
|
|
8478
|
-
} else if (!maskChar) {
|
|
8479
|
-
value += insertCharacter;
|
|
8614
|
+
if (!input) {
|
|
8615
|
+
throw new Error("react-input-mask: inputComponent doesn't contain input node");
|
|
8480
8616
|
}
|
|
8481
|
-
|
|
8482
|
-
|
|
8483
|
-
|
|
8617
|
+
return input;
|
|
8618
|
+
}, [inputRef]);
|
|
8619
|
+
}
|
|
8620
|
+
function useDeferLoop(callback) {
|
|
8621
|
+
var deferIdRef = React$1.useRef(null);
|
|
8622
|
+
var runLoop = React$1.useCallback(function () {
|
|
8623
|
+
// If there are simulated focus events, runLoop could be
|
|
8624
|
+
// called multiple times without blur or re-render
|
|
8625
|
+
if (deferIdRef.current !== null) {
|
|
8626
|
+
return;
|
|
8627
|
+
}
|
|
8628
|
+
function loop() {
|
|
8629
|
+
callback();
|
|
8630
|
+
deferIdRef.current = defer(loop);
|
|
8631
|
+
}
|
|
8632
|
+
loop();
|
|
8633
|
+
}, [callback]);
|
|
8634
|
+
var stopLoop = React$1.useCallback(function () {
|
|
8635
|
+
cancelDefer(deferIdRef.current);
|
|
8636
|
+
deferIdRef.current = null;
|
|
8637
|
+
}, []);
|
|
8638
|
+
React$1.useEffect(function () {
|
|
8639
|
+
if (deferIdRef.current) {
|
|
8640
|
+
stopLoop();
|
|
8641
|
+
runLoop();
|
|
8642
|
+
}
|
|
8643
|
+
}, [runLoop, stopLoop]);
|
|
8644
|
+
React$1.useEffect(cancelDefer, []);
|
|
8645
|
+
return [runLoop, stopLoop];
|
|
8646
|
+
}
|
|
8647
|
+
function useSelection(inputRef, isMasked) {
|
|
8648
|
+
var selectionRef = React$1.useRef({
|
|
8649
|
+
start: null,
|
|
8650
|
+
end: null
|
|
8484
8651
|
});
|
|
8485
|
-
|
|
8486
|
-
|
|
8487
|
-
|
|
8488
|
-
|
|
8489
|
-
|
|
8490
|
-
var
|
|
8491
|
-
|
|
8492
|
-
|
|
8493
|
-
|
|
8494
|
-
|
|
8495
|
-
arrayInsertStr.every(function (insertCharacter) {
|
|
8496
|
-
while (!isUsablePosition(insertPosition, insertCharacter)) {
|
|
8497
|
-
insertPosition++; // stop iteration if maximum value length reached
|
|
8652
|
+
var getInputElement = useInputElement(inputRef);
|
|
8653
|
+
var getSelection = React$1.useCallback(function () {
|
|
8654
|
+
var input = getInputElement();
|
|
8655
|
+
return getInputSelection(input);
|
|
8656
|
+
}, [getInputElement]);
|
|
8657
|
+
var getLastSelection = React$1.useCallback(function () {
|
|
8658
|
+
return selectionRef.current;
|
|
8659
|
+
}, []);
|
|
8660
|
+
var setSelection = React$1.useCallback(function (selection) {
|
|
8661
|
+
var input = getInputElement();
|
|
8498
8662
|
|
|
8499
|
-
|
|
8500
|
-
|
|
8501
|
-
|
|
8663
|
+
// Don't change selection on unfocused input
|
|
8664
|
+
// because Safari sets focus on selection change (#154)
|
|
8665
|
+
if (!input || !isInputFocused(input)) {
|
|
8666
|
+
return;
|
|
8502
8667
|
}
|
|
8503
|
-
|
|
8504
|
-
|
|
8505
|
-
|
|
8506
|
-
|
|
8507
|
-
|
|
8508
|
-
|
|
8509
|
-
|
|
8510
|
-
|
|
8511
|
-
|
|
8512
|
-
|
|
8513
|
-
|
|
8514
|
-
|
|
8515
|
-
|
|
8668
|
+
setInputSelection(input, selection.start, selection.end);
|
|
8669
|
+
|
|
8670
|
+
// Use actual selection in case the requested one was out of range
|
|
8671
|
+
selectionRef.current = getSelection();
|
|
8672
|
+
}, [getInputElement, getSelection]);
|
|
8673
|
+
var selectionLoop = React$1.useCallback(function () {
|
|
8674
|
+
selectionRef.current = getSelection();
|
|
8675
|
+
}, [getSelection]);
|
|
8676
|
+
var _useDeferLoop = useDeferLoop(selectionLoop),
|
|
8677
|
+
runSelectionLoop = _useDeferLoop[0],
|
|
8678
|
+
stopSelectionLoop = _useDeferLoop[1];
|
|
8679
|
+
React$1.useLayoutEffect(function () {
|
|
8680
|
+
if (!isMasked) {
|
|
8681
|
+
return;
|
|
8516
8682
|
}
|
|
8517
|
-
|
|
8518
|
-
|
|
8519
|
-
|
|
8520
|
-
|
|
8521
|
-
|
|
8522
|
-
for (var i = pos; i < mask.length; ++i) {
|
|
8523
|
-
if (!isPermanentCharacter(maskOptions, i)) {
|
|
8524
|
-
return i;
|
|
8683
|
+
var input = getInputElement();
|
|
8684
|
+
input.addEventListener("focus", runSelectionLoop);
|
|
8685
|
+
input.addEventListener("blur", stopSelectionLoop);
|
|
8686
|
+
if (isInputFocused(input)) {
|
|
8687
|
+
runSelectionLoop();
|
|
8525
8688
|
}
|
|
8526
|
-
|
|
8527
|
-
|
|
8689
|
+
return function () {
|
|
8690
|
+
input.removeEventListener("focus", runSelectionLoop);
|
|
8691
|
+
input.removeEventListener("blur", stopSelectionLoop);
|
|
8692
|
+
stopSelectionLoop();
|
|
8693
|
+
};
|
|
8694
|
+
});
|
|
8695
|
+
return {
|
|
8696
|
+
getSelection: getSelection,
|
|
8697
|
+
getLastSelection: getLastSelection,
|
|
8698
|
+
setSelection: setSelection
|
|
8699
|
+
};
|
|
8528
8700
|
}
|
|
8529
|
-
function
|
|
8530
|
-
|
|
8531
|
-
|
|
8532
|
-
|
|
8533
|
-
|
|
8534
|
-
|
|
8535
|
-
|
|
8536
|
-
var
|
|
8537
|
-
|
|
8538
|
-
|
|
8539
|
-
var
|
|
8540
|
-
|
|
8541
|
-
|
|
8542
|
-
|
|
8543
|
-
|
|
8544
|
-
if (!formattedEnteredStringLength) {
|
|
8545
|
-
removedLength = 0;
|
|
8546
|
-
} else {
|
|
8547
|
-
removedLength = previousSelection.length;
|
|
8548
|
-
}
|
|
8549
|
-
} else if (newValue.length < previousValue.length) {
|
|
8550
|
-
removedLength = previousValue.length - newValue.length;
|
|
8551
|
-
}
|
|
8552
|
-
newValue = previousValue;
|
|
8553
|
-
if (removedLength) {
|
|
8554
|
-
if (removedLength === 1 && !previousSelection.length) {
|
|
8555
|
-
var deleteFromRight = previousSelection.start === selection.start;
|
|
8556
|
-
cursorPosition = deleteFromRight ? getRightEditablePosition(maskOptions, selection.start) : getLeftEditablePosition(maskOptions, selection.start);
|
|
8701
|
+
function useValue(inputRef, initialValue) {
|
|
8702
|
+
var getInputElement = useInputElement(inputRef);
|
|
8703
|
+
var valueRef = React$1.useRef(initialValue);
|
|
8704
|
+
var getValue = React$1.useCallback(function () {
|
|
8705
|
+
var input = getInputElement();
|
|
8706
|
+
return input.value;
|
|
8707
|
+
}, [getInputElement]);
|
|
8708
|
+
var getLastValue = React$1.useCallback(function () {
|
|
8709
|
+
return valueRef.current;
|
|
8710
|
+
}, []);
|
|
8711
|
+
var setValue = React$1.useCallback(function (newValue) {
|
|
8712
|
+
valueRef.current = newValue;
|
|
8713
|
+
var input = getInputElement();
|
|
8714
|
+
if (input) {
|
|
8715
|
+
input.value = newValue;
|
|
8557
8716
|
}
|
|
8558
|
-
|
|
8717
|
+
}, [getInputElement]);
|
|
8718
|
+
return {
|
|
8719
|
+
getValue: getValue,
|
|
8720
|
+
getLastValue: getLastValue,
|
|
8721
|
+
setValue: setValue
|
|
8722
|
+
};
|
|
8723
|
+
}
|
|
8724
|
+
function useInputState(initialValue, isMasked) {
|
|
8725
|
+
var inputRef = React$1.useRef();
|
|
8726
|
+
var _useSelection = useSelection(inputRef, isMasked),
|
|
8727
|
+
getSelection = _useSelection.getSelection,
|
|
8728
|
+
getLastSelection = _useSelection.getLastSelection,
|
|
8729
|
+
setSelection = _useSelection.setSelection;
|
|
8730
|
+
var _useValue = useValue(inputRef, initialValue),
|
|
8731
|
+
getValue = _useValue.getValue,
|
|
8732
|
+
getLastValue = _useValue.getLastValue,
|
|
8733
|
+
setValue = _useValue.setValue;
|
|
8734
|
+
function getLastInputState() {
|
|
8735
|
+
return {
|
|
8736
|
+
value: getLastValue(),
|
|
8737
|
+
selection: getLastSelection()
|
|
8738
|
+
};
|
|
8559
8739
|
}
|
|
8560
|
-
|
|
8561
|
-
|
|
8562
|
-
|
|
8563
|
-
|
|
8564
|
-
|
|
8565
|
-
cursorPosition = prefix.length;
|
|
8566
|
-
} else if (cursorPosition >= prefix.length && cursorPosition < lastEditablePosition && formattedEnteredStringLength) {
|
|
8567
|
-
cursorPosition = getRightEditablePosition(maskOptions, cursorPosition);
|
|
8740
|
+
function getInputState() {
|
|
8741
|
+
return {
|
|
8742
|
+
value: getValue(),
|
|
8743
|
+
selection: getSelection()
|
|
8744
|
+
};
|
|
8568
8745
|
}
|
|
8569
|
-
|
|
8570
|
-
|
|
8571
|
-
|
|
8746
|
+
function setInputState(_ref) {
|
|
8747
|
+
var value = _ref.value,
|
|
8748
|
+
selection = _ref.selection;
|
|
8749
|
+
setValue(value);
|
|
8750
|
+
setSelection(selection);
|
|
8572
8751
|
}
|
|
8573
8752
|
return {
|
|
8574
|
-
|
|
8575
|
-
|
|
8576
|
-
|
|
8577
|
-
|
|
8578
|
-
end: cursorPosition
|
|
8579
|
-
}
|
|
8753
|
+
inputRef: inputRef,
|
|
8754
|
+
getInputState: getInputState,
|
|
8755
|
+
getLastInputState: getLastInputState,
|
|
8756
|
+
setInputState: setInputState
|
|
8580
8757
|
};
|
|
8581
8758
|
}
|
|
8582
|
-
function
|
|
8583
|
-
var
|
|
8584
|
-
|
|
8585
|
-
|
|
8586
|
-
|
|
8759
|
+
function usePrevious(value) {
|
|
8760
|
+
var ref = React$1.useRef();
|
|
8761
|
+
React$1.useEffect(function () {
|
|
8762
|
+
ref.current = value;
|
|
8763
|
+
});
|
|
8764
|
+
return ref.current;
|
|
8587
8765
|
}
|
|
8588
|
-
|
|
8589
|
-
|
|
8766
|
+
var CONTROLLED_PROPS = ["disabled", "onBlur", "onChange", "onFocus", "onMouseDown", "readOnly", "value"];
|
|
8767
|
+
var defaultFormatChars = {
|
|
8768
|
+
9: /[0-9]/,
|
|
8769
|
+
a: /[A-Za-z]/,
|
|
8770
|
+
"*": /[A-Za-z0-9]/
|
|
8771
|
+
};
|
|
8772
|
+
function validateMaxLength(props) {
|
|
8773
|
+
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;
|
|
8590
8774
|
}
|
|
8591
|
-
function
|
|
8592
|
-
|
|
8775
|
+
function validateMaskPlaceholder(props) {
|
|
8776
|
+
var mask = props.mask,
|
|
8777
|
+
maskPlaceholder = props.maskPlaceholder;
|
|
8778
|
+
!(!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;
|
|
8593
8779
|
}
|
|
8594
|
-
function
|
|
8595
|
-
|
|
8780
|
+
function validateChildren(props, inputElement) {
|
|
8781
|
+
var conflictProps = CONTROLLED_PROPS.filter(function (propId) {
|
|
8782
|
+
return inputElement.props[propId] != null && inputElement.props[propId] !== props[propId];
|
|
8783
|
+
});
|
|
8784
|
+
!!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;
|
|
8596
8785
|
}
|
|
8597
|
-
function
|
|
8598
|
-
var
|
|
8599
|
-
|
|
8600
|
-
|
|
8601
|
-
|
|
8602
|
-
|
|
8603
|
-
|
|
8604
|
-
|
|
8786
|
+
var parseMask = function parseMask(_ref) {
|
|
8787
|
+
var mask = _ref.mask,
|
|
8788
|
+
maskPlaceholder = _ref.maskPlaceholder;
|
|
8789
|
+
var permanents = [];
|
|
8790
|
+
if (!mask) {
|
|
8791
|
+
return {
|
|
8792
|
+
maskPlaceholder: null,
|
|
8793
|
+
mask: null,
|
|
8794
|
+
prefix: null,
|
|
8795
|
+
lastEditablePosition: null,
|
|
8796
|
+
permanents: []
|
|
8605
8797
|
};
|
|
8606
8798
|
}
|
|
8607
|
-
|
|
8608
|
-
|
|
8609
|
-
|
|
8610
|
-
|
|
8611
|
-
|
|
8612
|
-
|
|
8613
|
-
|
|
8614
|
-
|
|
8615
|
-
|
|
8616
|
-
|
|
8617
|
-
|
|
8618
|
-
|
|
8619
|
-
_this.focused = false;
|
|
8620
|
-
_this.mounted = false;
|
|
8621
|
-
_this.previousSelection = null;
|
|
8622
|
-
_this.selectionDeferId = null;
|
|
8623
|
-
_this.saveSelectionLoopDeferId = null;
|
|
8624
|
-
_this.saveSelectionLoop = function () {
|
|
8625
|
-
_this.previousSelection = _this.getSelection();
|
|
8626
|
-
_this.saveSelectionLoopDeferId = defer(_this.saveSelectionLoop);
|
|
8627
|
-
};
|
|
8628
|
-
_this.runSaveSelectionLoop = function () {
|
|
8629
|
-
if (_this.saveSelectionLoopDeferId === null) {
|
|
8630
|
-
_this.saveSelectionLoop();
|
|
8631
|
-
}
|
|
8632
|
-
};
|
|
8633
|
-
_this.stopSaveSelectionLoop = function () {
|
|
8634
|
-
if (_this.saveSelectionLoopDeferId !== null) {
|
|
8635
|
-
cancelDefer(_this.saveSelectionLoopDeferId);
|
|
8636
|
-
_this.saveSelectionLoopDeferId = null;
|
|
8637
|
-
_this.previousSelection = null;
|
|
8638
|
-
}
|
|
8639
|
-
};
|
|
8640
|
-
_this.getInputDOMNode = function () {
|
|
8641
|
-
if (!_this.mounted) {
|
|
8642
|
-
return null;
|
|
8643
|
-
}
|
|
8644
|
-
var input = reactDom.findDOMNode(_assertThisInitialized(_assertThisInitialized(_this)));
|
|
8645
|
-
var isDOMNode = typeof window !== 'undefined' && input instanceof window.Element; // workaround for react-test-renderer
|
|
8646
|
-
// https://github.com/sanniassin/react-input-mask/issues/147
|
|
8647
|
-
|
|
8648
|
-
if (input && !isDOMNode) {
|
|
8649
|
-
return null;
|
|
8650
|
-
}
|
|
8651
|
-
if (input.nodeName !== 'INPUT') {
|
|
8652
|
-
input = input.querySelector('input');
|
|
8653
|
-
}
|
|
8654
|
-
if (!input) {
|
|
8655
|
-
throw new Error('react-input-mask: inputComponent doesn\'t contain input node');
|
|
8656
|
-
}
|
|
8657
|
-
return input;
|
|
8658
|
-
};
|
|
8659
|
-
_this.getInputValue = function () {
|
|
8660
|
-
var input = _this.getInputDOMNode();
|
|
8661
|
-
if (!input) {
|
|
8662
|
-
return null;
|
|
8663
|
-
}
|
|
8664
|
-
return input.value;
|
|
8665
|
-
};
|
|
8666
|
-
_this.setInputValue = function (value) {
|
|
8667
|
-
var input = _this.getInputDOMNode();
|
|
8668
|
-
if (!input) {
|
|
8669
|
-
return;
|
|
8670
|
-
}
|
|
8671
|
-
_this.value = value;
|
|
8672
|
-
input.value = value;
|
|
8673
|
-
};
|
|
8674
|
-
_this.setCursorToEnd = function () {
|
|
8675
|
-
var filledLength = getFilledLength(_this.maskOptions, _this.value);
|
|
8676
|
-
var pos = getRightEditablePosition(_this.maskOptions, filledLength);
|
|
8677
|
-
if (pos !== null) {
|
|
8678
|
-
_this.setCursorPosition(pos);
|
|
8679
|
-
}
|
|
8680
|
-
};
|
|
8681
|
-
_this.setSelection = function (start, end, options) {
|
|
8682
|
-
if (options === void 0) {
|
|
8683
|
-
options = {};
|
|
8799
|
+
if (typeof mask === "string") {
|
|
8800
|
+
var isPermanent = false;
|
|
8801
|
+
var parsedMaskString = "";
|
|
8802
|
+
mask.split("").forEach(function (character) {
|
|
8803
|
+
if (!isPermanent && character === "\\") {
|
|
8804
|
+
isPermanent = true;
|
|
8805
|
+
} else {
|
|
8806
|
+
if (isPermanent || !defaultFormatChars[character]) {
|
|
8807
|
+
permanents.push(parsedMaskString.length);
|
|
8808
|
+
}
|
|
8809
|
+
parsedMaskString += character;
|
|
8810
|
+
isPermanent = false;
|
|
8684
8811
|
}
|
|
8685
|
-
|
|
8686
|
-
|
|
8687
|
-
|
|
8688
|
-
|
|
8689
|
-
if (!input || !isFocused) {
|
|
8690
|
-
return;
|
|
8812
|
+
});
|
|
8813
|
+
mask = parsedMaskString.split("").map(function (character, index) {
|
|
8814
|
+
if (permanents.indexOf(index) === -1) {
|
|
8815
|
+
return defaultFormatChars[character];
|
|
8691
8816
|
}
|
|
8692
|
-
|
|
8693
|
-
|
|
8694
|
-
|
|
8695
|
-
|
|
8817
|
+
return character;
|
|
8818
|
+
});
|
|
8819
|
+
} else {
|
|
8820
|
+
mask.forEach(function (character, index) {
|
|
8821
|
+
if (typeof character === "string") {
|
|
8822
|
+
permanents.push(index);
|
|
8696
8823
|
}
|
|
8697
|
-
|
|
8698
|
-
|
|
8699
|
-
|
|
8700
|
-
|
|
8701
|
-
|
|
8702
|
-
|
|
8703
|
-
|
|
8704
|
-
setInputSelection(input, start, end);
|
|
8705
|
-
});
|
|
8706
|
-
_this.previousSelection = {
|
|
8707
|
-
start: start,
|
|
8708
|
-
end: end,
|
|
8709
|
-
length: Math.abs(end - start)
|
|
8710
|
-
};
|
|
8711
|
-
};
|
|
8712
|
-
_this.getSelection = function () {
|
|
8713
|
-
var input = _this.getInputDOMNode();
|
|
8714
|
-
return getInputSelection(input);
|
|
8715
|
-
};
|
|
8716
|
-
_this.getCursorPosition = function () {
|
|
8717
|
-
return _this.getSelection().start;
|
|
8718
|
-
};
|
|
8719
|
-
_this.setCursorPosition = function (pos) {
|
|
8720
|
-
_this.setSelection(pos, pos);
|
|
8721
|
-
};
|
|
8722
|
-
_this.isFocused = function () {
|
|
8723
|
-
return _this.focused;
|
|
8724
|
-
};
|
|
8725
|
-
_this.getBeforeMaskedValueChangeConfig = function () {
|
|
8726
|
-
var _this$maskOptions = _this.maskOptions,
|
|
8727
|
-
mask = _this$maskOptions.mask,
|
|
8728
|
-
maskChar = _this$maskOptions.maskChar,
|
|
8729
|
-
permanents = _this$maskOptions.permanents,
|
|
8730
|
-
formatChars = _this$maskOptions.formatChars;
|
|
8731
|
-
var alwaysShowMask = _this.props.alwaysShowMask;
|
|
8732
|
-
return {
|
|
8733
|
-
mask: mask,
|
|
8734
|
-
maskChar: maskChar,
|
|
8735
|
-
permanents: permanents,
|
|
8736
|
-
alwaysShowMask: !!alwaysShowMask,
|
|
8737
|
-
formatChars: formatChars
|
|
8738
|
-
};
|
|
8739
|
-
};
|
|
8740
|
-
_this.isInputAutofilled = function (value, selection, previousValue, previousSelection) {
|
|
8741
|
-
var input = _this.getInputDOMNode(); // only check for positive match because it will be false negative
|
|
8742
|
-
// in case of autofill simulation in tests
|
|
8743
|
-
//
|
|
8744
|
-
// input.matches throws an exception if selector isn't supported
|
|
8745
|
-
|
|
8746
|
-
try {
|
|
8747
|
-
if (input.matches(':-webkit-autofill')) {
|
|
8748
|
-
return true;
|
|
8824
|
+
});
|
|
8825
|
+
}
|
|
8826
|
+
if (maskPlaceholder) {
|
|
8827
|
+
if (maskPlaceholder.length === 1) {
|
|
8828
|
+
maskPlaceholder = mask.map(function (character, index) {
|
|
8829
|
+
if (permanents.indexOf(index) !== -1) {
|
|
8830
|
+
return character;
|
|
8749
8831
|
}
|
|
8750
|
-
|
|
8751
|
-
|
|
8752
|
-
|
|
8753
|
-
|
|
8754
|
-
|
|
8755
|
-
|
|
8756
|
-
|
|
8832
|
+
return maskPlaceholder;
|
|
8833
|
+
});
|
|
8834
|
+
} else {
|
|
8835
|
+
maskPlaceholder = maskPlaceholder.split("");
|
|
8836
|
+
}
|
|
8837
|
+
permanents.forEach(function (position) {
|
|
8838
|
+
maskPlaceholder[position] = mask[position];
|
|
8839
|
+
});
|
|
8840
|
+
maskPlaceholder = maskPlaceholder.join("");
|
|
8841
|
+
}
|
|
8842
|
+
var prefix = permanents.filter(function (position, index) {
|
|
8843
|
+
return position === index;
|
|
8844
|
+
}).map(function (position) {
|
|
8845
|
+
return mask[position];
|
|
8846
|
+
}).join("");
|
|
8847
|
+
var lastEditablePosition = mask.length - 1;
|
|
8848
|
+
while (permanents.indexOf(lastEditablePosition) !== -1) {
|
|
8849
|
+
lastEditablePosition--;
|
|
8850
|
+
}
|
|
8851
|
+
return {
|
|
8852
|
+
maskPlaceholder: maskPlaceholder,
|
|
8853
|
+
prefix: prefix,
|
|
8854
|
+
mask: mask,
|
|
8855
|
+
lastEditablePosition: lastEditablePosition,
|
|
8856
|
+
permanents: permanents
|
|
8857
|
+
};
|
|
8858
|
+
};
|
|
8757
8859
|
|
|
8758
|
-
|
|
8860
|
+
/* eslint no-use-before-define: ["error", { functions: false }] */
|
|
8861
|
+
var MaskUtils = function MaskUtils(options) {
|
|
8862
|
+
var _this = this;
|
|
8863
|
+
this.isCharacterAllowedAtPosition = function (character, position) {
|
|
8864
|
+
var maskPlaceholder = _this.maskOptions.maskPlaceholder;
|
|
8865
|
+
if (_this.isCharacterFillingPosition(character, position)) {
|
|
8866
|
+
return true;
|
|
8867
|
+
}
|
|
8868
|
+
if (!maskPlaceholder) {
|
|
8869
|
+
return false;
|
|
8870
|
+
}
|
|
8871
|
+
return maskPlaceholder[position] === character;
|
|
8872
|
+
};
|
|
8873
|
+
this.isCharacterFillingPosition = function (character, position) {
|
|
8874
|
+
var mask = _this.maskOptions.mask;
|
|
8875
|
+
if (!character || position >= mask.length) {
|
|
8876
|
+
return false;
|
|
8877
|
+
}
|
|
8878
|
+
if (!_this.isPositionEditable(position)) {
|
|
8879
|
+
return mask[position] === character;
|
|
8880
|
+
}
|
|
8881
|
+
var charRule = mask[position];
|
|
8882
|
+
return new RegExp(charRule).test(character);
|
|
8883
|
+
};
|
|
8884
|
+
this.isPositionEditable = function (position) {
|
|
8885
|
+
var _this$maskOptions = _this.maskOptions,
|
|
8886
|
+
mask = _this$maskOptions.mask,
|
|
8887
|
+
permanents = _this$maskOptions.permanents;
|
|
8888
|
+
return position < mask.length && permanents.indexOf(position) === -1;
|
|
8889
|
+
};
|
|
8890
|
+
this.isValueEmpty = function (value) {
|
|
8891
|
+
return value.split("").every(function (character, position) {
|
|
8892
|
+
return !_this.isPositionEditable(position) || !_this.isCharacterFillingPosition(character, position);
|
|
8893
|
+
});
|
|
8894
|
+
};
|
|
8895
|
+
this.isValueFilled = function (value) {
|
|
8896
|
+
return _this.getFilledLength(value) === _this.maskOptions.lastEditablePosition + 1;
|
|
8897
|
+
};
|
|
8898
|
+
this.getDefaultSelectionForValue = function (value) {
|
|
8899
|
+
var filledLength = _this.getFilledLength(value);
|
|
8900
|
+
var cursorPosition = _this.getRightEditablePosition(filledLength);
|
|
8901
|
+
return {
|
|
8902
|
+
start: cursorPosition,
|
|
8903
|
+
end: cursorPosition
|
|
8759
8904
|
};
|
|
8760
|
-
|
|
8761
|
-
|
|
8762
|
-
|
|
8763
|
-
|
|
8764
|
-
|
|
8765
|
-
|
|
8766
|
-
|
|
8767
|
-
|
|
8768
|
-
|
|
8769
|
-
|
|
8770
|
-
|
|
8771
|
-
|
|
8772
|
-
|
|
8773
|
-
|
|
8774
|
-
|
|
8775
|
-
|
|
8776
|
-
|
|
8777
|
-
|
|
8778
|
-
|
|
8779
|
-
// cleared input in onPaste handler
|
|
8780
|
-
|
|
8781
|
-
if (beforePasteState) {
|
|
8782
|
-
previousSelection = beforePasteState.selection;
|
|
8783
|
-
previousValue = beforePasteState.value;
|
|
8784
|
-
selection = {
|
|
8785
|
-
start: previousSelection.start + value.length,
|
|
8786
|
-
end: previousSelection.start + value.length,
|
|
8787
|
-
length: 0
|
|
8788
|
-
};
|
|
8789
|
-
value = previousValue.slice(0, previousSelection.start) + value + previousValue.slice(previousSelection.end);
|
|
8790
|
-
_this.beforePasteState = null;
|
|
8905
|
+
};
|
|
8906
|
+
this.getFilledLength = function (value) {
|
|
8907
|
+
var characters = value.split("");
|
|
8908
|
+
var lastFilledIndex = findLastIndex(characters, function (character, position) {
|
|
8909
|
+
return _this.isPositionEditable(position) && _this.isCharacterFillingPosition(character, position);
|
|
8910
|
+
});
|
|
8911
|
+
return lastFilledIndex + 1;
|
|
8912
|
+
};
|
|
8913
|
+
this.getStringFillingLengthAtPosition = function (string, position) {
|
|
8914
|
+
var characters = string.split("");
|
|
8915
|
+
var insertedValue = characters.reduce(function (value, character) {
|
|
8916
|
+
return _this.insertCharacterAtPosition(value, character, value.length);
|
|
8917
|
+
}, repeat(" ", position));
|
|
8918
|
+
return insertedValue.length - position;
|
|
8919
|
+
};
|
|
8920
|
+
this.getLeftEditablePosition = function (position) {
|
|
8921
|
+
for (var i = position; i >= 0; i--) {
|
|
8922
|
+
if (_this.isPositionEditable(i)) {
|
|
8923
|
+
return i;
|
|
8791
8924
|
}
|
|
8792
|
-
|
|
8793
|
-
|
|
8794
|
-
|
|
8795
|
-
|
|
8796
|
-
|
|
8797
|
-
|
|
8798
|
-
|
|
8799
|
-
|
|
8800
|
-
|
|
8801
|
-
|
|
8802
|
-
|
|
8803
|
-
|
|
8804
|
-
|
|
8805
|
-
|
|
8925
|
+
}
|
|
8926
|
+
return null;
|
|
8927
|
+
};
|
|
8928
|
+
this.getRightEditablePosition = function (position) {
|
|
8929
|
+
var mask = _this.maskOptions.mask;
|
|
8930
|
+
for (var i = position; i < mask.length; i++) {
|
|
8931
|
+
if (_this.isPositionEditable(i)) {
|
|
8932
|
+
return i;
|
|
8933
|
+
}
|
|
8934
|
+
}
|
|
8935
|
+
return null;
|
|
8936
|
+
};
|
|
8937
|
+
this.formatValue = function (value) {
|
|
8938
|
+
var _this$maskOptions2 = _this.maskOptions,
|
|
8939
|
+
maskPlaceholder = _this$maskOptions2.maskPlaceholder,
|
|
8940
|
+
mask = _this$maskOptions2.mask;
|
|
8941
|
+
if (!maskPlaceholder) {
|
|
8942
|
+
value = _this.insertStringAtPosition("", value, 0);
|
|
8943
|
+
while (value.length < mask.length && !_this.isPositionEditable(value.length)) {
|
|
8944
|
+
value += mask[value.length];
|
|
8806
8945
|
}
|
|
8807
|
-
|
|
8808
|
-
|
|
8809
|
-
|
|
8946
|
+
return value;
|
|
8947
|
+
}
|
|
8948
|
+
return _this.insertStringAtPosition(maskPlaceholder, value, 0);
|
|
8949
|
+
};
|
|
8950
|
+
this.clearRange = function (value, start, len) {
|
|
8951
|
+
if (!len) {
|
|
8952
|
+
return value;
|
|
8953
|
+
}
|
|
8954
|
+
var end = start + len;
|
|
8955
|
+
var _this$maskOptions3 = _this.maskOptions,
|
|
8956
|
+
maskPlaceholder = _this$maskOptions3.maskPlaceholder,
|
|
8957
|
+
mask = _this$maskOptions3.mask;
|
|
8958
|
+
var clearedValue = value.split("").map(function (character, i) {
|
|
8959
|
+
var isEditable = _this.isPositionEditable(i);
|
|
8960
|
+
if (!maskPlaceholder && i >= end && !isEditable) {
|
|
8961
|
+
return "";
|
|
8810
8962
|
}
|
|
8811
|
-
if (
|
|
8812
|
-
|
|
8813
|
-
deferred: true
|
|
8814
|
-
});
|
|
8815
|
-
} else {
|
|
8816
|
-
_this.setSelection(newSelection.start, newSelection.end);
|
|
8963
|
+
if (i < start || i >= end) {
|
|
8964
|
+
return character;
|
|
8817
8965
|
}
|
|
8818
|
-
|
|
8819
|
-
|
|
8820
|
-
var beforeMaskedValueChange = _this.props.beforeMaskedValueChange;
|
|
8821
|
-
var _this$maskOptions2 = _this.maskOptions,
|
|
8822
|
-
mask = _this$maskOptions2.mask,
|
|
8823
|
-
prefix = _this$maskOptions2.prefix;
|
|
8824
|
-
_this.focused = true; // if autoFocus is set, onFocus triggers before componentDidMount
|
|
8825
|
-
|
|
8826
|
-
_this.mounted = true;
|
|
8827
|
-
if (mask) {
|
|
8828
|
-
if (!_this.value) {
|
|
8829
|
-
var emptyValue = formatValue(_this.maskOptions, prefix);
|
|
8830
|
-
var newValue = formatValue(_this.maskOptions, emptyValue);
|
|
8831
|
-
var filledLength = getFilledLength(_this.maskOptions, newValue);
|
|
8832
|
-
var cursorPosition = getRightEditablePosition(_this.maskOptions, filledLength);
|
|
8833
|
-
var newSelection = {
|
|
8834
|
-
start: cursorPosition,
|
|
8835
|
-
end: cursorPosition
|
|
8836
|
-
};
|
|
8837
|
-
if (isFunction(beforeMaskedValueChange)) {
|
|
8838
|
-
var modifiedValue = beforeMaskedValueChange({
|
|
8839
|
-
value: newValue,
|
|
8840
|
-
selection: newSelection
|
|
8841
|
-
}, {
|
|
8842
|
-
value: _this.value,
|
|
8843
|
-
selection: null
|
|
8844
|
-
}, null, _this.getBeforeMaskedValueChangeConfig());
|
|
8845
|
-
newValue = modifiedValue.value;
|
|
8846
|
-
newSelection = modifiedValue.selection;
|
|
8847
|
-
}
|
|
8848
|
-
var isInputValueChanged = newValue !== _this.getInputValue();
|
|
8849
|
-
if (isInputValueChanged) {
|
|
8850
|
-
_this.setInputValue(newValue);
|
|
8851
|
-
}
|
|
8852
|
-
if (isInputValueChanged && isFunction(_this.props.onChange)) {
|
|
8853
|
-
_this.props.onChange(event);
|
|
8854
|
-
}
|
|
8855
|
-
_this.setSelection(newSelection.start, newSelection.end);
|
|
8856
|
-
} else if (getFilledLength(_this.maskOptions, _this.value) < _this.maskOptions.mask.length) {
|
|
8857
|
-
_this.setCursorToEnd();
|
|
8858
|
-
}
|
|
8859
|
-
_this.runSaveSelectionLoop();
|
|
8966
|
+
if (!isEditable) {
|
|
8967
|
+
return mask[i];
|
|
8860
8968
|
}
|
|
8861
|
-
if (
|
|
8862
|
-
|
|
8969
|
+
if (maskPlaceholder) {
|
|
8970
|
+
return maskPlaceholder[i];
|
|
8863
8971
|
}
|
|
8864
|
-
|
|
8865
|
-
|
|
8866
|
-
|
|
8867
|
-
|
|
8868
|
-
|
|
8869
|
-
|
|
8870
|
-
|
|
8871
|
-
|
|
8872
|
-
|
|
8873
|
-
|
|
8874
|
-
|
|
8875
|
-
|
|
8876
|
-
|
|
8877
|
-
|
|
8878
|
-
|
|
8879
|
-
|
|
8880
|
-
|
|
8881
|
-
|
|
8882
|
-
|
|
8883
|
-
|
|
8884
|
-
|
|
8972
|
+
return "";
|
|
8973
|
+
}).join("");
|
|
8974
|
+
return _this.formatValue(clearedValue);
|
|
8975
|
+
};
|
|
8976
|
+
this.insertCharacterAtPosition = function (value, character, position) {
|
|
8977
|
+
var _this$maskOptions4 = _this.maskOptions,
|
|
8978
|
+
mask = _this$maskOptions4.mask,
|
|
8979
|
+
maskPlaceholder = _this$maskOptions4.maskPlaceholder;
|
|
8980
|
+
if (position >= mask.length) {
|
|
8981
|
+
return value;
|
|
8982
|
+
}
|
|
8983
|
+
var isAllowed = _this.isCharacterAllowedAtPosition(character, position);
|
|
8984
|
+
var isEditable = _this.isPositionEditable(position);
|
|
8985
|
+
var nextEditablePosition = _this.getRightEditablePosition(position);
|
|
8986
|
+
var isNextPlaceholder = maskPlaceholder && nextEditablePosition ? character === maskPlaceholder[nextEditablePosition] : null;
|
|
8987
|
+
var valueBefore = value.slice(0, position);
|
|
8988
|
+
if (isAllowed || !isEditable) {
|
|
8989
|
+
var insertedCharacter = isAllowed ? character : mask[position];
|
|
8990
|
+
value = valueBefore + insertedCharacter;
|
|
8991
|
+
}
|
|
8992
|
+
if (!isAllowed && !isEditable && !isNextPlaceholder) {
|
|
8993
|
+
value = _this.insertCharacterAtPosition(value, character, position + 1);
|
|
8994
|
+
}
|
|
8995
|
+
return value;
|
|
8996
|
+
};
|
|
8997
|
+
this.insertStringAtPosition = function (value, string, position) {
|
|
8998
|
+
var _this$maskOptions5 = _this.maskOptions,
|
|
8999
|
+
mask = _this$maskOptions5.mask,
|
|
9000
|
+
maskPlaceholder = _this$maskOptions5.maskPlaceholder;
|
|
9001
|
+
if (!string || position >= mask.length) {
|
|
9002
|
+
return value;
|
|
9003
|
+
}
|
|
9004
|
+
var characters = string.split("");
|
|
9005
|
+
var isFixedLength = _this.isValueFilled(value) || !!maskPlaceholder;
|
|
9006
|
+
var valueAfter = value.slice(position);
|
|
9007
|
+
value = characters.reduce(function (value, character) {
|
|
9008
|
+
return _this.insertCharacterAtPosition(value, character, value.length);
|
|
9009
|
+
}, value.slice(0, position));
|
|
9010
|
+
if (isFixedLength) {
|
|
9011
|
+
value += valueAfter.slice(value.length - position);
|
|
9012
|
+
} else if (_this.isValueFilled(value)) {
|
|
9013
|
+
value += mask.slice(value.length).join("");
|
|
9014
|
+
} else {
|
|
9015
|
+
var editableCharactersAfter = valueAfter.split("").filter(function (character, i) {
|
|
9016
|
+
return _this.isPositionEditable(position + i);
|
|
9017
|
+
});
|
|
9018
|
+
value = editableCharactersAfter.reduce(function (value, character) {
|
|
9019
|
+
var nextEditablePosition = _this.getRightEditablePosition(value.length);
|
|
9020
|
+
if (nextEditablePosition === null) {
|
|
9021
|
+
return value;
|
|
8885
9022
|
}
|
|
8886
|
-
if (
|
|
8887
|
-
|
|
9023
|
+
if (!_this.isPositionEditable(value.length)) {
|
|
9024
|
+
value += mask.slice(value.length, nextEditablePosition).join("");
|
|
8888
9025
|
}
|
|
9026
|
+
return _this.insertCharacterAtPosition(value, character, value.length);
|
|
9027
|
+
}, value);
|
|
9028
|
+
}
|
|
9029
|
+
return value;
|
|
9030
|
+
};
|
|
9031
|
+
this.processChange = function (currentState, previousState) {
|
|
9032
|
+
var _this$maskOptions6 = _this.maskOptions,
|
|
9033
|
+
mask = _this$maskOptions6.mask,
|
|
9034
|
+
prefix = _this$maskOptions6.prefix,
|
|
9035
|
+
lastEditablePosition = _this$maskOptions6.lastEditablePosition;
|
|
9036
|
+
var value = currentState.value,
|
|
9037
|
+
selection = currentState.selection;
|
|
9038
|
+
var previousValue = previousState.value;
|
|
9039
|
+
var previousSelection = previousState.selection;
|
|
9040
|
+
var newValue = value;
|
|
9041
|
+
var enteredString = "";
|
|
9042
|
+
var formattedEnteredStringLength = 0;
|
|
9043
|
+
var removedLength = 0;
|
|
9044
|
+
var cursorPosition = Math.min(previousSelection.start, selection.start);
|
|
9045
|
+
if (selection.end > previousSelection.start) {
|
|
9046
|
+
enteredString = newValue.slice(previousSelection.start, selection.end);
|
|
9047
|
+
formattedEnteredStringLength = _this.getStringFillingLengthAtPosition(enteredString, cursorPosition);
|
|
9048
|
+
if (!formattedEnteredStringLength) {
|
|
9049
|
+
removedLength = 0;
|
|
9050
|
+
} else {
|
|
9051
|
+
removedLength = previousSelection.length;
|
|
8889
9052
|
}
|
|
8890
|
-
|
|
8891
|
-
|
|
8892
|
-
|
|
8893
|
-
|
|
8894
|
-
|
|
8895
|
-
|
|
8896
|
-
|
|
8897
|
-
|
|
8898
|
-
// https://github.com/sanniassin/react-input-mask/issues/108
|
|
8899
|
-
if (!_this.focused && document.addEventListener) {
|
|
8900
|
-
_this.mouseDownX = event.clientX;
|
|
8901
|
-
_this.mouseDownY = event.clientY;
|
|
8902
|
-
_this.mouseDownTime = new Date().getTime();
|
|
8903
|
-
var mouseUpHandler = function mouseUpHandler(mouseUpEvent) {
|
|
8904
|
-
document.removeEventListener('mouseup', mouseUpHandler);
|
|
8905
|
-
if (!_this.focused) {
|
|
8906
|
-
return;
|
|
8907
|
-
}
|
|
8908
|
-
var deltaX = Math.abs(mouseUpEvent.clientX - _this.mouseDownX);
|
|
8909
|
-
var deltaY = Math.abs(mouseUpEvent.clientY - _this.mouseDownY);
|
|
8910
|
-
var axisDelta = Math.max(deltaX, deltaY);
|
|
8911
|
-
var timeDelta = new Date().getTime() - _this.mouseDownTime;
|
|
8912
|
-
if (axisDelta <= 10 && timeDelta <= 200 || axisDelta <= 5 && timeDelta <= 300) {
|
|
8913
|
-
_this.setCursorToEnd();
|
|
8914
|
-
}
|
|
8915
|
-
};
|
|
8916
|
-
document.addEventListener('mouseup', mouseUpHandler);
|
|
9053
|
+
} else if (newValue.length < previousValue.length) {
|
|
9054
|
+
removedLength = previousValue.length - newValue.length;
|
|
9055
|
+
}
|
|
9056
|
+
newValue = previousValue;
|
|
9057
|
+
if (removedLength) {
|
|
9058
|
+
if (removedLength === 1 && !previousSelection.length) {
|
|
9059
|
+
var deleteFromRight = previousSelection.start === selection.start;
|
|
9060
|
+
cursorPosition = deleteFromRight ? _this.getRightEditablePosition(selection.start) : _this.getLeftEditablePosition(selection.start);
|
|
8917
9061
|
}
|
|
8918
|
-
|
|
8919
|
-
|
|
9062
|
+
newValue = _this.clearRange(newValue, cursorPosition, removedLength);
|
|
9063
|
+
}
|
|
9064
|
+
newValue = _this.insertStringAtPosition(newValue, enteredString, cursorPosition);
|
|
9065
|
+
cursorPosition += formattedEnteredStringLength;
|
|
9066
|
+
if (cursorPosition >= mask.length) {
|
|
9067
|
+
cursorPosition = mask.length;
|
|
9068
|
+
} else if (cursorPosition < prefix.length && !formattedEnteredStringLength) {
|
|
9069
|
+
cursorPosition = prefix.length;
|
|
9070
|
+
} else if (cursorPosition >= prefix.length && cursorPosition < lastEditablePosition && formattedEnteredStringLength) {
|
|
9071
|
+
cursorPosition = _this.getRightEditablePosition(cursorPosition);
|
|
9072
|
+
}
|
|
9073
|
+
newValue = _this.formatValue(newValue);
|
|
9074
|
+
return {
|
|
9075
|
+
value: newValue,
|
|
9076
|
+
enteredString: enteredString,
|
|
9077
|
+
selection: {
|
|
9078
|
+
start: cursorPosition,
|
|
9079
|
+
end: cursorPosition
|
|
8920
9080
|
}
|
|
8921
9081
|
};
|
|
8922
|
-
|
|
8923
|
-
|
|
8924
|
-
|
|
8925
|
-
|
|
8926
|
-
|
|
8927
|
-
|
|
8928
|
-
|
|
8929
|
-
|
|
8930
|
-
|
|
8931
|
-
|
|
8932
|
-
|
|
8933
|
-
|
|
9082
|
+
};
|
|
9083
|
+
this.maskOptions = parseMask(options);
|
|
9084
|
+
};
|
|
9085
|
+
var _excluded = ["alwaysShowMask", "children", "mask", "maskPlaceholder", "beforeMaskedStateChange"];
|
|
9086
|
+
|
|
9087
|
+
// eslint-disable-next-line prefer-arrow-callback
|
|
9088
|
+
var InputMask = /*#__PURE__*/React$1.forwardRef(function InputMask(props, forwardedRef) {
|
|
9089
|
+
var alwaysShowMask = props.alwaysShowMask,
|
|
9090
|
+
children = props.children,
|
|
9091
|
+
mask = props.mask,
|
|
9092
|
+
maskPlaceholder = props.maskPlaceholder,
|
|
9093
|
+
beforeMaskedStateChange = props.beforeMaskedStateChange,
|
|
9094
|
+
restProps = _objectWithoutPropertiesLoose(props, _excluded);
|
|
9095
|
+
validateMaxLength(props);
|
|
9096
|
+
validateMaskPlaceholder(props);
|
|
9097
|
+
var maskUtils = new MaskUtils({
|
|
9098
|
+
mask: mask,
|
|
9099
|
+
maskPlaceholder: maskPlaceholder
|
|
9100
|
+
});
|
|
9101
|
+
var isMasked = !!mask;
|
|
9102
|
+
var isEditable = !restProps.disabled && !restProps.readOnly;
|
|
9103
|
+
var isControlled = props.value !== null && props.value !== undefined;
|
|
9104
|
+
var previousIsMasked = usePrevious(isMasked);
|
|
9105
|
+
var initialValue = toString((isControlled ? props.value : props.defaultValue) || "");
|
|
9106
|
+
var _useInputState = useInputState(initialValue, isMasked),
|
|
9107
|
+
inputRef = _useInputState.inputRef,
|
|
9108
|
+
getInputState = _useInputState.getInputState,
|
|
9109
|
+
setInputState = _useInputState.setInputState,
|
|
9110
|
+
getLastInputState = _useInputState.getLastInputState;
|
|
9111
|
+
var getInputElement = useInputElement(inputRef);
|
|
9112
|
+
function onChange(event) {
|
|
9113
|
+
var currentState = getInputState();
|
|
9114
|
+
var previousState = getLastInputState();
|
|
9115
|
+
var newInputState = maskUtils.processChange(currentState, previousState);
|
|
9116
|
+
if (beforeMaskedStateChange) {
|
|
9117
|
+
newInputState = beforeMaskedStateChange({
|
|
9118
|
+
currentState: currentState,
|
|
9119
|
+
previousState: previousState,
|
|
9120
|
+
nextState: newInputState
|
|
9121
|
+
});
|
|
9122
|
+
}
|
|
9123
|
+
setInputState(newInputState);
|
|
9124
|
+
if (props.onChange) {
|
|
9125
|
+
props.onChange(event);
|
|
9126
|
+
}
|
|
9127
|
+
}
|
|
9128
|
+
function onFocus(event) {
|
|
9129
|
+
// If autoFocus property is set, focus event fires before the ref handler gets called
|
|
9130
|
+
inputRef.current = event.target;
|
|
9131
|
+
var currentValue = getInputState().value;
|
|
9132
|
+
if (isMasked && !maskUtils.isValueFilled(currentValue)) {
|
|
9133
|
+
var newValue = maskUtils.formatValue(currentValue);
|
|
9134
|
+
var newSelection = maskUtils.getDefaultSelectionForValue(newValue);
|
|
9135
|
+
var newInputState = {
|
|
9136
|
+
value: newValue,
|
|
9137
|
+
selection: newSelection
|
|
9138
|
+
};
|
|
9139
|
+
if (beforeMaskedStateChange) {
|
|
9140
|
+
newInputState = beforeMaskedStateChange({
|
|
9141
|
+
currentState: getInputState(),
|
|
9142
|
+
nextState: newInputState
|
|
9143
|
+
});
|
|
9144
|
+
newValue = newInputState.value;
|
|
9145
|
+
newSelection = newInputState.selection;
|
|
8934
9146
|
}
|
|
8935
|
-
|
|
8936
|
-
|
|
8937
|
-
|
|
8938
|
-
_this.props.inputRef(ref);
|
|
9147
|
+
setInputState(newInputState);
|
|
9148
|
+
if (newValue !== currentValue && props.onChange) {
|
|
9149
|
+
props.onChange(event);
|
|
8939
9150
|
}
|
|
8940
|
-
|
|
8941
|
-
|
|
8942
|
-
|
|
8943
|
-
|
|
8944
|
-
|
|
8945
|
-
|
|
8946
|
-
|
|
8947
|
-
|
|
8948
|
-
|
|
8949
|
-
|
|
8950
|
-
|
|
8951
|
-
|
|
8952
|
-
|
|
8953
|
-
|
|
8954
|
-
|
|
8955
|
-
|
|
8956
|
-
|
|
8957
|
-
|
|
8958
|
-
|
|
8959
|
-
|
|
8960
|
-
|
|
8961
|
-
oldValue = defaultValue;
|
|
9151
|
+
|
|
9152
|
+
// Chrome resets selection after focus event,
|
|
9153
|
+
// so we want to restore it later
|
|
9154
|
+
defer(function () {
|
|
9155
|
+
setInputState(getLastInputState());
|
|
9156
|
+
});
|
|
9157
|
+
}
|
|
9158
|
+
if (props.onFocus) {
|
|
9159
|
+
props.onFocus(event);
|
|
9160
|
+
}
|
|
9161
|
+
}
|
|
9162
|
+
function onBlur(event) {
|
|
9163
|
+
var currentValue = getInputState().value;
|
|
9164
|
+
var lastValue = getLastInputState().value;
|
|
9165
|
+
if (isMasked && !alwaysShowMask && maskUtils.isValueEmpty(lastValue)) {
|
|
9166
|
+
var newValue = "";
|
|
9167
|
+
var newInputState = {
|
|
9168
|
+
value: newValue,
|
|
9169
|
+
selection: {
|
|
9170
|
+
start: null,
|
|
9171
|
+
end: null
|
|
8962
9172
|
}
|
|
8963
|
-
|
|
8964
|
-
|
|
8965
|
-
|
|
8966
|
-
|
|
8967
|
-
|
|
8968
|
-
|
|
8969
|
-
|
|
8970
|
-
}, null, _this.getBeforeMaskedValueChangeConfig());
|
|
8971
|
-
_newValue = modifiedValue.value;
|
|
9173
|
+
};
|
|
9174
|
+
if (beforeMaskedStateChange) {
|
|
9175
|
+
newInputState = beforeMaskedStateChange({
|
|
9176
|
+
currentState: getInputState(),
|
|
9177
|
+
nextState: newInputState
|
|
9178
|
+
});
|
|
9179
|
+
newValue = newInputState.value;
|
|
8972
9180
|
}
|
|
9181
|
+
setInputState(newInputState);
|
|
9182
|
+
if (newValue !== currentValue && props.onChange) {
|
|
9183
|
+
props.onChange(event);
|
|
9184
|
+
}
|
|
9185
|
+
}
|
|
9186
|
+
if (props.onBlur) {
|
|
9187
|
+
props.onBlur(event);
|
|
8973
9188
|
}
|
|
8974
|
-
_this.value = _newValue;
|
|
8975
|
-
return _this;
|
|
8976
9189
|
}
|
|
8977
|
-
var _proto = InputElement.prototype;
|
|
8978
|
-
_proto.componentDidMount = function componentDidMount() {
|
|
8979
|
-
this.mounted = true; // workaround for react-test-renderer
|
|
8980
|
-
// https://github.com/sanniassin/react-input-mask/issues/147
|
|
8981
9190
|
|
|
8982
|
-
|
|
8983
|
-
|
|
8984
|
-
|
|
8985
|
-
|
|
8986
|
-
|
|
8987
|
-
|
|
8988
|
-
|
|
8989
|
-
};
|
|
8990
|
-
_proto.componentDidUpdate = function componentDidUpdate() {
|
|
8991
|
-
var previousSelection = this.previousSelection;
|
|
8992
|
-
var _this$props = this.props,
|
|
8993
|
-
beforeMaskedValueChange = _this$props.beforeMaskedValueChange,
|
|
8994
|
-
alwaysShowMask = _this$props.alwaysShowMask,
|
|
8995
|
-
mask = _this$props.mask,
|
|
8996
|
-
maskChar = _this$props.maskChar,
|
|
8997
|
-
formatChars = _this$props.formatChars;
|
|
8998
|
-
var previousMaskOptions = this.maskOptions;
|
|
8999
|
-
var showEmpty = alwaysShowMask || this.isFocused();
|
|
9000
|
-
var hasValue = this.props.value != null;
|
|
9001
|
-
var newValue = hasValue ? getStringValue(this.props.value) : this.value;
|
|
9002
|
-
var cursorPosition = previousSelection ? previousSelection.start : null;
|
|
9003
|
-
this.maskOptions = parseMask(mask, maskChar, formatChars);
|
|
9004
|
-
if (!this.maskOptions.mask) {
|
|
9005
|
-
if (previousMaskOptions.mask) {
|
|
9006
|
-
this.stopSaveSelectionLoop(); // render depends on this.maskOptions and this.value,
|
|
9007
|
-
// call forceUpdate to keep it in sync
|
|
9008
|
-
|
|
9009
|
-
this.forceUpdate();
|
|
9010
|
-
}
|
|
9191
|
+
// Tiny unintentional mouse movements can break cursor
|
|
9192
|
+
// position on focus, so we have to restore it in that case
|
|
9193
|
+
//
|
|
9194
|
+
// https://github.com/sanniassin/react-input-mask/issues/108
|
|
9195
|
+
function onMouseDown(event) {
|
|
9196
|
+
var input = getInputElement();
|
|
9197
|
+
if (!input) {
|
|
9011
9198
|
return;
|
|
9012
|
-
} else if (!previousMaskOptions.mask && this.isFocused()) {
|
|
9013
|
-
this.runSaveSelectionLoop();
|
|
9014
9199
|
}
|
|
9015
|
-
var
|
|
9016
|
-
|
|
9017
|
-
|
|
9200
|
+
var _getInputState = getInputState(),
|
|
9201
|
+
value = _getInputState.value;
|
|
9202
|
+
var inputDocument = getElementDocument(input);
|
|
9203
|
+
if (!isInputFocused(input) && !maskUtils.isValueFilled(value)) {
|
|
9204
|
+
var mouseDownX = event.clientX;
|
|
9205
|
+
var mouseDownY = event.clientY;
|
|
9206
|
+
var mouseDownTime = new Date().getTime();
|
|
9207
|
+
var mouseUpHandler = function mouseUpHandler(mouseUpEvent) {
|
|
9208
|
+
inputDocument.removeEventListener("mouseup", mouseUpHandler);
|
|
9209
|
+
if (!isInputFocused(input)) {
|
|
9210
|
+
return;
|
|
9211
|
+
}
|
|
9212
|
+
var deltaX = Math.abs(mouseUpEvent.clientX - mouseDownX);
|
|
9213
|
+
var deltaY = Math.abs(mouseUpEvent.clientY - mouseDownY);
|
|
9214
|
+
var axisDelta = Math.max(deltaX, deltaY);
|
|
9215
|
+
var timeDelta = new Date().getTime() - mouseDownTime;
|
|
9216
|
+
if (axisDelta <= 10 && timeDelta <= 200 || axisDelta <= 5 && timeDelta <= 300) {
|
|
9217
|
+
var _lastState = getLastInputState();
|
|
9218
|
+
var newSelection = maskUtils.getDefaultSelectionForValue(_lastState.value);
|
|
9219
|
+
var newState = _extends({}, _lastState, {
|
|
9220
|
+
selection: newSelection
|
|
9221
|
+
});
|
|
9222
|
+
setInputState(newState);
|
|
9223
|
+
}
|
|
9224
|
+
};
|
|
9225
|
+
inputDocument.addEventListener("mouseup", mouseUpHandler);
|
|
9018
9226
|
}
|
|
9019
|
-
if (
|
|
9020
|
-
|
|
9227
|
+
if (props.onMouseDown) {
|
|
9228
|
+
props.onMouseDown(event);
|
|
9021
9229
|
}
|
|
9022
|
-
|
|
9023
|
-
|
|
9024
|
-
|
|
9025
|
-
|
|
9026
|
-
|
|
9027
|
-
|
|
9028
|
-
|
|
9230
|
+
}
|
|
9231
|
+
|
|
9232
|
+
// For controlled inputs we want to provide properly formatted
|
|
9233
|
+
// value prop
|
|
9234
|
+
if (isMasked && isControlled) {
|
|
9235
|
+
var input = getInputElement();
|
|
9236
|
+
var isFocused = input && isInputFocused(input);
|
|
9237
|
+
var newValue = isFocused || alwaysShowMask || props.value ? maskUtils.formatValue(props.value) : props.value;
|
|
9238
|
+
if (beforeMaskedStateChange) {
|
|
9239
|
+
newValue = beforeMaskedStateChange({
|
|
9240
|
+
nextState: {
|
|
9241
|
+
value: newValue,
|
|
9242
|
+
selection: {
|
|
9243
|
+
start: null,
|
|
9244
|
+
end: null
|
|
9245
|
+
}
|
|
9029
9246
|
}
|
|
9030
|
-
}
|
|
9247
|
+
}).value;
|
|
9031
9248
|
}
|
|
9032
|
-
|
|
9033
|
-
newValue
|
|
9249
|
+
setInputState(_extends({}, getLastInputState(), {
|
|
9250
|
+
value: newValue
|
|
9251
|
+
}));
|
|
9252
|
+
}
|
|
9253
|
+
var lastState = getLastInputState();
|
|
9254
|
+
var lastSelection = lastState.selection;
|
|
9255
|
+
var lastValue = lastState.value;
|
|
9256
|
+
React$1.useLayoutEffect(function () {
|
|
9257
|
+
if (!isMasked) {
|
|
9258
|
+
return;
|
|
9034
9259
|
}
|
|
9035
|
-
var
|
|
9036
|
-
|
|
9037
|
-
|
|
9038
|
-
};
|
|
9039
|
-
if (isFunction(beforeMaskedValueChange)) {
|
|
9040
|
-
var modifiedValue = beforeMaskedValueChange({
|
|
9041
|
-
value: newValue,
|
|
9042
|
-
selection: newSelection
|
|
9043
|
-
}, {
|
|
9044
|
-
value: this.value,
|
|
9045
|
-
selection: this.previousSelection
|
|
9046
|
-
}, null, this.getBeforeMaskedValueChangeConfig());
|
|
9047
|
-
newValue = modifiedValue.value;
|
|
9048
|
-
newSelection = modifiedValue.selection;
|
|
9049
|
-
}
|
|
9050
|
-
this.value = newValue;
|
|
9051
|
-
var isValueChanged = this.getInputValue() !== this.value; // render depends on this.maskOptions and this.value,
|
|
9052
|
-
// call forceUpdate to keep it in sync
|
|
9053
|
-
|
|
9054
|
-
if (isValueChanged) {
|
|
9055
|
-
this.setInputValue(this.value);
|
|
9056
|
-
this.forceUpdate();
|
|
9057
|
-
} else if (isMaskChanged) {
|
|
9058
|
-
this.forceUpdate();
|
|
9059
|
-
}
|
|
9060
|
-
var isSelectionChanged = false;
|
|
9061
|
-
if (newSelection.start != null && newSelection.end != null) {
|
|
9062
|
-
isSelectionChanged = !previousSelection || previousSelection.start !== newSelection.start || previousSelection.end !== newSelection.end;
|
|
9063
|
-
}
|
|
9064
|
-
if (isSelectionChanged || isValueChanged) {
|
|
9065
|
-
this.setSelection(newSelection.start, newSelection.end);
|
|
9260
|
+
var input = getInputElement();
|
|
9261
|
+
if (!input) {
|
|
9262
|
+
return;
|
|
9066
9263
|
}
|
|
9067
|
-
|
|
9068
|
-
|
|
9069
|
-
|
|
9070
|
-
|
|
9071
|
-
|
|
9264
|
+
var isFocused = isInputFocused(input);
|
|
9265
|
+
var previousSelection = lastSelection;
|
|
9266
|
+
var currentState = getInputState();
|
|
9267
|
+
var newInputState = _extends({}, currentState);
|
|
9268
|
+
|
|
9269
|
+
// Update value for uncontrolled inputs to make sure
|
|
9270
|
+
// it's always in sync with mask props
|
|
9271
|
+
if (!isControlled) {
|
|
9272
|
+
var currentValue = currentState.value;
|
|
9273
|
+
var formattedValue = maskUtils.formatValue(currentValue);
|
|
9274
|
+
var isValueEmpty = maskUtils.isValueEmpty(formattedValue);
|
|
9275
|
+
var shouldFormatValue = !isValueEmpty || isFocused || alwaysShowMask;
|
|
9276
|
+
if (shouldFormatValue) {
|
|
9277
|
+
newInputState.value = formattedValue;
|
|
9278
|
+
} else if (isValueEmpty && !isFocused) {
|
|
9279
|
+
newInputState.value = "";
|
|
9280
|
+
}
|
|
9072
9281
|
}
|
|
9073
|
-
|
|
9074
|
-
|
|
9075
|
-
|
|
9076
|
-
|
|
9077
|
-
|
|
9078
|
-
|
|
9079
|
-
|
|
9080
|
-
|
|
9081
|
-
|
|
9082
|
-
|
|
9083
|
-
|
|
9084
|
-
|
|
9085
|
-
|
|
9086
|
-
process.env.NODE_ENV !== "production" ? warning(
|
|
9087
|
-
// parse mask to test against actual mask prop as this.maskOptions
|
|
9088
|
-
// will be updated later in componentDidUpdate
|
|
9089
|
-
!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;
|
|
9090
|
-
if (children) {
|
|
9091
|
-
!isFunction(children) ? process.env.NODE_ENV !== "production" ? invariant(false, 'react-input-mask: children must be a function') : invariant(false) : void 0;
|
|
9092
|
-
var controlledProps = ['onChange', 'onPaste', 'onMouseDown', 'onFocus', 'onBlur', 'value', 'disabled', 'readOnly'];
|
|
9093
|
-
var childrenProps = _extends({}, restProps);
|
|
9094
|
-
controlledProps.forEach(function (propId) {
|
|
9095
|
-
return delete childrenProps[propId];
|
|
9096
|
-
});
|
|
9097
|
-
inputElement = children(childrenProps);
|
|
9098
|
-
var conflictProps = controlledProps.filter(function (propId) {
|
|
9099
|
-
return inputElement.props[propId] != null && inputElement.props[propId] !== restProps[propId];
|
|
9282
|
+
if (isFocused && !previousIsMasked) {
|
|
9283
|
+
// Adjust selection if input got masked while being focused
|
|
9284
|
+
newInputState.selection = maskUtils.getDefaultSelectionForValue(newInputState.value);
|
|
9285
|
+
} else if (isControlled && isFocused && previousSelection) {
|
|
9286
|
+
// Restore cursor position if value has changed outside change event
|
|
9287
|
+
if (previousSelection.start !== null && previousSelection.end !== null) {
|
|
9288
|
+
newInputState.selection = previousSelection;
|
|
9289
|
+
}
|
|
9290
|
+
}
|
|
9291
|
+
if (beforeMaskedStateChange) {
|
|
9292
|
+
newInputState = beforeMaskedStateChange({
|
|
9293
|
+
currentState: currentState,
|
|
9294
|
+
nextState: newInputState
|
|
9100
9295
|
});
|
|
9101
|
-
!!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;
|
|
9102
|
-
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;
|
|
9103
|
-
} else {
|
|
9104
|
-
inputElement = React$1.createElement("input", _extends({
|
|
9105
|
-
ref: this.handleRef
|
|
9106
|
-
}, restProps));
|
|
9107
9296
|
}
|
|
9108
|
-
|
|
9109
|
-
|
|
9110
|
-
|
|
9111
|
-
|
|
9112
|
-
|
|
9113
|
-
|
|
9114
|
-
|
|
9115
|
-
|
|
9116
|
-
|
|
9117
|
-
|
|
9118
|
-
if (restProps.value != null) {
|
|
9119
|
-
changedProps.value = this.value;
|
|
9120
|
-
}
|
|
9297
|
+
setInputState(newInputState);
|
|
9298
|
+
});
|
|
9299
|
+
var refCallback = function refCallback(node) {
|
|
9300
|
+
inputRef.current = node;
|
|
9301
|
+
|
|
9302
|
+
// if a ref callback is passed to InputMask
|
|
9303
|
+
if (isFunction(forwardedRef)) {
|
|
9304
|
+
forwardedRef(node);
|
|
9305
|
+
} else if (forwardedRef !== null && _typeof$1(forwardedRef) === "object") {
|
|
9306
|
+
forwardedRef.current = node;
|
|
9121
9307
|
}
|
|
9122
|
-
inputElement = React$1.cloneElement(inputElement, changedProps);
|
|
9123
|
-
return inputElement;
|
|
9124
9308
|
};
|
|
9125
|
-
|
|
9126
|
-
|
|
9127
|
-
|
|
9309
|
+
var inputProps = _extends({}, restProps, {
|
|
9310
|
+
onFocus: onFocus,
|
|
9311
|
+
onBlur: onBlur,
|
|
9312
|
+
onChange: isMasked && isEditable ? onChange : props.onChange,
|
|
9313
|
+
onMouseDown: isMasked && isEditable ? onMouseDown : props.onMouseDown,
|
|
9314
|
+
value: isMasked && isControlled ? lastValue : props.value
|
|
9315
|
+
});
|
|
9316
|
+
if (children) {
|
|
9317
|
+
validateChildren(props, children);
|
|
9318
|
+
|
|
9319
|
+
// {@link https://stackoverflow.com/q/63149840/327074}
|
|
9320
|
+
var onlyChild = React$1.Children.only(children);
|
|
9321
|
+
return /*#__PURE__*/React$1.cloneElement(onlyChild, _extends({}, inputProps, {
|
|
9322
|
+
ref: refCallback
|
|
9323
|
+
}));
|
|
9324
|
+
}
|
|
9325
|
+
return /*#__PURE__*/React$1.createElement("input", _extends({
|
|
9326
|
+
ref: refCallback
|
|
9327
|
+
}, inputProps));
|
|
9328
|
+
});
|
|
9329
|
+
InputMask.displayName = "InputMask";
|
|
9330
|
+
InputMask.defaultProps = {
|
|
9331
|
+
alwaysShowMask: false,
|
|
9332
|
+
maskPlaceholder: "_"
|
|
9333
|
+
};
|
|
9334
|
+
InputMask.propTypes = {
|
|
9335
|
+
alwaysShowMask: PropTypes.bool,
|
|
9336
|
+
beforeMaskedStateChange: PropTypes.func,
|
|
9337
|
+
children: PropTypes.element,
|
|
9338
|
+
mask: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.instanceOf(RegExp)]))]),
|
|
9339
|
+
maskPlaceholder: PropTypes.string,
|
|
9340
|
+
onFocus: PropTypes.func,
|
|
9341
|
+
onBlur: PropTypes.func,
|
|
9342
|
+
onChange: PropTypes.func,
|
|
9343
|
+
onMouseDown: PropTypes.func
|
|
9344
|
+
};
|
|
9345
|
+
reactInputMask_development = InputMask;
|
|
9128
9346
|
return reactInputMask_development;
|
|
9129
9347
|
}
|
|
9130
9348
|
|
|
9349
|
+
/* eslint-disable import/no-unresolved */
|
|
9131
9350
|
var hasRequiredReactInputMask;
|
|
9132
9351
|
function requireReactInputMask() {
|
|
9133
9352
|
if (hasRequiredReactInputMask) return reactInputMask.exports;
|
|
9134
9353
|
hasRequiredReactInputMask = 1;
|
|
9135
|
-
if (process.env.NODE_ENV ===
|
|
9354
|
+
if (process.env.NODE_ENV === "production") {
|
|
9136
9355
|
reactInputMask.exports = requireReactInputMask_production_min();
|
|
9137
9356
|
} else {
|
|
9138
9357
|
reactInputMask.exports = requireReactInputMask_development();
|
|
@@ -10142,7 +10361,7 @@ var t = function t(_t) {
|
|
|
10142
10361
|
return !!e && (e.clientHeight < t.scrollHeight || e.clientWidth < t.scrollWidth);
|
|
10143
10362
|
}(t);
|
|
10144
10363
|
}
|
|
10145
|
-
return
|
|
10364
|
+
return false;
|
|
10146
10365
|
},
|
|
10147
10366
|
o$1 = function o(t, e, n, _o2, l, r, i, s) {
|
|
10148
10367
|
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;
|
|
@@ -10204,41 +10423,41 @@ var t = function t(_t) {
|
|
|
10204
10423
|
for (var _t2 = 0; _t2 < w.length; _t2++) {
|
|
10205
10424
|
var _e2 = w[_t2],
|
|
10206
10425
|
_e$getBoundingClientR2 = _e2.getBoundingClientRect(),
|
|
10207
|
-
|
|
10208
|
-
|
|
10209
|
-
|
|
10210
|
-
|
|
10211
|
-
|
|
10212
|
-
|
|
10213
|
-
if ("if-needed" === c && x >= 0 && R >= 0 && I <= H && C <= b && x >=
|
|
10214
|
-
var
|
|
10215
|
-
|
|
10216
|
-
|
|
10217
|
-
|
|
10218
|
-
|
|
10219
|
-
var
|
|
10220
|
-
|
|
10221
|
-
var
|
|
10222
|
-
|
|
10223
|
-
|
|
10224
|
-
|
|
10225
|
-
if (m === _e2)
|
|
10226
|
-
|
|
10426
|
+
_l = _e$getBoundingClientR2.height,
|
|
10427
|
+
_r = _e$getBoundingClientR2.width,
|
|
10428
|
+
_i = _e$getBoundingClientR2.top,
|
|
10429
|
+
_s = _e$getBoundingClientR2.right,
|
|
10430
|
+
_d = _e$getBoundingClientR2.bottom,
|
|
10431
|
+
_h = _e$getBoundingClientR2.left;
|
|
10432
|
+
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;
|
|
10433
|
+
var _a = getComputedStyle(_e2),
|
|
10434
|
+
_g = parseInt(_a.borderLeftWidth, 10),
|
|
10435
|
+
_p = parseInt(_a.borderTopWidth, 10),
|
|
10436
|
+
_W = parseInt(_a.borderRightWidth, 10),
|
|
10437
|
+
_T = parseInt(_a.borderBottomWidth, 10);
|
|
10438
|
+
var _B = 0,
|
|
10439
|
+
_F = 0;
|
|
10440
|
+
var _V = "offsetWidth" in _e2 ? _e2.offsetWidth - _e2.clientWidth - _g - _W : 0,
|
|
10441
|
+
S = "offsetHeight" in _e2 ? _e2.offsetHeight - _e2.clientHeight - _p - _T : 0,
|
|
10442
|
+
X = "offsetWidth" in _e2 ? 0 === _e2.offsetWidth ? 0 : _r / _e2.offsetWidth : 0,
|
|
10443
|
+
Y = "offsetHeight" in _e2 ? 0 === _e2.offsetHeight ? 0 : _l / _e2.offsetHeight : 0;
|
|
10444
|
+
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 {
|
|
10445
|
+
_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);
|
|
10227
10446
|
var _t3 = _e2.scrollLeft,
|
|
10228
|
-
|
|
10229
|
-
|
|
10447
|
+
_n2 = _e2.scrollTop;
|
|
10448
|
+
_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;
|
|
10230
10449
|
}
|
|
10231
10450
|
L.push({
|
|
10232
10451
|
el: _e2,
|
|
10233
|
-
top:
|
|
10234
|
-
left:
|
|
10452
|
+
top: _B,
|
|
10453
|
+
left: _F
|
|
10235
10454
|
});
|
|
10236
10455
|
}
|
|
10237
10456
|
return L;
|
|
10238
10457
|
};
|
|
10239
10458
|
|
|
10240
10459
|
var o = function o(t) {
|
|
10241
|
-
return
|
|
10460
|
+
return false === t ? {
|
|
10242
10461
|
block: "end",
|
|
10243
10462
|
inline: "nearest"
|
|
10244
10463
|
} : function (t) {
|
|
@@ -10252,10 +10471,10 @@ function e(e, r$1) {
|
|
|
10252
10471
|
if (!e.isConnected || !function (t) {
|
|
10253
10472
|
var o = t;
|
|
10254
10473
|
for (; o && o.parentNode;) {
|
|
10255
|
-
if (o.parentNode === document) return
|
|
10474
|
+
if (o.parentNode === document) return true;
|
|
10256
10475
|
o = o.parentNode instanceof ShadowRoot ? o.parentNode.host : o.parentNode;
|
|
10257
10476
|
}
|
|
10258
|
-
return
|
|
10477
|
+
return false;
|
|
10259
10478
|
}(e)) return;
|
|
10260
10479
|
var n = function (t) {
|
|
10261
10480
|
var o = window.getComputedStyle(t);
|
|
@@ -10900,15 +11119,9 @@ var CreditCardNumberInput = function CreditCardNumberInput(_ref) {
|
|
|
10900
11119
|
setValue(event.target.value);
|
|
10901
11120
|
onChange === null || onChange === void 0 || onChange(event.target.value);
|
|
10902
11121
|
}, [setValue, onChange]);
|
|
10903
|
-
|
|
10904
|
-
// 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
|
|
10905
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10906
|
-
var renderInputField = function renderInputField(inputProps) {
|
|
10907
|
-
return /*#__PURE__*/React.createElement(CreditCardNumberInputField, _extends$1({}, rest, inputProps));
|
|
10908
|
-
};
|
|
10909
11122
|
return /*#__PURE__*/React.createElement(InputMask, {
|
|
10910
11123
|
mask: mask,
|
|
10911
|
-
|
|
11124
|
+
maskPlaceholder: maskChar,
|
|
10912
11125
|
alwaysShowMask: alwaysShowMask,
|
|
10913
11126
|
disabled: disabled,
|
|
10914
11127
|
readOnly: readOnly,
|
|
@@ -10917,7 +11130,7 @@ var CreditCardNumberInput = function CreditCardNumberInput(_ref) {
|
|
|
10917
11130
|
onMouseDown: onMouseDown,
|
|
10918
11131
|
onFocus: onFocus,
|
|
10919
11132
|
onBlur: onBlur
|
|
10920
|
-
},
|
|
11133
|
+
}, /*#__PURE__*/React.createElement(CreditCardNumberInputField, rest));
|
|
10921
11134
|
};
|
|
10922
11135
|
|
|
10923
11136
|
var _excluded$e = ["term", "children", "className"];
|
|
@@ -11757,11 +11970,6 @@ var LoadingShapesLavenderBlue = function LoadingShapesLavenderBlue() {
|
|
|
11757
11970
|
}));
|
|
11758
11971
|
};
|
|
11759
11972
|
|
|
11760
|
-
var preventNavigation = function preventNavigation(event) {
|
|
11761
|
-
event.preventDefault();
|
|
11762
|
-
event.returnValue = '';
|
|
11763
|
-
};
|
|
11764
|
-
|
|
11765
11973
|
var usePreventNavigation = function usePreventNavigation() {
|
|
11766
11974
|
var enabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
11767
11975
|
React.useEffect(function () {
|
|
@@ -11776,11 +11984,14 @@ var usePreventNavigation = function usePreventNavigation() {
|
|
|
11776
11984
|
|
|
11777
11985
|
var NavigationPreventer = function NavigationPreventer(_ref) {
|
|
11778
11986
|
var _ref$enabled = _ref.enabled,
|
|
11779
|
-
enabled = _ref$enabled === void 0 ? false : _ref$enabled
|
|
11987
|
+
enabled = _ref$enabled === void 0 ? false : _ref$enabled,
|
|
11988
|
+
_ref$message = _ref.message,
|
|
11989
|
+
message = _ref$message === void 0 ? 'Changes that you made may not be saved.' : _ref$message;
|
|
11780
11990
|
usePreventNavigation(enabled);
|
|
11781
|
-
|
|
11782
|
-
|
|
11783
|
-
|
|
11991
|
+
return /*#__PURE__*/React.createElement(reactRouterDom.Prompt, {
|
|
11992
|
+
when: enabled,
|
|
11993
|
+
message: message
|
|
11994
|
+
});
|
|
11784
11995
|
};
|
|
11785
11996
|
|
|
11786
11997
|
var __assign$1 = undefined && undefined.__assign || function () {
|