@popsure/dirty-swan 0.33.0 → 0.33.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +71 -67
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/App.d.ts +3 -0
- package/dist/esm/_commonjsHelpers-e7f67fd8.js +23 -0
- package/dist/esm/_commonjsHelpers-e7f67fd8.js.map +1 -0
- package/dist/esm/components/autocompleteAddress/index.js +2062 -0
- package/dist/esm/components/autocompleteAddress/index.js.map +1 -0
- package/dist/esm/components/autocompleteAddress/index.stories.js +110 -0
- package/dist/esm/components/autocompleteAddress/index.stories.js.map +1 -0
- package/dist/esm/components/autocompleteAddress/index.test.js +115 -0
- package/dist/esm/components/autocompleteAddress/index.test.js.map +1 -0
- package/dist/esm/components/button/index.js +26 -0
- package/dist/esm/components/button/index.js.map +1 -0
- package/dist/esm/components/cards/cardButton/index.js +6 -0
- package/dist/esm/components/cards/cardButton/index.js.map +1 -0
- package/dist/esm/components/cards/cardWithLeftIcon/index.js +7 -0
- package/dist/esm/components/cards/cardWithLeftIcon/index.js.map +1 -0
- package/dist/esm/components/cards/cardWithTopIcon/index.js +7 -0
- package/dist/esm/components/cards/cardWithTopIcon/index.js.map +1 -0
- package/dist/esm/components/cards/cardWithTopLeftIcon/index.js +7 -0
- package/dist/esm/components/cards/cardWithTopLeftIcon/index.js.map +1 -0
- package/dist/esm/components/cards/index.js +125 -0
- package/dist/esm/components/cards/index.js.map +1 -0
- package/dist/esm/components/cards/infoCard/index.js +7 -0
- package/dist/esm/components/cards/infoCard/index.js.map +1 -0
- package/dist/esm/components/chip/index.js +22 -0
- package/dist/esm/components/chip/index.js.map +1 -0
- package/dist/esm/components/comparisonTable/components/AccordionItem/AccordionItem.js +32 -0
- package/dist/esm/components/comparisonTable/components/AccordionItem/AccordionItem.js.map +1 -0
- package/dist/esm/components/comparisonTable/components/AccordionItem/index.js +8 -0
- package/dist/esm/components/comparisonTable/components/AccordionItem/index.js.map +1 -0
- package/dist/esm/components/comparisonTable/components/Chevron.js +10 -0
- package/dist/esm/components/comparisonTable/components/Chevron.js.map +1 -0
- package/dist/esm/components/comparisonTable/components/Row/index.js +36 -0
- package/dist/esm/components/comparisonTable/components/Row/index.js.map +1 -0
- package/dist/esm/components/comparisonTable/components/TableArrows/Arrow.js +10 -0
- package/dist/esm/components/comparisonTable/components/TableArrows/Arrow.js.map +1 -0
- package/dist/esm/components/comparisonTable/components/TableArrows/index.js +24 -0
- package/dist/esm/components/comparisonTable/components/TableArrows/index.js.map +1 -0
- package/dist/esm/components/comparisonTable/components/TableButton/index.js +15 -0
- package/dist/esm/components/comparisonTable/components/TableButton/index.js.map +1 -0
- package/dist/esm/components/comparisonTable/components/TableButton/index.test.js +37 -0
- package/dist/esm/components/comparisonTable/components/TableButton/index.test.js.map +1 -0
- package/dist/esm/components/comparisonTable/components/TableInfoButton/index.js +22 -0
- package/dist/esm/components/comparisonTable/components/TableInfoButton/index.js.map +1 -0
- package/dist/esm/components/comparisonTable/components/TableRating/StarIcon.js +10 -0
- package/dist/esm/components/comparisonTable/components/TableRating/StarIcon.js.map +1 -0
- package/dist/esm/components/comparisonTable/components/TableRating/ZapIcon.js +10 -0
- package/dist/esm/components/comparisonTable/components/TableRating/ZapIcon.js.map +1 -0
- package/dist/esm/components/comparisonTable/components/TableRating/index.js +27 -0
- package/dist/esm/components/comparisonTable/components/TableRating/index.js.map +1 -0
- package/dist/esm/components/comparisonTable/components/TableRowHeader/index.js +18 -0
- package/dist/esm/components/comparisonTable/components/TableRowHeader/index.js.map +1 -0
- package/dist/esm/components/comparisonTable/components/TableRowHeader/index.test.js +82 -0
- package/dist/esm/components/comparisonTable/components/TableRowHeader/index.test.js.map +1 -0
- package/dist/esm/components/comparisonTable/components/TableTrueFalse.js +13 -0
- package/dist/esm/components/comparisonTable/components/TableTrueFalse.js.map +1 -0
- package/dist/esm/components/comparisonTable/index.js +1683 -0
- package/dist/esm/components/comparisonTable/index.js.map +1 -0
- package/dist/esm/components/dateSelector/index.js +2180 -0
- package/dist/esm/components/dateSelector/index.js.map +1 -0
- package/dist/esm/components/dateSelector/index.test.js +65 -0
- package/dist/esm/components/dateSelector/index.test.js.map +1 -0
- package/dist/esm/components/downloadButton/index.js +36 -0
- package/dist/esm/components/downloadButton/index.js.map +1 -0
- package/dist/esm/components/downloadButton/index.stories.js +47 -0
- package/dist/esm/components/downloadButton/index.stories.js.map +1 -0
- package/dist/esm/components/input/autoSuggestInput/index.js +2157 -0
- package/dist/esm/components/input/autoSuggestInput/index.js.map +1 -0
- package/dist/esm/components/input/autoSuggestMultiSelect/index.js +41 -0
- package/dist/esm/components/input/autoSuggestMultiSelect/index.js.map +1 -0
- package/dist/esm/components/input/checkbox/index.js +58 -0
- package/dist/esm/components/input/checkbox/index.js.map +1 -0
- package/dist/esm/components/input/checkbox/index.stories.js +154 -0
- package/dist/esm/components/input/checkbox/index.stories.js.map +1 -0
- package/dist/esm/components/input/checkbox/index.test.js +106 -0
- package/dist/esm/components/input/checkbox/index.test.js.map +1 -0
- package/dist/esm/components/input/currency/index.js +63 -0
- package/dist/esm/components/input/currency/index.js.map +1 -0
- package/dist/esm/components/input/currency/index.test.js +209 -0
- package/dist/esm/components/input/currency/index.test.js.map +1 -0
- package/dist/esm/components/input/iban/index.js +33 -0
- package/dist/esm/components/input/iban/index.js.map +1 -0
- package/dist/esm/components/input/index.js +29 -0
- package/dist/esm/components/input/index.js.map +1 -0
- package/dist/esm/components/markdown/index.js +22178 -0
- package/dist/esm/components/markdown/index.js.map +1 -0
- package/dist/esm/components/markdown/index.stories.js +66 -0
- package/dist/esm/components/markdown/index.stories.js.map +1 -0
- package/dist/esm/components/modal/bottomModal/index.js +35 -0
- package/dist/esm/components/modal/bottomModal/index.js.map +1 -0
- package/dist/esm/components/modal/bottomOrRegularModal/index.js +36 -0
- package/dist/esm/components/modal/bottomOrRegularModal/index.js.map +1 -0
- package/dist/esm/components/modal/regularModal/index.js +28 -0
- package/dist/esm/components/modal/regularModal/index.js.map +1 -0
- package/dist/esm/components/multiDropzone/UploadFileCell/index.js +6 -0
- package/dist/esm/components/multiDropzone/UploadFileCell/index.js.map +1 -0
- package/dist/esm/components/multiDropzone/index.js +2862 -0
- package/dist/esm/components/multiDropzone/index.js.map +1 -0
- package/dist/esm/components/multiDropzone/index.test.js +201 -0
- package/dist/esm/components/multiDropzone/index.test.js.map +1 -0
- package/dist/esm/components/segmentedControl/index.js +42 -0
- package/dist/esm/components/segmentedControl/index.js.map +1 -0
- package/dist/esm/components/segmentedControl/index.stories.js +62 -0
- package/dist/esm/components/segmentedControl/index.stories.js.map +1 -0
- package/dist/esm/components/segmentedControl/index.test.js +63 -0
- package/dist/esm/components/segmentedControl/index.test.js.map +1 -0
- package/dist/esm/components/signaturePad/index.js +560 -0
- package/dist/esm/components/signaturePad/index.js.map +1 -0
- package/dist/esm/components/signaturePad/index.stories.js +33 -0
- package/dist/esm/components/signaturePad/index.stories.js.map +1 -0
- package/dist/esm/customRender-4157fcff.js +24102 -0
- package/dist/esm/customRender-4157fcff.js.map +1 -0
- package/dist/esm/extend-expect-46bdce4a.js +7406 -0
- package/dist/esm/extend-expect-46bdce4a.js.map +1 -0
- package/dist/esm/index-1463d5e9.js +382 -0
- package/dist/esm/index-1463d5e9.js.map +1 -0
- package/dist/esm/index-171a0108.js +997 -0
- package/dist/esm/index-171a0108.js.map +1 -0
- package/dist/esm/index-21239ab0.js +237 -0
- package/dist/esm/index-21239ab0.js.map +1 -0
- package/dist/esm/index-47663d39.js +48 -0
- package/dist/esm/index-47663d39.js.map +1 -0
- package/dist/esm/index-6ced5532.js +69 -0
- package/dist/esm/index-6ced5532.js.map +1 -0
- package/dist/esm/index-db2e797f.js +13 -0
- package/dist/esm/index-db2e797f.js.map +1 -0
- package/dist/esm/index-dd80248b.js +91 -0
- package/dist/esm/index-dd80248b.js.map +1 -0
- package/dist/esm/index-e9e37a34.js +62 -0
- package/dist/esm/index-e9e37a34.js.map +1 -0
- package/dist/esm/index-fb46adf9.js +12 -0
- package/dist/esm/index-fb46adf9.js.map +1 -0
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +50 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/lib/components/autocompleteAddress/index.d.ts +20 -0
- package/dist/esm/lib/components/autocompleteAddress/index.stories.d.ts +66 -0
- package/dist/esm/lib/components/autocompleteAddress/index.test.d.ts +1 -0
- package/dist/esm/lib/components/autocompleteAddress/mapStyle.d.ts +2 -0
- package/dist/esm/lib/components/autocompleteAddress/util/index.d.ts +4 -0
- package/dist/esm/lib/components/button/icons/index.d.ts +9 -0
- package/dist/esm/lib/components/button/index.d.ts +13 -0
- package/dist/esm/lib/components/cards/cardButton/index.d.ts +16 -0
- package/dist/esm/lib/components/cards/cardWithLeftIcon/index.d.ts +14 -0
- package/dist/esm/lib/components/cards/cardWithTopIcon/index.d.ts +15 -0
- package/dist/esm/lib/components/cards/cardWithTopLeftIcon/index.d.ts +14 -0
- package/dist/esm/lib/components/cards/icons/index.d.ts +13 -0
- package/dist/esm/lib/components/cards/index.d.ts +16 -0
- package/dist/esm/lib/components/cards/infoCard/index.d.ts +13 -0
- package/dist/esm/lib/components/chip/index.d.ts +6 -0
- package/dist/esm/lib/components/comparisonTable/components/AccordionItem/AccordionItem.d.ts +9 -0
- package/dist/esm/lib/components/comparisonTable/components/AccordionItem/index.d.ts +1 -0
- package/dist/esm/lib/components/comparisonTable/components/Chevron.d.ts +4 -0
- package/dist/esm/lib/components/comparisonTable/components/Row/index.d.ts +11 -0
- package/dist/esm/lib/components/comparisonTable/components/TableArrows/Arrow.d.ts +4 -0
- package/dist/esm/lib/components/comparisonTable/components/TableArrows/index.d.ts +10 -0
- package/dist/esm/lib/components/comparisonTable/components/TableButton/index.d.ts +8 -0
- package/dist/esm/lib/components/comparisonTable/components/TableButton/index.test.d.ts +1 -0
- package/dist/esm/lib/components/comparisonTable/components/TableInfoButton/index.d.ts +5 -0
- package/dist/esm/lib/components/comparisonTable/components/TableRating/StarIcon.d.ts +4 -0
- package/dist/esm/lib/components/comparisonTable/components/TableRating/ZapIcon.d.ts +4 -0
- package/dist/esm/lib/components/comparisonTable/components/TableRating/index.d.ts +7 -0
- package/dist/esm/lib/components/comparisonTable/components/TableRowHeader/index.d.ts +9 -0
- package/dist/esm/lib/components/comparisonTable/components/TableRowHeader/index.test.d.ts +1 -0
- package/dist/esm/lib/components/comparisonTable/components/TableTrueFalse.d.ts +5 -0
- package/dist/esm/lib/components/comparisonTable/hooks/useComparisonTable.d.ts +14 -0
- package/dist/esm/lib/components/comparisonTable/index.d.ts +52 -0
- package/dist/esm/lib/components/dateSelector/index.d.ts +23 -0
- package/dist/esm/lib/components/dateSelector/index.test.d.ts +1 -0
- package/dist/esm/lib/components/downloadButton/index.d.ts +10 -0
- package/dist/esm/lib/components/downloadButton/index.stories.d.ts +36 -0
- package/dist/esm/lib/components/input/autoSuggestInput/index.d.ts +15 -0
- package/dist/esm/lib/components/input/autoSuggestMultiSelect/index.d.ts +11 -0
- package/dist/esm/lib/components/input/checkbox/index.d.ts +17 -0
- package/dist/esm/lib/components/input/checkbox/index.stories.d.ts +64 -0
- package/dist/esm/lib/components/input/checkbox/index.test.d.ts +1 -0
- package/dist/esm/lib/components/input/currency/format/index.d.ts +2 -0
- package/dist/esm/lib/components/input/currency/index.d.ts +7 -0
- package/dist/esm/lib/components/input/currency/index.test.d.ts +1 -0
- package/dist/esm/lib/components/input/iban/formatIban/index.d.ts +1 -0
- package/dist/esm/lib/components/input/iban/index.d.ts +6 -0
- package/dist/esm/lib/components/input/index.d.ts +16 -0
- package/dist/esm/lib/components/markdown/index.d.ts +10 -0
- package/dist/esm/lib/components/markdown/index.stories.d.ts +44 -0
- package/dist/esm/lib/components/modal/bottomModal/index.d.ts +3 -0
- package/dist/esm/lib/components/modal/bottomOrRegularModal/index.d.ts +3 -0
- package/dist/esm/lib/components/modal/hooks/useOnClose.d.ts +9 -0
- package/dist/esm/lib/components/modal/index.d.ts +13 -0
- package/dist/esm/lib/components/modal/regularModal/index.d.ts +3 -0
- package/dist/esm/lib/components/multiDropzone/UploadFileCell/index.d.ts +10 -0
- package/dist/esm/lib/components/multiDropzone/icons/index.d.ts +11 -0
- package/dist/esm/lib/components/multiDropzone/index.d.ts +15 -0
- package/dist/esm/lib/components/multiDropzone/index.test.d.ts +1 -0
- package/dist/esm/lib/components/multiDropzone/types.d.ts +42 -0
- package/dist/esm/lib/components/multiDropzone/utils/index.d.ts +11 -0
- package/dist/esm/lib/components/segmentedControl/index.d.ts +12 -0
- package/dist/esm/lib/components/segmentedControl/index.stories.d.ts +37 -0
- package/dist/esm/lib/components/segmentedControl/index.test.d.ts +1 -0
- package/dist/esm/lib/components/signaturePad/index.d.ts +19 -0
- package/dist/esm/lib/components/signaturePad/index.stories.d.ts +21 -0
- package/dist/esm/lib/hooks/useOnClickOutside.d.ts +2 -0
- package/dist/esm/lib/index.d.ts +22 -0
- package/dist/esm/lib/models/autoSuggestInput/index.d.ts +4 -0
- package/dist/esm/lib/models/download.d.ts +1 -0
- package/dist/esm/lib/scss/private/base/demo.d.ts +5 -0
- package/dist/esm/lib/scss/public/demo.d.ts +2 -0
- package/dist/esm/lib/util/calendarDate/index.d.ts +3 -0
- package/dist/esm/lib/util/formatBytes/index.d.ts +1 -0
- package/dist/esm/lib/util/generateId/index.d.ts +2 -0
- package/dist/esm/lib/util/images/index.d.ts +11 -0
- package/dist/esm/lib/util/images/index.stories.d.ts +12 -0
- package/dist/esm/lib/util/testUtils/customRender.d.ts +7 -0
- package/dist/esm/lib/util/testUtils/index.d.ts +2 -0
- package/dist/esm/lib/util/zeroFill.d.ts +1 -0
- package/dist/esm/mapStyle-1288a869.js +187 -0
- package/dist/esm/mapStyle-1288a869.js.map +1 -0
- package/dist/esm/scss/private/base/demo.js +80 -0
- package/dist/esm/scss/private/base/demo.js.map +1 -0
- package/dist/esm/scss/public/demo.js +290 -0
- package/dist/esm/scss/public/demo.js.map +1 -0
- package/dist/esm/style-inject.es-1f59c1d0.js +29 -0
- package/dist/esm/style-inject.es-1f59c1d0.js.map +1 -0
- package/dist/esm/tslib.es6-5bc94358.js +104 -0
- package/dist/esm/tslib.es6-5bc94358.js.map +1 -0
- package/dist/esm/useOnClose-d818a54f.js +46 -0
- package/dist/esm/useOnClose-d818a54f.js.map +1 -0
- package/dist/esm/util/images/index.stories.js +23 -0
- package/dist/esm/util/images/index.stories.js.map +1 -0
- package/dist/esm/util/testUtils/customRender.js +7 -0
- package/dist/esm/util/testUtils/customRender.js.map +1 -0
- package/package.json +1 -1
- package/src/lib/components/input/checkbox/index.tsx +2 -1
- package/src/lib/components/input/checkbox/styles.module.scss +3 -0
- package/src/lib/components/markdown/index.stories.tsx +64 -2
- package/src/global.d.ts +0 -1
- package/src/lib/components/markdown/example.md +0 -78
|
@@ -0,0 +1,2157 @@
|
|
|
1
|
+
import { _ as __assign } from '../../../tslib.es6-5bc94358.js';
|
|
2
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
+
import { c as classnames } from '../../../index-e9e37a34.js';
|
|
4
|
+
import React__default from 'react';
|
|
5
|
+
import { p as propTypes } from '../../../index-171a0108.js';
|
|
6
|
+
import { s as styleInject } from '../../../style-inject.es-1f59c1d0.js';
|
|
7
|
+
import Input from '../index.js';
|
|
8
|
+
import '../../../index-dd80248b.js';
|
|
9
|
+
import '../../../index-fb46adf9.js';
|
|
10
|
+
|
|
11
|
+
var Autosuggest = {};
|
|
12
|
+
|
|
13
|
+
function shallowEqualArrays(arrA, arrB) {
|
|
14
|
+
if (arrA === arrB) {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (!arrA || !arrB) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
var len = arrA.length;
|
|
23
|
+
|
|
24
|
+
if (arrB.length !== len) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
for (var i = 0; i < len; i++) {
|
|
29
|
+
if (arrA[i] !== arrB[i]) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
var arrays = shallowEqualArrays;
|
|
38
|
+
|
|
39
|
+
var Autowhatever = {};
|
|
40
|
+
|
|
41
|
+
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
|
|
42
|
+
|
|
43
|
+
var dist$2 = function (_ref) {
|
|
44
|
+
var data = _ref.data;
|
|
45
|
+
var multiSection = _ref.multiSection;
|
|
46
|
+
|
|
47
|
+
function nextNonEmptySectionIndex(sectionIndex) {
|
|
48
|
+
if (sectionIndex === null) {
|
|
49
|
+
sectionIndex = 0;
|
|
50
|
+
} else {
|
|
51
|
+
sectionIndex++;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
while (sectionIndex < data.length && data[sectionIndex] === 0) {
|
|
55
|
+
sectionIndex++;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return sectionIndex === data.length ? null : sectionIndex;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function prevNonEmptySectionIndex(sectionIndex) {
|
|
62
|
+
if (sectionIndex === null) {
|
|
63
|
+
sectionIndex = data.length - 1;
|
|
64
|
+
} else {
|
|
65
|
+
sectionIndex--;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
while (sectionIndex >= 0 && data[sectionIndex] === 0) {
|
|
69
|
+
sectionIndex--;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return sectionIndex === -1 ? null : sectionIndex;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function next(position) {
|
|
76
|
+
var _position = _slicedToArray(position, 2);
|
|
77
|
+
|
|
78
|
+
var sectionIndex = _position[0];
|
|
79
|
+
var itemIndex = _position[1];
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
if (multiSection) {
|
|
83
|
+
if (itemIndex === null || itemIndex === data[sectionIndex] - 1) {
|
|
84
|
+
sectionIndex = nextNonEmptySectionIndex(sectionIndex);
|
|
85
|
+
|
|
86
|
+
if (sectionIndex === null) {
|
|
87
|
+
return [null, null];
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return [sectionIndex, 0];
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return [sectionIndex, itemIndex + 1];
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (data === 0 || itemIndex === data - 1) {
|
|
97
|
+
return [null, null];
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (itemIndex === null) {
|
|
101
|
+
return [null, 0];
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return [null, itemIndex + 1];
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function prev(position) {
|
|
108
|
+
var _position2 = _slicedToArray(position, 2);
|
|
109
|
+
|
|
110
|
+
var sectionIndex = _position2[0];
|
|
111
|
+
var itemIndex = _position2[1];
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
if (multiSection) {
|
|
115
|
+
if (itemIndex === null || itemIndex === 0) {
|
|
116
|
+
sectionIndex = prevNonEmptySectionIndex(sectionIndex);
|
|
117
|
+
|
|
118
|
+
if (sectionIndex === null) {
|
|
119
|
+
return [null, null];
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return [sectionIndex, data[sectionIndex] - 1];
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return [sectionIndex, itemIndex - 1];
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (data === 0 || itemIndex === 0) {
|
|
129
|
+
return [null, null];
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (itemIndex === null) {
|
|
133
|
+
return [null, data - 1];
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return [null, itemIndex - 1];
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function isLast(position) {
|
|
140
|
+
return next(position)[1] === null;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return {
|
|
144
|
+
next: next,
|
|
145
|
+
prev: prev,
|
|
146
|
+
isLast: isLast
|
|
147
|
+
};
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
var dist$1 = {exports: {}};
|
|
151
|
+
|
|
152
|
+
var propIsEnumerable = Object.prototype.propertyIsEnumerable;
|
|
153
|
+
|
|
154
|
+
function ToObject(val) {
|
|
155
|
+
if (val == null) {
|
|
156
|
+
throw new TypeError('Object.assign cannot be called with null or undefined');
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return Object(val);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function ownEnumerableKeys(obj) {
|
|
163
|
+
var keys = Object.getOwnPropertyNames(obj);
|
|
164
|
+
|
|
165
|
+
if (Object.getOwnPropertySymbols) {
|
|
166
|
+
keys = keys.concat(Object.getOwnPropertySymbols(obj));
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
return keys.filter(function (key) {
|
|
170
|
+
return propIsEnumerable.call(obj, key);
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
var objectAssign = Object.assign || function (target, source) {
|
|
175
|
+
var from;
|
|
176
|
+
var keys;
|
|
177
|
+
var to = ToObject(target);
|
|
178
|
+
|
|
179
|
+
for (var s = 1; s < arguments.length; s++) {
|
|
180
|
+
from = arguments[s];
|
|
181
|
+
keys = ownEnumerableKeys(Object(from));
|
|
182
|
+
|
|
183
|
+
for (var i = 0; i < keys.length; i++) {
|
|
184
|
+
to[keys[i]] = from[keys[i]];
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
return to;
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
(function (module, exports) {
|
|
192
|
+
|
|
193
|
+
Object.defineProperty(exports, '__esModule', {
|
|
194
|
+
value: true
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
var _slicedToArray = (function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i['return']) _i['return'](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError('Invalid attempt to destructure non-iterable instance'); } }; })();
|
|
198
|
+
|
|
199
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
|
200
|
+
|
|
201
|
+
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; return arr2; } else { return Array.from(arr); } }
|
|
202
|
+
|
|
203
|
+
var _objectAssign = objectAssign;
|
|
204
|
+
|
|
205
|
+
var _objectAssign2 = _interopRequireDefault(_objectAssign);
|
|
206
|
+
|
|
207
|
+
var truthy = function truthy(x) {
|
|
208
|
+
return x;
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
exports['default'] = function (input) {
|
|
212
|
+
var _ref = Array.isArray(input) && input.length === 2 ? input : [input, null];
|
|
213
|
+
|
|
214
|
+
var _ref2 = _slicedToArray(_ref, 2);
|
|
215
|
+
|
|
216
|
+
var theme = _ref2[0];
|
|
217
|
+
var classNameDecorator = _ref2[1];
|
|
218
|
+
|
|
219
|
+
return function (key) {
|
|
220
|
+
for (var _len = arguments.length, names = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
221
|
+
names[_key - 1] = arguments[_key];
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
var styles = names.map(function (name) {
|
|
225
|
+
return theme[name];
|
|
226
|
+
}).filter(truthy);
|
|
227
|
+
|
|
228
|
+
return typeof styles[0] === 'string' || typeof classNameDecorator === 'function' ? { key: key, className: classNameDecorator ? classNameDecorator.apply(undefined, _toConsumableArray(styles)) : styles.join(' ') } : { key: key, style: _objectAssign2['default'].apply(undefined, [{}].concat(_toConsumableArray(styles))) };
|
|
229
|
+
};
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
module.exports = exports['default'];
|
|
233
|
+
}(dist$1, dist$1.exports));
|
|
234
|
+
|
|
235
|
+
var SectionTitle = {};
|
|
236
|
+
|
|
237
|
+
var compareObjects = {};
|
|
238
|
+
|
|
239
|
+
(function (exports) {
|
|
240
|
+
|
|
241
|
+
Object.defineProperty(exports, "__esModule", {
|
|
242
|
+
value: true
|
|
243
|
+
});
|
|
244
|
+
exports["default"] = compareObjects;
|
|
245
|
+
|
|
246
|
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
247
|
+
|
|
248
|
+
function compareObjects(objA, objB) {
|
|
249
|
+
var keys = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
250
|
+
|
|
251
|
+
if (objA === objB) {
|
|
252
|
+
return false;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
var aKeys = Object.keys(objA);
|
|
256
|
+
var bKeys = Object.keys(objB);
|
|
257
|
+
|
|
258
|
+
if (aKeys.length !== bKeys.length) {
|
|
259
|
+
return true;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
var keysMap = {};
|
|
263
|
+
var i, len;
|
|
264
|
+
|
|
265
|
+
for (i = 0, len = keys.length; i < len; i++) {
|
|
266
|
+
keysMap[keys[i]] = true;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
for (i = 0, len = aKeys.length; i < len; i++) {
|
|
270
|
+
var key = aKeys[i];
|
|
271
|
+
var aValue = objA[key];
|
|
272
|
+
var bValue = objB[key];
|
|
273
|
+
|
|
274
|
+
if (aValue === bValue) {
|
|
275
|
+
continue;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
if (!keysMap[key] || aValue === null || bValue === null || _typeof(aValue) !== 'object' || _typeof(bValue) !== 'object') {
|
|
279
|
+
return true;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
var aValueKeys = Object.keys(aValue);
|
|
283
|
+
var bValueKeys = Object.keys(bValue);
|
|
284
|
+
|
|
285
|
+
if (aValueKeys.length !== bValueKeys.length) {
|
|
286
|
+
return true;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
for (var n = 0, length = aValueKeys.length; n < length; n++) {
|
|
290
|
+
var aValueKey = aValueKeys[n];
|
|
291
|
+
|
|
292
|
+
if (aValue[aValueKey] !== bValue[aValueKey]) {
|
|
293
|
+
return true;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
return false;
|
|
299
|
+
}
|
|
300
|
+
}(compareObjects));
|
|
301
|
+
|
|
302
|
+
(function (exports) {
|
|
303
|
+
|
|
304
|
+
Object.defineProperty(exports, "__esModule", {
|
|
305
|
+
value: true
|
|
306
|
+
});
|
|
307
|
+
exports["default"] = void 0;
|
|
308
|
+
|
|
309
|
+
var _react = _interopRequireWildcard(React__default);
|
|
310
|
+
|
|
311
|
+
var _propTypes = _interopRequireDefault(propTypes.exports);
|
|
312
|
+
|
|
313
|
+
var _compareObjects = _interopRequireDefault(compareObjects);
|
|
314
|
+
|
|
315
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
316
|
+
|
|
317
|
+
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
|
318
|
+
|
|
319
|
+
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
320
|
+
|
|
321
|
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
322
|
+
|
|
323
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
324
|
+
|
|
325
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
326
|
+
|
|
327
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
328
|
+
|
|
329
|
+
function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
330
|
+
|
|
331
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
332
|
+
|
|
333
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
334
|
+
|
|
335
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
|
336
|
+
|
|
337
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
338
|
+
|
|
339
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
340
|
+
|
|
341
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
342
|
+
|
|
343
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
344
|
+
|
|
345
|
+
var SectionTitle = /*#__PURE__*/function (_Component) {
|
|
346
|
+
_inherits(SectionTitle, _Component);
|
|
347
|
+
|
|
348
|
+
var _super = _createSuper(SectionTitle);
|
|
349
|
+
|
|
350
|
+
function SectionTitle() {
|
|
351
|
+
_classCallCheck(this, SectionTitle);
|
|
352
|
+
|
|
353
|
+
return _super.apply(this, arguments);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
_createClass(SectionTitle, [{
|
|
357
|
+
key: "shouldComponentUpdate",
|
|
358
|
+
value: function shouldComponentUpdate(nextProps) {
|
|
359
|
+
return (0, _compareObjects["default"])(nextProps, this.props);
|
|
360
|
+
}
|
|
361
|
+
}, {
|
|
362
|
+
key: "render",
|
|
363
|
+
value: function render() {
|
|
364
|
+
var _this$props = this.props,
|
|
365
|
+
section = _this$props.section,
|
|
366
|
+
renderSectionTitle = _this$props.renderSectionTitle,
|
|
367
|
+
theme = _this$props.theme,
|
|
368
|
+
sectionKeyPrefix = _this$props.sectionKeyPrefix;
|
|
369
|
+
var sectionTitle = renderSectionTitle(section);
|
|
370
|
+
|
|
371
|
+
if (!sectionTitle) {
|
|
372
|
+
return null;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
return /*#__PURE__*/_react["default"].createElement("div", theme("".concat(sectionKeyPrefix, "title"), 'sectionTitle'), sectionTitle);
|
|
376
|
+
}
|
|
377
|
+
}]);
|
|
378
|
+
|
|
379
|
+
return SectionTitle;
|
|
380
|
+
}(_react.Component);
|
|
381
|
+
|
|
382
|
+
exports["default"] = SectionTitle;
|
|
383
|
+
|
|
384
|
+
_defineProperty(SectionTitle, "propTypes", {
|
|
385
|
+
section: _propTypes["default"].any.isRequired,
|
|
386
|
+
renderSectionTitle: _propTypes["default"].func.isRequired,
|
|
387
|
+
theme: _propTypes["default"].func.isRequired,
|
|
388
|
+
sectionKeyPrefix: _propTypes["default"].string.isRequired
|
|
389
|
+
});
|
|
390
|
+
}(SectionTitle));
|
|
391
|
+
|
|
392
|
+
var ItemList = {};
|
|
393
|
+
|
|
394
|
+
var Item = {};
|
|
395
|
+
|
|
396
|
+
(function (exports) {
|
|
397
|
+
|
|
398
|
+
Object.defineProperty(exports, "__esModule", {
|
|
399
|
+
value: true
|
|
400
|
+
});
|
|
401
|
+
exports["default"] = void 0;
|
|
402
|
+
|
|
403
|
+
var _react = _interopRequireWildcard(React__default);
|
|
404
|
+
|
|
405
|
+
var _propTypes = _interopRequireDefault(propTypes.exports);
|
|
406
|
+
|
|
407
|
+
var _compareObjects = _interopRequireDefault(compareObjects);
|
|
408
|
+
|
|
409
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
410
|
+
|
|
411
|
+
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
|
412
|
+
|
|
413
|
+
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
414
|
+
|
|
415
|
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
416
|
+
|
|
417
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
418
|
+
|
|
419
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
420
|
+
|
|
421
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
422
|
+
|
|
423
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
424
|
+
|
|
425
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
426
|
+
|
|
427
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
428
|
+
|
|
429
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
430
|
+
|
|
431
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
432
|
+
|
|
433
|
+
function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
434
|
+
|
|
435
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
436
|
+
|
|
437
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
438
|
+
|
|
439
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
|
440
|
+
|
|
441
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
442
|
+
|
|
443
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
444
|
+
|
|
445
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
446
|
+
|
|
447
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
448
|
+
|
|
449
|
+
var Item = /*#__PURE__*/function (_Component) {
|
|
450
|
+
_inherits(Item, _Component);
|
|
451
|
+
|
|
452
|
+
var _super = _createSuper(Item);
|
|
453
|
+
|
|
454
|
+
function Item() {
|
|
455
|
+
var _this;
|
|
456
|
+
|
|
457
|
+
_classCallCheck(this, Item);
|
|
458
|
+
|
|
459
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
460
|
+
args[_key] = arguments[_key];
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
464
|
+
|
|
465
|
+
_defineProperty(_assertThisInitialized(_this), "storeItemReference", function (item) {
|
|
466
|
+
if (item !== null) {
|
|
467
|
+
_this.item = item;
|
|
468
|
+
}
|
|
469
|
+
});
|
|
470
|
+
|
|
471
|
+
_defineProperty(_assertThisInitialized(_this), "onMouseEnter", function (event) {
|
|
472
|
+
var _this$props = _this.props,
|
|
473
|
+
sectionIndex = _this$props.sectionIndex,
|
|
474
|
+
itemIndex = _this$props.itemIndex;
|
|
475
|
+
|
|
476
|
+
_this.props.onMouseEnter(event, {
|
|
477
|
+
sectionIndex: sectionIndex,
|
|
478
|
+
itemIndex: itemIndex
|
|
479
|
+
});
|
|
480
|
+
});
|
|
481
|
+
|
|
482
|
+
_defineProperty(_assertThisInitialized(_this), "onMouseLeave", function (event) {
|
|
483
|
+
var _this$props2 = _this.props,
|
|
484
|
+
sectionIndex = _this$props2.sectionIndex,
|
|
485
|
+
itemIndex = _this$props2.itemIndex;
|
|
486
|
+
|
|
487
|
+
_this.props.onMouseLeave(event, {
|
|
488
|
+
sectionIndex: sectionIndex,
|
|
489
|
+
itemIndex: itemIndex
|
|
490
|
+
});
|
|
491
|
+
});
|
|
492
|
+
|
|
493
|
+
_defineProperty(_assertThisInitialized(_this), "onMouseDown", function (event) {
|
|
494
|
+
var _this$props3 = _this.props,
|
|
495
|
+
sectionIndex = _this$props3.sectionIndex,
|
|
496
|
+
itemIndex = _this$props3.itemIndex;
|
|
497
|
+
|
|
498
|
+
_this.props.onMouseDown(event, {
|
|
499
|
+
sectionIndex: sectionIndex,
|
|
500
|
+
itemIndex: itemIndex
|
|
501
|
+
});
|
|
502
|
+
});
|
|
503
|
+
|
|
504
|
+
_defineProperty(_assertThisInitialized(_this), "onClick", function (event) {
|
|
505
|
+
var _this$props4 = _this.props,
|
|
506
|
+
sectionIndex = _this$props4.sectionIndex,
|
|
507
|
+
itemIndex = _this$props4.itemIndex;
|
|
508
|
+
|
|
509
|
+
_this.props.onClick(event, {
|
|
510
|
+
sectionIndex: sectionIndex,
|
|
511
|
+
itemIndex: itemIndex
|
|
512
|
+
});
|
|
513
|
+
});
|
|
514
|
+
|
|
515
|
+
return _this;
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
_createClass(Item, [{
|
|
519
|
+
key: "shouldComponentUpdate",
|
|
520
|
+
value: function shouldComponentUpdate(nextProps) {
|
|
521
|
+
return (0, _compareObjects["default"])(nextProps, this.props, ['renderItemData']);
|
|
522
|
+
}
|
|
523
|
+
}, {
|
|
524
|
+
key: "render",
|
|
525
|
+
value: function render() {
|
|
526
|
+
var _this$props5 = this.props,
|
|
527
|
+
isHighlighted = _this$props5.isHighlighted,
|
|
528
|
+
item = _this$props5.item,
|
|
529
|
+
renderItem = _this$props5.renderItem,
|
|
530
|
+
renderItemData = _this$props5.renderItemData,
|
|
531
|
+
restProps = _objectWithoutProperties(_this$props5, ["isHighlighted", "item", "renderItem", "renderItemData"]);
|
|
532
|
+
|
|
533
|
+
delete restProps.sectionIndex;
|
|
534
|
+
delete restProps.itemIndex;
|
|
535
|
+
|
|
536
|
+
if (typeof restProps.onMouseEnter === 'function') {
|
|
537
|
+
restProps.onMouseEnter = this.onMouseEnter;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
if (typeof restProps.onMouseLeave === 'function') {
|
|
541
|
+
restProps.onMouseLeave = this.onMouseLeave;
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
if (typeof restProps.onMouseDown === 'function') {
|
|
545
|
+
restProps.onMouseDown = this.onMouseDown;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
if (typeof restProps.onClick === 'function') {
|
|
549
|
+
restProps.onClick = this.onClick;
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
return /*#__PURE__*/_react["default"].createElement("li", _extends({
|
|
553
|
+
role: "option"
|
|
554
|
+
}, restProps, {
|
|
555
|
+
ref: this.storeItemReference
|
|
556
|
+
}), renderItem(item, _objectSpread({
|
|
557
|
+
isHighlighted: isHighlighted
|
|
558
|
+
}, renderItemData)));
|
|
559
|
+
}
|
|
560
|
+
}]);
|
|
561
|
+
|
|
562
|
+
return Item;
|
|
563
|
+
}(_react.Component);
|
|
564
|
+
|
|
565
|
+
exports["default"] = Item;
|
|
566
|
+
|
|
567
|
+
_defineProperty(Item, "propTypes", {
|
|
568
|
+
sectionIndex: _propTypes["default"].number,
|
|
569
|
+
isHighlighted: _propTypes["default"].bool.isRequired,
|
|
570
|
+
itemIndex: _propTypes["default"].number.isRequired,
|
|
571
|
+
item: _propTypes["default"].any.isRequired,
|
|
572
|
+
renderItem: _propTypes["default"].func.isRequired,
|
|
573
|
+
renderItemData: _propTypes["default"].object.isRequired,
|
|
574
|
+
onMouseEnter: _propTypes["default"].func,
|
|
575
|
+
onMouseLeave: _propTypes["default"].func,
|
|
576
|
+
onMouseDown: _propTypes["default"].func,
|
|
577
|
+
onClick: _propTypes["default"].func
|
|
578
|
+
});
|
|
579
|
+
}(Item));
|
|
580
|
+
|
|
581
|
+
(function (exports) {
|
|
582
|
+
|
|
583
|
+
Object.defineProperty(exports, "__esModule", {
|
|
584
|
+
value: true
|
|
585
|
+
});
|
|
586
|
+
exports["default"] = void 0;
|
|
587
|
+
|
|
588
|
+
var _react = _interopRequireWildcard(React__default);
|
|
589
|
+
|
|
590
|
+
var _propTypes = _interopRequireDefault(propTypes.exports);
|
|
591
|
+
|
|
592
|
+
var _Item = _interopRequireDefault(Item);
|
|
593
|
+
|
|
594
|
+
var _compareObjects = _interopRequireDefault(compareObjects);
|
|
595
|
+
|
|
596
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
597
|
+
|
|
598
|
+
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
|
599
|
+
|
|
600
|
+
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
601
|
+
|
|
602
|
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
603
|
+
|
|
604
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
605
|
+
|
|
606
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
607
|
+
|
|
608
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
609
|
+
|
|
610
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
611
|
+
|
|
612
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
613
|
+
|
|
614
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
615
|
+
|
|
616
|
+
function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
617
|
+
|
|
618
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
619
|
+
|
|
620
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
621
|
+
|
|
622
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
|
623
|
+
|
|
624
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
625
|
+
|
|
626
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
627
|
+
|
|
628
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
629
|
+
|
|
630
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
631
|
+
|
|
632
|
+
var ItemsList = /*#__PURE__*/function (_Component) {
|
|
633
|
+
_inherits(ItemsList, _Component);
|
|
634
|
+
|
|
635
|
+
var _super = _createSuper(ItemsList);
|
|
636
|
+
|
|
637
|
+
function ItemsList() {
|
|
638
|
+
var _this;
|
|
639
|
+
|
|
640
|
+
_classCallCheck(this, ItemsList);
|
|
641
|
+
|
|
642
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
643
|
+
args[_key] = arguments[_key];
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
647
|
+
|
|
648
|
+
_defineProperty(_assertThisInitialized(_this), "storeHighlightedItemReference", function (highlightedItem) {
|
|
649
|
+
_this.props.onHighlightedItemChange(highlightedItem === null ? null : highlightedItem.item);
|
|
650
|
+
});
|
|
651
|
+
|
|
652
|
+
return _this;
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
_createClass(ItemsList, [{
|
|
656
|
+
key: "shouldComponentUpdate",
|
|
657
|
+
value: function shouldComponentUpdate(nextProps) {
|
|
658
|
+
return (0, _compareObjects["default"])(nextProps, this.props, ['itemProps']);
|
|
659
|
+
}
|
|
660
|
+
}, {
|
|
661
|
+
key: "render",
|
|
662
|
+
value: function render() {
|
|
663
|
+
var _this2 = this;
|
|
664
|
+
|
|
665
|
+
var _this$props = this.props,
|
|
666
|
+
items = _this$props.items,
|
|
667
|
+
itemProps = _this$props.itemProps,
|
|
668
|
+
renderItem = _this$props.renderItem,
|
|
669
|
+
renderItemData = _this$props.renderItemData,
|
|
670
|
+
sectionIndex = _this$props.sectionIndex,
|
|
671
|
+
highlightedItemIndex = _this$props.highlightedItemIndex,
|
|
672
|
+
getItemId = _this$props.getItemId,
|
|
673
|
+
theme = _this$props.theme,
|
|
674
|
+
keyPrefix = _this$props.keyPrefix;
|
|
675
|
+
var sectionPrefix = sectionIndex === null ? keyPrefix : "".concat(keyPrefix, "section-").concat(sectionIndex, "-");
|
|
676
|
+
var isItemPropsFunction = typeof itemProps === 'function';
|
|
677
|
+
return /*#__PURE__*/_react["default"].createElement("ul", _extends({
|
|
678
|
+
role: "listbox"
|
|
679
|
+
}, theme("".concat(sectionPrefix, "items-list"), 'itemsList')), items.map(function (item, itemIndex) {
|
|
680
|
+
var isFirst = itemIndex === 0;
|
|
681
|
+
var isHighlighted = itemIndex === highlightedItemIndex;
|
|
682
|
+
var itemKey = "".concat(sectionPrefix, "item-").concat(itemIndex);
|
|
683
|
+
var itemPropsObj = isItemPropsFunction ? itemProps({
|
|
684
|
+
sectionIndex: sectionIndex,
|
|
685
|
+
itemIndex: itemIndex
|
|
686
|
+
}) : itemProps;
|
|
687
|
+
|
|
688
|
+
var allItemProps = _objectSpread({
|
|
689
|
+
id: getItemId(sectionIndex, itemIndex),
|
|
690
|
+
'aria-selected': isHighlighted
|
|
691
|
+
}, theme(itemKey, 'item', isFirst && 'itemFirst', isHighlighted && 'itemHighlighted'), {}, itemPropsObj);
|
|
692
|
+
|
|
693
|
+
if (isHighlighted) {
|
|
694
|
+
allItemProps.ref = _this2.storeHighlightedItemReference;
|
|
695
|
+
} // `key` is provided by theme()
|
|
696
|
+
|
|
697
|
+
/* eslint-disable react/jsx-key */
|
|
698
|
+
|
|
699
|
+
|
|
700
|
+
return /*#__PURE__*/_react["default"].createElement(_Item["default"], _extends({}, allItemProps, {
|
|
701
|
+
sectionIndex: sectionIndex,
|
|
702
|
+
isHighlighted: isHighlighted,
|
|
703
|
+
itemIndex: itemIndex,
|
|
704
|
+
item: item,
|
|
705
|
+
renderItem: renderItem,
|
|
706
|
+
renderItemData: renderItemData
|
|
707
|
+
}));
|
|
708
|
+
/* eslint-enable react/jsx-key */
|
|
709
|
+
}));
|
|
710
|
+
}
|
|
711
|
+
}]);
|
|
712
|
+
|
|
713
|
+
return ItemsList;
|
|
714
|
+
}(_react.Component);
|
|
715
|
+
|
|
716
|
+
exports["default"] = ItemsList;
|
|
717
|
+
|
|
718
|
+
_defineProperty(ItemsList, "propTypes", {
|
|
719
|
+
items: _propTypes["default"].array.isRequired,
|
|
720
|
+
itemProps: _propTypes["default"].oneOfType([_propTypes["default"].object, _propTypes["default"].func]),
|
|
721
|
+
renderItem: _propTypes["default"].func.isRequired,
|
|
722
|
+
renderItemData: _propTypes["default"].object.isRequired,
|
|
723
|
+
sectionIndex: _propTypes["default"].number,
|
|
724
|
+
highlightedItemIndex: _propTypes["default"].number,
|
|
725
|
+
onHighlightedItemChange: _propTypes["default"].func.isRequired,
|
|
726
|
+
getItemId: _propTypes["default"].func.isRequired,
|
|
727
|
+
theme: _propTypes["default"].func.isRequired,
|
|
728
|
+
keyPrefix: _propTypes["default"].string.isRequired
|
|
729
|
+
});
|
|
730
|
+
|
|
731
|
+
_defineProperty(ItemsList, "defaultProps", {
|
|
732
|
+
sectionIndex: null
|
|
733
|
+
});
|
|
734
|
+
}(ItemList));
|
|
735
|
+
|
|
736
|
+
(function (exports) {
|
|
737
|
+
|
|
738
|
+
Object.defineProperty(exports, "__esModule", {
|
|
739
|
+
value: true
|
|
740
|
+
});
|
|
741
|
+
exports["default"] = void 0;
|
|
742
|
+
|
|
743
|
+
var _react = _interopRequireWildcard(React__default);
|
|
744
|
+
|
|
745
|
+
var _propTypes = _interopRequireDefault(propTypes.exports);
|
|
746
|
+
|
|
747
|
+
var _sectionIterator = _interopRequireDefault(dist$2);
|
|
748
|
+
|
|
749
|
+
var _reactThemeable = _interopRequireDefault(dist$1.exports);
|
|
750
|
+
|
|
751
|
+
var _SectionTitle = _interopRequireDefault(SectionTitle);
|
|
752
|
+
|
|
753
|
+
var _ItemList = _interopRequireDefault(ItemList);
|
|
754
|
+
|
|
755
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
756
|
+
|
|
757
|
+
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
|
758
|
+
|
|
759
|
+
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
760
|
+
|
|
761
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
762
|
+
|
|
763
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
764
|
+
|
|
765
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
766
|
+
|
|
767
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
768
|
+
|
|
769
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
770
|
+
|
|
771
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
772
|
+
|
|
773
|
+
function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
774
|
+
|
|
775
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
776
|
+
|
|
777
|
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
778
|
+
|
|
779
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
780
|
+
|
|
781
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
782
|
+
|
|
783
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
784
|
+
|
|
785
|
+
function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
786
|
+
|
|
787
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
788
|
+
|
|
789
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
790
|
+
|
|
791
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
|
792
|
+
|
|
793
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
794
|
+
|
|
795
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
796
|
+
|
|
797
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
798
|
+
|
|
799
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
800
|
+
|
|
801
|
+
var emptyObject = {};
|
|
802
|
+
|
|
803
|
+
var defaultRenderInputComponent = function defaultRenderInputComponent(props) {
|
|
804
|
+
return /*#__PURE__*/_react["default"].createElement("input", props);
|
|
805
|
+
};
|
|
806
|
+
|
|
807
|
+
var defaultRenderItemsContainer = function defaultRenderItemsContainer(_ref) {
|
|
808
|
+
var containerProps = _ref.containerProps,
|
|
809
|
+
children = _ref.children;
|
|
810
|
+
return /*#__PURE__*/_react["default"].createElement("div", containerProps, children);
|
|
811
|
+
};
|
|
812
|
+
|
|
813
|
+
var defaultTheme = {
|
|
814
|
+
container: 'react-autowhatever__container',
|
|
815
|
+
containerOpen: 'react-autowhatever__container--open',
|
|
816
|
+
input: 'react-autowhatever__input',
|
|
817
|
+
inputOpen: 'react-autowhatever__input--open',
|
|
818
|
+
inputFocused: 'react-autowhatever__input--focused',
|
|
819
|
+
itemsContainer: 'react-autowhatever__items-container',
|
|
820
|
+
itemsContainerOpen: 'react-autowhatever__items-container--open',
|
|
821
|
+
itemsList: 'react-autowhatever__items-list',
|
|
822
|
+
item: 'react-autowhatever__item',
|
|
823
|
+
itemFirst: 'react-autowhatever__item--first',
|
|
824
|
+
itemHighlighted: 'react-autowhatever__item--highlighted',
|
|
825
|
+
sectionContainer: 'react-autowhatever__section-container',
|
|
826
|
+
sectionContainerFirst: 'react-autowhatever__section-container--first',
|
|
827
|
+
sectionTitle: 'react-autowhatever__section-title'
|
|
828
|
+
};
|
|
829
|
+
|
|
830
|
+
var Autowhatever = /*#__PURE__*/function (_Component) {
|
|
831
|
+
_inherits(Autowhatever, _Component);
|
|
832
|
+
|
|
833
|
+
var _super = _createSuper(Autowhatever);
|
|
834
|
+
|
|
835
|
+
function Autowhatever(props) {
|
|
836
|
+
var _this;
|
|
837
|
+
|
|
838
|
+
_classCallCheck(this, Autowhatever);
|
|
839
|
+
|
|
840
|
+
_this = _super.call(this, props);
|
|
841
|
+
|
|
842
|
+
_defineProperty(_assertThisInitialized(_this), "storeInputReference", function (input) {
|
|
843
|
+
if (input !== null) {
|
|
844
|
+
_this.input = input;
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
var userRef = _this.props.inputProps.ref;
|
|
848
|
+
|
|
849
|
+
if (userRef) {
|
|
850
|
+
if (typeof userRef === 'function') {
|
|
851
|
+
userRef(input);
|
|
852
|
+
} else if (_typeof(userRef) === 'object' && Object.prototype.hasOwnProperty.call(userRef, 'current')) {
|
|
853
|
+
userRef.current = input;
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
});
|
|
857
|
+
|
|
858
|
+
_defineProperty(_assertThisInitialized(_this), "storeItemsContainerReference", function (itemsContainer) {
|
|
859
|
+
if (itemsContainer !== null) {
|
|
860
|
+
_this.itemsContainer = itemsContainer;
|
|
861
|
+
}
|
|
862
|
+
});
|
|
863
|
+
|
|
864
|
+
_defineProperty(_assertThisInitialized(_this), "onHighlightedItemChange", function (highlightedItem) {
|
|
865
|
+
_this.highlightedItem = highlightedItem;
|
|
866
|
+
});
|
|
867
|
+
|
|
868
|
+
_defineProperty(_assertThisInitialized(_this), "getItemId", function (sectionIndex, itemIndex) {
|
|
869
|
+
if (itemIndex === null) {
|
|
870
|
+
return null;
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
var id = _this.props.id;
|
|
874
|
+
var section = sectionIndex === null ? '' : "section-".concat(sectionIndex);
|
|
875
|
+
return "react-autowhatever-".concat(id, "-").concat(section, "-item-").concat(itemIndex);
|
|
876
|
+
});
|
|
877
|
+
|
|
878
|
+
_defineProperty(_assertThisInitialized(_this), "onFocus", function (event) {
|
|
879
|
+
var inputProps = _this.props.inputProps;
|
|
880
|
+
|
|
881
|
+
_this.setState({
|
|
882
|
+
isInputFocused: true
|
|
883
|
+
});
|
|
884
|
+
|
|
885
|
+
inputProps.onFocus && inputProps.onFocus(event);
|
|
886
|
+
});
|
|
887
|
+
|
|
888
|
+
_defineProperty(_assertThisInitialized(_this), "onBlur", function (event) {
|
|
889
|
+
var inputProps = _this.props.inputProps;
|
|
890
|
+
|
|
891
|
+
_this.setState({
|
|
892
|
+
isInputFocused: false
|
|
893
|
+
});
|
|
894
|
+
|
|
895
|
+
inputProps.onBlur && inputProps.onBlur(event);
|
|
896
|
+
});
|
|
897
|
+
|
|
898
|
+
_defineProperty(_assertThisInitialized(_this), "onKeyDown", function (event) {
|
|
899
|
+
var _this$props = _this.props,
|
|
900
|
+
inputProps = _this$props.inputProps,
|
|
901
|
+
highlightedSectionIndex = _this$props.highlightedSectionIndex,
|
|
902
|
+
highlightedItemIndex = _this$props.highlightedItemIndex;
|
|
903
|
+
var keyCode = event.keyCode;
|
|
904
|
+
|
|
905
|
+
switch (keyCode) {
|
|
906
|
+
case 40: // ArrowDown
|
|
907
|
+
|
|
908
|
+
case 38:
|
|
909
|
+
{
|
|
910
|
+
// ArrowUp
|
|
911
|
+
var nextPrev = keyCode === 40 ? 'next' : 'prev';
|
|
912
|
+
|
|
913
|
+
var _this$sectionIterator = _this.sectionIterator[nextPrev]([highlightedSectionIndex, highlightedItemIndex]),
|
|
914
|
+
_this$sectionIterator2 = _slicedToArray(_this$sectionIterator, 2),
|
|
915
|
+
newHighlightedSectionIndex = _this$sectionIterator2[0],
|
|
916
|
+
newHighlightedItemIndex = _this$sectionIterator2[1];
|
|
917
|
+
|
|
918
|
+
inputProps.onKeyDown(event, {
|
|
919
|
+
newHighlightedSectionIndex: newHighlightedSectionIndex,
|
|
920
|
+
newHighlightedItemIndex: newHighlightedItemIndex
|
|
921
|
+
});
|
|
922
|
+
break;
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
default:
|
|
926
|
+
inputProps.onKeyDown(event, {
|
|
927
|
+
highlightedSectionIndex: highlightedSectionIndex,
|
|
928
|
+
highlightedItemIndex: highlightedItemIndex
|
|
929
|
+
});
|
|
930
|
+
}
|
|
931
|
+
});
|
|
932
|
+
|
|
933
|
+
_this.highlightedItem = null;
|
|
934
|
+
_this.state = {
|
|
935
|
+
isInputFocused: false
|
|
936
|
+
};
|
|
937
|
+
|
|
938
|
+
_this.setSectionsItems(props);
|
|
939
|
+
|
|
940
|
+
_this.setSectionIterator(props);
|
|
941
|
+
|
|
942
|
+
_this.setTheme(props);
|
|
943
|
+
|
|
944
|
+
return _this;
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
_createClass(Autowhatever, [{
|
|
948
|
+
key: "componentDidMount",
|
|
949
|
+
value: function componentDidMount() {
|
|
950
|
+
this.ensureHighlightedItemIsVisible();
|
|
951
|
+
} // eslint-disable-next-line camelcase, react/sort-comp
|
|
952
|
+
|
|
953
|
+
}, {
|
|
954
|
+
key: "UNSAFE_componentWillReceiveProps",
|
|
955
|
+
value: function UNSAFE_componentWillReceiveProps(nextProps) {
|
|
956
|
+
if (nextProps.items !== this.props.items) {
|
|
957
|
+
this.setSectionsItems(nextProps);
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
if (nextProps.items !== this.props.items || nextProps.multiSection !== this.props.multiSection) {
|
|
961
|
+
this.setSectionIterator(nextProps);
|
|
962
|
+
}
|
|
963
|
+
|
|
964
|
+
if (nextProps.theme !== this.props.theme) {
|
|
965
|
+
this.setTheme(nextProps);
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
}, {
|
|
969
|
+
key: "componentDidUpdate",
|
|
970
|
+
value: function componentDidUpdate() {
|
|
971
|
+
this.ensureHighlightedItemIsVisible();
|
|
972
|
+
}
|
|
973
|
+
}, {
|
|
974
|
+
key: "setSectionsItems",
|
|
975
|
+
value: function setSectionsItems(props) {
|
|
976
|
+
if (props.multiSection) {
|
|
977
|
+
this.sectionsItems = props.items.map(function (section) {
|
|
978
|
+
return props.getSectionItems(section);
|
|
979
|
+
});
|
|
980
|
+
this.sectionsLengths = this.sectionsItems.map(function (items) {
|
|
981
|
+
return items.length;
|
|
982
|
+
});
|
|
983
|
+
this.allSectionsAreEmpty = this.sectionsLengths.every(function (itemsCount) {
|
|
984
|
+
return itemsCount === 0;
|
|
985
|
+
});
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
}, {
|
|
989
|
+
key: "setSectionIterator",
|
|
990
|
+
value: function setSectionIterator(props) {
|
|
991
|
+
this.sectionIterator = (0, _sectionIterator["default"])({
|
|
992
|
+
multiSection: props.multiSection,
|
|
993
|
+
data: props.multiSection ? this.sectionsLengths : props.items.length
|
|
994
|
+
});
|
|
995
|
+
}
|
|
996
|
+
}, {
|
|
997
|
+
key: "setTheme",
|
|
998
|
+
value: function setTheme(props) {
|
|
999
|
+
this.theme = (0, _reactThemeable["default"])(props.theme);
|
|
1000
|
+
}
|
|
1001
|
+
}, {
|
|
1002
|
+
key: "renderSections",
|
|
1003
|
+
value: function renderSections() {
|
|
1004
|
+
var _this2 = this;
|
|
1005
|
+
|
|
1006
|
+
if (this.allSectionsAreEmpty) {
|
|
1007
|
+
return null;
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
var theme = this.theme;
|
|
1011
|
+
var _this$props2 = this.props,
|
|
1012
|
+
id = _this$props2.id,
|
|
1013
|
+
items = _this$props2.items,
|
|
1014
|
+
renderItem = _this$props2.renderItem,
|
|
1015
|
+
renderItemData = _this$props2.renderItemData,
|
|
1016
|
+
renderSectionTitle = _this$props2.renderSectionTitle,
|
|
1017
|
+
highlightedSectionIndex = _this$props2.highlightedSectionIndex,
|
|
1018
|
+
highlightedItemIndex = _this$props2.highlightedItemIndex,
|
|
1019
|
+
itemProps = _this$props2.itemProps;
|
|
1020
|
+
return items.map(function (section, sectionIndex) {
|
|
1021
|
+
var keyPrefix = "react-autowhatever-".concat(id, "-");
|
|
1022
|
+
var sectionKeyPrefix = "".concat(keyPrefix, "section-").concat(sectionIndex, "-");
|
|
1023
|
+
var isFirstSection = sectionIndex === 0; // `key` is provided by theme()
|
|
1024
|
+
|
|
1025
|
+
/* eslint-disable react/jsx-key */
|
|
1026
|
+
|
|
1027
|
+
return /*#__PURE__*/_react["default"].createElement("div", theme("".concat(sectionKeyPrefix, "container"), 'sectionContainer', isFirstSection && 'sectionContainerFirst'), /*#__PURE__*/_react["default"].createElement(_SectionTitle["default"], {
|
|
1028
|
+
section: section,
|
|
1029
|
+
renderSectionTitle: renderSectionTitle,
|
|
1030
|
+
theme: theme,
|
|
1031
|
+
sectionKeyPrefix: sectionKeyPrefix
|
|
1032
|
+
}), /*#__PURE__*/_react["default"].createElement(_ItemList["default"], {
|
|
1033
|
+
items: _this2.sectionsItems[sectionIndex],
|
|
1034
|
+
itemProps: itemProps,
|
|
1035
|
+
renderItem: renderItem,
|
|
1036
|
+
renderItemData: renderItemData,
|
|
1037
|
+
sectionIndex: sectionIndex,
|
|
1038
|
+
highlightedItemIndex: highlightedSectionIndex === sectionIndex ? highlightedItemIndex : null,
|
|
1039
|
+
onHighlightedItemChange: _this2.onHighlightedItemChange,
|
|
1040
|
+
getItemId: _this2.getItemId,
|
|
1041
|
+
theme: theme,
|
|
1042
|
+
keyPrefix: keyPrefix,
|
|
1043
|
+
ref: _this2.storeItemsListReference
|
|
1044
|
+
}));
|
|
1045
|
+
/* eslint-enable react/jsx-key */
|
|
1046
|
+
});
|
|
1047
|
+
}
|
|
1048
|
+
}, {
|
|
1049
|
+
key: "renderItems",
|
|
1050
|
+
value: function renderItems() {
|
|
1051
|
+
var items = this.props.items;
|
|
1052
|
+
|
|
1053
|
+
if (items.length === 0) {
|
|
1054
|
+
return null;
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
var theme = this.theme;
|
|
1058
|
+
var _this$props3 = this.props,
|
|
1059
|
+
id = _this$props3.id,
|
|
1060
|
+
renderItem = _this$props3.renderItem,
|
|
1061
|
+
renderItemData = _this$props3.renderItemData,
|
|
1062
|
+
highlightedSectionIndex = _this$props3.highlightedSectionIndex,
|
|
1063
|
+
highlightedItemIndex = _this$props3.highlightedItemIndex,
|
|
1064
|
+
itemProps = _this$props3.itemProps;
|
|
1065
|
+
return /*#__PURE__*/_react["default"].createElement(_ItemList["default"], {
|
|
1066
|
+
items: items,
|
|
1067
|
+
itemProps: itemProps,
|
|
1068
|
+
renderItem: renderItem,
|
|
1069
|
+
renderItemData: renderItemData,
|
|
1070
|
+
highlightedItemIndex: highlightedSectionIndex === null ? highlightedItemIndex : null,
|
|
1071
|
+
onHighlightedItemChange: this.onHighlightedItemChange,
|
|
1072
|
+
getItemId: this.getItemId,
|
|
1073
|
+
theme: theme,
|
|
1074
|
+
keyPrefix: "react-autowhatever-".concat(id, "-")
|
|
1075
|
+
});
|
|
1076
|
+
}
|
|
1077
|
+
}, {
|
|
1078
|
+
key: "ensureHighlightedItemIsVisible",
|
|
1079
|
+
value: function ensureHighlightedItemIsVisible() {
|
|
1080
|
+
var highlightedItem = this.highlightedItem;
|
|
1081
|
+
|
|
1082
|
+
if (!highlightedItem) {
|
|
1083
|
+
return;
|
|
1084
|
+
}
|
|
1085
|
+
|
|
1086
|
+
var itemsContainer = this.itemsContainer;
|
|
1087
|
+
var itemOffsetRelativeToContainer = highlightedItem.offsetParent === itemsContainer ? highlightedItem.offsetTop : highlightedItem.offsetTop - itemsContainer.offsetTop;
|
|
1088
|
+
var scrollTop = itemsContainer.scrollTop; // Top of the visible area
|
|
1089
|
+
|
|
1090
|
+
if (itemOffsetRelativeToContainer < scrollTop) {
|
|
1091
|
+
// Item is off the top of the visible area
|
|
1092
|
+
scrollTop = itemOffsetRelativeToContainer;
|
|
1093
|
+
} else if (itemOffsetRelativeToContainer + highlightedItem.offsetHeight > scrollTop + itemsContainer.offsetHeight) {
|
|
1094
|
+
// Item is off the bottom of the visible area
|
|
1095
|
+
scrollTop = itemOffsetRelativeToContainer + highlightedItem.offsetHeight - itemsContainer.offsetHeight;
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
if (scrollTop !== itemsContainer.scrollTop) {
|
|
1099
|
+
itemsContainer.scrollTop = scrollTop;
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1102
|
+
}, {
|
|
1103
|
+
key: "render",
|
|
1104
|
+
value: function render() {
|
|
1105
|
+
var theme = this.theme;
|
|
1106
|
+
var _this$props4 = this.props,
|
|
1107
|
+
id = _this$props4.id,
|
|
1108
|
+
multiSection = _this$props4.multiSection,
|
|
1109
|
+
renderInputComponent = _this$props4.renderInputComponent,
|
|
1110
|
+
renderItemsContainer = _this$props4.renderItemsContainer,
|
|
1111
|
+
highlightedSectionIndex = _this$props4.highlightedSectionIndex,
|
|
1112
|
+
highlightedItemIndex = _this$props4.highlightedItemIndex;
|
|
1113
|
+
var isInputFocused = this.state.isInputFocused;
|
|
1114
|
+
var renderedItems = multiSection ? this.renderSections() : this.renderItems();
|
|
1115
|
+
var isOpen = renderedItems !== null;
|
|
1116
|
+
var ariaActivedescendant = this.getItemId(highlightedSectionIndex, highlightedItemIndex);
|
|
1117
|
+
var itemsContainerId = "react-autowhatever-".concat(id);
|
|
1118
|
+
|
|
1119
|
+
var containerProps = _objectSpread({
|
|
1120
|
+
role: 'combobox',
|
|
1121
|
+
'aria-haspopup': 'listbox',
|
|
1122
|
+
'aria-owns': itemsContainerId,
|
|
1123
|
+
'aria-expanded': isOpen
|
|
1124
|
+
}, theme("react-autowhatever-".concat(id, "-container"), 'container', isOpen && 'containerOpen'), {}, this.props.containerProps);
|
|
1125
|
+
|
|
1126
|
+
var inputComponent = renderInputComponent(_objectSpread({
|
|
1127
|
+
type: 'text',
|
|
1128
|
+
value: '',
|
|
1129
|
+
autoComplete: 'off',
|
|
1130
|
+
'aria-autocomplete': 'list',
|
|
1131
|
+
'aria-controls': itemsContainerId,
|
|
1132
|
+
'aria-activedescendant': ariaActivedescendant
|
|
1133
|
+
}, theme("react-autowhatever-".concat(id, "-input"), 'input', isOpen && 'inputOpen', isInputFocused && 'inputFocused'), {}, this.props.inputProps, {
|
|
1134
|
+
onFocus: this.onFocus,
|
|
1135
|
+
onBlur: this.onBlur,
|
|
1136
|
+
onKeyDown: this.props.inputProps.onKeyDown && this.onKeyDown,
|
|
1137
|
+
ref: this.storeInputReference
|
|
1138
|
+
}));
|
|
1139
|
+
var itemsContainer = renderItemsContainer({
|
|
1140
|
+
containerProps: _objectSpread({
|
|
1141
|
+
id: itemsContainerId,
|
|
1142
|
+
role: 'listbox'
|
|
1143
|
+
}, theme("react-autowhatever-".concat(id, "-items-container"), 'itemsContainer', isOpen && 'itemsContainerOpen'), {
|
|
1144
|
+
ref: this.storeItemsContainerReference
|
|
1145
|
+
}),
|
|
1146
|
+
children: renderedItems
|
|
1147
|
+
});
|
|
1148
|
+
return /*#__PURE__*/_react["default"].createElement("div", containerProps, inputComponent, itemsContainer);
|
|
1149
|
+
}
|
|
1150
|
+
}]);
|
|
1151
|
+
|
|
1152
|
+
return Autowhatever;
|
|
1153
|
+
}(_react.Component);
|
|
1154
|
+
|
|
1155
|
+
exports["default"] = Autowhatever;
|
|
1156
|
+
|
|
1157
|
+
_defineProperty(Autowhatever, "propTypes", {
|
|
1158
|
+
id: _propTypes["default"].string,
|
|
1159
|
+
// Used in aria-* attributes. If multiple Autowhatever's are rendered on a page, they must have unique ids.
|
|
1160
|
+
multiSection: _propTypes["default"].bool,
|
|
1161
|
+
// Indicates whether a multi section layout should be rendered.
|
|
1162
|
+
renderInputComponent: _propTypes["default"].func,
|
|
1163
|
+
// When specified, it is used to render the input element.
|
|
1164
|
+
renderItemsContainer: _propTypes["default"].func,
|
|
1165
|
+
// Renders the items container.
|
|
1166
|
+
items: _propTypes["default"].array.isRequired,
|
|
1167
|
+
// Array of items or sections to render.
|
|
1168
|
+
renderItem: _propTypes["default"].func,
|
|
1169
|
+
// This function renders a single item.
|
|
1170
|
+
renderItemData: _propTypes["default"].object,
|
|
1171
|
+
// Arbitrary data that will be passed to renderItem()
|
|
1172
|
+
renderSectionTitle: _propTypes["default"].func,
|
|
1173
|
+
// This function gets a section and renders its title.
|
|
1174
|
+
getSectionItems: _propTypes["default"].func,
|
|
1175
|
+
// This function gets a section and returns its items, which will be passed into `renderItem` for rendering.
|
|
1176
|
+
containerProps: _propTypes["default"].object,
|
|
1177
|
+
// Arbitrary container props
|
|
1178
|
+
inputProps: _propTypes["default"].object,
|
|
1179
|
+
// Arbitrary input props
|
|
1180
|
+
itemProps: _propTypes["default"].oneOfType([// Arbitrary item props
|
|
1181
|
+
_propTypes["default"].object, _propTypes["default"].func]),
|
|
1182
|
+
highlightedSectionIndex: _propTypes["default"].number,
|
|
1183
|
+
// Section index of the highlighted item
|
|
1184
|
+
highlightedItemIndex: _propTypes["default"].number,
|
|
1185
|
+
// Highlighted item index (within a section)
|
|
1186
|
+
theme: _propTypes["default"].oneOfType([// Styles. See: https://github.com/markdalgleish/react-themeable
|
|
1187
|
+
_propTypes["default"].object, _propTypes["default"].array])
|
|
1188
|
+
});
|
|
1189
|
+
|
|
1190
|
+
_defineProperty(Autowhatever, "defaultProps", {
|
|
1191
|
+
id: '1',
|
|
1192
|
+
multiSection: false,
|
|
1193
|
+
renderInputComponent: defaultRenderInputComponent,
|
|
1194
|
+
renderItemsContainer: defaultRenderItemsContainer,
|
|
1195
|
+
renderItem: function renderItem() {
|
|
1196
|
+
throw new Error('`renderItem` must be provided');
|
|
1197
|
+
},
|
|
1198
|
+
renderItemData: emptyObject,
|
|
1199
|
+
renderSectionTitle: function renderSectionTitle() {
|
|
1200
|
+
throw new Error('`renderSectionTitle` must be provided');
|
|
1201
|
+
},
|
|
1202
|
+
getSectionItems: function getSectionItems() {
|
|
1203
|
+
throw new Error('`getSectionItems` must be provided');
|
|
1204
|
+
},
|
|
1205
|
+
containerProps: emptyObject,
|
|
1206
|
+
inputProps: emptyObject,
|
|
1207
|
+
itemProps: emptyObject,
|
|
1208
|
+
highlightedSectionIndex: null,
|
|
1209
|
+
highlightedItemIndex: null,
|
|
1210
|
+
theme: defaultTheme
|
|
1211
|
+
});
|
|
1212
|
+
}(Autowhatever));
|
|
1213
|
+
|
|
1214
|
+
var theme = {};
|
|
1215
|
+
|
|
1216
|
+
Object.defineProperty(theme, "__esModule", {
|
|
1217
|
+
value: true
|
|
1218
|
+
});
|
|
1219
|
+
theme.mapToAutowhateverTheme = theme.defaultTheme = void 0;
|
|
1220
|
+
var defaultTheme = {
|
|
1221
|
+
container: 'react-autosuggest__container',
|
|
1222
|
+
containerOpen: 'react-autosuggest__container--open',
|
|
1223
|
+
input: 'react-autosuggest__input',
|
|
1224
|
+
inputOpen: 'react-autosuggest__input--open',
|
|
1225
|
+
inputFocused: 'react-autosuggest__input--focused',
|
|
1226
|
+
suggestionsContainer: 'react-autosuggest__suggestions-container',
|
|
1227
|
+
suggestionsContainerOpen: 'react-autosuggest__suggestions-container--open',
|
|
1228
|
+
suggestionsList: 'react-autosuggest__suggestions-list',
|
|
1229
|
+
suggestion: 'react-autosuggest__suggestion',
|
|
1230
|
+
suggestionFirst: 'react-autosuggest__suggestion--first',
|
|
1231
|
+
suggestionHighlighted: 'react-autosuggest__suggestion--highlighted',
|
|
1232
|
+
sectionContainer: 'react-autosuggest__section-container',
|
|
1233
|
+
sectionContainerFirst: 'react-autosuggest__section-container--first',
|
|
1234
|
+
sectionTitle: 'react-autosuggest__section-title'
|
|
1235
|
+
};
|
|
1236
|
+
theme.defaultTheme = defaultTheme;
|
|
1237
|
+
|
|
1238
|
+
var mapToAutowhateverTheme = function mapToAutowhateverTheme(theme) {
|
|
1239
|
+
var result = {};
|
|
1240
|
+
|
|
1241
|
+
for (var key in theme) {
|
|
1242
|
+
switch (key) {
|
|
1243
|
+
case 'suggestionsContainer':
|
|
1244
|
+
result['itemsContainer'] = theme[key];
|
|
1245
|
+
break;
|
|
1246
|
+
|
|
1247
|
+
case 'suggestionsContainerOpen':
|
|
1248
|
+
result['itemsContainerOpen'] = theme[key];
|
|
1249
|
+
break;
|
|
1250
|
+
|
|
1251
|
+
case 'suggestion':
|
|
1252
|
+
result['item'] = theme[key];
|
|
1253
|
+
break;
|
|
1254
|
+
|
|
1255
|
+
case 'suggestionFirst':
|
|
1256
|
+
result['itemFirst'] = theme[key];
|
|
1257
|
+
break;
|
|
1258
|
+
|
|
1259
|
+
case 'suggestionHighlighted':
|
|
1260
|
+
result['itemHighlighted'] = theme[key];
|
|
1261
|
+
break;
|
|
1262
|
+
|
|
1263
|
+
case 'suggestionsList':
|
|
1264
|
+
result['itemsList'] = theme[key];
|
|
1265
|
+
break;
|
|
1266
|
+
|
|
1267
|
+
default:
|
|
1268
|
+
result[key] = theme[key];
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
1271
|
+
|
|
1272
|
+
return result;
|
|
1273
|
+
};
|
|
1274
|
+
|
|
1275
|
+
theme.mapToAutowhateverTheme = mapToAutowhateverTheme;
|
|
1276
|
+
|
|
1277
|
+
(function (exports) {
|
|
1278
|
+
|
|
1279
|
+
Object.defineProperty(exports, "__esModule", {
|
|
1280
|
+
value: true
|
|
1281
|
+
});
|
|
1282
|
+
exports["default"] = void 0;
|
|
1283
|
+
|
|
1284
|
+
var _react = _interopRequireWildcard(React__default);
|
|
1285
|
+
|
|
1286
|
+
var _propTypes = _interopRequireDefault(propTypes.exports);
|
|
1287
|
+
|
|
1288
|
+
var _arrays = _interopRequireDefault(arrays);
|
|
1289
|
+
|
|
1290
|
+
var _Autowhatever = _interopRequireDefault(Autowhatever);
|
|
1291
|
+
|
|
1292
|
+
var _theme = theme;
|
|
1293
|
+
|
|
1294
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
1295
|
+
|
|
1296
|
+
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
|
1297
|
+
|
|
1298
|
+
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
1299
|
+
|
|
1300
|
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
1301
|
+
|
|
1302
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
1303
|
+
|
|
1304
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
1305
|
+
|
|
1306
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
1307
|
+
|
|
1308
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
1309
|
+
|
|
1310
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
1311
|
+
|
|
1312
|
+
function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
1313
|
+
|
|
1314
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
1315
|
+
|
|
1316
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
1317
|
+
|
|
1318
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
|
1319
|
+
|
|
1320
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
1321
|
+
|
|
1322
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
1323
|
+
|
|
1324
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
1325
|
+
|
|
1326
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
1327
|
+
|
|
1328
|
+
var alwaysTrue = function alwaysTrue() {
|
|
1329
|
+
return true;
|
|
1330
|
+
};
|
|
1331
|
+
|
|
1332
|
+
var defaultShouldRenderSuggestions = function defaultShouldRenderSuggestions(value) {
|
|
1333
|
+
return value.trim().length > 0;
|
|
1334
|
+
};
|
|
1335
|
+
|
|
1336
|
+
var defaultRenderSuggestionsContainer = function defaultRenderSuggestionsContainer(_ref) {
|
|
1337
|
+
var containerProps = _ref.containerProps,
|
|
1338
|
+
children = _ref.children;
|
|
1339
|
+
return /*#__PURE__*/_react["default"].createElement("div", containerProps, children);
|
|
1340
|
+
};
|
|
1341
|
+
|
|
1342
|
+
var REASON_SUGGESTIONS_REVEALED = 'suggestions-revealed';
|
|
1343
|
+
var REASON_SUGGESTIONS_UPDATED = 'suggestions-updated';
|
|
1344
|
+
var REASON_SUGGESTION_SELECTED = 'suggestion-selected';
|
|
1345
|
+
var REASON_INPUT_FOCUSED = 'input-focused';
|
|
1346
|
+
var REASON_INPUT_CHANGED = 'input-changed';
|
|
1347
|
+
var REASON_INPUT_BLURRED = 'input-blurred';
|
|
1348
|
+
var REASON_ESCAPE_PRESSED = 'escape-pressed';
|
|
1349
|
+
|
|
1350
|
+
var Autosuggest = /*#__PURE__*/function (_Component) {
|
|
1351
|
+
_inherits(Autosuggest, _Component);
|
|
1352
|
+
|
|
1353
|
+
var _super = _createSuper(Autosuggest);
|
|
1354
|
+
|
|
1355
|
+
function Autosuggest(_ref2) {
|
|
1356
|
+
var _this;
|
|
1357
|
+
|
|
1358
|
+
var _alwaysRenderSuggestions = _ref2.alwaysRenderSuggestions;
|
|
1359
|
+
|
|
1360
|
+
_classCallCheck(this, Autosuggest);
|
|
1361
|
+
|
|
1362
|
+
_this = _super.call(this);
|
|
1363
|
+
|
|
1364
|
+
_defineProperty(_assertThisInitialized(_this), "onDocumentMouseDown", function (event) {
|
|
1365
|
+
_this.justClickedOnSuggestionsContainer = false;
|
|
1366
|
+
var node = event.detail && event.detail.target || // This is for testing only. Please show me a better way to emulate this.
|
|
1367
|
+
event.target;
|
|
1368
|
+
|
|
1369
|
+
while (node !== null && node !== document) {
|
|
1370
|
+
if (node.getAttribute && node.getAttribute('data-suggestion-index') !== null) {
|
|
1371
|
+
// Suggestion was clicked
|
|
1372
|
+
return;
|
|
1373
|
+
}
|
|
1374
|
+
|
|
1375
|
+
if (node === _this.suggestionsContainer) {
|
|
1376
|
+
// Something else inside suggestions container was clicked
|
|
1377
|
+
_this.justClickedOnSuggestionsContainer = true;
|
|
1378
|
+
return;
|
|
1379
|
+
}
|
|
1380
|
+
|
|
1381
|
+
node = node.parentNode;
|
|
1382
|
+
}
|
|
1383
|
+
});
|
|
1384
|
+
|
|
1385
|
+
_defineProperty(_assertThisInitialized(_this), "storeAutowhateverRef", function (autowhatever) {
|
|
1386
|
+
if (autowhatever !== null) {
|
|
1387
|
+
_this.autowhatever = autowhatever;
|
|
1388
|
+
}
|
|
1389
|
+
});
|
|
1390
|
+
|
|
1391
|
+
_defineProperty(_assertThisInitialized(_this), "onSuggestionMouseEnter", function (event, _ref3) {
|
|
1392
|
+
var sectionIndex = _ref3.sectionIndex,
|
|
1393
|
+
itemIndex = _ref3.itemIndex;
|
|
1394
|
+
|
|
1395
|
+
_this.updateHighlightedSuggestion(sectionIndex, itemIndex);
|
|
1396
|
+
|
|
1397
|
+
if (event.target === _this.pressedSuggestion) {
|
|
1398
|
+
_this.justSelectedSuggestion = true;
|
|
1399
|
+
}
|
|
1400
|
+
|
|
1401
|
+
_this.justMouseEntered = true;
|
|
1402
|
+
setTimeout(function () {
|
|
1403
|
+
_this.justMouseEntered = false;
|
|
1404
|
+
});
|
|
1405
|
+
});
|
|
1406
|
+
|
|
1407
|
+
_defineProperty(_assertThisInitialized(_this), "highlightFirstSuggestion", function () {
|
|
1408
|
+
_this.updateHighlightedSuggestion(_this.props.multiSection ? 0 : null, 0);
|
|
1409
|
+
});
|
|
1410
|
+
|
|
1411
|
+
_defineProperty(_assertThisInitialized(_this), "onDocumentMouseUp", function () {
|
|
1412
|
+
if (_this.pressedSuggestion && !_this.justSelectedSuggestion) {
|
|
1413
|
+
_this.input.focus();
|
|
1414
|
+
}
|
|
1415
|
+
|
|
1416
|
+
_this.pressedSuggestion = null;
|
|
1417
|
+
});
|
|
1418
|
+
|
|
1419
|
+
_defineProperty(_assertThisInitialized(_this), "onSuggestionMouseDown", function (event) {
|
|
1420
|
+
// Checking if this.justSelectedSuggestion is already true to not duplicate touch events in chrome
|
|
1421
|
+
// See: https://github.com/facebook/react/issues/9809#issuecomment-413978405
|
|
1422
|
+
if (!_this.justSelectedSuggestion) {
|
|
1423
|
+
_this.justSelectedSuggestion = true;
|
|
1424
|
+
_this.pressedSuggestion = event.target;
|
|
1425
|
+
}
|
|
1426
|
+
});
|
|
1427
|
+
|
|
1428
|
+
_defineProperty(_assertThisInitialized(_this), "onSuggestionsClearRequested", function () {
|
|
1429
|
+
var onSuggestionsClearRequested = _this.props.onSuggestionsClearRequested;
|
|
1430
|
+
onSuggestionsClearRequested && onSuggestionsClearRequested();
|
|
1431
|
+
});
|
|
1432
|
+
|
|
1433
|
+
_defineProperty(_assertThisInitialized(_this), "onSuggestionSelected", function (event, data) {
|
|
1434
|
+
var _this$props = _this.props,
|
|
1435
|
+
alwaysRenderSuggestions = _this$props.alwaysRenderSuggestions,
|
|
1436
|
+
onSuggestionSelected = _this$props.onSuggestionSelected,
|
|
1437
|
+
onSuggestionsFetchRequested = _this$props.onSuggestionsFetchRequested;
|
|
1438
|
+
onSuggestionSelected && onSuggestionSelected(event, data);
|
|
1439
|
+
|
|
1440
|
+
var keepSuggestionsOnSelect = _this.props.shouldKeepSuggestionsOnSelect(data.suggestion);
|
|
1441
|
+
|
|
1442
|
+
if (alwaysRenderSuggestions || keepSuggestionsOnSelect) {
|
|
1443
|
+
onSuggestionsFetchRequested({
|
|
1444
|
+
value: data.suggestionValue,
|
|
1445
|
+
reason: REASON_SUGGESTION_SELECTED
|
|
1446
|
+
});
|
|
1447
|
+
} else {
|
|
1448
|
+
_this.onSuggestionsClearRequested();
|
|
1449
|
+
}
|
|
1450
|
+
|
|
1451
|
+
_this.resetHighlightedSuggestion();
|
|
1452
|
+
});
|
|
1453
|
+
|
|
1454
|
+
_defineProperty(_assertThisInitialized(_this), "onSuggestionClick", function (event) {
|
|
1455
|
+
var _this$props2 = _this.props,
|
|
1456
|
+
alwaysRenderSuggestions = _this$props2.alwaysRenderSuggestions,
|
|
1457
|
+
focusInputOnSuggestionClick = _this$props2.focusInputOnSuggestionClick;
|
|
1458
|
+
|
|
1459
|
+
var _this$getSuggestionIn = _this.getSuggestionIndices(_this.findSuggestionElement(event.target)),
|
|
1460
|
+
sectionIndex = _this$getSuggestionIn.sectionIndex,
|
|
1461
|
+
suggestionIndex = _this$getSuggestionIn.suggestionIndex;
|
|
1462
|
+
|
|
1463
|
+
var clickedSuggestion = _this.getSuggestion(sectionIndex, suggestionIndex);
|
|
1464
|
+
|
|
1465
|
+
var clickedSuggestionValue = _this.props.getSuggestionValue(clickedSuggestion);
|
|
1466
|
+
|
|
1467
|
+
_this.maybeCallOnChange(event, clickedSuggestionValue, 'click');
|
|
1468
|
+
|
|
1469
|
+
_this.onSuggestionSelected(event, {
|
|
1470
|
+
suggestion: clickedSuggestion,
|
|
1471
|
+
suggestionValue: clickedSuggestionValue,
|
|
1472
|
+
suggestionIndex: suggestionIndex,
|
|
1473
|
+
sectionIndex: sectionIndex,
|
|
1474
|
+
method: 'click'
|
|
1475
|
+
});
|
|
1476
|
+
|
|
1477
|
+
var keepSuggestionsOnSelect = _this.props.shouldKeepSuggestionsOnSelect(clickedSuggestion);
|
|
1478
|
+
|
|
1479
|
+
if (!(alwaysRenderSuggestions || keepSuggestionsOnSelect)) {
|
|
1480
|
+
_this.closeSuggestions();
|
|
1481
|
+
}
|
|
1482
|
+
|
|
1483
|
+
if (focusInputOnSuggestionClick === true) {
|
|
1484
|
+
_this.input.focus();
|
|
1485
|
+
} else {
|
|
1486
|
+
_this.onBlur();
|
|
1487
|
+
}
|
|
1488
|
+
|
|
1489
|
+
setTimeout(function () {
|
|
1490
|
+
_this.justSelectedSuggestion = false;
|
|
1491
|
+
});
|
|
1492
|
+
});
|
|
1493
|
+
|
|
1494
|
+
_defineProperty(_assertThisInitialized(_this), "onBlur", function () {
|
|
1495
|
+
var _this$props3 = _this.props,
|
|
1496
|
+
inputProps = _this$props3.inputProps,
|
|
1497
|
+
shouldRenderSuggestions = _this$props3.shouldRenderSuggestions;
|
|
1498
|
+
var value = inputProps.value,
|
|
1499
|
+
onBlur = inputProps.onBlur;
|
|
1500
|
+
|
|
1501
|
+
var highlightedSuggestion = _this.getHighlightedSuggestion();
|
|
1502
|
+
|
|
1503
|
+
var shouldRender = shouldRenderSuggestions(value, REASON_INPUT_BLURRED);
|
|
1504
|
+
|
|
1505
|
+
_this.setState({
|
|
1506
|
+
isFocused: false,
|
|
1507
|
+
highlightedSectionIndex: null,
|
|
1508
|
+
highlightedSuggestionIndex: null,
|
|
1509
|
+
highlightedSuggestion: null,
|
|
1510
|
+
valueBeforeUpDown: null,
|
|
1511
|
+
isCollapsed: !shouldRender
|
|
1512
|
+
});
|
|
1513
|
+
|
|
1514
|
+
onBlur && onBlur(_this.blurEvent, {
|
|
1515
|
+
highlightedSuggestion: highlightedSuggestion
|
|
1516
|
+
});
|
|
1517
|
+
});
|
|
1518
|
+
|
|
1519
|
+
_defineProperty(_assertThisInitialized(_this), "onSuggestionMouseLeave", function (event) {
|
|
1520
|
+
_this.resetHighlightedSuggestion(false); // shouldResetValueBeforeUpDown
|
|
1521
|
+
|
|
1522
|
+
|
|
1523
|
+
if (_this.justSelectedSuggestion && event.target === _this.pressedSuggestion) {
|
|
1524
|
+
_this.justSelectedSuggestion = false;
|
|
1525
|
+
}
|
|
1526
|
+
});
|
|
1527
|
+
|
|
1528
|
+
_defineProperty(_assertThisInitialized(_this), "onSuggestionTouchStart", function () {
|
|
1529
|
+
_this.justSelectedSuggestion = true; // todo: event.preventDefault when https://github.com/facebook/react/issues/2043
|
|
1530
|
+
// todo: gets released so onSuggestionMouseDown won't fire in chrome
|
|
1531
|
+
});
|
|
1532
|
+
|
|
1533
|
+
_defineProperty(_assertThisInitialized(_this), "onSuggestionTouchMove", function () {
|
|
1534
|
+
_this.justSelectedSuggestion = false;
|
|
1535
|
+
_this.pressedSuggestion = null;
|
|
1536
|
+
|
|
1537
|
+
_this.input.focus();
|
|
1538
|
+
});
|
|
1539
|
+
|
|
1540
|
+
_defineProperty(_assertThisInitialized(_this), "itemProps", function (_ref4) {
|
|
1541
|
+
var sectionIndex = _ref4.sectionIndex,
|
|
1542
|
+
itemIndex = _ref4.itemIndex;
|
|
1543
|
+
return {
|
|
1544
|
+
'data-section-index': sectionIndex,
|
|
1545
|
+
'data-suggestion-index': itemIndex,
|
|
1546
|
+
onMouseEnter: _this.onSuggestionMouseEnter,
|
|
1547
|
+
onMouseLeave: _this.onSuggestionMouseLeave,
|
|
1548
|
+
onMouseDown: _this.onSuggestionMouseDown,
|
|
1549
|
+
onTouchStart: _this.onSuggestionTouchStart,
|
|
1550
|
+
onTouchMove: _this.onSuggestionTouchMove,
|
|
1551
|
+
onClick: _this.onSuggestionClick
|
|
1552
|
+
};
|
|
1553
|
+
});
|
|
1554
|
+
|
|
1555
|
+
_defineProperty(_assertThisInitialized(_this), "renderSuggestionsContainer", function (_ref5) {
|
|
1556
|
+
var containerProps = _ref5.containerProps,
|
|
1557
|
+
children = _ref5.children;
|
|
1558
|
+
var renderSuggestionsContainer = _this.props.renderSuggestionsContainer;
|
|
1559
|
+
return renderSuggestionsContainer({
|
|
1560
|
+
containerProps: containerProps,
|
|
1561
|
+
children: children,
|
|
1562
|
+
query: _this.getQuery()
|
|
1563
|
+
});
|
|
1564
|
+
});
|
|
1565
|
+
|
|
1566
|
+
_this.state = {
|
|
1567
|
+
isFocused: false,
|
|
1568
|
+
isCollapsed: !_alwaysRenderSuggestions,
|
|
1569
|
+
highlightedSectionIndex: null,
|
|
1570
|
+
highlightedSuggestionIndex: null,
|
|
1571
|
+
highlightedSuggestion: null,
|
|
1572
|
+
valueBeforeUpDown: null
|
|
1573
|
+
};
|
|
1574
|
+
_this.justPressedUpDown = false;
|
|
1575
|
+
_this.justMouseEntered = false;
|
|
1576
|
+
_this.pressedSuggestion = null;
|
|
1577
|
+
return _this;
|
|
1578
|
+
}
|
|
1579
|
+
|
|
1580
|
+
_createClass(Autosuggest, [{
|
|
1581
|
+
key: "componentDidMount",
|
|
1582
|
+
value: function componentDidMount() {
|
|
1583
|
+
document.addEventListener('mousedown', this.onDocumentMouseDown);
|
|
1584
|
+
document.addEventListener('mouseup', this.onDocumentMouseUp);
|
|
1585
|
+
this.input = this.autowhatever.input;
|
|
1586
|
+
this.suggestionsContainer = this.autowhatever.itemsContainer;
|
|
1587
|
+
} // eslint-disable-next-line camelcase, react/sort-comp
|
|
1588
|
+
|
|
1589
|
+
}, {
|
|
1590
|
+
key: "UNSAFE_componentWillReceiveProps",
|
|
1591
|
+
value: function UNSAFE_componentWillReceiveProps(nextProps) {
|
|
1592
|
+
// When highlightFirstSuggestion becomes deactivated, if the first suggestion was
|
|
1593
|
+
// set, we should reset the suggestion back to the unselected default state.
|
|
1594
|
+
var shouldResetHighlighting = this.state.highlightedSuggestionIndex === 0 && this.props.highlightFirstSuggestion && !nextProps.highlightFirstSuggestion;
|
|
1595
|
+
|
|
1596
|
+
if ((0, _arrays["default"])(nextProps.suggestions, this.props.suggestions)) {
|
|
1597
|
+
if (nextProps.highlightFirstSuggestion && nextProps.suggestions.length > 0 && this.justPressedUpDown === false && this.justMouseEntered === false) {
|
|
1598
|
+
this.highlightFirstSuggestion();
|
|
1599
|
+
} else if (shouldResetHighlighting) {
|
|
1600
|
+
this.resetHighlightedSuggestion();
|
|
1601
|
+
}
|
|
1602
|
+
} else {
|
|
1603
|
+
if (this.willRenderSuggestions(nextProps, REASON_SUGGESTIONS_UPDATED)) {
|
|
1604
|
+
if (this.state.isCollapsed && !this.justSelectedSuggestion) {
|
|
1605
|
+
this.revealSuggestions();
|
|
1606
|
+
}
|
|
1607
|
+
|
|
1608
|
+
if (shouldResetHighlighting) {
|
|
1609
|
+
this.resetHighlightedSuggestion();
|
|
1610
|
+
}
|
|
1611
|
+
} else {
|
|
1612
|
+
this.resetHighlightedSuggestion();
|
|
1613
|
+
}
|
|
1614
|
+
}
|
|
1615
|
+
}
|
|
1616
|
+
}, {
|
|
1617
|
+
key: "componentDidUpdate",
|
|
1618
|
+
value: function componentDidUpdate(prevProps, prevState) {
|
|
1619
|
+
var _this$props4 = this.props,
|
|
1620
|
+
suggestions = _this$props4.suggestions,
|
|
1621
|
+
onSuggestionHighlighted = _this$props4.onSuggestionHighlighted,
|
|
1622
|
+
highlightFirstSuggestion = _this$props4.highlightFirstSuggestion;
|
|
1623
|
+
|
|
1624
|
+
if (!(0, _arrays["default"])(suggestions, prevProps.suggestions) && suggestions.length > 0 && highlightFirstSuggestion) {
|
|
1625
|
+
this.highlightFirstSuggestion();
|
|
1626
|
+
return;
|
|
1627
|
+
}
|
|
1628
|
+
|
|
1629
|
+
if (onSuggestionHighlighted) {
|
|
1630
|
+
var highlightedSuggestion = this.getHighlightedSuggestion();
|
|
1631
|
+
var prevHighlightedSuggestion = prevState.highlightedSuggestion;
|
|
1632
|
+
|
|
1633
|
+
if (highlightedSuggestion != prevHighlightedSuggestion) {
|
|
1634
|
+
onSuggestionHighlighted({
|
|
1635
|
+
suggestion: highlightedSuggestion
|
|
1636
|
+
});
|
|
1637
|
+
}
|
|
1638
|
+
}
|
|
1639
|
+
}
|
|
1640
|
+
}, {
|
|
1641
|
+
key: "componentWillUnmount",
|
|
1642
|
+
value: function componentWillUnmount() {
|
|
1643
|
+
document.removeEventListener('mousedown', this.onDocumentMouseDown);
|
|
1644
|
+
document.removeEventListener('mouseup', this.onDocumentMouseUp);
|
|
1645
|
+
}
|
|
1646
|
+
}, {
|
|
1647
|
+
key: "updateHighlightedSuggestion",
|
|
1648
|
+
value: function updateHighlightedSuggestion(sectionIndex, suggestionIndex, prevValue) {
|
|
1649
|
+
var _this2 = this;
|
|
1650
|
+
|
|
1651
|
+
this.setState(function (state) {
|
|
1652
|
+
var valueBeforeUpDown = state.valueBeforeUpDown;
|
|
1653
|
+
|
|
1654
|
+
if (suggestionIndex === null) {
|
|
1655
|
+
valueBeforeUpDown = null;
|
|
1656
|
+
} else if (valueBeforeUpDown === null && typeof prevValue !== 'undefined') {
|
|
1657
|
+
valueBeforeUpDown = prevValue;
|
|
1658
|
+
}
|
|
1659
|
+
|
|
1660
|
+
return {
|
|
1661
|
+
highlightedSectionIndex: sectionIndex,
|
|
1662
|
+
highlightedSuggestionIndex: suggestionIndex,
|
|
1663
|
+
highlightedSuggestion: suggestionIndex === null ? null : _this2.getSuggestion(sectionIndex, suggestionIndex),
|
|
1664
|
+
valueBeforeUpDown: valueBeforeUpDown
|
|
1665
|
+
};
|
|
1666
|
+
});
|
|
1667
|
+
}
|
|
1668
|
+
}, {
|
|
1669
|
+
key: "resetHighlightedSuggestion",
|
|
1670
|
+
value: function resetHighlightedSuggestion() {
|
|
1671
|
+
var shouldResetValueBeforeUpDown = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
1672
|
+
this.setState(function (state) {
|
|
1673
|
+
var valueBeforeUpDown = state.valueBeforeUpDown;
|
|
1674
|
+
return {
|
|
1675
|
+
highlightedSectionIndex: null,
|
|
1676
|
+
highlightedSuggestionIndex: null,
|
|
1677
|
+
highlightedSuggestion: null,
|
|
1678
|
+
valueBeforeUpDown: shouldResetValueBeforeUpDown ? null : valueBeforeUpDown
|
|
1679
|
+
};
|
|
1680
|
+
});
|
|
1681
|
+
}
|
|
1682
|
+
}, {
|
|
1683
|
+
key: "revealSuggestions",
|
|
1684
|
+
value: function revealSuggestions() {
|
|
1685
|
+
this.setState({
|
|
1686
|
+
isCollapsed: false
|
|
1687
|
+
});
|
|
1688
|
+
}
|
|
1689
|
+
}, {
|
|
1690
|
+
key: "closeSuggestions",
|
|
1691
|
+
value: function closeSuggestions() {
|
|
1692
|
+
this.setState({
|
|
1693
|
+
highlightedSectionIndex: null,
|
|
1694
|
+
highlightedSuggestionIndex: null,
|
|
1695
|
+
highlightedSuggestion: null,
|
|
1696
|
+
valueBeforeUpDown: null,
|
|
1697
|
+
isCollapsed: true
|
|
1698
|
+
});
|
|
1699
|
+
}
|
|
1700
|
+
}, {
|
|
1701
|
+
key: "getSuggestion",
|
|
1702
|
+
value: function getSuggestion(sectionIndex, suggestionIndex) {
|
|
1703
|
+
var _this$props5 = this.props,
|
|
1704
|
+
suggestions = _this$props5.suggestions,
|
|
1705
|
+
multiSection = _this$props5.multiSection,
|
|
1706
|
+
getSectionSuggestions = _this$props5.getSectionSuggestions;
|
|
1707
|
+
|
|
1708
|
+
if (multiSection) {
|
|
1709
|
+
return getSectionSuggestions(suggestions[sectionIndex])[suggestionIndex];
|
|
1710
|
+
}
|
|
1711
|
+
|
|
1712
|
+
return suggestions[suggestionIndex];
|
|
1713
|
+
}
|
|
1714
|
+
}, {
|
|
1715
|
+
key: "getHighlightedSuggestion",
|
|
1716
|
+
value: function getHighlightedSuggestion() {
|
|
1717
|
+
var _this$state = this.state,
|
|
1718
|
+
highlightedSectionIndex = _this$state.highlightedSectionIndex,
|
|
1719
|
+
highlightedSuggestionIndex = _this$state.highlightedSuggestionIndex;
|
|
1720
|
+
|
|
1721
|
+
if (highlightedSuggestionIndex === null) {
|
|
1722
|
+
return null;
|
|
1723
|
+
}
|
|
1724
|
+
|
|
1725
|
+
return this.getSuggestion(highlightedSectionIndex, highlightedSuggestionIndex);
|
|
1726
|
+
}
|
|
1727
|
+
}, {
|
|
1728
|
+
key: "getSuggestionValueByIndex",
|
|
1729
|
+
value: function getSuggestionValueByIndex(sectionIndex, suggestionIndex) {
|
|
1730
|
+
var getSuggestionValue = this.props.getSuggestionValue;
|
|
1731
|
+
return getSuggestionValue(this.getSuggestion(sectionIndex, suggestionIndex));
|
|
1732
|
+
}
|
|
1733
|
+
}, {
|
|
1734
|
+
key: "getSuggestionIndices",
|
|
1735
|
+
value: function getSuggestionIndices(suggestionElement) {
|
|
1736
|
+
var sectionIndex = suggestionElement.getAttribute('data-section-index');
|
|
1737
|
+
var suggestionIndex = suggestionElement.getAttribute('data-suggestion-index');
|
|
1738
|
+
return {
|
|
1739
|
+
sectionIndex: typeof sectionIndex === 'string' ? parseInt(sectionIndex, 10) : null,
|
|
1740
|
+
suggestionIndex: parseInt(suggestionIndex, 10)
|
|
1741
|
+
};
|
|
1742
|
+
}
|
|
1743
|
+
}, {
|
|
1744
|
+
key: "findSuggestionElement",
|
|
1745
|
+
value: function findSuggestionElement(startNode) {
|
|
1746
|
+
var node = startNode;
|
|
1747
|
+
|
|
1748
|
+
do {
|
|
1749
|
+
if (node.getAttribute && node.getAttribute('data-suggestion-index') !== null) {
|
|
1750
|
+
return node;
|
|
1751
|
+
}
|
|
1752
|
+
|
|
1753
|
+
node = node.parentNode;
|
|
1754
|
+
} while (node !== null);
|
|
1755
|
+
|
|
1756
|
+
console.error('Clicked element:', startNode); // eslint-disable-line no-console
|
|
1757
|
+
|
|
1758
|
+
throw new Error("Couldn't find suggestion element");
|
|
1759
|
+
}
|
|
1760
|
+
}, {
|
|
1761
|
+
key: "maybeCallOnChange",
|
|
1762
|
+
value: function maybeCallOnChange(event, newValue, method) {
|
|
1763
|
+
var _this$props$inputProp = this.props.inputProps,
|
|
1764
|
+
value = _this$props$inputProp.value,
|
|
1765
|
+
onChange = _this$props$inputProp.onChange;
|
|
1766
|
+
|
|
1767
|
+
if (newValue !== value) {
|
|
1768
|
+
onChange(event, {
|
|
1769
|
+
newValue: newValue,
|
|
1770
|
+
method: method
|
|
1771
|
+
});
|
|
1772
|
+
}
|
|
1773
|
+
}
|
|
1774
|
+
}, {
|
|
1775
|
+
key: "willRenderSuggestions",
|
|
1776
|
+
value: function willRenderSuggestions(props, reason) {
|
|
1777
|
+
var suggestions = props.suggestions,
|
|
1778
|
+
inputProps = props.inputProps,
|
|
1779
|
+
shouldRenderSuggestions = props.shouldRenderSuggestions;
|
|
1780
|
+
var value = inputProps.value;
|
|
1781
|
+
return suggestions.length > 0 && shouldRenderSuggestions(value, reason);
|
|
1782
|
+
}
|
|
1783
|
+
}, {
|
|
1784
|
+
key: "getQuery",
|
|
1785
|
+
value: function getQuery() {
|
|
1786
|
+
var inputProps = this.props.inputProps;
|
|
1787
|
+
var value = inputProps.value;
|
|
1788
|
+
var valueBeforeUpDown = this.state.valueBeforeUpDown;
|
|
1789
|
+
return (valueBeforeUpDown === null ? value : valueBeforeUpDown).trim();
|
|
1790
|
+
}
|
|
1791
|
+
}, {
|
|
1792
|
+
key: "render",
|
|
1793
|
+
value: function render() {
|
|
1794
|
+
var _this3 = this;
|
|
1795
|
+
|
|
1796
|
+
var _this$props6 = this.props,
|
|
1797
|
+
suggestions = _this$props6.suggestions,
|
|
1798
|
+
renderInputComponent = _this$props6.renderInputComponent,
|
|
1799
|
+
onSuggestionsFetchRequested = _this$props6.onSuggestionsFetchRequested,
|
|
1800
|
+
renderSuggestion = _this$props6.renderSuggestion,
|
|
1801
|
+
inputProps = _this$props6.inputProps,
|
|
1802
|
+
multiSection = _this$props6.multiSection,
|
|
1803
|
+
renderSectionTitle = _this$props6.renderSectionTitle,
|
|
1804
|
+
id = _this$props6.id,
|
|
1805
|
+
getSectionSuggestions = _this$props6.getSectionSuggestions,
|
|
1806
|
+
theme = _this$props6.theme,
|
|
1807
|
+
getSuggestionValue = _this$props6.getSuggestionValue,
|
|
1808
|
+
alwaysRenderSuggestions = _this$props6.alwaysRenderSuggestions,
|
|
1809
|
+
highlightFirstSuggestion = _this$props6.highlightFirstSuggestion,
|
|
1810
|
+
containerProps = _this$props6.containerProps;
|
|
1811
|
+
var _this$state2 = this.state,
|
|
1812
|
+
isFocused = _this$state2.isFocused,
|
|
1813
|
+
isCollapsed = _this$state2.isCollapsed,
|
|
1814
|
+
highlightedSectionIndex = _this$state2.highlightedSectionIndex,
|
|
1815
|
+
highlightedSuggestionIndex = _this$state2.highlightedSuggestionIndex,
|
|
1816
|
+
valueBeforeUpDown = _this$state2.valueBeforeUpDown;
|
|
1817
|
+
var shouldRenderSuggestions = alwaysRenderSuggestions ? alwaysTrue : this.props.shouldRenderSuggestions;
|
|
1818
|
+
var value = inputProps.value,
|
|
1819
|
+
_onFocus = inputProps.onFocus,
|
|
1820
|
+
_onKeyDown = inputProps.onKeyDown;
|
|
1821
|
+
var willRenderSuggestions = this.willRenderSuggestions(this.props, 'render');
|
|
1822
|
+
var isOpen = alwaysRenderSuggestions || isFocused && !isCollapsed && willRenderSuggestions;
|
|
1823
|
+
var items = isOpen ? suggestions : [];
|
|
1824
|
+
|
|
1825
|
+
var autowhateverInputProps = _objectSpread({}, inputProps, {
|
|
1826
|
+
onFocus: function onFocus(event) {
|
|
1827
|
+
if (!_this3.justSelectedSuggestion && !_this3.justClickedOnSuggestionsContainer) {
|
|
1828
|
+
var shouldRender = shouldRenderSuggestions(value, REASON_INPUT_FOCUSED);
|
|
1829
|
+
|
|
1830
|
+
_this3.setState({
|
|
1831
|
+
isFocused: true,
|
|
1832
|
+
isCollapsed: !shouldRender
|
|
1833
|
+
});
|
|
1834
|
+
|
|
1835
|
+
_onFocus && _onFocus(event);
|
|
1836
|
+
|
|
1837
|
+
if (shouldRender) {
|
|
1838
|
+
onSuggestionsFetchRequested({
|
|
1839
|
+
value: value,
|
|
1840
|
+
reason: REASON_INPUT_FOCUSED
|
|
1841
|
+
});
|
|
1842
|
+
}
|
|
1843
|
+
}
|
|
1844
|
+
},
|
|
1845
|
+
onBlur: function onBlur(event) {
|
|
1846
|
+
if (_this3.justClickedOnSuggestionsContainer) {
|
|
1847
|
+
_this3.input.focus();
|
|
1848
|
+
|
|
1849
|
+
return;
|
|
1850
|
+
}
|
|
1851
|
+
|
|
1852
|
+
_this3.blurEvent = event;
|
|
1853
|
+
|
|
1854
|
+
if (!_this3.justSelectedSuggestion) {
|
|
1855
|
+
_this3.onBlur();
|
|
1856
|
+
|
|
1857
|
+
_this3.onSuggestionsClearRequested();
|
|
1858
|
+
}
|
|
1859
|
+
},
|
|
1860
|
+
onChange: function onChange(event) {
|
|
1861
|
+
var value = event.target.value;
|
|
1862
|
+
var shouldRender = shouldRenderSuggestions(value, REASON_INPUT_CHANGED);
|
|
1863
|
+
|
|
1864
|
+
_this3.maybeCallOnChange(event, value, 'type');
|
|
1865
|
+
|
|
1866
|
+
if (_this3.suggestionsContainer) {
|
|
1867
|
+
_this3.suggestionsContainer.scrollTop = 0;
|
|
1868
|
+
}
|
|
1869
|
+
|
|
1870
|
+
_this3.setState(_objectSpread({}, highlightFirstSuggestion ? {} : {
|
|
1871
|
+
highlightedSectionIndex: null,
|
|
1872
|
+
highlightedSuggestionIndex: null,
|
|
1873
|
+
highlightedSuggestion: null
|
|
1874
|
+
}, {
|
|
1875
|
+
valueBeforeUpDown: null,
|
|
1876
|
+
isCollapsed: !shouldRender
|
|
1877
|
+
}));
|
|
1878
|
+
|
|
1879
|
+
if (shouldRender) {
|
|
1880
|
+
onSuggestionsFetchRequested({
|
|
1881
|
+
value: value,
|
|
1882
|
+
reason: REASON_INPUT_CHANGED
|
|
1883
|
+
});
|
|
1884
|
+
} else {
|
|
1885
|
+
_this3.onSuggestionsClearRequested();
|
|
1886
|
+
}
|
|
1887
|
+
},
|
|
1888
|
+
onKeyDown: function onKeyDown(event, data) {
|
|
1889
|
+
var keyCode = event.keyCode;
|
|
1890
|
+
|
|
1891
|
+
switch (keyCode) {
|
|
1892
|
+
case 40: // ArrowDown
|
|
1893
|
+
|
|
1894
|
+
case 38:
|
|
1895
|
+
// ArrowUp
|
|
1896
|
+
if (isCollapsed) {
|
|
1897
|
+
if (shouldRenderSuggestions(value, REASON_SUGGESTIONS_REVEALED)) {
|
|
1898
|
+
onSuggestionsFetchRequested({
|
|
1899
|
+
value: value,
|
|
1900
|
+
reason: REASON_SUGGESTIONS_REVEALED
|
|
1901
|
+
});
|
|
1902
|
+
|
|
1903
|
+
_this3.revealSuggestions();
|
|
1904
|
+
|
|
1905
|
+
event.preventDefault(); // We act on the key.
|
|
1906
|
+
}
|
|
1907
|
+
} else if (suggestions.length > 0) {
|
|
1908
|
+
var newHighlightedSectionIndex = data.newHighlightedSectionIndex,
|
|
1909
|
+
newHighlightedItemIndex = data.newHighlightedItemIndex;
|
|
1910
|
+
var newValue;
|
|
1911
|
+
|
|
1912
|
+
if (newHighlightedItemIndex === null) {
|
|
1913
|
+
// valueBeforeUpDown can be null if, for example, user
|
|
1914
|
+
// hovers on the first suggestion and then pressed Up.
|
|
1915
|
+
// If that happens, use the original input value.
|
|
1916
|
+
newValue = valueBeforeUpDown === null ? value : valueBeforeUpDown;
|
|
1917
|
+
} else {
|
|
1918
|
+
newValue = _this3.getSuggestionValueByIndex(newHighlightedSectionIndex, newHighlightedItemIndex);
|
|
1919
|
+
}
|
|
1920
|
+
|
|
1921
|
+
_this3.updateHighlightedSuggestion(newHighlightedSectionIndex, newHighlightedItemIndex, value);
|
|
1922
|
+
|
|
1923
|
+
_this3.maybeCallOnChange(event, newValue, keyCode === 40 ? 'down' : 'up');
|
|
1924
|
+
|
|
1925
|
+
event.preventDefault(); // We act on the key.
|
|
1926
|
+
}
|
|
1927
|
+
|
|
1928
|
+
_this3.justPressedUpDown = true;
|
|
1929
|
+
setTimeout(function () {
|
|
1930
|
+
_this3.justPressedUpDown = false;
|
|
1931
|
+
});
|
|
1932
|
+
break;
|
|
1933
|
+
// Enter
|
|
1934
|
+
|
|
1935
|
+
case 13:
|
|
1936
|
+
{
|
|
1937
|
+
// See #388
|
|
1938
|
+
if (event.keyCode === 229) {
|
|
1939
|
+
break;
|
|
1940
|
+
}
|
|
1941
|
+
|
|
1942
|
+
var highlightedSuggestion = _this3.getHighlightedSuggestion();
|
|
1943
|
+
|
|
1944
|
+
if (isOpen && !alwaysRenderSuggestions) {
|
|
1945
|
+
_this3.closeSuggestions();
|
|
1946
|
+
}
|
|
1947
|
+
|
|
1948
|
+
if (highlightedSuggestion != null) {
|
|
1949
|
+
event.preventDefault();
|
|
1950
|
+
|
|
1951
|
+
var _newValue = getSuggestionValue(highlightedSuggestion);
|
|
1952
|
+
|
|
1953
|
+
_this3.maybeCallOnChange(event, _newValue, 'enter');
|
|
1954
|
+
|
|
1955
|
+
_this3.onSuggestionSelected(event, {
|
|
1956
|
+
suggestion: highlightedSuggestion,
|
|
1957
|
+
suggestionValue: _newValue,
|
|
1958
|
+
suggestionIndex: highlightedSuggestionIndex,
|
|
1959
|
+
sectionIndex: highlightedSectionIndex,
|
|
1960
|
+
method: 'enter'
|
|
1961
|
+
});
|
|
1962
|
+
|
|
1963
|
+
_this3.justSelectedSuggestion = true;
|
|
1964
|
+
setTimeout(function () {
|
|
1965
|
+
_this3.justSelectedSuggestion = false;
|
|
1966
|
+
});
|
|
1967
|
+
}
|
|
1968
|
+
|
|
1969
|
+
break;
|
|
1970
|
+
}
|
|
1971
|
+
// Escape
|
|
1972
|
+
|
|
1973
|
+
case 27:
|
|
1974
|
+
{
|
|
1975
|
+
if (isOpen) {
|
|
1976
|
+
// If input.type === 'search', the browser clears the input
|
|
1977
|
+
// when Escape is pressed. We want to disable this default
|
|
1978
|
+
// behaviour so that, when suggestions are shown, we just hide
|
|
1979
|
+
// them, without clearing the input.
|
|
1980
|
+
event.preventDefault();
|
|
1981
|
+
}
|
|
1982
|
+
|
|
1983
|
+
var willCloseSuggestions = isOpen && !alwaysRenderSuggestions;
|
|
1984
|
+
|
|
1985
|
+
if (valueBeforeUpDown === null) {
|
|
1986
|
+
// Didn't interact with Up/Down
|
|
1987
|
+
if (!willCloseSuggestions) {
|
|
1988
|
+
var _newValue2 = '';
|
|
1989
|
+
|
|
1990
|
+
_this3.maybeCallOnChange(event, _newValue2, 'escape');
|
|
1991
|
+
|
|
1992
|
+
if (shouldRenderSuggestions(_newValue2, REASON_ESCAPE_PRESSED)) {
|
|
1993
|
+
onSuggestionsFetchRequested({
|
|
1994
|
+
value: _newValue2,
|
|
1995
|
+
reason: REASON_ESCAPE_PRESSED
|
|
1996
|
+
});
|
|
1997
|
+
} else {
|
|
1998
|
+
_this3.onSuggestionsClearRequested();
|
|
1999
|
+
}
|
|
2000
|
+
}
|
|
2001
|
+
} else {
|
|
2002
|
+
// Interacted with Up/Down
|
|
2003
|
+
_this3.maybeCallOnChange(event, valueBeforeUpDown, 'escape');
|
|
2004
|
+
}
|
|
2005
|
+
|
|
2006
|
+
if (willCloseSuggestions) {
|
|
2007
|
+
_this3.onSuggestionsClearRequested();
|
|
2008
|
+
|
|
2009
|
+
_this3.closeSuggestions();
|
|
2010
|
+
} else {
|
|
2011
|
+
_this3.resetHighlightedSuggestion();
|
|
2012
|
+
}
|
|
2013
|
+
|
|
2014
|
+
break;
|
|
2015
|
+
}
|
|
2016
|
+
}
|
|
2017
|
+
|
|
2018
|
+
_onKeyDown && _onKeyDown(event);
|
|
2019
|
+
}
|
|
2020
|
+
});
|
|
2021
|
+
|
|
2022
|
+
var renderSuggestionData = {
|
|
2023
|
+
query: this.getQuery()
|
|
2024
|
+
};
|
|
2025
|
+
return /*#__PURE__*/_react["default"].createElement(_Autowhatever["default"], {
|
|
2026
|
+
multiSection: multiSection,
|
|
2027
|
+
items: items,
|
|
2028
|
+
renderInputComponent: renderInputComponent,
|
|
2029
|
+
renderItemsContainer: this.renderSuggestionsContainer,
|
|
2030
|
+
renderItem: renderSuggestion,
|
|
2031
|
+
renderItemData: renderSuggestionData,
|
|
2032
|
+
renderSectionTitle: renderSectionTitle,
|
|
2033
|
+
getSectionItems: getSectionSuggestions,
|
|
2034
|
+
highlightedSectionIndex: highlightedSectionIndex,
|
|
2035
|
+
highlightedItemIndex: highlightedSuggestionIndex,
|
|
2036
|
+
containerProps: containerProps,
|
|
2037
|
+
inputProps: autowhateverInputProps,
|
|
2038
|
+
itemProps: this.itemProps,
|
|
2039
|
+
theme: (0, _theme.mapToAutowhateverTheme)(theme),
|
|
2040
|
+
id: id,
|
|
2041
|
+
ref: this.storeAutowhateverRef
|
|
2042
|
+
});
|
|
2043
|
+
}
|
|
2044
|
+
}]);
|
|
2045
|
+
|
|
2046
|
+
return Autosuggest;
|
|
2047
|
+
}(_react.Component);
|
|
2048
|
+
|
|
2049
|
+
exports["default"] = Autosuggest;
|
|
2050
|
+
|
|
2051
|
+
_defineProperty(Autosuggest, "propTypes", {
|
|
2052
|
+
suggestions: _propTypes["default"].array.isRequired,
|
|
2053
|
+
onSuggestionsFetchRequested: function onSuggestionsFetchRequested(props, propName) {
|
|
2054
|
+
var onSuggestionsFetchRequested = props[propName];
|
|
2055
|
+
|
|
2056
|
+
if (typeof onSuggestionsFetchRequested !== 'function') {
|
|
2057
|
+
throw new Error("'onSuggestionsFetchRequested' must be implemented. See: https://github.com/moroshko/react-autosuggest#onSuggestionsFetchRequestedProp");
|
|
2058
|
+
}
|
|
2059
|
+
},
|
|
2060
|
+
onSuggestionsClearRequested: function onSuggestionsClearRequested(props, propName) {
|
|
2061
|
+
var onSuggestionsClearRequested = props[propName];
|
|
2062
|
+
|
|
2063
|
+
if (props.alwaysRenderSuggestions === false && typeof onSuggestionsClearRequested !== 'function') {
|
|
2064
|
+
throw new Error("'onSuggestionsClearRequested' must be implemented. See: https://github.com/moroshko/react-autosuggest#onSuggestionsClearRequestedProp");
|
|
2065
|
+
}
|
|
2066
|
+
},
|
|
2067
|
+
shouldKeepSuggestionsOnSelect: _propTypes["default"].func,
|
|
2068
|
+
onSuggestionSelected: _propTypes["default"].func,
|
|
2069
|
+
onSuggestionHighlighted: _propTypes["default"].func,
|
|
2070
|
+
renderInputComponent: _propTypes["default"].func,
|
|
2071
|
+
renderSuggestionsContainer: _propTypes["default"].func,
|
|
2072
|
+
getSuggestionValue: _propTypes["default"].func.isRequired,
|
|
2073
|
+
renderSuggestion: _propTypes["default"].func.isRequired,
|
|
2074
|
+
inputProps: function inputProps(props, propName) {
|
|
2075
|
+
var inputProps = props[propName];
|
|
2076
|
+
|
|
2077
|
+
if (!inputProps) {
|
|
2078
|
+
throw new Error("'inputProps' must be passed.");
|
|
2079
|
+
}
|
|
2080
|
+
|
|
2081
|
+
if (!Object.prototype.hasOwnProperty.call(inputProps, 'value')) {
|
|
2082
|
+
throw new Error("'inputProps' must have 'value'.");
|
|
2083
|
+
}
|
|
2084
|
+
|
|
2085
|
+
if (!Object.prototype.hasOwnProperty.call(inputProps, 'onChange')) {
|
|
2086
|
+
throw new Error("'inputProps' must have 'onChange'.");
|
|
2087
|
+
}
|
|
2088
|
+
},
|
|
2089
|
+
shouldRenderSuggestions: _propTypes["default"].func,
|
|
2090
|
+
alwaysRenderSuggestions: _propTypes["default"].bool,
|
|
2091
|
+
multiSection: _propTypes["default"].bool,
|
|
2092
|
+
renderSectionTitle: function renderSectionTitle(props, propName) {
|
|
2093
|
+
var renderSectionTitle = props[propName];
|
|
2094
|
+
|
|
2095
|
+
if (props.multiSection === true && typeof renderSectionTitle !== 'function') {
|
|
2096
|
+
throw new Error("'renderSectionTitle' must be implemented. See: https://github.com/moroshko/react-autosuggest#renderSectionTitleProp");
|
|
2097
|
+
}
|
|
2098
|
+
},
|
|
2099
|
+
getSectionSuggestions: function getSectionSuggestions(props, propName) {
|
|
2100
|
+
var getSectionSuggestions = props[propName];
|
|
2101
|
+
|
|
2102
|
+
if (props.multiSection === true && typeof getSectionSuggestions !== 'function') {
|
|
2103
|
+
throw new Error("'getSectionSuggestions' must be implemented. See: https://github.com/moroshko/react-autosuggest#getSectionSuggestionsProp");
|
|
2104
|
+
}
|
|
2105
|
+
},
|
|
2106
|
+
focusInputOnSuggestionClick: _propTypes["default"].bool,
|
|
2107
|
+
highlightFirstSuggestion: _propTypes["default"].bool,
|
|
2108
|
+
theme: _propTypes["default"].object,
|
|
2109
|
+
id: _propTypes["default"].string,
|
|
2110
|
+
containerProps: _propTypes["default"].object // Arbitrary container props
|
|
2111
|
+
|
|
2112
|
+
});
|
|
2113
|
+
|
|
2114
|
+
_defineProperty(Autosuggest, "defaultProps", {
|
|
2115
|
+
renderSuggestionsContainer: defaultRenderSuggestionsContainer,
|
|
2116
|
+
shouldRenderSuggestions: defaultShouldRenderSuggestions,
|
|
2117
|
+
alwaysRenderSuggestions: false,
|
|
2118
|
+
multiSection: false,
|
|
2119
|
+
shouldKeepSuggestionsOnSelect: function shouldKeepSuggestionsOnSelect() {
|
|
2120
|
+
return false;
|
|
2121
|
+
},
|
|
2122
|
+
focusInputOnSuggestionClick: true,
|
|
2123
|
+
highlightFirstSuggestion: false,
|
|
2124
|
+
theme: _theme.defaultTheme,
|
|
2125
|
+
id: '1',
|
|
2126
|
+
containerProps: {}
|
|
2127
|
+
});
|
|
2128
|
+
}(Autosuggest));
|
|
2129
|
+
|
|
2130
|
+
var dist = Autosuggest["default"];
|
|
2131
|
+
|
|
2132
|
+
var css_248z = "@keyframes style-module_appearInAnimation__yvH4A {\n from {\n opacity: 0;\n transform: translateY(16px);\n }\n to {\n opacity: 1;\n }\n}\n.style-module_suggestionsContainer__2yVXd {\n position: relative;\n}\n\n.style-module_suggestionsList__11o48 {\n position: absolute;\n z-index: 100;\n overflow: hidden;\n border-radius: 8px;\n border: 1px solid var(--ds-primary-500);\n width: 100%;\n height: fit-content;\n max-height: 216px;\n overflow-y: scroll;\n background-color: white;\n animation-name: style-module_appearInAnimation__yvH4A;\n animation-duration: 0.3s;\n animation-fill-mode: both;\n transform: translateY(8px);\n}\n\n.style-module_suggestion-option__z7pqG {\n display: flex;\n align-items: center;\n cursor: pointer;\n position: relative;\n margin: 0;\n padding: 12px 16px;\n color: var(--ds-grey-900);\n min-height: 48px;\n line-height: 24px;\n}\n\n.style-module_suggestion-img__1TfiA {\n width: 32px;\n height: 24px;\n border-radius: 2px;\n}\n\n.style-module_suggestion-text__7wL31 {\n flex: 1;\n}\n\n.style-module_nowrap__uks9c {\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n.style-module_suggestionHighlighted__2zu5h {\n background-color: var(--ds-primary-100);\n}";
|
|
2133
|
+
var styles = {"suggestionsContainer":"style-module_suggestionsContainer__2yVXd","suggestionsList":"style-module_suggestionsList__11o48","appearInAnimation":"style-module_appearInAnimation__yvH4A","suggestion-option":"style-module_suggestion-option__z7pqG","suggestion-img":"style-module_suggestion-img__1TfiA","suggestion-text":"style-module_suggestion-text__7wL31","nowrap":"style-module_nowrap__uks9c","suggestionHighlighted":"style-module_suggestionHighlighted__2zu5h"};
|
|
2134
|
+
styleInject(css_248z);
|
|
2135
|
+
|
|
2136
|
+
var AutoSuggestInput = (function (_a) {
|
|
2137
|
+
var currentOption = _a.currentOption, suggestions = _a.suggestions, handleSuggestionSelected = _a.handleSuggestionSelected, onChange = _a.onChange, handleSuggestionFetchRequest = _a.handleSuggestionFetchRequest, handleSuggestionClearRequest = _a.handleSuggestionClearRequest, placeholder = _a.placeholder, className = _a.className, wrapText = _a.wrapText, inputProps = _a.inputProps;
|
|
2138
|
+
var renderSuggestion = function (suggestion) {
|
|
2139
|
+
var _a;
|
|
2140
|
+
return (jsxs("div", __assign({ className: "" + styles['suggestion-option'] }, { children: [suggestion.leftIcon && (jsx("img", { className: "mr16 " + styles['suggestion-img'], src: suggestion.leftIcon, alt: suggestion.value }, void 0)),
|
|
2141
|
+
jsx("div", __assign({ className: classnames(styles['suggestion-text'], (_a = {},
|
|
2142
|
+
_a[styles.nowrap] = !wrapText,
|
|
2143
|
+
_a)) }, { children: suggestion.value }), void 0)] }), void 0));
|
|
2144
|
+
};
|
|
2145
|
+
var getSuggestionValue = function (suggestion) { return suggestion.value; };
|
|
2146
|
+
var renderInputComponent = function (autoSuggestInputProps) { return (jsx(Input, __assign({}, autoSuggestInputProps, { placeholder: placeholder, "data-cy": "suggest-multi-select-input" }), void 0)); };
|
|
2147
|
+
return (jsx("div", __assign({ className: className }, { children: jsx(dist, { theme: styles, suggestions: suggestions, onSuggestionsFetchRequested: handleSuggestionFetchRequest, onSuggestionsClearRequested: handleSuggestionClearRequest, getSuggestionValue: getSuggestionValue, renderSuggestion: renderSuggestion, highlightFirstSuggestion: true, inputProps: __assign(__assign({}, inputProps), { value: currentOption, onChange: function (_, _a) {
|
|
2148
|
+
var newValue = _a.newValue;
|
|
2149
|
+
onChange(newValue);
|
|
2150
|
+
} }), onSuggestionSelected: function (_, _a) {
|
|
2151
|
+
var suggestion = _a.suggestion;
|
|
2152
|
+
handleSuggestionSelected(suggestion);
|
|
2153
|
+
}, renderInputComponent: renderInputComponent }, void 0) }), void 0));
|
|
2154
|
+
});
|
|
2155
|
+
|
|
2156
|
+
export default AutoSuggestInput;
|
|
2157
|
+
//# sourceMappingURL=index.js.map
|