@elliemae/ds-pagination 3.80.0-next.51 → 3.80.0-next.53
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/parts/DSPaginator/DSPaginator.js +10 -166
- package/dist/cjs/parts/DSPaginator/DSPaginator.js.map +2 -2
- package/dist/cjs/parts/DSPaginator/{config/usePaginationSearch.js → DSPaginatorCTX.js} +7 -32
- package/dist/cjs/parts/DSPaginator/DSPaginatorCTX.js.map +7 -0
- package/dist/cjs/parts/DSPaginator/config/{createPaginatorHeader.js → getAmountOfPages.js} +8 -23
- package/dist/cjs/parts/DSPaginator/config/getAmountOfPages.js.map +7 -0
- package/dist/cjs/parts/DSPaginator/config/getInstanceIds.js +40 -0
- package/dist/cjs/parts/DSPaginator/config/getInstanceIds.js.map +7 -0
- package/dist/cjs/parts/DSPaginator/config/navigationKeys.js +44 -0
- package/dist/cjs/parts/DSPaginator/config/navigationKeys.js.map +7 -0
- package/dist/cjs/parts/DSPaginator/config/useFocusTracker.js +77 -0
- package/dist/cjs/parts/DSPaginator/config/useFocusTracker.js.map +7 -0
- package/dist/cjs/parts/DSPaginator/config/usePaginator.js +73 -49
- package/dist/cjs/parts/DSPaginator/config/usePaginator.js.map +2 -2
- package/dist/cjs/parts/DSPaginator/config/usePaginatorFloatingContext.js +86 -0
- package/dist/cjs/parts/DSPaginator/config/usePaginatorFloatingContext.js.map +7 -0
- package/dist/cjs/parts/DSPaginator/config/usePaginatorInteractions.js +170 -0
- package/dist/cjs/parts/DSPaginator/config/usePaginatorInteractions.js.map +7 -0
- package/dist/cjs/parts/DSPaginator/config/usePaginatorSizing.js +80 -0
- package/dist/cjs/parts/DSPaginator/config/usePaginatorSizing.js.map +7 -0
- package/dist/cjs/parts/DSPaginator/config/useValidateProps.js.map +2 -2
- package/dist/cjs/parts/DSPaginator/constants/index.js +49 -3
- package/dist/cjs/parts/DSPaginator/constants/index.js.map +2 -2
- package/dist/cjs/parts/DSPaginator/parts/OptionRenderer.js +98 -0
- package/dist/cjs/parts/DSPaginator/parts/OptionRenderer.js.map +7 -0
- package/dist/cjs/parts/DSPaginator/parts/Panel.js +131 -0
- package/dist/cjs/parts/DSPaginator/parts/Panel.js.map +7 -0
- package/dist/cjs/parts/DSPaginator/parts/Trigger.js +124 -0
- package/dist/cjs/parts/DSPaginator/parts/Trigger.js.map +7 -0
- package/dist/cjs/parts/DSPaginator/react-desc-prop-types.js +6 -1
- package/dist/cjs/parts/DSPaginator/react-desc-prop-types.js.map +2 -2
- package/dist/cjs/parts/DSPaginator/styled.js +113 -38
- package/dist/cjs/parts/DSPaginator/styled.js.map +3 -3
- package/dist/cjs/parts/DSPaginator/typescript-testing/slot-props.js +12 -1
- package/dist/cjs/parts/DSPaginator/typescript-testing/slot-props.js.map +2 -2
- package/dist/cjs/parts/DSPaginator/typescript-testing/typescript-testing.js +2 -1
- package/dist/cjs/parts/DSPaginator/typescript-testing/typescript-testing.js.map +2 -2
- package/dist/cjs/parts/DSPerPageSelector/DSPerPageSelector.js +10 -79
- package/dist/cjs/parts/DSPerPageSelector/DSPerPageSelector.js.map +3 -3
- package/dist/cjs/parts/DSPerPageSelector/DSPerPageSelectorCTX.js +38 -0
- package/dist/cjs/parts/DSPerPageSelector/DSPerPageSelectorCTX.js.map +7 -0
- package/dist/cjs/parts/DSPerPageSelector/config/getInstanceIds.js +40 -0
- package/dist/cjs/parts/DSPerPageSelector/config/getInstanceIds.js.map +7 -0
- package/dist/cjs/parts/DSPerPageSelector/config/getOptions.js.map +2 -2
- package/dist/cjs/parts/DSPerPageSelector/config/getSelectedOptionIndex.js +36 -0
- package/dist/cjs/parts/DSPerPageSelector/config/getSelectedOptionIndex.js.map +7 -0
- package/dist/cjs/parts/DSPerPageSelector/config/navigationKeys.js +44 -0
- package/dist/cjs/parts/DSPerPageSelector/config/navigationKeys.js.map +7 -0
- package/dist/cjs/parts/DSPerPageSelector/config/useFocusTracker.js +83 -0
- package/dist/cjs/parts/DSPerPageSelector/config/useFocusTracker.js.map +7 -0
- package/dist/cjs/parts/DSPerPageSelector/config/usePerPageSelector.js +68 -20
- package/dist/cjs/parts/DSPerPageSelector/config/usePerPageSelector.js.map +2 -2
- package/dist/cjs/parts/DSPerPageSelector/config/usePerPageSelectorFloatingContext.js +82 -0
- package/dist/cjs/parts/DSPerPageSelector/config/usePerPageSelectorFloatingContext.js.map +7 -0
- package/dist/cjs/parts/DSPerPageSelector/config/usePerPageSelectorInteractions.js +175 -0
- package/dist/cjs/parts/DSPerPageSelector/config/usePerPageSelectorInteractions.js.map +7 -0
- package/dist/cjs/parts/DSPerPageSelector/config/usePerPageSelectorSizing.js +66 -0
- package/dist/cjs/parts/DSPerPageSelector/config/usePerPageSelectorSizing.js.map +7 -0
- package/dist/cjs/parts/DSPerPageSelector/constants/index.js +47 -8
- package/dist/cjs/parts/DSPerPageSelector/constants/index.js.map +2 -2
- package/dist/cjs/parts/DSPerPageSelector/parts/OptionRenderer.js +94 -0
- package/dist/cjs/parts/DSPerPageSelector/parts/OptionRenderer.js.map +7 -0
- package/dist/cjs/parts/DSPerPageSelector/parts/Panel.js +120 -0
- package/dist/cjs/parts/DSPerPageSelector/parts/Panel.js.map +7 -0
- package/dist/cjs/parts/DSPerPageSelector/parts/Trigger.js +95 -0
- package/dist/cjs/parts/DSPerPageSelector/parts/Trigger.js.map +7 -0
- package/dist/cjs/parts/DSPerPageSelector/react-desc-prop-types.js +19 -2
- package/dist/cjs/parts/DSPerPageSelector/react-desc-prop-types.js.map +2 -2
- package/dist/cjs/parts/DSPerPageSelector/styled.js +104 -32
- package/dist/cjs/parts/DSPerPageSelector/styled.js.map +2 -2
- package/dist/cjs/parts/DSPerPageSelector/typescript-testing/slots-props.js +10 -1
- package/dist/cjs/parts/DSPerPageSelector/typescript-testing/slots-props.js.map +2 -2
- package/dist/cjs/parts/DSPerPageSelector/typescript-testing/typescript-testing.js +60 -1
- package/dist/cjs/parts/DSPerPageSelector/typescript-testing/typescript-testing.js.map +2 -2
- package/dist/cjs/react-desc-prop-types.js.map +1 -1
- package/dist/esm/parts/DSPaginator/DSPaginator.js +12 -168
- package/dist/esm/parts/DSPaginator/DSPaginator.js.map +2 -2
- package/dist/esm/parts/DSPaginator/DSPaginatorCTX.js +8 -0
- package/dist/esm/parts/DSPaginator/DSPaginatorCTX.js.map +7 -0
- package/dist/esm/parts/DSPaginator/config/getAmountOfPages.js +9 -0
- package/dist/esm/parts/DSPaginator/config/getAmountOfPages.js.map +7 -0
- package/dist/esm/parts/DSPaginator/config/getInstanceIds.js +10 -0
- package/dist/esm/parts/DSPaginator/config/getInstanceIds.js.map +7 -0
- package/dist/esm/parts/DSPaginator/config/navigationKeys.js +14 -0
- package/dist/esm/parts/DSPaginator/config/navigationKeys.js.map +7 -0
- package/dist/esm/parts/DSPaginator/config/useFocusTracker.js +47 -0
- package/dist/esm/parts/DSPaginator/config/useFocusTracker.js.map +7 -0
- package/dist/esm/parts/DSPaginator/config/usePaginator.js +74 -50
- package/dist/esm/parts/DSPaginator/config/usePaginator.js.map +2 -2
- package/dist/esm/parts/DSPaginator/config/usePaginatorFloatingContext.js +56 -0
- package/dist/esm/parts/DSPaginator/config/usePaginatorFloatingContext.js.map +7 -0
- package/dist/esm/parts/DSPaginator/config/usePaginatorInteractions.js +140 -0
- package/dist/esm/parts/DSPaginator/config/usePaginatorInteractions.js.map +7 -0
- package/dist/esm/parts/DSPaginator/config/usePaginatorSizing.js +56 -0
- package/dist/esm/parts/DSPaginator/config/usePaginatorSizing.js.map +7 -0
- package/dist/esm/parts/DSPaginator/config/useValidateProps.js.map +2 -2
- package/dist/esm/parts/DSPaginator/constants/index.js +49 -3
- package/dist/esm/parts/DSPaginator/constants/index.js.map +2 -2
- package/dist/esm/parts/DSPaginator/parts/OptionRenderer.js +68 -0
- package/dist/esm/parts/DSPaginator/parts/OptionRenderer.js.map +7 -0
- package/dist/esm/parts/DSPaginator/parts/Panel.js +101 -0
- package/dist/esm/parts/DSPaginator/parts/Panel.js.map +7 -0
- package/dist/esm/parts/DSPaginator/parts/Trigger.js +94 -0
- package/dist/esm/parts/DSPaginator/parts/Trigger.js.map +7 -0
- package/dist/esm/parts/DSPaginator/react-desc-prop-types.js +6 -1
- package/dist/esm/parts/DSPaginator/react-desc-prop-types.js.map +2 -2
- package/dist/esm/parts/DSPaginator/styled.js +120 -39
- package/dist/esm/parts/DSPaginator/styled.js.map +2 -2
- package/dist/esm/parts/DSPaginator/typescript-testing/slot-props.js +12 -1
- package/dist/esm/parts/DSPaginator/typescript-testing/slot-props.js.map +2 -2
- package/dist/esm/parts/DSPaginator/typescript-testing/typescript-testing.js +2 -1
- package/dist/esm/parts/DSPaginator/typescript-testing/typescript-testing.js.map +2 -2
- package/dist/esm/parts/DSPerPageSelector/DSPerPageSelector.js +11 -80
- package/dist/esm/parts/DSPerPageSelector/DSPerPageSelector.js.map +3 -3
- package/dist/esm/parts/DSPerPageSelector/DSPerPageSelectorCTX.js +8 -0
- package/dist/esm/parts/DSPerPageSelector/DSPerPageSelectorCTX.js.map +7 -0
- package/dist/esm/parts/DSPerPageSelector/config/getInstanceIds.js +10 -0
- package/dist/esm/parts/DSPerPageSelector/config/getInstanceIds.js.map +7 -0
- package/dist/esm/parts/DSPerPageSelector/config/getOptions.js.map +2 -2
- package/dist/esm/parts/DSPerPageSelector/config/getSelectedOptionIndex.js +6 -0
- package/dist/esm/parts/DSPerPageSelector/config/getSelectedOptionIndex.js.map +7 -0
- package/dist/esm/parts/DSPerPageSelector/config/navigationKeys.js +14 -0
- package/dist/esm/parts/DSPerPageSelector/config/navigationKeys.js.map +7 -0
- package/dist/esm/parts/DSPerPageSelector/config/useFocusTracker.js +53 -0
- package/dist/esm/parts/DSPerPageSelector/config/useFocusTracker.js.map +7 -0
- package/dist/esm/parts/DSPerPageSelector/config/usePerPageSelector.js +69 -21
- package/dist/esm/parts/DSPerPageSelector/config/usePerPageSelector.js.map +2 -2
- package/dist/esm/parts/DSPerPageSelector/config/usePerPageSelectorFloatingContext.js +52 -0
- package/dist/esm/parts/DSPerPageSelector/config/usePerPageSelectorFloatingContext.js.map +7 -0
- package/dist/esm/parts/DSPerPageSelector/config/usePerPageSelectorInteractions.js +145 -0
- package/dist/esm/parts/DSPerPageSelector/config/usePerPageSelectorInteractions.js.map +7 -0
- package/dist/esm/parts/DSPerPageSelector/config/usePerPageSelectorSizing.js +42 -0
- package/dist/esm/parts/DSPerPageSelector/config/usePerPageSelectorSizing.js.map +7 -0
- package/dist/esm/parts/DSPerPageSelector/constants/index.js +47 -8
- package/dist/esm/parts/DSPerPageSelector/constants/index.js.map +2 -2
- package/dist/esm/parts/DSPerPageSelector/parts/OptionRenderer.js +64 -0
- package/dist/esm/parts/DSPerPageSelector/parts/OptionRenderer.js.map +7 -0
- package/dist/esm/parts/DSPerPageSelector/parts/Panel.js +90 -0
- package/dist/esm/parts/DSPerPageSelector/parts/Panel.js.map +7 -0
- package/dist/esm/parts/DSPerPageSelector/parts/Trigger.js +65 -0
- package/dist/esm/parts/DSPerPageSelector/parts/Trigger.js.map +7 -0
- package/dist/esm/parts/DSPerPageSelector/react-desc-prop-types.js +19 -2
- package/dist/esm/parts/DSPerPageSelector/react-desc-prop-types.js.map +2 -2
- package/dist/esm/parts/DSPerPageSelector/styled.js +111 -33
- package/dist/esm/parts/DSPerPageSelector/styled.js.map +2 -2
- package/dist/esm/parts/DSPerPageSelector/typescript-testing/slots-props.js +10 -1
- package/dist/esm/parts/DSPerPageSelector/typescript-testing/slots-props.js.map +2 -2
- package/dist/esm/parts/DSPerPageSelector/typescript-testing/typescript-testing.js +60 -1
- package/dist/esm/parts/DSPerPageSelector/typescript-testing/typescript-testing.js.map +2 -2
- package/dist/esm/react-desc-prop-types.js.map +1 -1
- package/dist/types/parts/DSPageNextButton/config/usePageNextButton.d.ts +4 -4
- package/dist/types/parts/DSPagePrevButton/config/usePagePrevButton.d.ts +4 -4
- package/dist/types/parts/DSPaginationContainer/config/usePaginationContainer.d.ts +4 -4
- package/dist/types/parts/DSPaginationSeparator/config/usePaginationSeparator.d.ts +4 -4
- package/dist/types/parts/DSPaginator/DSPaginator.d.ts +5 -0
- package/dist/types/parts/DSPaginator/DSPaginatorCTX.d.ts +5 -0
- package/dist/types/parts/DSPaginator/config/getAmountOfPages.d.ts +1 -0
- package/dist/types/parts/DSPaginator/config/getInstanceIds.d.ts +3 -0
- package/dist/types/parts/DSPaginator/config/navigationKeys.d.ts +3 -0
- package/dist/types/parts/DSPaginator/config/useFocusTracker.d.ts +20 -0
- package/dist/types/parts/DSPaginator/config/usePaginator.d.ts +52 -18
- package/dist/types/parts/DSPaginator/config/usePaginatorFloatingContext.d.ts +31 -0
- package/dist/types/parts/DSPaginator/config/usePaginatorInteractions.d.ts +37 -0
- package/dist/types/parts/DSPaginator/config/usePaginatorSizing.d.ts +37 -0
- package/dist/types/parts/DSPaginator/constants/index.d.ts +36 -1
- package/dist/types/parts/DSPaginator/parts/OptionRenderer.d.ts +11 -0
- package/dist/types/parts/DSPaginator/parts/Panel.d.ts +5 -0
- package/dist/types/parts/DSPaginator/parts/Trigger.d.ts +5 -0
- package/dist/types/parts/DSPaginator/react-desc-prop-types.d.ts +17 -0
- package/dist/types/parts/DSPaginator/styled.d.ts +17 -4
- package/dist/types/parts/DSPerPageSelector/DSPerPageSelector.d.ts +5 -0
- package/dist/types/parts/DSPerPageSelector/DSPerPageSelectorCTX.d.ts +5 -0
- package/dist/types/parts/DSPerPageSelector/config/getInstanceIds.d.ts +3 -0
- package/dist/types/parts/DSPerPageSelector/config/getOptions.d.ts +3 -3
- package/dist/types/parts/DSPerPageSelector/config/getSelectedOptionIndex.d.ts +2 -0
- package/dist/types/parts/DSPerPageSelector/config/navigationKeys.d.ts +3 -0
- package/dist/types/parts/DSPerPageSelector/config/useFocusTracker.d.ts +22 -0
- package/dist/types/parts/DSPerPageSelector/config/usePerPageSelector.d.ts +43 -10
- package/dist/types/parts/DSPerPageSelector/config/usePerPageSelectorFloatingContext.d.ts +31 -0
- package/dist/types/parts/DSPerPageSelector/config/usePerPageSelectorInteractions.d.ts +38 -0
- package/dist/types/parts/DSPerPageSelector/config/usePerPageSelectorSizing.d.ts +25 -0
- package/dist/types/parts/DSPerPageSelector/constants/index.d.ts +32 -5
- package/dist/types/parts/DSPerPageSelector/parts/OptionRenderer.d.ts +11 -0
- package/dist/types/parts/DSPerPageSelector/parts/Panel.d.ts +5 -0
- package/dist/types/parts/DSPerPageSelector/parts/Trigger.d.ts +5 -0
- package/dist/types/parts/DSPerPageSelector/react-desc-prop-types.d.ts +27 -2
- package/dist/types/parts/DSPerPageSelector/styled.d.ts +15 -2
- package/dist/types/react-desc-prop-types.d.ts +2 -2
- package/package.json +15 -13
- package/dist/cjs/parts/DSPaginator/config/createPaginatorHeader.js.map +0 -7
- package/dist/cjs/parts/DSPaginator/config/getOptions.js +0 -76
- package/dist/cjs/parts/DSPaginator/config/getOptions.js.map +0 -7
- package/dist/cjs/parts/DSPaginator/config/usePaginationSearch.js.map +0 -7
- package/dist/esm/parts/DSPaginator/config/createPaginatorHeader.js +0 -24
- package/dist/esm/parts/DSPaginator/config/createPaginatorHeader.js.map +0 -7
- package/dist/esm/parts/DSPaginator/config/getOptions.js +0 -46
- package/dist/esm/parts/DSPaginator/config/getOptions.js.map +0 -7
- package/dist/esm/parts/DSPaginator/config/usePaginationSearch.js +0 -33
- package/dist/esm/parts/DSPaginator/config/usePaginationSearch.js.map +0 -7
- package/dist/types/parts/DSPaginator/config/createPaginatorHeader.d.ts +0 -9
- package/dist/types/parts/DSPaginator/config/getOptions.d.ts +0 -8
- package/dist/types/parts/DSPaginator/config/usePaginationSearch.d.ts +0 -1
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var navigationKeys_exports = {};
|
|
30
|
+
__export(navigationKeys_exports, {
|
|
31
|
+
NAVIGATION_KEYS: () => NAVIGATION_KEYS
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(navigationKeys_exports);
|
|
34
|
+
var React = __toESM(require("react"));
|
|
35
|
+
var import_constants = require("../constants/index.js");
|
|
36
|
+
const NAVIGATION_KEYS = {
|
|
37
|
+
ArrowDown: (currentIndex) => currentIndex + 1,
|
|
38
|
+
ArrowUp: (currentIndex) => currentIndex - 1,
|
|
39
|
+
PageDown: (currentIndex) => currentIndex + import_constants.PER_PAGE_SELECTOR_PAGE_JUMP,
|
|
40
|
+
PageUp: (currentIndex) => currentIndex - import_constants.PER_PAGE_SELECTOR_PAGE_JUMP,
|
|
41
|
+
Home: () => 0,
|
|
42
|
+
End: (_currentIndex, amountOfOptions) => amountOfOptions - 1
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=navigationKeys.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/parts/DSPerPageSelector/config/navigationKeys.ts", "../../../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["import { PER_PAGE_SELECTOR_PAGE_JUMP } from '../constants/index.js';\n\ntype GetTargetIndex = (currentIndex: number, amountOfOptions: number) => number;\n\n// the keys that only MOVE the focus through the options (APG listbox / select-only combobox navigation)\nexport const NAVIGATION_KEYS: Record<string, GetTargetIndex> = {\n ArrowDown: (currentIndex) => currentIndex + 1,\n ArrowUp: (currentIndex) => currentIndex - 1,\n PageDown: (currentIndex) => currentIndex + PER_PAGE_SELECTOR_PAGE_JUMP,\n PageUp: (currentIndex) => currentIndex - PER_PAGE_SELECTOR_PAGE_JUMP,\n Home: () => 0,\n End: (_currentIndex, amountOfOptions) => amountOfOptions - 1,\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,uBAA4C;AAKrC,MAAM,kBAAkD;AAAA,EAC7D,WAAW,CAAC,iBAAiB,eAAe;AAAA,EAC5C,SAAS,CAAC,iBAAiB,eAAe;AAAA,EAC1C,UAAU,CAAC,iBAAiB,eAAe;AAAA,EAC3C,QAAQ,CAAC,iBAAiB,eAAe;AAAA,EACzC,MAAM,MAAM;AAAA,EACZ,KAAK,CAAC,eAAe,oBAAoB,kBAAkB;AAC7D;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var useFocusTracker_exports = {};
|
|
30
|
+
__export(useFocusTracker_exports, {
|
|
31
|
+
getOptionRegionId: () => getOptionRegionId,
|
|
32
|
+
useFocusTracker: () => useFocusTracker
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(useFocusTracker_exports);
|
|
35
|
+
var React = __toESM(require("react"));
|
|
36
|
+
var import_react = require("react");
|
|
37
|
+
var import_constants = require("../constants/index.js");
|
|
38
|
+
var import_getSelectedOptionIndex = require("./getSelectedOptionIndex.js");
|
|
39
|
+
const getOptionRegionId = (dsId) => `${import_constants.PER_PAGE_SELECTOR_REGION_FOCUSES.OPTION_PREFIX}${dsId}`;
|
|
40
|
+
const useFocusTracker = ({ options, pageSize }) => {
|
|
41
|
+
const [focusRegion, setFocusRegion] = (0, import_react.useState)(import_constants.PER_PAGE_SELECTOR_REGION_FOCUSES.RESET);
|
|
42
|
+
const focusedIndex = (0, import_react.useMemo)(
|
|
43
|
+
() => options.findIndex((option) => getOptionRegionId(option.dsId) === focusRegion),
|
|
44
|
+
[focusRegion, options]
|
|
45
|
+
);
|
|
46
|
+
const clampIndex = (0, import_react.useCallback)((index) => Math.min(Math.max(index, 0), options.length - 1), [options.length]);
|
|
47
|
+
const trackFocusRegionReset = (0, import_react.useCallback)(() => setFocusRegion(import_constants.PER_PAGE_SELECTOR_REGION_FOCUSES.RESET), []);
|
|
48
|
+
const trackFocusTrigger = (0, import_react.useCallback)(() => setFocusRegion(import_constants.PER_PAGE_SELECTOR_REGION_FOCUSES.TRIGGER), []);
|
|
49
|
+
const trackFocusOptionAtIndex = (0, import_react.useCallback)(
|
|
50
|
+
(index) => {
|
|
51
|
+
if (options.length > 0) setFocusRegion(getOptionRegionId(options[clampIndex(index)].dsId));
|
|
52
|
+
},
|
|
53
|
+
[clampIndex, options]
|
|
54
|
+
);
|
|
55
|
+
const trackFocusOption = (0, import_react.useCallback)((dsId) => setFocusRegion(getOptionRegionId(dsId)), []);
|
|
56
|
+
const trackFocusSelectedOption = (0, import_react.useCallback)(
|
|
57
|
+
() => trackFocusOptionAtIndex(Math.max((0, import_getSelectedOptionIndex.getSelectedOptionIndex)(options, pageSize), 0)),
|
|
58
|
+
[options, pageSize, trackFocusOptionAtIndex]
|
|
59
|
+
);
|
|
60
|
+
return (0, import_react.useMemo)(
|
|
61
|
+
() => ({
|
|
62
|
+
focusRegion,
|
|
63
|
+
focusedIndex,
|
|
64
|
+
clampIndex,
|
|
65
|
+
trackFocusRegionReset,
|
|
66
|
+
trackFocusTrigger,
|
|
67
|
+
trackFocusOption,
|
|
68
|
+
trackFocusOptionAtIndex,
|
|
69
|
+
trackFocusSelectedOption
|
|
70
|
+
}),
|
|
71
|
+
[
|
|
72
|
+
focusRegion,
|
|
73
|
+
focusedIndex,
|
|
74
|
+
clampIndex,
|
|
75
|
+
trackFocusRegionReset,
|
|
76
|
+
trackFocusTrigger,
|
|
77
|
+
trackFocusOption,
|
|
78
|
+
trackFocusOptionAtIndex,
|
|
79
|
+
trackFocusSelectedOption
|
|
80
|
+
]
|
|
81
|
+
);
|
|
82
|
+
};
|
|
83
|
+
//# sourceMappingURL=useFocusTracker.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/parts/DSPerPageSelector/config/useFocusTracker.ts", "../../../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["import { useCallback, useMemo, useState } from 'react';\nimport { PER_PAGE_SELECTOR_REGION_FOCUSES } from '../constants/index.js';\nimport type { DSPerPageSelectorT } from '../react-desc-prop-types.js';\nimport { getSelectedOptionIndex } from './getSelectedOptionIndex.js';\n\ntype FocusTrackerConfigT = {\n options: DSPerPageSelectorT.PerPageOption[];\n pageSize: number;\n};\n\n// the identity of an option is its dsId: stable, never the position in the (virtualized) DOM\nexport const getOptionRegionId = (dsId: string) => `${PER_PAGE_SELECTOR_REGION_FOCUSES.OPTION_PREFIX}${dsId}`;\n\n/**\n * Focus tracker (see .github/memories/project_focus_tracker.md): the handlers declare WHAT must receive focus\n * (a semantic identity), each part checks whether it IS that identity, and only the matching part focuses itself\n * from its ref callback. Nothing in here calls `.focus()`.\n */\nexport const useFocusTracker = ({ options, pageSize }: FocusTrackerConfigT) => {\n const [focusRegion, setFocusRegion] = useState<string>(PER_PAGE_SELECTOR_REGION_FOCUSES.RESET);\n\n const focusedIndex = useMemo(\n () => options.findIndex((option) => getOptionRegionId(option.dsId) === focusRegion),\n [focusRegion, options],\n );\n\n const clampIndex = useCallback((index: number) => Math.min(Math.max(index, 0), options.length - 1), [options.length]);\n\n const trackFocusRegionReset = useCallback(() => setFocusRegion(PER_PAGE_SELECTOR_REGION_FOCUSES.RESET), []);\n const trackFocusTrigger = useCallback(() => setFocusRegion(PER_PAGE_SELECTOR_REGION_FOCUSES.TRIGGER), []);\n const trackFocusOptionAtIndex = useCallback(\n (index: number) => {\n if (options.length > 0) setFocusRegion(getOptionRegionId(options[clampIndex(index)].dsId));\n },\n [clampIndex, options],\n );\n const trackFocusOption = useCallback((dsId: string) => setFocusRegion(getOptionRegionId(dsId)), []);\n // on open the focus lands on the selected option, or on the first one when the page size is not one of the options\n const trackFocusSelectedOption = useCallback(\n () => trackFocusOptionAtIndex(Math.max(getSelectedOptionIndex(options, pageSize), 0)),\n [options, pageSize, trackFocusOptionAtIndex],\n );\n\n return useMemo(\n () => ({\n focusRegion,\n focusedIndex,\n clampIndex,\n trackFocusRegionReset,\n trackFocusTrigger,\n trackFocusOption,\n trackFocusOptionAtIndex,\n trackFocusSelectedOption,\n }),\n [\n focusRegion,\n focusedIndex,\n clampIndex,\n trackFocusRegionReset,\n trackFocusTrigger,\n trackFocusOption,\n trackFocusOptionAtIndex,\n trackFocusSelectedOption,\n ],\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAA+C;AAC/C,uBAAiD;AAEjD,oCAAuC;AAQhC,MAAM,oBAAoB,CAAC,SAAiB,GAAG,kDAAiC,aAAa,GAAG,IAAI;AAOpG,MAAM,kBAAkB,CAAC,EAAE,SAAS,SAAS,MAA2B;AAC7E,QAAM,CAAC,aAAa,cAAc,QAAI,uBAAiB,kDAAiC,KAAK;AAE7F,QAAM,mBAAe;AAAA,IACnB,MAAM,QAAQ,UAAU,CAAC,WAAW,kBAAkB,OAAO,IAAI,MAAM,WAAW;AAAA,IAClF,CAAC,aAAa,OAAO;AAAA,EACvB;AAEA,QAAM,iBAAa,0BAAY,CAAC,UAAkB,KAAK,IAAI,KAAK,IAAI,OAAO,CAAC,GAAG,QAAQ,SAAS,CAAC,GAAG,CAAC,QAAQ,MAAM,CAAC;AAEpH,QAAM,4BAAwB,0BAAY,MAAM,eAAe,kDAAiC,KAAK,GAAG,CAAC,CAAC;AAC1G,QAAM,wBAAoB,0BAAY,MAAM,eAAe,kDAAiC,OAAO,GAAG,CAAC,CAAC;AACxG,QAAM,8BAA0B;AAAA,IAC9B,CAAC,UAAkB;AACjB,UAAI,QAAQ,SAAS,EAAG,gBAAe,kBAAkB,QAAQ,WAAW,KAAK,CAAC,EAAE,IAAI,CAAC;AAAA,IAC3F;AAAA,IACA,CAAC,YAAY,OAAO;AAAA,EACtB;AACA,QAAM,uBAAmB,0BAAY,CAAC,SAAiB,eAAe,kBAAkB,IAAI,CAAC,GAAG,CAAC,CAAC;AAElG,QAAM,+BAA2B;AAAA,IAC/B,MAAM,wBAAwB,KAAK,QAAI,sDAAuB,SAAS,QAAQ,GAAG,CAAC,CAAC;AAAA,IACpF,CAAC,SAAS,UAAU,uBAAuB;AAAA,EAC7C;AAEA,aAAO;AAAA,IACL,OAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -34,47 +34,95 @@ module.exports = __toCommonJS(usePerPageSelector_exports);
|
|
|
34
34
|
var React = __toESM(require("react"));
|
|
35
35
|
var import_ds_props_helpers = require("@elliemae/ds-props-helpers");
|
|
36
36
|
var import_react = __toESM(require("react"));
|
|
37
|
+
var import_uid = require("uid");
|
|
37
38
|
var import_react_desc_prop_types = require("../react-desc-prop-types.js");
|
|
38
|
-
var import_useValidateProps = require("./useValidateProps.js");
|
|
39
39
|
var import_getOptions = require("./getOptions.js");
|
|
40
|
-
var
|
|
40
|
+
var import_getInstanceIds = require("./getInstanceIds.js");
|
|
41
|
+
var import_useFocusTracker = require("./useFocusTracker.js");
|
|
42
|
+
var import_usePerPageSelectorFloatingContext = require("./usePerPageSelectorFloatingContext.js");
|
|
43
|
+
var import_usePerPageSelectorInteractions = require("./usePerPageSelectorInteractions.js");
|
|
44
|
+
var import_usePerPageSelectorSizing = require("./usePerPageSelectorSizing.js");
|
|
45
|
+
var import_useValidateProps = require("./useValidateProps.js");
|
|
41
46
|
const usePerPageSelector = (propsFromUser) => {
|
|
42
47
|
const propsWithDefault = (0, import_ds_props_helpers.useMemoMergePropsWithDefault)(propsFromUser, import_react_desc_prop_types.defaultProps);
|
|
43
48
|
(0, import_useValidateProps.useValidateProps)(propsWithDefault, import_react_desc_prop_types.DSPerPageSelectorPropTypesSchema);
|
|
44
49
|
const xstyledProps = (0, import_ds_props_helpers.useGetXstyledProps)(propsWithDefault);
|
|
45
50
|
const globalAttributes = (0, import_ds_props_helpers.useGetGlobalAttributes)(propsWithDefault);
|
|
46
51
|
const ownerPropsConfig = (0, import_ds_props_helpers.useOwnerProps)(propsWithDefault);
|
|
47
|
-
const { pageSize, perPageOptions, perPageStep, minPerPage, maxPerPage } = propsWithDefault;
|
|
48
|
-
const
|
|
52
|
+
const { pageSize, perPageOptions, perPageStep, minPerPage, maxPerPage, listWidth } = propsWithDefault;
|
|
53
|
+
const instanceUid = (0, import_react.useMemo)(() => (0, import_uid.uid)(5), []);
|
|
54
|
+
const [isOpen, setIsOpen] = (0, import_react.useState)(false);
|
|
49
55
|
const options = (0, import_react.useMemo)(() => {
|
|
50
56
|
if (perPageOptions) return perPageOptions.map(import_getOptions.generateOption);
|
|
51
57
|
return (0, import_getOptions.getOptions)(perPageStep, minPerPage, maxPerPage);
|
|
52
58
|
}, [maxPerPage, minPerPage, perPageOptions, perPageStep]);
|
|
53
|
-
const
|
|
54
|
-
const btnRef = (0, import_react.useRef)(null);
|
|
59
|
+
const triggerRef = (0, import_react.useRef)(null);
|
|
55
60
|
const chevronRef = (0, import_react.useRef)(null);
|
|
56
|
-
const
|
|
57
|
-
(0,
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
const listActionRef = (0, import_react.useRef)({});
|
|
62
|
+
const sizing = (0, import_usePerPageSelectorSizing.usePerPageSelectorSizing)({ pageSize, options, listWidth, chevronRef, listActionRef });
|
|
63
|
+
const focusTrackers = (0, import_useFocusTracker.useFocusTracker)({ options, pageSize });
|
|
64
|
+
const { floatingStyles, floatingContext, handleTriggerRef, floatingInnerRef, floatingNodeRef } = (0, import_usePerPageSelectorFloatingContext.usePerPageSelectorFloatingContext)({
|
|
65
|
+
isOpen,
|
|
66
|
+
setIsOpen,
|
|
67
|
+
triggerRef,
|
|
68
|
+
trackFocusRegionReset: focusTrackers.trackFocusRegionReset,
|
|
69
|
+
chevronWidth: sizing.chevronWidth
|
|
70
|
+
});
|
|
71
|
+
const interactions = (0, import_usePerPageSelectorInteractions.usePerPageSelectorInteractions)({
|
|
72
|
+
propsWithDefault,
|
|
73
|
+
globalAttributes,
|
|
74
|
+
options,
|
|
75
|
+
isOpen,
|
|
76
|
+
setIsOpen,
|
|
77
|
+
focusTrackers,
|
|
78
|
+
triggerRef,
|
|
79
|
+
floatingNodeRef,
|
|
80
|
+
listActionRef
|
|
81
|
+
});
|
|
82
|
+
const ids = (0, import_react.useMemo)(
|
|
83
|
+
() => ({
|
|
84
|
+
headerId: (0, import_getInstanceIds.getHeaderId)(instanceUid),
|
|
85
|
+
listId: (0, import_getInstanceIds.getListId)(instanceUid),
|
|
86
|
+
dialogId: (0, import_getInstanceIds.getDialogId)(instanceUid)
|
|
87
|
+
}),
|
|
88
|
+
[instanceUid]
|
|
89
|
+
);
|
|
63
90
|
return import_react.default.useMemo(
|
|
64
91
|
() => ({
|
|
65
92
|
propsWithDefault,
|
|
66
93
|
xstyledProps,
|
|
67
94
|
globalAttributes,
|
|
68
95
|
ownerPropsConfig,
|
|
69
|
-
|
|
70
|
-
btnRef,
|
|
71
|
-
chevronRef,
|
|
72
|
-
chevronWidth,
|
|
73
|
-
isOpened,
|
|
96
|
+
isOpen,
|
|
74
97
|
options,
|
|
75
|
-
|
|
98
|
+
focusTrackers,
|
|
99
|
+
triggerRef,
|
|
100
|
+
chevronRef,
|
|
101
|
+
listActionRef,
|
|
102
|
+
floatingStyles,
|
|
103
|
+
floatingContext,
|
|
104
|
+
handleTriggerRef,
|
|
105
|
+
floatingInnerRef,
|
|
106
|
+
...sizing,
|
|
107
|
+
...ids,
|
|
108
|
+
...interactions
|
|
76
109
|
}),
|
|
77
|
-
[
|
|
110
|
+
[
|
|
111
|
+
propsWithDefault,
|
|
112
|
+
xstyledProps,
|
|
113
|
+
globalAttributes,
|
|
114
|
+
ownerPropsConfig,
|
|
115
|
+
isOpen,
|
|
116
|
+
options,
|
|
117
|
+
focusTrackers,
|
|
118
|
+
floatingStyles,
|
|
119
|
+
floatingContext,
|
|
120
|
+
handleTriggerRef,
|
|
121
|
+
floatingInnerRef,
|
|
122
|
+
sizing,
|
|
123
|
+
ids,
|
|
124
|
+
interactions
|
|
125
|
+
]
|
|
78
126
|
);
|
|
79
127
|
};
|
|
80
128
|
//# sourceMappingURL=usePerPageSelector.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/parts/DSPerPageSelector/config/usePerPageSelector.ts", "../../../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["import type { DSButtonV3T } from '@elliemae/ds-button-v2';\nimport {\n useGetGlobalAttributes,\n useGetXstyledProps,\n useMemoMergePropsWithDefault,\n useOwnerProps,\n} from '@elliemae/ds-props-helpers';\nimport React, {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;
|
|
4
|
+
"sourcesContent": ["import type { DSButtonV3T } from '@elliemae/ds-button-v2';\nimport type { DSFastListT } from '@elliemae/ds-fast-list';\nimport {\n useGetGlobalAttributes,\n useGetXstyledProps,\n useMemoMergePropsWithDefault,\n useOwnerProps,\n} from '@elliemae/ds-props-helpers';\nimport React, { useMemo, useRef, useState } from 'react';\nimport { uid } from 'uid';\nimport { type DSPerPageSelectorT, DSPerPageSelectorPropTypesSchema, defaultProps } from '../react-desc-prop-types.js';\nimport { generateOption, getOptions } from './getOptions.js';\nimport { getDialogId, getHeaderId, getListId } from './getInstanceIds.js';\nimport { useFocusTracker } from './useFocusTracker.js';\nimport { usePerPageSelectorFloatingContext } from './usePerPageSelectorFloatingContext.js';\nimport { usePerPageSelectorInteractions } from './usePerPageSelectorInteractions.js';\nimport { usePerPageSelectorSizing } from './usePerPageSelectorSizing.js';\nimport { useValidateProps } from './useValidateProps.js';\n\nexport const usePerPageSelector = (propsFromUser: DSPerPageSelectorT.Props) => {\n // =============================================================================\n // MERGE WITH DEFAULT AND VALIDATE PROPS\n // =============================================================================\n const propsWithDefault = useMemoMergePropsWithDefault<DSPerPageSelectorT.InternalProps>(propsFromUser, defaultProps);\n useValidateProps(propsWithDefault, DSPerPageSelectorPropTypesSchema);\n // =============================================================================\n // XSTYLED PROPS\n // =============================================================================\n const xstyledProps = useGetXstyledProps(propsWithDefault);\n // =============================================================================\n // GLOBAL ATTRIBUTES\n // =============================================================================\n const globalAttributes = useGetGlobalAttributes<\n DSPerPageSelectorT.InternalProps,\n HTMLButtonElement,\n DSButtonV3T.Props\n >(propsWithDefault);\n // =============================================================================\n // OWNER PROPS\n // =============================================================================\n const ownerPropsConfig = useOwnerProps(propsWithDefault);\n // =============================================================================\n // AD HOC PER COMPONENT LOGIC\n // =============================================================================\n const { pageSize, perPageOptions, perPageStep, minPerPage, maxPerPage, listWidth } = propsWithDefault;\n const instanceUid = useMemo(() => uid(5), []);\n const [isOpen, setIsOpen] = useState(false);\n const options = useMemo(() => {\n if (perPageOptions) return perPageOptions.map(generateOption);\n return getOptions(perPageStep, minPerPage, maxPerPage);\n }, [maxPerPage, minPerPage, perPageOptions, perPageStep]);\n\n const triggerRef = useRef<HTMLButtonElement | null>(null);\n const chevronRef = useRef<HTMLElement>(null);\n const listActionRef = useRef<DSFastListT.ActionRef>({});\n\n const sizing = usePerPageSelectorSizing({ pageSize, options, listWidth, chevronRef, listActionRef });\n\n const focusTrackers = useFocusTracker({ options, pageSize });\n\n const { floatingStyles, floatingContext, handleTriggerRef, floatingInnerRef, floatingNodeRef } =\n usePerPageSelectorFloatingContext({\n isOpen,\n setIsOpen,\n triggerRef,\n trackFocusRegionReset: focusTrackers.trackFocusRegionReset,\n chevronWidth: sizing.chevronWidth,\n });\n\n const interactions = usePerPageSelectorInteractions({\n propsWithDefault,\n globalAttributes,\n options,\n isOpen,\n setIsOpen,\n focusTrackers,\n triggerRef,\n floatingNodeRef,\n listActionRef,\n });\n\n const ids = useMemo(\n () => ({\n headerId: getHeaderId(instanceUid),\n listId: getListId(instanceUid),\n dialogId: getDialogId(instanceUid),\n }),\n [instanceUid],\n );\n\n return React.useMemo(\n () => ({\n propsWithDefault,\n xstyledProps,\n globalAttributes,\n ownerPropsConfig,\n isOpen,\n options,\n focusTrackers,\n triggerRef,\n chevronRef,\n listActionRef,\n floatingStyles,\n floatingContext,\n handleTriggerRef,\n floatingInnerRef,\n ...sizing,\n ...ids,\n ...interactions,\n }),\n [\n propsWithDefault,\n xstyledProps,\n globalAttributes,\n ownerPropsConfig,\n isOpen,\n options,\n focusTrackers,\n floatingStyles,\n floatingContext,\n handleTriggerRef,\n floatingInnerRef,\n sizing,\n ids,\n interactions,\n ],\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADEvB,8BAKO;AACP,mBAAiD;AACjD,iBAAoB;AACpB,mCAAwF;AACxF,wBAA2C;AAC3C,4BAAoD;AACpD,6BAAgC;AAChC,+CAAkD;AAClD,4CAA+C;AAC/C,sCAAyC;AACzC,8BAAiC;AAE1B,MAAM,qBAAqB,CAAC,kBAA4C;AAI7E,QAAM,uBAAmB,sDAA+D,eAAe,yCAAY;AACnH,gDAAiB,kBAAkB,6DAAgC;AAInE,QAAM,mBAAe,4CAAmB,gBAAgB;AAIxD,QAAM,uBAAmB,gDAIvB,gBAAgB;AAIlB,QAAM,uBAAmB,uCAAc,gBAAgB;AAIvD,QAAM,EAAE,UAAU,gBAAgB,aAAa,YAAY,YAAY,UAAU,IAAI;AACrF,QAAM,kBAAc,sBAAQ,UAAM,gBAAI,CAAC,GAAG,CAAC,CAAC;AAC5C,QAAM,CAAC,QAAQ,SAAS,QAAI,uBAAS,KAAK;AAC1C,QAAM,cAAU,sBAAQ,MAAM;AAC5B,QAAI,eAAgB,QAAO,eAAe,IAAI,gCAAc;AAC5D,eAAO,8BAAW,aAAa,YAAY,UAAU;AAAA,EACvD,GAAG,CAAC,YAAY,YAAY,gBAAgB,WAAW,CAAC;AAExD,QAAM,iBAAa,qBAAiC,IAAI;AACxD,QAAM,iBAAa,qBAAoB,IAAI;AAC3C,QAAM,oBAAgB,qBAA8B,CAAC,CAAC;AAEtD,QAAM,aAAS,0DAAyB,EAAE,UAAU,SAAS,WAAW,YAAY,cAAc,CAAC;AAEnG,QAAM,oBAAgB,wCAAgB,EAAE,SAAS,SAAS,CAAC;AAE3D,QAAM,EAAE,gBAAgB,iBAAiB,kBAAkB,kBAAkB,gBAAgB,QAC3F,4EAAkC;AAAA,IAChC;AAAA,IACA;AAAA,IACA;AAAA,IACA,uBAAuB,cAAc;AAAA,IACrC,cAAc,OAAO;AAAA,EACvB,CAAC;AAEH,QAAM,mBAAe,sEAA+B;AAAA,IAClD;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AAED,QAAM,UAAM;AAAA,IACV,OAAO;AAAA,MACL,cAAU,mCAAY,WAAW;AAAA,MACjC,YAAQ,iCAAU,WAAW;AAAA,MAC7B,cAAU,mCAAY,WAAW;AAAA,IACnC;AAAA,IACA,CAAC,WAAW;AAAA,EACd;AAEA,SAAO,aAAAA,QAAM;AAAA,IACX,OAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,IACL;AAAA,IACA;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
6
|
"names": ["React"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var usePerPageSelectorFloatingContext_exports = {};
|
|
30
|
+
__export(usePerPageSelectorFloatingContext_exports, {
|
|
31
|
+
usePerPageSelectorFloatingContext: () => usePerPageSelectorFloatingContext
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(usePerPageSelectorFloatingContext_exports);
|
|
34
|
+
var React = __toESM(require("react"));
|
|
35
|
+
var import_ds_floating_context = require("@elliemae/ds-floating-context");
|
|
36
|
+
var import_react = require("react");
|
|
37
|
+
const usePerPageSelectorFloatingContext = ({
|
|
38
|
+
isOpen,
|
|
39
|
+
setIsOpen,
|
|
40
|
+
triggerRef,
|
|
41
|
+
trackFocusRegionReset,
|
|
42
|
+
chevronWidth
|
|
43
|
+
}) => {
|
|
44
|
+
const floatingNodeRef = (0, import_react.useRef)(null);
|
|
45
|
+
const handleClose = (0, import_react.useCallback)(() => {
|
|
46
|
+
setIsOpen(false);
|
|
47
|
+
trackFocusRegionReset();
|
|
48
|
+
}, [setIsOpen, trackFocusRegionReset]);
|
|
49
|
+
const floatingContextConfig = (0, import_react.useMemo)(
|
|
50
|
+
() => ({
|
|
51
|
+
// the previous DSPerPageSelector opened upwards (it lives in a footer) and aligned the selected value with the trigger
|
|
52
|
+
placement: "top-start",
|
|
53
|
+
placementOrderPreference: ["top-start", "bottom-start"],
|
|
54
|
+
customOffset: [-(chevronWidth + 7), 2],
|
|
55
|
+
externallyControlledIsOpen: isOpen,
|
|
56
|
+
withoutAnimation: true,
|
|
57
|
+
onClickOutside: handleClose,
|
|
58
|
+
closeOnEscape: true,
|
|
59
|
+
onEscape: handleClose,
|
|
60
|
+
returnFocusToReference: true,
|
|
61
|
+
externalReferenceElement: triggerRef.current
|
|
62
|
+
}),
|
|
63
|
+
[chevronWidth, handleClose, isOpen, triggerRef]
|
|
64
|
+
);
|
|
65
|
+
const { refs: floatingRefs, floatingStyles, context: floatingContext } = (0, import_ds_floating_context.useFloatingContext)(floatingContextConfig);
|
|
66
|
+
const handleTriggerRef = (0, import_react.useCallback)(
|
|
67
|
+
(node) => {
|
|
68
|
+
triggerRef.current = node;
|
|
69
|
+
floatingRefs.setReference(node);
|
|
70
|
+
},
|
|
71
|
+
[floatingRefs, triggerRef]
|
|
72
|
+
);
|
|
73
|
+
const floatingInnerRef = (0, import_react.useCallback)(
|
|
74
|
+
(node) => {
|
|
75
|
+
floatingNodeRef.current = node;
|
|
76
|
+
floatingRefs.setFloating(node);
|
|
77
|
+
},
|
|
78
|
+
[floatingRefs.setFloating]
|
|
79
|
+
);
|
|
80
|
+
return { floatingStyles, floatingContext, handleTriggerRef, floatingInnerRef, floatingNodeRef };
|
|
81
|
+
};
|
|
82
|
+
//# sourceMappingURL=usePerPageSelectorFloatingContext.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/parts/DSPerPageSelector/config/usePerPageSelectorFloatingContext.ts", "../../../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["import { useFloatingContext, type DSHookFloatingContextT } from '@elliemae/ds-floating-context';\nimport type React from 'react';\nimport { useCallback, useMemo, useRef } from 'react';\n\ntype FloatingContextConfigT = {\n isOpen: boolean;\n setIsOpen: React.Dispatch<React.SetStateAction<boolean>>;\n triggerRef: React.MutableRefObject<HTMLButtonElement | null>;\n trackFocusRegionReset: () => void;\n chevronWidth: number;\n};\n\n/**\n * The single point that wires DSPerPageSelector to `useFloatingContext` (same shape as DSPaginator's one).\n *\n * The open state is owned by the component, so the floating context is \"controlled\" by it\n * (`externallyControlledIsOpen`) and this hook only translates the closing intents of the floating context into it:\n * - scoped Escape: the floating context routes it to `onEscape` and, because `returnFocusToReference` is on, it also\n * returns the focus to the trigger. This is the ONLY close path where the floating context moves the focus.\n * - click outside (panel + trigger): closes, the focus stays where the user clicked.\n * The other close paths (activation, Tab, trigger toggle) live in usePerPageSelectorInteractions.\n */\nexport const usePerPageSelectorFloatingContext = ({\n isOpen,\n setIsOpen,\n triggerRef,\n trackFocusRegionReset,\n chevronWidth,\n}: FloatingContextConfigT) => {\n const floatingNodeRef = useRef<HTMLDivElement | null>(null);\n\n const handleClose = useCallback(() => {\n setIsOpen(false);\n trackFocusRegionReset();\n }, [setIsOpen, trackFocusRegionReset]);\n\n const floatingContextConfig = useMemo(\n () =>\n ({\n // the previous DSPerPageSelector opened upwards (it lives in a footer) and aligned the selected value with the trigger\n placement: 'top-start',\n placementOrderPreference: ['top-start', 'bottom-start'],\n customOffset: [-(chevronWidth + 7), 2],\n externallyControlledIsOpen: isOpen,\n withoutAnimation: true,\n onClickOutside: handleClose,\n closeOnEscape: true,\n onEscape: handleClose,\n returnFocusToReference: true,\n externalReferenceElement: triggerRef.current,\n }) as DSHookFloatingContextT.Props,\n [chevronWidth, handleClose, isOpen, triggerRef],\n );\n\n const { refs: floatingRefs, floatingStyles, context: floatingContext } = useFloatingContext(floatingContextConfig);\n\n const handleTriggerRef = useCallback<React.RefCallback<HTMLButtonElement>>(\n (node) => {\n // eslint-disable-next-line no-param-reassign\n triggerRef.current = node;\n floatingRefs.setReference(node);\n },\n [floatingRefs, triggerRef],\n );\n\n const floatingInnerRef = useCallback<React.RefCallback<HTMLDivElement>>(\n (node) => {\n floatingNodeRef.current = node;\n (floatingRefs.setFloating as React.RefCallback<HTMLDivElement>)(node);\n },\n [floatingRefs.setFloating],\n );\n\n return { floatingStyles, floatingContext, handleTriggerRef, floatingInnerRef, floatingNodeRef };\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,iCAAgE;AAEhE,mBAA6C;AAoBtC,MAAM,oCAAoC,CAAC;AAAA,EAChD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAA8B;AAC5B,QAAM,sBAAkB,qBAA8B,IAAI;AAE1D,QAAM,kBAAc,0BAAY,MAAM;AACpC,cAAU,KAAK;AACf,0BAAsB;AAAA,EACxB,GAAG,CAAC,WAAW,qBAAqB,CAAC;AAErC,QAAM,4BAAwB;AAAA,IAC5B,OACG;AAAA;AAAA,MAEC,WAAW;AAAA,MACX,0BAA0B,CAAC,aAAa,cAAc;AAAA,MACtD,cAAc,CAAC,EAAE,eAAe,IAAI,CAAC;AAAA,MACrC,4BAA4B;AAAA,MAC5B,kBAAkB;AAAA,MAClB,gBAAgB;AAAA,MAChB,eAAe;AAAA,MACf,UAAU;AAAA,MACV,wBAAwB;AAAA,MACxB,0BAA0B,WAAW;AAAA,IACvC;AAAA,IACF,CAAC,cAAc,aAAa,QAAQ,UAAU;AAAA,EAChD;AAEA,QAAM,EAAE,MAAM,cAAc,gBAAgB,SAAS,gBAAgB,QAAI,+CAAmB,qBAAqB;AAEjH,QAAM,uBAAmB;AAAA,IACvB,CAAC,SAAS;AAER,iBAAW,UAAU;AACrB,mBAAa,aAAa,IAAI;AAAA,IAChC;AAAA,IACA,CAAC,cAAc,UAAU;AAAA,EAC3B;AAEA,QAAM,uBAAmB;AAAA,IACvB,CAAC,SAAS;AACR,sBAAgB,UAAU;AAC1B,MAAC,aAAa,YAAkD,IAAI;AAAA,IACtE;AAAA,IACA,CAAC,aAAa,WAAW;AAAA,EAC3B;AAEA,SAAO,EAAE,gBAAgB,iBAAiB,kBAAkB,kBAAkB,gBAAgB;AAChG;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var usePerPageSelectorInteractions_exports = {};
|
|
30
|
+
__export(usePerPageSelectorInteractions_exports, {
|
|
31
|
+
usePerPageSelectorInteractions: () => usePerPageSelectorInteractions
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(usePerPageSelectorInteractions_exports);
|
|
34
|
+
var React = __toESM(require("react"));
|
|
35
|
+
var import_react = require("react");
|
|
36
|
+
var import_constants = require("../constants/index.js");
|
|
37
|
+
var import_navigationKeys = require("./navigationKeys.js");
|
|
38
|
+
const isPrintableCharacter = (key) => key.length === 1 && key !== " ";
|
|
39
|
+
const usePerPageSelectorInteractions = ({
|
|
40
|
+
propsWithDefault,
|
|
41
|
+
globalAttributes,
|
|
42
|
+
options,
|
|
43
|
+
isOpen,
|
|
44
|
+
setIsOpen,
|
|
45
|
+
focusTrackers,
|
|
46
|
+
triggerRef,
|
|
47
|
+
floatingNodeRef,
|
|
48
|
+
listActionRef
|
|
49
|
+
}) => {
|
|
50
|
+
const { pageSize, onPageSizeChange } = propsWithDefault;
|
|
51
|
+
const {
|
|
52
|
+
focusedIndex,
|
|
53
|
+
clampIndex,
|
|
54
|
+
trackFocusOptionAtIndex,
|
|
55
|
+
trackFocusSelectedOption,
|
|
56
|
+
trackFocusTrigger,
|
|
57
|
+
trackFocusRegionReset
|
|
58
|
+
} = focusTrackers;
|
|
59
|
+
const typeaheadRef = (0, import_react.useRef)({ buffer: "", lastKeyTimestamp: 0 });
|
|
60
|
+
const moveFocusToIndex = (0, import_react.useCallback)(
|
|
61
|
+
(index) => {
|
|
62
|
+
const targetIndex = clampIndex(index);
|
|
63
|
+
trackFocusOptionAtIndex(targetIndex);
|
|
64
|
+
listActionRef.current.scrollTo?.(targetIndex, { align: "auto" });
|
|
65
|
+
},
|
|
66
|
+
[clampIndex, listActionRef, trackFocusOptionAtIndex]
|
|
67
|
+
);
|
|
68
|
+
const commitOption = (0, import_react.useCallback)(
|
|
69
|
+
(option) => {
|
|
70
|
+
if (option.value !== pageSize) onPageSizeChange(option.value);
|
|
71
|
+
setIsOpen(false);
|
|
72
|
+
trackFocusTrigger();
|
|
73
|
+
},
|
|
74
|
+
[onPageSizeChange, pageSize, setIsOpen, trackFocusTrigger]
|
|
75
|
+
);
|
|
76
|
+
const handleTriggerClick = (0, import_react.useCallback)(
|
|
77
|
+
(e) => {
|
|
78
|
+
globalAttributes.onClick?.(e);
|
|
79
|
+
if (isOpen) {
|
|
80
|
+
setIsOpen(false);
|
|
81
|
+
trackFocusTrigger();
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
if (options.length === 0) return;
|
|
85
|
+
setIsOpen(true);
|
|
86
|
+
trackFocusSelectedOption();
|
|
87
|
+
},
|
|
88
|
+
[globalAttributes.onClick, isOpen, options.length, setIsOpen, trackFocusSelectedOption, trackFocusTrigger]
|
|
89
|
+
);
|
|
90
|
+
const handleTriggerKeyDown = (0, import_react.useCallback)(
|
|
91
|
+
(e) => {
|
|
92
|
+
globalAttributes.onKeyDown?.(e);
|
|
93
|
+
if (e.key !== "ArrowDown" && e.key !== "ArrowUp") return;
|
|
94
|
+
if (isOpen || options.length === 0) return;
|
|
95
|
+
e.preventDefault();
|
|
96
|
+
setIsOpen(true);
|
|
97
|
+
trackFocusSelectedOption();
|
|
98
|
+
},
|
|
99
|
+
[globalAttributes.onKeyDown, isOpen, options.length, setIsOpen, trackFocusSelectedOption]
|
|
100
|
+
);
|
|
101
|
+
const handlePanelKeyDownCapture = (0, import_react.useCallback)(
|
|
102
|
+
(e) => {
|
|
103
|
+
if (e.key !== "Tab") return;
|
|
104
|
+
triggerRef.current?.focus();
|
|
105
|
+
trackFocusRegionReset();
|
|
106
|
+
const focusedOption = options[focusedIndex];
|
|
107
|
+
if (focusedOption && focusedOption.value !== pageSize) {
|
|
108
|
+
onPageSizeChange(focusedOption.value);
|
|
109
|
+
}
|
|
110
|
+
setIsOpen(false);
|
|
111
|
+
},
|
|
112
|
+
[focusedIndex, onPageSizeChange, options, pageSize, setIsOpen, trackFocusRegionReset, triggerRef]
|
|
113
|
+
);
|
|
114
|
+
const handleTypeahead = (0, import_react.useCallback)(
|
|
115
|
+
(character) => {
|
|
116
|
+
const now = Date.now();
|
|
117
|
+
const typeahead = typeaheadRef.current;
|
|
118
|
+
const isNewSearch = now - typeahead.lastKeyTimestamp > import_constants.PER_PAGE_SELECTOR_TYPEAHEAD_RESET_MS;
|
|
119
|
+
if (isNewSearch) typeahead.buffer = "";
|
|
120
|
+
typeahead.buffer += character.toLowerCase();
|
|
121
|
+
typeahead.lastKeyTimestamp = now;
|
|
122
|
+
const startIndex = isNewSearch ? focusedIndex + 1 : Math.max(focusedIndex, 0);
|
|
123
|
+
const ordered = [...options.slice(startIndex), ...options.slice(0, startIndex)];
|
|
124
|
+
const match = ordered.find((option) => option.label.toLowerCase().startsWith(typeahead.buffer));
|
|
125
|
+
if (match) moveFocusToIndex(options.indexOf(match));
|
|
126
|
+
},
|
|
127
|
+
[focusedIndex, moveFocusToIndex, options]
|
|
128
|
+
);
|
|
129
|
+
const handlePanelKeyDown = (0, import_react.useCallback)(
|
|
130
|
+
(e) => {
|
|
131
|
+
if (e.ctrlKey || e.metaKey || e.altKey) return;
|
|
132
|
+
const getTargetIndex = import_navigationKeys.NAVIGATION_KEYS[e.key];
|
|
133
|
+
if (getTargetIndex) {
|
|
134
|
+
e.preventDefault();
|
|
135
|
+
moveFocusToIndex(getTargetIndex(Math.max(focusedIndex, 0), options.length));
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
139
|
+
e.preventDefault();
|
|
140
|
+
if (focusedIndex >= 0) commitOption(options[focusedIndex]);
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
if (isPrintableCharacter(e.key)) handleTypeahead(e.key);
|
|
144
|
+
},
|
|
145
|
+
[commitOption, focusedIndex, handleTypeahead, moveFocusToIndex, options]
|
|
146
|
+
);
|
|
147
|
+
const handleBlurOutOfWidget = (0, import_react.useCallback)(
|
|
148
|
+
(e) => {
|
|
149
|
+
const nextFocused = e.relatedTarget;
|
|
150
|
+
if (!nextFocused) return;
|
|
151
|
+
if (triggerRef.current?.contains(nextFocused) || floatingNodeRef.current?.contains(nextFocused)) return;
|
|
152
|
+
trackFocusRegionReset();
|
|
153
|
+
},
|
|
154
|
+
[floatingNodeRef, trackFocusRegionReset, triggerRef]
|
|
155
|
+
);
|
|
156
|
+
return (0, import_react.useMemo)(
|
|
157
|
+
() => ({
|
|
158
|
+
commitOption,
|
|
159
|
+
handleTriggerClick,
|
|
160
|
+
handleTriggerKeyDown,
|
|
161
|
+
handlePanelKeyDown,
|
|
162
|
+
handlePanelKeyDownCapture,
|
|
163
|
+
handleBlurOutOfWidget
|
|
164
|
+
}),
|
|
165
|
+
[
|
|
166
|
+
commitOption,
|
|
167
|
+
handleTriggerClick,
|
|
168
|
+
handleTriggerKeyDown,
|
|
169
|
+
handlePanelKeyDown,
|
|
170
|
+
handlePanelKeyDownCapture,
|
|
171
|
+
handleBlurOutOfWidget
|
|
172
|
+
]
|
|
173
|
+
);
|
|
174
|
+
};
|
|
175
|
+
//# sourceMappingURL=usePerPageSelectorInteractions.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/parts/DSPerPageSelector/config/usePerPageSelectorInteractions.ts", "../../../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["import type { DSFastListT } from '@elliemae/ds-fast-list';\nimport type React from 'react';\nimport { useCallback, useMemo, useRef } from 'react';\nimport { PER_PAGE_SELECTOR_TYPEAHEAD_RESET_MS } from '../constants/index.js';\nimport type { DSPerPageSelectorT } from '../react-desc-prop-types.js';\nimport { NAVIGATION_KEYS } from './navigationKeys.js';\nimport type { useFocusTracker } from './useFocusTracker.js';\n\ntype InteractionsConfigT = {\n propsWithDefault: DSPerPageSelectorT.InternalProps;\n globalAttributes: { onClick?: unknown; onKeyDown?: unknown };\n options: DSPerPageSelectorT.PerPageOption[];\n isOpen: boolean;\n setIsOpen: React.Dispatch<React.SetStateAction<boolean>>;\n focusTrackers: ReturnType<typeof useFocusTracker>;\n triggerRef: React.MutableRefObject<HTMLButtonElement | null>;\n floatingNodeRef: React.MutableRefObject<HTMLDivElement | null>;\n listActionRef: React.MutableRefObject<DSFastListT.ActionRef>;\n};\n\nconst isPrintableCharacter = (key: string) => key.length === 1 && key !== ' ';\n\n/**\n * Every user intent on the trigger and on the list. The selection model is the one of a native select (and the same one\n * as DSPaginator):\n * - moving through the options (arrows, Home/End, PageUp/PageDown, typing the start of a label) only moves the focus:\n * `onPageSizeChange` is NOT invoked while navigating\n * - Enter, Space or a click on an option commits it, closes the list and returns the focus to the trigger\n * - Tab (and Shift+Tab) commits the focused option, closes the list and continues from the trigger\n * - Escape (see usePerPageSelectorFloatingContext) and click outside close without committing\n * Handlers only declare focus intents through the focus tracker (see useFocusTracker), with ONE documented exception:\n * Tab (see handlePanelKeyDownCapture).\n */\nexport const usePerPageSelectorInteractions = ({\n propsWithDefault,\n globalAttributes,\n options,\n isOpen,\n setIsOpen,\n focusTrackers,\n triggerRef,\n floatingNodeRef,\n listActionRef,\n}: InteractionsConfigT) => {\n const { pageSize, onPageSizeChange } = propsWithDefault;\n const {\n focusedIndex,\n clampIndex,\n trackFocusOptionAtIndex,\n trackFocusSelectedOption,\n trackFocusTrigger,\n trackFocusRegionReset,\n } = focusTrackers;\n const typeaheadRef = useRef({ buffer: '', lastKeyTimestamp: 0 });\n\n // the target option may not be mounted (virtualized): the focus intent is declared, the list is scrolled to it and\n // the option focuses itself from its ref callback as soon as it mounts\n const moveFocusToIndex = useCallback(\n (index: number) => {\n const targetIndex = clampIndex(index);\n trackFocusOptionAtIndex(targetIndex);\n listActionRef.current.scrollTo?.(targetIndex, { align: 'auto' });\n },\n [clampIndex, listActionRef, trackFocusOptionAtIndex],\n );\n\n const commitOption = useCallback(\n (option: DSPerPageSelectorT.PerPageOption) => {\n if (option.value !== pageSize) onPageSizeChange(option.value);\n setIsOpen(false);\n trackFocusTrigger();\n },\n [onPageSizeChange, pageSize, setIsOpen, trackFocusTrigger],\n );\n\n const handleTriggerClick = useCallback(\n (e: React.MouseEvent<HTMLButtonElement> | React.KeyboardEvent<HTMLButtonElement>) => {\n (globalAttributes.onClick as ((event: typeof e) => void) | undefined)?.(e);\n if (isOpen) {\n setIsOpen(false);\n trackFocusTrigger();\n return;\n }\n if (options.length === 0) return;\n setIsOpen(true);\n trackFocusSelectedOption();\n },\n [globalAttributes.onClick, isOpen, options.length, setIsOpen, trackFocusSelectedOption, trackFocusTrigger],\n );\n\n // ArrowDown / ArrowUp on the trigger open the list (same as the select-only combobox and menu button patterns)\n // Enter and Space are not handled here: the trigger is a native button and they arrive as a click\n const handleTriggerKeyDown = useCallback(\n (e: React.KeyboardEvent<HTMLButtonElement>) => {\n (globalAttributes.onKeyDown as React.KeyboardEventHandler<HTMLButtonElement> | undefined)?.(e);\n if (e.key !== 'ArrowDown' && e.key !== 'ArrowUp') return;\n if (isOpen || options.length === 0) return;\n e.preventDefault();\n setIsOpen(true);\n trackFocusSelectedOption();\n },\n [globalAttributes.onKeyDown, isOpen, options.length, setIsOpen, trackFocusSelectedOption],\n );\n\n /*\n * Tab is handled in the CAPTURE phase and moves the focus from the handler: the one exception to \"the ref callbacks\n * are the only place that calls .focus()\". Tab has a browser default action that runs right after the keydown\n * handlers return and moves the focus from wherever it IS at that moment. The panel is portaled, so from an option\n * the default would continue after the portal, not after the trigger: the trigger must hold the focus BEFORE the\n * default runs, and a post-commit mechanism (tracker -> render -> ref callback) can never be ahead of it.\n * Same decision as DSPaginator and ds-menu-button's `handleMenuTabKeyDownCapture` (see their\n * KNOWN_INTENTIONAL_DEVIATIONS.md). The tracker is reset (\"nothing to focus\") so nothing can steal the focus back.\n */\n const handlePanelKeyDownCapture = useCallback(\n (e: React.KeyboardEvent<HTMLElement>) => {\n if (e.key !== 'Tab') return;\n triggerRef.current?.focus();\n trackFocusRegionReset();\n const focusedOption = options[focusedIndex];\n if (focusedOption && focusedOption.value !== pageSize) {\n onPageSizeChange(focusedOption.value);\n }\n setIsOpen(false);\n },\n [focusedIndex, onPageSizeChange, options, pageSize, setIsOpen, trackFocusRegionReset, triggerRef],\n );\n\n // APG recommends type-ahead for every listbox: the typed characters (within a second of each other) are the prefix of\n // the label to focus. The first character looks from the NEXT option, so repeating a key cycles through its matches\n const handleTypeahead = useCallback(\n (character: string) => {\n const now = Date.now();\n const typeahead = typeaheadRef.current;\n const isNewSearch = now - typeahead.lastKeyTimestamp > PER_PAGE_SELECTOR_TYPEAHEAD_RESET_MS;\n if (isNewSearch) typeahead.buffer = '';\n typeahead.buffer += character.toLowerCase();\n typeahead.lastKeyTimestamp = now;\n const startIndex = isNewSearch ? focusedIndex + 1 : Math.max(focusedIndex, 0);\n const ordered = [...options.slice(startIndex), ...options.slice(0, startIndex)];\n const match = ordered.find((option) => option.label.toLowerCase().startsWith(typeahead.buffer));\n if (match) moveFocusToIndex(options.indexOf(match));\n },\n [focusedIndex, moveFocusToIndex, options],\n );\n\n const handlePanelKeyDown = useCallback(\n (e: React.KeyboardEvent<HTMLElement>) => {\n if (e.ctrlKey || e.metaKey || e.altKey) return;\n const getTargetIndex = NAVIGATION_KEYS[e.key];\n if (getTargetIndex) {\n e.preventDefault(); // the list scrolls through the virtualizer, not through the browser\n moveFocusToIndex(getTargetIndex(Math.max(focusedIndex, 0), options.length));\n return;\n }\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n if (focusedIndex >= 0) commitOption(options[focusedIndex]);\n return;\n }\n if (isPrintableCharacter(e.key)) handleTypeahead(e.key);\n },\n [commitOption, focusedIndex, handleTypeahead, moveFocusToIndex, options],\n );\n\n /*\n * The tracker resets when the focus leaves the whole widget (trigger + portaled panel), not on every blur:\n * - a blur with no `relatedTarget` is ambiguous (the focused option unmounted because the list scrolled, the\n * window lost focus...) and must NOT reset, or an option that is about to mount for a pending focus intent\n * would find the intent erased\n * - a blur towards the trigger or the panel is internal\n */\n const handleBlurOutOfWidget = useCallback(\n (e: React.FocusEvent<HTMLElement>) => {\n const nextFocused = e.relatedTarget as Node | null;\n if (!nextFocused) return;\n if (triggerRef.current?.contains(nextFocused) || floatingNodeRef.current?.contains(nextFocused)) return;\n trackFocusRegionReset();\n },\n [floatingNodeRef, trackFocusRegionReset, triggerRef],\n );\n\n return useMemo(\n () => ({\n commitOption,\n handleTriggerClick,\n handleTriggerKeyDown,\n handlePanelKeyDown,\n handlePanelKeyDownCapture,\n handleBlurOutOfWidget,\n }),\n [\n commitOption,\n handleTriggerClick,\n handleTriggerKeyDown,\n handlePanelKeyDown,\n handlePanelKeyDownCapture,\n handleBlurOutOfWidget,\n ],\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|