@elliemae/ds-pagination 3.16.0-next.2 → 3.16.0-next.21
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/DSPaginationDefinitions.js +17 -1
- package/dist/cjs/DSPaginationDefinitions.js.map +2 -2
- package/dist/cjs/Pagination.js +11 -7
- package/dist/cjs/Pagination.js.map +2 -2
- package/dist/cjs/PaginationDataTestID.js +7 -1
- package/dist/cjs/PaginationDataTestID.js.map +2 -2
- package/dist/cjs/index.js +36 -2
- package/dist/cjs/index.js.map +3 -3
- package/dist/cjs/package.json +7 -0
- package/dist/cjs/parts/DSPageNextButton.js +74 -0
- package/dist/cjs/parts/DSPageNextButton.js.map +7 -0
- package/dist/cjs/parts/DSPagePrevButton.js +74 -0
- package/dist/cjs/parts/DSPagePrevButton.js.map +7 -0
- package/dist/cjs/parts/DSPaginationContainer.js +61 -0
- package/dist/cjs/parts/DSPaginationContainer.js.map +7 -0
- package/dist/cjs/parts/DSPaginator/createPaginatorHeader.js +50 -0
- package/dist/cjs/parts/DSPaginator/createPaginatorHeader.js.map +7 -0
- package/dist/cjs/parts/DSPaginator/getOptions.js +76 -0
- package/dist/cjs/parts/DSPaginator/getOptions.js.map +7 -0
- package/dist/cjs/parts/DSPaginator/index.js +148 -0
- package/dist/cjs/parts/DSPaginator/index.js.map +7 -0
- package/dist/cjs/{hooks → parts/DSPaginator}/usePaginationSearch.js +9 -2
- package/dist/cjs/parts/DSPaginator/usePaginationSearch.js.map +7 -0
- package/dist/cjs/parts/DSPaginator/usePaginator.js +91 -0
- package/dist/cjs/parts/DSPaginator/usePaginator.js.map +7 -0
- package/dist/cjs/parts/{PagePrevButton.js → DSPerPageSelector/getOptions.js} +25 -22
- package/dist/cjs/parts/DSPerPageSelector/getOptions.js.map +7 -0
- package/dist/cjs/parts/DSPerPageSelector/index.js +106 -0
- package/dist/cjs/parts/DSPerPageSelector/index.js.map +7 -0
- package/dist/cjs/parts/DSPerPageSelector/usePerPageSelector.js +72 -0
- package/dist/cjs/parts/DSPerPageSelector/usePerPageSelector.js.map +7 -0
- package/dist/cjs/parts/PaginationContent.js +41 -52
- package/dist/cjs/parts/PaginationContent.js.map +3 -3
- package/dist/cjs/parts/index.js +49 -0
- package/dist/cjs/parts/index.js.map +7 -0
- package/dist/cjs/props.js +85 -0
- package/dist/cjs/props.js.map +7 -0
- package/dist/cjs/react-desc-prop-types.js +111 -33
- package/dist/cjs/react-desc-prop-types.js.map +2 -2
- package/dist/cjs/styled.js +21 -27
- package/dist/cjs/styled.js.map +2 -2
- package/dist/esm/DSPaginationDefinitions.js +13 -1
- package/dist/esm/DSPaginationDefinitions.js.map +2 -2
- package/dist/esm/Pagination.js +4 -4
- package/dist/esm/Pagination.js.map +1 -1
- package/dist/esm/PaginationDataTestID.js +3 -1
- package/dist/esm/PaginationDataTestID.js.map +2 -2
- package/dist/esm/index.js +39 -1
- package/dist/esm/index.js.map +3 -3
- package/dist/esm/package.json +7 -0
- package/dist/esm/parts/DSPageNextButton.js +50 -0
- package/dist/esm/parts/DSPageNextButton.js.map +7 -0
- package/dist/esm/parts/DSPagePrevButton.js +50 -0
- package/dist/esm/parts/DSPagePrevButton.js.map +7 -0
- package/dist/esm/parts/DSPaginationContainer.js +31 -0
- package/dist/esm/parts/DSPaginationContainer.js.map +7 -0
- package/dist/esm/parts/DSPaginator/createPaginatorHeader.js +20 -0
- package/dist/esm/parts/DSPaginator/createPaginatorHeader.js.map +7 -0
- package/dist/esm/parts/DSPaginator/getOptions.js +46 -0
- package/dist/esm/parts/DSPaginator/getOptions.js.map +7 -0
- package/dist/esm/parts/DSPaginator/index.js +118 -0
- package/dist/esm/parts/DSPaginator/index.js.map +7 -0
- package/dist/esm/{hooks → parts/DSPaginator}/usePaginationSearch.js +5 -2
- package/dist/esm/parts/DSPaginator/usePaginationSearch.js.map +7 -0
- package/dist/esm/parts/DSPaginator/usePaginator.js +61 -0
- package/dist/esm/parts/DSPaginator/usePaginator.js.map +7 -0
- package/dist/esm/parts/DSPerPageSelector/getOptions.js +22 -0
- package/dist/esm/parts/DSPerPageSelector/getOptions.js.map +7 -0
- package/dist/esm/parts/DSPerPageSelector/index.js +76 -0
- package/dist/esm/parts/DSPerPageSelector/index.js.map +7 -0
- package/dist/esm/parts/DSPerPageSelector/usePerPageSelector.js +42 -0
- package/dist/esm/parts/DSPerPageSelector/usePerPageSelector.js.map +7 -0
- package/dist/esm/parts/PaginationContent.js +37 -52
- package/dist/esm/parts/PaginationContent.js.map +2 -2
- package/dist/esm/parts/index.js +19 -0
- package/dist/esm/parts/index.js.map +7 -0
- package/dist/esm/props.js +55 -0
- package/dist/esm/props.js.map +7 -0
- package/dist/esm/react-desc-prop-types.js +88 -14
- package/dist/esm/react-desc-prop-types.js.map +2 -2
- package/dist/esm/styled.js +15 -25
- package/dist/esm/styled.js.map +2 -2
- package/dist/types/DSPaginationDefinitions.d.ts +6 -0
- package/dist/types/Pagination.d.ts +2 -2
- package/dist/types/PaginationDataTestID.d.ts +2 -0
- package/dist/types/index.d.ts +17 -1
- package/dist/types/parts/DSPageNextButton.d.ts +4 -0
- package/dist/types/parts/DSPagePrevButton.d.ts +4 -0
- package/dist/types/parts/DSPaginationContainer.d.ts +4 -0
- package/dist/types/parts/DSPaginator/createPaginatorHeader.d.ts +6 -0
- package/dist/types/parts/DSPaginator/getOptions.d.ts +7 -0
- package/dist/types/parts/DSPaginator/index.d.ts +4 -0
- package/dist/types/parts/DSPaginator/usePaginationSearch.d.ts +2 -0
- package/dist/types/parts/DSPaginator/usePaginator.d.ts +17 -0
- package/dist/types/parts/DSPerPageSelector/getOptions.d.ts +3 -0
- package/dist/types/parts/DSPerPageSelector/index.d.ts +4 -0
- package/dist/types/parts/DSPerPageSelector/usePerPageSelector.d.ts +13 -0
- package/dist/types/parts/PaginationContent.d.ts +1 -1
- package/dist/types/parts/index.d.ts +5 -0
- package/dist/types/props.d.ts +20 -0
- package/dist/types/react-desc-prop-types.d.ts +528 -9
- package/dist/types/styled.d.ts +7 -9
- package/dist/types/tests/a11y/axe.test.d.ts +1 -0
- package/dist/types/tests/callbacks/paginator.test.d.ts +1 -0
- package/dist/types/tests/callbacks/per-page-selector.test.d.ts +1 -0
- package/dist/types/tests/callbacks/prev-next-buttons.test.d.ts +1 -0
- package/dist/types/tests/keyboard/navigation.test.d.ts +1 -0
- package/dist/types/tests/keyboard/paginator-search.test.d.ts +1 -0
- package/dist/types/tests/render/page-count-loading.test.d.ts +1 -0
- package/dist/types/tests/render/paginator.test.d.ts +1 -0
- package/dist/types/tests/render/per-page-selector.test.d.ts +1 -0
- package/dist/types/tests/render/segmented-paginator.test.d.ts +1 -0
- package/dist/types/tests/render/simple.render.test.d.ts +1 -0
- package/package.json +18 -12
- package/dist/cjs/hooks/usePaginationSearch.js.map +0 -7
- package/dist/cjs/parts/PageNextButton.js +0 -52
- package/dist/cjs/parts/PageNextButton.js.map +0 -7
- package/dist/cjs/parts/PagePrevButton.js.map +0 -7
- package/dist/cjs/parts/Paginator.js +0 -162
- package/dist/cjs/parts/Paginator.js.map +0 -7
- package/dist/cjs/parts/PerPageSelector.js +0 -114
- package/dist/cjs/parts/PerPageSelector.js.map +0 -7
- package/dist/esm/hooks/usePaginationSearch.js.map +0 -7
- package/dist/esm/parts/PageNextButton.js +0 -26
- package/dist/esm/parts/PageNextButton.js.map +0 -7
- package/dist/esm/parts/PagePrevButton.js +0 -23
- package/dist/esm/parts/PagePrevButton.js.map +0 -7
- package/dist/esm/parts/Paginator.js +0 -136
- package/dist/esm/parts/Paginator.js.map +0 -7
- package/dist/esm/parts/PerPageSelector.js +0 -88
- package/dist/esm/parts/PerPageSelector.js.map +0 -7
- package/dist/types/hooks/usePaginationSearch.d.ts +0 -1
- package/dist/types/parts/PageNextButton.d.ts +0 -3
- package/dist/types/parts/PagePrevButton.d.ts +0 -3
- package/dist/types/parts/Paginator.d.ts +0 -11
- package/dist/types/parts/PerPageSelector.d.ts +0 -4
|
@@ -0,0 +1,148 @@
|
|
|
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 DSPaginator_exports = {};
|
|
30
|
+
__export(DSPaginator_exports, {
|
|
31
|
+
DSPaginator: () => DSPaginator,
|
|
32
|
+
DSPaginatorWithSchema: () => DSPaginatorWithSchema
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(DSPaginator_exports);
|
|
35
|
+
var React = __toESM(require("react"));
|
|
36
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
37
|
+
var import_react = require("react");
|
|
38
|
+
var import_ds_icons = require("@elliemae/ds-icons");
|
|
39
|
+
var import_ds_props_helpers = require("@elliemae/ds-props-helpers");
|
|
40
|
+
var import_ds_grid = require("@elliemae/ds-grid");
|
|
41
|
+
var import_ds_dropdownmenu = require("@elliemae/ds-dropdownmenu");
|
|
42
|
+
var import_ds_typography = require("@elliemae/ds-typography");
|
|
43
|
+
var import_ds_circular_progress_indicator = require("@elliemae/ds-circular-progress-indicator");
|
|
44
|
+
var import_styled = require("../../styled.js");
|
|
45
|
+
var import_react_desc_prop_types = require("../../react-desc-prop-types.js");
|
|
46
|
+
var import_DSPaginationDefinitions = require("../../DSPaginationDefinitions.js");
|
|
47
|
+
var import_usePaginator = require("./usePaginator.js");
|
|
48
|
+
var import_createPaginatorHeader = require("./createPaginatorHeader.js");
|
|
49
|
+
var import_PaginationDataTestID = require("../../PaginationDataTestID.js");
|
|
50
|
+
const DSPaginator = (props) => {
|
|
51
|
+
const propsWithDefault = (0, import_ds_props_helpers.useMemoMergePropsWithDefault)(
|
|
52
|
+
props,
|
|
53
|
+
import_react_desc_prop_types.paginatorDefaultProps
|
|
54
|
+
);
|
|
55
|
+
(0, import_ds_props_helpers.useValidateTypescriptPropTypes)(propsWithDefault, import_react_desc_prop_types.DSPaginatorPropTypesSchema, import_DSPaginationDefinitions.PaginatorName);
|
|
56
|
+
const { pageIndex, pageCount, isLoadingPageCount, onPageChange, pageDetails, pageDetailsTitle } = propsWithDefault;
|
|
57
|
+
const {
|
|
58
|
+
btnRef,
|
|
59
|
+
btnWidth,
|
|
60
|
+
pageInfoWidth,
|
|
61
|
+
options,
|
|
62
|
+
isOpened,
|
|
63
|
+
setIsOpened,
|
|
64
|
+
detailWidth,
|
|
65
|
+
globalAttributes,
|
|
66
|
+
xstyledAttributes,
|
|
67
|
+
actionRef,
|
|
68
|
+
onKeyDown
|
|
69
|
+
} = (0, import_usePaginator.usePaginator)(propsWithDefault);
|
|
70
|
+
const Header = (0, import_react.useMemo)(
|
|
71
|
+
() => (0, import_createPaginatorHeader.createPaginatorHeader)({ pageDetailsTitle, pageInfoWidth }),
|
|
72
|
+
[pageDetailsTitle, pageInfoWidth]
|
|
73
|
+
);
|
|
74
|
+
const buttonOnClick = (0, import_react.useMemo)(() => {
|
|
75
|
+
if (globalAttributes.onClick)
|
|
76
|
+
return globalAttributes.onClick;
|
|
77
|
+
return () => setIsOpened((prev) => !prev);
|
|
78
|
+
}, [globalAttributes.onClick, setIsOpened]);
|
|
79
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
80
|
+
import_ds_dropdownmenu.DSDropdownMenuV2,
|
|
81
|
+
{
|
|
82
|
+
isOpened,
|
|
83
|
+
options,
|
|
84
|
+
selectedOptions: { [pageIndex.toString()]: true },
|
|
85
|
+
onOptionClick: (_, clickedOption) => {
|
|
86
|
+
onPageChange(clickedOption.value);
|
|
87
|
+
setIsOpened(false);
|
|
88
|
+
btnRef.current?.focus();
|
|
89
|
+
},
|
|
90
|
+
onClickOutside: () => {
|
|
91
|
+
setIsOpened(false);
|
|
92
|
+
btnRef.current?.focus();
|
|
93
|
+
},
|
|
94
|
+
customOffset: [-23, 2],
|
|
95
|
+
startPlacementPreference: "top-start",
|
|
96
|
+
actionRef,
|
|
97
|
+
onKeyDown,
|
|
98
|
+
minWidth: pageDetails.length !== 0 ? btnWidth + 23 : pageCount.toString().length * 6 + 90,
|
|
99
|
+
maxHeight: 300,
|
|
100
|
+
HeaderComp: Header,
|
|
101
|
+
children: [
|
|
102
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
103
|
+
import_styled.PaginationDropdownButton,
|
|
104
|
+
{
|
|
105
|
+
buttonType: "raw",
|
|
106
|
+
disabled: isLoadingPageCount,
|
|
107
|
+
innerRef: btnRef,
|
|
108
|
+
"aria-pressed": isOpened,
|
|
109
|
+
"aria-label": `Page ${pageIndex} out of ${pageCount}, ${pageDetails.length !== 0 ? pageDetails[pageIndex - 1] : "\b\b"}. Press to change the current page`,
|
|
110
|
+
"data-testid": import_PaginationDataTestID.PAGINATION_DATA_TESTID.PAGINATOR,
|
|
111
|
+
...globalAttributes,
|
|
112
|
+
...xstyledAttributes,
|
|
113
|
+
onClick: buttonOnClick,
|
|
114
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ds_grid.Grid, { gutter: "xxxs", alignItems: "center", style: { gridAutoFlow: "column" }, children: [
|
|
115
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ds_typography.DSTypography, { fontSize: "18px", variant: "b1", as: "span", fontWeight: "semibold", textAlign: "start", children: pageIndex }),
|
|
116
|
+
"/ ",
|
|
117
|
+
pageCount,
|
|
118
|
+
isLoadingPageCount && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ds_circular_progress_indicator.DSCircularIndeterminateIndicator, { ml: "xxxs", mr: "xxxs", size: "xs" }),
|
|
119
|
+
pageDetails.length !== 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
120
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styled.DSPaginationSeparator, { height: "12px", ml: "12px", mr: "xxxs" }),
|
|
121
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
122
|
+
import_ds_typography.DSTypography,
|
|
123
|
+
{
|
|
124
|
+
fontSize: "13px",
|
|
125
|
+
w: detailWidth,
|
|
126
|
+
mr: "xxs",
|
|
127
|
+
variant: "b1",
|
|
128
|
+
as: "span",
|
|
129
|
+
fontWeight: "semibold",
|
|
130
|
+
textAlign: "start",
|
|
131
|
+
children: pageDetails[pageIndex - 1]
|
|
132
|
+
}
|
|
133
|
+
)
|
|
134
|
+
] }),
|
|
135
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ds_icons.ChevronDown, { ml: "xxxs", color: ["brand-primary", "700"] })
|
|
136
|
+
] })
|
|
137
|
+
}
|
|
138
|
+
),
|
|
139
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ds_grid.Grid, { style: { position: "relative" }, children: pageDetails.map((pageDetail) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styled.InvisibleDiv, { "data-testid": "ds-pagination-invisible-detail-for-width-calc", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ds_typography.DSTypography, { fontSize: "13px", mr: "xxs", variant: "b1", as: "span", fontWeight: "semibold", textAlign: "start", children: pageDetail }) }, pageDetail)) })
|
|
140
|
+
]
|
|
141
|
+
}
|
|
142
|
+
);
|
|
143
|
+
};
|
|
144
|
+
DSPaginator.propTypes = import_react_desc_prop_types.DSPaginatorPropTypesSchema;
|
|
145
|
+
DSPaginator.displayName = import_DSPaginationDefinitions.PaginatorName;
|
|
146
|
+
const DSPaginatorWithSchema = (0, import_ds_props_helpers.describe)(DSPaginator).description("Per Page Selector");
|
|
147
|
+
DSPaginatorWithSchema.propTypes = import_react_desc_prop_types.DSPaginatorPropTypesSchema;
|
|
148
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/parts/DSPaginator/index.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["/* eslint-disable react/prop-types */\nimport React, { useMemo } from 'react';\nimport type { DSButtonT } from '@elliemae/ds-button-v2';\nimport { ChevronDown } from '@elliemae/ds-icons';\nimport { describe, useMemoMergePropsWithDefault, useValidateTypescriptPropTypes } from '@elliemae/ds-props-helpers';\nimport { Grid } from '@elliemae/ds-grid';\nimport { DSDropdownMenuV2 } from '@elliemae/ds-dropdownmenu';\nimport { DSTypography } from '@elliemae/ds-typography';\nimport { DSCircularIndeterminateIndicator } from '@elliemae/ds-circular-progress-indicator';\nimport { InvisibleDiv, PaginationDropdownButton, DSPaginationSeparator } from '../../styled.js';\nimport { paginatorDefaultProps, DSPaginatorPropTypesSchema } from '../../react-desc-prop-types.js';\nimport { PaginatorName } from '../../DSPaginationDefinitions.js';\nimport { usePaginator } from './usePaginator.js';\nimport { createPaginatorHeader } from './createPaginatorHeader.js';\nimport { PAGINATION_DATA_TESTID } from '../../PaginationDataTestID.js';\nimport type { DSDropdownMenuT } from '@elliemae/ds-dropdownmenu';\nimport type { DSPaginationT } from '../../react-desc-prop-types.js';\n\nexport const DSPaginator: React.ComponentType<DSPaginationT.PaginatorProps> = (props) => {\n const propsWithDefault = useMemoMergePropsWithDefault<DSPaginationT.PaginatorInternalProps>(\n props,\n paginatorDefaultProps,\n );\n useValidateTypescriptPropTypes(propsWithDefault, DSPaginatorPropTypesSchema, PaginatorName);\n\n const { pageIndex, pageCount, isLoadingPageCount, onPageChange, pageDetails, pageDetailsTitle } = propsWithDefault;\n\n const {\n btnRef,\n btnWidth,\n pageInfoWidth,\n options,\n isOpened,\n setIsOpened,\n detailWidth,\n globalAttributes,\n xstyledAttributes,\n actionRef,\n onKeyDown,\n } = usePaginator(propsWithDefault);\n\n const Header = useMemo(\n () => createPaginatorHeader({ pageDetailsTitle, pageInfoWidth }),\n [pageDetailsTitle, pageInfoWidth],\n );\n\n const buttonOnClick: DSButtonT.Props['onClick'] = useMemo(() => {\n if (globalAttributes.onClick) return globalAttributes.onClick as DSButtonT.Props['onClick'];\n return () => setIsOpened((prev) => !prev);\n }, [globalAttributes.onClick, setIsOpened]);\n\n return (\n <DSDropdownMenuV2\n isOpened={isOpened}\n options={options}\n selectedOptions={{ [pageIndex.toString()]: true }}\n onOptionClick={(_, clickedOption) => {\n onPageChange((clickedOption as DSDropdownMenuT.ItemSingleOptions).value as number);\n setIsOpened(false);\n btnRef.current?.focus();\n }}\n onClickOutside={() => {\n setIsOpened(false);\n btnRef.current?.focus();\n }}\n customOffset={[-23, 2]}\n startPlacementPreference=\"top-start\"\n actionRef={actionRef}\n onKeyDown={onKeyDown}\n minWidth={pageDetails.length !== 0 ? btnWidth + 23 : pageCount.toString().length * 6 + 90}\n maxHeight={300}\n HeaderComp={Header}\n >\n <PaginationDropdownButton\n buttonType=\"raw\"\n disabled={isLoadingPageCount}\n innerRef={btnRef}\n aria-pressed={isOpened}\n aria-label={`Page ${pageIndex} out of ${pageCount}, ${\n pageDetails.length !== 0 ? pageDetails[pageIndex - 1] : '\\b\\b'\n }. Press to change the current page`}\n data-testid={PAGINATION_DATA_TESTID.PAGINATOR}\n {...globalAttributes}\n {...xstyledAttributes}\n onClick={buttonOnClick}\n >\n <Grid gutter=\"xxxs\" alignItems=\"center\" style={{ gridAutoFlow: 'column' }}>\n <DSTypography fontSize=\"18px\" variant=\"b1\" as=\"span\" fontWeight=\"semibold\" textAlign=\"start\">\n {pageIndex}\n </DSTypography>\n / {pageCount}\n {isLoadingPageCount && <DSCircularIndeterminateIndicator ml=\"xxxs\" mr=\"xxxs\" size=\"xs\" />}\n {pageDetails.length !== 0 && (\n <>\n <DSPaginationSeparator height=\"12px\" ml=\"12px\" mr=\"xxxs\" />\n <DSTypography\n fontSize=\"13px\"\n w={detailWidth}\n mr=\"xxs\"\n variant=\"b1\"\n as=\"span\"\n fontWeight=\"semibold\"\n textAlign=\"start\"\n >\n {pageDetails[pageIndex - 1]}\n </DSTypography>\n </>\n )}\n <ChevronDown ml=\"xxxs\" color={['brand-primary', '700']} />\n </Grid>\n </PaginationDropdownButton>\n {/* We calculate the length of the longest detail here (this is as per specs) */}\n <Grid style={{ position: 'relative' }}>\n {pageDetails.map((pageDetail) => (\n <InvisibleDiv data-testid=\"ds-pagination-invisible-detail-for-width-calc\" key={pageDetail}>\n <DSTypography fontSize=\"13px\" mr=\"xxs\" variant=\"b1\" as=\"span\" fontWeight=\"semibold\" textAlign=\"start\">\n {pageDetail}\n </DSTypography>\n </InvisibleDiv>\n ))}\n </Grid>\n </DSDropdownMenuV2>\n );\n};\n\nDSPaginator.propTypes = DSPaginatorPropTypesSchema;\nDSPaginator.displayName = PaginatorName;\nexport const DSPaginatorWithSchema = describe(DSPaginator).description('Per Page Selector');\nDSPaginatorWithSchema.propTypes = DSPaginatorPropTypesSchema;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -18,6 +18,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
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.
|
|
21
25
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
26
|
mod
|
|
23
27
|
));
|
|
@@ -32,8 +36,10 @@ var import_react = require("react");
|
|
|
32
36
|
const usePaginationSearch = (pageCount, actionRef) => {
|
|
33
37
|
const [searchValue, setSearchValue] = (0, import_react.useState)("");
|
|
34
38
|
const [shouldResetSearchValue, setShouldResetSearchValue] = (0, import_react.useState)(true);
|
|
35
|
-
const timeoutRef = (0, import_react.useRef)(
|
|
39
|
+
const timeoutRef = (0, import_react.useRef)();
|
|
36
40
|
(0, import_react.useEffect)(() => {
|
|
41
|
+
if (typeof pageCount === "string")
|
|
42
|
+
return;
|
|
37
43
|
if (searchValue !== "" && Number.parseInt(searchValue, 10) <= pageCount) {
|
|
38
44
|
actionRef.current.setActiveDescendant(searchValue);
|
|
39
45
|
actionRef.current.scrollOptionIntoView(searchValue);
|
|
@@ -47,7 +53,8 @@ const usePaginationSearch = (pageCount, actionRef) => {
|
|
|
47
53
|
else
|
|
48
54
|
setSearchValue((prevValue) => prevValue + e.key);
|
|
49
55
|
setShouldResetSearchValue(false);
|
|
50
|
-
|
|
56
|
+
if (timeoutRef.current)
|
|
57
|
+
clearTimeout(timeoutRef.current);
|
|
51
58
|
timeoutRef.current = setTimeout(() => {
|
|
52
59
|
setShouldResetSearchValue(true);
|
|
53
60
|
}, 1e3);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/parts/DSPaginator/usePaginationSearch.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["import { useCallback, useEffect, useRef, useState } from 'react';\n\nexport const usePaginationSearch = (\n pageCount: string | number,\n actionRef: React.MutableRefObject<Record<string, (dsId: string) => void>>,\n): React.KeyboardEventHandler => {\n const [searchValue, setSearchValue] = useState('');\n const [shouldResetSearchValue, setShouldResetSearchValue] = useState(true);\n\n const timeoutRef = useRef<NodeJS.Timeout>();\n\n useEffect(() => {\n if (typeof pageCount === 'string') return;\n\n if (searchValue !== '' && Number.parseInt(searchValue, 10) <= pageCount) {\n actionRef.current.setActiveDescendant(searchValue);\n actionRef.current.scrollOptionIntoView(searchValue);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [searchValue]);\n\n const onKeyDown = useCallback(\n (e: React.KeyboardEvent) => {\n if (e.code.startsWith('Digit')) {\n if (shouldResetSearchValue) setSearchValue(e.key);\n else setSearchValue((prevValue) => prevValue + e.key);\n\n setShouldResetSearchValue(false);\n if (timeoutRef.current) clearTimeout(timeoutRef.current);\n timeoutRef.current = setTimeout(() => {\n setShouldResetSearchValue(true);\n }, 1000);\n }\n },\n [shouldResetSearchValue],\n );\n\n return onKeyDown;\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAyD;AAElD,MAAM,sBAAsB,CACjC,WACA,cAC+B;AAC/B,QAAM,CAAC,aAAa,cAAc,QAAI,uBAAS,EAAE;AACjD,QAAM,CAAC,wBAAwB,yBAAyB,QAAI,uBAAS,IAAI;AAEzE,QAAM,iBAAa,qBAAuB;AAE1C,8BAAU,MAAM;AACd,QAAI,OAAO,cAAc;AAAU;AAEnC,QAAI,gBAAgB,MAAM,OAAO,SAAS,aAAa,EAAE,KAAK,WAAW;AACvE,gBAAU,QAAQ,oBAAoB,WAAW;AACjD,gBAAU,QAAQ,qBAAqB,WAAW;AAAA,IACpD;AAAA,EAEF,GAAG,CAAC,WAAW,CAAC;AAEhB,QAAM,gBAAY;AAAA,IAChB,CAAC,MAA2B;AAC1B,UAAI,EAAE,KAAK,WAAW,OAAO,GAAG;AAC9B,YAAI;AAAwB,yBAAe,EAAE,GAAG;AAAA;AAC3C,yBAAe,CAAC,cAAc,YAAY,EAAE,GAAG;AAEpD,kCAA0B,KAAK;AAC/B,YAAI,WAAW;AAAS,uBAAa,WAAW,OAAO;AACvD,mBAAW,UAAU,WAAW,MAAM;AACpC,oCAA0B,IAAI;AAAA,QAChC,GAAG,GAAI;AAAA,MACT;AAAA,IACF;AAAA,IACA,CAAC,sBAAsB;AAAA,EACzB;AAEA,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
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 usePaginator_exports = {};
|
|
30
|
+
__export(usePaginator_exports, {
|
|
31
|
+
usePaginator: () => usePaginator
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(usePaginator_exports);
|
|
34
|
+
var React = __toESM(require("react"));
|
|
35
|
+
var import_react = require("react");
|
|
36
|
+
var import_lodash = require("lodash");
|
|
37
|
+
var import_ds_props_helpers = require("@elliemae/ds-props-helpers");
|
|
38
|
+
var import_ds_utilities = require("@elliemae/ds-utilities");
|
|
39
|
+
var import_usePaginationSearch = require("./usePaginationSearch.js");
|
|
40
|
+
var import_getOptions = require("./getOptions.js");
|
|
41
|
+
const usePaginator = (props) => {
|
|
42
|
+
const { pageIndex, pageCount, pageDetails } = props;
|
|
43
|
+
const [isOpened, setIsOpened] = (0, import_react.useState)(false);
|
|
44
|
+
const [detailWidth, setDetailWidth] = (0, import_react.useState)(0);
|
|
45
|
+
const [pageInfoWidth, setPageInfoWidth] = (0, import_react.useState)(0);
|
|
46
|
+
const btnRef = (0, import_react.useRef)(null);
|
|
47
|
+
const actionRef = (0, import_react.useRef)({});
|
|
48
|
+
const { width: btnWidth } = (0, import_ds_utilities.useOnElementResize)(btnRef);
|
|
49
|
+
const options = (0, import_react.useMemo)(
|
|
50
|
+
() => (0, import_getOptions.getOptions)({ pageCount, pageIndex, pageDetails, pageInfoWidth }),
|
|
51
|
+
[pageCount, pageIndex, pageDetails, pageInfoWidth]
|
|
52
|
+
);
|
|
53
|
+
const onKeyDown = (0, import_usePaginationSearch.usePaginationSearch)(pageCount, actionRef);
|
|
54
|
+
const globalAttributes = (0, import_lodash.omit)((0, import_ds_props_helpers.useGetGlobalAttributes)(props), ["shape", "type", "size"]);
|
|
55
|
+
const xstyledAttributes = (0, import_ds_props_helpers.useGetXstyledProps)(props);
|
|
56
|
+
(0, import_react.useEffect)(() => {
|
|
57
|
+
if (isOpened) {
|
|
58
|
+
actionRef.current.setActiveDescendant(pageIndex.toString());
|
|
59
|
+
actionRef.current.scrollOptionIntoView(pageIndex.toString());
|
|
60
|
+
}
|
|
61
|
+
}, [isOpened]);
|
|
62
|
+
(0, import_react.useLayoutEffect)(() => {
|
|
63
|
+
const invisibleDetails = [
|
|
64
|
+
...document.body.querySelectorAll('[data-testid="ds-pagination-invisible-detail-for-width-calc"]')
|
|
65
|
+
];
|
|
66
|
+
const maxWidth = invisibleDetails.reduce((acc, cur) => Math.max(acc, cur.getBoundingClientRect().width), 0);
|
|
67
|
+
setDetailWidth(maxWidth);
|
|
68
|
+
}, [pageDetails]);
|
|
69
|
+
(0, import_react.useEffect)(() => {
|
|
70
|
+
setPageInfoWidth(() => {
|
|
71
|
+
if (detailWidth)
|
|
72
|
+
return btnWidth - detailWidth - 89;
|
|
73
|
+
return btnWidth - 56;
|
|
74
|
+
});
|
|
75
|
+
}, [btnWidth, detailWidth]);
|
|
76
|
+
return {
|
|
77
|
+
btnRef,
|
|
78
|
+
btnWidth,
|
|
79
|
+
pageInfoWidth,
|
|
80
|
+
options,
|
|
81
|
+
isOpened,
|
|
82
|
+
setIsOpened,
|
|
83
|
+
detailWidth,
|
|
84
|
+
setDetailWidth,
|
|
85
|
+
globalAttributes,
|
|
86
|
+
xstyledAttributes,
|
|
87
|
+
actionRef,
|
|
88
|
+
onKeyDown
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
//# sourceMappingURL=usePaginator.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/parts/DSPaginator/usePaginator.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["import { useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';\nimport { omit } from 'lodash';\nimport { useGetGlobalAttributes, useGetXstyledProps } from '@elliemae/ds-props-helpers';\nimport { useOnElementResize } from '@elliemae/ds-utilities';\nimport { usePaginationSearch } from './usePaginationSearch.js';\nimport { getOptions } from './getOptions.js';\nimport type { DSPaginationT } from '../../react-desc-prop-types.js';\n\nexport const usePaginator = (props: DSPaginationT.PaginatorInternalProps) => {\n const { pageIndex, pageCount, pageDetails } = props;\n\n const [isOpened, setIsOpened] = useState(false);\n const [detailWidth, setDetailWidth] = useState(0);\n const [pageInfoWidth, setPageInfoWidth] = useState(0);\n\n const btnRef = useRef<HTMLButtonElement>(null);\n const actionRef = useRef<Record<string, (dsId: string) => void>>({});\n\n const { width: btnWidth } = useOnElementResize(btnRef);\n\n const options = useMemo(\n () => getOptions({ pageCount, pageIndex, pageDetails, pageInfoWidth }),\n [pageCount, pageIndex, pageDetails, pageInfoWidth],\n );\n\n const onKeyDown = usePaginationSearch(pageCount, actionRef);\n\n const globalAttributes = omit(useGetGlobalAttributes(props), ['shape', 'type', 'size']);\n const xstyledAttributes = useGetXstyledProps(props);\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 useLayoutEffect(() => {\n const invisibleDetails = [\n ...document.body.querySelectorAll('[data-testid=\"ds-pagination-invisible-detail-for-width-calc\"]'),\n ] as HTMLDivElement[];\n const maxWidth = invisibleDetails.reduce((acc, cur) => Math.max(acc, cur.getBoundingClientRect().width), 0);\n setDetailWidth(maxWidth);\n }, [pageDetails]);\n\n useEffect(() => {\n setPageInfoWidth(() => {\n // Here we get the size of the page info\n // Inside of the button, we have the page info, the chevron, separators, page details and padding\n // We substract the detailWidth if present, and the padding + chevron + separators in each case\n if (detailWidth) return btnWidth - detailWidth - 89;\n return btnWidth - 56;\n });\n }, [btnWidth, detailWidth]);\n\n return {\n btnRef,\n btnWidth,\n pageInfoWidth,\n options,\n isOpened,\n setIsOpened,\n detailWidth,\n setDetailWidth,\n globalAttributes,\n xstyledAttributes,\n actionRef,\n onKeyDown,\n };\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAsE;AACtE,oBAAqB;AACrB,8BAA2D;AAC3D,0BAAmC;AACnC,iCAAoC;AACpC,wBAA2B;AAGpB,MAAM,eAAe,CAAC,UAAgD;AAC3E,QAAM,EAAE,WAAW,WAAW,YAAY,IAAI;AAE9C,QAAM,CAAC,UAAU,WAAW,QAAI,uBAAS,KAAK;AAC9C,QAAM,CAAC,aAAa,cAAc,QAAI,uBAAS,CAAC;AAChD,QAAM,CAAC,eAAe,gBAAgB,QAAI,uBAAS,CAAC;AAEpD,QAAM,aAAS,qBAA0B,IAAI;AAC7C,QAAM,gBAAY,qBAA+C,CAAC,CAAC;AAEnE,QAAM,EAAE,OAAO,SAAS,QAAI,wCAAmB,MAAM;AAErD,QAAM,cAAU;AAAA,IACd,UAAM,8BAAW,EAAE,WAAW,WAAW,aAAa,cAAc,CAAC;AAAA,IACrE,CAAC,WAAW,WAAW,aAAa,aAAa;AAAA,EACnD;AAEA,QAAM,gBAAY,gDAAoB,WAAW,SAAS;AAE1D,QAAM,uBAAmB,wBAAK,gDAAuB,KAAK,GAAG,CAAC,SAAS,QAAQ,MAAM,CAAC;AACtF,QAAM,wBAAoB,4CAAmB,KAAK;AAElD,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,oCAAgB,MAAM;AACpB,UAAM,mBAAmB;AAAA,MACvB,GAAG,SAAS,KAAK,iBAAiB,+DAA+D;AAAA,IACnG;AACA,UAAM,WAAW,iBAAiB,OAAO,CAAC,KAAK,QAAQ,KAAK,IAAI,KAAK,IAAI,sBAAsB,EAAE,KAAK,GAAG,CAAC;AAC1G,mBAAe,QAAQ;AAAA,EACzB,GAAG,CAAC,WAAW,CAAC;AAEhB,8BAAU,MAAM;AACd,qBAAiB,MAAM;AAIrB,UAAI;AAAa,eAAO,WAAW,cAAc;AACjD,aAAO,WAAW;AAAA,IACpB,CAAC;AAAA,EACH,GAAG,CAAC,UAAU,WAAW,CAAC;AAE1B,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -18,32 +18,35 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
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.
|
|
21
25
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
26
|
mod
|
|
23
27
|
));
|
|
24
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
-
var
|
|
26
|
-
__export(
|
|
27
|
-
|
|
29
|
+
var getOptions_exports = {};
|
|
30
|
+
__export(getOptions_exports, {
|
|
31
|
+
generateOption: () => generateOption,
|
|
32
|
+
getOptions: () => getOptions
|
|
28
33
|
});
|
|
29
|
-
module.exports = __toCommonJS(
|
|
34
|
+
module.exports = __toCommonJS(getOptions_exports);
|
|
30
35
|
var React = __toESM(require("react"));
|
|
31
|
-
var
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const PagePrevButton = ({ onPreviousPage, canPreviousPage }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
36
|
-
import_styled.PreviousNextPageButton,
|
|
37
|
-
{
|
|
38
|
-
onClick: () => {
|
|
39
|
-
if (canPreviousPage)
|
|
40
|
-
onPreviousPage();
|
|
41
|
-
},
|
|
42
|
-
disabled: !canPreviousPage,
|
|
43
|
-
buttonType: "raw",
|
|
44
|
-
"data-testid": import_PaginationDataTestID.PAGINATION_DATA_TESTID.PREVIOUS_BUTTON,
|
|
45
|
-
"aria-label": "Go to previous page",
|
|
46
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ds_icons.ChevronLeft, { color: canPreviousPage ? ["brand-primary", "700"] : ["neutral", "500"] })
|
|
36
|
+
var import_ds_utilities = require("@elliemae/ds-utilities");
|
|
37
|
+
const generateOption = (value) => {
|
|
38
|
+
if (typeof value === "object") {
|
|
39
|
+
return value;
|
|
47
40
|
}
|
|
48
|
-
|
|
49
|
-
|
|
41
|
+
return {
|
|
42
|
+
dsId: value.toString(),
|
|
43
|
+
value,
|
|
44
|
+
label: value.toString(),
|
|
45
|
+
type: "single"
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
const getOptions = (step, min, max) => {
|
|
49
|
+
const options = (0, import_ds_utilities.range)(min, max + step, step).map(generateOption);
|
|
50
|
+
return min === 0 ? options.slice(1, options.length) : options;
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=getOptions.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/parts/DSPerPageSelector/getOptions.ts", "../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["import { range } from '@elliemae/ds-utilities';\nimport type { DSDropdownMenuT } from '@elliemae/ds-dropdownmenu';\n\nexport const generateOption = (\n value: number | DSDropdownMenuT.ItemSingleOptions,\n): DSDropdownMenuT.ItemSingleOptions => {\n if (typeof value === 'object') {\n return value;\n }\n return {\n dsId: value.toString(),\n value,\n label: value.toString(),\n type: 'single',\n } as const;\n};\n\nexport const getOptions = (step: number, min: number, max: number) => {\n const options = range(min, max + step, step).map(generateOption);\n return min === 0 ? options.slice(1, options.length) : options;\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,0BAAsB;AAGf,MAAM,iBAAiB,CAC5B,UACsC;AACtC,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO;AAAA,EACT;AACA,SAAO;AAAA,IACL,MAAM,MAAM,SAAS;AAAA,IACrB;AAAA,IACA,OAAO,MAAM,SAAS;AAAA,IACtB,MAAM;AAAA,EACR;AACF;AAEO,MAAM,aAAa,CAAC,MAAc,KAAa,QAAgB;AACpE,QAAM,cAAU,2BAAM,KAAK,MAAM,MAAM,IAAI,EAAE,IAAI,cAAc;AAC/D,SAAO,QAAQ,IAAI,QAAQ,MAAM,GAAG,QAAQ,MAAM,IAAI;AACxD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
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 DSPerPageSelector_exports = {};
|
|
30
|
+
__export(DSPerPageSelector_exports, {
|
|
31
|
+
DSPerPageSelector: () => DSPerPageSelector,
|
|
32
|
+
DSPerPageSelectorWithSchema: () => DSPerPageSelectorWithSchema
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(DSPerPageSelector_exports);
|
|
35
|
+
var React = __toESM(require("react"));
|
|
36
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
37
|
+
var import_react = require("react");
|
|
38
|
+
var import_ds_props_helpers = require("@elliemae/ds-props-helpers");
|
|
39
|
+
var import_ds_dropdownmenu = require("@elliemae/ds-dropdownmenu");
|
|
40
|
+
var import_ds_icons = require("@elliemae/ds-icons");
|
|
41
|
+
var import_react_desc_prop_types = require("../../react-desc-prop-types.js");
|
|
42
|
+
var import_styled = require("../../styled.js");
|
|
43
|
+
var import_DSPaginationDefinitions = require("../../DSPaginationDefinitions.js");
|
|
44
|
+
var import_usePerPageSelector = require("./usePerPageSelector.js");
|
|
45
|
+
var import_PaginationDataTestID = require("../../PaginationDataTestID.js");
|
|
46
|
+
const Header = () => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: "Per Page" });
|
|
47
|
+
const DSPerPageSelector = (props) => {
|
|
48
|
+
const propsWithDefault = (0, import_ds_props_helpers.useMemoMergePropsWithDefault)(
|
|
49
|
+
props,
|
|
50
|
+
import_react_desc_prop_types.perPageSelectorDefaultProps
|
|
51
|
+
);
|
|
52
|
+
(0, import_ds_props_helpers.useValidateTypescriptPropTypes)(propsWithDefault, import_react_desc_prop_types.DSPerPageSelectorPropTypesSchema, import_DSPaginationDefinitions.PerPageSelectorName);
|
|
53
|
+
const { pageSize, onPageSizeChange } = propsWithDefault;
|
|
54
|
+
const { actionRef, btnRef, width, isOpened, setIsOpened, options, globalAttributes, xstyledAttributes } = (0, import_usePerPageSelector.usePerPageSelector)(propsWithDefault);
|
|
55
|
+
const buttonOnClick = (0, import_react.useMemo)(() => {
|
|
56
|
+
if (globalAttributes.onClick)
|
|
57
|
+
return globalAttributes.onClick;
|
|
58
|
+
return () => setIsOpened((prev) => !prev);
|
|
59
|
+
}, [globalAttributes.onClick, setIsOpened]);
|
|
60
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
61
|
+
import_ds_dropdownmenu.DSDropdownMenuV2,
|
|
62
|
+
{
|
|
63
|
+
isOpened,
|
|
64
|
+
options,
|
|
65
|
+
selectedOptions: { [pageSize.toString()]: true },
|
|
66
|
+
onOptionClick: (_, clickedOption) => {
|
|
67
|
+
onPageSizeChange(clickedOption.value);
|
|
68
|
+
setIsOpened(false);
|
|
69
|
+
btnRef.current?.focus();
|
|
70
|
+
},
|
|
71
|
+
onClickOutside: () => {
|
|
72
|
+
setIsOpened(false);
|
|
73
|
+
btnRef.current?.focus();
|
|
74
|
+
},
|
|
75
|
+
customOffset: [-23, 2],
|
|
76
|
+
startPlacementPreference: "top-start",
|
|
77
|
+
actionRef,
|
|
78
|
+
minWidth: width,
|
|
79
|
+
maxHeight: 300,
|
|
80
|
+
HeaderComp: Header,
|
|
81
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
82
|
+
import_styled.PaginationDropdownButton,
|
|
83
|
+
{
|
|
84
|
+
buttonType: "raw",
|
|
85
|
+
innerRef: btnRef,
|
|
86
|
+
"aria-pressed": isOpened,
|
|
87
|
+
"aria-label": `${pageSize} rows per page. Press to select rows per page`,
|
|
88
|
+
"data-testid": import_PaginationDataTestID.PAGINATION_DATA_TESTID.PER_PAGE_SELECTOR,
|
|
89
|
+
...globalAttributes,
|
|
90
|
+
...xstyledAttributes,
|
|
91
|
+
onClick: buttonOnClick,
|
|
92
|
+
children: [
|
|
93
|
+
pageSize,
|
|
94
|
+
" / page",
|
|
95
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ds_icons.ChevronDown, { color: ["brand-primary", "700"] })
|
|
96
|
+
]
|
|
97
|
+
}
|
|
98
|
+
)
|
|
99
|
+
}
|
|
100
|
+
);
|
|
101
|
+
};
|
|
102
|
+
DSPerPageSelector.propTypes = import_react_desc_prop_types.DSPerPageSelectorPropTypesSchema;
|
|
103
|
+
DSPerPageSelector.displayName = import_DSPaginationDefinitions.PerPageSelectorName;
|
|
104
|
+
const DSPerPageSelectorWithSchema = (0, import_ds_props_helpers.describe)(DSPerPageSelector).description("Per Page Selector");
|
|
105
|
+
DSPerPageSelectorWithSchema.propTypes = import_react_desc_prop_types.DSPerPageSelectorPropTypesSchema;
|
|
106
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/parts/DSPerPageSelector/index.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["import React, { useMemo } from 'react';\nimport { describe, useMemoMergePropsWithDefault, useValidateTypescriptPropTypes } from '@elliemae/ds-props-helpers';\nimport type { DSDropdownMenuT } from '@elliemae/ds-dropdownmenu';\nimport { DSDropdownMenuV2 } from '@elliemae/ds-dropdownmenu';\nimport { ChevronDown } from '@elliemae/ds-icons';\nimport { perPageSelectorDefaultProps, DSPerPageSelectorPropTypesSchema } from '../../react-desc-prop-types.js';\nimport { PaginationDropdownButton } from '../../styled.js';\nimport { PerPageSelectorName } from '../../DSPaginationDefinitions.js';\nimport { usePerPageSelector } from './usePerPageSelector.js';\nimport { PAGINATION_DATA_TESTID } from '../../PaginationDataTestID.js';\nimport type { DSPaginationT } from '../../react-desc-prop-types.js';\nimport type { DSButtonT } from '@elliemae/ds-button-v2';\n\nconst Header = () => <>{'Per Page'}</>;\n\nexport const DSPerPageSelector: React.ComponentType<DSPaginationT.PerPageSelectorProps> = (props) => {\n const propsWithDefault = useMemoMergePropsWithDefault<DSPaginationT.PerPageSelectorInternalProps>(\n props,\n perPageSelectorDefaultProps,\n );\n useValidateTypescriptPropTypes(propsWithDefault, DSPerPageSelectorPropTypesSchema, PerPageSelectorName);\n\n const { pageSize, onPageSizeChange } = propsWithDefault;\n\n const { actionRef, btnRef, width, isOpened, setIsOpened, options, globalAttributes, xstyledAttributes } =\n usePerPageSelector(propsWithDefault);\n\n const buttonOnClick: DSButtonT.Props['onClick'] = useMemo(() => {\n if (globalAttributes.onClick) return globalAttributes.onClick as DSButtonT.Props['onClick'];\n return () => setIsOpened((prev) => !prev);\n }, [globalAttributes.onClick, setIsOpened]);\n\n return (\n <DSDropdownMenuV2\n isOpened={isOpened}\n options={options}\n selectedOptions={{ [pageSize.toString()]: true }}\n onOptionClick={(_, clickedOption) => {\n onPageSizeChange((clickedOption as DSDropdownMenuT.ItemSingleOptions).value as number);\n setIsOpened(false);\n btnRef.current?.focus();\n }}\n onClickOutside={() => {\n setIsOpened(false);\n btnRef.current?.focus();\n }}\n customOffset={[-23, 2]}\n startPlacementPreference=\"top-start\"\n actionRef={actionRef}\n minWidth={width}\n maxHeight={300}\n HeaderComp={Header}\n >\n <PaginationDropdownButton\n buttonType=\"raw\"\n innerRef={btnRef}\n aria-pressed={isOpened}\n aria-label={`${pageSize} rows per page. Press to select rows per page`}\n data-testid={PAGINATION_DATA_TESTID.PER_PAGE_SELECTOR}\n {...globalAttributes}\n {...xstyledAttributes}\n onClick={buttonOnClick}\n >\n {pageSize} / page\n <ChevronDown color={['brand-primary', '700']} />\n </PaginationDropdownButton>\n </DSDropdownMenuV2>\n );\n};\n\nDSPerPageSelector.propTypes = DSPerPageSelectorPropTypesSchema;\nDSPerPageSelector.displayName = PerPageSelectorName;\nexport const DSPerPageSelectorWithSchema = describe(DSPerPageSelector).description('Per Page Selector');\nDSPerPageSelectorWithSchema.propTypes = DSPerPageSelectorPropTypesSchema;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADaF;AAbrB,mBAA+B;AAC/B,8BAAuF;AAEvF,6BAAiC;AACjC,sBAA4B;AAC5B,mCAA8E;AAC9E,oBAAyC;AACzC,qCAAoC;AACpC,gCAAmC;AACnC,kCAAuC;AAIvC,MAAM,SAAS,MAAM,2EAAG,sBAAW;AAE5B,MAAM,oBAA6E,CAAC,UAAU;AACnG,QAAM,uBAAmB;AAAA,IACvB;AAAA,IACA;AAAA,EACF;AACA,8DAA+B,kBAAkB,+DAAkC,kDAAmB;AAEtG,QAAM,EAAE,UAAU,iBAAiB,IAAI;AAEvC,QAAM,EAAE,WAAW,QAAQ,OAAO,UAAU,aAAa,SAAS,kBAAkB,kBAAkB,QACpG,8CAAmB,gBAAgB;AAErC,QAAM,oBAA4C,sBAAQ,MAAM;AAC9D,QAAI,iBAAiB;AAAS,aAAO,iBAAiB;AACtD,WAAO,MAAM,YAAY,CAAC,SAAS,CAAC,IAAI;AAAA,EAC1C,GAAG,CAAC,iBAAiB,SAAS,WAAW,CAAC;AAE1C,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA,iBAAiB,EAAE,CAAC,SAAS,SAAS,CAAC,GAAG,KAAK;AAAA,MAC/C,eAAe,CAAC,GAAG,kBAAkB;AACnC,yBAAkB,cAAoD,KAAe;AACrF,oBAAY,KAAK;AACjB,eAAO,SAAS,MAAM;AAAA,MACxB;AAAA,MACA,gBAAgB,MAAM;AACpB,oBAAY,KAAK;AACjB,eAAO,SAAS,MAAM;AAAA,MACxB;AAAA,MACA,cAAc,CAAC,KAAK,CAAC;AAAA,MACrB,0BAAyB;AAAA,MACzB;AAAA,MACA,UAAU;AAAA,MACV,WAAW;AAAA,MACX,YAAY;AAAA,MAEZ;AAAA,QAAC;AAAA;AAAA,UACC,YAAW;AAAA,UACX,UAAU;AAAA,UACV,gBAAc;AAAA,UACd,cAAY,GAAG;AAAA,UACf,eAAa,mDAAuB;AAAA,UACnC,GAAG;AAAA,UACH,GAAG;AAAA,UACJ,SAAS;AAAA,UAER;AAAA;AAAA,YAAS;AAAA,YACV,4CAAC,+BAAY,OAAO,CAAC,iBAAiB,KAAK,GAAG;AAAA;AAAA;AAAA,MAChD;AAAA;AAAA,EACF;AAEJ;AAEA,kBAAkB,YAAY;AAC9B,kBAAkB,cAAc;AACzB,MAAM,kCAA8B,kCAAS,iBAAiB,EAAE,YAAY,mBAAmB;AACtG,4BAA4B,YAAY;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
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 usePerPageSelector_exports = {};
|
|
30
|
+
__export(usePerPageSelector_exports, {
|
|
31
|
+
usePerPageSelector: () => usePerPageSelector
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(usePerPageSelector_exports);
|
|
34
|
+
var React = __toESM(require("react"));
|
|
35
|
+
var import_react = require("react");
|
|
36
|
+
var import_lodash = require("lodash");
|
|
37
|
+
var import_ds_props_helpers = require("@elliemae/ds-props-helpers");
|
|
38
|
+
var import_getOptions = require("./getOptions.js");
|
|
39
|
+
const usePerPageSelector = (props) => {
|
|
40
|
+
const { pageSize, perPageOptions, perPageStep, minPerPage, maxPerPage } = props;
|
|
41
|
+
const [isOpened, setIsOpened] = (0, import_react.useState)(false);
|
|
42
|
+
const options = (0, import_react.useMemo)(() => {
|
|
43
|
+
if (perPageOptions)
|
|
44
|
+
return perPageOptions.map(import_getOptions.generateOption);
|
|
45
|
+
return (0, import_getOptions.getOptions)(perPageStep, minPerPage, maxPerPage);
|
|
46
|
+
}, [maxPerPage, minPerPage, perPageOptions, perPageStep]);
|
|
47
|
+
const actionRef = (0, import_react.useRef)({});
|
|
48
|
+
const btnRef = (0, import_react.useRef)(null);
|
|
49
|
+
(0, import_react.useEffect)(() => {
|
|
50
|
+
if (isOpened) {
|
|
51
|
+
actionRef.current.setActiveDescendant(pageSize.toString());
|
|
52
|
+
actionRef.current.scrollOptionIntoView(pageSize.toString());
|
|
53
|
+
}
|
|
54
|
+
}, [isOpened]);
|
|
55
|
+
const width = (0, import_react.useMemo)(() => {
|
|
56
|
+
const maxLength = options.reduce((acc, cur) => Math.max(acc, ("label" in cur ? cur.label : "").length), 0);
|
|
57
|
+
return maxLength * 6 + 90;
|
|
58
|
+
}, [options]);
|
|
59
|
+
const globalAttributes = (0, import_lodash.omit)((0, import_ds_props_helpers.useGetGlobalAttributes)(props), ["shape", "type", "size"]);
|
|
60
|
+
const xstyledAttributes = (0, import_ds_props_helpers.useGetXstyledProps)(props);
|
|
61
|
+
return {
|
|
62
|
+
actionRef,
|
|
63
|
+
btnRef,
|
|
64
|
+
width,
|
|
65
|
+
isOpened,
|
|
66
|
+
setIsOpened,
|
|
67
|
+
options,
|
|
68
|
+
globalAttributes,
|
|
69
|
+
xstyledAttributes
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
//# sourceMappingURL=usePerPageSelector.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/parts/DSPerPageSelector/usePerPageSelector.ts", "../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["import { useEffect, useMemo, useRef, useState } from 'react';\nimport { omit } from 'lodash';\nimport { useGetGlobalAttributes, useGetXstyledProps } from '@elliemae/ds-props-helpers';\nimport { generateOption, getOptions } from './getOptions.js';\nimport type { DSPaginationT } from '../../react-desc-prop-types.js';\n\nexport const usePerPageSelector = (props: DSPaginationT.PerPageSelectorInternalProps) => {\n const { pageSize, perPageOptions, perPageStep, minPerPage, maxPerPage } = props;\n\n const [isOpened, setIsOpened] = useState(false);\n\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 actionRef = useRef<Record<string, (dsId: string) => void>>({});\n const btnRef = useRef<HTMLButtonElement>(null);\n\n useEffect(() => {\n if (isOpened) {\n actionRef.current.setActiveDescendant(pageSize.toString());\n actionRef.current.scrollOptionIntoView(pageSize.toString());\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [isOpened]);\n\n const width = useMemo(() => {\n const maxLength = options.reduce((acc, cur) => Math.max(acc, ('label' in cur ? cur.label : '').length), 0);\n return maxLength * 6 + 90;\n }, [options]);\n\n const globalAttributes = omit(useGetGlobalAttributes(props), ['shape', 'type', 'size']);\n const xstyledAttributes = useGetXstyledProps(props);\n\n return {\n actionRef,\n btnRef,\n width,\n isOpened,\n setIsOpened,\n options,\n globalAttributes,\n xstyledAttributes,\n };\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAqD;AACrD,oBAAqB;AACrB,8BAA2D;AAC3D,wBAA2C;AAGpC,MAAM,qBAAqB,CAAC,UAAsD;AACvF,QAAM,EAAE,UAAU,gBAAgB,aAAa,YAAY,WAAW,IAAI;AAE1E,QAAM,CAAC,UAAU,WAAW,QAAI,uBAAS,KAAK;AAE9C,QAAM,cAAU,sBAAQ,MAAM;AAC5B,QAAI;AAAgB,aAAO,eAAe,IAAI,gCAAc;AAC5D,eAAO,8BAAW,aAAa,YAAY,UAAU;AAAA,EACvD,GAAG,CAAC,YAAY,YAAY,gBAAgB,WAAW,CAAC;AAExD,QAAM,gBAAY,qBAA+C,CAAC,CAAC;AACnE,QAAM,aAAS,qBAA0B,IAAI;AAE7C,8BAAU,MAAM;AACd,QAAI,UAAU;AACZ,gBAAU,QAAQ,oBAAoB,SAAS,SAAS,CAAC;AACzD,gBAAU,QAAQ,qBAAqB,SAAS,SAAS,CAAC;AAAA,IAC5D;AAAA,EAEF,GAAG,CAAC,QAAQ,CAAC;AAEb,QAAM,YAAQ,sBAAQ,MAAM;AAC1B,UAAM,YAAY,QAAQ,OAAO,CAAC,KAAK,QAAQ,KAAK,IAAI,MAAM,WAAW,MAAM,IAAI,QAAQ,IAAI,MAAM,GAAG,CAAC;AACzG,WAAO,YAAY,IAAI;AAAA,EACzB,GAAG,CAAC,OAAO,CAAC;AAEZ,QAAM,uBAAmB,wBAAK,gDAAuB,KAAK,GAAG,CAAC,SAAS,QAAQ,MAAM,CAAC;AACtF,QAAM,wBAAoB,4CAAmB,KAAK;AAElD,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|