@salutejs/plasma-new-hope 0.157.1-canary.1454.11127745883.0 → 0.158.0-canary.1443.11125700749.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (196) hide show
  1. package/cjs/components/Attach/Attach.js +9 -13
  2. package/cjs/components/Attach/Attach.js.map +1 -1
  3. package/cjs/components/Attach/utils/truncateFilename.js +24 -0
  4. package/cjs/components/Attach/utils/truncateFilename.js.map +1 -0
  5. package/cjs/components/Steps/Steps.css +18 -0
  6. package/cjs/components/Steps/Steps.js +118 -0
  7. package/cjs/components/Steps/Steps.js.map +1 -0
  8. package/cjs/components/Steps/Steps.styles.js +9 -0
  9. package/cjs/components/Steps/Steps.styles.js.map +1 -0
  10. package/cjs/components/Steps/Steps.styles_1qandre.css +1 -0
  11. package/cjs/components/Steps/Steps.tokens.js +81 -0
  12. package/cjs/components/Steps/Steps.tokens.js.map +1 -0
  13. package/cjs/components/Steps/ui/StepItem/StepItem.css +16 -0
  14. package/cjs/components/Steps/ui/StepItem/StepItem.js +117 -0
  15. package/cjs/components/Steps/ui/StepItem/StepItem.js.map +1 -0
  16. package/cjs/components/Steps/ui/StepItem/StepItem.styles.js +83 -0
  17. package/cjs/components/Steps/ui/StepItem/StepItem.styles.js.map +1 -0
  18. package/cjs/components/Steps/ui/StepItem/StepItem.styles_1nnkvta.css +9 -0
  19. package/cjs/components/Steps/variations/_size/base.js +9 -0
  20. package/cjs/components/Steps/variations/_size/base.js.map +1 -0
  21. package/cjs/components/Steps/variations/_size/base_x642ct.css +1 -0
  22. package/cjs/components/Steps/variations/_view/base.js +9 -0
  23. package/cjs/components/Steps/variations/_view/base.js.map +1 -0
  24. package/cjs/components/Steps/variations/_view/base_x642ct.css +1 -0
  25. package/cjs/index.css +12 -0
  26. package/cjs/index.js +5 -0
  27. package/cjs/index.js.map +1 -1
  28. package/emotion/cjs/components/Attach/Attach.js +6 -9
  29. package/emotion/cjs/components/Attach/utils/index.js +7 -9
  30. package/emotion/cjs/components/Attach/utils/truncateFilename.js +23 -0
  31. package/emotion/cjs/components/Steps/Steps.js +130 -0
  32. package/emotion/cjs/components/Steps/Steps.review-doc.mdx +304 -0
  33. package/emotion/cjs/components/Steps/Steps.styles.js +9 -0
  34. package/emotion/cjs/components/Steps/Steps.template-doc.mdx +78 -0
  35. package/emotion/cjs/components/Steps/Steps.tokens.js +79 -0
  36. package/emotion/cjs/components/Steps/Steps.types.js +5 -0
  37. package/emotion/cjs/components/Steps/index.js +25 -0
  38. package/emotion/cjs/components/Steps/ui/StepItem/StepItem.js +127 -0
  39. package/emotion/cjs/components/Steps/ui/StepItem/StepItem.styles.js +52 -0
  40. package/emotion/cjs/components/Steps/ui/StepItem/StepItem.types.js +5 -0
  41. package/emotion/cjs/components/Steps/ui/StepItem/index.js +12 -0
  42. package/emotion/cjs/components/Steps/ui/index.js +16 -0
  43. package/emotion/cjs/components/Steps/variations/_size/base.js +8 -0
  44. package/emotion/cjs/components/Steps/variations/_size/tokens.json +1 -0
  45. package/emotion/cjs/components/Steps/variations/_view/base.js +8 -0
  46. package/emotion/cjs/components/Steps/variations/_view/tokens.json +1 -0
  47. package/emotion/cjs/examples/plasma_b2c/components/Steps/Steps.config.js +25 -0
  48. package/emotion/cjs/examples/plasma_b2c/components/Steps/Steps.js +13 -0
  49. package/emotion/cjs/examples/plasma_b2c/components/Steps/Steps.stories.tsx +169 -0
  50. package/emotion/cjs/index.js +11 -0
  51. package/emotion/es/components/Attach/Attach.js +7 -10
  52. package/emotion/es/components/Attach/utils/index.js +1 -2
  53. package/emotion/es/components/Attach/utils/truncateFilename.js +17 -0
  54. package/emotion/es/components/Steps/Steps.js +121 -0
  55. package/emotion/es/components/Steps/Steps.review-doc.mdx +304 -0
  56. package/emotion/es/components/Steps/Steps.styles.js +3 -0
  57. package/emotion/es/components/Steps/Steps.template-doc.mdx +78 -0
  58. package/emotion/es/components/Steps/Steps.tokens.js +73 -0
  59. package/emotion/es/components/Steps/Steps.types.js +1 -0
  60. package/emotion/es/components/Steps/index.js +2 -0
  61. package/emotion/es/components/Steps/ui/StepItem/StepItem.js +118 -0
  62. package/emotion/es/components/Steps/ui/StepItem/StepItem.styles.js +45 -0
  63. package/emotion/es/components/Steps/ui/StepItem/StepItem.types.js +1 -0
  64. package/emotion/es/components/Steps/ui/StepItem/index.js +1 -0
  65. package/emotion/es/components/Steps/ui/index.js +1 -0
  66. package/emotion/es/components/Steps/variations/_size/base.js +2 -0
  67. package/emotion/es/components/Steps/variations/_size/tokens.json +1 -0
  68. package/emotion/es/components/Steps/variations/_view/base.js +2 -0
  69. package/emotion/es/components/Steps/variations/_view/tokens.json +1 -0
  70. package/emotion/es/examples/plasma_b2c/components/Steps/Steps.config.js +19 -0
  71. package/emotion/es/examples/plasma_b2c/components/Steps/Steps.js +9 -0
  72. package/emotion/es/examples/plasma_b2c/components/Steps/Steps.stories.tsx +169 -0
  73. package/emotion/es/index.js +1 -0
  74. package/es/components/Attach/Attach.js +9 -13
  75. package/es/components/Attach/Attach.js.map +1 -1
  76. package/es/components/Attach/utils/truncateFilename.js +20 -0
  77. package/es/components/Attach/utils/truncateFilename.js.map +1 -0
  78. package/es/components/Steps/Steps.css +18 -0
  79. package/es/components/Steps/Steps.js +113 -0
  80. package/es/components/Steps/Steps.js.map +1 -0
  81. package/es/components/Steps/Steps.styles.js +5 -0
  82. package/es/components/Steps/Steps.styles.js.map +1 -0
  83. package/es/components/Steps/Steps.styles_1qandre.css +1 -0
  84. package/es/components/Steps/Steps.tokens.js +76 -0
  85. package/es/components/Steps/Steps.tokens.js.map +1 -0
  86. package/es/components/Steps/ui/StepItem/StepItem.css +16 -0
  87. package/es/components/Steps/ui/StepItem/StepItem.js +113 -0
  88. package/es/components/Steps/ui/StepItem/StepItem.js.map +1 -0
  89. package/es/components/Steps/ui/StepItem/StepItem.styles.js +71 -0
  90. package/es/components/Steps/ui/StepItem/StepItem.styles.js.map +1 -0
  91. package/es/components/Steps/ui/StepItem/StepItem.styles_1nnkvta.css +9 -0
  92. package/es/components/Steps/variations/_size/base.js +5 -0
  93. package/es/components/Steps/variations/_size/base.js.map +1 -0
  94. package/es/components/Steps/variations/_size/base_x642ct.css +1 -0
  95. package/es/components/Steps/variations/_view/base.js +5 -0
  96. package/es/components/Steps/variations/_view/base.js.map +1 -0
  97. package/es/components/Steps/variations/_view/base_x642ct.css +1 -0
  98. package/es/index.css +12 -0
  99. package/es/index.js +2 -0
  100. package/es/index.js.map +1 -1
  101. package/package.json +2 -2
  102. package/styled-components/cjs/components/Attach/Attach.js +6 -9
  103. package/styled-components/cjs/components/Attach/utils/index.js +7 -9
  104. package/styled-components/cjs/components/Attach/utils/truncateFilename.js +23 -0
  105. package/styled-components/cjs/components/Steps/Steps.js +130 -0
  106. package/styled-components/cjs/components/Steps/Steps.review-doc.mdx +304 -0
  107. package/styled-components/cjs/components/Steps/Steps.styles.js +9 -0
  108. package/styled-components/cjs/components/Steps/Steps.template-doc.mdx +78 -0
  109. package/styled-components/cjs/components/Steps/Steps.tokens.js +79 -0
  110. package/styled-components/cjs/components/Steps/Steps.types.js +5 -0
  111. package/styled-components/cjs/components/Steps/index.js +25 -0
  112. package/styled-components/cjs/components/Steps/ui/StepItem/StepItem.js +127 -0
  113. package/styled-components/cjs/components/Steps/ui/StepItem/StepItem.styles.js +43 -0
  114. package/styled-components/cjs/components/Steps/ui/StepItem/StepItem.types.js +5 -0
  115. package/styled-components/cjs/components/Steps/ui/StepItem/index.js +12 -0
  116. package/styled-components/cjs/components/Steps/ui/index.js +16 -0
  117. package/styled-components/cjs/components/Steps/variations/_size/base.js +8 -0
  118. package/styled-components/cjs/components/Steps/variations/_size/tokens.json +1 -0
  119. package/styled-components/cjs/components/Steps/variations/_view/base.js +8 -0
  120. package/styled-components/cjs/components/Steps/variations/_view/tokens.json +1 -0
  121. package/styled-components/cjs/examples/plasma_b2c/components/Steps/Steps.config.js +25 -0
  122. package/styled-components/cjs/examples/plasma_b2c/components/Steps/Steps.js +13 -0
  123. package/styled-components/cjs/examples/plasma_b2c/components/Steps/Steps.stories.tsx +169 -0
  124. package/styled-components/cjs/index.js +11 -0
  125. package/styled-components/es/components/Attach/Attach.js +7 -10
  126. package/styled-components/es/components/Attach/utils/index.js +1 -2
  127. package/styled-components/es/components/Attach/utils/truncateFilename.js +17 -0
  128. package/styled-components/es/components/Steps/Steps.js +121 -0
  129. package/styled-components/es/components/Steps/Steps.review-doc.mdx +304 -0
  130. package/styled-components/es/components/Steps/Steps.styles.js +3 -0
  131. package/styled-components/es/components/Steps/Steps.template-doc.mdx +78 -0
  132. package/styled-components/es/components/Steps/Steps.tokens.js +73 -0
  133. package/styled-components/es/components/Steps/Steps.types.js +1 -0
  134. package/styled-components/es/components/Steps/index.js +2 -0
  135. package/styled-components/es/components/Steps/ui/StepItem/StepItem.js +118 -0
  136. package/styled-components/es/components/Steps/ui/StepItem/StepItem.styles.js +36 -0
  137. package/styled-components/es/components/Steps/ui/StepItem/StepItem.types.js +1 -0
  138. package/styled-components/es/components/Steps/ui/StepItem/index.js +1 -0
  139. package/styled-components/es/components/Steps/ui/index.js +1 -0
  140. package/styled-components/es/components/Steps/variations/_size/base.js +2 -0
  141. package/styled-components/es/components/Steps/variations/_size/tokens.json +1 -0
  142. package/styled-components/es/components/Steps/variations/_view/base.js +2 -0
  143. package/styled-components/es/components/Steps/variations/_view/tokens.json +1 -0
  144. package/styled-components/es/examples/plasma_b2c/components/Steps/Steps.config.js +19 -0
  145. package/styled-components/es/examples/plasma_b2c/components/Steps/Steps.js +9 -0
  146. package/styled-components/es/examples/plasma_b2c/components/Steps/Steps.stories.tsx +169 -0
  147. package/styled-components/es/index.js +1 -0
  148. package/types/components/Attach/Attach.d.ts.map +1 -1
  149. package/types/components/Attach/utils/index.d.ts +1 -2
  150. package/types/components/Attach/utils/index.d.ts.map +1 -1
  151. package/types/components/Attach/utils/truncateFilename.d.ts +7 -0
  152. package/types/components/Attach/utils/truncateFilename.d.ts.map +1 -0
  153. package/types/components/Steps/Steps.d.ts +23 -0
  154. package/types/components/Steps/Steps.d.ts.map +1 -0
  155. package/types/components/Steps/Steps.styles.d.ts +2 -0
  156. package/types/components/Steps/Steps.styles.d.ts.map +1 -0
  157. package/types/components/Steps/Steps.tokens.d.ts +74 -0
  158. package/types/components/Steps/Steps.tokens.d.ts.map +1 -0
  159. package/types/components/Steps/Steps.types.d.ts +55 -0
  160. package/types/components/Steps/Steps.types.d.ts.map +1 -0
  161. package/types/components/Steps/index.d.ts +4 -0
  162. package/types/components/Steps/index.d.ts.map +1 -0
  163. package/types/components/Steps/ui/StepItem/StepItem.d.ts +17 -0
  164. package/types/components/Steps/ui/StepItem/StepItem.d.ts.map +1 -0
  165. package/types/components/Steps/ui/StepItem/StepItem.styles.d.ts +20 -0
  166. package/types/components/Steps/ui/StepItem/StepItem.styles.d.ts.map +1 -0
  167. package/types/components/Steps/ui/StepItem/StepItem.types.d.ts +35 -0
  168. package/types/components/Steps/ui/StepItem/StepItem.types.d.ts.map +1 -0
  169. package/types/components/Steps/ui/StepItem/index.d.ts +3 -0
  170. package/types/components/Steps/ui/StepItem/index.d.ts.map +1 -0
  171. package/types/components/Steps/ui/index.d.ts +2 -0
  172. package/types/components/Steps/ui/index.d.ts.map +1 -0
  173. package/types/components/Steps/variations/_size/base.d.ts +2 -0
  174. package/types/components/Steps/variations/_size/base.d.ts.map +1 -0
  175. package/types/components/Steps/variations/_view/base.d.ts +2 -0
  176. package/types/components/Steps/variations/_view/base.d.ts.map +1 -0
  177. package/types/examples/plasma_b2c/components/Steps/Steps.config.d.ts +18 -0
  178. package/types/examples/plasma_b2c/components/Steps/Steps.config.d.ts.map +1 -0
  179. package/types/examples/plasma_b2c/components/Steps/Steps.d.ts +35 -0
  180. package/types/examples/plasma_b2c/components/Steps/Steps.d.ts.map +1 -0
  181. package/types/index.d.ts +1 -0
  182. package/types/index.d.ts.map +1 -1
  183. package/cjs/components/Attach/utils/addSeparator.js +0 -17
  184. package/cjs/components/Attach/utils/addSeparator.js.map +0 -1
  185. package/cjs/components/Attach/utils/index.js +0 -11
  186. package/cjs/components/Attach/utils/index.js.map +0 -1
  187. package/emotion/cjs/components/Attach/utils/addSeparator.js +0 -15
  188. package/emotion/es/components/Attach/utils/addSeparator.js +0 -9
  189. package/es/components/Attach/utils/addSeparator.js +0 -13
  190. package/es/components/Attach/utils/addSeparator.js.map +0 -1
  191. package/es/components/Attach/utils/index.js +0 -7
  192. package/es/components/Attach/utils/index.js.map +0 -1
  193. package/styled-components/cjs/components/Attach/utils/addSeparator.js +0 -15
  194. package/styled-components/es/components/Attach/utils/addSeparator.js +0 -9
  195. package/types/components/Attach/utils/addSeparator.d.ts +0 -2
  196. package/types/components/Attach/utils/addSeparator.d.ts.map +0 -1
