@sheerid/jslib 1.126.0 → 1.128.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/es5/Tmetrix.bundle.js +5 -5
- package/es5/messages_ar.bundle.js +5 -5
- package/es5/messages_bg.bundle.js +5 -5
- package/es5/messages_cs.bundle.js +5 -5
- package/es5/messages_da.bundle.js +5 -5
- package/es5/messages_de.bundle.js +5 -5
- package/es5/messages_el.bundle.js +5 -5
- package/es5/messages_en-GB.bundle.js +5 -5
- package/es5/messages_es-ES.bundle.js +5 -5
- package/es5/messages_es.bundle.js +5 -5
- package/es5/messages_fi.bundle.js +5 -5
- package/es5/messages_fr-CA.bundle.js +5 -5
- package/es5/messages_fr.bundle.js +5 -5
- package/es5/messages_ga.bundle.js +5 -5
- package/es5/messages_hr.bundle.js +5 -5
- package/es5/messages_hu.bundle.js +5 -5
- package/es5/messages_id.bundle.js +5 -5
- package/es5/messages_it.bundle.js +5 -5
- package/es5/messages_iw.bundle.js +5 -5
- package/es5/messages_ja.bundle.js +5 -5
- package/es5/messages_ko.bundle.js +5 -5
- package/es5/messages_lo.bundle.js +5 -5
- package/es5/messages_lt.bundle.js +5 -5
- package/es5/messages_ms.bundle.js +5 -5
- package/es5/messages_nl.bundle.js +5 -5
- package/es5/messages_no.bundle.js +5 -5
- package/es5/messages_pl.bundle.js +5 -5
- package/es5/messages_pt-BR.bundle.js +5 -5
- package/es5/messages_pt.bundle.js +5 -5
- package/es5/messages_ru.bundle.js +5 -5
- package/es5/messages_sk.bundle.js +5 -5
- package/es5/messages_sl.bundle.js +5 -5
- package/es5/messages_sr.bundle.js +5 -5
- package/es5/messages_sv.bundle.js +5 -5
- package/es5/messages_th.bundle.js +5 -5
- package/es5/messages_tr.bundle.js +5 -5
- package/es5/messages_zh-HK.bundle.js +5 -5
- package/es5/messages_zh.bundle.js +5 -5
- package/es6/{ar-bab1b035.es.js → ar-2a0ea0a2.es.js} +3 -1
- package/es6/{cs-5719c099.es.js.map → ar-2a0ea0a2.es.js.map} +1 -1
- package/es6/{bg-e2e1c20e.es.js → bg-377290da.es.js} +3 -1
- package/es6/{ar-bab1b035.es.js.map → bg-377290da.es.js.map} +1 -1
- package/es6/{cs-5719c099.es.js → cs-3f62949a.es.js} +3 -1
- package/es6/{da-5c334bf6.es.js.map → cs-3f62949a.es.js.map} +1 -1
- package/es6/{da-5c334bf6.es.js → da-d179d5c7.es.js} +3 -1
- package/es6/{bg-e2e1c20e.es.js.map → da-d179d5c7.es.js.map} +1 -1
- package/es6/{de-99bcfcd6.es.js → de-e195240d.es.js} +3 -1
- package/es6/de-e195240d.es.js.map +1 -0
- package/es6/{el-50365c9c.es.js → el-a8c40916.es.js} +3 -1
- package/es6/el-a8c40916.es.js.map +1 -0
- package/es6/{en-GB-3190f9c5.es.js → en-GB-e6ff4f1e.es.js} +3 -1
- package/es6/{en-GB-3190f9c5.es.js.map → en-GB-e6ff4f1e.es.js.map} +1 -1
- package/es6/{es-f9815891.es.js → es-6087a4fc.es.js} +3 -1
- package/es6/es-6087a4fc.es.js.map +1 -0
- package/es6/{es-ES-8e81bf89.es.js → es-ES-44ea68e4.es.js} +3 -1
- package/es6/{es-ES-8e81bf89.es.js.map → es-ES-44ea68e4.es.js.map} +1 -1
- package/es6/{fi-f85170e8.es.js → fi-3464525e.es.js} +3 -1
- package/es6/fi-3464525e.es.js.map +1 -0
- package/es6/{fr-CA-7fb05572.es.js → fr-CA-f866402a.es.js} +3 -1
- package/es6/{fr-CA-7fb05572.es.js.map → fr-CA-f866402a.es.js.map} +1 -1
- package/es6/{fr-d75091bb.es.js → fr-f593680c.es.js} +3 -1
- package/es6/fr-f593680c.es.js.map +1 -0
- package/es6/{ga-1f24f896.es.js → ga-6f8cbfc2.es.js} +3 -1
- package/es6/ga-6f8cbfc2.es.js.map +1 -0
- package/es6/{hr-25a2d454.es.js → hr-626d1c31.es.js} +3 -1
- package/es6/hr-626d1c31.es.js.map +1 -0
- package/es6/{hu-dab0cd65.es.js → hu-4aa2549e.es.js} +3 -1
- package/es6/hu-4aa2549e.es.js.map +1 -0
- package/es6/{id-ca56da7f.es.js → id-2ba07070.es.js} +3 -1
- package/es6/id-2ba07070.es.js.map +1 -0
- package/es6/{it-67990c57.es.js → it-0e555eec.es.js} +3 -1
- package/es6/it-0e555eec.es.js.map +1 -0
- package/es6/{iw-f603181c.es.js → iw-91688793.es.js} +3 -1
- package/es6/iw-91688793.es.js.map +1 -0
- package/es6/{ja-c4079a32.es.js → ja-ebdbf86f.es.js} +28 -26
- package/es6/ja-ebdbf86f.es.js.map +1 -0
- package/es6/{ko-a298b847.es.js → ko-939af24c.es.js} +3 -1
- package/es6/ko-939af24c.es.js.map +1 -0
- package/es6/{lo-1d1b5d06.es.js → lo-08fdfe3a.es.js} +3 -1
- package/es6/lo-08fdfe3a.es.js.map +1 -0
- package/es6/{lt-4af7334d.es.js → lt-c4941c10.es.js} +3 -1
- package/es6/lt-c4941c10.es.js.map +1 -0
- package/es6/{ms-7084dd0e.es.js → ms-9441eded.es.js} +3 -1
- package/es6/ms-9441eded.es.js.map +1 -0
- package/es6/{nl-112d7daa.es.js → nl-89a503f5.es.js} +3 -1
- package/es6/nl-89a503f5.es.js.map +1 -0
- package/es6/{no-d9bbfe9b.es.js → no-fa64abdb.es.js} +3 -1
- package/es6/no-fa64abdb.es.js.map +1 -0
- package/es6/pl-b934b04b.es.js +974 -0
- package/es6/pl-b934b04b.es.js.map +1 -0
- package/es6/{pt-768cfc70.es.js → pt-5c797098.es.js} +3 -1
- package/es6/pt-5c797098.es.js.map +1 -0
- package/es6/{pt-BR-52f1e3dd.es.js → pt-BR-5222d627.es.js} +3 -1
- package/es6/{pt-BR-52f1e3dd.es.js.map → pt-BR-5222d627.es.js.map} +1 -1
- package/es6/{ru-dfbcc89f.es.js → ru-c9925608.es.js} +3 -1
- package/es6/ru-c9925608.es.js.map +1 -0
- package/es6/{sk-2d857318.es.js → sk-a264f056.es.js} +3 -1
- package/es6/sk-a264f056.es.js.map +1 -0
- package/es6/{sl-b242951a.es.js → sl-51754511.es.js} +3 -1
- package/es6/sl-51754511.es.js.map +1 -0
- package/es6/{sr-6c9eb7c9.es.js → sr-850a9b5e.es.js} +3 -1
- package/es6/sr-850a9b5e.es.js.map +1 -0
- package/es6/{sv-e7068235.es.js → sv-fedc1d6f.es.js} +3 -1
- package/es6/sv-fedc1d6f.es.js.map +1 -0
- package/es6/{th-c9e74f5c.es.js → th-4b9590bb.es.js} +3 -1
- package/es6/th-4b9590bb.es.js.map +1 -0
- package/es6/{tr-2bba52b9.es.js → tr-15c9df31.es.js} +3 -1
- package/es6/tr-15c9df31.es.js.map +1 -0
- package/es6/{zh-04e15385.es.js → zh-548784ee.es.js} +3 -1
- package/es6/zh-548784ee.es.js.map +1 -0
- package/es6/{zh-HK-42498244.es.js → zh-HK-9e038504.es.js} +3 -1
- package/es6/zh-HK-9e038504.es.js.map +1 -0
- package/localized-messages/ar.json +2 -0
- package/localized-messages/bg.json +2 -0
- package/localized-messages/cs.json +2 -0
- package/localized-messages/da.json +2 -0
- package/localized-messages/de.json +2 -0
- package/localized-messages/el.json +2 -0
- package/localized-messages/en-GB.json +2 -0
- package/localized-messages/en-US.json +2 -0
- package/localized-messages/es-ES.json +2 -0
- package/localized-messages/es.json +2 -0
- package/localized-messages/fi.json +2 -0
- package/localized-messages/fr-CA.json +2 -0
- package/localized-messages/fr.json +2 -0
- package/localized-messages/ga.json +2 -0
- package/localized-messages/hr.json +2 -0
- package/localized-messages/hu.json +2 -0
- package/localized-messages/id.json +2 -0
- package/localized-messages/it.json +2 -0
- package/localized-messages/iw.json +2 -0
- package/localized-messages/ja.json +27 -25
- package/localized-messages/ko.json +2 -0
- package/localized-messages/lo.json +2 -0
- package/localized-messages/lt.json +2 -0
- package/localized-messages/ms.json +2 -0
- package/localized-messages/nl.json +2 -0
- package/localized-messages/no.json +2 -0
- package/localized-messages/pl.json +810 -808
- package/localized-messages/pt-BR.json +2 -0
- package/localized-messages/pt.json +2 -0
- package/localized-messages/ru.json +2 -0
- package/localized-messages/sk.json +2 -0
- package/localized-messages/sl.json +2 -0
- package/localized-messages/sr.json +2 -0
- package/localized-messages/sv.json +2 -0
- package/localized-messages/th.json +2 -0
- package/localized-messages/tr.json +2 -0
- package/localized-messages/zh-HK.json +2 -0
- package/localized-messages/zh.json +2 -0
- package/manifest.json +48 -48
- package/package.json +3 -3
- package/sheerid-requestOrg.css +5 -5
- package/sheerid-requestOrg.css.map +1 -1
- package/sheerid-requestOrg.js +14 -21
- package/sheerid-requestOrg.js.map +1 -1
- package/sheerid-utils.js +8 -15
- package/sheerid-utils.js.map +1 -1
- package/sheerid.css +5 -5
- package/sheerid.css.map +1 -1
- package/sheerid.js +17 -24
- package/sheerid.js.map +1 -1
- package/sheerides6.js +1521 -1450
- package/sheerides6.js.map +1 -1
- package/src/components/FormInputs/InputSelect/InputSelectButton/InputSelectButtonComponent.d.ts +1 -1
- package/src/components/FormInputs/InputSelect/InputSelectList/InputSelectListComponent.d.ts +3 -1
- package/src/lib/types/runtimeTypes.d.ts +4 -2
- package/src/lib/types/types.d.ts +5 -2
- package/src/serverMocks/mocks.d.ts +1 -0
- package/types-reference.zip +0 -0
- package/es6/de-99bcfcd6.es.js.map +0 -1
- package/es6/el-50365c9c.es.js.map +0 -1
- package/es6/es-f9815891.es.js.map +0 -1
- package/es6/fi-f85170e8.es.js.map +0 -1
- package/es6/fr-d75091bb.es.js.map +0 -1
- package/es6/ga-1f24f896.es.js.map +0 -1
- package/es6/hr-25a2d454.es.js.map +0 -1
- package/es6/hu-dab0cd65.es.js.map +0 -1
- package/es6/id-ca56da7f.es.js.map +0 -1
- package/es6/it-67990c57.es.js.map +0 -1
- package/es6/iw-f603181c.es.js.map +0 -1
- package/es6/ja-c4079a32.es.js.map +0 -1
- package/es6/ko-a298b847.es.js.map +0 -1
- package/es6/lo-1d1b5d06.es.js.map +0 -1
- package/es6/lt-4af7334d.es.js.map +0 -1
- package/es6/ms-7084dd0e.es.js.map +0 -1
- package/es6/nl-112d7daa.es.js.map +0 -1
- package/es6/no-d9bbfe9b.es.js.map +0 -1
- package/es6/pl-80661fea.es.js +0 -972
- package/es6/pl-80661fea.es.js.map +0 -1
- package/es6/pt-768cfc70.es.js.map +0 -1
- package/es6/ru-dfbcc89f.es.js.map +0 -1
- package/es6/sk-2d857318.es.js.map +0 -1
- package/es6/sl-b242951a.es.js.map +0 -1
- package/es6/sr-6c9eb7c9.es.js.map +0 -1
- package/es6/sv-e7068235.es.js.map +0 -1
- package/es6/th-c9e74f5c.es.js.map +0 -1
- package/es6/tr-2bba52b9.es.js.map +0 -1
- package/es6/zh-04e15385.es.js.map +0 -1
- package/es6/zh-HK-42498244.es.js.map +0 -1
package/sheerides6.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useRef,
|
|
1
|
+
import React, { useRef, useEffect, useCallback, useMemo, Component, cloneElement, useLayoutEffect, useReducer, PureComponent, Children, useState, forwardRef, useImperativeHandle, Fragment as Fragment$4, Suspense as Suspense$4 } from 'react';
|
|
2
2
|
import { FormattedHTMLMessage, injectIntl, IntlProvider } from 'react-intl';
|
|
3
3
|
import 'react-intl/locale-data/en.js';
|
|
4
4
|
import ReactDOMServer from 'react-dom/server';
|
|
@@ -525,6 +525,7 @@ var VerificationStepsEnum;
|
|
|
525
525
|
VerificationStepsEnum["cancelEmailLoop"] = "cancelEmailLoop";
|
|
526
526
|
VerificationStepsEnum["consolation"] = "consolation";
|
|
527
527
|
VerificationStepsEnum["override"] = "override";
|
|
528
|
+
VerificationStepsEnum["cancelDocUpload"] = "cancelDocUpload";
|
|
528
529
|
})(VerificationStepsEnum || (VerificationStepsEnum = {}));
|
|
529
530
|
const VerificationSteps = Object.values(VerificationStepsEnum); // For runtime checks
|
|
530
531
|
// This depends on all collect steps starting with the string 'collect' if that
|
|
@@ -600,6 +601,7 @@ var SubSegmentEnum;
|
|
|
600
601
|
SubSegmentEnum["SNAP_BENEFITS"] = "snapBenefits";
|
|
601
602
|
SubSegmentEnum["OTHER_GOVERNMENT_ASSISTANCE"] = "otherGovernmentAssistance";
|
|
602
603
|
SubSegmentEnum["CHILD_CARE_WORKER"] = "childCareWorker";
|
|
604
|
+
SubSegmentEnum["LIBRARIAN"] = "librarian";
|
|
603
605
|
})(SubSegmentEnum || (SubSegmentEnum = {}));
|
|
604
606
|
Object.values(SubSegmentEnum); // For runtime checks
|
|
605
607
|
var MilitaryStatusDefaultMessagesEnum;
|
|
@@ -1720,44 +1722,44 @@ function arrayUnique(array) {
|
|
|
1720
1722
|
return array.sort().filter((item, pos, ary) => !pos || item !== ary[pos - 1]);
|
|
1721
1723
|
}
|
|
1722
1724
|
|
|
1723
|
-
/*!
|
|
1724
|
-
* Determine if an object is a Buffer
|
|
1725
|
-
*
|
|
1726
|
-
* @author Feross Aboukhadijeh <https://feross.org>
|
|
1727
|
-
* @license MIT
|
|
1728
|
-
*/
|
|
1729
|
-
|
|
1730
|
-
var isBuffer = function isBuffer (obj) {
|
|
1731
|
-
return obj != null && obj.constructor != null &&
|
|
1732
|
-
typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
|
|
1733
|
-
};
|
|
1734
|
-
|
|
1735
1725
|
var flat = flatten$1;
|
|
1736
1726
|
flatten$1.flatten = flatten$1;
|
|
1737
1727
|
flatten$1.unflatten = unflatten;
|
|
1738
1728
|
|
|
1729
|
+
function isBuffer (obj) {
|
|
1730
|
+
return obj &&
|
|
1731
|
+
obj.constructor &&
|
|
1732
|
+
(typeof obj.constructor.isBuffer === 'function') &&
|
|
1733
|
+
obj.constructor.isBuffer(obj)
|
|
1734
|
+
}
|
|
1735
|
+
|
|
1736
|
+
function keyIdentity (key) {
|
|
1737
|
+
return key
|
|
1738
|
+
}
|
|
1739
|
+
|
|
1739
1740
|
function flatten$1 (target, opts) {
|
|
1740
1741
|
opts = opts || {};
|
|
1741
1742
|
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1743
|
+
const delimiter = opts.delimiter || '.';
|
|
1744
|
+
const maxDepth = opts.maxDepth;
|
|
1745
|
+
const transformKey = opts.transformKey || keyIdentity;
|
|
1746
|
+
const output = {};
|
|
1745
1747
|
|
|
1746
1748
|
function step (object, prev, currentDepth) {
|
|
1747
1749
|
currentDepth = currentDepth || 1;
|
|
1748
1750
|
Object.keys(object).forEach(function (key) {
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1751
|
+
const value = object[key];
|
|
1752
|
+
const isarray = opts.safe && Array.isArray(value);
|
|
1753
|
+
const type = Object.prototype.toString.call(value);
|
|
1754
|
+
const isbuffer = isBuffer(value);
|
|
1755
|
+
const isobject = (
|
|
1754
1756
|
type === '[object Object]' ||
|
|
1755
1757
|
type === '[object Array]'
|
|
1756
1758
|
);
|
|
1757
1759
|
|
|
1758
|
-
|
|
1759
|
-
? prev + delimiter + key
|
|
1760
|
-
: key;
|
|
1760
|
+
const newKey = prev
|
|
1761
|
+
? prev + delimiter + transformKey(key)
|
|
1762
|
+
: transformKey(key);
|
|
1761
1763
|
|
|
1762
1764
|
if (!isarray && !isbuffer && isobject && Object.keys(value).length &&
|
|
1763
1765
|
(!opts.maxDepth || currentDepth < maxDepth)) {
|
|
@@ -1776,11 +1778,12 @@ function flatten$1 (target, opts) {
|
|
|
1776
1778
|
function unflatten (target, opts) {
|
|
1777
1779
|
opts = opts || {};
|
|
1778
1780
|
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1781
|
+
const delimiter = opts.delimiter || '.';
|
|
1782
|
+
const overwrite = opts.overwrite || false;
|
|
1783
|
+
const transformKey = opts.transformKey || keyIdentity;
|
|
1784
|
+
const result = {};
|
|
1782
1785
|
|
|
1783
|
-
|
|
1786
|
+
const isbuffer = isBuffer(target);
|
|
1784
1787
|
if (isbuffer || Object.prototype.toString.call(target) !== '[object Object]') {
|
|
1785
1788
|
return target
|
|
1786
1789
|
}
|
|
@@ -1788,7 +1791,7 @@ function unflatten (target, opts) {
|
|
|
1788
1791
|
// safely ensure that the key is
|
|
1789
1792
|
// an integer.
|
|
1790
1793
|
function getkey (key) {
|
|
1791
|
-
|
|
1794
|
+
const parsedKey = Number(key);
|
|
1792
1795
|
|
|
1793
1796
|
return (
|
|
1794
1797
|
isNaN(parsedKey) ||
|
|
@@ -1798,22 +1801,56 @@ function unflatten (target, opts) {
|
|
|
1798
1801
|
: parsedKey
|
|
1799
1802
|
}
|
|
1800
1803
|
|
|
1801
|
-
|
|
1802
|
-
return
|
|
1803
|
-
|
|
1804
|
+
function addKeys (keyPrefix, recipient, target) {
|
|
1805
|
+
return Object.keys(target).reduce(function (result, key) {
|
|
1806
|
+
result[keyPrefix + delimiter + key] = target[key];
|
|
1804
1807
|
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1808
|
+
return result
|
|
1809
|
+
}, recipient)
|
|
1810
|
+
}
|
|
1811
|
+
|
|
1812
|
+
function isEmpty (val) {
|
|
1813
|
+
const type = Object.prototype.toString.call(val);
|
|
1814
|
+
const isArray = type === '[object Array]';
|
|
1815
|
+
const isObject = type === '[object Object]';
|
|
1816
|
+
|
|
1817
|
+
if (!val) {
|
|
1818
|
+
return true
|
|
1819
|
+
} else if (isArray) {
|
|
1820
|
+
return !val.length
|
|
1821
|
+
} else if (isObject) {
|
|
1822
|
+
return !Object.keys(val).length
|
|
1823
|
+
}
|
|
1824
|
+
}
|
|
1825
|
+
|
|
1826
|
+
target = Object.keys(target).reduce(function (result, key) {
|
|
1827
|
+
const type = Object.prototype.toString.call(target[key]);
|
|
1828
|
+
const isObject = (type === '[object Object]' || type === '[object Array]');
|
|
1829
|
+
if (!isObject || isEmpty(target[key])) {
|
|
1830
|
+
result[key] = target[key];
|
|
1831
|
+
return result
|
|
1832
|
+
} else {
|
|
1833
|
+
return addKeys(
|
|
1834
|
+
key,
|
|
1835
|
+
result,
|
|
1836
|
+
flatten$1(target[key], opts)
|
|
1837
|
+
)
|
|
1838
|
+
}
|
|
1839
|
+
}, {});
|
|
1840
|
+
|
|
1841
|
+
Object.keys(target).forEach(function (key) {
|
|
1842
|
+
const split = key.split(delimiter).map(transformKey);
|
|
1843
|
+
let key1 = getkey(split.shift());
|
|
1844
|
+
let key2 = getkey(split[0]);
|
|
1845
|
+
let recipient = result;
|
|
1810
1846
|
|
|
1811
1847
|
while (key2 !== undefined) {
|
|
1812
1848
|
if (key1 === '__proto__') {
|
|
1813
1849
|
return
|
|
1814
1850
|
}
|
|
1815
|
-
|
|
1816
|
-
|
|
1851
|
+
|
|
1852
|
+
const type = Object.prototype.toString.call(recipient[key1]);
|
|
1853
|
+
const isobject = (
|
|
1817
1854
|
type === '[object Object]' ||
|
|
1818
1855
|
type === '[object Array]'
|
|
1819
1856
|
);
|
|
@@ -1854,6 +1891,7 @@ var enUSMessages = {
|
|
|
1854
1891
|
"defaultMessages.FIREFIGHTER": "Firefighter",
|
|
1855
1892
|
"defaultMessages.GOLD_STAR_FAMILY": "Gold Star Family",
|
|
1856
1893
|
"defaultMessages.HOME_BUYER": "Home Buyer",
|
|
1894
|
+
"defaultMessages.LIBRARIAN": "Librarian",
|
|
1857
1895
|
"defaultMessages.LICENSED_COSMETOLOGIST": "Licensed Cosmetologist",
|
|
1858
1896
|
"defaultMessages.LICENSED_REAL_ESTATE_AGENT": "Licensed Real Estate Agent",
|
|
1859
1897
|
"defaultMessages.MILITARY_FAMILY": "Military Family",
|
|
@@ -2424,6 +2462,7 @@ var enUSMessages = {
|
|
|
2424
2462
|
"defaultMessages.step.docUpload.addFile": "Add file",
|
|
2425
2463
|
"defaultMessages.step.docUpload.allowedDocuments": "Please only upload documents you are legally allowed to provide.",
|
|
2426
2464
|
"defaultMessages.step.docUpload.cancelButtonLabel": "Cancel",
|
|
2465
|
+
"defaultMessages.step.docUpload.cancelDocUploadLabel": "Click here if you are unable to verify with a document",
|
|
2427
2466
|
"defaultMessages.step.docUpload.fileInstructions": "Drag & drop your files here or <span class=\"sid-dropzone-wrap--link\">browse</span>",
|
|
2428
2467
|
"defaultMessages.step.docUpload.nameChanged": "If your name has changed since the document was issued, upload a 2nd document showing your official name change.",
|
|
2429
2468
|
"defaultMessages.step.docUpload.rejectedSubtitle": "We were unable to confirm your eligibility due to:",
|
|
@@ -2833,154 +2872,154 @@ const getMessagesModuleByLocale = async (locale) => {
|
|
|
2833
2872
|
switch (locale) {
|
|
2834
2873
|
case "ar":
|
|
2835
2874
|
localizedMessages = await import(
|
|
2836
|
-
/* webpackChunkName: "messages_ar" */ './es6/ar-
|
|
2875
|
+
/* webpackChunkName: "messages_ar" */ './es6/ar-2a0ea0a2.es.js').then((m) => m.default);
|
|
2837
2876
|
break;
|
|
2838
2877
|
case "bg":
|
|
2839
2878
|
localizedMessages = await import(
|
|
2840
|
-
/* webpackChunkName: "messages_bg" */ './es6/bg-
|
|
2879
|
+
/* webpackChunkName: "messages_bg" */ './es6/bg-377290da.es.js').then((m) => m.default);
|
|
2841
2880
|
break;
|
|
2842
2881
|
case "cs":
|
|
2843
2882
|
localizedMessages = await import(
|
|
2844
|
-
/* webpackChunkName: "messages_cs" */ './es6/cs-
|
|
2883
|
+
/* webpackChunkName: "messages_cs" */ './es6/cs-3f62949a.es.js').then((m) => m.default);
|
|
2845
2884
|
break;
|
|
2846
2885
|
case "da":
|
|
2847
2886
|
localizedMessages = await import(
|
|
2848
|
-
/* webpackChunkName: "messages_da" */ './es6/da-
|
|
2887
|
+
/* webpackChunkName: "messages_da" */ './es6/da-d179d5c7.es.js').then((m) => m.default);
|
|
2849
2888
|
break;
|
|
2850
2889
|
case "de":
|
|
2851
2890
|
localizedMessages = await import(
|
|
2852
|
-
/* webpackChunkName: "messages_de" */ './es6/de-
|
|
2891
|
+
/* webpackChunkName: "messages_de" */ './es6/de-e195240d.es.js').then((m) => m.default);
|
|
2853
2892
|
break;
|
|
2854
2893
|
case "el":
|
|
2855
2894
|
localizedMessages = await import(
|
|
2856
|
-
/* webpackChunkName: "messages_el" */ './es6/el-
|
|
2895
|
+
/* webpackChunkName: "messages_el" */ './es6/el-a8c40916.es.js').then((m) => m.default);
|
|
2857
2896
|
break;
|
|
2858
2897
|
case "en-GB":
|
|
2859
2898
|
localizedMessages = await import(
|
|
2860
|
-
/* webpackChunkName: "messages_en-GB" */ './es6/en-GB-
|
|
2899
|
+
/* webpackChunkName: "messages_en-GB" */ './es6/en-GB-e6ff4f1e.es.js').then((m) => m.default);
|
|
2861
2900
|
break;
|
|
2862
2901
|
case "en-US":
|
|
2863
2902
|
localizedMessages = enUSMessages;
|
|
2864
2903
|
break;
|
|
2865
2904
|
case "es-ES":
|
|
2866
2905
|
localizedMessages = await import(
|
|
2867
|
-
/* webpackChunkName: "messages_es-ES" */ './es6/es-ES-
|
|
2906
|
+
/* webpackChunkName: "messages_es-ES" */ './es6/es-ES-44ea68e4.es.js').then((m) => m.default);
|
|
2868
2907
|
break;
|
|
2869
2908
|
case "es":
|
|
2870
2909
|
localizedMessages = await import(
|
|
2871
|
-
/* webpackChunkName: "messages_es" */ './es6/es-
|
|
2910
|
+
/* webpackChunkName: "messages_es" */ './es6/es-6087a4fc.es.js').then((m) => m.default);
|
|
2872
2911
|
break;
|
|
2873
2912
|
case "fi":
|
|
2874
2913
|
localizedMessages = await import(
|
|
2875
|
-
/* webpackChunkName: "messages_fi" */ './es6/fi-
|
|
2914
|
+
/* webpackChunkName: "messages_fi" */ './es6/fi-3464525e.es.js').then((m) => m.default);
|
|
2876
2915
|
break;
|
|
2877
2916
|
case "fr-CA":
|
|
2878
2917
|
localizedMessages = await import(
|
|
2879
|
-
/* webpackChunkName: "messages_fr-CA" */ './es6/fr-CA-
|
|
2918
|
+
/* webpackChunkName: "messages_fr-CA" */ './es6/fr-CA-f866402a.es.js').then((m) => m.default);
|
|
2880
2919
|
break;
|
|
2881
2920
|
case "fr":
|
|
2882
2921
|
localizedMessages = await import(
|
|
2883
|
-
/* webpackChunkName: "messages_fr" */ './es6/fr-
|
|
2922
|
+
/* webpackChunkName: "messages_fr" */ './es6/fr-f593680c.es.js').then((m) => m.default);
|
|
2884
2923
|
break;
|
|
2885
2924
|
case "ga":
|
|
2886
2925
|
localizedMessages = await import(
|
|
2887
|
-
/* webpackChunkName: "messages_ga" */ './es6/ga-
|
|
2926
|
+
/* webpackChunkName: "messages_ga" */ './es6/ga-6f8cbfc2.es.js').then((m) => m.default);
|
|
2888
2927
|
break;
|
|
2889
2928
|
case "hr":
|
|
2890
2929
|
localizedMessages = await import(
|
|
2891
|
-
/* webpackChunkName: "messages_hr" */ './es6/hr-
|
|
2930
|
+
/* webpackChunkName: "messages_hr" */ './es6/hr-626d1c31.es.js').then((m) => m.default);
|
|
2892
2931
|
break;
|
|
2893
2932
|
case "hu":
|
|
2894
2933
|
localizedMessages = await import(
|
|
2895
|
-
/* webpackChunkName: "messages_hu" */ './es6/hu-
|
|
2934
|
+
/* webpackChunkName: "messages_hu" */ './es6/hu-4aa2549e.es.js').then((m) => m.default);
|
|
2896
2935
|
break;
|
|
2897
2936
|
case "id":
|
|
2898
2937
|
localizedMessages = await import(
|
|
2899
|
-
/* webpackChunkName: "messages_id" */ './es6/id-
|
|
2938
|
+
/* webpackChunkName: "messages_id" */ './es6/id-2ba07070.es.js').then((m) => m.default);
|
|
2900
2939
|
break;
|
|
2901
2940
|
case "it":
|
|
2902
2941
|
localizedMessages = await import(
|
|
2903
|
-
/* webpackChunkName: "messages_it" */ './es6/it-
|
|
2942
|
+
/* webpackChunkName: "messages_it" */ './es6/it-0e555eec.es.js').then((m) => m.default);
|
|
2904
2943
|
break;
|
|
2905
2944
|
case "iw":
|
|
2906
2945
|
localizedMessages = await import(
|
|
2907
|
-
/* webpackChunkName: "messages_iw" */ './es6/iw-
|
|
2946
|
+
/* webpackChunkName: "messages_iw" */ './es6/iw-91688793.es.js').then((m) => m.default);
|
|
2908
2947
|
break;
|
|
2909
2948
|
case "ja":
|
|
2910
2949
|
localizedMessages = await import(
|
|
2911
|
-
/* webpackChunkName: "messages_ja" */ './es6/ja-
|
|
2950
|
+
/* webpackChunkName: "messages_ja" */ './es6/ja-ebdbf86f.es.js').then((m) => m.default);
|
|
2912
2951
|
break;
|
|
2913
2952
|
case "ko":
|
|
2914
2953
|
localizedMessages = await import(
|
|
2915
|
-
/* webpackChunkName: "messages_ko" */ './es6/ko-
|
|
2954
|
+
/* webpackChunkName: "messages_ko" */ './es6/ko-939af24c.es.js').then((m) => m.default);
|
|
2916
2955
|
break;
|
|
2917
2956
|
case "lo":
|
|
2918
2957
|
localizedMessages = await import(
|
|
2919
|
-
/* webpackChunkName: "messages_lo" */ './es6/lo-
|
|
2958
|
+
/* webpackChunkName: "messages_lo" */ './es6/lo-08fdfe3a.es.js').then((m) => m.default);
|
|
2920
2959
|
break;
|
|
2921
2960
|
case "lt":
|
|
2922
2961
|
localizedMessages = await import(
|
|
2923
|
-
/* webpackChunkName: "messages_lt" */ './es6/lt-
|
|
2962
|
+
/* webpackChunkName: "messages_lt" */ './es6/lt-c4941c10.es.js').then((m) => m.default);
|
|
2924
2963
|
break;
|
|
2925
2964
|
case "ms":
|
|
2926
2965
|
localizedMessages = await import(
|
|
2927
|
-
/* webpackChunkName: "messages_ms" */ './es6/ms-
|
|
2966
|
+
/* webpackChunkName: "messages_ms" */ './es6/ms-9441eded.es.js').then((m) => m.default);
|
|
2928
2967
|
break;
|
|
2929
2968
|
case "nl":
|
|
2930
2969
|
localizedMessages = await import(
|
|
2931
|
-
/* webpackChunkName: "messages_nl" */ './es6/nl-
|
|
2970
|
+
/* webpackChunkName: "messages_nl" */ './es6/nl-89a503f5.es.js').then((m) => m.default);
|
|
2932
2971
|
break;
|
|
2933
2972
|
case "no":
|
|
2934
2973
|
localizedMessages = await import(
|
|
2935
|
-
/* webpackChunkName: "messages_no" */ './es6/no-
|
|
2974
|
+
/* webpackChunkName: "messages_no" */ './es6/no-fa64abdb.es.js').then((m) => m.default);
|
|
2936
2975
|
break;
|
|
2937
2976
|
case "pl":
|
|
2938
2977
|
localizedMessages = await import(
|
|
2939
|
-
/* webpackChunkName: "messages_pl" */ './es6/pl-
|
|
2978
|
+
/* webpackChunkName: "messages_pl" */ './es6/pl-b934b04b.es.js').then((m) => m.default);
|
|
2940
2979
|
break;
|
|
2941
2980
|
case "pt-BR":
|
|
2942
2981
|
localizedMessages = await import(
|
|
2943
|
-
/* webpackChunkName: "messages_pt-BR" */ './es6/pt-BR-
|
|
2982
|
+
/* webpackChunkName: "messages_pt-BR" */ './es6/pt-BR-5222d627.es.js').then((m) => m.default);
|
|
2944
2983
|
break;
|
|
2945
2984
|
case "pt":
|
|
2946
2985
|
localizedMessages = await import(
|
|
2947
|
-
/* webpackChunkName: "messages_pt" */ './es6/pt-
|
|
2986
|
+
/* webpackChunkName: "messages_pt" */ './es6/pt-5c797098.es.js').then((m) => m.default);
|
|
2948
2987
|
break;
|
|
2949
2988
|
case "ru":
|
|
2950
2989
|
localizedMessages = await import(
|
|
2951
|
-
/* webpackChunkName: "messages_ru" */ './es6/ru-
|
|
2990
|
+
/* webpackChunkName: "messages_ru" */ './es6/ru-c9925608.es.js').then((m) => m.default);
|
|
2952
2991
|
break;
|
|
2953
2992
|
case "sk":
|
|
2954
2993
|
localizedMessages = await import(
|
|
2955
|
-
/* webpackChunkName: "messages_sk" */ './es6/sk-
|
|
2994
|
+
/* webpackChunkName: "messages_sk" */ './es6/sk-a264f056.es.js').then((m) => m.default);
|
|
2956
2995
|
break;
|
|
2957
2996
|
case "sl":
|
|
2958
2997
|
localizedMessages = await import(
|
|
2959
|
-
/* webpackChunkName: "messages_sl" */ './es6/sl-
|
|
2998
|
+
/* webpackChunkName: "messages_sl" */ './es6/sl-51754511.es.js').then((m) => m.default);
|
|
2960
2999
|
break;
|
|
2961
3000
|
case "sr":
|
|
2962
3001
|
localizedMessages = await import(
|
|
2963
|
-
/* webpackChunkName: "messages_sr" */ './es6/sr-
|
|
3002
|
+
/* webpackChunkName: "messages_sr" */ './es6/sr-850a9b5e.es.js').then((m) => m.default);
|
|
2964
3003
|
break;
|
|
2965
3004
|
case "sv":
|
|
2966
3005
|
localizedMessages = await import(
|
|
2967
|
-
/* webpackChunkName: "messages_sv" */ './es6/sv-
|
|
3006
|
+
/* webpackChunkName: "messages_sv" */ './es6/sv-fedc1d6f.es.js').then((m) => m.default);
|
|
2968
3007
|
break;
|
|
2969
3008
|
case "th":
|
|
2970
3009
|
localizedMessages = await import(
|
|
2971
|
-
/* webpackChunkName: "messages_th" */ './es6/th-
|
|
3010
|
+
/* webpackChunkName: "messages_th" */ './es6/th-4b9590bb.es.js').then((m) => m.default);
|
|
2972
3011
|
break;
|
|
2973
3012
|
case "tr":
|
|
2974
3013
|
localizedMessages = await import(
|
|
2975
|
-
/* webpackChunkName: "messages_tr" */ './es6/tr-
|
|
3014
|
+
/* webpackChunkName: "messages_tr" */ './es6/tr-15c9df31.es.js').then((m) => m.default);
|
|
2976
3015
|
break;
|
|
2977
3016
|
case "zh-HK":
|
|
2978
3017
|
localizedMessages = await import(
|
|
2979
|
-
/* webpackChunkName: "messages_zh-HK" */ './es6/zh-HK-
|
|
3018
|
+
/* webpackChunkName: "messages_zh-HK" */ './es6/zh-HK-9e038504.es.js').then((m) => m.default);
|
|
2980
3019
|
break;
|
|
2981
3020
|
case "zh":
|
|
2982
3021
|
localizedMessages = await import(
|
|
2983
|
-
/* webpackChunkName: "messages_zh" */ './es6/zh-
|
|
3022
|
+
/* webpackChunkName: "messages_zh" */ './es6/zh-548784ee.es.js').then((m) => m.default);
|
|
2984
3023
|
break;
|
|
2985
3024
|
default:
|
|
2986
3025
|
logger.warn(`getMessagesModuleByLocale: Unable to load messages for ${locale}, falling back to en-US`);
|
|
@@ -3718,6 +3757,7 @@ const getAllEmptyViewModels = () => ({
|
|
|
3718
3757
|
error: deepClone(emptyViewModel),
|
|
3719
3758
|
cancelSocialSecurityNumber: deepClone(emptyViewModel),
|
|
3720
3759
|
docReviewLimitExceeded: deepClone(emptyViewModel),
|
|
3760
|
+
cancelDocUpload: deepClone(emptyViewModel),
|
|
3721
3761
|
});
|
|
3722
3762
|
const getFieldValidationErrorsEmpty = () => deepClone(initialErrorStructure);
|
|
3723
3763
|
const getExtendedFieldValidationErrorsEmpty = () => {
|
|
@@ -5081,7 +5121,14 @@ const InputText = ({ id, isErrored, className = undefined, hidePlaceholder = tru
|
|
|
5081
5121
|
if (isErrored)
|
|
5082
5122
|
internalClassName += " sid-text-input--error";
|
|
5083
5123
|
const finalRefId = refId || id;
|
|
5084
|
-
|
|
5124
|
+
const inputRef = useRef(null);
|
|
5125
|
+
// NOTE: Dependency array omitted to account for use of resetRef(), as useEffect with dep arr
|
|
5126
|
+
// will only trigger on initial render leaving the refs empty, this replicates prior version
|
|
5127
|
+
// where ref callback would trigger with each re-render
|
|
5128
|
+
useEffect(() => {
|
|
5129
|
+
setRef(finalRefId, inputRef.current);
|
|
5130
|
+
});
|
|
5131
|
+
return (React.createElement("input", Object.assign({ className: internalClassName, id: `sid-${id}`, name: `sid-${id}`, type: type, "aria-describedby": ariaDescribedBy, "aria-label": ariaLabel, "aria-required": required, "aria-invalid": isErrored, ref: inputRef }, props)));
|
|
5085
5132
|
};
|
|
5086
5133
|
// DO NOT INJECT INTL. Localize your strings pass them down as props
|
|
5087
5134
|
const InputTextComponent = InputText;
|
|
@@ -5223,62 +5270,6 @@ const SearchFieldComponent = ({ name, label, value, placeholder, isErrored, onCh
|
|
|
5223
5270
|
React.createElement(FormattedHTMLMessage, { id: `errorId.${isErrored}`, defaultMessage: "An unexpected error occurred" })))) : null));
|
|
5224
5271
|
};
|
|
5225
5272
|
|
|
5226
|
-
function _objectWithoutPropertiesLoose$1(source, excluded) {
|
|
5227
|
-
if (source == null) return {};
|
|
5228
|
-
var target = {};
|
|
5229
|
-
var sourceKeys = Object.keys(source);
|
|
5230
|
-
var key, i;
|
|
5231
|
-
|
|
5232
|
-
for (i = 0; i < sourceKeys.length; i++) {
|
|
5233
|
-
key = sourceKeys[i];
|
|
5234
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
5235
|
-
target[key] = source[key];
|
|
5236
|
-
}
|
|
5237
|
-
|
|
5238
|
-
return target;
|
|
5239
|
-
}
|
|
5240
|
-
|
|
5241
|
-
function _extends() {
|
|
5242
|
-
_extends = Object.assign || function (target) {
|
|
5243
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
5244
|
-
var source = arguments[i];
|
|
5245
|
-
|
|
5246
|
-
for (var key in source) {
|
|
5247
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
5248
|
-
target[key] = source[key];
|
|
5249
|
-
}
|
|
5250
|
-
}
|
|
5251
|
-
}
|
|
5252
|
-
|
|
5253
|
-
return target;
|
|
5254
|
-
};
|
|
5255
|
-
|
|
5256
|
-
return _extends.apply(this, arguments);
|
|
5257
|
-
}
|
|
5258
|
-
|
|
5259
|
-
function _assertThisInitialized(self) {
|
|
5260
|
-
if (self === void 0) {
|
|
5261
|
-
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
5262
|
-
}
|
|
5263
|
-
|
|
5264
|
-
return self;
|
|
5265
|
-
}
|
|
5266
|
-
|
|
5267
|
-
function _setPrototypeOf(o, p) {
|
|
5268
|
-
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
5269
|
-
o.__proto__ = p;
|
|
5270
|
-
return o;
|
|
5271
|
-
};
|
|
5272
|
-
|
|
5273
|
-
return _setPrototypeOf(o, p);
|
|
5274
|
-
}
|
|
5275
|
-
|
|
5276
|
-
function _inheritsLoose(subClass, superClass) {
|
|
5277
|
-
subClass.prototype = Object.create(superClass.prototype);
|
|
5278
|
-
subClass.prototype.constructor = subClass;
|
|
5279
|
-
_setPrototypeOf(subClass, superClass);
|
|
5280
|
-
}
|
|
5281
|
-
|
|
5282
5273
|
/** @license React v16.13.1
|
|
5283
5274
|
* react-is.production.min.js
|
|
5284
5275
|
*
|
|
@@ -6690,7 +6681,95 @@ var reactIs_3 = reactIs$2.isForwardRef;
|
|
|
6690
6681
|
|
|
6691
6682
|
function t$2(t){return "object"==typeof t&&null!=t&&1===t.nodeType}function e$2(t,e){return (!e||"hidden"!==t)&&"visible"!==t&&"clip"!==t}function n$2(t,n){if(t.clientHeight<t.scrollHeight||t.clientWidth<t.scrollWidth){var r=getComputedStyle(t,null);return e$2(r.overflowY,n)||e$2(r.overflowX,n)||function(t){var e=function(t){if(!t.ownerDocument||!t.ownerDocument.defaultView)return null;try{return t.ownerDocument.defaultView.frameElement}catch(t){return null}}(t);return !!e&&(e.clientHeight<t.scrollHeight||e.clientWidth<t.scrollWidth)}(t)}return !1}function r$2(t,e,n,r,i,o,l,d){return o<t&&l>e||o>t&&l<e?0:o<=t&&d<=n||l>=e&&d>=n?o-t-r:l>e&&d<n||o<t&&d>n?l-e+i:0}function computeScrollIntoView(e,i){var o=window,l=i.scrollMode,d=i.block,u=i.inline,h=i.boundary,a=i.skipOverflowHiddenElements,c="function"==typeof h?h:function(t){return t!==h};if(!t$2(e))throw new TypeError("Invalid target");for(var f=document.scrollingElement||document.documentElement,s=[],p=e;t$2(p)&&c(p);){if((p=p.parentElement)===f){s.push(p);break}null!=p&&p===document.body&&n$2(p)&&!n$2(document.documentElement)||null!=p&&n$2(p,a)&&s.push(p);}for(var m=o.visualViewport?o.visualViewport.width:innerWidth,g=o.visualViewport?o.visualViewport.height:innerHeight,w=window.scrollX||pageXOffset,v=window.scrollY||pageYOffset,W=e.getBoundingClientRect(),b=W.height,H=W.width,y=W.top,E=W.right,M=W.bottom,V=W.left,x="start"===d||"nearest"===d?y:"end"===d?M:y+b/2,I="center"===u?V+H/2:"end"===u?E:V,C=[],T=0;T<s.length;T++){var k=s[T],B=k.getBoundingClientRect(),D=B.height,O=B.width,R=B.top,X=B.right,Y=B.bottom,L=B.left;if("if-needed"===l&&y>=0&&V>=0&&M<=g&&E<=m&&y>=R&&M<=Y&&V>=L&&E<=X)return C;var S=getComputedStyle(k),j=parseInt(S.borderLeftWidth,10),q=parseInt(S.borderTopWidth,10),z=parseInt(S.borderRightWidth,10),A=parseInt(S.borderBottomWidth,10),F=0,G=0,J="offsetWidth"in k?k.offsetWidth-k.clientWidth-j-z:0,K="offsetHeight"in k?k.offsetHeight-k.clientHeight-q-A:0;if(f===k)F="start"===d?x:"end"===d?x-g:"nearest"===d?r$2(v,v+g,g,q,A,v+x,v+x+b,b):x-g/2,G="start"===u?I:"center"===u?I-m/2:"end"===u?I-m:r$2(w,w+m,m,j,z,w+I,w+I+H,H),F=Math.max(0,F+v),G=Math.max(0,G+w);else {F="start"===d?x-R-q:"end"===d?x-Y+A+K:"nearest"===d?r$2(R,Y,D,q,A+K,x,x+b,b):x-(R+D/2)+K/2,G="start"===u?I-L-j:"center"===u?I-(L+O/2)+J/2:"end"===u?I-X+z+J:r$2(L,X,O,j,z+J,I,I+H,H);var N=k.scrollLeft,P=k.scrollTop;x+=P-(F=Math.max(0,Math.min(P+F,k.scrollHeight-D+K))),I+=N-(G=Math.max(0,Math.min(N+G,k.scrollWidth-O+J)));}C.push({el:k,top:F,left:G});}return C}
|
|
6692
6683
|
|
|
6693
|
-
|
|
6684
|
+
/******************************************************************************
|
|
6685
|
+
Copyright (c) Microsoft Corporation.
|
|
6686
|
+
|
|
6687
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6688
|
+
purpose with or without fee is hereby granted.
|
|
6689
|
+
|
|
6690
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
6691
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
6692
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
6693
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
6694
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
6695
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
6696
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
6697
|
+
***************************************************************************** */
|
|
6698
|
+
|
|
6699
|
+
var __assign = function() {
|
|
6700
|
+
__assign = Object.assign || function __assign(t) {
|
|
6701
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
6702
|
+
s = arguments[i];
|
|
6703
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
6704
|
+
}
|
|
6705
|
+
return t;
|
|
6706
|
+
};
|
|
6707
|
+
return __assign.apply(this, arguments);
|
|
6708
|
+
};
|
|
6709
|
+
|
|
6710
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
6711
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
6712
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
6713
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6714
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6715
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
6716
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
6717
|
+
});
|
|
6718
|
+
}
|
|
6719
|
+
|
|
6720
|
+
function __generator(thisArg, body) {
|
|
6721
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
6722
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
6723
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
6724
|
+
function step(op) {
|
|
6725
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
6726
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
6727
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
6728
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
6729
|
+
switch (op[0]) {
|
|
6730
|
+
case 0: case 1: t = op; break;
|
|
6731
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
6732
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
6733
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
6734
|
+
default:
|
|
6735
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
6736
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
6737
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
6738
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
6739
|
+
if (t[2]) _.ops.pop();
|
|
6740
|
+
_.trys.pop(); continue;
|
|
6741
|
+
}
|
|
6742
|
+
op = body.call(thisArg, _);
|
|
6743
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
6744
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
6745
|
+
}
|
|
6746
|
+
}
|
|
6747
|
+
|
|
6748
|
+
function __read(o, n) {
|
|
6749
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
6750
|
+
if (!m) return o;
|
|
6751
|
+
var i = m.call(o), r, ar = [], e;
|
|
6752
|
+
try {
|
|
6753
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
6754
|
+
}
|
|
6755
|
+
catch (error) { e = { error: error }; }
|
|
6756
|
+
finally {
|
|
6757
|
+
try {
|
|
6758
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
6759
|
+
}
|
|
6760
|
+
finally { if (e) throw e.error; }
|
|
6761
|
+
}
|
|
6762
|
+
return ar;
|
|
6763
|
+
}
|
|
6764
|
+
|
|
6765
|
+
/** @deprecated */
|
|
6766
|
+
function __spread() {
|
|
6767
|
+
for (var ar = [], i = 0; i < arguments.length; i++)
|
|
6768
|
+
ar = ar.concat(__read(arguments[i]));
|
|
6769
|
+
return ar;
|
|
6770
|
+
}
|
|
6771
|
+
|
|
6772
|
+
let idCounter = 0;
|
|
6694
6773
|
/**
|
|
6695
6774
|
* Accepts a parameter and returns it if it's a function
|
|
6696
6775
|
* or a noop function if it's not. This allows us to
|
|
@@ -6717,15 +6796,17 @@ function scrollIntoView(node, menuNode) {
|
|
|
6717
6796
|
return;
|
|
6718
6797
|
}
|
|
6719
6798
|
|
|
6720
|
-
|
|
6799
|
+
const actions = computeScrollIntoView(node, {
|
|
6721
6800
|
boundary: menuNode,
|
|
6722
6801
|
block: 'nearest',
|
|
6723
6802
|
scrollMode: 'if-needed'
|
|
6724
6803
|
});
|
|
6725
|
-
actions.forEach(
|
|
6726
|
-
|
|
6727
|
-
|
|
6728
|
-
|
|
6804
|
+
actions.forEach(_ref => {
|
|
6805
|
+
let {
|
|
6806
|
+
el,
|
|
6807
|
+
top,
|
|
6808
|
+
left
|
|
6809
|
+
} = _ref;
|
|
6729
6810
|
el.scrollTop = top;
|
|
6730
6811
|
el.scrollLeft = left;
|
|
6731
6812
|
});
|
|
@@ -6739,7 +6820,7 @@ function scrollIntoView(node, menuNode) {
|
|
|
6739
6820
|
|
|
6740
6821
|
|
|
6741
6822
|
function isOrContainsNode(parent, child, environment) {
|
|
6742
|
-
|
|
6823
|
+
const result = parent === child || child instanceof environment.Node && parent.contains && parent.contains(child);
|
|
6743
6824
|
return result;
|
|
6744
6825
|
}
|
|
6745
6826
|
/**
|
|
@@ -6753,7 +6834,7 @@ function isOrContainsNode(parent, child, environment) {
|
|
|
6753
6834
|
|
|
6754
6835
|
|
|
6755
6836
|
function debounce$1(fn, time) {
|
|
6756
|
-
|
|
6837
|
+
let timeoutId;
|
|
6757
6838
|
|
|
6758
6839
|
function cancel() {
|
|
6759
6840
|
if (timeoutId) {
|
|
@@ -6767,9 +6848,9 @@ function debounce$1(fn, time) {
|
|
|
6767
6848
|
}
|
|
6768
6849
|
|
|
6769
6850
|
cancel();
|
|
6770
|
-
timeoutId = setTimeout(
|
|
6851
|
+
timeoutId = setTimeout(() => {
|
|
6771
6852
|
timeoutId = null;
|
|
6772
|
-
fn
|
|
6853
|
+
fn(...args);
|
|
6773
6854
|
}, time);
|
|
6774
6855
|
}
|
|
6775
6856
|
|
|
@@ -6795,9 +6876,9 @@ function callAllEventHandlers() {
|
|
|
6795
6876
|
args[_key3 - 1] = arguments[_key3];
|
|
6796
6877
|
}
|
|
6797
6878
|
|
|
6798
|
-
return fns.some(
|
|
6879
|
+
return fns.some(fn => {
|
|
6799
6880
|
if (fn) {
|
|
6800
|
-
fn
|
|
6881
|
+
fn(event, ...args);
|
|
6801
6882
|
}
|
|
6802
6883
|
|
|
6803
6884
|
return event.preventDownshiftDefault || event.hasOwnProperty('nativeEvent') && event.nativeEvent.preventDownshiftDefault;
|
|
@@ -6810,8 +6891,8 @@ function handleRefs() {
|
|
|
6810
6891
|
refs[_key4] = arguments[_key4];
|
|
6811
6892
|
}
|
|
6812
6893
|
|
|
6813
|
-
return
|
|
6814
|
-
refs.forEach(
|
|
6894
|
+
return node => {
|
|
6895
|
+
refs.forEach(ref => {
|
|
6815
6896
|
if (typeof ref === 'function') {
|
|
6816
6897
|
ref(node);
|
|
6817
6898
|
} else if (ref) {
|
|
@@ -6831,7 +6912,7 @@ function generateId() {
|
|
|
6831
6912
|
}
|
|
6832
6913
|
/**
|
|
6833
6914
|
* Default implementation for status message. Only added when menu is open.
|
|
6834
|
-
* Will
|
|
6915
|
+
* Will specify if there are results in the list, and if so, how many,
|
|
6835
6916
|
* and what keys are relevant.
|
|
6836
6917
|
*
|
|
6837
6918
|
* @param {Object} param the downshift state and other relevant properties
|
|
@@ -6840,9 +6921,11 @@ function generateId() {
|
|
|
6840
6921
|
|
|
6841
6922
|
|
|
6842
6923
|
function getA11yStatusMessage$1(_ref2) {
|
|
6843
|
-
|
|
6844
|
-
|
|
6845
|
-
|
|
6924
|
+
let {
|
|
6925
|
+
isOpen,
|
|
6926
|
+
resultCount,
|
|
6927
|
+
previousResultCount
|
|
6928
|
+
} = _ref2;
|
|
6846
6929
|
|
|
6847
6930
|
if (!isOpen) {
|
|
6848
6931
|
return '';
|
|
@@ -6853,7 +6936,7 @@ function getA11yStatusMessage$1(_ref2) {
|
|
|
6853
6936
|
}
|
|
6854
6937
|
|
|
6855
6938
|
if (resultCount !== previousResultCount) {
|
|
6856
|
-
return resultCount
|
|
6939
|
+
return `${resultCount} result${resultCount === 1 ? ' is' : 's are'} available, use up and down arrow keys to navigate. Press Enter key to select.`;
|
|
6857
6940
|
}
|
|
6858
6941
|
|
|
6859
6942
|
return '';
|
|
@@ -6909,10 +6992,10 @@ function getElementProps(element) {
|
|
|
6909
6992
|
|
|
6910
6993
|
function requiredProp(fnName, propName) {
|
|
6911
6994
|
// eslint-disable-next-line no-console
|
|
6912
|
-
console.error(
|
|
6995
|
+
console.error(`The property "${propName}" is required in "${fnName}"`);
|
|
6913
6996
|
}
|
|
6914
6997
|
|
|
6915
|
-
|
|
6998
|
+
const stateKeys = ['highlightedIndex', 'inputValue', 'isOpen', 'selectedItem', 'type'];
|
|
6916
6999
|
/**
|
|
6917
7000
|
* @param {Object} state the state object
|
|
6918
7001
|
* @return {Object} state that is relevant to downshift
|
|
@@ -6923,8 +7006,8 @@ function pickState(state) {
|
|
|
6923
7006
|
state = {};
|
|
6924
7007
|
}
|
|
6925
7008
|
|
|
6926
|
-
|
|
6927
|
-
stateKeys.forEach(
|
|
7009
|
+
const result = {};
|
|
7010
|
+
stateKeys.forEach(k => {
|
|
6928
7011
|
if (state.hasOwnProperty(k)) {
|
|
6929
7012
|
result[k] = state[k];
|
|
6930
7013
|
}
|
|
@@ -6945,7 +7028,7 @@ function pickState(state) {
|
|
|
6945
7028
|
|
|
6946
7029
|
|
|
6947
7030
|
function getState(state, props) {
|
|
6948
|
-
return Object.keys(state).reduce(
|
|
7031
|
+
return Object.keys(state).reduce((prevState, key) => {
|
|
6949
7032
|
prevState[key] = isControlledProp(props, key) ? props[key] : state[key];
|
|
6950
7033
|
return prevState;
|
|
6951
7034
|
}, {});
|
|
@@ -6972,12 +7055,14 @@ function isControlledProp(props, key) {
|
|
|
6972
7055
|
|
|
6973
7056
|
|
|
6974
7057
|
function normalizeArrowKey(event) {
|
|
6975
|
-
|
|
6976
|
-
|
|
7058
|
+
const {
|
|
7059
|
+
key,
|
|
7060
|
+
keyCode
|
|
7061
|
+
} = event;
|
|
6977
7062
|
/* istanbul ignore next (ie) */
|
|
6978
7063
|
|
|
6979
7064
|
if (keyCode >= 37 && keyCode <= 40 && key.indexOf('Arrow') !== 0) {
|
|
6980
|
-
return
|
|
7065
|
+
return `Arrow${key}`;
|
|
6981
7066
|
}
|
|
6982
7067
|
|
|
6983
7068
|
return key;
|
|
@@ -7014,13 +7099,13 @@ function getNextWrappingIndex(moveAmount, baseIndex, itemCount, getItemNodeFromI
|
|
|
7014
7099
|
return -1;
|
|
7015
7100
|
}
|
|
7016
7101
|
|
|
7017
|
-
|
|
7102
|
+
const itemsLastIndex = itemCount - 1;
|
|
7018
7103
|
|
|
7019
7104
|
if (typeof baseIndex !== 'number' || baseIndex < 0 || baseIndex >= itemCount) {
|
|
7020
7105
|
baseIndex = moveAmount > 0 ? -1 : itemsLastIndex + 1;
|
|
7021
7106
|
}
|
|
7022
7107
|
|
|
7023
|
-
|
|
7108
|
+
let newIndex = baseIndex + moveAmount;
|
|
7024
7109
|
|
|
7025
7110
|
if (newIndex < 0) {
|
|
7026
7111
|
newIndex = circular ? itemsLastIndex : 0;
|
|
@@ -7028,7 +7113,7 @@ function getNextWrappingIndex(moveAmount, baseIndex, itemCount, getItemNodeFromI
|
|
|
7028
7113
|
newIndex = circular ? 0 : itemsLastIndex;
|
|
7029
7114
|
}
|
|
7030
7115
|
|
|
7031
|
-
|
|
7116
|
+
const nonDisabledNewIndex = getNextNonDisabledIndex(moveAmount, newIndex, itemCount, getItemNodeFromIndex, circular);
|
|
7032
7117
|
|
|
7033
7118
|
if (nonDisabledNewIndex === -1) {
|
|
7034
7119
|
return baseIndex >= itemCount ? -1 : baseIndex;
|
|
@@ -7049,22 +7134,22 @@ function getNextWrappingIndex(moveAmount, baseIndex, itemCount, getItemNodeFromI
|
|
|
7049
7134
|
|
|
7050
7135
|
|
|
7051
7136
|
function getNextNonDisabledIndex(moveAmount, baseIndex, itemCount, getItemNodeFromIndex, circular) {
|
|
7052
|
-
|
|
7137
|
+
const currentElementNode = getItemNodeFromIndex(baseIndex);
|
|
7053
7138
|
|
|
7054
7139
|
if (!currentElementNode || !currentElementNode.hasAttribute('disabled')) {
|
|
7055
7140
|
return baseIndex;
|
|
7056
7141
|
}
|
|
7057
7142
|
|
|
7058
7143
|
if (moveAmount > 0) {
|
|
7059
|
-
for (
|
|
7144
|
+
for (let index = baseIndex + 1; index < itemCount; index++) {
|
|
7060
7145
|
if (!getItemNodeFromIndex(index).hasAttribute('disabled')) {
|
|
7061
7146
|
return index;
|
|
7062
7147
|
}
|
|
7063
7148
|
}
|
|
7064
7149
|
} else {
|
|
7065
|
-
for (
|
|
7066
|
-
if (!getItemNodeFromIndex(
|
|
7067
|
-
return
|
|
7150
|
+
for (let index = baseIndex - 1; index >= 0; index--) {
|
|
7151
|
+
if (!getItemNodeFromIndex(index).hasAttribute('disabled')) {
|
|
7152
|
+
return index;
|
|
7068
7153
|
}
|
|
7069
7154
|
}
|
|
7070
7155
|
}
|
|
@@ -7092,31 +7177,29 @@ function targetWithinDownshift(target, downshiftElements, environment, checkActi
|
|
|
7092
7177
|
checkActiveElement = true;
|
|
7093
7178
|
}
|
|
7094
7179
|
|
|
7095
|
-
return downshiftElements.some(
|
|
7096
|
-
return contextNode && (isOrContainsNode(contextNode, target, environment) || checkActiveElement && isOrContainsNode(contextNode, environment.document.activeElement, environment));
|
|
7097
|
-
});
|
|
7180
|
+
return downshiftElements.some(contextNode => contextNode && (isOrContainsNode(contextNode, target, environment) || checkActiveElement && isOrContainsNode(contextNode, environment.document.activeElement, environment)));
|
|
7098
7181
|
} // eslint-disable-next-line import/no-mutable-exports
|
|
7099
7182
|
|
|
7100
7183
|
|
|
7101
|
-
|
|
7184
|
+
let validateControlledUnchanged = noop;
|
|
7102
7185
|
/* istanbul ignore next */
|
|
7103
7186
|
|
|
7104
7187
|
if (process.env.NODE_ENV !== 'production') {
|
|
7105
|
-
validateControlledUnchanged =
|
|
7106
|
-
|
|
7107
|
-
Object.keys(state).forEach(
|
|
7188
|
+
validateControlledUnchanged = (state, prevProps, nextProps) => {
|
|
7189
|
+
const warningDescription = `This prop should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled Downshift element for the lifetime of the component. More info: https://github.com/downshift-js/downshift#control-props`;
|
|
7190
|
+
Object.keys(state).forEach(propKey => {
|
|
7108
7191
|
if (prevProps[propKey] !== undefined && nextProps[propKey] === undefined) {
|
|
7109
7192
|
// eslint-disable-next-line no-console
|
|
7110
|
-
console.error(
|
|
7193
|
+
console.error(`downshift: A component has changed the controlled prop "${propKey}" to be uncontrolled. ${warningDescription}`);
|
|
7111
7194
|
} else if (prevProps[propKey] === undefined && nextProps[propKey] !== undefined) {
|
|
7112
7195
|
// eslint-disable-next-line no-console
|
|
7113
|
-
console.error(
|
|
7196
|
+
console.error(`downshift: A component has changed the uncontrolled prop "${propKey}" to be controlled. ${warningDescription}`);
|
|
7114
7197
|
}
|
|
7115
7198
|
});
|
|
7116
7199
|
};
|
|
7117
7200
|
}
|
|
7118
7201
|
|
|
7119
|
-
|
|
7202
|
+
const cleanupStatus = debounce$1(documentProp => {
|
|
7120
7203
|
getStatusDiv(documentProp).textContent = '';
|
|
7121
7204
|
}, 500);
|
|
7122
7205
|
/**
|
|
@@ -7125,7 +7208,7 @@ var cleanupStatus = debounce$1(function (documentProp) {
|
|
|
7125
7208
|
*/
|
|
7126
7209
|
|
|
7127
7210
|
function setStatus(status, documentProp) {
|
|
7128
|
-
|
|
7211
|
+
const div = getStatusDiv(documentProp);
|
|
7129
7212
|
|
|
7130
7213
|
if (!status) {
|
|
7131
7214
|
return;
|
|
@@ -7146,7 +7229,7 @@ function getStatusDiv(documentProp) {
|
|
|
7146
7229
|
documentProp = document;
|
|
7147
7230
|
}
|
|
7148
7231
|
|
|
7149
|
-
|
|
7232
|
+
let statusDiv = documentProp.getElementById('a11y-status-message');
|
|
7150
7233
|
|
|
7151
7234
|
if (statusDiv) {
|
|
7152
7235
|
return statusDiv;
|
|
@@ -7171,23 +7254,23 @@ function getStatusDiv(documentProp) {
|
|
|
7171
7254
|
return statusDiv;
|
|
7172
7255
|
}
|
|
7173
7256
|
|
|
7174
|
-
|
|
7175
|
-
|
|
7176
|
-
|
|
7177
|
-
|
|
7178
|
-
|
|
7179
|
-
|
|
7180
|
-
|
|
7181
|
-
|
|
7182
|
-
|
|
7183
|
-
|
|
7184
|
-
|
|
7185
|
-
|
|
7186
|
-
|
|
7187
|
-
|
|
7188
|
-
|
|
7189
|
-
|
|
7190
|
-
|
|
7257
|
+
const unknown = process.env.NODE_ENV !== "production" ? '__autocomplete_unknown__' : 0;
|
|
7258
|
+
const mouseUp = process.env.NODE_ENV !== "production" ? '__autocomplete_mouseup__' : 1;
|
|
7259
|
+
const itemMouseEnter = process.env.NODE_ENV !== "production" ? '__autocomplete_item_mouseenter__' : 2;
|
|
7260
|
+
const keyDownArrowUp = process.env.NODE_ENV !== "production" ? '__autocomplete_keydown_arrow_up__' : 3;
|
|
7261
|
+
const keyDownArrowDown = process.env.NODE_ENV !== "production" ? '__autocomplete_keydown_arrow_down__' : 4;
|
|
7262
|
+
const keyDownEscape = process.env.NODE_ENV !== "production" ? '__autocomplete_keydown_escape__' : 5;
|
|
7263
|
+
const keyDownEnter = process.env.NODE_ENV !== "production" ? '__autocomplete_keydown_enter__' : 6;
|
|
7264
|
+
const keyDownHome = process.env.NODE_ENV !== "production" ? '__autocomplete_keydown_home__' : 7;
|
|
7265
|
+
const keyDownEnd = process.env.NODE_ENV !== "production" ? '__autocomplete_keydown_end__' : 8;
|
|
7266
|
+
const clickItem = process.env.NODE_ENV !== "production" ? '__autocomplete_click_item__' : 9;
|
|
7267
|
+
const blurInput = process.env.NODE_ENV !== "production" ? '__autocomplete_blur_input__' : 10;
|
|
7268
|
+
const changeInput = process.env.NODE_ENV !== "production" ? '__autocomplete_change_input__' : 11;
|
|
7269
|
+
const keyDownSpaceButton = process.env.NODE_ENV !== "production" ? '__autocomplete_keydown_space_button__' : 12;
|
|
7270
|
+
const clickButton = process.env.NODE_ENV !== "production" ? '__autocomplete_click_button__' : 13;
|
|
7271
|
+
const blurButton = process.env.NODE_ENV !== "production" ? '__autocomplete_blur_button__' : 14;
|
|
7272
|
+
const controlledPropUpdatedSelectedItem = process.env.NODE_ENV !== "production" ? '__autocomplete_controlled_prop_updated_selected_item__' : 15;
|
|
7273
|
+
const touchEnd = process.env.NODE_ENV !== "production" ? '__autocomplete_touchend__' : 16;
|
|
7191
7274
|
|
|
7192
7275
|
var stateChangeTypes$3 = /*#__PURE__*/Object.freeze({
|
|
7193
7276
|
__proto__: null,
|
|
@@ -7210,52 +7293,45 @@ var stateChangeTypes$3 = /*#__PURE__*/Object.freeze({
|
|
|
7210
7293
|
touchEnd: touchEnd
|
|
7211
7294
|
});
|
|
7212
7295
|
|
|
7213
|
-
|
|
7214
|
-
var Downshift = /*#__PURE__*/function (_Component) {
|
|
7215
|
-
_inheritsLoose(Downshift, _Component);
|
|
7296
|
+
/* eslint camelcase:0 */
|
|
7216
7297
|
|
|
7217
|
-
|
|
7298
|
+
const Downshift = /*#__PURE__*/(() => {
|
|
7299
|
+
class Downshift extends Component {
|
|
7300
|
+
constructor(_props) {
|
|
7218
7301
|
var _this;
|
|
7219
7302
|
|
|
7220
|
-
|
|
7221
|
-
|
|
7222
|
-
|
|
7223
|
-
|
|
7224
|
-
|
|
7225
|
-
|
|
7226
|
-
_this.labelId = _this.props.labelId || _this.id + "-label";
|
|
7227
|
-
_this.inputId = _this.props.inputId || _this.id + "-input";
|
|
7303
|
+
super(_props);
|
|
7304
|
+
_this = this;
|
|
7305
|
+
this.id = this.props.id || `downshift-${generateId()}`;
|
|
7306
|
+
this.menuId = this.props.menuId || `${this.id}-menu`;
|
|
7307
|
+
this.labelId = this.props.labelId || `${this.id}-label`;
|
|
7308
|
+
this.inputId = this.props.inputId || `${this.id}-input`;
|
|
7228
7309
|
|
|
7229
|
-
|
|
7230
|
-
return _this.id + "-item-" + index;
|
|
7231
|
-
};
|
|
7310
|
+
this.getItemId = this.props.getItemId || (index => `${this.id}-item-${index}`);
|
|
7232
7311
|
|
|
7233
|
-
|
|
7234
|
-
|
|
7235
|
-
|
|
7236
|
-
|
|
7237
|
-
|
|
7312
|
+
this.input = null;
|
|
7313
|
+
this.items = [];
|
|
7314
|
+
this.itemCount = null;
|
|
7315
|
+
this.previousResultCount = 0;
|
|
7316
|
+
this.timeoutIds = [];
|
|
7238
7317
|
|
|
7239
|
-
|
|
7240
|
-
|
|
7241
|
-
|
|
7242
|
-
return i !== id;
|
|
7243
|
-
});
|
|
7318
|
+
this.internalSetTimeout = (fn, time) => {
|
|
7319
|
+
const id = setTimeout(() => {
|
|
7320
|
+
this.timeoutIds = this.timeoutIds.filter(i => i !== id);
|
|
7244
7321
|
fn();
|
|
7245
7322
|
}, time);
|
|
7246
|
-
|
|
7247
|
-
_this.timeoutIds.push(id);
|
|
7323
|
+
this.timeoutIds.push(id);
|
|
7248
7324
|
};
|
|
7249
7325
|
|
|
7250
|
-
|
|
7251
|
-
|
|
7326
|
+
this.setItemCount = count => {
|
|
7327
|
+
this.itemCount = count;
|
|
7252
7328
|
};
|
|
7253
7329
|
|
|
7254
|
-
|
|
7255
|
-
|
|
7330
|
+
this.unsetItemCount = () => {
|
|
7331
|
+
this.itemCount = null;
|
|
7256
7332
|
};
|
|
7257
7333
|
|
|
7258
|
-
|
|
7334
|
+
this.setHighlightedIndex = function (highlightedIndex, otherStateToSet) {
|
|
7259
7335
|
if (highlightedIndex === void 0) {
|
|
7260
7336
|
highlightedIndex = _this.props.defaultHighlightedIndex;
|
|
7261
7337
|
}
|
|
@@ -7266,69 +7342,72 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
7266
7342
|
|
|
7267
7343
|
otherStateToSet = pickState(otherStateToSet);
|
|
7268
7344
|
|
|
7269
|
-
_this.internalSetState(
|
|
7270
|
-
highlightedIndex
|
|
7271
|
-
|
|
7345
|
+
_this.internalSetState({
|
|
7346
|
+
highlightedIndex,
|
|
7347
|
+
...otherStateToSet
|
|
7348
|
+
});
|
|
7272
7349
|
};
|
|
7273
7350
|
|
|
7274
|
-
|
|
7275
|
-
|
|
7351
|
+
this.clearSelection = cb => {
|
|
7352
|
+
this.internalSetState({
|
|
7276
7353
|
selectedItem: null,
|
|
7277
7354
|
inputValue: '',
|
|
7278
|
-
highlightedIndex:
|
|
7279
|
-
isOpen:
|
|
7355
|
+
highlightedIndex: this.props.defaultHighlightedIndex,
|
|
7356
|
+
isOpen: this.props.defaultIsOpen
|
|
7280
7357
|
}, cb);
|
|
7281
7358
|
};
|
|
7282
7359
|
|
|
7283
|
-
|
|
7360
|
+
this.selectItem = (item, otherStateToSet, cb) => {
|
|
7284
7361
|
otherStateToSet = pickState(otherStateToSet);
|
|
7285
|
-
|
|
7286
|
-
|
|
7287
|
-
|
|
7288
|
-
highlightedIndex: _this.props.defaultHighlightedIndex,
|
|
7362
|
+
this.internalSetState({
|
|
7363
|
+
isOpen: this.props.defaultIsOpen,
|
|
7364
|
+
highlightedIndex: this.props.defaultHighlightedIndex,
|
|
7289
7365
|
selectedItem: item,
|
|
7290
|
-
inputValue:
|
|
7291
|
-
|
|
7366
|
+
inputValue: this.props.itemToString(item),
|
|
7367
|
+
...otherStateToSet
|
|
7368
|
+
}, cb);
|
|
7292
7369
|
};
|
|
7293
7370
|
|
|
7294
|
-
|
|
7295
|
-
|
|
7371
|
+
this.selectItemAtIndex = (itemIndex, otherStateToSet, cb) => {
|
|
7372
|
+
const item = this.items[itemIndex];
|
|
7296
7373
|
|
|
7297
7374
|
if (item == null) {
|
|
7298
7375
|
return;
|
|
7299
7376
|
}
|
|
7300
7377
|
|
|
7301
|
-
|
|
7378
|
+
this.selectItem(item, otherStateToSet, cb);
|
|
7302
7379
|
};
|
|
7303
7380
|
|
|
7304
|
-
|
|
7305
|
-
return
|
|
7381
|
+
this.selectHighlightedItem = (otherStateToSet, cb) => {
|
|
7382
|
+
return this.selectItemAtIndex(this.getState().highlightedIndex, otherStateToSet, cb);
|
|
7306
7383
|
};
|
|
7307
7384
|
|
|
7308
|
-
|
|
7309
|
-
|
|
7310
|
-
|
|
7311
|
-
|
|
7385
|
+
this.internalSetState = (stateToSet, cb) => {
|
|
7386
|
+
let isItemSelected, onChangeArg;
|
|
7387
|
+
const onStateChangeArg = {};
|
|
7388
|
+
const isStateToSetFunction = typeof stateToSet === 'function'; // we want to call `onInputValueChange` before the `setState` call
|
|
7312
7389
|
// so someone controlling the `inputValue` state gets notified of
|
|
7313
7390
|
// the input change as soon as possible. This avoids issues with
|
|
7314
7391
|
// preserving the cursor position.
|
|
7315
7392
|
// See https://github.com/downshift-js/downshift/issues/217 for more info.
|
|
7316
7393
|
|
|
7317
7394
|
if (!isStateToSetFunction && stateToSet.hasOwnProperty('inputValue')) {
|
|
7318
|
-
|
|
7395
|
+
this.props.onInputValueChange(stateToSet.inputValue, { ...this.getStateAndHelpers(),
|
|
7396
|
+
...stateToSet
|
|
7397
|
+
});
|
|
7319
7398
|
}
|
|
7320
7399
|
|
|
7321
|
-
return
|
|
7322
|
-
state =
|
|
7323
|
-
|
|
7400
|
+
return this.setState(state => {
|
|
7401
|
+
state = this.getState(state);
|
|
7402
|
+
let newStateToSet = isStateToSetFunction ? stateToSet(state) : stateToSet; // Your own function that could modify the state that will be set.
|
|
7324
7403
|
|
|
7325
|
-
newStateToSet =
|
|
7404
|
+
newStateToSet = this.props.stateReducer(state, newStateToSet); // checks if an item is selected, regardless of if it's different from
|
|
7326
7405
|
// what was selected before
|
|
7327
7406
|
// used to determine if onSelect and onChange callbacks should be called
|
|
7328
7407
|
|
|
7329
7408
|
isItemSelected = newStateToSet.hasOwnProperty('selectedItem'); // this keeps track of the object we want to call with setState
|
|
7330
7409
|
|
|
7331
|
-
|
|
7410
|
+
const nextState = {}; // this is just used to tell whether the state changed
|
|
7332
7411
|
// and we're trying to update that state. OR if the selection has changed and we're
|
|
7333
7412
|
// trying to update the selection
|
|
7334
7413
|
|
|
@@ -7337,7 +7416,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
7337
7416
|
}
|
|
7338
7417
|
|
|
7339
7418
|
newStateToSet.type = newStateToSet.type || unknown;
|
|
7340
|
-
Object.keys(newStateToSet).forEach(
|
|
7419
|
+
Object.keys(newStateToSet).forEach(key => {
|
|
7341
7420
|
// onStateChangeArg should only have the state that is
|
|
7342
7421
|
// actually changing
|
|
7343
7422
|
if (state[key] !== newStateToSet[key]) {
|
|
@@ -7356,79 +7435,82 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
7356
7435
|
|
|
7357
7436
|
newStateToSet[key]; // if it's coming from props, then we don't care to set it internally
|
|
7358
7437
|
|
|
7359
|
-
if (!isControlledProp(
|
|
7438
|
+
if (!isControlledProp(this.props, key)) {
|
|
7360
7439
|
nextState[key] = newStateToSet[key];
|
|
7361
7440
|
}
|
|
7362
7441
|
}); // if stateToSet is a function, then we weren't able to call onInputValueChange
|
|
7363
7442
|
// earlier, so we'll call it now that we know what the inputValue state will be.
|
|
7364
7443
|
|
|
7365
7444
|
if (isStateToSetFunction && newStateToSet.hasOwnProperty('inputValue')) {
|
|
7366
|
-
|
|
7445
|
+
this.props.onInputValueChange(newStateToSet.inputValue, { ...this.getStateAndHelpers(),
|
|
7446
|
+
...newStateToSet
|
|
7447
|
+
});
|
|
7367
7448
|
}
|
|
7368
7449
|
|
|
7369
7450
|
return nextState;
|
|
7370
|
-
},
|
|
7451
|
+
}, () => {
|
|
7371
7452
|
// call the provided callback if it's a function
|
|
7372
7453
|
cbToCb(cb)(); // only call the onStateChange and onChange callbacks if
|
|
7373
7454
|
// we have relevant information to pass them.
|
|
7374
7455
|
|
|
7375
|
-
|
|
7456
|
+
const hasMoreStateThanType = Object.keys(onStateChangeArg).length > 1;
|
|
7376
7457
|
|
|
7377
7458
|
if (hasMoreStateThanType) {
|
|
7378
|
-
|
|
7459
|
+
this.props.onStateChange(onStateChangeArg, this.getStateAndHelpers());
|
|
7379
7460
|
}
|
|
7380
7461
|
|
|
7381
7462
|
if (isItemSelected) {
|
|
7382
|
-
|
|
7463
|
+
this.props.onSelect(stateToSet.selectedItem, this.getStateAndHelpers());
|
|
7383
7464
|
}
|
|
7384
7465
|
|
|
7385
7466
|
if (onChangeArg !== undefined) {
|
|
7386
|
-
|
|
7467
|
+
this.props.onChange(onChangeArg, this.getStateAndHelpers());
|
|
7387
7468
|
} // this is currently undocumented and therefore subject to change
|
|
7388
7469
|
// We'll try to not break it, but just be warned.
|
|
7389
7470
|
|
|
7390
7471
|
|
|
7391
|
-
|
|
7472
|
+
this.props.onUserAction(onStateChangeArg, this.getStateAndHelpers());
|
|
7392
7473
|
});
|
|
7393
7474
|
};
|
|
7394
7475
|
|
|
7395
|
-
|
|
7396
|
-
|
|
7397
|
-
|
|
7398
|
-
|
|
7399
|
-
|
|
7400
|
-
|
|
7401
|
-
|
|
7402
|
-
|
|
7403
|
-
|
|
7404
|
-
|
|
7405
|
-
|
|
7406
|
-
rest = _objectWithoutPropertiesLoose$1(_ref, ["refKey", "ref"]);
|
|
7407
|
-
|
|
7408
|
-
var _ref2 = _temp2 === void 0 ? {} : _temp2,
|
|
7409
|
-
_ref2$suppressRefErro = _ref2.suppressRefError,
|
|
7410
|
-
suppressRefError = _ref2$suppressRefErro === void 0 ? false : _ref2$suppressRefErro;
|
|
7411
|
-
|
|
7476
|
+
this.rootRef = node => this._rootNode = node;
|
|
7477
|
+
|
|
7478
|
+
this.getRootProps = function (_temp, _temp2) {
|
|
7479
|
+
let {
|
|
7480
|
+
refKey = 'ref',
|
|
7481
|
+
ref,
|
|
7482
|
+
...rest
|
|
7483
|
+
} = _temp === void 0 ? {} : _temp;
|
|
7484
|
+
let {
|
|
7485
|
+
suppressRefError = false
|
|
7486
|
+
} = _temp2 === void 0 ? {} : _temp2;
|
|
7412
7487
|
// this is used in the render to know whether the user has called getRootProps.
|
|
7413
7488
|
// It uses that to know whether to apply the props automatically
|
|
7414
7489
|
_this.getRootProps.called = true;
|
|
7415
7490
|
_this.getRootProps.refKey = refKey;
|
|
7416
7491
|
_this.getRootProps.suppressRefError = suppressRefError;
|
|
7417
7492
|
|
|
7418
|
-
|
|
7419
|
-
|
|
7493
|
+
const {
|
|
7494
|
+
isOpen
|
|
7495
|
+
} = _this.getState();
|
|
7420
7496
|
|
|
7421
|
-
return
|
|
7497
|
+
return {
|
|
7498
|
+
[refKey]: handleRefs(ref, _this.rootRef),
|
|
7499
|
+
role: 'combobox',
|
|
7500
|
+
'aria-expanded': isOpen,
|
|
7501
|
+
'aria-haspopup': 'listbox',
|
|
7502
|
+
'aria-owns': isOpen ? _this.menuId : null,
|
|
7503
|
+
'aria-labelledby': _this.labelId,
|
|
7504
|
+
...rest
|
|
7505
|
+
};
|
|
7422
7506
|
};
|
|
7423
7507
|
|
|
7424
|
-
|
|
7425
|
-
ArrowDown
|
|
7426
|
-
var _this2 = this;
|
|
7427
|
-
|
|
7508
|
+
this.keyDownHandlers = {
|
|
7509
|
+
ArrowDown(event) {
|
|
7428
7510
|
event.preventDefault();
|
|
7429
7511
|
|
|
7430
7512
|
if (this.getState().isOpen) {
|
|
7431
|
-
|
|
7513
|
+
const amount = event.shiftKey ? 5 : 1;
|
|
7432
7514
|
this.moveHighlightedIndex(amount, {
|
|
7433
7515
|
type: keyDownArrowDown
|
|
7434
7516
|
});
|
|
@@ -7436,31 +7518,27 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
7436
7518
|
this.internalSetState({
|
|
7437
7519
|
isOpen: true,
|
|
7438
7520
|
type: keyDownArrowDown
|
|
7439
|
-
},
|
|
7440
|
-
|
|
7521
|
+
}, () => {
|
|
7522
|
+
const itemCount = this.getItemCount();
|
|
7441
7523
|
|
|
7442
7524
|
if (itemCount > 0) {
|
|
7443
|
-
|
|
7444
|
-
|
|
7445
|
-
|
|
7446
|
-
|
|
7447
|
-
|
|
7448
|
-
});
|
|
7449
|
-
|
|
7450
|
-
_this2.setHighlightedIndex(nextHighlightedIndex, {
|
|
7525
|
+
const {
|
|
7526
|
+
highlightedIndex
|
|
7527
|
+
} = this.getState();
|
|
7528
|
+
const nextHighlightedIndex = getNextWrappingIndex(1, highlightedIndex, itemCount, index => this.getItemNodeFromIndex(index));
|
|
7529
|
+
this.setHighlightedIndex(nextHighlightedIndex, {
|
|
7451
7530
|
type: keyDownArrowDown
|
|
7452
7531
|
});
|
|
7453
7532
|
}
|
|
7454
7533
|
});
|
|
7455
7534
|
}
|
|
7456
7535
|
},
|
|
7457
|
-
ArrowUp: function ArrowUp(event) {
|
|
7458
|
-
var _this3 = this;
|
|
7459
7536
|
|
|
7537
|
+
ArrowUp(event) {
|
|
7460
7538
|
event.preventDefault();
|
|
7461
7539
|
|
|
7462
7540
|
if (this.getState().isOpen) {
|
|
7463
|
-
|
|
7541
|
+
const amount = event.shiftKey ? -5 : -1;
|
|
7464
7542
|
this.moveHighlightedIndex(amount, {
|
|
7465
7543
|
type: keyDownArrowUp
|
|
7466
7544
|
});
|
|
@@ -7468,37 +7546,36 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
7468
7546
|
this.internalSetState({
|
|
7469
7547
|
isOpen: true,
|
|
7470
7548
|
type: keyDownArrowUp
|
|
7471
|
-
},
|
|
7472
|
-
|
|
7549
|
+
}, () => {
|
|
7550
|
+
const itemCount = this.getItemCount();
|
|
7473
7551
|
|
|
7474
7552
|
if (itemCount > 0) {
|
|
7475
|
-
|
|
7476
|
-
|
|
7477
|
-
|
|
7478
|
-
|
|
7479
|
-
|
|
7480
|
-
});
|
|
7481
|
-
|
|
7482
|
-
_this3.setHighlightedIndex(nextHighlightedIndex, {
|
|
7553
|
+
const {
|
|
7554
|
+
highlightedIndex
|
|
7555
|
+
} = this.getState();
|
|
7556
|
+
const nextHighlightedIndex = getNextWrappingIndex(-1, highlightedIndex, itemCount, index => this.getItemNodeFromIndex(index));
|
|
7557
|
+
this.setHighlightedIndex(nextHighlightedIndex, {
|
|
7483
7558
|
type: keyDownArrowUp
|
|
7484
7559
|
});
|
|
7485
7560
|
}
|
|
7486
7561
|
});
|
|
7487
7562
|
}
|
|
7488
7563
|
},
|
|
7489
|
-
|
|
7564
|
+
|
|
7565
|
+
Enter(event) {
|
|
7490
7566
|
if (event.which === 229) {
|
|
7491
7567
|
return;
|
|
7492
7568
|
}
|
|
7493
7569
|
|
|
7494
|
-
|
|
7495
|
-
|
|
7496
|
-
|
|
7570
|
+
const {
|
|
7571
|
+
isOpen,
|
|
7572
|
+
highlightedIndex
|
|
7573
|
+
} = this.getState();
|
|
7497
7574
|
|
|
7498
7575
|
if (isOpen && highlightedIndex != null) {
|
|
7499
7576
|
event.preventDefault();
|
|
7500
|
-
|
|
7501
|
-
|
|
7577
|
+
const item = this.items[highlightedIndex];
|
|
7578
|
+
const itemNode = this.getItemNodeFromIndex(highlightedIndex);
|
|
7502
7579
|
|
|
7503
7580
|
if (item == null || itemNode && itemNode.hasAttribute('disabled')) {
|
|
7504
7581
|
return;
|
|
@@ -7509,125 +7586,131 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
7509
7586
|
});
|
|
7510
7587
|
}
|
|
7511
7588
|
},
|
|
7512
|
-
|
|
7589
|
+
|
|
7590
|
+
Escape(event) {
|
|
7513
7591
|
event.preventDefault();
|
|
7514
|
-
this.reset(
|
|
7515
|
-
type: keyDownEscape
|
|
7516
|
-
|
|
7517
|
-
|
|
7518
|
-
|
|
7519
|
-
|
|
7592
|
+
this.reset({
|
|
7593
|
+
type: keyDownEscape,
|
|
7594
|
+
...(!this.state.isOpen && {
|
|
7595
|
+
selectedItem: null,
|
|
7596
|
+
inputValue: ''
|
|
7597
|
+
})
|
|
7598
|
+
});
|
|
7520
7599
|
}
|
|
7600
|
+
|
|
7521
7601
|
};
|
|
7522
|
-
|
|
7523
|
-
|
|
7602
|
+
this.buttonKeyDownHandlers = { ...this.keyDownHandlers,
|
|
7603
|
+
|
|
7604
|
+
' '(event) {
|
|
7524
7605
|
event.preventDefault();
|
|
7525
7606
|
this.toggleMenu({
|
|
7526
7607
|
type: keyDownSpaceButton
|
|
7527
7608
|
});
|
|
7528
7609
|
}
|
|
7529
|
-
});
|
|
7530
|
-
_this.inputKeyDownHandlers = _extends({}, _this.keyDownHandlers, {
|
|
7531
|
-
Home: function Home(event) {
|
|
7532
|
-
var _this4 = this;
|
|
7533
7610
|
|
|
7534
|
-
|
|
7535
|
-
|
|
7611
|
+
};
|
|
7612
|
+
this.inputKeyDownHandlers = { ...this.keyDownHandlers,
|
|
7613
|
+
|
|
7614
|
+
Home(event) {
|
|
7615
|
+
const {
|
|
7616
|
+
isOpen
|
|
7617
|
+
} = this.getState();
|
|
7536
7618
|
|
|
7537
7619
|
if (!isOpen) {
|
|
7538
7620
|
return;
|
|
7539
7621
|
}
|
|
7540
7622
|
|
|
7541
7623
|
event.preventDefault();
|
|
7542
|
-
|
|
7624
|
+
const itemCount = this.getItemCount();
|
|
7543
7625
|
|
|
7544
7626
|
if (itemCount <= 0 || !isOpen) {
|
|
7545
7627
|
return;
|
|
7546
7628
|
} // get next non-disabled starting downwards from 0 if that's disabled.
|
|
7547
7629
|
|
|
7548
7630
|
|
|
7549
|
-
|
|
7550
|
-
return _this4.getItemNodeFromIndex(index);
|
|
7551
|
-
}, false);
|
|
7631
|
+
const newHighlightedIndex = getNextNonDisabledIndex(1, 0, itemCount, index => this.getItemNodeFromIndex(index), false);
|
|
7552
7632
|
this.setHighlightedIndex(newHighlightedIndex, {
|
|
7553
7633
|
type: keyDownHome
|
|
7554
7634
|
});
|
|
7555
7635
|
},
|
|
7556
|
-
End: function End(event) {
|
|
7557
|
-
var _this5 = this;
|
|
7558
7636
|
|
|
7559
|
-
|
|
7560
|
-
|
|
7637
|
+
End(event) {
|
|
7638
|
+
const {
|
|
7639
|
+
isOpen
|
|
7640
|
+
} = this.getState();
|
|
7561
7641
|
|
|
7562
7642
|
if (!isOpen) {
|
|
7563
7643
|
return;
|
|
7564
7644
|
}
|
|
7565
7645
|
|
|
7566
7646
|
event.preventDefault();
|
|
7567
|
-
|
|
7647
|
+
const itemCount = this.getItemCount();
|
|
7568
7648
|
|
|
7569
7649
|
if (itemCount <= 0 || !isOpen) {
|
|
7570
7650
|
return;
|
|
7571
7651
|
} // get next non-disabled starting upwards from last index if that's disabled.
|
|
7572
7652
|
|
|
7573
7653
|
|
|
7574
|
-
|
|
7575
|
-
return _this5.getItemNodeFromIndex(index);
|
|
7576
|
-
}, false);
|
|
7654
|
+
const newHighlightedIndex = getNextNonDisabledIndex(-1, itemCount - 1, itemCount, index => this.getItemNodeFromIndex(index), false);
|
|
7577
7655
|
this.setHighlightedIndex(newHighlightedIndex, {
|
|
7578
7656
|
type: keyDownEnd
|
|
7579
7657
|
});
|
|
7580
7658
|
}
|
|
7581
|
-
});
|
|
7582
7659
|
|
|
7583
|
-
|
|
7584
|
-
var _ref3 = _temp3 === void 0 ? {} : _temp3,
|
|
7585
|
-
onClick = _ref3.onClick;
|
|
7586
|
-
_ref3.onPress;
|
|
7587
|
-
var onKeyDown = _ref3.onKeyDown,
|
|
7588
|
-
onKeyUp = _ref3.onKeyUp,
|
|
7589
|
-
onBlur = _ref3.onBlur,
|
|
7590
|
-
rest = _objectWithoutPropertiesLoose$1(_ref3, ["onClick", "onPress", "onKeyDown", "onKeyUp", "onBlur"]);
|
|
7591
|
-
|
|
7592
|
-
var _this$getState5 = _this.getState(),
|
|
7593
|
-
isOpen = _this$getState5.isOpen;
|
|
7660
|
+
};
|
|
7594
7661
|
|
|
7595
|
-
|
|
7662
|
+
this.getToggleButtonProps = function (_temp3) {
|
|
7663
|
+
let {
|
|
7664
|
+
onClick,
|
|
7665
|
+
onPress,
|
|
7666
|
+
onKeyDown,
|
|
7667
|
+
onKeyUp,
|
|
7668
|
+
onBlur,
|
|
7669
|
+
...rest
|
|
7670
|
+
} = _temp3 === void 0 ? {} : _temp3;
|
|
7671
|
+
|
|
7672
|
+
const {
|
|
7673
|
+
isOpen
|
|
7674
|
+
} = _this.getState();
|
|
7675
|
+
|
|
7676
|
+
const enabledEventHandlers = {
|
|
7596
7677
|
onClick: callAllEventHandlers(onClick, _this.buttonHandleClick),
|
|
7597
7678
|
onKeyDown: callAllEventHandlers(onKeyDown, _this.buttonHandleKeyDown),
|
|
7598
7679
|
onKeyUp: callAllEventHandlers(onKeyUp, _this.buttonHandleKeyUp),
|
|
7599
7680
|
onBlur: callAllEventHandlers(onBlur, _this.buttonHandleBlur)
|
|
7600
7681
|
};
|
|
7601
|
-
|
|
7602
|
-
return
|
|
7682
|
+
const eventHandlers = rest.disabled ? {} : enabledEventHandlers;
|
|
7683
|
+
return {
|
|
7603
7684
|
type: 'button',
|
|
7604
7685
|
role: 'button',
|
|
7605
7686
|
'aria-label': isOpen ? 'close menu' : 'open menu',
|
|
7606
7687
|
'aria-haspopup': true,
|
|
7607
|
-
'data-toggle': true
|
|
7608
|
-
|
|
7688
|
+
'data-toggle': true,
|
|
7689
|
+
...eventHandlers,
|
|
7690
|
+
...rest
|
|
7691
|
+
};
|
|
7609
7692
|
};
|
|
7610
7693
|
|
|
7611
|
-
|
|
7694
|
+
this.buttonHandleKeyUp = event => {
|
|
7612
7695
|
// Prevent click event from emitting in Firefox
|
|
7613
7696
|
event.preventDefault();
|
|
7614
7697
|
};
|
|
7615
7698
|
|
|
7616
|
-
|
|
7617
|
-
|
|
7699
|
+
this.buttonHandleKeyDown = event => {
|
|
7700
|
+
const key = normalizeArrowKey(event);
|
|
7618
7701
|
|
|
7619
|
-
if (
|
|
7620
|
-
|
|
7702
|
+
if (this.buttonKeyDownHandlers[key]) {
|
|
7703
|
+
this.buttonKeyDownHandlers[key].call(this, event);
|
|
7621
7704
|
}
|
|
7622
7705
|
};
|
|
7623
7706
|
|
|
7624
|
-
|
|
7707
|
+
this.buttonHandleClick = event => {
|
|
7625
7708
|
event.preventDefault(); // handle odd case for Safari and Firefox which
|
|
7626
7709
|
// don't give the button the focus properly.
|
|
7627
7710
|
|
|
7628
7711
|
/* istanbul ignore if (can't reasonably test this) */
|
|
7629
7712
|
|
|
7630
|
-
if (
|
|
7713
|
+
if (this.props.environment.document.activeElement === this.props.environment.document.body) {
|
|
7631
7714
|
event.target.focus();
|
|
7632
7715
|
} // to simplify testing components that use downshift, we'll not wrap this in a setTimeout
|
|
7633
7716
|
// if the NODE_ENV is test. With the proper build system, this should be dead code eliminated
|
|
@@ -7635,69 +7718,71 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
7635
7718
|
|
|
7636
7719
|
|
|
7637
7720
|
if (process.env.NODE_ENV === 'test') {
|
|
7638
|
-
|
|
7721
|
+
this.toggleMenu({
|
|
7639
7722
|
type: clickButton
|
|
7640
7723
|
});
|
|
7641
7724
|
} else {
|
|
7642
7725
|
// Ensure that toggle of menu occurs after the potential blur event in iOS
|
|
7643
|
-
|
|
7644
|
-
|
|
7645
|
-
|
|
7646
|
-
});
|
|
7647
|
-
});
|
|
7726
|
+
this.internalSetTimeout(() => this.toggleMenu({
|
|
7727
|
+
type: clickButton
|
|
7728
|
+
}));
|
|
7648
7729
|
}
|
|
7649
7730
|
};
|
|
7650
7731
|
|
|
7651
|
-
|
|
7652
|
-
|
|
7732
|
+
this.buttonHandleBlur = event => {
|
|
7733
|
+
const blurTarget = event.target; // Save blur target for comparison with activeElement later
|
|
7653
7734
|
// Need setTimeout, so that when the user presses Tab, the activeElement is the next focused element, not body element
|
|
7654
7735
|
|
|
7655
|
-
|
|
7656
|
-
if (!
|
|
7736
|
+
this.internalSetTimeout(() => {
|
|
7737
|
+
if (!this.isMouseDown && (this.props.environment.document.activeElement == null || this.props.environment.document.activeElement.id !== this.inputId) && this.props.environment.document.activeElement !== blurTarget // Do nothing if we refocus the same element again (to solve issue in Safari on iOS)
|
|
7657
7738
|
) {
|
|
7658
|
-
|
|
7659
|
-
|
|
7660
|
-
|
|
7661
|
-
|
|
7739
|
+
this.reset({
|
|
7740
|
+
type: blurButton
|
|
7741
|
+
});
|
|
7742
|
+
}
|
|
7662
7743
|
});
|
|
7663
7744
|
};
|
|
7664
7745
|
|
|
7665
|
-
|
|
7666
|
-
return
|
|
7667
|
-
htmlFor:
|
|
7668
|
-
id:
|
|
7669
|
-
|
|
7746
|
+
this.getLabelProps = props => {
|
|
7747
|
+
return {
|
|
7748
|
+
htmlFor: this.inputId,
|
|
7749
|
+
id: this.labelId,
|
|
7750
|
+
...props
|
|
7751
|
+
};
|
|
7670
7752
|
};
|
|
7671
7753
|
|
|
7672
|
-
|
|
7673
|
-
|
|
7674
|
-
|
|
7675
|
-
|
|
7676
|
-
|
|
7677
|
-
|
|
7678
|
-
|
|
7679
|
-
|
|
7680
|
-
|
|
7681
|
-
|
|
7682
|
-
|
|
7754
|
+
this.getInputProps = function (_temp4) {
|
|
7755
|
+
let {
|
|
7756
|
+
onKeyDown,
|
|
7757
|
+
onBlur,
|
|
7758
|
+
onChange,
|
|
7759
|
+
onInput,
|
|
7760
|
+
onChangeText,
|
|
7761
|
+
...rest
|
|
7762
|
+
} = _temp4 === void 0 ? {} : _temp4;
|
|
7763
|
+
let onChangeKey;
|
|
7764
|
+
let eventHandlers = {};
|
|
7683
7765
|
/* istanbul ignore next (preact) */
|
|
7684
7766
|
|
|
7685
7767
|
{
|
|
7686
7768
|
onChangeKey = 'onChange';
|
|
7687
7769
|
}
|
|
7688
7770
|
|
|
7689
|
-
|
|
7690
|
-
|
|
7691
|
-
|
|
7692
|
-
|
|
7771
|
+
const {
|
|
7772
|
+
inputValue,
|
|
7773
|
+
isOpen,
|
|
7774
|
+
highlightedIndex
|
|
7775
|
+
} = _this.getState();
|
|
7693
7776
|
|
|
7694
7777
|
if (!rest.disabled) {
|
|
7695
|
-
|
|
7696
|
-
|
|
7697
|
-
|
|
7778
|
+
eventHandlers = {
|
|
7779
|
+
[onChangeKey]: callAllEventHandlers(onChange, onInput, _this.inputHandleChange),
|
|
7780
|
+
onKeyDown: callAllEventHandlers(onKeyDown, _this.inputHandleKeyDown),
|
|
7781
|
+
onBlur: callAllEventHandlers(onBlur, _this.inputHandleBlur)
|
|
7782
|
+
};
|
|
7698
7783
|
}
|
|
7699
7784
|
|
|
7700
|
-
return
|
|
7785
|
+
return {
|
|
7701
7786
|
'aria-autocomplete': 'list',
|
|
7702
7787
|
'aria-activedescendant': isOpen && typeof highlightedIndex === 'number' && highlightedIndex >= 0 ? _this.getItemId(highlightedIndex) : null,
|
|
7703
7788
|
'aria-controls': isOpen ? _this.menuId : null,
|
|
@@ -7706,77 +7791,79 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
7706
7791
|
// revert back since autocomplete="nope" is ignored on latest Chrome and Opera
|
|
7707
7792
|
autoComplete: 'off',
|
|
7708
7793
|
value: inputValue,
|
|
7709
|
-
id: _this.inputId
|
|
7710
|
-
|
|
7794
|
+
id: _this.inputId,
|
|
7795
|
+
...eventHandlers,
|
|
7796
|
+
...rest
|
|
7797
|
+
};
|
|
7711
7798
|
};
|
|
7712
7799
|
|
|
7713
|
-
|
|
7714
|
-
|
|
7800
|
+
this.inputHandleKeyDown = event => {
|
|
7801
|
+
const key = normalizeArrowKey(event);
|
|
7715
7802
|
|
|
7716
|
-
if (key &&
|
|
7717
|
-
|
|
7803
|
+
if (key && this.inputKeyDownHandlers[key]) {
|
|
7804
|
+
this.inputKeyDownHandlers[key].call(this, event);
|
|
7718
7805
|
}
|
|
7719
7806
|
};
|
|
7720
7807
|
|
|
7721
|
-
|
|
7722
|
-
|
|
7808
|
+
this.inputHandleChange = event => {
|
|
7809
|
+
this.internalSetState({
|
|
7723
7810
|
type: changeInput,
|
|
7724
7811
|
isOpen: true,
|
|
7725
7812
|
inputValue: event.target.value,
|
|
7726
|
-
highlightedIndex:
|
|
7813
|
+
highlightedIndex: this.props.defaultHighlightedIndex
|
|
7727
7814
|
});
|
|
7728
7815
|
};
|
|
7729
7816
|
|
|
7730
|
-
|
|
7817
|
+
this.inputHandleBlur = () => {
|
|
7731
7818
|
// Need setTimeout, so that when the user presses Tab, the activeElement is the next focused element, not the body element
|
|
7732
|
-
|
|
7733
|
-
|
|
7819
|
+
this.internalSetTimeout(() => {
|
|
7820
|
+
const downshiftButtonIsActive = this.props.environment.document && !!this.props.environment.document.activeElement && !!this.props.environment.document.activeElement.dataset && this.props.environment.document.activeElement.dataset.toggle && this._rootNode && this._rootNode.contains(this.props.environment.document.activeElement);
|
|
7734
7821
|
|
|
7735
|
-
if (!
|
|
7736
|
-
|
|
7822
|
+
if (!this.isMouseDown && !downshiftButtonIsActive) {
|
|
7823
|
+
this.reset({
|
|
7737
7824
|
type: blurInput
|
|
7738
7825
|
});
|
|
7739
7826
|
}
|
|
7740
7827
|
});
|
|
7741
7828
|
};
|
|
7742
7829
|
|
|
7743
|
-
|
|
7744
|
-
|
|
7830
|
+
this.menuRef = node => {
|
|
7831
|
+
this._menuNode = node;
|
|
7745
7832
|
};
|
|
7746
7833
|
|
|
7747
|
-
|
|
7748
|
-
|
|
7749
|
-
|
|
7750
|
-
|
|
7751
|
-
|
|
7752
|
-
|
|
7753
|
-
|
|
7754
|
-
|
|
7755
|
-
|
|
7756
|
-
var _ref6 = _temp6 === void 0 ? {} : _temp6,
|
|
7757
|
-
_ref6$suppressRefErro = _ref6.suppressRefError,
|
|
7758
|
-
suppressRefError = _ref6$suppressRefErro === void 0 ? false : _ref6$suppressRefErro;
|
|
7759
|
-
|
|
7834
|
+
this.getMenuProps = function (_temp5, _temp6) {
|
|
7835
|
+
let {
|
|
7836
|
+
refKey = 'ref',
|
|
7837
|
+
ref,
|
|
7838
|
+
...props
|
|
7839
|
+
} = _temp5 === void 0 ? {} : _temp5;
|
|
7840
|
+
let {
|
|
7841
|
+
suppressRefError = false
|
|
7842
|
+
} = _temp6 === void 0 ? {} : _temp6;
|
|
7760
7843
|
_this.getMenuProps.called = true;
|
|
7761
7844
|
_this.getMenuProps.refKey = refKey;
|
|
7762
7845
|
_this.getMenuProps.suppressRefError = suppressRefError;
|
|
7763
|
-
return
|
|
7846
|
+
return {
|
|
7847
|
+
[refKey]: handleRefs(ref, _this.menuRef),
|
|
7848
|
+
role: 'listbox',
|
|
7849
|
+
'aria-labelledby': props && props['aria-label'] ? null : _this.labelId,
|
|
7850
|
+
id: _this.menuId,
|
|
7851
|
+
...props
|
|
7852
|
+
};
|
|
7764
7853
|
};
|
|
7765
7854
|
|
|
7766
|
-
|
|
7767
|
-
|
|
7768
|
-
|
|
7769
|
-
|
|
7770
|
-
|
|
7771
|
-
|
|
7772
|
-
|
|
7773
|
-
|
|
7774
|
-
|
|
7775
|
-
|
|
7776
|
-
|
|
7777
|
-
|
|
7778
|
-
undefined : requiredProp('getItemProps', 'item') : _ref7$item,
|
|
7779
|
-
rest = _objectWithoutPropertiesLoose$1(_ref7, ["onMouseMove", "onMouseDown", "onClick", "onPress", "index", "item"]);
|
|
7855
|
+
this.getItemProps = function (_temp7) {
|
|
7856
|
+
let {
|
|
7857
|
+
onMouseMove,
|
|
7858
|
+
onMouseDown,
|
|
7859
|
+
onClick,
|
|
7860
|
+
onPress,
|
|
7861
|
+
index,
|
|
7862
|
+
item = process.env.NODE_ENV === 'production' ?
|
|
7863
|
+
/* istanbul ignore next */
|
|
7864
|
+
undefined : requiredProp('getItemProps', 'item'),
|
|
7865
|
+
...rest
|
|
7866
|
+
} = _temp7 === void 0 ? {} : _temp7;
|
|
7780
7867
|
|
|
7781
7868
|
if (index === undefined) {
|
|
7782
7869
|
_this.items.push(item);
|
|
@@ -7786,13 +7873,13 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
7786
7873
|
_this.items[index] = item;
|
|
7787
7874
|
}
|
|
7788
7875
|
|
|
7789
|
-
|
|
7790
|
-
|
|
7791
|
-
|
|
7876
|
+
const onSelectKey = 'onClick';
|
|
7877
|
+
const customClickHandler = onClick;
|
|
7878
|
+
const enabledEventHandlers = {
|
|
7792
7879
|
// onMouseMove is used over onMouseEnter here. onMouseMove
|
|
7793
7880
|
// is only triggered on actual mouse movement while onMouseEnter
|
|
7794
7881
|
// can fire on DOM changes, interrupting keyboard navigation
|
|
7795
|
-
onMouseMove: callAllEventHandlers(onMouseMove,
|
|
7882
|
+
onMouseMove: callAllEventHandlers(onMouseMove, () => {
|
|
7796
7883
|
if (index === _this.getState().highlightedIndex) {
|
|
7797
7884
|
return;
|
|
7798
7885
|
}
|
|
@@ -7807,72 +7894,81 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
7807
7894
|
|
|
7808
7895
|
_this.avoidScrolling = true;
|
|
7809
7896
|
|
|
7810
|
-
_this.internalSetTimeout(
|
|
7811
|
-
return _this.avoidScrolling = false;
|
|
7812
|
-
}, 250);
|
|
7897
|
+
_this.internalSetTimeout(() => _this.avoidScrolling = false, 250);
|
|
7813
7898
|
}),
|
|
7814
|
-
onMouseDown: callAllEventHandlers(onMouseDown,
|
|
7899
|
+
onMouseDown: callAllEventHandlers(onMouseDown, event => {
|
|
7815
7900
|
// This prevents the activeElement from being changed
|
|
7816
7901
|
// to the item so it can remain with the current activeElement
|
|
7817
7902
|
// which is a more common use case.
|
|
7818
7903
|
event.preventDefault();
|
|
7904
|
+
}),
|
|
7905
|
+
[onSelectKey]: callAllEventHandlers(customClickHandler, () => {
|
|
7906
|
+
_this.selectItemAtIndex(index, {
|
|
7907
|
+
type: clickItem
|
|
7908
|
+
});
|
|
7819
7909
|
})
|
|
7820
|
-
}
|
|
7821
|
-
_this.selectItemAtIndex(index, {
|
|
7822
|
-
type: clickItem
|
|
7823
|
-
});
|
|
7824
|
-
}), _enabledEventHandlers); // Passing down the onMouseDown handler to prevent redirect
|
|
7910
|
+
}; // Passing down the onMouseDown handler to prevent redirect
|
|
7825
7911
|
// of the activeElement if clicking on disabled items
|
|
7826
7912
|
|
|
7827
|
-
|
|
7913
|
+
const eventHandlers = rest.disabled ? {
|
|
7828
7914
|
onMouseDown: enabledEventHandlers.onMouseDown
|
|
7829
7915
|
} : enabledEventHandlers;
|
|
7830
|
-
return
|
|
7916
|
+
return {
|
|
7831
7917
|
id: _this.getItemId(index),
|
|
7832
7918
|
role: 'option',
|
|
7833
|
-
'aria-selected': _this.getState().highlightedIndex === index
|
|
7834
|
-
|
|
7919
|
+
'aria-selected': _this.getState().highlightedIndex === index,
|
|
7920
|
+
...eventHandlers,
|
|
7921
|
+
...rest
|
|
7922
|
+
};
|
|
7835
7923
|
};
|
|
7836
7924
|
|
|
7837
|
-
|
|
7838
|
-
|
|
7925
|
+
this.clearItems = () => {
|
|
7926
|
+
this.items = [];
|
|
7839
7927
|
};
|
|
7840
7928
|
|
|
7841
|
-
|
|
7929
|
+
this.reset = function (otherStateToSet, cb) {
|
|
7842
7930
|
if (otherStateToSet === void 0) {
|
|
7843
7931
|
otherStateToSet = {};
|
|
7844
7932
|
}
|
|
7845
7933
|
|
|
7846
7934
|
otherStateToSet = pickState(otherStateToSet);
|
|
7847
7935
|
|
|
7848
|
-
_this.internalSetState(
|
|
7849
|
-
|
|
7850
|
-
|
|
7936
|
+
_this.internalSetState(_ref => {
|
|
7937
|
+
let {
|
|
7938
|
+
selectedItem
|
|
7939
|
+
} = _ref;
|
|
7940
|
+
return {
|
|
7851
7941
|
isOpen: _this.props.defaultIsOpen,
|
|
7852
7942
|
highlightedIndex: _this.props.defaultHighlightedIndex,
|
|
7853
|
-
inputValue: _this.props.itemToString(selectedItem)
|
|
7854
|
-
|
|
7943
|
+
inputValue: _this.props.itemToString(selectedItem),
|
|
7944
|
+
...otherStateToSet
|
|
7945
|
+
};
|
|
7855
7946
|
}, cb);
|
|
7856
7947
|
};
|
|
7857
7948
|
|
|
7858
|
-
|
|
7949
|
+
this.toggleMenu = function (otherStateToSet, cb) {
|
|
7859
7950
|
if (otherStateToSet === void 0) {
|
|
7860
7951
|
otherStateToSet = {};
|
|
7861
7952
|
}
|
|
7862
7953
|
|
|
7863
7954
|
otherStateToSet = pickState(otherStateToSet);
|
|
7864
7955
|
|
|
7865
|
-
_this.internalSetState(
|
|
7866
|
-
|
|
7867
|
-
|
|
7868
|
-
|
|
7869
|
-
|
|
7870
|
-
|
|
7871
|
-
|
|
7872
|
-
|
|
7873
|
-
|
|
7874
|
-
|
|
7875
|
-
|
|
7956
|
+
_this.internalSetState(_ref2 => {
|
|
7957
|
+
let {
|
|
7958
|
+
isOpen
|
|
7959
|
+
} = _ref2;
|
|
7960
|
+
return {
|
|
7961
|
+
isOpen: !isOpen,
|
|
7962
|
+
...(isOpen && {
|
|
7963
|
+
highlightedIndex: _this.props.defaultHighlightedIndex
|
|
7964
|
+
}),
|
|
7965
|
+
...otherStateToSet
|
|
7966
|
+
};
|
|
7967
|
+
}, () => {
|
|
7968
|
+
const {
|
|
7969
|
+
isOpen,
|
|
7970
|
+
highlightedIndex
|
|
7971
|
+
} = _this.getState();
|
|
7876
7972
|
|
|
7877
7973
|
if (isOpen) {
|
|
7878
7974
|
if (_this.getItemCount() > 0 && typeof highlightedIndex === 'number') {
|
|
@@ -7884,70 +7980,63 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
7884
7980
|
});
|
|
7885
7981
|
};
|
|
7886
7982
|
|
|
7887
|
-
|
|
7888
|
-
|
|
7983
|
+
this.openMenu = cb => {
|
|
7984
|
+
this.internalSetState({
|
|
7889
7985
|
isOpen: true
|
|
7890
7986
|
}, cb);
|
|
7891
7987
|
};
|
|
7892
7988
|
|
|
7893
|
-
|
|
7894
|
-
|
|
7989
|
+
this.closeMenu = cb => {
|
|
7990
|
+
this.internalSetState({
|
|
7895
7991
|
isOpen: false
|
|
7896
7992
|
}, cb);
|
|
7897
7993
|
};
|
|
7898
7994
|
|
|
7899
|
-
|
|
7900
|
-
|
|
7901
|
-
|
|
7902
|
-
|
|
7903
|
-
|
|
7904
|
-
|
|
7905
|
-
|
|
7906
|
-
|
|
7907
|
-
|
|
7908
|
-
|
|
7909
|
-
|
|
7910
|
-
|
|
7911
|
-
|
|
7912
|
-
|
|
7913
|
-
_this.previousResultCount = resultCount;
|
|
7914
|
-
setStatus(status, _this.props.environment.document);
|
|
7995
|
+
this.updateStatus = debounce$1(() => {
|
|
7996
|
+
const state = this.getState();
|
|
7997
|
+
const item = this.items[state.highlightedIndex];
|
|
7998
|
+
const resultCount = this.getItemCount();
|
|
7999
|
+
const status = this.props.getA11yStatusMessage({
|
|
8000
|
+
itemToString: this.props.itemToString,
|
|
8001
|
+
previousResultCount: this.previousResultCount,
|
|
8002
|
+
resultCount,
|
|
8003
|
+
highlightedItem: item,
|
|
8004
|
+
...state
|
|
8005
|
+
});
|
|
8006
|
+
this.previousResultCount = resultCount;
|
|
8007
|
+
setStatus(status, this.props.environment.document);
|
|
7915
8008
|
}, 200);
|
|
7916
|
-
|
|
7917
|
-
|
|
7918
|
-
|
|
7919
|
-
|
|
7920
|
-
|
|
7921
|
-
|
|
7922
|
-
|
|
7923
|
-
|
|
7924
|
-
|
|
7925
|
-
|
|
7926
|
-
|
|
7927
|
-
|
|
7928
|
-
|
|
7929
|
-
var _state = _this.getState({
|
|
8009
|
+
// fancy destructuring + defaults + aliases
|
|
8010
|
+
// this basically says each value of state should either be set to
|
|
8011
|
+
// the initial value or the default value if the initial value is not provided
|
|
8012
|
+
const {
|
|
8013
|
+
defaultHighlightedIndex,
|
|
8014
|
+
initialHighlightedIndex: _highlightedIndex = defaultHighlightedIndex,
|
|
8015
|
+
defaultIsOpen,
|
|
8016
|
+
initialIsOpen: _isOpen = defaultIsOpen,
|
|
8017
|
+
initialInputValue: _inputValue = '',
|
|
8018
|
+
initialSelectedItem: _selectedItem = null
|
|
8019
|
+
} = this.props;
|
|
8020
|
+
|
|
8021
|
+
const _state = this.getState({
|
|
7930
8022
|
highlightedIndex: _highlightedIndex,
|
|
7931
8023
|
isOpen: _isOpen,
|
|
7932
8024
|
inputValue: _inputValue,
|
|
7933
8025
|
selectedItem: _selectedItem
|
|
7934
8026
|
});
|
|
7935
8027
|
|
|
7936
|
-
if (_state.selectedItem != null &&
|
|
7937
|
-
_state.inputValue =
|
|
8028
|
+
if (_state.selectedItem != null && this.props.initialInputValue === undefined) {
|
|
8029
|
+
_state.inputValue = this.props.itemToString(_state.selectedItem);
|
|
7938
8030
|
}
|
|
7939
8031
|
|
|
7940
|
-
|
|
7941
|
-
return _this;
|
|
8032
|
+
this.state = _state;
|
|
7942
8033
|
}
|
|
7943
8034
|
|
|
7944
|
-
var _proto = Downshift.prototype;
|
|
7945
|
-
|
|
7946
8035
|
/**
|
|
7947
8036
|
* Clear all running timeouts
|
|
7948
8037
|
*/
|
|
7949
|
-
|
|
7950
|
-
this.timeoutIds.forEach(
|
|
8038
|
+
internalClearTimeouts() {
|
|
8039
|
+
this.timeoutIds.forEach(id => {
|
|
7951
8040
|
clearTimeout(id);
|
|
7952
8041
|
});
|
|
7953
8042
|
this.timeoutIds = [];
|
|
@@ -7961,22 +8050,22 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
7961
8050
|
* @param {Object} stateToMerge defaults to this.state
|
|
7962
8051
|
* @return {Object} the state
|
|
7963
8052
|
*/
|
|
7964
|
-
;
|
|
7965
8053
|
|
|
7966
|
-
|
|
8054
|
+
|
|
8055
|
+
getState(stateToMerge) {
|
|
7967
8056
|
if (stateToMerge === void 0) {
|
|
7968
8057
|
stateToMerge = this.state;
|
|
7969
8058
|
}
|
|
7970
8059
|
|
|
7971
8060
|
return getState(stateToMerge, this.props);
|
|
7972
|
-
}
|
|
8061
|
+
}
|
|
7973
8062
|
|
|
7974
|
-
|
|
8063
|
+
getItemCount() {
|
|
7975
8064
|
// things read better this way. They're in priority order:
|
|
7976
8065
|
// 1. `this.itemCount`
|
|
7977
8066
|
// 2. `this.props.itemCount`
|
|
7978
8067
|
// 3. `this.items.length`
|
|
7979
|
-
|
|
8068
|
+
let itemCount = this.items.length;
|
|
7980
8069
|
|
|
7981
8070
|
if (this.itemCount != null) {
|
|
7982
8071
|
itemCount = this.itemCount;
|
|
@@ -7985,102 +8074,102 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
7985
8074
|
}
|
|
7986
8075
|
|
|
7987
8076
|
return itemCount;
|
|
7988
|
-
}
|
|
8077
|
+
}
|
|
7989
8078
|
|
|
7990
|
-
|
|
8079
|
+
getItemNodeFromIndex(index) {
|
|
7991
8080
|
return this.props.environment.document.getElementById(this.getItemId(index));
|
|
7992
|
-
}
|
|
8081
|
+
}
|
|
7993
8082
|
|
|
7994
|
-
|
|
8083
|
+
scrollHighlightedItemIntoView() {
|
|
7995
8084
|
/* istanbul ignore else (react-native) */
|
|
7996
8085
|
{
|
|
7997
|
-
|
|
8086
|
+
const node = this.getItemNodeFromIndex(this.getState().highlightedIndex);
|
|
7998
8087
|
this.props.scrollIntoView(node, this._menuNode);
|
|
7999
8088
|
}
|
|
8000
|
-
}
|
|
8001
|
-
|
|
8002
|
-
_proto.moveHighlightedIndex = function moveHighlightedIndex(amount, otherStateToSet) {
|
|
8003
|
-
var _this6 = this;
|
|
8004
|
-
|
|
8005
|
-
var itemCount = this.getItemCount();
|
|
8089
|
+
}
|
|
8006
8090
|
|
|
8007
|
-
|
|
8008
|
-
|
|
8091
|
+
moveHighlightedIndex(amount, otherStateToSet) {
|
|
8092
|
+
const itemCount = this.getItemCount();
|
|
8093
|
+
const {
|
|
8094
|
+
highlightedIndex
|
|
8095
|
+
} = this.getState();
|
|
8009
8096
|
|
|
8010
8097
|
if (itemCount > 0) {
|
|
8011
|
-
|
|
8012
|
-
return _this6.getItemNodeFromIndex(index);
|
|
8013
|
-
});
|
|
8098
|
+
const nextHighlightedIndex = getNextWrappingIndex(amount, highlightedIndex, itemCount, index => this.getItemNodeFromIndex(index));
|
|
8014
8099
|
this.setHighlightedIndex(nextHighlightedIndex, otherStateToSet);
|
|
8015
8100
|
}
|
|
8016
|
-
}
|
|
8101
|
+
}
|
|
8017
8102
|
|
|
8018
|
-
|
|
8019
|
-
|
|
8020
|
-
|
|
8021
|
-
|
|
8022
|
-
|
|
8023
|
-
|
|
8024
|
-
|
|
8025
|
-
|
|
8026
|
-
|
|
8027
|
-
|
|
8028
|
-
|
|
8029
|
-
|
|
8030
|
-
|
|
8031
|
-
|
|
8032
|
-
|
|
8033
|
-
|
|
8034
|
-
|
|
8035
|
-
|
|
8036
|
-
|
|
8037
|
-
|
|
8038
|
-
|
|
8039
|
-
|
|
8040
|
-
|
|
8041
|
-
|
|
8042
|
-
|
|
8043
|
-
|
|
8044
|
-
|
|
8045
|
-
|
|
8103
|
+
getStateAndHelpers() {
|
|
8104
|
+
const {
|
|
8105
|
+
highlightedIndex,
|
|
8106
|
+
inputValue,
|
|
8107
|
+
selectedItem,
|
|
8108
|
+
isOpen
|
|
8109
|
+
} = this.getState();
|
|
8110
|
+
const {
|
|
8111
|
+
itemToString
|
|
8112
|
+
} = this.props;
|
|
8113
|
+
const {
|
|
8114
|
+
id
|
|
8115
|
+
} = this;
|
|
8116
|
+
const {
|
|
8117
|
+
getRootProps,
|
|
8118
|
+
getToggleButtonProps,
|
|
8119
|
+
getLabelProps,
|
|
8120
|
+
getMenuProps,
|
|
8121
|
+
getInputProps,
|
|
8122
|
+
getItemProps,
|
|
8123
|
+
openMenu,
|
|
8124
|
+
closeMenu,
|
|
8125
|
+
toggleMenu,
|
|
8126
|
+
selectItem,
|
|
8127
|
+
selectItemAtIndex,
|
|
8128
|
+
selectHighlightedItem,
|
|
8129
|
+
setHighlightedIndex,
|
|
8130
|
+
clearSelection,
|
|
8131
|
+
clearItems,
|
|
8132
|
+
reset,
|
|
8133
|
+
setItemCount,
|
|
8134
|
+
unsetItemCount,
|
|
8135
|
+
internalSetState: setState
|
|
8136
|
+
} = this;
|
|
8046
8137
|
return {
|
|
8047
8138
|
// prop getters
|
|
8048
|
-
getRootProps
|
|
8049
|
-
getToggleButtonProps
|
|
8050
|
-
getLabelProps
|
|
8051
|
-
getMenuProps
|
|
8052
|
-
getInputProps
|
|
8053
|
-
getItemProps
|
|
8139
|
+
getRootProps,
|
|
8140
|
+
getToggleButtonProps,
|
|
8141
|
+
getLabelProps,
|
|
8142
|
+
getMenuProps,
|
|
8143
|
+
getInputProps,
|
|
8144
|
+
getItemProps,
|
|
8054
8145
|
// actions
|
|
8055
|
-
reset
|
|
8056
|
-
openMenu
|
|
8057
|
-
closeMenu
|
|
8058
|
-
toggleMenu
|
|
8059
|
-
selectItem
|
|
8060
|
-
selectItemAtIndex
|
|
8061
|
-
selectHighlightedItem
|
|
8062
|
-
setHighlightedIndex
|
|
8063
|
-
clearSelection
|
|
8064
|
-
clearItems
|
|
8065
|
-
setItemCount
|
|
8066
|
-
unsetItemCount
|
|
8067
|
-
setState
|
|
8146
|
+
reset,
|
|
8147
|
+
openMenu,
|
|
8148
|
+
closeMenu,
|
|
8149
|
+
toggleMenu,
|
|
8150
|
+
selectItem,
|
|
8151
|
+
selectItemAtIndex,
|
|
8152
|
+
selectHighlightedItem,
|
|
8153
|
+
setHighlightedIndex,
|
|
8154
|
+
clearSelection,
|
|
8155
|
+
clearItems,
|
|
8156
|
+
setItemCount,
|
|
8157
|
+
unsetItemCount,
|
|
8158
|
+
setState,
|
|
8068
8159
|
// props
|
|
8069
|
-
itemToString
|
|
8160
|
+
itemToString,
|
|
8070
8161
|
// derived
|
|
8071
|
-
id
|
|
8162
|
+
id,
|
|
8072
8163
|
// state
|
|
8073
|
-
highlightedIndex
|
|
8074
|
-
inputValue
|
|
8075
|
-
isOpen
|
|
8076
|
-
selectedItem
|
|
8164
|
+
highlightedIndex,
|
|
8165
|
+
inputValue,
|
|
8166
|
+
isOpen,
|
|
8167
|
+
selectedItem
|
|
8077
8168
|
};
|
|
8078
8169
|
} //////////////////////////// ROOT
|
|
8079
|
-
;
|
|
8080
8170
|
|
|
8081
|
-
_proto.componentDidMount = function componentDidMount() {
|
|
8082
|
-
var _this7 = this;
|
|
8083
8171
|
|
|
8172
|
+
componentDidMount() {
|
|
8084
8173
|
/* istanbul ignore if (react-native) */
|
|
8085
8174
|
if (process.env.NODE_ENV !== 'production' && !false && this.getMenuProps.called && !this.getMenuProps.suppressRefError) {
|
|
8086
8175
|
validateGetMenuPropsCalledCorrectly(this._menuNode, this.getMenuProps);
|
|
@@ -8094,22 +8183,20 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
8094
8183
|
// down long enough for the list to disappear (because the blur event fires on the input)
|
|
8095
8184
|
// this.isMouseDown is used in the blur handler on the input to determine whether the blur event should
|
|
8096
8185
|
// trigger hiding the menu.
|
|
8097
|
-
|
|
8098
|
-
|
|
8186
|
+
const onMouseDown = () => {
|
|
8187
|
+
this.isMouseDown = true;
|
|
8099
8188
|
};
|
|
8100
8189
|
|
|
8101
|
-
|
|
8102
|
-
|
|
8190
|
+
const onMouseUp = event => {
|
|
8191
|
+
this.isMouseDown = false; // if the target element or the activeElement is within a downshift node
|
|
8103
8192
|
// then we don't want to reset downshift
|
|
8104
8193
|
|
|
8105
|
-
|
|
8194
|
+
const contextWithinDownshift = targetWithinDownshift(event.target, [this._rootNode, this._menuNode], this.props.environment);
|
|
8106
8195
|
|
|
8107
|
-
if (!contextWithinDownshift &&
|
|
8108
|
-
|
|
8196
|
+
if (!contextWithinDownshift && this.getState().isOpen) {
|
|
8197
|
+
this.reset({
|
|
8109
8198
|
type: mouseUp
|
|
8110
|
-
},
|
|
8111
|
-
return _this7.props.onOuterClick(_this7.getStateAndHelpers());
|
|
8112
|
-
});
|
|
8199
|
+
}, () => this.props.onOuterClick(this.getStateAndHelpers()));
|
|
8113
8200
|
}
|
|
8114
8201
|
}; // Touching an element in iOS gives focus and hover states, but touching out of
|
|
8115
8202
|
// the element will remove hover, and persist the focus state, resulting in the
|
|
@@ -8119,38 +8206,36 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
8119
8206
|
// but not if the user is swiping
|
|
8120
8207
|
|
|
8121
8208
|
|
|
8122
|
-
|
|
8123
|
-
|
|
8209
|
+
const onTouchStart = () => {
|
|
8210
|
+
this.isTouchMove = false;
|
|
8124
8211
|
};
|
|
8125
8212
|
|
|
8126
|
-
|
|
8127
|
-
|
|
8213
|
+
const onTouchMove = () => {
|
|
8214
|
+
this.isTouchMove = true;
|
|
8128
8215
|
};
|
|
8129
8216
|
|
|
8130
|
-
|
|
8131
|
-
|
|
8217
|
+
const onTouchEnd = event => {
|
|
8218
|
+
const contextWithinDownshift = targetWithinDownshift(event.target, [this._rootNode, this._menuNode], this.props.environment, false);
|
|
8132
8219
|
|
|
8133
|
-
if (!
|
|
8134
|
-
|
|
8220
|
+
if (!this.isTouchMove && !contextWithinDownshift && this.getState().isOpen) {
|
|
8221
|
+
this.reset({
|
|
8135
8222
|
type: touchEnd
|
|
8136
|
-
},
|
|
8137
|
-
return _this7.props.onOuterClick(_this7.getStateAndHelpers());
|
|
8138
|
-
});
|
|
8223
|
+
}, () => this.props.onOuterClick(this.getStateAndHelpers()));
|
|
8139
8224
|
}
|
|
8140
8225
|
};
|
|
8141
8226
|
|
|
8142
|
-
|
|
8227
|
+
const {
|
|
8228
|
+
environment
|
|
8229
|
+
} = this.props;
|
|
8143
8230
|
environment.addEventListener('mousedown', onMouseDown);
|
|
8144
8231
|
environment.addEventListener('mouseup', onMouseUp);
|
|
8145
8232
|
environment.addEventListener('touchstart', onTouchStart);
|
|
8146
8233
|
environment.addEventListener('touchmove', onTouchMove);
|
|
8147
8234
|
environment.addEventListener('touchend', onTouchEnd);
|
|
8148
8235
|
|
|
8149
|
-
this.cleanup =
|
|
8150
|
-
|
|
8151
|
-
|
|
8152
|
-
_this7.updateStatus.cancel();
|
|
8153
|
-
|
|
8236
|
+
this.cleanup = () => {
|
|
8237
|
+
this.internalClearTimeouts();
|
|
8238
|
+
this.updateStatus.cancel();
|
|
8154
8239
|
environment.removeEventListener('mousedown', onMouseDown);
|
|
8155
8240
|
environment.removeEventListener('mouseup', onMouseUp);
|
|
8156
8241
|
environment.removeEventListener('touchstart', onTouchStart);
|
|
@@ -8158,21 +8243,21 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
8158
8243
|
environment.removeEventListener('touchend', onTouchEnd);
|
|
8159
8244
|
};
|
|
8160
8245
|
}
|
|
8161
|
-
}
|
|
8162
|
-
|
|
8163
|
-
_proto.shouldScroll = function shouldScroll(prevState, prevProps) {
|
|
8164
|
-
var _ref10 = this.props.highlightedIndex === undefined ? this.getState() : this.props,
|
|
8165
|
-
currentHighlightedIndex = _ref10.highlightedIndex;
|
|
8166
|
-
|
|
8167
|
-
var _ref11 = prevProps.highlightedIndex === undefined ? prevState : prevProps,
|
|
8168
|
-
prevHighlightedIndex = _ref11.highlightedIndex;
|
|
8246
|
+
}
|
|
8169
8247
|
|
|
8170
|
-
|
|
8171
|
-
|
|
8248
|
+
shouldScroll(prevState, prevProps) {
|
|
8249
|
+
const {
|
|
8250
|
+
highlightedIndex: currentHighlightedIndex
|
|
8251
|
+
} = this.props.highlightedIndex === undefined ? this.getState() : this.props;
|
|
8252
|
+
const {
|
|
8253
|
+
highlightedIndex: prevHighlightedIndex
|
|
8254
|
+
} = prevProps.highlightedIndex === undefined ? prevState : prevProps;
|
|
8255
|
+
const scrollWhenOpen = currentHighlightedIndex && this.getState().isOpen && !prevState.isOpen;
|
|
8256
|
+
const scrollWhenNavigating = currentHighlightedIndex !== prevHighlightedIndex;
|
|
8172
8257
|
return scrollWhenOpen || scrollWhenNavigating;
|
|
8173
|
-
}
|
|
8258
|
+
}
|
|
8174
8259
|
|
|
8175
|
-
|
|
8260
|
+
componentDidUpdate(prevProps, prevState) {
|
|
8176
8261
|
if (process.env.NODE_ENV !== 'production') {
|
|
8177
8262
|
validateControlledUnchanged(this.state, prevProps, this.props);
|
|
8178
8263
|
/* istanbul ignore if (react-native) */
|
|
@@ -8198,14 +8283,14 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
8198
8283
|
{
|
|
8199
8284
|
this.updateStatus();
|
|
8200
8285
|
}
|
|
8201
|
-
}
|
|
8286
|
+
}
|
|
8202
8287
|
|
|
8203
|
-
|
|
8288
|
+
componentWillUnmount() {
|
|
8204
8289
|
this.cleanup(); // avoids memory leak
|
|
8205
|
-
}
|
|
8290
|
+
}
|
|
8206
8291
|
|
|
8207
|
-
|
|
8208
|
-
|
|
8292
|
+
render() {
|
|
8293
|
+
const children = unwrapArray(this.props.children, noop); // because the items are rerendered every time we call the children
|
|
8209
8294
|
// we clear this out each render and it will be populated again as
|
|
8210
8295
|
// getItemProps is called.
|
|
8211
8296
|
|
|
@@ -8225,7 +8310,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
8225
8310
|
this.getLabelProps.called = false; // and something similar for getInputProps
|
|
8226
8311
|
|
|
8227
8312
|
this.getInputProps.called = false;
|
|
8228
|
-
|
|
8313
|
+
const element = unwrapArray(children(this.getStateAndHelpers()));
|
|
8229
8314
|
|
|
8230
8315
|
if (!element) {
|
|
8231
8316
|
return null;
|
|
@@ -8254,16 +8339,15 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
8254
8339
|
|
|
8255
8340
|
|
|
8256
8341
|
return undefined;
|
|
8257
|
-
}
|
|
8342
|
+
}
|
|
8258
8343
|
|
|
8259
|
-
|
|
8260
|
-
}(Component);
|
|
8344
|
+
}
|
|
8261
8345
|
|
|
8262
8346
|
Downshift.defaultProps = {
|
|
8263
8347
|
defaultHighlightedIndex: null,
|
|
8264
8348
|
defaultIsOpen: false,
|
|
8265
8349
|
getA11yStatusMessage: getA11yStatusMessage$1,
|
|
8266
|
-
itemToString:
|
|
8350
|
+
itemToString: i => {
|
|
8267
8351
|
if (i == null) {
|
|
8268
8352
|
return '';
|
|
8269
8353
|
}
|
|
@@ -8281,21 +8365,17 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
8281
8365
|
onChange: noop,
|
|
8282
8366
|
onSelect: noop,
|
|
8283
8367
|
onOuterClick: noop,
|
|
8284
|
-
selectedItemChanged:
|
|
8285
|
-
|
|
8286
|
-
},
|
|
8287
|
-
environment: typeof window === 'undefined'
|
|
8368
|
+
selectedItemChanged: (prevItem, item) => prevItem !== item,
|
|
8369
|
+
environment:
|
|
8288
8370
|
/* istanbul ignore next (ssr) */
|
|
8289
|
-
? {} : window,
|
|
8290
|
-
stateReducer:
|
|
8291
|
-
return stateToSet;
|
|
8292
|
-
},
|
|
8371
|
+
typeof window === 'undefined' ? {} : window,
|
|
8372
|
+
stateReducer: (state, stateToSet) => stateToSet,
|
|
8293
8373
|
suppressRefError: false,
|
|
8294
|
-
scrollIntoView
|
|
8374
|
+
scrollIntoView
|
|
8295
8375
|
};
|
|
8296
8376
|
Downshift.stateChangeTypes = stateChangeTypes$3;
|
|
8297
8377
|
return Downshift;
|
|
8298
|
-
}();
|
|
8378
|
+
})();
|
|
8299
8379
|
|
|
8300
8380
|
process.env.NODE_ENV !== "production" ? Downshift.propTypes = {
|
|
8301
8381
|
children: propTypes.func,
|
|
@@ -8343,36 +8423,41 @@ process.env.NODE_ENV !== "production" ? Downshift.propTypes = {
|
|
|
8343
8423
|
/* eslint-enable react/no-unused-prop-types */
|
|
8344
8424
|
|
|
8345
8425
|
} : void 0;
|
|
8426
|
+
var Downshift$1 = Downshift;
|
|
8346
8427
|
|
|
8347
|
-
function validateGetMenuPropsCalledCorrectly(node,
|
|
8348
|
-
|
|
8428
|
+
function validateGetMenuPropsCalledCorrectly(node, _ref3) {
|
|
8429
|
+
let {
|
|
8430
|
+
refKey
|
|
8431
|
+
} = _ref3;
|
|
8349
8432
|
|
|
8350
8433
|
if (!node) {
|
|
8351
8434
|
// eslint-disable-next-line no-console
|
|
8352
|
-
console.error(
|
|
8435
|
+
console.error(`downshift: The ref prop "${refKey}" from getMenuProps was not applied correctly on your menu element.`);
|
|
8353
8436
|
}
|
|
8354
8437
|
}
|
|
8355
8438
|
|
|
8356
|
-
function validateGetRootPropsCalledCorrectly(element,
|
|
8357
|
-
|
|
8358
|
-
|
|
8359
|
-
|
|
8439
|
+
function validateGetRootPropsCalledCorrectly(element, _ref4) {
|
|
8440
|
+
let {
|
|
8441
|
+
refKey
|
|
8442
|
+
} = _ref4;
|
|
8443
|
+
const refKeySpecified = refKey !== 'ref';
|
|
8444
|
+
const isComposite = !isDOMElement(element);
|
|
8360
8445
|
|
|
8361
8446
|
if (isComposite && !refKeySpecified && !reactIs_3(element)) {
|
|
8362
8447
|
// eslint-disable-next-line no-console
|
|
8363
8448
|
console.error('downshift: You returned a non-DOM element. You must specify a refKey in getRootProps');
|
|
8364
8449
|
} else if (!isComposite && refKeySpecified) {
|
|
8365
8450
|
// eslint-disable-next-line no-console
|
|
8366
|
-
console.error(
|
|
8451
|
+
console.error(`downshift: You returned a DOM element. You should not specify a refKey in getRootProps. You specified "${refKey}"`);
|
|
8367
8452
|
}
|
|
8368
8453
|
|
|
8369
8454
|
if (!reactIs_3(element) && !getElementProps(element)[refKey]) {
|
|
8370
8455
|
// eslint-disable-next-line no-console
|
|
8371
|
-
console.error(
|
|
8456
|
+
console.error(`downshift: You must apply the ref prop "${refKey}" from getRootProps onto your root element.`);
|
|
8372
8457
|
}
|
|
8373
8458
|
}
|
|
8374
8459
|
|
|
8375
|
-
|
|
8460
|
+
const dropdownDefaultStateValues = {
|
|
8376
8461
|
highlightedIndex: -1,
|
|
8377
8462
|
isOpen: false,
|
|
8378
8463
|
selectedItem: null,
|
|
@@ -8380,10 +8465,12 @@ var dropdownDefaultStateValues = {
|
|
|
8380
8465
|
};
|
|
8381
8466
|
|
|
8382
8467
|
function callOnChangeProps(action, state, newState) {
|
|
8383
|
-
|
|
8384
|
-
|
|
8385
|
-
|
|
8386
|
-
|
|
8468
|
+
const {
|
|
8469
|
+
props,
|
|
8470
|
+
type
|
|
8471
|
+
} = action;
|
|
8472
|
+
const changes = {};
|
|
8473
|
+
Object.keys(state).forEach(key => {
|
|
8387
8474
|
invokeOnChangeHandler(key, action, state, newState);
|
|
8388
8475
|
|
|
8389
8476
|
if (newState[key] !== state[key]) {
|
|
@@ -8392,21 +8479,25 @@ function callOnChangeProps(action, state, newState) {
|
|
|
8392
8479
|
});
|
|
8393
8480
|
|
|
8394
8481
|
if (props.onStateChange && Object.keys(changes).length) {
|
|
8395
|
-
props.onStateChange(
|
|
8396
|
-
type
|
|
8397
|
-
|
|
8482
|
+
props.onStateChange({
|
|
8483
|
+
type,
|
|
8484
|
+
...changes
|
|
8485
|
+
});
|
|
8398
8486
|
}
|
|
8399
8487
|
}
|
|
8400
8488
|
|
|
8401
8489
|
function invokeOnChangeHandler(key, action, state, newState) {
|
|
8402
|
-
|
|
8403
|
-
|
|
8404
|
-
|
|
8490
|
+
const {
|
|
8491
|
+
props,
|
|
8492
|
+
type
|
|
8493
|
+
} = action;
|
|
8494
|
+
const handler = `on${capitalizeString(key)}Change`;
|
|
8405
8495
|
|
|
8406
8496
|
if (props[handler] && newState[key] !== undefined && newState[key] !== state[key]) {
|
|
8407
|
-
props[handler](
|
|
8408
|
-
type
|
|
8409
|
-
|
|
8497
|
+
props[handler]({
|
|
8498
|
+
type,
|
|
8499
|
+
...newState
|
|
8500
|
+
});
|
|
8410
8501
|
}
|
|
8411
8502
|
}
|
|
8412
8503
|
/**
|
|
@@ -8430,37 +8521,38 @@ function stateReducer(s, a) {
|
|
|
8430
8521
|
|
|
8431
8522
|
|
|
8432
8523
|
function getA11ySelectionMessage(selectionParameters) {
|
|
8433
|
-
|
|
8434
|
-
|
|
8435
|
-
|
|
8524
|
+
const {
|
|
8525
|
+
selectedItem,
|
|
8526
|
+
itemToString: itemToStringLocal
|
|
8527
|
+
} = selectionParameters;
|
|
8528
|
+
return selectedItem ? `${itemToStringLocal(selectedItem)} has been selected.` : '';
|
|
8436
8529
|
}
|
|
8437
8530
|
/**
|
|
8438
8531
|
* Debounced call for updating the a11y message.
|
|
8439
8532
|
*/
|
|
8440
8533
|
|
|
8441
8534
|
|
|
8442
|
-
|
|
8535
|
+
const updateA11yStatus = debounce$1((getA11yMessage, document) => {
|
|
8443
8536
|
setStatus(getA11yMessage(), document);
|
|
8444
8537
|
}, 200); // istanbul ignore next
|
|
8445
8538
|
|
|
8446
|
-
|
|
8539
|
+
const useIsomorphicLayoutEffect = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined' ? useLayoutEffect : useEffect;
|
|
8447
8540
|
|
|
8448
8541
|
function useElementIds(_ref) {
|
|
8449
|
-
|
|
8450
|
-
|
|
8451
|
-
|
|
8452
|
-
|
|
8453
|
-
|
|
8454
|
-
|
|
8455
|
-
|
|
8456
|
-
|
|
8457
|
-
|
|
8458
|
-
|
|
8459
|
-
|
|
8460
|
-
|
|
8461
|
-
}
|
|
8462
|
-
|
|
8463
|
-
inputId: inputId || id + "-input"
|
|
8542
|
+
let {
|
|
8543
|
+
id = `downshift-${generateId()}`,
|
|
8544
|
+
labelId,
|
|
8545
|
+
menuId,
|
|
8546
|
+
getItemId,
|
|
8547
|
+
toggleButtonId,
|
|
8548
|
+
inputId
|
|
8549
|
+
} = _ref;
|
|
8550
|
+
const elementIdsRef = useRef({
|
|
8551
|
+
labelId: labelId || `${id}-label`,
|
|
8552
|
+
menuId: menuId || `${id}-menu`,
|
|
8553
|
+
getItemId: getItemId || (index => `${id}-item-${index}`),
|
|
8554
|
+
toggleButtonId: toggleButtonId || `${id}-toggle-button`,
|
|
8555
|
+
inputId: inputId || `${id}-input`
|
|
8464
8556
|
});
|
|
8465
8557
|
return elementIdsRef.current;
|
|
8466
8558
|
}
|
|
@@ -8482,11 +8574,11 @@ function itemToString(item) {
|
|
|
8482
8574
|
}
|
|
8483
8575
|
|
|
8484
8576
|
function capitalizeString(string) {
|
|
8485
|
-
return
|
|
8577
|
+
return `${string.slice(0, 1).toUpperCase()}${string.slice(1)}`;
|
|
8486
8578
|
}
|
|
8487
8579
|
|
|
8488
8580
|
function useLatestRef(val) {
|
|
8489
|
-
|
|
8581
|
+
const ref = useRef(val); // technically this is not "concurrent mode safe" because we're manipulating
|
|
8490
8582
|
// the value during render (so it's not idempotent). However, the places this
|
|
8491
8583
|
// hook is used is to support memoizing callbacks which will be called
|
|
8492
8584
|
// *during* render, so we need the latest values *during* render.
|
|
@@ -8508,30 +8600,25 @@ function useLatestRef(val) {
|
|
|
8508
8600
|
|
|
8509
8601
|
|
|
8510
8602
|
function useEnhancedReducer(reducer, initialState, props) {
|
|
8511
|
-
|
|
8512
|
-
|
|
8513
|
-
|
|
8603
|
+
const prevStateRef = useRef();
|
|
8604
|
+
const actionRef = useRef();
|
|
8605
|
+
const enhancedReducer = useCallback((state, action) => {
|
|
8514
8606
|
actionRef.current = action;
|
|
8515
8607
|
state = getState(state, action.props);
|
|
8516
|
-
|
|
8517
|
-
|
|
8518
|
-
changes
|
|
8519
|
-
})
|
|
8608
|
+
const changes = reducer(state, action);
|
|
8609
|
+
const newState = action.props.stateReducer(state, { ...action,
|
|
8610
|
+
changes
|
|
8611
|
+
});
|
|
8520
8612
|
return newState;
|
|
8521
8613
|
}, [reducer]);
|
|
8522
|
-
|
|
8523
|
-
|
|
8524
|
-
|
|
8525
|
-
|
|
8526
|
-
|
|
8527
|
-
|
|
8528
|
-
|
|
8529
|
-
|
|
8530
|
-
props: propsRef.current
|
|
8531
|
-
}, action));
|
|
8532
|
-
}, [propsRef]);
|
|
8533
|
-
var action = actionRef.current;
|
|
8534
|
-
useEffect(function () {
|
|
8614
|
+
const [state, dispatch] = useReducer(enhancedReducer, initialState);
|
|
8615
|
+
const propsRef = useLatestRef(props);
|
|
8616
|
+
const dispatchWithProps = useCallback(action => dispatch({
|
|
8617
|
+
props: propsRef.current,
|
|
8618
|
+
...action
|
|
8619
|
+
}), [propsRef]);
|
|
8620
|
+
const action = actionRef.current;
|
|
8621
|
+
useEffect(() => {
|
|
8535
8622
|
if (action && prevStateRef.current && prevStateRef.current !== state) {
|
|
8536
8623
|
callOnChangeProps(action, getState(prevStateRef.current, action.props), state);
|
|
8537
8624
|
}
|
|
@@ -8541,15 +8628,15 @@ function useEnhancedReducer(reducer, initialState, props) {
|
|
|
8541
8628
|
return [state, dispatchWithProps];
|
|
8542
8629
|
}
|
|
8543
8630
|
|
|
8544
|
-
|
|
8545
|
-
itemToString
|
|
8546
|
-
stateReducer
|
|
8547
|
-
getA11ySelectionMessage
|
|
8548
|
-
scrollIntoView
|
|
8631
|
+
const defaultProps$3 = {
|
|
8632
|
+
itemToString,
|
|
8633
|
+
stateReducer,
|
|
8634
|
+
getA11ySelectionMessage,
|
|
8635
|
+
scrollIntoView,
|
|
8549
8636
|
circularNavigation: false,
|
|
8550
|
-
environment:
|
|
8637
|
+
environment:
|
|
8551
8638
|
/* istanbul ignore next (ssr) */
|
|
8552
|
-
? {} : window
|
|
8639
|
+
typeof window === 'undefined' ? {} : window
|
|
8553
8640
|
};
|
|
8554
8641
|
|
|
8555
8642
|
function getDefaultValue$1(props, propKey, defaultStateValues) {
|
|
@@ -8557,10 +8644,10 @@ function getDefaultValue$1(props, propKey, defaultStateValues) {
|
|
|
8557
8644
|
defaultStateValues = dropdownDefaultStateValues;
|
|
8558
8645
|
}
|
|
8559
8646
|
|
|
8560
|
-
|
|
8647
|
+
const defaultValue = props[`default${capitalizeString(propKey)}`];
|
|
8561
8648
|
|
|
8562
|
-
if (
|
|
8563
|
-
return
|
|
8649
|
+
if (defaultValue !== undefined) {
|
|
8650
|
+
return defaultValue;
|
|
8564
8651
|
}
|
|
8565
8652
|
|
|
8566
8653
|
return defaultStateValues[propKey];
|
|
@@ -8571,38 +8658,44 @@ function getInitialValue$1(props, propKey, defaultStateValues) {
|
|
|
8571
8658
|
defaultStateValues = dropdownDefaultStateValues;
|
|
8572
8659
|
}
|
|
8573
8660
|
|
|
8574
|
-
|
|
8575
|
-
|
|
8661
|
+
const value = props[propKey];
|
|
8662
|
+
|
|
8663
|
+
if (value !== undefined) {
|
|
8664
|
+
return value;
|
|
8576
8665
|
}
|
|
8577
8666
|
|
|
8578
|
-
|
|
8667
|
+
const initialValue = props[`initial${capitalizeString(propKey)}`];
|
|
8579
8668
|
|
|
8580
|
-
if (
|
|
8581
|
-
return
|
|
8669
|
+
if (initialValue !== undefined) {
|
|
8670
|
+
return initialValue;
|
|
8582
8671
|
}
|
|
8583
8672
|
|
|
8584
8673
|
return getDefaultValue$1(props, propKey, defaultStateValues);
|
|
8585
8674
|
}
|
|
8586
8675
|
|
|
8587
8676
|
function getInitialState$2(props) {
|
|
8588
|
-
|
|
8589
|
-
|
|
8590
|
-
|
|
8591
|
-
|
|
8677
|
+
const selectedItem = getInitialValue$1(props, 'selectedItem');
|
|
8678
|
+
const isOpen = getInitialValue$1(props, 'isOpen');
|
|
8679
|
+
const highlightedIndex = getInitialValue$1(props, 'highlightedIndex');
|
|
8680
|
+
const inputValue = getInitialValue$1(props, 'inputValue');
|
|
8592
8681
|
return {
|
|
8593
8682
|
highlightedIndex: highlightedIndex < 0 && selectedItem && isOpen ? props.items.indexOf(selectedItem) : highlightedIndex,
|
|
8594
|
-
isOpen
|
|
8595
|
-
selectedItem
|
|
8596
|
-
inputValue
|
|
8683
|
+
isOpen,
|
|
8684
|
+
selectedItem,
|
|
8685
|
+
inputValue
|
|
8597
8686
|
};
|
|
8598
8687
|
}
|
|
8599
8688
|
|
|
8600
8689
|
function getHighlightedIndexOnOpen(props, state, offset, getItemNodeFromIndex) {
|
|
8601
|
-
|
|
8602
|
-
|
|
8603
|
-
|
|
8604
|
-
|
|
8605
|
-
|
|
8690
|
+
const {
|
|
8691
|
+
items,
|
|
8692
|
+
initialHighlightedIndex,
|
|
8693
|
+
defaultHighlightedIndex
|
|
8694
|
+
} = props;
|
|
8695
|
+
const {
|
|
8696
|
+
selectedItem,
|
|
8697
|
+
highlightedIndex
|
|
8698
|
+
} = state;
|
|
8606
8699
|
|
|
8607
8700
|
if (items.length === 0) {
|
|
8608
8701
|
return -1;
|
|
@@ -8643,39 +8736,35 @@ function getHighlightedIndexOnOpen(props, state, offset, getItemNodeFromIndex) {
|
|
|
8643
8736
|
|
|
8644
8737
|
|
|
8645
8738
|
function useMouseAndTouchTracker(isOpen, downshiftElementRefs, environment, handleBlur) {
|
|
8646
|
-
|
|
8739
|
+
const mouseAndTouchTrackersRef = useRef({
|
|
8647
8740
|
isMouseDown: false,
|
|
8648
8741
|
isTouchMove: false
|
|
8649
8742
|
});
|
|
8650
|
-
useEffect(
|
|
8743
|
+
useEffect(() => {
|
|
8651
8744
|
// The same strategy for checking if a click occurred inside or outside downsift
|
|
8652
8745
|
// as in downshift.js.
|
|
8653
|
-
|
|
8746
|
+
const onMouseDown = () => {
|
|
8654
8747
|
mouseAndTouchTrackersRef.current.isMouseDown = true;
|
|
8655
8748
|
};
|
|
8656
8749
|
|
|
8657
|
-
|
|
8750
|
+
const onMouseUp = event => {
|
|
8658
8751
|
mouseAndTouchTrackersRef.current.isMouseDown = false;
|
|
8659
8752
|
|
|
8660
|
-
if (isOpen && !targetWithinDownshift(event.target, downshiftElementRefs.map(
|
|
8661
|
-
return ref.current;
|
|
8662
|
-
}), environment)) {
|
|
8753
|
+
if (isOpen && !targetWithinDownshift(event.target, downshiftElementRefs.map(ref => ref.current), environment)) {
|
|
8663
8754
|
handleBlur();
|
|
8664
8755
|
}
|
|
8665
8756
|
};
|
|
8666
8757
|
|
|
8667
|
-
|
|
8758
|
+
const onTouchStart = () => {
|
|
8668
8759
|
mouseAndTouchTrackersRef.current.isTouchMove = false;
|
|
8669
8760
|
};
|
|
8670
8761
|
|
|
8671
|
-
|
|
8762
|
+
const onTouchMove = () => {
|
|
8672
8763
|
mouseAndTouchTrackersRef.current.isTouchMove = true;
|
|
8673
8764
|
};
|
|
8674
8765
|
|
|
8675
|
-
|
|
8676
|
-
if (isOpen && !mouseAndTouchTrackersRef.current.isTouchMove && !targetWithinDownshift(event.target, downshiftElementRefs.map(
|
|
8677
|
-
return ref.current;
|
|
8678
|
-
}), environment, false)) {
|
|
8766
|
+
const onTouchEnd = event => {
|
|
8767
|
+
if (isOpen && !mouseAndTouchTrackersRef.current.isTouchMove && !targetWithinDownshift(event.target, downshiftElementRefs.map(ref => ref.current), environment, false)) {
|
|
8679
8768
|
handleBlur();
|
|
8680
8769
|
}
|
|
8681
8770
|
};
|
|
@@ -8699,9 +8788,7 @@ function useMouseAndTouchTracker(isOpen, downshiftElementRefs, environment, hand
|
|
|
8699
8788
|
// eslint-disable-next-line import/no-mutable-exports
|
|
8700
8789
|
|
|
8701
8790
|
|
|
8702
|
-
|
|
8703
|
-
return noop;
|
|
8704
|
-
};
|
|
8791
|
+
let useGetterPropsCalledChecker = () => noop;
|
|
8705
8792
|
/**
|
|
8706
8793
|
* Custom hook that checks if getter props are called correctly.
|
|
8707
8794
|
*
|
|
@@ -8713,45 +8800,47 @@ var useGetterPropsCalledChecker = function useGetterPropsCalledChecker() {
|
|
|
8713
8800
|
|
|
8714
8801
|
|
|
8715
8802
|
if (process.env.NODE_ENV !== 'production') {
|
|
8716
|
-
useGetterPropsCalledChecker = function
|
|
8717
|
-
|
|
8803
|
+
useGetterPropsCalledChecker = function () {
|
|
8804
|
+
const isInitialMountRef = useRef(true);
|
|
8718
8805
|
|
|
8719
8806
|
for (var _len = arguments.length, propKeys = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
8720
8807
|
propKeys[_key] = arguments[_key];
|
|
8721
8808
|
}
|
|
8722
8809
|
|
|
8723
|
-
|
|
8810
|
+
const getterPropsCalledRef = useRef(propKeys.reduce((acc, propKey) => {
|
|
8724
8811
|
acc[propKey] = {};
|
|
8725
8812
|
return acc;
|
|
8726
8813
|
}, {}));
|
|
8727
|
-
useEffect(
|
|
8728
|
-
Object.keys(getterPropsCalledRef.current).forEach(
|
|
8729
|
-
|
|
8814
|
+
useEffect(() => {
|
|
8815
|
+
Object.keys(getterPropsCalledRef.current).forEach(propKey => {
|
|
8816
|
+
const propCallInfo = getterPropsCalledRef.current[propKey];
|
|
8730
8817
|
|
|
8731
8818
|
if (isInitialMountRef.current) {
|
|
8732
8819
|
if (!Object.keys(propCallInfo).length) {
|
|
8733
8820
|
// eslint-disable-next-line no-console
|
|
8734
|
-
console.error(
|
|
8821
|
+
console.error(`downshift: You forgot to call the ${propKey} getter function on your component / element.`);
|
|
8735
8822
|
return;
|
|
8736
8823
|
}
|
|
8737
8824
|
}
|
|
8738
8825
|
|
|
8739
|
-
|
|
8740
|
-
|
|
8741
|
-
|
|
8826
|
+
const {
|
|
8827
|
+
suppressRefError,
|
|
8828
|
+
refKey,
|
|
8829
|
+
elementRef
|
|
8830
|
+
} = propCallInfo;
|
|
8742
8831
|
|
|
8743
8832
|
if ((!elementRef || !elementRef.current) && !suppressRefError) {
|
|
8744
8833
|
// eslint-disable-next-line no-console
|
|
8745
|
-
console.error(
|
|
8834
|
+
console.error(`downshift: The ref prop "${refKey}" from ${propKey} was not applied correctly on your element.`);
|
|
8746
8835
|
}
|
|
8747
8836
|
});
|
|
8748
8837
|
isInitialMountRef.current = false;
|
|
8749
8838
|
});
|
|
8750
|
-
|
|
8839
|
+
const setGetterPropCallInfo = useCallback((propKey, suppressRefError, refKey, elementRef) => {
|
|
8751
8840
|
getterPropsCalledRef.current[propKey] = {
|
|
8752
|
-
suppressRefError
|
|
8753
|
-
refKey
|
|
8754
|
-
elementRef
|
|
8841
|
+
suppressRefError,
|
|
8842
|
+
refKey,
|
|
8843
|
+
elementRef
|
|
8755
8844
|
};
|
|
8756
8845
|
}, []);
|
|
8757
8846
|
return setGetterPropCallInfo;
|
|
@@ -8759,39 +8848,41 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
8759
8848
|
}
|
|
8760
8849
|
|
|
8761
8850
|
function useA11yMessageSetter(getA11yMessage, dependencyArray, _ref2) {
|
|
8762
|
-
|
|
8763
|
-
|
|
8764
|
-
|
|
8765
|
-
|
|
8766
|
-
|
|
8767
|
-
|
|
8851
|
+
let {
|
|
8852
|
+
isInitialMount,
|
|
8853
|
+
highlightedIndex,
|
|
8854
|
+
items,
|
|
8855
|
+
environment,
|
|
8856
|
+
...rest
|
|
8857
|
+
} = _ref2;
|
|
8768
8858
|
// Sets a11y status message on changes in state.
|
|
8769
|
-
useEffect(
|
|
8770
|
-
if (isInitialMount) {
|
|
8859
|
+
useEffect(() => {
|
|
8860
|
+
if (isInitialMount || false) {
|
|
8771
8861
|
return;
|
|
8772
8862
|
}
|
|
8773
8863
|
|
|
8774
|
-
updateA11yStatus(
|
|
8775
|
-
|
|
8776
|
-
|
|
8777
|
-
|
|
8778
|
-
|
|
8779
|
-
|
|
8780
|
-
}, environment.document); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
8864
|
+
updateA11yStatus(() => getA11yMessage({
|
|
8865
|
+
highlightedIndex,
|
|
8866
|
+
highlightedItem: items[highlightedIndex],
|
|
8867
|
+
resultCount: items.length,
|
|
8868
|
+
...rest
|
|
8869
|
+
}), environment.document); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
8781
8870
|
}, dependencyArray);
|
|
8782
8871
|
}
|
|
8783
8872
|
|
|
8784
8873
|
function useScrollIntoView(_ref3) {
|
|
8785
|
-
|
|
8786
|
-
|
|
8787
|
-
|
|
8788
|
-
|
|
8789
|
-
|
|
8790
|
-
|
|
8874
|
+
let {
|
|
8875
|
+
highlightedIndex,
|
|
8876
|
+
isOpen,
|
|
8877
|
+
itemRefs,
|
|
8878
|
+
getItemNodeFromIndex,
|
|
8879
|
+
menuElement,
|
|
8880
|
+
scrollIntoView: scrollIntoViewProp
|
|
8881
|
+
} = _ref3;
|
|
8791
8882
|
// used not to scroll on highlight by mouse.
|
|
8792
|
-
|
|
8883
|
+
const shouldScrollRef = useRef(true); // Scroll on highlighted item if change comes from keyboard.
|
|
8793
8884
|
|
|
8794
|
-
useIsomorphicLayoutEffect(
|
|
8885
|
+
useIsomorphicLayoutEffect(() => {
|
|
8795
8886
|
if (highlightedIndex < 0 || !isOpen || !Object.keys(itemRefs.current).length) {
|
|
8796
8887
|
return;
|
|
8797
8888
|
}
|
|
@@ -8807,17 +8898,19 @@ function useScrollIntoView(_ref3) {
|
|
|
8807
8898
|
} // eslint-disable-next-line import/no-mutable-exports
|
|
8808
8899
|
|
|
8809
8900
|
|
|
8810
|
-
|
|
8901
|
+
let useControlPropsValidator = noop;
|
|
8811
8902
|
/* istanbul ignore next */
|
|
8812
8903
|
|
|
8813
8904
|
if (process.env.NODE_ENV !== 'production') {
|
|
8814
|
-
useControlPropsValidator =
|
|
8815
|
-
|
|
8816
|
-
|
|
8817
|
-
|
|
8905
|
+
useControlPropsValidator = _ref4 => {
|
|
8906
|
+
let {
|
|
8907
|
+
isInitialMount,
|
|
8908
|
+
props,
|
|
8909
|
+
state
|
|
8910
|
+
} = _ref4;
|
|
8818
8911
|
// used for checking when props are moving from controlled to uncontrolled.
|
|
8819
|
-
|
|
8820
|
-
useEffect(
|
|
8912
|
+
const prevPropsRef = useRef(props);
|
|
8913
|
+
useEffect(() => {
|
|
8821
8914
|
if (isInitialMount) {
|
|
8822
8915
|
return;
|
|
8823
8916
|
}
|
|
@@ -8831,14 +8924,16 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
8831
8924
|
/* eslint-disable complexity */
|
|
8832
8925
|
|
|
8833
8926
|
function downshiftCommonReducer(state, action, stateChangeTypes) {
|
|
8834
|
-
|
|
8835
|
-
|
|
8836
|
-
|
|
8927
|
+
const {
|
|
8928
|
+
type,
|
|
8929
|
+
props
|
|
8930
|
+
} = action;
|
|
8931
|
+
let changes;
|
|
8837
8932
|
|
|
8838
8933
|
switch (type) {
|
|
8839
8934
|
case stateChangeTypes.ItemMouseMove:
|
|
8840
8935
|
changes = {
|
|
8841
|
-
highlightedIndex: action.index
|
|
8936
|
+
highlightedIndex: action.disabled ? -1 : action.index
|
|
8842
8937
|
};
|
|
8843
8938
|
break;
|
|
8844
8939
|
|
|
@@ -8894,43 +8989,44 @@ function downshiftCommonReducer(state, action, stateChangeTypes) {
|
|
|
8894
8989
|
throw new Error('Reducer called without proper action type.');
|
|
8895
8990
|
}
|
|
8896
8991
|
|
|
8897
|
-
return
|
|
8992
|
+
return { ...state,
|
|
8993
|
+
...changes
|
|
8994
|
+
};
|
|
8898
8995
|
}
|
|
8899
|
-
|
|
8900
8996
|
({
|
|
8901
|
-
|
|
8902
|
-
|
|
8903
|
-
|
|
8904
|
-
|
|
8905
|
-
|
|
8906
|
-
|
|
8907
|
-
|
|
8908
|
-
|
|
8909
|
-
|
|
8910
|
-
|
|
8911
|
-
|
|
8912
|
-
|
|
8913
|
-
|
|
8914
|
-
|
|
8915
|
-
|
|
8916
|
-
|
|
8917
|
-
|
|
8918
|
-
|
|
8919
|
-
|
|
8920
|
-
|
|
8921
|
-
|
|
8922
|
-
|
|
8923
|
-
|
|
8924
|
-
|
|
8925
|
-
|
|
8926
|
-
|
|
8927
|
-
|
|
8928
|
-
|
|
8929
|
-
|
|
8930
|
-
|
|
8931
|
-
|
|
8997
|
+
items: propTypes.array.isRequired,
|
|
8998
|
+
itemToString: propTypes.func,
|
|
8999
|
+
getA11yStatusMessage: propTypes.func,
|
|
9000
|
+
getA11ySelectionMessage: propTypes.func,
|
|
9001
|
+
circularNavigation: propTypes.bool,
|
|
9002
|
+
highlightedIndex: propTypes.number,
|
|
9003
|
+
defaultHighlightedIndex: propTypes.number,
|
|
9004
|
+
initialHighlightedIndex: propTypes.number,
|
|
9005
|
+
isOpen: propTypes.bool,
|
|
9006
|
+
defaultIsOpen: propTypes.bool,
|
|
9007
|
+
initialIsOpen: propTypes.bool,
|
|
9008
|
+
selectedItem: propTypes.any,
|
|
9009
|
+
initialSelectedItem: propTypes.any,
|
|
9010
|
+
defaultSelectedItem: propTypes.any,
|
|
9011
|
+
id: propTypes.string,
|
|
9012
|
+
labelId: propTypes.string,
|
|
9013
|
+
menuId: propTypes.string,
|
|
9014
|
+
getItemId: propTypes.func,
|
|
9015
|
+
toggleButtonId: propTypes.string,
|
|
9016
|
+
stateReducer: propTypes.func,
|
|
9017
|
+
onSelectedItemChange: propTypes.func,
|
|
9018
|
+
onHighlightedIndexChange: propTypes.func,
|
|
9019
|
+
onStateChange: propTypes.func,
|
|
9020
|
+
onIsOpenChange: propTypes.func,
|
|
9021
|
+
environment: propTypes.shape({
|
|
9022
|
+
addEventListener: propTypes.func,
|
|
9023
|
+
removeEventListener: propTypes.func,
|
|
9024
|
+
document: propTypes.shape({
|
|
9025
|
+
getElementById: propTypes.func,
|
|
9026
|
+
activeElement: propTypes.any,
|
|
9027
|
+
body: propTypes.any
|
|
9028
|
+
})
|
|
8932
9029
|
})
|
|
8933
|
-
})
|
|
8934
9030
|
});
|
|
8935
9031
|
/**
|
|
8936
9032
|
* Default implementation for status message. Only added when menu is open.
|
|
@@ -8940,32 +9036,21 @@ function downshiftCommonReducer(state, action, stateChangeTypes) {
|
|
|
8940
9036
|
* @param {Object} param the downshift state and other relevant properties
|
|
8941
9037
|
* @return {String} the a11y status message
|
|
8942
9038
|
*/
|
|
8943
|
-
|
|
8944
|
-
|
|
8945
|
-
|
|
8946
|
-
|
|
8947
|
-
|
|
8948
|
-
|
|
8949
|
-
|
|
9039
|
+
function getA11yStatusMessage(_a) {
|
|
9040
|
+
var isOpen = _a.isOpen, resultCount = _a.resultCount, previousResultCount = _a.previousResultCount;
|
|
9041
|
+
if (!isOpen) {
|
|
9042
|
+
return '';
|
|
9043
|
+
}
|
|
9044
|
+
if (!resultCount) {
|
|
9045
|
+
return 'No results are available.';
|
|
9046
|
+
}
|
|
9047
|
+
if (resultCount !== previousResultCount) {
|
|
9048
|
+
return "".concat(resultCount, " result").concat(resultCount === 1 ? ' is' : 's are', " available, use up and down arrow keys to navigate. Press Enter or Space Bar keys to select.");
|
|
9049
|
+
}
|
|
8950
9050
|
return '';
|
|
8951
|
-
}
|
|
8952
|
-
|
|
8953
|
-
if (!resultCount) {
|
|
8954
|
-
return 'No results are available.';
|
|
8955
|
-
}
|
|
8956
|
-
|
|
8957
|
-
if (resultCount !== previousResultCount) {
|
|
8958
|
-
return resultCount + " result" + (resultCount === 1 ? ' is' : 's are') + " available, use up and down arrow keys to navigate. Press Enter or Space Bar keys to select.";
|
|
8959
|
-
}
|
|
8960
|
-
|
|
8961
|
-
return '';
|
|
8962
9051
|
}
|
|
8963
|
-
|
|
8964
|
-
_extends({}, defaultProps$3, {
|
|
8965
|
-
getA11yStatusMessage: getA11yStatusMessage
|
|
8966
|
-
}); // eslint-disable-next-line import/no-mutable-exports
|
|
9052
|
+
__assign(__assign({}, defaultProps$3), { getA11yStatusMessage: getA11yStatusMessage });
|
|
8967
9053
|
/* istanbul ignore next */
|
|
8968
|
-
|
|
8969
9054
|
if (process.env.NODE_ENV !== 'production') ;
|
|
8970
9055
|
|
|
8971
9056
|
process.env.NODE_ENV !== "production" ? '__menu_keydown_arrow_down__' : 0;
|
|
@@ -8992,26 +9077,26 @@ process.env.NODE_ENV !== "production" ? '__function_select_item__' : 20;
|
|
|
8992
9077
|
process.env.NODE_ENV !== "production" ? '__function_set_input_value__' : 21;
|
|
8993
9078
|
process.env.NODE_ENV !== "production" ? '__function_reset__' : 22;
|
|
8994
9079
|
|
|
8995
|
-
|
|
8996
|
-
|
|
8997
|
-
|
|
8998
|
-
|
|
8999
|
-
|
|
9000
|
-
|
|
9001
|
-
|
|
9002
|
-
|
|
9003
|
-
|
|
9004
|
-
|
|
9005
|
-
|
|
9006
|
-
|
|
9007
|
-
|
|
9008
|
-
|
|
9009
|
-
|
|
9010
|
-
|
|
9011
|
-
|
|
9012
|
-
|
|
9013
|
-
|
|
9014
|
-
|
|
9080
|
+
const InputKeyDownArrowDown = process.env.NODE_ENV !== "production" ? '__input_keydown_arrow_down__' : 0;
|
|
9081
|
+
const InputKeyDownArrowUp = process.env.NODE_ENV !== "production" ? '__input_keydown_arrow_up__' : 1;
|
|
9082
|
+
const InputKeyDownEscape = process.env.NODE_ENV !== "production" ? '__input_keydown_escape__' : 2;
|
|
9083
|
+
const InputKeyDownHome = process.env.NODE_ENV !== "production" ? '__input_keydown_home__' : 3;
|
|
9084
|
+
const InputKeyDownEnd = process.env.NODE_ENV !== "production" ? '__input_keydown_end__' : 4;
|
|
9085
|
+
const InputKeyDownEnter = process.env.NODE_ENV !== "production" ? '__input_keydown_enter__' : 5;
|
|
9086
|
+
const InputChange = process.env.NODE_ENV !== "production" ? '__input_change__' : 6;
|
|
9087
|
+
const InputBlur = process.env.NODE_ENV !== "production" ? '__input_blur__' : 7;
|
|
9088
|
+
const MenuMouseLeave = process.env.NODE_ENV !== "production" ? '__menu_mouse_leave__' : 8;
|
|
9089
|
+
const ItemMouseMove = process.env.NODE_ENV !== "production" ? '__item_mouse_move__' : 9;
|
|
9090
|
+
const ItemClick = process.env.NODE_ENV !== "production" ? '__item_click__' : 10;
|
|
9091
|
+
const ToggleButtonClick = process.env.NODE_ENV !== "production" ? '__togglebutton_click__' : 11;
|
|
9092
|
+
const FunctionToggleMenu = process.env.NODE_ENV !== "production" ? '__function_toggle_menu__' : 12;
|
|
9093
|
+
const FunctionOpenMenu = process.env.NODE_ENV !== "production" ? '__function_open_menu__' : 13;
|
|
9094
|
+
const FunctionCloseMenu = process.env.NODE_ENV !== "production" ? '__function_close_menu__' : 14;
|
|
9095
|
+
const FunctionSetHighlightedIndex = process.env.NODE_ENV !== "production" ? '__function_set_highlighted_index__' : 15;
|
|
9096
|
+
const FunctionSelectItem = process.env.NODE_ENV !== "production" ? '__function_select_item__' : 16;
|
|
9097
|
+
const FunctionSetInputValue = process.env.NODE_ENV !== "production" ? '__function_set_input_value__' : 17;
|
|
9098
|
+
const FunctionReset$1 = process.env.NODE_ENV !== "production" ? '__function_reset__' : 18;
|
|
9099
|
+
const ControlledPropUpdatedSelectedItem = process.env.NODE_ENV !== "production" ? '__controlled_prop_updated_selected_item__' : 19;
|
|
9015
9100
|
|
|
9016
9101
|
var stateChangeTypes$1 = /*#__PURE__*/Object.freeze({
|
|
9017
9102
|
__proto__: null,
|
|
@@ -9038,20 +9123,24 @@ var stateChangeTypes$1 = /*#__PURE__*/Object.freeze({
|
|
|
9038
9123
|
});
|
|
9039
9124
|
|
|
9040
9125
|
function getInitialState$1(props) {
|
|
9041
|
-
|
|
9042
|
-
|
|
9043
|
-
|
|
9126
|
+
const initialState = getInitialState$2(props);
|
|
9127
|
+
const {
|
|
9128
|
+
selectedItem
|
|
9129
|
+
} = initialState;
|
|
9130
|
+
let {
|
|
9131
|
+
inputValue
|
|
9132
|
+
} = initialState;
|
|
9044
9133
|
|
|
9045
9134
|
if (inputValue === '' && selectedItem && props.defaultInputValue === undefined && props.initialInputValue === undefined && props.inputValue === undefined) {
|
|
9046
9135
|
inputValue = props.itemToString(selectedItem);
|
|
9047
9136
|
}
|
|
9048
9137
|
|
|
9049
|
-
return
|
|
9050
|
-
inputValue
|
|
9051
|
-
}
|
|
9138
|
+
return { ...initialState,
|
|
9139
|
+
inputValue
|
|
9140
|
+
};
|
|
9052
9141
|
}
|
|
9053
9142
|
|
|
9054
|
-
|
|
9143
|
+
const propTypes$1 = {
|
|
9055
9144
|
items: propTypes.array.isRequired,
|
|
9056
9145
|
itemToString: propTypes.func,
|
|
9057
9146
|
getA11yStatusMessage: propTypes.func,
|
|
@@ -9105,14 +9194,10 @@ var propTypes$1 = {
|
|
|
9105
9194
|
*/
|
|
9106
9195
|
|
|
9107
9196
|
function useControlledReducer(reducer, initialState, props) {
|
|
9108
|
-
|
|
9109
|
-
|
|
9110
|
-
var _useEnhancedReducer = useEnhancedReducer(reducer, initialState, props),
|
|
9111
|
-
state = _useEnhancedReducer[0],
|
|
9112
|
-
dispatch = _useEnhancedReducer[1]; // ToDo: if needed, make same approach as selectedItemChanged from Downshift.
|
|
9197
|
+
const previousSelectedItemRef = useRef();
|
|
9198
|
+
const [state, dispatch] = useEnhancedReducer(reducer, initialState, props); // ToDo: if needed, make same approach as selectedItemChanged from Downshift.
|
|
9113
9199
|
|
|
9114
|
-
|
|
9115
|
-
useEffect(function () {
|
|
9200
|
+
useEffect(() => {
|
|
9116
9201
|
if (isControlledProp(props, 'selectedItem')) {
|
|
9117
9202
|
if (previousSelectedItemRef.current !== props.selectedItem) {
|
|
9118
9203
|
dispatch({
|
|
@@ -9128,27 +9213,29 @@ function useControlledReducer(reducer, initialState, props) {
|
|
|
9128
9213
|
} // eslint-disable-next-line import/no-mutable-exports
|
|
9129
9214
|
|
|
9130
9215
|
|
|
9131
|
-
|
|
9216
|
+
let validatePropTypes$1 = noop;
|
|
9132
9217
|
/* istanbul ignore next */
|
|
9133
9218
|
|
|
9134
9219
|
if (process.env.NODE_ENV !== 'production') {
|
|
9135
|
-
validatePropTypes$1 =
|
|
9220
|
+
validatePropTypes$1 = (options, caller) => {
|
|
9136
9221
|
propTypes.checkPropTypes(propTypes$1, options, 'prop', caller.name);
|
|
9137
9222
|
};
|
|
9138
9223
|
}
|
|
9139
9224
|
|
|
9140
|
-
|
|
9225
|
+
const defaultProps$1 = { ...defaultProps$3,
|
|
9141
9226
|
getA11yStatusMessage: getA11yStatusMessage$1,
|
|
9142
9227
|
circularNavigation: true
|
|
9143
|
-
}
|
|
9228
|
+
};
|
|
9144
9229
|
|
|
9145
9230
|
/* eslint-disable complexity */
|
|
9146
9231
|
|
|
9147
9232
|
function downshiftUseComboboxReducer(state, action) {
|
|
9148
|
-
|
|
9149
|
-
|
|
9150
|
-
|
|
9151
|
-
|
|
9233
|
+
const {
|
|
9234
|
+
type,
|
|
9235
|
+
props,
|
|
9236
|
+
shiftKey
|
|
9237
|
+
} = action;
|
|
9238
|
+
let changes;
|
|
9152
9239
|
|
|
9153
9240
|
switch (type) {
|
|
9154
9241
|
case ItemClick:
|
|
@@ -9189,22 +9276,24 @@ function downshiftUseComboboxReducer(state, action) {
|
|
|
9189
9276
|
break;
|
|
9190
9277
|
|
|
9191
9278
|
case InputKeyDownEnter:
|
|
9192
|
-
changes =
|
|
9193
|
-
|
|
9194
|
-
|
|
9195
|
-
|
|
9196
|
-
|
|
9197
|
-
|
|
9279
|
+
changes = { ...(state.isOpen && state.highlightedIndex >= 0 && {
|
|
9280
|
+
selectedItem: props.items[state.highlightedIndex],
|
|
9281
|
+
isOpen: getDefaultValue$1(props, 'isOpen'),
|
|
9282
|
+
highlightedIndex: getDefaultValue$1(props, 'highlightedIndex'),
|
|
9283
|
+
inputValue: props.itemToString(props.items[state.highlightedIndex])
|
|
9284
|
+
})
|
|
9285
|
+
};
|
|
9198
9286
|
break;
|
|
9199
9287
|
|
|
9200
9288
|
case InputKeyDownEscape:
|
|
9201
|
-
changes =
|
|
9289
|
+
changes = {
|
|
9202
9290
|
isOpen: false,
|
|
9203
|
-
highlightedIndex: -1
|
|
9204
|
-
|
|
9205
|
-
|
|
9206
|
-
|
|
9207
|
-
|
|
9291
|
+
highlightedIndex: -1,
|
|
9292
|
+
...(!state.isOpen && {
|
|
9293
|
+
selectedItem: null,
|
|
9294
|
+
inputValue: ''
|
|
9295
|
+
})
|
|
9296
|
+
};
|
|
9208
9297
|
break;
|
|
9209
9298
|
|
|
9210
9299
|
case InputKeyDownHome:
|
|
@@ -9220,13 +9309,14 @@ function downshiftUseComboboxReducer(state, action) {
|
|
|
9220
9309
|
break;
|
|
9221
9310
|
|
|
9222
9311
|
case InputBlur:
|
|
9223
|
-
changes =
|
|
9312
|
+
changes = {
|
|
9224
9313
|
isOpen: false,
|
|
9225
|
-
highlightedIndex: -1
|
|
9226
|
-
|
|
9227
|
-
|
|
9228
|
-
|
|
9229
|
-
|
|
9314
|
+
highlightedIndex: -1,
|
|
9315
|
+
...(state.highlightedIndex >= 0 && action.selectItem && {
|
|
9316
|
+
selectedItem: props.items[state.highlightedIndex],
|
|
9317
|
+
inputValue: props.itemToString(props.items[state.highlightedIndex])
|
|
9318
|
+
})
|
|
9319
|
+
};
|
|
9230
9320
|
break;
|
|
9231
9321
|
|
|
9232
9322
|
case InputChange:
|
|
@@ -9254,10 +9344,13 @@ function downshiftUseComboboxReducer(state, action) {
|
|
|
9254
9344
|
return downshiftCommonReducer(state, action, stateChangeTypes$1);
|
|
9255
9345
|
}
|
|
9256
9346
|
|
|
9257
|
-
return
|
|
9347
|
+
return { ...state,
|
|
9348
|
+
...changes
|
|
9349
|
+
};
|
|
9258
9350
|
}
|
|
9259
9351
|
/* eslint-enable complexity */
|
|
9260
9352
|
|
|
9353
|
+
/* eslint-disable max-statements */
|
|
9261
9354
|
useCombobox.stateChangeTypes = stateChangeTypes$1;
|
|
9262
9355
|
|
|
9263
9356
|
function useCombobox(userProps) {
|
|
@@ -9267,87 +9360,88 @@ function useCombobox(userProps) {
|
|
|
9267
9360
|
|
|
9268
9361
|
validatePropTypes$1(userProps, useCombobox); // Props defaults and destructuring.
|
|
9269
9362
|
|
|
9270
|
-
|
|
9271
|
-
|
|
9272
|
-
|
|
9273
|
-
|
|
9274
|
-
|
|
9275
|
-
|
|
9276
|
-
|
|
9277
|
-
|
|
9278
|
-
|
|
9279
|
-
|
|
9280
|
-
|
|
9281
|
-
|
|
9282
|
-
|
|
9283
|
-
|
|
9284
|
-
|
|
9285
|
-
|
|
9286
|
-
|
|
9287
|
-
|
|
9288
|
-
|
|
9289
|
-
|
|
9290
|
-
|
|
9291
|
-
|
|
9292
|
-
|
|
9293
|
-
|
|
9294
|
-
|
|
9295
|
-
|
|
9296
|
-
|
|
9297
|
-
|
|
9298
|
-
|
|
9299
|
-
|
|
9300
|
-
|
|
9301
|
-
|
|
9302
|
-
|
|
9303
|
-
|
|
9304
|
-
|
|
9305
|
-
|
|
9363
|
+
const props = { ...defaultProps$1,
|
|
9364
|
+
...userProps
|
|
9365
|
+
};
|
|
9366
|
+
const {
|
|
9367
|
+
initialIsOpen,
|
|
9368
|
+
defaultIsOpen,
|
|
9369
|
+
items,
|
|
9370
|
+
scrollIntoView,
|
|
9371
|
+
environment,
|
|
9372
|
+
getA11yStatusMessage,
|
|
9373
|
+
getA11ySelectionMessage,
|
|
9374
|
+
itemToString
|
|
9375
|
+
} = props; // Initial state depending on controlled props.
|
|
9376
|
+
|
|
9377
|
+
const initialState = getInitialState$1(props);
|
|
9378
|
+
const [state, dispatch] = useControlledReducer(downshiftUseComboboxReducer, initialState, props);
|
|
9379
|
+
const {
|
|
9380
|
+
isOpen,
|
|
9381
|
+
highlightedIndex,
|
|
9382
|
+
selectedItem,
|
|
9383
|
+
inputValue
|
|
9384
|
+
} = state; // Element refs.
|
|
9385
|
+
|
|
9386
|
+
const menuRef = useRef(null);
|
|
9387
|
+
const itemRefs = useRef({});
|
|
9388
|
+
const inputRef = useRef(null);
|
|
9389
|
+
const toggleButtonRef = useRef(null);
|
|
9390
|
+
const comboboxRef = useRef(null);
|
|
9391
|
+
const isInitialMountRef = useRef(true); // prevent id re-generation between renders.
|
|
9392
|
+
|
|
9393
|
+
const elementIds = useElementIds(props); // used to keep track of how many items we had on previous cycle.
|
|
9394
|
+
|
|
9395
|
+
const previousResultCountRef = useRef(); // utility callback to get item element.
|
|
9396
|
+
|
|
9397
|
+
const latest = useLatestRef({
|
|
9398
|
+
state,
|
|
9399
|
+
props
|
|
9306
9400
|
});
|
|
9307
|
-
|
|
9308
|
-
return itemRefs.current[elementIds.getItemId(index)];
|
|
9309
|
-
}, [elementIds]); // Effects.
|
|
9401
|
+
const getItemNodeFromIndex = useCallback(index => itemRefs.current[elementIds.getItemId(index)], [elementIds]); // Effects.
|
|
9310
9402
|
// Sets a11y status message on changes in state.
|
|
9311
9403
|
|
|
9312
|
-
useA11yMessageSetter(getA11yStatusMessage, [isOpen, highlightedIndex, inputValue, items],
|
|
9404
|
+
useA11yMessageSetter(getA11yStatusMessage, [isOpen, highlightedIndex, inputValue, items], {
|
|
9313
9405
|
isInitialMount: isInitialMountRef.current,
|
|
9314
9406
|
previousResultCount: previousResultCountRef.current,
|
|
9315
|
-
items
|
|
9316
|
-
environment
|
|
9317
|
-
itemToString
|
|
9318
|
-
|
|
9407
|
+
items,
|
|
9408
|
+
environment,
|
|
9409
|
+
itemToString,
|
|
9410
|
+
...state
|
|
9411
|
+
}); // Sets a11y status message on changes in selectedItem.
|
|
9319
9412
|
|
|
9320
|
-
useA11yMessageSetter(getA11ySelectionMessage, [selectedItem],
|
|
9413
|
+
useA11yMessageSetter(getA11ySelectionMessage, [selectedItem], {
|
|
9321
9414
|
isInitialMount: isInitialMountRef.current,
|
|
9322
9415
|
previousResultCount: previousResultCountRef.current,
|
|
9323
|
-
items
|
|
9324
|
-
environment
|
|
9325
|
-
itemToString
|
|
9326
|
-
|
|
9416
|
+
items,
|
|
9417
|
+
environment,
|
|
9418
|
+
itemToString,
|
|
9419
|
+
...state
|
|
9420
|
+
}); // Scroll on highlighted item if change comes from keyboard.
|
|
9327
9421
|
|
|
9328
|
-
|
|
9422
|
+
const shouldScrollRef = useScrollIntoView({
|
|
9329
9423
|
menuElement: menuRef.current,
|
|
9330
|
-
highlightedIndex
|
|
9331
|
-
isOpen
|
|
9332
|
-
itemRefs
|
|
9333
|
-
scrollIntoView
|
|
9334
|
-
getItemNodeFromIndex
|
|
9424
|
+
highlightedIndex,
|
|
9425
|
+
isOpen,
|
|
9426
|
+
itemRefs,
|
|
9427
|
+
scrollIntoView,
|
|
9428
|
+
getItemNodeFromIndex
|
|
9335
9429
|
});
|
|
9336
9430
|
useControlPropsValidator({
|
|
9337
9431
|
isInitialMount: isInitialMountRef.current,
|
|
9338
|
-
props
|
|
9339
|
-
state
|
|
9432
|
+
props,
|
|
9433
|
+
state
|
|
9340
9434
|
}); // Focus the input on first render if required.
|
|
9341
9435
|
|
|
9342
|
-
useEffect(
|
|
9343
|
-
|
|
9436
|
+
useEffect(() => {
|
|
9437
|
+
const focusOnOpen = initialIsOpen || defaultIsOpen || isOpen;
|
|
9344
9438
|
|
|
9345
9439
|
if (focusOnOpen && inputRef.current) {
|
|
9346
9440
|
inputRef.current.focus();
|
|
9347
9441
|
} // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
9348
9442
|
|
|
9349
9443
|
}, []);
|
|
9350
|
-
useEffect(
|
|
9444
|
+
useEffect(() => {
|
|
9351
9445
|
if (isInitialMountRef.current) {
|
|
9352
9446
|
return;
|
|
9353
9447
|
}
|
|
@@ -9355,147 +9449,154 @@ function useCombobox(userProps) {
|
|
|
9355
9449
|
previousResultCountRef.current = items.length;
|
|
9356
9450
|
}); // Add mouse/touch events to document.
|
|
9357
9451
|
|
|
9358
|
-
|
|
9452
|
+
const mouseAndTouchTrackersRef = useMouseAndTouchTracker(isOpen, [comboboxRef, menuRef, toggleButtonRef], environment, () => {
|
|
9359
9453
|
dispatch({
|
|
9360
9454
|
type: InputBlur,
|
|
9361
9455
|
selectItem: false
|
|
9362
9456
|
});
|
|
9363
9457
|
});
|
|
9364
|
-
|
|
9458
|
+
const setGetterPropCallInfo = useGetterPropsCalledChecker('getInputProps', 'getComboboxProps', 'getMenuProps'); // Make initial ref false.
|
|
9365
9459
|
|
|
9366
|
-
useEffect(
|
|
9460
|
+
useEffect(() => {
|
|
9367
9461
|
isInitialMountRef.current = false;
|
|
9368
9462
|
}, []); // Reset itemRefs on close.
|
|
9369
9463
|
|
|
9370
|
-
useEffect(
|
|
9464
|
+
useEffect(() => {
|
|
9371
9465
|
if (!isOpen) {
|
|
9372
9466
|
itemRefs.current = {};
|
|
9373
9467
|
}
|
|
9374
9468
|
}, [isOpen]);
|
|
9375
9469
|
/* Event handler functions */
|
|
9376
9470
|
|
|
9377
|
-
|
|
9378
|
-
|
|
9379
|
-
|
|
9380
|
-
|
|
9381
|
-
|
|
9382
|
-
|
|
9383
|
-
|
|
9384
|
-
|
|
9385
|
-
|
|
9386
|
-
|
|
9387
|
-
|
|
9388
|
-
|
|
9389
|
-
|
|
9390
|
-
|
|
9391
|
-
|
|
9392
|
-
|
|
9393
|
-
|
|
9394
|
-
|
|
9395
|
-
|
|
9396
|
-
|
|
9397
|
-
|
|
9398
|
-
|
|
9471
|
+
const inputKeyDownHandlers = useMemo(() => ({
|
|
9472
|
+
ArrowDown(event) {
|
|
9473
|
+
event.preventDefault();
|
|
9474
|
+
dispatch({
|
|
9475
|
+
type: InputKeyDownArrowDown,
|
|
9476
|
+
shiftKey: event.shiftKey,
|
|
9477
|
+
getItemNodeFromIndex
|
|
9478
|
+
});
|
|
9479
|
+
},
|
|
9480
|
+
|
|
9481
|
+
ArrowUp(event) {
|
|
9482
|
+
event.preventDefault();
|
|
9483
|
+
dispatch({
|
|
9484
|
+
type: InputKeyDownArrowUp,
|
|
9485
|
+
shiftKey: event.shiftKey,
|
|
9486
|
+
getItemNodeFromIndex
|
|
9487
|
+
});
|
|
9488
|
+
},
|
|
9489
|
+
|
|
9490
|
+
Home(event) {
|
|
9491
|
+
if (!latest.current.state.isOpen) {
|
|
9492
|
+
return;
|
|
9493
|
+
}
|
|
9399
9494
|
|
|
9400
|
-
|
|
9401
|
-
|
|
9402
|
-
|
|
9403
|
-
|
|
9404
|
-
|
|
9405
|
-
|
|
9406
|
-
End: function End(event) {
|
|
9407
|
-
if (!latest.current.state.isOpen) {
|
|
9408
|
-
return;
|
|
9409
|
-
}
|
|
9495
|
+
event.preventDefault();
|
|
9496
|
+
dispatch({
|
|
9497
|
+
type: InputKeyDownHome,
|
|
9498
|
+
getItemNodeFromIndex
|
|
9499
|
+
});
|
|
9500
|
+
},
|
|
9410
9501
|
|
|
9411
|
-
|
|
9412
|
-
|
|
9413
|
-
|
|
9414
|
-
|
|
9415
|
-
});
|
|
9416
|
-
},
|
|
9417
|
-
Escape: function Escape() {
|
|
9418
|
-
var latestState = latest.current.state;
|
|
9502
|
+
End(event) {
|
|
9503
|
+
if (!latest.current.state.isOpen) {
|
|
9504
|
+
return;
|
|
9505
|
+
}
|
|
9419
9506
|
|
|
9420
|
-
|
|
9421
|
-
|
|
9422
|
-
|
|
9423
|
-
|
|
9424
|
-
|
|
9425
|
-
|
|
9426
|
-
Enter: function Enter(event) {
|
|
9427
|
-
var latestState = latest.current.state; // if closed or no highlighted index, do nothing.
|
|
9507
|
+
event.preventDefault();
|
|
9508
|
+
dispatch({
|
|
9509
|
+
type: InputKeyDownEnd,
|
|
9510
|
+
getItemNodeFromIndex
|
|
9511
|
+
});
|
|
9512
|
+
},
|
|
9428
9513
|
|
|
9429
|
-
|
|
9430
|
-
|
|
9431
|
-
return;
|
|
9432
|
-
}
|
|
9514
|
+
Escape(event) {
|
|
9515
|
+
const latestState = latest.current.state;
|
|
9433
9516
|
|
|
9517
|
+
if (latestState.isOpen || latestState.inputValue || latestState.selectedItem || latestState.highlightedIndex > -1) {
|
|
9434
9518
|
event.preventDefault();
|
|
9435
9519
|
dispatch({
|
|
9436
|
-
type:
|
|
9437
|
-
getItemNodeFromIndex: getItemNodeFromIndex
|
|
9520
|
+
type: InputKeyDownEscape
|
|
9438
9521
|
});
|
|
9439
9522
|
}
|
|
9440
|
-
}
|
|
9441
|
-
}, [dispatch, latest, getItemNodeFromIndex]); // Getter props.
|
|
9442
|
-
|
|
9443
|
-
var getLabelProps = useCallback(function (labelProps) {
|
|
9444
|
-
return _extends({
|
|
9445
|
-
id: elementIds.labelId,
|
|
9446
|
-
htmlFor: elementIds.inputId
|
|
9447
|
-
}, labelProps);
|
|
9448
|
-
}, [elementIds]);
|
|
9449
|
-
var getMenuProps = useCallback(function (_temp, _temp2) {
|
|
9450
|
-
var _extends2;
|
|
9451
|
-
|
|
9452
|
-
var _ref = _temp === void 0 ? {} : _temp,
|
|
9453
|
-
onMouseLeave = _ref.onMouseLeave,
|
|
9454
|
-
_ref$refKey = _ref.refKey,
|
|
9455
|
-
refKey = _ref$refKey === void 0 ? 'ref' : _ref$refKey,
|
|
9456
|
-
ref = _ref.ref,
|
|
9457
|
-
rest = _objectWithoutPropertiesLoose$1(_ref, ["onMouseLeave", "refKey", "ref"]);
|
|
9458
|
-
|
|
9459
|
-
var _ref2 = _temp2 === void 0 ? {} : _temp2,
|
|
9460
|
-
_ref2$suppressRefErro = _ref2.suppressRefError,
|
|
9461
|
-
suppressRefError = _ref2$suppressRefErro === void 0 ? false : _ref2$suppressRefErro;
|
|
9523
|
+
},
|
|
9462
9524
|
|
|
9463
|
-
|
|
9464
|
-
|
|
9465
|
-
|
|
9466
|
-
|
|
9525
|
+
Enter(event) {
|
|
9526
|
+
const latestState = latest.current.state; // if closed or no highlighted index, do nothing.
|
|
9527
|
+
|
|
9528
|
+
if (!latestState.isOpen || latestState.highlightedIndex < 0 || event.which === 229 // if IME composing, wait for next Enter keydown event.
|
|
9529
|
+
) {
|
|
9530
|
+
return;
|
|
9531
|
+
}
|
|
9532
|
+
|
|
9533
|
+
event.preventDefault();
|
|
9467
9534
|
dispatch({
|
|
9468
|
-
type:
|
|
9535
|
+
type: InputKeyDownEnter,
|
|
9536
|
+
getItemNodeFromIndex
|
|
9469
9537
|
});
|
|
9470
|
-
}
|
|
9538
|
+
}
|
|
9539
|
+
|
|
9540
|
+
}), [dispatch, latest, getItemNodeFromIndex]); // Getter props.
|
|
9541
|
+
|
|
9542
|
+
const getLabelProps = useCallback(labelProps => ({
|
|
9543
|
+
id: elementIds.labelId,
|
|
9544
|
+
htmlFor: elementIds.inputId,
|
|
9545
|
+
...labelProps
|
|
9546
|
+
}), [elementIds]);
|
|
9547
|
+
const getMenuProps = useCallback(function (_temp, _temp2) {
|
|
9548
|
+
let {
|
|
9549
|
+
onMouseLeave,
|
|
9550
|
+
refKey = 'ref',
|
|
9551
|
+
ref,
|
|
9552
|
+
...rest
|
|
9553
|
+
} = _temp === void 0 ? {} : _temp;
|
|
9554
|
+
let {
|
|
9555
|
+
suppressRefError = false
|
|
9556
|
+
} = _temp2 === void 0 ? {} : _temp2;
|
|
9557
|
+
setGetterPropCallInfo('getMenuProps', suppressRefError, refKey, menuRef);
|
|
9558
|
+
return {
|
|
9559
|
+
[refKey]: handleRefs(ref, menuNode => {
|
|
9560
|
+
menuRef.current = menuNode;
|
|
9561
|
+
}),
|
|
9562
|
+
id: elementIds.menuId,
|
|
9563
|
+
role: 'listbox',
|
|
9564
|
+
'aria-labelledby': elementIds.labelId,
|
|
9565
|
+
onMouseLeave: callAllEventHandlers(onMouseLeave, () => {
|
|
9566
|
+
dispatch({
|
|
9567
|
+
type: MenuMouseLeave
|
|
9568
|
+
});
|
|
9569
|
+
}),
|
|
9570
|
+
...rest
|
|
9571
|
+
};
|
|
9471
9572
|
}, [dispatch, setGetterPropCallInfo, elementIds]);
|
|
9472
|
-
|
|
9473
|
-
|
|
9474
|
-
|
|
9475
|
-
|
|
9476
|
-
|
|
9477
|
-
|
|
9478
|
-
|
|
9479
|
-
|
|
9480
|
-
|
|
9481
|
-
|
|
9482
|
-
|
|
9483
|
-
|
|
9484
|
-
|
|
9485
|
-
|
|
9486
|
-
|
|
9487
|
-
|
|
9488
|
-
|
|
9489
|
-
|
|
9573
|
+
const getItemProps = useCallback(function (_temp3) {
|
|
9574
|
+
let {
|
|
9575
|
+
item,
|
|
9576
|
+
index,
|
|
9577
|
+
refKey = 'ref',
|
|
9578
|
+
ref,
|
|
9579
|
+
onMouseMove,
|
|
9580
|
+
onMouseDown,
|
|
9581
|
+
onClick,
|
|
9582
|
+
onPress,
|
|
9583
|
+
disabled,
|
|
9584
|
+
...rest
|
|
9585
|
+
} = _temp3 === void 0 ? {} : _temp3;
|
|
9586
|
+
const {
|
|
9587
|
+
props: latestProps,
|
|
9588
|
+
state: latestState
|
|
9589
|
+
} = latest.current;
|
|
9590
|
+
const itemIndex = getItemIndex(index, item, latestProps.items);
|
|
9490
9591
|
|
|
9491
9592
|
if (itemIndex < 0) {
|
|
9492
9593
|
throw new Error('Pass either item or item index in getItemProps!');
|
|
9493
9594
|
}
|
|
9494
9595
|
|
|
9495
|
-
|
|
9496
|
-
|
|
9596
|
+
const onSelectKey = 'onClick';
|
|
9597
|
+
const customClickHandler = onClick;
|
|
9497
9598
|
|
|
9498
|
-
|
|
9599
|
+
const itemHandleMouseMove = () => {
|
|
9499
9600
|
if (index === latestState.highlightedIndex) {
|
|
9500
9601
|
return;
|
|
9501
9602
|
}
|
|
@@ -9503,41 +9604,48 @@ function useCombobox(userProps) {
|
|
|
9503
9604
|
shouldScrollRef.current = false;
|
|
9504
9605
|
dispatch({
|
|
9505
9606
|
type: ItemMouseMove,
|
|
9506
|
-
index
|
|
9607
|
+
index,
|
|
9608
|
+
disabled
|
|
9507
9609
|
});
|
|
9508
9610
|
};
|
|
9509
9611
|
|
|
9510
|
-
|
|
9612
|
+
const itemHandleClick = () => {
|
|
9511
9613
|
dispatch({
|
|
9512
9614
|
type: ItemClick,
|
|
9513
|
-
index
|
|
9615
|
+
index
|
|
9514
9616
|
});
|
|
9515
|
-
|
|
9516
|
-
if (inputRef.current) {
|
|
9517
|
-
inputRef.current.focus();
|
|
9518
|
-
}
|
|
9519
9617
|
};
|
|
9520
9618
|
|
|
9521
|
-
|
|
9522
|
-
|
|
9523
|
-
|
|
9524
|
-
|
|
9525
|
-
|
|
9526
|
-
|
|
9527
|
-
|
|
9619
|
+
const itemHandleMouseDown = e => e.preventDefault();
|
|
9620
|
+
|
|
9621
|
+
return {
|
|
9622
|
+
[refKey]: handleRefs(ref, itemNode => {
|
|
9623
|
+
if (itemNode) {
|
|
9624
|
+
itemRefs.current[elementIds.getItemId(itemIndex)] = itemNode;
|
|
9625
|
+
}
|
|
9626
|
+
}),
|
|
9627
|
+
disabled,
|
|
9628
|
+
role: 'option',
|
|
9629
|
+
'aria-selected': `${itemIndex === latestState.highlightedIndex}`,
|
|
9630
|
+
id: elementIds.getItemId(itemIndex),
|
|
9631
|
+
...(!disabled && {
|
|
9632
|
+
[onSelectKey]: callAllEventHandlers(customClickHandler, itemHandleClick)
|
|
9633
|
+
}),
|
|
9634
|
+
onMouseMove: callAllEventHandlers(onMouseMove, itemHandleMouseMove),
|
|
9635
|
+
onMouseDown: callAllEventHandlers(onMouseDown, itemHandleMouseDown),
|
|
9636
|
+
...rest
|
|
9637
|
+
};
|
|
9528
9638
|
}, [dispatch, latest, shouldScrollRef, elementIds]);
|
|
9529
|
-
|
|
9530
|
-
|
|
9531
|
-
|
|
9532
|
-
|
|
9533
|
-
|
|
9534
|
-
|
|
9535
|
-
|
|
9536
|
-
|
|
9537
|
-
|
|
9538
|
-
|
|
9539
|
-
|
|
9540
|
-
var toggleButtonHandleClick = function toggleButtonHandleClick() {
|
|
9639
|
+
const getToggleButtonProps = useCallback(function (_temp4) {
|
|
9640
|
+
let {
|
|
9641
|
+
onClick,
|
|
9642
|
+
onPress,
|
|
9643
|
+
refKey = 'ref',
|
|
9644
|
+
ref,
|
|
9645
|
+
...rest
|
|
9646
|
+
} = _temp4 === void 0 ? {} : _temp4;
|
|
9647
|
+
|
|
9648
|
+
const toggleButtonHandleClick = () => {
|
|
9541
9649
|
dispatch({
|
|
9542
9650
|
type: ToggleButtonClick
|
|
9543
9651
|
});
|
|
@@ -9547,49 +9655,52 @@ function useCombobox(userProps) {
|
|
|
9547
9655
|
}
|
|
9548
9656
|
};
|
|
9549
9657
|
|
|
9550
|
-
return
|
|
9551
|
-
|
|
9552
|
-
|
|
9553
|
-
|
|
9554
|
-
|
|
9658
|
+
return {
|
|
9659
|
+
[refKey]: handleRefs(ref, toggleButtonNode => {
|
|
9660
|
+
toggleButtonRef.current = toggleButtonNode;
|
|
9661
|
+
}),
|
|
9662
|
+
id: elementIds.toggleButtonId,
|
|
9663
|
+
tabIndex: -1,
|
|
9664
|
+
...(!rest.disabled && { ...({
|
|
9665
|
+
onClick: callAllEventHandlers(onClick, toggleButtonHandleClick)
|
|
9666
|
+
})
|
|
9667
|
+
}),
|
|
9668
|
+
...rest
|
|
9669
|
+
};
|
|
9555
9670
|
}, [dispatch, latest, elementIds]);
|
|
9556
|
-
|
|
9557
|
-
|
|
9558
|
-
|
|
9559
|
-
|
|
9560
|
-
|
|
9561
|
-
|
|
9562
|
-
|
|
9563
|
-
|
|
9564
|
-
|
|
9565
|
-
|
|
9566
|
-
|
|
9567
|
-
|
|
9568
|
-
|
|
9569
|
-
|
|
9570
|
-
var _ref7 = _temp6 === void 0 ? {} : _temp6,
|
|
9571
|
-
_ref7$suppressRefErro = _ref7.suppressRefError,
|
|
9572
|
-
suppressRefError = _ref7$suppressRefErro === void 0 ? false : _ref7$suppressRefErro;
|
|
9573
|
-
|
|
9671
|
+
const getInputProps = useCallback(function (_temp5, _temp6) {
|
|
9672
|
+
let {
|
|
9673
|
+
onKeyDown,
|
|
9674
|
+
onChange,
|
|
9675
|
+
onInput,
|
|
9676
|
+
onBlur,
|
|
9677
|
+
onChangeText,
|
|
9678
|
+
refKey = 'ref',
|
|
9679
|
+
ref,
|
|
9680
|
+
...rest
|
|
9681
|
+
} = _temp5 === void 0 ? {} : _temp5;
|
|
9682
|
+
let {
|
|
9683
|
+
suppressRefError = false
|
|
9684
|
+
} = _temp6 === void 0 ? {} : _temp6;
|
|
9574
9685
|
setGetterPropCallInfo('getInputProps', suppressRefError, refKey, inputRef);
|
|
9575
|
-
|
|
9686
|
+
const latestState = latest.current.state;
|
|
9576
9687
|
|
|
9577
|
-
|
|
9578
|
-
|
|
9688
|
+
const inputHandleKeyDown = event => {
|
|
9689
|
+
const key = normalizeArrowKey(event);
|
|
9579
9690
|
|
|
9580
9691
|
if (key && inputKeyDownHandlers[key]) {
|
|
9581
9692
|
inputKeyDownHandlers[key](event);
|
|
9582
9693
|
}
|
|
9583
9694
|
};
|
|
9584
9695
|
|
|
9585
|
-
|
|
9696
|
+
const inputHandleChange = event => {
|
|
9586
9697
|
dispatch({
|
|
9587
9698
|
type: InputChange,
|
|
9588
9699
|
inputValue: event.target.value
|
|
9589
9700
|
});
|
|
9590
9701
|
};
|
|
9591
9702
|
|
|
9592
|
-
|
|
9703
|
+
const inputHandleBlur = () => {
|
|
9593
9704
|
/* istanbul ignore else */
|
|
9594
9705
|
if (latestState.isOpen && !mouseAndTouchTrackersRef.current.isMouseDown) {
|
|
9595
9706
|
dispatch({
|
|
@@ -9601,105 +9712,117 @@ function useCombobox(userProps) {
|
|
|
9601
9712
|
/* istanbul ignore next (preact) */
|
|
9602
9713
|
|
|
9603
9714
|
|
|
9604
|
-
|
|
9605
|
-
|
|
9715
|
+
const onChangeKey = 'onChange';
|
|
9716
|
+
let eventHandlers = {};
|
|
9606
9717
|
|
|
9607
9718
|
if (!rest.disabled) {
|
|
9608
|
-
|
|
9609
|
-
|
|
9610
|
-
|
|
9719
|
+
eventHandlers = {
|
|
9720
|
+
[onChangeKey]: callAllEventHandlers(onChange, onInput, inputHandleChange),
|
|
9721
|
+
onKeyDown: callAllEventHandlers(onKeyDown, inputHandleKeyDown),
|
|
9722
|
+
onBlur: callAllEventHandlers(onBlur, inputHandleBlur)
|
|
9723
|
+
};
|
|
9611
9724
|
}
|
|
9612
9725
|
|
|
9613
|
-
return
|
|
9614
|
-
|
|
9615
|
-
|
|
9616
|
-
|
|
9617
|
-
|
|
9726
|
+
return {
|
|
9727
|
+
[refKey]: handleRefs(ref, inputNode => {
|
|
9728
|
+
inputRef.current = inputNode;
|
|
9729
|
+
}),
|
|
9730
|
+
id: elementIds.inputId,
|
|
9731
|
+
'aria-autocomplete': 'list',
|
|
9732
|
+
'aria-controls': elementIds.menuId,
|
|
9733
|
+
...(latestState.isOpen && latestState.highlightedIndex > -1 && {
|
|
9734
|
+
'aria-activedescendant': elementIds.getItemId(latestState.highlightedIndex)
|
|
9735
|
+
}),
|
|
9618
9736
|
'aria-labelledby': elementIds.labelId,
|
|
9619
9737
|
// https://developer.mozilla.org/en-US/docs/Web/Security/Securing_your_site/Turning_off_form_autocompletion
|
|
9620
9738
|
// revert back since autocomplete="nope" is ignored on latest Chrome and Opera
|
|
9621
9739
|
autoComplete: 'off',
|
|
9622
|
-
value: latestState.inputValue
|
|
9623
|
-
|
|
9740
|
+
value: latestState.inputValue,
|
|
9741
|
+
...eventHandlers,
|
|
9742
|
+
...rest
|
|
9743
|
+
};
|
|
9624
9744
|
}, [dispatch, inputKeyDownHandlers, latest, mouseAndTouchTrackersRef, setGetterPropCallInfo, elementIds]);
|
|
9625
|
-
|
|
9626
|
-
|
|
9627
|
-
|
|
9628
|
-
|
|
9629
|
-
|
|
9630
|
-
|
|
9631
|
-
|
|
9632
|
-
|
|
9633
|
-
|
|
9634
|
-
var _ref9 = _temp8 === void 0 ? {} : _temp8,
|
|
9635
|
-
_ref9$suppressRefErro = _ref9.suppressRefError,
|
|
9636
|
-
suppressRefError = _ref9$suppressRefErro === void 0 ? false : _ref9$suppressRefErro;
|
|
9637
|
-
|
|
9745
|
+
const getComboboxProps = useCallback(function (_temp7, _temp8) {
|
|
9746
|
+
let {
|
|
9747
|
+
refKey = 'ref',
|
|
9748
|
+
ref,
|
|
9749
|
+
...rest
|
|
9750
|
+
} = _temp7 === void 0 ? {} : _temp7;
|
|
9751
|
+
let {
|
|
9752
|
+
suppressRefError = false
|
|
9753
|
+
} = _temp8 === void 0 ? {} : _temp8;
|
|
9638
9754
|
setGetterPropCallInfo('getComboboxProps', suppressRefError, refKey, comboboxRef);
|
|
9639
|
-
return
|
|
9640
|
-
|
|
9641
|
-
|
|
9755
|
+
return {
|
|
9756
|
+
[refKey]: handleRefs(ref, comboboxNode => {
|
|
9757
|
+
comboboxRef.current = comboboxNode;
|
|
9758
|
+
}),
|
|
9759
|
+
role: 'combobox',
|
|
9760
|
+
'aria-haspopup': 'listbox',
|
|
9761
|
+
'aria-owns': elementIds.menuId,
|
|
9762
|
+
'aria-expanded': latest.current.state.isOpen,
|
|
9763
|
+
...rest
|
|
9764
|
+
};
|
|
9642
9765
|
}, [latest, setGetterPropCallInfo, elementIds]); // returns
|
|
9643
9766
|
|
|
9644
|
-
|
|
9767
|
+
const toggleMenu = useCallback(() => {
|
|
9645
9768
|
dispatch({
|
|
9646
9769
|
type: FunctionToggleMenu
|
|
9647
9770
|
});
|
|
9648
9771
|
}, [dispatch]);
|
|
9649
|
-
|
|
9772
|
+
const closeMenu = useCallback(() => {
|
|
9650
9773
|
dispatch({
|
|
9651
9774
|
type: FunctionCloseMenu
|
|
9652
9775
|
});
|
|
9653
9776
|
}, [dispatch]);
|
|
9654
|
-
|
|
9777
|
+
const openMenu = useCallback(() => {
|
|
9655
9778
|
dispatch({
|
|
9656
9779
|
type: FunctionOpenMenu
|
|
9657
9780
|
});
|
|
9658
9781
|
}, [dispatch]);
|
|
9659
|
-
|
|
9782
|
+
const setHighlightedIndex = useCallback(newHighlightedIndex => {
|
|
9660
9783
|
dispatch({
|
|
9661
9784
|
type: FunctionSetHighlightedIndex,
|
|
9662
9785
|
highlightedIndex: newHighlightedIndex
|
|
9663
9786
|
});
|
|
9664
9787
|
}, [dispatch]);
|
|
9665
|
-
|
|
9788
|
+
const selectItem = useCallback(newSelectedItem => {
|
|
9666
9789
|
dispatch({
|
|
9667
9790
|
type: FunctionSelectItem,
|
|
9668
9791
|
selectedItem: newSelectedItem
|
|
9669
9792
|
});
|
|
9670
9793
|
}, [dispatch]);
|
|
9671
|
-
|
|
9794
|
+
const setInputValue = useCallback(newInputValue => {
|
|
9672
9795
|
dispatch({
|
|
9673
9796
|
type: FunctionSetInputValue,
|
|
9674
9797
|
inputValue: newInputValue
|
|
9675
9798
|
});
|
|
9676
9799
|
}, [dispatch]);
|
|
9677
|
-
|
|
9800
|
+
const reset = useCallback(() => {
|
|
9678
9801
|
dispatch({
|
|
9679
9802
|
type: FunctionReset$1
|
|
9680
9803
|
});
|
|
9681
9804
|
}, [dispatch]);
|
|
9682
9805
|
return {
|
|
9683
9806
|
// prop getters.
|
|
9684
|
-
getItemProps
|
|
9685
|
-
getLabelProps
|
|
9686
|
-
getMenuProps
|
|
9687
|
-
getInputProps
|
|
9688
|
-
getComboboxProps
|
|
9689
|
-
getToggleButtonProps
|
|
9807
|
+
getItemProps,
|
|
9808
|
+
getLabelProps,
|
|
9809
|
+
getMenuProps,
|
|
9810
|
+
getInputProps,
|
|
9811
|
+
getComboboxProps,
|
|
9812
|
+
getToggleButtonProps,
|
|
9690
9813
|
// actions.
|
|
9691
|
-
toggleMenu
|
|
9692
|
-
openMenu
|
|
9693
|
-
closeMenu
|
|
9694
|
-
setHighlightedIndex
|
|
9695
|
-
setInputValue
|
|
9696
|
-
selectItem
|
|
9697
|
-
reset
|
|
9814
|
+
toggleMenu,
|
|
9815
|
+
openMenu,
|
|
9816
|
+
closeMenu,
|
|
9817
|
+
setHighlightedIndex,
|
|
9818
|
+
setInputValue,
|
|
9819
|
+
selectItem,
|
|
9820
|
+
reset,
|
|
9698
9821
|
// state.
|
|
9699
|
-
highlightedIndex
|
|
9700
|
-
isOpen
|
|
9701
|
-
selectedItem
|
|
9702
|
-
inputValue
|
|
9822
|
+
highlightedIndex,
|
|
9823
|
+
isOpen,
|
|
9824
|
+
selectedItem,
|
|
9825
|
+
inputValue
|
|
9703
9826
|
};
|
|
9704
9827
|
}
|
|
9705
9828
|
/**
|
|
@@ -9711,9 +9834,11 @@ function useCombobox(userProps) {
|
|
|
9711
9834
|
|
|
9712
9835
|
|
|
9713
9836
|
function getA11yRemovalMessage(selectionParameters) {
|
|
9714
|
-
|
|
9715
|
-
|
|
9716
|
-
|
|
9837
|
+
const {
|
|
9838
|
+
removedSelectedItem,
|
|
9839
|
+
itemToString: itemToStringLocal
|
|
9840
|
+
} = selectionParameters;
|
|
9841
|
+
return `${itemToStringLocal(removedSelectedItem)} has been removed.`;
|
|
9717
9842
|
}
|
|
9718
9843
|
|
|
9719
9844
|
({
|
|
@@ -9744,7 +9869,7 @@ function getA11yRemovalMessage(selectionParameters) {
|
|
|
9744
9869
|
itemToString: defaultProps$3.itemToString,
|
|
9745
9870
|
stateReducer: defaultProps$3.stateReducer,
|
|
9746
9871
|
environment: defaultProps$3.environment,
|
|
9747
|
-
getA11yRemovalMessage
|
|
9872
|
+
getA11yRemovalMessage,
|
|
9748
9873
|
keyNavigationNext: 'ArrowRight',
|
|
9749
9874
|
keyNavigationPrevious: 'ArrowLeft'
|
|
9750
9875
|
}); // eslint-disable-next-line import/no-mutable-exports
|
|
@@ -9766,25 +9891,25 @@ process.env.NODE_ENV !== "production" ? '__function_set_selected_items__' : 10;
|
|
|
9766
9891
|
process.env.NODE_ENV !== "production" ? '__function_set_active_index__' : 11;
|
|
9767
9892
|
process.env.NODE_ENV !== "production" ? '__function_reset__' : 12;
|
|
9768
9893
|
|
|
9769
|
-
const
|
|
9770
|
-
const
|
|
9771
|
-
const fullHeight = options.length * ROW_HEIGHT$2;
|
|
9772
|
-
const item = (item, index) => (React.createElement("div", Object.assign({ className: `sid-input-select-list__item ${highlightedIndex === index ? "sid-input-select-list__item--highlighted" : ""}`, key: index }, getItemProps({
|
|
9773
|
-
index,
|
|
9894
|
+
const InputSelectList = ({ getItemProps, getMenuProps, highlightedIndex, options, itemToString, ariaLabel, isOpen, }) => {
|
|
9895
|
+
const listItem = (item, index) => (React.createElement("div", Object.assign({ className: `sid-input-select-list__item ${highlightedIndex === index ? "sid-input-select-list__item--highlighted" : ""}` }, getItemProps({
|
|
9774
9896
|
item,
|
|
9897
|
+
index,
|
|
9898
|
+
key: item.value,
|
|
9775
9899
|
})), itemToString(options[index])));
|
|
9776
|
-
return (React.createElement("div", Object.assign({
|
|
9900
|
+
return (React.createElement("div", Object.assign({}, getMenuProps({ "aria-label": ariaLabel })), isOpen ? (React.createElement("div", { className: "sid-input-select-list__menu" }, options.length > 0 ? (options.map((option, index) => listItem(option, index))) : (React.createElement("div", { className: "sid-input-select-list__message" },
|
|
9901
|
+
React.createElement(FormattedHTMLMessage, { id: "noOptions", defaultMessage: "No Options" }))))) : null));
|
|
9777
9902
|
};
|
|
9778
9903
|
const InputSelectListComponent = InputSelectList;
|
|
9779
9904
|
|
|
9780
|
-
const InputSelectButton = ({ clearSelection, disabled, getToggleButtonProps, isOpen,
|
|
9905
|
+
const InputSelectButton = ({ clearSelection, disabled, getToggleButtonProps, isOpen, }) => {
|
|
9781
9906
|
if (clearSelection) {
|
|
9782
|
-
return (React.createElement("button", { "aria-label": "clear selection", className: "sid-input-select-button", disabled: disabled, onClick: clearSelection, type: "button", tabIndex: 0
|
|
9907
|
+
return (React.createElement("button", { "aria-label": "clear selection", className: "sid-input-select-button", disabled: disabled, onClick: clearSelection, type: "button", tabIndex: 0 },
|
|
9783
9908
|
React.createElement("svg", { viewBox: "0 0 20 20", preserveAspectRatio: "none", width: 12, fill: "transparent", stroke: "#5A5A5A", strokeWidth: "1.1px" },
|
|
9784
9909
|
React.createElement("path", { d: "M1,1 L19,19" }),
|
|
9785
9910
|
React.createElement("path", { d: "M19,1 L1,19" }))));
|
|
9786
9911
|
}
|
|
9787
|
-
return (React.createElement("button", Object.assign({}, getToggleButtonProps(), { className: "sid-input-select-button", disabled: disabled, type: "button", tabIndex: 0
|
|
9912
|
+
return (React.createElement("button", Object.assign({}, getToggleButtonProps(), { className: "sid-input-select-button", disabled: disabled, type: "button", tabIndex: 0 }),
|
|
9788
9913
|
React.createElement("svg", { viewBox: "0 0 20 20", preserveAspectRatio: "none", width: 16, fill: "transparent", stroke: "#5A5A5A", strokeWidth: "1.1px", transform: isOpen ? "rotate(180)" : undefined },
|
|
9789
9914
|
React.createElement("path", { d: "M1,6 L10,15 L19,6" }))));
|
|
9790
9915
|
};
|
|
@@ -9812,8 +9937,14 @@ suppressPlaceholder = true, value, autoFocus, ariaLabel, isRequired, buttonRef,
|
|
|
9812
9937
|
onKeyDown(event);
|
|
9813
9938
|
}
|
|
9814
9939
|
};
|
|
9815
|
-
const inputRef =
|
|
9816
|
-
|
|
9940
|
+
const inputRef = useRef(null);
|
|
9941
|
+
// NOTE: Dependency array omitted to account for use of resetRef(), as useEffect with dep arr
|
|
9942
|
+
// will only trigger on initial render leaving the refs empty, this replicates prior version
|
|
9943
|
+
// where ref callback would trigger with each re-render
|
|
9944
|
+
useEffect(() => {
|
|
9945
|
+
setRef(fieldId, inputRef.current);
|
|
9946
|
+
});
|
|
9947
|
+
return (React.createElement(Downshift$1, { id: inputId, onChange: onChange, itemToString: itemToString, selectedItem: value && value.value && value.label ? value : "", defaultHighlightedIndex: 0 }, ({ clearSelection, getInputProps, getItemProps, getMenuProps, getToggleButtonProps, highlightedIndex, inputValue, isOpen, openMenu, selectedItem, selectHighlightedItem, }) => (React.createElement("div", { className: `sid-input-select-list ${className || ""}` },
|
|
9817
9948
|
React.createElement("input", Object.assign({}, getInputProps({
|
|
9818
9949
|
ref: inputRef,
|
|
9819
9950
|
onClick: () => openMenu(),
|
|
@@ -9822,11 +9953,9 @@ suppressPlaceholder = true, value, autoFocus, ariaLabel, isRequired, buttonRef,
|
|
|
9822
9953
|
}), {
|
|
9823
9954
|
// TODO resolve next line. Product needs this to autofocus, but linter says bad for accessibility
|
|
9824
9955
|
// eslint-disable-next-line
|
|
9825
|
-
autoFocus: autoFocus, id: inputId, className: `sid-l-full-width sid-text-input ${suppressPlaceholder ? "sid-hidden-placeholder" : ""} ${isErrored ? "sid-text-input--error" : ""}`, disabled: disabled, placeholder: placeholder,
|
|
9956
|
+
autoFocus: autoFocus, id: inputId, className: `sid-l-full-width sid-text-input ${suppressPlaceholder ? "sid-hidden-placeholder" : ""} ${isErrored ? "sid-text-input--error" : ""}`, disabled: disabled, placeholder: placeholder, "aria-required": isRequired, "aria-labelledby": fieldLabelId, role: role })),
|
|
9826
9957
|
React.createElement(InputSelectButtonComponent, { disabled: disabled, getToggleButtonProps: getToggleButtonProps, isOpen: isOpen, clearSelection: selectedItem ? clearSelection : undefined, buttonRef: buttonRef }),
|
|
9827
|
-
React.createElement(
|
|
9828
|
-
React.createElement("div", { className: "sid-input-select-list__message" },
|
|
9829
|
-
React.createElement(FormattedHTMLMessage, { id: "noOptions", defaultMessage: "No Options" })))))) : null)))));
|
|
9958
|
+
React.createElement(InputSelectListComponent, { highlightedIndex: highlightedIndex, itemToString: itemToString, options: filterOptions(options, inputValue), getItemProps: getItemProps, getMenuProps: getMenuProps, ariaLabel: ariaLabel, isOpen: isOpen })))));
|
|
9830
9959
|
};
|
|
9831
9960
|
InputSelect.defaultProps = {
|
|
9832
9961
|
className: undefined,
|
|
@@ -9845,15 +9974,7 @@ const Country = ({ value, isErrored, options, onChange, onKeyDown, intl, placeho
|
|
|
9845
9974
|
React.createElement("div", { className: "sid-l-space-top-md" }),
|
|
9846
9975
|
React.createElement(FieldLabel, { text: React.createElement(FormattedHTMLMessage, { id: "country", defaultMessage: "Country" }), htmlForLabel: inputId, id: `${inputId}-label`, isRequired: isRequired }),
|
|
9847
9976
|
React.createElement(InputSelectComponent, { fieldId: "country", inputId: inputId, fieldLabelId: `${inputId}-label`, isErrored: isErrored, options: options, onChange: (country) => onChange(country), onKeyDown: onKeyDown, placeholder: placeholder ||
|
|
9848
|
-
intl.formatHTMLMessage({ id: "countryPlaceholder", defaultMessage: "Country" }), value: value
|
|
9849
|
-
? {
|
|
9850
|
-
value: value.value,
|
|
9851
|
-
label: intl.formatHTMLMessage({
|
|
9852
|
-
id: `countries.${value.value}`,
|
|
9853
|
-
defaultMessage: value.label || value.value,
|
|
9854
|
-
}),
|
|
9855
|
-
}
|
|
9856
|
-
: undefined, isRequired: true }),
|
|
9977
|
+
intl.formatHTMLMessage({ id: "countryPlaceholder", defaultMessage: "Country" }), value: options.find((option) => option.value === (value && value.value)), isRequired: true }),
|
|
9857
9978
|
isErrored ? (React.createElement("div", { className: "sid-field-error" },
|
|
9858
9979
|
React.createElement(FormattedHTMLMessage, { id: "errorId.invalidCountry", defaultMessage: "Invalid country" }))) : null));
|
|
9859
9980
|
};
|
|
@@ -9877,7 +9998,7 @@ const SelectButtonComponent = SelectButton;
|
|
|
9877
9998
|
|
|
9878
9999
|
const Select = ({ className, hideDropDownButton, isErrored, options, onChange, overrideInputClassName, placeholder, value, }) => {
|
|
9879
10000
|
const itemToString = (item) => (item ? item.label : "");
|
|
9880
|
-
return (React.createElement(Downshift, { onChange: onChange, itemToString: itemToString, initialSelectedItem: value && value.value && value.label ? value : undefined, defaultHighlightedIndex: 0 }, ({ getInputProps, getItemProps, getMenuProps, getToggleButtonProps, highlightedIndex, isOpen, openMenu, }) => (React.createElement("div", { className: `sid-select-list ${className}` },
|
|
10001
|
+
return (React.createElement(Downshift$1, { onChange: onChange, itemToString: itemToString, initialSelectedItem: value && value.value && value.label ? value : undefined, defaultHighlightedIndex: 0 }, ({ getInputProps, getItemProps, getMenuProps, getToggleButtonProps, highlightedIndex, isOpen, openMenu, }) => (React.createElement("div", { className: `sid-select-list ${className}` },
|
|
9881
10002
|
React.createElement("input", Object.assign({}, getInputProps({ onFocus: openMenu }), getToggleButtonProps, { className: `
|
|
9882
10003
|
sid-l-full-width
|
|
9883
10004
|
${overrideInputClassName || "sid-select-input"}
|
|
@@ -9909,13 +10030,7 @@ const ChangeLocale = ({ value, options, onChange, intl, }) => {
|
|
|
9909
10030
|
return (React.createElement("div", { className: "sid-change-locale" },
|
|
9910
10031
|
React.createElement("div", { className: "sid-field__label sid-change-locale__label " },
|
|
9911
10032
|
React.createElement(FormattedHTMLMessage, { id: "changeLanguage", defaultMessage: "Change language" })),
|
|
9912
|
-
React.createElement(SelectComponent, { className: "sid-change-locale__select", hideDropDownButton: true, options: newOptions, onChange: (locale) => onChange(locale), overrideInputClassName: "sid-change-locale__input", value:
|
|
9913
|
-
value: value.value,
|
|
9914
|
-
label: intl.formatHTMLMessage({
|
|
9915
|
-
id: `locales.${value.value}`,
|
|
9916
|
-
defaultMessage: "Label not found",
|
|
9917
|
-
}),
|
|
9918
|
-
} }),
|
|
10033
|
+
React.createElement(SelectComponent, { className: "sid-change-locale__select", hideDropDownButton: true, options: newOptions, onChange: (locale) => onChange(locale), overrideInputClassName: "sid-change-locale__input", value: newOptions.find((option) => option.value === (value && value.value)) }),
|
|
9919
10034
|
React.createElement("div", { className: "sid-l-space-btm-sm" })));
|
|
9920
10035
|
};
|
|
9921
10036
|
const ChangeLocaleComponent = injectIntl(ChangeLocale);
|
|
@@ -10966,6 +11081,14 @@ const mockCancelEmailLoopResponse = {
|
|
|
10966
11081
|
subSegment: null,
|
|
10967
11082
|
locale: "en-US",
|
|
10968
11083
|
};
|
|
11084
|
+
const mockCancelDocUploadResponse = {
|
|
11085
|
+
submissionUrl: "",
|
|
11086
|
+
verificationId: "63a22b25e7501047aa05bc3a",
|
|
11087
|
+
currentStep: "override",
|
|
11088
|
+
segment: "student",
|
|
11089
|
+
subSegment: null,
|
|
11090
|
+
locale: "en-US",
|
|
11091
|
+
};
|
|
10969
11092
|
const allMockedResponses = {
|
|
10970
11093
|
collectStudentPersonalInfo: mockStudentPersonalInfoResponse,
|
|
10971
11094
|
collectTeacherPersonalInfo: mockTeacherPersonalInfoResponse,
|
|
@@ -10997,6 +11120,7 @@ const allMockedResponses = {
|
|
|
10997
11120
|
collectAgePersonalInfo: mockAgePersonalInfoResponse,
|
|
10998
11121
|
collectMedicalProfessionalPersonalInfo: mockMedicalProfessionalPersonalInfoResponse,
|
|
10999
11122
|
cancelSocialSecurityNumber: {},
|
|
11123
|
+
cancelDocUpload: mockCancelDocUploadResponse,
|
|
11000
11124
|
};
|
|
11001
11125
|
|
|
11002
11126
|
/**
|
|
@@ -11936,7 +12060,7 @@ const stepToRequest = {
|
|
|
11936
12060
|
};
|
|
11937
12061
|
async function submitFromVerificationStep(step, previousResponse, viewModel) {
|
|
11938
12062
|
let response;
|
|
11939
|
-
const { docUpload, cancelSocialSecurityNumber, sso, cancelEmailLoop } = VerificationStepsEnum;
|
|
12063
|
+
const { docUpload, cancelSocialSecurityNumber, sso, cancelEmailLoop, cancelDocUpload } = VerificationStepsEnum;
|
|
11940
12064
|
try {
|
|
11941
12065
|
if (step === docUpload) {
|
|
11942
12066
|
const requestBody = viewModel;
|
|
@@ -11956,6 +12080,10 @@ async function submitFromVerificationStep(step, previousResponse, viewModel) {
|
|
|
11956
12080
|
response = await DeleteJson(previousResponse.cancelUrl);
|
|
11957
12081
|
return response;
|
|
11958
12082
|
}
|
|
12083
|
+
if (step === cancelDocUpload) {
|
|
12084
|
+
response = await DeleteJson(previousResponse.submissionUrl);
|
|
12085
|
+
return response;
|
|
12086
|
+
}
|
|
11959
12087
|
const requestBody = stepToRequest[step](viewModel);
|
|
11960
12088
|
response = await PostJson(previousResponse.submissionUrl, requestBody);
|
|
11961
12089
|
return response;
|
|
@@ -14871,6 +14999,20 @@ const removeAllFiles = (viewModel) => fn(viewModel, (draft) => {
|
|
|
14871
14999
|
}
|
|
14872
15000
|
});
|
|
14873
15001
|
|
|
15002
|
+
function _setPrototypeOf(o, p) {
|
|
15003
|
+
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
15004
|
+
o.__proto__ = p;
|
|
15005
|
+
return o;
|
|
15006
|
+
};
|
|
15007
|
+
return _setPrototypeOf(o, p);
|
|
15008
|
+
}
|
|
15009
|
+
|
|
15010
|
+
function _inheritsLoose(subClass, superClass) {
|
|
15011
|
+
subClass.prototype = Object.create(superClass.prototype);
|
|
15012
|
+
subClass.prototype.constructor = subClass;
|
|
15013
|
+
_setPrototypeOf(subClass, superClass);
|
|
15014
|
+
}
|
|
15015
|
+
|
|
14874
15016
|
var ReactReduxContext = React.createContext(null);
|
|
14875
15017
|
|
|
14876
15018
|
var Provider =
|
|
@@ -14961,6 +15103,41 @@ Provider.propTypes = {
|
|
|
14961
15103
|
children: propTypes.any
|
|
14962
15104
|
};
|
|
14963
15105
|
|
|
15106
|
+
function _assertThisInitialized(self) {
|
|
15107
|
+
if (self === void 0) {
|
|
15108
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
15109
|
+
}
|
|
15110
|
+
return self;
|
|
15111
|
+
}
|
|
15112
|
+
|
|
15113
|
+
function _extends() {
|
|
15114
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
15115
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
15116
|
+
var source = arguments[i];
|
|
15117
|
+
for (var key in source) {
|
|
15118
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
15119
|
+
target[key] = source[key];
|
|
15120
|
+
}
|
|
15121
|
+
}
|
|
15122
|
+
}
|
|
15123
|
+
return target;
|
|
15124
|
+
};
|
|
15125
|
+
return _extends.apply(this, arguments);
|
|
15126
|
+
}
|
|
15127
|
+
|
|
15128
|
+
function _objectWithoutPropertiesLoose$1(source, excluded) {
|
|
15129
|
+
if (source == null) return {};
|
|
15130
|
+
var target = {};
|
|
15131
|
+
var sourceKeys = Object.keys(source);
|
|
15132
|
+
var key, i;
|
|
15133
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
|
15134
|
+
key = sourceKeys[i];
|
|
15135
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
15136
|
+
target[key] = source[key];
|
|
15137
|
+
}
|
|
15138
|
+
return target;
|
|
15139
|
+
}
|
|
15140
|
+
|
|
14964
15141
|
/** @license React v16.13.1
|
|
14965
15142
|
* react-is.production.min.js
|
|
14966
15143
|
*
|
|
@@ -16393,8 +16570,15 @@ rtlDetect_1.getLangDir;
|
|
|
16393
16570
|
|
|
16394
16571
|
const OptInInput = ({ id = "new", isErrored, onChange, value, ariaLabelledby, }) => {
|
|
16395
16572
|
const a = ariaLabelledby ? { "aria-labelledby": ariaLabelledby } : {};
|
|
16573
|
+
const inputRef = useRef(null);
|
|
16574
|
+
// NOTE: Dependency array omitted to account for use of resetRef(), as useEffect with dep arr
|
|
16575
|
+
// will only trigger on initial render leaving the refs empty, this replicates prior version
|
|
16576
|
+
// where ref callback would trigger with each re-render
|
|
16577
|
+
useEffect(() => {
|
|
16578
|
+
setRef("optIn", inputRef.current);
|
|
16579
|
+
});
|
|
16396
16580
|
return (React.createElement("div", { className: "sid-checkbox" },
|
|
16397
|
-
React.createElement("input", { className: "sid-checkbox__input", id: `sid-opt-in__${id}`, name: "sid-opt-in", type: "checkbox", checked: value, ref:
|
|
16581
|
+
React.createElement("input", { className: "sid-checkbox__input", id: `sid-opt-in__${id}`, name: "sid-opt-in", type: "checkbox", checked: value, ref: inputRef, onChange: (e) => onChange(e.target.checked), "aria-hidden": true }),
|
|
16398
16582
|
React.createElement("span", Object.assign({}, a, { className: `sid-checkbox__input-like ${isErrored ? "sid-checkbox__input-like--error" : ""}`, onClick: onChange, onKeyUp: onChange, role: "checkbox", "aria-checked": value, tabIndex: 0, "data-testid": "stylable-checkbox-input" }))));
|
|
16399
16583
|
};
|
|
16400
16584
|
const OptInInputComponent = OptInInput;
|
|
@@ -16466,17 +16650,24 @@ isRequired = false, onKeyDown = undefined, placeholder = "", displaySmsConsent =
|
|
|
16466
16650
|
internationalSupport = false, // deprecated
|
|
16467
16651
|
selectedCountryCode = "us", }) => {
|
|
16468
16652
|
const getDefaultExplanation = () => !isRequired ? (React.createElement(FormattedHTMLMessage, { id: "phoneNumberExplanation", defaultMessage: "Optional - get text notifications of status updates" })) : ("");
|
|
16653
|
+
const inputRef = useRef(null);
|
|
16654
|
+
// NOTE: Dependency array omitted to account for use of resetRef(), as useEffect with dep arr
|
|
16655
|
+
// will only trigger on initial render leaving the refs empty, this replicates prior version
|
|
16656
|
+
// where ref callback would trigger with each re-render
|
|
16657
|
+
useEffect(() => {
|
|
16658
|
+
setRef("phoneNumber", inputRef.current);
|
|
16659
|
+
});
|
|
16469
16660
|
return (React.createElement("div", { className: "sid-field sid-phone-number" },
|
|
16470
16661
|
React.createElement("div", { className: "sid-l-space-top-md" }),
|
|
16471
16662
|
React.createElement(FieldLabel, { text: React.createElement(FormattedHTMLMessage, { id: "phoneNumber", defaultMessage: "Mobile Number" }), htmlForLabel: "sid-phone-number", id: "sid-phone-number-label", displayClasses: `sid-field__label-with-explanation${placeholder && "sid-h-screen-reader-only"}`, isRequired: isRequired }, explanation || getDefaultExplanation()),
|
|
16472
16663
|
React.createElement(React.Fragment, null,
|
|
16473
16664
|
React.createElement(PhoneInput, { country: selectedCountryCode.toLowerCase(), containerClass: "react-tel-input sid-phone-number__wrapper", inputClass: `sid-text-input sid-phone-number__field sid-phone-number__field--intl ${isRequired ? "sid-text-input--required" : ""} sid-l-full-width ${isErrored ? "sid-text-input--error" : ""}`, autoFormat: false, value: value, onChange: (value) => onChange(value), placeholder: placeholder,
|
|
16474
16665
|
// @ts-ignore
|
|
16475
|
-
ref:
|
|
16666
|
+
ref: inputRef, inputProps: {
|
|
16476
16667
|
id: "sid-phone-number",
|
|
16477
16668
|
name: "sid-phone-number",
|
|
16478
16669
|
onKeyDown: (e) => (onKeyDown ? onKeyDown(e) : undefined),
|
|
16479
|
-
}, "aria-labelledby": "sid-phone-number-label" })),
|
|
16670
|
+
}, "aria-labelledby": "sid-phone-number-label", countryCodeEditable: false })),
|
|
16480
16671
|
isErrored ? (React.createElement("div", { className: "sid-field-error" },
|
|
16481
16672
|
React.createElement(FormattedHTMLMessage, { id: "errorId.invalidPhoneNumber", defaultMessage: "Invalid mobile number" }))) : null,
|
|
16482
16673
|
displaySmsConsent && (React.createElement("div", { className: "sid-h-small-text sid-l-space-top-md sid-sms-consent" },
|
|
@@ -16718,10 +16909,16 @@ const Typeahead = ({ onChange, programId, className, countryCode, disabled, mini
|
|
|
16718
16909
|
});
|
|
16719
16910
|
// Maintain same labelledby value as previous versions even though label has "for" attribute
|
|
16720
16911
|
const comboboxArgs = { "aria-labelledby": `${inputHtmlId}-label` };
|
|
16721
|
-
const inputRef =
|
|
16912
|
+
const inputRef = useRef(null);
|
|
16913
|
+
// NOTE: Dependency array omitted to account for use of resetRef(), as useEffect with dep arr
|
|
16914
|
+
// will only trigger on initial render leaving the refs empty, this replicates prior version
|
|
16915
|
+
// where ref callback would trigger with each re-render
|
|
16916
|
+
useEffect(() => {
|
|
16917
|
+
setRef("organization", inputRef.current);
|
|
16918
|
+
});
|
|
16722
16919
|
return (React.createElement(React.Fragment, null,
|
|
16723
16920
|
React.createElement("div", Object.assign({ className: "sid-organization-list" }, getComboboxProps(comboboxArgs)),
|
|
16724
|
-
React.createElement("input", Object.assign({}, getInputProps({ ref: inputRef }), { className: `sid-l-full-width sid-hidden-placeholder sid-text-input ${className}`, disabled: disabled, id: inputHtmlId, placeholder: placeholder, "aria-required": isRequired
|
|
16921
|
+
React.createElement("input", Object.assign({}, getInputProps({ ref: inputRef }), { className: `sid-l-full-width sid-hidden-placeholder sid-text-input ${className}`, disabled: disabled, id: inputHtmlId, placeholder: placeholder, "aria-required": isRequired })),
|
|
16725
16922
|
React.createElement("div", Object.assign({}, getMenuProps()), isOpen ? (React.createElement(FetchOrganizationsComponent, { countryCode: countryCode, getItemProps: getItemProps, highlightedIndex: highlightedIndex, itemToString: itemToString, minimumSearchValueLength: minimumSearchValueLength, onLoaded: (loadedOrganizations) => setLoadedOrgs(loadedOrganizations), programId: programId, searchValue: inputValue, orgSearchUrl: orgSearchUrl, orgSearchTags: orgSearchTags, locale: locale, urlAddSchoolForm: urlAddSchoolForm, openOrgSearchEnabled: openOrgSearchEnabled })) : null))));
|
|
16726
16923
|
};
|
|
16727
16924
|
const TypeaheadComponent = Typeahead;
|
|
@@ -16758,46 +16955,20 @@ const BirthDate = ({ onChange, intl, isErrored, isRequired = true, errorId, valu
|
|
|
16758
16955
|
const birthDateDay = Number.parseInt(birthDateParts[2], 10) || undefined;
|
|
16759
16956
|
const minBirthYear = 1900;
|
|
16760
16957
|
const thisYear = new Date().getFullYear();
|
|
16958
|
+
/* prettier-ignore */
|
|
16761
16959
|
const months = [
|
|
16762
|
-
{
|
|
16763
|
-
|
|
16764
|
-
|
|
16765
|
-
},
|
|
16766
|
-
{
|
|
16767
|
-
value: "2",
|
|
16768
|
-
label: intl.formatHTMLMessage({ id: "dateTime.february", defaultMessage: "February" }),
|
|
16769
|
-
},
|
|
16770
|
-
{
|
|
16771
|
-
value: "3",
|
|
16772
|
-
label: intl.formatHTMLMessage({ id: "dateTime.march", defaultMessage: "March" }),
|
|
16773
|
-
},
|
|
16774
|
-
{
|
|
16775
|
-
value: "4",
|
|
16776
|
-
label: intl.formatHTMLMessage({ id: "dateTime.april", defaultMessage: "April" }),
|
|
16777
|
-
},
|
|
16960
|
+
{ value: "1", label: intl.formatHTMLMessage({ id: "dateTime.january", defaultMessage: "January" }) },
|
|
16961
|
+
{ value: "2", label: intl.formatHTMLMessage({ id: "dateTime.february", defaultMessage: "February" }) },
|
|
16962
|
+
{ value: "3", label: intl.formatHTMLMessage({ id: "dateTime.march", defaultMessage: "March" }) },
|
|
16963
|
+
{ value: "4", label: intl.formatHTMLMessage({ id: "dateTime.april", defaultMessage: "April" }) },
|
|
16778
16964
|
{ value: "5", label: intl.formatHTMLMessage({ id: "dateTime.may", defaultMessage: "May" }) },
|
|
16779
16965
|
{ value: "6", label: intl.formatHTMLMessage({ id: "dateTime.june", defaultMessage: "June" }) },
|
|
16780
16966
|
{ value: "7", label: intl.formatHTMLMessage({ id: "dateTime.july", defaultMessage: "July" }) },
|
|
16781
|
-
{
|
|
16782
|
-
|
|
16783
|
-
|
|
16784
|
-
},
|
|
16785
|
-
{
|
|
16786
|
-
value: "9",
|
|
16787
|
-
label: intl.formatHTMLMessage({ id: "dateTime.september", defaultMessage: "September" }),
|
|
16788
|
-
},
|
|
16789
|
-
{
|
|
16790
|
-
value: "10",
|
|
16791
|
-
label: intl.formatHTMLMessage({ id: "dateTime.october", defaultMessage: "October" }),
|
|
16792
|
-
},
|
|
16793
|
-
{
|
|
16794
|
-
value: "11",
|
|
16795
|
-
label: intl.formatHTMLMessage({ id: "dateTime.november", defaultMessage: "November" }),
|
|
16796
|
-
},
|
|
16797
|
-
{
|
|
16798
|
-
value: "12",
|
|
16799
|
-
label: intl.formatHTMLMessage({ id: "dateTime.december", defaultMessage: "December" }),
|
|
16800
|
-
},
|
|
16967
|
+
{ value: "8", label: intl.formatHTMLMessage({ id: "dateTime.august", defaultMessage: "August" }) },
|
|
16968
|
+
{ value: "9", label: intl.formatHTMLMessage({ id: "dateTime.september", defaultMessage: "September" }) },
|
|
16969
|
+
{ value: "10", label: intl.formatHTMLMessage({ id: "dateTime.october", defaultMessage: "October" }) },
|
|
16970
|
+
{ value: "11", label: intl.formatHTMLMessage({ id: "dateTime.november", defaultMessage: "November" }) },
|
|
16971
|
+
{ value: "12", label: intl.formatHTMLMessage({ id: "dateTime.december", defaultMessage: "December" }) },
|
|
16801
16972
|
];
|
|
16802
16973
|
const isDateFieldEmpty = (year, month, day) => (!day || day === "") && (!month || month === "") && (!year || year === "");
|
|
16803
16974
|
const updateBirthMonth = (month) => {
|
|
@@ -16856,23 +17027,26 @@ const BirthDate = ({ onChange, intl, isErrored, isRequired = true, errorId, valu
|
|
|
16856
17027
|
onChange(`${birthDateYear}-${formatTwoDigitValues(birthDateMonth)}-${formatTwoDigitValues(birthDateDay)}`);
|
|
16857
17028
|
}
|
|
16858
17029
|
};
|
|
16859
|
-
const handleOnKeyDown = (event) => {
|
|
16860
|
-
if (event.key === "Tab" && !event.shiftKey) {
|
|
16861
|
-
event.preventDefault();
|
|
16862
|
-
setFocus("inputSelectButtonBirthDate");
|
|
16863
|
-
}
|
|
16864
|
-
};
|
|
16865
17030
|
const monthFieldId = "sid-birthdate__month";
|
|
16866
17031
|
const fieldLabelId = "sid-birthdate-label";
|
|
16867
17032
|
const errMsg = errorId ? (React.createElement("div", { className: "sid-field-error" },
|
|
16868
17033
|
React.createElement(FormattedHTMLMessage, { id: `errorId.${errorId}`, defaultMessage: "Invalid birth date" }))) : (React.createElement("div", { className: "sid-field-error" },
|
|
16869
17034
|
React.createElement(FormattedHTMLMessage, { id: "errorId.invalidBirthDate", defaultMessage: "Invalid birth date" })));
|
|
17035
|
+
const birthDateDayRef = useRef(null);
|
|
17036
|
+
const birthDateYearRef = useRef(null);
|
|
17037
|
+
// NOTE: Dependency array omitted to account for use of resetRef(), as useEffect with dep arr
|
|
17038
|
+
// will only trigger on initial render leaving the refs empty, this replicates prior version
|
|
17039
|
+
// where ref callback would trigger with each re-render
|
|
17040
|
+
useEffect(() => {
|
|
17041
|
+
setRef("birthDateDay", birthDateDayRef.current);
|
|
17042
|
+
setRef("birthDateYear", birthDateYearRef.current);
|
|
17043
|
+
});
|
|
16870
17044
|
return (React.createElement("div", { className: "sid-field sid-birthdate" },
|
|
16871
17045
|
React.createElement("div", { className: "sid-l-space-top-md" }),
|
|
16872
17046
|
React.createElement(FieldLabel, { text: React.createElement(FormattedHTMLMessage, { id: "birthDate", defaultMessage: "Date of birth" }), htmlForLabel: monthFieldId, id: fieldLabelId, displayClasses: "sid-field__label-with-explanation", isRequired: isRequired },
|
|
16873
17047
|
React.createElement(FormattedHTMLMessage, { id: "verificationPurposesOnly", defaultMessage: "Used for verification purposes only" })),
|
|
16874
17048
|
React.createElement("div", { className: "sid-birthdate__inputs" },
|
|
16875
|
-
React.createElement(InputSelectComponent, { className: "sid-birthdate__month", fieldId: "birthDate", inputId: monthFieldId, fieldLabelId: fieldLabelId, isErrored: isErrored, options: months,
|
|
17049
|
+
React.createElement(InputSelectComponent, { className: "sid-birthdate__month", fieldId: "birthDate", inputId: monthFieldId, fieldLabelId: fieldLabelId, isErrored: isErrored, options: months, onChange: (choice) => {
|
|
16876
17050
|
if (choice) {
|
|
16877
17051
|
updateBirthMonth(choice.value);
|
|
16878
17052
|
}
|
|
@@ -16881,8 +17055,8 @@ const BirthDate = ({ onChange, intl, isErrored, isRequired = true, errorId, valu
|
|
|
16881
17055
|
updateBirthMonth(null);
|
|
16882
17056
|
}
|
|
16883
17057
|
}, placeholder: intl.formatHTMLMessage({ id: "dateTime.month", defaultMessage: "Month" }), suppressPlaceholder: false, value: birthDateMonth ? months[birthDateMonth - 1] : undefined, isRequired: isRequired, buttonRef: "inputSelectButtonBirthDate" }),
|
|
16884
|
-
React.createElement("input", { className: `sid-birthdate__day sid-text-input sid-text-input--required ${isErrored ? "sid-text-input--error" : ""}`, id: "sid-birthdate-day", min: 1, max: 31, name: "sid-birthdate-day", onChange: (e) => updateBirthDay(e.target.value), onBlur: getBirthDate, pattern: "\\d*", placeholder: intl.formatHTMLMessage({ id: "dateTime.day", defaultMessage: "Day" }), "aria-label": intl.formatHTMLMessage({ id: "dateTime.day", defaultMessage: "Day" }), "aria-labelledby": "sid-birthdate", "aria-required": isRequired, ref:
|
|
16885
|
-
React.createElement("input", { className: `sid-birthdate__year sid-text-input sid-text-input--required ${isErrored ? "sid-text-input--error" : ""}`, id: "sid-birthdate-year", name: "sid-birthdate-year", type: "text", min: minBirthYear, max: thisYear, value: birthDateYear || "", pattern: "\\d*", placeholder: intl.formatHTMLMessage({ id: "dateTime.year", defaultMessage: "Year" }), "aria-label": intl.formatHTMLMessage({ id: "dateTime.year", defaultMessage: "Year" }), "aria-labelledby": "sid-birthdate", "aria-required": isRequired, ref:
|
|
17058
|
+
React.createElement("input", { className: `sid-birthdate__day sid-text-input sid-text-input--required ${isErrored ? "sid-text-input--error" : ""}`, id: "sid-birthdate-day", min: 1, max: 31, name: "sid-birthdate-day", onChange: (e) => updateBirthDay(e.target.value), onBlur: getBirthDate, pattern: "\\d*", placeholder: intl.formatHTMLMessage({ id: "dateTime.day", defaultMessage: "Day" }), "aria-label": intl.formatHTMLMessage({ id: "dateTime.day", defaultMessage: "Day" }), "aria-labelledby": "sid-birthdate", "aria-required": isRequired, ref: birthDateDayRef, type: "text", value: birthDateDay || "" }),
|
|
17059
|
+
React.createElement("input", { className: `sid-birthdate__year sid-text-input sid-text-input--required ${isErrored ? "sid-text-input--error" : ""}`, id: "sid-birthdate-year", name: "sid-birthdate-year", type: "text", min: minBirthYear, max: thisYear, value: birthDateYear || "", pattern: "\\d*", placeholder: intl.formatHTMLMessage({ id: "dateTime.year", defaultMessage: "Year" }), "aria-label": intl.formatHTMLMessage({ id: "dateTime.year", defaultMessage: "Year" }), "aria-labelledby": "sid-birthdate", "aria-required": isRequired, ref: birthDateYearRef, onChange: (e) => updateBirthYear(e.target.value), onBlur: getBirthDate })),
|
|
16886
17060
|
isErrored ? errMsg : null));
|
|
16887
17061
|
};
|
|
16888
17062
|
BirthDate.defaultProps = {
|
|
@@ -17755,10 +17929,19 @@ const StepMemberPersonalInfoComponent = StepMemberPersonalInfo;
|
|
|
17755
17929
|
|
|
17756
17930
|
const Status = ({ value, isErrored, errorId = "invalidStatus", options, onChange, intl, placeholder = "", onKeyDown = undefined, segmentId, }) => {
|
|
17757
17931
|
const inputId = `sid-${segmentId}-status`;
|
|
17932
|
+
const hasOnlyOneOption = options.length === 1;
|
|
17933
|
+
React.useEffect(() => {
|
|
17934
|
+
if (hasOnlyOneOption) {
|
|
17935
|
+
onChange(options[0]);
|
|
17936
|
+
}
|
|
17937
|
+
}, []);
|
|
17938
|
+
if (hasOnlyOneOption) {
|
|
17939
|
+
return null;
|
|
17940
|
+
}
|
|
17758
17941
|
return (React.createElement("div", { className: `sid-field ${inputId}` },
|
|
17759
17942
|
React.createElement("div", { className: "sid-l-space-top-md" }),
|
|
17760
17943
|
React.createElement(FieldLabel, { text: React.createElement(FormattedHTMLMessage, { id: "status", defaultMessage: "Status" }), htmlForLabel: inputId, id: `${inputId}-label`, displayClasses: placeholder && "sid-h-screen-reader-only" }),
|
|
17761
|
-
React.createElement(InputSelectComponent, { fieldId: "status", inputId: inputId, fieldLabelId: `${inputId}-label`, isErrored: isErrored, options: options, onChange: (status) => onChange(status), onKeyDown: onKeyDown, value: value, placeholder: placeholder ||
|
|
17944
|
+
React.createElement(InputSelectComponent, { fieldId: "status", inputId: inputId, fieldLabelId: `${inputId}-label`, isErrored: isErrored, options: options, onChange: (status) => onChange(status), onKeyDown: onKeyDown, value: options.find((option) => option.value === (value && value.value)), placeholder: placeholder ||
|
|
17762
17945
|
intl.formatHTMLMessage({ id: "statusPlaceholder", defaultMessage: "Status" }), isRequired: true }),
|
|
17763
17946
|
isErrored ? (React.createElement("div", { className: "sid-field-error" },
|
|
17764
17947
|
React.createElement(FormattedHTMLMessage, { id: `errorId.${errorId}`, defaultMessage: `Invalid ${segmentId} status` }))) : null));
|
|
@@ -17840,11 +18023,11 @@ const BranchOfService = ({ autoFocus, onChange, value, isErrored, organizations,
|
|
|
17840
18023
|
return (React.createElement("div", { className: `sid-field ${inputId}-id` },
|
|
17841
18024
|
React.createElement("div", { className: "sid-l-space-top-md" }),
|
|
17842
18025
|
React.createElement(FieldLabel, { text: React.createElement(FormattedHTMLMessage, { id: "branchOfService", defaultMessage: "Branch Of Service" }), htmlForLabel: inputId, id: `${inputId}-label`, displayClasses: placeholder && "sid-h-screen-reader-only" }),
|
|
17843
|
-
React.createElement(InputSelectComponent, { autoFocus: autoFocus, fieldId: "organization", inputId: inputId, fieldLabelId: `${inputId}-label`, isErrored: isErrored, options: SortByLabel(options), onChange: (branch) => handleStateChange(branch, onChange), value: value
|
|
18026
|
+
React.createElement(InputSelectComponent, { autoFocus: autoFocus, fieldId: "organization", inputId: inputId, fieldLabelId: `${inputId}-label`, isErrored: isErrored, options: SortByLabel(options), onChange: (branch) => handleStateChange(branch, onChange), value: options.find((option) => option.value === (value && value.value)), placeholder: placeholder ||
|
|
17844
18027
|
intl.formatHTMLMessage({
|
|
17845
18028
|
id: "branchOfServicePlaceholder",
|
|
17846
18029
|
defaultMessage: "Branch Of Service",
|
|
17847
|
-
}) }),
|
|
18030
|
+
}), isRequired: true }),
|
|
17848
18031
|
isErrored ? (React.createElement("div", { className: "sid-field-error" },
|
|
17849
18032
|
React.createElement(FormattedHTMLMessage, { id: "errorId.invalidOrganization", defaultMessage: "You must select an organization from the list" }))) : null));
|
|
17850
18033
|
};
|
|
@@ -17963,46 +18146,20 @@ const DischargeDate = ({ onChange, intl, isErrored, value, }) => {
|
|
|
17963
18146
|
const minDischargeYear = 1900;
|
|
17964
18147
|
const thisYear = new Date().getFullYear();
|
|
17965
18148
|
const inputId = "sid-discharge-date";
|
|
18149
|
+
/* prettier-ignore */
|
|
17966
18150
|
const months = [
|
|
17967
|
-
{
|
|
17968
|
-
|
|
17969
|
-
|
|
17970
|
-
},
|
|
17971
|
-
{
|
|
17972
|
-
value: "2",
|
|
17973
|
-
label: intl.formatHTMLMessage({ id: "dateTime.february", defaultMessage: "February" }),
|
|
17974
|
-
},
|
|
17975
|
-
{
|
|
17976
|
-
value: "3",
|
|
17977
|
-
label: intl.formatHTMLMessage({ id: "dateTime.march", defaultMessage: "March" }),
|
|
17978
|
-
},
|
|
17979
|
-
{
|
|
17980
|
-
value: "4",
|
|
17981
|
-
label: intl.formatHTMLMessage({ id: "dateTime.april", defaultMessage: "April" }),
|
|
17982
|
-
},
|
|
18151
|
+
{ value: "1", label: intl.formatHTMLMessage({ id: "dateTime.january", defaultMessage: "January" }), },
|
|
18152
|
+
{ value: "2", label: intl.formatHTMLMessage({ id: "dateTime.february", defaultMessage: "February" }), },
|
|
18153
|
+
{ value: "3", label: intl.formatHTMLMessage({ id: "dateTime.march", defaultMessage: "March" }), },
|
|
18154
|
+
{ value: "4", label: intl.formatHTMLMessage({ id: "dateTime.april", defaultMessage: "April" }), },
|
|
17983
18155
|
{ value: "5", label: intl.formatHTMLMessage({ id: "dateTime.may", defaultMessage: "May" }) },
|
|
17984
18156
|
{ value: "6", label: intl.formatHTMLMessage({ id: "dateTime.june", defaultMessage: "June" }) },
|
|
17985
18157
|
{ value: "7", label: intl.formatHTMLMessage({ id: "dateTime.july", defaultMessage: "July" }) },
|
|
17986
|
-
{
|
|
17987
|
-
|
|
17988
|
-
|
|
17989
|
-
},
|
|
17990
|
-
{
|
|
17991
|
-
value: "9",
|
|
17992
|
-
label: intl.formatHTMLMessage({ id: "dateTime.september", defaultMessage: "September" }),
|
|
17993
|
-
},
|
|
17994
|
-
{
|
|
17995
|
-
value: "10",
|
|
17996
|
-
label: intl.formatHTMLMessage({ id: "dateTime.october", defaultMessage: "October" }),
|
|
17997
|
-
},
|
|
17998
|
-
{
|
|
17999
|
-
value: "11",
|
|
18000
|
-
label: intl.formatHTMLMessage({ id: "dateTime.november", defaultMessage: "November" }),
|
|
18001
|
-
},
|
|
18002
|
-
{
|
|
18003
|
-
value: "12",
|
|
18004
|
-
label: intl.formatHTMLMessage({ id: "dateTime.december", defaultMessage: "December" }),
|
|
18005
|
-
},
|
|
18158
|
+
{ value: "8", label: intl.formatHTMLMessage({ id: "dateTime.august", defaultMessage: "August" }), },
|
|
18159
|
+
{ value: "9", label: intl.formatHTMLMessage({ id: "dateTime.september", defaultMessage: "September" }), },
|
|
18160
|
+
{ value: "10", label: intl.formatHTMLMessage({ id: "dateTime.october", defaultMessage: "October" }), },
|
|
18161
|
+
{ value: "11", label: intl.formatHTMLMessage({ id: "dateTime.november", defaultMessage: "November" }), },
|
|
18162
|
+
{ value: "12", label: intl.formatHTMLMessage({ id: "dateTime.december", defaultMessage: "December" }), },
|
|
18006
18163
|
];
|
|
18007
18164
|
const updateDischargeMonth = (month) => {
|
|
18008
18165
|
if (month === "" || month === null) {
|
|
@@ -18031,20 +18188,12 @@ const DischargeDate = ({ onChange, intl, isErrored, value, }) => {
|
|
|
18031
18188
|
const getDischargeDate = () => {
|
|
18032
18189
|
onChange(`${dischargeDateYear}-${formatTwoDigitValues(dischargeDateMonth)}-${formatTwoDigitValues(dischargeDateDay)}`);
|
|
18033
18190
|
};
|
|
18034
|
-
const handleOnKeyDown = (event) => {
|
|
18035
|
-
if (event.key === "Tab") {
|
|
18036
|
-
if (!event.shiftKey) {
|
|
18037
|
-
event.preventDefault();
|
|
18038
|
-
setFocus("inputSelectButtonDischargeDate");
|
|
18039
|
-
}
|
|
18040
|
-
}
|
|
18041
|
-
};
|
|
18042
18191
|
return (React.createElement("div", { className: `sid-field ${inputId}` },
|
|
18043
18192
|
React.createElement("div", { className: "sid-l-space-top-md" }),
|
|
18044
18193
|
React.createElement(FieldLabel, { text: React.createElement(FormattedHTMLMessage, { id: "dischargeDate", defaultMessage: "Discharge date" }), htmlForLabel: `${inputId}__month`, id: `${inputId}-label`, displayClasses: "sid-field__label-with-explanation" },
|
|
18045
18194
|
React.createElement(FormattedHTMLMessage, { id: "verificationPurposesOnly", defaultMessage: "Used for verification purposes only" })),
|
|
18046
18195
|
React.createElement("div", { className: `${inputId}__inputs` },
|
|
18047
|
-
React.createElement(InputSelectComponent, { className: `${inputId}__month`, fieldId: "dischargeDate", inputId: `${inputId}__month`, fieldLabelId: `${inputId}-label`, isErrored: isErrored, options: months,
|
|
18196
|
+
React.createElement(InputSelectComponent, { className: `${inputId}__month`, fieldId: "dischargeDate", inputId: `${inputId}__month`, fieldLabelId: `${inputId}-label`, isErrored: isErrored, options: months, onChange: (choice) => {
|
|
18048
18197
|
if (choice) {
|
|
18049
18198
|
updateDischargeMonth(choice.value);
|
|
18050
18199
|
}
|
|
@@ -18441,27 +18590,13 @@ const StepMedicalProfessionalPersonalInfoComponent = injectIntl(StepMedicalProfe
|
|
|
18441
18590
|
|
|
18442
18591
|
const StateSelect = ({ value, isErrored, options, onChange, intl, placeholder = "", label = "", isRequired = false, }) => {
|
|
18443
18592
|
const stateFieldId = "sid-state";
|
|
18444
|
-
const handleOnKeyDown = (event) => {
|
|
18445
|
-
if (event.key === "Tab" && !event.shiftKey) {
|
|
18446
|
-
event.preventDefault();
|
|
18447
|
-
setFocus("inputSelectButtonState");
|
|
18448
|
-
}
|
|
18449
|
-
};
|
|
18450
18593
|
return (React.createElement("div", { className: `sid-field ${stateFieldId}__select` },
|
|
18451
18594
|
React.createElement("div", { className: "sid-l-space-top-md" }),
|
|
18452
18595
|
React.createElement(FieldLabel, { text: label || React.createElement(FormattedHTMLMessage, { id: "state", defaultMessage: "State where you live" }), htmlForLabel: stateFieldId, id: `${stateFieldId}-label`, displayClasses: placeholder && "sid-h-screen-reader-only", isRequired: isRequired }),
|
|
18453
|
-
React.createElement(InputSelectComponent, { fieldId: "state", inputId: stateFieldId, fieldLabelId: `${stateFieldId}-label`, isErrored: isErrored, options: options, onChange: (state) => onChange(state),
|
|
18596
|
+
React.createElement(InputSelectComponent, { fieldId: "state", inputId: stateFieldId, fieldLabelId: `${stateFieldId}-label`, isErrored: isErrored, options: options, onChange: (state) => onChange(state), placeholder: intl.formatHTMLMessage({
|
|
18454
18597
|
id: "statePlaceholder",
|
|
18455
18598
|
defaultMessage: "State",
|
|
18456
|
-
}), value: value
|
|
18457
|
-
? {
|
|
18458
|
-
value,
|
|
18459
|
-
label: intl.formatHTMLMessage({
|
|
18460
|
-
id: `states.${value}`,
|
|
18461
|
-
defaultMessage: value.label || value,
|
|
18462
|
-
}),
|
|
18463
|
-
}
|
|
18464
|
-
: undefined, suppressPlaceholder: false, isRequired: isRequired, buttonRef: "inputSelectButtonState" }),
|
|
18599
|
+
}), value: options.find((option) => option.value === value), suppressPlaceholder: false, isRequired: isRequired, buttonRef: "inputSelectButtonState" }),
|
|
18465
18600
|
isErrored ? (React.createElement("div", { className: "sid-field-error" },
|
|
18466
18601
|
React.createElement(FormattedHTMLMessage, { id: "errorId.invalidState", defaultMessage: "Invalid state" }))) : null));
|
|
18467
18602
|
};
|
|
@@ -18883,6 +19018,7 @@ const defaultStatusMessages$1 = {
|
|
|
18883
19018
|
LICENSED_REAL_ESTATE_AGENT: "Licensed Real Estate Agent",
|
|
18884
19019
|
VETERINARIAN: "Veterinarian",
|
|
18885
19020
|
CHILD_CARE_WORKER: "Child Care Worker",
|
|
19021
|
+
LIBRARIAN: "Librarian",
|
|
18886
19022
|
};
|
|
18887
19023
|
const StepLicensedProfessionalPersonalInfo = ({ intl, verificationService, }) => {
|
|
18888
19024
|
const viewModel = verificationService.viewModel;
|
|
@@ -19397,6 +19533,7 @@ const StepSSOComponent = ({ verificationService }) => {
|
|
|
19397
19533
|
const verificationResponse = verificationService.verificationResponse;
|
|
19398
19534
|
const previousVerificationResponse = verificationService.previousVerificationResponse || undefined;
|
|
19399
19535
|
const { verificationId } = verificationService.verificationResponse;
|
|
19536
|
+
const isMockingStep = getRouteOverride();
|
|
19400
19537
|
let timeout;
|
|
19401
19538
|
const pollForVerificationServiceUpdates = () => setTimeout(() => {
|
|
19402
19539
|
verificationService.fetchExistingVerificationRequest(programId, verificationId, previousVerificationResponse, previousViewModel);
|
|
@@ -19422,7 +19559,7 @@ const StepSSOComponent = ({ verificationService }) => {
|
|
|
19422
19559
|
setTabRef(window.open(verificationResponse.loginUrl, "_blank"));
|
|
19423
19560
|
getTabRef().focus();
|
|
19424
19561
|
};
|
|
19425
|
-
if (viewModel.isSSOActive) {
|
|
19562
|
+
if (viewModel.isSSOActive && !isMockingStep) {
|
|
19426
19563
|
timeout = pollForVerificationServiceUpdates();
|
|
19427
19564
|
}
|
|
19428
19565
|
if (!viewModel.countryChoice && previousViewModel && previousViewModel.countryChoice) {
|
|
@@ -19618,6 +19755,7 @@ const StepPending = ({ verificationService, intl }) => {
|
|
|
19618
19755
|
undefined;
|
|
19619
19756
|
const { verificationId } = verificationService.verificationResponse;
|
|
19620
19757
|
const countdownSeconds = 20;
|
|
19758
|
+
const isMockingStep = getRouteOverride();
|
|
19621
19759
|
const isMockingPreviousStepSSO = getPreviousStepOverride() && getPreviousStepOverride() === VerificationStepsEnum.sso;
|
|
19622
19760
|
const isMockingPreviousStepDocUpload = getPreviousStepOverride() && getPreviousStepOverride() === VerificationStepsEnum.docUpload;
|
|
19623
19761
|
const isPreviousStepSSO = () => {
|
|
@@ -19633,9 +19771,10 @@ const StepPending = ({ verificationService, intl }) => {
|
|
|
19633
19771
|
: showCountDown
|
|
19634
19772
|
? DOC_UPLOAD_POLL_DURATION_DURING_COUNTDOWN
|
|
19635
19773
|
: DOC_UPLOAD_POLL_DURATION;
|
|
19636
|
-
const stopPollingInterval =
|
|
19637
|
-
|
|
19638
|
-
|
|
19774
|
+
const stopPollingInterval = !isMockingStep &&
|
|
19775
|
+
usePollingInterval(() => {
|
|
19776
|
+
verificationService.fetchExistingVerificationRequest(programId, verificationId, verificationLastResponse, previousViewModel, false);
|
|
19777
|
+
}, pollTime);
|
|
19639
19778
|
const cancelSSOStep = () => {
|
|
19640
19779
|
const nextState = fn(viewModel, () => { });
|
|
19641
19780
|
logger.info("StepSSOComponent submitting cancel request");
|
|
@@ -19847,83 +19986,6 @@ const StepEmailLoop = ({ intl, verificationService }) => {
|
|
|
19847
19986
|
};
|
|
19848
19987
|
const StepEmailLoopComponent = injectIntl(StepEmailLoop);
|
|
19849
19988
|
|
|
19850
|
-
/*! *****************************************************************************
|
|
19851
|
-
Copyright (c) Microsoft Corporation.
|
|
19852
|
-
|
|
19853
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
19854
|
-
purpose with or without fee is hereby granted.
|
|
19855
|
-
|
|
19856
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
19857
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
19858
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
19859
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
19860
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
19861
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
19862
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
19863
|
-
***************************************************************************** */
|
|
19864
|
-
|
|
19865
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
19866
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19867
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
19868
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
19869
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
19870
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19871
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19872
|
-
});
|
|
19873
|
-
}
|
|
19874
|
-
|
|
19875
|
-
function __generator(thisArg, body) {
|
|
19876
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
19877
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
19878
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
19879
|
-
function step(op) {
|
|
19880
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
19881
|
-
while (_) try {
|
|
19882
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19883
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19884
|
-
switch (op[0]) {
|
|
19885
|
-
case 0: case 1: t = op; break;
|
|
19886
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
19887
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
19888
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
19889
|
-
default:
|
|
19890
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
19891
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
19892
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
19893
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
19894
|
-
if (t[2]) _.ops.pop();
|
|
19895
|
-
_.trys.pop(); continue;
|
|
19896
|
-
}
|
|
19897
|
-
op = body.call(thisArg, _);
|
|
19898
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
19899
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
19900
|
-
}
|
|
19901
|
-
}
|
|
19902
|
-
|
|
19903
|
-
function __read(o, n) {
|
|
19904
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
19905
|
-
if (!m) return o;
|
|
19906
|
-
var i = m.call(o), r, ar = [], e;
|
|
19907
|
-
try {
|
|
19908
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
19909
|
-
}
|
|
19910
|
-
catch (error) { e = { error: error }; }
|
|
19911
|
-
finally {
|
|
19912
|
-
try {
|
|
19913
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
19914
|
-
}
|
|
19915
|
-
finally { if (e) throw e.error; }
|
|
19916
|
-
}
|
|
19917
|
-
return ar;
|
|
19918
|
-
}
|
|
19919
|
-
|
|
19920
|
-
/** @deprecated */
|
|
19921
|
-
function __spread() {
|
|
19922
|
-
for (var ar = [], i = 0; i < arguments.length; i++)
|
|
19923
|
-
ar = ar.concat(__read(arguments[i]));
|
|
19924
|
-
return ar;
|
|
19925
|
-
}
|
|
19926
|
-
|
|
19927
19989
|
var COMMON_MIME_TYPES = new Map([
|
|
19928
19990
|
['avi', 'video/avi'],
|
|
19929
19991
|
['gif', 'image/gif'],
|
|
@@ -21502,6 +21564,7 @@ const StepDocUpload = ({ verificationService, intl }) => {
|
|
|
21502
21564
|
const viewModel = verificationService.viewModel;
|
|
21503
21565
|
const { fieldValidationErrors } = verificationService;
|
|
21504
21566
|
const subSegment = getSafe(() => verificationService.verificationResponse.subSegment);
|
|
21567
|
+
const { overrideEnabled } = verificationService.programTheme;
|
|
21505
21568
|
const getFileForView = (file) => ({
|
|
21506
21569
|
name: file.name,
|
|
21507
21570
|
url: file.type.includes("image") ? URL.createObjectURL(file) : "",
|
|
@@ -21588,6 +21651,11 @@ const StepDocUpload = ({ verificationService, intl }) => {
|
|
|
21588
21651
|
viewModel.erroredFileNames
|
|
21589
21652
|
? viewModel.erroredFileNames.map((filename) => React.createElement("div", null, filename))
|
|
21590
21653
|
: null)) : null;
|
|
21654
|
+
const cancelDocUpload = async () => {
|
|
21655
|
+
logger.info("StepDocUploadComponent submitting form after skipping document upload");
|
|
21656
|
+
const nextState = fn(viewModel, () => { });
|
|
21657
|
+
verificationService.submitStep(VerificationStepsEnum.cancelDocUpload, nextState, verificationService.verificationResponse);
|
|
21658
|
+
};
|
|
21591
21659
|
return (React.createElement("div", { id: "sid-step-doc-upload", className: "sid-l-container" },
|
|
21592
21660
|
React.createElement("div", { className: "sid-header sid-l-horz-center sid-l-space-top-md" },
|
|
21593
21661
|
React.createElement("div", { className: "sid-l-horz-center" },
|
|
@@ -21644,6 +21712,9 @@ const StepDocUpload = ({ verificationService, intl }) => {
|
|
|
21644
21712
|
React.createElement(FormattedHTMLMessage, { id: "step.docUpload.submitButtonLabel", defaultMessage: "Continue" })),
|
|
21645
21713
|
React.createElement("button", { onClick: removeFilesAndUpdate, type: "button", className: "sid-btn sid-btn--light sid-submit__cancel sid-l-space-left-sm", "aria-label": "cancel", disabled: currentFileNames.length <= 0 },
|
|
21646
21714
|
React.createElement(FormattedHTMLMessage, { id: "step.docUpload.cancelButtonLabel", defaultMessage: "Cancel" }))))) : null),
|
|
21715
|
+
overrideEnabled && (React.createElement("div", { className: "sid-submit sid-l-horz-center sid-l-space-top-sm" },
|
|
21716
|
+
React.createElement("a", { href: "#", className: "sid-link", onClick: () => cancelDocUpload(), role: "button" },
|
|
21717
|
+
React.createElement(FormattedHTMLMessage, { id: "step.docUpload.cancelDocUploadLabel", defaultMessage: "Click here if you are unable to verify with a document" })))),
|
|
21647
21718
|
React.createElement(FormFooterComponent, { verificationService: verificationService })));
|
|
21648
21719
|
};
|
|
21649
21720
|
const StepDocUploadComponent = injectIntl(StepDocUpload);
|