@semcore/wizard 16.2.2 → 16.2.3-prerelease.8
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 +6 -0
- package/README.md +4 -4
- package/lib/cjs/Wizard.js +278 -295
- package/lib/cjs/Wizard.js.map +1 -1
- package/lib/cjs/Wizard.types.js.map +1 -1
- package/lib/cjs/index.js +4 -4
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/translations/__intergalactic-dynamic-locales.js +16 -16
- package/lib/cjs/translations/__intergalactic-dynamic-locales.js.map +1 -1
- package/lib/es6/Wizard.js +267 -285
- package/lib/es6/Wizard.js.map +1 -1
- package/lib/es6/Wizard.types.js.map +1 -1
- package/lib/es6/translations/__intergalactic-dynamic-locales.js +15 -15
- package/lib/es6/translations/__intergalactic-dynamic-locales.js.map +1 -1
- package/lib/esm/Wizard.mjs +266 -253
- package/lib/esm/translations/__intergalactic-dynamic-locales.mjs +1 -1
- package/lib/types/Wizard.types.d.ts +16 -27
- package/package.json +7 -6
- package/src/Wizard.tsx +5 -7
- package/src/Wizard.types.ts +19 -27
|
@@ -1,13 +1,11 @@
|
|
|
1
|
+
import type { BoxProps } from '@semcore/base-components';
|
|
1
2
|
import type { ButtonProps } from '@semcore/button';
|
|
2
|
-
import type {
|
|
3
|
+
import type { Intergalactic } from '@semcore/core';
|
|
3
4
|
import type { useI18n } from '@semcore/core/lib/utils/enhances/WithI18n';
|
|
4
|
-
import type { BoxProps } from '@semcore/flex-box';
|
|
5
5
|
import type { ModalProps } from '@semcore/modal';
|
|
6
6
|
import type React from 'react';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export interface IWizardProps extends WizardProps, UnknownProperties {
|
|
10
|
-
}
|
|
7
|
+
/** Ordered step position from 0 */
|
|
8
|
+
export type WizardStep = number;
|
|
11
9
|
export type WizardProps = ModalProps & {
|
|
12
10
|
/**
|
|
13
11
|
* Active step value
|
|
@@ -16,9 +14,6 @@ export type WizardProps = ModalProps & {
|
|
|
16
14
|
/** Specifies the locale for i18n support */
|
|
17
15
|
locale?: string;
|
|
18
16
|
};
|
|
19
|
-
/** @deprecated */
|
|
20
|
-
export interface IWizardSidebarProps extends WizardSidebarProps, UnknownProperties {
|
|
21
|
-
}
|
|
22
17
|
export type WizardSidebarProps = BoxProps & {
|
|
23
18
|
/**
|
|
24
19
|
* Sidebar title
|
|
@@ -29,12 +24,9 @@ export type WizardSidebarProps = BoxProps & {
|
|
|
29
24
|
*/
|
|
30
25
|
id?: string;
|
|
31
26
|
};
|
|
32
|
-
/** @deprecated */
|
|
33
|
-
export interface IWizardStepProps extends WizardStepProps, UnknownProperties {
|
|
34
|
-
}
|
|
35
27
|
export type WizardStepProps = BoxProps & {
|
|
36
28
|
/**
|
|
37
|
-
*
|
|
29
|
+
* Ordered step position from 0
|
|
38
30
|
*/
|
|
39
31
|
step: WizardStep;
|
|
40
32
|
/**
|
|
@@ -47,18 +39,15 @@ export type WizardStepProps = BoxProps & {
|
|
|
47
39
|
*/
|
|
48
40
|
active?: boolean;
|
|
49
41
|
};
|
|
50
|
-
|
|
51
|
-
export interface IWizardStepperProps extends WizardStepperProps, UnknownProperties {
|
|
52
|
-
}
|
|
53
|
-
export type WizardStepperProps<T extends WizardStep = WizardStep> = BoxProps & {
|
|
42
|
+
export type WizardStepperProps = BoxProps & {
|
|
54
43
|
/**
|
|
55
|
-
*
|
|
44
|
+
* Ordered step position from 0
|
|
56
45
|
*/
|
|
57
|
-
step:
|
|
46
|
+
step: WizardStep;
|
|
58
47
|
/**
|
|
59
48
|
* Is invoked when active the step
|
|
60
49
|
*/
|
|
61
|
-
onActive?: ((step:
|
|
50
|
+
onActive?: ((step: WizardStep, e: React.SyntheticEvent<HTMLElement> | React.KeyboardEvent) => void) | React.Dispatch<React.SetStateAction<WizardStep>>;
|
|
62
51
|
/**
|
|
63
52
|
* Stepper number
|
|
64
53
|
* @default incremental value
|
|
@@ -92,39 +81,39 @@ export type WizardContentProps = BoxProps & {
|
|
|
92
81
|
*/
|
|
93
82
|
noSidebar?: boolean;
|
|
94
83
|
};
|
|
95
|
-
export type WizardStepBackProps
|
|
84
|
+
export type WizardStepBackProps = ButtonProps & {
|
|
96
85
|
/** Callback invoked when navigating to the previous step */
|
|
97
|
-
onActive?: ((step:
|
|
86
|
+
onActive?: ((step: WizardStep, e?: React.SyntheticEvent<HTMLElement>) => void) | React.Dispatch<React.SetStateAction<WizardStep>>;
|
|
98
87
|
/** Step name being navigated to */
|
|
99
88
|
stepName?: string;
|
|
100
89
|
/**
|
|
101
90
|
* CurrentStep
|
|
102
91
|
* @internal
|
|
103
92
|
*/
|
|
104
|
-
step?:
|
|
93
|
+
step?: WizardStep;
|
|
105
94
|
/**
|
|
106
95
|
* Translation function
|
|
107
96
|
* @internal
|
|
108
97
|
*/
|
|
109
98
|
getI18nText?: ReturnType<typeof useI18n>;
|
|
110
99
|
};
|
|
111
|
-
export type WizardStepNextProps
|
|
100
|
+
export type WizardStepNextProps = ButtonProps & {
|
|
112
101
|
/** Callback invoked when navigating to the next step */
|
|
113
|
-
onActive?: ((step:
|
|
102
|
+
onActive?: ((step: WizardStep, e?: React.SyntheticEvent<HTMLElement>) => void) | React.Dispatch<React.SetStateAction<WizardStep>>;
|
|
114
103
|
/** Step name being navigated to */
|
|
115
104
|
stepName?: string;
|
|
116
105
|
/**
|
|
117
106
|
* CurrentStep
|
|
118
107
|
* @internal
|
|
119
108
|
*/
|
|
120
|
-
step?:
|
|
109
|
+
step?: WizardStep;
|
|
121
110
|
/**
|
|
122
111
|
* Translation function
|
|
123
112
|
* @internal
|
|
124
113
|
*/
|
|
125
114
|
getI18nText?: ReturnType<typeof useI18n>;
|
|
126
115
|
};
|
|
127
|
-
export type IntergalacticWizardStepperComponent<PropsExtending = {}> = (<
|
|
116
|
+
export type IntergalacticWizardStepperComponent<PropsExtending = {}> = (<Tag extends Intergalactic.Tag = 'div'>(props: Intergalactic.InternalTypings.ComponentProps<Tag, 'div', WizardStepperProps> & PropsExtending) => Intergalactic.InternalTypings.ComponentRenderingResults) & Intergalactic.InternalTypings.ComponentAdditive<'div', 'div', WizardStepperProps>;
|
|
128
117
|
export type WizardType = Intergalactic.Component<'div', WizardProps> & {
|
|
129
118
|
Sidebar: Intergalactic.Component<'div', WizardSidebarProps>;
|
|
130
119
|
Step: Intergalactic.Component<'div', WizardStepProps>;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@semcore/wizard",
|
|
3
3
|
"description": "Semrush Wizard Component",
|
|
4
|
-
"version": "16.2.
|
|
4
|
+
"version": "16.2.3-prerelease.8",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/es6/index.js",
|
|
7
7
|
"typings": "lib/types/index.d.ts",
|
|
@@ -14,13 +14,12 @@
|
|
|
14
14
|
"types": "./lib/types/index.d.ts"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@semcore/button": "16.0.
|
|
18
|
-
"@semcore/flex-box": "16.0.11",
|
|
19
|
-
"@semcore/icon": "16.7.3",
|
|
17
|
+
"@semcore/button": "16.0.13-prerelease.8",
|
|
20
18
|
"@semcore/modal": "16.1.12"
|
|
21
19
|
},
|
|
22
20
|
"peerDependencies": {
|
|
23
|
-
"@semcore/base-components": "^16.
|
|
21
|
+
"@semcore/base-components": "^16.4.3-prerelease.8",
|
|
22
|
+
"@semcore/icon": "^16.7.2-prerelease.8"
|
|
24
23
|
},
|
|
25
24
|
"repository": {
|
|
26
25
|
"type": "git",
|
|
@@ -28,8 +27,10 @@
|
|
|
28
27
|
"directory": "semcore/wizard"
|
|
29
28
|
},
|
|
30
29
|
"devDependencies": {
|
|
30
|
+
"@semcore/base-components": "16.4.3-prerelease.8",
|
|
31
|
+
"@semcore/testing-utils": "1.0.0",
|
|
31
32
|
"@semcore/core": "16.5.1",
|
|
32
|
-
"@semcore/
|
|
33
|
+
"@semcore/icon": "16.7.2-prerelease.8"
|
|
33
34
|
},
|
|
34
35
|
"scripts": {
|
|
35
36
|
"build": "pnpm semcore-builder && pnpm vite build"
|
package/src/Wizard.tsx
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
+
import { ScreenReaderOnly, Box } from '@semcore/base-components';
|
|
1
2
|
import Button from '@semcore/button';
|
|
2
3
|
import { createComponent, Component, Root, sstyled } from '@semcore/core';
|
|
3
4
|
import type { IRootComponentProps, Intergalactic } from '@semcore/core';
|
|
4
5
|
import i18nEnhance from '@semcore/core/lib/utils/enhances/i18nEnhance';
|
|
5
|
-
import keyboardFocusEnhance from '@semcore/core/lib/utils/enhances/keyboardFocusEnhance';
|
|
6
6
|
import findComponent from '@semcore/core/lib/utils/findComponent';
|
|
7
7
|
import uniqueIDEnhancement from '@semcore/core/lib/utils/uniqueID';
|
|
8
8
|
import { setFocus } from '@semcore/core/lib/utils/use/useFocusLock';
|
|
9
|
-
import { ScreenReaderOnly, Box } from '@semcore/flex-box';
|
|
10
9
|
import ArrowLeft from '@semcore/icon/ArrowLeft/m';
|
|
11
10
|
import ArrowRight from '@semcore/icon/ArrowRight/m';
|
|
12
11
|
import CheckM from '@semcore/icon/Check/m';
|
|
@@ -32,7 +31,7 @@ type State = {
|
|
|
32
31
|
highlighted: number;
|
|
33
32
|
};
|
|
34
33
|
|
|
35
|
-
class WizardRoot extends Component<WizardProps, {},
|
|
34
|
+
class WizardRoot extends Component<WizardProps, typeof WizardRoot.enhance, {}, {}, State> {
|
|
36
35
|
static displayName = 'Wizard';
|
|
37
36
|
static style = style;
|
|
38
37
|
static enhance = [i18nEnhance(localizedMessages), uniqueIDEnhancement()] as const;
|
|
@@ -49,7 +48,6 @@ class WizardRoot extends Component<WizardProps, {}, State, typeof WizardRoot.enh
|
|
|
49
48
|
stepperRefs: Array<HTMLElement | null> = [];
|
|
50
49
|
|
|
51
50
|
state: State = {
|
|
52
|
-
// @ts-ignore
|
|
53
51
|
highlighted: this.props.step,
|
|
54
52
|
};
|
|
55
53
|
|
|
@@ -172,7 +170,7 @@ class WizardRoot extends Component<WizardProps, {}, State, typeof WizardRoot.enh
|
|
|
172
170
|
|
|
173
171
|
componentDidUpdate(prevProps: WizardProps) {
|
|
174
172
|
if (prevProps.step === this.asProps.step) return;
|
|
175
|
-
|
|
173
|
+
|
|
176
174
|
this.setState({ highlighted: this.asProps.step });
|
|
177
175
|
setTimeout(() => {
|
|
178
176
|
if (prevProps.step === this.asProps.step) return;
|
|
@@ -241,6 +239,7 @@ function Stepper(props: Required<WizardStepperProps> & IRootComponentProps) {
|
|
|
241
239
|
getI18nText,
|
|
242
240
|
focusNext,
|
|
243
241
|
focusPrev,
|
|
242
|
+
disabled,
|
|
244
243
|
} = props;
|
|
245
244
|
const SStepper = Root;
|
|
246
245
|
const SStepNumber = 'span';
|
|
@@ -276,6 +275,7 @@ function Stepper(props: Required<WizardStepperProps> & IRootComponentProps) {
|
|
|
276
275
|
<SStepper
|
|
277
276
|
render={Box}
|
|
278
277
|
role='tab'
|
|
278
|
+
tabIndex={disabled ? undefined : 0}
|
|
279
279
|
onClick={handlerClick}
|
|
280
280
|
onKeyDown={handlerKeyDown}
|
|
281
281
|
>
|
|
@@ -288,8 +288,6 @@ function Stepper(props: Required<WizardStepperProps> & IRootComponentProps) {
|
|
|
288
288
|
);
|
|
289
289
|
}
|
|
290
290
|
|
|
291
|
-
Stepper.enhance = [keyboardFocusEnhance()];
|
|
292
|
-
|
|
293
291
|
function Content(props: WizardContentProps & IRootComponentProps) {
|
|
294
292
|
const { Children, styles } = props;
|
|
295
293
|
const SContent = Root;
|
package/src/Wizard.types.ts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
+
import type { BoxProps } from '@semcore/base-components';
|
|
1
2
|
import type { ButtonProps } from '@semcore/button';
|
|
2
|
-
import type {
|
|
3
|
+
import type { Intergalactic } from '@semcore/core';
|
|
3
4
|
import type { useI18n } from '@semcore/core/lib/utils/enhances/WithI18n';
|
|
4
|
-
import type { BoxProps } from '@semcore/flex-box';
|
|
5
5
|
import type { ModalProps } from '@semcore/modal';
|
|
6
6
|
import type React from 'react';
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
/** Ordered step position from 0 */
|
|
9
|
+
export type WizardStep = number;
|
|
9
10
|
|
|
10
|
-
/** @deprecated */
|
|
11
|
-
export interface IWizardProps extends WizardProps, UnknownProperties {}
|
|
12
11
|
export type WizardProps = ModalProps & {
|
|
13
12
|
/**
|
|
14
13
|
* Active step value
|
|
@@ -18,8 +17,6 @@ export type WizardProps = ModalProps & {
|
|
|
18
17
|
locale?: string;
|
|
19
18
|
};
|
|
20
19
|
|
|
21
|
-
/** @deprecated */
|
|
22
|
-
export interface IWizardSidebarProps extends WizardSidebarProps, UnknownProperties {}
|
|
23
20
|
export type WizardSidebarProps = BoxProps & {
|
|
24
21
|
/**
|
|
25
22
|
* Sidebar title
|
|
@@ -32,11 +29,9 @@ export type WizardSidebarProps = BoxProps & {
|
|
|
32
29
|
id?: string;
|
|
33
30
|
};
|
|
34
31
|
|
|
35
|
-
/** @deprecated */
|
|
36
|
-
export interface IWizardStepProps extends WizardStepProps, UnknownProperties {}
|
|
37
32
|
export type WizardStepProps = BoxProps & {
|
|
38
33
|
/**
|
|
39
|
-
*
|
|
34
|
+
* Ordered step position from 0
|
|
40
35
|
*/
|
|
41
36
|
step: WizardStep;
|
|
42
37
|
/**
|
|
@@ -50,19 +45,17 @@ export type WizardStepProps = BoxProps & {
|
|
|
50
45
|
active?: boolean;
|
|
51
46
|
};
|
|
52
47
|
|
|
53
|
-
|
|
54
|
-
export interface IWizardStepperProps extends WizardStepperProps, UnknownProperties {}
|
|
55
|
-
export type WizardStepperProps<T extends WizardStep = WizardStep> = BoxProps & {
|
|
48
|
+
export type WizardStepperProps = BoxProps & {
|
|
56
49
|
/**
|
|
57
|
-
*
|
|
50
|
+
* Ordered step position from 0
|
|
58
51
|
*/
|
|
59
|
-
step:
|
|
52
|
+
step: WizardStep;
|
|
60
53
|
/**
|
|
61
54
|
* Is invoked when active the step
|
|
62
55
|
*/
|
|
63
56
|
onActive?:
|
|
64
|
-
| ((step:
|
|
65
|
-
| React.Dispatch<React.SetStateAction<
|
|
57
|
+
| ((step: WizardStep, e: React.SyntheticEvent<HTMLElement> | React.KeyboardEvent) => void)
|
|
58
|
+
| React.Dispatch<React.SetStateAction<WizardStep>>;
|
|
66
59
|
/**
|
|
67
60
|
* Stepper number
|
|
68
61
|
* @default incremental value
|
|
@@ -100,11 +93,11 @@ export type WizardContentProps = BoxProps & {
|
|
|
100
93
|
noSidebar?: boolean;
|
|
101
94
|
};
|
|
102
95
|
|
|
103
|
-
export type WizardStepBackProps
|
|
96
|
+
export type WizardStepBackProps = ButtonProps & {
|
|
104
97
|
/** Callback invoked when navigating to the previous step */
|
|
105
98
|
onActive?:
|
|
106
|
-
| ((step:
|
|
107
|
-
| React.Dispatch<React.SetStateAction<
|
|
99
|
+
| ((step: WizardStep, e?: React.SyntheticEvent<HTMLElement>) => void)
|
|
100
|
+
| React.Dispatch<React.SetStateAction<WizardStep>>;
|
|
108
101
|
/** Step name being navigated to */
|
|
109
102
|
stepName?: string;
|
|
110
103
|
|
|
@@ -112,18 +105,18 @@ export type WizardStepBackProps<T extends WizardStep = WizardStep> = ButtonProps
|
|
|
112
105
|
* CurrentStep
|
|
113
106
|
* @internal
|
|
114
107
|
*/
|
|
115
|
-
step?:
|
|
108
|
+
step?: WizardStep;
|
|
116
109
|
/**
|
|
117
110
|
* Translation function
|
|
118
111
|
* @internal
|
|
119
112
|
*/
|
|
120
113
|
getI18nText?: ReturnType<typeof useI18n>;
|
|
121
114
|
};
|
|
122
|
-
export type WizardStepNextProps
|
|
115
|
+
export type WizardStepNextProps = ButtonProps & {
|
|
123
116
|
/** Callback invoked when navigating to the next step */
|
|
124
117
|
onActive?:
|
|
125
|
-
| ((step:
|
|
126
|
-
| React.Dispatch<React.SetStateAction<
|
|
118
|
+
| ((step: WizardStep, e?: React.SyntheticEvent<HTMLElement>) => void)
|
|
119
|
+
| React.Dispatch<React.SetStateAction<WizardStep>>;
|
|
127
120
|
/** Step name being navigated to */
|
|
128
121
|
stepName?: string;
|
|
129
122
|
|
|
@@ -131,7 +124,7 @@ export type WizardStepNextProps<T extends WizardStep = WizardStep> = ButtonProps
|
|
|
131
124
|
* CurrentStep
|
|
132
125
|
* @internal
|
|
133
126
|
*/
|
|
134
|
-
step?:
|
|
127
|
+
step?: WizardStep;
|
|
135
128
|
/**
|
|
136
129
|
* Translation function
|
|
137
130
|
* @internal
|
|
@@ -140,10 +133,9 @@ export type WizardStepNextProps<T extends WizardStep = WizardStep> = ButtonProps
|
|
|
140
133
|
};
|
|
141
134
|
|
|
142
135
|
export type IntergalacticWizardStepperComponent<PropsExtending = {}> = (<
|
|
143
|
-
Value extends WizardStep,
|
|
144
136
|
Tag extends Intergalactic.Tag = 'div',
|
|
145
137
|
>(
|
|
146
|
-
props: Intergalactic.InternalTypings.ComponentProps<Tag, 'div', WizardStepperProps
|
|
138
|
+
props: Intergalactic.InternalTypings.ComponentProps<Tag, 'div', WizardStepperProps> &
|
|
147
139
|
PropsExtending,
|
|
148
140
|
) => Intergalactic.InternalTypings.ComponentRenderingResults) &
|
|
149
141
|
Intergalactic.InternalTypings.ComponentAdditive<'div', 'div', WizardStepperProps>;
|