@@ -0,0 +1,169 @@
1
+ import React, { useState, useEffect } from 'react';
2
+ import type { ComponentProps } from 'react';
3
+ import type { StoryObj, Meta } from '@storybook/react';
4
+ import { disableProps } from '@salutejs/plasma-sb-utils';
5
+
6
+ import { IconMic } from '../../../../components/_Icon';
7
+ import { argTypesFromConfig, WithTheme } from '../../../_helpers';
8
+ import { StepItemProps } from '../../../../components/Steps/ui';
9
+
10
+ import { Steps, mergedConfig } from './Steps';
11
+
12
+ const meta: Meta<typeof Steps> = {
13
+ title: 'plasma_b2c/Steps',
14
+ decorators: [WithTheme],
15
+ component: Steps,
16
+ argTypes: {
17
+ ...argTypesFromConfig(mergedConfig),
18
+ },
19
+ };
20
+
21
+ export default meta;
22
+
23
+ type Story = StoryObj<ComponentProps<typeof Steps>>;
24
+
25
+ const renderIndicator = ({ status, size }) => {
26
+ let iconSize;
27
+ if (size === 'xs' || size === 's') {
28
+ iconSize = 'xs';
29
+ } else if (status === 'active') {
30
+ iconSize = 's';
31
+ } else {
32
+ iconSize = 'xs';
33
+ }
34
+
35
+ return <IconMic color="inherit" size={iconSize} />;
36
+ };
37
+
38
+ const DefaultStory = (args) => {
39
+ const { maxWidth, title, content, size, indicatorType, quantity, hasContent, loading, disabled, simple } = args;
40
+
41
+ const innerTitle = title || 'Title';
42
+
43
+ const [items, setItems] = useState([]);
44
+
45
+ useEffect(() => {
46
+ const newItems = new Array(quantity).fill(null).map((_, index) => {
47
+ const indicator = index + 1;
48
+
49
+ if (simple) {
50
+ return {
51
+ indicator,
52
+ status: 'inactive',
53
+ };
54
+ }
55
+
56
+ return {
57
+ title: innerTitle,
58
+ content,
59
+ indicator,
60
+ status: 'inactive',
61
+ };
62
+ });
63
+
64
+ setItems(newItems);
65
+ }, [hasContent, loading, quantity, innerTitle, content, simple]);
66
+
67
+ useEffect(() => {
68
+ setItems((curItems) =>
69
+ curItems.map((item, index) => {
70
+ if (indicatorType === 'numbered') {
71
+ return { ...item, indicator: index + 1 };
72
+ }
73
+
74
+ if (indicatorType === 'bullet') {
75
+ return { ...item, indicator: undefined };
76
+ }
77
+
78
+ if (indicatorType === 'icon') {
79
+ return { ...item, indicator: renderIndicator };
80
+ }
81
+
82
+ return item;
83
+ }),
84
+ );
85
+ }, [indicatorType]);
86
+
87
+ useEffect(() => {
88
+ setItems((curItems) => curItems.map((item) => ({ ...item, disabled })));
89
+ }, [disabled]);
90
+
91
+ const onChange = (item: StepItemProps, index: number, prevIndex: number) => {
92
+ if (prevIndex !== undefined) {
93
+ items[prevIndex].status = 'completed';
94
+ }
95
+
96
+ items[index].status = 'active';
97
+
98
+ setItems([...items]);
99
+ };
100
+
101
+ return (
102
+ <div style={{ maxWidth }}>
103
+ <Steps size={size} items={items} onChange={onChange} hasLoader={loading} {...args} />
104
+ </div>
105
+ );
106
+ };
107
+
108
+ export const Default: Story = {
109
+ args: {
110
+ maxWidth: '100%',
111
+ quantity: 6,
112
+ size: 'm',
113
+ title: 'Title',
114
+ content: 'Content',
115
+ contentAlign: 'left',
116
+ indicatorType: 'numbered',
117
+ orientation: 'horizontal',
118
+ hasLine: true,
119
+ hasContent: 'all',
120
+ disabled: false,
121
+ loading: false,
122
+ simple: false,
123
+ },
124
+ argTypes: {
125
+ maxWidth: {
126
+ control: {
127
+ type: 'text',
128
+ },
129
+ },
130
+ size: {
131
+ options: ['xs', 's', 'm', 'l'],
132
+ control: {
133
+ type: 'inline-radio',
134
+ },
135
+ },
136
+ orientation: {
137
+ options: ['horizontal', 'vertical'],
138
+ control: {
139
+ type: 'inline-radio',
140
+ },
141
+ },
142
+ contentAlign: {
143
+ options: ['left', 'center'],
144
+ control: {
145
+ type: 'inline-radio',
146
+ },
147
+ if: { arg: 'orientation', eq: 'horizontal' },
148
+ },
149
+ indicatorType: {
150
+ options: ['numbered', 'bullet', 'icon'],
151
+ control: {
152
+ type: 'inline-radio',
153
+ },
154
+ },
155
+ hasContent: {
156
+ options: ['all', 'active', 'none'],
157
+ control: {
158
+ type: 'inline-radio',
159
+ },
160
+ },
161
+ simple: {
162
+ control: {
163
+ type: 'boolean',
164
+ },
165
+ },
166
+ ...disableProps(['view']),
167
+ },
168
+ render: (args) => <DefaultStory {...args} />,
169
+ };
@@ -553,6 +553,17 @@ Object.keys(_Slider).forEach(function (key) {
553
553
  }
554
554
  });
