@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,92 @@
1
+ "use strict";
2
+
3
+ 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); }
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.flowRoot = exports.flowConfig = void 0;
8
+ var _react = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("react"));
9
+ var _classnames = /*#__PURE__*/_interopRequireDefault( /*#__PURE__*/require("classnames"));
10
+ var _lodash = /*#__PURE__*/_interopRequireDefault( /*#__PURE__*/require("lodash.chunk"));
11
+ var _Flow = /*#__PURE__*/require("./Flow.styles");
12
+ var _excluded = ["children", "className", "style", "orientation", "arrangement", "alignment", "mainAxisGap", "crossAxisGap", "minColWidth", "itemsPerLine"];
13
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
14
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
15
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
16
+ 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); }
17
+ 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; }
18
+ 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; }
19
+ 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; }
20
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
21
+ 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); }
22
+ 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; }
23
+ 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; }
24
+ var flowRoot = exports.flowRoot = function flowRoot(Root) {
25
+ return /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
26
+ var children = _ref.children,
27
+ className = _ref.className,
28
+ style = _ref.style,
29
+ _ref$orientation = _ref.orientation,
30
+ orientation = _ref$orientation === void 0 ? 'horizontal' : _ref$orientation,
31
+ arrangement = _ref.arrangement,
32
+ alignment = _ref.alignment,
33
+ _ref$mainAxisGap = _ref.mainAxisGap,
34
+ mainAxisGap = _ref$mainAxisGap === void 0 ? '0' : _ref$mainAxisGap,
35
+ _ref$crossAxisGap = _ref.crossAxisGap,
36
+ crossAxisGap = _ref$crossAxisGap === void 0 ? '0' : _ref$crossAxisGap,
37
+ _ref$minColWidth = _ref.minColWidth,
38
+ minColWidth = _ref$minColWidth === void 0 ? 'auto' : _ref$minColWidth,
39
+ itemsPerLine = _ref.itemsPerLine,
40
+ rest = _objectWithoutProperties(_ref, _excluded);
41
+ var isVertical = orientation === 'vertical';
42
+ var hasMinWidth = Boolean(minColWidth && minColWidth !== 'auto');
43
+ var needGrid = Boolean(Number(itemsPerLine) > 0 || hasMinWidth);
44
+ var innerMainAxisGap = typeof mainAxisGap === 'number' || !Number.isNaN(+mainAxisGap) ? "".concat(mainAxisGap || 0, "px") : mainAxisGap;
45
+ var innerCrossAxisGap = typeof crossAxisGap === 'number' || !Number.isNaN(+crossAxisGap) ? "".concat(crossAxisGap || 0, "px") : crossAxisGap;
46
+ if (arrangement === 'spaceBetween' || arrangement === 'spaceAround') {
47
+ innerMainAxisGap = '0';
48
+ }
49
+ var hasChunks = Number(itemsPerLine) > 0;
50
+ var chunks = hasChunks ? (0, _lodash["default"])(_react["default"].Children.toArray(children), itemsPerLine) : [];
51
+ var gap = isVertical ? "".concat(innerMainAxisGap, " ").concat(innerCrossAxisGap) : "".concat(innerCrossAxisGap, " ").concat(innerMainAxisGap);
52
+ var wrapperGap = isVertical ? "0 ".concat(innerCrossAxisGap) : "".concat(innerCrossAxisGap, " 0");
53
+ var lineGap = isVertical ? "".concat(innerMainAxisGap, " 0") : "0 ".concat(innerMainAxisGap);
54
+ return /*#__PURE__*/_react["default"].createElement(Root, _extends({
55
+ ref: ref,
56
+ className: (0, _classnames["default"])(className, {
57
+ vertical: isVertical,
58
+ grid: hasMinWidth,
59
+ elastic: hasMinWidth,
60
+ hasChunks: hasChunks
61
+ }),
62
+ style: _objectSpread(_objectSpread({}, style), {}, {
63
+ '--plasma-private-gap': hasChunks ? wrapperGap : gap,
64
+ '--plasma-private-items': String(itemsPerLine),
65
+ '--plasma-private-min-width': String(minColWidth)
66
+ }),
67
+ "data-arrangement": arrangement,
68
+ "data-alignment": alignment
69
+ }, rest), hasChunks && chunks.map(function (chunkNode) {
70
+ return /*#__PURE__*/_react["default"].createElement(_Flow.Line, {
71
+ className: (0, _classnames["default"])({
72
+ vertical: isVertical,
73
+ grid: needGrid,
74
+ elastic: hasMinWidth
75
+ }),
76
+ style: {
77
+ '--plasma-private-gap': lineGap
78
+ },
79
+ "data-arrangement": arrangement,
80
+ "data-alignment": alignment
81
+ }, chunkNode);
82
+ }), !hasChunks && children);
83
+ });
84
+ };
85
+ var flowConfig = exports.flowConfig = {
86
+ name: 'Flow',
87
+ tag: 'div',
88
+ layout: flowRoot,
89
+ base: _Flow.base,
90
+ defaults: {},
91
+ variations: {}
92
+ };
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ 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); }
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.base = exports.Line = void 0;
8
+ var _styledComponents = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("styled-components"));
9
+ var _templateObject;
10
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
11
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
12
+ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
13
+ var base = exports.base = /*#__PURE__*/(0, _styledComponents.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"])));
14
+ var Line = exports.Line = /*#__PURE__*/_styledComponents["default"].div.withConfig({
15
+ componentId: "plasma-new-hope__sc-1eomci9-0"
16
+ })(["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,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "flowConfig", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _Flow.flowConfig;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "flowRoot", {
13
+ enumerable: true,
14
+ get: function get() {
15
+ return _Flow.flowRoot;
16
+ }
17
+ });
18
+ var _Flow = /*#__PURE__*/require("./Flow");
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.config = void 0;
7
+ var config = exports.config = {
8
+ defaults: {},
9
+ variations: {}
10
+ };
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Flow = void 0;
7
+ var _Flow = /*#__PURE__*/require("../../../../components/Flow");
8
+ var _engines = /*#__PURE__*/require("../../../../engines");
9
+ var _Flow2 = /*#__PURE__*/require("./Flow.config");
10
+ var mergedConfig = /*#__PURE__*/(0, _engines.mergeConfig)(_Flow.flowConfig, _Flow2.config);
11
+ var Flow = exports.Flow = /*#__PURE__*/(0, _engines.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,10 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.config = void 0;
7
+ var config = exports.config = {
8
+ defaults: {},
9
+ variations: {}
10
+ };
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Flow = void 0;
7
+ var _Flow = /*#__PURE__*/require("../../../../components/Flow");
8
+ var _engines = /*#__PURE__*/require("../../../../engines");
9
+ var _Flow2 = /*#__PURE__*/require("./Flow.config");
10
+ var mergedConfig = /*#__PURE__*/(0, _engines.mergeConfig)(_Flow.flowConfig, _Flow2.config);
11
+ var Flow = exports.Flow = /*#__PURE__*/(0, _engines.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
+ };
@@ -135,6 +135,17 @@ Object.keys(_Cell).forEach(function (key) {
135
135
  }
136
136
  });
137
137
  });
138
+ var _Flow = /*#__PURE__*/require("./components/Flow");
139
+ Object.keys(_Flow).forEach(function (key) {
140
+ if (key === "default" || key === "__esModule") return;
141
+ if (key in exports && exports[key] === _Flow[key]) return;
142
+ Object.defineProperty(exports, key, {
143
+ enumerable: true,
144
+ get: function get() {
145
+ return _Flow[key];
146
+ }
147
+ });
148
+ });
138
149
  var _Link = /*#__PURE__*/require("./components/Link");
139
150
  Object.keys(_Link).forEach(function (key) {
140
151
  if (key === "default" || key === "__esModule") return;