@salutejs/plasma-new-hope 0.237.1-canary.1689.12525929253.0 → 0.238.0-canary.1657.12529257851.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 (85) hide show
  1. package/cjs/components/Flow/Flow.css +2 -0
  2. package/cjs/components/Flow/Flow.js +84 -0
  3. package/cjs/components/Flow/Flow.js.map +1 -0
  4. package/cjs/components/Flow/Flow.styles.js +17 -0
  5. package/cjs/components/Flow/Flow.styles.js.map +1 -0
  6. package/cjs/components/Flow/Flow.styles_q8k0on.css +2 -0
  7. package/cjs/index.css +3 -0
  8. package/cjs/index.js +3 -0
  9. package/cjs/index.js.map +1 -1
  10. package/emotion/cjs/components/Flow/Flow.js +92 -0
  11. package/emotion/cjs/components/Flow/Flow.styles.js +31 -0
  12. package/emotion/cjs/components/Flow/Flow.template-doc.mdx +127 -0
  13. package/emotion/cjs/components/Flow/Flow.types.js +5 -0
  14. package/emotion/cjs/components/Flow/index.js +18 -0
  15. package/emotion/cjs/examples/plasma_b2c/components/Flow/Flow.config.js +10 -0
  16. package/emotion/cjs/examples/plasma_b2c/components/Flow/Flow.js +11 -0
  17. package/emotion/cjs/examples/plasma_b2c/components/Flow/Flow.stories.tsx +135 -0
  18. package/emotion/cjs/examples/plasma_web/components/Flow/Flow.config.js +10 -0
  19. package/emotion/cjs/examples/plasma_web/components/Flow/Flow.js +11 -0
  20. package/emotion/cjs/examples/plasma_web/components/Flow/Flow.stories.tsx +135 -0
  21. package/emotion/cjs/index.js +11 -0
  22. package/emotion/es/components/Flow/Flow.js +83 -0
  23. package/emotion/es/components/Flow/Flow.styles.js +24 -0
  24. package/emotion/es/components/Flow/Flow.template-doc.mdx +127 -0
  25. package/emotion/es/components/Flow/Flow.types.js +1 -0
  26. package/emotion/es/components/Flow/index.js +1 -0
  27. package/emotion/es/examples/plasma_b2c/components/Flow/Flow.config.js +4 -0
  28. package/emotion/es/examples/plasma_b2c/components/Flow/Flow.js +5 -0
  29. package/emotion/es/examples/plasma_b2c/components/Flow/Flow.stories.tsx +135 -0
  30. package/emotion/es/examples/plasma_web/components/Flow/Flow.config.js +4 -0
  31. package/emotion/es/examples/plasma_web/components/Flow/Flow.js +5 -0
  32. package/emotion/es/examples/plasma_web/components/Flow/Flow.stories.tsx +135 -0
  33. package/emotion/es/index.js +2 -0
  34. package/es/components/Flow/Flow.css +2 -0
  35. package/es/components/Flow/Flow.js +79 -0
  36. package/es/components/Flow/Flow.js.map +1 -0
  37. package/es/components/Flow/Flow.styles.js +12 -0
  38. package/es/components/Flow/Flow.styles.js.map +1 -0
  39. package/es/components/Flow/Flow.styles_q8k0on.css +2 -0
  40. package/es/index.css +3 -0
  41. package/es/index.js +1 -0
  42. package/es/index.js.map +1 -1
  43. package/package.json +24 -5
  44. package/styled-components/cjs/components/Flow/Flow.js +92 -0
  45. package/styled-components/cjs/components/Flow/Flow.styles.js +16 -0
  46. package/styled-components/cjs/components/Flow/Flow.template-doc.mdx +127 -0
  47. package/styled-components/cjs/components/Flow/Flow.types.js +5 -0
  48. package/styled-components/cjs/components/Flow/index.js +18 -0
  49. package/styled-components/cjs/examples/plasma_b2c/components/Flow/Flow.config.js +10 -0
  50. package/styled-components/cjs/examples/plasma_b2c/components/Flow/Flow.js +11 -0
  51. package/styled-components/cjs/examples/plasma_b2c/components/Flow/Flow.stories.tsx +135 -0
  52. package/styled-components/cjs/examples/plasma_web/components/Flow/Flow.config.js +10 -0
  53. package/styled-components/cjs/examples/plasma_web/components/Flow/Flow.js +11 -0
  54. package/styled-components/cjs/examples/plasma_web/components/Flow/Flow.stories.tsx +135 -0
  55. package/styled-components/cjs/index.js +11 -0
  56. package/styled-components/es/components/Flow/Flow.js +83 -0
  57. package/styled-components/es/components/Flow/Flow.styles.js +8 -0
  58. package/styled-components/es/components/Flow/Flow.template-doc.mdx +127 -0
  59. package/styled-components/es/components/Flow/Flow.types.js +1 -0
  60. package/styled-components/es/components/Flow/index.js +1 -0
  61. package/styled-components/es/examples/plasma_b2c/components/Flow/Flow.config.js +4 -0
  62. package/styled-components/es/examples/plasma_b2c/components/Flow/Flow.js +5 -0
  63. package/styled-components/es/examples/plasma_b2c/components/Flow/Flow.stories.tsx +135 -0
  64. package/styled-components/es/examples/plasma_web/components/Flow/Flow.config.js +4 -0
  65. package/styled-components/es/examples/plasma_web/components/Flow/Flow.js +5 -0
  66. package/styled-components/es/examples/plasma_web/components/Flow/Flow.stories.tsx +135 -0
  67. package/styled-components/es/index.js +2 -0
  68. package/types/components/Flow/Flow.d.ts +33 -0
  69. package/types/components/Flow/Flow.d.ts.map +1 -0
  70. package/types/components/Flow/Flow.styles.d.ts +4 -0
  71. package/types/components/Flow/Flow.styles.d.ts.map +1 -0
  72. package/types/components/Flow/Flow.types.d.ts +34 -0
  73. package/types/components/Flow/Flow.types.d.ts.map +1 -0
  74. package/types/components/Flow/index.d.ts +3 -0
  75. package/types/components/Flow/index.d.ts.map +1 -0
  76. package/types/examples/plasma_b2c/components/Flow/Flow.config.d.ts +5 -0
  77. package/types/examples/plasma_b2c/components/Flow/Flow.config.d.ts.map +1 -0
  78. package/types/examples/plasma_b2c/components/Flow/Flow.d.ts +5 -0
  79. package/types/examples/plasma_b2c/components/Flow/Flow.d.ts.map +1 -0
  80. package/types/examples/plasma_web/components/Flow/Flow.config.d.ts +5 -0
  81. package/types/examples/plasma_web/components/Flow/Flow.config.d.ts.map +1 -0
  82. package/types/examples/plasma_web/components/Flow/Flow.d.ts +5 -0
  83. package/types/examples/plasma_web/components/Flow/Flow.d.ts.map +1 -0
  84. package/types/index.d.ts +2 -0
  85. package/types/index.d.ts.map +1 -1
