@salutejs/plasma-new-hope 0.322.0-canary.1944.14660891986.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,95 @@
1
+ ---
2
+ id: segment
3
+ title: Segment
4
+ ---
5
+
6
+ import { PropsTable, Description } from '@site/src/components';
7
+
8
+ # PaginationDots
9
+ Элементы переключения. Oтображают возможность перемещения между небольшим количеством однородных элементов контента.
10
+
11
+ ## PaginationDots
12
+
13
+ <Description name="PaginationDots" />
14
+ <PropsTable name="PaginationDots" exclude={['css']} />
15
+
16
+ ```tsx live
17
+ import React from 'react';
18
+ import { SegmentGroup, SegmentItem, SegmentProvider, useSegment } from '@salutejs/{{ package }}';
19
+
20
+ export function App() {
21
+ const items = Array(8).fill(0);
22
+
23
+ const SegmentTemplate = () => {
24
+ const {selectedSegmentItems} = useSegment();
25
+
26
+ return (
27
+ <>
28
+ <div>Выбранный элемент: {selectedSegmentItems.join(', ')}</div>
29
+ <br />
30
+ <SegmentGroup hasBackground pilled clip={false}>
31
+ {items.map((_, i) => (
32
+ <SegmentItem
33
+ label={`Label ${i}`}
34
+ value={`label_${i}`}
35
+ key={`label_${i}`}
36
+ view='default'
37
+ pilled
38
+ />
39
+ ))}
40
+ </SegmentGroup>
41
+ </>
42
+ )
43
+ }
44
+
45
+ return (
46
+ <div style={{ display: "block" }} >
47
+ <SegmentProvider defaultSelected={['label_1']}>
48
+ <SegmentTemplate/>
49
+ </SegmentProvider>
50
+ </div>
51
+ );
52
+ }
53
+ ```
54
+
55
+ ### Вертикальное отображение
56
+
57
+ Для смены ориентации передаем `orientation: 'vertical'`
58
+
59
+ ```tsx live
60
+ import React from 'react';
61
+ import { SegmentGroup, SegmentItem, SegmentProvider, useSegment } from '@salutejs/{{ package }}';
62
+
63
+ export function App() {
64
+ const items = Array(8).fill(0);
65
+
66
+ const SegmentTemplate = () => {
67
+ const {selectedSegmentItems} = useSegment();
68
+
69
+ return (
70
+ <>
71
+ <div>Выбранный элемент: {selectedSegmentItems.join(', ')}</div>
72
+ <br />
73
+ <SegmentGroup hasBackground clip={false}>
74
+ {items.map((_, i) => (
75
+ <SegmentItem
76
+ label={`Label ${i}`}
77
+ value={`label_${i}`}
78
+ key={`label_${i}`}
79
+ view='secondary'
80
+ />
81
+ ))}
82
+ </SegmentGroup>
83
+ </>
84
+ )
85
+ }
86
+
87
+ return (
88
+ <div style={{ display: "block" }} >
89
+ <SegmentProvider defaultSelected={['label_1']}>
90
+ <SegmentTemplate/>
91
+ </SegmentProvider>
92
+ </div>
93
+ );
94
+ }
95
+ ```
@@ -0,0 +1,24 @@
1
+ export var classes = {
2
+ active: 'active',
3
+ prevActive: 'prevActive',
4
+ centered: 'centered',
5
+ vertical: 'vertical',
6
+ clickable: 'clickable',
7
+ skipAnimation: 'skipAnimation'
8
+ };
9
+ export var tokens = {
10
+ paginationWidth: '--plasma-pagination-width',
11
+ dotPadding: '--plasma-pagination-dots-dot-padding',
12
+ verticalDotPadding: '--plasma-pagination-dots-vertical-dot-padding',
13
+ dotSizeM: '--plasma-pagination-dots-dot-size-m',
14
+ dotSizeS: '--plasma-pagination-dots-dot-size-s',
15
+ dotSizeXS: '--plasma-pagination-dots-dot-size-xs',
16
+ dotBorderRadius: '--plasma-pagination-dots-dot-border-radius',
17
+ lineWidth: '--plasma-pagination-dots-line-width',
18
+ lineHeight: '--plasma-pagination-dots-line-height',
19
+ lineBorderRadius: '--plasma-pagination-dots-line-border-radius',
20
+ verticalLineWidth: '--plasma-pagination-dots-vertical-line-width',
21
+ verticalLineHeight: '--plasma-pagination-dots-vertical-line-height',
22
+ itemBackground: '--plasma-pagination-dots-item-background',
23
+ activeItemBackground: '--plasma-pagination-dots-active-item-background'
24
+ };
@@ -0,0 +1,102 @@
1
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
2
+ 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."); }
3
+ 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; } }
4
+ 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; }
5
+ 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; } }
6
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
7
+ import { useLayoutEffect, useRef, useState } from 'react';
8
+ import { getVisualOffsets } from "../PaginationDots";
9
+ export var useAnimation = function useAnimation(_ref) {
10
+ var isVertical = _ref.isVertical,
11
+ onAnimationEnd = _ref.onAnimationEnd,
12
+ activeElementRef = _ref.activeElementRef,
13
+ animatedDotsWrapperRef = _ref.animatedDotsWrapperRef,
14
+ canScrollForward = _ref.canScrollForward,
15
+ canScrollBackward = _ref.canScrollBackward,
16
+ dots = _ref.dots,
17
+ prevDots = _ref.prevDots,
18
+ innerViewIndex = _ref.innerViewIndex;
19
+ var isAnimationRunningRef = useRef(false);
20
+ var _useState = useState(true),
21
+ _useState2 = _slicedToArray(_useState, 2),
22
+ skipAnimation = _useState2[0],
23
+ setSkipAnimation = _useState2[1];
24
+ var _useState3 = useState(false),
25
+ _useState4 = _slicedToArray(_useState3, 2),
26
+ hasForwardAnimation = _useState4[0],
27
+ setHasForwardAnimation = _useState4[1];
28
+ var _useState5 = useState(false),
29
+ _useState6 = _slicedToArray(_useState5, 2),
30
+ hasBackwardAnimation = _useState6[0],
31
+ setHasBackwardAnimation = _useState6[1];
32
+ var hasAnimation = hasForwardAnimation || hasBackwardAnimation;
33
+ var handleAnimationEnd = function handleAnimationEnd() {
34
+ if (isAnimationRunningRef.current) {
35
+ isAnimationRunningRef.current = false;
36
+ onAnimationEnd();
37
+ }
38
+ setHasForwardAnimation(false);
39
+ setHasBackwardAnimation(false);
40
+ };
41
+ useLayoutEffect(function () {
42
+ var _activeElementRef$cur, _activeElementRef$cur2;
43
+ var animatedEl = animatedDotsWrapperRef.current;
44
+ if (!animatedEl || !hasForwardAnimation && !hasBackwardAnimation) {
45
+ return;
46
+ }
47
+ var before = getVisualOffsets(prevDots, innerViewIndex);
48
+ var after = getVisualOffsets(dots, innerViewIndex);
49
+ var diff = before - after;
50
+ var _ref2 = activeElementRef.current,
51
+ activeWidth = _ref2.offsetWidth,
52
+ activeHeight = _ref2.offsetHeight;
53
+ var _ref3 = (hasBackwardAnimation ? (_activeElementRef$cur = activeElementRef.current) === null || _activeElementRef$cur === void 0 ? void 0 : _activeElementRef$cur.previousSibling : (_activeElementRef$cur2 = activeElementRef.current) === null || _activeElementRef$cur2 === void 0 ? void 0 : _activeElementRef$cur2.nextSibling) || {},
54
+ width = _ref3.offsetWidth,
55
+ height = _ref3.offsetHeight;
56
+ animatedEl.style.transition = 'none';
57
+ if (hasForwardAnimation) {
58
+ if (canScrollForward) {
59
+ animatedEl.style.transform = isVertical ? "translateY(".concat(height, "px)") : "translateX(".concat(width, "px)");
60
+ } else {
61
+ animatedEl.style.transform = isVertical ? "translateY(".concat(height - activeHeight, "px)") : "translateX(".concat(width - activeWidth, "px)");
62
+ }
63
+ requestAnimationFrame(function () {
64
+ animatedEl.style.transition = 'transform 0.3s linear';
65
+ if (canScrollForward) {
66
+ animatedEl.style.transform = isVertical ? "translateY(".concat(-diff, "px)") : "translateX(".concat(-diff, "px)");
67
+ } else {
68
+ animatedEl.style.transform = isVertical ? "translateY(-".concat(activeHeight, "px)") : "translateX(-".concat(activeWidth, "px)");
69
+ }
70
+ isAnimationRunningRef.current = true;
71
+ });
72
+ }
73
+ if (hasBackwardAnimation) {
74
+ if (canScrollBackward) {
75
+ animatedEl.style.transform = isVertical ? "translateY(".concat(-height, "px)") : "translateX(".concat(-width, "px)");
76
+ } else {
77
+ animatedEl.style.transform = isVertical ? "translateY(".concat(-height + activeHeight, "px)") : "translateX(".concat(-width + activeWidth, "px)");
78
+ }
79
+ requestAnimationFrame(function () {
80
+ if (animatedEl) {
81
+ animatedEl.style.transition = 'transform 0.3s linear';
82
+ if (canScrollBackward) {
83
+ animatedEl.style.transform = isVertical ? "translateY(".concat(-diff, "px)") : "translateX(".concat(-diff, "px)");
84
+ } else {
85
+ animatedEl.style.transform = isVertical ? "translateY(".concat(activeHeight, "px)") : "translateX(".concat(activeWidth, "px)");
86
+ }
87
+ isAnimationRunningRef.current = true;
88
+ }
89
+ });
90
+ }
91
+ }, [isVertical, innerViewIndex, hasForwardAnimation, hasBackwardAnimation]);
92
+ return {
93
+ skipAnimation: skipAnimation,
94
+ hasAnimation: hasAnimation,
95
+ hasBackwardAnimation: hasBackwardAnimation,
96
+ hasForwardAnimation: hasForwardAnimation,
97
+ setSkipAnimation: setSkipAnimation,
98
+ setHasForwardAnimation: setHasForwardAnimation,
99
+ setHasBackwardAnimation: setHasBackwardAnimation,
100
+ handleAnimationEnd: handleAnimationEnd
101
+ };
102
+ };
@@ -0,0 +1,2 @@
1
+ export { paginationDotsRoot, paginationDotsConfig } from "./PaginationDots";
2
+ export { tokens as paginationDotsTokens, classes as paginationDotsClasses } from "./PaginationDots.tokens";
@@ -0,0 +1,40 @@
1
+ export var getDotSize = function getDotSize(size, index, offset, count, visibleCount) {
2
+ var innerViewValue = index - offset;
3
+ var toEnd = count - (visibleCount + offset);
4
+ var canScrollBackward = Boolean(offset);
5
+ var canScrollForward = Boolean(toEnd);
6
+ var isFirst = innerViewValue === 0;
7
+ var isSecond = innerViewValue === 1;
8
+ var isSecondLast = innerViewValue === visibleCount - 2;
9
+ var isLast = innerViewValue === visibleCount - 1;
10
+ if (size === 's') {
11
+ if (isFirst && canScrollBackward || isLast && canScrollForward) {
12
+ return 'xs';
13
+ }
14
+ return 's';
15
+ }
16
+ if (canScrollBackward) {
17
+ // (m) m m s xs
18
+ // m (m) m s xs
19
+ // m m (m) s xs
20
+ // s m (m) s xs
21
+ // xs s m (m) s
22
+ // xs s m (m) s
23
+ // xs s m m (m)
24
+ if (isFirst) {
25
+ return offset === 1 ? 's' : 'xs';
26
+ }
27
+ if (isSecond && offset > 1) {
28
+ return 's';
29
+ }
30
+ }
31
+ if (canScrollForward) {
32
+ if (isLast) {
33
+ return toEnd === 1 ? 's' : 'xs';
34
+ }
35
+ if (isSecondLast && toEnd > 1) {
36
+ return 's';
37
+ }
38
+ }
39
+ return 'm';
40
+ };
@@ -0,0 +1,2 @@
1
+ import { css } from 'styled-components';
2
+ export var base = /*#__PURE__*/css([""]);
@@ -0,0 +1,2 @@
1
+ import { css } from 'styled-components';
2
+ export var base = /*#__PURE__*/css([""]);
@@ -0,0 +1,17 @@
1
+ import { css } from 'styled-components';
2
+ import { paginationDotsTokens as tokens } from "../../../../components/PaginationDots";
3
+ export var config = {
4
+ defaults: {
5
+ view: 'default',
6
+ size: 'm'
7
+ },
8
+ variations: {
9
+ view: {
10
+ "default": /*#__PURE__*/css(["", ":#0808081f;", ":#080808;"], tokens.itemBackground, tokens.activeItemBackground)
11
+ },
12
+ size: {
13
+ s: /*#__PURE__*/css(["", ":0 0.375rem;", ":0.375rem 0;", ":0.75rem;", ":0.5rem;", ":0.375rem;", ":50%;", ":2rem;", ":0.5rem;", ":0.375rem;", ":0.5rem;", ":2rem;"], tokens.dotPadding, tokens.verticalDotPadding, tokens.dotSizeM, tokens.dotSizeS, tokens.dotSizeXS, tokens.dotBorderRadius, tokens.lineWidth, tokens.lineHeight, tokens.lineBorderRadius, tokens.verticalLineWidth, tokens.verticalLineHeight),
14
+ m: /*#__PURE__*/css(["", ":0 0.375rem;", ":0.375rem 0;", ":50%;", ":0.75rem;", ":0.5rem;", ":0.375rem;", ":3rem;", ":0.75rem;", ":0.375rem;", ":0.75rem;", ":3rem;"], tokens.dotPadding, tokens.verticalDotPadding, tokens.dotBorderRadius, tokens.dotSizeM, tokens.dotSizeS, tokens.dotSizeXS, tokens.lineWidth, tokens.lineHeight, tokens.lineBorderRadius, tokens.verticalLineWidth, tokens.verticalLineHeight)
15
+ }
16
+ }
17
+ };
@@ -0,0 +1,5 @@
1
+ import { paginationDotsConfig } from "../../../../components/PaginationDots";
2
+ import { component, mergeConfig } from "../../../../engines";
3
+ import { config } from "./PaginationDots.config";
4
+ var mergedConfig = /*#__PURE__*/mergeConfig(paginationDotsConfig, config);
5
+ export var PaginationDots = /*#__PURE__*/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,18 @@
1
+ import { css } from 'styled-components';
2
+ import { paginationDotsTokens as tokens } from "../../../../components/PaginationDots";
3
+ export var config = {
4
+ defaults: {
5
+ view: 'default',
6
+ focused: 'true',
7
+ size: 'm'
8
+ },
9
+ variations: {
10
+ view: {
11
+ "default": /*#__PURE__*/css(["", ":'#0808081f',", ":'#080808',"], tokens.itemBackground, tokens.activeItemBackground)
12
+ },
13
+ size: {
14
+ s: /*#__PURE__*/css(["", ":'0 0.375rem',", ":'0.375rem 0',", ":'0.375rem',", ":'0.5rem',", ":'0.75rem',", ":'50%',", ":'2rem',", ":'0.5rem',", ":'0.375rem',", ":'0.5rem',", ":'2rem',"], tokens.dotPadding, tokens.verticalDotPadding, tokens.dotSizeM, tokens.dotSizeS, tokens.dotSizeXS, tokens.dotBorderRadius, tokens.lineWidth, tokens.lineHeight, tokens.lineBorderRadius, tokens.verticalLineWidth, tokens.verticalLineHeight),
15
+ m: /*#__PURE__*/css(["", ":'0 0.375rem',", ":'0.375rem 0',", ":'50%',", ":'0.375rem',", ":'0.5rem',", ":'0.75rem',", ":'3rem',", ":'0.75rem',", ":'0.375rem',", ":'0.75rem',", ":'3rem',"], tokens.dotPadding, tokens.verticalDotPadding, tokens.dotBorderRadius, tokens.dotSizeM, tokens.dotSizeS, tokens.dotSizeXS, tokens.lineWidth, tokens.lineHeight, tokens.lineBorderRadius, tokens.verticalLineWidth, tokens.verticalLineHeight)
16
+ }
17
+ }
18
+ };
@@ -0,0 +1,5 @@
1
+ import { paginationDotsConfig } from "../../../../components/PaginationDots";
2
+ import { component, mergeConfig } from "../../../../engines";
3
+ import { config } from "./PaginationDots.config";
4
+ var mergedConfig = /*#__PURE__*/mergeConfig(paginationDotsConfig, config);
5
+ export var PaginationDots = /*#__PURE__*/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,31 @@
1
+ import React from 'react';
2
+ import { RootProps } from '../../engines';
3
+ import { PaginationDotsProps } from './PaginationDots.types';
4
+ declare const sizesMap: {
5
+ readonly xs: 18;
6
+ readonly s: 20;
7
+ readonly m: 24;
8
+ };
9
+ export declare type DotSize = keyof typeof sizesMap;
10
+ export declare const getVisualOffsets: (dots: DotSize[], innerViewValue: number) => number;
11
+ export declare const paginationDotsRoot: (Root: RootProps<HTMLDivElement, PaginationDotsProps>) => React.ForwardRefExoticComponent<PaginationDotsProps & React.RefAttributes<HTMLDivElement>>;
12
+ export declare const paginationDotsConfig: {
13
+ name: string;
14
+ tag: string;
15
+ layout: (Root: RootProps<HTMLDivElement, PaginationDotsProps>) => React.ForwardRefExoticComponent<PaginationDotsProps & React.RefAttributes<HTMLDivElement>>;
16
+ base: import("@linaria/core").LinariaClassName;
17
+ variations: {
18
+ view: {
19
+ css: import("@linaria/core").LinariaClassName;
20
+ };
21
+ size: {
22
+ css: import("@linaria/core").LinariaClassName;
23
+ };
24
+ };
25
+ defaults: {
26
+ view: string;
27
+ size: string;
28
+ };
29
+ };
30
+ export {};
31
+ //# sourceMappingURL=PaginationDots.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PaginationDots.d.ts","sourceRoot":"","sources":["../../../src/components/PaginationDots/PaginationDots.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmE,MAAM,OAAO,CAAC;AAIxF,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAK1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAM7D,QAAA,MAAM,QAAQ;;;;CAIJ,CAAC;AAEX,oBAAY,OAAO,GAAG,MAAM,OAAO,QAAQ,CAAC;AAgB5C,eAAO,MAAM,gBAAgB,SAAU,OAAO,EAAE,kBAAkB,MAAM,WAKvE,CAAC;AA2BF,eAAO,MAAM,kBAAkB,SAAU,UAAU,cAAc,EAAE,mBAAmB,CAAC,+FA+RlF,CAAC;AAEN,eAAO,MAAM,oBAAoB;;;mBAjSQ,UAAU,cAAc,EAAE,mBAAmB,CAAC;;;;;;;;;;;;;;CAkTtF,CAAC"}
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ export declare const Wrapper: import("@linaria/react").StyledComponent<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & Record<never, unknown>>;
3
+ export declare const AnimatedDotsWrapper: import("@linaria/react").StyledComponent<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & Record<never, unknown>>;
4
+ export declare const Dot: import("@linaria/react").StyledComponent<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & Record<never, unknown>>;
5
+ export declare const Line: import("@linaria/react").StyledMeta & import("react").FunctionComponent<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & Record<never, unknown> & {
6
+ as?: import("react").ElementType<any> | undefined;
7
+ }>;
8
+ export declare const base: import("@linaria/core").LinariaClassName;
9
+ //# sourceMappingURL=PaginationDots.styles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PaginationDots.styles.d.ts","sourceRoot":"","sources":["../../../src/components/PaginationDots/PaginationDots.styles.ts"],"names":[],"mappings":";AAKA,eAAO,MAAM,OAAO,qKAKnB,CAAC;AAEF,eAAO,MAAM,mBAAmB,qKAI/B,CAAC;AAEF,eAAO,MAAM,GAAG,qKAuLf,CAAC;AAEF,eAAO,MAAM,IAAI;;EAkFhB,CAAC;AAEF,eAAO,MAAM,IAAI,0CA8BhB,CAAC"}
@@ -0,0 +1,25 @@
1
+ export declare const classes: {
2
+ active: string;
3
+ prevActive: string;
4
+ centered: string;
5
+ vertical: string;
6
+ clickable: string;
7
+ skipAnimation: string;
8
+ };
9
+ export declare const tokens: {
10
+ paginationWidth: string;
11
+ dotPadding: string;
12
+ verticalDotPadding: string;
13
+ dotSizeM: string;
14
+ dotSizeS: string;
15
+ dotSizeXS: string;
16
+ dotBorderRadius: string;
17
+ lineWidth: string;
18
+ lineHeight: string;
19
+ lineBorderRadius: string;
20
+ verticalLineWidth: string;
21
+ verticalLineHeight: string;
22
+ itemBackground: string;
23
+ activeItemBackground: string;
24
+ };
25
+ //# sourceMappingURL=PaginationDots.tokens.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PaginationDots.tokens.d.ts","sourceRoot":"","sources":["../../../src/components/PaginationDots/PaginationDots.tokens.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO;;;;;;;CAOnB,CAAC;AAEF,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;CAoBlB,CAAC"}
@@ -0,0 +1,46 @@
1
+ import type { HTMLAttributesWithoutOnChange } from '../../engines/types';
2
+ interface CustomPaginationDots {
3
+ /**
4
+ * Размер контрола.
5
+ */
6
+ size?: string;
7
+ /**
8
+ * Вид контрола.
9
+ * @default default
10
+ */
11
+ view?: string;
12
+ /**
13
+ * Отображение активного элемента
14
+ * @default 'dot'
15
+ */
16
+ activeElementView?: 'dot' | 'line';
17
+ /**
18
+ * Ориентация элементов
19
+ */
20
+ orientation?: 'horizontal' | 'vertical';
21
+ /**
22
+ * Центрирует элемент по горизонтали на всю ширину контейнера
23
+ * @default false
24
+ */
25
+ centered?: boolean;
26
+ /**
27
+ * Выбранная страница
28
+ */
29
+ value?: number;
30
+ /**
31
+ * Количество страниц
32
+ */
33
+ count?: number;
34
+ /**
35
+ * Максимальное количество видимых точек, для условий count > visibleCount
36
+ */
37
+ visibleCount?: number;
38
+ /**
39
+ * Обработчик клика по точке
40
+ */
41
+ onChange?: (index: number) => void;
42
+ }
43
+ export interface PaginationDotsProps extends HTMLAttributesWithoutOnChange<HTMLDivElement>, CustomPaginationDots {
44
+ }
45
+ export {};
46
+ //# sourceMappingURL=PaginationDots.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PaginationDots.types.d.ts","sourceRoot":"","sources":["../../../src/components/PaginationDots/PaginationDots.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,qBAAqB,CAAC;AAEzE,UAAU,oBAAoB;IAC1B;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,iBAAiB,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IACnC;;OAEG;IACH,WAAW,CAAC,EAAE,YAAY,GAAG,UAAU,CAAC;IACxC;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACtC;AAED,MAAM,WAAW,mBAAoB,SAAQ,6BAA6B,CAAC,cAAc,CAAC,EAAE,oBAAoB;CAAG"}
@@ -0,0 +1,23 @@
1
+ /// <reference types="react" />
2
+ import { DotSize } from '../PaginationDots';
3
+ export declare const useAnimation: ({ isVertical, onAnimationEnd, activeElementRef, animatedDotsWrapperRef, canScrollForward, canScrollBackward, dots, prevDots, innerViewIndex, }: {
4
+ dots: DotSize[];
5
+ prevDots: DotSize[];
6
+ innerViewIndex: number;
7
+ canScrollForward: boolean;
8
+ canScrollBackward: boolean;
9
+ isVertical: boolean;
10
+ onAnimationEnd: () => void;
11
+ activeElementRef: React.RefObject<HTMLDivElement>;
12
+ animatedDotsWrapperRef: React.RefObject<HTMLDivElement>;
13
+ }) => {
14
+ skipAnimation: boolean;
15
+ hasAnimation: boolean;
16
+ hasBackwardAnimation: boolean;
17
+ hasForwardAnimation: boolean;
18
+ setSkipAnimation: import("react").Dispatch<import("react").SetStateAction<boolean>>;
19
+ setHasForwardAnimation: import("react").Dispatch<import("react").SetStateAction<boolean>>;
20
+ setHasBackwardAnimation: import("react").Dispatch<import("react").SetStateAction<boolean>>;
21
+ handleAnimationEnd: () => void;
22
+ };
23
+ //# sourceMappingURL=useAnimation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAnimation.d.ts","sourceRoot":"","sources":["../../../../src/components/PaginationDots/hooks/useAnimation.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAoB,MAAM,mBAAmB,CAAC;AAE9D,eAAO,MAAM,YAAY;UAWf,OAAO,EAAE;cACL,OAAO,EAAE;oBACH,MAAM;sBACJ,OAAO;uBACN,OAAO;gBACd,OAAO;oBACH,MAAM,IAAI;sBACR,MAAM,SAAS,CAAC,cAAc,CAAC;4BACzB,MAAM,SAAS,CAAC,cAAc,CAAC;;;;;;;;;;CA+F1D,CAAC"}