@k-int/stripes-kint-components 1.3.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +34 -2
- package/es/artifacts/coverage-jest/lcov-report/block-navigation.js +109 -0
- package/es/artifacts/coverage-jest/lcov-report/prettify.js +998 -0
- package/es/artifacts/coverage-jest/lcov-report/sorter.js +238 -0
- package/es/index.js +69 -17
- package/es/lib/ActionList/ActionList.js +63 -24
- package/es/lib/ActionList/ActionListFieldArray.js +158 -96
- package/es/lib/ActionList/index.js +7 -3
- package/es/lib/EditableRefdataList/EditableRefdataList.js +69 -24
- package/es/lib/EditableRefdataList/index.js +7 -3
- package/es/lib/EditableSettingsList/EditableSettingsList.js +90 -0
- package/es/lib/EditableSettingsList/EditableSettingsListFieldArray.js +90 -0
- package/es/lib/EditableSettingsList/EditableSettingsListFieldArray.test.js +181 -0
- package/es/lib/{Settings → EditableSettingsList/SettingField}/EditSettingValue.js +72 -9
- package/es/lib/EditableSettingsList/SettingField/EditSettingValue.test.js +447 -0
- package/es/lib/{Settings → EditableSettingsList/SettingField}/RenderSettingValue.js +45 -7
- package/es/lib/EditableSettingsList/SettingField/RenderSettingValue.test.js +495 -0
- package/es/lib/EditableSettingsList/SettingField/SettingField.js +187 -0
- package/es/lib/EditableSettingsList/SettingField/SettingField.test.js +180 -0
- package/es/lib/EditableSettingsList/SettingField/index.js +35 -0
- package/es/lib/EditableSettingsList/index.js +35 -0
- package/es/lib/NoResultsMessage/NoResultsMessage.js +122 -0
- package/es/lib/NoResultsMessage/index.js +19 -0
- package/es/lib/QueryTypedown/QueryTypedown.js +48 -9
- package/es/lib/QueryTypedown/index.js +6 -2
- package/es/lib/RefdataButtons/RefdataButtons.js +143 -0
- package/es/lib/RefdataButtons/index.js +19 -0
- package/es/lib/SASQLookupComponent/SASQLookupComponent.js +202 -131
- package/es/lib/SASQLookupComponent/index.js +6 -2
- package/es/lib/SASQRoute/SASQRoute.js +55 -18
- package/es/lib/SASQRoute/index.js +6 -2
- package/es/lib/SASQViewComponent/SASQViewComponent.js +50 -11
- package/es/lib/SASQViewComponent/index.js +6 -2
- package/es/lib/SearchField/SearchField.js +48 -13
- package/es/lib/SearchField/index.js +6 -2
- package/es/lib/SettingPage/SettingPage.js +99 -0
- package/es/lib/SettingPage/SettingPagePane.js +83 -0
- package/es/lib/SettingPage/index.js +27 -0
- package/es/lib/TypeDown/TypeDown.js +143 -101
- package/es/lib/TypeDown/index.js +6 -2
- package/es/lib/Typedown/Typedown.js +140 -96
- package/es/lib/Typedown/index.js +6 -2
- package/es/lib/constants/eventCodes.js +31 -1
- package/es/lib/contexts/SettingsContext.js +41 -0
- package/es/lib/contexts/index.js +19 -0
- package/es/lib/hooks/index.js +42 -8
- package/es/lib/hooks/settingsHooks/index.js +27 -0
- package/es/lib/hooks/settingsHooks/useSettingSection.js +74 -0
- package/es/lib/hooks/settingsHooks/useSettings.js +175 -0
- package/es/lib/hooks/typedownHooks/index.js +8 -28
- package/es/lib/hooks/typedownHooks/useTypedown.js +129 -12
- package/es/lib/hooks/typedownHooks/useTypedownData.js +35 -2
- package/es/lib/hooks/typedownHooks/useTypedownToggle.js +39 -6
- package/es/lib/hooks/useActiveElement.js +33 -2
- package/es/lib/hooks/useHelperApp.js +51 -12
- package/es/lib/hooks/useKiwtFieldArray.js +142 -0
- package/es/lib/hooks/useKiwtSASQuery.js +62 -7
- package/es/lib/hooks/useLocalStorageState.js +37 -4
- package/es/lib/hooks/useMutateRefdataValue.js +42 -9
- package/es/lib/hooks/useQIndex.js +108 -0
- package/es/lib/hooks/useRefdata.js +56 -12
- package/es/lib/hooks/useTemplates.js +36 -3
- package/es/lib/utils/buildUrl.js +43 -10
- package/es/lib/utils/generateKiwtQuery.js +31 -108
- package/es/lib/utils/generateKiwtQueryParams.js +154 -0
- package/es/lib/utils/index.js +55 -3
- package/es/lib/utils/refdataOptions.js +43 -0
- package/es/lib/utils/renderHelpText.js +109 -0
- package/es/lib/utils/selectorSafe.js +31 -2
- package/es/lib/utils/sortByLabel.js +55 -0
- package/es/lib/utils/toCamelCase.js +48 -0
- package/jest.config.js +15 -1
- package/junit.xml +79 -0
- package/package.json +17 -10
- package/src/artifacts/coverage-jest/lcov-report/ActionList/ActionList.js.html +256 -0
- package/src/artifacts/coverage-jest/lcov-report/ActionList/ActionListFieldArray.js.html +799 -0
- package/src/artifacts/coverage-jest/lcov-report/ActionList/index.html +146 -0
- package/src/artifacts/coverage-jest/lcov-report/ActionList/index.js.html +88 -0
- package/src/artifacts/coverage-jest/lcov-report/EditableRefdataList/EditableRefdataList.js.html +376 -0
- package/src/artifacts/coverage-jest/lcov-report/EditableRefdataList/index.html +131 -0
- package/src/artifacts/coverage-jest/lcov-report/EditableRefdataList/index.js.html +88 -0
- package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/EditableSettingsList.js.html +223 -0
- package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/EditableSettingsListFieldArray.js.html +211 -0
- package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/SettingField/EditSettingValue.js.html +376 -0
- package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/SettingField/RenderSettingValue.js.html +262 -0
- package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/SettingField/SettingField.js.html +436 -0
- package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/SettingField/index.html +161 -0
- package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/SettingField/index.js.html +94 -0
- package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/index.html +146 -0
- package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/index.js.html +94 -0
- package/src/artifacts/coverage-jest/lcov-report/NoResultsMessage/NoResultsMessage.js.html +319 -0
- package/src/artifacts/coverage-jest/lcov-report/NoResultsMessage/index.html +131 -0
- package/src/artifacts/coverage-jest/lcov-report/NoResultsMessage/index.js.html +88 -0
- package/src/artifacts/coverage-jest/lcov-report/QueryTypedown/QueryTypedown.js.html +184 -0
- package/src/artifacts/coverage-jest/lcov-report/QueryTypedown/index.html +131 -0
- package/src/artifacts/coverage-jest/lcov-report/QueryTypedown/index.js.html +88 -0
- package/src/artifacts/coverage-jest/lcov-report/RefdataButtons/RefdataButtons.js.html +370 -0
- package/src/artifacts/coverage-jest/lcov-report/RefdataButtons/index.html +131 -0
- package/src/artifacts/coverage-jest/lcov-report/RefdataButtons/index.js.html +88 -0
- package/src/artifacts/coverage-jest/lcov-report/SASQLookupComponent/SASQLookupComponent.js.html +949 -0
- package/src/artifacts/coverage-jest/lcov-report/SASQLookupComponent/index.html +131 -0
- package/src/artifacts/coverage-jest/lcov-report/SASQLookupComponent/index.js.html +88 -0
- package/src/artifacts/coverage-jest/lcov-report/SASQRoute/SASQRoute.js.html +274 -0
- package/src/artifacts/coverage-jest/lcov-report/SASQRoute/index.html +131 -0
- package/src/artifacts/coverage-jest/lcov-report/SASQRoute/index.js.html +88 -0
- package/src/artifacts/coverage-jest/lcov-report/SASQViewComponent/SASQViewComponent.js.html +250 -0
- package/src/artifacts/coverage-jest/lcov-report/SASQViewComponent/index.html +131 -0
- package/src/artifacts/coverage-jest/lcov-report/SASQViewComponent/index.js.html +88 -0
- package/src/artifacts/coverage-jest/lcov-report/SearchField/SearchField.js.html +214 -0
- package/src/artifacts/coverage-jest/lcov-report/SearchField/index.html +131 -0
- package/src/artifacts/coverage-jest/lcov-report/SearchField/index.js.html +88 -0
- package/src/artifacts/coverage-jest/lcov-report/SettingPage/SettingPage.js.html +211 -0
- package/src/artifacts/coverage-jest/lcov-report/SettingPage/SettingPagePane.js.html +178 -0
- package/src/artifacts/coverage-jest/lcov-report/SettingPage/index.html +146 -0
- package/src/artifacts/coverage-jest/lcov-report/SettingPage/index.js.html +91 -0
- package/src/artifacts/coverage-jest/lcov-report/TypeDown/TypeDown.js.html +769 -0
- package/src/artifacts/coverage-jest/lcov-report/TypeDown/index.html +131 -0
- package/src/artifacts/coverage-jest/lcov-report/TypeDown/index.js.html +88 -0
- package/src/artifacts/coverage-jest/lcov-report/Typedown/Typedown.js.html +790 -0
- package/src/artifacts/coverage-jest/lcov-report/Typedown/index.html +131 -0
- package/src/artifacts/coverage-jest/lcov-report/Typedown/index.js.html +88 -0
- package/src/artifacts/coverage-jest/lcov-report/base.css +224 -0
- package/src/artifacts/coverage-jest/lcov-report/block-navigation.js +87 -0
- package/src/artifacts/coverage-jest/lcov-report/constants/eventCodes.js.html +94 -0
- package/src/artifacts/coverage-jest/lcov-report/constants/index.html +116 -0
- package/src/artifacts/coverage-jest/lcov-report/contexts/SettingsContext.js.html +97 -0
- package/src/artifacts/coverage-jest/lcov-report/contexts/index.html +131 -0
- package/src/artifacts/coverage-jest/lcov-report/contexts/index.js.html +91 -0
- package/src/artifacts/coverage-jest/lcov-report/favicon.png +0 -0
- package/src/artifacts/coverage-jest/lcov-report/hooks/index.html +251 -0
- package/src/artifacts/coverage-jest/lcov-report/hooks/index.js.html +115 -0
- package/src/artifacts/coverage-jest/lcov-report/hooks/settingsHooks/index.html +146 -0
- package/src/artifacts/coverage-jest/lcov-report/hooks/settingsHooks/index.js.html +91 -0
- package/src/artifacts/coverage-jest/lcov-report/hooks/settingsHooks/useSettingSection.js.html +163 -0
- package/src/artifacts/coverage-jest/lcov-report/hooks/settingsHooks/useSettings.js.html +403 -0
- package/src/artifacts/coverage-jest/lcov-report/hooks/typedownHooks/index.html +161 -0
- package/src/artifacts/coverage-jest/lcov-report/hooks/typedownHooks/index.js.html +94 -0
- package/src/artifacts/coverage-jest/lcov-report/hooks/typedownHooks/useTypedown.js.html +520 -0
- package/src/artifacts/coverage-jest/lcov-report/hooks/typedownHooks/useTypedownData.js.html +163 -0
- package/src/artifacts/coverage-jest/lcov-report/hooks/typedownHooks/useTypedownToggle.js.html +163 -0
- package/src/artifacts/coverage-jest/lcov-report/hooks/useActiveElement.js.html +157 -0
- package/src/artifacts/coverage-jest/lcov-report/hooks/useHelperApp.js.html +283 -0
- package/src/artifacts/coverage-jest/lcov-report/hooks/useKiwtFieldArray.js.html +274 -0
- package/src/artifacts/coverage-jest/lcov-report/hooks/useKiwtSASQuery.js.html +178 -0
- package/src/artifacts/coverage-jest/lcov-report/hooks/useLocalStorageState.js.html +136 -0
- package/src/artifacts/coverage-jest/lcov-report/hooks/useMutateRefdataValue.js.html +301 -0
- package/src/artifacts/coverage-jest/lcov-report/hooks/useQIndex.js.html +208 -0
- package/src/artifacts/coverage-jest/lcov-report/hooks/useRefdata.js.html +268 -0
- package/src/artifacts/coverage-jest/lcov-report/hooks/useTemplates.js.html +166 -0
- package/src/artifacts/coverage-jest/lcov-report/index.html +401 -0
- package/src/artifacts/coverage-jest/lcov-report/prettify.css +1 -0
- package/src/artifacts/coverage-jest/lcov-report/prettify.js +2 -0
- package/src/artifacts/coverage-jest/lcov-report/sort-arrow-sprite.png +0 -0
- package/src/artifacts/coverage-jest/lcov-report/sorter.js +196 -0
- package/src/artifacts/coverage-jest/lcov-report/utils/buildUrl.js.html +193 -0
- package/src/artifacts/coverage-jest/lcov-report/utils/generateKiwtQuery.js.html +109 -0
- package/src/artifacts/coverage-jest/lcov-report/utils/generateKiwtQueryParams.js.html +286 -0
- package/src/artifacts/coverage-jest/lcov-report/utils/index.html +236 -0
- package/src/artifacts/coverage-jest/lcov-report/utils/index.js.html +121 -0
- package/src/artifacts/coverage-jest/lcov-report/utils/refdataOptions.js.html +106 -0
- package/src/artifacts/coverage-jest/lcov-report/utils/renderHelpText.js.html +166 -0
- package/src/artifacts/coverage-jest/lcov-report/utils/selectorSafe.js.html +103 -0
- package/src/artifacts/coverage-jest/lcov-report/utils/sortByLabel.js.html +130 -0
- package/src/artifacts/coverage-jest/lcov-report/utils/toCamelCase.js.html +127 -0
- package/src/artifacts/coverage-jest/lcov.info +1999 -0
- package/src/index.js +21 -6
- package/src/lib/ActionList/ActionList.js +5 -2
- package/src/lib/ActionList/ActionListFieldArray.js +20 -8
- package/src/lib/ActionList/README.md +1 -0
- package/src/lib/ActionList/index.js +1 -1
- package/src/lib/EditableRefdataList/EditableRefdataList.js +10 -5
- package/src/lib/EditableRefdataList/index.js +1 -1
- package/src/lib/{Settings → EditableSettingsList}/EditableSettingsList.js +0 -0
- package/src/lib/{Settings → EditableSettingsList}/EditableSettingsListFieldArray.js +2 -2
- package/src/lib/EditableSettingsList/EditableSettingsListFieldArray.test.js +111 -0
- package/src/lib/{Settings → EditableSettingsList/SettingField}/EditSettingValue.js +24 -1
- package/src/lib/EditableSettingsList/SettingField/EditSettingValue.test.js +379 -0
- package/src/lib/{Settings → EditableSettingsList/SettingField}/RenderSettingValue.js +2 -1
- package/src/lib/EditableSettingsList/SettingField/RenderSettingValue.test.js +368 -0
- package/src/lib/{Settings → EditableSettingsList/SettingField}/SettingField.js +7 -7
- package/src/lib/EditableSettingsList/SettingField/SettingField.test.js +80 -0
- package/src/lib/EditableSettingsList/SettingField/index.js +3 -0
- package/src/lib/EditableSettingsList/index.js +3 -0
- package/src/lib/NoResultsMessage/NoResultsMessage.js +78 -0
- package/src/lib/NoResultsMessage/index.js +1 -0
- package/src/lib/{Settings → RefdataButtons}/RefdataButtons.js +1 -1
- package/src/lib/RefdataButtons/index.js +1 -0
- package/src/lib/SASQLookupComponent/SASQLookupComponent.js +36 -8
- package/src/lib/SASQRoute/README.md +1 -1
- package/src/lib/{Settings → SettingPage}/SettingPage.js +5 -5
- package/src/lib/{Settings → SettingPage}/SettingPagePane.js +12 -2
- package/src/lib/SettingPage/index.js +2 -0
- package/src/lib/TypeDown/README.md +1 -115
- package/src/lib/TypeDown/TypeDown.js +4 -2
- package/src/lib/Typedown/Typedown.js +2 -1
- package/src/lib/{Settings → contexts}/SettingsContext.js +1 -1
- package/src/lib/contexts/index.js +2 -0
- package/src/lib/hooks/README.md +107 -0
- package/src/lib/hooks/index.js +3 -0
- package/src/lib/hooks/settingsHooks/index.js +2 -0
- package/src/lib/{Settings → hooks/settingsHooks}/useSettingSection.js +0 -0
- package/src/lib/{Settings → hooks/settingsHooks}/useSettings.js +14 -6
- package/src/lib/hooks/typedownHooks/index.js +0 -3
- package/src/lib/hooks/typedownHooks/useTypedown.js +93 -11
- package/src/lib/hooks/useHelperApp.js +5 -1
- package/src/lib/hooks/useKiwtFieldArray.js +63 -0
- package/src/lib/hooks/useKiwtSASQuery.js +9 -1
- package/src/lib/hooks/useQIndex.js +41 -0
- package/src/lib/hooks/useRefdata.js +17 -6
- package/src/lib/utils/README.md +39 -1
- package/src/lib/utils/generateKiwtQuery.js +3 -62
- package/src/lib/utils/generateKiwtQueryParams.js +67 -0
- package/src/lib/utils/index.js +10 -0
- package/src/lib/utils/refdataOptions.js +7 -0
- package/src/lib/{Settings/utils → utils}/renderHelpText.js +1 -1
- package/src/lib/{Settings/utils → utils}/sortByLabel.js +1 -1
- package/src/lib/{Settings/utils → utils}/toCamelCase.js +0 -0
- package/styles/NoResultsMessage.css +38 -0
- package/test/helpers/index.js +1 -0
- package/test/helpers/translationsProperties.js +40 -0
- package/test/jest/helpers/KintHarness.js +36 -0
- package/test/jest/helpers/index.js +2 -0
- package/test/jest/helpers/renderWithKintHarness.js +15 -0
- package/test/jest/jest-transformer.js +4 -0
- package/test/jest/setupTests.js +1 -0
- package/translations/stripes-kint-components/en.json +4 -1
- package/babelOptions.js +0 -30
- package/es/lib/Settings/EditableSettingsList.js +0 -57
- package/es/lib/Settings/EditableSettingsListFieldArray.js +0 -59
- package/es/lib/Settings/RefdataButtons.js +0 -100
- package/es/lib/Settings/SettingField.js +0 -144
- package/es/lib/Settings/SettingPage.js +0 -64
- package/es/lib/Settings/SettingPagePane.js +0 -43
- package/es/lib/Settings/SettingsContext.js +0 -18
- package/es/lib/Settings/index.js +0 -71
- package/es/lib/Settings/useSettingSection.js +0 -41
- package/es/lib/Settings/useSettings.js +0 -126
- package/es/lib/Settings/utils/index.js +0 -31
- package/es/lib/Settings/utils/renderHelpText.js +0 -57
- package/es/lib/Settings/utils/sortByLabel.js +0 -26
- package/es/lib/Settings/utils/toCamelCase.js +0 -19
- package/es/lib/hooks/typedownHooks/useTypedownFooter.js +0 -47
- package/es/lib/hooks/typedownHooks/useTypedownList.js +0 -45
- package/es/lib/hooks/typedownHooks/useTypedownSearchField.js +0 -47
- package/es/lib/utils/getFocusableElements.js +0 -132
- package/src/lib/Settings/index.js +0 -8
- package/src/lib/Settings/utils/index.js +0 -3
- package/src/lib/hooks/typedownHooks/useTypedownFooter.js +0 -43
- package/src/lib/hooks/typedownHooks/useTypedownList.js +0 -36
- package/src/lib/hooks/typedownHooks/useTypedownSearchField.js +0 -39
- package/src/lib/utils/getFocusableElements.js +0 -99
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
|
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
|
|
10
|
-
var _reactIntl = require("react-intl");
|
|
11
|
-
|
|
12
|
-
var _renderHelpText = _interopRequireDefault(require("../../../../styles/renderHelpText.css"));
|
|
13
|
-
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
15
|
-
|
|
16
|
-
var renderHelpText = function renderHelpText(id) {
|
|
17
|
-
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
18
|
-
className: _renderHelpText["default"].help
|
|
19
|
-
}, /*#__PURE__*/_react["default"].createElement(_reactIntl.FormattedMessage, {
|
|
20
|
-
id: id,
|
|
21
|
-
values: {
|
|
22
|
-
b: function b(chunks) {
|
|
23
|
-
return /*#__PURE__*/_react["default"].createElement("b", null, chunks);
|
|
24
|
-
},
|
|
25
|
-
i: function i(chunks) {
|
|
26
|
-
return /*#__PURE__*/_react["default"].createElement("i", null, chunks);
|
|
27
|
-
},
|
|
28
|
-
em: function em(chunks) {
|
|
29
|
-
return /*#__PURE__*/_react["default"].createElement("em", null, chunks);
|
|
30
|
-
},
|
|
31
|
-
strong: function strong(chunks) {
|
|
32
|
-
return /*#__PURE__*/_react["default"].createElement("strong", null, chunks);
|
|
33
|
-
},
|
|
34
|
-
span: function span(chunks) {
|
|
35
|
-
return /*#__PURE__*/_react["default"].createElement("span", null, chunks);
|
|
36
|
-
},
|
|
37
|
-
div: function div(chunks) {
|
|
38
|
-
return /*#__PURE__*/_react["default"].createElement("div", null, chunks);
|
|
39
|
-
},
|
|
40
|
-
p: function p(chunks) {
|
|
41
|
-
return /*#__PURE__*/_react["default"].createElement("p", null, chunks);
|
|
42
|
-
},
|
|
43
|
-
ul: function ul(chunks) {
|
|
44
|
-
return /*#__PURE__*/_react["default"].createElement("ul", null, chunks);
|
|
45
|
-
},
|
|
46
|
-
ol: function ol(chunks) {
|
|
47
|
-
return /*#__PURE__*/_react["default"].createElement("ol", null, chunks);
|
|
48
|
-
},
|
|
49
|
-
li: function li(chunks) {
|
|
50
|
-
return /*#__PURE__*/_react["default"].createElement("li", null, chunks);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}));
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
var _default = renderHelpText;
|
|
57
|
-
exports["default"] = _default;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
|
|
8
|
-
var sortByLabel = function sortByLabel(a, b) {
|
|
9
|
-
var _a$label$toLowerCase, _a$label, _a$id, _b$label$toLowerCase, _b$label, _b$id;
|
|
10
|
-
|
|
11
|
-
var al = (_a$label$toLowerCase = (_a$label = a.label) === null || _a$label === void 0 ? void 0 : _a$label.toLowerCase()) !== null && _a$label$toLowerCase !== void 0 ? _a$label$toLowerCase : (_a$id = a.id) === null || _a$id === void 0 ? void 0 : _a$id.toLowerCase();
|
|
12
|
-
var bl = (_b$label$toLowerCase = (_b$label = b.label) === null || _b$label === void 0 ? void 0 : _b$label.toLowerCase()) !== null && _b$label$toLowerCase !== void 0 ? _b$label$toLowerCase : (_b$id = b.id) === null || _b$id === void 0 ? void 0 : _b$id.toLowerCase();
|
|
13
|
-
|
|
14
|
-
if (al < bl) {
|
|
15
|
-
return -1;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
if (al > bl) {
|
|
19
|
-
return 1;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return 0;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
var _default = sortByLabel;
|
|
26
|
-
exports["default"] = _default;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
|
|
8
|
-
var toCamelCase = function toCamelCase(str) {
|
|
9
|
-
return (// First split string on any capital letters
|
|
10
|
-
str.split(/(?=[A-Z])/).join(' ') // Remove all non alpha-numeric chars, and replace _ with ' '
|
|
11
|
-
.replace(/[_]/gi, ' ').replace(/[^0-9a-zA-Z\s]/gi, '') // CamelCase the remains
|
|
12
|
-
.replace(/(?:^\w|[A-Z]|\b\w)/g, function (ltr, idx) {
|
|
13
|
-
return idx === 0 ? ltr.toLowerCase() : ltr.toUpperCase();
|
|
14
|
-
}).replace(/\s+/g, '')
|
|
15
|
-
);
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
var _default = toCamelCase;
|
|
19
|
-
exports["default"] = _default;
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
|
|
8
|
-
var _react = require("react");
|
|
9
|
-
|
|
10
|
-
var _getFocusableElements = require("../../utils/getFocusableElements");
|
|
11
|
-
|
|
12
|
-
var _eventCodes = require("../../constants/eventCodes");
|
|
13
|
-
|
|
14
|
-
// TODO swap to stripes-components export once available (Will need <= peer dep bump)
|
|
15
|
-
var useTypedownFooter = function useTypedownFooter(searchField) {
|
|
16
|
-
var footerRef = (0, _react.useRef)();
|
|
17
|
-
var footer = document.getElementById('typedown-footer'); // Add an event listener to the footer, so that we can control tab behaviour between footer elements
|
|
18
|
-
|
|
19
|
-
(0, _react.useEffect)(function () {
|
|
20
|
-
if (footer) {
|
|
21
|
-
footer.addEventListener('keydown', function (e) {
|
|
22
|
-
// We want special behaviour on tab
|
|
23
|
-
if (e.code === _eventCodes.TAB) {
|
|
24
|
-
// Prevent the default behaviour
|
|
25
|
-
e.preventDefault();
|
|
26
|
-
var focusFunc = e.shiftKey ? _getFocusableElements.getPreviousFocusable : _getFocusableElements.getNextFocusable;
|
|
27
|
-
var elem = focusFunc(footerRef.current, true, true, false, true);
|
|
28
|
-
|
|
29
|
-
if (elem) {
|
|
30
|
-
// Focus on next focusable element
|
|
31
|
-
elem.focus();
|
|
32
|
-
} else if (e.shiftKey) {
|
|
33
|
-
// We are at the beginning of the list, refocus on search bar
|
|
34
|
-
searchField.focus();
|
|
35
|
-
} else {
|
|
36
|
-
// We are at the end of the list, move onto next focusable element in page
|
|
37
|
-
(0, _getFocusableElements.getNextFocusable)(searchField, false).focus();
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
}, [footer, searchField]);
|
|
43
|
-
return footerRef;
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
var _default = useTypedownFooter;
|
|
47
|
-
exports["default"] = _default;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
|
|
8
|
-
var _getFocusableElements = require("../../utils/getFocusableElements");
|
|
9
|
-
|
|
10
|
-
var _eventCodes = require("../../constants/eventCodes");
|
|
11
|
-
|
|
12
|
-
// TODO swap to stripes-components export once available (Will need <= peer dep bump)
|
|
13
|
-
var useTypedownList = function useTypedownList(listRef, footerRef, searchField) {
|
|
14
|
-
return function (e) {
|
|
15
|
-
if (e.code === _eventCodes.DOWN_ARROW) {
|
|
16
|
-
var elem = (0, _getFocusableElements.getNextFocusable)(listRef.current, true, true);
|
|
17
|
-
elem.focus();
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
if (e.code === _eventCodes.UP_ARROW) {
|
|
21
|
-
var _elem = (0, _getFocusableElements.getPreviousFocusable)(listRef.current, true, true);
|
|
22
|
-
|
|
23
|
-
_elem.focus();
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
if (e.code === _eventCodes.TAB) {
|
|
27
|
-
e.preventDefault();
|
|
28
|
-
|
|
29
|
-
var _elem2;
|
|
30
|
-
|
|
31
|
-
if (!e.shiftKey && !footerRef.current) {
|
|
32
|
-
_elem2 = (0, _getFocusableElements.getNextFocusable)(searchField, false);
|
|
33
|
-
} else if (!e.shiftKey) {
|
|
34
|
-
_elem2 = (0, _getFocusableElements.getNextFocusable)(footerRef.current, true, true, true, true);
|
|
35
|
-
} else {
|
|
36
|
-
_elem2 = searchField;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
_elem2.focus();
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
var _default = useTypedownList;
|
|
45
|
-
exports["default"] = _default;
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
|
|
8
|
-
var _getFocusableElements = require("../../utils/getFocusableElements");
|
|
9
|
-
|
|
10
|
-
var _eventCodes = require("../../constants/eventCodes");
|
|
11
|
-
|
|
12
|
-
// TODO swap to stripes-components export once available (Will need <= peer dep bump)
|
|
13
|
-
var useTypedownSearchField = function useTypedownSearchField(listRef, footerRef, searchField) {
|
|
14
|
-
return function (e) {
|
|
15
|
-
if (e.code === _eventCodes.UP_ARROW) {
|
|
16
|
-
var elem = (0, _getFocusableElements.getLastFocusable)(listRef.current, true, true);
|
|
17
|
-
|
|
18
|
-
if (elem) {
|
|
19
|
-
elem.focus();
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
if (e.code === _eventCodes.DOWN_ARROW) {
|
|
24
|
-
var _elem = (0, _getFocusableElements.getFirstFocusable)(listRef.current, true, true);
|
|
25
|
-
|
|
26
|
-
if (_elem) {
|
|
27
|
-
_elem.focus();
|
|
28
|
-
}
|
|
29
|
-
} // Tab key (But not while shifting)
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
if (e.code === _eventCodes.TAB && !e.shiftKey) {
|
|
33
|
-
e.preventDefault(); // If we have focusable elements in the footer, then focus on them, else unfocus searchbar
|
|
34
|
-
|
|
35
|
-
var _elem2 = (0, _getFocusableElements.getNextFocusable)(footerRef.current, true, true, true, true);
|
|
36
|
-
|
|
37
|
-
if (_elem2) {
|
|
38
|
-
_elem2.focus();
|
|
39
|
-
} else {
|
|
40
|
-
(0, _getFocusableElements.getNextFocusable)(searchField, false).focus();
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
var _default = useTypedownSearchField;
|
|
47
|
-
exports["default"] = _default;
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getFirstFocusable = getFirstFocusable;
|
|
7
|
-
exports.getLastFocusable = getLastFocusable;
|
|
8
|
-
exports.getNextFocusable = getNextFocusable;
|
|
9
|
-
exports.getPreviousFocusable = getPreviousFocusable;
|
|
10
|
-
|
|
11
|
-
var _contains = _interopRequireDefault(require("dom-helpers/query/contains"));
|
|
12
|
-
|
|
13
|
-
var _matches = _interopRequireDefault(require("dom-helpers/query/matches"));
|
|
14
|
-
|
|
15
|
-
var _first = _interopRequireDefault(require("lodash/first"));
|
|
16
|
-
|
|
17
|
-
var _last = _interopRequireDefault(require("lodash/last"));
|
|
18
|
-
|
|
19
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
20
|
-
|
|
21
|
-
// THIS FILE IS ADAPTED FROM https://github.com/folio-org/stripes-components/blob/master/util/getFocusableElements.js
|
|
22
|
-
// With the option included to return null if run out of options
|
|
23
|
-
// TODO swap to stripes-components export once available (Will need <= peer dep bump)
|
|
24
|
-
function getVisibleFocusableElements() {
|
|
25
|
-
var container = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : document;
|
|
26
|
-
var includeContained = arguments.length > 1 ? arguments[1] : undefined;
|
|
27
|
-
var currentElement = arguments.length > 2 ? arguments[2] : undefined;
|
|
28
|
-
|
|
29
|
-
if (container.querySelectorAll) {
|
|
30
|
-
// eslint-disable-next-line max-len
|
|
31
|
-
var focusableSelector = 'a:not([disabled]), button:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([disabled]):not([tabindex="-1"]), [tabIndex="-1"]:not([disabled]):focus';
|
|
32
|
-
return Array.from(container.querySelectorAll(focusableSelector)).filter(function (element) {
|
|
33
|
-
if (!includeContained) {
|
|
34
|
-
if (element === currentElement) {
|
|
35
|
-
return true;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (currentElement && (0, _contains["default"])(currentElement, element)) {
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if ((0, _matches["default"])(element, '[data-focus-exclude]')) {
|
|
44
|
-
return false;
|
|
45
|
-
} // check for visibility while always include the current activeElement
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
return element.offsetWidth > 0 || element.offsetHeight > 0 || element === document.activeElement;
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return [];
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function getNextorPrevious(collection, current, loop, next) {
|
|
56
|
-
var nullOnExit = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
57
|
-
var index = collection.indexOf(current);
|
|
58
|
-
|
|
59
|
-
if (index === -1) {
|
|
60
|
-
index = collection.indexOf(document.activeElement);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
var nextElement = collection[index + 1];
|
|
64
|
-
var previousElement = collection[index - 1]; // First determine if travelling forwards or backwards through the list
|
|
65
|
-
|
|
66
|
-
if (next) {
|
|
67
|
-
// If looping then loop to beginning if nextElement is null
|
|
68
|
-
if (loop) {
|
|
69
|
-
return nextElement || collection[0];
|
|
70
|
-
} // If nullOnExit then return null if nextElement is null
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
if (nullOnExit) {
|
|
74
|
-
return nextElement;
|
|
75
|
-
} // Else return end of the list if nextElement is null
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
return collection[index + 1] || collection[collection.length - 1];
|
|
79
|
-
} else {
|
|
80
|
-
// If looping then loop to end if previousElement is null
|
|
81
|
-
if (loop) {
|
|
82
|
-
return previousElement || collection[collection.length - 1];
|
|
83
|
-
} // If nullOnExit then return null if previousElement is null
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
if (nullOnExit) {
|
|
87
|
-
return previousElement;
|
|
88
|
-
} // Else return beginning of the list if previousElement is null
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
return collection[index - 1] || collection[0];
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
function getFocusableElement(next, currentElement) {
|
|
96
|
-
var includeContained = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
97
|
-
var onlyContained = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
98
|
-
var loop = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
|
|
99
|
-
var nullOnExit = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
|
|
100
|
-
var container = includeContained && onlyContained ? currentElement : document;
|
|
101
|
-
var focusable = getVisibleFocusableElements(container, includeContained, currentElement);
|
|
102
|
-
|
|
103
|
-
if (focusable.length > 0) {
|
|
104
|
-
return getNextorPrevious(focusable, currentElement, loop, next, nullOnExit);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
return null;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
function getNextFocusable() {
|
|
111
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
112
|
-
args[_key] = arguments[_key];
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
return getFocusableElement.apply(void 0, [true].concat(args));
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
function getPreviousFocusable() {
|
|
119
|
-
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
120
|
-
args[_key2] = arguments[_key2];
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
return getFocusableElement.apply(void 0, [false].concat(args));
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
function getLastFocusable(container) {
|
|
127
|
-
return (0, _last["default"])(getVisibleFocusableElements(container));
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
function getFirstFocusable(container) {
|
|
131
|
-
return (0, _first["default"])(getVisibleFocusableElements(container));
|
|
132
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export { default as EditableSettingsList } from './EditableSettingsList';
|
|
2
|
-
export { default as EditableSettingsListFieldArray } from './EditableSettingsListFieldArray';
|
|
3
|
-
export { default as SettingField } from './SettingField';
|
|
4
|
-
export { default as SettingPagePane } from './SettingPagePane';
|
|
5
|
-
export { default as SettingPage } from './SettingPage';
|
|
6
|
-
export { default as RefdataButtons } from './RefdataButtons';
|
|
7
|
-
export { default as useSettings } from './useSettings';
|
|
8
|
-
export { default as SettingsContext } from './SettingsContext';
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef } from 'react';
|
|
2
|
-
|
|
3
|
-
// TODO swap to stripes-components export once available (Will need <= peer dep bump)
|
|
4
|
-
import {
|
|
5
|
-
getNextFocusable,
|
|
6
|
-
getPreviousFocusable,
|
|
7
|
-
} from '../../utils/getFocusableElements';
|
|
8
|
-
import { TAB } from '../../constants/eventCodes';
|
|
9
|
-
|
|
10
|
-
const useTypedownFooter = (searchField) => {
|
|
11
|
-
const footerRef = useRef();
|
|
12
|
-
|
|
13
|
-
const footer = document.getElementById('typedown-footer');
|
|
14
|
-
// Add an event listener to the footer, so that we can control tab behaviour between footer elements
|
|
15
|
-
useEffect(() => {
|
|
16
|
-
if (footer) {
|
|
17
|
-
footer.addEventListener('keydown', e => {
|
|
18
|
-
// We want special behaviour on tab
|
|
19
|
-
if (e.code === TAB) {
|
|
20
|
-
// Prevent the default behaviour
|
|
21
|
-
e.preventDefault();
|
|
22
|
-
const focusFunc = e.shiftKey ? getPreviousFocusable : getNextFocusable;
|
|
23
|
-
const elem = focusFunc(footerRef.current, true, true, false, true);
|
|
24
|
-
|
|
25
|
-
if (elem) {
|
|
26
|
-
// Focus on next focusable element
|
|
27
|
-
elem.focus();
|
|
28
|
-
} else if (e.shiftKey) {
|
|
29
|
-
// We are at the beginning of the list, refocus on search bar
|
|
30
|
-
searchField.focus();
|
|
31
|
-
} else {
|
|
32
|
-
// We are at the end of the list, move onto next focusable element in page
|
|
33
|
-
getNextFocusable(searchField, false).focus();
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
}, [footer, searchField]);
|
|
39
|
-
|
|
40
|
-
return footerRef;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export default useTypedownFooter;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
// TODO swap to stripes-components export once available (Will need <= peer dep bump)
|
|
2
|
-
import {
|
|
3
|
-
getNextFocusable,
|
|
4
|
-
getPreviousFocusable,
|
|
5
|
-
} from '../../utils/getFocusableElements';
|
|
6
|
-
|
|
7
|
-
import { UP_ARROW, DOWN_ARROW, TAB } from '../../constants/eventCodes';
|
|
8
|
-
|
|
9
|
-
const useTypedownList = (listRef, footerRef, searchField) => {
|
|
10
|
-
return e => {
|
|
11
|
-
if (e.code === DOWN_ARROW) {
|
|
12
|
-
const elem = getNextFocusable(listRef.current, true, true);
|
|
13
|
-
elem.focus();
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
if (e.code === UP_ARROW) {
|
|
17
|
-
const elem = getPreviousFocusable(listRef.current, true, true);
|
|
18
|
-
elem.focus();
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
if (e.code === TAB) {
|
|
22
|
-
e.preventDefault();
|
|
23
|
-
let elem;
|
|
24
|
-
if (!e.shiftKey && !footerRef.current) {
|
|
25
|
-
elem = getNextFocusable(searchField, false);
|
|
26
|
-
} else if (!e.shiftKey) {
|
|
27
|
-
elem = getNextFocusable(footerRef.current, true, true, true, true);
|
|
28
|
-
} else {
|
|
29
|
-
elem = searchField;
|
|
30
|
-
}
|
|
31
|
-
elem.focus();
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export default useTypedownList;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
// TODO swap to stripes-components export once available (Will need <= peer dep bump)
|
|
2
|
-
import {
|
|
3
|
-
getNextFocusable,
|
|
4
|
-
getFirstFocusable,
|
|
5
|
-
getLastFocusable
|
|
6
|
-
} from '../../utils/getFocusableElements';
|
|
7
|
-
import { UP_ARROW, DOWN_ARROW, TAB } from '../../constants/eventCodes';
|
|
8
|
-
|
|
9
|
-
const useTypedownSearchField = (listRef, footerRef, searchField) => {
|
|
10
|
-
return e => {
|
|
11
|
-
if (e.code === UP_ARROW) {
|
|
12
|
-
const elem = getLastFocusable(listRef.current, true, true);
|
|
13
|
-
if (elem) {
|
|
14
|
-
elem.focus();
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
if (e.code === DOWN_ARROW) {
|
|
19
|
-
const elem = getFirstFocusable(listRef.current, true, true);
|
|
20
|
-
if (elem) {
|
|
21
|
-
elem.focus();
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// Tab key (But not while shifting)
|
|
26
|
-
if (e.code === TAB && !e.shiftKey) {
|
|
27
|
-
e.preventDefault();
|
|
28
|
-
// If we have focusable elements in the footer, then focus on them, else unfocus searchbar
|
|
29
|
-
const elem = getNextFocusable(footerRef.current, true, true, true, true);
|
|
30
|
-
if (elem) {
|
|
31
|
-
elem.focus();
|
|
32
|
-
} else {
|
|
33
|
-
getNextFocusable(searchField, false).focus();
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export default useTypedownSearchField;
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
// THIS FILE IS ADAPTED FROM https://github.com/folio-org/stripes-components/blob/master/util/getFocusableElements.js
|
|
2
|
-
// With the option included to return null if run out of options
|
|
3
|
-
// TODO swap to stripes-components export once available (Will need <= peer dep bump)
|
|
4
|
-
|
|
5
|
-
import contains from 'dom-helpers/query/contains';
|
|
6
|
-
import matches from 'dom-helpers/query/matches';
|
|
7
|
-
import first from 'lodash/first';
|
|
8
|
-
import last from 'lodash/last';
|
|
9
|
-
|
|
10
|
-
function getVisibleFocusableElements(container = document, includeContained, currentElement) {
|
|
11
|
-
if (container.querySelectorAll) {
|
|
12
|
-
// eslint-disable-next-line max-len
|
|
13
|
-
const focusableSelector = 'a:not([disabled]), button:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([disabled]):not([tabindex="-1"]), [tabIndex="-1"]:not([disabled]):focus';
|
|
14
|
-
return Array.from(container.querySelectorAll(focusableSelector))
|
|
15
|
-
.filter((element) => {
|
|
16
|
-
if (!includeContained) {
|
|
17
|
-
if (element === currentElement) {
|
|
18
|
-
return true;
|
|
19
|
-
}
|
|
20
|
-
if (currentElement && contains(currentElement, element)) {
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (matches(element, '[data-focus-exclude]')) {
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// check for visibility while always include the current activeElement
|
|
30
|
-
return element.offsetWidth > 0 ||
|
|
31
|
-
element.offsetHeight > 0 ||
|
|
32
|
-
element === document.activeElement;
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
return [];
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function getNextorPrevious(collection, current, loop, next, nullOnExit = false) {
|
|
39
|
-
let index = collection.indexOf(current);
|
|
40
|
-
if (index === -1) {
|
|
41
|
-
index = collection.indexOf(document.activeElement);
|
|
42
|
-
}
|
|
43
|
-
const nextElement = collection[index + 1];
|
|
44
|
-
const previousElement = collection[index - 1];
|
|
45
|
-
|
|
46
|
-
// First determine if travelling forwards or backwards through the list
|
|
47
|
-
if (next) {
|
|
48
|
-
// If looping then loop to beginning if nextElement is null
|
|
49
|
-
if (loop) {
|
|
50
|
-
return nextElement || collection[0];
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// If nullOnExit then return null if nextElement is null
|
|
54
|
-
if (nullOnExit) {
|
|
55
|
-
return nextElement;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// Else return end of the list if nextElement is null
|
|
59
|
-
return collection[index + 1] || collection[collection.length - 1];
|
|
60
|
-
} else {
|
|
61
|
-
// If looping then loop to end if previousElement is null
|
|
62
|
-
if (loop) {
|
|
63
|
-
return previousElement || collection[collection.length - 1];
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// If nullOnExit then return null if previousElement is null
|
|
67
|
-
if (nullOnExit) {
|
|
68
|
-
return previousElement;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// Else return beginning of the list if previousElement is null
|
|
72
|
-
return collection[index - 1] || collection[0];
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function getFocusableElement(next, currentElement, includeContained = true, onlyContained = false, loop = true, nullOnExit = false) {
|
|
77
|
-
const container = includeContained && onlyContained ? currentElement : document;
|
|
78
|
-
const focusable = getVisibleFocusableElements(container, includeContained, currentElement);
|
|
79
|
-
if (focusable.length > 0) {
|
|
80
|
-
return getNextorPrevious(focusable, currentElement, loop, next, nullOnExit);
|
|
81
|
-
}
|
|
82
|
-
return null;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export function getNextFocusable(...args) {
|
|
86
|
-
return getFocusableElement(true, ...args);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export function getPreviousFocusable(...args) {
|
|
90
|
-
return getFocusableElement(false, ...args);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export function getLastFocusable(container) {
|
|
94
|
-
return last(getVisibleFocusableElements(container));
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export function getFirstFocusable(container) {
|
|
98
|
-
return first(getVisibleFocusableElements(container));
|
|
99
|
-
}
|