@moda/om 21.7.2 → 21.9.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 +305 -30
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +305 -31
- package/dist/index.esm.js.map +1 -1
- package/dist/src/components/Field/Field.d.ts +1 -1
- package/dist/src/components/OtpInput/OtpInput.d.ts +14 -0
- package/dist/src/components/OtpInput/OtpInput.stories.d.ts +7 -0
- package/dist/src/components/OtpInput/OtpInput.test.d.ts +1 -0
- package/dist/src/components/OtpInput/index.d.ts +1 -0
- package/dist/src/components/Tabs/TabList.d.ts +1 -0
- package/dist/src/components/Tabs/Tabs.d.ts +1 -0
- package/dist/src/components/index.d.ts +1 -0
- package/dist/styles.css +1 -1
- package/package.json +54 -53
- package/src/components/OtpInput/OtpInput.scss +24 -0
- package/src/components/OtpInput/OtpInput.stories.tsx +26 -0
- package/src/components/OtpInput/OtpInput.test.tsx +45 -0
- package/src/components/OtpInput/OtpInput.tsx +95 -0
- package/src/components/OtpInput/index.ts +1 -0
- package/src/components/Tabs/TabList.tsx +15 -9
- package/src/components/Tabs/Tabs.tsx +8 -1
- package/src/components/index.ts +1 -0
- package/src/global.d.ts +9 -0
package/dist/index.cjs.js
CHANGED
|
@@ -356,18 +356,18 @@ requireFocusVisible();
|
|
|
356
356
|
|
|
357
357
|
var dist$4 = {};
|
|
358
358
|
|
|
359
|
-
var colors = {};
|
|
359
|
+
var colors$1 = {};
|
|
360
360
|
|
|
361
361
|
var hasRequiredColors;
|
|
362
362
|
function requireColors() {
|
|
363
|
-
if (hasRequiredColors) return colors;
|
|
363
|
+
if (hasRequiredColors) return colors$1;
|
|
364
364
|
hasRequiredColors = 1;
|
|
365
|
-
Object.defineProperty(colors, "__esModule", {
|
|
365
|
+
Object.defineProperty(colors$1, "__esModule", {
|
|
366
366
|
value: true
|
|
367
367
|
});
|
|
368
|
-
colors.colors = void 0;
|
|
368
|
+
colors$1.colors = void 0;
|
|
369
369
|
// THIS FILE IS AUTO-GENERATED. DO NOT EDIT.
|
|
370
|
-
colors.colors = {
|
|
370
|
+
colors$1.colors = {
|
|
371
371
|
"all": {
|
|
372
372
|
"coal": "rgb(0, 0, 0)",
|
|
373
373
|
"ink": "rgb(25, 26, 27)",
|
|
@@ -452,7 +452,7 @@ function requireColors() {
|
|
|
452
452
|
"silver": "rgb(217, 217, 217)"
|
|
453
453
|
}
|
|
454
454
|
};
|
|
455
|
-
return colors;
|
|
455
|
+
return colors$1;
|
|
456
456
|
}
|
|
457
457
|
|
|
458
458
|
var typography = {};
|
|
@@ -594,7 +594,7 @@ function requireBreakpoints() {
|
|
|
594
594
|
|
|
595
595
|
var helpers = {};
|
|
596
596
|
|
|
597
|
-
var
|
|
597
|
+
var colors = {
|
|
598
598
|
aliceblue: [240, 248, 255],
|
|
599
599
|
antiquewhite: [250, 235, 215],
|
|
600
600
|
aqua: [0, 255, 255],
|
|
@@ -744,6 +744,8 @@ var colorNames = {
|
|
|
744
744
|
yellow: [255, 255, 0],
|
|
745
745
|
yellowgreen: [154, 205, 50]
|
|
746
746
|
};
|
|
747
|
+
for (var key in colors) Object.freeze(colors[key]);
|
|
748
|
+
var colorNames = Object.freeze(colors);
|
|
747
749
|
|
|
748
750
|
var reverseNames = Object.create(null);
|
|
749
751
|
|
|
@@ -795,8 +797,8 @@ cs.get.rgb = function (string) {
|
|
|
795
797
|
}
|
|
796
798
|
var abbr = /^#([a-f\d]{3,4})$/i;
|
|
797
799
|
var hex = /^#([a-f\d]{6})([a-f\d]{2})?$/i;
|
|
798
|
-
var rgba = /^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|/]\s*([+-]?
|
|
799
|
-
var per = /^rgba?\(\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*(?:[,|/]\s*([+-]?[\d.]+)(%?)\s*)?\)
|
|
800
|
+
var rgba = /^rgba?\(\s*([+-]?(?:\d*\.)?\d+(?:e\d+)?)(?=[\s,])\s*(?:,\s*)?([+-]?(?:\d*\.)?\d+(?:e\d+)?)(?=[\s,])\s*(?:,\s*)?([+-]?(?:\d*\.)?\d+(?:e\d+)?)\s*(?:[\s,|/]\s*([+-]?(?:\d*\.)?\d+(?:e\d+)?)(%?)\s*)?\)$/i;
|
|
801
|
+
var per = /^rgba?\(\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*(?:[\s,|/]\s*([+-]?[\d.]+)(%?)\s*)?\)$/i;
|
|
800
802
|
var keyword = /^(\w+)$/;
|
|
801
803
|
var rgb = [0, 0, 0, 1];
|
|
802
804
|
var match;
|
|
@@ -824,7 +826,7 @@ cs.get.rgb = function (string) {
|
|
|
824
826
|
}
|
|
825
827
|
} else if (match = string.match(rgba)) {
|
|
826
828
|
for (i = 0; i < 3; i++) {
|
|
827
|
-
rgb[i] = Number.
|
|
829
|
+
rgb[i] = Number.parseFloat(match[i + 1]);
|
|
828
830
|
}
|
|
829
831
|
if (match[4]) {
|
|
830
832
|
rgb[3] = match[5] ? Number.parseFloat(match[4]) * 0.01 : Number.parseFloat(match[4]);
|
|
@@ -836,14 +838,16 @@ cs.get.rgb = function (string) {
|
|
|
836
838
|
if (match[4]) {
|
|
837
839
|
rgb[3] = match[5] ? Number.parseFloat(match[4]) * 0.01 : Number.parseFloat(match[4]);
|
|
838
840
|
}
|
|
839
|
-
} else if (match = string.match(keyword)) {
|
|
841
|
+
} else if (match = string.toLowerCase().match(keyword)) {
|
|
840
842
|
if (match[1] === 'transparent') {
|
|
841
843
|
return [0, 0, 0, 0];
|
|
842
844
|
}
|
|
843
845
|
if (!Object.hasOwn(colorNames, match[1])) {
|
|
844
846
|
return null;
|
|
845
847
|
}
|
|
846
|
-
|
|
848
|
+
|
|
849
|
+
// eslint-disable-next-line unicorn/prefer-spread
|
|
850
|
+
rgb = colorNames[match[1]].slice();
|
|
847
851
|
rgb[3] = 1;
|
|
848
852
|
return rgb;
|
|
849
853
|
} else {
|
|
@@ -859,7 +863,7 @@ cs.get.hsl = function (string) {
|
|
|
859
863
|
if (!string) {
|
|
860
864
|
return null;
|
|
861
865
|
}
|
|
862
|
-
var hsl = /^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*(?:[,|/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[
|
|
866
|
+
var hsl = /^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*(?:[,|/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:e[+-]?\d+)?)\s*)?\)$/i;
|
|
863
867
|
var match = string.match(hsl);
|
|
864
868
|
if (match) {
|
|
865
869
|
var alpha = Number.parseFloat(match[4]);
|
|
@@ -875,7 +879,7 @@ cs.get.hwb = function (string) {
|
|
|
875
879
|
if (!string) {
|
|
876
880
|
return null;
|
|
877
881
|
}
|
|
878
|
-
var hwb = /^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s
|
|
882
|
+
var hwb = /^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*[\s,]\s*([+-]?[\d.]+)%\s*[\s,]\s*([+-]?[\d.]+)%\s*(?:[\s,]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:e[+-]?\d+)?)\s*)?\)$/i;
|
|
879
883
|
var match = string.match(hwb);
|
|
880
884
|
if (match) {
|
|
881
885
|
var alpha = Number.parseFloat(match[4]);
|
|
@@ -3116,8 +3120,6 @@ var extractRef$2 = function extractRef(ref) {
|
|
|
3116
3120
|
var effectCar = createSidecarMedium();
|
|
3117
3121
|
var focusHiddenMarker = 'data-focus-on-hidden';
|
|
3118
3122
|
|
|
3119
|
-
__assign$a({}, RemoveScroll.classNames);
|
|
3120
|
-
|
|
3121
3123
|
var PREVENT_SCROLL = {
|
|
3122
3124
|
preventScroll: true
|
|
3123
3125
|
};
|
|
@@ -4890,6 +4892,13 @@ function RemoveScrollSideCar(props) {
|
|
|
4890
4892
|
if ('touches' in event && moveDirection === 'h' && target.type === 'range') {
|
|
4891
4893
|
return false;
|
|
4892
4894
|
}
|
|
4895
|
+
// allow drag selection (iOS); check if selection's anchorNode is the same as target or contains target
|
|
4896
|
+
var selection = window.getSelection();
|
|
4897
|
+
var anchorNode = selection && selection.anchorNode;
|
|
4898
|
+
var isTouchingSelection = anchorNode ? anchorNode === target || anchorNode.contains(target) : false;
|
|
4899
|
+
if (isTouchingSelection) {
|
|
4900
|
+
return false;
|
|
4901
|
+
}
|
|
4893
4902
|
var canBeScrolledInMainDirection = locationCouldBeScrolled(moveDirection, target);
|
|
4894
4903
|
if (!canBeScrolledInMainDirection) {
|
|
4895
4904
|
return true;
|
|
@@ -9566,14 +9575,13 @@ function requireClone() {
|
|
|
9566
9575
|
Object.defineProperty(clone, "__esModule", {
|
|
9567
9576
|
value: true
|
|
9568
9577
|
});
|
|
9569
|
-
clone.clone =
|
|
9578
|
+
clone.clone = clone$1;
|
|
9570
9579
|
function clone$1(originalObject) {
|
|
9571
9580
|
if (!originalObject) {
|
|
9572
9581
|
return null;
|
|
9573
9582
|
}
|
|
9574
9583
|
return JSON.parse(JSON.stringify(originalObject));
|
|
9575
9584
|
}
|
|
9576
|
-
clone.clone = clone$1;
|
|
9577
9585
|
return clone;
|
|
9578
9586
|
}
|
|
9579
9587
|
|
|
@@ -9589,7 +9597,7 @@ function requireMatches() {
|
|
|
9589
9597
|
Object.defineProperty(matches, "__esModule", {
|
|
9590
9598
|
value: true
|
|
9591
9599
|
});
|
|
9592
|
-
matches.matches =
|
|
9600
|
+
matches.matches = matches$1;
|
|
9593
9601
|
function matchesRange(cardNumber, min, max) {
|
|
9594
9602
|
var maxLengthToCheck = String(min).length;
|
|
9595
9603
|
var substr = cardNumber.substr(0, maxLengthToCheck);
|
|
@@ -9608,7 +9616,6 @@ function requireMatches() {
|
|
|
9608
9616
|
}
|
|
9609
9617
|
return matchesPattern(cardNumber, pattern);
|
|
9610
9618
|
}
|
|
9611
|
-
matches.matches = matches$1;
|
|
9612
9619
|
return matches;
|
|
9613
9620
|
}
|
|
9614
9621
|
|
|
@@ -9619,7 +9626,7 @@ function requireAddMatchingCardsToResults() {
|
|
|
9619
9626
|
Object.defineProperty(addMatchingCardsToResults, "__esModule", {
|
|
9620
9627
|
value: true
|
|
9621
9628
|
});
|
|
9622
|
-
addMatchingCardsToResults.addMatchingCardsToResults =
|
|
9629
|
+
addMatchingCardsToResults.addMatchingCardsToResults = addMatchingCardsToResults$1;
|
|
9623
9630
|
var clone_1 = requireClone();
|
|
9624
9631
|
var matches_1 = requireMatches();
|
|
9625
9632
|
function addMatchingCardsToResults$1(cardNumber, cardConfiguration, results) {
|
|
@@ -9642,7 +9649,6 @@ function requireAddMatchingCardsToResults() {
|
|
|
9642
9649
|
break;
|
|
9643
9650
|
}
|
|
9644
9651
|
}
|
|
9645
|
-
addMatchingCardsToResults.addMatchingCardsToResults = addMatchingCardsToResults$1;
|
|
9646
9652
|
return addMatchingCardsToResults;
|
|
9647
9653
|
}
|
|
9648
9654
|
|
|
@@ -9655,11 +9661,10 @@ function requireIsValidInputType() {
|
|
|
9655
9661
|
Object.defineProperty(isValidInputType, "__esModule", {
|
|
9656
9662
|
value: true
|
|
9657
9663
|
});
|
|
9658
|
-
isValidInputType.isValidInputType =
|
|
9664
|
+
isValidInputType.isValidInputType = isValidInputType$1;
|
|
9659
9665
|
function isValidInputType$1(cardNumber) {
|
|
9660
9666
|
return typeof cardNumber === "string" || cardNumber instanceof String;
|
|
9661
9667
|
}
|
|
9662
|
-
isValidInputType.isValidInputType = isValidInputType$1;
|
|
9663
9668
|
return isValidInputType;
|
|
9664
9669
|
}
|
|
9665
9670
|
|
|
@@ -9672,7 +9677,7 @@ function requireFindBestMatch() {
|
|
|
9672
9677
|
Object.defineProperty(findBestMatch, "__esModule", {
|
|
9673
9678
|
value: true
|
|
9674
9679
|
});
|
|
9675
|
-
findBestMatch.findBestMatch =
|
|
9680
|
+
findBestMatch.findBestMatch = findBestMatch$1;
|
|
9676
9681
|
function hasEnoughResultsToDetermineBestMatch(results) {
|
|
9677
9682
|
var numberOfResultsWithMaxStrengthProperty = results.filter(function (result) {
|
|
9678
9683
|
return result.matchStrength;
|
|
@@ -9702,7 +9707,6 @@ function requireFindBestMatch() {
|
|
|
9702
9707
|
return bestMatch;
|
|
9703
9708
|
});
|
|
9704
9709
|
}
|
|
9705
|
-
findBestMatch.findBestMatch = findBestMatch$1;
|
|
9706
9710
|
return findBestMatch;
|
|
9707
9711
|
}
|
|
9708
9712
|
|
|
@@ -12334,6 +12338,273 @@ var Paginator = function Paginator(_ref) {
|
|
|
12334
12338
|
})));
|
|
12335
12339
|
};
|
|
12336
12340
|
|
|
12341
|
+
var isStyleObject = function isStyleObject(obj) {
|
|
12342
|
+
return _typeof$1(obj) === 'object' && obj !== null;
|
|
12343
|
+
};
|
|
12344
|
+
var OTPInput = function OTPInput(_a) {
|
|
12345
|
+
var _b = _a.value,
|
|
12346
|
+
value = _b === void 0 ? '' : _b,
|
|
12347
|
+
_c = _a.numInputs,
|
|
12348
|
+
numInputs = _c === void 0 ? 4 : _c,
|
|
12349
|
+
onChange = _a.onChange,
|
|
12350
|
+
onPaste = _a.onPaste,
|
|
12351
|
+
renderInput = _a.renderInput,
|
|
12352
|
+
_d = _a.shouldAutoFocus,
|
|
12353
|
+
shouldAutoFocus = _d === void 0 ? false : _d,
|
|
12354
|
+
_e = _a.inputType,
|
|
12355
|
+
inputType = _e === void 0 ? 'text' : _e,
|
|
12356
|
+
renderSeparator = _a.renderSeparator,
|
|
12357
|
+
placeholder = _a.placeholder,
|
|
12358
|
+
containerStyle = _a.containerStyle,
|
|
12359
|
+
inputStyle = _a.inputStyle,
|
|
12360
|
+
_f = _a.skipDefaultStyles,
|
|
12361
|
+
skipDefaultStyles = _f === void 0 ? false : _f;
|
|
12362
|
+
var _g = React.useState(0),
|
|
12363
|
+
activeInput = _g[0],
|
|
12364
|
+
setActiveInput = _g[1];
|
|
12365
|
+
var inputRefs = React.useRef([]);
|
|
12366
|
+
var getOTPValue = function getOTPValue() {
|
|
12367
|
+
return value ? value.toString().split('') : [];
|
|
12368
|
+
};
|
|
12369
|
+
var isInputNum = inputType === 'number' || inputType === 'tel';
|
|
12370
|
+
React.useEffect(function () {
|
|
12371
|
+
inputRefs.current = inputRefs.current.slice(0, numInputs);
|
|
12372
|
+
}, [numInputs]);
|
|
12373
|
+
React.useEffect(function () {
|
|
12374
|
+
var _a;
|
|
12375
|
+
if (shouldAutoFocus) {
|
|
12376
|
+
(_a = inputRefs.current[0]) === null || _a === void 0 ? void 0 : _a.focus();
|
|
12377
|
+
}
|
|
12378
|
+
}, [shouldAutoFocus]);
|
|
12379
|
+
var getPlaceholderValue = function getPlaceholderValue() {
|
|
12380
|
+
if (typeof placeholder === 'string') {
|
|
12381
|
+
if (placeholder.length === numInputs) {
|
|
12382
|
+
return placeholder;
|
|
12383
|
+
}
|
|
12384
|
+
if (placeholder.length > 0) {
|
|
12385
|
+
console.error('Length of the placeholder should be equal to the number of inputs.');
|
|
12386
|
+
}
|
|
12387
|
+
}
|
|
12388
|
+
return undefined;
|
|
12389
|
+
};
|
|
12390
|
+
var isInputValueValid = function isInputValueValid(value) {
|
|
12391
|
+
var isTypeValid = isInputNum ? !isNaN(Number(value)) : typeof value === 'string';
|
|
12392
|
+
return isTypeValid && value.trim().length === 1;
|
|
12393
|
+
};
|
|
12394
|
+
var handleChange = function handleChange(event) {
|
|
12395
|
+
var value = event.target.value;
|
|
12396
|
+
if (isInputValueValid(value)) {
|
|
12397
|
+
changeCodeAtFocus(value);
|
|
12398
|
+
focusInput(activeInput + 1);
|
|
12399
|
+
}
|
|
12400
|
+
};
|
|
12401
|
+
var handleInputChange = function handleInputChange(event) {
|
|
12402
|
+
var nativeEvent = event.nativeEvent;
|
|
12403
|
+
var value = event.target.value;
|
|
12404
|
+
if (!isInputValueValid(value)) {
|
|
12405
|
+
// Pasting from the native autofill suggestion on a mobile device can pass
|
|
12406
|
+
// the pasted string as one long input to one of the cells. This ensures
|
|
12407
|
+
// that we handle the full input and not just the first character.
|
|
12408
|
+
if (value.length === numInputs) {
|
|
12409
|
+
var hasInvalidInput = value.split('').some(function (cellInput) {
|
|
12410
|
+
return !isInputValueValid(cellInput);
|
|
12411
|
+
});
|
|
12412
|
+
if (!hasInvalidInput) {
|
|
12413
|
+
handleOTPChange(value.split(''));
|
|
12414
|
+
focusInput(numInputs - 1);
|
|
12415
|
+
}
|
|
12416
|
+
}
|
|
12417
|
+
// @ts-expect-error - This was added previously to handle and edge case
|
|
12418
|
+
// for dealing with keyCode "229 Unidentified" on Android. Check if this is
|
|
12419
|
+
// still needed.
|
|
12420
|
+
if (nativeEvent.data === null && nativeEvent.inputType === 'deleteContentBackward') {
|
|
12421
|
+
event.preventDefault();
|
|
12422
|
+
changeCodeAtFocus('');
|
|
12423
|
+
focusInput(activeInput - 1);
|
|
12424
|
+
}
|
|
12425
|
+
// Clear the input if it's not valid value because firefox allows
|
|
12426
|
+
// pasting non-numeric characters in a number type input
|
|
12427
|
+
event.target.value = '';
|
|
12428
|
+
}
|
|
12429
|
+
};
|
|
12430
|
+
var handleFocus = function handleFocus(event) {
|
|
12431
|
+
return function (index) {
|
|
12432
|
+
setActiveInput(index);
|
|
12433
|
+
event.target.select();
|
|
12434
|
+
};
|
|
12435
|
+
};
|
|
12436
|
+
var handleBlur = function handleBlur() {
|
|
12437
|
+
setActiveInput(activeInput - 1);
|
|
12438
|
+
};
|
|
12439
|
+
var handleKeyDown = function handleKeyDown(event) {
|
|
12440
|
+
var otp = getOTPValue();
|
|
12441
|
+
if ([event.code, event.key].includes('Backspace')) {
|
|
12442
|
+
event.preventDefault();
|
|
12443
|
+
changeCodeAtFocus('');
|
|
12444
|
+
focusInput(activeInput - 1);
|
|
12445
|
+
} else if (event.code === 'Delete') {
|
|
12446
|
+
event.preventDefault();
|
|
12447
|
+
changeCodeAtFocus('');
|
|
12448
|
+
} else if (event.code === 'ArrowLeft') {
|
|
12449
|
+
event.preventDefault();
|
|
12450
|
+
focusInput(activeInput - 1);
|
|
12451
|
+
} else if (event.code === 'ArrowRight') {
|
|
12452
|
+
event.preventDefault();
|
|
12453
|
+
focusInput(activeInput + 1);
|
|
12454
|
+
}
|
|
12455
|
+
// React does not trigger onChange when the same value is entered
|
|
12456
|
+
// again. So we need to focus the next input manually in this case.
|
|
12457
|
+
else if (event.key === otp[activeInput]) {
|
|
12458
|
+
event.preventDefault();
|
|
12459
|
+
focusInput(activeInput + 1);
|
|
12460
|
+
} else if (event.code === 'Spacebar' || event.code === 'Space' || event.code === 'ArrowUp' || event.code === 'ArrowDown') {
|
|
12461
|
+
event.preventDefault();
|
|
12462
|
+
}
|
|
12463
|
+
};
|
|
12464
|
+
var focusInput = function focusInput(index) {
|
|
12465
|
+
var _a, _b;
|
|
12466
|
+
var activeInput = Math.max(Math.min(numInputs - 1, index), 0);
|
|
12467
|
+
if (inputRefs.current[activeInput]) {
|
|
12468
|
+
(_a = inputRefs.current[activeInput]) === null || _a === void 0 ? void 0 : _a.focus();
|
|
12469
|
+
(_b = inputRefs.current[activeInput]) === null || _b === void 0 ? void 0 : _b.select();
|
|
12470
|
+
setActiveInput(activeInput);
|
|
12471
|
+
}
|
|
12472
|
+
};
|
|
12473
|
+
var changeCodeAtFocus = function changeCodeAtFocus(value) {
|
|
12474
|
+
var otp = getOTPValue();
|
|
12475
|
+
otp[activeInput] = value[0];
|
|
12476
|
+
handleOTPChange(otp);
|
|
12477
|
+
};
|
|
12478
|
+
var handleOTPChange = function handleOTPChange(otp) {
|
|
12479
|
+
var otpValue = otp.join('');
|
|
12480
|
+
onChange(otpValue);
|
|
12481
|
+
};
|
|
12482
|
+
var handlePaste = function handlePaste(event) {
|
|
12483
|
+
var _a;
|
|
12484
|
+
event.preventDefault();
|
|
12485
|
+
var otp = getOTPValue();
|
|
12486
|
+
var nextActiveInput = activeInput;
|
|
12487
|
+
// Get pastedData in an array of max size (num of inputs - current position)
|
|
12488
|
+
var pastedData = event.clipboardData.getData('text/plain').slice(0, numInputs - activeInput).split('');
|
|
12489
|
+
// Prevent pasting if the clipboard data contains non-numeric values for number inputs
|
|
12490
|
+
if (isInputNum && pastedData.some(function (value) {
|
|
12491
|
+
return isNaN(Number(value));
|
|
12492
|
+
})) {
|
|
12493
|
+
return;
|
|
12494
|
+
}
|
|
12495
|
+
// Paste data from focused input onwards
|
|
12496
|
+
for (var pos = 0; pos < numInputs; ++pos) {
|
|
12497
|
+
if (pos >= activeInput && pastedData.length > 0) {
|
|
12498
|
+
otp[pos] = (_a = pastedData.shift()) !== null && _a !== void 0 ? _a : '';
|
|
12499
|
+
nextActiveInput++;
|
|
12500
|
+
}
|
|
12501
|
+
}
|
|
12502
|
+
focusInput(nextActiveInput);
|
|
12503
|
+
handleOTPChange(otp);
|
|
12504
|
+
};
|
|
12505
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
12506
|
+
style: Object.assign({
|
|
12507
|
+
display: 'flex',
|
|
12508
|
+
alignItems: 'center'
|
|
12509
|
+
}, isStyleObject(containerStyle) && containerStyle),
|
|
12510
|
+
className: typeof containerStyle === 'string' ? containerStyle : undefined,
|
|
12511
|
+
onPaste: onPaste
|
|
12512
|
+
}, Array.from({
|
|
12513
|
+
length: numInputs
|
|
12514
|
+
}, function (_, index) {
|
|
12515
|
+
return index;
|
|
12516
|
+
}).map(function (index) {
|
|
12517
|
+
var _a, _b, _c;
|
|
12518
|
+
return /*#__PURE__*/React.createElement(React.Fragment, {
|
|
12519
|
+
key: index
|
|
12520
|
+
}, renderInput({
|
|
12521
|
+
value: (_a = getOTPValue()[index]) !== null && _a !== void 0 ? _a : '',
|
|
12522
|
+
placeholder: (_c = (_b = getPlaceholderValue()) === null || _b === void 0 ? void 0 : _b[index]) !== null && _c !== void 0 ? _c : undefined,
|
|
12523
|
+
ref: function ref(element) {
|
|
12524
|
+
return inputRefs.current[index] = element;
|
|
12525
|
+
},
|
|
12526
|
+
onChange: handleChange,
|
|
12527
|
+
onFocus: function onFocus(event) {
|
|
12528
|
+
return handleFocus(event)(index);
|
|
12529
|
+
},
|
|
12530
|
+
onBlur: handleBlur,
|
|
12531
|
+
onKeyDown: handleKeyDown,
|
|
12532
|
+
onPaste: handlePaste,
|
|
12533
|
+
autoComplete: 'off',
|
|
12534
|
+
'aria-label': "Please enter OTP character ".concat(index + 1),
|
|
12535
|
+
style: Object.assign(!skipDefaultStyles ? {
|
|
12536
|
+
width: '1em',
|
|
12537
|
+
textAlign: 'center'
|
|
12538
|
+
} : {}, isStyleObject(inputStyle) ? inputStyle : {}),
|
|
12539
|
+
className: typeof inputStyle === 'string' ? inputStyle : undefined,
|
|
12540
|
+
type: inputType,
|
|
12541
|
+
inputMode: isInputNum ? 'numeric' : 'text',
|
|
12542
|
+
onInput: handleInputChange
|
|
12543
|
+
}, index), index < numInputs - 1 && (typeof renderSeparator === 'function' ? renderSeparator(index) : renderSeparator));
|
|
12544
|
+
}));
|
|
12545
|
+
};
|
|
12546
|
+
|
|
12547
|
+
var getInputAriaLabel = function getInputAriaLabel(index, inputCount, ariaLabel, label) {
|
|
12548
|
+
var baseLabel = ariaLabel || label || 'One-time password digit';
|
|
12549
|
+
return "".concat(baseLabel, " ").concat(index + 1, " of ").concat(inputCount);
|
|
12550
|
+
};
|
|
12551
|
+
var OtpInput = function OtpInput(_ref) {
|
|
12552
|
+
var ariaDescribedBy = _ref['aria-describedby'],
|
|
12553
|
+
ariaLabel = _ref['aria-label'],
|
|
12554
|
+
_ref$autoComplete = _ref.autoComplete,
|
|
12555
|
+
autoComplete = _ref$autoComplete === void 0 ? 'one-time-code' : _ref$autoComplete,
|
|
12556
|
+
className = _ref.className,
|
|
12557
|
+
disabled = _ref.disabled,
|
|
12558
|
+
error = _ref.error,
|
|
12559
|
+
focus = _ref.focus,
|
|
12560
|
+
id = _ref.id,
|
|
12561
|
+
inputClassName = _ref.inputClassName,
|
|
12562
|
+
_ref$inputType = _ref.inputType,
|
|
12563
|
+
inputType = _ref$inputType === void 0 ? 'tel' : _ref$inputType,
|
|
12564
|
+
label = _ref.label,
|
|
12565
|
+
name = _ref.name,
|
|
12566
|
+
_ref$numInputs = _ref.numInputs,
|
|
12567
|
+
numInputs = _ref$numInputs === void 0 ? 4 : _ref$numInputs,
|
|
12568
|
+
onChange = _ref.onChange,
|
|
12569
|
+
onPaste = _ref.onPaste,
|
|
12570
|
+
placeholder = _ref.placeholder,
|
|
12571
|
+
renderSeparator = _ref.renderSeparator,
|
|
12572
|
+
required = _ref.required,
|
|
12573
|
+
shouldAutoFocus = _ref.shouldAutoFocus,
|
|
12574
|
+
_ref$value = _ref.value,
|
|
12575
|
+
value = _ref$value === void 0 ? '' : _ref$value;
|
|
12576
|
+
return /*#__PURE__*/React.createElement(OTPInput, {
|
|
12577
|
+
containerStyle: classNames('OtpInput', className),
|
|
12578
|
+
inputType: inputType,
|
|
12579
|
+
numInputs: numInputs,
|
|
12580
|
+
onChange: onChange,
|
|
12581
|
+
onPaste: onPaste,
|
|
12582
|
+
placeholder: placeholder,
|
|
12583
|
+
renderSeparator: renderSeparator,
|
|
12584
|
+
shouldAutoFocus: shouldAutoFocus,
|
|
12585
|
+
skipDefaultStyles: true,
|
|
12586
|
+
value: value,
|
|
12587
|
+
renderInput: function renderInput(inputProps, index) {
|
|
12588
|
+
return /*#__PURE__*/React.createElement("input", _extends$1({}, inputProps, {
|
|
12589
|
+
id: id ? "".concat(id, "-").concat(index + 1) : undefined,
|
|
12590
|
+
autoComplete: autoComplete,
|
|
12591
|
+
"aria-describedby": ariaDescribedBy,
|
|
12592
|
+
"aria-invalid": error ? true : undefined,
|
|
12593
|
+
"aria-label": getInputAriaLabel(index, numInputs, ariaLabel, label),
|
|
12594
|
+
className: classNames(inputProps.className, 'OtpInput__input', inputClassName, {
|
|
12595
|
+
'OtpInput__input--disabled': disabled,
|
|
12596
|
+
'OtpInput__input--error': error,
|
|
12597
|
+
'OtpInput__input--focus': focus
|
|
12598
|
+
}),
|
|
12599
|
+
disabled: disabled,
|
|
12600
|
+
name: name,
|
|
12601
|
+
required: required
|
|
12602
|
+
}));
|
|
12603
|
+
}
|
|
12604
|
+
});
|
|
12605
|
+
};
|
|
12606
|
+
OtpInput.displayName = 'OtpInput';
|
|
12607
|
+
|
|
12337
12608
|
var PasswordInput = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
12338
12609
|
var rest = _extends$1({}, (_objectDestructuringEmpty(_ref), _ref));
|
|
12339
12610
|
var _useState = React.useState(false),
|
|
@@ -12675,9 +12946,10 @@ var Tab = function Tab(_ref) {
|
|
|
12675
12946
|
var TabList = function TabList(_ref) {
|
|
12676
12947
|
var tabs = _ref.tabs,
|
|
12677
12948
|
onTabSelected = _ref.onTabSelected,
|
|
12678
|
-
activePanel = _ref.activePanel
|
|
12949
|
+
activePanel = _ref.activePanel,
|
|
12950
|
+
className = _ref.className;
|
|
12679
12951
|
return /*#__PURE__*/React.createElement("div", {
|
|
12680
|
-
className:
|
|
12952
|
+
className: classNames('TabList', className)
|
|
12681
12953
|
}, tabs.map(function (tab) {
|
|
12682
12954
|
return /*#__PURE__*/React.createElement(Tab, {
|
|
12683
12955
|
key: tab.name,
|
|
@@ -12709,13 +12981,14 @@ var TabPanels = function TabPanels(_ref) {
|
|
|
12709
12981
|
}));
|
|
12710
12982
|
};
|
|
12711
12983
|
|
|
12712
|
-
var _excluded$4 = ["tabs", "onTabClicked", "defaultActiveTab", "activeTab", "className"];
|
|
12984
|
+
var _excluded$4 = ["tabs", "onTabClicked", "defaultActiveTab", "activeTab", "className", "tabListClassName"];
|
|
12713
12985
|
var Tabs = function Tabs(_ref) {
|
|
12714
12986
|
var tabs = _ref.tabs,
|
|
12715
12987
|
onTabClicked = _ref.onTabClicked,
|
|
12716
12988
|
defaultActiveTab = _ref.defaultActiveTab,
|
|
12717
12989
|
activeTab = _ref.activeTab,
|
|
12718
12990
|
className = _ref.className,
|
|
12991
|
+
tabListClassName = _ref.tabListClassName,
|
|
12719
12992
|
rest = _objectWithoutProperties(_ref, _excluded$4);
|
|
12720
12993
|
var _useState = React.useState(activeTab || defaultActiveTab || tabs[0].name),
|
|
12721
12994
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -12733,7 +13006,8 @@ var Tabs = function Tabs(_ref) {
|
|
|
12733
13006
|
}, rest), /*#__PURE__*/React.createElement(TabList, {
|
|
12734
13007
|
tabs: tabs,
|
|
12735
13008
|
onTabSelected: handleTabClick,
|
|
12736
|
-
activePanel: activePanel
|
|
13009
|
+
activePanel: activePanel,
|
|
13010
|
+
className: tabListClassName
|
|
12737
13011
|
}), /*#__PURE__*/React.createElement(TabPanels, {
|
|
12738
13012
|
panels: tabs,
|
|
12739
13013
|
activePanel: activePanel
|
|
@@ -12884,6 +13158,7 @@ exports.Modal = Modal;
|
|
|
12884
13158
|
exports.ModalOverlay = ModalOverlay;
|
|
12885
13159
|
exports.MultiSelect = MultiSelect;
|
|
12886
13160
|
exports.NoLineDivider = NoLineDivider;
|
|
13161
|
+
exports.OtpInput = OtpInput;
|
|
12887
13162
|
exports.Oval = Oval;
|
|
12888
13163
|
exports.Overlay = Overlay;
|
|
12889
13164
|
exports.POPOVER_MOUSEOUT_DELAY_MS = POPOVER_MOUSEOUT_DELAY_MS;
|