@elliemae/ds-pagination 3.16.0-next.4 → 3.16.0-next.5
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 +13 -1
- package/dist/cjs/DSPaginationDefinitions.js.map +2 -2
- package/dist/cjs/PaginationDataTestID.js +3 -1
- package/dist/cjs/PaginationDataTestID.js.map +2 -2
- package/dist/cjs/index.js +32 -2
- package/dist/cjs/index.js.map +3 -3
- package/dist/cjs/parts/DSPageNextButton.js +70 -0
- package/dist/cjs/parts/DSPageNextButton.js.map +7 -0
- package/dist/cjs/parts/DSPagePrevButton.js +70 -0
- package/dist/cjs/parts/DSPagePrevButton.js.map +7 -0
- package/dist/cjs/parts/DSPaginationContainer.js +57 -0
- package/dist/cjs/parts/DSPaginationContainer.js.map +7 -0
- package/dist/cjs/parts/{PageNextButton.js → DSPaginator/createPaginatorHeader.js} +19 -25
- package/dist/cjs/parts/DSPaginator/createPaginatorHeader.js.map +7 -0
- package/dist/cjs/parts/DSPaginator/getOptions.js +72 -0
- package/dist/cjs/parts/DSPaginator/getOptions.js.map +7 -0
- package/dist/cjs/parts/DSPaginator/index.js +144 -0
- package/dist/cjs/parts/DSPaginator/index.js.map +7 -0
- package/dist/cjs/{hooks → parts/DSPaginator}/usePaginationSearch.js +5 -2
- package/dist/cjs/parts/DSPaginator/usePaginationSearch.js.map +7 -0
- package/dist/cjs/parts/DSPaginator/usePaginator.js +87 -0
- package/dist/cjs/parts/DSPaginator/usePaginator.js.map +7 -0
- package/dist/cjs/parts/{PagePrevButton.js → DSPerPageSelector/getOptions.js} +21 -22
- package/dist/cjs/parts/DSPerPageSelector/getOptions.js.map +7 -0
- package/dist/cjs/parts/{PerPageSelector.js → DSPerPageSelector/index.js} +37 -49
- package/dist/cjs/parts/DSPerPageSelector/index.js.map +7 -0
- package/dist/cjs/parts/DSPerPageSelector/usePerPageSelector.js +68 -0
- package/dist/cjs/parts/DSPerPageSelector/usePerPageSelector.js.map +7 -0
- package/dist/cjs/parts/PaginationContent.js +36 -51
- package/dist/cjs/parts/PaginationContent.js.map +3 -3
- package/dist/cjs/parts/index.js +45 -0
- package/dist/cjs/parts/index.js.map +7 -0
- package/dist/cjs/react-desc-prop-types.js +107 -33
- package/dist/cjs/react-desc-prop-types.js.map +2 -2
- package/dist/cjs/styled.js +17 -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/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/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/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/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/index.d.ts +5 -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 +16 -11
- package/dist/cjs/hooks/usePaginationSearch.js.map +0 -7
- package/dist/cjs/package.json +0 -7
- 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.map +0 -7
- package/dist/esm/hooks/usePaginationSearch.js.map +0 -7
- package/dist/esm/package.json +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
package/dist/esm/index.js
CHANGED
|
@@ -1,3 +1,41 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
|
|
2
|
+
import { DSPaginationSeparator } from "./styled";
|
|
3
|
+
import { DSPaginationStyledPartPropTypesSchema } from "./react-desc-prop-types";
|
|
4
|
+
import { describe } from "@elliemae/ds-props-helpers";
|
|
5
|
+
import { PaginationSeparatorName } from "./DSPaginationDefinitions";
|
|
6
|
+
DSPaginationSeparator.propTypes = DSPaginationStyledPartPropTypesSchema;
|
|
7
|
+
DSPaginationSeparator.displayName = PaginationSeparatorName;
|
|
8
|
+
const DSPaginationSeparatorWithSchema = describe(DSPaginationSeparator).description("Pagination Separator");
|
|
9
|
+
import { DSPagination, DSPaginationWithSchema } from "./Pagination";
|
|
10
|
+
import {
|
|
11
|
+
DSPageNextButton,
|
|
12
|
+
DSPageNextButtonWithSchema,
|
|
13
|
+
DSPagePrevButton,
|
|
14
|
+
DSPagePrevButtonWithSchema,
|
|
15
|
+
DSPaginationContainer,
|
|
16
|
+
DSPaginationContainerWithSchema,
|
|
17
|
+
DSPerPageSelector,
|
|
18
|
+
DSPerPageSelectorWithSchema,
|
|
19
|
+
DSPaginator,
|
|
20
|
+
DSPaginatorWithSchema
|
|
21
|
+
} from "./parts";
|
|
22
|
+
import { DSPaginationSeparator as DSPaginationSeparator2 } from "./styled";
|
|
23
|
+
import { PAGINATION_DATA_TESTID } from "./PaginationDataTestID";
|
|
24
|
+
export {
|
|
25
|
+
DSPageNextButton,
|
|
26
|
+
DSPageNextButtonWithSchema,
|
|
27
|
+
DSPagePrevButton,
|
|
28
|
+
DSPagePrevButtonWithSchema,
|
|
29
|
+
DSPagination,
|
|
30
|
+
DSPaginationContainer,
|
|
31
|
+
DSPaginationContainerWithSchema,
|
|
32
|
+
DSPaginationSeparator2 as DSPaginationSeparator,
|
|
33
|
+
DSPaginationSeparatorWithSchema,
|
|
34
|
+
DSPaginationWithSchema,
|
|
35
|
+
DSPaginator,
|
|
36
|
+
DSPaginatorWithSchema,
|
|
37
|
+
DSPerPageSelector,
|
|
38
|
+
DSPerPageSelectorWithSchema,
|
|
39
|
+
PAGINATION_DATA_TESTID
|
|
40
|
+
};
|
|
3
41
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACAvB,cAAc;",
|
|
6
|
-
"names": []
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { DSPaginationSeparator } from './styled';\nimport { DSPaginationStyledPartPropTypesSchema } from './react-desc-prop-types';\nimport { describe } from '@elliemae/ds-props-helpers';\nimport { PaginationSeparatorName } from './DSPaginationDefinitions';\n\nDSPaginationSeparator.propTypes = DSPaginationStyledPartPropTypesSchema;\nDSPaginationSeparator.displayName = PaginationSeparatorName;\nconst DSPaginationSeparatorWithSchema = describe(DSPaginationSeparator).description('Pagination Separator');\n\nexport { DSPagination, DSPaginationWithSchema } from './Pagination';\nexport {\n DSPageNextButton,\n DSPageNextButtonWithSchema,\n DSPagePrevButton,\n DSPagePrevButtonWithSchema,\n DSPaginationContainer,\n DSPaginationContainerWithSchema,\n DSPerPageSelector,\n DSPerPageSelectorWithSchema,\n DSPaginator,\n DSPaginatorWithSchema,\n} from './parts';\n\nexport { DSPaginationSeparator } from './styled';\n\nexport { DSPaginationSeparatorWithSchema };\n\nexport { PAGINATION_DATA_TESTID } from './PaginationDataTestID';\n\nexport type { DSPaginationT } from './react-desc-prop-types';\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,6BAA6B;AACtC,SAAS,6CAA6C;AACtD,SAAS,gBAAgB;AACzB,SAAS,+BAA+B;AAExC,sBAAsB,YAAY;AAClC,sBAAsB,cAAc;AACpC,MAAM,kCAAkC,SAAS,qBAAqB,EAAE,YAAY,sBAAsB;AAE1G,SAAS,cAAc,8BAA8B;AACrD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,yBAAAA,8BAA6B;AAItC,SAAS,8BAA8B;",
|
|
6
|
+
"names": ["DSPaginationSeparator"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { omit } from "lodash";
|
|
4
|
+
import { ChevronRight } from "@elliemae/ds-icons";
|
|
5
|
+
import {
|
|
6
|
+
describe,
|
|
7
|
+
useGetGlobalAttributes,
|
|
8
|
+
useGetXstyledProps,
|
|
9
|
+
useMemoMergePropsWithDefault,
|
|
10
|
+
useValidateTypescriptPropTypes
|
|
11
|
+
} from "@elliemae/ds-props-helpers";
|
|
12
|
+
import { PAGINATION_DATA_TESTID } from "../PaginationDataTestID";
|
|
13
|
+
import { PreviousNextPageButton } from "../styled";
|
|
14
|
+
import { pageNextButtonDefaultProps, DSPageNextButtonPropTypesSchema } from "../react-desc-prop-types";
|
|
15
|
+
import { PageNextButtonName } from "../DSPaginationDefinitions";
|
|
16
|
+
const DSPageNextButton = (props) => {
|
|
17
|
+
const propsWithDefault = useMemoMergePropsWithDefault(
|
|
18
|
+
props,
|
|
19
|
+
pageNextButtonDefaultProps
|
|
20
|
+
);
|
|
21
|
+
useValidateTypescriptPropTypes(propsWithDefault, DSPageNextButtonPropTypesSchema, PageNextButtonName);
|
|
22
|
+
const { canNextPage, onNextPage } = propsWithDefault;
|
|
23
|
+
const globalAttributes = omit(useGetGlobalAttributes(propsWithDefault), "shape", "size", "type");
|
|
24
|
+
const xstyledAttributes = useGetXstyledProps(propsWithDefault);
|
|
25
|
+
return /* @__PURE__ */ jsx(
|
|
26
|
+
PreviousNextPageButton,
|
|
27
|
+
{
|
|
28
|
+
disabled: !canNextPage,
|
|
29
|
+
buttonType: "raw",
|
|
30
|
+
"data-testid": PAGINATION_DATA_TESTID.NEXT_BUTTON,
|
|
31
|
+
"aria-label": "Go to next page",
|
|
32
|
+
...globalAttributes,
|
|
33
|
+
...xstyledAttributes,
|
|
34
|
+
onClick: () => {
|
|
35
|
+
if (canNextPage)
|
|
36
|
+
onNextPage();
|
|
37
|
+
},
|
|
38
|
+
children: /* @__PURE__ */ jsx(ChevronRight, { color: canNextPage ? ["brand-primary", "700"] : ["neutral", "500"] })
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
};
|
|
42
|
+
DSPageNextButton.propTypes = DSPageNextButtonPropTypesSchema;
|
|
43
|
+
DSPageNextButton.displayName = PageNextButtonName;
|
|
44
|
+
const DSPageNextButtonWithSchema = describe(DSPageNextButton).description("Per Page Selector");
|
|
45
|
+
DSPageNextButtonWithSchema.propTypes = DSPageNextButtonPropTypesSchema;
|
|
46
|
+
export {
|
|
47
|
+
DSPageNextButton,
|
|
48
|
+
DSPageNextButtonWithSchema
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=DSPageNextButton.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/parts/DSPageNextButton.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable react/prop-types */\nimport React from 'react';\nimport { omit } from 'lodash';\nimport { ChevronRight } from '@elliemae/ds-icons';\nimport {\n describe,\n useGetGlobalAttributes,\n useGetXstyledProps,\n useMemoMergePropsWithDefault,\n useValidateTypescriptPropTypes,\n} from '@elliemae/ds-props-helpers';\nimport { PAGINATION_DATA_TESTID } from '../PaginationDataTestID';\nimport { PreviousNextPageButton } from '../styled';\nimport { pageNextButtonDefaultProps, DSPageNextButtonPropTypesSchema } from '../react-desc-prop-types';\nimport { PageNextButtonName } from '../DSPaginationDefinitions';\nimport type { DSPaginationT } from '../react-desc-prop-types';\n\nexport const DSPageNextButton: React.ComponentType<DSPaginationT.PageNextButtonProps> = (props) => {\n const propsWithDefault = useMemoMergePropsWithDefault<DSPaginationT.PageNextButtonInternalProps>(\n props,\n pageNextButtonDefaultProps,\n );\n useValidateTypescriptPropTypes(propsWithDefault, DSPageNextButtonPropTypesSchema, PageNextButtonName);\n\n const { canNextPage, onNextPage } = propsWithDefault;\n const globalAttributes = omit(useGetGlobalAttributes(propsWithDefault), 'shape', 'size', 'type');\n const xstyledAttributes = useGetXstyledProps(propsWithDefault);\n\n return (\n <PreviousNextPageButton\n disabled={!canNextPage}\n buttonType=\"raw\"\n data-testid={PAGINATION_DATA_TESTID.NEXT_BUTTON}\n aria-label=\"Go to next page\"\n {...globalAttributes}\n {...xstyledAttributes}\n onClick={() => {\n if (canNextPage) onNextPage();\n }}\n >\n <ChevronRight color={canNextPage ? ['brand-primary', '700'] : ['neutral', '500']} />\n </PreviousNextPageButton>\n );\n};\n\nDSPageNextButton.propTypes = DSPageNextButtonPropTypesSchema;\nDSPageNextButton.displayName = PageNextButtonName;\nexport const DSPageNextButtonWithSchema = describe(DSPageNextButton).description('Per Page Selector');\nDSPageNextButtonWithSchema.propTypes = DSPageNextButtonPropTypesSchema;\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACwCjB;AAtCN,SAAS,YAAY;AACrB,SAAS,oBAAoB;AAC7B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,8BAA8B;AACvC,SAAS,8BAA8B;AACvC,SAAS,4BAA4B,uCAAuC;AAC5E,SAAS,0BAA0B;AAG5B,MAAM,mBAA2E,CAAC,UAAU;AACjG,QAAM,mBAAmB;AAAA,IACvB;AAAA,IACA;AAAA,EACF;AACA,iCAA+B,kBAAkB,iCAAiC,kBAAkB;AAEpG,QAAM,EAAE,aAAa,WAAW,IAAI;AACpC,QAAM,mBAAmB,KAAK,uBAAuB,gBAAgB,GAAG,SAAS,QAAQ,MAAM;AAC/F,QAAM,oBAAoB,mBAAmB,gBAAgB;AAE7D,SACE;AAAA,IAAC;AAAA;AAAA,MACC,UAAU,CAAC;AAAA,MACX,YAAW;AAAA,MACX,eAAa,uBAAuB;AAAA,MACpC,cAAW;AAAA,MACV,GAAG;AAAA,MACH,GAAG;AAAA,MACJ,SAAS,MAAM;AACb,YAAI;AAAa,qBAAW;AAAA,MAC9B;AAAA,MAEA,8BAAC,gBAAa,OAAO,cAAc,CAAC,iBAAiB,KAAK,IAAI,CAAC,WAAW,KAAK,GAAG;AAAA;AAAA,EACpF;AAEJ;AAEA,iBAAiB,YAAY;AAC7B,iBAAiB,cAAc;AACxB,MAAM,6BAA6B,SAAS,gBAAgB,EAAE,YAAY,mBAAmB;AACpG,2BAA2B,YAAY;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { omit } from "lodash";
|
|
4
|
+
import { ChevronLeft } from "@elliemae/ds-icons";
|
|
5
|
+
import { PAGINATION_DATA_TESTID } from "../PaginationDataTestID";
|
|
6
|
+
import { PreviousNextPageButton } from "../styled";
|
|
7
|
+
import { pagePrevButtonDefaultProps, DSPagePrevButtonPropTypesSchema } from "../react-desc-prop-types";
|
|
8
|
+
import {
|
|
9
|
+
describe,
|
|
10
|
+
useGetGlobalAttributes,
|
|
11
|
+
useGetXstyledProps,
|
|
12
|
+
useMemoMergePropsWithDefault,
|
|
13
|
+
useValidateTypescriptPropTypes
|
|
14
|
+
} from "@elliemae/ds-props-helpers";
|
|
15
|
+
import { PagePrevButtonName } from "../DSPaginationDefinitions";
|
|
16
|
+
const DSPagePrevButton = (props) => {
|
|
17
|
+
const propsWithDefault = useMemoMergePropsWithDefault(
|
|
18
|
+
props,
|
|
19
|
+
pagePrevButtonDefaultProps
|
|
20
|
+
);
|
|
21
|
+
useValidateTypescriptPropTypes(propsWithDefault, DSPagePrevButtonPropTypesSchema, PagePrevButtonName);
|
|
22
|
+
const { canPreviousPage, onPreviousPage } = propsWithDefault;
|
|
23
|
+
const globalAttributes = omit(useGetGlobalAttributes(propsWithDefault), "shape", "size", "type");
|
|
24
|
+
const xstyledAttributes = useGetXstyledProps(propsWithDefault);
|
|
25
|
+
return /* @__PURE__ */ jsx(
|
|
26
|
+
PreviousNextPageButton,
|
|
27
|
+
{
|
|
28
|
+
disabled: !canPreviousPage,
|
|
29
|
+
buttonType: "raw",
|
|
30
|
+
"data-testid": PAGINATION_DATA_TESTID.PREVIOUS_BUTTON,
|
|
31
|
+
"aria-label": "Go to previous page",
|
|
32
|
+
...globalAttributes,
|
|
33
|
+
...xstyledAttributes,
|
|
34
|
+
onClick: () => {
|
|
35
|
+
if (canPreviousPage)
|
|
36
|
+
onPreviousPage();
|
|
37
|
+
},
|
|
38
|
+
children: /* @__PURE__ */ jsx(ChevronLeft, { color: canPreviousPage ? ["brand-primary", "700"] : ["neutral", "500"] })
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
};
|
|
42
|
+
DSPagePrevButton.propTypes = DSPagePrevButtonPropTypesSchema;
|
|
43
|
+
DSPagePrevButton.displayName = PagePrevButtonName;
|
|
44
|
+
const DSPagePrevButtonWithSchema = describe(DSPagePrevButton).description("Per Page Selector");
|
|
45
|
+
DSPagePrevButtonWithSchema.propTypes = DSPagePrevButtonPropTypesSchema;
|
|
46
|
+
export {
|
|
47
|
+
DSPagePrevButton,
|
|
48
|
+
DSPagePrevButtonWithSchema
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=DSPagePrevButton.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/parts/DSPagePrevButton.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable react/prop-types */\nimport React from 'react';\nimport { omit } from 'lodash';\nimport { ChevronLeft } from '@elliemae/ds-icons';\nimport { PAGINATION_DATA_TESTID } from '../PaginationDataTestID';\nimport { PreviousNextPageButton } from '../styled';\nimport { pagePrevButtonDefaultProps, DSPagePrevButtonPropTypesSchema } from '../react-desc-prop-types';\nimport {\n describe,\n useGetGlobalAttributes,\n useGetXstyledProps,\n useMemoMergePropsWithDefault,\n useValidateTypescriptPropTypes,\n} from '@elliemae/ds-props-helpers';\nimport { PagePrevButtonName } from '../DSPaginationDefinitions';\nimport type { DSPaginationT } from '../react-desc-prop-types';\n\nexport const DSPagePrevButton: React.ComponentType<DSPaginationT.PagePrevButtonProps> = (props) => {\n const propsWithDefault = useMemoMergePropsWithDefault<DSPaginationT.PagePrevButtonInternalProps>(\n props,\n pagePrevButtonDefaultProps,\n );\n useValidateTypescriptPropTypes(propsWithDefault, DSPagePrevButtonPropTypesSchema, PagePrevButtonName);\n\n const { canPreviousPage, onPreviousPage } = propsWithDefault;\n const globalAttributes = omit(useGetGlobalAttributes(propsWithDefault), 'shape', 'size', 'type');\n const xstyledAttributes = useGetXstyledProps(propsWithDefault);\n\n return (\n <PreviousNextPageButton\n disabled={!canPreviousPage}\n buttonType=\"raw\"\n data-testid={PAGINATION_DATA_TESTID.PREVIOUS_BUTTON}\n aria-label=\"Go to previous page\"\n {...globalAttributes}\n {...xstyledAttributes}\n onClick={() => {\n if (canPreviousPage) onPreviousPage();\n }}\n >\n <ChevronLeft color={canPreviousPage ? ['brand-primary', '700'] : ['neutral', '500']} />\n </PreviousNextPageButton>\n );\n};\n\nDSPagePrevButton.propTypes = DSPagePrevButtonPropTypesSchema;\nDSPagePrevButton.displayName = PagePrevButtonName;\nexport const DSPagePrevButtonWithSchema = describe(DSPagePrevButton).description('Per Page Selector');\nDSPagePrevButtonWithSchema.propTypes = DSPagePrevButtonPropTypesSchema;\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACwCjB;AAtCN,SAAS,YAAY;AACrB,SAAS,mBAAmB;AAC5B,SAAS,8BAA8B;AACvC,SAAS,8BAA8B;AACvC,SAAS,4BAA4B,uCAAuC;AAC5E;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,0BAA0B;AAG5B,MAAM,mBAA2E,CAAC,UAAU;AACjG,QAAM,mBAAmB;AAAA,IACvB;AAAA,IACA;AAAA,EACF;AACA,iCAA+B,kBAAkB,iCAAiC,kBAAkB;AAEpG,QAAM,EAAE,iBAAiB,eAAe,IAAI;AAC5C,QAAM,mBAAmB,KAAK,uBAAuB,gBAAgB,GAAG,SAAS,QAAQ,MAAM;AAC/F,QAAM,oBAAoB,mBAAmB,gBAAgB;AAE7D,SACE;AAAA,IAAC;AAAA;AAAA,MACC,UAAU,CAAC;AAAA,MACX,YAAW;AAAA,MACX,eAAa,uBAAuB;AAAA,MACpC,cAAW;AAAA,MACV,GAAG;AAAA,MACH,GAAG;AAAA,MACJ,SAAS,MAAM;AACb,YAAI;AAAiB,yBAAe;AAAA,MACtC;AAAA,MAEA,8BAAC,eAAY,OAAO,kBAAkB,CAAC,iBAAiB,KAAK,IAAI,CAAC,WAAW,KAAK,GAAG;AAAA;AAAA,EACvF;AAEJ;AAEA,iBAAiB,YAAY;AAC7B,iBAAiB,cAAc;AACxB,MAAM,6BAA6B,SAAS,gBAAgB,EAAE,YAAY,mBAAmB;AACpG,2BAA2B,YAAY;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { omit } from "lodash";
|
|
4
|
+
import { describe, useGetGlobalAttributes, useGetXstyledProps } from "@elliemae/ds-props-helpers";
|
|
5
|
+
import { PAGINATION_DATA_TESTID } from "../PaginationDataTestID";
|
|
6
|
+
import { StyledPaginationContainer, StyledPaginationWrapper } from "../styled";
|
|
7
|
+
import { DSPaginationContainerPropTypesSchema } from "../react-desc-prop-types";
|
|
8
|
+
import { PaginationContainerName } from "../DSPaginationDefinitions";
|
|
9
|
+
const DSPaginationContainer = (props) => {
|
|
10
|
+
const globalAttributes = omit(useGetGlobalAttributes(props), ["rows", "wrap"]);
|
|
11
|
+
const xstyledProps = useGetXstyledProps(props);
|
|
12
|
+
return /* @__PURE__ */ jsx(
|
|
13
|
+
StyledPaginationContainer,
|
|
14
|
+
{
|
|
15
|
+
"data-testid": PAGINATION_DATA_TESTID.CONTAINER,
|
|
16
|
+
...globalAttributes,
|
|
17
|
+
...xstyledProps,
|
|
18
|
+
cols: ["minmax(auto, 80%)"],
|
|
19
|
+
children: /* @__PURE__ */ jsx(StyledPaginationWrapper, { children: props.children })
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
};
|
|
23
|
+
DSPaginationContainer.propTypes = DSPaginationContainerPropTypesSchema;
|
|
24
|
+
DSPaginationContainer.displayName = PaginationContainerName;
|
|
25
|
+
const DSPaginationContainerWithSchema = describe(DSPaginationContainer).description("Per Page Selector");
|
|
26
|
+
DSPaginationContainerWithSchema.propTypes = DSPaginationContainerPropTypesSchema;
|
|
27
|
+
export {
|
|
28
|
+
DSPaginationContainer,
|
|
29
|
+
DSPaginationContainerWithSchema
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=DSPaginationContainer.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/parts/DSPaginationContainer.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\nimport { omit } from 'lodash';\nimport { describe, useGetGlobalAttributes, useGetXstyledProps } from '@elliemae/ds-props-helpers';\nimport { PAGINATION_DATA_TESTID } from '../PaginationDataTestID';\nimport { StyledPaginationContainer, StyledPaginationWrapper } from '../styled';\nimport { DSPaginationContainerPropTypesSchema } from '../react-desc-prop-types';\nimport { PaginationContainerName } from '../DSPaginationDefinitions';\nimport type { DSPaginationT } from '../react-desc-prop-types';\n\nexport const DSPaginationContainer: React.ComponentType<DSPaginationT.ContainerProps> = (props) => {\n const globalAttributes = omit(useGetGlobalAttributes(props), ['rows', 'wrap']);\n const xstyledProps = useGetXstyledProps(props);\n\n return (\n <StyledPaginationContainer\n data-testid={PAGINATION_DATA_TESTID.CONTAINER}\n {...globalAttributes}\n {...xstyledProps}\n cols={['minmax(auto, 80%)']}\n >\n <StyledPaginationWrapper>{props.children}</StyledPaginationWrapper>\n </StyledPaginationContainer>\n );\n};\n\nDSPaginationContainer.propTypes = DSPaginationContainerPropTypesSchema;\nDSPaginationContainer.displayName = PaginationContainerName;\nexport const DSPaginationContainerWithSchema = describe(DSPaginationContainer).description('Per Page Selector');\nDSPaginationContainerWithSchema.propTypes = DSPaginationContainerPropTypesSchema;\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACoBjB;AAnBN,SAAS,YAAY;AACrB,SAAS,UAAU,wBAAwB,0BAA0B;AACrE,SAAS,8BAA8B;AACvC,SAAS,2BAA2B,+BAA+B;AACnE,SAAS,4CAA4C;AACrD,SAAS,+BAA+B;AAGjC,MAAM,wBAA2E,CAAC,UAAU;AACjG,QAAM,mBAAmB,KAAK,uBAAuB,KAAK,GAAG,CAAC,QAAQ,MAAM,CAAC;AAC7E,QAAM,eAAe,mBAAmB,KAAK;AAE7C,SACE;AAAA,IAAC;AAAA;AAAA,MACC,eAAa,uBAAuB;AAAA,MACnC,GAAG;AAAA,MACH,GAAG;AAAA,MACJ,MAAM,CAAC,mBAAmB;AAAA,MAE1B,8BAAC,2BAAyB,gBAAM,UAAS;AAAA;AAAA,EAC3C;AAEJ;AAEA,sBAAsB,YAAY;AAClC,sBAAsB,cAAc;AAC7B,MAAM,kCAAkC,SAAS,qBAAqB,EAAE,YAAY,mBAAmB;AAC9G,gCAAgC,YAAY;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Grid } from "@elliemae/ds-grid";
|
|
4
|
+
import { DSPaginationSeparator } from "../../styled";
|
|
5
|
+
const createPaginatorHeader = ({ pageDetailsTitle, pageInfoWidth }) => {
|
|
6
|
+
const Comp = () => {
|
|
7
|
+
if (pageDetailsTitle === "")
|
|
8
|
+
return /* @__PURE__ */ jsx(Fragment, { children: "Page" });
|
|
9
|
+
return /* @__PURE__ */ jsxs(Grid, { cols: [`${pageInfoWidth + 50}px`, "8px", "auto"], children: [
|
|
10
|
+
/* @__PURE__ */ jsx("span", { style: { marginLeft: "8px" }, children: "Page" }),
|
|
11
|
+
/* @__PURE__ */ jsx(DSPaginationSeparator, { height: "100%" }),
|
|
12
|
+
/* @__PURE__ */ jsx("span", { children: pageDetailsTitle })
|
|
13
|
+
] });
|
|
14
|
+
};
|
|
15
|
+
return Comp;
|
|
16
|
+
};
|
|
17
|
+
export {
|
|
18
|
+
createPaginatorHeader
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=createPaginatorHeader.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/parts/DSPaginator/createPaginatorHeader.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\nimport { Grid } from '@elliemae/ds-grid';\nimport { DSPaginationSeparator } from '../../styled';\n\ninterface PaginatorHeaderOptions {\n pageDetailsTitle: string;\n pageInfoWidth: number;\n}\n\nexport const createPaginatorHeader = ({ pageDetailsTitle, pageInfoWidth }: PaginatorHeaderOptions) => {\n const Comp = () => {\n if (pageDetailsTitle === '') return <>Page</>;\n\n return (\n <Grid cols={[`${pageInfoWidth + 50}px`, '8px', 'auto']}>\n <span style={{ marginLeft: '8px' }}>Page</span>\n <DSPaginationSeparator height=\"100%\" />\n <span>{pageDetailsTitle}</span>\n </Grid>\n );\n };\n return Comp;\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACWiB,wBAGlC,YAHkC;AAVxC,SAAS,YAAY;AACrB,SAAS,6BAA6B;AAO/B,MAAM,wBAAwB,CAAC,EAAE,kBAAkB,cAAc,MAA8B;AACpG,QAAM,OAAO,MAAM;AACjB,QAAI,qBAAqB;AAAI,aAAO,gCAAE,kBAAI;AAE1C,WACE,qBAAC,QAAK,MAAM,CAAC,GAAG,gBAAgB,QAAQ,OAAO,MAAM,GACnD;AAAA,0BAAC,UAAK,OAAO,EAAE,YAAY,MAAM,GAAG,kBAAI;AAAA,MACxC,oBAAC,yBAAsB,QAAO,QAAO;AAAA,MACrC,oBAAC,UAAM,4BAAiB;AAAA,OAC1B;AAAA,EAEJ;AACA,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Grid } from "@elliemae/ds-grid";
|
|
4
|
+
import { Checkmark } from "@elliemae/ds-icons";
|
|
5
|
+
const OptionWithDetails = (props) => {
|
|
6
|
+
const Comp = () => {
|
|
7
|
+
const { pageInfoWidth, pageIndex, index, pageDetails } = props;
|
|
8
|
+
return /* @__PURE__ */ jsxs(Grid, { cols: ["16px", `${pageInfoWidth + 16}px`, "auto"], gutter: "xxs", alignItems: "center", children: [
|
|
9
|
+
pageIndex - 1 === index ? /* @__PURE__ */ jsx(Checkmark, { size: "s", color: ["brand-primary", "600"] }) : /* @__PURE__ */ jsx("div", {}),
|
|
10
|
+
/* @__PURE__ */ jsx("span", { children: index + 1 }),
|
|
11
|
+
/* @__PURE__ */ jsx(
|
|
12
|
+
"span",
|
|
13
|
+
{
|
|
14
|
+
style: {
|
|
15
|
+
whiteSpace: "nowrap",
|
|
16
|
+
textOverflow: "ellipsis",
|
|
17
|
+
overflow: "hidden"
|
|
18
|
+
},
|
|
19
|
+
children: pageDetails[index]
|
|
20
|
+
}
|
|
21
|
+
)
|
|
22
|
+
] });
|
|
23
|
+
};
|
|
24
|
+
return Comp;
|
|
25
|
+
};
|
|
26
|
+
const getOptions = (args) => {
|
|
27
|
+
const { pageCount, pageIndex, pageDetails, pageInfoWidth } = args;
|
|
28
|
+
const amountOfPages = typeof pageCount === "string" ? pageIndex + 1 : pageCount;
|
|
29
|
+
const options = new Array(amountOfPages).fill(0).map((_, index) => {
|
|
30
|
+
const option = {
|
|
31
|
+
dsId: (index + 1).toString(),
|
|
32
|
+
label: (index + 1).toString(),
|
|
33
|
+
value: index + 1,
|
|
34
|
+
type: "single"
|
|
35
|
+
};
|
|
36
|
+
if (pageDetails?.length) {
|
|
37
|
+
option.render = OptionWithDetails({ pageInfoWidth, pageIndex, index, pageDetails });
|
|
38
|
+
}
|
|
39
|
+
return option;
|
|
40
|
+
});
|
|
41
|
+
return options;
|
|
42
|
+
};
|
|
43
|
+
export {
|
|
44
|
+
getOptions
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=getOptions.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/parts/DSPaginator/getOptions.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\nimport { Grid } from '@elliemae/ds-grid';\nimport { Checkmark } from '@elliemae/ds-icons';\nimport type { DSDropdownMenuT } from '@elliemae/ds-dropdownmenu';\n\ninterface OptionWithDetailsT {\n pageInfoWidth: number;\n pageIndex: number;\n index: number;\n pageDetails: string[];\n}\n\nconst OptionWithDetails = (props: OptionWithDetailsT) => {\n const Comp = () => {\n const { pageInfoWidth, pageIndex, index, pageDetails } = props;\n return (\n <Grid cols={['16px', `${pageInfoWidth + 16}px`, 'auto']} gutter=\"xxs\" alignItems=\"center\">\n {pageIndex - 1 === index ? <Checkmark size=\"s\" color={['brand-primary', '600']} /> : <div />}\n <span>{index + 1}</span>\n <span\n style={{\n whiteSpace: 'nowrap',\n textOverflow: 'ellipsis',\n overflow: 'hidden',\n }}\n >\n {pageDetails[index]}\n </span>\n </Grid>\n );\n };\n return Comp;\n};\n\nexport const getOptions = (args: {\n pageCount: number | string;\n pageIndex: number;\n pageDetails: string[];\n pageInfoWidth: number;\n}): DSDropdownMenuT.ItemSingleOptions[] => {\n const { pageCount, pageIndex, pageDetails, pageInfoWidth } = args;\n\n const amountOfPages = typeof pageCount === 'string' ? pageIndex + 1 : pageCount;\n\n const options = new Array(amountOfPages).fill(0).map((_, index) => {\n const option: DSDropdownMenuT.ItemSingleOptions = {\n dsId: (index + 1).toString(),\n label: (index + 1).toString(),\n value: index + 1,\n type: 'single',\n };\n if (pageDetails?.length) {\n option.render = OptionWithDetails({ pageInfoWidth, pageIndex, index, pageDetails });\n }\n return option;\n });\n return options;\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACgBjB,SAC6B,KAD7B;AAfN,SAAS,YAAY;AACrB,SAAS,iBAAiB;AAU1B,MAAM,oBAAoB,CAAC,UAA8B;AACvD,QAAM,OAAO,MAAM;AACjB,UAAM,EAAE,eAAe,WAAW,OAAO,YAAY,IAAI;AACzD,WACE,qBAAC,QAAK,MAAM,CAAC,QAAQ,GAAG,gBAAgB,QAAQ,MAAM,GAAG,QAAO,OAAM,YAAW,UAC9E;AAAA,kBAAY,MAAM,QAAQ,oBAAC,aAAU,MAAK,KAAI,OAAO,CAAC,iBAAiB,KAAK,GAAG,IAAK,oBAAC,SAAI;AAAA,MAC1F,oBAAC,UAAM,kBAAQ,GAAE;AAAA,MACjB;AAAA,QAAC;AAAA;AAAA,UACC,OAAO;AAAA,YACL,YAAY;AAAA,YACZ,cAAc;AAAA,YACd,UAAU;AAAA,UACZ;AAAA,UAEC,sBAAY;AAAA;AAAA,MACf;AAAA,OACF;AAAA,EAEJ;AACA,SAAO;AACT;AAEO,MAAM,aAAa,CAAC,SAKgB;AACzC,QAAM,EAAE,WAAW,WAAW,aAAa,cAAc,IAAI;AAE7D,QAAM,gBAAgB,OAAO,cAAc,WAAW,YAAY,IAAI;AAEtE,QAAM,UAAU,IAAI,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,IAAI,CAAC,GAAG,UAAU;AACjE,UAAM,SAA4C;AAAA,MAChD,OAAO,QAAQ,GAAG,SAAS;AAAA,MAC3B,QAAQ,QAAQ,GAAG,SAAS;AAAA,MAC5B,OAAO,QAAQ;AAAA,MACf,MAAM;AAAA,IACR;AACA,QAAI,aAAa,QAAQ;AACvB,aAAO,SAAS,kBAAkB,EAAE,eAAe,WAAW,OAAO,YAAY,CAAC;AAAA,IACpF;AACA,WAAO;AAAA,EACT,CAAC;AACD,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useMemo } from "react";
|
|
4
|
+
import { ChevronDown } from "@elliemae/ds-icons";
|
|
5
|
+
import { describe, useMemoMergePropsWithDefault, useValidateTypescriptPropTypes } from "@elliemae/ds-props-helpers";
|
|
6
|
+
import { Grid } from "@elliemae/ds-grid";
|
|
7
|
+
import { DSDropdownMenuV2 } from "@elliemae/ds-dropdownmenu";
|
|
8
|
+
import { DSTypography } from "@elliemae/ds-typography";
|
|
9
|
+
import { DSCircularIndeterminateIndicator } from "@elliemae/ds-circular-progress-indicator";
|
|
10
|
+
import { InvisibleDiv, PaginationDropdownButton, DSPaginationSeparator } from "../../styled";
|
|
11
|
+
import { paginatorDefaultProps, DSPaginatorPropTypesSchema } from "../../react-desc-prop-types";
|
|
12
|
+
import { PaginatorName } from "../../DSPaginationDefinitions";
|
|
13
|
+
import { usePaginator } from "./usePaginator";
|
|
14
|
+
import { createPaginatorHeader } from "./createPaginatorHeader";
|
|
15
|
+
import { PAGINATION_DATA_TESTID } from "../../PaginationDataTestID";
|
|
16
|
+
const DSPaginator = (props) => {
|
|
17
|
+
const propsWithDefault = useMemoMergePropsWithDefault(
|
|
18
|
+
props,
|
|
19
|
+
paginatorDefaultProps
|
|
20
|
+
);
|
|
21
|
+
useValidateTypescriptPropTypes(propsWithDefault, DSPaginatorPropTypesSchema, PaginatorName);
|
|
22
|
+
const { pageIndex, pageCount, isLoadingPageCount, onPageChange, pageDetails, pageDetailsTitle } = propsWithDefault;
|
|
23
|
+
const {
|
|
24
|
+
btnRef,
|
|
25
|
+
btnWidth,
|
|
26
|
+
pageInfoWidth,
|
|
27
|
+
options,
|
|
28
|
+
isOpened,
|
|
29
|
+
setIsOpened,
|
|
30
|
+
detailWidth,
|
|
31
|
+
globalAttributes,
|
|
32
|
+
xstyledAttributes,
|
|
33
|
+
actionRef,
|
|
34
|
+
onKeyDown
|
|
35
|
+
} = usePaginator(propsWithDefault);
|
|
36
|
+
const Header = useMemo(
|
|
37
|
+
() => createPaginatorHeader({ pageDetailsTitle, pageInfoWidth }),
|
|
38
|
+
[pageDetailsTitle, pageInfoWidth]
|
|
39
|
+
);
|
|
40
|
+
const buttonOnClick = useMemo(() => {
|
|
41
|
+
if (globalAttributes.onClick)
|
|
42
|
+
return globalAttributes.onClick;
|
|
43
|
+
return () => setIsOpened((prev) => !prev);
|
|
44
|
+
}, [globalAttributes.onClick, setIsOpened]);
|
|
45
|
+
return /* @__PURE__ */ jsxs(
|
|
46
|
+
DSDropdownMenuV2,
|
|
47
|
+
{
|
|
48
|
+
isOpened,
|
|
49
|
+
options,
|
|
50
|
+
selectedOptions: { [pageIndex.toString()]: true },
|
|
51
|
+
onOptionClick: (_, clickedOption) => {
|
|
52
|
+
onPageChange(clickedOption.value);
|
|
53
|
+
setIsOpened(false);
|
|
54
|
+
btnRef.current?.focus();
|
|
55
|
+
},
|
|
56
|
+
onClickOutside: () => {
|
|
57
|
+
setIsOpened(false);
|
|
58
|
+
btnRef.current?.focus();
|
|
59
|
+
},
|
|
60
|
+
customOffset: [-23, 2],
|
|
61
|
+
startPlacementPreference: "top-start",
|
|
62
|
+
actionRef,
|
|
63
|
+
onKeyDown,
|
|
64
|
+
minWidth: pageDetails.length !== 0 ? btnWidth + 23 : pageCount.toString().length * 6 + 90,
|
|
65
|
+
maxHeight: 300,
|
|
66
|
+
HeaderComp: Header,
|
|
67
|
+
children: [
|
|
68
|
+
/* @__PURE__ */ jsx(
|
|
69
|
+
PaginationDropdownButton,
|
|
70
|
+
{
|
|
71
|
+
buttonType: "raw",
|
|
72
|
+
disabled: isLoadingPageCount,
|
|
73
|
+
innerRef: btnRef,
|
|
74
|
+
"aria-pressed": isOpened,
|
|
75
|
+
"aria-label": `Page ${pageIndex} out of ${pageCount}, ${pageDetails.length !== 0 ? pageDetails[pageIndex - 1] : "\b\b"}. Press to change the current page`,
|
|
76
|
+
"data-testid": PAGINATION_DATA_TESTID.PAGINATOR,
|
|
77
|
+
...globalAttributes,
|
|
78
|
+
...xstyledAttributes,
|
|
79
|
+
onClick: buttonOnClick,
|
|
80
|
+
children: /* @__PURE__ */ jsxs(Grid, { gutter: "xxxs", alignItems: "center", style: { gridAutoFlow: "column" }, children: [
|
|
81
|
+
/* @__PURE__ */ jsx(DSTypography, { fontSize: "18px", variant: "b1", as: "span", fontWeight: "semibold", textAlign: "start", children: pageIndex }),
|
|
82
|
+
"/ ",
|
|
83
|
+
pageCount,
|
|
84
|
+
isLoadingPageCount && /* @__PURE__ */ jsx(DSCircularIndeterminateIndicator, { ml: "xxxs", mr: "xxxs", size: "xs" }),
|
|
85
|
+
pageDetails.length !== 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
86
|
+
/* @__PURE__ */ jsx(DSPaginationSeparator, { height: "12px", ml: "12px", mr: "xxxs" }),
|
|
87
|
+
/* @__PURE__ */ jsx(
|
|
88
|
+
DSTypography,
|
|
89
|
+
{
|
|
90
|
+
fontSize: "13px",
|
|
91
|
+
w: detailWidth,
|
|
92
|
+
mr: "12px",
|
|
93
|
+
variant: "b1",
|
|
94
|
+
as: "span",
|
|
95
|
+
fontWeight: "semibold",
|
|
96
|
+
textAlign: "start",
|
|
97
|
+
children: pageDetails[pageIndex - 1]
|
|
98
|
+
}
|
|
99
|
+
)
|
|
100
|
+
] }),
|
|
101
|
+
/* @__PURE__ */ jsx(ChevronDown, { color: ["brand-primary", "700"] })
|
|
102
|
+
] })
|
|
103
|
+
}
|
|
104
|
+
),
|
|
105
|
+
/* @__PURE__ */ jsx(Grid, { style: { position: "relative" }, children: pageDetails.map((pageDetail) => /* @__PURE__ */ jsx(InvisibleDiv, { "data-testid": "ds-pagination-invisible-detail-for-width-calc", children: /* @__PURE__ */ jsx(DSTypography, { fontSize: "13px", mr: "xxs", variant: "b1", as: "span", fontWeight: "semibold", textAlign: "start", children: pageDetail }) }, pageDetail)) })
|
|
106
|
+
]
|
|
107
|
+
}
|
|
108
|
+
);
|
|
109
|
+
};
|
|
110
|
+
DSPaginator.propTypes = DSPaginatorPropTypesSchema;
|
|
111
|
+
DSPaginator.displayName = PaginatorName;
|
|
112
|
+
const DSPaginatorWithSchema = describe(DSPaginator).description("Per Page Selector");
|
|
113
|
+
DSPaginatorWithSchema.propTypes = DSPaginatorPropTypesSchema;
|
|
114
|
+
export {
|
|
115
|
+
DSPaginator,
|
|
116
|
+
DSPaginatorWithSchema
|
|
117
|
+
};
|
|
118
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/parts/DSPaginator/index.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* 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';\nimport { paginatorDefaultProps, DSPaginatorPropTypesSchema } from '../../react-desc-prop-types';\nimport { PaginatorName } from '../../DSPaginationDefinitions';\nimport { usePaginator } from './usePaginator';\nimport { createPaginatorHeader } from './createPaginatorHeader';\nimport { PAGINATION_DATA_TESTID } from '../../PaginationDataTestID';\nimport type { DSDropdownMenuT } from '@elliemae/ds-dropdownmenu';\nimport type { DSPaginationT } from '../../react-desc-prop-types';\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=\"12px\"\n variant=\"b1\"\n as=\"span\"\n fontWeight=\"semibold\"\n textAlign=\"start\"\n >\n {pageDetails[pageIndex - 1]}\n </DSTypography>\n </>\n )}\n <ChevronDown 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"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -3,8 +3,10 @@ import { useCallback, useEffect, useRef, useState } from "react";
|
|
|
3
3
|
const usePaginationSearch = (pageCount, actionRef) => {
|
|
4
4
|
const [searchValue, setSearchValue] = useState("");
|
|
5
5
|
const [shouldResetSearchValue, setShouldResetSearchValue] = useState(true);
|
|
6
|
-
const timeoutRef = useRef(
|
|
6
|
+
const timeoutRef = useRef();
|
|
7
7
|
useEffect(() => {
|
|
8
|
+
if (typeof pageCount === "string")
|
|
9
|
+
return;
|
|
8
10
|
if (searchValue !== "" && Number.parseInt(searchValue, 10) <= pageCount) {
|
|
9
11
|
actionRef.current.setActiveDescendant(searchValue);
|
|
10
12
|
actionRef.current.scrollOptionIntoView(searchValue);
|
|
@@ -18,7 +20,8 @@ const usePaginationSearch = (pageCount, actionRef) => {
|
|
|
18
20
|
else
|
|
19
21
|
setSearchValue((prevValue) => prevValue + e.key);
|
|
20
22
|
setShouldResetSearchValue(false);
|
|
21
|
-
|
|
23
|
+
if (timeoutRef.current)
|
|
24
|
+
clearTimeout(timeoutRef.current);
|
|
22
25
|
timeoutRef.current = setTimeout(() => {
|
|
23
26
|
setShouldResetSearchValue(true);
|
|
24
27
|
}, 1e3);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/parts/DSPaginator/usePaginationSearch.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "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"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,aAAa,WAAW,QAAQ,gBAAgB;AAElD,MAAM,sBAAsB,CACjC,WACA,cAC+B;AAC/B,QAAM,CAAC,aAAa,cAAc,IAAI,SAAS,EAAE;AACjD,QAAM,CAAC,wBAAwB,yBAAyB,IAAI,SAAS,IAAI;AAEzE,QAAM,aAAa,OAAuB;AAE1C,YAAU,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,YAAY;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,61 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
3
|
+
import { omit } from "lodash";
|
|
4
|
+
import { useGetGlobalAttributes, useGetXstyledProps } from "@elliemae/ds-props-helpers";
|
|
5
|
+
import { useOnElementResize } from "@elliemae/ds-utilities";
|
|
6
|
+
import { usePaginationSearch } from "./usePaginationSearch";
|
|
7
|
+
import { getOptions } from "./getOptions";
|
|
8
|
+
const usePaginator = (props) => {
|
|
9
|
+
const { pageIndex, pageCount, pageDetails } = props;
|
|
10
|
+
const [isOpened, setIsOpened] = useState(false);
|
|
11
|
+
const [detailWidth, setDetailWidth] = useState(0);
|
|
12
|
+
const [pageInfoWidth, setPageInfoWidth] = useState(0);
|
|
13
|
+
const btnRef = useRef(null);
|
|
14
|
+
const actionRef = useRef({});
|
|
15
|
+
const { width: btnWidth } = useOnElementResize(btnRef);
|
|
16
|
+
const options = useMemo(
|
|
17
|
+
() => getOptions({ pageCount, pageIndex, pageDetails, pageInfoWidth }),
|
|
18
|
+
[pageCount, pageIndex, pageDetails, pageInfoWidth]
|
|
19
|
+
);
|
|
20
|
+
const onKeyDown = usePaginationSearch(pageCount, actionRef);
|
|
21
|
+
const globalAttributes = omit(useGetGlobalAttributes(props), ["shape", "type", "size"]);
|
|
22
|
+
const xstyledAttributes = useGetXstyledProps(props);
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
if (isOpened) {
|
|
25
|
+
actionRef.current.setActiveDescendant(pageIndex.toString());
|
|
26
|
+
actionRef.current.scrollOptionIntoView(pageIndex.toString());
|
|
27
|
+
}
|
|
28
|
+
}, [isOpened]);
|
|
29
|
+
useLayoutEffect(() => {
|
|
30
|
+
const invisibleDetails = [
|
|
31
|
+
...document.body.querySelectorAll('[data-testid="ds-pagination-invisible-detail-for-width-calc"]')
|
|
32
|
+
];
|
|
33
|
+
const maxWidth = invisibleDetails.reduce((acc, cur) => Math.max(acc, cur.getBoundingClientRect().width), 0);
|
|
34
|
+
setDetailWidth(maxWidth);
|
|
35
|
+
}, [pageDetails]);
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
setPageInfoWidth(() => {
|
|
38
|
+
if (detailWidth)
|
|
39
|
+
return btnWidth - detailWidth - 89;
|
|
40
|
+
return btnWidth - 56;
|
|
41
|
+
});
|
|
42
|
+
}, [btnWidth, detailWidth]);
|
|
43
|
+
return {
|
|
44
|
+
btnRef,
|
|
45
|
+
btnWidth,
|
|
46
|
+
pageInfoWidth,
|
|
47
|
+
options,
|
|
48
|
+
isOpened,
|
|
49
|
+
setIsOpened,
|
|
50
|
+
detailWidth,
|
|
51
|
+
setDetailWidth,
|
|
52
|
+
globalAttributes,
|
|
53
|
+
xstyledAttributes,
|
|
54
|
+
actionRef,
|
|
55
|
+
onKeyDown
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
export {
|
|
59
|
+
usePaginator
|
|
60
|
+
};
|
|
61
|
+
//# sourceMappingURL=usePaginator.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/parts/DSPaginator/usePaginator.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "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';\nimport { getOptions } from './getOptions';\nimport type { DSPaginationT } from '../../react-desc-prop-types';\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"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,WAAW,iBAAiB,SAAS,QAAQ,gBAAgB;AACtE,SAAS,YAAY;AACrB,SAAS,wBAAwB,0BAA0B;AAC3D,SAAS,0BAA0B;AACnC,SAAS,2BAA2B;AACpC,SAAS,kBAAkB;AAGpB,MAAM,eAAe,CAAC,UAAgD;AAC3E,QAAM,EAAE,WAAW,WAAW,YAAY,IAAI;AAE9C,QAAM,CAAC,UAAU,WAAW,IAAI,SAAS,KAAK;AAC9C,QAAM,CAAC,aAAa,cAAc,IAAI,SAAS,CAAC;AAChD,QAAM,CAAC,eAAe,gBAAgB,IAAI,SAAS,CAAC;AAEpD,QAAM,SAAS,OAA0B,IAAI;AAC7C,QAAM,YAAY,OAA+C,CAAC,CAAC;AAEnE,QAAM,EAAE,OAAO,SAAS,IAAI,mBAAmB,MAAM;AAErD,QAAM,UAAU;AAAA,IACd,MAAM,WAAW,EAAE,WAAW,WAAW,aAAa,cAAc,CAAC;AAAA,IACrE,CAAC,WAAW,WAAW,aAAa,aAAa;AAAA,EACnD;AAEA,QAAM,YAAY,oBAAoB,WAAW,SAAS;AAE1D,QAAM,mBAAmB,KAAK,uBAAuB,KAAK,GAAG,CAAC,SAAS,QAAQ,MAAM,CAAC;AACtF,QAAM,oBAAoB,mBAAmB,KAAK;AAElD,YAAU,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,kBAAgB,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,YAAU,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
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { range } from "@elliemae/ds-utilities";
|
|
3
|
+
const generateOption = (value) => {
|
|
4
|
+
if (typeof value === "object") {
|
|
5
|
+
return value;
|
|
6
|
+
}
|
|
7
|
+
return {
|
|
8
|
+
dsId: value.toString(),
|
|
9
|
+
value,
|
|
10
|
+
label: value.toString(),
|
|
11
|
+
type: "single"
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
const getOptions = (step, min, max) => {
|
|
15
|
+
const options = range(min, max + step, step).map(generateOption);
|
|
16
|
+
return min === 0 ? options.slice(1, options.length) : options;
|
|
17
|
+
};
|
|
18
|
+
export {
|
|
19
|
+
generateOption,
|
|
20
|
+
getOptions
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=getOptions.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/parts/DSPerPageSelector/getOptions.ts"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "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"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,aAAa;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,UAAU,MAAM,KAAK,MAAM,MAAM,IAAI,EAAE,IAAI,cAAc;AAC/D,SAAO,QAAQ,IAAI,QAAQ,MAAM,GAAG,QAAQ,MAAM,IAAI;AACxD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|