@snack-uikit/stepper 0.4.3-preview-00fa1de0.0 → 0.5.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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,26 @@
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.0 (2023-12-28)
7
+
8
+
9
+ ### Features
10
+
11
+ * **FF-3960:** add step description, change step layout ([bbda81d](https://github.com/cloud-ru-tech/snack-uikit/commit/bbda81d731bcde8a00577ec63d089d120808a90a))
12
+
13
+
14
+
15
+
16
+
17
+ ## 0.4.3 (2023-12-25)
18
+
19
+ ### Only dependencies have been changed
20
+ * [@snack-uikit/truncate-string@0.4.3](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/truncate-string/CHANGELOG.md)
21
+
22
+
23
+
24
+
25
+
6
26
  ## 0.4.2 (2023-12-18)
7
27
 
8
28
  ### Only dependencies have been changed
@@ -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, all) => (_jsx(Step, { step: step, isLast: all.length - 1 === index, "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'] }, 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,7 @@
1
1
  .icon{
2
2
  width:var(--size-stepper-step-status, 32px);
3
3
  height:var(--size-stepper-step-status, 32px);
4
- border-radius:var(--radius-stepper-step-status, 16px);
4
+ border-radius:var(--radius-stepper-step-status, 24px);
5
5
  border-width:var(--border-width-stepper-step-status, 2px);
6
6
  overflow:hidden;
7
7
  display:inline-flex;
@@ -3,6 +3,5 @@ import { StepViewData } from '../../types';
3
3
  export type StepProps = WithSupportProps<{
4
4
  step: StepViewData;
5
5
  className?: string;
6
- isLast: boolean;
7
6
  }>;
8
- export declare function Step({ step, className, isLast, 'data-test-id': testId, ...props }: StepProps): import("react/jsx-runtime").JSX.Element;
7
+ export declare function Step({ step, className, 'data-test-id': testId, ...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, isLast, 'data-test-id': testId } = _a, props = __rest(_a, ["step", "className", "isLast", 'data-test-id']);
25
- return (_jsxs("div", Object.assign({ className: cn(styles.step, className), "data-state": step.state }, extractSupportProps(props), { children: [_jsxs("button", { className: styles.content, 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(Typography.SansBodyM, { className: styles.title, tag: 'div', children: _jsx(TruncateString, { text: step.title }) })] }), !isLast && (_jsx("div", { className: styles.tail, "data-completed": step.state === STEP_STATE.Completed || undefined, "data-test-id": getTailTestId(testId), children: _jsx("div", { className: styles.tailLine }) }))] })));
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 }) }))] })] })));
26
26
  }
