@pingux/astro 2.119.0-alpha.1 → 2.119.0-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/lib/cjs/components/Button/Buttons.styles.d.ts +40 -0
  2. package/lib/cjs/components/Button/Buttons.styles.js +4 -0
  3. package/lib/cjs/components/ListView/ListView.stories.d.ts +3 -0
  4. package/lib/cjs/components/ListView/ListView.stories.js +2 -1
  5. package/lib/cjs/components/NavBar/NavBar.stories.d.ts +1 -0
  6. package/lib/cjs/components/NavBar/NavBar.stories.js +272 -107
  7. package/lib/cjs/{styles/themeOverrides → components/NavBar}/stories/NavBar.chromatic.stories.js +53 -53
  8. package/lib/cjs/components/NavBar/stories/NavBarNextGenComponent.js +191 -0
  9. package/lib/cjs/{styles/themeOverrides/nextGenDarkMode → components/NavBar}/stories/NextGenDarkNavStory.chomatic.stories.js +2 -2
  10. package/lib/cjs/{styles/themes/next-gen → components/NavBar}/stories/NextGenNavBar.chromatic.stories.js +1 -1
  11. package/lib/cjs/components/NavBarSection/NavBarItem.js +3 -1
  12. package/lib/cjs/components/NavBarSection/NavBarItemHeader.js +9 -6
  13. package/lib/cjs/components/NavBarSection/NavBarItemHeader.test.d.ts +1 -0
  14. package/lib/cjs/components/NavBarSection/NavBarItemHeader.test.js +86 -0
  15. package/lib/cjs/components/Pagination/Pagination.d.ts +4 -0
  16. package/lib/cjs/components/Pagination/Pagination.js +78 -0
  17. package/lib/cjs/components/Pagination/Pagination.mdx +68 -0
  18. package/lib/cjs/components/Pagination/Pagination.stories.d.ts +39 -0
  19. package/lib/cjs/components/Pagination/Pagination.stories.js +159 -0
  20. package/lib/cjs/components/Pagination/Pagination.styles.d.ts +17 -0
  21. package/lib/cjs/components/Pagination/Pagination.styles.js +27 -0
  22. package/lib/cjs/components/Pagination/Pagination.test.d.ts +1 -0
  23. package/lib/cjs/components/Pagination/Pagination.test.js +208 -0
  24. package/lib/cjs/components/Pagination/PaginationProvider.d.ts +4 -0
  25. package/lib/cjs/components/Pagination/PaginationProvider.js +38 -0
  26. package/lib/cjs/components/Pagination/index.d.ts +2 -0
  27. package/lib/cjs/components/Pagination/index.js +33 -0
  28. package/lib/cjs/context/PaginationContext/index.d.ts +10 -0
  29. package/lib/cjs/context/PaginationContext/index.js +20 -0
  30. package/lib/cjs/hooks/index.d.ts +2 -0
  31. package/lib/cjs/hooks/index.js +14 -0
  32. package/lib/cjs/hooks/usePagination/index.d.ts +1 -0
  33. package/lib/cjs/hooks/usePagination/index.js +14 -0
  34. package/lib/cjs/hooks/usePagination/usePagination.d.ts +682 -0
  35. package/lib/cjs/hooks/usePagination/usePagination.js +178 -0
  36. package/lib/cjs/hooks/usePaginationState/index.d.ts +1 -0
  37. package/lib/cjs/hooks/usePaginationState/index.js +14 -0
  38. package/lib/cjs/hooks/usePaginationState/usePaginationState.d.ts +4 -0
  39. package/lib/cjs/hooks/usePaginationState/usePaginationState.js +18 -0
  40. package/lib/cjs/index.d.ts +3 -0
  41. package/lib/cjs/index.js +24 -0
  42. package/lib/cjs/styles/themeOverrides/nextGenDarkMode/variants/buttons.d.ts +3 -0
  43. package/lib/cjs/styles/themeOverrides/nextGenDarkMode/variants/buttons.js +3 -0
  44. package/lib/cjs/styles/themes/next-gen/convertedComponentList.d.ts +4 -0
  45. package/lib/cjs/styles/themes/next-gen/convertedComponentList.js +8 -3
  46. package/lib/cjs/styles/themes/next-gen/next-gen.d.ts +30 -0
  47. package/lib/cjs/styles/themes/next-gen/variants/button.d.ts +17 -0
  48. package/lib/cjs/styles/themes/next-gen/variants/button.js +7 -1
  49. package/lib/cjs/styles/themes/next-gen/variants/links.d.ts +9 -0
  50. package/lib/cjs/styles/themes/next-gen/variants/links.js +12 -1
  51. package/lib/cjs/styles/themes/next-gen/variants/navbar.d.ts +4 -0
  52. package/lib/cjs/styles/themes/next-gen/variants/navbar.js +11 -7
  53. package/lib/cjs/styles/themes/next-gen/variants/variants.d.ts +4 -0
  54. package/lib/cjs/styles/variants/variants.js +3 -1
  55. package/lib/cjs/types/pagination.d.ts +46 -0
  56. package/lib/cjs/types/pagination.js +6 -0
  57. package/lib/cjs/utils/devUtils/shouldReturnComingSoon.js +8 -2
  58. package/lib/components/Button/Buttons.styles.js +4 -0
  59. package/lib/components/ListView/ListView.stories.js +1 -1
  60. package/lib/components/NavBar/NavBar.stories.js +196 -32
  61. package/lib/{styles/themeOverrides → components/NavBar}/stories/NavBar.chromatic.stories.js +2 -2
  62. package/lib/components/NavBar/stories/NavBarNextGenComponent.js +182 -0
  63. package/lib/{styles/themeOverrides/nextGenDarkMode → components/NavBar}/stories/NextGenDarkNavStory.chomatic.stories.js +2 -2
  64. package/lib/{styles/themes/next-gen → components/NavBar}/stories/NextGenNavBar.chromatic.stories.js +1 -1
  65. package/lib/components/NavBarSection/NavBarItem.js +4 -2
  66. package/lib/components/NavBarSection/NavBarItemHeader.js +7 -4
  67. package/lib/components/NavBarSection/NavBarItemHeader.test.js +83 -0
  68. package/lib/components/Pagination/Pagination.js +64 -0
  69. package/lib/components/Pagination/Pagination.mdx +68 -0
  70. package/lib/components/Pagination/Pagination.stories.js +141 -0
  71. package/lib/components/Pagination/Pagination.styles.js +19 -0
  72. package/lib/components/Pagination/Pagination.test.js +205 -0
  73. package/lib/components/Pagination/PaginationProvider.js +24 -0
  74. package/lib/components/Pagination/index.js +2 -0
  75. package/lib/context/PaginationContext/index.js +11 -0
  76. package/lib/hooks/index.js +2 -0
  77. package/lib/hooks/usePagination/index.js +1 -0
  78. package/lib/hooks/usePagination/usePagination.js +170 -0
  79. package/lib/hooks/usePaginationState/index.js +1 -0
  80. package/lib/hooks/usePaginationState/usePaginationState.js +10 -0
  81. package/lib/index.js +3 -0
  82. package/lib/styles/themeOverrides/nextGenDarkMode/variants/buttons.js +3 -0
  83. package/lib/styles/themes/next-gen/convertedComponentList.js +6 -2
  84. package/lib/styles/themes/next-gen/variants/button.js +7 -1
  85. package/lib/styles/themes/next-gen/variants/links.js +12 -1
  86. package/lib/styles/themes/next-gen/variants/navbar.js +11 -7
  87. package/lib/styles/variants/variants.js +3 -1
  88. package/lib/types/pagination.js +1 -0
  89. package/lib/utils/devUtils/shouldReturnComingSoon.js +9 -3
  90. package/package.json +1 -1
  91. package/lib/cjs/recipes/NextGen/NavBarNextGen.stories.d.ts +0 -6
  92. package/lib/cjs/recipes/NextGen/NavBarNextGen.stories.js +0 -19
  93. package/lib/cjs/styles/themes/next-gen/stories/NavBarNextGenComponent.js +0 -191
  94. package/lib/recipes/NextGen/NavBarNextGen.stories.js +0 -9
  95. package/lib/styles/themes/next-gen/stories/NavBarNextGenComponent.js +0 -182
  96. /package/lib/cjs/{styles/themes/next-gen → components/NavBar}/stories/NavBarNextGenComponent.d.ts +0 -0
  97. /package/lib/cjs/{styles/themeOverrides/nextGenDarkMode → components/NavBar}/stories/NextGenDarkNavStory.chomatic.stories.d.ts +0 -0
  98. /package/lib/cjs/{styles/themes/next-gen → components/NavBar}/stories/NextGenNavBar.chromatic.stories.d.ts +0 -0
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+
3
+ var _Object$keys = require("@babel/runtime-corejs3/core-js-stable/object/keys");
4
+ var _Object$getOwnPropertySymbols = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols");
5
+ var _filterInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/filter");
6
+ var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
7
+ var _forEachInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/for-each");
8
+ var _Object$getOwnPropertyDescriptors = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors");
9
+ var _Object$defineProperties = require("@babel/runtime-corejs3/core-js-stable/object/define-properties");
10
+ var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
11
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
12
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
13
+ var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
14
+ var _react = _interopRequireDefault(require("react"));
15
+ var _ViewDashboardIcon = _interopRequireDefault(require("@pingux/mdi-react/ViewDashboardIcon"));
16
+ var _hooks = require("../../hooks");
17
+ var _testWrapper = require("../../utils/testUtils/testWrapper");
18
+ var _NavBar = _interopRequireDefault(require("../NavBar"));
19
+ var _NavBarSection = _interopRequireDefault(require("./NavBarSection"));
20
+ var _react2 = require("@emotion/react");
21
+ function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
22
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
23
+ var data = [{
24
+ 'data-id': 'dashboard-data-id',
25
+ heading: 'Dashboard',
26
+ icon: _ViewDashboardIcon["default"],
27
+ key: 'Dashboard',
28
+ children: ['Users', 'Group', 'Populations', 'Attributes', 'Roles', 'Dashboard Unique']
29
+ }];
30
+ var mockTheme = {
31
+ themeState: {
32
+ isOnyx: false
33
+ },
34
+ icons: {
35
+ MenuDown: function MenuDown() {
36
+ return (0, _react2.jsx)("span", null, "MenuDown");
37
+ },
38
+ MenuUp: function MenuUp() {
39
+ return (0, _react2.jsx)("span", null, "MenuUp");
40
+ }
41
+ }
42
+ };
43
+ jest.mock('../../hooks/useGetTheme', function () {
44
+ return {
45
+ __esModule: true,
46
+ "default": jest.fn()
47
+ };
48
+ });
49
+ var NavBarWithSection = /*#__PURE__*/_react["default"].forwardRef(function (props, ref) {
50
+ return (0, _react2.jsx)(_NavBar["default"], null, (0, _react2.jsx)(_NavBarSection["default"], (0, _extends2["default"])({
51
+ ref: ref
52
+ }, props, {
53
+ items: data
54
+ })));
55
+ });
56
+ var getComponent = function getComponent() {
57
+ return (0, _testWrapper.render)((0, _react2.jsx)(NavBarWithSection, null));
58
+ };
59
+ describe('NavItemHeader', function () {
60
+ beforeEach(function () {
61
+ jest.clearAllMocks();
62
+ _hooks.useGetTheme.mockReturnValue(mockTheme);
63
+ });
64
+ it('should render Icon', function () {
65
+ getComponent();
66
+ var icon = _testWrapper.screen.getByTestId('Dashboard').querySelector('svg');
67
+ expect(icon).toBeInTheDocument();
68
+ expect(icon).toHaveAttribute('width', '20px');
69
+ });
70
+ });
71
+ describe('NavItemHeader', function () {
72
+ beforeEach(function () {
73
+ jest.clearAllMocks();
74
+ _hooks.useGetTheme.mockReturnValue(_objectSpread(_objectSpread({}, mockTheme), {}, {
75
+ themeState: {
76
+ isOnyx: true
77
+ }
78
+ }));
79
+ });
80
+ it('should render Icon', function () {
81
+ getComponent();
82
+ var icon = _testWrapper.screen.getByTestId('Dashboard').querySelector('svg');
83
+ expect(icon).toBeInTheDocument();
84
+ expect(icon).toHaveAttribute('width', 'icon-200');
85
+ });
86
+ });
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { PaginationProps } from '../../types/pagination';
3
+ declare const Pagination: React.ForwardRefExoticComponent<PaginationProps & React.RefAttributes<HTMLDivElement>>;
4
+ export default Pagination;
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+
3
+ var _typeof = require("@babel/runtime-corejs3/helpers/typeof");
4
+ var _WeakMap = require("@babel/runtime-corejs3/core-js-stable/weak-map");
5
+ var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
6
+ var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
7
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
8
+ _Object$defineProperty(exports, "__esModule", {
9
+ value: true
10
+ });
11
+ exports["default"] = void 0;
12
+ var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
13
+ var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
14
+ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/objectWithoutProperties"));
15
+ var _react = _interopRequireWildcard(require("react"));
16
+ var _ChevronLeftIcon = _interopRequireDefault(require("@pingux/mdi-react/ChevronLeftIcon"));
17
+ var _ChevronRightIcon = _interopRequireDefault(require("@pingux/mdi-react/ChevronRightIcon"));
18
+ var _hooks = require("../../hooks");
19
+ var _usePagination2 = _interopRequireDefault(require("../../hooks/usePagination"));
20
+ var _index = require("../../index");
21
+ var _react2 = require("@emotion/react");
22
+ var _excluded = ["setOffsetCount", "offsetOptions"];
23
+ function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "function") return null; var cacheBabelInterop = new _WeakMap(); var cacheNodeInterop = new _WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
24
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = _Object$defineProperty && _Object$getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { _Object$defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
25
+ var RangeSelectPopover = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
26
+ var state = props.state,
27
+ buttonProps = props.buttonProps;
28
+ var setOffsetCount = state.setOffsetCount,
29
+ offsetOptions = state.offsetOptions,
30
+ others = (0, _objectWithoutProperties2["default"])(state, _excluded);
31
+ var menuRef = (0, _hooks.useLocalOrForwardRef)(ref);
32
+ return (0, _react2.jsx)(_index.OverlayProvider, null, (0, _react2.jsx)(_index.Box, {
33
+ sx: {
34
+ flexGrow: 1
35
+ }
36
+ }, (0, _react2.jsx)(_index.PopoverMenu, {
37
+ ref: menuRef
38
+ }, (0, _react2.jsx)(_index.Button, (0, _extends2["default"])({}, buttonProps, {
39
+ variant: "paginationMenu"
40
+ }), state.popoverButtonString), (0, _react2.jsx)(_index.Menu, (0, _extends2["default"])({
41
+ onSelectionChange: setOffsetCount,
42
+ selectionMode: "single"
43
+ }, others), (0, _map["default"])(offsetOptions).call(offsetOptions, function (option) {
44
+ return (0, _react2.jsx)(_index.Item, {
45
+ key: option,
46
+ textValue: "".concat(option)
47
+ }, "Show", ' ', option, ' ', "Results");
48
+ })))));
49
+ });
50
+ var Pagination = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
51
+ var _usePagination = (0, _usePagination2["default"])(props),
52
+ state = _usePagination.state,
53
+ previousButtonProps = _usePagination.previousButtonProps,
54
+ nextButtonProps = _usePagination.nextButtonProps,
55
+ containerProps = _usePagination.containerProps,
56
+ offsetMenuProps = _usePagination.offsetMenuProps;
57
+ var paginationRef = (0, _hooks.useLocalOrForwardRef)(ref);
58
+ return (0, _react2.jsx)(_index.Box, (0, _extends2["default"])({
59
+ isRow: true,
60
+ variant: "pagination.container"
61
+ }, containerProps, {
62
+ ref: paginationRef
63
+ }), (0, _react2.jsx)(_index.Box, {
64
+ variant: "pagination.wrapper",
65
+ isRow: true
66
+ }, (0, _react2.jsx)(RangeSelectPopover, (0, _extends2["default"])({}, offsetMenuProps, {
67
+ state: state
68
+ })), (0, _react2.jsx)(_index.Box, {
69
+ variant: "pagination.iconWrapper",
70
+ isRow: true
71
+ }, (0, _react2.jsx)(_index.IconButton, previousButtonProps, (0, _react2.jsx)(_index.Icon, {
72
+ icon: _ChevronLeftIcon["default"]
73
+ })), (0, _react2.jsx)(_index.IconButton, nextButtonProps, (0, _react2.jsx)(_index.Icon, {
74
+ icon: _ChevronRightIcon["default"]
75
+ })))));
76
+ });
77
+ var _default = Pagination;
78
+ exports["default"] = _default;
@@ -0,0 +1,68 @@
1
+ import { Meta } from '@storybook/addon-docs';
2
+
3
+ <Meta title="Components/Pagination/Pagination" />
4
+
5
+ # Pagination
6
+
7
+ The Pagination component allows users to navigate through large datasets by dividing them into smaller, more manageable pages. It provides controls for navigating between pages and selecting the number of items displayed per page.
8
+
9
+ ### Features
10
+
11
+ - Customizable offset options to control the number of items displayed per page.
12
+ - Next/Previous navigation buttons for seamless page transitions.
13
+ - Works in both controlled and uncontrolled states.
14
+ - Integrates with `PaginationContext` for managing state.
15
+
16
+ ### Required Components
17
+
18
+ This component requires the following components:
19
+ - `PaginationProvider`
20
+ - `ListView` (optional for displaying paginated data)
21
+
22
+ ### Accessibility
23
+
24
+ This component adheres to the [WCAG 2.1 - 2.4.4 Link Purpose (In Context)](https://www.w3.org/WAI/WCAG21/Understanding/link-purpose-in-context.html) accessibility guidelines.
25
+
26
+ #### Keyboard Navigation
27
+
28
+ | Key | Functions |
29
+ |---------------|-----------------------------------|
30
+ | Tab | Moves focus between controls. |
31
+ | Enter | Activates the focused control. |
32
+
33
+ #### Screen Readers
34
+
35
+ This component uses the following attributes to assist screen readers:
36
+ - **`aria-label`**: Provides an accessible name for the pagination controls.
37
+ - **`aria-disabled`**: Indicates when navigation buttons are disabled.
38
+ - **`aria-live`**: Updates screen readers with changes in pagination state.
39
+
40
+ ### Usage
41
+
42
+ ```tsx
43
+ import { Pagination, PaginationProvider } from '@pingux/astro';
44
+
45
+ <PaginationProvider>
46
+ <Pagination totalCount={250} />
47
+ <ListView
48
+ items={animals.slice(paginationState.firstRenderedIndex, paginationState.lastRenderedIndex).map(item => ({
49
+ name: item.name,
50
+ key: item.name,
51
+ id: item.name,
52
+ }))}
53
+ >
54
+ {(item) => (
55
+ <Item key={item.name}>
56
+ <ListViewItem
57
+ data={{
58
+ text: item.name,
59
+ icon: FormSelectIcon,
60
+ }}
61
+ iconProps={{
62
+ color: 'text.secondary',
63
+ }}
64
+ />
65
+ </Item>
66
+ )}
67
+ </ListView>
68
+ </PaginationProvider>
@@ -0,0 +1,39 @@
1
+ import React from 'react';
2
+ declare const _default: {
3
+ title: string;
4
+ component: React.ForwardRefExoticComponent<import("../../types/pagination").PaginationProps & React.RefAttributes<HTMLDivElement>>;
5
+ parameters: {
6
+ docs: {
7
+ page: () => React.JSX.Element;
8
+ };
9
+ };
10
+ argTypes: {
11
+ totalCount: {
12
+ control: {
13
+ type: string;
14
+ };
15
+ };
16
+ currentPageIndex: {
17
+ control: {
18
+ type: string;
19
+ };
20
+ };
21
+ offsetCount: {
22
+ control: {
23
+ type: string;
24
+ };
25
+ };
26
+ offsetOptions: {
27
+ control: {
28
+ type: string;
29
+ };
30
+ };
31
+ onPageIndexChange: {};
32
+ onOffsetCountChange: {};
33
+ };
34
+ };
35
+ export default _default;
36
+ export declare const Default: (args: any) => React.JSX.Element;
37
+ export declare const WithListView: () => React.JSX.Element;
38
+ export declare const Controlled: () => React.JSX.Element;
39
+ export declare const CustomOptions: () => React.JSX.Element;
@@ -0,0 +1,159 @@
1
+ "use strict";
2
+
3
+ var _typeof = require("@babel/runtime-corejs3/helpers/typeof");
4
+ var _WeakMap = require("@babel/runtime-corejs3/core-js-stable/weak-map");
5
+ var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
6
+ var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
7
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
8
+ _Object$defineProperty(exports, "__esModule", {
9
+ value: true
10
+ });
11
+ exports["default"] = exports.WithListView = exports.Default = exports.CustomOptions = exports.Controlled = void 0;
12
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/slicedToArray"));
13
+ var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
14
+ var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
15
+ var _slice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/slice"));
16
+ var _react = _interopRequireWildcard(require("react"));
17
+ var _FormSelectIcon = _interopRequireDefault(require("@pingux/mdi-react/FormSelectIcon"));
18
+ var _usePaginationState2 = _interopRequireDefault(require("../../hooks/usePaginationState"));
19
+ var _index = require("../../index");
20
+ var _ListView = require("../ListView/ListView.stories");
21
+ var _Pagination = _interopRequireDefault(require("./Pagination.mdx"));
22
+ var _react2 = require("@emotion/react");
23
+ function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "function") return null; var cacheBabelInterop = new _WeakMap(); var cacheNodeInterop = new _WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
24
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = _Object$defineProperty && _Object$getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { _Object$defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
25
+ var _default = {
26
+ title: 'Components/Pagination',
27
+ component: _index.Pagination,
28
+ parameters: {
29
+ docs: {
30
+ page: function page() {
31
+ return (0, _react2.jsx)(_Pagination["default"], null);
32
+ }
33
+ }
34
+ },
35
+ argTypes: {
36
+ totalCount: {
37
+ control: {
38
+ type: 'number'
39
+ }
40
+ },
41
+ currentPageIndex: {
42
+ control: {
43
+ type: 'number'
44
+ }
45
+ },
46
+ offsetCount: {
47
+ control: {
48
+ type: 'number'
49
+ }
50
+ },
51
+ offsetOptions: {
52
+ control: {
53
+ type: 'array'
54
+ }
55
+ },
56
+ onPageIndexChange: {},
57
+ onOffsetCountChange: {}
58
+ }
59
+ };
60
+ exports["default"] = _default;
61
+ var ExampleComponent = function ExampleComponent() {
62
+ var _context;
63
+ var _usePaginationState = (0, _usePaginationState2["default"])(),
64
+ paginationState = _usePaginationState.paginationState;
65
+ return (0, _react2.jsx)(_index.ScrollBox, {
66
+ maxHeight: "400px"
67
+ }, (0, _react2.jsx)(_index.ListView, {
68
+ items: (0, _map["default"])(_context = (0, _slice["default"])(_ListView.animals).call(_ListView.animals, paginationState.firstRenderedIndex, paginationState.lastRenderedIndex + 1)).call(_context, function (_item) {
69
+ return {
70
+ name: _item.name,
71
+ key: _item.name,
72
+ id: _item.name
73
+ };
74
+ })
75
+ }, function (item) {
76
+ return (0, _react2.jsx)(_index.Item, {
77
+ key: item.name
78
+ }, (0, _react2.jsx)(_index.ListViewItem, {
79
+ data: {
80
+ text: item.name,
81
+ icon: _FormSelectIcon["default"]
82
+ },
83
+ iconProps: {
84
+ color: 'text.secondary'
85
+ }
86
+ }));
87
+ }));
88
+ };
89
+ var Default = function Default(args) {
90
+ return (0, _react2.jsx)(_index.Box, {
91
+ sx: {
92
+ maxWidth: '350px',
93
+ gap: 'sm'
94
+ }
95
+ }, (0, _react2.jsx)(_index.Pagination, (0, _extends2["default"])({
96
+ totalCount: 250
97
+ }, args)));
98
+ };
99
+ exports.Default = Default;
100
+ var WithListView = function WithListView() {
101
+ return (0, _react2.jsx)(_index.PaginationProvider, null, (0, _react2.jsx)(_index.Box, {
102
+ gap: "sm"
103
+ }, (0, _react2.jsx)(ExampleComponent, null), (0, _react2.jsx)(_index.Pagination, {
104
+ totalCount: _ListView.animals.length
105
+ })));
106
+ };
107
+ exports.WithListView = WithListView;
108
+ var Controlled = function Controlled() {
109
+ var _useState = (0, _react.useState)(24),
110
+ _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
111
+ index = _useState2[0],
112
+ setIndex = _useState2[1];
113
+ var _useState3 = (0, _react.useState)(10),
114
+ _useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
115
+ offsetCount = _useState4[0],
116
+ setOffsetCount = _useState4[1];
117
+ return (0, _react2.jsx)(_index.Box, {
118
+ sx: {
119
+ maxWidth: '350px',
120
+ gap: 'sm'
121
+ }
122
+ }, (0, _react2.jsx)(_index.Button, {
123
+ onPress: function onPress() {
124
+ return setIndex(0);
125
+ }
126
+ }, "Reset Index"), (0, _react2.jsx)(_index.Pagination, {
127
+ totalCount: 250,
128
+ currentPageIndex: index,
129
+ offsetCount: offsetCount,
130
+ onOffsetCountChange: setOffsetCount,
131
+ onPageIndexChange: function onPageIndexChange(i) {
132
+ setIndex(i);
133
+ }
134
+ }));
135
+ };
136
+ exports.Controlled = Controlled;
137
+ var CustomOptions = function CustomOptions() {
138
+ var _useState5 = (0, _react.useState)(24),
139
+ _useState6 = (0, _slicedToArray2["default"])(_useState5, 2),
140
+ index = _useState6[0],
141
+ setIndex = _useState6[1];
142
+ var testFunc = function testFunc(key) {
143
+ setIndex(key);
144
+ };
145
+ return (0, _react2.jsx)(_index.Box, {
146
+ sx: {
147
+ maxWidth: '350px',
148
+ gap: 'sm'
149
+ }
150
+ }, (0, _react2.jsx)(_index.Pagination, {
151
+ totalCount: 250,
152
+ currentPageIndex: index,
153
+ offsetOptions: [10, 15, 25, 50, 100],
154
+ onPageIndexChange: function onPageIndexChange(key) {
155
+ testFunc(key);
156
+ }
157
+ }));
158
+ };
159
+ exports.CustomOptions = CustomOptions;
@@ -0,0 +1,17 @@
1
+ declare const _default: {
2
+ container: {
3
+ alignItems: string;
4
+ minWidth: string;
5
+ with: string;
6
+ ml: string;
7
+ flexGrow: number;
8
+ };
9
+ iconWrapper: {
10
+ ml: string;
11
+ };
12
+ wrapper: {
13
+ ml: string;
14
+ alignItems: string;
15
+ };
16
+ };
17
+ export default _default;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
4
+ _Object$defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports["default"] = void 0;
8
+ var container = {
9
+ alignItems: 'center',
10
+ minWidth: '100%',
11
+ "with": '100%',
12
+ ml: 'auto',
13
+ flexGrow: 1
14
+ };
15
+ var iconWrapper = {
16
+ ml: 'md'
17
+ };
18
+ var wrapper = {
19
+ ml: 'auto',
20
+ alignItems: 'center'
21
+ };
22
+ var _default = {
23
+ container: container,
24
+ iconWrapper: iconWrapper,
25
+ wrapper: wrapper
26
+ };
27
+ exports["default"] = _default;
@@ -0,0 +1 @@
1
+ export {};