@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.
Files changed (202) hide show
  1. package/dist/cjs/parts/DSPaginator/DSPaginator.js +10 -166
  2. package/dist/cjs/parts/DSPaginator/DSPaginator.js.map +2 -2
  3. package/dist/cjs/parts/DSPaginator/{config/usePaginationSearch.js → DSPaginatorCTX.js} +7 -32
  4. package/dist/cjs/parts/DSPaginator/DSPaginatorCTX.js.map +7 -0
  5. package/dist/cjs/parts/DSPaginator/config/{createPaginatorHeader.js → getAmountOfPages.js} +8 -23
  6. package/dist/cjs/parts/DSPaginator/config/getAmountOfPages.js.map +7 -0
  7. package/dist/cjs/parts/DSPaginator/config/getInstanceIds.js +40 -0
  8. package/dist/cjs/parts/DSPaginator/config/getInstanceIds.js.map +7 -0
  9. package/dist/cjs/parts/DSPaginator/config/navigationKeys.js +44 -0
  10. package/dist/cjs/parts/DSPaginator/config/navigationKeys.js.map +7 -0
  11. package/dist/cjs/parts/DSPaginator/config/useFocusTracker.js +77 -0
  12. package/dist/cjs/parts/DSPaginator/config/useFocusTracker.js.map +7 -0
  13. package/dist/cjs/parts/DSPaginator/config/usePaginator.js +73 -49
  14. package/dist/cjs/parts/DSPaginator/config/usePaginator.js.map +2 -2
  15. package/dist/cjs/parts/DSPaginator/config/usePaginatorFloatingContext.js +86 -0
  16. package/dist/cjs/parts/DSPaginator/config/usePaginatorFloatingContext.js.map +7 -0
  17. package/dist/cjs/parts/DSPaginator/config/usePaginatorInteractions.js +170 -0
  18. package/dist/cjs/parts/DSPaginator/config/usePaginatorInteractions.js.map +7 -0
  19. package/dist/cjs/parts/DSPaginator/config/usePaginatorSizing.js +80 -0
  20. package/dist/cjs/parts/DSPaginator/config/usePaginatorSizing.js.map +7 -0
  21. package/dist/cjs/parts/DSPaginator/config/useValidateProps.js.map +2 -2
  22. package/dist/cjs/parts/DSPaginator/constants/index.js +49 -3
  23. package/dist/cjs/parts/DSPaginator/constants/index.js.map +2 -2
  24. package/dist/cjs/parts/DSPaginator/parts/OptionRenderer.js +98 -0
  25. package/dist/cjs/parts/DSPaginator/parts/OptionRenderer.js.map +7 -0
  26. package/dist/cjs/parts/DSPaginator/parts/Panel.js +131 -0
  27. package/dist/cjs/parts/DSPaginator/parts/Panel.js.map +7 -0
  28. package/dist/cjs/parts/DSPaginator/parts/Trigger.js +124 -0
  29. package/dist/cjs/parts/DSPaginator/parts/Trigger.js.map +7 -0
  30. package/dist/cjs/parts/DSPaginator/react-desc-prop-types.js +6 -1
  31. package/dist/cjs/parts/DSPaginator/react-desc-prop-types.js.map +2 -2
  32. package/dist/cjs/parts/DSPaginator/styled.js +113 -38
  33. package/dist/cjs/parts/DSPaginator/styled.js.map +3 -3
  34. package/dist/cjs/parts/DSPaginator/typescript-testing/slot-props.js +12 -1
  35. package/dist/cjs/parts/DSPaginator/typescript-testing/slot-props.js.map +2 -2
  36. package/dist/cjs/parts/DSPaginator/typescript-testing/typescript-testing.js +2 -1
  37. package/dist/cjs/parts/DSPaginator/typescript-testing/typescript-testing.js.map +2 -2
  38. package/dist/cjs/parts/DSPerPageSelector/DSPerPageSelector.js +10 -79
  39. package/dist/cjs/parts/DSPerPageSelector/DSPerPageSelector.js.map +3 -3
  40. package/dist/cjs/parts/DSPerPageSelector/DSPerPageSelectorCTX.js +38 -0
  41. package/dist/cjs/parts/DSPerPageSelector/DSPerPageSelectorCTX.js.map +7 -0
  42. package/dist/cjs/parts/DSPerPageSelector/config/getInstanceIds.js +40 -0
  43. package/dist/cjs/parts/DSPerPageSelector/config/getInstanceIds.js.map +7 -0
  44. package/dist/cjs/parts/DSPerPageSelector/config/getOptions.js.map +2 -2
  45. package/dist/cjs/parts/DSPerPageSelector/config/getSelectedOptionIndex.js +36 -0
  46. package/dist/cjs/parts/DSPerPageSelector/config/getSelectedOptionIndex.js.map +7 -0
  47. package/dist/cjs/parts/DSPerPageSelector/config/navigationKeys.js +44 -0
  48. package/dist/cjs/parts/DSPerPageSelector/config/navigationKeys.js.map +7 -0
  49. package/dist/cjs/parts/DSPerPageSelector/config/useFocusTracker.js +83 -0
  50. package/dist/cjs/parts/DSPerPageSelector/config/useFocusTracker.js.map +7 -0
  51. package/dist/cjs/parts/DSPerPageSelector/config/usePerPageSelector.js +68 -20
  52. package/dist/cjs/parts/DSPerPageSelector/config/usePerPageSelector.js.map +2 -2
  53. package/dist/cjs/parts/DSPerPageSelector/config/usePerPageSelectorFloatingContext.js +82 -0
  54. package/dist/cjs/parts/DSPerPageSelector/config/usePerPageSelectorFloatingContext.js.map +7 -0
  55. package/dist/cjs/parts/DSPerPageSelector/config/usePerPageSelectorInteractions.js +175 -0
  56. package/dist/cjs/parts/DSPerPageSelector/config/usePerPageSelectorInteractions.js.map +7 -0
  57. package/dist/cjs/parts/DSPerPageSelector/config/usePerPageSelectorSizing.js +66 -0
  58. package/dist/cjs/parts/DSPerPageSelector/config/usePerPageSelectorSizing.js.map +7 -0
  59. package/dist/cjs/parts/DSPerPageSelector/constants/index.js +47 -8
  60. package/dist/cjs/parts/DSPerPageSelector/constants/index.js.map +2 -2
  61. package/dist/cjs/parts/DSPerPageSelector/parts/OptionRenderer.js +94 -0
  62. package/dist/cjs/parts/DSPerPageSelector/parts/OptionRenderer.js.map +7 -0
  63. package/dist/cjs/parts/DSPerPageSelector/parts/Panel.js +120 -0
  64. package/dist/cjs/parts/DSPerPageSelector/parts/Panel.js.map +7 -0
  65. package/dist/cjs/parts/DSPerPageSelector/parts/Trigger.js +95 -0
  66. package/dist/cjs/parts/DSPerPageSelector/parts/Trigger.js.map +7 -0
  67. package/dist/cjs/parts/DSPerPageSelector/react-desc-prop-types.js +19 -2
  68. package/dist/cjs/parts/DSPerPageSelector/react-desc-prop-types.js.map +2 -2
  69. package/dist/cjs/parts/DSPerPageSelector/styled.js +104 -32
  70. package/dist/cjs/parts/DSPerPageSelector/styled.js.map +2 -2
  71. package/dist/cjs/parts/DSPerPageSelector/typescript-testing/slots-props.js +10 -1
  72. package/dist/cjs/parts/DSPerPageSelector/typescript-testing/slots-props.js.map +2 -2
  73. package/dist/cjs/parts/DSPerPageSelector/typescript-testing/typescript-testing.js +60 -1
  74. package/dist/cjs/parts/DSPerPageSelector/typescript-testing/typescript-testing.js.map +2 -2
  75. package/dist/cjs/react-desc-prop-types.js.map +1 -1
  76. package/dist/esm/parts/DSPaginator/DSPaginator.js +12 -168
  77. package/dist/esm/parts/DSPaginator/DSPaginator.js.map +2 -2
  78. package/dist/esm/parts/DSPaginator/DSPaginatorCTX.js +8 -0
  79. package/dist/esm/parts/DSPaginator/DSPaginatorCTX.js.map +7 -0
  80. package/dist/esm/parts/DSPaginator/config/getAmountOfPages.js +9 -0
  81. package/dist/esm/parts/DSPaginator/config/getAmountOfPages.js.map +7 -0
  82. package/dist/esm/parts/DSPaginator/config/getInstanceIds.js +10 -0
  83. package/dist/esm/parts/DSPaginator/config/getInstanceIds.js.map +7 -0
  84. package/dist/esm/parts/DSPaginator/config/navigationKeys.js +14 -0
  85. package/dist/esm/parts/DSPaginator/config/navigationKeys.js.map +7 -0
  86. package/dist/esm/parts/DSPaginator/config/useFocusTracker.js +47 -0
  87. package/dist/esm/parts/DSPaginator/config/useFocusTracker.js.map +7 -0
  88. package/dist/esm/parts/DSPaginator/config/usePaginator.js +74 -50
  89. package/dist/esm/parts/DSPaginator/config/usePaginator.js.map +2 -2
  90. package/dist/esm/parts/DSPaginator/config/usePaginatorFloatingContext.js +56 -0
  91. package/dist/esm/parts/DSPaginator/config/usePaginatorFloatingContext.js.map +7 -0
  92. package/dist/esm/parts/DSPaginator/config/usePaginatorInteractions.js +140 -0
  93. package/dist/esm/parts/DSPaginator/config/usePaginatorInteractions.js.map +7 -0
  94. package/dist/esm/parts/DSPaginator/config/usePaginatorSizing.js +56 -0
  95. package/dist/esm/parts/DSPaginator/config/usePaginatorSizing.js.map +7 -0
  96. package/dist/esm/parts/DSPaginator/config/useValidateProps.js.map +2 -2
  97. package/dist/esm/parts/DSPaginator/constants/index.js +49 -3
  98. package/dist/esm/parts/DSPaginator/constants/index.js.map +2 -2
  99. package/dist/esm/parts/DSPaginator/parts/OptionRenderer.js +68 -0
  100. package/dist/esm/parts/DSPaginator/parts/OptionRenderer.js.map +7 -0
  101. package/dist/esm/parts/DSPaginator/parts/Panel.js +101 -0
  102. package/dist/esm/parts/DSPaginator/parts/Panel.js.map +7 -0
  103. package/dist/esm/parts/DSPaginator/parts/Trigger.js +94 -0
  104. package/dist/esm/parts/DSPaginator/parts/Trigger.js.map +7 -0
  105. package/dist/esm/parts/DSPaginator/react-desc-prop-types.js +6 -1
  106. package/dist/esm/parts/DSPaginator/react-desc-prop-types.js.map +2 -2
  107. package/dist/esm/parts/DSPaginator/styled.js +120 -39
  108. package/dist/esm/parts/DSPaginator/styled.js.map +2 -2
  109. package/dist/esm/parts/DSPaginator/typescript-testing/slot-props.js +12 -1
  110. package/dist/esm/parts/DSPaginator/typescript-testing/slot-props.js.map +2 -2
  111. package/dist/esm/parts/DSPaginator/typescript-testing/typescript-testing.js +2 -1
  112. package/dist/esm/parts/DSPaginator/typescript-testing/typescript-testing.js.map +2 -2
  113. package/dist/esm/parts/DSPerPageSelector/DSPerPageSelector.js +11 -80
  114. package/dist/esm/parts/DSPerPageSelector/DSPerPageSelector.js.map +3 -3
  115. package/dist/esm/parts/DSPerPageSelector/DSPerPageSelectorCTX.js +8 -0
  116. package/dist/esm/parts/DSPerPageSelector/DSPerPageSelectorCTX.js.map +7 -0
  117. package/dist/esm/parts/DSPerPageSelector/config/getInstanceIds.js +10 -0
  118. package/dist/esm/parts/DSPerPageSelector/config/getInstanceIds.js.map +7 -0
  119. package/dist/esm/parts/DSPerPageSelector/config/getOptions.js.map +2 -2
  120. package/dist/esm/parts/DSPerPageSelector/config/getSelectedOptionIndex.js +6 -0
  121. package/dist/esm/parts/DSPerPageSelector/config/getSelectedOptionIndex.js.map +7 -0
  122. package/dist/esm/parts/DSPerPageSelector/config/navigationKeys.js +14 -0
  123. package/dist/esm/parts/DSPerPageSelector/config/navigationKeys.js.map +7 -0
  124. package/dist/esm/parts/DSPerPageSelector/config/useFocusTracker.js +53 -0
  125. package/dist/esm/parts/DSPerPageSelector/config/useFocusTracker.js.map +7 -0
  126. package/dist/esm/parts/DSPerPageSelector/config/usePerPageSelector.js +69 -21
  127. package/dist/esm/parts/DSPerPageSelector/config/usePerPageSelector.js.map +2 -2
  128. package/dist/esm/parts/DSPerPageSelector/config/usePerPageSelectorFloatingContext.js +52 -0
  129. package/dist/esm/parts/DSPerPageSelector/config/usePerPageSelectorFloatingContext.js.map +7 -0
  130. package/dist/esm/parts/DSPerPageSelector/config/usePerPageSelectorInteractions.js +145 -0
  131. package/dist/esm/parts/DSPerPageSelector/config/usePerPageSelectorInteractions.js.map +7 -0
  132. package/dist/esm/parts/DSPerPageSelector/config/usePerPageSelectorSizing.js +42 -0
  133. package/dist/esm/parts/DSPerPageSelector/config/usePerPageSelectorSizing.js.map +7 -0
  134. package/dist/esm/parts/DSPerPageSelector/constants/index.js +47 -8
  135. package/dist/esm/parts/DSPerPageSelector/constants/index.js.map +2 -2
  136. package/dist/esm/parts/DSPerPageSelector/parts/OptionRenderer.js +64 -0
  137. package/dist/esm/parts/DSPerPageSelector/parts/OptionRenderer.js.map +7 -0
  138. package/dist/esm/parts/DSPerPageSelector/parts/Panel.js +90 -0
  139. package/dist/esm/parts/DSPerPageSelector/parts/Panel.js.map +7 -0
  140. package/dist/esm/parts/DSPerPageSelector/parts/Trigger.js +65 -0
  141. package/dist/esm/parts/DSPerPageSelector/parts/Trigger.js.map +7 -0
  142. package/dist/esm/parts/DSPerPageSelector/react-desc-prop-types.js +19 -2
  143. package/dist/esm/parts/DSPerPageSelector/react-desc-prop-types.js.map +2 -2
  144. package/dist/esm/parts/DSPerPageSelector/styled.js +111 -33
  145. package/dist/esm/parts/DSPerPageSelector/styled.js.map +2 -2
  146. package/dist/esm/parts/DSPerPageSelector/typescript-testing/slots-props.js +10 -1
  147. package/dist/esm/parts/DSPerPageSelector/typescript-testing/slots-props.js.map +2 -2
  148. package/dist/esm/parts/DSPerPageSelector/typescript-testing/typescript-testing.js +60 -1
  149. package/dist/esm/parts/DSPerPageSelector/typescript-testing/typescript-testing.js.map +2 -2
  150. package/dist/esm/react-desc-prop-types.js.map +1 -1
  151. package/dist/types/parts/DSPageNextButton/config/usePageNextButton.d.ts +4 -4
  152. package/dist/types/parts/DSPagePrevButton/config/usePagePrevButton.d.ts +4 -4
  153. package/dist/types/parts/DSPaginationContainer/config/usePaginationContainer.d.ts +4 -4
  154. package/dist/types/parts/DSPaginationSeparator/config/usePaginationSeparator.d.ts +4 -4
  155. package/dist/types/parts/DSPaginator/DSPaginator.d.ts +5 -0
  156. package/dist/types/parts/DSPaginator/DSPaginatorCTX.d.ts +5 -0
  157. package/dist/types/parts/DSPaginator/config/getAmountOfPages.d.ts +1 -0
  158. package/dist/types/parts/DSPaginator/config/getInstanceIds.d.ts +3 -0
  159. package/dist/types/parts/DSPaginator/config/navigationKeys.d.ts +3 -0
  160. package/dist/types/parts/DSPaginator/config/useFocusTracker.d.ts +20 -0
  161. package/dist/types/parts/DSPaginator/config/usePaginator.d.ts +52 -18
  162. package/dist/types/parts/DSPaginator/config/usePaginatorFloatingContext.d.ts +31 -0
  163. package/dist/types/parts/DSPaginator/config/usePaginatorInteractions.d.ts +37 -0
  164. package/dist/types/parts/DSPaginator/config/usePaginatorSizing.d.ts +37 -0
  165. package/dist/types/parts/DSPaginator/constants/index.d.ts +36 -1
  166. package/dist/types/parts/DSPaginator/parts/OptionRenderer.d.ts +11 -0
  167. package/dist/types/parts/DSPaginator/parts/Panel.d.ts +5 -0
  168. package/dist/types/parts/DSPaginator/parts/Trigger.d.ts +5 -0
  169. package/dist/types/parts/DSPaginator/react-desc-prop-types.d.ts +17 -0
  170. package/dist/types/parts/DSPaginator/styled.d.ts +17 -4
  171. package/dist/types/parts/DSPerPageSelector/DSPerPageSelector.d.ts +5 -0
  172. package/dist/types/parts/DSPerPageSelector/DSPerPageSelectorCTX.d.ts +5 -0
  173. package/dist/types/parts/DSPerPageSelector/config/getInstanceIds.d.ts +3 -0
  174. package/dist/types/parts/DSPerPageSelector/config/getOptions.d.ts +3 -3
  175. package/dist/types/parts/DSPerPageSelector/config/getSelectedOptionIndex.d.ts +2 -0
  176. package/dist/types/parts/DSPerPageSelector/config/navigationKeys.d.ts +3 -0
  177. package/dist/types/parts/DSPerPageSelector/config/useFocusTracker.d.ts +22 -0
  178. package/dist/types/parts/DSPerPageSelector/config/usePerPageSelector.d.ts +43 -10
  179. package/dist/types/parts/DSPerPageSelector/config/usePerPageSelectorFloatingContext.d.ts +31 -0
  180. package/dist/types/parts/DSPerPageSelector/config/usePerPageSelectorInteractions.d.ts +38 -0
  181. package/dist/types/parts/DSPerPageSelector/config/usePerPageSelectorSizing.d.ts +25 -0
  182. package/dist/types/parts/DSPerPageSelector/constants/index.d.ts +32 -5
  183. package/dist/types/parts/DSPerPageSelector/parts/OptionRenderer.d.ts +11 -0
  184. package/dist/types/parts/DSPerPageSelector/parts/Panel.d.ts +5 -0
  185. package/dist/types/parts/DSPerPageSelector/parts/Trigger.d.ts +5 -0
  186. package/dist/types/parts/DSPerPageSelector/react-desc-prop-types.d.ts +27 -2
  187. package/dist/types/parts/DSPerPageSelector/styled.d.ts +15 -2
  188. package/dist/types/react-desc-prop-types.d.ts +2 -2
  189. package/package.json +15 -13
  190. package/dist/cjs/parts/DSPaginator/config/createPaginatorHeader.js.map +0 -7
  191. package/dist/cjs/parts/DSPaginator/config/getOptions.js +0 -76
  192. package/dist/cjs/parts/DSPaginator/config/getOptions.js.map +0 -7
  193. package/dist/cjs/parts/DSPaginator/config/usePaginationSearch.js.map +0 -7
  194. package/dist/esm/parts/DSPaginator/config/createPaginatorHeader.js +0 -24
  195. package/dist/esm/parts/DSPaginator/config/createPaginatorHeader.js.map +0 -7
  196. package/dist/esm/parts/DSPaginator/config/getOptions.js +0 -46
  197. package/dist/esm/parts/DSPaginator/config/getOptions.js.map +0 -7
  198. package/dist/esm/parts/DSPaginator/config/usePaginationSearch.js +0 -33
  199. package/dist/esm/parts/DSPaginator/config/usePaginationSearch.js.map +0 -7
  200. package/dist/types/parts/DSPaginator/config/createPaginatorHeader.d.ts +0 -9
  201. package/dist/types/parts/DSPaginator/config/getOptions.d.ts +0 -8
  202. package/dist/types/parts/DSPaginator/config/usePaginationSearch.d.ts +0 -1