@@ -0,0 +1,83 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ var _excluded = ["children", "className", "style", "orientation", "arrangement", "alignment", "mainAxisGap", "crossAxisGap", "minColWidth", "itemsPerLine"];
3
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
4
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
5
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
6
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
7
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
8
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
9
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
10
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
11
+ import React, { forwardRef } from 'react';
12
+ import cls from 'classnames';
13
+ import chunk from 'lodash.chunk';
14
+ import { base, Line } from './Flow.styles';
15
+ export var flowRoot = function flowRoot(Root) {
16
+ return /*#__PURE__*/forwardRef(function (_ref, ref) {
17
+ var children = _ref.children,
18
+ className = _ref.className,
19
+ style = _ref.style,
20
+ _ref$orientation = _ref.orientation,
21
+ orientation = _ref$orientation === void 0 ? 'horizontal' : _ref$orientation,
22
+ arrangement = _ref.arrangement,
23
+ alignment = _ref.alignment,
24
+ _ref$mainAxisGap = _ref.mainAxisGap,
25
+ mainAxisGap = _ref$mainAxisGap === void 0 ? '0' : _ref$mainAxisGap,
26
+ _ref$crossAxisGap = _ref.crossAxisGap,
27
+ crossAxisGap = _ref$crossAxisGap === void 0 ? '0' : _ref$crossAxisGap,
28
+ _ref$minColWidth = _ref.minColWidth,
29
+ minColWidth = _ref$minColWidth === void 0 ? 'auto' : _ref$minColWidth,
30
+ itemsPerLine = _ref.itemsPerLine,
31
+ rest = _objectWithoutProperties(_ref, _excluded);
32
+ var isVertical = orientation === 'vertical';
33
+ var hasMinWidth = Boolean(minColWidth && minColWidth !== 'auto');
34
+ var needGrid = Boolean(Number(itemsPerLine) > 0 || hasMinWidth);
35
+ var innerMainAxisGap = typeof mainAxisGap === 'number' || !Number.isNaN(+mainAxisGap) ? "".concat(mainAxisGap || 0, "px") : mainAxisGap;
36
+ var innerCrossAxisGap = typeof crossAxisGap === 'number' || !Number.isNaN(+crossAxisGap) ? "".concat(crossAxisGap || 0, "px") : crossAxisGap;
37
+ if (arrangement === 'spaceBetween' || arrangement === 'spaceAround') {
38
+ innerMainAxisGap = '0';
39
+ }
40
+ var hasChunks = Number(itemsPerLine) > 0;
41
+ var chunks = hasChunks ? chunk(React.Children.toArray(children), itemsPerLine) : [];
42
+ var gap = isVertical ? "".concat(innerMainAxisGap, " ").concat(innerCrossAxisGap) : "".concat(innerCrossAxisGap, " ").concat(innerMainAxisGap);
43
+ var wrapperGap = isVertical ? "0 ".concat(innerCrossAxisGap) : "".concat(innerCrossAxisGap, " 0");
44
+ var lineGap = isVertical ? "".concat(innerMainAxisGap, " 0") : "0 ".concat(innerMainAxisGap);
45
+ return /*#__PURE__*/React.createElement(Root, _extends({
46
+ ref: ref,
47
+ className: cls(className, {
48
+ vertical: isVertical,
49
+ grid: hasMinWidth,
50
+ elastic: hasMinWidth,
51
+ hasChunks: hasChunks
52
+ }),
53
+ style: _objectSpread(_objectSpread({}, style), {}, {
54
+ '--plasma-private-gap': hasChunks ? wrapperGap : gap,
55
+ '--plasma-private-items': String(itemsPerLine),
56
+ '--plasma-private-min-width': String(minColWidth)
57
+ }),
58
+ "data-arrangement": arrangement,
59
+ "data-alignment": alignment
60
+ }, rest), hasChunks && chunks.map(function (chunkNode) {
61
+ return /*#__PURE__*/React.createElement(Line, {
62
+ className: cls({
63
+ vertical: isVertical,
64
+ grid: needGrid,
65
+ elastic: hasMinWidth
66
+ }),
67
+ style: {
68
+ '--plasma-private-gap': lineGap
69
+ },
70
+ "data-arrangement": arrangement,
71
+ "data-alignment": alignment
72
+ }, chunkNode);
73
+ }), !hasChunks && children);
74
+ });
75
+ };
76
+ export var flowConfig = {
77
+ name: 'Flow',
78
+ tag: 'div',
79
+ layout: flowRoot,
80
+ base: base,
81
+ defaults: {},
82
+ variations: {}
83
+ };
@@ -0,0 +1,8 @@
1
+ var _templateObject;
2
+ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
3
+ import { css } from 'styled-components';
4
+ import styled from 'styled-components';
5
+ export var base = /*#__PURE__*/css(_templateObject || (_templateObject = /*#__PURE__*/_taggedTemplateLiteral(["\n display: flex;\n flex-direction: row;\n flex-wrap: wrap;\n\n gap: var(--plasma-private-gap);\n\n &.hasChunks {\n flex-wrap: nowrap;\n flex-direction: column;\n\n &.vertical {\n flex-direction: row;\n }\n }\n\n &.vertical {\n flex-direction: column;\n }\n\n &.grid {\n display: grid;\n\n grid-template-columns: repeat(var(--plasma-private-items), auto);\n grid-auto-flow: row;\n\n &.elastic {\n grid-template-columns: repeat(auto-fill, minmax(var(--plasma-private-min-width), auto));\n grid-auto-flow: row;\n }\n\n &:not(.vertical) {\n &[data-arrangement='start'] {\n justify-items: start;\n }\n\n &[data-arrangement='center'] {\n justify-items: center;\n }\n\n &[data-arrangement='end'] {\n justify-items: end;\n }\n\n &[data-arrangement='spaceBetween'] {\n justify-content: space-between;\n }\n\n &[data-arrangement='spaceAround'] {\n justify-content: space-around;\n }\n\n &[data-alignment='start'] {\n align-items: start;\n }\n\n &[data-alignment='center'] {\n align-items: center;\n }\n\n &[data-alignment='end'] {\n align-items: end;\n }\n }\n\n &.vertical {\n grid-template-columns: auto;\n grid-template-rows: repeat(var(--plasma-private-items), auto);\n grid-auto-flow: column;\n\n &[data-arrangement='start'] {\n align-items: start;\n }\n\n &[data-arrangement='center'] {\n align-items: center;\n }\n\n &[data-arrangement='end'] {\n align-items: end;\n }\n\n &[data-arrangement='spaceBetween'] {\n align-content: space-between;\n align-items: normal;\n }\n\n &[data-arrangement='spaceAround'] {\n align-content: space-around;\n align-items: normal;\n }\n\n &[data-alignment='start'] {\n justify-items: start;\n }\n\n &[data-alignment='center'] {\n justify-items: center;\n }\n\n &[data-alignment='end'] {\n justify-items: end;\n }\n }\n }\n\n &:not(&.grid):not(&.hasChunks) {\n align-content: start;\n\n &[data-arrangement='start'] {\n justify-content: start;\n }\n\n &[data-arrangement='center'] {\n justify-content: center;\n }\n\n &[data-arrangement='end'] {\n justify-content: end;\n }\n\n &[data-arrangement='spaceBetween'] {\n justify-content: space-between;\n }\n\n &[data-arrangement='spaceAround'] {\n justify-content: space-around;\n }\n\n &[data-alignment='start'] {\n align-items: start;\n }\n\n &[data-alignment='center'] {\n align-items: center;\n }\n\n &[data-alignment='end'] {\n align-items: end;\n }\n }\n"])));
6
+ export var Line = /*#__PURE__*/styled.div.withConfig({
7
+ componentId: "plasma-new-hope__sc-1eomci9-0"
8
+ })(["display:flex;gap:var(--plasma-private-gap);&.vertical{flex-direction:column;height:100%;}&[data-arrangement='start']{justify-content:start;}&[data-arrangement='center']{justify-content:center;}&[data-arrangement='end']{justify-content:end;}&[data-arrangement='spaceBetween']{justify-content:space-between;}&[data-arrangement='spaceAround']{justify-content:space-around;}&[data-alignment='start']{align-items:start;}&[data-alignment='center']{align-items:center;}&[data-alignment='end']{align-items:end;}"]);
@@ -0,0 +1,127 @@
1
+ ---
2
+ id: flow
3
+ title: Flow
4
+ ---
5
+
6
+ import { PropsTable, Description } from '@site/src/components';
7
+
8
+ # Flow
9
+ Универсальный контейнер для упорядоченного размещения вложенных компонентов (например, медиафайлы, карточки или блоки текста).
10
+
11
+
12
+ ## Flow
13
+ <Description name="Flow" />
14
+ <PropsTable name="Flow" exclude={['css', 'focused', 'minColWidth']} />
15
+
16
+ ## Использование
17
+ По умолчанию компонент `Flow` отображается на основе `display: flex; flex-wrap: wrap`,
18
+ при указании `itemsPerLine` компонент переходит на `display: flex; flex-wrap: nowrap` с превентивным разбиением на колонки/столбцы.
19
+
20
+
21
+ ## Примеры
22
+
23
+ ### Горизонтальное отображение с переполнением
24
+
25
+ ```tsx live
26
+ import React from 'react';
27
+ import { Flow } from '@salutejs/{{ package }}';
28
+
29
+ export function App() {
30
+ const numbers = ['one', 'two', 'three', 'four', 'five', 'six'];
31
+
32
+ const style = (index) => ({
33
+ display: 'flex',
34
+ alignItems: 'center',
35
+ justifyContent: 'center',
36
+ width: `${2 + numbers[index].length}ch`,
37
+ height: '25px',
38
+ backgroundColor: '#999',
39
+ borderRadius: '10px',
40
+ });
41
+
42
+ return (
43
+ <div>
44
+ <Flow mainAxisGap="0.5ch" crossAxisGap="1ch" style={{ width: '15ch' }} >
45
+ {Array(6)
46
+ .fill(0)
47
+ .map((_, i) => (<div key={i} style={style(i)}>{numbers[i]}</div>))}
48
+ </Flow>
49
+ </div>
50
+ );
51
+ }
52
+ ```
53
+
54
+ ### Вертикальное отображение с переполнением
55
+
56
+ ```tsx live
57
+ import React from 'react';
58
+ import { Flow } from '@salutejs/{{ package }}';
59
+
60
+ export function App() {
61
+ const numbers = ['one', 'two', 'three', 'four', 'five', 'six'];
62
+
63
+ const style = (index) => ({
64
+ display: 'flex',
65
+ alignItems: 'center',
66
+ justifyContent: 'center',
67
+ width: `${2 + numbers[index].length}ch`,
68
+ height: '25px',
69
+ backgroundColor: '#999',
70
+ borderRadius: '10px',
71
+ });
72
+
73
+ return (
74
+ <div>
75
+ <Flow
76
+ alignment="center"
77
+ orientation="vertical"
78
+ mainAxisGap="0.5ch"
79
+ crossAxisGap="1ch"
80
+ style={{ height: '90px' }}
81
+ >
82
+ {Array(6)
83
+ .fill(0)
84
+ .map((_, i) => (<div key={i} style={style(i)}>{numbers[i]}</div>))}
85
+ </Flow>
86
+ </div>
87
+ );
88
+ }
89
+ ```
90
+
91
+ ### Отображение с разбиением на строки
92
+ С ограничением количества элементов в строке.
93
+
94
+ ```tsx live
95
+ import React from 'react';
96
+ import { Flow } from '@salutejs/{{ package }}';
97
+
98
+ export function App() {
99
+ const numbers = ['one', 'two', 'three', 'four', 'five', 'six'];
100
+
101
+ const style = (index) => ({
102
+ display: 'flex',
103
+ alignItems: 'center',
104
+ justifyContent: 'center',
105
+ width: `${2 + numbers[index].length}ch`,
106
+ height: '25px',
107
+ backgroundColor: '#999',
108
+ borderRadius: '10px',
109
+ });
110
+
111
+ return (
112
+ <div>
113
+ <Flow
114
+ arrangement="end"
115
+ itemsPerLine={2}
116
+ mainAxisGap="0.5ch"
117
+ crossAxisGap="1ch"
118
+ >
119
+ {Array(6)
120
+ .fill(0)
121
+ .map((_, i) => (<div key={i} style={style(i)}>{numbers[i]}</div>))}
122
+ </Flow>
123
+ </div>
124
+ );
125
+ }
126
+ ```
127
+
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export { flowRoot, flowConfig } from './Flow';
@@ -0,0 +1,4 @@
1
+ export var config = {
2
+ defaults: {},
3
+ variations: {}
4
+ };
@@ -0,0 +1,5 @@
1
+ import { flowConfig } from '../../../../components/Flow';
2
+ import { component, mergeConfig } from '../../../../engines';
3
+ import { config } from './Flow.config';
4
+ var mergedConfig = /*#__PURE__*/mergeConfig(flowConfig, config);
5
+ export var Flow = /*#__PURE__*/component(mergedConfig);
@@ -0,0 +1,135 @@
1
+ import React, { ComponentProps } from 'react';
2
+ import type { StoryObj, Meta } from '@storybook/react';
3
+ import styled from 'styled-components';
4
+ import { disableProps } from '@salutejs/plasma-sb-utils';
5
+
6
+ import { WithTheme } from '../../../_helpers';
7
+
8
+ import { Flow } from './Flow';
9
+
10
+ const orientations = ['vertical', 'horizontal'];
11
+ const arrangements = ['start', 'center', 'end', 'spaceBetween', 'spaceAround'];
12
+ const alignments = ['start', 'center', 'end'];
13
+
14
+ const widths = [100, 32, 171, 74, 179, 55];
15
+ const heights = [10, 50, 45, 33, 14, 55];
16
+
17
+ const FlowCustom = styled(Flow)`
18
+ background: var(--surface-transparent-primary);
19
+ border-radius: 0.5rem;
20
+ `;
21
+
22
+ const Item = styled.div`
23
+ padding: 0.5rem 1rem;
24
+ border-radius: 0.5rem;
25
+ background: #aab1e9;
26
+ display: flex;
27
+ align-items: center;
28
+ justify-content: center;
29
+ `;
30
+
31
+ const meta: Meta<typeof Flow> = {
32
+ title: 'b2c/Layout/Flow',
33
+ component: Flow,
34
+ decorators: [WithTheme],
35
+ argTypes: {
36
+ itemsCount: {
37
+ control: {
38
+ type: 'number',
39
+ },
40
+ },
41
+ containerWidth: {
42
+ control: {
43
+ type: 'text',
44
+ },
45
+ },
46
+ containerHeight: {
47
+ control: {
48
+ type: 'text',
49
+ },
50
+ },
51
+ orientation: {
52
+ options: orientations,
53
+ control: {
54
+ type: 'select',
55
+ },
56
+ },
57
+ arrangement: {
58
+ options: arrangements,
59
+ control: {
60
+ type: 'select',
61
+ },
62
+ },
63
+ alignment: {
64
+ options: alignments,
65
+ control: {
66
+ type: 'select',
67
+ },
68
+ },
69
+ mainAxisGap: {
70
+ control: {
71
+ type: 'text',
72
+ },
73
+ },
74
+ crossAxisGap: {
75
+ control: {
76
+ type: 'text',
77
+ },
78
+ },
79
+ itemsPerLine: {
80
+ control: {
81
+ type: 'text',
82
+ },
83
+ },
84
+ minColWidth: {
85
+ control: {
86
+ type: 'text',
87
+ },
88
+ },
89
+ ...disableProps(['minColWidth']),
90
+ },
91
+ };
92
+
93
+ export default meta;
94
+
95
+ type Story = StoryObj<typeof Flow>;
96
+
97
+ export const Default: Story = {
98
+ args: {
99
+ containerWidth: '450px',
100
+ containerHeight: '200px',
101
+ orientation: 'horizontal',
102
+ arrangement: 'start',
103
+ alignment: 'start',
104
+ mainAxisGap: '10',
105
+ crossAxisGap: '10',
106
+ itemsPerLine: '',
107
+ itemsCount: 6,
108
+ },
109
+ render: ({ itemsCount, containerWidth, containerHeight, ...args }: ComponentProps<typeof Flow>) => {
110
+ const hasLines = Boolean(args.itemsPerLine);
111
+
112
+ return (
113
+ <FlowCustom {...args} style={{ width: containerWidth, height: containerHeight }}>
114
+ {new Array(itemsCount).fill(null).map((width, index) => (
115
+ <Item
116
+ key={index}
117
+ style={
118
+ hasLines
119
+ ? {
120
+ minWidth: widths[index % widths.length],
121
+ minHeight: heights[index % heights.length],
122
+ }
123
+ : {
124
+ width: widths[index % widths.length],
125
+ height: heights[index % heights.length],
126
+ }
127
+ }
128
+ >
129
+ {index + 1}
130
+ </Item>
131
+ ))}
132
+ </FlowCustom>
133
+ );
134
+ },
135
+ };
@@ -0,0 +1,4 @@
1
+ export var config = {
2
+ defaults: {},
3
+ variations: {}
4
+ };
@@ -0,0 +1,5 @@
1
+ import { flowConfig } from '../../../../components/Flow';
2
+ import { component, mergeConfig } from '../../../../engines';
3
+ import { config } from './Flow.config';
4
+ var mergedConfig = /*#__PURE__*/mergeConfig(flowConfig, config);
5
+ export var Flow = /*#__PURE__*/component(mergedConfig);
@@ -0,0 +1,135 @@
1
+ import React, { ComponentProps } from 'react';
2
+ import type { StoryObj, Meta } from '@storybook/react';
3
+ import styled from 'styled-components';
4
+ import { disableProps } from '@salutejs/plasma-sb-utils';
5
+
6
+ import { WithTheme } from '../../../_helpers';
7
+
8
+ import { Flow } from './Flow';
9
+
10
+ const orientations = ['vertical', 'horizontal'];
11
+ const arrangements = ['start', 'center', 'end', 'spaceBetween', 'spaceAround'];
12
+ const alignments = ['start', 'center', 'end'];
13
+
14
+ const widths = [100, 32, 171, 74, 179, 55];
15
+ const heights = [10, 50, 45, 33, 14, 55];
16
+
17
+ const FlowCustom = styled(Flow)`
18
+ background: var(--surface-transparent-primary);
19
+ border-radius: 0.5rem;
20
+ `;
21
+
22
+ const Item = styled.div`
23
+ padding: 0.5rem 1rem;
24
+ border-radius: 0.5rem;
25
+ background: #aab1e9;
26
+ display: flex;
27
+ align-items: center;
28
+ justify-content: center;
29
+ `;
30
+
31
+ const meta: Meta<typeof Flow> = {
32
+ title: 'web/Layout/Flow',
33
+ component: Flow,
34
+ decorators: [WithTheme],
35
+ argTypes: {
36
+ itemsCount: {
37
+ control: {
38
+ type: 'number',
39
+ },
40
+ },
41
+ containerWidth: {
42
+ control: {
43
+ type: 'text',
44
+ },
45
+ },
46
+ containerHeight: {
47
+ control: {
48
+ type: 'text',
49
+ },
50
+ },
51
+ orientation: {
52
+ options: orientations,
53
+ control: {
54
+ type: 'select',
55
+ },
56
+ },
57
+ arrangement: {
58
+ options: arrangements,
59
+ control: {
60
+ type: 'select',
61
+ },
62
+ },
63
+ alignment: {
64
+ options: alignments,
65
+ control: {
66
+ type: 'select',
67
+ },
68
+ },
69
+ mainAxisGap: {
70
+ control: {
71
+ type: 'text',
72
+ },
73
+ },
74
+ crossAxisGap: {
75
+ control: {
76
+ type: 'text',
77
+ },
78
+ },
79
+ itemsPerLine: {
80
+ control: {
81
+ type: 'text',
82
+ },
83
+ },
84
+ minColWidth: {
85
+ control: {
86
+ type: 'text',
87
+ },
88
+ },
89
+ ...disableProps(['minColWidth']),
90
+ },
91
+ };
92
+
93
+ export default meta;
94
+
95
+ type Story = StoryObj<typeof Flow>;
96
+
97
+ export const Default: Story = {
98
+ args: {
99
+ containerWidth: '450px',
100
+ containerHeight: '200px',
101
+ orientation: 'horizontal',
102
+ arrangement: 'start',
103
+ alignment: 'start',
104
+ mainAxisGap: '10',
105
+ crossAxisGap: '10',
106
+ itemsPerLine: '',
107
+ itemsCount: 6,
108
+ },
109
+ render: ({ itemsCount, containerWidth, containerHeight, ...args }: ComponentProps<typeof Flow>) => {
110
+ const hasLines = Boolean(args.itemsPerLine);
111
+
112
+ return (
113
+ <FlowCustom {...args} style={{ width: containerWidth, height: containerHeight }}>
114
+ {new Array(itemsCount).fill(null).map((width, index) => (
115
+ <Item
116
+ key={index}
117
+ style={
118
+ hasLines
119
+ ? {
120
+ minWidth: widths[index % widths.length],
121
+ minHeight: heights[index % heights.length],
122
+ }
123
+ : {
124
+ width: widths[index % widths.length],
125
+ height: heights[index % heights.length],
126
+ }
127
+ }
128
+ >
129
+ {index + 1}
130
+ </Item>
131
+ ))}
132
+ </FlowCustom>
133
+ );
134
+ },
135
+ };
@@ -12,6 +12,7 @@ export * from './components/Breadcrumbs';
12
12
  export * from './components/Chip';
