@onewelcome/react-lib-components 5.0.0 → 5.2.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/dist/cjs/Button/Button.module.cjs.js +1 -1
- package/dist/cjs/Button/IconButton.module.cjs.js +1 -1
- package/dist/cjs/DataGrid/DataGridActions/DataGridColumnsToggle.cjs.js +1 -1
- package/dist/cjs/DataGrid/DataGridActions/DataGridColumnsToggle.cjs.js.map +1 -1
- package/dist/cjs/Form/Radio/Radio.cjs.js.map +1 -1
- package/dist/cjs/Form/Select/Option.cjs.js +1 -1
- package/dist/cjs/Form/Select/Option.cjs.js.map +1 -1
- package/dist/cjs/Icon/Icon.module.cjs.js +1 -1
- package/dist/cjs/Link/Link.module.cjs.js +1 -1
- package/dist/cjs/Notifications/BaseModal/BaseModal.cjs.js +1 -1
- package/dist/cjs/Notifications/BaseModal/BaseModal.cjs.js.map +1 -1
- package/dist/cjs/Notifications/BaseModal/useRepeatFocus.cjs.js +2 -0
- package/dist/cjs/Notifications/BaseModal/useRepeatFocus.cjs.js.map +1 -0
- package/dist/cjs/Stepper/Step.cjs.js +1 -1
- package/dist/cjs/Stepper/Step.cjs.js.map +1 -1
- package/dist/cjs/Stepper/Step.module.cjs.js +1 -1
- package/dist/cjs/Stepper/Stepper.cjs.js +1 -1
- package/dist/cjs/Stepper/Stepper.cjs.js.map +1 -1
- package/dist/cjs/Stepper/Stepper.module.cjs.js +1 -1
- package/dist/cjs/Tooltip/Tooltip.cjs.js +1 -1
- package/dist/cjs/Tooltip/Tooltip.cjs.js.map +1 -1
- package/dist/cjs/Wizard/Wizard.cjs.js.map +1 -1
- package/dist/cjs/Wizard/WizardActions/WizardActions.cjs.js.map +1 -1
- package/dist/cjs/Wizard/WizardStateProvider.cjs.js.map +1 -1
- package/dist/cjs/Wizard/WizardSteps/WizardSteps.cjs.js.map +1 -1
- package/dist/cjs/src/components/Notifications/BaseModal/useRepeatFocus.d.ts +7 -0
- package/dist/cjs/src/components/Stepper/Step.d.ts +5 -3
- package/dist/cjs/src/components/Stepper/Stepper.d.ts +3 -1
- package/dist/cjs/src/components/Wizard/WizardActions/WizardActions.d.ts +3 -0
- package/dist/cjs/src/components/Wizard/WizardStateProvider.d.ts +3 -0
- package/dist/cjs/src/components/Wizard/WizardSteps/WizardSteps.d.ts +3 -0
- package/dist/cjs/src/index.d.ts +1 -0
- package/dist/esm/Button/Button.module.esm.js +1 -1
- package/dist/esm/Button/IconButton.module.esm.js +1 -1
- package/dist/esm/DataGrid/DataGridActions/DataGridColumnsToggle.esm.js +1 -1
- package/dist/esm/DataGrid/DataGridActions/DataGridColumnsToggle.esm.js.map +1 -1
- package/dist/esm/Form/Radio/Radio.esm.js.map +1 -1
- package/dist/esm/Form/Select/Option.esm.js +1 -1
- package/dist/esm/Form/Select/Option.esm.js.map +1 -1
- package/dist/esm/Icon/Icon.module.esm.js +1 -1
- package/dist/esm/Link/Link.module.esm.js +1 -1
- package/dist/esm/Notifications/BaseModal/BaseModal.esm.js +1 -1
- package/dist/esm/Notifications/BaseModal/BaseModal.esm.js.map +1 -1
- package/dist/esm/Notifications/BaseModal/useRepeatFocus.esm.js +2 -0
- package/dist/esm/Notifications/BaseModal/useRepeatFocus.esm.js.map +1 -0
- package/dist/esm/Stepper/Step.esm.js +1 -1
- package/dist/esm/Stepper/Step.esm.js.map +1 -1
- package/dist/esm/Stepper/Step.module.esm.js +1 -1
- package/dist/esm/Stepper/Stepper.esm.js +1 -1
- package/dist/esm/Stepper/Stepper.esm.js.map +1 -1
- package/dist/esm/Stepper/Stepper.module.esm.js +1 -1
- package/dist/esm/Tooltip/Tooltip.esm.js +1 -1
- package/dist/esm/Tooltip/Tooltip.esm.js.map +1 -1
- package/dist/esm/Wizard/Wizard.esm.js.map +1 -1
- package/dist/esm/Wizard/WizardActions/WizardActions.esm.js.map +1 -1
- package/dist/esm/Wizard/WizardStateProvider.esm.js.map +1 -1
- package/dist/esm/Wizard/WizardSteps/WizardSteps.esm.js.map +1 -1
- package/dist/esm/src/components/Notifications/BaseModal/useRepeatFocus.d.ts +7 -0
- package/dist/esm/src/components/Stepper/Step.d.ts +5 -3
- package/dist/esm/src/components/Stepper/Stepper.d.ts +3 -1
- package/dist/esm/src/components/Wizard/WizardActions/WizardActions.d.ts +3 -0
- package/dist/esm/src/components/Wizard/WizardStateProvider.d.ts +3 -0
- package/dist/esm/src/components/Wizard/WizardSteps/WizardSteps.d.ts +3 -0
- package/dist/esm/src/index.d.ts +1 -0
- package/package.json +2 -1
- package/src/components/DataGrid/DataGridActions/DataGridColumnsToggle.tsx +5 -1
- package/src/components/Form/Radio/Radio.tsx +3 -1
- package/src/components/Form/Select/Option.tsx +1 -1
- package/src/components/Notifications/BaseModal/BaseModal.test.tsx +36 -1
- package/src/components/Notifications/BaseModal/BaseModal.tsx +10 -3
- package/src/components/Notifications/BaseModal/useRepeatFocus.tsx +73 -0
- package/src/components/Stepper/Step.module.scss +129 -59
- package/src/components/Stepper/Step.tsx +57 -54
- package/src/components/Stepper/Stepper.module.scss +12 -8
- package/src/components/Stepper/Stepper.test.tsx +3 -3
- package/src/components/Stepper/Stepper.tsx +17 -7
- package/src/components/Tooltip/Tooltip.tsx +2 -2
- package/src/components/Wizard/Wizard.tsx +3 -0
- package/src/components/Wizard/WizardActions/WizardActions.tsx +3 -0
- package/src/components/Wizard/WizardStateProvider.tsx +3 -0
- package/src/components/Wizard/WizardSteps/WizardSteps.tsx +3 -0
- package/src/index.ts +1 -0
- package/src/mixins.module.scss +1 -0
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
@use "../../mixins.module.scss";
|
|
18
18
|
|
|
19
19
|
@mixin stepState($status: "waiting") {
|
|
20
|
-
& .step
|
|
20
|
+
& .step {
|
|
21
21
|
color: var(--stepper-default-text-color);
|
|
22
22
|
|
|
23
23
|
@if $status == "current" {
|
|
@@ -34,16 +34,14 @@
|
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
@if $status == "
|
|
39
|
-
|
|
40
|
-
} @else if $status == "done" {
|
|
41
|
-
border-color: var(--stepper-line-bold-color);
|
|
37
|
+
& .stepper-line {
|
|
38
|
+
@if $status == "done" {
|
|
39
|
+
background-color: var(--stepper-line-bold-color);
|
|
42
40
|
}
|
|
43
41
|
}
|
|
44
42
|
|
|
45
43
|
&:hover {
|
|
46
|
-
& .step
|
|
44
|
+
& .step {
|
|
47
45
|
@if $status == "current" {
|
|
48
46
|
border-color: var(--stepper-current-hover-color);
|
|
49
47
|
background-color: var(--stepper-current-hover-color);
|
|
@@ -61,7 +59,7 @@
|
|
|
61
59
|
}
|
|
62
60
|
|
|
63
61
|
&:active {
|
|
64
|
-
& .step
|
|
62
|
+
& .step {
|
|
65
63
|
@if $status == "current" {
|
|
66
64
|
border-color: var(--stepper-current-active-color);
|
|
67
65
|
background-color: var(--stepper-current-active-color);
|
|
@@ -78,10 +76,11 @@
|
|
|
78
76
|
}
|
|
79
77
|
}
|
|
80
78
|
|
|
81
|
-
|
|
79
|
+
&.disabled {
|
|
82
80
|
cursor: not-allowed;
|
|
83
81
|
|
|
84
|
-
& .step
|
|
82
|
+
& .step {
|
|
83
|
+
cursor: not-allowed;
|
|
85
84
|
@if $status == "current" {
|
|
86
85
|
border-color: var(--stepper-current-disabled-color);
|
|
87
86
|
background-color: var(--stepper-current-disabled-color);
|
|
@@ -97,7 +96,8 @@
|
|
|
97
96
|
}
|
|
98
97
|
}
|
|
99
98
|
|
|
100
|
-
& .
|
|
99
|
+
& .label {
|
|
100
|
+
cursor: not-allowed;
|
|
101
101
|
color: var(--stepper-label-disabled-color);
|
|
102
102
|
|
|
103
103
|
& .caption {
|
|
@@ -108,8 +108,8 @@
|
|
|
108
108
|
);
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
|
-
|
|
112
|
-
|
|
111
|
+
& .stepper-line {
|
|
112
|
+
background-color: if(
|
|
113
113
|
$status == "done",
|
|
114
114
|
var(--stepper-line-bold-disabled-color),
|
|
115
115
|
var(--stepper-line-disabled-color)
|
|
@@ -119,57 +119,110 @@
|
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
.step-wrapper {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
122
|
+
pointer-events: none; //turn off pointer-events beside .label and .step where we turn it on
|
|
123
|
+
display: grid;
|
|
124
|
+
gap: 0.5rem;
|
|
125
|
+
grid-template-columns: 1.875rem 1fr;
|
|
126
|
+
grid-template-rows: auto 1fr;
|
|
127
127
|
background-color: transparent;
|
|
128
128
|
border: 0;
|
|
129
129
|
padding: 0;
|
|
130
130
|
margin: 0;
|
|
131
|
-
cursor: pointer;
|
|
132
131
|
|
|
133
|
-
|
|
132
|
+
&.horizontal {
|
|
133
|
+
grid-template-columns: 1.875rem auto 1fr;
|
|
134
|
+
grid-template-rows: auto 1fr;
|
|
135
|
+
align-items: start;
|
|
136
|
+
width: 100%;
|
|
134
137
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
138
|
+
.stepper-line {
|
|
139
|
+
background-color: var(--stepper-line-color);
|
|
140
|
+
min-height: auto;
|
|
141
|
+
height: 2px;
|
|
142
|
+
width: 100%;
|
|
143
|
+
min-width: 1rem;
|
|
144
|
+
border-radius: 2px;
|
|
145
|
+
margin-top: 0.8125rem;
|
|
146
|
+
}
|
|
140
147
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
}
|
|
148
|
+
.label {
|
|
149
|
+
margin-top: 0.25rem;
|
|
150
|
+
}
|
|
145
151
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
152
|
+
&.text-bottom {
|
|
153
|
+
grid-template-columns: 5rem 1fr;
|
|
154
|
+
gap: 0;
|
|
155
|
+
|
|
156
|
+
.step {
|
|
157
|
+
justify-self: center;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
.label {
|
|
161
|
+
justify-self: center;
|
|
162
|
+
text-align: center;
|
|
163
|
+
grid-column-start: 1;
|
|
164
|
+
grid-column-end: 1;
|
|
165
|
+
grid-row-start: 2;
|
|
166
|
+
grid-row-end: 2;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
.stepper-line {
|
|
170
|
+
margin-right: -1.125rem;
|
|
171
|
+
margin-left: -1.125rem;
|
|
172
|
+
width: calc(100% + 2.25rem);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.label-inner-wrapper {
|
|
176
|
+
display: inline;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
&.last-step {
|
|
180
|
+
justify-content: center;
|
|
181
|
+
grid-template-columns: 5rem;
|
|
182
|
+
grid-template-rows: auto 1fr;
|
|
183
|
+
flex: 1 0 5rem;
|
|
184
|
+
display: grid;
|
|
153
185
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
186
|
+
.label {
|
|
187
|
+
width: auto;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
&.last-step {
|
|
193
|
+
display: flex;
|
|
194
|
+
width: max-content;
|
|
158
195
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
196
|
+
.label {
|
|
197
|
+
width: max-content;
|
|
198
|
+
}
|
|
162
199
|
}
|
|
163
200
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
border-bottom: none;
|
|
167
|
-
margin: 0.5rem 0 0.5rem 1.6875rem;
|
|
168
|
-
border-left: 2px solid var(--stepper-line-color);
|
|
169
|
-
min-height: 0.5rem;
|
|
170
|
-
height: 100%;
|
|
171
|
-
width: 100%;
|
|
201
|
+
.label-inner-wrapper {
|
|
202
|
+
display: flex;
|
|
172
203
|
}
|
|
204
|
+
|
|
205
|
+
.stepper-line-extender {
|
|
206
|
+
display: block;
|
|
207
|
+
flex: 1;
|
|
208
|
+
margin-left: 0.4375rem;
|
|
209
|
+
margin-right: -1rem;
|
|
210
|
+
margin-top: 0.5625rem;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
.stepper-line {
|
|
215
|
+
pointer-events: none;
|
|
216
|
+
justify-self: center;
|
|
217
|
+
background-color: var(--stepper-line-color);
|
|
218
|
+
min-height: 0.375rem; //on design pixes used in rounding does not count, so that's why it's not 4px but 6px
|
|
219
|
+
height: 100%;
|
|
220
|
+
width: 2px;
|
|
221
|
+
border-radius: 2px;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
&.vertical.has-caption .stepper-line {
|
|
225
|
+
min-height: 1.375rem; //on design pixes used in rounding does not count, so that's why it's not 20px but 22px
|
|
173
226
|
}
|
|
174
227
|
|
|
175
228
|
&.waiting {
|
|
@@ -179,7 +232,7 @@
|
|
|
179
232
|
&.current {
|
|
180
233
|
@include stepState($status: "current");
|
|
181
234
|
|
|
182
|
-
& .
|
|
235
|
+
& .label {
|
|
183
236
|
font-weight: 700;
|
|
184
237
|
& .caption {
|
|
185
238
|
font-weight: 400;
|
|
@@ -194,13 +247,15 @@
|
|
|
194
247
|
&.error {
|
|
195
248
|
@include stepState($status: "error");
|
|
196
249
|
|
|
197
|
-
& .
|
|
250
|
+
& .label .caption {
|
|
198
251
|
color: var(--stepper-caption-error-color);
|
|
199
252
|
}
|
|
200
253
|
}
|
|
201
254
|
}
|
|
202
255
|
|
|
203
256
|
.step {
|
|
257
|
+
pointer-events: visible;
|
|
258
|
+
cursor: pointer;
|
|
204
259
|
flex-shrink: 0;
|
|
205
260
|
box-sizing: border-box;
|
|
206
261
|
display: flex;
|
|
@@ -216,16 +271,31 @@
|
|
|
216
271
|
}
|
|
217
272
|
|
|
218
273
|
.label {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
274
|
+
pointer-events: visible;
|
|
275
|
+
cursor: pointer;
|
|
276
|
+
grid-column-start: 2;
|
|
277
|
+
grid-column-end: 2;
|
|
278
|
+
grid-row-start: 1;
|
|
279
|
+
grid-row-end: span 2;
|
|
280
|
+
align-self: start;
|
|
281
|
+
|
|
282
|
+
margin: 0.25rem 0 0;
|
|
283
|
+
padding: 0;
|
|
284
|
+
background-color: initial;
|
|
285
|
+
border: none;
|
|
286
|
+
text-align: left;
|
|
222
287
|
color: var(--stepper-label-color);
|
|
288
|
+
font-family: var(--font-family);
|
|
289
|
+
font-size: var(--font-size-form-label);
|
|
290
|
+
line-height: 1.25rem;
|
|
291
|
+
|
|
292
|
+
@include mixins.focusVisibleOutline($outlineOffset: "1px");
|
|
223
293
|
}
|
|
224
294
|
|
|
225
295
|
.caption {
|
|
226
|
-
|
|
227
|
-
top: 1.25rem;
|
|
228
|
-
left: 0;
|
|
296
|
+
display: block;
|
|
229
297
|
color: var(--stepper-caption-color);
|
|
298
|
+
font-family: var(--font-family);
|
|
230
299
|
font-size: 0.75rem;
|
|
300
|
+
line-height: 1rem;
|
|
231
301
|
}
|
|
@@ -14,19 +14,14 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import React, {
|
|
18
|
-
ComponentPropsWithRef,
|
|
19
|
-
ForwardRefRenderFunction,
|
|
20
|
-
useLayoutEffect,
|
|
21
|
-
useRef,
|
|
22
|
-
useState
|
|
23
|
-
} from "react";
|
|
17
|
+
import React, { CSSProperties, ComponentPropsWithRef, ForwardRefRenderFunction } from "react";
|
|
24
18
|
import { Icon, Icons } from "../Icon/Icon";
|
|
25
19
|
import classes from "./Step.module.scss";
|
|
20
|
+
import { gapBetweenStepsInRem } from "./Stepper";
|
|
26
21
|
|
|
27
22
|
export type StepStatus = "waiting" | "current" | "done" | "error";
|
|
28
23
|
|
|
29
|
-
export interface Props extends ComponentPropsWithRef<"
|
|
24
|
+
export interface Props extends Omit<ComponentPropsWithRef<"div">, "onClick"> {
|
|
30
25
|
status: StepStatus;
|
|
31
26
|
label: string;
|
|
32
27
|
caption?: string;
|
|
@@ -34,6 +29,8 @@ export interface Props extends ComponentPropsWithRef<"button"> {
|
|
|
34
29
|
lastStep?: boolean;
|
|
35
30
|
disabled?: boolean;
|
|
36
31
|
direction?: "horizontal" | "vertical";
|
|
32
|
+
textPosition?: "bottom" | "right";
|
|
33
|
+
onClick?: (event: React.MouseEvent<HTMLButtonElement | HTMLDivElement>) => void;
|
|
37
34
|
}
|
|
38
35
|
|
|
39
36
|
const getStepContent = (index: number, status: StepStatus) => {
|
|
@@ -49,63 +46,69 @@ const getStepContent = (index: number, status: StepStatus) => {
|
|
|
49
46
|
}
|
|
50
47
|
};
|
|
51
48
|
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
const getStepMaxWidth = (isHorizontal: boolean, lastStep: boolean, index: number) => {
|
|
50
|
+
if (isHorizontal && lastStep) {
|
|
51
|
+
const percentage = 100 / (index + 1);
|
|
52
|
+
const gapSize = index * gapBetweenStepsInRem;
|
|
53
|
+
return `calc(${percentage}% - ${gapSize}rem)`;
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export const StepComponent: ForwardRefRenderFunction<HTMLDivElement, Props> = (
|
|
58
|
+
{
|
|
59
|
+
label,
|
|
60
|
+
caption,
|
|
61
|
+
status,
|
|
62
|
+
index,
|
|
63
|
+
direction,
|
|
64
|
+
disabled,
|
|
65
|
+
lastStep,
|
|
66
|
+
onClick,
|
|
67
|
+
textPosition,
|
|
68
|
+
...rest
|
|
69
|
+
}: Props,
|
|
54
70
|
ref
|
|
55
71
|
) => {
|
|
56
72
|
const stepIndex = index ?? 0;
|
|
57
73
|
const additionalClasses = [classes[status]];
|
|
58
|
-
const
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
const captionRef = useRef<HTMLSpanElement>(null);
|
|
63
|
-
const labelRef = useRef<HTMLSpanElement>(null);
|
|
64
|
-
const stepContentRef = useRef<HTMLDivElement>(null);
|
|
74
|
+
const additionalStyles: CSSProperties = {};
|
|
75
|
+
const isHorizontal = direction === "horizontal";
|
|
76
|
+
const isTextBottom = textPosition === "bottom";
|
|
77
|
+
const hasCaption = !!caption;
|
|
65
78
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
setStepContentHeight(capionHeight + stepContentHeight);
|
|
72
|
-
}
|
|
79
|
+
additionalClasses.push(isHorizontal ? classes["horizontal"] : classes["vertical"]);
|
|
80
|
+
disabled && additionalClasses.push(classes["disabled"]);
|
|
81
|
+
isTextBottom && additionalClasses.push(classes["text-bottom"]);
|
|
82
|
+
lastStep && additionalClasses.push(classes["last-step"]);
|
|
83
|
+
hasCaption && additionalClasses.push(classes["has-caption"]);
|
|
73
84
|
|
|
74
|
-
|
|
75
|
-
const captionWidth = captionRef.current.getBoundingClientRect().width;
|
|
76
|
-
const labelWidth = labelRef.current.getBoundingClientRect().width;
|
|
77
|
-
setStepContentWidth(captionWidth > labelWidth ? captionWidth + 36 : labelWidth + 36);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}, []);
|
|
85
|
+
additionalStyles["maxWidth"] = getStepMaxWidth(isHorizontal, !!lastStep, index!);
|
|
81
86
|
|
|
82
87
|
return (
|
|
83
|
-
<
|
|
84
|
-
{
|
|
85
|
-
ref={ref}
|
|
86
|
-
disabled={disabled}
|
|
87
|
-
aria-current={status === "current" ? "step" : undefined}
|
|
88
|
+
<div
|
|
89
|
+
style={additionalStyles}
|
|
88
90
|
className={`${classes["step-wrapper"]} ${additionalClasses.join(" ")}`}
|
|
91
|
+
{...rest}
|
|
89
92
|
>
|
|
90
|
-
<div
|
|
91
|
-
|
|
92
|
-
height: lastStep && direction == "vertical" ? `${stepContentHeight}px` : "auto",
|
|
93
|
-
width: lastStep && direction == "horizontal" ? `${stepContentWidth}px` : "auto"
|
|
94
|
-
}}
|
|
95
|
-
>
|
|
96
|
-
<div ref={stepContentRef} className={classes["step-content"]}>
|
|
97
|
-
<div aria-hidden className={classes["step"]}>
|
|
98
|
-
{getStepContent(stepIndex, status)}
|
|
99
|
-
</div>
|
|
100
|
-
<span ref={labelRef} className={classes["label"]}>
|
|
101
|
-
{label}
|
|
102
|
-
<span ref={captionRef} className={classes["caption"]}>
|
|
103
|
-
{caption}
|
|
104
|
-
</span>
|
|
105
|
-
</span>
|
|
106
|
-
</div>
|
|
93
|
+
<div aria-hidden className={classes["step"]} onClick={onClick}>
|
|
94
|
+
{getStepContent(stepIndex, status)}
|
|
107
95
|
</div>
|
|
108
|
-
|
|
96
|
+
<button
|
|
97
|
+
aria-current={status === "current" ? "step" : undefined}
|
|
98
|
+
className={classes["label"]}
|
|
99
|
+
disabled={disabled}
|
|
100
|
+
onClick={onClick}
|
|
101
|
+
>
|
|
102
|
+
<span className={classes["label-inner-wrapper"]}>
|
|
103
|
+
{label}{" "}
|
|
104
|
+
{!lastStep && isHorizontal && !isTextBottom && (
|
|
105
|
+
<div className={`${classes["stepper-line"]} ${classes["stepper-line-extender"]}`}></div>
|
|
106
|
+
)}
|
|
107
|
+
</span>
|
|
108
|
+
<span className={classes["caption"]}>{caption}</span>
|
|
109
|
+
</button>
|
|
110
|
+
{!lastStep && <div className={classes["stepper-line"]}></div>}
|
|
111
|
+
</div>
|
|
109
112
|
);
|
|
110
113
|
};
|
|
111
114
|
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
.stepper {
|
|
2
|
-
width: 100%;
|
|
3
2
|
display: flex;
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
gap: 0.5rem;
|
|
4
|
+
justify-content: flex-start;
|
|
5
|
+
width: auto;
|
|
6
|
+
flex-direction: column;
|
|
6
7
|
|
|
7
|
-
&.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
&.horizontal {
|
|
9
|
+
justify-content: center;
|
|
10
|
+
flex-direction: row;
|
|
11
|
+
width: 100%;
|
|
12
|
+
|
|
13
|
+
&.text-bottom {
|
|
14
|
+
gap: 0;
|
|
15
|
+
}
|
|
12
16
|
}
|
|
13
17
|
}
|
|
@@ -62,13 +62,13 @@ describe("<Stepper/> should render", () => {
|
|
|
62
62
|
});
|
|
63
63
|
|
|
64
64
|
it("should render the horizontal stepper", () => {
|
|
65
|
-
const { StepperComponent
|
|
65
|
+
const { StepperComponent } = createStepper(params => ({
|
|
66
66
|
...params,
|
|
67
67
|
direction: "horizontal"
|
|
68
68
|
}));
|
|
69
69
|
|
|
70
70
|
expect(StepperComponent).toBeDefined();
|
|
71
|
-
expect(StepperComponent.classList.
|
|
71
|
+
expect(StepperComponent.classList).toContain("horizontal");
|
|
72
72
|
});
|
|
73
73
|
|
|
74
74
|
it("should render the vertical stepper", () => {
|
|
@@ -78,6 +78,6 @@ describe("<Stepper/> should render", () => {
|
|
|
78
78
|
}));
|
|
79
79
|
|
|
80
80
|
expect(StepperComponent).toBeDefined();
|
|
81
|
-
expect(StepperComponent.classList.
|
|
81
|
+
expect(StepperComponent.classList).not.toContain("horizontal");
|
|
82
82
|
});
|
|
83
83
|
});
|
|
@@ -21,16 +21,25 @@ import classes from "./Stepper.module.scss";
|
|
|
21
21
|
export interface Props extends ComponentPropsWithRef<"div"> {
|
|
22
22
|
steps: StepProps[];
|
|
23
23
|
direction: "horizontal" | "vertical";
|
|
24
|
+
textPosition?: "bottom" | "right";
|
|
24
25
|
}
|
|
25
26
|
|
|
26
|
-
export const
|
|
27
|
+
export const gapBetweenStepsInRem = 0.5;
|
|
28
|
+
|
|
29
|
+
export const Stepper = ({
|
|
30
|
+
steps,
|
|
31
|
+
direction = "horizontal",
|
|
32
|
+
textPosition,
|
|
33
|
+
className,
|
|
34
|
+
...rest
|
|
35
|
+
}: Props) => {
|
|
36
|
+
const additionalClasses = [];
|
|
37
|
+
direction === "horizontal" && additionalClasses.push(classes["horizontal"]);
|
|
38
|
+
textPosition === "bottom" && additionalClasses.push(classes["text-bottom"]);
|
|
39
|
+
className && additionalClasses.push(className);
|
|
40
|
+
|
|
27
41
|
return (
|
|
28
|
-
<div
|
|
29
|
-
{...rest}
|
|
30
|
-
className={`${classes["stepper"]} ${
|
|
31
|
-
direction === "horizontal" ? classes["horizontal"] : classes["vertical"]
|
|
32
|
-
}`}
|
|
33
|
-
>
|
|
42
|
+
<div {...rest} className={`${classes["stepper"]} ${additionalClasses.join(" ")}`}>
|
|
34
43
|
{steps.map((step, index) => (
|
|
35
44
|
<Step
|
|
36
45
|
{...step}
|
|
@@ -38,6 +47,7 @@ export const Stepper = ({ steps, direction = "horizontal", ...rest }: Props) =>
|
|
|
38
47
|
index={index}
|
|
39
48
|
direction={direction}
|
|
40
49
|
lastStep={index + 1 === steps.length}
|
|
50
|
+
textPosition={textPosition}
|
|
41
51
|
/>
|
|
42
52
|
))}
|
|
43
53
|
</div>
|
|
@@ -157,11 +157,11 @@ const TooltipComponent: ForwardRefRenderFunction<HTMLDivElement, Props> = (
|
|
|
157
157
|
useEffect(() => {
|
|
158
158
|
if (!visible) return;
|
|
159
159
|
|
|
160
|
-
|
|
160
|
+
const escapePressHandler = (event: KeyboardEvent) => {
|
|
161
161
|
if (event.key === "Escape") {
|
|
162
162
|
setVisible(false);
|
|
163
163
|
}
|
|
164
|
-
}
|
|
164
|
+
};
|
|
165
165
|
|
|
166
166
|
document.addEventListener("keyup", escapePressHandler);
|
|
167
167
|
|
|
@@ -47,6 +47,9 @@ const useStepChanging = (onStepChange: (stepNo: number) => void) => {
|
|
|
47
47
|
}, [currentStepNo]);
|
|
48
48
|
};
|
|
49
49
|
|
|
50
|
+
/**
|
|
51
|
+
* @deprecated
|
|
52
|
+
*/
|
|
50
53
|
const WizardContent = ({ steps, mode, onStepChange, children }: Props) => {
|
|
51
54
|
useSetWizardState(steps, mode);
|
|
52
55
|
useStepChanging(onStepChange);
|
|
@@ -61,6 +61,9 @@ const useNextStepNo = (mode: WizardMode, currentStepNo: number, steps: Step[]) =
|
|
|
61
61
|
const usePreviousStepNo = (mode: WizardMode, currentStepNo: number, steps: Step[]) =>
|
|
62
62
|
useMemo(calculatePrevStepNo(steps, currentStepNo), [mode, currentStepNo, steps]);
|
|
63
63
|
|
|
64
|
+
/**
|
|
65
|
+
* @deprecated
|
|
66
|
+
*/
|
|
64
67
|
export const WizardActions = ({ actions }: Props) => {
|
|
65
68
|
const {
|
|
66
69
|
state: { mode, steps, currentStepNo },
|
package/src/index.ts
CHANGED
|
@@ -54,6 +54,7 @@ export { StatusIndicator } from "./components/StatusIndicator/StatusIndicator";
|
|
|
54
54
|
export type { Props as StatusIndicatorProps } from "./components/StatusIndicator/StatusIndicator";
|
|
55
55
|
export { Stepper } from "./components/Stepper/Stepper";
|
|
56
56
|
export type { Props as StepperProps } from "./components/Stepper/Stepper";
|
|
57
|
+
export type { Props as StepProps } from "./components/Stepper/Step";
|
|
57
58
|
export { Pagination } from "./components/Pagination/Pagination";
|
|
58
59
|
export type {
|
|
59
60
|
Props as PaginationProps,
|