@k-int/stripes-kint-components 1.5.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +40 -1
- package/es/index.js +80 -25
- package/es/lib/ActionList/ActionList.js +92 -33
- package/es/lib/ActionList/ActionListFieldArray.js +202 -104
- package/es/lib/ActionList/index.js +7 -3
- package/es/lib/CustomProperties/Config/CustomPropertiesLookup.js +198 -0
- package/es/lib/CustomProperties/Config/CustomPropertiesSettings.js +321 -0
- package/es/lib/CustomProperties/Config/CustomPropertiesView.js +166 -0
- package/es/lib/CustomProperties/Config/CustomPropertyForm.js +357 -0
- package/es/lib/CustomProperties/Config/index.js +41 -0
- 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/FormModal/FormModal.js +126 -0
- package/es/lib/FormModal/index.js +19 -0
- package/es/lib/NoResultsMessage/NoResultsMessage.js +65 -32
- package/es/lib/NoResultsMessage/index.js +7 -3
- 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 +194 -140
- 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 +174 -99
- package/es/lib/Typedown/index.js +6 -2
- package/es/lib/constants/customProperties.js +60 -0
- 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 +44 -10
- 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/useCustomProperties.js +112 -0
- package/es/lib/hooks/useHelperApp.js +44 -11
- package/es/lib/hooks/useKiwtFieldArray.js +37 -4
- package/es/lib/hooks/useKiwtSASQuery.js +43 -9
- package/es/lib/hooks/useLocalStorageState.js +37 -4
- package/es/lib/hooks/useMutateCustomProperties.js +143 -0
- package/es/lib/hooks/useMutateRefdataValue.js +42 -9
- package/es/lib/hooks/useQIndex.js +42 -9
- package/es/lib/hooks/useRefdata.js +43 -16
- package/es/lib/hooks/useTemplates.js +36 -3
- package/es/lib/utils/buildUrl.js +43 -10
- package/es/lib/utils/generateKiwtQuery.js +33 -4
- package/es/lib/utils/generateKiwtQueryParams.js +31 -2
- package/es/lib/utils/index.js +41 -5
- 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/package.json +19 -10
- package/src/index.js +25 -10
- package/src/lib/ActionList/ActionList.js +32 -22
- package/src/lib/ActionList/ActionListFieldArray.js +56 -10
- package/src/lib/ActionList/README.md +5 -1
- package/src/lib/ActionList/index.js +1 -1
- package/src/lib/CustomProperties/Config/CustomPropertiesLookup.js +111 -0
- package/src/lib/CustomProperties/Config/CustomPropertiesSettings.js +237 -0
- package/src/lib/CustomProperties/Config/CustomPropertiesView.js +150 -0
- package/src/lib/CustomProperties/Config/CustomPropertyForm.js +295 -0
- package/src/lib/CustomProperties/Config/index.js +4 -0
- 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/FormModal/FormModal.js +71 -0
- package/src/lib/FormModal/index.js +1 -0
- package/src/lib/NoResultsMessage/NoResultsMessage.js +2 -2
- package/src/lib/NoResultsMessage/index.js +1 -1
- package/src/lib/{Settings → RefdataButtons}/RefdataButtons.js +1 -1
- package/src/lib/RefdataButtons/index.js +1 -0
- package/src/lib/SASQLookupComponent/SASQLookupComponent.js +7 -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/Typedown.js +52 -9
- package/src/lib/constants/customProperties.js +9 -0
- package/src/lib/{Settings → contexts}/SettingsContext.js +1 -1
- package/src/lib/contexts/index.js +2 -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/useCustomProperties.js +73 -0
- package/src/lib/hooks/useMutateCustomProperties.js +62 -0
- package/src/lib/hooks/useRefdata.js +2 -8
- package/src/lib/utils/index.js +7 -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/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 +48 -1
- package/yarn-error.log +14118 -0
- 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/TypeDown/TypeDown.js +0 -209
- package/es/lib/TypeDown/index.js +0 -15
- 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/TypeDown/README.md +0 -1
- package/src/lib/TypeDown/TypeDown.js +0 -226
- package/src/lib/TypeDown/index.js +0 -1
- 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,126 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
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); }
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports["default"] = void 0;
|
|
9
|
-
|
|
10
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
-
|
|
12
|
-
var _reactQuery = require("react-query");
|
|
13
|
-
|
|
14
|
-
var _reactIntl = require("react-intl");
|
|
15
|
-
|
|
16
|
-
var _core = require("@folio/stripes/core");
|
|
17
|
-
|
|
18
|
-
var _smartComponents = require("@folio/stripes/smart-components");
|
|
19
|
-
|
|
20
|
-
var _SettingPage = _interopRequireDefault(require("./SettingPage"));
|
|
21
|
-
|
|
22
|
-
var _SettingPagePane = _interopRequireDefault(require("./SettingPagePane"));
|
|
23
|
-
|
|
24
|
-
var _SettingsContext = _interopRequireDefault(require("./SettingsContext"));
|
|
25
|
-
|
|
26
|
-
var _utils = require("./utils");
|
|
27
|
-
|
|
28
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
29
|
-
|
|
30
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
31
|
-
|
|
32
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && 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; }
|
|
33
|
-
|
|
34
|
-
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); }
|
|
35
|
-
|
|
36
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
37
|
-
|
|
38
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
39
|
-
|
|
40
|
-
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(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
41
|
-
|
|
42
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
43
|
-
|
|
44
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
45
|
-
|
|
46
|
-
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; }
|
|
47
|
-
|
|
48
|
-
var useSettings = function useSettings(_ref) {
|
|
49
|
-
var dynamicPageExclusions = _ref.dynamicPageExclusions,
|
|
50
|
-
intlKey = _ref.intlKey,
|
|
51
|
-
persistentPages = _ref.persistentPages,
|
|
52
|
-
refdataEndpoint = _ref.refdataEndpoint,
|
|
53
|
-
settingEndpoint = _ref.settingEndpoint,
|
|
54
|
-
templateEndpoint = _ref.templateEndpoint;
|
|
55
|
-
var ky = (0, _core.useOkapiKy)();
|
|
56
|
-
var intl = (0, _reactIntl.useIntl)();
|
|
57
|
-
var extraPathItems = dynamicPageExclusions.map(function (dpe) {
|
|
58
|
-
return "filters=section!=".concat(dpe);
|
|
59
|
-
});
|
|
60
|
-
extraPathItems.push('max=500');
|
|
61
|
-
|
|
62
|
-
var _useQuery = (0, _reactQuery.useQuery)(['stripes-kint-components', 'useSettings', 'appSettings', settingEndpoint], function () {
|
|
63
|
-
return ky("".concat(settingEndpoint, "?").concat(extraPathItems.join('&'))).json();
|
|
64
|
-
}),
|
|
65
|
-
_useQuery$data = _useQuery.data,
|
|
66
|
-
appSettings = _useQuery$data === void 0 ? [] : _useQuery$data,
|
|
67
|
-
isLoading = _useQuery.isLoading;
|
|
68
|
-
|
|
69
|
-
var sections = _toConsumableArray(new Set(appSettings.map(function (s) {
|
|
70
|
-
return s.section;
|
|
71
|
-
})));
|
|
72
|
-
|
|
73
|
-
var dynamic = sections.map(function (section) {
|
|
74
|
-
return {
|
|
75
|
-
route: section,
|
|
76
|
-
label: intl.formatMessage({
|
|
77
|
-
defaultMessage: section,
|
|
78
|
-
id: "".concat(intlKey, ".settings.settingsSection.").concat((0, _utils.toCamelCase)(section))
|
|
79
|
-
}),
|
|
80
|
-
component: function component(props) {
|
|
81
|
-
return /*#__PURE__*/_react["default"].createElement(_SettingPagePane["default"], {
|
|
82
|
-
sectionName: section
|
|
83
|
-
}, /*#__PURE__*/_react["default"].createElement(_SettingPage["default"], _extends({
|
|
84
|
-
sectionName: section
|
|
85
|
-
}, props)));
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
});
|
|
89
|
-
var pageList = persistentPages.concat(dynamic).sort(_utils.sortByLabel);
|
|
90
|
-
|
|
91
|
-
var SettingsContextProvider = function SettingsContextProvider(_ref2) {
|
|
92
|
-
var children = _ref2.children;
|
|
93
|
-
return /*#__PURE__*/_react["default"].createElement(_SettingsContext["default"].Provider, {
|
|
94
|
-
value: {
|
|
95
|
-
intlKey: intlKey,
|
|
96
|
-
refdataEndpoint: refdataEndpoint,
|
|
97
|
-
settingEndpoint: settingEndpoint,
|
|
98
|
-
templateEndpoint: templateEndpoint
|
|
99
|
-
}
|
|
100
|
-
}, children);
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
var SettingsComponent = function SettingsComponent(props) {
|
|
104
|
-
var settingsData = (0, _react.useContext)(_SettingsContext["default"]);
|
|
105
|
-
return /*#__PURE__*/_react["default"].createElement(_smartComponents.Settings, _extends({
|
|
106
|
-
pages: pageList,
|
|
107
|
-
paneTitle: /*#__PURE__*/_react["default"].createElement(_reactIntl.FormattedMessage, {
|
|
108
|
-
id: "".concat(settingsData.intlKey, ".meta.title")
|
|
109
|
-
})
|
|
110
|
-
}, props));
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
var SettingsComponentWithContext = function SettingsComponentWithContext(props) {
|
|
114
|
-
return /*#__PURE__*/_react["default"].createElement(SettingsContextProvider, null, /*#__PURE__*/_react["default"].createElement(SettingsComponent, props));
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
return {
|
|
118
|
-
isLoading: isLoading,
|
|
119
|
-
pageList: pageList,
|
|
120
|
-
SettingsComponent: SettingsComponentWithContext,
|
|
121
|
-
SettingsContextProvider: SettingsContextProvider
|
|
122
|
-
};
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
var _default = useSettings;
|
|
126
|
-
exports["default"] = _default;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "renderHelpText", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function get() {
|
|
9
|
-
return _renderHelpText["default"];
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(exports, "sortByLabel", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function get() {
|
|
15
|
-
return _sortByLabel["default"];
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
Object.defineProperty(exports, "toCamelCase", {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: function get() {
|
|
21
|
-
return _toCamelCase["default"];
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
var _renderHelpText = _interopRequireDefault(require("./renderHelpText"));
|
|
26
|
-
|
|
27
|
-
var _toCamelCase = _interopRequireDefault(require("./toCamelCase"));
|
|
28
|
-
|
|
29
|
-
var _sortByLabel = _interopRequireDefault(require("./sortByLabel"));
|
|
30
|
-
|
|
31
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
@@ -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,209 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
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); }
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports["default"] = void 0;
|
|
9
|
-
|
|
10
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
-
|
|
12
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
-
|
|
14
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
15
|
-
|
|
16
|
-
var _get = _interopRequireDefault(require("lodash/get"));
|
|
17
|
-
|
|
18
|
-
var _components = require("@folio/stripes/components");
|
|
19
|
-
|
|
20
|
-
var _interactionStyles = require("@folio/stripes-components/lib/sharedStyles/interactionStyles.css");
|
|
21
|
-
|
|
22
|
-
var _SearchField = _interopRequireDefault(require("../SearchField"));
|
|
23
|
-
|
|
24
|
-
var _TypeDown = _interopRequireDefault(require("../../../styles/TypeDown.css"));
|
|
25
|
-
|
|
26
|
-
var _typedownHooks = require("../hooks/typedownHooks");
|
|
27
|
-
|
|
28
|
-
var _selectorSafe = _interopRequireDefault(require("../utils/selectorSafe"));
|
|
29
|
-
|
|
30
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
31
|
-
|
|
32
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
33
|
-
|
|
34
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && 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; }
|
|
35
|
-
|
|
36
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
37
|
-
|
|
38
|
-
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."); }
|
|
39
|
-
|
|
40
|
-
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(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
41
|
-
|
|
42
|
-
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; }
|
|
43
|
-
|
|
44
|
-
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_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; }
|
|
45
|
-
|
|
46
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
47
|
-
|
|
48
|
-
/* @deprecated
|
|
49
|
-
* Replaced by Typedown and QueryTypedown.
|
|
50
|
-
*/
|
|
51
|
-
var TypeDown = function TypeDown(_ref) {
|
|
52
|
-
var input = _ref.input,
|
|
53
|
-
meta = _ref.meta,
|
|
54
|
-
onChange = _ref.onChange,
|
|
55
|
-
path = _ref.path,
|
|
56
|
-
pathMutator = _ref.pathMutator,
|
|
57
|
-
_ref$renderFooter = _ref.renderFooter,
|
|
58
|
-
renderFooter = _ref$renderFooter === void 0 ? null : _ref$renderFooter,
|
|
59
|
-
_ref$renderListItem = _ref.renderListItem,
|
|
60
|
-
renderListItem = _ref$renderListItem === void 0 ? null : _ref$renderListItem,
|
|
61
|
-
_ref$uniqueIdentifica = _ref.uniqueIdentificationPath,
|
|
62
|
-
uniqueIdentificationPath = _ref$uniqueIdentifica === void 0 ? 'id' : _ref$uniqueIdentifica;
|
|
63
|
-
(0, _react.useEffect)(function () {
|
|
64
|
-
if (process.env.NODE_ENV === 'development') {
|
|
65
|
-
console.warn('TypeDown component is deprecated, you likely want either Typedown or QueryTypedown');
|
|
66
|
-
}
|
|
67
|
-
}, []);
|
|
68
|
-
var selectedUniqueId = (0, _get["default"])(input.value, uniqueIdentificationPath);
|
|
69
|
-
|
|
70
|
-
var _useState = (0, _react.useState)(pathMutator(null, path)),
|
|
71
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
72
|
-
callPath = _useState2[0],
|
|
73
|
-
setCallPath = _useState2[1];
|
|
74
|
-
|
|
75
|
-
var data = (0, _typedownHooks.useTypedownData)(callPath); // Hook to set up all the essentials
|
|
76
|
-
|
|
77
|
-
var _useTypedown = (0, _typedownHooks.useTypedown)(input.name),
|
|
78
|
-
_useTypedown$refs = _useTypedown.refs,
|
|
79
|
-
listRef = _useTypedown$refs.listRef,
|
|
80
|
-
triggerRef = _useTypedown$refs.triggerRef,
|
|
81
|
-
overlayRef = _useTypedown$refs.overlayRef,
|
|
82
|
-
footerRef = _useTypedown$refs.footerRef,
|
|
83
|
-
_useTypedown$handlers = _useTypedown.handlers,
|
|
84
|
-
handleNextFocus = _useTypedown$handlers.handleNextFocus,
|
|
85
|
-
listKeyDownHandler = _useTypedown$handlers.listKeyDownHandler,
|
|
86
|
-
searchFieldKeyDownHandler = _useTypedown$handlers.searchFieldKeyDownHandler,
|
|
87
|
-
_useTypedown$variable = _useTypedown.variables,
|
|
88
|
-
open = _useTypedown$variable.open,
|
|
89
|
-
portal = _useTypedown$variable.portal,
|
|
90
|
-
resizeRef = _useTypedown$variable.resizeRef,
|
|
91
|
-
searchWidth = _useTypedown$variable.searchWidth;
|
|
92
|
-
|
|
93
|
-
var renderItem = (0, _react.useCallback)(function (option) {
|
|
94
|
-
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
95
|
-
className: _TypeDown["default"].listItem
|
|
96
|
-
}, renderListItem ? renderListItem(option) : (0, _get["default"])(option, uniqueIdentificationPath));
|
|
97
|
-
}, [renderListItem, uniqueIdentificationPath]);
|
|
98
|
-
|
|
99
|
-
var handleChange = function handleChange(value) {
|
|
100
|
-
input.onChange(value);
|
|
101
|
-
|
|
102
|
-
if (typeof onChange === 'function') {
|
|
103
|
-
onChange(value);
|
|
104
|
-
}
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
var dropDown = (0, _react.useCallback)(function () {
|
|
108
|
-
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
109
|
-
className: _TypeDown["default"].dropdownMenu,
|
|
110
|
-
id: "typedown-parent-".concat((0, _selectorSafe["default"])(input.name), "-menu"),
|
|
111
|
-
style: {
|
|
112
|
-
'--searchWidth': "".concat(searchWidth, "px")
|
|
113
|
-
}
|
|
114
|
-
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
115
|
-
ref: listRef,
|
|
116
|
-
className: _TypeDown["default"].listContainer,
|
|
117
|
-
id: "typedown-list"
|
|
118
|
-
}, data !== null && data !== void 0 && data.length ? data === null || data === void 0 ? void 0 : data.map(function (d, index) {
|
|
119
|
-
var isSelected = (0, _get["default"])(input.value, uniqueIdentificationPath) === (0, _get["default"])(d, uniqueIdentificationPath);
|
|
120
|
-
return /*#__PURE__*/_react["default"].createElement("button", {
|
|
121
|
-
key: "typedown-button-[".concat(index, "]"),
|
|
122
|
-
className: (0, _classnames["default"])(_interactionStyles.interactionStyles, _TypeDown["default"].fullWidth, _TypeDown["default"].menuButton),
|
|
123
|
-
"data-selected": isSelected,
|
|
124
|
-
id: "typedown-button-[".concat(index, "]"),
|
|
125
|
-
onClick: function onClick() {
|
|
126
|
-
handleChange(d);
|
|
127
|
-
handleNextFocus();
|
|
128
|
-
},
|
|
129
|
-
onKeyDown: listKeyDownHandler,
|
|
130
|
-
type: "button"
|
|
131
|
-
}, renderItem(d));
|
|
132
|
-
}) :
|
|
133
|
-
/*#__PURE__*/
|
|
134
|
-
// TODO test this
|
|
135
|
-
_react["default"].createElement(_components.EndOfList, null)), renderFooter && /*#__PURE__*/_react["default"].createElement("div", {
|
|
136
|
-
ref: footerRef,
|
|
137
|
-
className: _TypeDown["default"].footer,
|
|
138
|
-
id: "typedown-footer"
|
|
139
|
-
}, renderFooter()));
|
|
140
|
-
}, [data, footerRef, handleNextFocus, input, listKeyDownHandler, listRef, renderFooter, renderItem, searchWidth, uniqueIdentificationPath]);
|
|
141
|
-
|
|
142
|
-
var renderSearchField = function renderSearchField() {
|
|
143
|
-
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
144
|
-
ref: triggerRef,
|
|
145
|
-
id: "typedown-parent-".concat((0, _selectorSafe["default"])(input.name), "-searchField")
|
|
146
|
-
}, /*#__PURE__*/_react["default"].createElement(_SearchField["default"] // Pass meta through so correct styling gets applied to the TextField
|
|
147
|
-
, {
|
|
148
|
-
id: "typedown-searchField",
|
|
149
|
-
marginBottom0: true,
|
|
150
|
-
meta: meta,
|
|
151
|
-
onChange: function onChange(e) {
|
|
152
|
-
setCallPath(pathMutator(e.target.value, path));
|
|
153
|
-
},
|
|
154
|
-
onKeyDown: searchFieldKeyDownHandler
|
|
155
|
-
}));
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
159
|
-
ref: resizeRef
|
|
160
|
-
}, renderSearchField(), /*#__PURE__*/_react["default"].createElement(_components.Popper, {
|
|
161
|
-
key: "typedown-menu-toggle",
|
|
162
|
-
anchorRef: triggerRef,
|
|
163
|
-
className: (0, _classnames["default"])(_TypeDown["default"].dropdown, _TypeDown["default"].fullWidth),
|
|
164
|
-
isOpen: open,
|
|
165
|
-
modifiers: {
|
|
166
|
-
flip: {
|
|
167
|
-
boundariesElement: 'viewport',
|
|
168
|
-
padding: 10
|
|
169
|
-
},
|
|
170
|
-
preventOverflow: {
|
|
171
|
-
boundariesElement: 'viewport',
|
|
172
|
-
padding: 10
|
|
173
|
-
}
|
|
174
|
-
},
|
|
175
|
-
overlayProps: {
|
|
176
|
-
'ref': overlayRef,
|
|
177
|
-
'tabIndex': '-1',
|
|
178
|
-
'onClick': function onClick(e) {
|
|
179
|
-
e.stopPropagation();
|
|
180
|
-
} // prevent propagation of click events
|
|
181
|
-
|
|
182
|
-
},
|
|
183
|
-
overlayRef: overlayRef,
|
|
184
|
-
portal: portal
|
|
185
|
-
}, dropDown()), selectedUniqueId && !open && /*#__PURE__*/_react["default"].createElement("div", {
|
|
186
|
-
className: (0, _classnames["default"])(_TypeDown["default"].selected, _TypeDown["default"].selectedDisplay)
|
|
187
|
-
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
188
|
-
className: _TypeDown["default"].selectedItem
|
|
189
|
-
}, renderItem(input.value)), /*#__PURE__*/_react["default"].createElement(_components.IconButton, {
|
|
190
|
-
className: _TypeDown["default"].clearItem,
|
|
191
|
-
icon: "times-circle-solid",
|
|
192
|
-
onClick: function onClick() {
|
|
193
|
-
return handleChange();
|
|
194
|
-
}
|
|
195
|
-
})));
|
|
196
|
-
};
|
|
197
|
-
|
|
198
|
-
TypeDown.propTypes = {
|
|
199
|
-
input: _propTypes["default"].object,
|
|
200
|
-
meta: _propTypes["default"].object,
|
|
201
|
-
onChange: _propTypes["default"].func,
|
|
202
|
-
path: _propTypes["default"].string,
|
|
203
|
-
pathMutator: _propTypes["default"].func,
|
|
204
|
-
renderFooter: _propTypes["default"].func,
|
|
205
|
-
renderListItem: _propTypes["default"].func,
|
|
206
|
-
uniqueIdentificationPath: _propTypes["default"].string
|
|
207
|
-
};
|
|
208
|
-
var _default = TypeDown;
|
|
209
|
-
exports["default"] = _default;
|
package/es/lib/TypeDown/index.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "default", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function get() {
|
|
9
|
-
return _TypeDown["default"];
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
var _TypeDown = _interopRequireDefault(require("./TypeDown"));
|
|
14
|
-
|
|
15
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
@@ -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;
|