555
555
  });
556
+ var _Steps = /*#__PURE__*/require("./components/Steps");
557
+ Object.keys(_Steps).forEach(function (key) {
558
+ if (key === "default" || key === "__esModule") return;
559
+ if (key in exports && exports[key] === _Steps[key]) return;
560
+ Object.defineProperty(exports, key, {
561
+ enumerable: true,
562
+ get: function get() {
563
+ return _Steps[key];
564
+ }
565
+ });
566
+ });
556
567
  var _Range = /*#__PURE__*/require("./components/Range");
557
568
  Object.keys(_Range).forEach(function (key) {
558
569
  if (key === "default" || key === "__esModule") return;
@@ -17,7 +17,7 @@ import { base as sizeCSS } from './variations/_size/base';
17
17
  import { base as viewCSS } from './variations/_view/base';
18
18
  import { base, StyledHiddenInput, StyledHiddenInputHelper } from './Attach.styles';
19
19
  import { StyledCell } from './ui/Cell/Cell';
20
- import { extractExtension, getFileicon, addSeparator, separator } from './utils';
20
+ import { extractExtension, getFileicon, truncateFilename } from './utils';
21
21
  import { classes } from './Attach.tokens';
22
22
  import { AttachButton } from './components/AttachButton';
23
23
  import { StyledIconButtonCancel } from './ui/IconButton/IconButton.styles';
@@ -76,18 +76,15 @@ export var attachRoot = function attachRoot(Root) {
76
76
  cellLeft = _cellRef$current$getB.left;
77
77
  var leftDiff = cellLeft - parentLeft;
78
78
  var currentTextWidth = textWidth;
79
- if (currentTextWidth + emptyTextCellWidth.current + leftDiff <= parentWidth || currentTextWidth + emptyTextCellWidth.current < buttonWidth) {
80
- setTruncatedFilename(filename);
81
- return;
82
- }
83
- var currFilename = addSeparator(filename, separator);
84
- for (var i = currFilename.indexOf(separator) - 1; i > 0; i -= 1) {
79
+ var currFilename = filename;
80
+ for (var i = filename.length - 1; i > 0; i -= 1) {
85
81
  if (currentTextWidth + emptyTextCellWidth.current + leftDiff <= parentWidth) {
86
82
  break;
87
83
  }
88
- var left = currFilename.slice(0, i);
89
- var right = currFilename.slice(i + 1);
90
- var newFilename = "".concat(left).concat(right);
84
+ var newFilename = truncateFilename({
85
+ filename: inputHelperRef.current.textContent,
86
+ startNameTruncationIndex: i
87
+ });
91
88
  inputHelperRef.current.textContent = newFilename;
92
89
  currentTextWidth = inputHelperRef.current.offsetWidth;
93
90
  if (currentTextWidth + emptyTextCellWidth.current < buttonWidth) {
@@ -1,4 +1,3 @@
1
1
  export { extractExtension } from './extractExtension';
2
2
  export { getFileicon } from './getFileicon';
3
- export { addSeparator } from './addSeparator';
4
- export var separator = '...';
3
+ export { truncateFilename } from './truncateFilename';
@@ -0,0 +1,17 @@
1
+ export var truncateFilename = function truncateFilename(_ref) {
2
+ var filename = _ref.filename,
3
+ startNameTruncationIndex = _ref.startNameTruncationIndex,
4
+ _ref$separator = _ref.separator,
5
+ separator = _ref$separator === void 0 ? '...' : _ref$separator,
6
+ _ref$minNameLength = _ref.minNameLength,
7
+ minNameLength = _ref$minNameLength === void 0 ? 5 : _ref$minNameLength;
8
+ var strings = filename.split('.');
9
+ var extension = strings.length > 1 ? strings[strings.length - 1] : null;
10
+ var name = strings.length > 1 ? strings.slice(0, -1).join('.') : strings[0];
11
+ if (name.length <= minNameLength || startNameTruncationIndex >= name.length - 1) {
12
+ return filename;
13
+ }
14
+ var lastNameLetter = name[name.length - 1];
15
+ var truncatedName = "".concat(name.substring(0, startNameTruncationIndex)).concat(separator).concat(lastNameLetter);
16
+ return extension ? "".concat(truncatedName, ".").concat(extension) : truncatedName;
17
+ };
@@ -0,0 +1,121 @@
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 = ["size", "orientation", "contentAlign", "hasLine", "hasContent", "hasLoader", "items", "onChange", "current", "status"];
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 _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; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
6
+ 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); }
7
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
8
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
9
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
10
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
11
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
12
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
13
+ 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; }
14
+ 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; }
15
+ import React, { forwardRef, useState, useEffect } from 'react';
16
+ import cls from 'classnames';
17
+ import { classes } from './Steps.tokens';
18
+ import { base } from './Steps.styles';
19
+ import { StepItem } from './ui';
20
+ import { base as sizeCSS } from './variations/_size/base';
21
+ import { base as viewCSS } from './variations/_view/base';
22
+ export var stepsRoot = function stepsRoot(Root) {
23
+ return /*#__PURE__*/forwardRef(function (props, outerRef) {
24
+ var _props$size = props.size,
25
+ size = _props$size === void 0 ? 's' : _props$size,
26
+ _props$orientation = props.orientation,
27
+ orientation = _props$orientation === void 0 ? 'horizontal' : _props$orientation,
28
+ _props$contentAlign = props.contentAlign,
29
+ contentAlign = _props$contentAlign === void 0 ? 'left' : _props$contentAlign,
30
+ _props$hasLine = props.hasLine,
31
+ hasLine = _props$hasLine === void 0 ? true : _props$hasLine,
32
+ _props$hasContent = props.hasContent,
33
+ hasContent = _props$hasContent === void 0 ? 'all' : _props$hasContent,
34
+ hasLoader = props.hasLoader,
35
+ _props$items = props.items,
36
+ items = _props$items === void 0 ? [] : _props$items,
37
+ onChange = props.onChange,
38
+ current = props.current,
39
+ status = props.status,
40
+ rest = _objectWithoutProperties(props, _excluded);
41
+ var _useState = useState(),
42
+ _useState2 = _slicedToArray(_useState, 2),
43
+ prevIndex = _useState2[0],
44
+ setPrevIndex = _useState2[1];
45
+ var isUncontrolled = current !== undefined;
46
+ var hasIndicator = items.some(function (item) {
47
+ return item.indicator != null;
48
+ });
49
+ var isSimple = items.every(function (item) {
50
+ return !item.title && !item.content;
51
+ });
52
+ useEffect(function () {
53
+ return function () {
54
+ if (current !== undefined) {
55
+ setPrevIndex(current);
56
+ } else {
57
+ var index = items.findIndex(function (item) {
58
+ return item.status === 'active';
59
+ });
60
+ setPrevIndex(index !== -1 ? index : undefined);
61
+ }
62
+ };
63
+ }, [current, items]);
64
+ return /*#__PURE__*/React.createElement(Root, _extends({
65
+ size: size,
66
+ view: "default",
67
+ ref: outerRef,
68
+ className: cls(_defineProperty(_defineProperty(_defineProperty({}, classes.verticalOrientation, orientation === 'vertical'), classes.simple, isSimple), classes.hasIndicator, hasIndicator))
69
+ }, rest), items.map(function (item, index) {
70
+ var itemStatus = 'inactive';
71
+ if (isUncontrolled) {
72
+ if (current > index) {
73
+ itemStatus = 'completed';
74
+ } else if (current === index) {
75
+ itemStatus = status || 'active';
76
+ }
77
+ } else {
78
+ itemStatus = status || item.status || 'inactive';
79
+ }
80
+ if (item.disabled) {
81
+ itemStatus = 'inactive';
82
+ }
83
+ var isActive = itemStatus === 'active';
84
+ var content = item.content;
85
+ if (hasContent === 'active' && !isActive || hasContent === 'none') {
86
+ content = '';
87
+ }
88
+ return /*#__PURE__*/React.createElement(StepItem, {
89
+ key: index,
90
+ index: index,
91
+ title: item.title,
92
+ content: content,
93
+ indicator: item.indicator,
94
+ status: itemStatus,
95
+ size: size,
96
+ orientation: orientation,
97
+ contentAlign: orientation === 'horizontal' ? contentAlign : 'left',
98
+ hasLine: hasLine,
99
+ hasLoader: hasLoader && isActive,
100
+ onClick: onChange ? function () {
101
+ return onChange(item, index, prevIndex);
102
+ } : undefined,
103
+ items: items
104
+ });
105
+ }));
106
+ });
107
+ };
108
+ export var stepsConfig = {
109
+ name: 'Steps',
110
+ tag: 'div',
111
+ layout: stepsRoot,
112
+ base: base,
113
+ variations: {
114
+ size: sizeCSS,
115
+ view: viewCSS
116
+ },
117
+ defaults: {
118
+ view: 'default',
119
+ size: 's'
120
+ }
121
+ };
@@ -0,0 +1,304 @@
1
+ ---
2
+ id: steps
3
+ title: Steps
4
+ ---
5
+
6
+ # Steps
7
+ Шаги могут отображаться в нескольких размерах, в упрощенном виде и в горизонтальной/вертикальной ориентации
8
+
9
+ ```tsx live
10
+ import { ReactNode } from 'react';
11
+
12
+ export type StepStatus = 'active' | 'inactive' | 'completed';
13
+
14
+ export interface StepItemProps {
15
+ /**
16
+ * Заголовок
17
+ */
18
+ title?: string;
19
+ /**
20
+ * Контент, может быть как React компонентом, так и функцией
21
+ */
22
+ content?: string | ReactNode | ((status: StepStatus, index: number, items: StepItemProps[]) => ReactNode);
23
+ /**
24
+ * Индикатор шага, может быть как React компонентом, так и функцией
25
+ */
26
+ indicator?: number | string | ReactNode | ((status: StepStatus, item: StepItemProps) => ReactNode | null);
27
+ /**
28
+ * Статус шага: активный, инактивный, завершенный
29
+ * @description
30
+ * active - активный шаг
31
+ * inactive - не пройденный шаг
32
+ * completed - пройденный шаг
33
+ */
34
+ status?: StepStatus;
35
+ /**
36
+ * Отключенный шаг
37
+ * @default false
38
+ */
39
+ disabled?: boolean;
40
+ }
41
+
42
+ interface BaseSteps {
43
+ /**
44
+ * Ориентация компонента
45
+ * @default 'horizontal'
46
+ */
47
+ orientation?: 'horizontal' | 'vertical';
48
+ /**
49
+ * Выравнивание контента в шагах
50
+ * @default 'left'
51
+ */
52
+ contentAlign?: 'left' | 'center';
53
+ /**
54
+ * Включает разделительную линию
55
+ * @default true
56
+ */
57
+ hasLine?: boolean;
58
+ /**
59
+ * Индекс текущего шага, для uncontrolled компонента
60
+ */
61
+ current?: number;
62
+ /**
63
+ * Статус текущего шага, имеет приоритет над item.status
64
+ */
65
+ status?: StepStatus;
66
+ /**
67
+ * Обработчик изменения шага, делает индикаторы и заголовки шагов кликабельными
68
+ */
69
+ onChange?: (item: StepItemProps, index: number, prevIndex?: number) => void;
70
+ /**
71
+ * Массив шагов
72
+ */
73
+ items: StepItemProps[];
74
+ }
75
+
76
+ type IndicatorSizeSimple = 8 | 16;
77
+ type IndicatorSize = 24 | 36;
78
+
79
+ export type Steps = BaseSteps & {
80
+ /**
81
+ * Размер шага
82
+ */
83
+ size: 'xs' | 's';
84
+ indicatorSize: never;
85
+ } & {
86
+ /**
87
+ * Размер шага
88
+ */
89
+ size: 'm' | 'l';
90
+ /**
91
+ * Размер индикатора
92
+ */
93
+ indicatorSize: IndicatorSize | IndicatorSizeSimple;
94
+ };
95
+
96
+ ```
97
+
98
+ примеры использования https://codesandbox.io/p/devbox/crzql2?file=%2Fsrc%2FDemo.tsx%3A23%2C1
99
+
100
+ ```
101
+ import React, { useState } from 'react';
102
+ import { fullItems } from './App.data.tsx';
103
+ import { Steps } from './Steps/Steps.tsx';
104
+ import { StepItemProps, StepStatus } from './Steps/Steps.types';
105
+
106
+ const DemoContent: React.FC<{ onClick: () => void; status: string; index?: number; current?: number }> = ({
107
+ onClick,
108
+ status,
109
+ index,
110
+ current = 0,
111
+ children,
112
+ }) => {
113
+ return (
114
+ <>
115
+ <div>Content</div>
116
+ <button onClick={onClick} disabled={index !== (current || 0)}>
117
+ {children}
118
+ </button>
119
+ </>
120
+ );
121
+ };
122
+
123
+ export const DemoWithExternalControl = () => {
124
+ const items = [
125
+ {
126
+ title: 'Title',
127
+ indicator: '1',
128
+ content: 'Content',
129
+ },
130
+ {
131
+ title: 'Title',
132
+ indicator: '2',
133
+ content: 'Content',
134
+ },
135
+ {
136
+ title: 'Title',
137
+ indicator: '3',
138
+ content: 'Content',
139
+ },
140
+ {
141
+ title: 'Title',
142
+ indicator: '4',
143
+ content: 'Content',
144
+ },
145
+ ];
146
+
147
+ const [current, setCurrent] = useState(1);
148
+ const [status, setStatus] = useState('active');
149
+
150
+ const isLast = current === items.length - 1;
151
+
152
+ const onClick = () => {
153
+ if (isLast) {
154
+ setStatus('completed');
155
+ } else {
156
+ setCurrent(current + 1);
157
+ }
158
+ };
159
+
160
+ return (
161
+ <>
162
+ <Steps style={{ width: '1000px' }} current={current} status={status} items={items} />
163
+ <br />
164
+ <div>
165
+ External control:{' '}
166
+ <button onClick={onClick} style={{ width: '5rem' }}>
167
+ {isLast ? 'complete' : 'next'}
168
+ </button>
169
+ </div>
170
+ <hr />
171
+ </>
172
+ );
173
+ };
174
+
175
+ export const DemoWithInternalControls = () => {
176
+ const [current, setCurrent] = useState(undefined);
177
+ const [status, setStatus] = useState<StepStatus | undefined>();
178
+
179
+ const renderContent = (status, index, items) => {
180
+ const isFirst = index === 0 && current === undefined;
181
+ const isLast = index === items.length - 1;
182
+
183
+ const onNext = () => setCurrent((current) => (current === undefined ? 0 : current + 1));
184
+ const onComplete = () => {
185
+ setStatus('completed');
186
+ };
187
+
188
+ return (
189
+ <DemoContent onClick={isLast ? onComplete : onNext} index={index} status={status} current={current}>
190
+ {isFirst && 'go'}
191
+ {isLast && 'complete'}
192
+ {!isFirst && !isLast && 'next'}
193
+ </DemoContent>
194
+ );
195
+ };
196
+
197
+ return (
198
+ <Steps
199
+ current={current}
200
+ status={status}
201
+ items={[
202
+ {
203
+ title: 'Title',
204
+ indicator: '1',
205
+ content: renderContent,
206
+ },
207
+ {
208
+ title: 'Title',
209
+ indicator: '2',
210
+ content: renderContent,
211
+ },
212
+ {
213
+ title: 'Title',
214
+ indicator: '3',
215
+ content: renderContent,
216
+ },
217
+ {
218
+ title: 'Title',
219
+ indicator: '4',
220
+ content: renderContent,
221
+ },
222
+ ]}
223
+ />
224
+ );
225
+ };
226
+
227
+ export const DemoWithControlledUsage = () => {
228
+ const [exampleItems, setExampleItems] = useState<StepItemProps[]>(() =>
229
+ fullItems.map((item) => ({ ...item, status: 'inactive' }))
230
+ );
231
+
232
+ return (
233
+ <Steps
234
+ style={{ width: '1000px' }}
235
+ onChange={(item, index) => {
236
+ setExampleItems(
237
+ exampleItems.map((item, itemIndex) => {
238
+ if (index > itemIndex) {
239
+ return { ...item, status: 'completed' };
240
+ }
241
+
242
+ if (index === itemIndex) {
243
+ return { ...item, status: 'active' };
244
+ }
245
+
246
+ return { ...item, status: 'inactive' };
247
+ })
248
+ );
249
+ }}
250
+ items={exampleItems}
251
+ />
252
+ );
253
+ };
254
+
255
+ export const DemoWithControlledFreeUsage = () => {
256
+ const [items, setItems] = useState<StepItemProps[]>(() => fullItems.map((item) => ({ ...item, status: 'inactive' })));
257
+
258
+ return (
259
+ <Steps
260
+ style={{ width: '1000px' }}
261
+ onChange={(item, index, prevIndex) => {
262
+ console.log('!!! onChange', index, prevIndex);
263
+
264
+ const newItems = [...items];
265
+ if (prevIndex !== undefined) {
266
+ newItems[prevIndex].status = 'completed';
267
+ }
268
+ newItems[index].status = 'active';
269
+
270
+ setItems(newItems);
271
+ }}
272
+ items={items}
273
+ />
274
+ );
275
+ };
276
+
277
+ export const DemoControlledWithStatus = () => {
278
+ const [items, setItems] = useState<StepItemProps[]>(() => fullItems.map(({ status, ...item }) => ({ ...item })));
279
+ return (
280
+ <Steps
281
+ style={{ width: '1000px' }}
282
+ current={2}
283
+ status="active"
284
+ onClick={(item, index) => {
285
+ setItems(
286
+ items.map((item, itemIndex) => {
287
+ if (index > itemIndex) {
288
+ return { ...item, status: 'completed' };
289
+ }
290
+
291
+ if (index === itemIndex) {
292
+ return { ...item, status: 'active' };
293
+ }
294
+
295
+ return { ...item, status: 'inactive' };
296
+ })
297
+ );
298
+ }}
299
+ items={items}
300
+ />
301
+ );
302
+ };
303
+
304
+ ```
@@ -0,0 +1,3 @@
1
+ import { css } from 'styled-components';
2
+ import { classes, tokens } from './Steps.tokens';
3
+ export var base = /*#__PURE__*/css(["display:flex;flex-direction:row;&.", "{align-items:center;&.", "{height:var(", ");}&:not(.", "){height:var(", ");}&.", "{&.", "{width:var(", ");height:auto;}&:not(.", "){width:var(", ");height:auto;}}}&.", "{display:inline;flex-direction:column;justify-content:center;&.", "{display:inline-flex;}}"], classes.simple, classes.hasIndicator, tokens.activeIndicatorSize, classes.hasIndicator, tokens.activeBulletSize, classes.verticalOrientation, classes.hasIndicator, tokens.activeIndicatorSize, classes.hasIndicator, tokens.activeBulletSize, classes.verticalOrientation, classes.simple);