@pega/cosmos-react-core 9.0.0-build.19.6 → 9.0.0-build.19.7
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/lib/components/MultiStepForm/FormProgress.styles.d.ts +17 -5
- package/lib/components/MultiStepForm/FormProgress.styles.d.ts.map +1 -1
- package/lib/components/MultiStepForm/FormProgress.styles.js +174 -69
- package/lib/components/MultiStepForm/FormProgress.styles.js.map +1 -1
- package/lib/components/MultiStepForm/HorizontalFormProgress.d.ts +2 -1
- package/lib/components/MultiStepForm/HorizontalFormProgress.d.ts.map +1 -1
- package/lib/components/MultiStepForm/HorizontalFormProgress.js +42 -24
- package/lib/components/MultiStepForm/HorizontalFormProgress.js.map +1 -1
- package/lib/components/MultiStepForm/MultiStepForm.d.ts +1 -1
- package/lib/components/MultiStepForm/MultiStepForm.d.ts.map +1 -1
- package/lib/components/MultiStepForm/MultiStepForm.js +18 -6
- package/lib/components/MultiStepForm/MultiStepForm.js.map +1 -1
- package/lib/components/MultiStepForm/MultiStepForm.types.d.ts +20 -6
- package/lib/components/MultiStepForm/MultiStepForm.types.d.ts.map +1 -1
- package/lib/components/MultiStepForm/MultiStepForm.types.js.map +1 -1
- package/lib/components/MultiStepForm/VerticalFormProgress.d.ts +1 -1
- package/lib/components/MultiStepForm/VerticalFormProgress.d.ts.map +1 -1
- package/lib/components/MultiStepForm/VerticalFormProgress.js +7 -4
- package/lib/components/MultiStepForm/VerticalFormProgress.js.map +1 -1
- package/lib/components/MultiStepForm/useFormProgressOverflow.d.ts +6 -0
- package/lib/components/MultiStepForm/useFormProgressOverflow.d.ts.map +1 -0
- package/lib/components/MultiStepForm/useFormProgressOverflow.js +34 -0
- package/lib/components/MultiStepForm/useFormProgressOverflow.js.map +1 -0
- package/lib/hooks/useI18n.d.ts +2 -0
- package/lib/hooks/useI18n.d.ts.map +1 -1
- package/lib/i18n/default.d.ts +2 -0
- package/lib/i18n/default.d.ts.map +1 -1
- package/lib/i18n/default.js +2 -0
- package/lib/i18n/default.js.map +1 -1
- package/lib/i18n/i18n.d.ts +2 -0
- package/lib/i18n/i18n.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,18 +1,30 @@
|
|
|
1
1
|
import type { Step } from './MultiStepForm.types';
|
|
2
|
+
/** Min width of each step item including labels in ch units */
|
|
3
|
+
export declare const stepItemMinWidth = 15;
|
|
4
|
+
/** Min width of step marker without labels in ch units */
|
|
5
|
+
export declare const stepMarkerMinWidth = 3;
|
|
2
6
|
export declare const CurrentStepPopover: import("styled-components").StyledComponent<(<Modifiers extends string = string>(props: import("../Popover").PopoverProps<Modifiers> & import("../..").ForwardProps) => import("react").ReactElement | null), import("styled-components").DefaultTheme, {}, never>;
|
|
3
|
-
export declare const StyledBar: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {
|
|
7
|
+
export declare const StyledBar: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {
|
|
8
|
+
shifted?: boolean;
|
|
9
|
+
}, never>;
|
|
4
10
|
export declare const StyledFill: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
5
|
-
export declare const StyledFormProgress: import("styled-components").StyledComponent<import("../..").ForwardRefForwardPropsComponent<import("../Flex").FlexProps>, import("styled-components").DefaultTheme, {
|
|
6
|
-
|
|
7
|
-
|
|
11
|
+
export declare const StyledFormProgress: import("styled-components").StyledComponent<import("../..").ForwardRefForwardPropsComponent<import("../Flex").FlexProps>, import("styled-components").DefaultTheme, {
|
|
12
|
+
showStepNames?: boolean;
|
|
13
|
+
}, never>;
|
|
8
14
|
export declare const StepMarker: import("styled-components").StyledComponent<import("../..").ForwardRefForwardPropsComponent<import("../Button/BareButton").BareButtonProps>, import("styled-components").DefaultTheme, {
|
|
9
15
|
current: boolean;
|
|
10
16
|
depth: Step["depth"];
|
|
11
|
-
|
|
17
|
+
completed?: Step["completed"];
|
|
18
|
+
clickable?: boolean;
|
|
19
|
+
}, never>;
|
|
20
|
+
export declare const StyleHorizontalStepMarkers: import("styled-components").StyledComponent<"ol", import("styled-components").DefaultTheme, {
|
|
21
|
+
showStepNames?: boolean;
|
|
12
22
|
}, never>;
|
|
23
|
+
export declare const StyledVerticalStepMarkers: import("styled-components").StyledComponent<"ol", import("styled-components").DefaultTheme, {}, never>;
|
|
13
24
|
export declare const StyledBulletWrapper: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {
|
|
14
25
|
hasNext: boolean;
|
|
15
26
|
prior: boolean;
|
|
16
27
|
}, never>;
|
|
17
28
|
export declare const StyledStepText: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
29
|
+
export declare const StyledHorizontalStepText: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
18
30
|
//# sourceMappingURL=FormProgress.styles.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormProgress.styles.d.ts","sourceRoot":"","sources":["../../../src/components/MultiStepForm/FormProgress.styles.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FormProgress.styles.d.ts","sourceRoot":"","sources":["../../../src/components/MultiStepForm/FormProgress.styles.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAElD,+DAA+D;AAC/D,eAAO,MAAM,gBAAgB,KAAK,CAAC;AAEnC,0DAA0D;AAC1D,eAAO,MAAM,kBAAkB,IAAI,CAAC;AAEpC,eAAO,MAAM,kBAAkB,oQAU9B,CAAC;AAyBF,eAAO,MAAM,SAAS;cAA0B,OAAO;SAkBrD,CAAC;AAIH,eAAO,MAAM,UAAU,yGA2BrB,CAAC;AAIH,eAAO,MAAM,kBAAkB;oBAAkC,OAAO;SAmBtE,CAAC;AAIH,eAAO,MAAM,UAAU;aACZ,OAAO;WACT,IAAI,CAAC,OAAO,CAAC;gBACR,IAAI,CAAC,WAAW,CAAC;gBACjB,OAAO;SAqGnB,CAAC;AAIH,eAAO,MAAM,0BAA0B;oBAA+B,OAAO;SAsD5E,CAAC;AAIF,eAAO,MAAM,yBAAyB,wGAErC,CAAC;AAEF,eAAO,MAAM,mBAAmB;aACrB,OAAO;WACT,OAAO;SAuCd,CAAC;AAIH,eAAO,MAAM,cAAc,yGAKzB,CAAC;AAIH,eAAO,MAAM,wBAAwB,yGAUnC,CAAC"}
|
|
@@ -7,6 +7,11 @@ import { StyledText } from '../Text';
|
|
|
7
7
|
import { calculateFontSize } from '../../styles';
|
|
8
8
|
import { useDirection } from '../../hooks';
|
|
9
9
|
import Flex from '../Flex';
|
|
10
|
+
import { ellipsisOverflow } from '../../styles/mixins';
|
|
11
|
+
/** Min width of each step item including labels in ch units */
|
|
12
|
+
export const stepItemMinWidth = 15;
|
|
13
|
+
/** Min width of step marker without labels in ch units */
|
|
14
|
+
export const stepMarkerMinWidth = 3;
|
|
10
15
|
export const CurrentStepPopover = styled(Popover) `
|
|
11
16
|
max-width: 100%;
|
|
12
17
|
background-color: transparent;
|
|
@@ -15,17 +20,35 @@ export const CurrentStepPopover = styled(Popover) `
|
|
|
15
20
|
animation: none;
|
|
16
21
|
|
|
17
22
|
& > ${StyledText} {
|
|
18
|
-
|
|
19
|
-
white-space: nowrap;
|
|
20
|
-
text-overflow: ellipsis;
|
|
23
|
+
${ellipsisOverflow}
|
|
21
24
|
}
|
|
22
25
|
`;
|
|
23
|
-
|
|
24
|
-
const {
|
|
26
|
+
const calculateStepMarkerSizes = (fontSize, fontScale) => {
|
|
27
|
+
const { m: stepMarkerSize } = calculateFontSize(fontSize, fontScale);
|
|
28
|
+
return {
|
|
29
|
+
stepMarkerSize,
|
|
30
|
+
smallStepMarkerSize: `calc(${stepMarkerSize} / 1.5)`,
|
|
31
|
+
bigStepMarkerSize: `calc(${stepMarkerSize} * 1.5)`
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
const calculateBarTopPadding = (fontSize, fontScale, lineHeight) => {
|
|
35
|
+
const { bigStepMarkerSize } = calculateStepMarkerSizes(fontSize, fontScale);
|
|
36
|
+
return {
|
|
37
|
+
// assuming the step progress always contains current step marker which is the biggest one,
|
|
38
|
+
// the top padding of the bar should be half of the big step marker size minus line height of the bar
|
|
39
|
+
// to be vertically centered
|
|
40
|
+
stepBarTopPadding: `calc((${bigStepMarkerSize} / 2) - (${lineHeight} / 2))`
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
export const StyledBar = styled.div(({ shifted, theme }) => {
|
|
44
|
+
const { base: { 'font-size': fontSize, 'font-scale': fontScale }, components: { 'form-control': { 'border-color': borderColor } } } = theme;
|
|
45
|
+
const lineHeight = '0.125rem';
|
|
46
|
+
const { stepBarTopPadding } = calculateBarTopPadding(fontSize, fontScale, lineHeight);
|
|
25
47
|
return css `
|
|
26
48
|
position: absolute;
|
|
49
|
+
${shifted && `inset-block-start: ${stepBarTopPadding};`}
|
|
27
50
|
width: 100%;
|
|
28
|
-
height:
|
|
51
|
+
height: ${lineHeight};
|
|
29
52
|
background: ${borderColor};
|
|
30
53
|
`;
|
|
31
54
|
});
|
|
@@ -33,10 +56,14 @@ StyledBar.defaultProps = defaultThemeProp;
|
|
|
33
56
|
export const StyledFill = styled.div(({ theme }) => {
|
|
34
57
|
const { base: { animation: { speed: animationSpeed, timing: { ease: animationTiming } }, palette: { interactive } } } = theme;
|
|
35
58
|
const { ltr } = useDirection();
|
|
59
|
+
const markedLineThicknessFactor = 2;
|
|
36
60
|
return css `
|
|
37
61
|
position: absolute;
|
|
38
62
|
width: 100%;
|
|
39
|
-
height: 100
|
|
63
|
+
height: calc(100% * ${markedLineThicknessFactor});
|
|
64
|
+
|
|
65
|
+
/* top position based on line thickness factor to keep the fill centered */
|
|
66
|
+
top: calc(-50% * (${markedLineThicknessFactor} - 1));
|
|
40
67
|
background: ${interactive};
|
|
41
68
|
transition: all calc(2 * ${animationSpeed}) ${animationTiming};
|
|
42
69
|
transform: scaleX(var(--fillScale));
|
|
@@ -44,107 +71,174 @@ export const StyledFill = styled.div(({ theme }) => {
|
|
|
44
71
|
`;
|
|
45
72
|
});
|
|
46
73
|
StyledFill.defaultProps = defaultThemeProp;
|
|
47
|
-
export const StyledFormProgress = styled(Flex)(({ theme }) => {
|
|
48
|
-
const { base: { spacing, 'font-size': fontSize, 'font-scale': fontScale }, components: { text: { h4: { 'font-size':
|
|
74
|
+
export const StyledFormProgress = styled(Flex)(({ showStepNames, theme }) => {
|
|
75
|
+
const { base: { spacing, 'font-size': fontSize, 'font-scale': fontScale }, components: { text: { h4: { 'font-size': h3fontSize } } } } = theme;
|
|
49
76
|
const fontSizes = calculateFontSize(fontSize, fontScale);
|
|
50
77
|
return css `
|
|
51
78
|
position: relative;
|
|
52
|
-
|
|
79
|
+
${!showStepNames &&
|
|
80
|
+
`padding-block-end: calc(${spacing} + ${fontSizes[h3fontSize]} * 1.35);`}
|
|
53
81
|
`;
|
|
54
82
|
});
|
|
55
83
|
StyledFormProgress.defaultProps = defaultThemeProp;
|
|
56
|
-
export const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
84
|
+
export const StepMarker = styled(BareButton)(({ current, depth, completed, clickable, theme }) => {
|
|
85
|
+
const { base: { 'font-size': fontSize, 'font-scale': fontScale, animation: { speed: animationSpeed, timing: { ease: animationTiming } }, palette: { interactive, 'primary-background': primaryBackground }, shadow: { focus: focusShadow }, 'hit-area': { 'mouse-min': buttonSize, 'finger-min': touchButtonSize } }, components: { 'form-control': { 'border-color': borderColor, 'border-width': borderWidth } } } = theme;
|
|
86
|
+
const { stepMarkerSize, smallStepMarkerSize, bigStepMarkerSize } = calculateStepMarkerSizes(fontSize, fontScale);
|
|
87
|
+
// Determine the actual size for this marker based on its state
|
|
88
|
+
let markerSize = stepMarkerSize;
|
|
89
|
+
if (current) {
|
|
90
|
+
markerSize = bigStepMarkerSize;
|
|
62
91
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
box-shadow: ${theme.base.shadow['focus-group']};
|
|
92
|
+
else if (depth === 1) {
|
|
93
|
+
markerSize = smallStepMarkerSize;
|
|
66
94
|
}
|
|
67
|
-
`;
|
|
68
|
-
});
|
|
69
|
-
StyledStepMarkers.defaultProps = defaultThemeProp;
|
|
70
|
-
export const StyledVerticalStepMarkers = styled.ol `
|
|
71
|
-
list-style-type: none;
|
|
72
|
-
`;
|
|
73
|
-
export const StepMarker = styled(BareButton)(({ current, depth, prior, theme }) => {
|
|
74
|
-
const { base: { 'font-size': fontSize, 'font-scale': fontScale, animation: { speed: animationSpeed, timing: { ease: animationTiming } }, palette: { interactive, 'primary-background': primaryBackground }, shadow: { focus: focusShadow }, 'hit-area': { 'mouse-min': buttonSize, 'finger-min': touchButtonSize } }, components: { 'form-control': { 'border-color': borderColor } } } = theme;
|
|
75
|
-
const { m: stepMarkerSize } = calculateFontSize(fontSize, fontScale);
|
|
76
|
-
const smallStepMarkerSize = `calc(${stepMarkerSize} / 1.5)`;
|
|
77
95
|
return css `
|
|
78
96
|
position: relative;
|
|
79
97
|
z-index: 1;
|
|
80
|
-
${size(depth === 1 ? smallStepMarkerSize : stepMarkerSize)}
|
|
81
|
-
border-radius: 100%;
|
|
82
|
-
background: ${primaryBackground};
|
|
83
|
-
border: 0.0625rem solid ${borderColor};
|
|
84
|
-
transition: all calc(2 * ${animationSpeed}) ${animationTiming};
|
|
85
98
|
|
|
86
|
-
|
|
99
|
+
/* Fixed container size based on the biggest marker to prevent layout shifts */
|
|
100
|
+
${size(bigStepMarkerSize)}
|
|
101
|
+
display: flex;
|
|
102
|
+
align-items: center;
|
|
103
|
+
justify-content: center;
|
|
104
|
+
flex-shrink: 0;
|
|
105
|
+
|
|
106
|
+
${clickable
|
|
107
|
+
? css `
|
|
108
|
+
border-color: ${interactive};
|
|
109
|
+
`
|
|
110
|
+
: css `
|
|
111
|
+
cursor: default;
|
|
112
|
+
`}
|
|
113
|
+
|
|
114
|
+
&::before {
|
|
115
|
+
content: '';
|
|
116
|
+
${size(markerSize)}
|
|
117
|
+
position: absolute;
|
|
118
|
+
border-radius: 100%;
|
|
119
|
+
transition: all calc(2 * ${animationSpeed}) ${animationTiming};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
&:focus::before {
|
|
123
|
+
box-shadow: ${focusShadow};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
${!current &&
|
|
87
127
|
css `
|
|
88
|
-
|
|
89
|
-
|
|
128
|
+
border-color: transparent;
|
|
129
|
+
background: transparent;
|
|
130
|
+
|
|
131
|
+
&::before {
|
|
132
|
+
background: ${primaryBackground};
|
|
133
|
+
border: calc(2 * ${borderWidth}) solid ${clickable ? interactive : borderColor};
|
|
134
|
+
|
|
135
|
+
${completed &&
|
|
136
|
+
css `
|
|
137
|
+
background: ${interactive};
|
|
138
|
+
border-color: ${interactive};
|
|
139
|
+
`}
|
|
140
|
+
}
|
|
90
141
|
`}
|
|
91
|
-
|
|
142
|
+
|
|
143
|
+
${current &&
|
|
92
144
|
css `
|
|
93
|
-
|
|
145
|
+
&::before {
|
|
146
|
+
background: ${interactive};
|
|
147
|
+
}
|
|
94
148
|
`}
|
|
149
|
+
|
|
95
150
|
::after {
|
|
96
151
|
content: '';
|
|
97
152
|
position: absolute;
|
|
98
153
|
${size(buttonSize)}
|
|
99
|
-
inset-block-start: ${
|
|
100
|
-
|
|
101
|
-
: `calc((${buttonSize} - ${stepMarkerSize}) / -2) `};
|
|
102
|
-
inset-inline-start: ${depth === 1
|
|
103
|
-
? `calc((${buttonSize} - ${smallStepMarkerSize}) / -2) `
|
|
104
|
-
: `calc((${buttonSize} - ${stepMarkerSize}) / -2) `};
|
|
154
|
+
inset-block-start: ${`calc((${buttonSize} - ${bigStepMarkerSize}) / -2) `};
|
|
155
|
+
inset-inline-start: ${`calc((${buttonSize} - ${bigStepMarkerSize}) / -2) `};
|
|
105
156
|
|
|
106
157
|
@media (pointer: coarse) {
|
|
107
|
-
inset-block-start: ${
|
|
108
|
-
|
|
109
|
-
: `calc((${touchButtonSize} - ${stepMarkerSize}) / -2) `};
|
|
110
|
-
inset-inline-start: ${depth === 1
|
|
111
|
-
? `calc((${touchButtonSize} - ${smallStepMarkerSize}) / -2) `
|
|
112
|
-
: `calc((${touchButtonSize} - ${stepMarkerSize}) / -2) `};
|
|
158
|
+
inset-block-start: ${`calc((${touchButtonSize} - ${bigStepMarkerSize}) / -2) `};
|
|
159
|
+
inset-inline-start: ${`calc((${touchButtonSize} - ${bigStepMarkerSize}) / -2) `};
|
|
113
160
|
${size(touchButtonSize)}
|
|
114
161
|
}
|
|
115
162
|
}
|
|
163
|
+
`;
|
|
164
|
+
});
|
|
165
|
+
StepMarker.defaultProps = defaultThemeProp;
|
|
166
|
+
export const StyleHorizontalStepMarkers = styled.ol(({ showStepNames, theme }) => {
|
|
167
|
+
return css `
|
|
168
|
+
list-style-type: none;
|
|
169
|
+
justify-content: space-between;
|
|
116
170
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
171
|
+
li {
|
|
172
|
+
display: flex;
|
|
173
|
+
position: relative;
|
|
174
|
+
flex: 1 1 0;
|
|
120
175
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
176
|
+
/* min width changes based on whether step names are shown */
|
|
177
|
+
min-width: ${`${showStepNames ? stepItemMinWidth : stepMarkerMinWidth}ch`};
|
|
178
|
+
font-size: small;
|
|
179
|
+
margin-inline: ${theme.base.spacing};
|
|
180
|
+
flex-direction: column;
|
|
181
|
+
align-items: center;
|
|
182
|
+
text-align: center;
|
|
183
|
+
}
|
|
125
184
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
185
|
+
li:first-child,
|
|
186
|
+
li:last-child {
|
|
187
|
+
flex: 0.5 1 0;
|
|
188
|
+
/* stylelint-disable-next-line unit-allowed-list */
|
|
189
|
+
min-width: ${`${showStepNames ? stepItemMinWidth / 2 : stepMarkerMinWidth / 2}ch`};
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
li:first-child {
|
|
193
|
+
align-items: flex-start;
|
|
194
|
+
text-align: left;
|
|
195
|
+
margin-inline-start: 0;
|
|
196
|
+
padding-inline-start: 0;
|
|
197
|
+
|
|
198
|
+
${StepMarker}::before {
|
|
199
|
+
inset-inline-start: 0;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
li:last-child {
|
|
204
|
+
align-items: flex-end;
|
|
205
|
+
text-align: right;
|
|
206
|
+
margin-inline-end: 0;
|
|
207
|
+
padding-inline-end: 0;
|
|
208
|
+
|
|
209
|
+
${StepMarker}::before {
|
|
210
|
+
inset-inline-end: 0;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
&:has(:focus-visible) {
|
|
215
|
+
box-shadow: ${theme.base.shadow['focus-group']};
|
|
216
|
+
}
|
|
217
|
+
`;
|
|
130
218
|
});
|
|
131
|
-
|
|
219
|
+
StyleHorizontalStepMarkers.defaultProps = defaultThemeProp;
|
|
220
|
+
export const StyledVerticalStepMarkers = styled.ol `
|
|
221
|
+
list-style-type: none;
|
|
222
|
+
`;
|
|
132
223
|
export const StyledBulletWrapper = styled.div(({ theme, hasNext, prior }) => {
|
|
133
|
-
const { base: { animation: { speed: animationSpeed }, palette: { interactive } }, components: { 'form-control': { 'border-color': borderColor } } } = theme;
|
|
224
|
+
const { base: { 'font-size': fontSize, 'font-scale': fontScale, animation: { speed: animationSpeed }, palette: { interactive } }, components: { 'form-control': { 'border-color': borderColor } } } = theme;
|
|
225
|
+
const baseLineWidth = '0.125rem';
|
|
226
|
+
const lineWidth = prior ? `calc(2 * ${baseLineWidth})` : baseLineWidth;
|
|
227
|
+
const { bigStepMarkerSize } = calculateStepMarkerSizes(fontSize, fontScale);
|
|
134
228
|
return css `
|
|
135
229
|
position: relative;
|
|
136
|
-
text-align: center;
|
|
137
230
|
min-width: 2rem;
|
|
138
|
-
padding-block-start: calc(1.15 * ${theme.base.spacing});
|
|
139
231
|
|
|
140
232
|
${hasNext &&
|
|
141
233
|
css `
|
|
142
234
|
&::after {
|
|
143
235
|
content: '';
|
|
144
236
|
position: absolute;
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
237
|
+
|
|
238
|
+
/* Center the line horizontally and vertically relative to the step marker */
|
|
239
|
+
inset-block-start: calc(${bigStepMarkerSize});
|
|
240
|
+
inset-inline-start: calc(50% - (${lineWidth} / 2));
|
|
241
|
+
width: ${lineWidth};
|
|
148
242
|
height: 100%;
|
|
149
243
|
background: ${prior ? interactive : borderColor};
|
|
150
244
|
transition: background calc(2 * ${animationSpeed});
|
|
@@ -160,4 +254,15 @@ export const StyledStepText = styled.div(({ theme }) => {
|
|
|
160
254
|
`;
|
|
161
255
|
});
|
|
162
256
|
StyledStepText.defaultProps = defaultThemeProp;
|
|
257
|
+
export const StyledHorizontalStepText = styled.div(({ theme }) => {
|
|
258
|
+
const fontSize = calculateFontSize(theme.base['font-size'], theme.base['font-scale']);
|
|
259
|
+
return css `
|
|
260
|
+
padding-block: ${theme.base.spacing};
|
|
261
|
+
overflow-wrap: break-word;
|
|
262
|
+
min-width: inherit;
|
|
263
|
+
font-size: ${fontSize.xxs};
|
|
264
|
+
text-align: inherit;
|
|
265
|
+
`;
|
|
266
|
+
});
|
|
267
|
+
StyledHorizontalStepText.defaultProps = defaultThemeProp;
|
|
163
268
|
//# sourceMappingURL=FormProgress.styles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormProgress.styles.js","sourceRoot":"","sources":["../../../src/components/MultiStepForm/FormProgress.styles.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,UAAU,MAAM,sBAAsB,CAAC;AAC9C,OAAO,OAAO,MAAM,YAAY,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AW;;GAE5B,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,UAAU,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAE3C,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC,GAAG,CAG1C,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE;IAC/B,MAAM,EACJ,IAAI,EAAE,EACJ,SAAS,EAAE,EAAE,KAAK,EAAE,cAAc,EAAE,EACpC,OAAO,EAAE,EAAE,WAAW,EAAE,EACzB,EACD,UAAU,EAAE,EACV,cAAc,EAAE,EAAE,cAAc,EAAE,WAAW,EAAE,EAChD,EACF,GAAG,KAAK,CAAC;IACV,OAAO,GAAG,CAAA;;;;uCAI2B,KAAK,CAAC,IAAI,CAAC,OAAO;;MAEnD,OAAO;QACT,GAAG,CAAA;;;;;;;;sBAQe,KAAK,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW;0CACb,cAAc;;KAEnD;GACF,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,mBAAmB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAEpD,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IACrD,OAAO,GAAG,CAAA;qBACS,KAAK,CAAC,IAAI,CAAC,OAAO;;GAEpC,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,cAAc,CAAC,YAAY,GAAG,gBAAgB,CAAC","sourcesContent":["import styled, { css } from 'styled-components';\nimport { size } from 'polished';\n\nimport { defaultThemeProp } from '../../theme';\nimport BareButton from '../Button/BareButton';\nimport Popover from '../Popover';\nimport { StyledText } from '../Text';\nimport { calculateFontSize, type FontSize } from '../../styles';\nimport { useDirection } from '../../hooks';\nimport Flex from '../Flex';\n\nimport type { Step } from './MultiStepForm.types';\n\nexport const CurrentStepPopover = styled(Popover)`\n max-width: 100%;\n background-color: transparent;\n z-index: 0;\n box-shadow: none;\n animation: none;\n\n & > ${StyledText} {\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n }\n`;\n\nexport const StyledBar = styled.div(({ theme }) => {\n const {\n components: {\n 'form-control': { 'border-color': borderColor }\n }\n } = theme;\n\n return css`\n position: absolute;\n width: 100%;\n height: 0.0625rem;\n background: ${borderColor};\n `;\n});\n\nStyledBar.defaultProps = defaultThemeProp;\n\nexport const StyledFill = styled.div(({ theme }) => {\n const {\n base: {\n animation: {\n speed: animationSpeed,\n timing: { ease: animationTiming }\n },\n palette: { interactive }\n }\n } = theme;\n\n const { ltr } = useDirection();\n\n return css`\n position: absolute;\n width: 100%;\n height: 100%;\n background: ${interactive};\n transition: all calc(2 * ${animationSpeed}) ${animationTiming};\n transform: scaleX(var(--fillScale));\n transform-origin: ${ltr ? 0 : '100%'} 0;\n `;\n});\n\nStyledFill.defaultProps = defaultThemeProp;\n\nexport const StyledFormProgress = styled(Flex)(({ theme }) => {\n const {\n base: { spacing, 'font-size': fontSize, 'font-scale': fontScale },\n components: {\n text: {\n h4: { 'font-size': h4fontSize }\n }\n }\n } = theme;\n const fontSizes = calculateFontSize(fontSize, fontScale);\n\n return css`\n position: relative;\n padding-block-start: calc(${spacing} + ${fontSizes[h4fontSize as FontSize]} * 1.35);\n `;\n});\n\nStyledFormProgress.defaultProps = defaultThemeProp;\n\nexport const StyledStepMarkers = styled.ol(({ theme }) => {\n return css`\n list-style-type: none;\n\n li {\n display: flex;\n }\n\n &:has(:focus-visible) {\n box-shadow: ${theme.base.shadow['focus-group']};\n }\n `;\n});\n\nStyledStepMarkers.defaultProps = defaultThemeProp;\n\nexport const StyledVerticalStepMarkers = styled.ol`\n list-style-type: none;\n`;\n\nexport const StepMarker = styled(BareButton)<{\n current: boolean;\n depth: Step['depth'];\n prior: boolean;\n}>(({ current, depth, prior, theme }) => {\n const {\n base: {\n 'font-size': fontSize,\n 'font-scale': fontScale,\n animation: {\n speed: animationSpeed,\n timing: { ease: animationTiming }\n },\n palette: { interactive, 'primary-background': primaryBackground },\n shadow: { focus: focusShadow },\n 'hit-area': { 'mouse-min': buttonSize, 'finger-min': touchButtonSize }\n },\n components: {\n 'form-control': { 'border-color': borderColor }\n }\n } = theme;\n\n const { m: stepMarkerSize } = calculateFontSize(fontSize, fontScale);\n const smallStepMarkerSize = `calc(${stepMarkerSize} / 1.5)`;\n\n return css`\n position: relative;\n z-index: 1;\n ${size(depth === 1 ? smallStepMarkerSize : stepMarkerSize)}\n border-radius: 100%;\n background: ${primaryBackground};\n border: 0.0625rem solid ${borderColor};\n transition: all calc(2 * ${animationSpeed}) ${animationTiming};\n\n ${current &&\n css`\n background: ${interactive};\n border-color: ${interactive};\n `}\n ${prior &&\n css`\n border-color: ${interactive};\n `}\n ::after {\n content: '';\n position: absolute;\n ${size(buttonSize)}\n inset-block-start: ${depth === 1\n ? `calc((${buttonSize} - ${smallStepMarkerSize}) / -2) `\n : `calc((${buttonSize} - ${stepMarkerSize}) / -2) `};\n inset-inline-start: ${depth === 1\n ? `calc((${buttonSize} - ${smallStepMarkerSize}) / -2) `\n : `calc((${buttonSize} - ${stepMarkerSize}) / -2) `};\n\n @media (pointer: coarse) {\n inset-block-start: ${depth === 1\n ? `calc((${touchButtonSize} - ${smallStepMarkerSize}) / -2) `\n : `calc((${touchButtonSize} - ${stepMarkerSize}) / -2) `};\n inset-inline-start: ${depth === 1\n ? `calc((${touchButtonSize} - ${smallStepMarkerSize}) / -2) `\n : `calc((${touchButtonSize} - ${stepMarkerSize}) / -2) `};\n ${size(touchButtonSize)}\n }\n }\n\n &:not(:only-child):first-child::after {\n inset-inline-start: 0;\n }\n\n &:not(:only-child):last-child::after {\n inset-inline-start: unset;\n inset-inline-end: 0;\n }\n\n :focus {\n box-shadow: ${focusShadow};\n }\n `;\n});\n\nStepMarker.defaultProps = defaultThemeProp;\n\nexport const StyledBulletWrapper = styled.div<{\n hasNext: boolean;\n prior: boolean;\n}>(({ theme, hasNext, prior }) => {\n const {\n base: {\n animation: { speed: animationSpeed },\n palette: { interactive }\n },\n components: {\n 'form-control': { 'border-color': borderColor }\n }\n } = theme;\n return css`\n position: relative;\n text-align: center;\n min-width: 2rem;\n padding-block-start: calc(1.15 * ${theme.base.spacing});\n\n ${hasNext &&\n css`\n &::after {\n content: '';\n position: absolute;\n margin-block-start: 0.85rem;\n inset-inline-start: calc(50% - 0.03125rem);\n width: 0.0625rem;\n height: 100%;\n background: ${prior ? interactive : borderColor};\n transition: background calc(2 * ${animationSpeed});\n }\n `}\n `;\n});\n\nStyledBulletWrapper.defaultProps = defaultThemeProp;\n\nexport const StyledStepText = styled.div(({ theme }) => {\n return css`\n padding-block: ${theme.base.spacing};\n overflow-wrap: break-word;\n `;\n});\n\nStyledStepText.defaultProps = defaultThemeProp;\n"]}
|
|
1
|
+
{"version":3,"file":"FormProgress.styles.js","sourceRoot":"","sources":["../../../src/components/MultiStepForm/FormProgress.styles.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,UAAU,MAAM,sBAAsB,CAAC;AAC9C,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,iBAAiB,EAAiB,MAAM,cAAc,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAIvD,+DAA+D;AAC/D,MAAM,CAAC,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAEnC,0DAA0D;AAC1D,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAEpC,MAAM,CAAC,MAAM,kBAAkB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AAC,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;IAEtF,OAAO,GAAG,CAAA;qBACS,KAAK,CAAC,IAAI,CAAC,OAAO;;;iBAGtB,QAAQ,CAAC,GAAG;;GAE1B,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,wBAAwB,CAAC,YAAY,GAAG,gBAAgB,CAAC","sourcesContent":["import styled, { css } from 'styled-components';\nimport { size } from 'polished';\n\nimport { defaultThemeProp } from '../../theme';\nimport BareButton from '../Button/BareButton';\nimport Popover from '../Popover';\nimport { StyledText } from '../Text';\nimport { calculateFontSize, type FontSize } from '../../styles';\nimport { useDirection } from '../../hooks';\nimport Flex from '../Flex';\nimport { ellipsisOverflow } from '../../styles/mixins';\n\nimport type { Step } from './MultiStepForm.types';\n\n/** Min width of each step item including labels in ch units */\nexport const stepItemMinWidth = 15;\n\n/** Min width of step marker without labels in ch units */\nexport const stepMarkerMinWidth = 3;\n\nexport const CurrentStepPopover = styled(Popover)`\n max-width: 100%;\n background-color: transparent;\n z-index: 0;\n box-shadow: none;\n animation: none;\n\n & > ${StyledText} {\n ${ellipsisOverflow}\n }\n`;\n\nconst calculateStepMarkerSizes = (fontSize: string, fontScale: string | number) => {\n const { m: stepMarkerSize } = calculateFontSize(fontSize, fontScale);\n return {\n stepMarkerSize,\n smallStepMarkerSize: `calc(${stepMarkerSize} / 1.5)`,\n bigStepMarkerSize: `calc(${stepMarkerSize} * 1.5)`\n };\n};\n\nconst calculateBarTopPadding = (\n fontSize: string,\n fontScale: string | number,\n lineHeight: string\n) => {\n const { bigStepMarkerSize } = calculateStepMarkerSizes(fontSize, fontScale);\n return {\n // assuming the step progress always contains current step marker which is the biggest one,\n // the top padding of the bar should be half of the big step marker size minus line height of the bar\n // to be vertically centered\n stepBarTopPadding: `calc((${bigStepMarkerSize} / 2) - (${lineHeight} / 2))`\n };\n};\n\nexport const StyledBar = styled.div<{ shifted?: boolean }>(({ shifted, theme }) => {\n const {\n base: { 'font-size': fontSize, 'font-scale': fontScale },\n components: {\n 'form-control': { 'border-color': borderColor }\n }\n } = theme;\n\n const lineHeight = '0.125rem';\n const { stepBarTopPadding } = calculateBarTopPadding(fontSize, fontScale, lineHeight);\n\n return css`\n position: absolute;\n ${shifted && `inset-block-start: ${stepBarTopPadding};`}\n width: 100%;\n height: ${lineHeight};\n background: ${borderColor};\n `;\n});\n\nStyledBar.defaultProps = defaultThemeProp;\n\nexport const StyledFill = styled.div(({ theme }) => {\n const {\n base: {\n animation: {\n speed: animationSpeed,\n timing: { ease: animationTiming }\n },\n palette: { interactive }\n }\n } = theme;\n\n const { ltr } = useDirection();\n\n const markedLineThicknessFactor = 2;\n\n return css`\n position: absolute;\n width: 100%;\n height: calc(100% * ${markedLineThicknessFactor});\n\n /* top position based on line thickness factor to keep the fill centered */\n top: calc(-50% * (${markedLineThicknessFactor} - 1));\n background: ${interactive};\n transition: all calc(2 * ${animationSpeed}) ${animationTiming};\n transform: scaleX(var(--fillScale));\n transform-origin: ${ltr ? 0 : '100%'} 0;\n `;\n});\n\nStyledFill.defaultProps = defaultThemeProp;\n\nexport const StyledFormProgress = styled(Flex)<{ showStepNames?: boolean }>(({\n showStepNames,\n theme\n}) => {\n const {\n base: { spacing, 'font-size': fontSize, 'font-scale': fontScale },\n components: {\n text: {\n h4: { 'font-size': h3fontSize }\n }\n }\n } = theme;\n const fontSizes = calculateFontSize(fontSize, fontScale);\n\n return css`\n position: relative;\n ${!showStepNames &&\n `padding-block-end: calc(${spacing} + ${fontSizes[h3fontSize as FontSize]} * 1.35);`}\n `;\n});\n\nStyledFormProgress.defaultProps = defaultThemeProp;\n\nexport const StepMarker = styled(BareButton)<{\n current: boolean;\n depth: Step['depth'];\n completed?: Step['completed'];\n clickable?: boolean;\n}>(({ current, depth, completed, clickable, theme }) => {\n const {\n base: {\n 'font-size': fontSize,\n 'font-scale': fontScale,\n animation: {\n speed: animationSpeed,\n timing: { ease: animationTiming }\n },\n palette: { interactive, 'primary-background': primaryBackground },\n shadow: { focus: focusShadow },\n 'hit-area': { 'mouse-min': buttonSize, 'finger-min': touchButtonSize }\n },\n components: {\n 'form-control': { 'border-color': borderColor, 'border-width': borderWidth }\n }\n } = theme;\n\n const { stepMarkerSize, smallStepMarkerSize, bigStepMarkerSize } = calculateStepMarkerSizes(\n fontSize,\n fontScale\n );\n\n // Determine the actual size for this marker based on its state\n let markerSize = stepMarkerSize;\n if (current) {\n markerSize = bigStepMarkerSize;\n } else if (depth === 1) {\n markerSize = smallStepMarkerSize;\n }\n\n return css`\n position: relative;\n z-index: 1;\n\n /* Fixed container size based on the biggest marker to prevent layout shifts */\n ${size(bigStepMarkerSize)}\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n\n ${clickable\n ? css`\n border-color: ${interactive};\n `\n : css`\n cursor: default;\n `}\n\n &::before {\n content: '';\n ${size(markerSize)}\n position: absolute;\n border-radius: 100%;\n transition: all calc(2 * ${animationSpeed}) ${animationTiming};\n }\n\n &:focus::before {\n box-shadow: ${focusShadow};\n }\n\n ${!current &&\n css`\n border-color: transparent;\n background: transparent;\n\n &::before {\n background: ${primaryBackground};\n border: calc(2 * ${borderWidth}) solid ${clickable ? interactive : borderColor};\n\n ${completed &&\n css`\n background: ${interactive};\n border-color: ${interactive};\n `}\n }\n `}\n\n ${current &&\n css`\n &::before {\n background: ${interactive};\n }\n `}\n\n ::after {\n content: '';\n position: absolute;\n ${size(buttonSize)}\n inset-block-start: ${`calc((${buttonSize} - ${bigStepMarkerSize}) / -2) `};\n inset-inline-start: ${`calc((${buttonSize} - ${bigStepMarkerSize}) / -2) `};\n\n @media (pointer: coarse) {\n inset-block-start: ${`calc((${touchButtonSize} - ${bigStepMarkerSize}) / -2) `};\n inset-inline-start: ${`calc((${touchButtonSize} - ${bigStepMarkerSize}) / -2) `};\n ${size(touchButtonSize)}\n }\n }\n `;\n});\n\nStepMarker.defaultProps = defaultThemeProp;\n\nexport const StyleHorizontalStepMarkers = styled.ol<{ showStepNames?: boolean }>(\n ({ showStepNames, theme }) => {\n return css`\n list-style-type: none;\n justify-content: space-between;\n\n li {\n display: flex;\n position: relative;\n flex: 1 1 0;\n\n /* min width changes based on whether step names are shown */\n min-width: ${`${showStepNames ? stepItemMinWidth : stepMarkerMinWidth}ch`};\n font-size: small;\n margin-inline: ${theme.base.spacing};\n flex-direction: column;\n align-items: center;\n text-align: center;\n }\n\n li:first-child,\n li:last-child {\n flex: 0.5 1 0;\n /* stylelint-disable-next-line unit-allowed-list */\n min-width: ${`${showStepNames ? stepItemMinWidth / 2 : stepMarkerMinWidth / 2}ch`};\n }\n\n li:first-child {\n align-items: flex-start;\n text-align: left;\n margin-inline-start: 0;\n padding-inline-start: 0;\n\n ${StepMarker}::before {\n inset-inline-start: 0;\n }\n }\n\n li:last-child {\n align-items: flex-end;\n text-align: right;\n margin-inline-end: 0;\n padding-inline-end: 0;\n\n ${StepMarker}::before {\n inset-inline-end: 0;\n }\n }\n\n &:has(:focus-visible) {\n box-shadow: ${theme.base.shadow['focus-group']};\n }\n `;\n }\n);\n\nStyleHorizontalStepMarkers.defaultProps = defaultThemeProp;\n\nexport const StyledVerticalStepMarkers = styled.ol`\n list-style-type: none;\n`;\n\nexport const StyledBulletWrapper = styled.div<{\n hasNext: boolean;\n prior: boolean;\n}>(({ theme, hasNext, prior }) => {\n const {\n base: {\n 'font-size': fontSize,\n 'font-scale': fontScale,\n animation: { speed: animationSpeed },\n palette: { interactive }\n },\n components: {\n 'form-control': { 'border-color': borderColor }\n }\n } = theme;\n\n const baseLineWidth = '0.125rem';\n const lineWidth = prior ? `calc(2 * ${baseLineWidth})` : baseLineWidth;\n\n const { bigStepMarkerSize } = calculateStepMarkerSizes(fontSize, fontScale);\n\n return css`\n position: relative;\n min-width: 2rem;\n\n ${hasNext &&\n css`\n &::after {\n content: '';\n position: absolute;\n\n /* Center the line horizontally and vertically relative to the step marker */\n inset-block-start: calc(${bigStepMarkerSize});\n inset-inline-start: calc(50% - (${lineWidth} / 2));\n width: ${lineWidth};\n height: 100%;\n background: ${prior ? interactive : borderColor};\n transition: background calc(2 * ${animationSpeed});\n }\n `}\n `;\n});\n\nStyledBulletWrapper.defaultProps = defaultThemeProp;\n\nexport const StyledStepText = styled.div(({ theme }) => {\n return css`\n padding-block: ${theme.base.spacing};\n overflow-wrap: break-word;\n `;\n});\n\nStyledStepText.defaultProps = defaultThemeProp;\n\nexport const StyledHorizontalStepText = styled.div(({ theme }) => {\n const fontSize = calculateFontSize(theme.base['font-size'], theme.base['font-scale']);\n\n return css`\n padding-block: ${theme.base.spacing};\n overflow-wrap: break-word;\n min-width: inherit;\n font-size: ${fontSize.xxs};\n text-align: inherit;\n `;\n});\n\nStyledHorizontalStepText.defaultProps = defaultThemeProp;\n"]}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { FunctionComponent } from 'react';
|
|
2
2
|
import type { ForwardProps } from '../../types';
|
|
3
|
-
import type MultiStepFormProps from './MultiStepForm.types';
|
|
3
|
+
import type { MultiStepFormProps } from './MultiStepForm.types';
|
|
4
4
|
interface FormProgressProps {
|
|
5
5
|
steps: MultiStepFormProps['steps'];
|
|
6
6
|
currentStepId: MultiStepFormProps['currentStepId'];
|
|
7
|
+
showStepNames?: boolean;
|
|
7
8
|
}
|
|
8
9
|
declare const HorizontalFormProgress: FunctionComponent<FormProgressProps & ForwardProps>;
|
|
9
10
|
export default HorizontalFormProgress;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HorizontalFormProgress.d.ts","sourceRoot":"","sources":["../../../src/components/MultiStepForm/HorizontalFormProgress.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAiB,MAAM,OAAO,CAAC;AAG9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"HorizontalFormProgress.d.ts","sourceRoot":"","sources":["../../../src/components/MultiStepForm/HorizontalFormProgress.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAiB,MAAM,OAAO,CAAC;AAG9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAiBhD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAIhE,UAAU,iBAAiB;IACzB,KAAK,EAAE,kBAAkB,CAAC,OAAO,CAAC,CAAC;IACnC,aAAa,EAAE,kBAAkB,CAAC,eAAe,CAAC,CAAC;IACnD,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,QAAA,MAAM,sBAAsB,EAAE,iBAAiB,CAAC,iBAAiB,GAAG,YAAY,CAwM/E,CAAC;AAEF,eAAe,sBAAsB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { remToPx, stripUnit } from 'polished';
|
|
3
3
|
import { useEffect, useRef, useState } from 'react';
|
|
4
4
|
import { useArrows, useElement, useI18n, useTheme } from '../../hooks';
|
|
@@ -6,9 +6,16 @@ import { tryCatch } from '../../utils';
|
|
|
6
6
|
import Flex from '../Flex';
|
|
7
7
|
import Text from '../Text';
|
|
8
8
|
import Tooltip from '../Tooltip';
|
|
9
|
-
import
|
|
10
|
-
|
|
9
|
+
import Button from '../Button';
|
|
10
|
+
import InfoDialog from '../Dialog/InfoDialog';
|
|
11
|
+
import { CurrentStepPopover, StepMarker, StyledBar, StyledFill, StyledFormProgress, StyledHorizontalStepText, StyleHorizontalStepMarkers } from './FormProgress.styles';
|
|
12
|
+
import VerticalFormProgress from './VerticalFormProgress';
|
|
13
|
+
import { useFormProgressOverflow } from './useFormProgressOverflow';
|
|
14
|
+
const HorizontalFormProgress = ({ steps, currentStepId, showStepNames = false, ...restProps }) => {
|
|
11
15
|
const t = useI18n();
|
|
16
|
+
const [stepsDialogButtonEl, setStepsDialogButtonEl] = useElement();
|
|
17
|
+
const [showStepsDialog, setShowStepsDialog] = useState(false);
|
|
18
|
+
const { ref: formProgressRef, state: stepsAreOverflowing } = useFormProgressOverflow(steps.length, showStepNames);
|
|
12
19
|
const curIdx = steps.findIndex(step => step.id === currentStepId);
|
|
13
20
|
const curStep = steps[curIdx];
|
|
14
21
|
const fillScale = curIdx / (steps.length - 1);
|
|
@@ -16,19 +23,18 @@ const HorizontalFormProgress = ({ steps, currentStepId, ...restProps }) => {
|
|
|
16
23
|
const [stepEls, setStepEls] = useState({});
|
|
17
24
|
const stepsRef = useRef(null);
|
|
18
25
|
const theme = useTheme();
|
|
19
|
-
let popoverPlacement = '
|
|
26
|
+
let popoverPlacement = 'bottom';
|
|
20
27
|
if (curIdx === 0)
|
|
21
|
-
popoverPlacement = '
|
|
28
|
+
popoverPlacement = 'bottom-start';
|
|
22
29
|
else if (curIdx === steps.length - 1)
|
|
23
|
-
popoverPlacement = '
|
|
30
|
+
popoverPlacement = 'bottom-end';
|
|
24
31
|
useArrows(stepsRef, {
|
|
25
|
-
selector: '
|
|
26
|
-
cycle: false,
|
|
32
|
+
selector: '[data-step-marker]',
|
|
27
33
|
dir: 'left-right',
|
|
28
34
|
initialFocusElement: currentStepEl
|
|
29
35
|
});
|
|
30
36
|
useArrows(stepsRef, {
|
|
31
|
-
selector: '
|
|
37
|
+
selector: '[data-step-marker]',
|
|
32
38
|
cycle: false,
|
|
33
39
|
dir: 'up-down',
|
|
34
40
|
initialFocusElement: currentStepEl
|
|
@@ -38,7 +44,13 @@ const HorizontalFormProgress = ({ steps, currentStepId, ...restProps }) => {
|
|
|
38
44
|
setCurrentStepEl(stepEls[curStep.id]);
|
|
39
45
|
}
|
|
40
46
|
}, [Object.keys(stepEls), curStep]);
|
|
41
|
-
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
if (!stepsAreOverflowing) {
|
|
49
|
+
setShowStepsDialog(false);
|
|
50
|
+
}
|
|
51
|
+
}, [stepsAreOverflowing]);
|
|
52
|
+
const numberOfSteps = steps.length;
|
|
53
|
+
return (_jsxs(StyledFormProgress, { ref: formProgressRef, ...restProps, container: { alignItems: 'center' }, showStepNames: showStepNames, children: [_jsx(CurrentStepPopover, { show: !showStepNames, target: currentStepEl, placement: popoverPlacement, strategy: 'absolute', portal: false, hideOnTargetHidden: true, modifiers: [
|
|
42
54
|
{
|
|
43
55
|
name: 'offset',
|
|
44
56
|
options: {
|
|
@@ -62,20 +74,26 @@ const HorizontalFormProgress = ({ steps, currentStepId, ...restProps }) => {
|
|
|
62
74
|
padding: 0
|
|
63
75
|
}
|
|
64
76
|
}
|
|
65
|
-
], children: _jsx(Text, { variant: 'h4', children: curStep.name }) }),
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
], children: _jsx(Text, { variant: 'h4', children: curStep.name }) }), stepsAreOverflowing ? (_jsxs("div", { children: [_jsx(Button, { ref: setStepsDialogButtonEl, variant: 'link', onClick: () => {
|
|
78
|
+
setShowStepsDialog(true);
|
|
79
|
+
}, children: t('step_num', [curIdx + 1, numberOfSteps]) }), _jsx(Text, { variant: 'h4', children: curStep.name }), stepsDialogButtonEl && showStepsDialog && (_jsx(InfoDialog, { heading: t('steps'), target: stepsDialogButtonEl, onDismiss: () => {
|
|
80
|
+
setShowStepsDialog(false);
|
|
81
|
+
}, placement: 'bottom-start', children: _jsx(VerticalFormProgress, { steps: steps, currentStepId: currentStepId }) }))] })) : (_jsxs(_Fragment, { children: [_jsx(Flex, { ref: stepsRef, as: StyleHorizontalStepMarkers, container: { justify: 'between', alignItems: 'start' }, item: { grow: 1 }, showStepNames: showStepNames, children: steps.map((step, index) => {
|
|
82
|
+
const isCurrent = index === curIdx;
|
|
83
|
+
return (_jsxs("li", { children: [_jsx(StepMarker, { ref: (el) => {
|
|
84
|
+
setStepEls(curr => {
|
|
85
|
+
const newEls = { ...curr };
|
|
86
|
+
if (!el && newEls[step.id]) {
|
|
87
|
+
delete newEls[step.id];
|
|
88
|
+
return newEls;
|
|
89
|
+
}
|
|
90
|
+
if (el)
|
|
91
|
+
return { ...newEls, [step.id]: el };
|
|
92
|
+
return newEls;
|
|
93
|
+
});
|
|
94
|
+
}, id: step.id, "data-step-marker": '', "aria-label": `${step.name} - ${t('step_num', [index + 1, steps.length])}`, "aria-current": isCurrent ? 'step' : undefined, tabIndex: isCurrent ? 0 : -1, current: isCurrent, depth: step.depth, completed: step.completed, onClick: step.onMarkerClick, clickable: !!step.onMarkerClick && !isCurrent, children: !showStepNames && !isCurrent && (_jsx(Tooltip, { target: stepEls[step.id], showDelay: 'none', hideDelay: 'short', describeTarget: false, children: step.name })) }), showStepNames &&
|
|
95
|
+
(!!step.onMarkerClick && !isCurrent ? (_jsx(Button, { variant: 'link', onClick: step.onMarkerClick, as: StyledHorizontalStepText, tabIndex: -1, children: step.name })) : (_jsx(Text, { variant: isCurrent ? 'h3' : undefined, as: StyledHorizontalStepText, children: step.name })))] }, step.id));
|
|
96
|
+
}) }), _jsx(StyledBar, { shifted: showStepNames, children: _jsx(StyledFill, { style: { '--fillScale': fillScale } }) })] }))] }));
|
|
79
97
|
};
|
|
80
98
|
export default HorizontalFormProgress;
|
|
81
99
|
//# sourceMappingURL=HorizontalFormProgress.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HorizontalFormProgress.js","sourceRoot":"","sources":["../../../src/components/MultiStepForm/HorizontalFormProgress.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAGpD,OAAO,EAAE,SAAS,EAAE,UAAU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,MAAM,EACzB,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,KAAK,EAAE,KAAK,GAAG,MAAM,EACrB,OAAO,EAAE,IAAI,CAAC,aAAa,YAE1B,KAAK,KAAK,MAAM,IAAI,CACnB,KAAC,OAAO,IACN,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,EACxB,SAAS,EAAC,MAAM,EAChB,SAAS,EAAC,OAAO,EACjB,cAAc,EAAE,KAAK,YAEpB,IAAI,CAAC,IAAI,GACF,CACX,GACU,IAhCN,IAAI,CAAC,EAAE,CAiCX,CACN,CAAC;gBACJ,CAAC,CAAC,GACG,EAEP,KAAC,SAAS,cACR,KAAC,UAAU,IAAC,KAAK,EAAE,EAAE,aAAa,EAAE,SAAS,EAAmB,GAAI,GAC1D,IACO,CACtB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,sBAAsB,CAAC","sourcesContent":["import { remToPx, stripUnit } from 'polished';\nimport { useEffect, useRef, useState } from 'react';\nimport type { FunctionComponent, CSSProperties } from 'react';\n\nimport { useArrows, useElement, useI18n, useTheme } from '../../hooks';\nimport type { ForwardProps } from '../../types';\nimport { tryCatch } from '../../utils';\nimport Flex from '../Flex';\nimport Text from '../Text';\nimport Tooltip from '../Tooltip';\n\nimport {\n CurrentStepPopover,\n StepMarker,\n StyledBar,\n StyledFill,\n StyledFormProgress,\n StyledStepMarkers\n} from './FormProgress.styles';\nimport type MultiStepFormProps from './MultiStepForm.types';\n\ninterface FormProgressProps {\n steps: MultiStepFormProps['steps'];\n currentStepId: MultiStepFormProps['currentStepId'];\n}\n\nconst HorizontalFormProgress: FunctionComponent<FormProgressProps & ForwardProps> = ({\n steps,\n currentStepId,\n ...restProps\n}) => {\n const t = useI18n();\n\n const curIdx = steps.findIndex(step => step.id === currentStepId);\n const curStep = steps[curIdx];\n const fillScale = curIdx / (steps.length - 1);\n\n const [currentStepEl, setCurrentStepEl] = useElement();\n const [stepEls, setStepEls] = useState<Record<string, HTMLElement>>({});\n const stepsRef = useRef(null);\n const theme = useTheme();\n\n let popoverPlacement: 'top' | 'top-start' | 'top-end' = 'top';\n if (curIdx === 0) popoverPlacement = 'top-start';\n else if (curIdx === steps.length - 1) popoverPlacement = 'top-end';\n\n useArrows(stepsRef, {\n selector: 'button',\n cycle: false,\n dir: 'left-right',\n initialFocusElement: currentStepEl\n });\n\n useArrows(stepsRef, {\n selector: 'button',\n cycle: false,\n dir: 'up-down',\n initialFocusElement: currentStepEl\n });\n\n useEffect(() => {\n if (stepEls[curStep.id] && stepEls[curStep.id] !== currentStepEl) {\n setCurrentStepEl(stepEls[curStep.id]);\n }\n }, [Object.keys(stepEls), curStep]);\n\n return (\n <StyledFormProgress {...restProps} container={{ alignItems: 'center' }}>\n <CurrentStepPopover\n show\n target={currentStepEl}\n placement={popoverPlacement}\n strategy='absolute'\n portal={false}\n hideOnTargetHidden\n modifiers={[\n {\n name: 'offset',\n options: {\n offset: [\n 0,\n tryCatch(\n () => stripUnit(remToPx(theme.base.spacing)),\n () => 8\n )\n ]\n }\n },\n {\n name: 'placeAndContain',\n enabled: false\n },\n {\n name: 'flip',\n enabled: false\n },\n {\n name: 'preventOverflow',\n options: {\n padding: 0\n }\n }\n ]}\n >\n <Text variant='h4'>{curStep.name}</Text>\n </CurrentStepPopover>\n <Flex\n ref={stepsRef}\n as={StyledStepMarkers}\n container={{ justify: 'between', alignItems: 'center' }}\n item={{ grow: 1 }}\n >\n {steps.map((step, index) => {\n return (\n <li key={step.id}>\n <StepMarker\n ref={(el: HTMLElement | null) => {\n setStepEls(curr => {\n const newEls = { ...curr };\n if (!el && newEls[step.id]) {\n delete newEls[step.id];\n return newEls;\n }\n if (el) return { ...newEls, [step.id]: el };\n return newEls;\n });\n }}\n id={step.id}\n aria-label={`${step.name} - ${t('step_num', [index + 1, steps.length])}`}\n aria-current={index === curIdx ? 'step' : undefined}\n tabIndex={index === curIdx ? 0 : -1}\n current={index === curIdx}\n depth={step.depth}\n prior={index < curIdx}\n onClick={step.onMarkerClick}\n >\n {index !== curIdx && (\n <Tooltip\n target={stepEls[step.id]}\n showDelay='none'\n hideDelay='short'\n describeTarget={false}\n >\n {step.name}\n </Tooltip>\n )}\n </StepMarker>\n </li>\n );\n })}\n </Flex>\n\n <StyledBar>\n <StyledFill style={{ '--fillScale': fillScale } as CSSProperties} />\n </StyledBar>\n </StyledFormProgress>\n );\n};\n\nexport default HorizontalFormProgress;\n"]}
|
|
1
|
+
{"version":3,"file":"HorizontalFormProgress.js","sourceRoot":"","sources":["../../../src/components/MultiStepForm/HorizontalFormProgress.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAGpD,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,OAAO,UAAU,MAAM,sBAAsB,CAAC;AAE9C,OAAO,EACL,kBAAkB,EAClB,UAAU,EACV,SAAS,EACT,UAAU,EACV,kBAAkB,EAClB,wBAAwB,EACxB,0BAA0B,EAC3B,MAAM,uBAAuB,CAAC;AAE/B,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAQpE,MAAM,sBAAsB,GAAwD,CAAC,EACnF,KAAK,EACL,aAAa,EACb,aAAa,GAAG,KAAK,EACrB,GAAG,SAAS,EACb,EAAE,EAAE;IACH,MAAM,CAAC,GAAG,OAAO,EAAE,CAAC;IAEpB,MAAM,CAA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,aAAa;wCACZ,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CACpC,KAAC,MAAM,IACL,OAAO,EAAC,MAAM,EACd,OAAO,EAAE,IAAI,CAAC,aAAa,EAC3B,EAAE,EAAE,wBAAwB,EAC5B,QAAQ,EAAE,CAAC,CAAC,YAEX,IAAI,CAAC,IAAI,GACH,CACV,CAAC,CAAC,CAAC,CACF,KAAC,IAAI,IAAC,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,EAAE,EAAE,EAAE,wBAAwB,YACtE,IAAI,CAAC,IAAI,GACL,CACR,CAAC,KAjDG,IAAI,CAAC,EAAE,CAkDX,CACN,CAAC;wBACJ,CAAC,CAAC,GACG,EACP,KAAC,SAAS,IAAC,OAAO,EAAE,aAAa,YAC/B,KAAC,UAAU,IAAC,KAAK,EAAE,EAAE,aAAa,EAAE,SAAS,EAAmB,GAAI,GAC1D,IACX,CACJ,IACkB,CACtB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,sBAAsB,CAAC","sourcesContent":["import { remToPx, stripUnit } from 'polished';\nimport { useEffect, useRef, useState } from 'react';\nimport type { FunctionComponent, CSSProperties } from 'react';\n\nimport { useArrows, useElement, useI18n, useTheme } from '../../hooks';\nimport type { ForwardProps } from '../../types';\nimport { tryCatch } from '../../utils';\nimport Flex from '../Flex';\nimport Text from '../Text';\nimport Tooltip from '../Tooltip';\nimport Button from '../Button';\nimport InfoDialog from '../Dialog/InfoDialog';\n\nimport {\n CurrentStepPopover,\n StepMarker,\n StyledBar,\n StyledFill,\n StyledFormProgress,\n StyledHorizontalStepText,\n StyleHorizontalStepMarkers\n} from './FormProgress.styles';\nimport type { MultiStepFormProps } from './MultiStepForm.types';\nimport VerticalFormProgress from './VerticalFormProgress';\nimport { useFormProgressOverflow } from './useFormProgressOverflow';\n\ninterface FormProgressProps {\n steps: MultiStepFormProps['steps'];\n currentStepId: MultiStepFormProps['currentStepId'];\n showStepNames?: boolean;\n}\n\nconst HorizontalFormProgress: FunctionComponent<FormProgressProps & ForwardProps> = ({\n steps,\n currentStepId,\n showStepNames = false,\n ...restProps\n}) => {\n const t = useI18n();\n\n const [stepsDialogButtonEl, setStepsDialogButtonEl] = useElement<HTMLButtonElement>();\n const [showStepsDialog, setShowStepsDialog] = useState(false);\n\n const { ref: formProgressRef, state: stepsAreOverflowing } = useFormProgressOverflow(\n steps.length,\n showStepNames\n );\n\n const curIdx = steps.findIndex(step => step.id === currentStepId);\n const curStep = steps[curIdx];\n const fillScale = curIdx / (steps.length - 1);\n\n const [currentStepEl, setCurrentStepEl] = useElement();\n const [stepEls, setStepEls] = useState<Record<string, HTMLElement>>({});\n const stepsRef = useRef(null);\n const theme = useTheme();\n\n let popoverPlacement: 'bottom' | 'bottom-start' | 'bottom-end' = 'bottom';\n if (curIdx === 0) popoverPlacement = 'bottom-start';\n else if (curIdx === steps.length - 1) popoverPlacement = 'bottom-end';\n\n useArrows(stepsRef, {\n selector: '[data-step-marker]',\n dir: 'left-right',\n initialFocusElement: currentStepEl\n });\n\n useArrows(stepsRef, {\n selector: '[data-step-marker]',\n cycle: false,\n dir: 'up-down',\n initialFocusElement: currentStepEl\n });\n\n useEffect(() => {\n if (stepEls[curStep.id] && stepEls[curStep.id] !== currentStepEl) {\n setCurrentStepEl(stepEls[curStep.id]);\n }\n }, [Object.keys(stepEls), curStep]);\n\n useEffect(() => {\n if (!stepsAreOverflowing) {\n setShowStepsDialog(false);\n }\n }, [stepsAreOverflowing]);\n\n const numberOfSteps = steps.length;\n\n return (\n <StyledFormProgress\n ref={formProgressRef}\n {...restProps}\n container={{ alignItems: 'center' }}\n showStepNames={showStepNames}\n >\n <CurrentStepPopover\n show={!showStepNames}\n target={currentStepEl}\n placement={popoverPlacement}\n strategy='absolute'\n portal={false}\n hideOnTargetHidden\n modifiers={[\n {\n name: 'offset',\n options: {\n offset: [\n 0,\n tryCatch(\n () => stripUnit(remToPx(theme.base.spacing)),\n () => 8\n )\n ]\n }\n },\n {\n name: 'placeAndContain',\n enabled: false\n },\n {\n name: 'flip',\n enabled: false\n },\n {\n name: 'preventOverflow',\n options: {\n padding: 0\n }\n }\n ]}\n >\n <Text variant='h4'>{curStep.name}</Text>\n </CurrentStepPopover>\n\n {stepsAreOverflowing ? (\n <div>\n <Button\n ref={setStepsDialogButtonEl}\n variant='link'\n onClick={() => {\n setShowStepsDialog(true);\n }}\n >\n {t('step_num', [curIdx + 1, numberOfSteps])}\n </Button>\n <Text variant='h4'>{curStep.name}</Text>\n {stepsDialogButtonEl && showStepsDialog && (\n <InfoDialog\n heading={t('steps')}\n target={stepsDialogButtonEl}\n onDismiss={() => {\n setShowStepsDialog(false);\n }}\n placement='bottom-start'\n >\n <VerticalFormProgress steps={steps} currentStepId={currentStepId} />\n </InfoDialog>\n )}\n </div>\n ) : (\n <>\n <Flex\n ref={stepsRef}\n as={StyleHorizontalStepMarkers}\n container={{ justify: 'between', alignItems: 'start' }}\n item={{ grow: 1 }}\n showStepNames={showStepNames}\n >\n {steps.map((step, index) => {\n const isCurrent = index === curIdx;\n return (\n <li key={step.id}>\n <StepMarker\n ref={(el: HTMLElement | null) => {\n setStepEls(curr => {\n const newEls = { ...curr };\n if (!el && newEls[step.id]) {\n delete newEls[step.id];\n return newEls;\n }\n if (el) return { ...newEls, [step.id]: el };\n return newEls;\n });\n }}\n id={step.id}\n data-step-marker=''\n aria-label={`${step.name} - ${t('step_num', [index + 1, steps.length])}`}\n aria-current={isCurrent ? 'step' : undefined}\n tabIndex={isCurrent ? 0 : -1}\n current={isCurrent}\n depth={step.depth}\n completed={step.completed}\n onClick={step.onMarkerClick}\n clickable={!!step.onMarkerClick && !isCurrent}\n >\n {!showStepNames && !isCurrent && (\n <Tooltip\n target={stepEls[step.id]}\n showDelay='none'\n hideDelay='short'\n describeTarget={false}\n >\n {step.name}\n </Tooltip>\n )}\n </StepMarker>\n {showStepNames &&\n (!!step.onMarkerClick && !isCurrent ? (\n <Button\n variant='link'\n onClick={step.onMarkerClick}\n as={StyledHorizontalStepText}\n tabIndex={-1}\n >\n {step.name}\n </Button>\n ) : (\n <Text variant={isCurrent ? 'h3' : undefined} as={StyledHorizontalStepText}>\n {step.name}\n </Text>\n ))}\n </li>\n );\n })}\n </Flex>\n <StyledBar shifted={showStepNames}>\n <StyledFill style={{ '--fillScale': fillScale } as CSSProperties} />\n </StyledBar>\n </>\n )}\n </StyledFormProgress>\n );\n};\n\nexport default HorizontalFormProgress;\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ForwardRefForwardPropsComponent } from '../../types';
|
|
2
|
-
import type MultiStepFormProps from './MultiStepForm.types';
|
|
2
|
+
import type { MultiStepFormProps } from './MultiStepForm.types';
|
|
3
3
|
export declare const StyledForm: import("styled-components").StyledComponent<"form", import("styled-components").DefaultTheme, {
|
|
4
4
|
actions?: boolean;
|
|
5
5
|
heading?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MultiStepForm.d.ts","sourceRoot":"","sources":["../../../src/components/MultiStepForm/MultiStepForm.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,aAAa,CAAC;AAWnE,OAAO,KAAK,kBAAkB,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"MultiStepForm.d.ts","sourceRoot":"","sources":["../../../src/components/MultiStepForm/MultiStepForm.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,aAAa,CAAC;AAWnE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAIhE,eAAO,MAAM,UAAU;cAA2B,OAAO;cAAY,OAAO;SAuB3E,CAAC;AAIF,eAAO,MAAM,iBAAiB,yGAAe,CAAC;AAE9C,eAAO,MAAM,qBAAqB,gKAIjC,CAAC;AAEF,eAAO,MAAM,yBAAyB,gKAqBpC,CAAC;AAIH,QAAA,MAAM,aAAa,EAAE,+BAA+B,CAAC,kBAAkB,CAsNtE,CAAC;AAEF,eAAe,aAAa,CAAC"}
|