13
13
  export * from './components/ChipGroup';
14
14
  export * from './components/Cell';
15
+ export * from './components/Flow';
15
16
  export * from './components/Link';
16
17
  export * from './components/Spinner';
17
18
  export * from './components/Checkbox';
@@ -44,6 +45,7 @@ export * from './components/SSRProvider';
44
45
  export * from './components/Combobox';
45
46
  export * from './components/Indicator';
46
47
  export * from './components/ButtonBase';
48
+ export * from './components/Flow';
47
49
  export * from './components/Grid';
48
50
  export * from './components/Progress';
49
51
  export * from './components/Select';
@@ -0,0 +1,33 @@
1
+ import React from 'react';
2
+ import { RootProps } from '../../engines';
3
+ import { FlowProps } from './Flow.types';
4
+ declare type TempFlowTypes = FlowProps & {
5
+ /**
6
+ * Минимальный размер колонки для эластичной сетки с динамическим количеством растянутых столбцов
7
+ * через `repeat(auto-fill, minmax(${minColWidth}, auto))`
8
+ */
9
+ minColWidth?: string;
10
+ };
11
+ export declare const flowRoot: (Root: RootProps<HTMLDivElement, TempFlowTypes>) => React.ForwardRefExoticComponent<FlowProps & {
12
+ /**
13
+ * Минимальный размер колонки для эластичной сетки с динамическим количеством растянутых столбцов
14
+ * через `repeat(auto-fill, minmax(${minColWidth}, auto))`
15
+ */
16
+ minColWidth?: string | undefined;
17
+ } & React.RefAttributes<HTMLDivElement>>;
18
+ export declare const flowConfig: {
19
+ name: string;
20
+ tag: string;
21
+ layout: (Root: RootProps<HTMLDivElement, TempFlowTypes>) => React.ForwardRefExoticComponent<FlowProps & {
22
+ /**
23
+ * Минимальный размер колонки для эластичной сетки с динамическим количеством растянутых столбцов
24
+ * через `repeat(auto-fill, minmax(${minColWidth}, auto))`
25
+ */
26
+ minColWidth?: string | undefined;
27
+ } & React.RefAttributes<HTMLDivElement>>;
28
+ base: import("@linaria/core").LinariaClassName;
29
+ defaults: {};
30
+ variations: {};
31
+ };
32
+ export {};
33
+ //# sourceMappingURL=Flow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Flow.d.ts","sourceRoot":"","sources":["../../../src/components/Flow/Flow.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoC,MAAM,OAAO,CAAC;AAIzD,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAG1C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,aAAK,aAAa,GAAG,SAAS,GAAG;IAC7B;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,eAAO,MAAM,QAAQ,SAAU,UAAU,cAAc,EAAE,aAAa,CAAC;IAPnE;;;OAGG;;wCAiGF,CAAC;AAEN,eAAO,MAAM,UAAU;;;mBA/FQ,UAAU,cAAc,EAAE,aAAa,CAAC;QAPnE;;;WAGG;;;;;;CA0GN,CAAC"}
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ export declare const base: import("@linaria/core").LinariaClassName;
3
+ export declare const Line: import("@linaria/react").StyledComponent<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & Record<never, unknown>>;
4
+ //# sourceMappingURL=Flow.styles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Flow.styles.d.ts","sourceRoot":"","sources":["../../../src/components/Flow/Flow.styles.ts"],"names":[],"mappings":";AAGA,eAAO,MAAM,IAAI,0CA6IhB,CAAC;AAEF,eAAO,MAAM,IAAI,qKAyChB,CAAC"}
@@ -0,0 +1,34 @@
1
+ import { CSSProperties, ReactNode } from 'react';
2
+ export interface FlowProps {
3
+ children: ReactNode;
4
+ className?: string;
5
+ style?: CSSProperties;
6
+ /**
7
+ * Ориентация элементов
8
+ * @default `horizontal`
9
+ */
10
+ orientation?: 'horizontal' | 'vertical';
11
+ /**
12
+ * Расположение элементов относительно выбранной ориентации
13
+ */
14
+ arrangement?: 'start' | 'center' | 'end' | 'spaceBetween' | 'spaceAround';
15
+ /**
16
+ * Выравнивание элементов внутри строк по вертикали при горизонтальной ориентации,
17
+ * или внутри столбцов по горизонтали при вертикальной
18
+ */
19
+ alignment?: 'start' | 'center' | 'end';
20
+ /**
21
+ * Фиксированный отступ между элементами по главной оси
22
+ */
23
+ mainAxisGap?: number | string;
24
+ /**
25
+ * Фиксированный отступ между элементами по второстепенной оси
26
+ */
27
+ crossAxisGap?: number | string;
28
+ /**
29
+ * Количество элементов по главной оси в отображении grid, при itemsPerLine > 0,
30
+ * иначе используется flex и flex-wrap
31
+ */
32
+ itemsPerLine?: number;
33
+ }
34
+ //# sourceMappingURL=Flow.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Flow.types.d.ts","sourceRoot":"","sources":["../../../src/components/Flow/Flow.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEjD,MAAM,WAAW,SAAS;IACtB,QAAQ,EAAE,SAAS,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB;;;OAGG;IACH,WAAW,CAAC,EAAE,YAAY,GAAG,UAAU,CAAC;IACxC;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,KAAK,GAAG,cAAc,GAAG,aAAa,CAAC;IAC1E;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAC;IACvC;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC9B;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC/B;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACzB"}
@@ -0,0 +1,3 @@
1
+ export { flowRoot, flowConfig } from './Flow';
2
+ export type { FlowProps } from './Flow.types';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Flow/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAC9C,YAAY,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1,5 @@
1
+ export declare const config: {
2
+ defaults: {};
3
+ variations: {};
4
+ };
5
+ //# sourceMappingURL=Flow.config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Flow.config.d.ts","sourceRoot":"","sources":["../../../../../src/examples/plasma_b2c/components/Flow/Flow.config.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM;;;CAGlB,CAAC"}
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ export declare const Flow: import("react").FunctionComponent<import("../../../../engines/types").PropsType<{}> & import("../../../../components/Flow").FlowProps & {
3
+ minColWidth?: string | undefined;
4
+ } & import("react").RefAttributes<HTMLDivElement>>;
5
+ //# sourceMappingURL=Flow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Flow.d.ts","sourceRoot":"","sources":["../../../../../src/examples/plasma_b2c/components/Flow/Flow.ts"],"names":[],"mappings":";AAOA,eAAO,MAAM,IAAI;;kDAA0B,CAAC"}