@@ -1,13 +1,11 @@
1
1
  .tailLine{
2
2
  height:var(--size-stepper-step-track-line, 2px);
3
+ border-radius:var(--radius-stepper-step-track-line, 2px);
3
4
  flex-grow:1;
4
5
  background-color:var(--sys-neutral-decor-default, #dedede);
5
6
  }
6
7
 
7
8
  .tail{
8
- height:var(--size-stepper-step-track-container, 32px);
9
- padding-left:var(--space-stepper-step-track, 8px);
10
- padding-right:var(--space-stepper-step-track, 8px);
11
9
  display:flex;
12
10
  flex-grow:1;
13
11
  flex-shrink:1;
@@ -20,22 +18,36 @@
20
18
 
21
19
  .title{
22
20
  overflow:hidden;
21
+ color:var(--sys-neutral-text-main, #333333);
22
+ }
23
+
24
+ .description{
25
+ overflow:hidden;
26
+ color:var(--sys-neutral-text-light, #898989);
23
27
  }
24
28
 
25
29
  .step{
30
+ gap:var(--space-stepper-step-container-gap, 4px);
31
+ padding-right:var(--space-stepper-step-container-padding-right, 8px);
26
32
  display:flex;
27
33
  flex:1;
34
+ flex-direction:column;
28
35
  align-items:center;
29
36
  justify-content:center;
30
37
  min-width:0;
31
38
  }
32
- .step:last-child{
33
- max-width:-moz-max-content;
34
- max-width:max-content;
39
+
40
+ .track{
41
+ gap:var(--space-stepper-step-track-gap, 8px);
42
+ display:flex;
43
+ width:100%;
35
44
  }
36
45
 
37
- .content{
38
- gap:var(--space-stepper-step-content-gap, 8px);
46
+ .statusContainer{
47
+ width:var(--size-stepper-step-status, 32px);
48
+ height:var(--size-stepper-step-status, 32px);
49
+ border-radius:var(--radius-stepper-step-status, 24px);
50
+ border-width:var(--border-width-stepper-step-status, 2px);
39
51
  overflow:hidden;
40
52
  display:flex;
41
53
  flex-shrink:1;
@@ -46,20 +58,26 @@
46
58
  background-color:transparent;
47
59
  border:none;
48
60
  }
49
- .content:focus-visible{
61
+ .statusContainer:focus-visible{
50
62
  outline-width:var(--border-state-focus-s-border-width, 2px);
51
63
  outline-style:var(--border-state-focus-s-border-style, solid);
52
64
  outline-color:var(--border-state-focus-s-border-color, );
53
65
  outline-color:var(--sys-available-complementary, #131313);
54
66
  outline-offset:var(--spacing-state-focus-offset, 2px);
55
67
  }
56
- .content:not([disabled]){
68
+ .statusContainer:not([disabled]){
57
69
  cursor:pointer;
58
70
  }
59
- .content:not([disabled]):focus-visible, .content:not([disabled]):hover{
71
+ .statusContainer:not([disabled]):focus-visible, .statusContainer:not([disabled]):hover{
60
72
  color:var(--sys-neutral-text-light, #898989);
61
73
  }
62
74
 
63
75
  .icon{
64
76
  flex-shrink:0;
77
+ }
78
+
79
+ .content{
80
+ display:flex;
81
+ flex-direction:column;
82
+ width:100%;
65
83
  }
package/dist/types.d.ts CHANGED
@@ -4,6 +4,7 @@ export type StepState = ValueOf<typeof STEP_STATE>;
4
4
  export type StepValidationResult = ValueOf<typeof STEP_VALIDATION_RESULT>;
5
5
  export type StepData = {
6
6
  title: string;
7
+ description?: string;
7
8
  validation?(): Promise<StepValidationResult>;
8
9
  };
9
10
  export type StepViewData = StepData & {
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public"
5
5
  },
6
6
  "title": "Stepper",
7
- "version": "0.4.3-preview-00fa1de0.0",
7
+ "version": "0.5.0",
8
8
  "sideEffects": [
9
9
  "*.css",
10
10
  "*.woff",
@@ -34,10 +34,10 @@
34
34
  "dependencies": {
35
35
  "@snack-uikit/icons": "0.19.2",
36
36
  "@snack-uikit/loaders": "0.5.0",
37
- "@snack-uikit/truncate-string": "0.4.3-preview-00fa1de0.0",
38
- "@snack-uikit/typography": "0.6.0",
37
+ "@snack-uikit/truncate-string": "0.4.4",
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": "197debfa780364e989e8de7c27ebe15474429c57"
42
+ "gitHead": "57c597a3eebaf6528c0c61b6b27dd244753de1cf"
43
43
  }
@@ -148,13 +148,8 @@ export function Stepper({
148
148
 
149
149
  const stepper = (
150
150
  <div className={cn(styles.stepper, className)} {...extractSupportProps(props)}>
151
- {stepsView.map((step, index, all) => (
152
- <Step
153
- key={step.title + index}
154
- step={step}
155
- isLast={all.length - 1 === index}
156
- data-test-id={props['data-test-id']}
157
- />
151
+ {stepsView.map((step, index) => (
152
+ <Step key={step.title + index} step={step} data-test-id={props['data-test-id']} />
158
153
  ))}
159
154
  </div>
160
155
  );
@@ -13,28 +13,25 @@ import styles from './styles.module.scss';
13
13
  export type StepProps = WithSupportProps<{
14
14
  step: StepViewData;
15
15
  className?: string;
16
- isLast: boolean;
17
16
  }>;
18
17
 
19
18
  const getTailTestId = getTestIdBuilder('_element-tail');
20
19
  const getStepTestId = getTestIdBuilder('_element-step');
21
20
 
22
- export function Step({ step, className, isLast, 'data-test-id': testId, ...props }: StepProps) {
21
+ export function Step({ step, className, 'data-test-id': testId, ...props }: StepProps) {
23
22
  return (
24
23
  <div className={cn(styles.step, className)} data-state={step.state} {...extractSupportProps(props)}>
25
- <button
26
- className={styles.content}
27
- onClick={step.onClick}
28
- disabled={!step.onClick}
29
- data-test-id={getStepTestId(testId)}
30
- data-state={step.state}
31
- >
32
- <Icon {...step} className={styles.icon} />
33
- <Typography.SansBodyM className={styles.title} tag='div'>
34
- <TruncateString text={step.title} />
35
- </Typography.SansBodyM>
36
- </button>
37
- {!isLast && (
24
+ <div className={styles.track}>
25
+ <button
26
+ className={styles.statusContainer}
27
+ onClick={step.onClick}
28
+ disabled={!step.onClick}
29
+ data-test-id={getStepTestId(testId)}
30
+ data-state={step.state}
31
+ >
32
+ <Icon {...step} className={styles.icon} />
33
+ </button>
34
+
38
35
  <div
39
36
  className={styles.tail}
40
37
  data-completed={step.state === STEP_STATE.Completed || undefined}
@@ -42,7 +39,19 @@ export function Step({ step, className, isLast, 'data-test-id': testId, ...props
42
39
  >
43
40
  <div className={styles.tailLine} />
44
41
  </div>
45
- )}
42
+ </div>
43
+
44
+ <div className={styles.content}>
45
+ <Typography.SansBodyM className={styles.title} tag='div'>
46
+ <TruncateString text={step.title} />
47
+ </Typography.SansBodyM>
48
+
49
+ {step.description && (
50
+ <Typography.SansBodyS className={styles.description} tag='div'>
51
+ <TruncateString text={step.description} maxLines={2} />
52
+ </Typography.SansBodyS>
53
+ )}
54
+ </div>
46
55
  </div>
47
56
  );
48
57
  }
@@ -9,8 +9,6 @@
9
9
  }
10
10
 
11
11
  .tail {
12
- @include composite-var($stepper-step-track-container);
13
-
14
12
  display: flex;
15
13
  flex-grow: 1;
16
14
  flex-shrink: 1;
@@ -25,23 +23,35 @@
25
23
 
26
24
  .title {
27
25
  overflow: hidden;
26
+ color: $sys-neutral-text-main;
27
+ }
28
+
29
+ .description {
30
+ overflow: hidden;
31
+ color: $sys-neutral-text-light;
28
32
  }
29
33
 
30
34
  .step {
35
+ @include composite-var($stepper-step-container);
36
+
31
37
  display: flex;
32
38
  flex: 1;
39
+ flex-direction: column;
33
40
  align-items: center;
34
41
  justify-content: center;
35
42
 
36
43
  min-width: 0;
44
+ }
37
45
 
38
- &:last-child {
39
- max-width: max-content;
40
- }
46
+ .track {
47
+ @include composite-var($stepper-step-track);
48
+
49
+ display: flex;
50
+ width: 100%;
41
51
  }
42
52
 
43
- .content {
44
- @include composite-var($stepper-step-container-content);
53
+ .statusContainer {
54
+ @include composite-var($stepper-step-status-container);
45
55
 
46
56
  overflow: hidden;
47
57
  display: flex;
@@ -74,3 +84,9 @@
74
84
  .icon {
75
85
  flex-shrink: 0;
76
86
  }
87
+
88
+ .content {
89
+ display: flex;
90
+ flex-direction: column;
91
+ width: 100%;
92
+ }
package/src/types.ts CHANGED
@@ -8,6 +8,7 @@ export type StepValidationResult = ValueOf<typeof STEP_VALIDATION_RESULT>;
8
8
 
9
9
  export type StepData = {
10
10
  title: string;
11
+ description?: string;
11
12
  validation?(): Promise<StepValidationResult>;
12
13
  };
13
14