@@ -34,11 +34,15 @@ module.exports = __toCommonJS(usePaginator_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");
39
+ var import_getAmountOfPages = require("./getAmountOfPages.js");
40
+ var import_getInstanceIds = require("./getInstanceIds.js");
41
+ var import_useFocusTracker = require("./useFocusTracker.js");
42
+ var import_usePaginatorFloatingContext = require("./usePaginatorFloatingContext.js");
43
+ var import_usePaginatorInteractions = require("./usePaginatorInteractions.js");
44
+ var import_usePaginatorSizing = require("./usePaginatorSizing.js");
38
45
  var import_useValidateProps = require("./useValidateProps.js");
39
- var import_useOnElementOnResize = require("../../shared/useOnElementOnResize.js");
40
- var import_getOptions = require("./getOptions.js");
41
- var import_usePaginationSearch = require("./usePaginationSearch.js");
42
46
  const usePaginator = (propsFromUser) => {
43
47
  const propsWithDefault = (0, import_ds_props_helpers.useMemoMergePropsWithDefault)(propsFromUser, import_react_desc_prop_types.defaultProps);
44
48
  (0, import_useValidateProps.useValidateProps)(propsWithDefault, import_react_desc_prop_types.DSPaginatorPropTypesSchema);
@@ -47,66 +51,86 @@ const usePaginator = (propsFromUser) => {
47
51
  propsWithDefault
48
52
  );
49
53
  const ownerPropsConfig = (0, import_ds_props_helpers.useOwnerProps)(propsWithDefault);
50
- const { pageIndex, pageCount, pageDetails } = propsWithDefault;
51
- const [isOpened, setIsOpened] = (0, import_react.useState)(false);
52
- const btnRef = (0, import_react.useRef)(null);
53
- const actionRef = (0, import_react.useRef)({});
54
- const widestChildRef = import_react.default.useRef(null);
55
- const pageInfoRef = import_react.default.useRef(null);
56
- const checkMarkRef = (0, import_react.useRef)(null);
57
- const { width: btnWidth } = (0, import_useOnElementOnResize.useOnElementResize)(btnRef);
58
- const { width: checkMarkWidth } = (0, import_useOnElementOnResize.useOnElementResize)(checkMarkRef);
59
- const { width: pageInfoWidth } = (0, import_useOnElementOnResize.useOnElementResize)(pageInfoRef);
60
- const { width: detailWidth } = (0, import_useOnElementOnResize.useOnElementResize)(widestChildRef);
61
- const options = (0, import_react.useMemo)(
62
- () => (0, import_getOptions.getOptions)({ pageCount, pageIndex, pageDetails, pageInfoWidth, checkMarkWidth }),
63
- [pageCount, pageIndex, pageDetails, pageInfoWidth, checkMarkWidth]
54
+ const { pageIndex, pageCount, pageDetails, listWidth } = propsWithDefault;
55
+ const instanceUid = (0, import_react.useMemo)(() => (0, import_uid.uid)(5), []);
56
+ const [isOpen, setIsOpen] = (0, import_react.useState)(false);
57
+ const amountOfPages = (0, import_getAmountOfPages.getAmountOfPages)(pageCount, pageIndex);
58
+ const triggerRef = (0, import_react.useRef)(null);
59
+ const chevronRef = (0, import_react.useRef)(null);
60
+ const pageInfoRef = (0, import_react.useRef)(null);
61
+ const listActionRef = (0, import_react.useRef)({});
62
+ const sizing = (0, import_usePaginatorSizing.usePaginatorSizing)({
63
+ pageCount,
64
+ pageIndex,
65
+ pageDetails,
66
+ listWidth,
67
+ chevronRef,
68
+ pageInfoRef,
69
+ listActionRef
70
+ });
71
+ const focusTrackers = (0, import_useFocusTracker.useFocusTracker)({ amountOfPages, pageIndex });
72
+ const { floatingStyles, floatingContext, handleTriggerRef, floatingInnerRef, floatingNodeRef } = (0, import_usePaginatorFloatingContext.usePaginatorFloatingContext)({
73
+ isOpen,
74
+ setIsOpen,
75
+ triggerRef,
76
+ trackFocusRegionReset: focusTrackers.trackFocusRegionReset,
77
+ chevronWidth: sizing.chevronWidth
78
+ });
79
+ const interactions = (0, import_usePaginatorInteractions.usePaginatorInteractions)({
80
+ propsWithDefault,
81
+ globalAttributes,
82
+ isOpen,
83
+ setIsOpen,
84
+ amountOfPages,
85
+ focusTrackers,
86
+ triggerRef,
87
+ floatingNodeRef,
88
+ listActionRef
89
+ });
90
+ const ids = (0, import_react.useMemo)(
91
+ () => ({
92
+ headerId: (0, import_getInstanceIds.getHeaderId)(instanceUid),
93
+ listId: (0, import_getInstanceIds.getListId)(instanceUid),
94
+ dialogId: (0, import_getInstanceIds.getDialogId)(instanceUid)
95
+ }),
96
+ [instanceUid]
64
97
  );
65
- const onKeyDown = (0, import_usePaginationSearch.usePaginationSearch)(pageCount, actionRef);
66
- (0, import_react.useEffect)(() => {
67
- if (isOpened) {
68
- actionRef.current.setActiveDescendant(pageIndex.toString());
69
- actionRef.current.scrollOptionIntoView(pageIndex.toString());
70
- }
71
- }, [isOpened]);
72
98
  return import_react.default.useMemo(
73
99
  () => ({
74
100
  propsWithDefault,
75
101
  xstyledProps,
76
102
  globalAttributes,
77
103
  ownerPropsConfig,
78
- btnRef,
79
- btnWidth,
80
- pageInfoWidth,
104
+ isOpen,
105
+ amountOfPages,
106
+ focusTrackers,
107
+ triggerRef,
108
+ chevronRef,
81
109
  pageInfoRef,
82
- options,
83
- isOpened,
84
- detailWidth,
85
- actionRef,
86
- widestChildRef,
87
- checkMarkRef,
88
- checkMarkWidth,
89
- setIsOpened,
90
- onKeyDown
110
+ listActionRef,
111
+ floatingStyles,
112
+ floatingContext,
113
+ handleTriggerRef,
114
+ floatingInnerRef,
115
+ ...sizing,
116
+ ...ids,
117
+ ...interactions
91
118
  }),
92
119
  [
93
120
  propsWithDefault,
94
121
  xstyledProps,
95
122
  globalAttributes,
96
123
  ownerPropsConfig,
97
- btnRef,
98
- btnWidth,
99
- pageInfoWidth,
100
- options,
101
- isOpened,
102
- detailWidth,
103
- actionRef,
104
- widestChildRef,
105
- checkMarkRef,
106
- checkMarkWidth,
107
- pageInfoRef,
108
- setIsOpened,
109
- onKeyDown
124
+ isOpen,
125
+ amountOfPages,
126
+ focusTrackers,
127
+ floatingStyles,
128
+ floatingContext,
129
+ handleTriggerRef,
130
+ floatingInnerRef,
131
+ sizing,
132
+ ids,
133
+ interactions
110
134
  ]
111
135
  );
112
136
  };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/parts/DSPaginator/config/usePaginator.ts", "../../../../../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["/* eslint-disable max-statements */\nimport {\n useGetGlobalAttributes,\n useGetXstyledProps,\n useMemoMergePropsWithDefault,\n useOwnerProps,\n} from '@elliemae/ds-props-helpers';\nimport React, { useEffect, useMemo, useRef, useState } from 'react';\n\nimport type { DSButtonV3T } from '@elliemae/ds-button-v2';\nimport { type DSPaginatorT, DSPaginatorPropTypesSchema, defaultProps } from '../react-desc-prop-types.js';\nimport { useValidateProps } from './useValidateProps.js';\nimport { useOnElementResize } from '../../shared/useOnElementOnResize.js';\nimport { getOptions } from './getOptions.js';\nimport { usePaginationSearch } from './usePaginationSearch.js';\n\nexport const usePaginator = (propsFromUser: DSPaginatorT.Props) => {\n // =============================================================================\n // MERGE WITH DEFAULT AND VALIDATE PROPS\n // =============================================================================\n const propsWithDefault = useMemoMergePropsWithDefault<DSPaginatorT.InternalProps>(propsFromUser, defaultProps);\n useValidateProps(propsWithDefault, DSPaginatorPropTypesSchema);\n // =============================================================================\n // XSTYLED PROPS\n // =============================================================================\n const xstyledProps = useGetXstyledProps(propsWithDefault);\n // =============================================================================\n // GLOBAL ATTRIBUTES\n // =============================================================================\n const globalAttributes = useGetGlobalAttributes<DSPaginatorT.InternalProps, HTMLButtonElement, DSButtonV3T.Props>(\n propsWithDefault,\n );\n // =============================================================================\n // OWNER PROPS\n // =============================================================================\n const ownerPropsConfig = useOwnerProps(propsWithDefault);\n // =============================================================================\n // AD HOC PER COMPONENT LOGIC\n // =============================================================================\n\n const { pageIndex, pageCount, pageDetails } = propsWithDefault;\n\n const [isOpened, setIsOpened] = useState(false);\n\n const btnRef = useRef<HTMLButtonElement>(null);\n const actionRef = useRef<Record<string, (dsId: string) => void>>({});\n const widestChildRef = React.useRef<HTMLDivElement | null>(null);\n const pageInfoRef = React.useRef<HTMLDivElement | null>(null);\n const checkMarkRef = useRef<HTMLDivElement>(null);\n\n // btnWidth is used to calculate dropdown min-width when pageDetails are provided\n const { width: btnWidth } = useOnElementResize(btnRef);\n\n // checkMarkWidth is used to calculate dropdown offset so, when opening the dropdown,\n // selected page is aligned properly with the available options.\n // It is also used to calculate paginatorHeader and options custom render.\n const { width: checkMarkWidth } = useOnElementResize(checkMarkRef);\n // pageInfoWidth is used to calculate dropdown min-width when pageDetails are provided on segmented pagination\n // pageInfoWidth || detailWidth\n const { width: pageInfoWidth } = useOnElementResize(pageInfoRef);\n // detailWidth is used to calculate dropdown min-width when pageDetails are provided on segmented pagination\n // pageInfoWidth || detailWidth\n const { width: detailWidth } = useOnElementResize(widestChildRef);\n const options = useMemo(\n () => getOptions({ pageCount, pageIndex, pageDetails, pageInfoWidth, checkMarkWidth }),\n [pageCount, pageIndex, pageDetails, pageInfoWidth, checkMarkWidth],\n );\n // =============================================================================\n // HELPERS HOOKS CONFIGS\n // =============================================================================\n // const eventHandlers = useEventHandlers({ propsWithDefault, instanceUid }); // <-- complex logic should be made atomics this way\n const onKeyDown = usePaginationSearch(pageCount, actionRef);\n\n useEffect(() => {\n if (isOpened) {\n actionRef.current.setActiveDescendant(pageIndex.toString());\n actionRef.current.scrollOptionIntoView(pageIndex.toString());\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [isOpened]);\n\n return React.useMemo(\n () => ({\n propsWithDefault,\n xstyledProps,\n globalAttributes,\n ownerPropsConfig,\n btnRef,\n btnWidth,\n pageInfoWidth,\n pageInfoRef,\n options,\n isOpened,\n detailWidth,\n actionRef,\n widestChildRef,\n checkMarkRef,\n checkMarkWidth,\n setIsOpened,\n onKeyDown,\n }),\n [\n propsWithDefault,\n xstyledProps,\n globalAttributes,\n ownerPropsConfig,\n btnRef,\n btnWidth,\n pageInfoWidth,\n options,\n isOpened,\n detailWidth,\n actionRef,\n widestChildRef,\n checkMarkRef,\n checkMarkWidth,\n pageInfoRef,\n setIsOpened,\n onKeyDown,\n ],\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADCvB,8BAKO;AACP,mBAA4D;AAG5D,mCAA4E;AAC5E,8BAAiC;AACjC,kCAAmC;AACnC,wBAA2B;AAC3B,iCAAoC;AAE7B,MAAM,eAAe,CAAC,kBAAsC;AAIjE,QAAM,uBAAmB,sDAAyD,eAAe,yCAAY;AAC7G,gDAAiB,kBAAkB,uDAA0B;AAI7D,QAAM,mBAAe,4CAAmB,gBAAgB;AAIxD,QAAM,uBAAmB;AAAA,IACvB;AAAA,EACF;AAIA,QAAM,uBAAmB,uCAAc,gBAAgB;AAKvD,QAAM,EAAE,WAAW,WAAW,YAAY,IAAI;AAE9C,QAAM,CAAC,UAAU,WAAW,QAAI,uBAAS,KAAK;AAE9C,QAAM,aAAS,qBAA0B,IAAI;AAC7C,QAAM,gBAAY,qBAA+C,CAAC,CAAC;AACnE,QAAM,iBAAiB,aAAAA,QAAM,OAA8B,IAAI;AAC/D,QAAM,cAAc,aAAAA,QAAM,OAA8B,IAAI;AAC5D,QAAM,mBAAe,qBAAuB,IAAI;AAGhD,QAAM,EAAE,OAAO,SAAS,QAAI,gDAAmB,MAAM;AAKrD,QAAM,EAAE,OAAO,eAAe,QAAI,gDAAmB,YAAY;AAGjE,QAAM,EAAE,OAAO,cAAc,QAAI,gDAAmB,WAAW;AAG/D,QAAM,EAAE,OAAO,YAAY,QAAI,gDAAmB,cAAc;AAChE,QAAM,cAAU;AAAA,IACd,UAAM,8BAAW,EAAE,WAAW,WAAW,aAAa,eAAe,eAAe,CAAC;AAAA,IACrF,CAAC,WAAW,WAAW,aAAa,eAAe,cAAc;AAAA,EACnE;AAKA,QAAM,gBAAY,gDAAoB,WAAW,SAAS;AAE1D,8BAAU,MAAM;AACd,QAAI,UAAU;AACZ,gBAAU,QAAQ,oBAAoB,UAAU,SAAS,CAAC;AAC1D,gBAAU,QAAQ,qBAAqB,UAAU,SAAS,CAAC;AAAA,IAC7D;AAAA,EAEF,GAAG,CAAC,QAAQ,CAAC;AAEb,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;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,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;",
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 { DSPaginatorPropTypesSchema, defaultProps, type DSPaginatorT } from '../react-desc-prop-types.js';\nimport { getAmountOfPages } from './getAmountOfPages.js';\nimport { getDialogId, getHeaderId, getListId } from './getInstanceIds.js';\nimport { useFocusTracker } from './useFocusTracker.js';\nimport { usePaginatorFloatingContext } from './usePaginatorFloatingContext.js';\nimport { usePaginatorInteractions } from './usePaginatorInteractions.js';\nimport { usePaginatorSizing } from './usePaginatorSizing.js';\nimport { useValidateProps } from './useValidateProps.js';\n\nexport const usePaginator = (propsFromUser: DSPaginatorT.Props) => {\n // =============================================================================\n // MERGE WITH DEFAULT AND VALIDATE PROPS\n // =============================================================================\n const propsWithDefault = useMemoMergePropsWithDefault<DSPaginatorT.InternalProps>(propsFromUser, defaultProps);\n useValidateProps(propsWithDefault, DSPaginatorPropTypesSchema);\n // =============================================================================\n // XSTYLED PROPS\n // =============================================================================\n const xstyledProps = useGetXstyledProps(propsWithDefault);\n // =============================================================================\n // GLOBAL ATTRIBUTES\n // =============================================================================\n const globalAttributes = useGetGlobalAttributes<DSPaginatorT.InternalProps, HTMLButtonElement, DSButtonV3T.Props>(\n propsWithDefault,\n );\n // =============================================================================\n // OWNER PROPS\n // =============================================================================\n const ownerPropsConfig = useOwnerProps(propsWithDefault);\n // =============================================================================\n // AD HOC PER COMPONENT LOGIC\n // =============================================================================\n const { pageIndex, pageCount, pageDetails, listWidth } = propsWithDefault;\n const instanceUid = useMemo(() => uid(5), []);\n const [isOpen, setIsOpen] = useState(false);\n const amountOfPages = getAmountOfPages(pageCount, pageIndex);\n\n const triggerRef = useRef<HTMLButtonElement | null>(null);\n const chevronRef = useRef<HTMLElement>(null);\n const pageInfoRef = useRef<HTMLDivElement>(null);\n const listActionRef = useRef<DSFastListT.ActionRef>({});\n\n const sizing = usePaginatorSizing({\n pageCount,\n pageIndex,\n pageDetails,\n listWidth,\n chevronRef,\n pageInfoRef,\n listActionRef,\n });\n\n const focusTrackers = useFocusTracker({ amountOfPages, pageIndex });\n\n const { floatingStyles, floatingContext, handleTriggerRef, floatingInnerRef, floatingNodeRef } =\n usePaginatorFloatingContext({\n isOpen,\n setIsOpen,\n triggerRef,\n trackFocusRegionReset: focusTrackers.trackFocusRegionReset,\n chevronWidth: sizing.chevronWidth,\n });\n\n const interactions = usePaginatorInteractions({\n propsWithDefault,\n globalAttributes,\n isOpen,\n setIsOpen,\n amountOfPages,\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 amountOfPages,\n focusTrackers,\n triggerRef,\n chevronRef,\n pageInfoRef,\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 amountOfPages,\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,mCAA4E;AAC5E,8BAAiC;AACjC,4BAAoD;AACpD,6BAAgC;AAChC,yCAA4C;AAC5C,sCAAyC;AACzC,gCAAmC;AACnC,8BAAiC;AAE1B,MAAM,eAAe,CAAC,kBAAsC;AAIjE,QAAM,uBAAmB,sDAAyD,eAAe,yCAAY;AAC7G,gDAAiB,kBAAkB,uDAA0B;AAI7D,QAAM,mBAAe,4CAAmB,gBAAgB;AAIxD,QAAM,uBAAmB;AAAA,IACvB;AAAA,EACF;AAIA,QAAM,uBAAmB,uCAAc,gBAAgB;AAIvD,QAAM,EAAE,WAAW,WAAW,aAAa,UAAU,IAAI;AACzD,QAAM,kBAAc,sBAAQ,UAAM,gBAAI,CAAC,GAAG,CAAC,CAAC;AAC5C,QAAM,CAAC,QAAQ,SAAS,QAAI,uBAAS,KAAK;AAC1C,QAAM,oBAAgB,0CAAiB,WAAW,SAAS;AAE3D,QAAM,iBAAa,qBAAiC,IAAI;AACxD,QAAM,iBAAa,qBAAoB,IAAI;AAC3C,QAAM,kBAAc,qBAAuB,IAAI;AAC/C,QAAM,oBAAgB,qBAA8B,CAAC,CAAC;AAEtD,QAAM,aAAS,8CAAmB;AAAA,IAChC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AAED,QAAM,oBAAgB,wCAAgB,EAAE,eAAe,UAAU,CAAC;AAElE,QAAM,EAAE,gBAAgB,iBAAiB,kBAAkB,kBAAkB,gBAAgB,QAC3F,gEAA4B;AAAA,IAC1B;AAAA,IACA;AAAA,IACA;AAAA,IACA,uBAAuB,cAAc;AAAA,IACrC,cAAc,OAAO;AAAA,EACvB,CAAC;AAEH,QAAM,mBAAe,0DAAyB;AAAA,IAC5C;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;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,86 @@
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 usePaginatorFloatingContext_exports = {};
30
+ __export(usePaginatorFloatingContext_exports, {
31
+ usePaginatorFloatingContext: () => usePaginatorFloatingContext
32
+ });
33
+ module.exports = __toCommonJS(usePaginatorFloatingContext_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 usePaginatorFloatingContext = ({
38
+ isOpen,
39
+ setIsOpen,
40
+ triggerRef,
41
+ trackFocusRegionReset,
42
+ chevronWidth
43
+ }) => {
44
+ const floatingNodeRef = (0, import_react.useRef)(null);
45
+ const handleClickOutside = (0, import_react.useCallback)(() => {
46
+ setIsOpen(false);
47
+ trackFocusRegionReset();
48
+ }, [setIsOpen, trackFocusRegionReset]);
49
+ const handleScopedEscape = (0, import_react.useCallback)(() => {
50
+ setIsOpen(false);
51
+ trackFocusRegionReset();
52
+ }, [setIsOpen, trackFocusRegionReset]);
53
+ const floatingContextConfig = (0, import_react.useMemo)(
54
+ () => ({
55
+ // the existing DSPaginator opens upwards (it lives in a footer) and aligns the selected page with the trigger
56
+ placement: "top-start",
57
+ placementOrderPreference: ["top-start", "bottom-start"],
58
+ customOffset: [-(chevronWidth + 7), 2],
59
+ externallyControlledIsOpen: isOpen,
60
+ withoutAnimation: true,
61
+ onClickOutside: handleClickOutside,
62
+ closeOnEscape: true,
63
+ onEscape: handleScopedEscape,
64
+ returnFocusToReference: true,
65
+ externalReferenceElement: triggerRef.current
66
+ }),
67
+ [chevronWidth, handleClickOutside, handleScopedEscape, isOpen, triggerRef]
68
+ );
69
+ const { refs: floatingRefs, floatingStyles, context: floatingContext } = (0, import_ds_floating_context.useFloatingContext)(floatingContextConfig);
70
+ const handleTriggerRef = (0, import_react.useCallback)(
71
+ (node) => {
72
+ triggerRef.current = node;
73
+ floatingRefs.setReference(node);
74
+ },
75
+ [floatingRefs, triggerRef]
76
+ );
77
+ const floatingInnerRef = (0, import_react.useCallback)(
78
+ (node) => {
79
+ floatingNodeRef.current = node;
80
+ floatingRefs.setFloating(node);
81
+ },
82
+ [floatingRefs.setFloating]
83
+ );
84
+ return { floatingStyles, floatingContext, handleTriggerRef, floatingInnerRef, floatingNodeRef };
85
+ };
86
+ //# sourceMappingURL=usePaginatorFloatingContext.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/parts/DSPaginator/config/usePaginatorFloatingContext.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 DSPaginator to `useFloatingContext` (same shape as ds-app-picker'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 usePaginatorInteractions.\n */\nexport const usePaginatorFloatingContext = ({\n isOpen,\n setIsOpen,\n triggerRef,\n trackFocusRegionReset,\n chevronWidth,\n}: FloatingContextConfigT) => {\n const floatingNodeRef = useRef<HTMLDivElement | null>(null);\n\n const handleClickOutside = useCallback(() => {\n setIsOpen(false);\n trackFocusRegionReset();\n }, [setIsOpen, trackFocusRegionReset]);\n\n const handleScopedEscape = useCallback(() => {\n setIsOpen(false);\n trackFocusRegionReset();\n }, [setIsOpen, trackFocusRegionReset]);\n\n const floatingContextConfig = useMemo(\n () =>\n ({\n // the existing DSPaginator opens upwards (it lives in a footer) and aligns the selected page 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: handleClickOutside,\n closeOnEscape: true,\n onEscape: handleScopedEscape,\n returnFocusToReference: true,\n externalReferenceElement: triggerRef.current,\n }) as DSHookFloatingContextT.Props,\n [chevronWidth, handleClickOutside, handleScopedEscape, 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,8BAA8B,CAAC;AAAA,EAC1C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAA8B;AAC5B,QAAM,sBAAkB,qBAA8B,IAAI;AAE1D,QAAM,yBAAqB,0BAAY,MAAM;AAC3C,cAAU,KAAK;AACf,0BAAsB;AAAA,EACxB,GAAG,CAAC,WAAW,qBAAqB,CAAC;AAErC,QAAM,yBAAqB,0BAAY,MAAM;AAC3C,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,oBAAoB,oBAAoB,QAAQ,UAAU;AAAA,EAC3E;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,170 @@
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 usePaginatorInteractions_exports = {};
30
+ __export(usePaginatorInteractions_exports, {
31
+ usePaginatorInteractions: () => usePaginatorInteractions
32
+ });
33
+ module.exports = __toCommonJS(usePaginatorInteractions_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 DIGIT_REGEXP = /^[0-9]$/;
39
+ const usePaginatorInteractions = ({
40
+ propsWithDefault,
41
+ globalAttributes,
42
+ isOpen,
43
+ setIsOpen,
44
+ amountOfPages,
45
+ focusTrackers,
46
+ triggerRef,
47
+ floatingNodeRef,
48
+ listActionRef
49
+ }) => {
50
+ const { pageIndex, pageCount, onPageChange } = propsWithDefault;
51
+ const {
52
+ focusedPage,
53
+ clampPage,
54
+ trackFocusOption,
55
+ trackFocusSelectedOption,
56
+ trackFocusTrigger,
57
+ trackFocusRegionReset
58
+ } = focusTrackers;
59
+ const typeaheadRef = (0, import_react.useRef)({ buffer: "", lastKeyTimestamp: 0 });
60
+ const moveFocusToPage = (0, import_react.useCallback)(
61
+ (page) => {
62
+ const targetPage = clampPage(page);
63
+ trackFocusOption(targetPage);
64
+ listActionRef.current.scrollTo?.(targetPage - 1, { align: "auto" });
65
+ },
66
+ [clampPage, listActionRef, trackFocusOption]
67
+ );
68
+ const commitPage = (0, import_react.useCallback)(
69
+ (page) => {
70
+ if (page !== pageIndex) onPageChange(page);
71
+ setIsOpen(false);
72
+ trackFocusTrigger();
73
+ },
74
+ [onPageChange, pageIndex, 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 (amountOfPages === 0) return;
85
+ setIsOpen(true);
86
+ trackFocusSelectedOption();
87
+ },
88
+ [amountOfPages, globalAttributes.onClick, isOpen, 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 || amountOfPages === 0) return;
95
+ e.preventDefault();
96
+ setIsOpen(true);
97
+ trackFocusSelectedOption();
98
+ },
99
+ [amountOfPages, globalAttributes.onKeyDown, isOpen, 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
+ if (focusedPage !== null && focusedPage !== pageIndex) onPageChange(focusedPage);
107
+ setIsOpen(false);
108
+ },
109
+ [focusedPage, onPageChange, pageIndex, setIsOpen, trackFocusRegionReset, triggerRef]
110
+ );
111
+ const handleDigitTypeahead = (0, import_react.useCallback)(
112
+ (digit) => {
113
+ if (typeof pageCount === "string") return;
114
+ const now = Date.now();
115
+ const typeahead = typeaheadRef.current;
116
+ if (now - typeahead.lastKeyTimestamp > import_constants.PAGINATOR_TYPEAHEAD_RESET_MS) typeahead.buffer = "";
117
+ typeahead.buffer += digit;
118
+ typeahead.lastKeyTimestamp = now;
119
+ const targetPage = Number.parseInt(typeahead.buffer, 10);
120
+ if (targetPage >= 1 && targetPage <= amountOfPages) moveFocusToPage(targetPage);
121
+ },
122
+ [amountOfPages, moveFocusToPage, pageCount]
123
+ );
124
+ const handlePanelKeyDown = (0, import_react.useCallback)(
125
+ (e) => {
126
+ if (e.ctrlKey || e.metaKey || e.altKey) return;
127
+ const getTargetPage = import_navigationKeys.NAVIGATION_KEYS[e.key];
128
+ if (getTargetPage) {
129
+ e.preventDefault();
130
+ moveFocusToPage(getTargetPage(focusedPage ?? pageIndex, amountOfPages));
131
+ return;
132
+ }
133
+ if (e.key === "Enter" || e.key === " ") {
134
+ e.preventDefault();
135
+ if (focusedPage !== null) commitPage(focusedPage);
136
+ return;
137
+ }
138
+ if (DIGIT_REGEXP.test(e.key)) handleDigitTypeahead(e.key);
139
+ },
140
+ [amountOfPages, commitPage, focusedPage, handleDigitTypeahead, moveFocusToPage, pageIndex]
141
+ );
142
+ const handleBlurOutOfWidget = (0, import_react.useCallback)(
143
+ (e) => {
144
+ const nextFocused = e.relatedTarget;
145
+ if (!nextFocused) return;
146
+ if (triggerRef.current?.contains(nextFocused) || floatingNodeRef.current?.contains(nextFocused)) return;
147
+ trackFocusRegionReset();
148
+ },
149
+ [floatingNodeRef, trackFocusRegionReset, triggerRef]
150
+ );
151
+ return (0, import_react.useMemo)(
152
+ () => ({
153
+ commitPage,
154
+ handleTriggerClick,
155
+ handleTriggerKeyDown,
156
+ handlePanelKeyDown,
157
+ handlePanelKeyDownCapture,
158
+ handleBlurOutOfWidget
159
+ }),
160
+ [
161
+ commitPage,
162
+ handleTriggerClick,
163
+ handleTriggerKeyDown,
164
+ handlePanelKeyDown,
165
+ handlePanelKeyDownCapture,
166
+ handleBlurOutOfWidget
167
+ ]
168
+ );
169
+ };
170
+ //# sourceMappingURL=usePaginatorInteractions.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/parts/DSPaginator/config/usePaginatorInteractions.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 { PAGINATOR_TYPEAHEAD_RESET_MS } from '../constants/index.js';\nimport { NAVIGATION_KEYS } from './navigationKeys.js';\nimport type { DSPaginatorT } from '../react-desc-prop-types.js';\nimport type { useFocusTracker } from './useFocusTracker.js';\n\ntype InteractionsConfigT = {\n propsWithDefault: DSPaginatorT.InternalProps;\n globalAttributes: { onClick?: unknown; onKeyDown?: unknown };\n isOpen: boolean;\n setIsOpen: React.Dispatch<React.SetStateAction<boolean>>;\n amountOfPages: number;\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 DIGIT_REGEXP = /^[0-9]$/;\n\n/**\n * Every user intent on the trigger and on the list. The selection model is the one of a native select:\n * - moving through the options (arrows, Home/End, PageUp/PageDown, typing a page number) only moves the focus:\n * `onPageChange` is NOT invoked while navigating, because committing a page is a costly side effect for a paginator\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 usePaginatorFloatingContext) 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 usePaginatorInteractions = ({\n propsWithDefault,\n globalAttributes,\n isOpen,\n setIsOpen,\n amountOfPages,\n focusTrackers,\n triggerRef,\n floatingNodeRef,\n listActionRef,\n}: InteractionsConfigT) => {\n const { pageIndex, pageCount, onPageChange } = propsWithDefault;\n const {\n focusedPage,\n clampPage,\n trackFocusOption,\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 moveFocusToPage = useCallback(\n (page: number) => {\n const targetPage = clampPage(page);\n trackFocusOption(targetPage);\n listActionRef.current.scrollTo?.(targetPage - 1, { align: 'auto' });\n },\n [clampPage, listActionRef, trackFocusOption],\n );\n\n const commitPage = useCallback(\n (page: number) => {\n if (page !== pageIndex) onPageChange(page);\n setIsOpen(false);\n trackFocusTrigger();\n },\n [onPageChange, pageIndex, 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 (amountOfPages === 0) return;\n setIsOpen(true);\n trackFocusSelectedOption();\n },\n [amountOfPages, globalAttributes.onClick, isOpen, setIsOpen, trackFocusSelectedOption, trackFocusTrigger],\n );\n\n // ArrowDown / ArrowUp on the trigger open the list (same as the select-only combobox and the 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 || amountOfPages === 0) return;\n e.preventDefault();\n setIsOpen(true);\n trackFocusSelectedOption();\n },\n [amountOfPages, globalAttributes.onKeyDown, isOpen, 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 ds-menu-button's `handleMenuTabKeyDownCapture` (see its KNOWN_INTENTIONAL_DEVIATIONS.md).\n * 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 if (focusedPage !== null && focusedPage !== pageIndex) onPageChange(focusedPage);\n setIsOpen(false);\n },\n [focusedPage, onPageChange, pageIndex, setIsOpen, trackFocusRegionReset, triggerRef],\n );\n\n const handleDigitTypeahead = useCallback(\n (digit: string) => {\n // an unknown page count (string) only exposes the pages up to the next one: nothing meaningful to type\n if (typeof pageCount === 'string') return;\n const now = Date.now();\n const typeahead = typeaheadRef.current;\n if (now - typeahead.lastKeyTimestamp > PAGINATOR_TYPEAHEAD_RESET_MS) typeahead.buffer = '';\n typeahead.buffer += digit;\n typeahead.lastKeyTimestamp = now;\n const targetPage = Number.parseInt(typeahead.buffer, 10);\n if (targetPage >= 1 && targetPage <= amountOfPages) moveFocusToPage(targetPage);\n },\n [amountOfPages, moveFocusToPage, pageCount],\n );\n\n const handlePanelKeyDown = useCallback(\n (e: React.KeyboardEvent<HTMLElement>) => {\n if (e.ctrlKey || e.metaKey || e.altKey) return;\n const getTargetPage = NAVIGATION_KEYS[e.key];\n if (getTargetPage) {\n e.preventDefault(); // the list scrolls through the virtualizer, not through the browser\n moveFocusToPage(getTargetPage(focusedPage ?? pageIndex, amountOfPages));\n return;\n }\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n if (focusedPage !== null) commitPage(focusedPage);\n return;\n }\n if (DIGIT_REGEXP.test(e.key)) handleDigitTypeahead(e.key);\n },\n [amountOfPages, commitPage, focusedPage, handleDigitTypeahead, moveFocusToPage, pageIndex],\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 commitPage,\n handleTriggerClick,\n handleTriggerKeyDown,\n handlePanelKeyDown,\n handlePanelKeyDownCapture,\n handleBlurOutOfWidget,\n }),\n [\n commitPage,\n handleTriggerClick,\n handleTriggerKeyDown,\n handlePanelKeyDown,\n handlePanelKeyDownCapture,\n handleBlurOutOfWidget,\n ],\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADEvB,mBAA6C;AAC7C,uBAA6C;AAC7C,4BAAgC;AAgBhC,MAAM,eAAe;AAYd,MAAM,2BAA2B,CAAC;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAA2B;AACzB,QAAM,EAAE,WAAW,WAAW,aAAa,IAAI;AAC/C,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI;AACJ,QAAM,mBAAe,qBAAO,EAAE,QAAQ,IAAI,kBAAkB,EAAE,CAAC;AAI/D,QAAM,sBAAkB;AAAA,IACtB,CAAC,SAAiB;AAChB,YAAM,aAAa,UAAU,IAAI;AACjC,uBAAiB,UAAU;AAC3B,oBAAc,QAAQ,WAAW,aAAa,GAAG,EAAE,OAAO,OAAO,CAAC;AAAA,IACpE;AAAA,IACA,CAAC,WAAW,eAAe,gBAAgB;AAAA,EAC7C;AAEA,QAAM,iBAAa;AAAA,IACjB,CAAC,SAAiB;AAChB,UAAI,SAAS,UAAW,cAAa,IAAI;AACzC,gBAAU,KAAK;AACf,wBAAkB;AAAA,IACpB;AAAA,IACA,CAAC,cAAc,WAAW,WAAW,iBAAiB;AAAA,EACxD;AAEA,QAAM,yBAAqB;AAAA,IACzB,CAAC,MAAoF;AACnF,MAAC,iBAAiB,UAAsD,CAAC;AACzE,UAAI,QAAQ;AACV,kBAAU,KAAK;AACf,0BAAkB;AAClB;AAAA,MACF;AACA,UAAI,kBAAkB,EAAG;AACzB,gBAAU,IAAI;AACd,+BAAyB;AAAA,IAC3B;AAAA,IACA,CAAC,eAAe,iBAAiB,SAAS,QAAQ,WAAW,0BAA0B,iBAAiB;AAAA,EAC1G;AAIA,QAAM,2BAAuB;AAAA,IAC3B,CAAC,MAA8C;AAC7C,MAAC,iBAAiB,YAA0E,CAAC;AAC7F,UAAI,EAAE,QAAQ,eAAe,EAAE,QAAQ,UAAW;AAClD,UAAI,UAAU,kBAAkB,EAAG;AACnC,QAAE,eAAe;AACjB,gBAAU,IAAI;AACd,+BAAyB;AAAA,IAC3B;AAAA,IACA,CAAC,eAAe,iBAAiB,WAAW,QAAQ,WAAW,wBAAwB;AAAA,EACzF;AAWA,QAAM,gCAA4B;AAAA,IAChC,CAAC,MAAwC;AACvC,UAAI,EAAE,QAAQ,MAAO;AACrB,iBAAW,SAAS,MAAM;AAC1B,4BAAsB;AACtB,UAAI,gBAAgB,QAAQ,gBAAgB,UAAW,cAAa,WAAW;AAC/E,gBAAU,KAAK;AAAA,IACjB;AAAA,IACA,CAAC,aAAa,cAAc,WAAW,WAAW,uBAAuB,UAAU;AAAA,EACrF;AAEA,QAAM,2BAAuB;AAAA,IAC3B,CAAC,UAAkB;AAEjB,UAAI,OAAO,cAAc,SAAU;AACnC,YAAM,MAAM,KAAK,IAAI;AACrB,YAAM,YAAY,aAAa;AAC/B,UAAI,MAAM,UAAU,mBAAmB,8CAA8B,WAAU,SAAS;AACxF,gBAAU,UAAU;AACpB,gBAAU,mBAAmB;AAC7B,YAAM,aAAa,OAAO,SAAS,UAAU,QAAQ,EAAE;AACvD,UAAI,cAAc,KAAK,cAAc,cAAe,iBAAgB,UAAU;AAAA,IAChF;AAAA,IACA,CAAC,eAAe,iBAAiB,SAAS;AAAA,EAC5C;AAEA,QAAM,yBAAqB;AAAA,IACzB,CAAC,MAAwC;AACvC,UAAI,EAAE,WAAW,EAAE,WAAW,EAAE,OAAQ;AACxC,YAAM,gBAAgB,sCAAgB,EAAE,GAAG;AAC3C,UAAI,eAAe;AACjB,UAAE,eAAe;AACjB,wBAAgB,cAAc,eAAe,WAAW,aAAa,CAAC;AACtE;AAAA,MACF;AACA,UAAI,EAAE,QAAQ,WAAW,EAAE,QAAQ,KAAK;AACtC,UAAE,eAAe;AACjB,YAAI,gBAAgB,KAAM,YAAW,WAAW;AAChD;AAAA,MACF;AACA,UAAI,aAAa,KAAK,EAAE,GAAG,EAAG,sBAAqB,EAAE,GAAG;AAAA,IAC1D;AAAA,IACA,CAAC,eAAe,YAAY,aAAa,sBAAsB,iBAAiB,SAAS;AAAA,EAC3F;AASA,QAAM,4BAAwB;AAAA,IAC5B,CAAC,MAAqC;AACpC,YAAM,cAAc,EAAE;AACtB,UAAI,CAAC,YAAa;AAClB,UAAI,WAAW,SAAS,SAAS,WAAW,KAAK,gBAAgB,SAAS,SAAS,WAAW,EAAG;AACjG,4BAAsB;AAAA,IACxB;AAAA,IACA,CAAC,iBAAiB,uBAAuB,UAAU;AAAA,EACrD;AAEA,aAAO;AAAA,IACL,OAAO;AAAA,MACL;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,IACF;AAAA,EACF;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,80 @@
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 usePaginatorSizing_exports = {};
30
+ __export(usePaginatorSizing_exports, {
31
+ usePaginatorSizing: () => usePaginatorSizing
32
+ });
33
+ module.exports = __toCommonJS(usePaginatorSizing_exports);
34
+ var React = __toESM(require("react"));
35
+ var import_react = require("react");
36
+ var import_useOnElementOnResize = require("../../shared/useOnElementOnResize.js");
37
+ var import_constants = require("../constants/index.js");
38
+ const toCssLength = (value) => typeof value === "number" ? `${value}px` : value;
39
+ const usePaginatorSizing = ({
40
+ pageCount,
41
+ pageIndex,
42
+ pageDetails,
43
+ listWidth,
44
+ chevronRef,
45
+ pageInfoRef,
46
+ listActionRef
47
+ }) => {
48
+ const { width: chevronWidth } = (0, import_useOnElementOnResize.useOnElementResize)(chevronRef);
49
+ const { width: pageInfoWidth } = (0, import_useOnElementOnResize.useOnElementResize)(pageInfoRef);
50
+ const hasDetails = pageDetails.length !== 0;
51
+ const configuredWidth = (0, import_react.useMemo)(() => {
52
+ if (listWidth !== void 0) return toCssLength(listWidth);
53
+ return hasDetails ? `${import_constants.PAGINATOR_DEFAULT_LIST_WIDTH}px` : void 0;
54
+ }, [hasDetails, listWidth]);
55
+ const cappedWidth = configuredWidth ? `min(${configuredWidth}, calc(100vw - ${import_constants.PAGINATOR_VIEWPORT_MARGIN}px))` : void 0;
56
+ const panelStyle = (0, import_react.useMemo)(
57
+ () => cappedWidth ? { width: cappedWidth } : { minWidth: `calc(${chevronWidth + 60}px + ${pageCount.toString().length}ch)` },
58
+ [cappedWidth, chevronWidth, pageCount]
59
+ );
60
+ const listMaxHeight = import_constants.PAGINATOR_PANEL_MAX_HEIGHT - import_constants.PAGINATOR_HEADER_HEIGHT - import_constants.PAGINATOR_PANEL_PADDING_BOTTOM;
61
+ const handleListWrapperRef = (0, import_react.useCallback)(
62
+ (node) => {
63
+ if (node) listActionRef.current.scrollTo?.(pageIndex - 1, { align: "center" });
64
+ },
65
+ [listActionRef, pageIndex]
66
+ );
67
+ return (0, import_react.useMemo)(
68
+ () => ({
69
+ hasDetails,
70
+ chevronWidth,
71
+ pageInfoWidth,
72
+ panelStyle,
73
+ detailMaxWidth: cappedWidth,
74
+ listMaxHeight,
75
+ handleListWrapperRef
76
+ }),
77
+ [hasDetails, chevronWidth, pageInfoWidth, panelStyle, cappedWidth, listMaxHeight, handleListWrapperRef]
78
+ );
79
+ };
80
+ //# sourceMappingURL=usePaginatorSizing.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/parts/DSPaginator/config/usePaginatorSizing.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 } from 'react';\nimport { useOnElementResize } from '../../shared/useOnElementOnResize.js';\nimport {\n PAGINATOR_DEFAULT_LIST_WIDTH,\n PAGINATOR_HEADER_HEIGHT,\n PAGINATOR_PANEL_MAX_HEIGHT,\n PAGINATOR_PANEL_PADDING_BOTTOM,\n PAGINATOR_VIEWPORT_MARGIN,\n} from '../constants/index.js';\n\ntype SizingConfigT = {\n pageCount: number | string;\n pageIndex: number;\n pageDetails: string[] | readonly string[];\n listWidth?: number | string;\n chevronRef: React.RefObject<HTMLElement>;\n pageInfoRef: React.RefObject<HTMLDivElement>;\n listActionRef: React.MutableRefObject<DSFastListT.ActionRef>;\n};\n\nconst toCssLength = (value: number | string) => (typeof value === 'number' ? `${value}px` : value);\n\n/**\n * Everything about sizes. The rows of the list are virtualized (out of flow), so nothing inside the list can make the panel\n * grow: its width is an explicit policy, not something derived from its content.\n * - with `pageDetails` (or when the consumer passes `listWidth`) the list is `listWidth` wide (280px by default), never wider\n * than the viewport, and the details WRAP inside it. Nothing here renders or measures every detail: that would be O(n) hidden\n * components just to size the list to the widest detail, and it forced a one-line (truncating) design.\n * - without details the list is as wide as its page numbers need (the previous formula: chevron + 60px + the digits of the\n * page count in `ch`), plain CSS.\n * The trigger does not reserve the width of the widest detail either: it follows the detail of the current page.\n */\nexport const usePaginatorSizing = ({\n pageCount,\n pageIndex,\n pageDetails,\n listWidth,\n chevronRef,\n pageInfoRef,\n listActionRef,\n}: SizingConfigT) => {\n const { width: chevronWidth } = useOnElementResize(chevronRef);\n const { width: pageInfoWidth } = useOnElementResize(pageInfoRef);\n const hasDetails = pageDetails.length !== 0;\n\n const configuredWidth = useMemo(() => {\n if (listWidth !== undefined) return toCssLength(listWidth);\n return hasDetails ? `${PAGINATOR_DEFAULT_LIST_WIDTH}px` : undefined;\n }, [hasDetails, listWidth]);\n const cappedWidth = configuredWidth\n ? `min(${configuredWidth}, calc(100vw - ${PAGINATOR_VIEWPORT_MARGIN}px))`\n : undefined;\n const panelStyle = useMemo(\n () =>\n cappedWidth\n ? { width: cappedWidth }\n : { minWidth: `calc(${chevronWidth + 60}px + ${pageCount.toString().length}ch)` },\n [cappedWidth, chevronWidth, pageCount],\n );\n // the tallest the scrolling list gets: the rows can wrap, so the list is as tall as its rows up to this maximum\n const listMaxHeight = PAGINATOR_PANEL_MAX_HEIGHT - PAGINATOR_HEADER_HEIGHT - PAGINATOR_PANEL_PADDING_BOTTOM;\n\n /*\n * The virtual list mounts at scroll offset 0, but the selected page (where the focus must land on open) can be\n * anywhere, and the virtualizer resets its scroll element to its initial offset when it binds to it (measured: a\n * `scrollTop` set when the container mounts is overwritten with 0). So the list is told to scroll once it is bound:\n * React attaches the ref callbacks child first, so this one, on the element that wraps the list, runs after the list's\n * own layout effects (no effect, no timer). The selected option then mounts in range and focuses itself (focus tracker).\n * The callback changes only when `pageIndex` changes, which closes the list.\n */\n const handleListWrapperRef = useCallback(\n (node: HTMLDivElement | null) => {\n if (node) listActionRef.current.scrollTo?.(pageIndex - 1, { align: 'center' });\n },\n [listActionRef, pageIndex],\n );\n\n return useMemo(\n () => ({\n hasDetails,\n chevronWidth,\n pageInfoWidth,\n panelStyle,\n detailMaxWidth: cappedWidth,\n listMaxHeight,\n handleListWrapperRef,\n }),\n [hasDetails, chevronWidth, pageInfoWidth, panelStyle, cappedWidth, listMaxHeight, handleListWrapperRef],\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADEvB,mBAAqC;AACrC,kCAAmC;AACnC,uBAMO;AAYP,MAAM,cAAc,CAAC,UAA4B,OAAO,UAAU,WAAW,GAAG,KAAK,OAAO;AAYrF,MAAM,qBAAqB,CAAC;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAqB;AACnB,QAAM,EAAE,OAAO,aAAa,QAAI,gDAAmB,UAAU;AAC7D,QAAM,EAAE,OAAO,cAAc,QAAI,gDAAmB,WAAW;AAC/D,QAAM,aAAa,YAAY,WAAW;AAE1C,QAAM,sBAAkB,sBAAQ,MAAM;AACpC,QAAI,cAAc,OAAW,QAAO,YAAY,SAAS;AACzD,WAAO,aAAa,GAAG,6CAA4B,OAAO;AAAA,EAC5D,GAAG,CAAC,YAAY,SAAS,CAAC;AAC1B,QAAM,cAAc,kBAChB,OAAO,eAAe,kBAAkB,0CAAyB,SACjE;AACJ,QAAM,iBAAa;AAAA,IACjB,MACE,cACI,EAAE,OAAO,YAAY,IACrB,EAAE,UAAU,QAAQ,eAAe,EAAE,QAAQ,UAAU,SAAS,EAAE,MAAM,MAAM;AAAA,IACpF,CAAC,aAAa,cAAc,SAAS;AAAA,EACvC;AAEA,QAAM,gBAAgB,8CAA6B,2CAA0B;AAU7E,QAAM,2BAAuB;AAAA,IAC3B,CAAC,SAAgC;AAC/B,UAAI,KAAM,eAAc,QAAQ,WAAW,YAAY,GAAG,EAAE,OAAO,SAAS,CAAC;AAAA,IAC/E;AAAA,IACA,CAAC,eAAe,SAAS;AAAA,EAC3B;AAEA,aAAO;AAAA,IACL,OAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,gBAAgB;AAAA,MAChB;AAAA,MACA;AAAA,IACF;AAAA,IACA,CAAC,YAAY,cAAc,eAAe,YAAY,aAAa,eAAe,oBAAoB;AAAA,EACxG;AACF;",
6
+ "names": []
7
+ }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/parts/DSPaginator/config/useValidateProps.ts", "../../../../../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["import { useValidateTypescriptPropTypes } from '@elliemae/ds-props-helpers';\nimport type { ValidationMap } from '@elliemae/ds-props-helpers';\nimport { type DSPaginatorT } from '../react-desc-prop-types.js';\nimport { DSPaginatorName } from '../constants/index.js';\n\nexport const useValidateProps = (\n props: DSPaginatorT.InternalProps,\n propTypes: ValidationMap<DSPaginatorT.Props>,\n): void => {\n // we validate the \"required if\" via 'isRequiredIf from our custom PropTypes\n useValidateTypescriptPropTypes(props, propTypes, DSPaginatorName);\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,8BAA+C;AAG/C,uBAAgC;AAEzB,MAAM,mBAAmB,CAC9B,OACA,cACS;AAET,8DAA+B,OAAO,WAAW,gCAAe;AAClE;",
4
+ "sourcesContent": ["import { useValidateTypescriptPropTypes } from '@elliemae/ds-props-helpers';\nimport type { ValidationMap } from '@elliemae/ds-props-helpers';\nimport { type DSPaginatorT } from '../react-desc-prop-types.js';\nimport { DSPaginatorName } from '../constants/index.js';\n\nexport const useValidateProps = (\n props: DSPaginatorT.InternalProps,\n propTypes: ValidationMap<DSPaginatorT.Props>,\n): void => {\n useValidateTypescriptPropTypes(props, propTypes, DSPaginatorName);\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,8BAA+C;AAG/C,uBAAgC;AAEzB,MAAM,mBAAmB,CAC9B,OACA,cACS;AACT,8DAA+B,OAAO,WAAW,gCAAe;AAClE;",
6
6
  "names": []
7
7
  }