@snack-uikit/stepper 0.5.2 → 0.5.4
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.
- package/CHANGELOG.md +21 -0
- package/README.md +2 -2
- package/dist/components/Stepper/Stepper.d.ts +2 -2
- package/dist/components/Stepper/Stepper.js +1 -1
- package/dist/components/Stepper/styles.module.css +1 -0
- package/dist/helperComponents/Step/Step.d.ts +2 -1
- package/dist/helperComponents/Step/Step.js +2 -2
- package/package.json +4 -4
- package/src/components/Stepper/Stepper.tsx +8 -3
- package/src/components/Stepper/styles.module.scss +1 -0
- package/src/helperComponents/Step/Step.tsx +11 -8
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,27 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## 0.5.4 (2024-02-14)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **FF-0000:** optional props ([efa7f9c](https://github.com/cloud-ru-tech/snack-uikit/commit/efa7f9cb22ffc26a27ee1eb8ccbdf4b0facea628))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## 0.5.3 (2024-02-05)
|
|
18
|
+
|
|
19
|
+
### Only dependencies have been changed
|
|
20
|
+
* [@snack-uikit/icons@0.20.1](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/icons/CHANGELOG.md)
|
|
21
|
+
* [@snack-uikit/truncate-string@0.4.7](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/truncate-string/CHANGELOG.md)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
6
27
|
## 0.5.2 (2024-02-01)
|
|
7
28
|
|
|
8
29
|
### Only dependencies have been changed
|
package/README.md
CHANGED
|
@@ -48,12 +48,12 @@ return (
|
|
|
48
48
|
### Props
|
|
49
49
|
| name | type | default value | description |
|
|
50
50
|
|------|------|---------------|-------------|
|
|
51
|
-
| onCompleteChange* | `(isCompleted: boolean) => void` | - | Колбек изменения завершенности |
|
|
52
|
-
| onChangeCurrentStep* | `(newValue: number, prevValue: number) => void` | - | Колбек смены текущего степа |
|
|
53
51
|
| children* | `({stepper, ...api}) => ReactElement` | - | Render function. Принимает аргументы: `stepper` - JSX-элемент степпера, `goNext` - перейти на след. шаг, `goPrev` - перейти на пред. шаг, `resetValidation` - сбросить состояние валидации для текущего шага, `isCompleted` - окончен ли процесс, `currentStepIndex` - индекс текущего шага, `stepCount` - кол-во шагов. |
|
|
54
52
|
| steps* | `StepData[]` | - | Массив шагов |
|
|
55
53
|
| defaultCurrentStepIndex | `number` | - | Индекс текущего шага по-дефолту |
|
|
56
54
|
| className | `string` | - | CSS-класс |
|
|
55
|
+
| onChangeCurrentStep | `(newValue: number, prevValue: number) => void` | - | Колбек смены текущего степа |
|
|
56
|
+
| onCompleteChange | `(isCompleted: boolean) => void` | - | Колбек изменения завершенности |
|
|
57
57
|
|
|
58
58
|
|
|
59
59
|
[//]: DOCUMENTATION_SECTION_END
|
|
@@ -18,8 +18,8 @@ export type StepperProps = WithSupportProps<{
|
|
|
18
18
|
*/
|
|
19
19
|
children: (params: StepperState) => ReactElement;
|
|
20
20
|
/** Колбек смены текущего степа */
|
|
21
|
-
onChangeCurrentStep
|
|
21
|
+
onChangeCurrentStep?: (newValue: number, prevValue: number) => void;
|
|
22
22
|
/** Колбек изменения завершенности */
|
|
23
|
-
onCompleteChange
|
|
23
|
+
onCompleteChange?: (isCompleted: boolean) => void;
|
|
24
24
|
}>;
|
|
25
25
|
export declare function Stepper({ children, steps, className, onChangeCurrentStep, onCompleteChange, defaultCurrentStepIndex, ...props }: StepperProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -96,7 +96,7 @@ export function Stepper(_a) {
|
|
|
96
96
|
setCurrentStepState(STEP_STATE.Current);
|
|
97
97
|
}
|
|
98
98
|
}, [currentStepState]);
|
|
99
|
-
const stepper = (_jsx("div", Object.assign({ className: cn(styles.stepper, className) }, extractSupportProps(props), { children: stepsView.map((step, index) => (_jsx(Step, { step: step, "data-test-id": props['data-test-id'] }, step.title + index))) })));
|
|
99
|
+
const stepper = (_jsx("div", Object.assign({ className: cn(styles.stepper, className) }, extractSupportProps(props), { children: stepsView.map((step, index) => (_jsx(Step, { step: step, "data-test-id": props['data-test-id'], hideTailLine: index === steps.length - 1 }, step.title + index))) })));
|
|
100
100
|
const stepperApi = { goNext, goPrev, currentStepIndex, isCompleted, resetValidation, stepCount: steps.length };
|
|
101
101
|
return _jsx(StepperContext.Provider, { value: stepperApi, children: children(Object.assign({ stepper }, stepperApi)) });
|
|
102
102
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { WithSupportProps } from '@snack-uikit/utils';
|
|
2
2
|
import { StepViewData } from '../../types';
|
|
3
3
|
export type StepProps = WithSupportProps<{
|
|
4
|
+
hideTailLine?: boolean;
|
|
4
5
|
step: StepViewData;
|
|
5
6
|
className?: string;
|
|
6
7
|
}>;
|
|
7
|
-
export declare function Step({ step, className, 'data-test-id': testId, ...props }: StepProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export declare function Step({ step, className, 'data-test-id': testId, hideTailLine, ...props }: StepProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -21,6 +21,6 @@ import styles from './styles.module.css';
|
|
|
21
21
|
const getTailTestId = getTestIdBuilder('_element-tail');
|
|
22
22
|
const getStepTestId = getTestIdBuilder('_element-step');
|
|
23
23
|
export function Step(_a) {
|
|
24
|
-
var { step, className, 'data-test-id': testId } = _a, props = __rest(_a, ["step", "className", 'data-test-id']);
|
|
25
|
-
return (_jsxs("div", Object.assign({ className: cn(styles.step, className), "data-state": step.state }, extractSupportProps(props), { children: [_jsxs("div", { className: styles.track, children: [_jsx("button", { className: styles.statusContainer, onClick: step.onClick, disabled: !step.onClick, "data-test-id": getStepTestId(testId), "data-state": step.state, children: _jsx(Icon, Object.assign({}, step, { className: styles.icon })) }), _jsx("div", { className: styles.tail, "data-completed": step.state === STEP_STATE.Completed || undefined, "data-test-id": getTailTestId(testId), children: _jsx("div", { className: styles.tailLine }) })] }), _jsxs("div", { className: styles.content, children: [_jsx(Typography.SansBodyM, { className: styles.title, tag: 'div', children: _jsx(TruncateString, { text: step.title }) }), step.description && (_jsx(Typography.SansBodyS, { className: styles.description, tag: 'div', children: _jsx(TruncateString, { text: step.description, maxLines: 2 }) }))] })] })));
|
|
24
|
+
var { step, className, 'data-test-id': testId, hideTailLine } = _a, props = __rest(_a, ["step", "className", 'data-test-id', "hideTailLine"]);
|
|
25
|
+
return (_jsxs("div", Object.assign({ className: cn(styles.step, className), "data-state": step.state }, extractSupportProps(props), { children: [_jsxs("div", { className: styles.track, children: [_jsx("button", { className: styles.statusContainer, onClick: step.onClick, disabled: !step.onClick, "data-test-id": getStepTestId(testId), "data-state": step.state, children: _jsx(Icon, Object.assign({}, step, { className: styles.icon })) }), !hideTailLine && (_jsx("div", { className: styles.tail, "data-completed": step.state === STEP_STATE.Completed || undefined, "data-test-id": getTailTestId(testId), children: _jsx("div", { className: styles.tailLine }) }))] }), _jsxs("div", { className: styles.content, children: [_jsx(Typography.SansBodyM, { className: styles.title, tag: 'div', children: _jsx(TruncateString, { text: step.title }) }), step.description && (_jsx(Typography.SansBodyS, { className: styles.description, tag: 'div', children: _jsx(TruncateString, { text: step.description, maxLines: 2 }) }))] })] })));
|
|
26
26
|
}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
6
|
"title": "Stepper",
|
|
7
|
-
"version": "0.5.
|
|
7
|
+
"version": "0.5.4",
|
|
8
8
|
"sideEffects": [
|
|
9
9
|
"*.css",
|
|
10
10
|
"*.woff",
|
|
@@ -32,12 +32,12 @@
|
|
|
32
32
|
"license": "Apache-2.0",
|
|
33
33
|
"scripts": {},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@snack-uikit/icons": "0.20.
|
|
35
|
+
"@snack-uikit/icons": "0.20.1",
|
|
36
36
|
"@snack-uikit/loaders": "0.5.0",
|
|
37
|
-
"@snack-uikit/truncate-string": "0.4.
|
|
37
|
+
"@snack-uikit/truncate-string": "0.4.7",
|
|
38
38
|
"@snack-uikit/typography": "0.6.1",
|
|
39
39
|
"@snack-uikit/utils": "3.2.0",
|
|
40
40
|
"classnames": "2.3.2"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "529392c26fdb9c9b6e51a3f5c47419c726c57410"
|
|
43
43
|
}
|
|
@@ -27,9 +27,9 @@ export type StepperProps = WithSupportProps<{
|
|
|
27
27
|
*/
|
|
28
28
|
children: (params: StepperState) => ReactElement;
|
|
29
29
|
/** Колбек смены текущего степа */
|
|
30
|
-
onChangeCurrentStep
|
|
30
|
+
onChangeCurrentStep?: (newValue: number, prevValue: number) => void;
|
|
31
31
|
/** Колбек изменения завершенности */
|
|
32
|
-
onCompleteChange
|
|
32
|
+
onCompleteChange?: (isCompleted: boolean) => void;
|
|
33
33
|
}>;
|
|
34
34
|
|
|
35
35
|
export function Stepper({
|
|
@@ -149,7 +149,12 @@ export function Stepper({
|
|
|
149
149
|
const stepper = (
|
|
150
150
|
<div className={cn(styles.stepper, className)} {...extractSupportProps(props)}>
|
|
151
151
|
{stepsView.map((step, index) => (
|
|
152
|
-
<Step
|
|
152
|
+
<Step
|
|
153
|
+
key={step.title + index}
|
|
154
|
+
step={step}
|
|
155
|
+
data-test-id={props['data-test-id']}
|
|
156
|
+
hideTailLine={index === steps.length - 1}
|
|
157
|
+
/>
|
|
153
158
|
))}
|
|
154
159
|
</div>
|
|
155
160
|
);
|
|
@@ -11,6 +11,7 @@ import { Icon } from '../Icon';
|
|
|
11
11
|
import styles from './styles.module.scss';
|
|
12
12
|
|
|
13
13
|
export type StepProps = WithSupportProps<{
|
|
14
|
+
hideTailLine?: boolean;
|
|
14
15
|
step: StepViewData;
|
|
15
16
|
className?: string;
|
|
16
17
|
}>;
|
|
@@ -18,7 +19,7 @@ export type StepProps = WithSupportProps<{
|
|
|
18
19
|
const getTailTestId = getTestIdBuilder('_element-tail');
|
|
19
20
|
const getStepTestId = getTestIdBuilder('_element-step');
|
|
20
21
|
|
|
21
|
-
export function Step({ step, className, 'data-test-id': testId, ...props }: StepProps) {
|
|
22
|
+
export function Step({ step, className, 'data-test-id': testId, hideTailLine, ...props }: StepProps) {
|
|
22
23
|
return (
|
|
23
24
|
<div className={cn(styles.step, className)} data-state={step.state} {...extractSupportProps(props)}>
|
|
24
25
|
<div className={styles.track}>
|
|
@@ -32,13 +33,15 @@ export function Step({ step, className, 'data-test-id': testId, ...props }: Step
|
|
|
32
33
|
<Icon {...step} className={styles.icon} />
|
|
33
34
|
</button>
|
|
34
35
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
36
|
+
{!hideTailLine && (
|
|
37
|
+
<div
|
|
38
|
+
className={styles.tail}
|
|
39
|
+
data-completed={step.state === STEP_STATE.Completed || undefined}
|
|
40
|
+
data-test-id={getTailTestId(testId)}
|
|
41
|
+
>
|
|
42
|
+
<div className={styles.tailLine} />
|
|
43
|
+
</div>
|
|
44
|
+
)}
|
|
42
45
|
</div>
|
|
43
46
|
|
|
44
47
|
<div className={styles.content}>
|