@elliemae/ds-pagination 3.80.0-next.50 → 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,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/parts/DSPerPageSelector/config/useFocusTracker.ts"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "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"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,aAAa,SAAS,gBAAgB;AAC/C,SAAS,wCAAwC;AAEjD,SAAS,8BAA8B;AAQhC,MAAM,oBAAoB,CAAC,SAAiB,GAAG,iCAAiC,aAAa,GAAG,IAAI;AAOpG,MAAM,kBAAkB,CAAC,EAAE,SAAS,SAAS,MAA2B;AAC7E,QAAM,CAAC,aAAa,cAAc,IAAI,SAAiB,iCAAiC,KAAK;AAE7F,QAAM,eAAe;AAAA,IACnB,MAAM,QAAQ,UAAU,CAAC,WAAW,kBAAkB,OAAO,IAAI,MAAM,WAAW;AAAA,IAClF,CAAC,aAAa,OAAO;AAAA,EACvB;AAEA,QAAM,aAAa,YAAY,CAAC,UAAkB,KAAK,IAAI,KAAK,IAAI,OAAO,CAAC,GAAG,QAAQ,SAAS,CAAC,GAAG,CAAC,QAAQ,MAAM,CAAC;AAEpH,QAAM,wBAAwB,YAAY,MAAM,eAAe,iCAAiC,KAAK,GAAG,CAAC,CAAC;AAC1G,QAAM,oBAAoB,YAAY,MAAM,eAAe,iCAAiC,OAAO,GAAG,CAAC,CAAC;AACxG,QAAM,0BAA0B;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,mBAAmB,YAAY,CAAC,SAAiB,eAAe,kBAAkB,IAAI,CAAC,GAAG,CAAC,CAAC;AAElG,QAAM,2BAA2B;AAAA,IAC/B,MAAM,wBAAwB,KAAK,IAAI,uBAAuB,SAAS,QAAQ,GAAG,CAAC,CAAC;AAAA,IACpF,CAAC,SAAS,UAAU,uBAAuB;AAAA,EAC7C;AAEA,SAAO;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
|
+
}
|
|
@@ -5,48 +5,96 @@ import {
|
|
|
5
5
|
useMemoMergePropsWithDefault,
|
|
6
6
|
useOwnerProps
|
|
7
7
|
} from "@elliemae/ds-props-helpers";
|
|
8
|
-
import React2, {
|
|
8
|
+
import React2, { useMemo, useRef, useState } from "react";
|
|
9
|
+
import { uid } from "uid";
|
|
9
10
|
import { DSPerPageSelectorPropTypesSchema, defaultProps } from "../react-desc-prop-types.js";
|
|
10
|
-
import { useValidateProps } from "./useValidateProps.js";
|
|
11
11
|
import { generateOption, getOptions } from "./getOptions.js";
|
|
12
|
-
import {
|
|
12
|
+
import { getDialogId, getHeaderId, getListId } from "./getInstanceIds.js";
|
|
13
|
+
import { useFocusTracker } from "./useFocusTracker.js";
|
|
14
|
+
import { usePerPageSelectorFloatingContext } from "./usePerPageSelectorFloatingContext.js";
|
|
15
|
+
import { usePerPageSelectorInteractions } from "./usePerPageSelectorInteractions.js";
|
|
16
|
+
import { usePerPageSelectorSizing } from "./usePerPageSelectorSizing.js";
|
|
17
|
+
import { useValidateProps } from "./useValidateProps.js";
|
|
13
18
|
const usePerPageSelector = (propsFromUser) => {
|
|
14
19
|
const propsWithDefault = useMemoMergePropsWithDefault(propsFromUser, defaultProps);
|
|
15
20
|
useValidateProps(propsWithDefault, DSPerPageSelectorPropTypesSchema);
|
|
16
21
|
const xstyledProps = useGetXstyledProps(propsWithDefault);
|
|
17
22
|
const globalAttributes = useGetGlobalAttributes(propsWithDefault);
|
|
18
23
|
const ownerPropsConfig = useOwnerProps(propsWithDefault);
|
|
19
|
-
const { pageSize, perPageOptions, perPageStep, minPerPage, maxPerPage } = propsWithDefault;
|
|
20
|
-
const
|
|
24
|
+
const { pageSize, perPageOptions, perPageStep, minPerPage, maxPerPage, listWidth } = propsWithDefault;
|
|
25
|
+
const instanceUid = useMemo(() => uid(5), []);
|
|
26
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
21
27
|
const options = useMemo(() => {
|
|
22
28
|
if (perPageOptions) return perPageOptions.map(generateOption);
|
|
23
29
|
return getOptions(perPageStep, minPerPage, maxPerPage);
|
|
24
30
|
}, [maxPerPage, minPerPage, perPageOptions, perPageStep]);
|
|
25
|
-
const
|
|
26
|
-
const btnRef = useRef(null);
|
|
31
|
+
const triggerRef = useRef(null);
|
|
27
32
|
const chevronRef = useRef(null);
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
const listActionRef = useRef({});
|
|
34
|
+
const sizing = usePerPageSelectorSizing({ pageSize, options, listWidth, chevronRef, listActionRef });
|
|
35
|
+
const focusTrackers = useFocusTracker({ options, pageSize });
|
|
36
|
+
const { floatingStyles, floatingContext, handleTriggerRef, floatingInnerRef, floatingNodeRef } = usePerPageSelectorFloatingContext({
|
|
37
|
+
isOpen,
|
|
38
|
+
setIsOpen,
|
|
39
|
+
triggerRef,
|
|
40
|
+
trackFocusRegionReset: focusTrackers.trackFocusRegionReset,
|
|
41
|
+
chevronWidth: sizing.chevronWidth
|
|
42
|
+
});
|
|
43
|
+
const interactions = usePerPageSelectorInteractions({
|
|
44
|
+
propsWithDefault,
|
|
45
|
+
globalAttributes,
|
|
46
|
+
options,
|
|
47
|
+
isOpen,
|
|
48
|
+
setIsOpen,
|
|
49
|
+
focusTrackers,
|
|
50
|
+
triggerRef,
|
|
51
|
+
floatingNodeRef,
|
|
52
|
+
listActionRef
|
|
53
|
+
});
|
|
54
|
+
const ids = useMemo(
|
|
55
|
+
() => ({
|
|
56
|
+
headerId: getHeaderId(instanceUid),
|
|
57
|
+
listId: getListId(instanceUid),
|
|
58
|
+
dialogId: getDialogId(instanceUid)
|
|
59
|
+
}),
|
|
60
|
+
[instanceUid]
|
|
61
|
+
);
|
|
35
62
|
return React2.useMemo(
|
|
36
63
|
() => ({
|
|
37
64
|
propsWithDefault,
|
|
38
65
|
xstyledProps,
|
|
39
66
|
globalAttributes,
|
|
40
67
|
ownerPropsConfig,
|
|
41
|
-
|
|
42
|
-
btnRef,
|
|
43
|
-
chevronRef,
|
|
44
|
-
chevronWidth,
|
|
45
|
-
isOpened,
|
|
68
|
+
isOpen,
|
|
46
69
|
options,
|
|
47
|
-
|
|
70
|
+
focusTrackers,
|
|
71
|
+
triggerRef,
|
|
72
|
+
chevronRef,
|
|
73
|
+
listActionRef,
|
|
74
|
+
floatingStyles,
|
|
75
|
+
floatingContext,
|
|
76
|
+
handleTriggerRef,
|
|
77
|
+
floatingInnerRef,
|
|
78
|
+
...sizing,
|
|
79
|
+
...ids,
|
|
80
|
+
...interactions
|
|
48
81
|
}),
|
|
49
|
-
[
|
|
82
|
+
[
|
|
83
|
+
propsWithDefault,
|
|
84
|
+
xstyledProps,
|
|
85
|
+
globalAttributes,
|
|
86
|
+
ownerPropsConfig,
|
|
87
|
+
isOpen,
|
|
88
|
+
options,
|
|
89
|
+
focusTrackers,
|
|
90
|
+
floatingStyles,
|
|
91
|
+
floatingContext,
|
|
92
|
+
handleTriggerRef,
|
|
93
|
+
floatingInnerRef,
|
|
94
|
+
sizing,
|
|
95
|
+
ids,
|
|
96
|
+
interactions
|
|
97
|
+
]
|
|
50
98
|
);
|
|
51
99
|
};
|
|
52
100
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/parts/DSPerPageSelector/config/usePerPageSelector.ts"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "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,YAAY,WAAW;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "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"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACEvB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,OAAOA,UAAS,SAAS,QAAQ,gBAAgB;AACjD,SAAS,WAAW;AACpB,SAAkC,kCAAkC,oBAAoB;AACxF,SAAS,gBAAgB,kBAAkB;AAC3C,SAAS,aAAa,aAAa,iBAAiB;AACpD,SAAS,uBAAuB;AAChC,SAAS,yCAAyC;AAClD,SAAS,sCAAsC;AAC/C,SAAS,gCAAgC;AACzC,SAAS,wBAAwB;AAE1B,MAAM,qBAAqB,CAAC,kBAA4C;AAI7E,QAAM,mBAAmB,6BAA+D,eAAe,YAAY;AACnH,mBAAiB,kBAAkB,gCAAgC;AAInE,QAAM,eAAe,mBAAmB,gBAAgB;AAIxD,QAAM,mBAAmB,uBAIvB,gBAAgB;AAIlB,QAAM,mBAAmB,cAAc,gBAAgB;AAIvD,QAAM,EAAE,UAAU,gBAAgB,aAAa,YAAY,YAAY,UAAU,IAAI;AACrF,QAAM,cAAc,QAAQ,MAAM,IAAI,CAAC,GAAG,CAAC,CAAC;AAC5C,QAAM,CAAC,QAAQ,SAAS,IAAI,SAAS,KAAK;AAC1C,QAAM,UAAU,QAAQ,MAAM;AAC5B,QAAI,eAAgB,QAAO,eAAe,IAAI,cAAc;AAC5D,WAAO,WAAW,aAAa,YAAY,UAAU;AAAA,EACvD,GAAG,CAAC,YAAY,YAAY,gBAAgB,WAAW,CAAC;AAExD,QAAM,aAAa,OAAiC,IAAI;AACxD,QAAM,aAAa,OAAoB,IAAI;AAC3C,QAAM,gBAAgB,OAA8B,CAAC,CAAC;AAEtD,QAAM,SAAS,yBAAyB,EAAE,UAAU,SAAS,WAAW,YAAY,cAAc,CAAC;AAEnG,QAAM,gBAAgB,gBAAgB,EAAE,SAAS,SAAS,CAAC;AAE3D,QAAM,EAAE,gBAAgB,iBAAiB,kBAAkB,kBAAkB,gBAAgB,IAC3F,kCAAkC;AAAA,IAChC;AAAA,IACA;AAAA,IACA;AAAA,IACA,uBAAuB,cAAc;AAAA,IACrC,cAAc,OAAO;AAAA,EACvB,CAAC;AAEH,QAAM,eAAe,+BAA+B;AAAA,IAClD;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AAED,QAAM,MAAM;AAAA,IACV,OAAO;AAAA,MACL,UAAU,YAAY,WAAW;AAAA,MACjC,QAAQ,UAAU,WAAW;AAAA,MAC7B,UAAU,YAAY,WAAW;AAAA,IACnC;AAAA,IACA,CAAC,WAAW;AAAA,EACd;AAEA,SAAOA,OAAM;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,52 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { useFloatingContext } from "@elliemae/ds-floating-context";
|
|
3
|
+
import { useCallback, useMemo, useRef } from "react";
|
|
4
|
+
const usePerPageSelectorFloatingContext = ({
|
|
5
|
+
isOpen,
|
|
6
|
+
setIsOpen,
|
|
7
|
+
triggerRef,
|
|
8
|
+
trackFocusRegionReset,
|
|
9
|
+
chevronWidth
|
|
10
|
+
}) => {
|
|
11
|
+
const floatingNodeRef = useRef(null);
|
|
12
|
+
const handleClose = useCallback(() => {
|
|
13
|
+
setIsOpen(false);
|
|
14
|
+
trackFocusRegionReset();
|
|
15
|
+
}, [setIsOpen, trackFocusRegionReset]);
|
|
16
|
+
const floatingContextConfig = useMemo(
|
|
17
|
+
() => ({
|
|
18
|
+
// the previous DSPerPageSelector opened upwards (it lives in a footer) and aligned the selected value with the trigger
|
|
19
|
+
placement: "top-start",
|
|
20
|
+
placementOrderPreference: ["top-start", "bottom-start"],
|
|
21
|
+
customOffset: [-(chevronWidth + 7), 2],
|
|
22
|
+
externallyControlledIsOpen: isOpen,
|
|
23
|
+
withoutAnimation: true,
|
|
24
|
+
onClickOutside: handleClose,
|
|
25
|
+
closeOnEscape: true,
|
|
26
|
+
onEscape: handleClose,
|
|
27
|
+
returnFocusToReference: true,
|
|
28
|
+
externalReferenceElement: triggerRef.current
|
|
29
|
+
}),
|
|
30
|
+
[chevronWidth, handleClose, isOpen, triggerRef]
|
|
31
|
+
);
|
|
32
|
+
const { refs: floatingRefs, floatingStyles, context: floatingContext } = useFloatingContext(floatingContextConfig);
|
|
33
|
+
const handleTriggerRef = useCallback(
|
|
34
|
+
(node) => {
|
|
35
|
+
triggerRef.current = node;
|
|
36
|
+
floatingRefs.setReference(node);
|
|
37
|
+
},
|
|
38
|
+
[floatingRefs, triggerRef]
|
|
39
|
+
);
|
|
40
|
+
const floatingInnerRef = useCallback(
|
|
41
|
+
(node) => {
|
|
42
|
+
floatingNodeRef.current = node;
|
|
43
|
+
floatingRefs.setFloating(node);
|
|
44
|
+
},
|
|
45
|
+
[floatingRefs.setFloating]
|
|
46
|
+
);
|
|
47
|
+
return { floatingStyles, floatingContext, handleTriggerRef, floatingInnerRef, floatingNodeRef };
|
|
48
|
+
};
|
|
49
|
+
export {
|
|
50
|
+
usePerPageSelectorFloatingContext
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=usePerPageSelectorFloatingContext.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/parts/DSPerPageSelector/config/usePerPageSelectorFloatingContext.ts"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "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"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,0BAAuD;AAEhE,SAAS,aAAa,SAAS,cAAc;AAoBtC,MAAM,oCAAoC,CAAC;AAAA,EAChD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAA8B;AAC5B,QAAM,kBAAkB,OAA8B,IAAI;AAE1D,QAAM,cAAc,YAAY,MAAM;AACpC,cAAU,KAAK;AACf,0BAAsB;AAAA,EACxB,GAAG,CAAC,WAAW,qBAAqB,CAAC;AAErC,QAAM,wBAAwB;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,IAAI,mBAAmB,qBAAqB;AAEjH,QAAM,mBAAmB;AAAA,IACvB,CAAC,SAAS;AAER,iBAAW,UAAU;AACrB,mBAAa,aAAa,IAAI;AAAA,IAChC;AAAA,IACA,CAAC,cAAc,UAAU;AAAA,EAC3B;AAEA,QAAM,mBAAmB;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,145 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { useCallback, useMemo, useRef } from "react";
|
|
3
|
+
import { PER_PAGE_SELECTOR_TYPEAHEAD_RESET_MS } from "../constants/index.js";
|
|
4
|
+
import { NAVIGATION_KEYS } from "./navigationKeys.js";
|
|
5
|
+
const isPrintableCharacter = (key) => key.length === 1 && key !== " ";
|
|
6
|
+
const usePerPageSelectorInteractions = ({
|
|
7
|
+
propsWithDefault,
|
|
8
|
+
globalAttributes,
|
|
9
|
+
options,
|
|
10
|
+
isOpen,
|
|
11
|
+
setIsOpen,
|
|
12
|
+
focusTrackers,
|
|
13
|
+
triggerRef,
|
|
14
|
+
floatingNodeRef,
|
|
15
|
+
listActionRef
|
|
16
|
+
}) => {
|
|
17
|
+
const { pageSize, onPageSizeChange } = propsWithDefault;
|
|
18
|
+
const {
|
|
19
|
+
focusedIndex,
|
|
20
|
+
clampIndex,
|
|
21
|
+
trackFocusOptionAtIndex,
|
|
22
|
+
trackFocusSelectedOption,
|
|
23
|
+
trackFocusTrigger,
|
|
24
|
+
trackFocusRegionReset
|
|
25
|
+
} = focusTrackers;
|
|
26
|
+
const typeaheadRef = useRef({ buffer: "", lastKeyTimestamp: 0 });
|
|
27
|
+
const moveFocusToIndex = useCallback(
|
|
28
|
+
(index) => {
|
|
29
|
+
const targetIndex = clampIndex(index);
|
|
30
|
+
trackFocusOptionAtIndex(targetIndex);
|
|
31
|
+
listActionRef.current.scrollTo?.(targetIndex, { align: "auto" });
|
|
32
|
+
},
|
|
33
|
+
[clampIndex, listActionRef, trackFocusOptionAtIndex]
|
|
34
|
+
);
|
|
35
|
+
const commitOption = useCallback(
|
|
36
|
+
(option) => {
|
|
37
|
+
if (option.value !== pageSize) onPageSizeChange(option.value);
|
|
38
|
+
setIsOpen(false);
|
|
39
|
+
trackFocusTrigger();
|
|
40
|
+
},
|
|
41
|
+
[onPageSizeChange, pageSize, setIsOpen, trackFocusTrigger]
|
|
42
|
+
);
|
|
43
|
+
const handleTriggerClick = useCallback(
|
|
44
|
+
(e) => {
|
|
45
|
+
globalAttributes.onClick?.(e);
|
|
46
|
+
if (isOpen) {
|
|
47
|
+
setIsOpen(false);
|
|
48
|
+
trackFocusTrigger();
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
if (options.length === 0) return;
|
|
52
|
+
setIsOpen(true);
|
|
53
|
+
trackFocusSelectedOption();
|
|
54
|
+
},
|
|
55
|
+
[globalAttributes.onClick, isOpen, options.length, setIsOpen, trackFocusSelectedOption, trackFocusTrigger]
|
|
56
|
+
);
|
|
57
|
+
const handleTriggerKeyDown = useCallback(
|
|
58
|
+
(e) => {
|
|
59
|
+
globalAttributes.onKeyDown?.(e);
|
|
60
|
+
if (e.key !== "ArrowDown" && e.key !== "ArrowUp") return;
|
|
61
|
+
if (isOpen || options.length === 0) return;
|
|
62
|
+
e.preventDefault();
|
|
63
|
+
setIsOpen(true);
|
|
64
|
+
trackFocusSelectedOption();
|
|
65
|
+
},
|
|
66
|
+
[globalAttributes.onKeyDown, isOpen, options.length, setIsOpen, trackFocusSelectedOption]
|
|
67
|
+
);
|
|
68
|
+
const handlePanelKeyDownCapture = useCallback(
|
|
69
|
+
(e) => {
|
|
70
|
+
if (e.key !== "Tab") return;
|
|
71
|
+
triggerRef.current?.focus();
|
|
72
|
+
trackFocusRegionReset();
|
|
73
|
+
const focusedOption = options[focusedIndex];
|
|
74
|
+
if (focusedOption && focusedOption.value !== pageSize) {
|
|
75
|
+
onPageSizeChange(focusedOption.value);
|
|
76
|
+
}
|
|
77
|
+
setIsOpen(false);
|
|
78
|
+
},
|
|
79
|
+
[focusedIndex, onPageSizeChange, options, pageSize, setIsOpen, trackFocusRegionReset, triggerRef]
|
|
80
|
+
);
|
|
81
|
+
const handleTypeahead = useCallback(
|
|
82
|
+
(character) => {
|
|
83
|
+
const now = Date.now();
|
|
84
|
+
const typeahead = typeaheadRef.current;
|
|
85
|
+
const isNewSearch = now - typeahead.lastKeyTimestamp > PER_PAGE_SELECTOR_TYPEAHEAD_RESET_MS;
|
|
86
|
+
if (isNewSearch) typeahead.buffer = "";
|
|
87
|
+
typeahead.buffer += character.toLowerCase();
|
|
88
|
+
typeahead.lastKeyTimestamp = now;
|
|
89
|
+
const startIndex = isNewSearch ? focusedIndex + 1 : Math.max(focusedIndex, 0);
|
|
90
|
+
const ordered = [...options.slice(startIndex), ...options.slice(0, startIndex)];
|
|
91
|
+
const match = ordered.find((option) => option.label.toLowerCase().startsWith(typeahead.buffer));
|
|
92
|
+
if (match) moveFocusToIndex(options.indexOf(match));
|
|
93
|
+
},
|
|
94
|
+
[focusedIndex, moveFocusToIndex, options]
|
|
95
|
+
);
|
|
96
|
+
const handlePanelKeyDown = useCallback(
|
|
97
|
+
(e) => {
|
|
98
|
+
if (e.ctrlKey || e.metaKey || e.altKey) return;
|
|
99
|
+
const getTargetIndex = NAVIGATION_KEYS[e.key];
|
|
100
|
+
if (getTargetIndex) {
|
|
101
|
+
e.preventDefault();
|
|
102
|
+
moveFocusToIndex(getTargetIndex(Math.max(focusedIndex, 0), options.length));
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
106
|
+
e.preventDefault();
|
|
107
|
+
if (focusedIndex >= 0) commitOption(options[focusedIndex]);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
if (isPrintableCharacter(e.key)) handleTypeahead(e.key);
|
|
111
|
+
},
|
|
112
|
+
[commitOption, focusedIndex, handleTypeahead, moveFocusToIndex, options]
|
|
113
|
+
);
|
|
114
|
+
const handleBlurOutOfWidget = useCallback(
|
|
115
|
+
(e) => {
|
|
116
|
+
const nextFocused = e.relatedTarget;
|
|
117
|
+
if (!nextFocused) return;
|
|
118
|
+
if (triggerRef.current?.contains(nextFocused) || floatingNodeRef.current?.contains(nextFocused)) return;
|
|
119
|
+
trackFocusRegionReset();
|
|
120
|
+
},
|
|
121
|
+
[floatingNodeRef, trackFocusRegionReset, triggerRef]
|
|
122
|
+
);
|
|
123
|
+
return useMemo(
|
|
124
|
+
() => ({
|
|
125
|
+
commitOption,
|
|
126
|
+
handleTriggerClick,
|
|
127
|
+
handleTriggerKeyDown,
|
|
128
|
+
handlePanelKeyDown,
|
|
129
|
+
handlePanelKeyDownCapture,
|
|
130
|
+
handleBlurOutOfWidget
|
|
131
|
+
}),
|
|
132
|
+
[
|
|
133
|
+
commitOption,
|
|
134
|
+
handleTriggerClick,
|
|
135
|
+
handleTriggerKeyDown,
|
|
136
|
+
handlePanelKeyDown,
|
|
137
|
+
handlePanelKeyDownCapture,
|
|
138
|
+
handleBlurOutOfWidget
|
|
139
|
+
]
|
|
140
|
+
);
|
|
141
|
+
};
|
|
142
|
+
export {
|
|
143
|
+
usePerPageSelectorInteractions
|
|
144
|
+
};
|
|
145
|
+
//# sourceMappingURL=usePerPageSelectorInteractions.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/parts/DSPerPageSelector/config/usePerPageSelectorInteractions.ts"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "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"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACEvB,SAAS,aAAa,SAAS,cAAc;AAC7C,SAAS,4CAA4C;AAErD,SAAS,uBAAuB;AAehC,MAAM,uBAAuB,CAAC,QAAgB,IAAI,WAAW,KAAK,QAAQ;AAanE,MAAM,iCAAiC,CAAC;AAAA,EAC7C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAA2B;AACzB,QAAM,EAAE,UAAU,iBAAiB,IAAI;AACvC,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI;AACJ,QAAM,eAAe,OAAO,EAAE,QAAQ,IAAI,kBAAkB,EAAE,CAAC;AAI/D,QAAM,mBAAmB;AAAA,IACvB,CAAC,UAAkB;AACjB,YAAM,cAAc,WAAW,KAAK;AACpC,8BAAwB,WAAW;AACnC,oBAAc,QAAQ,WAAW,aAAa,EAAE,OAAO,OAAO,CAAC;AAAA,IACjE;AAAA,IACA,CAAC,YAAY,eAAe,uBAAuB;AAAA,EACrD;AAEA,QAAM,eAAe;AAAA,IACnB,CAAC,WAA6C;AAC5C,UAAI,OAAO,UAAU,SAAU,kBAAiB,OAAO,KAAK;AAC5D,gBAAU,KAAK;AACf,wBAAkB;AAAA,IACpB;AAAA,IACA,CAAC,kBAAkB,UAAU,WAAW,iBAAiB;AAAA,EAC3D;AAEA,QAAM,qBAAqB;AAAA,IACzB,CAAC,MAAoF;AACnF,MAAC,iBAAiB,UAAsD,CAAC;AACzE,UAAI,QAAQ;AACV,kBAAU,KAAK;AACf,0BAAkB;AAClB;AAAA,MACF;AACA,UAAI,QAAQ,WAAW,EAAG;AAC1B,gBAAU,IAAI;AACd,+BAAyB;AAAA,IAC3B;AAAA,IACA,CAAC,iBAAiB,SAAS,QAAQ,QAAQ,QAAQ,WAAW,0BAA0B,iBAAiB;AAAA,EAC3G;AAIA,QAAM,uBAAuB;AAAA,IAC3B,CAAC,MAA8C;AAC7C,MAAC,iBAAiB,YAA0E,CAAC;AAC7F,UAAI,EAAE,QAAQ,eAAe,EAAE,QAAQ,UAAW;AAClD,UAAI,UAAU,QAAQ,WAAW,EAAG;AACpC,QAAE,eAAe;AACjB,gBAAU,IAAI;AACd,+BAAyB;AAAA,IAC3B;AAAA,IACA,CAAC,iBAAiB,WAAW,QAAQ,QAAQ,QAAQ,WAAW,wBAAwB;AAAA,EAC1F;AAWA,QAAM,4BAA4B;AAAA,IAChC,CAAC,MAAwC;AACvC,UAAI,EAAE,QAAQ,MAAO;AACrB,iBAAW,SAAS,MAAM;AAC1B,4BAAsB;AACtB,YAAM,gBAAgB,QAAQ,YAAY;AAC1C,UAAI,iBAAiB,cAAc,UAAU,UAAU;AACrD,yBAAiB,cAAc,KAAK;AAAA,MACtC;AACA,gBAAU,KAAK;AAAA,IACjB;AAAA,IACA,CAAC,cAAc,kBAAkB,SAAS,UAAU,WAAW,uBAAuB,UAAU;AAAA,EAClG;AAIA,QAAM,kBAAkB;AAAA,IACtB,CAAC,cAAsB;AACrB,YAAM,MAAM,KAAK,IAAI;AACrB,YAAM,YAAY,aAAa;AAC/B,YAAM,cAAc,MAAM,UAAU,mBAAmB;AACvD,UAAI,YAAa,WAAU,SAAS;AACpC,gBAAU,UAAU,UAAU,YAAY;AAC1C,gBAAU,mBAAmB;AAC7B,YAAM,aAAa,cAAc,eAAe,IAAI,KAAK,IAAI,cAAc,CAAC;AAC5E,YAAM,UAAU,CAAC,GAAG,QAAQ,MAAM,UAAU,GAAG,GAAG,QAAQ,MAAM,GAAG,UAAU,CAAC;AAC9E,YAAM,QAAQ,QAAQ,KAAK,CAAC,WAAW,OAAO,MAAM,YAAY,EAAE,WAAW,UAAU,MAAM,CAAC;AAC9F,UAAI,MAAO,kBAAiB,QAAQ,QAAQ,KAAK,CAAC;AAAA,IACpD;AAAA,IACA,CAAC,cAAc,kBAAkB,OAAO;AAAA,EAC1C;AAEA,QAAM,qBAAqB;AAAA,IACzB,CAAC,MAAwC;AACvC,UAAI,EAAE,WAAW,EAAE,WAAW,EAAE,OAAQ;AACxC,YAAM,iBAAiB,gBAAgB,EAAE,GAAG;AAC5C,UAAI,gBAAgB;AAClB,UAAE,eAAe;AACjB,yBAAiB,eAAe,KAAK,IAAI,cAAc,CAAC,GAAG,QAAQ,MAAM,CAAC;AAC1E;AAAA,MACF;AACA,UAAI,EAAE,QAAQ,WAAW,EAAE,QAAQ,KAAK;AACtC,UAAE,eAAe;AACjB,YAAI,gBAAgB,EAAG,cAAa,QAAQ,YAAY,CAAC;AACzD;AAAA,MACF;AACA,UAAI,qBAAqB,EAAE,GAAG,EAAG,iBAAgB,EAAE,GAAG;AAAA,IACxD;AAAA,IACA,CAAC,cAAc,cAAc,iBAAiB,kBAAkB,OAAO;AAAA,EACzE;AASA,QAAM,wBAAwB;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,SAAO;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,42 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { useCallback, useMemo } from "react";
|
|
3
|
+
import { useOnElementResize } from "../../shared/useOnElementOnResize.js";
|
|
4
|
+
import {
|
|
5
|
+
PER_PAGE_SELECTOR_DEFAULT_LIST_WIDTH,
|
|
6
|
+
PER_PAGE_SELECTOR_HEADER_HEIGHT,
|
|
7
|
+
PER_PAGE_SELECTOR_PANEL_MAX_HEIGHT,
|
|
8
|
+
PER_PAGE_SELECTOR_PANEL_PADDING_BOTTOM,
|
|
9
|
+
PER_PAGE_SELECTOR_VIEWPORT_MARGIN
|
|
10
|
+
} from "../constants/index.js";
|
|
11
|
+
import { getSelectedOptionIndex } from "./getSelectedOptionIndex.js";
|
|
12
|
+
const toCssLength = (value) => typeof value === "number" ? `${value}px` : value;
|
|
13
|
+
const usePerPageSelectorSizing = ({
|
|
14
|
+
pageSize,
|
|
15
|
+
options,
|
|
16
|
+
listWidth,
|
|
17
|
+
chevronRef,
|
|
18
|
+
listActionRef
|
|
19
|
+
}) => {
|
|
20
|
+
const { width: chevronWidth } = useOnElementResize(chevronRef);
|
|
21
|
+
const configuredWidth = toCssLength(listWidth ?? PER_PAGE_SELECTOR_DEFAULT_LIST_WIDTH);
|
|
22
|
+
const panelStyle = useMemo(
|
|
23
|
+
() => ({ width: `min(${configuredWidth}, calc(100vw - ${PER_PAGE_SELECTOR_VIEWPORT_MARGIN}px))` }),
|
|
24
|
+
[configuredWidth]
|
|
25
|
+
);
|
|
26
|
+
const listMaxHeight = PER_PAGE_SELECTOR_PANEL_MAX_HEIGHT - PER_PAGE_SELECTOR_HEADER_HEIGHT - PER_PAGE_SELECTOR_PANEL_PADDING_BOTTOM;
|
|
27
|
+
const handleListWrapperRef = useCallback(
|
|
28
|
+
(node) => {
|
|
29
|
+
const selectedIndex = getSelectedOptionIndex(options, pageSize);
|
|
30
|
+
if (node && selectedIndex >= 0) listActionRef.current.scrollTo?.(selectedIndex, { align: "center" });
|
|
31
|
+
},
|
|
32
|
+
[listActionRef, options, pageSize]
|
|
33
|
+
);
|
|
34
|
+
return useMemo(
|
|
35
|
+
() => ({ chevronWidth, panelStyle, listMaxHeight, handleListWrapperRef }),
|
|
36
|
+
[chevronWidth, panelStyle, listMaxHeight, handleListWrapperRef]
|
|
37
|
+
);
|
|
38
|
+
};
|
|
39
|
+
export {
|
|
40
|
+
usePerPageSelectorSizing
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=usePerPageSelectorSizing.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/parts/DSPerPageSelector/config/usePerPageSelectorSizing.ts"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "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 PER_PAGE_SELECTOR_DEFAULT_LIST_WIDTH,\n PER_PAGE_SELECTOR_HEADER_HEIGHT,\n PER_PAGE_SELECTOR_PANEL_MAX_HEIGHT,\n PER_PAGE_SELECTOR_PANEL_PADDING_BOTTOM,\n PER_PAGE_SELECTOR_VIEWPORT_MARGIN,\n} from '../constants/index.js';\nimport type { DSPerPageSelectorT } from '../react-desc-prop-types.js';\nimport { getSelectedOptionIndex } from './getSelectedOptionIndex.js';\n\ntype SizingConfigT = {\n pageSize: number;\n options: DSPerPageSelectorT.PerPageOption[];\n listWidth?: number | string;\n chevronRef: React.RefObject<HTMLElement>;\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. The list is `listWidth` wide (100px by\n * default), never wider than the viewport, and the labels WRAP inside it. Nothing here renders or measures every label: that\n * would be O(n) hidden components just to size the list to the widest label, and it forced a one-line (truncating) design.\n */\nexport const usePerPageSelectorSizing = ({\n pageSize,\n options,\n listWidth,\n chevronRef,\n listActionRef,\n}: SizingConfigT) => {\n const { width: chevronWidth } = useOnElementResize(chevronRef);\n const configuredWidth = toCssLength(listWidth ?? PER_PAGE_SELECTOR_DEFAULT_LIST_WIDTH);\n const panelStyle = useMemo(\n () => ({ width: `min(${configuredWidth}, calc(100vw - ${PER_PAGE_SELECTOR_VIEWPORT_MARGIN}px))` }),\n [configuredWidth],\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 =\n PER_PAGE_SELECTOR_PANEL_MAX_HEIGHT - PER_PAGE_SELECTOR_HEADER_HEIGHT - PER_PAGE_SELECTOR_PANEL_PADDING_BOTTOM;\n\n /*\n * The virtual list mounts at scroll offset 0, but the selected option (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. So the list is told\n * to scroll once it is bound: React attaches the ref callbacks child first, so this one, on the element that wraps the\n * list, runs after the list's own layout effects (no effect, no timer). The selected option then mounts in range and\n * focuses itself (focus tracker). The callback changes only when the page size changes, which closes the list.\n */\n const handleListWrapperRef = useCallback(\n (node: HTMLDivElement | null) => {\n const selectedIndex = getSelectedOptionIndex(options, pageSize);\n if (node && selectedIndex >= 0) listActionRef.current.scrollTo?.(selectedIndex, { align: 'center' });\n },\n [listActionRef, options, pageSize],\n );\n\n return useMemo(\n () => ({ chevronWidth, panelStyle, listMaxHeight, handleListWrapperRef }),\n [chevronWidth, panelStyle, listMaxHeight, handleListWrapperRef],\n );\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACEvB,SAAS,aAAa,eAAe;AACrC,SAAS,0BAA0B;AACnC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,8BAA8B;AAUvC,MAAM,cAAc,CAAC,UAA4B,OAAO,UAAU,WAAW,GAAG,KAAK,OAAO;AAQrF,MAAM,2BAA2B,CAAC;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAqB;AACnB,QAAM,EAAE,OAAO,aAAa,IAAI,mBAAmB,UAAU;AAC7D,QAAM,kBAAkB,YAAY,aAAa,oCAAoC;AACrF,QAAM,aAAa;AAAA,IACjB,OAAO,EAAE,OAAO,OAAO,eAAe,kBAAkB,iCAAiC,OAAO;AAAA,IAChG,CAAC,eAAe;AAAA,EAClB;AAEA,QAAM,gBACJ,qCAAqC,kCAAkC;AASzE,QAAM,uBAAuB;AAAA,IAC3B,CAAC,SAAgC;AAC/B,YAAM,gBAAgB,uBAAuB,SAAS,QAAQ;AAC9D,UAAI,QAAQ,iBAAiB,EAAG,eAAc,QAAQ,WAAW,eAAe,EAAE,OAAO,SAAS,CAAC;AAAA,IACrG;AAAA,IACA,CAAC,eAAe,SAAS,QAAQ;AAAA,EACnC;AAEA,SAAO;AAAA,IACL,OAAO,EAAE,cAAc,YAAY,eAAe,qBAAqB;AAAA,IACvE,CAAC,cAAc,YAAY,eAAe,oBAAoB;AAAA,EAChE;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -2,19 +2,58 @@ import * as React from "react";
|
|
|
2
2
|
import { slotObjectToDataTestIds } from "@elliemae/ds-system";
|
|
3
3
|
import { DSPaginationName } from "../../../constants/index.js";
|
|
4
4
|
const DSPerPageSelectorName = "DSPerPageSelector";
|
|
5
|
-
const EXAMPLE_CONSTANTS = {
|
|
6
|
-
HELLO: "WORLD",
|
|
7
|
-
FOO: "BAR"
|
|
8
|
-
};
|
|
9
5
|
const PER_PAGE_SELECTOR_SLOTS = {
|
|
10
|
-
PER_PAGE_SELECTOR: "per-page-selector"
|
|
6
|
+
PER_PAGE_SELECTOR: "per-page-selector",
|
|
7
|
+
// legacy ones...
|
|
8
|
+
TRIGGER_WRAPPER: "per-page-selector-trigger-wrapper",
|
|
9
|
+
FLOATING_WRAPPER: "per-page-selector-floating-wrapper",
|
|
10
|
+
PANEL: "per-page-selector-panel",
|
|
11
|
+
HEADER: "per-page-selector-header",
|
|
12
|
+
LIST_WRAPPER: "per-page-selector-list-wrapper",
|
|
13
|
+
LIST: "per-page-selector-list",
|
|
14
|
+
OPTION: "per-page-selector-option",
|
|
15
|
+
OPTION_CHECKMARK: "per-page-selector-option-checkmark",
|
|
16
|
+
OPTION_LABEL: "per-page-selector-option-label"
|
|
17
|
+
};
|
|
18
|
+
const PER_PAGE_SELECTOR_DATA_TESTID = {
|
|
19
|
+
...slotObjectToDataTestIds(DSPaginationName, PER_PAGE_SELECTOR_SLOTS),
|
|
20
|
+
// legacy values of the DSDropdownMenuV2 the per page selector used to render: it is now its own widget but QA and
|
|
21
|
+
// consumers select on these, so they stay on the equivalent element — breaking change if removed
|
|
22
|
+
TRIGGER_WRAPPER: "dropdown-menu-trigger-wrapper",
|
|
23
|
+
// wraps the trigger
|
|
24
|
+
PANEL: "dropdown-menu-wrapper",
|
|
25
|
+
// wraps the header and the list (it used to be the focus holder of the open menu)
|
|
26
|
+
HEADER: "ds-dropdownmenu-header-wrapper",
|
|
27
|
+
LIST: "dropdown-menu-listbox",
|
|
28
|
+
OPTION: "ds-menu-item"
|
|
29
|
+
// one per option
|
|
30
|
+
};
|
|
31
|
+
const PER_PAGE_SELECTOR_REGION_FOCUSES = {
|
|
32
|
+
RESET: "",
|
|
33
|
+
TRIGGER: "trigger",
|
|
34
|
+
OPTION_PREFIX: "option-"
|
|
11
35
|
};
|
|
12
|
-
const
|
|
36
|
+
const PER_PAGE_SELECTOR_OPTION_HEIGHT = 32;
|
|
37
|
+
const PER_PAGE_SELECTOR_PANEL_MAX_HEIGHT = 300;
|
|
38
|
+
const PER_PAGE_SELECTOR_HEADER_HEIGHT = 17;
|
|
39
|
+
const PER_PAGE_SELECTOR_PANEL_PADDING_BOTTOM = 4;
|
|
40
|
+
const PER_PAGE_SELECTOR_DEFAULT_LIST_WIDTH = 100;
|
|
41
|
+
const PER_PAGE_SELECTOR_VIEWPORT_MARGIN = 16;
|
|
42
|
+
const PER_PAGE_SELECTOR_PAGE_JUMP = 10;
|
|
43
|
+
const PER_PAGE_SELECTOR_TYPEAHEAD_RESET_MS = 1e3;
|
|
13
44
|
export {
|
|
14
45
|
DSPaginationName,
|
|
15
46
|
DSPerPageSelectorName,
|
|
16
|
-
EXAMPLE_CONSTANTS,
|
|
17
47
|
PER_PAGE_SELECTOR_DATA_TESTID,
|
|
18
|
-
|
|
48
|
+
PER_PAGE_SELECTOR_DEFAULT_LIST_WIDTH,
|
|
49
|
+
PER_PAGE_SELECTOR_HEADER_HEIGHT,
|
|
50
|
+
PER_PAGE_SELECTOR_OPTION_HEIGHT,
|
|
51
|
+
PER_PAGE_SELECTOR_PAGE_JUMP,
|
|
52
|
+
PER_PAGE_SELECTOR_PANEL_MAX_HEIGHT,
|
|
53
|
+
PER_PAGE_SELECTOR_PANEL_PADDING_BOTTOM,
|
|
54
|
+
PER_PAGE_SELECTOR_REGION_FOCUSES,
|
|
55
|
+
PER_PAGE_SELECTOR_SLOTS,
|
|
56
|
+
PER_PAGE_SELECTOR_TYPEAHEAD_RESET_MS,
|
|
57
|
+
PER_PAGE_SELECTOR_VIEWPORT_MARGIN
|
|
19
58
|
};
|
|
20
59
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/parts/DSPerPageSelector/constants/index.ts"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { slotObjectToDataTestIds } from '@elliemae/ds-system';\nimport { DSPaginationName } from '../../../constants/index.js';\nexport { DSPaginationName };\n\n// This should be used only for displayName, and useValidateProps.\n// For slots definition, use parent component name\nexport const DSPerPageSelectorName = 'DSPerPageSelector';\n\nexport const
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,+BAA+B;AACxC,SAAS,wBAAwB;AAK1B,MAAM,wBAAwB;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { slotObjectToDataTestIds } from '@elliemae/ds-system';\nimport { DSPaginationName } from '../../../constants/index.js';\nexport { DSPaginationName };\n\n// This should be used only for displayName, and useValidateProps.\n// For slots definition, use parent component name\nexport const DSPerPageSelectorName = 'DSPerPageSelector';\n\n// we are naming this with the ${component_name}_slots convention to namespace & avoid errors on duplicate exports variables in aggregators\n// the slots are owned by DSPagination (DSPaginationName): `per-page-selector` is the legacy one (the trigger), the rest are new\nexport const PER_PAGE_SELECTOR_SLOTS = {\n PER_PAGE_SELECTOR: 'per-page-selector', // legacy ones...\n TRIGGER_WRAPPER: 'per-page-selector-trigger-wrapper',\n FLOATING_WRAPPER: 'per-page-selector-floating-wrapper',\n PANEL: 'per-page-selector-panel',\n HEADER: 'per-page-selector-header',\n LIST_WRAPPER: 'per-page-selector-list-wrapper',\n LIST: 'per-page-selector-list',\n OPTION: 'per-page-selector-option',\n OPTION_CHECKMARK: 'per-page-selector-option-checkmark',\n OPTION_LABEL: 'per-page-selector-option-label',\n} as const;\n\n// we are naming this with the ${component_name}_data_testid convention to namespace & avoid errors on duplicate exports variables in aggregators\nexport const PER_PAGE_SELECTOR_DATA_TESTID = {\n ...slotObjectToDataTestIds(DSPaginationName, PER_PAGE_SELECTOR_SLOTS),\n // legacy values of the DSDropdownMenuV2 the per page selector used to render: it is now its own widget but QA and\n // consumers select on these, so they stay on the equivalent element \u2014 breaking change if removed\n TRIGGER_WRAPPER: 'dropdown-menu-trigger-wrapper', // wraps the trigger\n PANEL: 'dropdown-menu-wrapper', // wraps the header and the list (it used to be the focus holder of the open menu)\n HEADER: 'ds-dropdownmenu-header-wrapper',\n LIST: 'dropdown-menu-listbox',\n OPTION: 'ds-menu-item', // one per option\n};\n\n// we are naming this with the ${component_name}_region_focuses convention to namespace & avoid errors on duplicate exports variables in aggregators\n// semantic identities of the focus tracker: never positional, an option is identified by its dsId\nexport const PER_PAGE_SELECTOR_REGION_FOCUSES = {\n RESET: '',\n TRIGGER: 'trigger',\n OPTION_PREFIX: 'option-',\n} as const;\n\n// the rows of the list are fixed height, the virtual list estimate and the panel height are derived from it\nexport const PER_PAGE_SELECTOR_OPTION_HEIGHT = 32;\n// the max height of the whole panel (header + list), same as the previous DSPerPageSelector (measured: header ~17px)\nexport const PER_PAGE_SELECTOR_PANEL_MAX_HEIGHT = 300;\nexport const PER_PAGE_SELECTOR_HEADER_HEIGHT = 17;\n// the previous DSDropdownMenuV2 wrapper always kept 4px of padding below the list, inside the same max height\nexport const PER_PAGE_SELECTOR_PANEL_PADDING_BOTTOM = 4;\n// the width of the open list: labels wrap inside it instead of the list growing to the widest one (that would need every\n// label rendered and measured up front). 100px is what the previous formula gave for numeric labels and for `All`.\n// Overridable with the `listWidth` prop.\nexport const PER_PAGE_SELECTOR_DEFAULT_LIST_WIDTH = 100;\n// the list never gets wider than the viewport minus this margin (reflow at high zoom levels)\nexport const PER_PAGE_SELECTOR_VIEWPORT_MARGIN = 16;\n// APG listbox / select-only combobox: PageUp / PageDown move 10 options\nexport const PER_PAGE_SELECTOR_PAGE_JUMP = 10;\n// characters typed within this window build a single prefix to look for\nexport const PER_PAGE_SELECTOR_TYPEAHEAD_RESET_MS = 1000;\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,+BAA+B;AACxC,SAAS,wBAAwB;AAK1B,MAAM,wBAAwB;AAI9B,MAAM,0BAA0B;AAAA,EACrC,mBAAmB;AAAA;AAAA,EACnB,iBAAiB;AAAA,EACjB,kBAAkB;AAAA,EAClB,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,cAAc;AAAA,EACd,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,kBAAkB;AAAA,EAClB,cAAc;AAChB;AAGO,MAAM,gCAAgC;AAAA,EAC3C,GAAG,wBAAwB,kBAAkB,uBAAuB;AAAA;AAAA;AAAA,EAGpE,iBAAiB;AAAA;AAAA,EACjB,OAAO;AAAA;AAAA,EACP,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,QAAQ;AAAA;AACV;AAIO,MAAM,mCAAmC;AAAA,EAC9C,OAAO;AAAA,EACP,SAAS;AAAA,EACT,eAAe;AACjB;AAGO,MAAM,kCAAkC;AAExC,MAAM,qCAAqC;AAC3C,MAAM,kCAAkC;AAExC,MAAM,yCAAyC;AAI/C,MAAM,uCAAuC;AAE7C,MAAM,oCAAoC;AAE1C,MAAM,8BAA8B;AAEpC,MAAM,uCAAuC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Checkmark } from "@elliemae/ds-icons";
|
|
4
|
+
import { useCallback, useContext } from "react";
|
|
5
|
+
import { getSelectedOptionIndex } from "../config/getSelectedOptionIndex.js";
|
|
6
|
+
import { getOptionRegionId } from "../config/useFocusTracker.js";
|
|
7
|
+
import { PER_PAGE_SELECTOR_DATA_TESTID } from "../constants/index.js";
|
|
8
|
+
import { DSPerPageSelectorContext } from "../DSPerPageSelectorCTX.js";
|
|
9
|
+
import { StyledOption, StyledOptionCheckmark, StyledOptionLabel } from "../styled.js";
|
|
10
|
+
const OptionRenderer = ({ index }) => {
|
|
11
|
+
const {
|
|
12
|
+
propsWithDefault: { pageSize },
|
|
13
|
+
ownerPropsConfig: { getOwnerProps },
|
|
14
|
+
options,
|
|
15
|
+
chevronWidth,
|
|
16
|
+
focusTrackers: { focusRegion, trackFocusOption },
|
|
17
|
+
commitOption
|
|
18
|
+
} = useContext(DSPerPageSelectorContext);
|
|
19
|
+
const option = options[index];
|
|
20
|
+
const isSelected = getSelectedOptionIndex(options, pageSize) === index;
|
|
21
|
+
const isFocusTarget = focusRegion === getOptionRegionId(option.dsId);
|
|
22
|
+
const handleRef = useCallback(
|
|
23
|
+
(node) => {
|
|
24
|
+
if (node && isFocusTarget) node.focus();
|
|
25
|
+
},
|
|
26
|
+
[isFocusTarget]
|
|
27
|
+
);
|
|
28
|
+
const handleFocus = useCallback(() => trackFocusOption(option.dsId), [option.dsId, trackFocusOption]);
|
|
29
|
+
const handleClick = useCallback(() => commitOption(option), [commitOption, option]);
|
|
30
|
+
const getOwnerPropsArguments = useCallback(() => ({ option, isSelected }), [option, isSelected]);
|
|
31
|
+
return /* @__PURE__ */ jsxs(
|
|
32
|
+
StyledOption,
|
|
33
|
+
{
|
|
34
|
+
"data-testid": PER_PAGE_SELECTOR_DATA_TESTID.OPTION,
|
|
35
|
+
role: "option",
|
|
36
|
+
"aria-selected": isSelected,
|
|
37
|
+
"aria-setsize": options.length,
|
|
38
|
+
"aria-posinset": index + 1,
|
|
39
|
+
tabIndex: isFocusTarget ? 0 : -1,
|
|
40
|
+
innerRef: handleRef,
|
|
41
|
+
onFocus: handleFocus,
|
|
42
|
+
onClick: handleClick,
|
|
43
|
+
style: { gridTemplateColumns: `${chevronWidth}px auto` },
|
|
44
|
+
getOwnerProps,
|
|
45
|
+
getOwnerPropsArguments,
|
|
46
|
+
children: [
|
|
47
|
+
/* @__PURE__ */ jsx(
|
|
48
|
+
StyledOptionCheckmark,
|
|
49
|
+
{
|
|
50
|
+
"aria-hidden": "true",
|
|
51
|
+
getOwnerProps,
|
|
52
|
+
getOwnerPropsArguments,
|
|
53
|
+
children: isSelected ? /* @__PURE__ */ jsx(Checkmark, { size: "s", color: ["brand-primary", "600"] }) : null
|
|
54
|
+
}
|
|
55
|
+
),
|
|
56
|
+
/* @__PURE__ */ jsx(StyledOptionLabel, { getOwnerProps, getOwnerPropsArguments, children: option.label })
|
|
57
|
+
]
|
|
58
|
+
}
|
|
59
|
+
);
|
|
60
|
+
};
|
|
61
|
+
export {
|
|
62
|
+
OptionRenderer
|
|
63
|
+
};
|
|
64
|
+
//# sourceMappingURL=OptionRenderer.js.map
|