@salutejs/plasma-new-hope 0.322.0-canary.1944.14662885061.0 → 0.322.0-canary.1947.14664713311.0

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 (91) hide show
  1. package/emotion/cjs/components/PaginationDots/PaginationDots.js +321 -0
  2. package/emotion/cjs/components/PaginationDots/PaginationDots.styles.js +44 -0
  3. package/emotion/cjs/components/PaginationDots/PaginationDots.template-doc.mdx +95 -0
  4. package/emotion/cjs/components/PaginationDots/PaginationDots.tokens.js +30 -0
  5. package/emotion/cjs/components/PaginationDots/PaginationDots.types.js +5 -0
  6. package/emotion/cjs/components/PaginationDots/hooks/useAnimation.js +108 -0
  7. package/emotion/cjs/components/PaginationDots/index.js +31 -0
  8. package/emotion/cjs/components/PaginationDots/utils/getDotSize.js +46 -0
  9. package/emotion/cjs/components/PaginationDots/variations/_size/base.js +8 -0
  10. package/emotion/cjs/components/PaginationDots/variations/_size/tokens.json +1 -0
  11. package/emotion/cjs/components/PaginationDots/variations/_view/base.js +8 -0
  12. package/emotion/cjs/components/PaginationDots/variations/_view/tokens.json +1 -0
  13. package/emotion/cjs/examples/plasma_b2c/components/PaginationDots/PaginationDots.config.js +23 -0
  14. package/emotion/cjs/examples/plasma_b2c/components/PaginationDots/PaginationDots.js +11 -0
  15. package/emotion/cjs/examples/plasma_b2c/components/PaginationDots/PaginationDots.stories.tsx +87 -0
  16. package/emotion/cjs/examples/plasma_web/components/PaginationDots/PaginationDots.config.js +24 -0
  17. package/emotion/cjs/examples/plasma_web/components/PaginationDots/PaginationDots.js +11 -0
  18. package/emotion/cjs/examples/plasma_web/components/PaginationDots/PaginationDots.stories.tsx +68 -0
  19. package/emotion/es/components/PaginationDots/PaginationDots.js +311 -0
  20. package/emotion/es/components/PaginationDots/PaginationDots.styles.js +37 -0
  21. package/emotion/es/components/PaginationDots/PaginationDots.template-doc.mdx +95 -0
  22. package/emotion/es/components/PaginationDots/PaginationDots.tokens.js +24 -0
  23. package/emotion/es/components/PaginationDots/PaginationDots.types.js +1 -0
  24. package/emotion/es/components/PaginationDots/hooks/useAnimation.js +102 -0
  25. package/emotion/es/components/PaginationDots/index.js +2 -0
  26. package/emotion/es/components/PaginationDots/utils/getDotSize.js +40 -0
  27. package/emotion/es/components/PaginationDots/variations/_size/base.js +2 -0
  28. package/emotion/es/components/PaginationDots/variations/_size/tokens.json +1 -0
  29. package/emotion/es/components/PaginationDots/variations/_view/base.js +2 -0
  30. package/emotion/es/components/PaginationDots/variations/_view/tokens.json +1 -0
  31. package/emotion/es/examples/plasma_b2c/components/PaginationDots/PaginationDots.config.js +17 -0
  32. package/emotion/es/examples/plasma_b2c/components/PaginationDots/PaginationDots.js +5 -0
  33. package/emotion/es/examples/plasma_b2c/components/PaginationDots/PaginationDots.stories.tsx +87 -0
  34. package/emotion/es/examples/plasma_web/components/PaginationDots/PaginationDots.config.js +18 -0
  35. package/emotion/es/examples/plasma_web/components/PaginationDots/PaginationDots.js +5 -0
  36. package/emotion/es/examples/plasma_web/components/PaginationDots/PaginationDots.stories.tsx +68 -0
  37. package/package.json +4 -4
  38. package/styled-components/cjs/components/PaginationDots/PaginationDots.js +321 -0
  39. package/styled-components/cjs/components/PaginationDots/PaginationDots.styles.js +26 -0
  40. package/styled-components/cjs/components/PaginationDots/PaginationDots.template-doc.mdx +95 -0
  41. package/styled-components/cjs/components/PaginationDots/PaginationDots.tokens.js +30 -0
  42. package/styled-components/cjs/components/PaginationDots/PaginationDots.types.js +5 -0
  43. package/styled-components/cjs/components/PaginationDots/hooks/useAnimation.js +108 -0
  44. package/styled-components/cjs/components/PaginationDots/index.js +31 -0
  45. package/styled-components/cjs/components/PaginationDots/utils/getDotSize.js +46 -0
  46. package/styled-components/cjs/components/PaginationDots/variations/_size/base.js +8 -0
  47. package/styled-components/cjs/components/PaginationDots/variations/_size/tokens.json +1 -0
  48. package/styled-components/cjs/components/PaginationDots/variations/_view/base.js +8 -0
  49. package/styled-components/cjs/components/PaginationDots/variations/_view/tokens.json +1 -0
  50. package/styled-components/cjs/examples/plasma_b2c/components/PaginationDots/PaginationDots.config.js +23 -0
  51. package/styled-components/cjs/examples/plasma_b2c/components/PaginationDots/PaginationDots.js +11 -0
  52. package/styled-components/cjs/examples/plasma_b2c/components/PaginationDots/PaginationDots.stories.tsx +87 -0
  53. package/styled-components/cjs/examples/plasma_web/components/PaginationDots/PaginationDots.config.js +24 -0
  54. package/styled-components/cjs/examples/plasma_web/components/PaginationDots/PaginationDots.js +11 -0
  55. package/styled-components/cjs/examples/plasma_web/components/PaginationDots/PaginationDots.stories.tsx +68 -0
  56. package/styled-components/es/components/PaginationDots/PaginationDots.js +311 -0
  57. package/styled-components/es/components/PaginationDots/PaginationDots.styles.js +18 -0
  58. package/styled-components/es/components/PaginationDots/PaginationDots.template-doc.mdx +95 -0
  59. package/styled-components/es/components/PaginationDots/PaginationDots.tokens.js +24 -0
  60. package/styled-components/es/components/PaginationDots/PaginationDots.types.js +1 -0
  61. package/styled-components/es/components/PaginationDots/hooks/useAnimation.js +102 -0
  62. package/styled-components/es/components/PaginationDots/index.js +2 -0
  63. package/styled-components/es/components/PaginationDots/utils/getDotSize.js +40 -0
  64. package/styled-components/es/components/PaginationDots/variations/_size/base.js +2 -0
  65. package/styled-components/es/components/PaginationDots/variations/_size/tokens.json +1 -0
  66. package/styled-components/es/components/PaginationDots/variations/_view/base.js +2 -0
  67. package/styled-components/es/components/PaginationDots/variations/_view/tokens.json +1 -0
  68. package/styled-components/es/examples/plasma_b2c/components/PaginationDots/PaginationDots.config.js +17 -0
  69. package/styled-components/es/examples/plasma_b2c/components/PaginationDots/PaginationDots.js +5 -0
  70. package/styled-components/es/examples/plasma_b2c/components/PaginationDots/PaginationDots.stories.tsx +87 -0
  71. package/styled-components/es/examples/plasma_web/components/PaginationDots/PaginationDots.config.js +18 -0
  72. package/styled-components/es/examples/plasma_web/components/PaginationDots/PaginationDots.js +5 -0
  73. package/styled-components/es/examples/plasma_web/components/PaginationDots/PaginationDots.stories.tsx +68 -0
  74. package/types/components/PaginationDots/PaginationDots.d.ts +31 -0
  75. package/types/components/PaginationDots/PaginationDots.d.ts.map +1 -0
  76. package/types/components/PaginationDots/PaginationDots.styles.d.ts +9 -0
  77. package/types/components/PaginationDots/PaginationDots.styles.d.ts.map +1 -0
  78. package/types/components/PaginationDots/PaginationDots.tokens.d.ts +25 -0
  79. package/types/components/PaginationDots/PaginationDots.tokens.d.ts.map +1 -0
  80. package/types/components/PaginationDots/PaginationDots.types.d.ts +46 -0
  81. package/types/components/PaginationDots/PaginationDots.types.d.ts.map +1 -0
  82. package/types/components/PaginationDots/hooks/useAnimation.d.ts +23 -0
  83. package/types/components/PaginationDots/hooks/useAnimation.d.ts.map +1 -0
  84. package/types/components/PaginationDots/index.d.ts +4 -0
  85. package/types/components/PaginationDots/index.d.ts.map +1 -0
  86. package/types/components/PaginationDots/utils/getDotSize.d.ts +2 -0
  87. package/types/components/PaginationDots/utils/getDotSize.d.ts.map +1 -0
  88. package/types/components/PaginationDots/variations/_size/base.d.ts +2 -0
  89. package/types/components/PaginationDots/variations/_size/base.d.ts.map +1 -0
  90. package/types/components/PaginationDots/variations/_view/base.d.ts +2 -0
  91. package/types/components/PaginationDots/variations/_view/base.d.ts.map +1 -0
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getDotSize = void 0;
7
+ var getDotSize = exports.getDotSize = function getDotSize(size, index, offset, count, visibleCount) {
8
+ var innerViewValue = index - offset;
9
+ var toEnd = count - (visibleCount + offset);
10
+ var canScrollBackward = Boolean(offset);
11
+ var canScrollForward = Boolean(toEnd);
12
+ var isFirst = innerViewValue === 0;
13
+ var isSecond = innerViewValue === 1;
14
+ var isSecondLast = innerViewValue === visibleCount - 2;
15
+ var isLast = innerViewValue === visibleCount - 1;
16
+ if (size === 's') {
17
+ if (isFirst && canScrollBackward || isLast && canScrollForward) {
18
+ return 'xs';
19
+ }
20
+ return 's';
21
+ }
22
+ if (canScrollBackward) {
23
+ // (m) m m s xs
24
+ // m (m) m s xs
25
+ // m m (m) s xs
26
+ // s m (m) s xs
27
+ // xs s m (m) s
28
+ // xs s m (m) s
29
+ // xs s m m (m)
30
+ if (isFirst) {
31
+ return offset === 1 ? 's' : 'xs';
32
+ }
33
+ if (isSecond && offset > 1) {
34
+ return 's';
35
+ }
36
+ }
37
+ if (canScrollForward) {
38
+ if (isLast) {
39
+ return toEnd === 1 ? 's' : 'xs';
40
+ }
41
+ if (isSecondLast && toEnd > 1) {
42
+ return 's';
43
+ }
44
+ }
45
+ return 'm';
46
+ };
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.base = void 0;
7
+ var _styledComponents = /*#__PURE__*/require("styled-components");
8
+ var base = exports.base = /*#__PURE__*/(0, _styledComponents.css)([""]);
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.base = void 0;
7
+ var _styledComponents = /*#__PURE__*/require("styled-components");
8
+ var base = exports.base = /*#__PURE__*/(0, _styledComponents.css)([""]);
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.config = void 0;
7
+ var _styledComponents = /*#__PURE__*/require("styled-components");
8
+ var _PaginationDots = /*#__PURE__*/require("../../../../components/PaginationDots");
9
+ var config = exports.config = {
10
+ defaults: {
11
+ view: 'default',
12
+ size: 'm'
13
+ },
14
+ variations: {
15
+ view: {
16
+ "default": /*#__PURE__*/(0, _styledComponents.css)(["", ":#0808081f;", ":#080808;"], _PaginationDots.paginationDotsTokens.itemBackground, _PaginationDots.paginationDotsTokens.activeItemBackground)
17
+ },
18
+ size: {
19
+ s: /*#__PURE__*/(0, _styledComponents.css)(["", ":0 0.375rem;", ":0.375rem 0;", ":0.75rem;", ":0.5rem;", ":0.375rem;", ":50%;", ":2rem;", ":0.5rem;", ":0.375rem;", ":0.5rem;", ":2rem;"], _PaginationDots.paginationDotsTokens.dotPadding, _PaginationDots.paginationDotsTokens.verticalDotPadding, _PaginationDots.paginationDotsTokens.dotSizeM, _PaginationDots.paginationDotsTokens.dotSizeS, _PaginationDots.paginationDotsTokens.dotSizeXS, _PaginationDots.paginationDotsTokens.dotBorderRadius, _PaginationDots.paginationDotsTokens.lineWidth, _PaginationDots.paginationDotsTokens.lineHeight, _PaginationDots.paginationDotsTokens.lineBorderRadius, _PaginationDots.paginationDotsTokens.verticalLineWidth, _PaginationDots.paginationDotsTokens.verticalLineHeight),
20
+ m: /*#__PURE__*/(0, _styledComponents.css)(["", ":0 0.375rem;", ":0.375rem 0;", ":50%;", ":0.75rem;", ":0.5rem;", ":0.375rem;", ":3rem;", ":0.75rem;", ":0.375rem;", ":0.75rem;", ":3rem;"], _PaginationDots.paginationDotsTokens.dotPadding, _PaginationDots.paginationDotsTokens.verticalDotPadding, _PaginationDots.paginationDotsTokens.dotBorderRadius, _PaginationDots.paginationDotsTokens.dotSizeM, _PaginationDots.paginationDotsTokens.dotSizeS, _PaginationDots.paginationDotsTokens.dotSizeXS, _PaginationDots.paginationDotsTokens.lineWidth, _PaginationDots.paginationDotsTokens.lineHeight, _PaginationDots.paginationDotsTokens.lineBorderRadius, _PaginationDots.paginationDotsTokens.verticalLineWidth, _PaginationDots.paginationDotsTokens.verticalLineHeight)
21
+ }
22
+ }
23
+ };
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.PaginationDots = void 0;
7
+ var _PaginationDots = /*#__PURE__*/require("../../../../components/PaginationDots");
8
+ var _engines = /*#__PURE__*/require("../../../../engines");
9
+ var _PaginationDots2 = /*#__PURE__*/require("./PaginationDots.config");
10
+ var mergedConfig = /*#__PURE__*/(0, _engines.mergeConfig)(_PaginationDots.paginationDotsConfig, _PaginationDots2.config);
11
+ var PaginationDots = exports.PaginationDots = /*#__PURE__*/(0, _engines.component)(mergedConfig);
@@ -0,0 +1,87 @@
1
+ import * as React from 'react';
2
+ import { ComponentProps, useState } from 'react';
3
+ import type { StoryObj, Meta } from '@storybook/react';
4
+ import { disableProps, getConfigVariations } from '@salutejs/plasma-sb-utils';
5
+
6
+ import { WithTheme } from '../../../_helpers';
7
+
8
+ import { PaginationDots } from './PaginationDots';
9
+ import { config } from './PaginationDots.config';
10
+
11
+ const { views, sizes } = getConfigVariations(config);
12
+ const orientations: Array<string> = ['vertical', 'horizontal'];
13
+
14
+ const meta: Meta<typeof PaginationDots> = {
15
+ title: 'b2c/Data Entry/PaginationDots',
16
+ decorators: [WithTheme],
17
+ component: PaginationDots,
18
+ args: {
19
+ view: 'default',
20
+ size: 'm',
21
+ },
22
+ argTypes: {
23
+ view: {
24
+ options: views,
25
+ control: {
26
+ type: 'select',
27
+ },
28
+ },
29
+ size: {
30
+ options: sizes,
31
+ control: {
32
+ type: 'inline-radio',
33
+ },
34
+ },
35
+ dotType: {
36
+ options: ['dot', 'line'],
37
+ control: {
38
+ type: 'inline-radio',
39
+ },
40
+ },
41
+ orientation: {
42
+ options: orientations,
43
+ control: {
44
+ type: 'inline-radio',
45
+ },
46
+ },
47
+ count: {
48
+ control: {
49
+ type: 'number',
50
+ },
51
+ },
52
+ visibleCount: {
53
+ control: {
54
+ type: 'number',
55
+ },
56
+ },
57
+ ...disableProps(['value', 'focused', 'pin']),
58
+ },
59
+ };
60
+
61
+ export default meta;
62
+
63
+ type StoryPropsDefault = ComponentProps<typeof PaginationDots> & {
64
+ currentDot: string;
65
+ };
66
+
67
+ const StoryDefault = ({ dotType, ...rest }: StoryPropsDefault) => {
68
+ const [value, setValue] = useState(0);
69
+
70
+ return (
71
+ <div style={{ width: '400px', height: '400px' }}>
72
+ <PaginationDots value={value} activeElementView={dotType} onChange={setValue} {...rest} />
73
+ </div>
74
+ );
75
+ };
76
+
77
+ export const Default: StoryObj<StoryPropsDefault> = {
78
+ args: {
79
+ size: 'm',
80
+ dotType: 'dot',
81
+ orientation: 'horizontal',
82
+ centered: false,
83
+ count: 9,
84
+ visibleCount: 9,
85
+ },
86
+ render: (args) => <StoryDefault {...args} />,
87
+ };
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.config = void 0;
7
+ var _styledComponents = /*#__PURE__*/require("styled-components");
8
+ var _PaginationDots = /*#__PURE__*/require("../../../../components/PaginationDots");
9
+ var config = exports.config = {
10
+ defaults: {
11
+ view: 'default',
12
+ focused: 'true',
13
+ size: 'm'
14
+ },
15
+ variations: {
16
+ view: {
17
+ "default": /*#__PURE__*/(0, _styledComponents.css)(["", ":'#0808081f',", ":'#080808',"], _PaginationDots.paginationDotsTokens.itemBackground, _PaginationDots.paginationDotsTokens.activeItemBackground)
18
+ },
19
+ size: {
20
+ s: /*#__PURE__*/(0, _styledComponents.css)(["", ":'0 0.375rem',", ":'0.375rem 0',", ":'0.375rem',", ":'0.5rem',", ":'0.75rem',", ":'50%',", ":'2rem',", ":'0.5rem',", ":'0.375rem',", ":'0.5rem',", ":'2rem',"], _PaginationDots.paginationDotsTokens.dotPadding, _PaginationDots.paginationDotsTokens.verticalDotPadding, _PaginationDots.paginationDotsTokens.dotSizeM, _PaginationDots.paginationDotsTokens.dotSizeS, _PaginationDots.paginationDotsTokens.dotSizeXS, _PaginationDots.paginationDotsTokens.dotBorderRadius, _PaginationDots.paginationDotsTokens.lineWidth, _PaginationDots.paginationDotsTokens.lineHeight, _PaginationDots.paginationDotsTokens.lineBorderRadius, _PaginationDots.paginationDotsTokens.verticalLineWidth, _PaginationDots.paginationDotsTokens.verticalLineHeight),
21
+ m: /*#__PURE__*/(0, _styledComponents.css)(["", ":'0 0.375rem',", ":'0.375rem 0',", ":'50%',", ":'0.375rem',", ":'0.5rem',", ":'0.75rem',", ":'3rem',", ":'0.75rem',", ":'0.375rem',", ":'0.75rem',", ":'3rem',"], _PaginationDots.paginationDotsTokens.dotPadding, _PaginationDots.paginationDotsTokens.verticalDotPadding, _PaginationDots.paginationDotsTokens.dotBorderRadius, _PaginationDots.paginationDotsTokens.dotSizeM, _PaginationDots.paginationDotsTokens.dotSizeS, _PaginationDots.paginationDotsTokens.dotSizeXS, _PaginationDots.paginationDotsTokens.lineWidth, _PaginationDots.paginationDotsTokens.lineHeight, _PaginationDots.paginationDotsTokens.lineBorderRadius, _PaginationDots.paginationDotsTokens.verticalLineWidth, _PaginationDots.paginationDotsTokens.verticalLineHeight)
22
+ }
23
+ }
24
+ };
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.PaginationDots = void 0;
7
+ var _PaginationDots = /*#__PURE__*/require("../../../../components/PaginationDots");
8
+ var _engines = /*#__PURE__*/require("../../../../engines");
9
+ var _PaginationDots2 = /*#__PURE__*/require("./PaginationDots.config");
10
+ var mergedConfig = /*#__PURE__*/(0, _engines.mergeConfig)(_PaginationDots.paginationDotsConfig, _PaginationDots2.config);
11
+ var PaginationDots = exports.PaginationDots = /*#__PURE__*/(0, _engines.component)(mergedConfig);
@@ -0,0 +1,68 @@
1
+ import * as React from 'react';
2
+ import type { ComponentProps } from 'react';
3
+ import type { StoryObj, Meta } from '@storybook/react';
4
+ import { disableProps, getConfigVariations } from '@salutejs/plasma-sb-utils';
5
+
6
+ import { WithTheme } from '../../../_helpers';
7
+
8
+ import { PaginationDots } from './PaginationDots';
9
+ import { config } from './PaginationDots.config';
10
+
11
+ const { views, sizes } = getConfigVariations(config);
12
+ const orientations: Array<string> = ['vertical', 'horizontal'];
13
+
14
+ const meta: Meta<typeof PaginationDots> = {
15
+ title: 'web/Data Entry/PaginationDots',
16
+ decorators: [WithTheme],
17
+ component: PaginationDots,
18
+ args: {
19
+ view: 'default',
20
+ size: 'm',
21
+ },
22
+ argTypes: {
23
+ view: {
24
+ options: views,
25
+ control: {
26
+ type: 'select',
27
+ },
28
+ },
29
+ size: {
30
+ options: sizes,
31
+ control: {
32
+ type: 'inner-radio',
33
+ },
34
+ },
35
+ orientation: {
36
+ options: orientations,
37
+ control: {
38
+ type: 'inline-radio',
39
+ },
40
+ },
41
+ activeDotCentered: {
42
+ control: {
43
+ type: 'boolean',
44
+ },
45
+ },
46
+ ...disableProps(['value', 'focused', 'pin']),
47
+ },
48
+ };
49
+
50
+ export default meta;
51
+
52
+ type StoryPropsDefault = ComponentProps<typeof PaginationDots> & {
53
+ enableContentLeft: boolean;
54
+ enableContentRight: boolean;
55
+ };
56
+
57
+ const StoryDefault = ({ size, ...rest }: StoryPropsDefault) => {
58
+ return <PaginationDots size={size} value={0} count={9} {...rest} />;
59
+ };
60
+
61
+ export const Default: StoryObj<StoryPropsDefault> = {
62
+ args: {
63
+ orientation: 'horizontal',
64
+ stretched: true,
65
+ currentDot: 'first',
66
+ },
67
+ render: (args) => <StoryDefault {...args} />,
68
+ };
@@ -0,0 +1,311 @@
1
+ var _excluded = ["view", "size", "activeElementView", "orientation", "centered", "value", "count", "visibleCount", "onChange"];
2
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
+ function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
4
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
5
+ function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
6
+ function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
7
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
8
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
9
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
10
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
11
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
12
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
13
+ function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
14
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
15
+ import React, { forwardRef, useEffect, useLayoutEffect, useRef, useState } from 'react';
16
+ import cls from 'classnames';
17
+ import { useForkRef } from '@salutejs/plasma-core';
18
+ import { usePreviousValue } from "../../hooks";
19
+ import { base as viewCSS } from "../PaginationDots/variations/_view/base";
20
+ import { base as sizeCSS } from "../PaginationDots/variations/_size/base";
21
+ import { AnimatedDotsWrapper, base, Dot, Line, Wrapper } from "./PaginationDots.styles";
22
+ import { classes } from "./PaginationDots.tokens";
23
+ import { getDotSize } from "./utils/getDotSize";
24
+ import { useAnimation } from "./hooks/useAnimation";
25
+ var sizesMap = {
26
+ xs: 18,
27
+ s: 20,
28
+ m: 24
29
+ };
30
+ var getInitialOffset = function getInitialOffset(value, visibleCount, count) {
31
+ var middle = Math.floor(visibleCount / 2);
32
+ if (value < middle) {
33
+ return 0;
34
+ }
35
+ if (count - value <= middle) {
36
+ return count - visibleCount;
37
+ }
38
+ return value - middle;
39
+ };
40
+ export var getVisualOffsets = function getVisualOffsets(dots, innerViewValue) {
41
+ var before = dots.slice(0, innerViewValue).reduce(function (acc, size) {
42
+ return acc + sizesMap[size];
43
+ }, 0);
44
+ var after = dots.slice(innerViewValue + 1).reduce(function (acc, size) {
45
+ return acc + sizesMap[size];
46
+ }, 0);
47
+ return (after - before) / 2;
48
+ };
49
+ var getFirstAnimatedDotsOffset = function getFirstAnimatedDotsOffset(dots, prevDots) {
50
+ var sizeBefore = sizesMap[prevDots[0]];
51
+ var sizeAfter = sizesMap[dots[0]];
52
+ return sizeBefore - sizeAfter;
53
+ };
54
+ var getLastAnimatedDotsOffset = function getLastAnimatedDotsOffset(dots, prevDots) {
55
+ var sizeBefore = sizesMap[prevDots[prevDots.length - 1]];
56
+ var sizeAfter = sizesMap[dots[dots.length - 1]];
57
+ return sizeBefore - sizeAfter;
58
+ };
59
+
60
+ /*
61
+ (m) m m s xs value: 0, offset: 0
62
+ m (m) m s xs value: 1, offset: 0
63
+ m m (m) s xs value: 2, offset: 0
64
+ s m (m) s xs value: 3, offset: 1
65
+ xs s (m) s xs value: 4, offset: 2
66
+
67
+ */
68
+
69
+ var isDebug = false;
70
+ export var paginationDotsRoot = function paginationDotsRoot(Root) {
71
+ return /*#__PURE__*/forwardRef(function (_ref, outerRef) {
72
+ var view = _ref.view,
73
+ size = _ref.size,
74
+ _ref$activeElementVie = _ref.activeElementView,
75
+ activeElementView = _ref$activeElementVie === void 0 ? 'dot' : _ref$activeElementVie,
76
+ _ref$orientation = _ref.orientation,
77
+ orientation = _ref$orientation === void 0 ? 'horizontal' : _ref$orientation,
78
+ _ref$centered = _ref.centered,
79
+ centered = _ref$centered === void 0 ? false : _ref$centered,
80
+ _ref$value = _ref.value,
81
+ value = _ref$value === void 0 ? 0 : _ref$value,
82
+ _ref$count = _ref.count,
83
+ count = _ref$count === void 0 ? 0 : _ref$count,
84
+ visibleCount = _ref.visibleCount,
85
+ onChange = _ref.onChange,
86
+ rest = _objectWithoutProperties(_ref, _excluded);
87
+ var innerRef = useRef(null);
88
+ var wrapperRef = useRef(null);
89
+ var activeElementRef = useRef(null);
90
+ var animatedDotsWrapperRef = useRef(null);
91
+ useForkRef(outerRef, innerRef);
92
+ var innerValue = Math.min(value, count - 1);
93
+ var innerVisibleCount = Math.min(visibleCount || count, count);
94
+ var isLineView = activeElementView === 'line';
95
+ var isVertical = orientation === 'vertical';
96
+ var hasScroll = innerVisibleCount < count;
97
+ var _useState = useState(innerValue),
98
+ _useState2 = _slicedToArray(_useState, 2),
99
+ currentValue = _useState2[0],
100
+ setCurrentValue = _useState2[1];
101
+ var _useState3 = useState(),
102
+ _useState4 = _slicedToArray(_useState3, 2),
103
+ prevValue = _useState4[0],
104
+ setPrevValue = _useState4[1];
105
+ var _useState5 = useState(function () {
106
+ return getInitialOffset(innerValue, innerVisibleCount, count);
107
+ }),
108
+ _useState6 = _slicedToArray(_useState5, 2),
109
+ offset = _useState6[0],
110
+ setOffset = _useState6[1];
111
+ var prevOffset = usePreviousValue(offset);
112
+ var prevDotsRef = useRef([]);
113
+ var dots = new Array(innerVisibleCount).fill(null).map(function (_, index) {
114
+ return getDotSize(size, index + offset, offset, count, innerVisibleCount);
115
+ });
116
+ var setVisualOffset = function setVisualOffset(currentValueNew, newOffset) {
117
+ var innerViewValue = currentValueNew - newOffset;
118
+
119
+ // canScrollBackward || canScrollForward
120
+ var withAnimation = centered ? true : newOffset !== offset;
121
+ if (!animatedDotsWrapperRef.current || !withAnimation) {
122
+ if (wrapperRef.current) {
123
+ wrapperRef.current.style.transform = 'none';
124
+ }
125
+ return;
126
+ }
127
+ var visualOffset = getVisualOffsets(dots, innerViewValue);
128
+ if (wrapperRef.current) {
129
+ wrapperRef.current.style.transform = isVertical ? "translateY(".concat(visualOffset, "px)") : "translateX(".concat(visualOffset, "px)");
130
+ }
131
+ };
132
+ if (isDebug) {
133
+ console.log('!!!', JSON.stringify({
134
+ prevValue: prevValue,
135
+ prevOffset: prevOffset,
136
+ value: innerValue,
137
+ offset: offset
138
+ }));
139
+ }
140
+ var canScrollForward = prevValue !== undefined ? !!offset && count - innerVisibleCount > prevOffset : false;
141
+ var canScrollBackward = Boolean(prevOffset && offset + innerVisibleCount !== count);
142
+ var _useAnimation = useAnimation({
143
+ innerViewIndex: currentValue - offset,
144
+ dots: dots,
145
+ prevDots: prevDotsRef.current,
146
+ canScrollBackward: canScrollBackward,
147
+ canScrollForward: canScrollForward,
148
+ isVertical: isVertical,
149
+ activeElementRef: activeElementRef,
150
+ animatedDotsWrapperRef: animatedDotsWrapperRef,
151
+ onAnimationEnd: function onAnimationEnd() {
152
+ console.log('!!! onAnimationEnd');
153
+ var newOffset = getInitialOffset(innerValue, innerVisibleCount, count);
154
+ setOffset(newOffset);
155
+ setPrevValue(undefined);
156
+ setSkipAnimation(true);
157
+ }
158
+ }),
159
+ skipAnimation = _useAnimation.skipAnimation,
160
+ hasAnimation = _useAnimation.hasAnimation,
161
+ hasForwardAnimation = _useAnimation.hasForwardAnimation,
162
+ hasBackwardAnimation = _useAnimation.hasBackwardAnimation,
163
+ setSkipAnimation = _useAnimation.setSkipAnimation,
164
+ setHasForwardAnimation = _useAnimation.setHasForwardAnimation,
165
+ setHasBackwardAnimation = _useAnimation.setHasBackwardAnimation,
166
+ handleAnimationEnd = _useAnimation.handleAnimationEnd;
167
+ var hasAnimatedDot = hasAnimation && innerVisibleCount > 2 && (hasBackwardAnimation && canScrollBackward || hasForwardAnimation && canScrollForward);
168
+ var calcOffset = function calcOffset(currentValue, prevValue) {
169
+ if (prevValue === undefined || centered && !hasScroll) {
170
+ return;
171
+ }
172
+ var toFront = currentValue > prevValue;
173
+ var toBack = currentValue < prevValue;
174
+ var newOffset = getInitialOffset(currentValue, innerVisibleCount, count);
175
+ var withAnimation = centered ? true : newOffset !== offset;
176
+ if (toFront) {
177
+ if (withAnimation) {
178
+ setHasForwardAnimation(true);
179
+ prevDotsRef.current = _toConsumableArray(dots);
180
+ setOffset(newOffset);
181
+ } else {
182
+ setOffset(newOffset);
183
+ }
184
+ } else if (toBack) {
185
+ if (withAnimation) {
186
+ setHasBackwardAnimation(true);
187
+ prevDotsRef.current = _toConsumableArray(dots);
188
+ setOffset(newOffset);
189
+ } else {
190
+ setOffset(newOffset);
191
+ }
192
+ }
193
+ };
194
+ useLayoutEffect(function () {
195
+ setVisualOffset(innerValue, offset);
196
+ }, [isVertical, centered]);
197
+ useLayoutEffect(function () {
198
+ if (prevValue === undefined) {
199
+ setVisualOffset(innerValue, offset);
200
+ if (animatedDotsWrapperRef.current) {
201
+ animatedDotsWrapperRef.current.style.transition = 'none';
202
+ animatedDotsWrapperRef.current.style.transform = 'none';
203
+ }
204
+ }
205
+ }, [innerValue, offset, prevValue]);
206
+ useLayoutEffect(function () {
207
+ setSkipAnimation(true);
208
+ setPrevValue(undefined);
209
+ }, [count, innerVisibleCount, isVertical, isLineView, hasScroll]);
210
+ useEffect(function () {
211
+ // setSkipAnimation(true);
212
+ // setPrevValue(undefined);
213
+ }, []);
214
+ var onMove = function onMove(newValue) {
215
+ setSkipAnimation(false);
216
+ calcOffset(newValue, currentValue);
217
+ setCurrentValue(newValue);
218
+ setPrevValue(currentValue);
219
+ onChange === null || onChange === void 0 || onChange(newValue);
220
+ };
221
+ if (!innerVisibleCount || innerVisibleCount <= 0) {
222
+ return null;
223
+ }
224
+ var dotsNodes = dots.map(function (dotSize, viewIndex) {
225
+ var dotIndex = viewIndex + offset;
226
+ var isCurrent = dotIndex === currentValue;
227
+ var isClickable = dotIndex === currentValue - 1 || dotIndex === currentValue + 1;
228
+ var onClick = isClickable && !hasAnimation ? function () {
229
+ return onMove(dotIndex);
230
+ } : undefined;
231
+ if (isCurrent) {
232
+ var ActiveElement = activeElementView === 'dot' ? Dot : Line;
233
+ return /*#__PURE__*/React.createElement(ActiveElement, {
234
+ key: viewIndex,
235
+ ref: activeElementRef,
236
+ "data-size": size,
237
+ "data-view": activeElementView,
238
+ className: cls(classes.active, isVertical && classes.vertical, skipAnimation && classes.skipAnimation)
239
+ }, isDebug ? dotIndex : null);
240
+ }
241
+ var isPrevActive = prevValue === dotIndex;
242
+ var innerViewValue = dotIndex - offset;
243
+ var isFirst = innerViewValue === 0;
244
+ var isLast = innerViewValue === innerVisibleCount - 1;
245
+ return /*#__PURE__*/React.createElement(Dot, {
246
+ key: viewIndex,
247
+ className: cls(isVertical && classes.vertical, isClickable && classes.clickable, isPrevActive && classes.prevActive, skipAnimation && classes.skipAnimation),
248
+ style: {
249
+ visibility: isLast && hasForwardAnimation && canScrollForward || isFirst && hasBackwardAnimation && canScrollBackward ? 'hidden' : 'visible'
250
+ },
251
+ "data-size": dotSize,
252
+ "data-view": activeElementView,
253
+ onClick: onClick
254
+ }, isDebug ? dotIndex : null);
255
+ });
256
+ return /*#__PURE__*/React.createElement(Root, _extends({
257
+ size: size,
258
+ view: view,
259
+ className: cls(centered && classes.centered, isVertical && classes.vertical),
260
+ ref: innerRef
261
+ }, rest), /*#__PURE__*/React.createElement(Wrapper, {
262
+ ref: wrapperRef,
263
+ "data-size": size
264
+ }, hasAnimatedDot && /*#__PURE__*/React.createElement(Dot, {
265
+ className: cls(isVertical && classes.vertical, {
266
+ hidden: hasForwardAnimation,
267
+ showed: hasBackwardAnimation
268
+ }),
269
+ "data-view": activeElementView,
270
+ "data-size": dots[0],
271
+ style: isVertical ? {
272
+ top: "".concat(getFirstAnimatedDotsOffset(dots, prevDotsRef.current), "px")
273
+ } : {
274
+ left: "".concat(getFirstAnimatedDotsOffset(dots, prevDotsRef.current), "px")
275
+ }
276
+ }, isDebug ? offset + (hasForwardAnimation ? -1 : 0) : null), /*#__PURE__*/React.createElement(AnimatedDotsWrapper, {
277
+ ref: animatedDotsWrapperRef,
278
+ onTransitionEnd: handleAnimationEnd
279
+ }, dotsNodes), hasAnimatedDot && /*#__PURE__*/React.createElement(Dot, {
280
+ className: cls(isVertical && classes.vertical, {
281
+ hidden: hasBackwardAnimation,
282
+ showed: hasForwardAnimation
283
+ }),
284
+ "data-view": activeElementView,
285
+ "data-size": dots[dots.length - 1],
286
+ style: isVertical ? {
287
+ bottom: "".concat(getLastAnimatedDotsOffset(dots, prevDotsRef.current), "px")
288
+ } : {
289
+ right: "".concat(getLastAnimatedDotsOffset(dots, prevDotsRef.current), "px")
290
+ }
291
+ }, isDebug ? offset + innerVisibleCount + (hasForwardAnimation ? -1 : 0) : null)));
292
+ });
293
+ };
294
+ export var paginationDotsConfig = {
295
+ name: 'PaginationDots',
296
+ tag: 'div',
297
+ layout: paginationDotsRoot,
298
+ base: base,
299
+ variations: {
300
+ view: {
301
+ css: viewCSS
302
+ },
303
+ size: {
304
+ css: sizeCSS
305
+ }
306
+ },
307
+ defaults: {
308
+ view: 'default',
309
+ size: 'm'
310
+ }
311
+ };
@@ -0,0 +1,18 @@
1
+ var _templateObject;
2
+ function _taggedTemplateLiteral(e, t) { return t || (t = e.slice(0)), Object.freeze(Object.defineProperties(e, { raw: { value: Object.freeze(t) } })); }
3
+ import { css } from 'styled-components';
4
+ import styled from 'styled-components';
5
+ import { classes, tokens } from "./PaginationDots.tokens";
6
+ export var Wrapper = /*#__PURE__*/styled.div.withConfig({
7
+ componentId: "plasma-new-hope__sc-b6xerq-0"
8
+ })(["position:relative;display:flex;align-items:center;justify-content:center;"]);
9
+ export var AnimatedDotsWrapper = /*#__PURE__*/styled.div.withConfig({
10
+ componentId: "plasma-new-hope__sc-b6xerq-1"
11
+ })(["display:flex;align-items:center;justify-content:center;"]);
12
+ export var Dot = /*#__PURE__*/styled.div.withConfig({
13
+ componentId: "plasma-new-hope__sc-b6xerq-2"
14
+ })(["box-sizing:border-box;padding:var(", ");&:before{content:'';display:block;border-radius:var(", ");background-color:var(", ");transition:width 0.3s linear,height 0.3s linear;}&.", "{&:before{background-color:var(", ");}}&[data-size='xs']{&:before{--plasma-private-dot-size:var(", ");width:var(", ");height:var(", ");}}&[data-size='s']{&:before{--plasma-private-dot-size:var(", ");width:var(", ");height:var(", ");}}&[data-size='m']{&:before{--plasma-private-dot-size:var(", ");width:var(", ");height:var(", ");}}&.", "{cursor:pointer;}@keyframes showAnimation{from{transform:scale(0);opacity:0;}to{transform:scale(1);opacity:1;}}@keyframes showWithColor{from{background-color:var(", ");}to{background-color:var(", ");}}@keyframes hideWithColor{from{background-color:var(", ");}to{background-color:var(", ");}}@keyframes hideAnimation{from{transform:scale(1);opacity:1;}to{transform:scale(0);opacity:0;}}@keyframes reversedWidthAnimation{from{width:var(", ");height:var(", ");border-radius:var(", ");background-color:var(", ");}to{width:var(--plasma-private-dot-size);height:var(--plasma-private-dot-size);border-radius:var(", ");background-color:var(", ");}}@keyframes reversedHeightAnimation{from{width:var(", ");height:var(", ");border-radius:var(", ");}to{width:var(--plasma-private-dot-size);height:var(--plasma-private-dot-size);border-radius:var(", ");}}&.", "{&[data-view='line']{&:before{animation-name:reversedWidthAnimation;animation-duration:0.3s;animation-iteration-count:1;animation-play-state:running;animation-timing-function:linear;}&.", "{&:before{animation-name:reversedHeightAnimation;}}}&[data-view='dot']{&:before{animation-name:hideWithColor;animation-duration:0.3s;animation-iteration-count:1;animation-play-state:running;animation-timing-function:linear;animation-timing-function:ease-out;}}}&.hidden{position:absolute;animation-name:hideAnimation;animation-duration:calc(0.3s + 0.1s);animation-iteration-count:1;animation-play-state:running;animation-timing-function:linear;}&.showed{position:absolute;animation-name:showAnimation;animation-duration:0.3s;animation-iteration-count:1;animation-play-state:running;animation-timing-function:linear;}&.", "{&[data-view='dot']{&:before{animation-name:showWithColor;animation-duration:0.3s;animation-iteration-count:1;animation-play-state:running;animation-timing-function:linear;animation-timing-function:ease-in;}}}&.", "{transition:none;animation-name:none !important;&:before{transition:none;animation-name:none !important;}}"], tokens.dotPadding, tokens.dotBorderRadius, tokens.itemBackground, classes.active, tokens.activeItemBackground, tokens.dotSizeXS, tokens.dotSizeXS, tokens.dotSizeXS, tokens.dotSizeS, tokens.dotSizeS, tokens.dotSizeS, tokens.dotSizeM, tokens.dotSizeM, tokens.dotSizeM, classes.clickable, tokens.itemBackground, tokens.activeItemBackground, tokens.activeItemBackground, tokens.itemBackground, tokens.lineWidth, tokens.lineHeight, tokens.lineBorderRadius, tokens.activeItemBackground, tokens.lineBorderRadius, tokens.itemBackground, tokens.verticalLineWidth, tokens.verticalLineHeight, tokens.lineBorderRadius, tokens.lineBorderRadius, classes.prevActive, classes.vertical, classes.active, classes.skipAnimation);
15
+ export var Line = /*#__PURE__*/styled(Dot).withConfig({
16
+ componentId: "plasma-new-hope__sc-b6xerq-3"
17
+ })(["@keyframes widthAnimation{from{width:var(", ");height:var(", ");background-color:var(", ");}to{width:var(", ");height:var(", ");background-color:var(", ");}}@keyframes heightAnimation{from{width:var(", ");height:var(", ");background-color:var(", ");}to{width:var(", ");height:var(", ");background-color:var(", ");}}&[data-size='s']{&:before{width:var(", ");height:var(", ");border-radius:var(", ");}}&[data-size='m']{&:before{width:var(", ");height:var(", ");border-radius:var(", ");}}&.", "{&[data-size='s']{&:before{width:var(", ");height:var(", ");}}&[data-size='m']{&:before{width:var(", ");height:var(", ");}}}&.", "{&:before{animation-name:widthAnimation;animation-duration:0.3s;animation-iteration-count:1;animation-play-state:running;animation-timing-function:linear;}&.", "{&:before{animation-name:heightAnimation;}}}&.", "{animation-name:none !important;&:before{animation-name:none !important;}}"], tokens.lineHeight, tokens.lineHeight, tokens.itemBackground, tokens.lineWidth, tokens.lineHeight, tokens.activeItemBackground, tokens.lineHeight, tokens.lineHeight, tokens.itemBackground, tokens.verticalLineWidth, tokens.verticalLineHeight, tokens.activeItemBackground, tokens.lineWidth, tokens.lineHeight, tokens.lineBorderRadius, tokens.lineWidth, tokens.lineHeight, tokens.lineBorderRadius, classes.vertical, tokens.verticalLineWidth, tokens.verticalLineHeight, tokens.verticalLineWidth, tokens.verticalLineHeight, classes.active, classes.vertical, classes.skipAnimation);
18
+ export var base = /*#__PURE__*/css(_templateObject || (_templateObject = /*#__PURE__*/_taggedTemplateLiteral(["\n display: flex;\n align-items: center;\n justify-content: flex-start;\n\n &.", " {\n width: 100%;\n justify-content: center;\n }\n\n &.", " {\n display: inline-flex;\n flex-direction: column;\n align-items: center;\n\n ", " {\n padding: var(", ");\n }\n\n ", " {\n flex-direction: column;\n }\n\n &.", " {\n width: auto;\n height: 100%;\n\n position: relative;\n }\n }\n"])), classes.centered, classes.vertical, Dot, tokens.verticalDotPadding, AnimatedDotsWrapper, classes.centered);